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)
154 struct rte_crypto_sym_op *sop;
155 union rte_crypto_sym_ofs ofs;
156 struct rte_crypto_sgl sgl;
157 struct rte_crypto_sym_vec symvec;
158 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
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;
175 symvec.digest = &digest_ptr;
176 symvec.aad = &aad_ptr;
180 /* for CPU crypto the IOVA address is not required */
181 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
182 digest_ptr.va = (void *)sop->aead.digest.data;
183 aad_ptr.va = (void *)sop->aead.aad.data;
187 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
191 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
193 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
197 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
200 struct rte_crypto_sym_op *sop;
201 union rte_crypto_sym_ofs ofs;
202 struct rte_crypto_sgl sgl;
203 struct rte_crypto_sym_vec symvec;
204 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
205 struct rte_crypto_vec vec[UINT8_MAX];
209 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
210 sop->auth.data.length, vec, RTE_DIM(vec));
212 if (n < 0 || n != sop->m_src->nb_segs) {
213 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
221 symvec.digest = &digest_ptr;
225 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
226 digest_ptr.va = (void *)sop->auth.digest.data;
229 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
230 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
231 (sop->cipher.data.offset + sop->cipher.data.length);
233 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
237 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
239 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
242 static struct rte_crypto_op *
243 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
246 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
248 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
249 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
255 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
258 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
259 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
266 static struct crypto_testsuite_params testsuite_params = { NULL };
267 static struct crypto_unittest_params unittest_params;
270 testsuite_setup(void)
272 struct crypto_testsuite_params *ts_params = &testsuite_params;
273 struct rte_cryptodev_info info;
274 uint32_t i = 0, nb_devs, dev_id;
278 memset(ts_params, 0, sizeof(*ts_params));
280 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
281 if (ts_params->mbuf_pool == NULL) {
282 /* Not already created so create */
283 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
285 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
287 if (ts_params->mbuf_pool == NULL) {
288 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
293 ts_params->large_mbuf_pool = rte_mempool_lookup(
294 "CRYPTO_LARGE_MBUFPOOL");
295 if (ts_params->large_mbuf_pool == NULL) {
296 /* Not already created so create */
297 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
298 "CRYPTO_LARGE_MBUFPOOL",
301 if (ts_params->large_mbuf_pool == NULL) {
303 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
308 ts_params->op_mpool = rte_crypto_op_pool_create(
309 "MBUF_CRYPTO_SYM_OP_POOL",
310 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
311 NUM_MBUFS, MBUF_CACHE_SIZE,
313 sizeof(struct rte_crypto_sym_xform) +
316 if (ts_params->op_mpool == NULL) {
317 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
321 /* Create an AESNI MB device if required */
322 if (gbl_driver_id == rte_cryptodev_driver_id_get(
323 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
324 nb_devs = rte_cryptodev_device_count_by_driver(
325 rte_cryptodev_driver_id_get(
326 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
329 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
331 TEST_ASSERT(ret == 0,
332 "Failed to create instance of"
334 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
338 /* Create an AESNI GCM device if required */
339 if (gbl_driver_id == rte_cryptodev_driver_id_get(
340 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
341 nb_devs = rte_cryptodev_device_count_by_driver(
342 rte_cryptodev_driver_id_get(
343 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
345 TEST_ASSERT_SUCCESS(rte_vdev_init(
346 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
347 "Failed to create instance of"
349 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
353 /* Create a SNOW 3G device if required */
354 if (gbl_driver_id == rte_cryptodev_driver_id_get(
355 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
356 nb_devs = rte_cryptodev_device_count_by_driver(
357 rte_cryptodev_driver_id_get(
358 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
360 TEST_ASSERT_SUCCESS(rte_vdev_init(
361 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
362 "Failed to create instance of"
364 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
368 /* Create a KASUMI device if required */
369 if (gbl_driver_id == rte_cryptodev_driver_id_get(
370 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
371 nb_devs = rte_cryptodev_device_count_by_driver(
372 rte_cryptodev_driver_id_get(
373 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
375 TEST_ASSERT_SUCCESS(rte_vdev_init(
376 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
377 "Failed to create instance of"
379 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
383 /* Create a ZUC device if required */
384 if (gbl_driver_id == rte_cryptodev_driver_id_get(
385 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
386 nb_devs = rte_cryptodev_device_count_by_driver(
387 rte_cryptodev_driver_id_get(
388 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
390 TEST_ASSERT_SUCCESS(rte_vdev_init(
391 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
392 "Failed to create instance of"
394 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
398 /* Create a NULL device if required */
399 if (gbl_driver_id == rte_cryptodev_driver_id_get(
400 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
401 nb_devs = rte_cryptodev_device_count_by_driver(
402 rte_cryptodev_driver_id_get(
403 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
406 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
408 TEST_ASSERT(ret == 0,
409 "Failed to create instance of"
411 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
415 /* Create an OPENSSL device if required */
416 if (gbl_driver_id == rte_cryptodev_driver_id_get(
417 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
418 nb_devs = rte_cryptodev_device_count_by_driver(
419 rte_cryptodev_driver_id_get(
420 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
423 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
426 TEST_ASSERT(ret == 0, "Failed to create "
427 "instance of pmd : %s",
428 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
432 /* Create a ARMv8 device if required */
433 if (gbl_driver_id == rte_cryptodev_driver_id_get(
434 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
435 nb_devs = rte_cryptodev_device_count_by_driver(
436 rte_cryptodev_driver_id_get(
437 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
440 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
443 TEST_ASSERT(ret == 0, "Failed to create "
444 "instance of pmd : %s",
445 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
449 /* Create a MVSAM device if required */
450 if (gbl_driver_id == rte_cryptodev_driver_id_get(
451 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
452 nb_devs = rte_cryptodev_device_count_by_driver(
453 rte_cryptodev_driver_id_get(
454 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
457 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
460 TEST_ASSERT(ret == 0, "Failed to create "
461 "instance of pmd : %s",
462 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
466 /* Create an CCP device if required */
467 if (gbl_driver_id == rte_cryptodev_driver_id_get(
468 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
469 nb_devs = rte_cryptodev_device_count_by_driver(
470 rte_cryptodev_driver_id_get(
471 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
474 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
477 TEST_ASSERT(ret == 0, "Failed to create "
478 "instance of pmd : %s",
479 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
483 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
484 char vdev_args[VDEV_ARGS_SIZE] = {""};
485 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
486 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
487 uint16_t worker_core_count = 0;
488 uint16_t socket_id = 0;
490 if (gbl_driver_id == rte_cryptodev_driver_id_get(
491 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
493 /* Identify the Worker Cores
494 * Use 2 worker cores for the device args
496 RTE_LCORE_FOREACH_SLAVE(i) {
497 if (worker_core_count > 1)
499 snprintf(vdev_args, sizeof(vdev_args),
500 "%s%d", temp_str, i);
501 strcpy(temp_str, vdev_args);
502 strlcat(temp_str, ";", sizeof(temp_str));
504 socket_id = rte_lcore_to_socket_id(i);
506 if (worker_core_count != 2) {
508 "Cryptodev scheduler test require at least "
509 "two worker cores to run. "
510 "Please use the correct coremask.\n");
513 strcpy(temp_str, vdev_args);
514 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
515 temp_str, socket_id);
516 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
517 nb_devs = rte_cryptodev_device_count_by_driver(
518 rte_cryptodev_driver_id_get(
519 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
522 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
524 TEST_ASSERT(ret == 0,
525 "Failed to create instance %u of"
527 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
530 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
532 nb_devs = rte_cryptodev_count();
534 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
538 /* Create list of valid crypto devs */
539 for (i = 0; i < nb_devs; i++) {
540 rte_cryptodev_info_get(i, &info);
541 if (info.driver_id == gbl_driver_id)
542 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
545 if (ts_params->valid_dev_count < 1)
548 /* Set up all the qps on the first of the valid devices found */
550 dev_id = ts_params->valid_devs[0];
552 rte_cryptodev_info_get(dev_id, &info);
554 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
555 ts_params->conf.socket_id = SOCKET_ID_ANY;
556 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
558 unsigned int session_size =
559 rte_cryptodev_sym_get_private_session_size(dev_id);
562 * Create mempool with maximum number of sessions * 2,
563 * to include the session headers
565 if (info.sym.max_nb_sessions != 0 &&
566 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
567 RTE_LOG(ERR, USER1, "Device does not support "
568 "at least %u sessions\n",
573 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
574 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
576 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
577 "session mempool allocation failed");
579 ts_params->session_priv_mpool = rte_mempool_create(
583 0, 0, NULL, NULL, NULL,
586 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
587 "session mempool allocation failed");
591 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
593 "Failed to configure cryptodev %u with %u qps",
594 dev_id, ts_params->conf.nb_queue_pairs);
596 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
597 ts_params->qp_conf.mp_session = ts_params->session_mpool;
598 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
600 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
601 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
602 dev_id, qp_id, &ts_params->qp_conf,
603 rte_cryptodev_socket_id(dev_id)),
604 "Failed to setup queue pair %u on cryptodev %u",
612 testsuite_teardown(void)
614 struct crypto_testsuite_params *ts_params = &testsuite_params;
616 if (ts_params->mbuf_pool != NULL) {
617 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
618 rte_mempool_avail_count(ts_params->mbuf_pool));
621 if (ts_params->op_mpool != NULL) {
622 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
623 rte_mempool_avail_count(ts_params->op_mpool));
626 /* Free session mempools */
627 if (ts_params->session_priv_mpool != NULL) {
628 rte_mempool_free(ts_params->session_priv_mpool);
629 ts_params->session_priv_mpool = NULL;
632 if (ts_params->session_mpool != NULL) {
633 rte_mempool_free(ts_params->session_mpool);
634 ts_params->session_mpool = NULL;
639 dev_configure_and_start(uint64_t ff_disable)
641 struct crypto_testsuite_params *ts_params = &testsuite_params;
642 struct crypto_unittest_params *ut_params = &unittest_params;
646 /* Clear unit test parameters before running test */
647 memset(ut_params, 0, sizeof(*ut_params));
649 /* Reconfigure device to default parameters */
650 ts_params->conf.socket_id = SOCKET_ID_ANY;
651 ts_params->conf.ff_disable = ff_disable;
652 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
653 ts_params->qp_conf.mp_session = ts_params->session_mpool;
654 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
656 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
658 "Failed to configure cryptodev %u",
659 ts_params->valid_devs[0]);
661 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
662 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
663 ts_params->valid_devs[0], qp_id,
665 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
666 "Failed to setup queue pair %u on cryptodev %u",
667 qp_id, ts_params->valid_devs[0]);
671 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
673 /* Start the device */
674 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
675 "Failed to start cryptodev %u",
676 ts_params->valid_devs[0]);
684 /* Configure and start the device with security feature disabled */
685 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
689 ut_setup_security(void)
691 /* Configure and start the device with no features disabled */
692 return dev_configure_and_start(0);
698 struct crypto_testsuite_params *ts_params = &testsuite_params;
699 struct crypto_unittest_params *ut_params = &unittest_params;
700 struct rte_cryptodev_stats stats;
702 /* free crypto session structure */
703 #ifdef RTE_LIBRTE_SECURITY
704 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
705 if (ut_params->sec_session) {
706 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
707 (ts_params->valid_devs[0]),
708 ut_params->sec_session);
709 ut_params->sec_session = NULL;
714 if (ut_params->sess) {
715 rte_cryptodev_sym_session_clear(
716 ts_params->valid_devs[0],
718 rte_cryptodev_sym_session_free(ut_params->sess);
719 ut_params->sess = NULL;
723 /* free crypto operation structure */
725 rte_crypto_op_free(ut_params->op);
728 * free mbuf - both obuf and ibuf are usually the same,
729 * so check if they point at the same address is necessary,
730 * to avoid freeing the mbuf twice.
732 if (ut_params->obuf) {
733 rte_pktmbuf_free(ut_params->obuf);
734 if (ut_params->ibuf == ut_params->obuf)
738 if (ut_params->ibuf) {
739 rte_pktmbuf_free(ut_params->ibuf);
743 if (ts_params->mbuf_pool != NULL)
744 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
745 rte_mempool_avail_count(ts_params->mbuf_pool));
747 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
749 /* Stop the device */
750 rte_cryptodev_stop(ts_params->valid_devs[0]);
754 test_device_configure_invalid_dev_id(void)
756 struct crypto_testsuite_params *ts_params = &testsuite_params;
757 uint16_t dev_id, num_devs = 0;
759 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
760 "Need at least %d devices for test", 1);
762 /* valid dev_id values */
763 dev_id = ts_params->valid_devs[0];
765 /* Stop the device in case it's started so it can be configured */
766 rte_cryptodev_stop(dev_id);
768 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
769 "Failed test for rte_cryptodev_configure: "
770 "invalid dev_num %u", dev_id);
772 /* invalid dev_id values */
775 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
776 "Failed test for rte_cryptodev_configure: "
777 "invalid dev_num %u", dev_id);
781 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
782 "Failed test for rte_cryptodev_configure:"
783 "invalid dev_num %u", dev_id);
789 test_device_configure_invalid_queue_pair_ids(void)
791 struct crypto_testsuite_params *ts_params = &testsuite_params;
792 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
794 /* Stop the device in case it's started so it can be configured */
795 rte_cryptodev_stop(ts_params->valid_devs[0]);
797 /* valid - max value queue pairs */
798 ts_params->conf.nb_queue_pairs = orig_nb_qps;
800 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
802 "Failed to configure cryptodev: dev_id %u, qp_id %u",
803 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
805 /* valid - one queue pairs */
806 ts_params->conf.nb_queue_pairs = 1;
808 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
810 "Failed to configure cryptodev: dev_id %u, qp_id %u",
811 ts_params->valid_devs[0],
812 ts_params->conf.nb_queue_pairs);
815 /* invalid - zero queue pairs */
816 ts_params->conf.nb_queue_pairs = 0;
818 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
820 "Failed test for rte_cryptodev_configure, dev_id %u,"
822 ts_params->valid_devs[0],
823 ts_params->conf.nb_queue_pairs);
826 /* invalid - max value supported by field queue pairs */
827 ts_params->conf.nb_queue_pairs = UINT16_MAX;
829 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
831 "Failed test for rte_cryptodev_configure, dev_id %u,"
833 ts_params->valid_devs[0],
834 ts_params->conf.nb_queue_pairs);
837 /* invalid - max value + 1 queue pairs */
838 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
840 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
842 "Failed test for rte_cryptodev_configure, dev_id %u,"
844 ts_params->valid_devs[0],
845 ts_params->conf.nb_queue_pairs);
847 /* revert to original testsuite value */
848 ts_params->conf.nb_queue_pairs = orig_nb_qps;
854 test_queue_pair_descriptor_setup(void)
856 struct crypto_testsuite_params *ts_params = &testsuite_params;
857 struct rte_cryptodev_qp_conf qp_conf = {
858 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
862 /* Stop the device in case it's started so it can be configured */
863 rte_cryptodev_stop(ts_params->valid_devs[0]);
865 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
867 "Failed to configure cryptodev %u",
868 ts_params->valid_devs[0]);
871 * Test various ring sizes on this device. memzones can't be
872 * freed so are re-used if ring is released and re-created.
874 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
875 qp_conf.mp_session = ts_params->session_mpool;
876 qp_conf.mp_session_private = ts_params->session_priv_mpool;
878 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
879 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
880 ts_params->valid_devs[0], qp_id, &qp_conf,
881 rte_cryptodev_socket_id(
882 ts_params->valid_devs[0])),
884 "rte_cryptodev_queue_pair_setup: num_inflights "
885 "%u on qp %u on cryptodev %u",
886 qp_conf.nb_descriptors, qp_id,
887 ts_params->valid_devs[0]);
890 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
892 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
893 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
894 ts_params->valid_devs[0], qp_id, &qp_conf,
895 rte_cryptodev_socket_id(
896 ts_params->valid_devs[0])),
898 " rte_cryptodev_queue_pair_setup: num_inflights"
899 " %u on qp %u on cryptodev %u",
900 qp_conf.nb_descriptors, qp_id,
901 ts_params->valid_devs[0]);
904 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
906 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
907 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
908 ts_params->valid_devs[0], qp_id, &qp_conf,
909 rte_cryptodev_socket_id(
910 ts_params->valid_devs[0])),
912 "rte_cryptodev_queue_pair_setup: num_inflights"
913 " %u on qp %u on cryptodev %u",
914 qp_conf.nb_descriptors, qp_id,
915 ts_params->valid_devs[0]);
918 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
920 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
921 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
922 ts_params->valid_devs[0], qp_id, &qp_conf,
923 rte_cryptodev_socket_id(
924 ts_params->valid_devs[0])),
926 " rte_cryptodev_queue_pair_setup:"
927 "num_inflights %u on qp %u on cryptodev %u",
928 qp_conf.nb_descriptors, qp_id,
929 ts_params->valid_devs[0]);
932 /* test invalid queue pair id */
933 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
935 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
937 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
938 ts_params->valid_devs[0],
940 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
941 "Failed test for rte_cryptodev_queue_pair_setup:"
942 "invalid qp %u on cryptodev %u",
943 qp_id, ts_params->valid_devs[0]);
945 qp_id = 0xffff; /*invalid*/
947 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
948 ts_params->valid_devs[0],
950 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
951 "Failed test for rte_cryptodev_queue_pair_setup:"
952 "invalid qp %u on cryptodev %u",
953 qp_id, ts_params->valid_devs[0]);
958 /* ***** Plaintext data for tests ***** */
960 const char catch_22_quote_1[] =
961 "There was only one catch and that was Catch-22, which "
962 "specified that a concern for one's safety in the face of "
963 "dangers that were real and immediate was the process of a "
964 "rational mind. Orr was crazy and could be grounded. All he "
965 "had to do was ask; and as soon as he did, he would no longer "
966 "be crazy and would have to fly more missions. Orr would be "
967 "crazy to fly more missions and sane if he didn't, but if he "
968 "was sane he had to fly them. If he flew them he was crazy "
969 "and didn't have to; but if he didn't want to he was sane and "
970 "had to. Yossarian was moved very deeply by the absolute "
971 "simplicity of this clause of Catch-22 and let out a "
972 "respectful whistle. \"That's some catch, that Catch-22\", he "
973 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
975 const char catch_22_quote[] =
976 "What a lousy earth! He wondered how many people were "
977 "destitute that same night even in his own prosperous country, "
978 "how many homes were shanties, how many husbands were drunk "
979 "and wives socked, and how many children were bullied, abused, "
980 "or abandoned. How many families hungered for food they could "
981 "not afford to buy? How many hearts were broken? How many "
982 "suicides would take place that same night, how many people "
983 "would go insane? How many cockroaches and landlords would "
984 "triumph? How many winners were losers, successes failures, "
985 "and rich men poor men? How many wise guys were stupid? How "
986 "many happy endings were unhappy endings? How many honest men "
987 "were liars, brave men cowards, loyal men traitors, how many "
988 "sainted men were corrupt, how many people in positions of "
989 "trust had sold their souls to bodyguards, how many had never "
990 "had souls? How many straight-and-narrow paths were crooked "
991 "paths? How many best families were worst families and how "
992 "many good people were bad people? When you added them all up "
993 "and then subtracted, you might be left with only the children, "
994 "and perhaps with Albert Einstein and an old violinist or "
995 "sculptor somewhere.";
997 #define QUOTE_480_BYTES (480)
998 #define QUOTE_512_BYTES (512)
999 #define QUOTE_768_BYTES (768)
1000 #define QUOTE_1024_BYTES (1024)
1004 /* ***** SHA1 Hash Tests ***** */
1006 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1008 static uint8_t hmac_sha1_key[] = {
1009 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1010 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1011 0xDE, 0xF4, 0xDE, 0xAD };
1013 /* ***** SHA224 Hash Tests ***** */
1015 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1018 /* ***** AES-CBC Cipher Tests ***** */
1020 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1021 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1023 static uint8_t aes_cbc_key[] = {
1024 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1025 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1027 static uint8_t aes_cbc_iv[] = {
1028 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1029 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1032 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1034 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1035 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1036 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1037 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1038 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1039 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1040 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1041 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1042 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1043 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1044 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1045 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1046 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1047 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1048 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1049 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1050 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1051 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1052 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1053 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1054 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1055 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1056 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1057 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1058 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1059 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1060 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1061 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1062 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1063 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1064 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1065 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1066 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1067 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1068 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1069 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1070 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1071 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1072 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1073 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1074 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1075 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1076 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1077 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1078 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1079 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1080 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1081 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1082 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1083 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1084 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1085 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1086 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1087 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1088 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1089 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1090 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1091 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1092 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1093 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1094 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1095 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1096 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1097 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1098 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1101 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1102 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1103 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1104 0x18, 0x8c, 0x1d, 0x32
1108 /* Multisession Vector context Test */
1109 /*Begin Session 0 */
1110 static uint8_t ms_aes_cbc_key0[] = {
1111 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1112 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1115 static uint8_t ms_aes_cbc_iv0[] = {
1116 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1117 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1120 static const uint8_t ms_aes_cbc_cipher0[] = {
1121 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1122 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1123 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1124 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1125 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1126 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1127 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1128 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1129 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1130 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1131 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1132 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1133 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1134 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1135 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1136 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1137 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1138 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1139 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1140 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1141 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1142 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1143 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1144 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1145 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1146 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1147 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1148 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1149 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1150 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1151 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1152 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1153 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1154 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1155 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1156 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1157 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1158 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1159 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1160 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1161 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1162 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1163 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1164 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1165 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1166 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1167 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1168 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1169 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1170 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1171 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1172 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1173 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1174 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1175 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1176 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1177 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1178 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1179 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1180 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1181 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1182 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1183 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1184 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1188 static uint8_t ms_hmac_key0[] = {
1189 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1190 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1191 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1192 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1193 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1194 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1195 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1196 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1199 static const uint8_t ms_hmac_digest0[] = {
1200 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1201 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1202 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1203 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1204 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1205 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1206 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1207 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1211 /* Begin session 1 */
1213 static uint8_t ms_aes_cbc_key1[] = {
1214 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1215 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1218 static uint8_t ms_aes_cbc_iv1[] = {
1219 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1220 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1223 static const uint8_t ms_aes_cbc_cipher1[] = {
1224 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1225 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1226 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1227 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1228 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1229 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1230 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1231 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1232 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1233 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1234 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1235 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1236 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1237 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1238 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1239 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1240 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1241 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1242 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1243 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1244 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1245 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1246 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1247 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1248 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1249 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1250 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1251 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1252 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1253 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1254 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1255 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1256 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1257 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1258 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1259 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1260 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1261 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1262 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1263 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1264 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1265 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1266 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1267 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1268 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1269 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1270 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1271 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1272 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1273 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1274 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1275 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1276 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1277 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1278 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1279 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1280 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1281 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1282 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1283 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1284 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1285 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1286 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1287 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1291 static uint8_t ms_hmac_key1[] = {
1292 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1293 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1294 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1295 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1296 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1297 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1298 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1299 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1302 static const uint8_t ms_hmac_digest1[] = {
1303 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1304 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1305 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1306 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1307 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1308 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1309 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1310 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1313 /* Begin Session 2 */
1314 static uint8_t ms_aes_cbc_key2[] = {
1315 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1316 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1319 static uint8_t ms_aes_cbc_iv2[] = {
1320 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1321 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1324 static const uint8_t ms_aes_cbc_cipher2[] = {
1325 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1326 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1327 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1328 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1329 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1330 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1331 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1332 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1333 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1334 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1335 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1336 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1337 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1338 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1339 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1340 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1341 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1342 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1343 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1344 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1345 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1346 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1347 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1348 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1349 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1350 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1351 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1352 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1353 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1354 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1355 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1356 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1357 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1358 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1359 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1360 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1361 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1362 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1363 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1364 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1365 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1366 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1367 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1368 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1369 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1370 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1371 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1372 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1373 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1374 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1375 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1376 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1377 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1378 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1379 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1380 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1381 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1382 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1383 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1384 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1385 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1386 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1387 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1388 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1391 static uint8_t ms_hmac_key2[] = {
1392 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1393 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1394 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1395 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1396 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1397 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1398 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1399 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1402 static const uint8_t ms_hmac_digest2[] = {
1403 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1404 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1405 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1406 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1407 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1408 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1409 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1410 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1417 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1419 struct crypto_testsuite_params *ts_params = &testsuite_params;
1420 struct crypto_unittest_params *ut_params = &unittest_params;
1422 /* Verify the capabilities */
1423 struct rte_cryptodev_sym_capability_idx cap_idx;
1424 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1425 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1426 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1429 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1430 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1431 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1435 /* Generate test mbuf data and space for digest */
1436 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1437 catch_22_quote, QUOTE_512_BYTES, 0);
1439 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1440 DIGEST_BYTE_LENGTH_SHA1);
1441 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1443 /* Setup Cipher Parameters */
1444 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1445 ut_params->cipher_xform.next = &ut_params->auth_xform;
1447 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1448 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1449 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1450 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1451 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1452 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1454 /* Setup HMAC Parameters */
1455 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1457 ut_params->auth_xform.next = NULL;
1459 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1460 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1461 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1462 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1463 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1465 ut_params->sess = rte_cryptodev_sym_session_create(
1466 ts_params->session_mpool);
1468 /* Create crypto session*/
1469 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1470 ut_params->sess, &ut_params->cipher_xform,
1471 ts_params->session_priv_mpool);
1472 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1474 /* Generate crypto op data structure */
1475 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1476 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1477 TEST_ASSERT_NOT_NULL(ut_params->op,
1478 "Failed to allocate symmetric crypto operation struct");
1480 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1482 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1484 /* set crypto operation source mbuf */
1485 sym_op->m_src = ut_params->ibuf;
1487 /* Set crypto operation authentication parameters */
1488 sym_op->auth.digest.data = ut_params->digest;
1489 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1490 ut_params->ibuf, QUOTE_512_BYTES);
1492 sym_op->auth.data.offset = 0;
1493 sym_op->auth.data.length = QUOTE_512_BYTES;
1495 /* Copy IV at the end of the crypto operation */
1496 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1497 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1499 /* Set crypto operation cipher parameters */
1500 sym_op->cipher.data.offset = 0;
1501 sym_op->cipher.data.length = QUOTE_512_BYTES;
1503 /* Process crypto operation */
1504 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1505 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1508 TEST_ASSERT_NOT_NULL(
1509 process_crypto_request(ts_params->valid_devs[0],
1511 "failed to process sym crypto op");
1513 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1514 "crypto op processing failed");
1517 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1520 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1521 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1523 "ciphertext data not as expected");
1525 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1527 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1528 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1529 gbl_driver_id == rte_cryptodev_driver_id_get(
1530 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1531 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1532 DIGEST_BYTE_LENGTH_SHA1,
1533 "Generated digest data not as expected");
1535 return TEST_SUCCESS;
1538 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1540 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1542 static uint8_t hmac_sha512_key[] = {
1543 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1544 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1545 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1546 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1547 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1548 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1549 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1550 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1552 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1553 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1554 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1555 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1556 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1557 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1558 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1559 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1560 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1565 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1566 struct crypto_unittest_params *ut_params,
1567 uint8_t *cipher_key,
1571 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1572 struct crypto_unittest_params *ut_params,
1573 struct crypto_testsuite_params *ts_params,
1574 const uint8_t *cipher,
1575 const uint8_t *digest,
1580 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1581 struct crypto_unittest_params *ut_params,
1582 uint8_t *cipher_key,
1586 /* Setup Cipher Parameters */
1587 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1588 ut_params->cipher_xform.next = NULL;
1590 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1591 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1592 ut_params->cipher_xform.cipher.key.data = cipher_key;
1593 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1594 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1595 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1597 /* Setup HMAC Parameters */
1598 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1599 ut_params->auth_xform.next = &ut_params->cipher_xform;
1601 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1602 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1603 ut_params->auth_xform.auth.key.data = hmac_key;
1604 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1605 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1607 return TEST_SUCCESS;
1612 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1613 struct crypto_unittest_params *ut_params,
1614 struct crypto_testsuite_params *ts_params,
1615 const uint8_t *cipher,
1616 const uint8_t *digest,
1619 /* Generate test mbuf data and digest */
1620 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1623 QUOTE_512_BYTES, 0);
1625 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1626 DIGEST_BYTE_LENGTH_SHA512);
1627 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1629 rte_memcpy(ut_params->digest,
1631 DIGEST_BYTE_LENGTH_SHA512);
1633 /* Generate Crypto op data structure */
1634 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1635 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1636 TEST_ASSERT_NOT_NULL(ut_params->op,
1637 "Failed to allocate symmetric crypto operation struct");
1639 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1641 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1643 /* set crypto operation source mbuf */
1644 sym_op->m_src = ut_params->ibuf;
1646 sym_op->auth.digest.data = ut_params->digest;
1647 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1648 ut_params->ibuf, QUOTE_512_BYTES);
1650 sym_op->auth.data.offset = 0;
1651 sym_op->auth.data.length = QUOTE_512_BYTES;
1653 /* Copy IV at the end of the crypto operation */
1654 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1655 iv, CIPHER_IV_LENGTH_AES_CBC);
1657 sym_op->cipher.data.offset = 0;
1658 sym_op->cipher.data.length = QUOTE_512_BYTES;
1660 /* Process crypto operation */
1661 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1662 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1665 TEST_ASSERT_NOT_NULL(
1666 process_crypto_request(ts_params->valid_devs[0],
1668 "failed to process sym crypto op");
1670 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1671 "crypto op processing failed");
1673 ut_params->obuf = ut_params->op->sym->m_src;
1676 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1677 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1680 "Plaintext data not as expected");
1683 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1684 "Digest verification failed");
1686 return TEST_SUCCESS;
1690 test_blockcipher(enum blockcipher_test_type test_type)
1692 struct crypto_testsuite_params *ts_params = &testsuite_params;
1695 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1696 ts_params->op_mpool,
1697 ts_params->session_mpool, ts_params->session_priv_mpool,
1698 ts_params->valid_devs[0],
1701 if (status == -ENOTSUP)
1704 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1706 return TEST_SUCCESS;
1710 test_AES_cipheronly_all(void)
1712 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1716 test_AES_docsis_all(void)
1718 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1722 test_DES_docsis_all(void)
1724 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1728 test_DES_cipheronly_all(void)
1730 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1734 test_authonly_all(void)
1736 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1740 test_AES_chain_all(void)
1742 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1746 test_3DES_chain_all(void)
1748 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1752 test_3DES_cipheronly_all(void)
1754 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1757 /* ***** SNOW 3G Tests ***** */
1759 create_wireless_algo_hash_session(uint8_t dev_id,
1760 const uint8_t *key, const uint8_t key_len,
1761 const uint8_t iv_len, const uint8_t auth_len,
1762 enum rte_crypto_auth_operation op,
1763 enum rte_crypto_auth_algorithm algo)
1765 uint8_t hash_key[key_len];
1768 struct crypto_testsuite_params *ts_params = &testsuite_params;
1769 struct crypto_unittest_params *ut_params = &unittest_params;
1771 memcpy(hash_key, key, key_len);
1773 debug_hexdump(stdout, "key:", key, key_len);
1775 /* Setup Authentication Parameters */
1776 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1777 ut_params->auth_xform.next = NULL;
1779 ut_params->auth_xform.auth.op = op;
1780 ut_params->auth_xform.auth.algo = algo;
1781 ut_params->auth_xform.auth.key.length = key_len;
1782 ut_params->auth_xform.auth.key.data = hash_key;
1783 ut_params->auth_xform.auth.digest_length = auth_len;
1784 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
1785 ut_params->auth_xform.auth.iv.length = iv_len;
1786 ut_params->sess = rte_cryptodev_sym_session_create(
1787 ts_params->session_mpool);
1789 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1790 &ut_params->auth_xform,
1791 ts_params->session_priv_mpool);
1792 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1793 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1798 create_wireless_algo_cipher_session(uint8_t dev_id,
1799 enum rte_crypto_cipher_operation op,
1800 enum rte_crypto_cipher_algorithm algo,
1801 const uint8_t *key, const uint8_t key_len,
1804 uint8_t cipher_key[key_len];
1806 struct crypto_testsuite_params *ts_params = &testsuite_params;
1807 struct crypto_unittest_params *ut_params = &unittest_params;
1809 memcpy(cipher_key, key, key_len);
1811 /* Setup Cipher Parameters */
1812 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1813 ut_params->cipher_xform.next = NULL;
1815 ut_params->cipher_xform.cipher.algo = algo;
1816 ut_params->cipher_xform.cipher.op = op;
1817 ut_params->cipher_xform.cipher.key.data = cipher_key;
1818 ut_params->cipher_xform.cipher.key.length = key_len;
1819 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1820 ut_params->cipher_xform.cipher.iv.length = iv_len;
1822 debug_hexdump(stdout, "key:", key, key_len);
1824 /* Create Crypto session */
1825 ut_params->sess = rte_cryptodev_sym_session_create(
1826 ts_params->session_mpool);
1828 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1829 &ut_params->cipher_xform,
1830 ts_params->session_priv_mpool);
1831 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1837 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
1838 unsigned int cipher_len,
1839 unsigned int cipher_offset)
1841 struct crypto_testsuite_params *ts_params = &testsuite_params;
1842 struct crypto_unittest_params *ut_params = &unittest_params;
1844 /* Generate Crypto op data structure */
1845 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1846 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1847 TEST_ASSERT_NOT_NULL(ut_params->op,
1848 "Failed to allocate pktmbuf offload");
1850 /* Set crypto operation data parameters */
1851 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1853 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1855 /* set crypto operation source mbuf */
1856 sym_op->m_src = ut_params->ibuf;
1859 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1861 sym_op->cipher.data.length = cipher_len;
1862 sym_op->cipher.data.offset = cipher_offset;
1867 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
1868 unsigned int cipher_len,
1869 unsigned int cipher_offset)
1871 struct crypto_testsuite_params *ts_params = &testsuite_params;
1872 struct crypto_unittest_params *ut_params = &unittest_params;
1874 /* Generate Crypto op data structure */
1875 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1876 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1877 TEST_ASSERT_NOT_NULL(ut_params->op,
1878 "Failed to allocate pktmbuf offload");
1880 /* Set crypto operation data parameters */
1881 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1883 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1885 /* set crypto operation source mbuf */
1886 sym_op->m_src = ut_params->ibuf;
1887 sym_op->m_dst = ut_params->obuf;
1890 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1892 sym_op->cipher.data.length = cipher_len;
1893 sym_op->cipher.data.offset = cipher_offset;
1898 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1899 enum rte_crypto_cipher_operation cipher_op,
1900 enum rte_crypto_auth_operation auth_op,
1901 enum rte_crypto_auth_algorithm auth_algo,
1902 enum rte_crypto_cipher_algorithm cipher_algo,
1903 const uint8_t *key, uint8_t key_len,
1904 uint8_t auth_iv_len, uint8_t auth_len,
1905 uint8_t cipher_iv_len)
1908 uint8_t cipher_auth_key[key_len];
1911 struct crypto_testsuite_params *ts_params = &testsuite_params;
1912 struct crypto_unittest_params *ut_params = &unittest_params;
1914 memcpy(cipher_auth_key, key, key_len);
1916 /* Setup Authentication Parameters */
1917 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1918 ut_params->auth_xform.next = NULL;
1920 ut_params->auth_xform.auth.op = auth_op;
1921 ut_params->auth_xform.auth.algo = auth_algo;
1922 ut_params->auth_xform.auth.key.length = key_len;
1923 /* Hash key = cipher key */
1924 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1925 ut_params->auth_xform.auth.digest_length = auth_len;
1926 /* Auth IV will be after cipher IV */
1927 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1928 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1930 /* Setup Cipher Parameters */
1931 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1932 ut_params->cipher_xform.next = &ut_params->auth_xform;
1934 ut_params->cipher_xform.cipher.algo = cipher_algo;
1935 ut_params->cipher_xform.cipher.op = cipher_op;
1936 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1937 ut_params->cipher_xform.cipher.key.length = key_len;
1938 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1939 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
1941 debug_hexdump(stdout, "key:", key, key_len);
1943 /* Create Crypto session*/
1944 ut_params->sess = rte_cryptodev_sym_session_create(
1945 ts_params->session_mpool);
1946 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1948 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
1949 &ut_params->cipher_xform,
1950 ts_params->session_priv_mpool);
1951 if (status == -ENOTSUP)
1954 TEST_ASSERT_EQUAL(status, 0, "session init failed");
1959 create_wireless_cipher_auth_session(uint8_t dev_id,
1960 enum rte_crypto_cipher_operation cipher_op,
1961 enum rte_crypto_auth_operation auth_op,
1962 enum rte_crypto_auth_algorithm auth_algo,
1963 enum rte_crypto_cipher_algorithm cipher_algo,
1964 const struct wireless_test_data *tdata)
1966 const uint8_t key_len = tdata->key.len;
1967 uint8_t cipher_auth_key[key_len];
1970 struct crypto_testsuite_params *ts_params = &testsuite_params;
1971 struct crypto_unittest_params *ut_params = &unittest_params;
1972 const uint8_t *key = tdata->key.data;
1973 const uint8_t auth_len = tdata->digest.len;
1974 uint8_t cipher_iv_len = tdata->cipher_iv.len;
1975 uint8_t auth_iv_len = tdata->auth_iv.len;
1977 memcpy(cipher_auth_key, key, key_len);
1979 /* Setup Authentication Parameters */
1980 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1981 ut_params->auth_xform.next = NULL;
1983 ut_params->auth_xform.auth.op = auth_op;
1984 ut_params->auth_xform.auth.algo = auth_algo;
1985 ut_params->auth_xform.auth.key.length = key_len;
1986 /* Hash key = cipher key */
1987 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1988 ut_params->auth_xform.auth.digest_length = auth_len;
1989 /* Auth IV will be after cipher IV */
1990 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
1991 ut_params->auth_xform.auth.iv.length = auth_iv_len;
1993 /* Setup Cipher Parameters */
1994 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1995 ut_params->cipher_xform.next = &ut_params->auth_xform;
1997 ut_params->cipher_xform.cipher.algo = cipher_algo;
1998 ut_params->cipher_xform.cipher.op = cipher_op;
1999 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2000 ut_params->cipher_xform.cipher.key.length = key_len;
2001 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2002 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2005 debug_hexdump(stdout, "key:", key, key_len);
2007 /* Create Crypto session*/
2008 ut_params->sess = rte_cryptodev_sym_session_create(
2009 ts_params->session_mpool);
2011 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2012 &ut_params->cipher_xform,
2013 ts_params->session_priv_mpool);
2014 if (status == -ENOTSUP)
2017 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2018 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2023 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2024 const struct wireless_test_data *tdata)
2026 return create_wireless_cipher_auth_session(dev_id,
2027 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2028 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2029 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2033 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2034 enum rte_crypto_cipher_operation cipher_op,
2035 enum rte_crypto_auth_operation auth_op,
2036 enum rte_crypto_auth_algorithm auth_algo,
2037 enum rte_crypto_cipher_algorithm cipher_algo,
2038 const uint8_t *key, const uint8_t key_len,
2039 uint8_t auth_iv_len, uint8_t auth_len,
2040 uint8_t cipher_iv_len)
2042 uint8_t auth_cipher_key[key_len];
2044 struct crypto_testsuite_params *ts_params = &testsuite_params;
2045 struct crypto_unittest_params *ut_params = &unittest_params;
2047 memcpy(auth_cipher_key, key, key_len);
2049 /* Setup Authentication Parameters */
2050 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2051 ut_params->auth_xform.auth.op = auth_op;
2052 ut_params->auth_xform.next = &ut_params->cipher_xform;
2053 ut_params->auth_xform.auth.algo = auth_algo;
2054 ut_params->auth_xform.auth.key.length = key_len;
2055 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2056 ut_params->auth_xform.auth.digest_length = auth_len;
2057 /* Auth IV will be after cipher IV */
2058 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2059 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2061 /* Setup Cipher Parameters */
2062 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2063 ut_params->cipher_xform.next = NULL;
2064 ut_params->cipher_xform.cipher.algo = cipher_algo;
2065 ut_params->cipher_xform.cipher.op = cipher_op;
2066 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2067 ut_params->cipher_xform.cipher.key.length = key_len;
2068 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2069 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2071 debug_hexdump(stdout, "key:", key, key_len);
2073 /* Create Crypto session*/
2074 ut_params->sess = rte_cryptodev_sym_session_create(
2075 ts_params->session_mpool);
2076 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2078 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2079 ut_params->auth_xform.next = NULL;
2080 ut_params->cipher_xform.next = &ut_params->auth_xform;
2081 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2082 &ut_params->cipher_xform,
2083 ts_params->session_priv_mpool);
2086 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2087 &ut_params->auth_xform,
2088 ts_params->session_priv_mpool);
2090 if (status == -ENOTSUP)
2093 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2099 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2100 unsigned int auth_tag_len,
2101 const uint8_t *iv, unsigned int iv_len,
2102 unsigned int data_pad_len,
2103 enum rte_crypto_auth_operation op,
2104 unsigned int auth_len, unsigned int auth_offset)
2106 struct crypto_testsuite_params *ts_params = &testsuite_params;
2108 struct crypto_unittest_params *ut_params = &unittest_params;
2110 /* Generate Crypto op data structure */
2111 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2112 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2113 TEST_ASSERT_NOT_NULL(ut_params->op,
2114 "Failed to allocate pktmbuf offload");
2116 /* Set crypto operation data parameters */
2117 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2119 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2121 /* set crypto operation source mbuf */
2122 sym_op->m_src = ut_params->ibuf;
2125 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2128 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2129 ut_params->ibuf, auth_tag_len);
2131 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2132 "no room to append auth tag");
2133 ut_params->digest = sym_op->auth.digest.data;
2134 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2135 ut_params->ibuf, data_pad_len);
2136 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2137 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2139 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2141 debug_hexdump(stdout, "digest:",
2142 sym_op->auth.digest.data,
2145 sym_op->auth.data.length = auth_len;
2146 sym_op->auth.data.offset = auth_offset;
2152 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2153 enum rte_crypto_auth_operation op)
2155 struct crypto_testsuite_params *ts_params = &testsuite_params;
2156 struct crypto_unittest_params *ut_params = &unittest_params;
2158 const uint8_t *auth_tag = tdata->digest.data;
2159 const unsigned int auth_tag_len = tdata->digest.len;
2160 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2161 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2163 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2164 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2165 const uint8_t *auth_iv = tdata->auth_iv.data;
2166 const uint8_t auth_iv_len = tdata->auth_iv.len;
2167 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2168 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2170 /* Generate Crypto op data structure */
2171 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2172 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2173 TEST_ASSERT_NOT_NULL(ut_params->op,
2174 "Failed to allocate pktmbuf offload");
2175 /* Set crypto operation data parameters */
2176 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2178 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2180 /* set crypto operation source mbuf */
2181 sym_op->m_src = ut_params->ibuf;
2184 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2185 ut_params->ibuf, auth_tag_len);
2187 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2188 "no room to append auth tag");
2189 ut_params->digest = sym_op->auth.digest.data;
2190 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2191 ut_params->ibuf, data_pad_len);
2192 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2193 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2195 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2197 debug_hexdump(stdout, "digest:",
2198 sym_op->auth.digest.data,
2201 /* Copy cipher and auth IVs at the end of the crypto operation */
2202 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2204 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2205 iv_ptr += cipher_iv_len;
2206 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2208 sym_op->cipher.data.length = cipher_len;
2209 sym_op->cipher.data.offset = 0;
2210 sym_op->auth.data.length = auth_len;
2211 sym_op->auth.data.offset = 0;
2217 create_zuc_cipher_hash_generate_operation(
2218 const struct wireless_test_data *tdata)
2220 return create_wireless_cipher_hash_operation(tdata,
2221 RTE_CRYPTO_AUTH_OP_GENERATE);
2225 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2226 const unsigned auth_tag_len,
2227 const uint8_t *auth_iv, uint8_t auth_iv_len,
2228 unsigned data_pad_len,
2229 enum rte_crypto_auth_operation op,
2230 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2231 const unsigned cipher_len, const unsigned cipher_offset,
2232 const unsigned auth_len, const unsigned auth_offset)
2234 struct crypto_testsuite_params *ts_params = &testsuite_params;
2235 struct crypto_unittest_params *ut_params = &unittest_params;
2237 enum rte_crypto_cipher_algorithm cipher_algo =
2238 ut_params->cipher_xform.cipher.algo;
2239 enum rte_crypto_auth_algorithm auth_algo =
2240 ut_params->auth_xform.auth.algo;
2242 /* Generate Crypto op data structure */
2243 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2244 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2245 TEST_ASSERT_NOT_NULL(ut_params->op,
2246 "Failed to allocate pktmbuf offload");
2247 /* Set crypto operation data parameters */
2248 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2250 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2252 /* set crypto operation source mbuf */
2253 sym_op->m_src = ut_params->ibuf;
2256 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2257 ut_params->ibuf, auth_tag_len);
2259 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2260 "no room to append auth tag");
2261 ut_params->digest = sym_op->auth.digest.data;
2263 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2264 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2265 ut_params->ibuf, data_pad_len);
2267 struct rte_mbuf *m = ut_params->ibuf;
2268 unsigned int offset = data_pad_len;
2270 while (offset > m->data_len && m->next != NULL) {
2271 offset -= m->data_len;
2274 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2278 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2279 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2281 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2283 debug_hexdump(stdout, "digest:",
2284 sym_op->auth.digest.data,
2287 /* Copy cipher and auth IVs at the end of the crypto operation */
2288 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2290 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2291 iv_ptr += cipher_iv_len;
2292 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2294 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2295 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2296 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2297 sym_op->cipher.data.length = cipher_len;
2298 sym_op->cipher.data.offset = cipher_offset;
2300 sym_op->cipher.data.length = cipher_len >> 3;
2301 sym_op->cipher.data.offset = cipher_offset >> 3;
2304 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2305 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2306 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2307 sym_op->auth.data.length = auth_len;
2308 sym_op->auth.data.offset = auth_offset;
2310 sym_op->auth.data.length = auth_len >> 3;
2311 sym_op->auth.data.offset = auth_offset >> 3;
2318 create_wireless_algo_auth_cipher_operation(
2319 const uint8_t *auth_tag, unsigned int auth_tag_len,
2320 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2321 const uint8_t *auth_iv, uint8_t auth_iv_len,
2322 unsigned int data_pad_len,
2323 unsigned int cipher_len, unsigned int cipher_offset,
2324 unsigned int auth_len, unsigned int auth_offset,
2325 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2327 struct crypto_testsuite_params *ts_params = &testsuite_params;
2328 struct crypto_unittest_params *ut_params = &unittest_params;
2330 enum rte_crypto_cipher_algorithm cipher_algo =
2331 ut_params->cipher_xform.cipher.algo;
2332 enum rte_crypto_auth_algorithm auth_algo =
2333 ut_params->auth_xform.auth.algo;
2335 /* Generate Crypto op data structure */
2336 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2337 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2338 TEST_ASSERT_NOT_NULL(ut_params->op,
2339 "Failed to allocate pktmbuf offload");
2341 /* Set crypto operation data parameters */
2342 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2344 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2346 /* set crypto operation mbufs */
2347 sym_op->m_src = ut_params->ibuf;
2348 if (op_mode == OUT_OF_PLACE)
2349 sym_op->m_dst = ut_params->obuf;
2353 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2354 (op_mode == IN_PLACE ?
2355 ut_params->ibuf : ut_params->obuf),
2356 uint8_t *, data_pad_len);
2357 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2358 (op_mode == IN_PLACE ?
2359 ut_params->ibuf : ut_params->obuf),
2361 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2363 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2364 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2365 sym_op->m_src : sym_op->m_dst);
2366 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2367 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2368 sgl_buf = sgl_buf->next;
2370 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2371 uint8_t *, remaining_off);
2372 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2374 memset(sym_op->auth.digest.data, 0, remaining_off);
2375 while (sgl_buf->next != NULL) {
2376 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2377 0, rte_pktmbuf_data_len(sgl_buf));
2378 sgl_buf = sgl_buf->next;
2382 /* Copy digest for the verification */
2384 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2386 /* Copy cipher and auth IVs at the end of the crypto operation */
2387 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2388 ut_params->op, uint8_t *, IV_OFFSET);
2390 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2391 iv_ptr += cipher_iv_len;
2392 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2394 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2395 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2396 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2397 sym_op->cipher.data.length = cipher_len;
2398 sym_op->cipher.data.offset = cipher_offset;
2400 sym_op->cipher.data.length = cipher_len >> 3;
2401 sym_op->cipher.data.offset = cipher_offset >> 3;
2404 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2405 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2406 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2407 sym_op->auth.data.length = auth_len;
2408 sym_op->auth.data.offset = auth_offset;
2410 sym_op->auth.data.length = auth_len >> 3;
2411 sym_op->auth.data.offset = auth_offset >> 3;
2418 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2420 struct crypto_testsuite_params *ts_params = &testsuite_params;
2421 struct crypto_unittest_params *ut_params = &unittest_params;
2424 unsigned plaintext_pad_len;
2425 unsigned plaintext_len;
2427 struct rte_cryptodev_info dev_info;
2429 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2430 uint64_t feat_flags = dev_info.feature_flags;
2432 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2433 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2434 printf("Device doesn't support NON-Byte Aligned Data.\n");
2438 /* Verify the capabilities */
2439 struct rte_cryptodev_sym_capability_idx cap_idx;
2440 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2441 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2442 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2446 /* Create SNOW 3G session */
2447 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2448 tdata->key.data, tdata->key.len,
2449 tdata->auth_iv.len, tdata->digest.len,
2450 RTE_CRYPTO_AUTH_OP_GENERATE,
2451 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2455 /* alloc mbuf and set payload */
2456 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2458 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2459 rte_pktmbuf_tailroom(ut_params->ibuf));
2461 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2462 /* Append data which is padded to a multiple of */
2463 /* the algorithms block size */
2464 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2465 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2467 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2469 /* Create SNOW 3G operation */
2470 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2471 tdata->auth_iv.data, tdata->auth_iv.len,
2472 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2473 tdata->validAuthLenInBits.len,
2478 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2480 ut_params->obuf = ut_params->op->sym->m_src;
2481 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2482 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2483 + plaintext_pad_len;
2486 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2489 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2490 "SNOW 3G Generated auth tag not as expected");
2496 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2498 struct crypto_testsuite_params *ts_params = &testsuite_params;
2499 struct crypto_unittest_params *ut_params = &unittest_params;
2502 unsigned plaintext_pad_len;
2503 unsigned plaintext_len;
2505 struct rte_cryptodev_info dev_info;
2507 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2508 uint64_t feat_flags = dev_info.feature_flags;
2510 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2511 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2512 printf("Device doesn't support NON-Byte Aligned Data.\n");
2516 /* Verify the capabilities */
2517 struct rte_cryptodev_sym_capability_idx cap_idx;
2518 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2519 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2520 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2524 /* Create SNOW 3G session */
2525 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2526 tdata->key.data, tdata->key.len,
2527 tdata->auth_iv.len, tdata->digest.len,
2528 RTE_CRYPTO_AUTH_OP_VERIFY,
2529 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2532 /* alloc mbuf and set payload */
2533 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2535 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2536 rte_pktmbuf_tailroom(ut_params->ibuf));
2538 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2539 /* Append data which is padded to a multiple of */
2540 /* the algorithms block size */
2541 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2542 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2544 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2546 /* Create SNOW 3G operation */
2547 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2549 tdata->auth_iv.data, tdata->auth_iv.len,
2551 RTE_CRYPTO_AUTH_OP_VERIFY,
2552 tdata->validAuthLenInBits.len,
2557 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2559 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2560 ut_params->obuf = ut_params->op->sym->m_src;
2561 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2562 + plaintext_pad_len;
2565 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2574 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2576 struct crypto_testsuite_params *ts_params = &testsuite_params;
2577 struct crypto_unittest_params *ut_params = &unittest_params;
2580 unsigned plaintext_pad_len;
2581 unsigned plaintext_len;
2584 /* Verify the capabilities */
2585 struct rte_cryptodev_sym_capability_idx cap_idx;
2586 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2587 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2588 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2592 /* Create KASUMI session */
2593 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2594 tdata->key.data, tdata->key.len,
2595 0, tdata->digest.len,
2596 RTE_CRYPTO_AUTH_OP_GENERATE,
2597 RTE_CRYPTO_AUTH_KASUMI_F9);
2601 /* alloc mbuf and set payload */
2602 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2604 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2605 rte_pktmbuf_tailroom(ut_params->ibuf));
2607 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2608 /* Append data which is padded to a multiple of */
2609 /* the algorithms block size */
2610 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2611 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2613 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2615 /* Create KASUMI operation */
2616 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2618 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2619 tdata->plaintext.len,
2624 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2625 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2628 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2631 ut_params->obuf = ut_params->op->sym->m_src;
2632 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2633 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2634 + plaintext_pad_len;
2637 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2640 DIGEST_BYTE_LENGTH_KASUMI_F9,
2641 "KASUMI Generated auth tag not as expected");
2647 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2649 struct crypto_testsuite_params *ts_params = &testsuite_params;
2650 struct crypto_unittest_params *ut_params = &unittest_params;
2653 unsigned plaintext_pad_len;
2654 unsigned plaintext_len;
2657 /* Verify the capabilities */
2658 struct rte_cryptodev_sym_capability_idx cap_idx;
2659 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2660 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2661 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2665 /* Create KASUMI session */
2666 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2667 tdata->key.data, tdata->key.len,
2668 0, tdata->digest.len,
2669 RTE_CRYPTO_AUTH_OP_VERIFY,
2670 RTE_CRYPTO_AUTH_KASUMI_F9);
2673 /* alloc mbuf and set payload */
2674 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2676 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2677 rte_pktmbuf_tailroom(ut_params->ibuf));
2679 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2680 /* Append data which is padded to a multiple */
2681 /* of the algorithms block size */
2682 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2683 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2685 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2687 /* Create KASUMI operation */
2688 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2692 RTE_CRYPTO_AUTH_OP_VERIFY,
2693 tdata->plaintext.len,
2698 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2700 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2701 ut_params->obuf = ut_params->op->sym->m_src;
2702 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2703 + plaintext_pad_len;
2706 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2715 test_snow3g_hash_generate_test_case_1(void)
2717 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2721 test_snow3g_hash_generate_test_case_2(void)
2723 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2727 test_snow3g_hash_generate_test_case_3(void)
2729 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2733 test_snow3g_hash_generate_test_case_4(void)
2735 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2739 test_snow3g_hash_generate_test_case_5(void)
2741 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2745 test_snow3g_hash_generate_test_case_6(void)
2747 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2751 test_snow3g_hash_verify_test_case_1(void)
2753 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2758 test_snow3g_hash_verify_test_case_2(void)
2760 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2764 test_snow3g_hash_verify_test_case_3(void)
2766 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2770 test_snow3g_hash_verify_test_case_4(void)
2772 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2776 test_snow3g_hash_verify_test_case_5(void)
2778 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2782 test_snow3g_hash_verify_test_case_6(void)
2784 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2788 test_kasumi_hash_generate_test_case_1(void)
2790 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2794 test_kasumi_hash_generate_test_case_2(void)
2796 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2800 test_kasumi_hash_generate_test_case_3(void)
2802 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2806 test_kasumi_hash_generate_test_case_4(void)
2808 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2812 test_kasumi_hash_generate_test_case_5(void)
2814 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2818 test_kasumi_hash_generate_test_case_6(void)
2820 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2824 test_kasumi_hash_verify_test_case_1(void)
2826 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2830 test_kasumi_hash_verify_test_case_2(void)
2832 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2836 test_kasumi_hash_verify_test_case_3(void)
2838 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2842 test_kasumi_hash_verify_test_case_4(void)
2844 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2848 test_kasumi_hash_verify_test_case_5(void)
2850 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2854 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2856 struct crypto_testsuite_params *ts_params = &testsuite_params;
2857 struct crypto_unittest_params *ut_params = &unittest_params;
2860 uint8_t *plaintext, *ciphertext;
2861 unsigned plaintext_pad_len;
2862 unsigned plaintext_len;
2864 /* Verify the capabilities */
2865 struct rte_cryptodev_sym_capability_idx cap_idx;
2866 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2867 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2868 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2872 /* Create KASUMI session */
2873 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2874 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2875 RTE_CRYPTO_CIPHER_KASUMI_F8,
2876 tdata->key.data, tdata->key.len,
2877 tdata->cipher_iv.len);
2881 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2883 /* Clear mbuf payload */
2884 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2885 rte_pktmbuf_tailroom(ut_params->ibuf));
2887 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2888 /* Append data which is padded to a multiple */
2889 /* of the algorithms block size */
2890 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2891 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2893 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2895 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2897 /* Create KASUMI operation */
2898 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2899 tdata->cipher_iv.len,
2900 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2901 tdata->validCipherOffsetInBits.len);
2905 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2907 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2909 ut_params->obuf = ut_params->op->sym->m_dst;
2910 if (ut_params->obuf)
2911 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2913 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
2915 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2917 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
2918 (tdata->validCipherOffsetInBits.len >> 3);
2920 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2922 reference_ciphertext,
2923 tdata->validCipherLenInBits.len,
2924 "KASUMI Ciphertext data not as expected");
2929 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2931 struct crypto_testsuite_params *ts_params = &testsuite_params;
2932 struct crypto_unittest_params *ut_params = &unittest_params;
2936 unsigned int plaintext_pad_len;
2937 unsigned int plaintext_len;
2939 uint8_t buffer[10000];
2940 const uint8_t *ciphertext;
2942 struct rte_cryptodev_info dev_info;
2944 /* Verify the capabilities */
2945 struct rte_cryptodev_sym_capability_idx cap_idx;
2946 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2947 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
2948 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2952 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2954 uint64_t feat_flags = dev_info.feature_flags;
2956 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
2957 printf("Device doesn't support in-place scatter-gather. "
2962 /* Create KASUMI session */
2963 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2964 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2965 RTE_CRYPTO_CIPHER_KASUMI_F8,
2966 tdata->key.data, tdata->key.len,
2967 tdata->cipher_iv.len);
2971 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2974 /* Append data which is padded to a multiple */
2975 /* of the algorithms block size */
2976 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2978 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2979 plaintext_pad_len, 10, 0);
2981 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2983 /* Create KASUMI operation */
2984 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2985 tdata->cipher_iv.len,
2986 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2987 tdata->validCipherOffsetInBits.len);
2991 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2993 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2995 ut_params->obuf = ut_params->op->sym->m_dst;
2997 if (ut_params->obuf)
2998 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
2999 plaintext_len, buffer);
3001 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3002 tdata->validCipherOffsetInBits.len >> 3,
3003 plaintext_len, buffer);
3006 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3008 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3009 (tdata->validCipherOffsetInBits.len >> 3);
3011 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3013 reference_ciphertext,
3014 tdata->validCipherLenInBits.len,
3015 "KASUMI Ciphertext data not as expected");
3020 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3022 struct crypto_testsuite_params *ts_params = &testsuite_params;
3023 struct crypto_unittest_params *ut_params = &unittest_params;
3026 uint8_t *plaintext, *ciphertext;
3027 unsigned plaintext_pad_len;
3028 unsigned plaintext_len;
3030 /* Verify the capabilities */
3031 struct rte_cryptodev_sym_capability_idx cap_idx;
3032 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3033 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3034 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3038 /* Create KASUMI session */
3039 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3040 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3041 RTE_CRYPTO_CIPHER_KASUMI_F8,
3042 tdata->key.data, tdata->key.len,
3043 tdata->cipher_iv.len);
3047 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3048 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3050 /* Clear mbuf payload */
3051 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3052 rte_pktmbuf_tailroom(ut_params->ibuf));
3054 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3055 /* Append data which is padded to a multiple */
3056 /* of the algorithms block size */
3057 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3058 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3060 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3061 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3063 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3065 /* Create KASUMI operation */
3066 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3067 tdata->cipher_iv.len,
3068 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3069 tdata->validCipherOffsetInBits.len);
3073 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3075 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3077 ut_params->obuf = ut_params->op->sym->m_dst;
3078 if (ut_params->obuf)
3079 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3081 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3083 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3085 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3086 (tdata->validCipherOffsetInBits.len >> 3);
3088 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3090 reference_ciphertext,
3091 tdata->validCipherLenInBits.len,
3092 "KASUMI Ciphertext data not as expected");
3097 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3099 struct crypto_testsuite_params *ts_params = &testsuite_params;
3100 struct crypto_unittest_params *ut_params = &unittest_params;
3103 unsigned int plaintext_pad_len;
3104 unsigned int plaintext_len;
3106 const uint8_t *ciphertext;
3107 uint8_t buffer[2048];
3109 struct rte_cryptodev_info dev_info;
3111 /* Verify the capabilities */
3112 struct rte_cryptodev_sym_capability_idx cap_idx;
3113 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3114 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3115 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3119 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3121 uint64_t feat_flags = dev_info.feature_flags;
3122 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3123 printf("Device doesn't support out-of-place scatter-gather "
3124 "in both input and output mbufs. "
3129 /* Create KASUMI session */
3130 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3131 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3132 RTE_CRYPTO_CIPHER_KASUMI_F8,
3133 tdata->key.data, tdata->key.len,
3134 tdata->cipher_iv.len);
3138 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3139 /* Append data which is padded to a multiple */
3140 /* of the algorithms block size */
3141 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3143 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3144 plaintext_pad_len, 10, 0);
3145 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3146 plaintext_pad_len, 3, 0);
3148 /* Append data which is padded to a multiple */
3149 /* of the algorithms block size */
3150 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3152 /* Create KASUMI operation */
3153 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3154 tdata->cipher_iv.len,
3155 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3156 tdata->validCipherOffsetInBits.len);
3160 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3162 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3164 ut_params->obuf = ut_params->op->sym->m_dst;
3165 if (ut_params->obuf)
3166 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3167 plaintext_pad_len, buffer);
3169 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3170 tdata->validCipherOffsetInBits.len >> 3,
3171 plaintext_pad_len, buffer);
3173 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3174 (tdata->validCipherOffsetInBits.len >> 3);
3176 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3178 reference_ciphertext,
3179 tdata->validCipherLenInBits.len,
3180 "KASUMI Ciphertext data not as expected");
3186 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3188 struct crypto_testsuite_params *ts_params = &testsuite_params;
3189 struct crypto_unittest_params *ut_params = &unittest_params;
3192 uint8_t *ciphertext, *plaintext;
3193 unsigned ciphertext_pad_len;
3194 unsigned ciphertext_len;
3196 /* Verify the capabilities */
3197 struct rte_cryptodev_sym_capability_idx cap_idx;
3198 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3199 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3200 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3204 /* Create KASUMI session */
3205 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3206 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3207 RTE_CRYPTO_CIPHER_KASUMI_F8,
3208 tdata->key.data, tdata->key.len,
3209 tdata->cipher_iv.len);
3213 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3214 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3216 /* Clear mbuf payload */
3217 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3218 rte_pktmbuf_tailroom(ut_params->ibuf));
3220 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3221 /* Append data which is padded to a multiple */
3222 /* of the algorithms block size */
3223 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3224 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3225 ciphertext_pad_len);
3226 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3227 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3229 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3231 /* Create KASUMI operation */
3232 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3233 tdata->cipher_iv.len,
3234 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3235 tdata->validCipherOffsetInBits.len);
3239 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3241 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3243 ut_params->obuf = ut_params->op->sym->m_dst;
3244 if (ut_params->obuf)
3245 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3247 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3249 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3251 const uint8_t *reference_plaintext = tdata->plaintext.data +
3252 (tdata->validCipherOffsetInBits.len >> 3);
3254 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3256 reference_plaintext,
3257 tdata->validCipherLenInBits.len,
3258 "KASUMI Plaintext data not as expected");
3263 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3265 struct crypto_testsuite_params *ts_params = &testsuite_params;
3266 struct crypto_unittest_params *ut_params = &unittest_params;
3269 uint8_t *ciphertext, *plaintext;
3270 unsigned ciphertext_pad_len;
3271 unsigned ciphertext_len;
3273 /* Verify the capabilities */
3274 struct rte_cryptodev_sym_capability_idx cap_idx;
3275 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3276 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3277 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3281 /* Create KASUMI session */
3282 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3283 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3284 RTE_CRYPTO_CIPHER_KASUMI_F8,
3285 tdata->key.data, tdata->key.len,
3286 tdata->cipher_iv.len);
3290 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3292 /* Clear mbuf payload */
3293 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3294 rte_pktmbuf_tailroom(ut_params->ibuf));
3296 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3297 /* Append data which is padded to a multiple */
3298 /* of the algorithms block size */
3299 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3300 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3301 ciphertext_pad_len);
3302 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3304 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3306 /* Create KASUMI operation */
3307 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3308 tdata->cipher_iv.len,
3309 tdata->ciphertext.len,
3310 tdata->validCipherOffsetInBits.len);
3314 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3316 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3318 ut_params->obuf = ut_params->op->sym->m_dst;
3319 if (ut_params->obuf)
3320 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3322 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3324 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3326 const uint8_t *reference_plaintext = tdata->plaintext.data +
3327 (tdata->validCipherOffsetInBits.len >> 3);
3329 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3331 reference_plaintext,
3332 tdata->validCipherLenInBits.len,
3333 "KASUMI Plaintext data not as expected");
3338 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3340 struct crypto_testsuite_params *ts_params = &testsuite_params;
3341 struct crypto_unittest_params *ut_params = &unittest_params;
3344 uint8_t *plaintext, *ciphertext;
3345 unsigned plaintext_pad_len;
3346 unsigned plaintext_len;
3348 /* Verify the capabilities */
3349 struct rte_cryptodev_sym_capability_idx cap_idx;
3350 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3351 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3352 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3356 /* Create SNOW 3G session */
3357 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3358 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3359 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3360 tdata->key.data, tdata->key.len,
3361 tdata->cipher_iv.len);
3365 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3367 /* Clear mbuf payload */
3368 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3369 rte_pktmbuf_tailroom(ut_params->ibuf));
3371 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3372 /* Append data which is padded to a multiple of */
3373 /* the algorithms block size */
3374 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3375 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3377 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3379 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3381 /* Create SNOW 3G operation */
3382 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3383 tdata->cipher_iv.len,
3384 tdata->validCipherLenInBits.len,
3389 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3391 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3393 ut_params->obuf = ut_params->op->sym->m_dst;
3394 if (ut_params->obuf)
3395 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3397 ciphertext = plaintext;
3399 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3402 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3404 tdata->ciphertext.data,
3405 tdata->validDataLenInBits.len,
3406 "SNOW 3G Ciphertext data not as expected");
3412 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3414 struct crypto_testsuite_params *ts_params = &testsuite_params;
3415 struct crypto_unittest_params *ut_params = &unittest_params;
3416 uint8_t *plaintext, *ciphertext;
3419 unsigned plaintext_pad_len;
3420 unsigned plaintext_len;
3422 /* Verify the capabilities */
3423 struct rte_cryptodev_sym_capability_idx cap_idx;
3424 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3425 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3426 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3430 /* Create SNOW 3G session */
3431 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3432 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3433 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3434 tdata->key.data, tdata->key.len,
3435 tdata->cipher_iv.len);
3439 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3440 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3442 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3443 "Failed to allocate input buffer in mempool");
3444 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3445 "Failed to allocate output buffer in mempool");
3447 /* Clear mbuf payload */
3448 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3449 rte_pktmbuf_tailroom(ut_params->ibuf));
3451 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3452 /* Append data which is padded to a multiple of */
3453 /* the algorithms block size */
3454 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3455 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3457 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3458 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3460 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3462 /* Create SNOW 3G operation */
3463 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3464 tdata->cipher_iv.len,
3465 tdata->validCipherLenInBits.len,
3470 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3472 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3474 ut_params->obuf = ut_params->op->sym->m_dst;
3475 if (ut_params->obuf)
3476 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3478 ciphertext = plaintext;
3480 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3483 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3485 tdata->ciphertext.data,
3486 tdata->validDataLenInBits.len,
3487 "SNOW 3G Ciphertext data not as expected");
3492 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3494 struct crypto_testsuite_params *ts_params = &testsuite_params;
3495 struct crypto_unittest_params *ut_params = &unittest_params;
3498 unsigned int plaintext_pad_len;
3499 unsigned int plaintext_len;
3500 uint8_t buffer[10000];
3501 const uint8_t *ciphertext;
3503 struct rte_cryptodev_info dev_info;
3505 /* Verify the capabilities */
3506 struct rte_cryptodev_sym_capability_idx cap_idx;
3507 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3508 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3509 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3513 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3515 uint64_t feat_flags = dev_info.feature_flags;
3517 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3518 printf("Device doesn't support out-of-place scatter-gather "
3519 "in both input and output mbufs. "
3524 /* Create SNOW 3G session */
3525 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3526 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3527 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3528 tdata->key.data, tdata->key.len,
3529 tdata->cipher_iv.len);
3533 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3534 /* Append data which is padded to a multiple of */
3535 /* the algorithms block size */
3536 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3538 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3539 plaintext_pad_len, 10, 0);
3540 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3541 plaintext_pad_len, 3, 0);
3543 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3544 "Failed to allocate input buffer in mempool");
3545 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3546 "Failed to allocate output buffer in mempool");
3548 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3550 /* Create SNOW 3G operation */
3551 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3552 tdata->cipher_iv.len,
3553 tdata->validCipherLenInBits.len,
3558 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3560 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3562 ut_params->obuf = ut_params->op->sym->m_dst;
3563 if (ut_params->obuf)
3564 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3565 plaintext_len, buffer);
3567 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3568 plaintext_len, buffer);
3570 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3573 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3575 tdata->ciphertext.data,
3576 tdata->validDataLenInBits.len,
3577 "SNOW 3G Ciphertext data not as expected");
3582 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3584 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3586 uint8_t curr_byte, prev_byte;
3587 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3588 uint8_t lower_byte_mask = (1 << offset) - 1;
3591 prev_byte = buffer[0];
3592 buffer[0] >>= offset;
3594 for (i = 1; i < length_in_bytes; i++) {
3595 curr_byte = buffer[i];
3596 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3597 (curr_byte >> offset);
3598 prev_byte = curr_byte;
3603 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3605 struct crypto_testsuite_params *ts_params = &testsuite_params;
3606 struct crypto_unittest_params *ut_params = &unittest_params;
3607 uint8_t *plaintext, *ciphertext;
3609 uint32_t plaintext_len;
3610 uint32_t plaintext_pad_len;
3611 uint8_t extra_offset = 4;
3612 uint8_t *expected_ciphertext_shifted;
3613 struct rte_cryptodev_info dev_info;
3615 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3616 uint64_t feat_flags = dev_info.feature_flags;
3618 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3619 ((tdata->validDataLenInBits.len % 8) != 0)) {
3620 printf("Device doesn't support NON-Byte Aligned Data.\n");
3624 /* Verify the capabilities */
3625 struct rte_cryptodev_sym_capability_idx cap_idx;
3626 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3627 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3628 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3632 /* Create SNOW 3G session */
3633 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3634 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3635 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3636 tdata->key.data, tdata->key.len,
3637 tdata->cipher_iv.len);
3641 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3642 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3644 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3645 "Failed to allocate input buffer in mempool");
3646 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3647 "Failed to allocate output buffer in mempool");
3649 /* Clear mbuf payload */
3650 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3651 rte_pktmbuf_tailroom(ut_params->ibuf));
3653 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3655 * Append data which is padded to a
3656 * multiple of the algorithms block size
3658 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3660 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3663 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3665 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3666 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3668 #ifdef RTE_APP_TEST_DEBUG
3669 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3671 /* Create SNOW 3G operation */
3672 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3673 tdata->cipher_iv.len,
3674 tdata->validCipherLenInBits.len,
3679 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3681 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3683 ut_params->obuf = ut_params->op->sym->m_dst;
3684 if (ut_params->obuf)
3685 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3687 ciphertext = plaintext;
3689 #ifdef RTE_APP_TEST_DEBUG
3690 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3693 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3695 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3696 "failed to reserve memory for ciphertext shifted\n");
3698 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3699 ceil_byte_length(tdata->ciphertext.len));
3700 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3703 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3705 expected_ciphertext_shifted,
3706 tdata->validDataLenInBits.len,
3708 "SNOW 3G Ciphertext data not as expected");
3712 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3714 struct crypto_testsuite_params *ts_params = &testsuite_params;
3715 struct crypto_unittest_params *ut_params = &unittest_params;
3719 uint8_t *plaintext, *ciphertext;
3720 unsigned ciphertext_pad_len;
3721 unsigned ciphertext_len;
3723 /* Verify the capabilities */
3724 struct rte_cryptodev_sym_capability_idx cap_idx;
3725 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3726 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3727 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3731 /* Create SNOW 3G session */
3732 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3733 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3734 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3735 tdata->key.data, tdata->key.len,
3736 tdata->cipher_iv.len);
3740 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3742 /* Clear mbuf payload */
3743 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3744 rte_pktmbuf_tailroom(ut_params->ibuf));
3746 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3747 /* Append data which is padded to a multiple of */
3748 /* the algorithms block size */
3749 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3750 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3751 ciphertext_pad_len);
3752 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3754 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3756 /* Create SNOW 3G operation */
3757 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3758 tdata->cipher_iv.len,
3759 tdata->validCipherLenInBits.len,
3760 tdata->cipher.offset_bits);
3764 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3766 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3767 ut_params->obuf = ut_params->op->sym->m_dst;
3768 if (ut_params->obuf)
3769 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3771 plaintext = ciphertext;
3773 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3776 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3777 tdata->plaintext.data,
3778 tdata->validDataLenInBits.len,
3779 "SNOW 3G Plaintext data not as expected");
3783 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3785 struct crypto_testsuite_params *ts_params = &testsuite_params;
3786 struct crypto_unittest_params *ut_params = &unittest_params;
3790 uint8_t *plaintext, *ciphertext;
3791 unsigned ciphertext_pad_len;
3792 unsigned ciphertext_len;
3794 /* Verify the capabilities */
3795 struct rte_cryptodev_sym_capability_idx cap_idx;
3796 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3797 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3798 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3802 /* Create SNOW 3G session */
3803 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3804 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3805 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3806 tdata->key.data, tdata->key.len,
3807 tdata->cipher_iv.len);
3811 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3812 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3814 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3815 "Failed to allocate input buffer");
3816 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3817 "Failed to allocate output buffer");
3819 /* Clear mbuf payload */
3820 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3821 rte_pktmbuf_tailroom(ut_params->ibuf));
3823 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3824 rte_pktmbuf_tailroom(ut_params->obuf));
3826 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3827 /* Append data which is padded to a multiple of */
3828 /* the algorithms block size */
3829 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3830 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3831 ciphertext_pad_len);
3832 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3833 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3835 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3837 /* Create SNOW 3G operation */
3838 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3839 tdata->cipher_iv.len,
3840 tdata->validCipherLenInBits.len,
3845 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3847 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3848 ut_params->obuf = ut_params->op->sym->m_dst;
3849 if (ut_params->obuf)
3850 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3852 plaintext = ciphertext;
3854 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3857 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3858 tdata->plaintext.data,
3859 tdata->validDataLenInBits.len,
3860 "SNOW 3G Plaintext data not as expected");
3865 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3867 struct crypto_testsuite_params *ts_params = &testsuite_params;
3868 struct crypto_unittest_params *ut_params = &unittest_params;
3872 uint8_t *plaintext, *ciphertext;
3873 unsigned int plaintext_pad_len;
3874 unsigned int plaintext_len;
3876 struct rte_cryptodev_info dev_info;
3877 struct rte_cryptodev_sym_capability_idx cap_idx;
3879 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3880 uint64_t feat_flags = dev_info.feature_flags;
3882 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3883 ((tdata->validAuthLenInBits.len % 8 != 0) ||
3884 (tdata->validDataLenInBits.len % 8 != 0))) {
3885 printf("Device doesn't support NON-Byte Aligned Data.\n");
3889 /* Check if device supports ZUC EEA3 */
3890 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3891 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3893 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3897 /* Check if device supports ZUC EIA3 */
3898 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3899 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3901 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3905 /* Create ZUC session */
3906 retval = create_zuc_cipher_auth_encrypt_generate_session(
3907 ts_params->valid_devs[0],
3911 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3913 /* clear mbuf payload */
3914 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3915 rte_pktmbuf_tailroom(ut_params->ibuf));
3917 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3918 /* Append data which is padded to a multiple of */
3919 /* the algorithms block size */
3920 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3921 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3923 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3925 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3927 /* Create ZUC operation */
3928 retval = create_zuc_cipher_hash_generate_operation(tdata);
3932 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3934 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3935 ut_params->obuf = ut_params->op->sym->m_src;
3936 if (ut_params->obuf)
3937 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3939 ciphertext = plaintext;
3941 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3943 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3945 tdata->ciphertext.data,
3946 tdata->validDataLenInBits.len,
3947 "ZUC Ciphertext data not as expected");
3949 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3950 + plaintext_pad_len;
3953 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3957 "ZUC Generated auth tag not as expected");
3962 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3964 struct crypto_testsuite_params *ts_params = &testsuite_params;
3965 struct crypto_unittest_params *ut_params = &unittest_params;
3969 uint8_t *plaintext, *ciphertext;
3970 unsigned plaintext_pad_len;
3971 unsigned plaintext_len;
3973 /* Verify the capabilities */
3974 struct rte_cryptodev_sym_capability_idx cap_idx;
3975 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3976 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3977 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3980 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3981 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3982 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3986 /* Create SNOW 3G session */
3987 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3988 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3989 RTE_CRYPTO_AUTH_OP_GENERATE,
3990 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3991 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3992 tdata->key.data, tdata->key.len,
3993 tdata->auth_iv.len, tdata->digest.len,
3994 tdata->cipher_iv.len);
3997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3999 /* clear mbuf payload */
4000 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4001 rte_pktmbuf_tailroom(ut_params->ibuf));
4003 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4004 /* Append data which is padded to a multiple of */
4005 /* the algorithms block size */
4006 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4007 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4009 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4011 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4013 /* Create SNOW 3G operation */
4014 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4015 tdata->digest.len, tdata->auth_iv.data,
4017 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4018 tdata->cipher_iv.data, tdata->cipher_iv.len,
4019 tdata->validCipherLenInBits.len,
4021 tdata->validAuthLenInBits.len,
4027 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4029 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4030 ut_params->obuf = ut_params->op->sym->m_src;
4031 if (ut_params->obuf)
4032 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4034 ciphertext = plaintext;
4036 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4038 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4040 tdata->ciphertext.data,
4041 tdata->validDataLenInBits.len,
4042 "SNOW 3G Ciphertext data not as expected");
4044 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4045 + plaintext_pad_len;
4048 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4051 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4052 "SNOW 3G Generated auth tag not as expected");
4057 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4058 uint8_t op_mode, uint8_t verify)
4060 struct crypto_testsuite_params *ts_params = &testsuite_params;
4061 struct crypto_unittest_params *ut_params = &unittest_params;
4065 uint8_t *plaintext = NULL, *ciphertext = NULL;
4066 unsigned int plaintext_pad_len;
4067 unsigned int plaintext_len;
4068 unsigned int ciphertext_pad_len;
4069 unsigned int ciphertext_len;
4071 struct rte_cryptodev_info dev_info;
4073 /* Verify the capabilities */
4074 struct rte_cryptodev_sym_capability_idx cap_idx;
4075 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4076 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4077 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4080 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4081 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4082 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4086 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4088 uint64_t feat_flags = dev_info.feature_flags;
4090 if (op_mode == OUT_OF_PLACE) {
4091 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4092 printf("Device doesn't support digest encrypted.\n");
4097 /* Create SNOW 3G session */
4098 retval = create_wireless_algo_auth_cipher_session(
4099 ts_params->valid_devs[0],
4100 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4101 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4102 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4103 : RTE_CRYPTO_AUTH_OP_GENERATE),
4104 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4105 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4106 tdata->key.data, tdata->key.len,
4107 tdata->auth_iv.len, tdata->digest.len,
4108 tdata->cipher_iv.len);
4113 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4114 if (op_mode == OUT_OF_PLACE)
4115 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4117 /* clear mbuf payload */
4118 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4119 rte_pktmbuf_tailroom(ut_params->ibuf));
4120 if (op_mode == OUT_OF_PLACE)
4121 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4122 rte_pktmbuf_tailroom(ut_params->obuf));
4124 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4125 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4126 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4127 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4130 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4131 ciphertext_pad_len);
4132 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4133 if (op_mode == OUT_OF_PLACE)
4134 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4135 debug_hexdump(stdout, "ciphertext:", ciphertext,
4138 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4140 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4141 if (op_mode == OUT_OF_PLACE)
4142 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4143 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4146 /* Create SNOW 3G operation */
4147 retval = create_wireless_algo_auth_cipher_operation(
4148 tdata->digest.data, tdata->digest.len,
4149 tdata->cipher_iv.data, tdata->cipher_iv.len,
4150 tdata->auth_iv.data, tdata->auth_iv.len,
4151 (tdata->digest.offset_bytes == 0 ?
4152 (verify ? ciphertext_pad_len : plaintext_pad_len)
4153 : tdata->digest.offset_bytes),
4154 tdata->validCipherLenInBits.len,
4155 tdata->cipher.offset_bits,
4156 tdata->validAuthLenInBits.len,
4157 tdata->auth.offset_bits,
4158 op_mode, 0, verify);
4163 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4166 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4168 ut_params->obuf = (op_mode == IN_PLACE ?
4169 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4172 if (ut_params->obuf)
4173 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4176 plaintext = ciphertext +
4177 (tdata->cipher.offset_bits >> 3);
4179 debug_hexdump(stdout, "plaintext:", plaintext,
4180 (tdata->plaintext.len >> 3) - tdata->digest.len);
4181 debug_hexdump(stdout, "plaintext expected:",
4182 tdata->plaintext.data,
4183 (tdata->plaintext.len >> 3) - tdata->digest.len);
4185 if (ut_params->obuf)
4186 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4189 ciphertext = plaintext;
4191 debug_hexdump(stdout, "ciphertext:", ciphertext,
4193 debug_hexdump(stdout, "ciphertext expected:",
4194 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4196 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4197 + (tdata->digest.offset_bytes == 0 ?
4198 plaintext_pad_len : tdata->digest.offset_bytes);
4200 debug_hexdump(stdout, "digest:", ut_params->digest,
4202 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4208 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4210 tdata->plaintext.data,
4211 tdata->plaintext.len >> 3,
4212 "SNOW 3G Plaintext data not as expected");
4214 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4216 tdata->ciphertext.data,
4217 tdata->validDataLenInBits.len,
4218 "SNOW 3G Ciphertext data not as expected");
4220 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4223 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4224 "SNOW 3G Generated auth tag not as expected");
4230 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4231 uint8_t op_mode, uint8_t verify)
4233 struct crypto_testsuite_params *ts_params = &testsuite_params;
4234 struct crypto_unittest_params *ut_params = &unittest_params;
4238 const uint8_t *plaintext = NULL;
4239 const uint8_t *ciphertext = NULL;
4240 const uint8_t *digest = NULL;
4241 unsigned int plaintext_pad_len;
4242 unsigned int plaintext_len;
4243 unsigned int ciphertext_pad_len;
4244 unsigned int ciphertext_len;
4245 uint8_t buffer[10000];
4246 uint8_t digest_buffer[10000];
4248 struct rte_cryptodev_info dev_info;
4250 /* Verify the capabilities */
4251 struct rte_cryptodev_sym_capability_idx cap_idx;
4252 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4253 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4254 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4257 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4258 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4259 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4263 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4265 uint64_t feat_flags = dev_info.feature_flags;
4267 if (op_mode == IN_PLACE) {
4268 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4269 printf("Device doesn't support in-place scatter-gather "
4270 "in both input and output mbufs.\n");
4274 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4275 printf("Device doesn't support out-of-place scatter-gather "
4276 "in both input and output mbufs.\n");
4279 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4280 printf("Device doesn't support digest encrypted.\n");
4285 /* Create SNOW 3G session */
4286 retval = create_wireless_algo_auth_cipher_session(
4287 ts_params->valid_devs[0],
4288 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4289 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4290 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4291 : RTE_CRYPTO_AUTH_OP_GENERATE),
4292 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4293 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4294 tdata->key.data, tdata->key.len,
4295 tdata->auth_iv.len, tdata->digest.len,
4296 tdata->cipher_iv.len);
4301 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4302 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4303 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4304 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4306 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4307 plaintext_pad_len, 15, 0);
4308 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4309 "Failed to allocate input buffer in mempool");
4311 if (op_mode == OUT_OF_PLACE) {
4312 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4313 plaintext_pad_len, 15, 0);
4314 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4315 "Failed to allocate output buffer in mempool");
4319 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4320 tdata->ciphertext.data);
4321 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4322 ciphertext_len, buffer);
4323 debug_hexdump(stdout, "ciphertext:", ciphertext,
4326 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4327 tdata->plaintext.data);
4328 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4329 plaintext_len, buffer);
4330 debug_hexdump(stdout, "plaintext:", plaintext,
4333 memset(buffer, 0, sizeof(buffer));
4335 /* Create SNOW 3G operation */
4336 retval = create_wireless_algo_auth_cipher_operation(
4337 tdata->digest.data, tdata->digest.len,
4338 tdata->cipher_iv.data, tdata->cipher_iv.len,
4339 tdata->auth_iv.data, tdata->auth_iv.len,
4340 (tdata->digest.offset_bytes == 0 ?
4341 (verify ? ciphertext_pad_len : plaintext_pad_len)
4342 : tdata->digest.offset_bytes),
4343 tdata->validCipherLenInBits.len,
4344 tdata->cipher.offset_bits,
4345 tdata->validAuthLenInBits.len,
4346 tdata->auth.offset_bits,
4347 op_mode, 1, verify);
4352 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4357 ut_params->obuf = (op_mode == IN_PLACE ?
4358 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4361 if (ut_params->obuf)
4362 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4363 plaintext_len, buffer);
4365 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4366 plaintext_len, buffer);
4368 debug_hexdump(stdout, "plaintext:", plaintext,
4369 (tdata->plaintext.len >> 3) - tdata->digest.len);
4370 debug_hexdump(stdout, "plaintext expected:",
4371 tdata->plaintext.data,
4372 (tdata->plaintext.len >> 3) - tdata->digest.len);
4374 if (ut_params->obuf)
4375 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4376 ciphertext_len, buffer);
4378 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4379 ciphertext_len, buffer);
4381 debug_hexdump(stdout, "ciphertext:", ciphertext,
4383 debug_hexdump(stdout, "ciphertext expected:",
4384 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4386 if (ut_params->obuf)
4387 digest = rte_pktmbuf_read(ut_params->obuf,
4388 (tdata->digest.offset_bytes == 0 ?
4389 plaintext_pad_len : tdata->digest.offset_bytes),
4390 tdata->digest.len, digest_buffer);
4392 digest = rte_pktmbuf_read(ut_params->ibuf,
4393 (tdata->digest.offset_bytes == 0 ?
4394 plaintext_pad_len : tdata->digest.offset_bytes),
4395 tdata->digest.len, digest_buffer);
4397 debug_hexdump(stdout, "digest:", digest,
4399 debug_hexdump(stdout, "digest expected:",
4400 tdata->digest.data, tdata->digest.len);
4405 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4407 tdata->plaintext.data,
4408 tdata->plaintext.len >> 3,
4409 "SNOW 3G Plaintext data not as expected");
4411 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4413 tdata->ciphertext.data,
4414 tdata->validDataLenInBits.len,
4415 "SNOW 3G Ciphertext data not as expected");
4417 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4420 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4421 "SNOW 3G Generated auth tag not as expected");
4427 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4428 uint8_t op_mode, uint8_t verify)
4430 struct crypto_testsuite_params *ts_params = &testsuite_params;
4431 struct crypto_unittest_params *ut_params = &unittest_params;
4435 uint8_t *plaintext = NULL, *ciphertext = NULL;
4436 unsigned int plaintext_pad_len;
4437 unsigned int plaintext_len;
4438 unsigned int ciphertext_pad_len;
4439 unsigned int ciphertext_len;
4441 struct rte_cryptodev_info dev_info;
4443 /* Verify the capabilities */
4444 struct rte_cryptodev_sym_capability_idx cap_idx;
4445 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4446 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4447 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4450 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4451 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4452 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4456 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4458 uint64_t feat_flags = dev_info.feature_flags;
4460 if (op_mode == OUT_OF_PLACE) {
4461 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4462 printf("Device doesn't support digest encrypted.\n");
4467 /* Create KASUMI session */
4468 retval = create_wireless_algo_auth_cipher_session(
4469 ts_params->valid_devs[0],
4470 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4471 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4472 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4473 : RTE_CRYPTO_AUTH_OP_GENERATE),
4474 RTE_CRYPTO_AUTH_KASUMI_F9,
4475 RTE_CRYPTO_CIPHER_KASUMI_F8,
4476 tdata->key.data, tdata->key.len,
4477 0, tdata->digest.len,
4478 tdata->cipher_iv.len);
4483 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4484 if (op_mode == OUT_OF_PLACE)
4485 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4487 /* clear mbuf payload */
4488 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4489 rte_pktmbuf_tailroom(ut_params->ibuf));
4490 if (op_mode == OUT_OF_PLACE)
4491 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4492 rte_pktmbuf_tailroom(ut_params->obuf));
4494 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4495 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4496 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4497 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4500 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4501 ciphertext_pad_len);
4502 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4503 if (op_mode == OUT_OF_PLACE)
4504 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4505 debug_hexdump(stdout, "ciphertext:", ciphertext,
4508 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4510 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4511 if (op_mode == OUT_OF_PLACE)
4512 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4513 debug_hexdump(stdout, "plaintext:", plaintext,
4517 /* Create KASUMI operation */
4518 retval = create_wireless_algo_auth_cipher_operation(
4519 tdata->digest.data, tdata->digest.len,
4520 tdata->cipher_iv.data, tdata->cipher_iv.len,
4522 (tdata->digest.offset_bytes == 0 ?
4523 (verify ? ciphertext_pad_len : plaintext_pad_len)
4524 : tdata->digest.offset_bytes),
4525 tdata->validCipherLenInBits.len,
4526 tdata->validCipherOffsetInBits.len,
4527 tdata->validAuthLenInBits.len,
4529 op_mode, 0, verify);
4534 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4537 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4539 ut_params->obuf = (op_mode == IN_PLACE ?
4540 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4544 if (ut_params->obuf)
4545 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4548 plaintext = ciphertext;
4550 debug_hexdump(stdout, "plaintext:", plaintext,
4551 (tdata->plaintext.len >> 3) - tdata->digest.len);
4552 debug_hexdump(stdout, "plaintext expected:",
4553 tdata->plaintext.data,
4554 (tdata->plaintext.len >> 3) - tdata->digest.len);
4556 if (ut_params->obuf)
4557 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4560 ciphertext = plaintext;
4562 debug_hexdump(stdout, "ciphertext:", ciphertext,
4564 debug_hexdump(stdout, "ciphertext expected:",
4565 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4567 ut_params->digest = rte_pktmbuf_mtod(
4568 ut_params->obuf, uint8_t *) +
4569 (tdata->digest.offset_bytes == 0 ?
4570 plaintext_pad_len : tdata->digest.offset_bytes);
4572 debug_hexdump(stdout, "digest:", ut_params->digest,
4574 debug_hexdump(stdout, "digest expected:",
4575 tdata->digest.data, tdata->digest.len);
4580 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4582 tdata->plaintext.data,
4583 tdata->plaintext.len >> 3,
4584 "KASUMI Plaintext data not as expected");
4586 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4588 tdata->ciphertext.data,
4589 tdata->ciphertext.len >> 3,
4590 "KASUMI Ciphertext data not as expected");
4592 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4595 DIGEST_BYTE_LENGTH_KASUMI_F9,
4596 "KASUMI Generated auth tag not as expected");
4602 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4603 uint8_t op_mode, uint8_t verify)
4605 struct crypto_testsuite_params *ts_params = &testsuite_params;
4606 struct crypto_unittest_params *ut_params = &unittest_params;
4610 const uint8_t *plaintext = NULL;
4611 const uint8_t *ciphertext = NULL;
4612 const uint8_t *digest = NULL;
4613 unsigned int plaintext_pad_len;
4614 unsigned int plaintext_len;
4615 unsigned int ciphertext_pad_len;
4616 unsigned int ciphertext_len;
4617 uint8_t buffer[10000];
4618 uint8_t digest_buffer[10000];
4620 struct rte_cryptodev_info dev_info;
4622 /* Verify the capabilities */
4623 struct rte_cryptodev_sym_capability_idx cap_idx;
4624 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4625 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4626 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4629 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4630 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4631 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4635 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4637 uint64_t feat_flags = dev_info.feature_flags;
4639 if (op_mode == IN_PLACE) {
4640 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4641 printf("Device doesn't support in-place scatter-gather "
4642 "in both input and output mbufs.\n");
4646 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4647 printf("Device doesn't support out-of-place scatter-gather "
4648 "in both input and output mbufs.\n");
4651 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4652 printf("Device doesn't support digest encrypted.\n");
4657 /* Create KASUMI session */
4658 retval = create_wireless_algo_auth_cipher_session(
4659 ts_params->valid_devs[0],
4660 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4661 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4662 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4663 : RTE_CRYPTO_AUTH_OP_GENERATE),
4664 RTE_CRYPTO_AUTH_KASUMI_F9,
4665 RTE_CRYPTO_CIPHER_KASUMI_F8,
4666 tdata->key.data, tdata->key.len,
4667 0, tdata->digest.len,
4668 tdata->cipher_iv.len);
4673 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4674 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4675 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4676 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4678 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4679 plaintext_pad_len, 15, 0);
4680 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4681 "Failed to allocate input buffer in mempool");
4683 if (op_mode == OUT_OF_PLACE) {
4684 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4685 plaintext_pad_len, 15, 0);
4686 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4687 "Failed to allocate output buffer in mempool");
4691 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4692 tdata->ciphertext.data);
4693 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4694 ciphertext_len, buffer);
4695 debug_hexdump(stdout, "ciphertext:", ciphertext,
4698 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4699 tdata->plaintext.data);
4700 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4701 plaintext_len, buffer);
4702 debug_hexdump(stdout, "plaintext:", plaintext,
4705 memset(buffer, 0, sizeof(buffer));
4707 /* Create KASUMI operation */
4708 retval = create_wireless_algo_auth_cipher_operation(
4709 tdata->digest.data, tdata->digest.len,
4710 tdata->cipher_iv.data, tdata->cipher_iv.len,
4712 (tdata->digest.offset_bytes == 0 ?
4713 (verify ? ciphertext_pad_len : plaintext_pad_len)
4714 : tdata->digest.offset_bytes),
4715 tdata->validCipherLenInBits.len,
4716 tdata->validCipherOffsetInBits.len,
4717 tdata->validAuthLenInBits.len,
4719 op_mode, 1, verify);
4724 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4727 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4729 ut_params->obuf = (op_mode == IN_PLACE ?
4730 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4733 if (ut_params->obuf)
4734 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4735 plaintext_len, buffer);
4737 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4738 plaintext_len, buffer);
4740 debug_hexdump(stdout, "plaintext:", plaintext,
4741 (tdata->plaintext.len >> 3) - tdata->digest.len);
4742 debug_hexdump(stdout, "plaintext expected:",
4743 tdata->plaintext.data,
4744 (tdata->plaintext.len >> 3) - tdata->digest.len);
4746 if (ut_params->obuf)
4747 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4748 ciphertext_len, buffer);
4750 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4751 ciphertext_len, buffer);
4753 debug_hexdump(stdout, "ciphertext:", ciphertext,
4755 debug_hexdump(stdout, "ciphertext expected:",
4756 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4758 if (ut_params->obuf)
4759 digest = rte_pktmbuf_read(ut_params->obuf,
4760 (tdata->digest.offset_bytes == 0 ?
4761 plaintext_pad_len : tdata->digest.offset_bytes),
4762 tdata->digest.len, digest_buffer);
4764 digest = rte_pktmbuf_read(ut_params->ibuf,
4765 (tdata->digest.offset_bytes == 0 ?
4766 plaintext_pad_len : tdata->digest.offset_bytes),
4767 tdata->digest.len, digest_buffer);
4769 debug_hexdump(stdout, "digest:", digest,
4771 debug_hexdump(stdout, "digest expected:",
4772 tdata->digest.data, tdata->digest.len);
4777 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4779 tdata->plaintext.data,
4780 tdata->plaintext.len >> 3,
4781 "KASUMI Plaintext data not as expected");
4783 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4785 tdata->ciphertext.data,
4786 tdata->validDataLenInBits.len,
4787 "KASUMI Ciphertext data not as expected");
4789 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4792 DIGEST_BYTE_LENGTH_KASUMI_F9,
4793 "KASUMI Generated auth tag not as expected");
4799 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4801 struct crypto_testsuite_params *ts_params = &testsuite_params;
4802 struct crypto_unittest_params *ut_params = &unittest_params;
4806 uint8_t *plaintext, *ciphertext;
4807 unsigned plaintext_pad_len;
4808 unsigned plaintext_len;
4810 /* Verify the capabilities */
4811 struct rte_cryptodev_sym_capability_idx cap_idx;
4812 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4813 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4814 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4817 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4818 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4819 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4823 /* Create KASUMI session */
4824 retval = create_wireless_algo_cipher_auth_session(
4825 ts_params->valid_devs[0],
4826 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4827 RTE_CRYPTO_AUTH_OP_GENERATE,
4828 RTE_CRYPTO_AUTH_KASUMI_F9,
4829 RTE_CRYPTO_CIPHER_KASUMI_F8,
4830 tdata->key.data, tdata->key.len,
4831 0, tdata->digest.len,
4832 tdata->cipher_iv.len);
4836 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4838 /* clear mbuf payload */
4839 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4840 rte_pktmbuf_tailroom(ut_params->ibuf));
4842 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4843 /* Append data which is padded to a multiple of */
4844 /* the algorithms block size */
4845 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4846 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4848 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4850 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4852 /* Create KASUMI operation */
4853 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4854 tdata->digest.len, NULL, 0,
4855 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4856 tdata->cipher_iv.data, tdata->cipher_iv.len,
4857 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4858 tdata->validCipherOffsetInBits.len,
4859 tdata->validAuthLenInBits.len,
4865 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4867 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4869 if (ut_params->op->sym->m_dst)
4870 ut_params->obuf = ut_params->op->sym->m_dst;
4872 ut_params->obuf = ut_params->op->sym->m_src;
4874 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4875 tdata->validCipherOffsetInBits.len >> 3);
4877 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4878 + plaintext_pad_len;
4880 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4881 (tdata->validCipherOffsetInBits.len >> 3);
4883 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4885 reference_ciphertext,
4886 tdata->validCipherLenInBits.len,
4887 "KASUMI Ciphertext data not as expected");
4890 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4893 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4894 "KASUMI Generated auth tag not as expected");
4899 test_zuc_encryption(const struct wireless_test_data *tdata)
4901 struct crypto_testsuite_params *ts_params = &testsuite_params;
4902 struct crypto_unittest_params *ut_params = &unittest_params;
4905 uint8_t *plaintext, *ciphertext;
4906 unsigned plaintext_pad_len;
4907 unsigned plaintext_len;
4909 struct rte_cryptodev_sym_capability_idx cap_idx;
4911 /* Check if device supports ZUC EEA3 */
4912 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4913 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4915 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4919 /* Create ZUC session */
4920 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4921 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4922 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4923 tdata->key.data, tdata->key.len,
4924 tdata->cipher_iv.len);
4928 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4930 /* Clear mbuf payload */
4931 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4932 rte_pktmbuf_tailroom(ut_params->ibuf));
4934 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4935 /* Append data which is padded to a multiple */
4936 /* of the algorithms block size */
4937 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4938 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4940 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4942 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4944 /* Create ZUC operation */
4945 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4946 tdata->cipher_iv.len,
4947 tdata->plaintext.len,
4952 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4954 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4956 ut_params->obuf = ut_params->op->sym->m_dst;
4957 if (ut_params->obuf)
4958 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4960 ciphertext = plaintext;
4962 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4965 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4967 tdata->ciphertext.data,
4968 tdata->validCipherLenInBits.len,
4969 "ZUC Ciphertext data not as expected");
4974 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4976 struct crypto_testsuite_params *ts_params = &testsuite_params;
4977 struct crypto_unittest_params *ut_params = &unittest_params;
4981 unsigned int plaintext_pad_len;
4982 unsigned int plaintext_len;
4983 const uint8_t *ciphertext;
4984 uint8_t ciphertext_buffer[2048];
4985 struct rte_cryptodev_info dev_info;
4987 struct rte_cryptodev_sym_capability_idx cap_idx;
4989 /* Check if device supports ZUC EEA3 */
4990 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4991 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4993 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4997 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4999 uint64_t feat_flags = dev_info.feature_flags;
5001 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5002 printf("Device doesn't support in-place scatter-gather. "
5007 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5009 /* Append data which is padded to a multiple */
5010 /* of the algorithms block size */
5011 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5013 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5014 plaintext_pad_len, 10, 0);
5016 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5017 tdata->plaintext.data);
5019 /* Create ZUC session */
5020 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5021 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5022 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5023 tdata->key.data, tdata->key.len,
5024 tdata->cipher_iv.len);
5028 /* Clear mbuf payload */
5030 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5032 /* Create ZUC operation */
5033 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5034 tdata->cipher_iv.len, tdata->plaintext.len,
5039 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5041 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5043 ut_params->obuf = ut_params->op->sym->m_dst;
5044 if (ut_params->obuf)
5045 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5046 0, plaintext_len, ciphertext_buffer);
5048 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5049 0, plaintext_len, ciphertext_buffer);
5052 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5055 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5057 tdata->ciphertext.data,
5058 tdata->validCipherLenInBits.len,
5059 "ZUC Ciphertext data not as expected");
5065 test_zuc_authentication(const struct wireless_test_data *tdata)
5067 struct crypto_testsuite_params *ts_params = &testsuite_params;
5068 struct crypto_unittest_params *ut_params = &unittest_params;
5071 unsigned plaintext_pad_len;
5072 unsigned plaintext_len;
5075 struct rte_cryptodev_sym_capability_idx cap_idx;
5076 struct rte_cryptodev_info dev_info;
5078 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5079 uint64_t feat_flags = dev_info.feature_flags;
5081 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5082 (tdata->validAuthLenInBits.len % 8 != 0)) {
5083 printf("Device doesn't support NON-Byte Aligned Data.\n");
5087 /* Check if device supports ZUC EIA3 */
5088 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5089 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5091 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5095 /* Create ZUC session */
5096 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5097 tdata->key.data, tdata->key.len,
5098 tdata->auth_iv.len, tdata->digest.len,
5099 RTE_CRYPTO_AUTH_OP_GENERATE,
5100 RTE_CRYPTO_AUTH_ZUC_EIA3);
5104 /* alloc mbuf and set payload */
5105 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5107 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5108 rte_pktmbuf_tailroom(ut_params->ibuf));
5110 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5111 /* Append data which is padded to a multiple of */
5112 /* the algorithms block size */
5113 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5114 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5116 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5118 /* Create ZUC operation */
5119 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5120 tdata->auth_iv.data, tdata->auth_iv.len,
5121 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5122 tdata->validAuthLenInBits.len,
5127 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5129 ut_params->obuf = ut_params->op->sym->m_src;
5130 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5131 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5132 + plaintext_pad_len;
5135 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5139 "ZUC Generated auth tag not as expected");
5145 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5146 uint8_t op_mode, uint8_t verify)
5148 struct crypto_testsuite_params *ts_params = &testsuite_params;
5149 struct crypto_unittest_params *ut_params = &unittest_params;
5153 uint8_t *plaintext = NULL, *ciphertext = NULL;
5154 unsigned int plaintext_pad_len;
5155 unsigned int plaintext_len;
5156 unsigned int ciphertext_pad_len;
5157 unsigned int ciphertext_len;
5159 struct rte_cryptodev_info dev_info;
5160 struct rte_cryptodev_sym_capability_idx cap_idx;
5162 /* Check if device supports ZUC EIA3 */
5163 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5164 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5166 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5170 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5172 uint64_t feat_flags = dev_info.feature_flags;
5174 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5175 printf("Device doesn't support digest encrypted.\n");
5178 if (op_mode == IN_PLACE) {
5179 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5180 printf("Device doesn't support in-place scatter-gather "
5181 "in both input and output mbufs.\n");
5185 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5186 printf("Device doesn't support out-of-place scatter-gather "
5187 "in both input and output mbufs.\n");
5192 /* Create ZUC session */
5193 retval = create_wireless_algo_auth_cipher_session(
5194 ts_params->valid_devs[0],
5195 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5196 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5197 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5198 : RTE_CRYPTO_AUTH_OP_GENERATE),
5199 RTE_CRYPTO_AUTH_ZUC_EIA3,
5200 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5201 tdata->key.data, tdata->key.len,
5202 tdata->auth_iv.len, tdata->digest.len,
5203 tdata->cipher_iv.len);
5208 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5209 if (op_mode == OUT_OF_PLACE)
5210 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5212 /* clear mbuf payload */
5213 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5214 rte_pktmbuf_tailroom(ut_params->ibuf));
5215 if (op_mode == OUT_OF_PLACE)
5216 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5217 rte_pktmbuf_tailroom(ut_params->obuf));
5219 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5220 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5221 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5222 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5225 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5226 ciphertext_pad_len);
5227 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5228 if (op_mode == OUT_OF_PLACE)
5229 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5230 debug_hexdump(stdout, "ciphertext:", ciphertext,
5233 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5235 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5236 if (op_mode == OUT_OF_PLACE)
5237 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5238 debug_hexdump(stdout, "plaintext:", plaintext,
5242 /* Create ZUC operation */
5243 retval = create_wireless_algo_auth_cipher_operation(
5244 tdata->digest.data, tdata->digest.len,
5245 tdata->cipher_iv.data, tdata->cipher_iv.len,
5246 tdata->auth_iv.data, tdata->auth_iv.len,
5247 (tdata->digest.offset_bytes == 0 ?
5248 (verify ? ciphertext_pad_len : plaintext_pad_len)
5249 : tdata->digest.offset_bytes),
5250 tdata->validCipherLenInBits.len,
5251 tdata->validCipherOffsetInBits.len,
5252 tdata->validAuthLenInBits.len,
5254 op_mode, 0, verify);
5259 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5262 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5264 ut_params->obuf = (op_mode == IN_PLACE ?
5265 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5269 if (ut_params->obuf)
5270 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5273 plaintext = ciphertext;
5275 debug_hexdump(stdout, "plaintext:", plaintext,
5276 (tdata->plaintext.len >> 3) - tdata->digest.len);
5277 debug_hexdump(stdout, "plaintext expected:",
5278 tdata->plaintext.data,
5279 (tdata->plaintext.len >> 3) - tdata->digest.len);
5281 if (ut_params->obuf)
5282 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5285 ciphertext = plaintext;
5287 debug_hexdump(stdout, "ciphertext:", ciphertext,
5289 debug_hexdump(stdout, "ciphertext expected:",
5290 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5292 ut_params->digest = rte_pktmbuf_mtod(
5293 ut_params->obuf, uint8_t *) +
5294 (tdata->digest.offset_bytes == 0 ?
5295 plaintext_pad_len : tdata->digest.offset_bytes);
5297 debug_hexdump(stdout, "digest:", ut_params->digest,
5299 debug_hexdump(stdout, "digest expected:",
5300 tdata->digest.data, tdata->digest.len);
5305 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5307 tdata->plaintext.data,
5308 tdata->plaintext.len >> 3,
5309 "ZUC Plaintext data not as expected");
5311 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5313 tdata->ciphertext.data,
5314 tdata->ciphertext.len >> 3,
5315 "ZUC Ciphertext data not as expected");
5317 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5320 DIGEST_BYTE_LENGTH_KASUMI_F9,
5321 "ZUC Generated auth tag not as expected");
5327 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5328 uint8_t op_mode, uint8_t verify)
5330 struct crypto_testsuite_params *ts_params = &testsuite_params;
5331 struct crypto_unittest_params *ut_params = &unittest_params;
5335 const uint8_t *plaintext = NULL;
5336 const uint8_t *ciphertext = NULL;
5337 const uint8_t *digest = NULL;
5338 unsigned int plaintext_pad_len;
5339 unsigned int plaintext_len;
5340 unsigned int ciphertext_pad_len;
5341 unsigned int ciphertext_len;
5342 uint8_t buffer[10000];
5343 uint8_t digest_buffer[10000];
5345 struct rte_cryptodev_info dev_info;
5346 struct rte_cryptodev_sym_capability_idx cap_idx;
5348 /* Check if device supports ZUC EIA3 */
5349 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5350 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5352 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5356 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5358 uint64_t feat_flags = dev_info.feature_flags;
5360 if (op_mode == IN_PLACE) {
5361 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5362 printf("Device doesn't support in-place scatter-gather "
5363 "in both input and output mbufs.\n");
5367 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5368 printf("Device doesn't support out-of-place scatter-gather "
5369 "in both input and output mbufs.\n");
5372 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5373 printf("Device doesn't support digest encrypted.\n");
5378 /* Create ZUC session */
5379 retval = create_wireless_algo_auth_cipher_session(
5380 ts_params->valid_devs[0],
5381 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5382 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5383 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5384 : RTE_CRYPTO_AUTH_OP_GENERATE),
5385 RTE_CRYPTO_AUTH_ZUC_EIA3,
5386 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5387 tdata->key.data, tdata->key.len,
5388 tdata->auth_iv.len, tdata->digest.len,
5389 tdata->cipher_iv.len);
5394 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5395 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5396 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5397 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5399 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5400 plaintext_pad_len, 15, 0);
5401 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5402 "Failed to allocate input buffer in mempool");
5404 if (op_mode == OUT_OF_PLACE) {
5405 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5406 plaintext_pad_len, 15, 0);
5407 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5408 "Failed to allocate output buffer in mempool");
5412 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5413 tdata->ciphertext.data);
5414 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5415 ciphertext_len, buffer);
5416 debug_hexdump(stdout, "ciphertext:", ciphertext,
5419 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5420 tdata->plaintext.data);
5421 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5422 plaintext_len, buffer);
5423 debug_hexdump(stdout, "plaintext:", plaintext,
5426 memset(buffer, 0, sizeof(buffer));
5428 /* Create ZUC operation */
5429 retval = create_wireless_algo_auth_cipher_operation(
5430 tdata->digest.data, tdata->digest.len,
5431 tdata->cipher_iv.data, tdata->cipher_iv.len,
5433 (tdata->digest.offset_bytes == 0 ?
5434 (verify ? ciphertext_pad_len : plaintext_pad_len)
5435 : tdata->digest.offset_bytes),
5436 tdata->validCipherLenInBits.len,
5437 tdata->validCipherOffsetInBits.len,
5438 tdata->validAuthLenInBits.len,
5440 op_mode, 1, verify);
5445 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5448 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5450 ut_params->obuf = (op_mode == IN_PLACE ?
5451 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5454 if (ut_params->obuf)
5455 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5456 plaintext_len, buffer);
5458 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5459 plaintext_len, buffer);
5461 debug_hexdump(stdout, "plaintext:", plaintext,
5462 (tdata->plaintext.len >> 3) - tdata->digest.len);
5463 debug_hexdump(stdout, "plaintext expected:",
5464 tdata->plaintext.data,
5465 (tdata->plaintext.len >> 3) - tdata->digest.len);
5467 if (ut_params->obuf)
5468 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5469 ciphertext_len, buffer);
5471 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5472 ciphertext_len, buffer);
5474 debug_hexdump(stdout, "ciphertext:", ciphertext,
5476 debug_hexdump(stdout, "ciphertext expected:",
5477 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5479 if (ut_params->obuf)
5480 digest = rte_pktmbuf_read(ut_params->obuf,
5481 (tdata->digest.offset_bytes == 0 ?
5482 plaintext_pad_len : tdata->digest.offset_bytes),
5483 tdata->digest.len, digest_buffer);
5485 digest = rte_pktmbuf_read(ut_params->ibuf,
5486 (tdata->digest.offset_bytes == 0 ?
5487 plaintext_pad_len : tdata->digest.offset_bytes),
5488 tdata->digest.len, digest_buffer);
5490 debug_hexdump(stdout, "digest:", digest,
5492 debug_hexdump(stdout, "digest expected:",
5493 tdata->digest.data, tdata->digest.len);
5498 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5500 tdata->plaintext.data,
5501 tdata->plaintext.len >> 3,
5502 "ZUC Plaintext data not as expected");
5504 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5506 tdata->ciphertext.data,
5507 tdata->validDataLenInBits.len,
5508 "ZUC Ciphertext data not as expected");
5510 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5513 DIGEST_BYTE_LENGTH_KASUMI_F9,
5514 "ZUC Generated auth tag not as expected");
5520 test_kasumi_encryption_test_case_1(void)
5522 return test_kasumi_encryption(&kasumi_test_case_1);
5526 test_kasumi_encryption_test_case_1_sgl(void)
5528 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5532 test_kasumi_encryption_test_case_1_oop(void)
5534 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5538 test_kasumi_encryption_test_case_1_oop_sgl(void)
5540 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5544 test_kasumi_encryption_test_case_2(void)
5546 return test_kasumi_encryption(&kasumi_test_case_2);
5550 test_kasumi_encryption_test_case_3(void)
5552 return test_kasumi_encryption(&kasumi_test_case_3);
5556 test_kasumi_encryption_test_case_4(void)
5558 return test_kasumi_encryption(&kasumi_test_case_4);
5562 test_kasumi_encryption_test_case_5(void)
5564 return test_kasumi_encryption(&kasumi_test_case_5);
5568 test_kasumi_decryption_test_case_1(void)
5570 return test_kasumi_decryption(&kasumi_test_case_1);
5574 test_kasumi_decryption_test_case_1_oop(void)
5576 return test_kasumi_decryption_oop(&kasumi_test_case_1);
5580 test_kasumi_decryption_test_case_2(void)
5582 return test_kasumi_decryption(&kasumi_test_case_2);
5586 test_kasumi_decryption_test_case_3(void)
5588 return test_kasumi_decryption(&kasumi_test_case_3);
5592 test_kasumi_decryption_test_case_4(void)
5594 return test_kasumi_decryption(&kasumi_test_case_4);
5598 test_kasumi_decryption_test_case_5(void)
5600 return test_kasumi_decryption(&kasumi_test_case_5);
5603 test_snow3g_encryption_test_case_1(void)
5605 return test_snow3g_encryption(&snow3g_test_case_1);
5609 test_snow3g_encryption_test_case_1_oop(void)
5611 return test_snow3g_encryption_oop(&snow3g_test_case_1);
5615 test_snow3g_encryption_test_case_1_oop_sgl(void)
5617 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5622 test_snow3g_encryption_test_case_1_offset_oop(void)
5624 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5628 test_snow3g_encryption_test_case_2(void)
5630 return test_snow3g_encryption(&snow3g_test_case_2);
5634 test_snow3g_encryption_test_case_3(void)
5636 return test_snow3g_encryption(&snow3g_test_case_3);
5640 test_snow3g_encryption_test_case_4(void)
5642 return test_snow3g_encryption(&snow3g_test_case_4);
5646 test_snow3g_encryption_test_case_5(void)
5648 return test_snow3g_encryption(&snow3g_test_case_5);
5652 test_snow3g_decryption_test_case_1(void)
5654 return test_snow3g_decryption(&snow3g_test_case_1);
5658 test_snow3g_decryption_test_case_1_oop(void)
5660 return test_snow3g_decryption_oop(&snow3g_test_case_1);
5664 test_snow3g_decryption_test_case_2(void)
5666 return test_snow3g_decryption(&snow3g_test_case_2);
5670 test_snow3g_decryption_test_case_3(void)
5672 return test_snow3g_decryption(&snow3g_test_case_3);
5676 test_snow3g_decryption_test_case_4(void)
5678 return test_snow3g_decryption(&snow3g_test_case_4);
5682 test_snow3g_decryption_test_case_5(void)
5684 return test_snow3g_decryption(&snow3g_test_case_5);
5688 * Function prepares snow3g_hash_test_data from snow3g_test_data.
5689 * Pattern digest from snow3g_test_data must be allocated as
5690 * 4 last bytes in plaintext.
5693 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5694 struct snow3g_hash_test_data *output)
5696 if ((pattern != NULL) && (output != NULL)) {
5697 output->key.len = pattern->key.len;
5699 memcpy(output->key.data,
5700 pattern->key.data, pattern->key.len);
5702 output->auth_iv.len = pattern->auth_iv.len;
5704 memcpy(output->auth_iv.data,
5705 pattern->auth_iv.data, pattern->auth_iv.len);
5707 output->plaintext.len = pattern->plaintext.len;
5709 memcpy(output->plaintext.data,
5710 pattern->plaintext.data, pattern->plaintext.len >> 3);
5712 output->digest.len = pattern->digest.len;
5714 memcpy(output->digest.data,
5715 &pattern->plaintext.data[pattern->digest.offset_bytes],
5716 pattern->digest.len);
5718 output->validAuthLenInBits.len =
5719 pattern->validAuthLenInBits.len;
5724 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5727 test_snow3g_decryption_with_digest_test_case_1(void)
5729 struct snow3g_hash_test_data snow3g_hash_data;
5732 * Function prepare data for hash veryfication test case.
5733 * Digest is allocated in 4 last bytes in plaintext, pattern.
5735 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5737 return test_snow3g_decryption(&snow3g_test_case_7) &
5738 test_snow3g_authentication_verify(&snow3g_hash_data);
5742 test_snow3g_cipher_auth_test_case_1(void)
5744 return test_snow3g_cipher_auth(&snow3g_test_case_3);
5748 test_snow3g_auth_cipher_test_case_1(void)
5750 return test_snow3g_auth_cipher(
5751 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5755 test_snow3g_auth_cipher_test_case_2(void)
5757 return test_snow3g_auth_cipher(
5758 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5762 test_snow3g_auth_cipher_test_case_2_oop(void)
5764 return test_snow3g_auth_cipher(
5765 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5769 test_snow3g_auth_cipher_part_digest_enc(void)
5771 return test_snow3g_auth_cipher(
5772 &snow3g_auth_cipher_partial_digest_encryption,
5777 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5779 return test_snow3g_auth_cipher(
5780 &snow3g_auth_cipher_partial_digest_encryption,
5785 test_snow3g_auth_cipher_test_case_3_sgl(void)
5787 return test_snow3g_auth_cipher_sgl(
5788 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
5792 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
5794 return test_snow3g_auth_cipher_sgl(
5795 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
5799 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
5801 return test_snow3g_auth_cipher_sgl(
5802 &snow3g_auth_cipher_partial_digest_encryption,
5807 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
5809 return test_snow3g_auth_cipher_sgl(
5810 &snow3g_auth_cipher_partial_digest_encryption,
5815 test_snow3g_auth_cipher_verify_test_case_1(void)
5817 return test_snow3g_auth_cipher(
5818 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5822 test_snow3g_auth_cipher_verify_test_case_2(void)
5824 return test_snow3g_auth_cipher(
5825 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5829 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5831 return test_snow3g_auth_cipher(
5832 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5836 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5838 return test_snow3g_auth_cipher(
5839 &snow3g_auth_cipher_partial_digest_encryption,
5844 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5846 return test_snow3g_auth_cipher(
5847 &snow3g_auth_cipher_partial_digest_encryption,
5852 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
5854 return test_snow3g_auth_cipher_sgl(
5855 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
5859 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
5861 return test_snow3g_auth_cipher_sgl(
5862 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
5866 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
5868 return test_snow3g_auth_cipher_sgl(
5869 &snow3g_auth_cipher_partial_digest_encryption,
5874 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
5876 return test_snow3g_auth_cipher_sgl(
5877 &snow3g_auth_cipher_partial_digest_encryption,
5882 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5884 return test_snow3g_auth_cipher(
5885 &snow3g_test_case_7, IN_PLACE, 0);
5889 test_kasumi_auth_cipher_test_case_1(void)
5891 return test_kasumi_auth_cipher(
5892 &kasumi_test_case_3, IN_PLACE, 0);
5896 test_kasumi_auth_cipher_test_case_2(void)
5898 return test_kasumi_auth_cipher(
5899 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5903 test_kasumi_auth_cipher_test_case_2_oop(void)
5905 return test_kasumi_auth_cipher(
5906 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5910 test_kasumi_auth_cipher_test_case_2_sgl(void)
5912 return test_kasumi_auth_cipher_sgl(
5913 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5917 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
5919 return test_kasumi_auth_cipher_sgl(
5920 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5924 test_kasumi_auth_cipher_verify_test_case_1(void)
5926 return test_kasumi_auth_cipher(
5927 &kasumi_test_case_3, IN_PLACE, 1);
5931 test_kasumi_auth_cipher_verify_test_case_2(void)
5933 return test_kasumi_auth_cipher(
5934 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5938 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5940 return test_kasumi_auth_cipher(
5941 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5945 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
5947 return test_kasumi_auth_cipher_sgl(
5948 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5952 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
5954 return test_kasumi_auth_cipher_sgl(
5955 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5959 test_kasumi_cipher_auth_test_case_1(void)
5961 return test_kasumi_cipher_auth(&kasumi_test_case_6);
5965 test_zuc_encryption_test_case_1(void)
5967 return test_zuc_encryption(&zuc_test_case_cipher_193b);
5971 test_zuc_encryption_test_case_2(void)
5973 return test_zuc_encryption(&zuc_test_case_cipher_800b);
5977 test_zuc_encryption_test_case_3(void)
5979 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5983 test_zuc_encryption_test_case_4(void)
5985 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5989 test_zuc_encryption_test_case_5(void)
5991 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5995 test_zuc_encryption_test_case_6_sgl(void)
5997 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6001 test_zuc_hash_generate_test_case_1(void)
6003 return test_zuc_authentication(&zuc_test_case_auth_1b);
6007 test_zuc_hash_generate_test_case_2(void)
6009 return test_zuc_authentication(&zuc_test_case_auth_90b);
6013 test_zuc_hash_generate_test_case_3(void)
6015 return test_zuc_authentication(&zuc_test_case_auth_577b);
6019 test_zuc_hash_generate_test_case_4(void)
6021 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6025 test_zuc_hash_generate_test_case_5(void)
6027 return test_zuc_authentication(&zuc_test_auth_5670b);
6031 test_zuc_hash_generate_test_case_6(void)
6033 return test_zuc_authentication(&zuc_test_case_auth_128b);
6037 test_zuc_hash_generate_test_case_7(void)
6039 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6043 test_zuc_hash_generate_test_case_8(void)
6045 return test_zuc_authentication(&zuc_test_case_auth_584b);
6049 test_zuc_cipher_auth_test_case_1(void)
6051 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6055 test_zuc_cipher_auth_test_case_2(void)
6057 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6061 test_zuc_auth_cipher_test_case_1(void)
6063 return test_zuc_auth_cipher(
6064 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6068 test_zuc_auth_cipher_test_case_1_oop(void)
6070 return test_zuc_auth_cipher(
6071 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6075 test_zuc_auth_cipher_test_case_1_sgl(void)
6077 return test_zuc_auth_cipher_sgl(
6078 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6082 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6084 return test_zuc_auth_cipher_sgl(
6085 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6089 test_zuc_auth_cipher_verify_test_case_1(void)
6091 return test_zuc_auth_cipher(
6092 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6096 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6098 return test_zuc_auth_cipher(
6099 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6103 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6105 return test_zuc_auth_cipher_sgl(
6106 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6110 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6112 return test_zuc_auth_cipher_sgl(
6113 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6117 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6119 uint8_t dev_id = testsuite_params.valid_devs[0];
6121 struct rte_cryptodev_sym_capability_idx cap_idx;
6123 /* Check if device supports particular cipher algorithm */
6124 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6125 cap_idx.algo.cipher = tdata->cipher_algo;
6126 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6129 /* Check if device supports particular hash algorithm */
6130 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6131 cap_idx.algo.auth = tdata->auth_algo;
6132 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6139 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6140 uint8_t op_mode, uint8_t verify)
6142 struct crypto_testsuite_params *ts_params = &testsuite_params;
6143 struct crypto_unittest_params *ut_params = &unittest_params;
6147 uint8_t *plaintext = NULL, *ciphertext = NULL;
6148 unsigned int plaintext_pad_len;
6149 unsigned int plaintext_len;
6150 unsigned int ciphertext_pad_len;
6151 unsigned int ciphertext_len;
6153 struct rte_cryptodev_info dev_info;
6154 struct rte_crypto_op *op;
6156 /* Check if device supports particular algorithms separately */
6157 if (test_mixed_check_if_unsupported(tdata))
6160 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6162 uint64_t feat_flags = dev_info.feature_flags;
6164 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6165 printf("Device doesn't support digest encrypted.\n");
6169 /* Create the session */
6171 retval = create_wireless_algo_cipher_auth_session(
6172 ts_params->valid_devs[0],
6173 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6174 RTE_CRYPTO_AUTH_OP_VERIFY,
6177 tdata->auth_key.data, tdata->auth_key.len,
6178 tdata->auth_iv.len, tdata->digest_enc.len,
6179 tdata->cipher_iv.len);
6181 retval = create_wireless_algo_auth_cipher_session(
6182 ts_params->valid_devs[0],
6183 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6184 RTE_CRYPTO_AUTH_OP_GENERATE,
6187 tdata->auth_key.data, tdata->auth_key.len,
6188 tdata->auth_iv.len, tdata->digest_enc.len,
6189 tdata->cipher_iv.len);
6193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6194 if (op_mode == OUT_OF_PLACE)
6195 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6197 /* clear mbuf payload */
6198 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6199 rte_pktmbuf_tailroom(ut_params->ibuf));
6200 if (op_mode == OUT_OF_PLACE)
6201 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6202 rte_pktmbuf_tailroom(ut_params->obuf));
6204 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6205 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6206 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6207 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6210 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6211 ciphertext_pad_len);
6212 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6213 if (op_mode == OUT_OF_PLACE)
6214 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6215 debug_hexdump(stdout, "ciphertext:", ciphertext,
6218 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6220 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6221 if (op_mode == OUT_OF_PLACE)
6222 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6223 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6226 /* Create the operation */
6227 retval = create_wireless_algo_auth_cipher_operation(
6228 tdata->digest_enc.data, tdata->digest_enc.len,
6229 tdata->cipher_iv.data, tdata->cipher_iv.len,
6230 tdata->auth_iv.data, tdata->auth_iv.len,
6231 (tdata->digest_enc.offset == 0 ?
6233 : tdata->digest_enc.offset),
6234 tdata->validCipherLen.len_bits,
6235 tdata->cipher.offset_bits,
6236 tdata->validAuthLen.len_bits,
6237 tdata->auth.offset_bits,
6238 op_mode, 0, verify);
6243 op = process_crypto_request(ts_params->valid_devs[0],
6246 /* Check if the op failed because the device doesn't */
6247 /* support this particular combination of algorithms */
6248 if (op == NULL && ut_params->op->status ==
6249 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6250 printf("Device doesn't support this mixed combination. "
6256 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6258 ut_params->obuf = (op_mode == IN_PLACE ?
6259 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6262 if (ut_params->obuf)
6263 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6266 plaintext = ciphertext +
6267 (tdata->cipher.offset_bits >> 3);
6269 debug_hexdump(stdout, "plaintext:", plaintext,
6270 tdata->plaintext.len_bits >> 3);
6271 debug_hexdump(stdout, "plaintext expected:",
6272 tdata->plaintext.data,
6273 tdata->plaintext.len_bits >> 3);
6275 if (ut_params->obuf)
6276 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6279 ciphertext = plaintext;
6281 debug_hexdump(stdout, "ciphertext:", ciphertext,
6283 debug_hexdump(stdout, "ciphertext expected:",
6284 tdata->ciphertext.data,
6285 tdata->ciphertext.len_bits >> 3);
6287 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6288 + (tdata->digest_enc.offset == 0 ?
6289 plaintext_pad_len : tdata->digest_enc.offset);
6291 debug_hexdump(stdout, "digest:", ut_params->digest,
6292 tdata->digest_enc.len);
6293 debug_hexdump(stdout, "digest expected:",
6294 tdata->digest_enc.data,
6295 tdata->digest_enc.len);
6300 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6302 tdata->plaintext.data,
6303 tdata->plaintext.len_bits >> 3,
6304 "Plaintext data not as expected");
6306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6308 tdata->ciphertext.data,
6309 tdata->validDataLen.len_bits,
6310 "Ciphertext data not as expected");
6312 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6314 tdata->digest_enc.data,
6315 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6316 "Generated auth tag not as expected");
6319 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6320 "crypto op processing failed");
6326 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6327 uint8_t op_mode, uint8_t verify)
6329 struct crypto_testsuite_params *ts_params = &testsuite_params;
6330 struct crypto_unittest_params *ut_params = &unittest_params;
6334 const uint8_t *plaintext = NULL;
6335 const uint8_t *ciphertext = NULL;
6336 const uint8_t *digest = NULL;
6337 unsigned int plaintext_pad_len;
6338 unsigned int plaintext_len;
6339 unsigned int ciphertext_pad_len;
6340 unsigned int ciphertext_len;
6341 uint8_t buffer[10000];
6342 uint8_t digest_buffer[10000];
6344 struct rte_cryptodev_info dev_info;
6345 struct rte_crypto_op *op;
6347 /* Check if device supports particular algorithms */
6348 if (test_mixed_check_if_unsupported(tdata))
6351 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6353 uint64_t feat_flags = dev_info.feature_flags;
6355 if (op_mode == IN_PLACE) {
6356 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6357 printf("Device doesn't support in-place scatter-gather "
6358 "in both input and output mbufs.\n");
6362 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6363 printf("Device doesn't support out-of-place scatter-gather "
6364 "in both input and output mbufs.\n");
6367 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6368 printf("Device doesn't support digest encrypted.\n");
6373 /* Create the session */
6375 retval = create_wireless_algo_cipher_auth_session(
6376 ts_params->valid_devs[0],
6377 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6378 RTE_CRYPTO_AUTH_OP_VERIFY,
6381 tdata->auth_key.data, tdata->auth_key.len,
6382 tdata->auth_iv.len, tdata->digest_enc.len,
6383 tdata->cipher_iv.len);
6385 retval = create_wireless_algo_auth_cipher_session(
6386 ts_params->valid_devs[0],
6387 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6388 RTE_CRYPTO_AUTH_OP_GENERATE,
6391 tdata->auth_key.data, tdata->auth_key.len,
6392 tdata->auth_iv.len, tdata->digest_enc.len,
6393 tdata->cipher_iv.len);
6397 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6398 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6399 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6402 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6403 ciphertext_pad_len, 15, 0);
6404 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6405 "Failed to allocate input buffer in mempool");
6407 if (op_mode == OUT_OF_PLACE) {
6408 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6409 plaintext_pad_len, 15, 0);
6410 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6411 "Failed to allocate output buffer in mempool");
6415 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6416 tdata->ciphertext.data);
6417 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6418 ciphertext_len, buffer);
6419 debug_hexdump(stdout, "ciphertext:", ciphertext,
6422 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6423 tdata->plaintext.data);
6424 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6425 plaintext_len, buffer);
6426 debug_hexdump(stdout, "plaintext:", plaintext,
6429 memset(buffer, 0, sizeof(buffer));
6431 /* Create the operation */
6432 retval = create_wireless_algo_auth_cipher_operation(
6433 tdata->digest_enc.data, tdata->digest_enc.len,
6434 tdata->cipher_iv.data, tdata->cipher_iv.len,
6435 tdata->auth_iv.data, tdata->auth_iv.len,
6436 (tdata->digest_enc.offset == 0 ?
6438 : tdata->digest_enc.offset),
6439 tdata->validCipherLen.len_bits,
6440 tdata->cipher.offset_bits,
6441 tdata->validAuthLen.len_bits,
6442 tdata->auth.offset_bits,
6443 op_mode, 1, verify);
6448 op = process_crypto_request(ts_params->valid_devs[0],
6451 /* Check if the op failed because the device doesn't */
6452 /* support this particular combination of algorithms */
6453 if (op == NULL && ut_params->op->status ==
6454 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6455 printf("Device doesn't support this mixed combination. "
6462 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6464 ut_params->obuf = (op_mode == IN_PLACE ?
6465 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6468 if (ut_params->obuf)
6469 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6470 plaintext_len, buffer);
6472 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6473 plaintext_len, buffer);
6475 debug_hexdump(stdout, "plaintext:", plaintext,
6476 (tdata->plaintext.len_bits >> 3) -
6477 tdata->digest_enc.len);
6478 debug_hexdump(stdout, "plaintext expected:",
6479 tdata->plaintext.data,
6480 (tdata->plaintext.len_bits >> 3) -
6481 tdata->digest_enc.len);
6483 if (ut_params->obuf)
6484 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6485 ciphertext_len, buffer);
6487 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6488 ciphertext_len, buffer);
6490 debug_hexdump(stdout, "ciphertext:", ciphertext,
6492 debug_hexdump(stdout, "ciphertext expected:",
6493 tdata->ciphertext.data,
6494 tdata->ciphertext.len_bits >> 3);
6496 if (ut_params->obuf)
6497 digest = rte_pktmbuf_read(ut_params->obuf,
6498 (tdata->digest_enc.offset == 0 ?
6500 tdata->digest_enc.offset),
6501 tdata->digest_enc.len, digest_buffer);
6503 digest = rte_pktmbuf_read(ut_params->ibuf,
6504 (tdata->digest_enc.offset == 0 ?
6506 tdata->digest_enc.offset),
6507 tdata->digest_enc.len, digest_buffer);
6509 debug_hexdump(stdout, "digest:", digest,
6510 tdata->digest_enc.len);
6511 debug_hexdump(stdout, "digest expected:",
6512 tdata->digest_enc.data, tdata->digest_enc.len);
6517 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6519 tdata->plaintext.data,
6520 tdata->plaintext.len_bits >> 3,
6521 "Plaintext data not as expected");
6523 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6525 tdata->ciphertext.data,
6526 tdata->validDataLen.len_bits,
6527 "Ciphertext data not as expected");
6528 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6530 tdata->digest_enc.data,
6531 tdata->digest_enc.len,
6532 "Generated auth tag not as expected");
6535 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6536 "crypto op processing failed");
6541 /** AUTH AES CMAC + CIPHER AES CTR */
6544 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6546 return test_mixed_auth_cipher(
6547 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6551 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6553 return test_mixed_auth_cipher(
6554 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6558 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6560 return test_mixed_auth_cipher_sgl(
6561 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6565 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6567 return test_mixed_auth_cipher_sgl(
6568 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6572 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6574 return test_mixed_auth_cipher(
6575 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6579 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6581 return test_mixed_auth_cipher(
6582 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6586 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6588 return test_mixed_auth_cipher_sgl(
6589 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6593 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6595 return test_mixed_auth_cipher_sgl(
6596 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6599 /** MIXED AUTH + CIPHER */
6602 test_auth_zuc_cipher_snow_test_case_1(void)
6604 return test_mixed_auth_cipher(
6605 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6609 test_verify_auth_zuc_cipher_snow_test_case_1(void)
6611 return test_mixed_auth_cipher(
6612 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6616 test_auth_aes_cmac_cipher_snow_test_case_1(void)
6618 return test_mixed_auth_cipher(
6619 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6623 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
6625 return test_mixed_auth_cipher(
6626 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6630 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
6632 return test_mixed_auth_cipher(
6633 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6637 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
6639 return test_mixed_auth_cipher(
6640 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6644 test_auth_snow_cipher_aes_ctr_test_case_1(void)
6646 return test_mixed_auth_cipher(
6647 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6651 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
6653 return test_mixed_auth_cipher(
6654 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6658 test_auth_snow_cipher_zuc_test_case_1(void)
6660 return test_mixed_auth_cipher(
6661 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6665 test_verify_auth_snow_cipher_zuc_test_case_1(void)
6667 return test_mixed_auth_cipher(
6668 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6672 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
6674 return test_mixed_auth_cipher(
6675 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6679 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
6681 return test_mixed_auth_cipher(
6682 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6686 test_auth_null_cipher_snow_test_case_1(void)
6688 return test_mixed_auth_cipher(
6689 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
6693 test_verify_auth_null_cipher_snow_test_case_1(void)
6695 return test_mixed_auth_cipher(
6696 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
6700 test_auth_null_cipher_zuc_test_case_1(void)
6702 return test_mixed_auth_cipher(
6703 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
6707 test_verify_auth_null_cipher_zuc_test_case_1(void)
6709 return test_mixed_auth_cipher(
6710 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
6714 test_auth_snow_cipher_null_test_case_1(void)
6716 return test_mixed_auth_cipher(
6717 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6721 test_verify_auth_snow_cipher_null_test_case_1(void)
6723 return test_mixed_auth_cipher(
6724 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6728 test_auth_zuc_cipher_null_test_case_1(void)
6730 return test_mixed_auth_cipher(
6731 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6735 test_verify_auth_zuc_cipher_null_test_case_1(void)
6737 return test_mixed_auth_cipher(
6738 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6742 test_auth_null_cipher_aes_ctr_test_case_1(void)
6744 return test_mixed_auth_cipher(
6745 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6749 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
6751 return test_mixed_auth_cipher(
6752 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6756 test_auth_aes_cmac_cipher_null_test_case_1(void)
6758 return test_mixed_auth_cipher(
6759 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
6763 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
6765 return test_mixed_auth_cipher(
6766 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
6769 /* ***** AEAD algorithm Tests ***** */
6772 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6773 enum rte_crypto_aead_operation op,
6774 const uint8_t *key, const uint8_t key_len,
6775 const uint16_t aad_len, const uint8_t auth_len,
6778 uint8_t aead_key[key_len];
6780 struct crypto_testsuite_params *ts_params = &testsuite_params;
6781 struct crypto_unittest_params *ut_params = &unittest_params;
6783 memcpy(aead_key, key, key_len);
6785 /* Setup AEAD Parameters */
6786 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6787 ut_params->aead_xform.next = NULL;
6788 ut_params->aead_xform.aead.algo = algo;
6789 ut_params->aead_xform.aead.op = op;
6790 ut_params->aead_xform.aead.key.data = aead_key;
6791 ut_params->aead_xform.aead.key.length = key_len;
6792 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6793 ut_params->aead_xform.aead.iv.length = iv_len;
6794 ut_params->aead_xform.aead.digest_length = auth_len;
6795 ut_params->aead_xform.aead.aad_length = aad_len;
6797 debug_hexdump(stdout, "key:", key, key_len);
6799 /* Create Crypto session*/
6800 ut_params->sess = rte_cryptodev_sym_session_create(
6801 ts_params->session_mpool);
6803 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6804 &ut_params->aead_xform,
6805 ts_params->session_priv_mpool);
6807 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6813 create_aead_xform(struct rte_crypto_op *op,
6814 enum rte_crypto_aead_algorithm algo,
6815 enum rte_crypto_aead_operation aead_op,
6816 uint8_t *key, const uint8_t key_len,
6817 const uint8_t aad_len, const uint8_t auth_len,
6820 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6821 "failed to allocate space for crypto transform");
6823 struct rte_crypto_sym_op *sym_op = op->sym;
6825 /* Setup AEAD Parameters */
6826 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6827 sym_op->xform->next = NULL;
6828 sym_op->xform->aead.algo = algo;
6829 sym_op->xform->aead.op = aead_op;
6830 sym_op->xform->aead.key.data = key;
6831 sym_op->xform->aead.key.length = key_len;
6832 sym_op->xform->aead.iv.offset = IV_OFFSET;
6833 sym_op->xform->aead.iv.length = iv_len;
6834 sym_op->xform->aead.digest_length = auth_len;
6835 sym_op->xform->aead.aad_length = aad_len;
6837 debug_hexdump(stdout, "key:", key, key_len);
6843 create_aead_operation(enum rte_crypto_aead_operation op,
6844 const struct aead_test_data *tdata)
6846 struct crypto_testsuite_params *ts_params = &testsuite_params;
6847 struct crypto_unittest_params *ut_params = &unittest_params;
6849 uint8_t *plaintext, *ciphertext;
6850 unsigned int aad_pad_len, plaintext_pad_len;
6852 /* Generate Crypto op data structure */
6853 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6854 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6855 TEST_ASSERT_NOT_NULL(ut_params->op,
6856 "Failed to allocate symmetric crypto operation struct");
6858 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6860 /* Append aad data */
6861 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6862 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6863 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6865 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6866 "no room to append aad");
6868 sym_op->aead.aad.phys_addr =
6869 rte_pktmbuf_iova(ut_params->ibuf);
6870 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6871 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6872 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6875 /* Append IV at the end of the crypto operation*/
6876 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6877 uint8_t *, IV_OFFSET);
6879 /* Copy IV 1 byte after the IV pointer, according to the API */
6880 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6881 debug_hexdump(stdout, "iv:", iv_ptr,
6884 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6885 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6887 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6888 "no room to append aad");
6890 sym_op->aead.aad.phys_addr =
6891 rte_pktmbuf_iova(ut_params->ibuf);
6892 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6893 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6896 /* Append IV at the end of the crypto operation*/
6897 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6898 uint8_t *, IV_OFFSET);
6900 if (tdata->iv.len == 0) {
6901 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
6902 debug_hexdump(stdout, "iv:", iv_ptr,
6905 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6906 debug_hexdump(stdout, "iv:", iv_ptr,
6911 /* Append plaintext/ciphertext */
6912 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6913 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6914 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6916 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6918 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6919 debug_hexdump(stdout, "plaintext:", plaintext,
6920 tdata->plaintext.len);
6922 if (ut_params->obuf) {
6923 ciphertext = (uint8_t *)rte_pktmbuf_append(
6925 plaintext_pad_len + aad_pad_len);
6926 TEST_ASSERT_NOT_NULL(ciphertext,
6927 "no room to append ciphertext");
6929 memset(ciphertext + aad_pad_len, 0,
6930 tdata->ciphertext.len);
6933 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6934 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6936 TEST_ASSERT_NOT_NULL(ciphertext,
6937 "no room to append ciphertext");
6939 memcpy(ciphertext, tdata->ciphertext.data,
6940 tdata->ciphertext.len);
6941 debug_hexdump(stdout, "ciphertext:", ciphertext,
6942 tdata->ciphertext.len);
6944 if (ut_params->obuf) {
6945 plaintext = (uint8_t *)rte_pktmbuf_append(
6947 plaintext_pad_len + aad_pad_len);
6948 TEST_ASSERT_NOT_NULL(plaintext,
6949 "no room to append plaintext");
6951 memset(plaintext + aad_pad_len, 0,
6952 tdata->plaintext.len);
6956 /* Append digest data */
6957 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6958 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6959 ut_params->obuf ? ut_params->obuf :
6961 tdata->auth_tag.len);
6962 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6963 "no room to append digest");
6964 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6965 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6966 ut_params->obuf ? ut_params->obuf :
6971 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6972 ut_params->ibuf, tdata->auth_tag.len);
6973 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6974 "no room to append digest");
6975 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6977 plaintext_pad_len + aad_pad_len);
6979 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6980 tdata->auth_tag.len);
6981 debug_hexdump(stdout, "digest:",
6982 sym_op->aead.digest.data,
6983 tdata->auth_tag.len);
6986 sym_op->aead.data.length = tdata->plaintext.len;
6987 sym_op->aead.data.offset = aad_pad_len;
6993 test_authenticated_encryption(const struct aead_test_data *tdata)
6995 struct crypto_testsuite_params *ts_params = &testsuite_params;
6996 struct crypto_unittest_params *ut_params = &unittest_params;
6999 uint8_t *ciphertext, *auth_tag;
7000 uint16_t plaintext_pad_len;
7003 /* Verify the capabilities */
7004 struct rte_cryptodev_sym_capability_idx cap_idx;
7005 const struct rte_cryptodev_symmetric_capability *capability;
7006 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7007 cap_idx.algo.aead = tdata->algo;
7008 capability = rte_cryptodev_sym_capability_get(
7009 ts_params->valid_devs[0], &cap_idx);
7010 if (capability == NULL)
7012 if (rte_cryptodev_sym_capability_check_aead(
7013 capability, tdata->key.len, tdata->auth_tag.len,
7014 tdata->aad.len, tdata->iv.len))
7017 /* Create AEAD session */
7018 retval = create_aead_session(ts_params->valid_devs[0],
7020 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7021 tdata->key.data, tdata->key.len,
7022 tdata->aad.len, tdata->auth_tag.len,
7027 if (tdata->aad.len > MBUF_SIZE) {
7028 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7029 /* Populate full size of add data */
7030 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7031 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7033 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7035 /* clear mbuf payload */
7036 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7037 rte_pktmbuf_tailroom(ut_params->ibuf));
7039 /* Create AEAD operation */
7040 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7044 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7046 ut_params->op->sym->m_src = ut_params->ibuf;
7048 /* Process crypto operation */
7049 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7050 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7052 TEST_ASSERT_NOT_NULL(
7053 process_crypto_request(ts_params->valid_devs[0],
7054 ut_params->op), "failed to process sym crypto op");
7056 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7057 "crypto op processing failed");
7059 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7061 if (ut_params->op->sym->m_dst) {
7062 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7064 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7065 uint8_t *, plaintext_pad_len);
7067 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7069 ut_params->op->sym->cipher.data.offset);
7070 auth_tag = ciphertext + plaintext_pad_len;
7073 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7074 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7077 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7079 tdata->ciphertext.data,
7080 tdata->ciphertext.len,
7081 "Ciphertext data not as expected");
7083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7085 tdata->auth_tag.data,
7086 tdata->auth_tag.len,
7087 "Generated auth tag not as expected");
7093 #ifdef RTE_LIBRTE_SECURITY
7095 security_proto_supported(enum rte_security_session_action_type action,
7096 enum rte_security_session_protocol proto)
7098 struct crypto_testsuite_params *ts_params = &testsuite_params;
7100 const struct rte_security_capability *capabilities;
7101 const struct rte_security_capability *capability;
7104 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7105 rte_cryptodev_get_sec_ctx(
7106 ts_params->valid_devs[0]);
7109 capabilities = rte_security_capabilities_get(ctx);
7111 if (capabilities == NULL)
7114 while ((capability = &capabilities[i++])->action !=
7115 RTE_SECURITY_ACTION_TYPE_NONE) {
7116 if (capability->action == action &&
7117 capability->protocol == proto)
7124 /* Basic algorithm run function for async inplace mode.
7125 * Creates a session from input parameters and runs one operation
7126 * on input_vec. Checks the output of the crypto operation against
7130 test_pdcp_proto(int i, int oop,
7131 enum rte_crypto_cipher_operation opc,
7132 enum rte_crypto_auth_operation opa,
7134 unsigned int input_vec_len,
7135 uint8_t *output_vec,
7136 unsigned int output_vec_len)
7138 struct crypto_testsuite_params *ts_params = &testsuite_params;
7139 struct crypto_unittest_params *ut_params = &unittest_params;
7141 int ret = TEST_SUCCESS;
7142 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7143 rte_cryptodev_get_sec_ctx(
7144 ts_params->valid_devs[0]);
7146 /* Verify the capabilities */
7147 struct rte_security_capability_idx sec_cap_idx;
7149 sec_cap_idx.action = ut_params->type;
7150 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7151 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7152 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7155 /* Generate test mbuf data */
7156 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7158 /* clear mbuf payload */
7159 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7160 rte_pktmbuf_tailroom(ut_params->ibuf));
7162 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7164 memcpy(plaintext, input_vec, input_vec_len);
7166 /* Out of place support */
7169 * For out-op-place we need to alloc another mbuf
7171 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7172 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7175 /* Setup Cipher Parameters */
7176 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7177 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7178 ut_params->cipher_xform.cipher.op = opc;
7179 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7180 ut_params->cipher_xform.cipher.key.length =
7181 pdcp_test_params[i].cipher_key_len;
7182 ut_params->cipher_xform.cipher.iv.length =
7183 pdcp_test_packet_direction[i] ? 4 : 0;
7184 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7186 /* Setup HMAC Parameters if ICV header is required */
7187 if (pdcp_test_params[i].auth_alg != 0) {
7188 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7189 ut_params->auth_xform.next = NULL;
7190 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7191 ut_params->auth_xform.auth.op = opa;
7192 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7193 ut_params->auth_xform.auth.key.length =
7194 pdcp_test_params[i].auth_key_len;
7196 ut_params->cipher_xform.next = &ut_params->auth_xform;
7198 ut_params->cipher_xform.next = NULL;
7201 struct rte_security_session_conf sess_conf = {
7202 .action_type = ut_params->type,
7203 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7205 .bearer = pdcp_test_bearer[i],
7206 .domain = pdcp_test_params[i].domain,
7207 .pkt_dir = pdcp_test_packet_direction[i],
7208 .sn_size = pdcp_test_data_sn_size[i],
7209 .hfn = pdcp_test_packet_direction[i] ?
7210 0 : pdcp_test_hfn[i],
7212 * hfn can be set as pdcp_test_hfn[i]
7213 * if hfn_ovrd is not set. Here, PDCP
7214 * packet direction is just used to
7215 * run half of the cases with session
7216 * HFN and other half with per packet
7219 .hfn_threshold = pdcp_test_hfn_threshold[i],
7220 .hfn_ovrd = pdcp_test_packet_direction[i] ? 1 : 0,
7222 .crypto_xform = &ut_params->cipher_xform
7225 /* Create security session */
7226 ut_params->sec_session = rte_security_session_create(ctx,
7227 &sess_conf, ts_params->session_priv_mpool);
7229 if (!ut_params->sec_session) {
7230 printf("TestCase %s()-%d line %d failed %s: ",
7231 __func__, i, __LINE__, "Failed to allocate session");
7236 /* Generate crypto op data structure */
7237 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7238 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7239 if (!ut_params->op) {
7240 printf("TestCase %s()-%d line %d failed %s: ",
7241 __func__, i, __LINE__,
7242 "Failed to allocate symmetric crypto operation struct");
7247 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7248 uint32_t *, IV_OFFSET);
7249 *per_pkt_hfn = pdcp_test_packet_direction[i] ? pdcp_test_hfn[i] : 0;
7251 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7253 /* set crypto operation source mbuf */
7254 ut_params->op->sym->m_src = ut_params->ibuf;
7256 ut_params->op->sym->m_dst = ut_params->obuf;
7258 /* Process crypto operation */
7259 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7261 printf("TestCase %s()-%d line %d failed %s: ",
7262 __func__, i, __LINE__,
7263 "failed to process sym crypto op");
7268 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7269 printf("TestCase %s()-%d line %d failed %s: ",
7270 __func__, i, __LINE__, "crypto op processing failed");
7276 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7279 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7283 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7284 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7285 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7286 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7292 rte_crypto_op_free(ut_params->op);
7293 ut_params->op = NULL;
7295 if (ut_params->sec_session)
7296 rte_security_session_destroy(ctx, ut_params->sec_session);
7297 ut_params->sec_session = NULL;
7299 rte_pktmbuf_free(ut_params->ibuf);
7300 ut_params->ibuf = NULL;
7302 rte_pktmbuf_free(ut_params->obuf);
7303 ut_params->obuf = NULL;
7310 test_pdcp_proto_SGL(int i, int oop,
7311 enum rte_crypto_cipher_operation opc,
7312 enum rte_crypto_auth_operation opa,
7314 unsigned int input_vec_len,
7315 uint8_t *output_vec,
7316 unsigned int output_vec_len,
7318 uint32_t fragsz_oop)
7320 struct crypto_testsuite_params *ts_params = &testsuite_params;
7321 struct crypto_unittest_params *ut_params = &unittest_params;
7323 struct rte_mbuf *buf, *buf_oop = NULL;
7324 int ret = TEST_SUCCESS;
7328 unsigned int trn_data = 0;
7329 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7330 rte_cryptodev_get_sec_ctx(
7331 ts_params->valid_devs[0]);
7333 /* Verify the capabilities */
7334 struct rte_security_capability_idx sec_cap_idx;
7336 sec_cap_idx.action = ut_params->type;
7337 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7338 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7339 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7342 if (fragsz > input_vec_len)
7343 fragsz = input_vec_len;
7345 uint16_t plaintext_len = fragsz;
7346 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7348 if (fragsz_oop > output_vec_len)
7349 frag_size_oop = output_vec_len;
7352 if (input_vec_len % fragsz != 0) {
7353 if (input_vec_len / fragsz + 1 > 16)
7355 } else if (input_vec_len / fragsz > 16)
7358 /* Out of place support */
7361 * For out-op-place we need to alloc another mbuf
7363 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7364 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7365 buf_oop = ut_params->obuf;
7368 /* Generate test mbuf data */
7369 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7371 /* clear mbuf payload */
7372 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7373 rte_pktmbuf_tailroom(ut_params->ibuf));
7375 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7377 memcpy(plaintext, input_vec, plaintext_len);
7378 trn_data += plaintext_len;
7380 buf = ut_params->ibuf;
7383 * Loop until no more fragments
7386 while (trn_data < input_vec_len) {
7388 to_trn = (input_vec_len - trn_data < fragsz) ?
7389 (input_vec_len - trn_data) : fragsz;
7391 to_trn_tbl[ecx++] = to_trn;
7393 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7396 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7397 rte_pktmbuf_tailroom(buf));
7400 if (oop && !fragsz_oop) {
7402 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7403 buf_oop = buf_oop->next;
7404 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7405 0, rte_pktmbuf_tailroom(buf_oop));
7406 rte_pktmbuf_append(buf_oop, to_trn);
7409 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7412 memcpy(plaintext, input_vec + trn_data, to_trn);
7416 ut_params->ibuf->nb_segs = segs;
7419 if (fragsz_oop && oop) {
7423 trn_data = frag_size_oop;
7424 while (trn_data < output_vec_len) {
7427 (output_vec_len - trn_data <
7429 (output_vec_len - trn_data) :
7432 to_trn_tbl[ecx++] = to_trn;
7435 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7436 buf_oop = buf_oop->next;
7437 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7438 0, rte_pktmbuf_tailroom(buf_oop));
7439 rte_pktmbuf_append(buf_oop, to_trn);
7443 ut_params->obuf->nb_segs = segs;
7446 /* Setup Cipher Parameters */
7447 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7448 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7449 ut_params->cipher_xform.cipher.op = opc;
7450 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7451 ut_params->cipher_xform.cipher.key.length =
7452 pdcp_test_params[i].cipher_key_len;
7453 ut_params->cipher_xform.cipher.iv.length = 0;
7455 /* Setup HMAC Parameters if ICV header is required */
7456 if (pdcp_test_params[i].auth_alg != 0) {
7457 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7458 ut_params->auth_xform.next = NULL;
7459 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7460 ut_params->auth_xform.auth.op = opa;
7461 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7462 ut_params->auth_xform.auth.key.length =
7463 pdcp_test_params[i].auth_key_len;
7465 ut_params->cipher_xform.next = &ut_params->auth_xform;
7467 ut_params->cipher_xform.next = NULL;
7470 struct rte_security_session_conf sess_conf = {
7471 .action_type = ut_params->type,
7472 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7474 .bearer = pdcp_test_bearer[i],
7475 .domain = pdcp_test_params[i].domain,
7476 .pkt_dir = pdcp_test_packet_direction[i],
7477 .sn_size = pdcp_test_data_sn_size[i],
7478 .hfn = pdcp_test_hfn[i],
7479 .hfn_threshold = pdcp_test_hfn_threshold[i],
7482 .crypto_xform = &ut_params->cipher_xform
7485 /* Create security session */
7486 ut_params->sec_session = rte_security_session_create(ctx,
7487 &sess_conf, ts_params->session_priv_mpool);
7489 if (!ut_params->sec_session) {
7490 printf("TestCase %s()-%d line %d failed %s: ",
7491 __func__, i, __LINE__, "Failed to allocate session");
7496 /* Generate crypto op data structure */
7497 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7498 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7499 if (!ut_params->op) {
7500 printf("TestCase %s()-%d line %d failed %s: ",
7501 __func__, i, __LINE__,
7502 "Failed to allocate symmetric crypto operation struct");
7507 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7509 /* set crypto operation source mbuf */
7510 ut_params->op->sym->m_src = ut_params->ibuf;
7512 ut_params->op->sym->m_dst = ut_params->obuf;
7514 /* Process crypto operation */
7515 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7517 printf("TestCase %s()-%d line %d failed %s: ",
7518 __func__, i, __LINE__,
7519 "failed to process sym crypto op");
7524 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7525 printf("TestCase %s()-%d line %d failed %s: ",
7526 __func__, i, __LINE__, "crypto op processing failed");
7532 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7535 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7539 fragsz = frag_size_oop;
7540 if (memcmp(ciphertext, output_vec, fragsz)) {
7541 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7542 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7543 rte_hexdump(stdout, "reference", output_vec, fragsz);
7548 buf = ut_params->op->sym->m_src->next;
7550 buf = ut_params->op->sym->m_dst->next;
7552 unsigned int off = fragsz;
7556 ciphertext = rte_pktmbuf_mtod(buf,
7558 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7559 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7560 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7561 rte_hexdump(stdout, "reference", output_vec + off,
7566 off += to_trn_tbl[ecx++];
7570 rte_crypto_op_free(ut_params->op);
7571 ut_params->op = NULL;
7573 if (ut_params->sec_session)
7574 rte_security_session_destroy(ctx, ut_params->sec_session);
7575 ut_params->sec_session = NULL;
7577 rte_pktmbuf_free(ut_params->ibuf);
7578 ut_params->ibuf = NULL;
7580 rte_pktmbuf_free(ut_params->obuf);
7581 ut_params->obuf = NULL;
7588 test_pdcp_proto_cplane_encap(int i)
7590 return test_pdcp_proto(i, 0,
7591 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7592 RTE_CRYPTO_AUTH_OP_GENERATE,
7593 pdcp_test_data_in[i],
7594 pdcp_test_data_in_len[i],
7595 pdcp_test_data_out[i],
7596 pdcp_test_data_in_len[i]+4);
7600 test_pdcp_proto_uplane_encap(int i)
7602 return test_pdcp_proto(i, 0,
7603 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7604 RTE_CRYPTO_AUTH_OP_GENERATE,
7605 pdcp_test_data_in[i],
7606 pdcp_test_data_in_len[i],
7607 pdcp_test_data_out[i],
7608 pdcp_test_data_in_len[i]);
7613 test_pdcp_proto_uplane_encap_with_int(int i)
7615 return test_pdcp_proto(i, 0,
7616 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7617 RTE_CRYPTO_AUTH_OP_GENERATE,
7618 pdcp_test_data_in[i],
7619 pdcp_test_data_in_len[i],
7620 pdcp_test_data_out[i],
7621 pdcp_test_data_in_len[i] + 4);
7625 test_pdcp_proto_cplane_decap(int i)
7627 return test_pdcp_proto(i, 0,
7628 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7629 RTE_CRYPTO_AUTH_OP_VERIFY,
7630 pdcp_test_data_out[i],
7631 pdcp_test_data_in_len[i] + 4,
7632 pdcp_test_data_in[i],
7633 pdcp_test_data_in_len[i]);
7637 test_pdcp_proto_uplane_decap(int i)
7639 return test_pdcp_proto(i, 0,
7640 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7641 RTE_CRYPTO_AUTH_OP_VERIFY,
7642 pdcp_test_data_out[i],
7643 pdcp_test_data_in_len[i],
7644 pdcp_test_data_in[i],
7645 pdcp_test_data_in_len[i]);
7649 test_pdcp_proto_uplane_decap_with_int(int i)
7651 return test_pdcp_proto(i, 0,
7652 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7653 RTE_CRYPTO_AUTH_OP_VERIFY,
7654 pdcp_test_data_out[i],
7655 pdcp_test_data_in_len[i] + 4,
7656 pdcp_test_data_in[i],
7657 pdcp_test_data_in_len[i]);
7661 test_PDCP_PROTO_SGL_in_place_32B(void)
7663 /* i can be used for running any PDCP case
7664 * In this case it is uplane 12-bit AES-SNOW DL encap
7666 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7667 return test_pdcp_proto_SGL(i, IN_PLACE,
7668 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7669 RTE_CRYPTO_AUTH_OP_GENERATE,
7670 pdcp_test_data_in[i],
7671 pdcp_test_data_in_len[i],
7672 pdcp_test_data_out[i],
7673 pdcp_test_data_in_len[i]+4,
7677 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7679 /* i can be used for running any PDCP case
7680 * In this case it is uplane 18-bit NULL-NULL DL encap
7682 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7683 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7684 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7685 RTE_CRYPTO_AUTH_OP_GENERATE,
7686 pdcp_test_data_in[i],
7687 pdcp_test_data_in_len[i],
7688 pdcp_test_data_out[i],
7689 pdcp_test_data_in_len[i]+4,
7693 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7695 /* i can be used for running any PDCP case
7696 * In this case it is uplane 18-bit AES DL encap
7698 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7700 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7701 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7702 RTE_CRYPTO_AUTH_OP_GENERATE,
7703 pdcp_test_data_in[i],
7704 pdcp_test_data_in_len[i],
7705 pdcp_test_data_out[i],
7706 pdcp_test_data_in_len[i],
7710 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7712 /* i can be used for running any PDCP case
7713 * In this case it is cplane 12-bit AES-ZUC DL encap
7715 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7716 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7717 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7718 RTE_CRYPTO_AUTH_OP_GENERATE,
7719 pdcp_test_data_in[i],
7720 pdcp_test_data_in_len[i],
7721 pdcp_test_data_out[i],
7722 pdcp_test_data_in_len[i]+4,
7727 test_PDCP_PROTO_all(void)
7729 struct crypto_testsuite_params *ts_params = &testsuite_params;
7730 struct crypto_unittest_params *ut_params = &unittest_params;
7731 struct rte_cryptodev_info dev_info;
7734 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7735 uint64_t feat_flags = dev_info.feature_flags;
7737 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
7740 /* Set action type */
7741 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
7742 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
7745 if (security_proto_supported(ut_params->type,
7746 RTE_SECURITY_PROTOCOL_PDCP) < 0)
7749 status = test_PDCP_PROTO_cplane_encap_all();
7750 status += test_PDCP_PROTO_cplane_decap_all();
7751 status += test_PDCP_PROTO_uplane_encap_all();
7752 status += test_PDCP_PROTO_uplane_decap_all();
7753 status += test_PDCP_PROTO_SGL_in_place_32B();
7754 status += test_PDCP_PROTO_SGL_oop_32B_128B();
7755 status += test_PDCP_PROTO_SGL_oop_32B_40B();
7756 status += test_PDCP_PROTO_SGL_oop_128B_32B();
7761 return TEST_SUCCESS;
7765 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
7767 struct crypto_testsuite_params *ts_params = &testsuite_params;
7768 struct crypto_unittest_params *ut_params = &unittest_params;
7769 uint8_t *plaintext, *ciphertext;
7771 int32_t cipher_len, crc_len;
7772 uint32_t crc_data_len;
7773 int ret = TEST_SUCCESS;
7775 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7776 rte_cryptodev_get_sec_ctx(
7777 ts_params->valid_devs[0]);
7779 /* Verify the capabilities */
7780 struct rte_security_capability_idx sec_cap_idx;
7781 const struct rte_security_capability *sec_cap;
7782 const struct rte_cryptodev_capabilities *crypto_cap;
7783 const struct rte_cryptodev_symmetric_capability *sym_cap;
7786 sec_cap_idx.action = ut_params->type;
7787 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
7788 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
7790 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
7791 if (sec_cap == NULL)
7794 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
7795 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
7796 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
7797 crypto_cap->sym.xform_type ==
7798 RTE_CRYPTO_SYM_XFORM_CIPHER &&
7799 crypto_cap->sym.cipher.algo ==
7800 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
7801 sym_cap = &crypto_cap->sym;
7802 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
7809 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
7812 /* Setup source mbuf payload */
7813 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7814 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7815 rte_pktmbuf_tailroom(ut_params->ibuf));
7817 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7818 d_td->ciphertext.len);
7820 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
7822 /* Setup cipher session parameters */
7823 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7824 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
7825 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
7826 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
7827 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
7828 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
7829 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7830 ut_params->cipher_xform.next = NULL;
7832 /* Setup DOCSIS session parameters */
7833 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
7835 struct rte_security_session_conf sess_conf = {
7836 .action_type = ut_params->type,
7837 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
7838 .docsis = ut_params->docsis_xform,
7839 .crypto_xform = &ut_params->cipher_xform,
7842 /* Create security session */
7843 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
7844 ts_params->session_priv_mpool);
7846 if (!ut_params->sec_session) {
7847 printf("TestCase %s(%d) line %d: %s\n",
7848 __func__, i, __LINE__, "failed to allocate session");
7853 /* Generate crypto op data structure */
7854 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7855 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7856 if (!ut_params->op) {
7857 printf("TestCase %s(%d) line %d: %s\n",
7858 __func__, i, __LINE__,
7859 "failed to allocate symmetric crypto operation");
7864 /* Setup CRC operation parameters */
7865 crc_len = d_td->ciphertext.no_crc == false ?
7866 (d_td->ciphertext.len -
7867 d_td->ciphertext.crc_offset -
7868 RTE_ETHER_CRC_LEN) :
7870 crc_len = crc_len > 0 ? crc_len : 0;
7871 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
7872 ut_params->op->sym->auth.data.length = crc_len;
7873 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
7875 /* Setup cipher operation parameters */
7876 cipher_len = d_td->ciphertext.no_cipher == false ?
7877 (d_td->ciphertext.len -
7878 d_td->ciphertext.cipher_offset) :
7880 cipher_len = cipher_len > 0 ? cipher_len : 0;
7881 ut_params->op->sym->cipher.data.length = cipher_len;
7882 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
7884 /* Setup cipher IV */
7885 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
7886 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
7888 /* Attach session to operation */
7889 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7891 /* Set crypto operation mbufs */
7892 ut_params->op->sym->m_src = ut_params->ibuf;
7893 ut_params->op->sym->m_dst = NULL;
7895 /* Process crypto operation */
7896 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
7898 printf("TestCase %s(%d) line %d: %s\n",
7899 __func__, i, __LINE__,
7900 "failed to process security crypto op");
7905 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7906 printf("TestCase %s(%d) line %d: %s\n",
7907 __func__, i, __LINE__, "crypto op processing failed");
7912 /* Validate plaintext */
7913 plaintext = ciphertext;
7915 if (memcmp(plaintext, d_td->plaintext.data,
7916 d_td->plaintext.len - crc_data_len)) {
7917 printf("TestCase %s(%d) line %d: %s\n",
7918 __func__, i, __LINE__, "plaintext not as expected\n");
7919 rte_hexdump(stdout, "expected", d_td->plaintext.data,
7920 d_td->plaintext.len);
7921 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
7927 rte_crypto_op_free(ut_params->op);
7928 ut_params->op = NULL;
7930 if (ut_params->sec_session)
7931 rte_security_session_destroy(ctx, ut_params->sec_session);
7932 ut_params->sec_session = NULL;
7934 rte_pktmbuf_free(ut_params->ibuf);
7935 ut_params->ibuf = NULL;
7941 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
7943 struct crypto_testsuite_params *ts_params = &testsuite_params;
7944 struct crypto_unittest_params *ut_params = &unittest_params;
7945 uint8_t *plaintext, *ciphertext;
7947 int32_t cipher_len, crc_len;
7948 int ret = TEST_SUCCESS;
7950 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7951 rte_cryptodev_get_sec_ctx(
7952 ts_params->valid_devs[0]);
7954 /* Verify the capabilities */
7955 struct rte_security_capability_idx sec_cap_idx;
7956 const struct rte_security_capability *sec_cap;
7957 const struct rte_cryptodev_capabilities *crypto_cap;
7958 const struct rte_cryptodev_symmetric_capability *sym_cap;
7961 sec_cap_idx.action = ut_params->type;
7962 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
7963 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
7965 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
7966 if (sec_cap == NULL)
7969 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
7970 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
7971 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
7972 crypto_cap->sym.xform_type ==
7973 RTE_CRYPTO_SYM_XFORM_CIPHER &&
7974 crypto_cap->sym.cipher.algo ==
7975 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
7976 sym_cap = &crypto_cap->sym;
7977 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
7984 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
7987 /* Setup source mbuf payload */
7988 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7989 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7990 rte_pktmbuf_tailroom(ut_params->ibuf));
7992 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7993 d_td->plaintext.len);
7995 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
7997 /* Setup cipher session parameters */
7998 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7999 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8000 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8001 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8002 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8003 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8004 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8005 ut_params->cipher_xform.next = NULL;
8007 /* Setup DOCSIS session parameters */
8008 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8010 struct rte_security_session_conf sess_conf = {
8011 .action_type = ut_params->type,
8012 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8013 .docsis = ut_params->docsis_xform,
8014 .crypto_xform = &ut_params->cipher_xform,
8017 /* Create security session */
8018 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8019 ts_params->session_priv_mpool);
8021 if (!ut_params->sec_session) {
8022 printf("TestCase %s(%d) line %d: %s\n",
8023 __func__, i, __LINE__, "failed to allocate session");
8028 /* Generate crypto op data structure */
8029 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8030 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8031 if (!ut_params->op) {
8032 printf("TestCase %s(%d) line %d: %s\n",
8033 __func__, i, __LINE__,
8034 "failed to allocate security crypto operation");
8039 /* Setup CRC operation parameters */
8040 crc_len = d_td->plaintext.no_crc == false ?
8041 (d_td->plaintext.len -
8042 d_td->plaintext.crc_offset -
8043 RTE_ETHER_CRC_LEN) :
8045 crc_len = crc_len > 0 ? crc_len : 0;
8046 ut_params->op->sym->auth.data.length = crc_len;
8047 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8049 /* Setup cipher operation parameters */
8050 cipher_len = d_td->plaintext.no_cipher == false ?
8051 (d_td->plaintext.len -
8052 d_td->plaintext.cipher_offset) :
8054 cipher_len = cipher_len > 0 ? cipher_len : 0;
8055 ut_params->op->sym->cipher.data.length = cipher_len;
8056 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8058 /* Setup cipher IV */
8059 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8060 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8062 /* Attach session to operation */
8063 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8065 /* Set crypto operation mbufs */
8066 ut_params->op->sym->m_src = ut_params->ibuf;
8067 ut_params->op->sym->m_dst = NULL;
8069 /* Process crypto operation */
8070 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8072 printf("TestCase %s(%d) line %d: %s\n",
8073 __func__, i, __LINE__,
8074 "failed to process security crypto op");
8079 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8080 printf("TestCase %s(%d) line %d: %s\n",
8081 __func__, i, __LINE__, "crypto op processing failed");
8086 /* Validate ciphertext */
8087 ciphertext = plaintext;
8089 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8090 printf("TestCase %s(%d) line %d: %s\n",
8091 __func__, i, __LINE__, "ciphertext not as expected\n");
8092 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8093 d_td->ciphertext.len);
8094 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8100 rte_crypto_op_free(ut_params->op);
8101 ut_params->op = NULL;
8103 if (ut_params->sec_session)
8104 rte_security_session_destroy(ctx, ut_params->sec_session);
8105 ut_params->sec_session = NULL;
8107 rte_pktmbuf_free(ut_params->ibuf);
8108 ut_params->ibuf = NULL;
8113 #define TEST_DOCSIS_COUNT(func) do { \
8115 if (ret == TEST_SUCCESS) { \
8116 printf("\t%2d)", n++); \
8117 printf("+++++ PASSED:" #func"\n"); \
8119 } else if (ret == -ENOTSUP) { \
8120 printf("\t%2d)", n++); \
8121 printf("~~~~~ UNSUPP:" #func"\n"); \
8124 printf("\t%2d)", n++); \
8125 printf("----- FAILED:" #func"\n"); \
8131 test_DOCSIS_PROTO_uplink_all(void)
8133 int p = 0, u = 0, f = 0, n = 0;
8135 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8136 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8137 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8138 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8139 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8140 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8141 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8142 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8143 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8144 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8145 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8146 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8147 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8148 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8149 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8150 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8151 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8152 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8153 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8154 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8155 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8156 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8157 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8158 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8159 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8160 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8163 printf("## %s: %d passed out of %d (%d unsupported)\n",
8170 test_DOCSIS_PROTO_downlink_all(void)
8172 int p = 0, u = 0, f = 0, n = 0;
8174 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8175 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8176 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8177 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8178 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8179 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8180 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8181 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8182 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8183 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8184 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8185 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8186 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8187 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8188 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8189 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8190 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8191 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8192 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8193 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8194 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8195 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8196 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8197 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8198 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8199 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8202 printf("## %s: %d passed out of %d (%d unsupported)\n",
8209 test_DOCSIS_PROTO_all(void)
8211 struct crypto_testsuite_params *ts_params = &testsuite_params;
8212 struct crypto_unittest_params *ut_params = &unittest_params;
8213 struct rte_cryptodev_info dev_info;
8216 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8217 uint64_t feat_flags = dev_info.feature_flags;
8219 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8222 /* Set action type */
8223 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8224 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8227 if (security_proto_supported(ut_params->type,
8228 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8231 status = test_DOCSIS_PROTO_uplink_all();
8232 status += test_DOCSIS_PROTO_downlink_all();
8237 return TEST_SUCCESS;
8242 test_AES_GCM_authenticated_encryption_test_case_1(void)
8244 return test_authenticated_encryption(&gcm_test_case_1);
8248 test_AES_GCM_authenticated_encryption_test_case_2(void)
8250 return test_authenticated_encryption(&gcm_test_case_2);
8254 test_AES_GCM_authenticated_encryption_test_case_3(void)
8256 return test_authenticated_encryption(&gcm_test_case_3);
8260 test_AES_GCM_authenticated_encryption_test_case_4(void)
8262 return test_authenticated_encryption(&gcm_test_case_4);
8266 test_AES_GCM_authenticated_encryption_test_case_5(void)
8268 return test_authenticated_encryption(&gcm_test_case_5);
8272 test_AES_GCM_authenticated_encryption_test_case_6(void)
8274 return test_authenticated_encryption(&gcm_test_case_6);
8278 test_AES_GCM_authenticated_encryption_test_case_7(void)
8280 return test_authenticated_encryption(&gcm_test_case_7);
8284 test_AES_GCM_authenticated_encryption_test_case_8(void)
8286 return test_authenticated_encryption(&gcm_test_case_8);
8290 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
8292 return test_authenticated_encryption(&gcm_J0_test_case_1);
8296 test_AES_GCM_auth_encryption_test_case_192_1(void)
8298 return test_authenticated_encryption(&gcm_test_case_192_1);
8302 test_AES_GCM_auth_encryption_test_case_192_2(void)
8304 return test_authenticated_encryption(&gcm_test_case_192_2);
8308 test_AES_GCM_auth_encryption_test_case_192_3(void)
8310 return test_authenticated_encryption(&gcm_test_case_192_3);
8314 test_AES_GCM_auth_encryption_test_case_192_4(void)
8316 return test_authenticated_encryption(&gcm_test_case_192_4);
8320 test_AES_GCM_auth_encryption_test_case_192_5(void)
8322 return test_authenticated_encryption(&gcm_test_case_192_5);
8326 test_AES_GCM_auth_encryption_test_case_192_6(void)
8328 return test_authenticated_encryption(&gcm_test_case_192_6);
8332 test_AES_GCM_auth_encryption_test_case_192_7(void)
8334 return test_authenticated_encryption(&gcm_test_case_192_7);
8338 test_AES_GCM_auth_encryption_test_case_256_1(void)
8340 return test_authenticated_encryption(&gcm_test_case_256_1);
8344 test_AES_GCM_auth_encryption_test_case_256_2(void)
8346 return test_authenticated_encryption(&gcm_test_case_256_2);
8350 test_AES_GCM_auth_encryption_test_case_256_3(void)
8352 return test_authenticated_encryption(&gcm_test_case_256_3);
8356 test_AES_GCM_auth_encryption_test_case_256_4(void)
8358 return test_authenticated_encryption(&gcm_test_case_256_4);
8362 test_AES_GCM_auth_encryption_test_case_256_5(void)
8364 return test_authenticated_encryption(&gcm_test_case_256_5);
8368 test_AES_GCM_auth_encryption_test_case_256_6(void)
8370 return test_authenticated_encryption(&gcm_test_case_256_6);
8374 test_AES_GCM_auth_encryption_test_case_256_7(void)
8376 return test_authenticated_encryption(&gcm_test_case_256_7);
8380 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8382 return test_authenticated_encryption(&gcm_test_case_aad_1);
8386 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8388 return test_authenticated_encryption(&gcm_test_case_aad_2);
8392 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8394 struct aead_test_data tdata;
8397 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8398 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8399 tdata.iv.data[0] += 1;
8400 res = test_authenticated_encryption(&tdata);
8401 if (res == -ENOTSUP)
8403 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8404 return TEST_SUCCESS;
8408 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8410 struct aead_test_data tdata;
8413 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8414 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8415 tdata.plaintext.data[0] += 1;
8416 res = test_authenticated_encryption(&tdata);
8417 if (res == -ENOTSUP)
8419 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8420 return TEST_SUCCESS;
8424 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8426 struct aead_test_data tdata;
8429 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8430 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8431 tdata.ciphertext.data[0] += 1;
8432 res = test_authenticated_encryption(&tdata);
8433 if (res == -ENOTSUP)
8435 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8436 return TEST_SUCCESS;
8440 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8442 struct aead_test_data tdata;
8445 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8446 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8448 res = test_authenticated_encryption(&tdata);
8449 if (res == -ENOTSUP)
8451 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8452 return TEST_SUCCESS;
8456 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8458 struct aead_test_data tdata;
8459 uint8_t aad[gcm_test_case_7.aad.len];
8462 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8463 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8464 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8466 tdata.aad.data = aad;
8467 res = test_authenticated_encryption(&tdata);
8468 if (res == -ENOTSUP)
8470 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8471 return TEST_SUCCESS;
8475 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8477 struct aead_test_data tdata;
8480 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8481 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8482 tdata.auth_tag.data[0] += 1;
8483 res = test_authenticated_encryption(&tdata);
8484 if (res == -ENOTSUP)
8486 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8487 return TEST_SUCCESS;
8491 test_authenticated_decryption(const struct aead_test_data *tdata)
8493 struct crypto_testsuite_params *ts_params = &testsuite_params;
8494 struct crypto_unittest_params *ut_params = &unittest_params;
8500 /* Verify the capabilities */
8501 struct rte_cryptodev_sym_capability_idx cap_idx;
8502 const struct rte_cryptodev_symmetric_capability *capability;
8503 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8504 cap_idx.algo.aead = tdata->algo;
8505 capability = rte_cryptodev_sym_capability_get(
8506 ts_params->valid_devs[0], &cap_idx);
8507 if (capability == NULL)
8509 if (rte_cryptodev_sym_capability_check_aead(
8510 capability, tdata->key.len, tdata->auth_tag.len,
8511 tdata->aad.len, tdata->iv.len))
8514 /* Create AEAD session */
8515 retval = create_aead_session(ts_params->valid_devs[0],
8517 RTE_CRYPTO_AEAD_OP_DECRYPT,
8518 tdata->key.data, tdata->key.len,
8519 tdata->aad.len, tdata->auth_tag.len,
8524 /* alloc mbuf and set payload */
8525 if (tdata->aad.len > MBUF_SIZE) {
8526 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8527 /* Populate full size of add data */
8528 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8529 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8531 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8533 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8534 rte_pktmbuf_tailroom(ut_params->ibuf));
8536 /* Create AEAD operation */
8537 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8541 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8543 ut_params->op->sym->m_src = ut_params->ibuf;
8545 /* Process crypto operation */
8546 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8547 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8549 TEST_ASSERT_NOT_NULL(
8550 process_crypto_request(ts_params->valid_devs[0],
8551 ut_params->op), "failed to process sym crypto op");
8553 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8554 "crypto op processing failed");
8556 if (ut_params->op->sym->m_dst)
8557 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8560 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8562 ut_params->op->sym->cipher.data.offset);
8564 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8567 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8569 tdata->plaintext.data,
8570 tdata->plaintext.len,
8571 "Plaintext data not as expected");
8573 TEST_ASSERT_EQUAL(ut_params->op->status,
8574 RTE_CRYPTO_OP_STATUS_SUCCESS,
8575 "Authentication failed");
8581 test_AES_GCM_authenticated_decryption_test_case_1(void)
8583 return test_authenticated_decryption(&gcm_test_case_1);
8587 test_AES_GCM_authenticated_decryption_test_case_2(void)
8589 return test_authenticated_decryption(&gcm_test_case_2);
8593 test_AES_GCM_authenticated_decryption_test_case_3(void)
8595 return test_authenticated_decryption(&gcm_test_case_3);
8599 test_AES_GCM_authenticated_decryption_test_case_4(void)
8601 return test_authenticated_decryption(&gcm_test_case_4);
8605 test_AES_GCM_authenticated_decryption_test_case_5(void)
8607 return test_authenticated_decryption(&gcm_test_case_5);
8611 test_AES_GCM_authenticated_decryption_test_case_6(void)
8613 return test_authenticated_decryption(&gcm_test_case_6);
8617 test_AES_GCM_authenticated_decryption_test_case_7(void)
8619 return test_authenticated_decryption(&gcm_test_case_7);
8623 test_AES_GCM_authenticated_decryption_test_case_8(void)
8625 return test_authenticated_decryption(&gcm_test_case_8);
8629 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
8631 return test_authenticated_decryption(&gcm_J0_test_case_1);
8635 test_AES_GCM_auth_decryption_test_case_192_1(void)
8637 return test_authenticated_decryption(&gcm_test_case_192_1);
8641 test_AES_GCM_auth_decryption_test_case_192_2(void)
8643 return test_authenticated_decryption(&gcm_test_case_192_2);
8647 test_AES_GCM_auth_decryption_test_case_192_3(void)
8649 return test_authenticated_decryption(&gcm_test_case_192_3);
8653 test_AES_GCM_auth_decryption_test_case_192_4(void)
8655 return test_authenticated_decryption(&gcm_test_case_192_4);
8659 test_AES_GCM_auth_decryption_test_case_192_5(void)
8661 return test_authenticated_decryption(&gcm_test_case_192_5);
8665 test_AES_GCM_auth_decryption_test_case_192_6(void)
8667 return test_authenticated_decryption(&gcm_test_case_192_6);
8671 test_AES_GCM_auth_decryption_test_case_192_7(void)
8673 return test_authenticated_decryption(&gcm_test_case_192_7);
8677 test_AES_GCM_auth_decryption_test_case_256_1(void)
8679 return test_authenticated_decryption(&gcm_test_case_256_1);
8683 test_AES_GCM_auth_decryption_test_case_256_2(void)
8685 return test_authenticated_decryption(&gcm_test_case_256_2);
8689 test_AES_GCM_auth_decryption_test_case_256_3(void)
8691 return test_authenticated_decryption(&gcm_test_case_256_3);
8695 test_AES_GCM_auth_decryption_test_case_256_4(void)
8697 return test_authenticated_decryption(&gcm_test_case_256_4);
8701 test_AES_GCM_auth_decryption_test_case_256_5(void)
8703 return test_authenticated_decryption(&gcm_test_case_256_5);
8707 test_AES_GCM_auth_decryption_test_case_256_6(void)
8709 return test_authenticated_decryption(&gcm_test_case_256_6);
8713 test_AES_GCM_auth_decryption_test_case_256_7(void)
8715 return test_authenticated_decryption(&gcm_test_case_256_7);
8719 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8721 return test_authenticated_decryption(&gcm_test_case_aad_1);
8725 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8727 return test_authenticated_decryption(&gcm_test_case_aad_2);
8731 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8733 struct aead_test_data tdata;
8736 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8737 tdata.iv.data[0] += 1;
8738 res = test_authenticated_decryption(&tdata);
8739 if (res == -ENOTSUP)
8741 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8742 return TEST_SUCCESS;
8746 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8748 struct aead_test_data tdata;
8751 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8752 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8753 tdata.plaintext.data[0] += 1;
8754 res = test_authenticated_decryption(&tdata);
8755 if (res == -ENOTSUP)
8757 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8758 return TEST_SUCCESS;
8762 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8764 struct aead_test_data tdata;
8767 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8768 tdata.ciphertext.data[0] += 1;
8769 res = test_authenticated_decryption(&tdata);
8770 if (res == -ENOTSUP)
8772 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8773 return TEST_SUCCESS;
8777 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8779 struct aead_test_data tdata;
8782 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8784 res = test_authenticated_decryption(&tdata);
8785 if (res == -ENOTSUP)
8787 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8788 return TEST_SUCCESS;
8792 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8794 struct aead_test_data tdata;
8795 uint8_t aad[gcm_test_case_7.aad.len];
8798 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8799 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8801 tdata.aad.data = aad;
8802 res = test_authenticated_decryption(&tdata);
8803 if (res == -ENOTSUP)
8805 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8806 return TEST_SUCCESS;
8810 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8812 struct aead_test_data tdata;
8815 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8816 tdata.auth_tag.data[0] += 1;
8817 res = test_authenticated_decryption(&tdata);
8818 if (res == -ENOTSUP)
8820 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8821 return TEST_SUCCESS;
8825 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8827 struct crypto_testsuite_params *ts_params = &testsuite_params;
8828 struct crypto_unittest_params *ut_params = &unittest_params;
8831 uint8_t *ciphertext, *auth_tag;
8832 uint16_t plaintext_pad_len;
8834 /* Verify the capabilities */
8835 struct rte_cryptodev_sym_capability_idx cap_idx;
8836 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8837 cap_idx.algo.aead = tdata->algo;
8838 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8842 /* not supported with CPU crypto */
8843 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8846 /* Create AEAD session */
8847 retval = create_aead_session(ts_params->valid_devs[0],
8849 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8850 tdata->key.data, tdata->key.len,
8851 tdata->aad.len, tdata->auth_tag.len,
8856 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8857 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8859 /* clear mbuf payload */
8860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8861 rte_pktmbuf_tailroom(ut_params->ibuf));
8862 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8863 rte_pktmbuf_tailroom(ut_params->obuf));
8865 /* Create AEAD operation */
8866 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8870 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8872 ut_params->op->sym->m_src = ut_params->ibuf;
8873 ut_params->op->sym->m_dst = ut_params->obuf;
8875 /* Process crypto operation */
8876 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8877 ut_params->op), "failed to process sym crypto op");
8879 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8880 "crypto op processing failed");
8882 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8884 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8885 ut_params->op->sym->cipher.data.offset);
8886 auth_tag = ciphertext + plaintext_pad_len;
8888 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8889 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8892 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8894 tdata->ciphertext.data,
8895 tdata->ciphertext.len,
8896 "Ciphertext data not as expected");
8898 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8900 tdata->auth_tag.data,
8901 tdata->auth_tag.len,
8902 "Generated auth tag not as expected");
8909 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8911 return test_authenticated_encryption_oop(&gcm_test_case_5);
8915 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8917 struct crypto_testsuite_params *ts_params = &testsuite_params;
8918 struct crypto_unittest_params *ut_params = &unittest_params;
8923 /* Verify the capabilities */
8924 struct rte_cryptodev_sym_capability_idx cap_idx;
8925 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8926 cap_idx.algo.aead = tdata->algo;
8927 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8931 /* not supported with CPU crypto */
8932 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8935 /* Create AEAD session */
8936 retval = create_aead_session(ts_params->valid_devs[0],
8938 RTE_CRYPTO_AEAD_OP_DECRYPT,
8939 tdata->key.data, tdata->key.len,
8940 tdata->aad.len, tdata->auth_tag.len,
8945 /* alloc mbuf and set payload */
8946 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8947 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8949 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8950 rte_pktmbuf_tailroom(ut_params->ibuf));
8951 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8952 rte_pktmbuf_tailroom(ut_params->obuf));
8954 /* Create AEAD operation */
8955 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8959 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8961 ut_params->op->sym->m_src = ut_params->ibuf;
8962 ut_params->op->sym->m_dst = ut_params->obuf;
8964 /* Process crypto operation */
8965 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8966 ut_params->op), "failed to process sym crypto op");
8968 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8969 "crypto op processing failed");
8971 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8972 ut_params->op->sym->cipher.data.offset);
8974 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8977 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8979 tdata->plaintext.data,
8980 tdata->plaintext.len,
8981 "Plaintext data not as expected");
8983 TEST_ASSERT_EQUAL(ut_params->op->status,
8984 RTE_CRYPTO_OP_STATUS_SUCCESS,
8985 "Authentication failed");
8990 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8992 return test_authenticated_decryption_oop(&gcm_test_case_5);
8996 test_authenticated_encryption_sessionless(
8997 const struct aead_test_data *tdata)
8999 struct crypto_testsuite_params *ts_params = &testsuite_params;
9000 struct crypto_unittest_params *ut_params = &unittest_params;
9003 uint8_t *ciphertext, *auth_tag;
9004 uint16_t plaintext_pad_len;
9005 uint8_t key[tdata->key.len + 1];
9006 struct rte_cryptodev_info dev_info;
9008 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9009 uint64_t feat_flags = dev_info.feature_flags;
9011 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9012 printf("Device doesn't support Sessionless ops.\n");
9016 /* not supported with CPU crypto */
9017 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9020 /* Verify the capabilities */
9021 struct rte_cryptodev_sym_capability_idx cap_idx;
9022 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9023 cap_idx.algo.aead = tdata->algo;
9024 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9028 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9030 /* clear mbuf payload */
9031 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9032 rte_pktmbuf_tailroom(ut_params->ibuf));
9034 /* Create AEAD operation */
9035 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9039 /* Create GCM xform */
9040 memcpy(key, tdata->key.data, tdata->key.len);
9041 retval = create_aead_xform(ut_params->op,
9043 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9044 key, tdata->key.len,
9045 tdata->aad.len, tdata->auth_tag.len,
9050 ut_params->op->sym->m_src = ut_params->ibuf;
9052 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9053 RTE_CRYPTO_OP_SESSIONLESS,
9054 "crypto op session type not sessionless");
9056 /* Process crypto operation */
9057 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9058 ut_params->op), "failed to process sym crypto op");
9060 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9062 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9063 "crypto op status not success");
9065 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9067 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9068 ut_params->op->sym->cipher.data.offset);
9069 auth_tag = ciphertext + plaintext_pad_len;
9071 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9072 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9075 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9077 tdata->ciphertext.data,
9078 tdata->ciphertext.len,
9079 "Ciphertext data not as expected");
9081 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9083 tdata->auth_tag.data,
9084 tdata->auth_tag.len,
9085 "Generated auth tag not as expected");
9092 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9094 return test_authenticated_encryption_sessionless(
9099 test_authenticated_decryption_sessionless(
9100 const struct aead_test_data *tdata)
9102 struct crypto_testsuite_params *ts_params = &testsuite_params;
9103 struct crypto_unittest_params *ut_params = &unittest_params;
9107 uint8_t key[tdata->key.len + 1];
9108 struct rte_cryptodev_info dev_info;
9110 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9111 uint64_t feat_flags = dev_info.feature_flags;
9113 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9114 printf("Device doesn't support Sessionless ops.\n");
9118 /* not supported with CPU crypto */
9119 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9122 /* Verify the capabilities */
9123 struct rte_cryptodev_sym_capability_idx cap_idx;
9124 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9125 cap_idx.algo.aead = tdata->algo;
9126 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9130 /* alloc mbuf and set payload */
9131 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9133 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9134 rte_pktmbuf_tailroom(ut_params->ibuf));
9136 /* Create AEAD operation */
9137 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9141 /* Create AEAD xform */
9142 memcpy(key, tdata->key.data, tdata->key.len);
9143 retval = create_aead_xform(ut_params->op,
9145 RTE_CRYPTO_AEAD_OP_DECRYPT,
9146 key, tdata->key.len,
9147 tdata->aad.len, tdata->auth_tag.len,
9152 ut_params->op->sym->m_src = ut_params->ibuf;
9154 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9155 RTE_CRYPTO_OP_SESSIONLESS,
9156 "crypto op session type not sessionless");
9158 /* Process crypto operation */
9159 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9160 ut_params->op), "failed to process sym crypto op");
9162 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9164 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9165 "crypto op status not success");
9167 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9168 ut_params->op->sym->cipher.data.offset);
9170 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9173 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9175 tdata->plaintext.data,
9176 tdata->plaintext.len,
9177 "Plaintext data not as expected");
9179 TEST_ASSERT_EQUAL(ut_params->op->status,
9180 RTE_CRYPTO_OP_STATUS_SUCCESS,
9181 "Authentication failed");
9186 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9188 return test_authenticated_decryption_sessionless(
9193 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9195 return test_authenticated_encryption(&ccm_test_case_128_1);
9199 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9201 return test_authenticated_encryption(&ccm_test_case_128_2);
9205 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9207 return test_authenticated_encryption(&ccm_test_case_128_3);
9211 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9213 return test_authenticated_decryption(&ccm_test_case_128_1);
9217 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9219 return test_authenticated_decryption(&ccm_test_case_128_2);
9223 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9225 return test_authenticated_decryption(&ccm_test_case_128_3);
9229 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9231 return test_authenticated_encryption(&ccm_test_case_192_1);
9235 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9237 return test_authenticated_encryption(&ccm_test_case_192_2);
9241 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9243 return test_authenticated_encryption(&ccm_test_case_192_3);
9247 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9249 return test_authenticated_decryption(&ccm_test_case_192_1);
9253 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9255 return test_authenticated_decryption(&ccm_test_case_192_2);
9259 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9261 return test_authenticated_decryption(&ccm_test_case_192_3);
9265 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9267 return test_authenticated_encryption(&ccm_test_case_256_1);
9271 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9273 return test_authenticated_encryption(&ccm_test_case_256_2);
9277 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9279 return test_authenticated_encryption(&ccm_test_case_256_3);
9283 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9285 return test_authenticated_decryption(&ccm_test_case_256_1);
9289 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9291 return test_authenticated_decryption(&ccm_test_case_256_2);
9295 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9297 return test_authenticated_decryption(&ccm_test_case_256_3);
9303 struct crypto_testsuite_params *ts_params = &testsuite_params;
9304 struct rte_cryptodev_stats stats;
9306 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9309 /* Verify the capabilities */
9310 struct rte_cryptodev_sym_capability_idx cap_idx;
9311 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9312 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
9313 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9316 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9317 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9318 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9322 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9326 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9327 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9328 &stats) == -ENODEV),
9329 "rte_cryptodev_stats_get invalid dev failed");
9330 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9331 "rte_cryptodev_stats_get invalid Param failed");
9333 /* Test expected values */
9334 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9335 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9337 "rte_cryptodev_stats_get failed");
9338 TEST_ASSERT((stats.enqueued_count == 1),
9339 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9340 TEST_ASSERT((stats.dequeued_count == 1),
9341 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9342 TEST_ASSERT((stats.enqueue_err_count == 0),
9343 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9344 TEST_ASSERT((stats.dequeue_err_count == 0),
9345 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9347 /* invalid device but should ignore and not reset device stats*/
9348 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9349 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9351 "rte_cryptodev_stats_get failed");
9352 TEST_ASSERT((stats.enqueued_count == 1),
9353 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9355 /* check that a valid reset clears stats */
9356 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9357 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9359 "rte_cryptodev_stats_get failed");
9360 TEST_ASSERT((stats.enqueued_count == 0),
9361 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9362 TEST_ASSERT((stats.dequeued_count == 0),
9363 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9365 return TEST_SUCCESS;
9368 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9369 struct crypto_unittest_params *ut_params,
9370 enum rte_crypto_auth_operation op,
9371 const struct HMAC_MD5_vector *test_case)
9375 memcpy(key, test_case->key.data, test_case->key.len);
9377 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9378 ut_params->auth_xform.next = NULL;
9379 ut_params->auth_xform.auth.op = op;
9381 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9383 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9384 ut_params->auth_xform.auth.key.length = test_case->key.len;
9385 ut_params->auth_xform.auth.key.data = key;
9387 ut_params->sess = rte_cryptodev_sym_session_create(
9388 ts_params->session_mpool);
9390 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9391 ut_params->sess, &ut_params->auth_xform,
9392 ts_params->session_priv_mpool);
9394 if (ut_params->sess == NULL)
9397 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9399 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9400 rte_pktmbuf_tailroom(ut_params->ibuf));
9405 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9406 const struct HMAC_MD5_vector *test_case,
9407 uint8_t **plaintext)
9409 uint16_t plaintext_pad_len;
9411 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9413 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9416 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9418 memcpy(*plaintext, test_case->plaintext.data,
9419 test_case->plaintext.len);
9421 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9422 ut_params->ibuf, MD5_DIGEST_LEN);
9423 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9424 "no room to append digest");
9425 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9426 ut_params->ibuf, plaintext_pad_len);
9428 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9429 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9430 test_case->auth_tag.len);
9433 sym_op->auth.data.offset = 0;
9434 sym_op->auth.data.length = test_case->plaintext.len;
9436 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9437 ut_params->op->sym->m_src = ut_params->ibuf;
9443 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9445 uint16_t plaintext_pad_len;
9446 uint8_t *plaintext, *auth_tag;
9448 struct crypto_testsuite_params *ts_params = &testsuite_params;
9449 struct crypto_unittest_params *ut_params = &unittest_params;
9451 /* Verify the capabilities */
9452 struct rte_cryptodev_sym_capability_idx cap_idx;
9453 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9454 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9455 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9459 if (MD5_HMAC_create_session(ts_params, ut_params,
9460 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9463 /* Generate Crypto op data structure */
9464 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9465 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9466 TEST_ASSERT_NOT_NULL(ut_params->op,
9467 "Failed to allocate symmetric crypto operation struct");
9469 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9472 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9475 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9476 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9479 TEST_ASSERT_NOT_NULL(
9480 process_crypto_request(ts_params->valid_devs[0],
9482 "failed to process sym crypto op");
9484 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9485 "crypto op processing failed");
9487 if (ut_params->op->sym->m_dst) {
9488 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9489 uint8_t *, plaintext_pad_len);
9491 auth_tag = plaintext + plaintext_pad_len;
9494 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9496 test_case->auth_tag.data,
9497 test_case->auth_tag.len,
9498 "HMAC_MD5 generated tag not as expected");
9500 return TEST_SUCCESS;
9504 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9508 struct crypto_testsuite_params *ts_params = &testsuite_params;
9509 struct crypto_unittest_params *ut_params = &unittest_params;
9511 /* Verify the capabilities */
9512 struct rte_cryptodev_sym_capability_idx cap_idx;
9513 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9514 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
9515 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9519 if (MD5_HMAC_create_session(ts_params, ut_params,
9520 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9524 /* Generate Crypto op data structure */
9525 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9526 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9527 TEST_ASSERT_NOT_NULL(ut_params->op,
9528 "Failed to allocate symmetric crypto operation struct");
9530 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9533 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9534 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
9537 TEST_ASSERT_NOT_NULL(
9538 process_crypto_request(ts_params->valid_devs[0],
9540 "failed to process sym crypto op");
9542 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9543 "HMAC_MD5 crypto op processing failed");
9545 return TEST_SUCCESS;
9549 test_MD5_HMAC_generate_case_1(void)
9551 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9555 test_MD5_HMAC_verify_case_1(void)
9557 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9561 test_MD5_HMAC_generate_case_2(void)
9563 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9567 test_MD5_HMAC_verify_case_2(void)
9569 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9573 test_multi_session(void)
9575 struct crypto_testsuite_params *ts_params = &testsuite_params;
9576 struct crypto_unittest_params *ut_params = &unittest_params;
9578 struct rte_cryptodev_info dev_info;
9579 struct rte_cryptodev_sym_session **sessions;
9583 /* Verify the capabilities */
9584 struct rte_cryptodev_sym_capability_idx cap_idx;
9585 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9586 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9587 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9590 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9591 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9592 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9596 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9597 aes_cbc_key, hmac_sha512_key);
9600 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9602 sessions = rte_malloc(NULL,
9603 (sizeof(struct rte_cryptodev_sym_session *) *
9604 MAX_NB_SESSIONS) + 1, 0);
9606 /* Create multiple crypto sessions*/
9607 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9609 sessions[i] = rte_cryptodev_sym_session_create(
9610 ts_params->session_mpool);
9612 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9613 sessions[i], &ut_params->auth_xform,
9614 ts_params->session_priv_mpool);
9615 TEST_ASSERT_NOT_NULL(sessions[i],
9616 "Session creation failed at session number %u",
9619 /* Attempt to send a request on each session */
9620 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9624 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9625 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9627 "Failed to perform decrypt on request number %u.", i);
9628 /* free crypto operation structure */
9630 rte_crypto_op_free(ut_params->op);
9633 * free mbuf - both obuf and ibuf are usually the same,
9634 * so check if they point at the same address is necessary,
9635 * to avoid freeing the mbuf twice.
9637 if (ut_params->obuf) {
9638 rte_pktmbuf_free(ut_params->obuf);
9639 if (ut_params->ibuf == ut_params->obuf)
9640 ut_params->ibuf = 0;
9641 ut_params->obuf = 0;
9643 if (ut_params->ibuf) {
9644 rte_pktmbuf_free(ut_params->ibuf);
9645 ut_params->ibuf = 0;
9649 /* Next session create should fail */
9650 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9651 sessions[i], &ut_params->auth_xform,
9652 ts_params->session_priv_mpool);
9653 TEST_ASSERT_NULL(sessions[i],
9654 "Session creation succeeded unexpectedly!");
9656 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9657 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9659 rte_cryptodev_sym_session_free(sessions[i]);
9664 return TEST_SUCCESS;
9667 struct multi_session_params {
9668 struct crypto_unittest_params ut_params;
9669 uint8_t *cipher_key;
9671 const uint8_t *cipher;
9672 const uint8_t *digest;
9676 #define MB_SESSION_NUMBER 3
9679 test_multi_session_random_usage(void)
9681 struct crypto_testsuite_params *ts_params = &testsuite_params;
9682 struct rte_cryptodev_info dev_info;
9683 struct rte_cryptodev_sym_session **sessions;
9685 struct multi_session_params ut_paramz[] = {
9688 .cipher_key = ms_aes_cbc_key0,
9689 .hmac_key = ms_hmac_key0,
9690 .cipher = ms_aes_cbc_cipher0,
9691 .digest = ms_hmac_digest0,
9692 .iv = ms_aes_cbc_iv0
9695 .cipher_key = ms_aes_cbc_key1,
9696 .hmac_key = ms_hmac_key1,
9697 .cipher = ms_aes_cbc_cipher1,
9698 .digest = ms_hmac_digest1,
9699 .iv = ms_aes_cbc_iv1
9702 .cipher_key = ms_aes_cbc_key2,
9703 .hmac_key = ms_hmac_key2,
9704 .cipher = ms_aes_cbc_cipher2,
9705 .digest = ms_hmac_digest2,
9706 .iv = ms_aes_cbc_iv2
9711 /* Verify the capabilities */
9712 struct rte_cryptodev_sym_capability_idx cap_idx;
9713 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9714 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
9715 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9718 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9719 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9720 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9724 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9726 sessions = rte_malloc(NULL,
9727 (sizeof(struct rte_cryptodev_sym_session *)
9728 * MAX_NB_SESSIONS) + 1, 0);
9730 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9731 sessions[i] = rte_cryptodev_sym_session_create(
9732 ts_params->session_mpool);
9734 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9735 sizeof(struct crypto_unittest_params));
9737 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9738 &ut_paramz[i].ut_params,
9739 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9741 /* Create multiple crypto sessions*/
9742 rte_cryptodev_sym_session_init(
9743 ts_params->valid_devs[0],
9745 &ut_paramz[i].ut_params.auth_xform,
9746 ts_params->session_priv_mpool);
9748 TEST_ASSERT_NOT_NULL(sessions[i],
9749 "Session creation failed at session number %u",
9755 for (i = 0; i < 40000; i++) {
9757 j = rand() % MB_SESSION_NUMBER;
9759 TEST_ASSERT_SUCCESS(
9760 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9762 &ut_paramz[j].ut_params,
9763 ts_params, ut_paramz[j].cipher,
9764 ut_paramz[j].digest,
9766 "Failed to perform decrypt on request number %u.", i);
9768 if (ut_paramz[j].ut_params.op)
9769 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9772 * free mbuf - both obuf and ibuf are usually the same,
9773 * so check if they point at the same address is necessary,
9774 * to avoid freeing the mbuf twice.
9776 if (ut_paramz[j].ut_params.obuf) {
9777 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9778 if (ut_paramz[j].ut_params.ibuf
9779 == ut_paramz[j].ut_params.obuf)
9780 ut_paramz[j].ut_params.ibuf = 0;
9781 ut_paramz[j].ut_params.obuf = 0;
9783 if (ut_paramz[j].ut_params.ibuf) {
9784 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9785 ut_paramz[j].ut_params.ibuf = 0;
9789 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9790 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9792 rte_cryptodev_sym_session_free(sessions[i]);
9797 return TEST_SUCCESS;
9800 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9801 0xab, 0xab, 0xab, 0xab,
9802 0xab, 0xab, 0xab, 0xab,
9803 0xab, 0xab, 0xab, 0xab};
9806 test_null_invalid_operation(void)
9808 struct crypto_testsuite_params *ts_params = &testsuite_params;
9809 struct crypto_unittest_params *ut_params = &unittest_params;
9812 /* This test is for NULL PMD only */
9813 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9814 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9817 /* Setup Cipher Parameters */
9818 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9819 ut_params->cipher_xform.next = NULL;
9821 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9822 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9824 ut_params->sess = rte_cryptodev_sym_session_create(
9825 ts_params->session_mpool);
9827 /* Create Crypto session*/
9828 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9829 ut_params->sess, &ut_params->cipher_xform,
9830 ts_params->session_priv_mpool);
9831 TEST_ASSERT(ret < 0,
9832 "Session creation succeeded unexpectedly");
9835 /* Setup HMAC Parameters */
9836 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9837 ut_params->auth_xform.next = NULL;
9839 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9840 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9842 ut_params->sess = rte_cryptodev_sym_session_create(
9843 ts_params->session_mpool);
9845 /* Create Crypto session*/
9846 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9847 ut_params->sess, &ut_params->auth_xform,
9848 ts_params->session_priv_mpool);
9849 TEST_ASSERT(ret < 0,
9850 "Session creation succeeded unexpectedly");
9852 return TEST_SUCCESS;
9856 #define NULL_BURST_LENGTH (32)
9859 test_null_burst_operation(void)
9861 struct crypto_testsuite_params *ts_params = &testsuite_params;
9862 struct crypto_unittest_params *ut_params = &unittest_params;
9864 unsigned i, burst_len = NULL_BURST_LENGTH;
9866 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9867 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9869 /* This test is for NULL PMD only */
9870 if (gbl_driver_id != rte_cryptodev_driver_id_get(
9871 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
9874 /* Setup Cipher Parameters */
9875 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9876 ut_params->cipher_xform.next = &ut_params->auth_xform;
9878 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9879 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9881 /* Setup HMAC Parameters */
9882 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9883 ut_params->auth_xform.next = NULL;
9885 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9886 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9888 ut_params->sess = rte_cryptodev_sym_session_create(
9889 ts_params->session_mpool);
9891 /* Create Crypto session*/
9892 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9893 ut_params->sess, &ut_params->cipher_xform,
9894 ts_params->session_priv_mpool);
9895 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9897 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9898 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9899 burst_len, "failed to generate burst of crypto ops");
9901 /* Generate an operation for each mbuf in burst */
9902 for (i = 0; i < burst_len; i++) {
9903 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9905 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9907 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9911 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9913 burst[i]->sym->m_src = m;
9916 /* Process crypto operation */
9917 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9918 0, burst, burst_len),
9920 "Error enqueuing burst");
9922 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9923 0, burst_dequeued, burst_len),
9925 "Error dequeuing burst");
9928 for (i = 0; i < burst_len; i++) {
9930 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9931 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9933 "data not as expected");
9935 rte_pktmbuf_free(burst[i]->sym->m_src);
9936 rte_crypto_op_free(burst[i]);
9939 return TEST_SUCCESS;
9943 generate_gmac_large_plaintext(uint8_t *data)
9947 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9948 memcpy(&data[i], &data[0], 32);
9952 create_gmac_operation(enum rte_crypto_auth_operation op,
9953 const struct gmac_test_data *tdata)
9955 struct crypto_testsuite_params *ts_params = &testsuite_params;
9956 struct crypto_unittest_params *ut_params = &unittest_params;
9957 struct rte_crypto_sym_op *sym_op;
9959 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9961 /* Generate Crypto op data structure */
9962 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9963 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9964 TEST_ASSERT_NOT_NULL(ut_params->op,
9965 "Failed to allocate symmetric crypto operation struct");
9967 sym_op = ut_params->op->sym;
9969 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9970 ut_params->ibuf, tdata->gmac_tag.len);
9971 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9972 "no room to append digest");
9974 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9975 ut_params->ibuf, plaintext_pad_len);
9977 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9978 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9979 tdata->gmac_tag.len);
9980 debug_hexdump(stdout, "digest:",
9981 sym_op->auth.digest.data,
9982 tdata->gmac_tag.len);
9985 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9986 uint8_t *, IV_OFFSET);
9988 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9990 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9992 sym_op->cipher.data.length = 0;
9993 sym_op->cipher.data.offset = 0;
9995 sym_op->auth.data.offset = 0;
9996 sym_op->auth.data.length = tdata->plaintext.len;
10002 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
10003 const struct gmac_test_data *tdata,
10004 void *digest_mem, uint64_t digest_phys)
10006 struct crypto_testsuite_params *ts_params = &testsuite_params;
10007 struct crypto_unittest_params *ut_params = &unittest_params;
10008 struct rte_crypto_sym_op *sym_op;
10010 /* Generate Crypto op data structure */
10011 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10012 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10013 TEST_ASSERT_NOT_NULL(ut_params->op,
10014 "Failed to allocate symmetric crypto operation struct");
10016 sym_op = ut_params->op->sym;
10018 sym_op->auth.digest.data = digest_mem;
10019 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10020 "no room to append digest");
10022 sym_op->auth.digest.phys_addr = digest_phys;
10024 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10025 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10026 tdata->gmac_tag.len);
10027 debug_hexdump(stdout, "digest:",
10028 sym_op->auth.digest.data,
10029 tdata->gmac_tag.len);
10032 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10033 uint8_t *, IV_OFFSET);
10035 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10037 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10039 sym_op->cipher.data.length = 0;
10040 sym_op->cipher.data.offset = 0;
10042 sym_op->auth.data.offset = 0;
10043 sym_op->auth.data.length = tdata->plaintext.len;
10048 static int create_gmac_session(uint8_t dev_id,
10049 const struct gmac_test_data *tdata,
10050 enum rte_crypto_auth_operation auth_op)
10052 uint8_t auth_key[tdata->key.len];
10054 struct crypto_testsuite_params *ts_params = &testsuite_params;
10055 struct crypto_unittest_params *ut_params = &unittest_params;
10057 memcpy(auth_key, tdata->key.data, tdata->key.len);
10059 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10060 ut_params->auth_xform.next = NULL;
10062 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10063 ut_params->auth_xform.auth.op = auth_op;
10064 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10065 ut_params->auth_xform.auth.key.length = tdata->key.len;
10066 ut_params->auth_xform.auth.key.data = auth_key;
10067 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10068 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10071 ut_params->sess = rte_cryptodev_sym_session_create(
10072 ts_params->session_mpool);
10074 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10075 &ut_params->auth_xform,
10076 ts_params->session_priv_mpool);
10078 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10084 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10086 struct crypto_testsuite_params *ts_params = &testsuite_params;
10087 struct crypto_unittest_params *ut_params = &unittest_params;
10091 uint8_t *auth_tag, *plaintext;
10092 uint16_t plaintext_pad_len;
10094 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10095 "No GMAC length in the source data");
10097 /* Verify the capabilities */
10098 struct rte_cryptodev_sym_capability_idx cap_idx;
10099 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10100 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10101 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10105 retval = create_gmac_session(ts_params->valid_devs[0],
10106 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10111 if (tdata->plaintext.len > MBUF_SIZE)
10112 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10114 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10115 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10116 "Failed to allocate input buffer in mempool");
10118 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10119 rte_pktmbuf_tailroom(ut_params->ibuf));
10121 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10123 * Runtime generate the large plain text instead of use hard code
10124 * plain text vector. It is done to avoid create huge source file
10125 * with the test vector.
10127 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10128 generate_gmac_large_plaintext(tdata->plaintext.data);
10130 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10131 plaintext_pad_len);
10132 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10134 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10135 debug_hexdump(stdout, "plaintext:", plaintext,
10136 tdata->plaintext.len);
10138 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10144 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10146 ut_params->op->sym->m_src = ut_params->ibuf;
10148 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10149 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10152 TEST_ASSERT_NOT_NULL(
10153 process_crypto_request(ts_params->valid_devs[0],
10154 ut_params->op), "failed to process sym crypto op");
10156 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10157 "crypto op processing failed");
10159 if (ut_params->op->sym->m_dst) {
10160 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10161 uint8_t *, plaintext_pad_len);
10163 auth_tag = plaintext + plaintext_pad_len;
10166 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10168 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10170 tdata->gmac_tag.data,
10171 tdata->gmac_tag.len,
10172 "GMAC Generated auth tag not as expected");
10178 test_AES_GMAC_authentication_test_case_1(void)
10180 return test_AES_GMAC_authentication(&gmac_test_case_1);
10184 test_AES_GMAC_authentication_test_case_2(void)
10186 return test_AES_GMAC_authentication(&gmac_test_case_2);
10190 test_AES_GMAC_authentication_test_case_3(void)
10192 return test_AES_GMAC_authentication(&gmac_test_case_3);
10196 test_AES_GMAC_authentication_test_case_4(void)
10198 return test_AES_GMAC_authentication(&gmac_test_case_4);
10202 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10204 struct crypto_testsuite_params *ts_params = &testsuite_params;
10205 struct crypto_unittest_params *ut_params = &unittest_params;
10207 uint32_t plaintext_pad_len;
10208 uint8_t *plaintext;
10210 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10211 "No GMAC length in the source data");
10213 /* Verify the capabilities */
10214 struct rte_cryptodev_sym_capability_idx cap_idx;
10215 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10216 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10217 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10221 retval = create_gmac_session(ts_params->valid_devs[0],
10222 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10227 if (tdata->plaintext.len > MBUF_SIZE)
10228 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10230 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10231 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10232 "Failed to allocate input buffer in mempool");
10234 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10235 rte_pktmbuf_tailroom(ut_params->ibuf));
10237 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10240 * Runtime generate the large plain text instead of use hard code
10241 * plain text vector. It is done to avoid create huge source file
10242 * with the test vector.
10244 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10245 generate_gmac_large_plaintext(tdata->plaintext.data);
10247 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10248 plaintext_pad_len);
10249 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10251 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10252 debug_hexdump(stdout, "plaintext:", plaintext,
10253 tdata->plaintext.len);
10255 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10261 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10263 ut_params->op->sym->m_src = ut_params->ibuf;
10265 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10266 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10269 TEST_ASSERT_NOT_NULL(
10270 process_crypto_request(ts_params->valid_devs[0],
10271 ut_params->op), "failed to process sym crypto op");
10273 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10274 "crypto op processing failed");
10281 test_AES_GMAC_authentication_verify_test_case_1(void)
10283 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10287 test_AES_GMAC_authentication_verify_test_case_2(void)
10289 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10293 test_AES_GMAC_authentication_verify_test_case_3(void)
10295 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10299 test_AES_GMAC_authentication_verify_test_case_4(void)
10301 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10305 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
10308 struct crypto_testsuite_params *ts_params = &testsuite_params;
10309 struct crypto_unittest_params *ut_params = &unittest_params;
10310 struct rte_cryptodev_info dev_info;
10311 uint64_t feature_flags;
10312 unsigned int trn_data = 0;
10313 void *digest_mem = NULL;
10315 unsigned int to_trn = 0;
10316 struct rte_mbuf *buf = NULL;
10317 uint8_t *auth_tag, *plaintext;
10320 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10321 "No GMAC length in the source data");
10323 /* Verify the capabilities */
10324 struct rte_cryptodev_sym_capability_idx cap_idx;
10325 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10326 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10327 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10331 /* Check for any input SGL support */
10332 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10333 feature_flags = dev_info.feature_flags;
10335 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) &&
10336 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) &&
10337 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
10340 if (fragsz > tdata->plaintext.len)
10341 fragsz = tdata->plaintext.len;
10343 uint16_t plaintext_len = fragsz;
10345 retval = create_gmac_session(ts_params->valid_devs[0],
10346 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10351 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10352 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10353 "Failed to allocate input buffer in mempool");
10355 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10356 rte_pktmbuf_tailroom(ut_params->ibuf));
10358 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10360 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10362 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
10364 trn_data += plaintext_len;
10366 buf = ut_params->ibuf;
10369 * Loop until no more fragments
10372 while (trn_data < tdata->plaintext.len) {
10374 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
10375 (tdata->plaintext.len - trn_data) : fragsz;
10377 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10380 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
10381 rte_pktmbuf_tailroom(buf));
10383 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
10386 memcpy(plaintext, tdata->plaintext.data + trn_data,
10388 trn_data += to_trn;
10389 if (trn_data == tdata->plaintext.len)
10390 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
10391 tdata->gmac_tag.len);
10393 ut_params->ibuf->nb_segs = segs;
10396 * Place digest at the end of the last buffer
10398 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
10401 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10402 + tdata->gmac_tag.len);
10403 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
10404 tdata->plaintext.len);
10407 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
10408 tdata, digest_mem, digest_phys);
10413 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10415 ut_params->op->sym->m_src = ut_params->ibuf;
10417 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10420 TEST_ASSERT_NOT_NULL(
10421 process_crypto_request(ts_params->valid_devs[0],
10422 ut_params->op), "failed to process sym crypto op");
10424 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10425 "crypto op processing failed");
10427 auth_tag = digest_mem;
10428 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10429 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10431 tdata->gmac_tag.data,
10432 tdata->gmac_tag.len,
10433 "GMAC Generated auth tag not as expected");
10438 /* Segment size not multiple of block size (16B) */
10440 test_AES_GMAC_authentication_SGL_40B(void)
10442 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
10446 test_AES_GMAC_authentication_SGL_80B(void)
10448 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
10452 test_AES_GMAC_authentication_SGL_2048B(void)
10454 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
10457 /* Segment size not multiple of block size (16B) */
10459 test_AES_GMAC_authentication_SGL_2047B(void)
10461 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
10464 struct test_crypto_vector {
10465 enum rte_crypto_cipher_algorithm crypto_algo;
10466 unsigned int cipher_offset;
10467 unsigned int cipher_len;
10480 const uint8_t *data;
10485 const uint8_t *data;
10489 enum rte_crypto_auth_algorithm auth_algo;
10490 unsigned int auth_offset;
10498 const uint8_t *data;
10508 static const struct test_crypto_vector
10509 hmac_sha1_test_crypto_vector = {
10510 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10512 .data = plaintext_hash,
10517 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10518 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10519 0xDE, 0xF4, 0xDE, 0xAD
10525 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10526 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10527 0x3F, 0x91, 0x64, 0x59
10533 static const struct test_crypto_vector
10534 aes128_gmac_test_vector = {
10535 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10537 .data = plaintext_hash,
10542 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10543 0x08, 0x09, 0x0A, 0x0B
10549 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10550 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10556 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10557 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10563 static const struct test_crypto_vector
10564 aes128cbc_hmac_sha1_test_vector = {
10565 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10566 .cipher_offset = 0,
10570 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10571 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10577 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10578 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10583 .data = plaintext_hash,
10587 .data = ciphertext512_aes128cbc,
10590 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10594 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10595 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10596 0xDE, 0xF4, 0xDE, 0xAD
10602 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10603 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10604 0x18, 0x8C, 0x1D, 0x32
10610 static const struct test_crypto_vector
10611 aes128cbc_hmac_sha1_aad_test_vector = {
10612 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10613 .cipher_offset = 8,
10617 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10618 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10624 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10625 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10630 .data = plaintext_hash,
10634 .data = ciphertext512_aes128cbc_aad,
10637 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10641 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10642 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10643 0xDE, 0xF4, 0xDE, 0xAD
10649 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
10650 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
10651 0x62, 0x0F, 0xFB, 0x10
10658 data_corruption(uint8_t *data)
10664 tag_corruption(uint8_t *data, unsigned int tag_offset)
10666 data[tag_offset] += 1;
10670 create_auth_session(struct crypto_unittest_params *ut_params,
10672 const struct test_crypto_vector *reference,
10673 enum rte_crypto_auth_operation auth_op)
10675 struct crypto_testsuite_params *ts_params = &testsuite_params;
10676 uint8_t auth_key[reference->auth_key.len + 1];
10678 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10680 /* Setup Authentication Parameters */
10681 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10682 ut_params->auth_xform.auth.op = auth_op;
10683 ut_params->auth_xform.next = NULL;
10684 ut_params->auth_xform.auth.algo = reference->auth_algo;
10685 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10686 ut_params->auth_xform.auth.key.data = auth_key;
10687 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10689 /* Create Crypto session*/
10690 ut_params->sess = rte_cryptodev_sym_session_create(
10691 ts_params->session_mpool);
10693 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10694 &ut_params->auth_xform,
10695 ts_params->session_priv_mpool);
10697 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10703 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10705 const struct test_crypto_vector *reference,
10706 enum rte_crypto_auth_operation auth_op,
10707 enum rte_crypto_cipher_operation cipher_op)
10709 struct crypto_testsuite_params *ts_params = &testsuite_params;
10710 uint8_t cipher_key[reference->cipher_key.len + 1];
10711 uint8_t auth_key[reference->auth_key.len + 1];
10713 memcpy(cipher_key, reference->cipher_key.data,
10714 reference->cipher_key.len);
10715 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10717 /* Setup Authentication Parameters */
10718 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10719 ut_params->auth_xform.auth.op = auth_op;
10720 ut_params->auth_xform.auth.algo = reference->auth_algo;
10721 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10722 ut_params->auth_xform.auth.key.data = auth_key;
10723 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10725 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10726 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10727 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10729 ut_params->auth_xform.next = &ut_params->cipher_xform;
10731 /* Setup Cipher Parameters */
10732 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10733 ut_params->cipher_xform.next = NULL;
10734 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10735 ut_params->cipher_xform.cipher.op = cipher_op;
10736 ut_params->cipher_xform.cipher.key.data = cipher_key;
10737 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10738 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10739 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10742 /* Create Crypto session*/
10743 ut_params->sess = rte_cryptodev_sym_session_create(
10744 ts_params->session_mpool);
10746 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10747 &ut_params->auth_xform,
10748 ts_params->session_priv_mpool);
10750 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10756 create_auth_operation(struct crypto_testsuite_params *ts_params,
10757 struct crypto_unittest_params *ut_params,
10758 const struct test_crypto_vector *reference,
10759 unsigned int auth_generate)
10761 /* Generate Crypto op data structure */
10762 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10763 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10764 TEST_ASSERT_NOT_NULL(ut_params->op,
10765 "Failed to allocate pktmbuf offload");
10767 /* Set crypto operation data parameters */
10768 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10770 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10772 /* set crypto operation source mbuf */
10773 sym_op->m_src = ut_params->ibuf;
10776 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10777 ut_params->ibuf, reference->digest.len);
10779 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10780 "no room to append auth tag");
10782 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10783 ut_params->ibuf, reference->plaintext.len);
10786 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10788 memcpy(sym_op->auth.digest.data,
10789 reference->digest.data,
10790 reference->digest.len);
10792 debug_hexdump(stdout, "digest:",
10793 sym_op->auth.digest.data,
10794 reference->digest.len);
10796 sym_op->auth.data.length = reference->plaintext.len;
10797 sym_op->auth.data.offset = 0;
10803 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10804 struct crypto_unittest_params *ut_params,
10805 const struct test_crypto_vector *reference,
10806 unsigned int auth_generate)
10808 /* Generate Crypto op data structure */
10809 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10810 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10811 TEST_ASSERT_NOT_NULL(ut_params->op,
10812 "Failed to allocate pktmbuf offload");
10814 /* Set crypto operation data parameters */
10815 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10817 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10819 /* set crypto operation source mbuf */
10820 sym_op->m_src = ut_params->ibuf;
10823 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10824 ut_params->ibuf, reference->digest.len);
10826 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10827 "no room to append auth tag");
10829 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10830 ut_params->ibuf, reference->ciphertext.len);
10833 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10835 memcpy(sym_op->auth.digest.data,
10836 reference->digest.data,
10837 reference->digest.len);
10839 debug_hexdump(stdout, "digest:",
10840 sym_op->auth.digest.data,
10841 reference->digest.len);
10843 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10844 reference->iv.data, reference->iv.len);
10846 sym_op->cipher.data.length = 0;
10847 sym_op->cipher.data.offset = 0;
10849 sym_op->auth.data.length = reference->plaintext.len;
10850 sym_op->auth.data.offset = 0;
10856 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10857 struct crypto_unittest_params *ut_params,
10858 const struct test_crypto_vector *reference,
10859 unsigned int auth_generate)
10861 /* Generate Crypto op data structure */
10862 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10863 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10864 TEST_ASSERT_NOT_NULL(ut_params->op,
10865 "Failed to allocate pktmbuf offload");
10867 /* Set crypto operation data parameters */
10868 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10870 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10872 /* set crypto operation source mbuf */
10873 sym_op->m_src = ut_params->ibuf;
10876 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10877 ut_params->ibuf, reference->digest.len);
10879 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10880 "no room to append auth tag");
10882 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10883 ut_params->ibuf, reference->ciphertext.len);
10886 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10888 memcpy(sym_op->auth.digest.data,
10889 reference->digest.data,
10890 reference->digest.len);
10892 debug_hexdump(stdout, "digest:",
10893 sym_op->auth.digest.data,
10894 reference->digest.len);
10896 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10897 reference->iv.data, reference->iv.len);
10899 sym_op->cipher.data.length = reference->cipher_len;
10900 sym_op->cipher.data.offset = reference->cipher_offset;
10902 sym_op->auth.data.length = reference->plaintext.len;
10903 sym_op->auth.data.offset = reference->auth_offset;
10909 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10910 struct crypto_unittest_params *ut_params,
10911 const struct test_crypto_vector *reference)
10913 return create_auth_operation(ts_params, ut_params, reference, 0);
10917 create_auth_verify_GMAC_operation(
10918 struct crypto_testsuite_params *ts_params,
10919 struct crypto_unittest_params *ut_params,
10920 const struct test_crypto_vector *reference)
10922 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10926 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10927 struct crypto_unittest_params *ut_params,
10928 const struct test_crypto_vector *reference)
10930 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10934 test_authentication_verify_fail_when_data_corruption(
10935 struct crypto_testsuite_params *ts_params,
10936 struct crypto_unittest_params *ut_params,
10937 const struct test_crypto_vector *reference,
10938 unsigned int data_corrupted)
10942 uint8_t *plaintext;
10944 /* Verify the capabilities */
10945 struct rte_cryptodev_sym_capability_idx cap_idx;
10946 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10947 cap_idx.algo.auth = reference->auth_algo;
10948 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10952 /* Create session */
10953 retval = create_auth_session(ut_params,
10954 ts_params->valid_devs[0],
10956 RTE_CRYPTO_AUTH_OP_VERIFY);
10960 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10961 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10962 "Failed to allocate input buffer in mempool");
10964 /* clear mbuf payload */
10965 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10966 rte_pktmbuf_tailroom(ut_params->ibuf));
10968 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10969 reference->plaintext.len);
10970 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10971 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10973 debug_hexdump(stdout, "plaintext:", plaintext,
10974 reference->plaintext.len);
10976 /* Create operation */
10977 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10982 if (data_corrupted)
10983 data_corruption(plaintext);
10985 tag_corruption(plaintext, reference->plaintext.len);
10987 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
10988 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10990 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10991 RTE_CRYPTO_OP_STATUS_SUCCESS,
10992 "authentication not failed");
10994 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10996 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11003 test_authentication_verify_GMAC_fail_when_corruption(
11004 struct crypto_testsuite_params *ts_params,
11005 struct crypto_unittest_params *ut_params,
11006 const struct test_crypto_vector *reference,
11007 unsigned int data_corrupted)
11010 uint8_t *plaintext;
11012 /* Verify the capabilities */
11013 struct rte_cryptodev_sym_capability_idx cap_idx;
11014 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11015 cap_idx.algo.auth = reference->auth_algo;
11016 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11020 /* Create session */
11021 retval = create_auth_cipher_session(ut_params,
11022 ts_params->valid_devs[0],
11024 RTE_CRYPTO_AUTH_OP_VERIFY,
11025 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11029 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11030 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11031 "Failed to allocate input buffer in mempool");
11033 /* clear mbuf payload */
11034 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11035 rte_pktmbuf_tailroom(ut_params->ibuf));
11037 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11038 reference->plaintext.len);
11039 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11040 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11042 debug_hexdump(stdout, "plaintext:", plaintext,
11043 reference->plaintext.len);
11045 /* Create operation */
11046 retval = create_auth_verify_GMAC_operation(ts_params,
11053 if (data_corrupted)
11054 data_corruption(plaintext);
11056 tag_corruption(plaintext, reference->aad.len);
11058 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11059 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11061 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11062 RTE_CRYPTO_OP_STATUS_SUCCESS,
11063 "authentication not failed");
11065 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11067 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11074 test_authenticated_decryption_fail_when_corruption(
11075 struct crypto_testsuite_params *ts_params,
11076 struct crypto_unittest_params *ut_params,
11077 const struct test_crypto_vector *reference,
11078 unsigned int data_corrupted)
11082 uint8_t *ciphertext;
11084 /* Verify the capabilities */
11085 struct rte_cryptodev_sym_capability_idx cap_idx;
11086 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11087 cap_idx.algo.auth = reference->auth_algo;
11088 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11091 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11092 cap_idx.algo.cipher = reference->crypto_algo;
11093 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11097 /* Create session */
11098 retval = create_auth_cipher_session(ut_params,
11099 ts_params->valid_devs[0],
11101 RTE_CRYPTO_AUTH_OP_VERIFY,
11102 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11106 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11107 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11108 "Failed to allocate input buffer in mempool");
11110 /* clear mbuf payload */
11111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11112 rte_pktmbuf_tailroom(ut_params->ibuf));
11114 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11115 reference->ciphertext.len);
11116 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11117 memcpy(ciphertext, reference->ciphertext.data,
11118 reference->ciphertext.len);
11120 /* Create operation */
11121 retval = create_cipher_auth_verify_operation(ts_params,
11128 if (data_corrupted)
11129 data_corruption(ciphertext);
11131 tag_corruption(ciphertext, reference->ciphertext.len);
11133 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11134 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11136 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11137 RTE_CRYPTO_OP_STATUS_SUCCESS,
11138 "authentication not failed");
11140 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11142 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11149 test_authenticated_encryt_with_esn(
11150 struct crypto_testsuite_params *ts_params,
11151 struct crypto_unittest_params *ut_params,
11152 const struct test_crypto_vector *reference)
11156 uint8_t *authciphertext, *plaintext, *auth_tag;
11157 uint16_t plaintext_pad_len;
11158 uint8_t cipher_key[reference->cipher_key.len + 1];
11159 uint8_t auth_key[reference->auth_key.len + 1];
11161 /* Verify the capabilities */
11162 struct rte_cryptodev_sym_capability_idx cap_idx;
11163 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11164 cap_idx.algo.auth = reference->auth_algo;
11165 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11168 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11169 cap_idx.algo.cipher = reference->crypto_algo;
11170 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11174 /* Create session */
11175 memcpy(cipher_key, reference->cipher_key.data,
11176 reference->cipher_key.len);
11177 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11179 /* Setup Cipher Parameters */
11180 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11181 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11182 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11183 ut_params->cipher_xform.cipher.key.data = cipher_key;
11184 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11185 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11186 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11188 ut_params->cipher_xform.next = &ut_params->auth_xform;
11190 /* Setup Authentication Parameters */
11191 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11192 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11193 ut_params->auth_xform.auth.algo = reference->auth_algo;
11194 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11195 ut_params->auth_xform.auth.key.data = auth_key;
11196 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11197 ut_params->auth_xform.next = NULL;
11199 /* Create Crypto session*/
11200 ut_params->sess = rte_cryptodev_sym_session_create(
11201 ts_params->session_mpool);
11203 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11205 &ut_params->cipher_xform,
11206 ts_params->session_priv_mpool);
11208 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11210 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11211 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11212 "Failed to allocate input buffer in mempool");
11214 /* clear mbuf payload */
11215 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11216 rte_pktmbuf_tailroom(ut_params->ibuf));
11218 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11219 reference->plaintext.len);
11220 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11221 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11223 /* Create operation */
11224 retval = create_cipher_auth_operation(ts_params,
11231 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11232 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11235 ut_params->op = process_crypto_request(
11236 ts_params->valid_devs[0], ut_params->op);
11238 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11240 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11241 "crypto op processing failed");
11243 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11245 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11246 ut_params->op->sym->auth.data.offset);
11247 auth_tag = authciphertext + plaintext_pad_len;
11248 debug_hexdump(stdout, "ciphertext:", authciphertext,
11249 reference->ciphertext.len);
11250 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11252 /* Validate obuf */
11253 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11255 reference->ciphertext.data,
11256 reference->ciphertext.len,
11257 "Ciphertext data not as expected");
11259 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11261 reference->digest.data,
11262 reference->digest.len,
11263 "Generated digest not as expected");
11265 return TEST_SUCCESS;
11270 test_authenticated_decrypt_with_esn(
11271 struct crypto_testsuite_params *ts_params,
11272 struct crypto_unittest_params *ut_params,
11273 const struct test_crypto_vector *reference)
11277 uint8_t *ciphertext;
11278 uint8_t cipher_key[reference->cipher_key.len + 1];
11279 uint8_t auth_key[reference->auth_key.len + 1];
11281 /* Verify the capabilities */
11282 struct rte_cryptodev_sym_capability_idx cap_idx;
11283 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11284 cap_idx.algo.auth = reference->auth_algo;
11285 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11288 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11289 cap_idx.algo.cipher = reference->crypto_algo;
11290 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11294 /* Create session */
11295 memcpy(cipher_key, reference->cipher_key.data,
11296 reference->cipher_key.len);
11297 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11299 /* Setup Authentication Parameters */
11300 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11301 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11302 ut_params->auth_xform.auth.algo = reference->auth_algo;
11303 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11304 ut_params->auth_xform.auth.key.data = auth_key;
11305 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11306 ut_params->auth_xform.next = &ut_params->cipher_xform;
11308 /* Setup Cipher Parameters */
11309 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11310 ut_params->cipher_xform.next = NULL;
11311 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11312 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11313 ut_params->cipher_xform.cipher.key.data = cipher_key;
11314 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11315 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11316 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11318 /* Create Crypto session*/
11319 ut_params->sess = rte_cryptodev_sym_session_create(
11320 ts_params->session_mpool);
11322 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11324 &ut_params->auth_xform,
11325 ts_params->session_priv_mpool);
11327 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11330 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11331 "Failed to allocate input buffer in mempool");
11333 /* clear mbuf payload */
11334 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11335 rte_pktmbuf_tailroom(ut_params->ibuf));
11337 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11338 reference->ciphertext.len);
11339 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11340 memcpy(ciphertext, reference->ciphertext.data,
11341 reference->ciphertext.len);
11343 /* Create operation */
11344 retval = create_cipher_auth_verify_operation(ts_params,
11351 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11352 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11355 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11358 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11359 TEST_ASSERT_EQUAL(ut_params->op->status,
11360 RTE_CRYPTO_OP_STATUS_SUCCESS,
11361 "crypto op processing passed");
11363 ut_params->obuf = ut_params->op->sym->m_src;
11364 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11370 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11371 const struct aead_test_data *tdata,
11372 void *digest_mem, uint64_t digest_phys)
11374 struct crypto_testsuite_params *ts_params = &testsuite_params;
11375 struct crypto_unittest_params *ut_params = &unittest_params;
11377 const unsigned int auth_tag_len = tdata->auth_tag.len;
11378 const unsigned int iv_len = tdata->iv.len;
11379 unsigned int aad_len = tdata->aad.len;
11380 unsigned int aad_len_pad = 0;
11382 /* Generate Crypto op data structure */
11383 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11384 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11385 TEST_ASSERT_NOT_NULL(ut_params->op,
11386 "Failed to allocate symmetric crypto operation struct");
11388 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11390 sym_op->aead.digest.data = digest_mem;
11392 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11393 "no room to append digest");
11395 sym_op->aead.digest.phys_addr = digest_phys;
11397 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11398 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11400 debug_hexdump(stdout, "digest:",
11401 sym_op->aead.digest.data,
11405 /* Append aad data */
11406 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11407 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11408 uint8_t *, IV_OFFSET);
11410 /* Copy IV 1 byte after the IV pointer, according to the API */
11411 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11413 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11415 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11416 ut_params->ibuf, aad_len);
11417 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11418 "no room to prepend aad");
11419 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11422 memset(sym_op->aead.aad.data, 0, aad_len);
11423 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11424 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11426 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11427 debug_hexdump(stdout, "aad:",
11428 sym_op->aead.aad.data, aad_len);
11430 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11431 uint8_t *, IV_OFFSET);
11433 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11435 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11437 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11438 ut_params->ibuf, aad_len_pad);
11439 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11440 "no room to prepend aad");
11441 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11444 memset(sym_op->aead.aad.data, 0, aad_len);
11445 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11447 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11448 debug_hexdump(stdout, "aad:",
11449 sym_op->aead.aad.data, aad_len);
11452 sym_op->aead.data.length = tdata->plaintext.len;
11453 sym_op->aead.data.offset = aad_len_pad;
11458 #define SGL_MAX_NO 16
11461 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11462 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11464 struct crypto_testsuite_params *ts_params = &testsuite_params;
11465 struct crypto_unittest_params *ut_params = &unittest_params;
11466 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11469 int to_trn_tbl[SGL_MAX_NO];
11471 unsigned int trn_data = 0;
11472 uint8_t *plaintext, *ciphertext, *auth_tag;
11473 struct rte_cryptodev_info dev_info;
11475 /* Verify the capabilities */
11476 struct rte_cryptodev_sym_capability_idx cap_idx;
11477 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11478 cap_idx.algo.aead = tdata->algo;
11479 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11483 /* OOP not supported with CPU crypto */
11484 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11487 /* Detailed check for the particular SGL support flag */
11488 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11490 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11491 if (sgl_in && (!(dev_info.feature_flags &
11492 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
11495 unsigned int sgl_in = fragsz < tdata->plaintext.len;
11496 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
11497 tdata->plaintext.len;
11498 if (sgl_in && !sgl_out) {
11499 if (!(dev_info.feature_flags &
11500 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
11502 } else if (!sgl_in && sgl_out) {
11503 if (!(dev_info.feature_flags &
11504 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
11506 } else if (sgl_in && sgl_out) {
11507 if (!(dev_info.feature_flags &
11508 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
11513 if (fragsz > tdata->plaintext.len)
11514 fragsz = tdata->plaintext.len;
11516 uint16_t plaintext_len = fragsz;
11517 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11519 if (fragsz_oop > tdata->plaintext.len)
11520 frag_size_oop = tdata->plaintext.len;
11523 void *digest_mem = NULL;
11525 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11527 if (tdata->plaintext.len % fragsz != 0) {
11528 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11531 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11536 * For out-op-place we need to alloc another mbuf
11539 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11540 rte_pktmbuf_append(ut_params->obuf,
11541 frag_size_oop + prepend_len);
11542 buf_oop = ut_params->obuf;
11545 /* Create AEAD session */
11546 retval = create_aead_session(ts_params->valid_devs[0],
11548 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11549 tdata->key.data, tdata->key.len,
11550 tdata->aad.len, tdata->auth_tag.len,
11555 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11557 /* clear mbuf payload */
11558 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11559 rte_pktmbuf_tailroom(ut_params->ibuf));
11561 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11564 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11566 trn_data += plaintext_len;
11568 buf = ut_params->ibuf;
11571 * Loop until no more fragments
11574 while (trn_data < tdata->plaintext.len) {
11576 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11577 (tdata->plaintext.len - trn_data) : fragsz;
11579 to_trn_tbl[ecx++] = to_trn;
11581 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11584 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11585 rte_pktmbuf_tailroom(buf));
11588 if (oop && !fragsz_oop) {
11589 buf_last_oop = buf_oop->next =
11590 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11591 buf_oop = buf_oop->next;
11592 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11593 0, rte_pktmbuf_tailroom(buf_oop));
11594 rte_pktmbuf_append(buf_oop, to_trn);
11597 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11600 memcpy(plaintext, tdata->plaintext.data + trn_data,
11602 trn_data += to_trn;
11603 if (trn_data == tdata->plaintext.len) {
11606 digest_mem = rte_pktmbuf_append(buf_oop,
11607 tdata->auth_tag.len);
11609 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11610 tdata->auth_tag.len);
11614 uint64_t digest_phys = 0;
11616 ut_params->ibuf->nb_segs = segs;
11619 if (fragsz_oop && oop) {
11623 if (frag_size_oop == tdata->plaintext.len) {
11624 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11625 tdata->auth_tag.len);
11627 digest_phys = rte_pktmbuf_iova_offset(
11629 tdata->plaintext.len + prepend_len);
11632 trn_data = frag_size_oop;
11633 while (trn_data < tdata->plaintext.len) {
11636 (tdata->plaintext.len - trn_data <
11638 (tdata->plaintext.len - trn_data) :
11641 to_trn_tbl[ecx++] = to_trn;
11643 buf_last_oop = buf_oop->next =
11644 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11645 buf_oop = buf_oop->next;
11646 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11647 0, rte_pktmbuf_tailroom(buf_oop));
11648 rte_pktmbuf_append(buf_oop, to_trn);
11650 trn_data += to_trn;
11652 if (trn_data == tdata->plaintext.len) {
11653 digest_mem = rte_pktmbuf_append(buf_oop,
11654 tdata->auth_tag.len);
11658 ut_params->obuf->nb_segs = segs;
11662 * Place digest at the end of the last buffer
11665 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11666 if (oop && buf_last_oop)
11667 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11669 if (!digest_mem && !oop) {
11670 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11671 + tdata->auth_tag.len);
11672 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11673 tdata->plaintext.len);
11676 /* Create AEAD operation */
11677 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11678 tdata, digest_mem, digest_phys);
11683 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11685 ut_params->op->sym->m_src = ut_params->ibuf;
11687 ut_params->op->sym->m_dst = ut_params->obuf;
11689 /* Process crypto operation */
11690 if (oop == IN_PLACE &&
11691 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11692 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
11694 TEST_ASSERT_NOT_NULL(
11695 process_crypto_request(ts_params->valid_devs[0],
11696 ut_params->op), "failed to process sym crypto op");
11698 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11699 "crypto op processing failed");
11702 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11703 uint8_t *, prepend_len);
11705 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11706 uint8_t *, prepend_len);
11710 fragsz = fragsz_oop;
11712 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11714 tdata->ciphertext.data,
11716 "Ciphertext data not as expected");
11718 buf = ut_params->op->sym->m_src->next;
11720 buf = ut_params->op->sym->m_dst->next;
11722 unsigned int off = fragsz;
11726 ciphertext = rte_pktmbuf_mtod(buf,
11729 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11731 tdata->ciphertext.data + off,
11733 "Ciphertext data not as expected");
11735 off += to_trn_tbl[ecx++];
11739 auth_tag = digest_mem;
11740 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11742 tdata->auth_tag.data,
11743 tdata->auth_tag.len,
11744 "Generated auth tag not as expected");
11750 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11752 return test_authenticated_encryption_SGL(
11753 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11757 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11759 return test_authenticated_encryption_SGL(
11760 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11764 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11766 return test_authenticated_encryption_SGL(
11767 &gcm_test_case_8, OUT_OF_PLACE, 400,
11768 gcm_test_case_8.plaintext.len);
11772 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11774 /* This test is not for OPENSSL PMD */
11775 if (gbl_driver_id == rte_cryptodev_driver_id_get(
11776 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
11779 return test_authenticated_encryption_SGL(
11780 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11784 test_authentication_verify_fail_when_data_corrupted(
11785 struct crypto_testsuite_params *ts_params,
11786 struct crypto_unittest_params *ut_params,
11787 const struct test_crypto_vector *reference)
11789 return test_authentication_verify_fail_when_data_corruption(
11790 ts_params, ut_params, reference, 1);
11794 test_authentication_verify_fail_when_tag_corrupted(
11795 struct crypto_testsuite_params *ts_params,
11796 struct crypto_unittest_params *ut_params,
11797 const struct test_crypto_vector *reference)
11799 return test_authentication_verify_fail_when_data_corruption(
11800 ts_params, ut_params, reference, 0);
11804 test_authentication_verify_GMAC_fail_when_data_corrupted(
11805 struct crypto_testsuite_params *ts_params,
11806 struct crypto_unittest_params *ut_params,
11807 const struct test_crypto_vector *reference)
11809 return test_authentication_verify_GMAC_fail_when_corruption(
11810 ts_params, ut_params, reference, 1);
11814 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11815 struct crypto_testsuite_params *ts_params,
11816 struct crypto_unittest_params *ut_params,
11817 const struct test_crypto_vector *reference)
11819 return test_authentication_verify_GMAC_fail_when_corruption(
11820 ts_params, ut_params, reference, 0);
11824 test_authenticated_decryption_fail_when_data_corrupted(
11825 struct crypto_testsuite_params *ts_params,
11826 struct crypto_unittest_params *ut_params,
11827 const struct test_crypto_vector *reference)
11829 return test_authenticated_decryption_fail_when_corruption(
11830 ts_params, ut_params, reference, 1);
11834 test_authenticated_decryption_fail_when_tag_corrupted(
11835 struct crypto_testsuite_params *ts_params,
11836 struct crypto_unittest_params *ut_params,
11837 const struct test_crypto_vector *reference)
11839 return test_authenticated_decryption_fail_when_corruption(
11840 ts_params, ut_params, reference, 0);
11844 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11846 return test_authentication_verify_fail_when_data_corrupted(
11847 &testsuite_params, &unittest_params,
11848 &hmac_sha1_test_crypto_vector);
11852 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11854 return test_authentication_verify_fail_when_tag_corrupted(
11855 &testsuite_params, &unittest_params,
11856 &hmac_sha1_test_crypto_vector);
11860 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11862 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11863 &testsuite_params, &unittest_params,
11864 &aes128_gmac_test_vector);
11868 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11870 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11871 &testsuite_params, &unittest_params,
11872 &aes128_gmac_test_vector);
11876 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11878 return test_authenticated_decryption_fail_when_data_corrupted(
11881 &aes128cbc_hmac_sha1_test_vector);
11885 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11887 return test_authenticated_decryption_fail_when_tag_corrupted(
11890 &aes128cbc_hmac_sha1_test_vector);
11894 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11896 return test_authenticated_encryt_with_esn(
11899 &aes128cbc_hmac_sha1_aad_test_vector);
11903 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11905 return test_authenticated_decrypt_with_esn(
11908 &aes128cbc_hmac_sha1_aad_test_vector);
11912 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
11914 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
11918 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
11920 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
11923 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11925 /* global AESNI worker IDs for the scheduler test */
11926 uint8_t aesni_ids[2];
11929 test_scheduler_attach_slave_op(void)
11931 struct crypto_testsuite_params *ts_params = &testsuite_params;
11932 uint8_t sched_id = ts_params->valid_devs[0];
11933 uint32_t nb_devs, i, nb_devs_attached = 0;
11935 char vdev_name[32];
11937 /* create 2 AESNI_MB if necessary */
11938 nb_devs = rte_cryptodev_device_count_by_driver(
11939 rte_cryptodev_driver_id_get(
11940 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11942 for (i = nb_devs; i < 2; i++) {
11943 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11944 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11946 ret = rte_vdev_init(vdev_name, NULL);
11948 TEST_ASSERT(ret == 0,
11949 "Failed to create instance %u of"
11951 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11955 /* attach 2 AESNI_MB cdevs */
11956 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11958 struct rte_cryptodev_info info;
11959 unsigned int session_size;
11961 rte_cryptodev_info_get(i, &info);
11962 if (info.driver_id != rte_cryptodev_driver_id_get(
11963 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11966 session_size = rte_cryptodev_sym_get_private_session_size(i);
11968 * Create the session mempool again, since now there are new devices
11969 * to use the mempool.
11971 if (ts_params->session_mpool) {
11972 rte_mempool_free(ts_params->session_mpool);
11973 ts_params->session_mpool = NULL;
11975 if (ts_params->session_priv_mpool) {
11976 rte_mempool_free(ts_params->session_priv_mpool);
11977 ts_params->session_priv_mpool = NULL;
11980 if (info.sym.max_nb_sessions != 0 &&
11981 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11982 RTE_LOG(ERR, USER1,
11983 "Device does not support "
11984 "at least %u sessions\n",
11986 return TEST_FAILED;
11989 * Create mempool with maximum number of sessions,
11990 * to include the session headers
11992 if (ts_params->session_mpool == NULL) {
11993 ts_params->session_mpool =
11994 rte_cryptodev_sym_session_pool_create(
11996 MAX_NB_SESSIONS, 0, 0, 0,
11998 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11999 "session mempool allocation failed");
12003 * Create mempool with maximum number of sessions,
12004 * to include device specific session private data
12006 if (ts_params->session_priv_mpool == NULL) {
12007 ts_params->session_priv_mpool = rte_mempool_create(
12008 "test_sess_mp_priv",
12011 0, 0, NULL, NULL, NULL,
12012 NULL, SOCKET_ID_ANY,
12015 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
12016 "session mempool allocation failed");
12019 ts_params->qp_conf.mp_session = ts_params->session_mpool;
12020 ts_params->qp_conf.mp_session_private =
12021 ts_params->session_priv_mpool;
12023 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
12026 TEST_ASSERT(ret == 0,
12027 "Failed to attach device %u of pmd : %s", i,
12028 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12030 aesni_ids[nb_devs_attached] = (uint8_t)i;
12032 nb_devs_attached++;
12039 test_scheduler_detach_slave_op(void)
12041 struct crypto_testsuite_params *ts_params = &testsuite_params;
12042 uint8_t sched_id = ts_params->valid_devs[0];
12046 for (i = 0; i < 2; i++) {
12047 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
12049 TEST_ASSERT(ret == 0,
12050 "Failed to detach device %u", aesni_ids[i]);
12057 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
12059 struct crypto_testsuite_params *ts_params = &testsuite_params;
12060 uint8_t sched_id = ts_params->valid_devs[0];
12062 return rte_cryptodev_scheduler_mode_set(sched_id,
12067 test_scheduler_mode_roundrobin_op(void)
12069 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
12070 0, "Failed to set roundrobin mode");
12076 test_scheduler_mode_multicore_op(void)
12078 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
12079 0, "Failed to set multicore mode");
12085 test_scheduler_mode_failover_op(void)
12087 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
12088 0, "Failed to set failover mode");
12094 test_scheduler_mode_pkt_size_distr_op(void)
12096 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
12097 0, "Failed to set pktsize mode");
12102 static struct unit_test_suite cryptodev_scheduler_testsuite = {
12103 .suite_name = "Crypto Device Scheduler Unit Test Suite",
12104 .setup = testsuite_setup,
12105 .teardown = testsuite_teardown,
12106 .unit_test_cases = {
12108 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12109 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
12110 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12111 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12112 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12113 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12116 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12117 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
12118 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12119 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12120 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12121 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12124 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12125 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
12126 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12127 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12128 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12129 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12132 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12133 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
12134 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12135 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12136 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12137 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12139 TEST_CASES_END() /**< NULL terminate unit test array */
12143 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
12145 static struct unit_test_suite cryptodev_testsuite = {
12146 .suite_name = "Crypto Unit Test Suite",
12147 .setup = testsuite_setup,
12148 .teardown = testsuite_teardown,
12149 .unit_test_cases = {
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_device_configure_invalid_dev_id),
12152 TEST_CASE_ST(ut_setup, ut_teardown,
12153 test_queue_pair_descriptor_setup),
12154 TEST_CASE_ST(ut_setup, ut_teardown,
12155 test_device_configure_invalid_queue_pair_ids),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_multi_session),
12159 TEST_CASE_ST(ut_setup, ut_teardown,
12160 test_multi_session_random_usage),
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_null_invalid_operation),
12164 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
12166 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12167 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12168 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12169 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12170 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
12171 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
12172 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
12173 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12174 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
12176 /** AES CCM Authenticated Encryption 128 bits key */
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 test_AES_CCM_authenticated_encryption_test_case_128_1),
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 test_AES_CCM_authenticated_encryption_test_case_128_2),
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 test_AES_CCM_authenticated_encryption_test_case_128_3),
12184 /** AES CCM Authenticated Decryption 128 bits key*/
12185 TEST_CASE_ST(ut_setup, ut_teardown,
12186 test_AES_CCM_authenticated_decryption_test_case_128_1),
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_AES_CCM_authenticated_decryption_test_case_128_2),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_AES_CCM_authenticated_decryption_test_case_128_3),
12192 /** AES CCM Authenticated Encryption 192 bits key */
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_AES_CCM_authenticated_encryption_test_case_192_1),
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_AES_CCM_authenticated_encryption_test_case_192_2),
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_AES_CCM_authenticated_encryption_test_case_192_3),
12200 /** AES CCM Authenticated Decryption 192 bits key*/
12201 TEST_CASE_ST(ut_setup, ut_teardown,
12202 test_AES_CCM_authenticated_decryption_test_case_192_1),
12203 TEST_CASE_ST(ut_setup, ut_teardown,
12204 test_AES_CCM_authenticated_decryption_test_case_192_2),
12205 TEST_CASE_ST(ut_setup, ut_teardown,
12206 test_AES_CCM_authenticated_decryption_test_case_192_3),
12208 /** AES CCM Authenticated Encryption 256 bits key */
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_AES_CCM_authenticated_encryption_test_case_256_1),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_AES_CCM_authenticated_encryption_test_case_256_2),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_AES_CCM_authenticated_encryption_test_case_256_3),
12216 /** AES CCM Authenticated Decryption 256 bits key*/
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_AES_CCM_authenticated_decryption_test_case_256_1),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_AES_CCM_authenticated_decryption_test_case_256_2),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_AES_CCM_authenticated_decryption_test_case_256_3),
12224 /** AES GCM Authenticated Encryption */
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_AES_GCM_authenticated_encryption_test_case_1),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_AES_GCM_authenticated_encryption_test_case_2),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_AES_GCM_authenticated_encryption_test_case_3),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_AES_GCM_authenticated_encryption_test_case_4),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_AES_GCM_authenticated_encryption_test_case_5),
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 test_AES_GCM_authenticated_encryption_test_case_6),
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_AES_GCM_authenticated_encryption_test_case_7),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_authenticated_encryption_test_case_8),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_AES_GCM_J0_authenticated_encryption_test_case_1),
12252 /** AES GCM Authenticated Decryption */
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_authenticated_decryption_test_case_1),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_authenticated_decryption_test_case_2),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_AES_GCM_authenticated_decryption_test_case_3),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_AES_GCM_authenticated_decryption_test_case_4),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_AES_GCM_authenticated_decryption_test_case_5),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_AES_GCM_authenticated_decryption_test_case_6),
12265 TEST_CASE_ST(ut_setup, ut_teardown,
12266 test_AES_GCM_authenticated_decryption_test_case_7),
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_AES_GCM_authenticated_decryption_test_case_8),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_AES_GCM_J0_authenticated_decryption_test_case_1),
12272 /** AES GCM Authenticated Encryption 192 bits key */
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 test_AES_GCM_auth_encryption_test_case_192_1),
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 test_AES_GCM_auth_encryption_test_case_192_2),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_AES_GCM_auth_encryption_test_case_192_3),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_AES_GCM_auth_encryption_test_case_192_4),
12281 TEST_CASE_ST(ut_setup, ut_teardown,
12282 test_AES_GCM_auth_encryption_test_case_192_5),
12283 TEST_CASE_ST(ut_setup, ut_teardown,
12284 test_AES_GCM_auth_encryption_test_case_192_6),
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_AES_GCM_auth_encryption_test_case_192_7),
12288 /** AES GCM Authenticated Decryption 192 bits key */
12289 TEST_CASE_ST(ut_setup, ut_teardown,
12290 test_AES_GCM_auth_decryption_test_case_192_1),
12291 TEST_CASE_ST(ut_setup, ut_teardown,
12292 test_AES_GCM_auth_decryption_test_case_192_2),
12293 TEST_CASE_ST(ut_setup, ut_teardown,
12294 test_AES_GCM_auth_decryption_test_case_192_3),
12295 TEST_CASE_ST(ut_setup, ut_teardown,
12296 test_AES_GCM_auth_decryption_test_case_192_4),
12297 TEST_CASE_ST(ut_setup, ut_teardown,
12298 test_AES_GCM_auth_decryption_test_case_192_5),
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_AES_GCM_auth_decryption_test_case_192_6),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_AES_GCM_auth_decryption_test_case_192_7),
12304 /** AES GCM Authenticated Encryption 256 bits key */
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_AES_GCM_auth_encryption_test_case_256_1),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_AES_GCM_auth_encryption_test_case_256_2),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_AES_GCM_auth_encryption_test_case_256_3),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_AES_GCM_auth_encryption_test_case_256_4),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_AES_GCM_auth_encryption_test_case_256_5),
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_AES_GCM_auth_encryption_test_case_256_6),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_AES_GCM_auth_encryption_test_case_256_7),
12320 /** AES GCM Authenticated Decryption 256 bits key */
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_AES_GCM_auth_decryption_test_case_256_1),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_AES_GCM_auth_decryption_test_case_256_2),
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_AES_GCM_auth_decryption_test_case_256_3),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_AES_GCM_auth_decryption_test_case_256_4),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_AES_GCM_auth_decryption_test_case_256_5),
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_AES_GCM_auth_decryption_test_case_256_6),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_AES_GCM_auth_decryption_test_case_256_7),
12336 /** AES GCM Authenticated Encryption big aad size */
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_AES_GCM_auth_encryption_test_case_aad_1),
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_AES_GCM_auth_encryption_test_case_aad_2),
12342 /** AES GCM Authenticated Decryption big aad size */
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_AES_GCM_auth_decryption_test_case_aad_1),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_AES_GCM_auth_decryption_test_case_aad_2),
12348 /** Out of place tests */
12349 TEST_CASE_ST(ut_setup, ut_teardown,
12350 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12354 /** Session-less tests */
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12360 /** AES GMAC Authentication */
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_AES_GMAC_authentication_test_case_1),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 test_AES_GMAC_authentication_verify_test_case_1),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_AES_GMAC_authentication_test_case_2),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_AES_GMAC_authentication_verify_test_case_2),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_AES_GMAC_authentication_test_case_3),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_AES_GMAC_authentication_verify_test_case_3),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_AES_GMAC_authentication_test_case_4),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_AES_GMAC_authentication_verify_test_case_4),
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_AES_GMAC_authentication_SGL_40B),
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_AES_GMAC_authentication_SGL_80B),
12381 TEST_CASE_ST(ut_setup, ut_teardown,
12382 test_AES_GMAC_authentication_SGL_2048B),
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_AES_GMAC_authentication_SGL_2047B),
12386 /** Chacha20-Poly1305 */
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_chacha20_poly1305_encrypt_test_case_rfc8439),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_chacha20_poly1305_decrypt_test_case_rfc8439),
12391 /** SNOW 3G encrypt only (UEA2) */
12392 TEST_CASE_ST(ut_setup, ut_teardown,
12393 test_snow3g_encryption_test_case_1),
12394 TEST_CASE_ST(ut_setup, ut_teardown,
12395 test_snow3g_encryption_test_case_2),
12396 TEST_CASE_ST(ut_setup, ut_teardown,
12397 test_snow3g_encryption_test_case_3),
12398 TEST_CASE_ST(ut_setup, ut_teardown,
12399 test_snow3g_encryption_test_case_4),
12400 TEST_CASE_ST(ut_setup, ut_teardown,
12401 test_snow3g_encryption_test_case_5),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_snow3g_encryption_test_case_1_oop),
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_snow3g_encryption_test_case_1_oop_sgl),
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_snow3g_encryption_test_case_1_offset_oop),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_snow3g_decryption_test_case_1_oop),
12412 /** SNOW 3G generate auth, then encrypt (UEA2) */
12413 TEST_CASE_ST(ut_setup, ut_teardown,
12414 test_snow3g_auth_cipher_test_case_1),
12415 TEST_CASE_ST(ut_setup, ut_teardown,
12416 test_snow3g_auth_cipher_test_case_2),
12417 TEST_CASE_ST(ut_setup, ut_teardown,
12418 test_snow3g_auth_cipher_test_case_2_oop),
12419 TEST_CASE_ST(ut_setup, ut_teardown,
12420 test_snow3g_auth_cipher_part_digest_enc),
12421 TEST_CASE_ST(ut_setup, ut_teardown,
12422 test_snow3g_auth_cipher_part_digest_enc_oop),
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_snow3g_auth_cipher_test_case_3_sgl),
12425 TEST_CASE_ST(ut_setup, ut_teardown,
12426 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_snow3g_auth_cipher_part_digest_enc_sgl),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12432 /** SNOW 3G decrypt (UEA2), then verify auth */
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_snow3g_auth_cipher_verify_test_case_1),
12435 TEST_CASE_ST(ut_setup, ut_teardown,
12436 test_snow3g_auth_cipher_verify_test_case_2),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_snow3g_auth_cipher_verify_test_case_2_oop),
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 test_snow3g_auth_cipher_verify_part_digest_enc),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12452 /** SNOW 3G decrypt only (UEA2) */
12453 TEST_CASE_ST(ut_setup, ut_teardown,
12454 test_snow3g_decryption_test_case_1),
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_snow3g_decryption_test_case_2),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_snow3g_decryption_test_case_3),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 test_snow3g_decryption_test_case_4),
12461 TEST_CASE_ST(ut_setup, ut_teardown,
12462 test_snow3g_decryption_test_case_5),
12463 TEST_CASE_ST(ut_setup, ut_teardown,
12464 test_snow3g_decryption_with_digest_test_case_1),
12465 TEST_CASE_ST(ut_setup, ut_teardown,
12466 test_snow3g_hash_generate_test_case_1),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_snow3g_hash_generate_test_case_2),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 test_snow3g_hash_generate_test_case_3),
12471 /* Tests with buffers which length is not byte-aligned */
12472 TEST_CASE_ST(ut_setup, ut_teardown,
12473 test_snow3g_hash_generate_test_case_4),
12474 TEST_CASE_ST(ut_setup, ut_teardown,
12475 test_snow3g_hash_generate_test_case_5),
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_snow3g_hash_generate_test_case_6),
12478 TEST_CASE_ST(ut_setup, ut_teardown,
12479 test_snow3g_hash_verify_test_case_1),
12480 TEST_CASE_ST(ut_setup, ut_teardown,
12481 test_snow3g_hash_verify_test_case_2),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_snow3g_hash_verify_test_case_3),
12484 /* Tests with buffers which length is not byte-aligned */
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_snow3g_hash_verify_test_case_4),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_snow3g_hash_verify_test_case_5),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_snow3g_hash_verify_test_case_6),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_snow3g_cipher_auth_test_case_1),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_snow3g_auth_cipher_with_digest_test_case_1),
12496 /** ZUC encrypt only (EEA3) */
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 test_zuc_encryption_test_case_1),
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 test_zuc_encryption_test_case_2),
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_zuc_encryption_test_case_3),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_zuc_encryption_test_case_4),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_zuc_encryption_test_case_5),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_zuc_encryption_test_case_6_sgl),
12510 /** ZUC authenticate (EIA3) */
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 test_zuc_hash_generate_test_case_1),
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_zuc_hash_generate_test_case_2),
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 test_zuc_hash_generate_test_case_3),
12517 TEST_CASE_ST(ut_setup, ut_teardown,
12518 test_zuc_hash_generate_test_case_4),
12519 TEST_CASE_ST(ut_setup, ut_teardown,
12520 test_zuc_hash_generate_test_case_5),
12521 TEST_CASE_ST(ut_setup, ut_teardown,
12522 test_zuc_hash_generate_test_case_6),
12523 TEST_CASE_ST(ut_setup, ut_teardown,
12524 test_zuc_hash_generate_test_case_7),
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 test_zuc_hash_generate_test_case_8),
12528 /** ZUC alg-chain (EEA3/EIA3) */
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 test_zuc_cipher_auth_test_case_1),
12531 TEST_CASE_ST(ut_setup, ut_teardown,
12532 test_zuc_cipher_auth_test_case_2),
12534 /** ZUC generate auth, then encrypt (EEA3) */
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_zuc_auth_cipher_test_case_1),
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_zuc_auth_cipher_test_case_1_oop),
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_zuc_auth_cipher_test_case_1_sgl),
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 test_zuc_auth_cipher_test_case_1_oop_sgl),
12544 /** ZUC decrypt (EEA3), then verify auth */
12545 TEST_CASE_ST(ut_setup, ut_teardown,
12546 test_zuc_auth_cipher_verify_test_case_1),
12547 TEST_CASE_ST(ut_setup, ut_teardown,
12548 test_zuc_auth_cipher_verify_test_case_1_oop),
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_zuc_auth_cipher_verify_test_case_1_sgl),
12551 TEST_CASE_ST(ut_setup, ut_teardown,
12552 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12554 /** HMAC_MD5 Authentication */
12555 TEST_CASE_ST(ut_setup, ut_teardown,
12556 test_MD5_HMAC_generate_case_1),
12557 TEST_CASE_ST(ut_setup, ut_teardown,
12558 test_MD5_HMAC_verify_case_1),
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_MD5_HMAC_generate_case_2),
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_MD5_HMAC_verify_case_2),
12564 /** KASUMI hash only (UIA1) */
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_kasumi_hash_generate_test_case_1),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_kasumi_hash_generate_test_case_2),
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 test_kasumi_hash_generate_test_case_3),
12571 TEST_CASE_ST(ut_setup, ut_teardown,
12572 test_kasumi_hash_generate_test_case_4),
12573 TEST_CASE_ST(ut_setup, ut_teardown,
12574 test_kasumi_hash_generate_test_case_5),
12575 TEST_CASE_ST(ut_setup, ut_teardown,
12576 test_kasumi_hash_generate_test_case_6),
12578 TEST_CASE_ST(ut_setup, ut_teardown,
12579 test_kasumi_hash_verify_test_case_1),
12580 TEST_CASE_ST(ut_setup, ut_teardown,
12581 test_kasumi_hash_verify_test_case_2),
12582 TEST_CASE_ST(ut_setup, ut_teardown,
12583 test_kasumi_hash_verify_test_case_3),
12584 TEST_CASE_ST(ut_setup, ut_teardown,
12585 test_kasumi_hash_verify_test_case_4),
12586 TEST_CASE_ST(ut_setup, ut_teardown,
12587 test_kasumi_hash_verify_test_case_5),
12589 /** KASUMI encrypt only (UEA1) */
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_kasumi_encryption_test_case_1),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_kasumi_encryption_test_case_1_sgl),
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_kasumi_encryption_test_case_1_oop),
12596 TEST_CASE_ST(ut_setup, ut_teardown,
12597 test_kasumi_encryption_test_case_1_oop_sgl),
12598 TEST_CASE_ST(ut_setup, ut_teardown,
12599 test_kasumi_encryption_test_case_2),
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_kasumi_encryption_test_case_3),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_kasumi_encryption_test_case_4),
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_kasumi_encryption_test_case_5),
12607 /** KASUMI decrypt only (UEA1) */
12608 TEST_CASE_ST(ut_setup, ut_teardown,
12609 test_kasumi_decryption_test_case_1),
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_kasumi_decryption_test_case_2),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_kasumi_decryption_test_case_3),
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_kasumi_decryption_test_case_4),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_kasumi_decryption_test_case_5),
12618 TEST_CASE_ST(ut_setup, ut_teardown,
12619 test_kasumi_decryption_test_case_1_oop),
12621 TEST_CASE_ST(ut_setup, ut_teardown,
12622 test_kasumi_cipher_auth_test_case_1),
12624 /** KASUMI generate auth, then encrypt (F8) */
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_kasumi_auth_cipher_test_case_1),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_kasumi_auth_cipher_test_case_2),
12629 TEST_CASE_ST(ut_setup, ut_teardown,
12630 test_kasumi_auth_cipher_test_case_2_oop),
12631 TEST_CASE_ST(ut_setup, ut_teardown,
12632 test_kasumi_auth_cipher_test_case_2_sgl),
12633 TEST_CASE_ST(ut_setup, ut_teardown,
12634 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12636 /** KASUMI decrypt (F8), then verify auth */
12637 TEST_CASE_ST(ut_setup, ut_teardown,
12638 test_kasumi_auth_cipher_verify_test_case_1),
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 test_kasumi_auth_cipher_verify_test_case_2),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_kasumi_auth_cipher_verify_test_case_2_oop),
12643 TEST_CASE_ST(ut_setup, ut_teardown,
12644 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12645 TEST_CASE_ST(ut_setup, ut_teardown,
12646 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12648 /** ESN Testcase */
12649 TEST_CASE_ST(ut_setup, ut_teardown,
12650 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12651 TEST_CASE_ST(ut_setup, ut_teardown,
12652 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12654 /** Negative tests */
12655 TEST_CASE_ST(ut_setup, ut_teardown,
12656 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12657 TEST_CASE_ST(ut_setup, ut_teardown,
12658 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12661 TEST_CASE_ST(ut_setup, ut_teardown,
12662 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12667 TEST_CASE_ST(ut_setup, ut_teardown,
12668 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12677 TEST_CASE_ST(ut_setup, ut_teardown,
12678 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12679 TEST_CASE_ST(ut_setup, ut_teardown,
12680 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12681 TEST_CASE_ST(ut_setup, ut_teardown,
12682 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12683 TEST_CASE_ST(ut_setup, ut_teardown,
12684 authentication_verify_AES128_GMAC_fail_data_corrupt),
12685 TEST_CASE_ST(ut_setup, ut_teardown,
12686 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12687 TEST_CASE_ST(ut_setup, ut_teardown,
12688 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12692 /** Mixed CIPHER + HASH algorithms */
12693 /** AUTH AES CMAC + CIPHER AES CTR */
12694 TEST_CASE_ST(ut_setup, ut_teardown,
12695 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12698 TEST_CASE_ST(ut_setup, ut_teardown,
12699 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12702 TEST_CASE_ST(ut_setup, ut_teardown,
12703 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12704 TEST_CASE_ST(ut_setup, ut_teardown,
12705 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12708 TEST_CASE_ST(ut_setup, ut_teardown,
12709 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12711 /** AUTH ZUC + CIPHER SNOW3G */
12712 TEST_CASE_ST(ut_setup, ut_teardown,
12713 test_auth_zuc_cipher_snow_test_case_1),
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_verify_auth_zuc_cipher_snow_test_case_1),
12716 /** AUTH AES CMAC + CIPHER SNOW3G */
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_auth_aes_cmac_cipher_snow_test_case_1),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12721 /** AUTH ZUC + CIPHER AES CTR */
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_auth_zuc_cipher_aes_ctr_test_case_1),
12724 TEST_CASE_ST(ut_setup, ut_teardown,
12725 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12726 /** AUTH SNOW3G + CIPHER AES CTR */
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_auth_snow_cipher_aes_ctr_test_case_1),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12731 /** AUTH SNOW3G + CIPHER ZUC */
12732 TEST_CASE_ST(ut_setup, ut_teardown,
12733 test_auth_snow_cipher_zuc_test_case_1),
12734 TEST_CASE_ST(ut_setup, ut_teardown,
12735 test_verify_auth_snow_cipher_zuc_test_case_1),
12736 /** AUTH AES CMAC + CIPHER ZUC */
12737 TEST_CASE_ST(ut_setup, ut_teardown,
12738 test_auth_aes_cmac_cipher_zuc_test_case_1),
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12742 /** AUTH NULL + CIPHER SNOW3G */
12743 TEST_CASE_ST(ut_setup, ut_teardown,
12744 test_auth_null_cipher_snow_test_case_1),
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_verify_auth_null_cipher_snow_test_case_1),
12747 /** AUTH NULL + CIPHER ZUC */
12748 TEST_CASE_ST(ut_setup, ut_teardown,
12749 test_auth_null_cipher_zuc_test_case_1),
12750 TEST_CASE_ST(ut_setup, ut_teardown,
12751 test_verify_auth_null_cipher_zuc_test_case_1),
12752 /** AUTH SNOW3G + CIPHER NULL */
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_auth_snow_cipher_null_test_case_1),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_verify_auth_snow_cipher_null_test_case_1),
12757 /** AUTH ZUC + CIPHER NULL */
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_auth_zuc_cipher_null_test_case_1),
12760 TEST_CASE_ST(ut_setup, ut_teardown,
12761 test_verify_auth_zuc_cipher_null_test_case_1),
12762 /** AUTH NULL + CIPHER AES CTR */
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_auth_null_cipher_aes_ctr_test_case_1),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12767 /** AUTH AES CMAC + CIPHER NULL */
12768 TEST_CASE_ST(ut_setup, ut_teardown,
12769 test_auth_aes_cmac_cipher_null_test_case_1),
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12773 #ifdef RTE_LIBRTE_SECURITY
12774 TEST_CASE_ST(ut_setup_security, ut_teardown,
12775 test_PDCP_PROTO_all),
12776 TEST_CASE_ST(ut_setup_security, ut_teardown,
12777 test_DOCSIS_PROTO_all),
12779 TEST_CASES_END() /**< NULL terminate unit test array */
12783 static struct unit_test_suite cryptodev_virtio_testsuite = {
12784 .suite_name = "Crypto VIRTIO Unit Test Suite",
12785 .setup = testsuite_setup,
12786 .teardown = testsuite_teardown,
12787 .unit_test_cases = {
12788 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12790 TEST_CASES_END() /**< NULL terminate unit test array */
12794 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
12795 .suite_name = "Crypto CAAM JR Unit Test Suite",
12796 .setup = testsuite_setup,
12797 .teardown = testsuite_teardown,
12798 .unit_test_cases = {
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_device_configure_invalid_dev_id),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_multi_session),
12804 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12805 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12806 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12807 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12808 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12810 TEST_CASES_END() /**< NULL terminate unit test array */
12814 static struct unit_test_suite cryptodev_mrvl_testsuite = {
12815 .suite_name = "Crypto Device Marvell Component Test Suite",
12816 .setup = testsuite_setup,
12817 .teardown = testsuite_teardown,
12818 .unit_test_cases = {
12819 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 test_multi_session_random_usage),
12822 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12823 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12824 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12825 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12826 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12828 /** Negative tests */
12829 TEST_CASE_ST(ut_setup, ut_teardown,
12830 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12838 TEST_CASES_END() /**< NULL terminate unit test array */
12842 static struct unit_test_suite cryptodev_ccp_testsuite = {
12843 .suite_name = "Crypto Device CCP Unit Test Suite",
12844 .setup = testsuite_setup,
12845 .teardown = testsuite_teardown,
12846 .unit_test_cases = {
12847 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12848 TEST_CASE_ST(ut_setup, ut_teardown,
12849 test_multi_session_random_usage),
12850 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12851 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12852 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12853 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12854 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12856 /** Negative tests */
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12866 TEST_CASES_END() /**< NULL terminate unit test array */
12871 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
12873 gbl_driver_id = rte_cryptodev_driver_id_get(
12874 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
12876 if (gbl_driver_id == -1) {
12877 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
12878 return TEST_SKIPPED;
12881 return unit_test_suite_runner(&cryptodev_testsuite);
12885 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
12887 gbl_driver_id = rte_cryptodev_driver_id_get(
12888 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
12890 if (gbl_driver_id == -1) {
12891 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
12892 return TEST_FAILED;
12895 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12899 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12901 gbl_driver_id = rte_cryptodev_driver_id_get(
12902 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12904 if (gbl_driver_id == -1) {
12905 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
12906 return TEST_SKIPPED;
12909 return unit_test_suite_runner(&cryptodev_testsuite);
12913 test_cryptodev_cpu_aesni_mb(void)
12916 enum rte_security_session_action_type at;
12918 gbl_driver_id = rte_cryptodev_driver_id_get(
12919 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12921 if (gbl_driver_id == -1) {
12922 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
12923 return TEST_SKIPPED;
12926 at = gbl_action_type;
12927 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
12928 rc = unit_test_suite_runner(&cryptodev_testsuite);
12929 gbl_action_type = at;
12934 test_cryptodev_openssl(void)
12936 gbl_driver_id = rte_cryptodev_driver_id_get(
12937 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
12939 if (gbl_driver_id == -1) {
12940 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
12941 return TEST_SKIPPED;
12944 return unit_test_suite_runner(&cryptodev_testsuite);
12948 test_cryptodev_aesni_gcm(void)
12950 gbl_driver_id = rte_cryptodev_driver_id_get(
12951 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12953 if (gbl_driver_id == -1) {
12954 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
12955 return TEST_SKIPPED;
12958 return unit_test_suite_runner(&cryptodev_testsuite);
12962 test_cryptodev_cpu_aesni_gcm(void)
12965 enum rte_security_session_action_type at;
12967 gbl_driver_id = rte_cryptodev_driver_id_get(
12968 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12970 if (gbl_driver_id == -1) {
12971 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
12972 return TEST_SKIPPED;
12975 at = gbl_action_type;
12976 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
12977 rc = unit_test_suite_runner(&cryptodev_testsuite);
12978 gbl_action_type = at;
12983 test_cryptodev_null(void)
12985 gbl_driver_id = rte_cryptodev_driver_id_get(
12986 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
12988 if (gbl_driver_id == -1) {
12989 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
12990 return TEST_SKIPPED;
12993 return unit_test_suite_runner(&cryptodev_testsuite);
12997 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
12999 gbl_driver_id = rte_cryptodev_driver_id_get(
13000 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13002 if (gbl_driver_id == -1) {
13003 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
13004 return TEST_SKIPPED;
13007 return unit_test_suite_runner(&cryptodev_testsuite);
13011 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13013 gbl_driver_id = rte_cryptodev_driver_id_get(
13014 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13016 if (gbl_driver_id == -1) {
13017 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
13018 return TEST_SKIPPED;
13021 return unit_test_suite_runner(&cryptodev_testsuite);
13025 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13027 gbl_driver_id = rte_cryptodev_driver_id_get(
13028 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13030 if (gbl_driver_id == -1) {
13031 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
13032 return TEST_SKIPPED;
13035 return unit_test_suite_runner(&cryptodev_testsuite);
13039 test_cryptodev_armv8(void)
13041 gbl_driver_id = rte_cryptodev_driver_id_get(
13042 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13044 if (gbl_driver_id == -1) {
13045 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
13046 return TEST_SKIPPED;
13049 return unit_test_suite_runner(&cryptodev_testsuite);
13053 test_cryptodev_mrvl(void)
13055 gbl_driver_id = rte_cryptodev_driver_id_get(
13056 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13058 if (gbl_driver_id == -1) {
13059 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
13060 return TEST_SKIPPED;
13063 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13066 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13069 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13071 gbl_driver_id = rte_cryptodev_driver_id_get(
13072 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13074 if (gbl_driver_id == -1) {
13075 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
13076 return TEST_SKIPPED;
13079 if (rte_cryptodev_driver_id_get(
13080 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13081 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13082 return TEST_SKIPPED;
13084 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13087 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13092 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13094 gbl_driver_id = rte_cryptodev_driver_id_get(
13095 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13097 if (gbl_driver_id == -1) {
13098 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
13099 return TEST_SKIPPED;
13102 return unit_test_suite_runner(&cryptodev_testsuite);
13106 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13108 gbl_driver_id = rte_cryptodev_driver_id_get(
13109 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13111 if (gbl_driver_id == -1) {
13112 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
13113 return TEST_SKIPPED;
13116 return unit_test_suite_runner(&cryptodev_testsuite);
13120 test_cryptodev_ccp(void)
13122 gbl_driver_id = rte_cryptodev_driver_id_get(
13123 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13125 if (gbl_driver_id == -1) {
13126 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
13127 return TEST_FAILED;
13130 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13134 test_cryptodev_octeontx(void)
13136 gbl_driver_id = rte_cryptodev_driver_id_get(
13137 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13138 if (gbl_driver_id == -1) {
13139 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
13140 return TEST_FAILED;
13142 return unit_test_suite_runner(&cryptodev_testsuite);
13146 test_cryptodev_octeontx2(void)
13148 gbl_driver_id = rte_cryptodev_driver_id_get(
13149 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13150 if (gbl_driver_id == -1) {
13151 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
13152 return TEST_FAILED;
13154 return unit_test_suite_runner(&cryptodev_testsuite);
13158 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13160 gbl_driver_id = rte_cryptodev_driver_id_get(
13161 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13163 if (gbl_driver_id == -1) {
13164 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
13165 return TEST_FAILED;
13168 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13172 test_cryptodev_nitrox(void)
13174 gbl_driver_id = rte_cryptodev_driver_id_get(
13175 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13177 if (gbl_driver_id == -1) {
13178 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
13179 return TEST_FAILED;
13182 return unit_test_suite_runner(&cryptodev_testsuite);
13186 test_cryptodev_bcmfs(void)
13188 gbl_driver_id = rte_cryptodev_driver_id_get(
13189 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
13191 if (gbl_driver_id == -1) {
13192 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
13193 return TEST_FAILED;
13196 return unit_test_suite_runner(&cryptodev_testsuite);
13199 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13200 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13201 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13202 test_cryptodev_cpu_aesni_mb);
13203 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13204 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13205 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13206 test_cryptodev_cpu_aesni_gcm);
13207 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13208 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13209 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13210 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13211 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13212 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13213 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13214 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13215 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13216 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13217 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13218 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13219 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13220 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
13221 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);