1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
19 #include <rte_cryptodev_pmd.h>
20 #include <rte_string_fns.h>
22 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
23 #include <rte_cryptodev_scheduler.h>
24 #include <rte_cryptodev_scheduler_operations.h>
27 #include <rte_lcore.h>
30 #include "test_cryptodev.h"
32 #include "test_cryptodev_blockcipher.h"
33 #include "test_cryptodev_aes_test_vectors.h"
34 #include "test_cryptodev_des_test_vectors.h"
35 #include "test_cryptodev_hash_test_vectors.h"
36 #include "test_cryptodev_kasumi_test_vectors.h"
37 #include "test_cryptodev_kasumi_hash_test_vectors.h"
38 #include "test_cryptodev_snow3g_test_vectors.h"
39 #include "test_cryptodev_snow3g_hash_test_vectors.h"
40 #include "test_cryptodev_zuc_test_vectors.h"
41 #include "test_cryptodev_aead_test_vectors.h"
42 #include "test_cryptodev_hmac_test_vectors.h"
43 #include "test_cryptodev_mixed_test_vectors.h"
44 #ifdef RTE_LIBRTE_SECURITY
45 #include "test_cryptodev_security_pdcp_test_vectors.h"
46 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
47 #include "test_cryptodev_security_pdcp_test_func.h"
48 #include "test_cryptodev_security_docsis_test_vectors.h"
50 #define SDAP_DISABLED 0
51 #define SDAP_ENABLED 1
54 #define VDEV_ARGS_SIZE 100
55 #define MAX_NB_SESSIONS 4
57 #define MAX_DRV_SERVICE_CTX_SIZE 256
59 #define MAX_RAW_DEQUEUE_COUNT 65535
62 #define OUT_OF_PLACE 1
65 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_testsuite_params {
76 struct rte_mempool *mbuf_pool;
77 struct rte_mempool *large_mbuf_pool;
78 struct rte_mempool *op_mpool;
79 struct rte_mempool *session_mpool;
80 struct rte_mempool *session_priv_mpool;
81 struct rte_cryptodev_config conf;
82 struct rte_cryptodev_qp_conf qp_conf;
84 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
85 uint8_t valid_dev_count;
88 struct crypto_unittest_params {
89 struct rte_crypto_sym_xform cipher_xform;
90 struct rte_crypto_sym_xform auth_xform;
91 struct rte_crypto_sym_xform aead_xform;
92 #ifdef RTE_LIBRTE_SECURITY
93 struct rte_security_docsis_xform docsis_xform;
97 struct rte_cryptodev_sym_session *sess;
98 #ifdef RTE_LIBRTE_SECURITY
99 struct rte_security_session *sec_session;
102 #ifdef RTE_LIBRTE_SECURITY
103 enum rte_security_session_action_type type;
105 struct rte_crypto_op *op;
107 struct rte_mbuf *obuf, *ibuf;
112 #define ALIGN_POW2_ROUNDUP(num, align) \
113 (((num) + (align) - 1) & ~((align) - 1))
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
131 static struct rte_mbuf *
132 setup_test_string(struct rte_mempool *mpool,
133 const char *string, size_t len, uint8_t blocksize)
135 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
136 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
138 memset(m->buf_addr, 0, m->buf_len);
140 char *dst = rte_pktmbuf_append(m, t_len);
147 rte_memcpy(dst, string, t_len);
149 memset(dst, 0, t_len);
155 /* Get number of bytes in X bits (rounding up) */
157 ceil_byte_length(uint32_t num_bits)
160 return ((num_bits >> 3) + 1);
162 return (num_bits >> 3);
166 get_raw_dp_dequeue_count(void *user_data __rte_unused)
172 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
173 uint8_t is_op_success)
175 struct rte_crypto_op *op = user_data;
176 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
177 RTE_CRYPTO_OP_STATUS_ERROR;
181 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
182 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
183 uint8_t len_in_bits, uint8_t cipher_iv_len)
185 struct rte_crypto_sym_op *sop = op->sym;
186 struct rte_crypto_op *ret_op = NULL;
187 struct rte_crypto_vec data_vec[UINT8_MAX];
188 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
189 union rte_crypto_sym_ofs ofs;
190 struct rte_crypto_sym_vec vec;
191 struct rte_crypto_sgl sgl;
193 union rte_cryptodev_session_ctx sess;
195 struct rte_crypto_raw_dp_ctx *ctx;
196 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
200 int ctx_service_size;
202 int enqueue_status, dequeue_status;
204 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
205 if (ctx_service_size < 0) {
206 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
210 ctx = malloc(ctx_service_size);
212 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
216 /* Both are enums, setting crypto_sess will suit any session type */
217 sess.crypto_sess = op->sym->session;
219 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
220 op->sess_type, sess, 0) < 0) {
221 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
227 aad_auth_iv.iova = 0;
228 aad_auth_iv.va = NULL;
235 vec.digest = &digest;
236 vec.aad = &aad_auth_iv;
237 vec.status = &status;
241 if (is_cipher && is_auth) {
242 cipher_offset = sop->cipher.data.offset;
243 cipher_len = sop->cipher.data.length;
244 auth_offset = sop->auth.data.offset;
245 auth_len = sop->auth.data.length;
246 max_len = RTE_MAX(cipher_offset + cipher_len,
247 auth_offset + auth_len);
249 max_len = max_len >> 3;
250 cipher_offset = cipher_offset >> 3;
251 auth_offset = auth_offset >> 3;
252 cipher_len = cipher_len >> 3;
253 auth_len = auth_len >> 3;
255 ofs.ofs.cipher.head = cipher_offset;
256 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
257 ofs.ofs.auth.head = auth_offset;
258 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
259 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
260 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
261 aad_auth_iv.va = rte_crypto_op_ctod_offset(
262 op, void *, IV_OFFSET + cipher_iv_len);
263 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
265 digest.va = (void *)sop->auth.digest.data;
266 digest.iova = sop->auth.digest.phys_addr;
268 } else if (is_cipher) {
269 cipher_offset = sop->cipher.data.offset;
270 cipher_len = sop->cipher.data.length;
271 max_len = cipher_len + cipher_offset;
273 max_len = max_len >> 3;
274 cipher_offset = cipher_offset >> 3;
275 cipher_len = cipher_len >> 3;
277 ofs.ofs.cipher.head = cipher_offset;
278 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
279 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
280 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
282 } else if (is_auth) {
283 auth_offset = sop->auth.data.offset;
284 auth_len = sop->auth.data.length;
285 max_len = auth_len + auth_offset;
287 max_len = max_len >> 3;
288 auth_offset = auth_offset >> 3;
289 auth_len = auth_len >> 3;
291 ofs.ofs.auth.head = auth_offset;
292 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
293 aad_auth_iv.va = rte_crypto_op_ctod_offset(
294 op, void *, IV_OFFSET + cipher_iv_len);
295 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
297 digest.va = (void *)sop->auth.digest.data;
298 digest.iova = sop->auth.digest.phys_addr;
301 cipher_offset = sop->aead.data.offset;
302 cipher_len = sop->aead.data.length;
303 max_len = cipher_len + cipher_offset;
305 max_len = max_len >> 3;
306 cipher_offset = cipher_offset >> 3;
307 cipher_len = cipher_len >> 3;
309 ofs.ofs.cipher.head = cipher_offset;
310 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
311 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
312 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
313 aad_auth_iv.va = (void *)sop->aead.aad.data;
314 aad_auth_iv.iova = sop->aead.aad.phys_addr;
315 digest.va = (void *)sop->aead.digest.data;
316 digest.iova = sop->aead.digest.phys_addr;
319 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
320 data_vec, RTE_DIM(data_vec));
321 if (n < 0 || n > sop->m_src->nb_segs) {
322 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
328 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
329 &enqueue_status) < 1) {
330 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
334 if (enqueue_status == 0) {
335 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
337 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
340 } else if (enqueue_status < 0) {
341 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
346 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
347 n = rte_cryptodev_raw_dequeue_burst(ctx,
348 get_raw_dp_dequeue_count, post_process_raw_dp_op,
349 (void **)&ret_op, 0, &n_success,
351 if (dequeue_status < 0) {
352 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
359 if (n == 1 && dequeue_status == 0) {
360 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
361 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
366 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
367 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
368 RTE_CRYPTO_OP_STATUS_SUCCESS;
375 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
378 struct rte_crypto_sym_op *sop;
379 union rte_crypto_sym_ofs ofs;
380 struct rte_crypto_sgl sgl;
381 struct rte_crypto_sym_vec symvec;
382 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
383 struct rte_crypto_vec vec[UINT8_MAX];
387 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
388 sop->aead.data.length, vec, RTE_DIM(vec));
390 if (n < 0 || n != sop->m_src->nb_segs) {
391 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
399 symvec.digest = &digest_ptr;
400 symvec.aad = &aad_ptr;
404 /* for CPU crypto the IOVA address is not required */
405 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
406 digest_ptr.va = (void *)sop->aead.digest.data;
407 aad_ptr.va = (void *)sop->aead.aad.data;
411 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
415 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
417 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
421 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
424 struct rte_crypto_sym_op *sop;
425 union rte_crypto_sym_ofs ofs;
426 struct rte_crypto_sgl sgl;
427 struct rte_crypto_sym_vec symvec;
428 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
429 struct rte_crypto_vec vec[UINT8_MAX];
433 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
434 sop->auth.data.length, vec, RTE_DIM(vec));
436 if (n < 0 || n != sop->m_src->nb_segs) {
437 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
445 symvec.digest = &digest_ptr;
449 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
450 digest_ptr.va = (void *)sop->auth.digest.data;
453 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
454 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
455 (sop->cipher.data.offset + sop->cipher.data.length);
457 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
461 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
463 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
466 static struct rte_crypto_op *
467 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
470 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
472 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
473 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
479 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
482 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
483 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
490 static struct crypto_testsuite_params testsuite_params = { NULL };
491 static struct crypto_unittest_params unittest_params;
494 testsuite_setup(void)
496 struct crypto_testsuite_params *ts_params = &testsuite_params;
497 struct rte_cryptodev_info info;
498 uint32_t i = 0, nb_devs, dev_id;
502 memset(ts_params, 0, sizeof(*ts_params));
504 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
505 if (ts_params->mbuf_pool == NULL) {
506 /* Not already created so create */
507 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
509 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
511 if (ts_params->mbuf_pool == NULL) {
512 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
517 ts_params->large_mbuf_pool = rte_mempool_lookup(
518 "CRYPTO_LARGE_MBUFPOOL");
519 if (ts_params->large_mbuf_pool == NULL) {
520 /* Not already created so create */
521 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
522 "CRYPTO_LARGE_MBUFPOOL",
525 if (ts_params->large_mbuf_pool == NULL) {
527 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
532 ts_params->op_mpool = rte_crypto_op_pool_create(
533 "MBUF_CRYPTO_SYM_OP_POOL",
534 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
535 NUM_MBUFS, MBUF_CACHE_SIZE,
537 sizeof(struct rte_crypto_sym_xform) +
540 if (ts_params->op_mpool == NULL) {
541 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
545 /* Create an AESNI MB device if required */
546 if (gbl_driver_id == rte_cryptodev_driver_id_get(
547 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
548 nb_devs = rte_cryptodev_device_count_by_driver(
549 rte_cryptodev_driver_id_get(
550 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
553 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
555 TEST_ASSERT(ret == 0,
556 "Failed to create instance of"
558 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
562 /* Create an AESNI GCM device if required */
563 if (gbl_driver_id == rte_cryptodev_driver_id_get(
564 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
565 nb_devs = rte_cryptodev_device_count_by_driver(
566 rte_cryptodev_driver_id_get(
567 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
569 TEST_ASSERT_SUCCESS(rte_vdev_init(
570 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
571 "Failed to create instance of"
573 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
577 /* Create a SNOW 3G device if required */
578 if (gbl_driver_id == rte_cryptodev_driver_id_get(
579 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
580 nb_devs = rte_cryptodev_device_count_by_driver(
581 rte_cryptodev_driver_id_get(
582 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
584 TEST_ASSERT_SUCCESS(rte_vdev_init(
585 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
586 "Failed to create instance of"
588 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
592 /* Create a KASUMI device if required */
593 if (gbl_driver_id == rte_cryptodev_driver_id_get(
594 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
595 nb_devs = rte_cryptodev_device_count_by_driver(
596 rte_cryptodev_driver_id_get(
597 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
599 TEST_ASSERT_SUCCESS(rte_vdev_init(
600 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
601 "Failed to create instance of"
603 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
607 /* Create a ZUC device if required */
608 if (gbl_driver_id == rte_cryptodev_driver_id_get(
609 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
610 nb_devs = rte_cryptodev_device_count_by_driver(
611 rte_cryptodev_driver_id_get(
612 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
614 TEST_ASSERT_SUCCESS(rte_vdev_init(
615 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
616 "Failed to create instance of"
618 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
622 /* Create a NULL device if required */
623 if (gbl_driver_id == rte_cryptodev_driver_id_get(
624 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
625 nb_devs = rte_cryptodev_device_count_by_driver(
626 rte_cryptodev_driver_id_get(
627 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
630 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
632 TEST_ASSERT(ret == 0,
633 "Failed to create instance of"
635 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
639 /* Create an OPENSSL device if required */
640 if (gbl_driver_id == rte_cryptodev_driver_id_get(
641 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
642 nb_devs = rte_cryptodev_device_count_by_driver(
643 rte_cryptodev_driver_id_get(
644 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
647 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
650 TEST_ASSERT(ret == 0, "Failed to create "
651 "instance of pmd : %s",
652 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
656 /* Create a ARMv8 device if required */
657 if (gbl_driver_id == rte_cryptodev_driver_id_get(
658 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
659 nb_devs = rte_cryptodev_device_count_by_driver(
660 rte_cryptodev_driver_id_get(
661 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
664 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
667 TEST_ASSERT(ret == 0, "Failed to create "
668 "instance of pmd : %s",
669 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
673 /* Create a MVSAM device if required */
674 if (gbl_driver_id == rte_cryptodev_driver_id_get(
675 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
676 nb_devs = rte_cryptodev_device_count_by_driver(
677 rte_cryptodev_driver_id_get(
678 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
681 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
684 TEST_ASSERT(ret == 0, "Failed to create "
685 "instance of pmd : %s",
686 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
690 /* Create an CCP device if required */
691 if (gbl_driver_id == rte_cryptodev_driver_id_get(
692 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
693 nb_devs = rte_cryptodev_device_count_by_driver(
694 rte_cryptodev_driver_id_get(
695 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
698 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
701 TEST_ASSERT(ret == 0, "Failed to create "
702 "instance of pmd : %s",
703 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
707 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
708 char vdev_args[VDEV_ARGS_SIZE] = {""};
709 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
710 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
711 uint16_t worker_core_count = 0;
712 uint16_t socket_id = 0;
714 if (gbl_driver_id == rte_cryptodev_driver_id_get(
715 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
717 /* Identify the Worker Cores
718 * Use 2 worker cores for the device args
720 RTE_LCORE_FOREACH_SLAVE(i) {
721 if (worker_core_count > 1)
723 snprintf(vdev_args, sizeof(vdev_args),
724 "%s%d", temp_str, i);
725 strcpy(temp_str, vdev_args);
726 strlcat(temp_str, ";", sizeof(temp_str));
728 socket_id = rte_lcore_to_socket_id(i);
730 if (worker_core_count != 2) {
732 "Cryptodev scheduler test require at least "
733 "two worker cores to run. "
734 "Please use the correct coremask.\n");
737 strcpy(temp_str, vdev_args);
738 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
739 temp_str, socket_id);
740 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
741 nb_devs = rte_cryptodev_device_count_by_driver(
742 rte_cryptodev_driver_id_get(
743 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
746 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
748 TEST_ASSERT(ret == 0,
749 "Failed to create instance %u of"
751 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
754 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
756 nb_devs = rte_cryptodev_count();
758 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
762 /* Create list of valid crypto devs */
763 for (i = 0; i < nb_devs; i++) {
764 rte_cryptodev_info_get(i, &info);
765 if (info.driver_id == gbl_driver_id)
766 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
769 if (ts_params->valid_dev_count < 1)
772 /* Set up all the qps on the first of the valid devices found */
774 dev_id = ts_params->valid_devs[0];
776 rte_cryptodev_info_get(dev_id, &info);
778 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
779 ts_params->conf.socket_id = SOCKET_ID_ANY;
780 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
782 unsigned int session_size =
783 rte_cryptodev_sym_get_private_session_size(dev_id);
785 #ifdef RTE_LIBRTE_SECURITY
786 unsigned int security_session_size = rte_security_session_get_size(
787 rte_cryptodev_get_sec_ctx(dev_id));
789 if (session_size < security_session_size)
790 session_size = security_session_size;
793 * Create mempool with maximum number of sessions.
795 if (info.sym.max_nb_sessions != 0 &&
796 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
797 RTE_LOG(ERR, USER1, "Device does not support "
798 "at least %u sessions\n",
803 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
804 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
806 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
807 "session mempool allocation failed");
809 ts_params->session_priv_mpool = rte_mempool_create(
813 0, 0, NULL, NULL, NULL,
816 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
817 "session mempool allocation failed");
821 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
823 "Failed to configure cryptodev %u with %u qps",
824 dev_id, ts_params->conf.nb_queue_pairs);
826 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
827 ts_params->qp_conf.mp_session = ts_params->session_mpool;
828 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
830 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
831 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
832 dev_id, qp_id, &ts_params->qp_conf,
833 rte_cryptodev_socket_id(dev_id)),
834 "Failed to setup queue pair %u on cryptodev %u",
842 testsuite_teardown(void)
844 struct crypto_testsuite_params *ts_params = &testsuite_params;
846 if (ts_params->mbuf_pool != NULL) {
847 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
848 rte_mempool_avail_count(ts_params->mbuf_pool));
851 if (ts_params->op_mpool != NULL) {
852 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
853 rte_mempool_avail_count(ts_params->op_mpool));
856 /* Free session mempools */
857 if (ts_params->session_priv_mpool != NULL) {
858 rte_mempool_free(ts_params->session_priv_mpool);
859 ts_params->session_priv_mpool = NULL;
862 if (ts_params->session_mpool != NULL) {
863 rte_mempool_free(ts_params->session_mpool);
864 ts_params->session_mpool = NULL;
869 dev_configure_and_start(uint64_t ff_disable)
871 struct crypto_testsuite_params *ts_params = &testsuite_params;
872 struct crypto_unittest_params *ut_params = &unittest_params;
876 /* Clear unit test parameters before running test */
877 memset(ut_params, 0, sizeof(*ut_params));
879 /* Reconfigure device to default parameters */
880 ts_params->conf.socket_id = SOCKET_ID_ANY;
881 ts_params->conf.ff_disable = ff_disable;
882 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
883 ts_params->qp_conf.mp_session = ts_params->session_mpool;
884 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
886 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
888 "Failed to configure cryptodev %u",
889 ts_params->valid_devs[0]);
891 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
892 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
893 ts_params->valid_devs[0], qp_id,
895 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
896 "Failed to setup queue pair %u on cryptodev %u",
897 qp_id, ts_params->valid_devs[0]);
901 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
903 /* Start the device */
904 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
905 "Failed to start cryptodev %u",
906 ts_params->valid_devs[0]);
914 /* Configure and start the device with security feature disabled */
915 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
919 ut_setup_security(void)
921 /* Configure and start the device with no features disabled */
922 return dev_configure_and_start(0);
928 struct crypto_testsuite_params *ts_params = &testsuite_params;
929 struct crypto_unittest_params *ut_params = &unittest_params;
930 struct rte_cryptodev_stats stats;
932 /* free crypto session structure */
933 #ifdef RTE_LIBRTE_SECURITY
934 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
935 if (ut_params->sec_session) {
936 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
937 (ts_params->valid_devs[0]),
938 ut_params->sec_session);
939 ut_params->sec_session = NULL;
944 if (ut_params->sess) {
945 rte_cryptodev_sym_session_clear(
946 ts_params->valid_devs[0],
948 rte_cryptodev_sym_session_free(ut_params->sess);
949 ut_params->sess = NULL;
953 /* free crypto operation structure */
955 rte_crypto_op_free(ut_params->op);
958 * free mbuf - both obuf and ibuf are usually the same,
959 * so check if they point at the same address is necessary,
960 * to avoid freeing the mbuf twice.
962 if (ut_params->obuf) {
963 rte_pktmbuf_free(ut_params->obuf);
964 if (ut_params->ibuf == ut_params->obuf)
968 if (ut_params->ibuf) {
969 rte_pktmbuf_free(ut_params->ibuf);
973 if (ts_params->mbuf_pool != NULL)
974 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
975 rte_mempool_avail_count(ts_params->mbuf_pool));
977 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
979 /* Stop the device */
980 rte_cryptodev_stop(ts_params->valid_devs[0]);
984 test_device_configure_invalid_dev_id(void)
986 struct crypto_testsuite_params *ts_params = &testsuite_params;
987 uint16_t dev_id, num_devs = 0;
989 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
990 "Need at least %d devices for test", 1);
992 /* valid dev_id values */
993 dev_id = ts_params->valid_devs[0];
995 /* Stop the device in case it's started so it can be configured */
996 rte_cryptodev_stop(dev_id);
998 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
999 "Failed test for rte_cryptodev_configure: "
1000 "invalid dev_num %u", dev_id);
1002 /* invalid dev_id values */
1005 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1006 "Failed test for rte_cryptodev_configure: "
1007 "invalid dev_num %u", dev_id);
1011 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1012 "Failed test for rte_cryptodev_configure:"
1013 "invalid dev_num %u", dev_id);
1015 return TEST_SUCCESS;
1019 test_device_configure_invalid_queue_pair_ids(void)
1021 struct crypto_testsuite_params *ts_params = &testsuite_params;
1022 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1024 /* Stop the device in case it's started so it can be configured */
1025 rte_cryptodev_stop(ts_params->valid_devs[0]);
1027 /* valid - max value queue pairs */
1028 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1030 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1032 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1033 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1035 /* valid - one queue pairs */
1036 ts_params->conf.nb_queue_pairs = 1;
1038 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1040 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1041 ts_params->valid_devs[0],
1042 ts_params->conf.nb_queue_pairs);
1045 /* invalid - zero queue pairs */
1046 ts_params->conf.nb_queue_pairs = 0;
1048 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1050 "Failed test for rte_cryptodev_configure, dev_id %u,"
1052 ts_params->valid_devs[0],
1053 ts_params->conf.nb_queue_pairs);
1056 /* invalid - max value supported by field queue pairs */
1057 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1059 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1061 "Failed test for rte_cryptodev_configure, dev_id %u,"
1063 ts_params->valid_devs[0],
1064 ts_params->conf.nb_queue_pairs);
1067 /* invalid - max value + 1 queue pairs */
1068 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1070 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1072 "Failed test for rte_cryptodev_configure, dev_id %u,"
1074 ts_params->valid_devs[0],
1075 ts_params->conf.nb_queue_pairs);
1077 /* revert to original testsuite value */
1078 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1080 return TEST_SUCCESS;
1084 test_queue_pair_descriptor_setup(void)
1086 struct crypto_testsuite_params *ts_params = &testsuite_params;
1087 struct rte_cryptodev_qp_conf qp_conf = {
1088 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1092 /* Stop the device in case it's started so it can be configured */
1093 rte_cryptodev_stop(ts_params->valid_devs[0]);
1095 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1097 "Failed to configure cryptodev %u",
1098 ts_params->valid_devs[0]);
1101 * Test various ring sizes on this device. memzones can't be
1102 * freed so are re-used if ring is released and re-created.
1104 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1105 qp_conf.mp_session = ts_params->session_mpool;
1106 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1108 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1109 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1110 ts_params->valid_devs[0], qp_id, &qp_conf,
1111 rte_cryptodev_socket_id(
1112 ts_params->valid_devs[0])),
1114 "rte_cryptodev_queue_pair_setup: num_inflights "
1115 "%u on qp %u on cryptodev %u",
1116 qp_conf.nb_descriptors, qp_id,
1117 ts_params->valid_devs[0]);
1120 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1122 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1123 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1124 ts_params->valid_devs[0], qp_id, &qp_conf,
1125 rte_cryptodev_socket_id(
1126 ts_params->valid_devs[0])),
1128 " rte_cryptodev_queue_pair_setup: num_inflights"
1129 " %u on qp %u on cryptodev %u",
1130 qp_conf.nb_descriptors, qp_id,
1131 ts_params->valid_devs[0]);
1134 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1136 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1137 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1138 ts_params->valid_devs[0], qp_id, &qp_conf,
1139 rte_cryptodev_socket_id(
1140 ts_params->valid_devs[0])),
1142 "rte_cryptodev_queue_pair_setup: num_inflights"
1143 " %u on qp %u on cryptodev %u",
1144 qp_conf.nb_descriptors, qp_id,
1145 ts_params->valid_devs[0]);
1148 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1150 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1151 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1152 ts_params->valid_devs[0], qp_id, &qp_conf,
1153 rte_cryptodev_socket_id(
1154 ts_params->valid_devs[0])),
1156 " rte_cryptodev_queue_pair_setup:"
1157 "num_inflights %u on qp %u on cryptodev %u",
1158 qp_conf.nb_descriptors, qp_id,
1159 ts_params->valid_devs[0]);
1162 /* test invalid queue pair id */
1163 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1165 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1167 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1168 ts_params->valid_devs[0],
1170 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1171 "Failed test for rte_cryptodev_queue_pair_setup:"
1172 "invalid qp %u on cryptodev %u",
1173 qp_id, ts_params->valid_devs[0]);
1175 qp_id = 0xffff; /*invalid*/
1177 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1178 ts_params->valid_devs[0],
1180 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1181 "Failed test for rte_cryptodev_queue_pair_setup:"
1182 "invalid qp %u on cryptodev %u",
1183 qp_id, ts_params->valid_devs[0]);
1185 return TEST_SUCCESS;
1188 /* ***** Plaintext data for tests ***** */
1190 const char catch_22_quote_1[] =
1191 "There was only one catch and that was Catch-22, which "
1192 "specified that a concern for one's safety in the face of "
1193 "dangers that were real and immediate was the process of a "
1194 "rational mind. Orr was crazy and could be grounded. All he "
1195 "had to do was ask; and as soon as he did, he would no longer "
1196 "be crazy and would have to fly more missions. Orr would be "
1197 "crazy to fly more missions and sane if he didn't, but if he "
1198 "was sane he had to fly them. If he flew them he was crazy "
1199 "and didn't have to; but if he didn't want to he was sane and "
1200 "had to. Yossarian was moved very deeply by the absolute "
1201 "simplicity of this clause of Catch-22 and let out a "
1202 "respectful whistle. \"That's some catch, that Catch-22\", he "
1203 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1205 const char catch_22_quote[] =
1206 "What a lousy earth! He wondered how many people were "
1207 "destitute that same night even in his own prosperous country, "
1208 "how many homes were shanties, how many husbands were drunk "
1209 "and wives socked, and how many children were bullied, abused, "
1210 "or abandoned. How many families hungered for food they could "
1211 "not afford to buy? How many hearts were broken? How many "
1212 "suicides would take place that same night, how many people "
1213 "would go insane? How many cockroaches and landlords would "
1214 "triumph? How many winners were losers, successes failures, "
1215 "and rich men poor men? How many wise guys were stupid? How "
1216 "many happy endings were unhappy endings? How many honest men "
1217 "were liars, brave men cowards, loyal men traitors, how many "
1218 "sainted men were corrupt, how many people in positions of "
1219 "trust had sold their souls to bodyguards, how many had never "
1220 "had souls? How many straight-and-narrow paths were crooked "
1221 "paths? How many best families were worst families and how "
1222 "many good people were bad people? When you added them all up "
1223 "and then subtracted, you might be left with only the children, "
1224 "and perhaps with Albert Einstein and an old violinist or "
1225 "sculptor somewhere.";
1227 #define QUOTE_480_BYTES (480)
1228 #define QUOTE_512_BYTES (512)
1229 #define QUOTE_768_BYTES (768)
1230 #define QUOTE_1024_BYTES (1024)
1234 /* ***** SHA1 Hash Tests ***** */
1236 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1238 static uint8_t hmac_sha1_key[] = {
1239 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1240 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1241 0xDE, 0xF4, 0xDE, 0xAD };
1243 /* ***** SHA224 Hash Tests ***** */
1245 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1248 /* ***** AES-CBC Cipher Tests ***** */
1250 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1251 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1253 static uint8_t aes_cbc_key[] = {
1254 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1255 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1257 static uint8_t aes_cbc_iv[] = {
1258 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1259 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1262 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1264 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1265 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1266 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1267 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1268 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1269 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1270 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1271 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1272 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1273 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1274 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1275 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1276 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1277 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1278 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1279 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1280 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1281 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1282 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1283 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1284 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1285 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1286 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1287 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1288 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1289 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1290 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1291 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1292 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1293 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1294 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1295 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1296 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1297 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1298 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1299 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1300 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1301 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1302 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1303 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1304 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1305 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1306 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1307 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1308 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1309 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1310 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1311 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1312 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1313 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1314 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1315 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1316 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1317 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1318 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1319 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1320 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1321 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1322 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1323 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1324 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1325 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1326 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1327 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1328 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1331 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1332 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1333 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1334 0x18, 0x8c, 0x1d, 0x32
1338 /* Multisession Vector context Test */
1339 /*Begin Session 0 */
1340 static uint8_t ms_aes_cbc_key0[] = {
1341 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1342 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1345 static uint8_t ms_aes_cbc_iv0[] = {
1346 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1347 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1350 static const uint8_t ms_aes_cbc_cipher0[] = {
1351 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1352 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1353 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1354 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1355 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1356 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1357 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1358 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1359 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1360 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1361 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1362 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1363 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1364 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1365 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1366 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1367 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1368 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1369 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1370 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1371 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1372 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1373 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1374 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1375 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1376 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1377 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1378 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1379 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1380 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1381 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1382 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1383 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1384 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1385 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1386 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1387 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1388 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1389 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1390 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1391 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1392 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1393 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1394 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1395 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1396 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1397 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1398 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1399 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1400 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1401 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1402 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1403 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1404 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1405 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1406 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1407 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1408 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1409 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1410 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1411 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1412 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1413 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1414 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1418 static uint8_t ms_hmac_key0[] = {
1419 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1420 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1421 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1422 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1423 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1424 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1425 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1426 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1429 static const uint8_t ms_hmac_digest0[] = {
1430 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1431 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1432 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1433 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1434 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1435 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1436 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1437 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1441 /* Begin session 1 */
1443 static uint8_t ms_aes_cbc_key1[] = {
1444 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1445 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1448 static uint8_t ms_aes_cbc_iv1[] = {
1449 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1450 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1453 static const uint8_t ms_aes_cbc_cipher1[] = {
1454 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1455 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1456 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1457 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1458 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1459 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1460 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1461 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1462 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1463 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1464 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1465 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1466 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1467 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1468 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1469 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1470 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1471 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1472 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1473 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1474 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1475 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1476 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1477 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1478 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1479 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1480 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1481 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1482 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1483 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1484 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1485 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1486 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1487 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1488 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1489 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1490 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1491 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1492 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1493 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1494 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1495 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1496 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1497 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1498 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1499 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1500 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1501 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1502 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1503 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1504 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1505 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1506 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1507 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1508 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1509 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1510 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1511 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1512 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1513 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1514 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1515 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1516 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1517 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1521 static uint8_t ms_hmac_key1[] = {
1522 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1523 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1524 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1525 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1526 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1527 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1528 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1529 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1532 static const uint8_t ms_hmac_digest1[] = {
1533 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1534 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1535 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1536 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1537 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1538 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1539 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1540 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1543 /* Begin Session 2 */
1544 static uint8_t ms_aes_cbc_key2[] = {
1545 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1546 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1549 static uint8_t ms_aes_cbc_iv2[] = {
1550 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1551 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1554 static const uint8_t ms_aes_cbc_cipher2[] = {
1555 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1556 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1557 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1558 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1559 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1560 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1561 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1562 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1563 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1564 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1565 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1566 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1567 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1568 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1569 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1570 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1571 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1572 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1573 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1574 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1575 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1576 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1577 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1578 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1579 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1580 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1581 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1582 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1583 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1584 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1585 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1586 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1587 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1588 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1589 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1590 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1591 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1592 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1593 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1594 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1595 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1596 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1597 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1598 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1599 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1600 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1601 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1602 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1603 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1604 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1605 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1606 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1607 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1608 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1609 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1610 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1611 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1612 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1613 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1614 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1615 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1616 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1617 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1618 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1621 static uint8_t ms_hmac_key2[] = {
1622 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1623 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1624 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1625 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1626 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1627 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1628 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1629 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1632 static const uint8_t ms_hmac_digest2[] = {
1633 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1634 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1635 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1636 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1637 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1638 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1639 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1640 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1647 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1649 struct crypto_testsuite_params *ts_params = &testsuite_params;
1650 struct crypto_unittest_params *ut_params = &unittest_params;
1652 /* Verify the capabilities */
1653 struct rte_cryptodev_sym_capability_idx cap_idx;
1654 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1655 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1656 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1659 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1660 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1661 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1665 /* Generate test mbuf data and space for digest */
1666 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1667 catch_22_quote, QUOTE_512_BYTES, 0);
1669 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1670 DIGEST_BYTE_LENGTH_SHA1);
1671 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1673 /* Setup Cipher Parameters */
1674 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1675 ut_params->cipher_xform.next = &ut_params->auth_xform;
1677 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1678 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1679 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1680 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1681 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1682 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1684 /* Setup HMAC Parameters */
1685 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1687 ut_params->auth_xform.next = NULL;
1689 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1690 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1691 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1692 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1693 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1695 ut_params->sess = rte_cryptodev_sym_session_create(
1696 ts_params->session_mpool);
1698 /* Create crypto session*/
1699 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1700 ut_params->sess, &ut_params->cipher_xform,
1701 ts_params->session_priv_mpool);
1702 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1704 /* Generate crypto op data structure */
1705 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1706 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1707 TEST_ASSERT_NOT_NULL(ut_params->op,
1708 "Failed to allocate symmetric crypto operation struct");
1710 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1712 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1714 /* set crypto operation source mbuf */
1715 sym_op->m_src = ut_params->ibuf;
1717 /* Set crypto operation authentication parameters */
1718 sym_op->auth.digest.data = ut_params->digest;
1719 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1720 ut_params->ibuf, QUOTE_512_BYTES);
1722 sym_op->auth.data.offset = 0;
1723 sym_op->auth.data.length = QUOTE_512_BYTES;
1725 /* Copy IV at the end of the crypto operation */
1726 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1727 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1729 /* Set crypto operation cipher parameters */
1730 sym_op->cipher.data.offset = 0;
1731 sym_op->cipher.data.length = QUOTE_512_BYTES;
1733 /* Process crypto operation */
1734 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1735 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1738 TEST_ASSERT_NOT_NULL(
1739 process_crypto_request(ts_params->valid_devs[0],
1741 "failed to process sym crypto op");
1743 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1744 "crypto op processing failed");
1747 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1750 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1751 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1753 "ciphertext data not as expected");
1755 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1757 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1758 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1759 gbl_driver_id == rte_cryptodev_driver_id_get(
1760 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1761 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1762 DIGEST_BYTE_LENGTH_SHA1,
1763 "Generated digest data not as expected");
1765 return TEST_SUCCESS;
1768 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1770 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1772 static uint8_t hmac_sha512_key[] = {
1773 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1774 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1775 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1776 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1777 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1778 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1779 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1780 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1782 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1783 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1784 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1785 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1786 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1787 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1788 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1789 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1790 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1795 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1796 struct crypto_unittest_params *ut_params,
1797 uint8_t *cipher_key,
1801 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1802 struct crypto_unittest_params *ut_params,
1803 struct crypto_testsuite_params *ts_params,
1804 const uint8_t *cipher,
1805 const uint8_t *digest,
1810 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1811 struct crypto_unittest_params *ut_params,
1812 uint8_t *cipher_key,
1816 /* Setup Cipher Parameters */
1817 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1818 ut_params->cipher_xform.next = NULL;
1820 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1821 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1822 ut_params->cipher_xform.cipher.key.data = cipher_key;
1823 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1824 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1825 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1827 /* Setup HMAC Parameters */
1828 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1829 ut_params->auth_xform.next = &ut_params->cipher_xform;
1831 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1832 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1833 ut_params->auth_xform.auth.key.data = hmac_key;
1834 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1835 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1837 return TEST_SUCCESS;
1842 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1843 struct crypto_unittest_params *ut_params,
1844 struct crypto_testsuite_params *ts_params,
1845 const uint8_t *cipher,
1846 const uint8_t *digest,
1849 /* Generate test mbuf data and digest */
1850 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1853 QUOTE_512_BYTES, 0);
1855 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1856 DIGEST_BYTE_LENGTH_SHA512);
1857 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1859 rte_memcpy(ut_params->digest,
1861 DIGEST_BYTE_LENGTH_SHA512);
1863 /* Generate Crypto op data structure */
1864 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1865 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1866 TEST_ASSERT_NOT_NULL(ut_params->op,
1867 "Failed to allocate symmetric crypto operation struct");
1869 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1871 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1873 /* set crypto operation source mbuf */
1874 sym_op->m_src = ut_params->ibuf;
1876 sym_op->auth.digest.data = ut_params->digest;
1877 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1878 ut_params->ibuf, QUOTE_512_BYTES);
1880 sym_op->auth.data.offset = 0;
1881 sym_op->auth.data.length = QUOTE_512_BYTES;
1883 /* Copy IV at the end of the crypto operation */
1884 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1885 iv, CIPHER_IV_LENGTH_AES_CBC);
1887 sym_op->cipher.data.offset = 0;
1888 sym_op->cipher.data.length = QUOTE_512_BYTES;
1890 /* Process crypto operation */
1891 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1892 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1894 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1895 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
1896 ut_params->op, 1, 1, 0, 0);
1898 TEST_ASSERT_NOT_NULL(
1899 process_crypto_request(ts_params->valid_devs[0],
1901 "failed to process sym crypto op");
1903 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1904 "crypto op processing failed");
1906 ut_params->obuf = ut_params->op->sym->m_src;
1909 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1910 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1913 "Plaintext data not as expected");
1916 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1917 "Digest verification failed");
1919 return TEST_SUCCESS;
1923 test_blockcipher(enum blockcipher_test_type test_type)
1925 struct crypto_testsuite_params *ts_params = &testsuite_params;
1928 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1929 ts_params->op_mpool,
1930 ts_params->session_mpool, ts_params->session_priv_mpool,
1931 ts_params->valid_devs[0],
1934 if (status == -ENOTSUP)
1937 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1939 return TEST_SUCCESS;
1943 test_AES_cipheronly_all(void)
1945 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1949 test_AES_docsis_all(void)
1951 /* Data-path service does not support DOCSIS yet */
1952 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1954 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1958 test_DES_docsis_all(void)
1960 /* Data-path service does not support DOCSIS yet */
1961 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1963 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1967 test_DES_cipheronly_all(void)
1969 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1973 test_authonly_all(void)
1975 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1979 test_AES_chain_all(void)
1981 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1985 test_3DES_chain_all(void)
1987 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1991 test_3DES_cipheronly_all(void)
1993 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1996 /* ***** SNOW 3G Tests ***** */
1998 create_wireless_algo_hash_session(uint8_t dev_id,
1999 const uint8_t *key, const uint8_t key_len,
2000 const uint8_t iv_len, const uint8_t auth_len,
2001 enum rte_crypto_auth_operation op,
2002 enum rte_crypto_auth_algorithm algo)
2004 uint8_t hash_key[key_len];
2007 struct crypto_testsuite_params *ts_params = &testsuite_params;
2008 struct crypto_unittest_params *ut_params = &unittest_params;
2010 memcpy(hash_key, key, key_len);
2012 debug_hexdump(stdout, "key:", key, key_len);
2014 /* Setup Authentication Parameters */
2015 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2016 ut_params->auth_xform.next = NULL;
2018 ut_params->auth_xform.auth.op = op;
2019 ut_params->auth_xform.auth.algo = algo;
2020 ut_params->auth_xform.auth.key.length = key_len;
2021 ut_params->auth_xform.auth.key.data = hash_key;
2022 ut_params->auth_xform.auth.digest_length = auth_len;
2023 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2024 ut_params->auth_xform.auth.iv.length = iv_len;
2025 ut_params->sess = rte_cryptodev_sym_session_create(
2026 ts_params->session_mpool);
2028 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2029 &ut_params->auth_xform,
2030 ts_params->session_priv_mpool);
2031 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2032 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2037 create_wireless_algo_cipher_session(uint8_t dev_id,
2038 enum rte_crypto_cipher_operation op,
2039 enum rte_crypto_cipher_algorithm algo,
2040 const uint8_t *key, const uint8_t key_len,
2043 uint8_t cipher_key[key_len];
2045 struct crypto_testsuite_params *ts_params = &testsuite_params;
2046 struct crypto_unittest_params *ut_params = &unittest_params;
2048 memcpy(cipher_key, key, key_len);
2050 /* Setup Cipher Parameters */
2051 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2052 ut_params->cipher_xform.next = NULL;
2054 ut_params->cipher_xform.cipher.algo = algo;
2055 ut_params->cipher_xform.cipher.op = op;
2056 ut_params->cipher_xform.cipher.key.data = cipher_key;
2057 ut_params->cipher_xform.cipher.key.length = key_len;
2058 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2059 ut_params->cipher_xform.cipher.iv.length = iv_len;
2061 debug_hexdump(stdout, "key:", key, key_len);
2063 /* Create Crypto session */
2064 ut_params->sess = rte_cryptodev_sym_session_create(
2065 ts_params->session_mpool);
2067 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2068 &ut_params->cipher_xform,
2069 ts_params->session_priv_mpool);
2070 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2071 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2076 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2077 unsigned int cipher_len,
2078 unsigned int cipher_offset)
2080 struct crypto_testsuite_params *ts_params = &testsuite_params;
2081 struct crypto_unittest_params *ut_params = &unittest_params;
2083 /* Generate Crypto op data structure */
2084 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2085 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2086 TEST_ASSERT_NOT_NULL(ut_params->op,
2087 "Failed to allocate pktmbuf offload");
2089 /* Set crypto operation data parameters */
2090 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2092 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2094 /* set crypto operation source mbuf */
2095 sym_op->m_src = ut_params->ibuf;
2098 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2100 sym_op->cipher.data.length = cipher_len;
2101 sym_op->cipher.data.offset = cipher_offset;
2106 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2107 unsigned int cipher_len,
2108 unsigned int cipher_offset)
2110 struct crypto_testsuite_params *ts_params = &testsuite_params;
2111 struct crypto_unittest_params *ut_params = &unittest_params;
2113 /* Generate Crypto op data structure */
2114 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2115 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2116 TEST_ASSERT_NOT_NULL(ut_params->op,
2117 "Failed to allocate pktmbuf offload");
2119 /* Set crypto operation data parameters */
2120 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2122 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2124 /* set crypto operation source mbuf */
2125 sym_op->m_src = ut_params->ibuf;
2126 sym_op->m_dst = ut_params->obuf;
2129 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2131 sym_op->cipher.data.length = cipher_len;
2132 sym_op->cipher.data.offset = cipher_offset;
2137 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2138 enum rte_crypto_cipher_operation cipher_op,
2139 enum rte_crypto_auth_operation auth_op,
2140 enum rte_crypto_auth_algorithm auth_algo,
2141 enum rte_crypto_cipher_algorithm cipher_algo,
2142 const uint8_t *key, uint8_t key_len,
2143 uint8_t auth_iv_len, uint8_t auth_len,
2144 uint8_t cipher_iv_len)
2147 uint8_t cipher_auth_key[key_len];
2150 struct crypto_testsuite_params *ts_params = &testsuite_params;
2151 struct crypto_unittest_params *ut_params = &unittest_params;
2153 memcpy(cipher_auth_key, key, key_len);
2155 /* Setup Authentication Parameters */
2156 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2157 ut_params->auth_xform.next = NULL;
2159 ut_params->auth_xform.auth.op = auth_op;
2160 ut_params->auth_xform.auth.algo = auth_algo;
2161 ut_params->auth_xform.auth.key.length = key_len;
2162 /* Hash key = cipher key */
2163 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2164 ut_params->auth_xform.auth.digest_length = auth_len;
2165 /* Auth IV will be after cipher IV */
2166 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2167 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2169 /* Setup Cipher Parameters */
2170 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2171 ut_params->cipher_xform.next = &ut_params->auth_xform;
2173 ut_params->cipher_xform.cipher.algo = cipher_algo;
2174 ut_params->cipher_xform.cipher.op = cipher_op;
2175 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2176 ut_params->cipher_xform.cipher.key.length = key_len;
2177 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2178 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2180 debug_hexdump(stdout, "key:", key, key_len);
2182 /* Create Crypto session*/
2183 ut_params->sess = rte_cryptodev_sym_session_create(
2184 ts_params->session_mpool);
2185 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2187 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2188 &ut_params->cipher_xform,
2189 ts_params->session_priv_mpool);
2190 if (status == -ENOTSUP)
2193 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2198 create_wireless_cipher_auth_session(uint8_t dev_id,
2199 enum rte_crypto_cipher_operation cipher_op,
2200 enum rte_crypto_auth_operation auth_op,
2201 enum rte_crypto_auth_algorithm auth_algo,
2202 enum rte_crypto_cipher_algorithm cipher_algo,
2203 const struct wireless_test_data *tdata)
2205 const uint8_t key_len = tdata->key.len;
2206 uint8_t cipher_auth_key[key_len];
2209 struct crypto_testsuite_params *ts_params = &testsuite_params;
2210 struct crypto_unittest_params *ut_params = &unittest_params;
2211 const uint8_t *key = tdata->key.data;
2212 const uint8_t auth_len = tdata->digest.len;
2213 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2214 uint8_t auth_iv_len = tdata->auth_iv.len;
2216 memcpy(cipher_auth_key, key, key_len);
2218 /* Setup Authentication Parameters */
2219 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2220 ut_params->auth_xform.next = NULL;
2222 ut_params->auth_xform.auth.op = auth_op;
2223 ut_params->auth_xform.auth.algo = auth_algo;
2224 ut_params->auth_xform.auth.key.length = key_len;
2225 /* Hash key = cipher key */
2226 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2227 ut_params->auth_xform.auth.digest_length = auth_len;
2228 /* Auth IV will be after cipher IV */
2229 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2230 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2232 /* Setup Cipher Parameters */
2233 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2234 ut_params->cipher_xform.next = &ut_params->auth_xform;
2236 ut_params->cipher_xform.cipher.algo = cipher_algo;
2237 ut_params->cipher_xform.cipher.op = cipher_op;
2238 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2239 ut_params->cipher_xform.cipher.key.length = key_len;
2240 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2241 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2244 debug_hexdump(stdout, "key:", key, key_len);
2246 /* Create Crypto session*/
2247 ut_params->sess = rte_cryptodev_sym_session_create(
2248 ts_params->session_mpool);
2250 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2251 &ut_params->cipher_xform,
2252 ts_params->session_priv_mpool);
2253 if (status == -ENOTSUP)
2256 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2257 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2262 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2263 const struct wireless_test_data *tdata)
2265 return create_wireless_cipher_auth_session(dev_id,
2266 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2267 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2268 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2272 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2273 enum rte_crypto_cipher_operation cipher_op,
2274 enum rte_crypto_auth_operation auth_op,
2275 enum rte_crypto_auth_algorithm auth_algo,
2276 enum rte_crypto_cipher_algorithm cipher_algo,
2277 const uint8_t *key, const uint8_t key_len,
2278 uint8_t auth_iv_len, uint8_t auth_len,
2279 uint8_t cipher_iv_len)
2281 uint8_t auth_cipher_key[key_len];
2283 struct crypto_testsuite_params *ts_params = &testsuite_params;
2284 struct crypto_unittest_params *ut_params = &unittest_params;
2286 memcpy(auth_cipher_key, key, key_len);
2288 /* Setup Authentication Parameters */
2289 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2290 ut_params->auth_xform.auth.op = auth_op;
2291 ut_params->auth_xform.next = &ut_params->cipher_xform;
2292 ut_params->auth_xform.auth.algo = auth_algo;
2293 ut_params->auth_xform.auth.key.length = key_len;
2294 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2295 ut_params->auth_xform.auth.digest_length = auth_len;
2296 /* Auth IV will be after cipher IV */
2297 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2298 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2300 /* Setup Cipher Parameters */
2301 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2302 ut_params->cipher_xform.next = NULL;
2303 ut_params->cipher_xform.cipher.algo = cipher_algo;
2304 ut_params->cipher_xform.cipher.op = cipher_op;
2305 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2306 ut_params->cipher_xform.cipher.key.length = key_len;
2307 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2308 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2310 debug_hexdump(stdout, "key:", key, key_len);
2312 /* Create Crypto session*/
2313 ut_params->sess = rte_cryptodev_sym_session_create(
2314 ts_params->session_mpool);
2315 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2317 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2318 ut_params->auth_xform.next = NULL;
2319 ut_params->cipher_xform.next = &ut_params->auth_xform;
2320 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2321 &ut_params->cipher_xform,
2322 ts_params->session_priv_mpool);
2325 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2326 &ut_params->auth_xform,
2327 ts_params->session_priv_mpool);
2329 if (status == -ENOTSUP)
2332 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2338 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2339 unsigned int auth_tag_len,
2340 const uint8_t *iv, unsigned int iv_len,
2341 unsigned int data_pad_len,
2342 enum rte_crypto_auth_operation op,
2343 unsigned int auth_len, unsigned int auth_offset)
2345 struct crypto_testsuite_params *ts_params = &testsuite_params;
2347 struct crypto_unittest_params *ut_params = &unittest_params;
2349 /* Generate Crypto op data structure */
2350 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2351 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2352 TEST_ASSERT_NOT_NULL(ut_params->op,
2353 "Failed to allocate pktmbuf offload");
2355 /* Set crypto operation data parameters */
2356 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2358 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2360 /* set crypto operation source mbuf */
2361 sym_op->m_src = ut_params->ibuf;
2364 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2367 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2368 ut_params->ibuf, auth_tag_len);
2370 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2371 "no room to append auth tag");
2372 ut_params->digest = sym_op->auth.digest.data;
2373 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2374 ut_params->ibuf, data_pad_len);
2375 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2376 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2378 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2380 debug_hexdump(stdout, "digest:",
2381 sym_op->auth.digest.data,
2384 sym_op->auth.data.length = auth_len;
2385 sym_op->auth.data.offset = auth_offset;
2391 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2392 enum rte_crypto_auth_operation op)
2394 struct crypto_testsuite_params *ts_params = &testsuite_params;
2395 struct crypto_unittest_params *ut_params = &unittest_params;
2397 const uint8_t *auth_tag = tdata->digest.data;
2398 const unsigned int auth_tag_len = tdata->digest.len;
2399 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2400 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2402 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2403 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2404 const uint8_t *auth_iv = tdata->auth_iv.data;
2405 const uint8_t auth_iv_len = tdata->auth_iv.len;
2406 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2407 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2409 /* Generate Crypto op data structure */
2410 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2411 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2412 TEST_ASSERT_NOT_NULL(ut_params->op,
2413 "Failed to allocate pktmbuf offload");
2414 /* Set crypto operation data parameters */
2415 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2417 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2419 /* set crypto operation source mbuf */
2420 sym_op->m_src = ut_params->ibuf;
2423 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2424 ut_params->ibuf, auth_tag_len);
2426 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2427 "no room to append auth tag");
2428 ut_params->digest = sym_op->auth.digest.data;
2429 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2430 ut_params->ibuf, data_pad_len);
2431 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2432 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2434 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2436 debug_hexdump(stdout, "digest:",
2437 sym_op->auth.digest.data,
2440 /* Copy cipher and auth IVs at the end of the crypto operation */
2441 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2443 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2444 iv_ptr += cipher_iv_len;
2445 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2447 sym_op->cipher.data.length = cipher_len;
2448 sym_op->cipher.data.offset = 0;
2449 sym_op->auth.data.length = auth_len;
2450 sym_op->auth.data.offset = 0;
2456 create_zuc_cipher_hash_generate_operation(
2457 const struct wireless_test_data *tdata)
2459 return create_wireless_cipher_hash_operation(tdata,
2460 RTE_CRYPTO_AUTH_OP_GENERATE);
2464 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2465 const unsigned auth_tag_len,
2466 const uint8_t *auth_iv, uint8_t auth_iv_len,
2467 unsigned data_pad_len,
2468 enum rte_crypto_auth_operation op,
2469 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2470 const unsigned cipher_len, const unsigned cipher_offset,
2471 const unsigned auth_len, const unsigned auth_offset)
2473 struct crypto_testsuite_params *ts_params = &testsuite_params;
2474 struct crypto_unittest_params *ut_params = &unittest_params;
2476 enum rte_crypto_cipher_algorithm cipher_algo =
2477 ut_params->cipher_xform.cipher.algo;
2478 enum rte_crypto_auth_algorithm auth_algo =
2479 ut_params->auth_xform.auth.algo;
2481 /* Generate Crypto op data structure */
2482 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2483 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2484 TEST_ASSERT_NOT_NULL(ut_params->op,
2485 "Failed to allocate pktmbuf offload");
2486 /* Set crypto operation data parameters */
2487 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2489 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2491 /* set crypto operation source mbuf */
2492 sym_op->m_src = ut_params->ibuf;
2495 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2496 ut_params->ibuf, auth_tag_len);
2498 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2499 "no room to append auth tag");
2500 ut_params->digest = sym_op->auth.digest.data;
2502 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2503 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2504 ut_params->ibuf, data_pad_len);
2506 struct rte_mbuf *m = ut_params->ibuf;
2507 unsigned int offset = data_pad_len;
2509 while (offset > m->data_len && m->next != NULL) {
2510 offset -= m->data_len;
2513 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2517 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2518 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2520 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2522 debug_hexdump(stdout, "digest:",
2523 sym_op->auth.digest.data,
2526 /* Copy cipher and auth IVs at the end of the crypto operation */
2527 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2529 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2530 iv_ptr += cipher_iv_len;
2531 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2533 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2534 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2535 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2536 sym_op->cipher.data.length = cipher_len;
2537 sym_op->cipher.data.offset = cipher_offset;
2539 sym_op->cipher.data.length = cipher_len >> 3;
2540 sym_op->cipher.data.offset = cipher_offset >> 3;
2543 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2544 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2545 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2546 sym_op->auth.data.length = auth_len;
2547 sym_op->auth.data.offset = auth_offset;
2549 sym_op->auth.data.length = auth_len >> 3;
2550 sym_op->auth.data.offset = auth_offset >> 3;
2557 create_wireless_algo_auth_cipher_operation(
2558 const uint8_t *auth_tag, unsigned int auth_tag_len,
2559 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2560 const uint8_t *auth_iv, uint8_t auth_iv_len,
2561 unsigned int data_pad_len,
2562 unsigned int cipher_len, unsigned int cipher_offset,
2563 unsigned int auth_len, unsigned int auth_offset,
2564 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2566 struct crypto_testsuite_params *ts_params = &testsuite_params;
2567 struct crypto_unittest_params *ut_params = &unittest_params;
2569 enum rte_crypto_cipher_algorithm cipher_algo =
2570 ut_params->cipher_xform.cipher.algo;
2571 enum rte_crypto_auth_algorithm auth_algo =
2572 ut_params->auth_xform.auth.algo;
2574 /* Generate Crypto op data structure */
2575 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2576 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2577 TEST_ASSERT_NOT_NULL(ut_params->op,
2578 "Failed to allocate pktmbuf offload");
2580 /* Set crypto operation data parameters */
2581 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2583 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2585 /* set crypto operation mbufs */
2586 sym_op->m_src = ut_params->ibuf;
2587 if (op_mode == OUT_OF_PLACE)
2588 sym_op->m_dst = ut_params->obuf;
2592 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2593 (op_mode == IN_PLACE ?
2594 ut_params->ibuf : ut_params->obuf),
2595 uint8_t *, data_pad_len);
2596 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2597 (op_mode == IN_PLACE ?
2598 ut_params->ibuf : ut_params->obuf),
2600 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2602 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2603 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2604 sym_op->m_src : sym_op->m_dst);
2605 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2606 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2607 sgl_buf = sgl_buf->next;
2609 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2610 uint8_t *, remaining_off);
2611 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2613 memset(sym_op->auth.digest.data, 0, remaining_off);
2614 while (sgl_buf->next != NULL) {
2615 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2616 0, rte_pktmbuf_data_len(sgl_buf));
2617 sgl_buf = sgl_buf->next;
2621 /* Copy digest for the verification */
2623 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2625 /* Copy cipher and auth IVs at the end of the crypto operation */
2626 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2627 ut_params->op, uint8_t *, IV_OFFSET);
2629 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2630 iv_ptr += cipher_iv_len;
2631 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2633 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2634 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2635 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2636 sym_op->cipher.data.length = cipher_len;
2637 sym_op->cipher.data.offset = cipher_offset;
2639 sym_op->cipher.data.length = cipher_len >> 3;
2640 sym_op->cipher.data.offset = cipher_offset >> 3;
2643 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2644 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2645 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2646 sym_op->auth.data.length = auth_len;
2647 sym_op->auth.data.offset = auth_offset;
2649 sym_op->auth.data.length = auth_len >> 3;
2650 sym_op->auth.data.offset = auth_offset >> 3;
2657 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2659 struct crypto_testsuite_params *ts_params = &testsuite_params;
2660 struct crypto_unittest_params *ut_params = &unittest_params;
2663 unsigned plaintext_pad_len;
2664 unsigned plaintext_len;
2666 struct rte_cryptodev_info dev_info;
2668 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2669 uint64_t feat_flags = dev_info.feature_flags;
2671 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2672 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2673 printf("Device doesn't support NON-Byte Aligned Data.\n");
2677 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2678 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2679 printf("Device doesn't support RAW data-path APIs.\n");
2683 /* Verify the capabilities */
2684 struct rte_cryptodev_sym_capability_idx cap_idx;
2685 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2686 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2687 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2691 /* Create SNOW 3G session */
2692 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2693 tdata->key.data, tdata->key.len,
2694 tdata->auth_iv.len, tdata->digest.len,
2695 RTE_CRYPTO_AUTH_OP_GENERATE,
2696 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2700 /* alloc mbuf and set payload */
2701 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2703 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2704 rte_pktmbuf_tailroom(ut_params->ibuf));
2706 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2707 /* Append data which is padded to a multiple of */
2708 /* the algorithms block size */
2709 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2710 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2712 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2714 /* Create SNOW 3G operation */
2715 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2716 tdata->auth_iv.data, tdata->auth_iv.len,
2717 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2718 tdata->validAuthLenInBits.len,
2723 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2724 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2725 ut_params->op, 0, 1, 1, 0);
2727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2729 ut_params->obuf = ut_params->op->sym->m_src;
2730 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2731 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2732 + plaintext_pad_len;
2735 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2738 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2739 "SNOW 3G Generated auth tag not as expected");
2745 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2747 struct crypto_testsuite_params *ts_params = &testsuite_params;
2748 struct crypto_unittest_params *ut_params = &unittest_params;
2751 unsigned plaintext_pad_len;
2752 unsigned plaintext_len;
2754 struct rte_cryptodev_info dev_info;
2756 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2757 uint64_t feat_flags = dev_info.feature_flags;
2759 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2760 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2761 printf("Device doesn't support NON-Byte Aligned Data.\n");
2765 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2766 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2767 printf("Device doesn't support RAW data-path APIs.\n");
2771 /* Verify the capabilities */
2772 struct rte_cryptodev_sym_capability_idx cap_idx;
2773 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2774 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2775 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2779 /* Create SNOW 3G session */
2780 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2781 tdata->key.data, tdata->key.len,
2782 tdata->auth_iv.len, tdata->digest.len,
2783 RTE_CRYPTO_AUTH_OP_VERIFY,
2784 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2787 /* alloc mbuf and set payload */
2788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2790 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2791 rte_pktmbuf_tailroom(ut_params->ibuf));
2793 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2794 /* Append data which is padded to a multiple of */
2795 /* the algorithms block size */
2796 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2797 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2799 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2801 /* Create SNOW 3G operation */
2802 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2804 tdata->auth_iv.data, tdata->auth_iv.len,
2806 RTE_CRYPTO_AUTH_OP_VERIFY,
2807 tdata->validAuthLenInBits.len,
2812 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2813 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2814 ut_params->op, 0, 1, 1, 0);
2816 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2818 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2819 ut_params->obuf = ut_params->op->sym->m_src;
2820 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2821 + plaintext_pad_len;
2824 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2833 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2835 struct crypto_testsuite_params *ts_params = &testsuite_params;
2836 struct crypto_unittest_params *ut_params = &unittest_params;
2839 unsigned plaintext_pad_len;
2840 unsigned plaintext_len;
2842 struct rte_cryptodev_info dev_info;
2844 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2845 uint64_t feat_flags = dev_info.feature_flags;
2847 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2848 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2849 printf("Device doesn't support RAW data-path APIs.\n");
2853 /* Verify the capabilities */
2854 struct rte_cryptodev_sym_capability_idx cap_idx;
2855 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2856 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2857 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2861 /* Create KASUMI session */
2862 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2863 tdata->key.data, tdata->key.len,
2864 0, tdata->digest.len,
2865 RTE_CRYPTO_AUTH_OP_GENERATE,
2866 RTE_CRYPTO_AUTH_KASUMI_F9);
2870 /* alloc mbuf and set payload */
2871 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2873 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2874 rte_pktmbuf_tailroom(ut_params->ibuf));
2876 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2877 /* Append data which is padded to a multiple of */
2878 /* the algorithms block size */
2879 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2880 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2882 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2884 /* Create KASUMI operation */
2885 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2887 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2888 tdata->plaintext.len,
2893 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2894 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2896 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2897 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2898 ut_params->op, 0, 1, 1, 0);
2900 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2903 ut_params->obuf = ut_params->op->sym->m_src;
2904 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2905 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2906 + plaintext_pad_len;
2909 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2912 DIGEST_BYTE_LENGTH_KASUMI_F9,
2913 "KASUMI Generated auth tag not as expected");
2919 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2921 struct crypto_testsuite_params *ts_params = &testsuite_params;
2922 struct crypto_unittest_params *ut_params = &unittest_params;
2925 unsigned plaintext_pad_len;
2926 unsigned plaintext_len;
2928 struct rte_cryptodev_info dev_info;
2930 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2931 uint64_t feat_flags = dev_info.feature_flags;
2933 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2934 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2935 printf("Device doesn't support RAW data-path APIs.\n");
2939 /* Verify the capabilities */
2940 struct rte_cryptodev_sym_capability_idx cap_idx;
2941 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2942 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2943 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2947 /* Create KASUMI session */
2948 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2949 tdata->key.data, tdata->key.len,
2950 0, tdata->digest.len,
2951 RTE_CRYPTO_AUTH_OP_VERIFY,
2952 RTE_CRYPTO_AUTH_KASUMI_F9);
2955 /* alloc mbuf and set payload */
2956 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2958 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2959 rte_pktmbuf_tailroom(ut_params->ibuf));
2961 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2962 /* Append data which is padded to a multiple */
2963 /* of the algorithms block size */
2964 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2965 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2967 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2969 /* Create KASUMI operation */
2970 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2974 RTE_CRYPTO_AUTH_OP_VERIFY,
2975 tdata->plaintext.len,
2980 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2981 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2982 ut_params->op, 0, 1, 1, 0);
2984 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2986 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2987 ut_params->obuf = ut_params->op->sym->m_src;
2988 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2989 + plaintext_pad_len;
2992 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3001 test_snow3g_hash_generate_test_case_1(void)
3003 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3007 test_snow3g_hash_generate_test_case_2(void)
3009 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3013 test_snow3g_hash_generate_test_case_3(void)
3015 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3019 test_snow3g_hash_generate_test_case_4(void)
3021 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3025 test_snow3g_hash_generate_test_case_5(void)
3027 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3031 test_snow3g_hash_generate_test_case_6(void)
3033 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3037 test_snow3g_hash_verify_test_case_1(void)
3039 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3044 test_snow3g_hash_verify_test_case_2(void)
3046 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3050 test_snow3g_hash_verify_test_case_3(void)
3052 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3056 test_snow3g_hash_verify_test_case_4(void)
3058 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3062 test_snow3g_hash_verify_test_case_5(void)
3064 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3068 test_snow3g_hash_verify_test_case_6(void)
3070 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3074 test_kasumi_hash_generate_test_case_1(void)
3076 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3080 test_kasumi_hash_generate_test_case_2(void)
3082 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3086 test_kasumi_hash_generate_test_case_3(void)
3088 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3092 test_kasumi_hash_generate_test_case_4(void)
3094 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3098 test_kasumi_hash_generate_test_case_5(void)
3100 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3104 test_kasumi_hash_generate_test_case_6(void)
3106 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3110 test_kasumi_hash_verify_test_case_1(void)
3112 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3116 test_kasumi_hash_verify_test_case_2(void)
3118 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3122 test_kasumi_hash_verify_test_case_3(void)
3124 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3128 test_kasumi_hash_verify_test_case_4(void)
3130 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3134 test_kasumi_hash_verify_test_case_5(void)
3136 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3140 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3142 struct crypto_testsuite_params *ts_params = &testsuite_params;
3143 struct crypto_unittest_params *ut_params = &unittest_params;
3146 uint8_t *plaintext, *ciphertext;
3147 unsigned plaintext_pad_len;
3148 unsigned plaintext_len;
3149 struct rte_cryptodev_info dev_info;
3151 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3152 uint64_t feat_flags = dev_info.feature_flags;
3154 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3155 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3156 printf("Device doesn't support RAW data-path APIs.\n");
3160 /* Verify the capabilities */
3161 struct rte_cryptodev_sym_capability_idx cap_idx;
3162 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3163 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3164 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3168 /* Create KASUMI session */
3169 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3170 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3171 RTE_CRYPTO_CIPHER_KASUMI_F8,
3172 tdata->key.data, tdata->key.len,
3173 tdata->cipher_iv.len);
3177 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3179 /* Clear mbuf payload */
3180 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3181 rte_pktmbuf_tailroom(ut_params->ibuf));
3183 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3184 /* Append data which is padded to a multiple */
3185 /* of the algorithms block size */
3186 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3187 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3189 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3191 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3193 /* Create KASUMI operation */
3194 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3195 tdata->cipher_iv.len,
3196 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3197 tdata->validCipherOffsetInBits.len);
3201 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3202 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3203 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3205 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3207 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3209 ut_params->obuf = ut_params->op->sym->m_dst;
3210 if (ut_params->obuf)
3211 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3213 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3215 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3217 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3218 (tdata->validCipherOffsetInBits.len >> 3);
3220 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3222 reference_ciphertext,
3223 tdata->validCipherLenInBits.len,
3224 "KASUMI Ciphertext data not as expected");
3229 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3231 struct crypto_testsuite_params *ts_params = &testsuite_params;
3232 struct crypto_unittest_params *ut_params = &unittest_params;
3236 unsigned int plaintext_pad_len;
3237 unsigned int plaintext_len;
3239 uint8_t buffer[10000];
3240 const uint8_t *ciphertext;
3242 struct rte_cryptodev_info dev_info;
3244 /* Verify the capabilities */
3245 struct rte_cryptodev_sym_capability_idx cap_idx;
3246 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3247 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3248 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3252 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3254 uint64_t feat_flags = dev_info.feature_flags;
3256 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3257 printf("Device doesn't support in-place scatter-gather. "
3262 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3263 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3264 printf("Device doesn't support RAW data-path APIs.\n");
3268 /* Create KASUMI session */
3269 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3270 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3271 RTE_CRYPTO_CIPHER_KASUMI_F8,
3272 tdata->key.data, tdata->key.len,
3273 tdata->cipher_iv.len);
3277 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3280 /* Append data which is padded to a multiple */
3281 /* of the algorithms block size */
3282 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3284 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3285 plaintext_pad_len, 10, 0);
3287 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3289 /* Create KASUMI operation */
3290 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3291 tdata->cipher_iv.len,
3292 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3293 tdata->validCipherOffsetInBits.len);
3297 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3298 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3299 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3301 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3303 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3305 ut_params->obuf = ut_params->op->sym->m_dst;
3307 if (ut_params->obuf)
3308 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3309 plaintext_len, buffer);
3311 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3312 tdata->validCipherOffsetInBits.len >> 3,
3313 plaintext_len, buffer);
3316 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3318 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3319 (tdata->validCipherOffsetInBits.len >> 3);
3321 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3323 reference_ciphertext,
3324 tdata->validCipherLenInBits.len,
3325 "KASUMI Ciphertext data not as expected");
3330 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3332 struct crypto_testsuite_params *ts_params = &testsuite_params;
3333 struct crypto_unittest_params *ut_params = &unittest_params;
3336 uint8_t *plaintext, *ciphertext;
3337 unsigned plaintext_pad_len;
3338 unsigned plaintext_len;
3340 /* Verify the capabilities */
3341 struct rte_cryptodev_sym_capability_idx cap_idx;
3342 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3343 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3344 /* Data-path service does not support OOP */
3345 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3349 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3352 /* Create KASUMI session */
3353 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3354 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3355 RTE_CRYPTO_CIPHER_KASUMI_F8,
3356 tdata->key.data, tdata->key.len,
3357 tdata->cipher_iv.len);
3361 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3362 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3364 /* Clear mbuf payload */
3365 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3366 rte_pktmbuf_tailroom(ut_params->ibuf));
3368 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3369 /* Append data which is padded to a multiple */
3370 /* of the algorithms block size */
3371 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3372 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3374 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3375 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3377 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3379 /* Create KASUMI operation */
3380 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3381 tdata->cipher_iv.len,
3382 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3383 tdata->validCipherOffsetInBits.len);
3387 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3389 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3391 ut_params->obuf = ut_params->op->sym->m_dst;
3392 if (ut_params->obuf)
3393 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3395 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3397 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3399 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3400 (tdata->validCipherOffsetInBits.len >> 3);
3402 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3404 reference_ciphertext,
3405 tdata->validCipherLenInBits.len,
3406 "KASUMI Ciphertext data not as expected");
3411 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3413 struct crypto_testsuite_params *ts_params = &testsuite_params;
3414 struct crypto_unittest_params *ut_params = &unittest_params;
3417 unsigned int plaintext_pad_len;
3418 unsigned int plaintext_len;
3420 const uint8_t *ciphertext;
3421 uint8_t buffer[2048];
3423 struct rte_cryptodev_info dev_info;
3425 /* Verify the capabilities */
3426 struct rte_cryptodev_sym_capability_idx cap_idx;
3427 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3428 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3429 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3433 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3436 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3438 uint64_t feat_flags = dev_info.feature_flags;
3439 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3440 printf("Device doesn't support out-of-place scatter-gather "
3441 "in both input and output mbufs. "
3446 /* Create KASUMI session */
3447 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3448 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3449 RTE_CRYPTO_CIPHER_KASUMI_F8,
3450 tdata->key.data, tdata->key.len,
3451 tdata->cipher_iv.len);
3455 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3456 /* Append data which is padded to a multiple */
3457 /* of the algorithms block size */
3458 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3460 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3461 plaintext_pad_len, 10, 0);
3462 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3463 plaintext_pad_len, 3, 0);
3465 /* Append data which is padded to a multiple */
3466 /* of the algorithms block size */
3467 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3469 /* Create KASUMI operation */
3470 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3471 tdata->cipher_iv.len,
3472 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3473 tdata->validCipherOffsetInBits.len);
3477 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3479 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3481 ut_params->obuf = ut_params->op->sym->m_dst;
3482 if (ut_params->obuf)
3483 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3484 plaintext_pad_len, buffer);
3486 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3487 tdata->validCipherOffsetInBits.len >> 3,
3488 plaintext_pad_len, buffer);
3490 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3491 (tdata->validCipherOffsetInBits.len >> 3);
3493 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3495 reference_ciphertext,
3496 tdata->validCipherLenInBits.len,
3497 "KASUMI Ciphertext data not as expected");
3503 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3505 struct crypto_testsuite_params *ts_params = &testsuite_params;
3506 struct crypto_unittest_params *ut_params = &unittest_params;
3509 uint8_t *ciphertext, *plaintext;
3510 unsigned ciphertext_pad_len;
3511 unsigned ciphertext_len;
3513 /* Verify the capabilities */
3514 struct rte_cryptodev_sym_capability_idx cap_idx;
3515 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3516 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3517 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3521 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3524 /* Create KASUMI session */
3525 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3526 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3527 RTE_CRYPTO_CIPHER_KASUMI_F8,
3528 tdata->key.data, tdata->key.len,
3529 tdata->cipher_iv.len);
3533 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3534 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3536 /* Clear mbuf payload */
3537 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3538 rte_pktmbuf_tailroom(ut_params->ibuf));
3540 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3541 /* Append data which is padded to a multiple */
3542 /* of the algorithms block size */
3543 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3544 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3545 ciphertext_pad_len);
3546 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3547 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3549 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3551 /* Create KASUMI operation */
3552 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3553 tdata->cipher_iv.len,
3554 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3555 tdata->validCipherOffsetInBits.len);
3559 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3561 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3563 ut_params->obuf = ut_params->op->sym->m_dst;
3564 if (ut_params->obuf)
3565 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3567 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3569 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3571 const uint8_t *reference_plaintext = tdata->plaintext.data +
3572 (tdata->validCipherOffsetInBits.len >> 3);
3574 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3576 reference_plaintext,
3577 tdata->validCipherLenInBits.len,
3578 "KASUMI Plaintext data not as expected");
3583 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3585 struct crypto_testsuite_params *ts_params = &testsuite_params;
3586 struct crypto_unittest_params *ut_params = &unittest_params;
3589 uint8_t *ciphertext, *plaintext;
3590 unsigned ciphertext_pad_len;
3591 unsigned ciphertext_len;
3592 struct rte_cryptodev_info dev_info;
3594 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3595 uint64_t feat_flags = dev_info.feature_flags;
3597 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3598 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3599 printf("Device doesn't support RAW data-path APIs.\n");
3603 /* Verify the capabilities */
3604 struct rte_cryptodev_sym_capability_idx cap_idx;
3605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3606 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3611 /* Create KASUMI session */
3612 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3613 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3614 RTE_CRYPTO_CIPHER_KASUMI_F8,
3615 tdata->key.data, tdata->key.len,
3616 tdata->cipher_iv.len);
3620 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3622 /* Clear mbuf payload */
3623 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3624 rte_pktmbuf_tailroom(ut_params->ibuf));
3626 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3627 /* Append data which is padded to a multiple */
3628 /* of the algorithms block size */
3629 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3630 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3631 ciphertext_pad_len);
3632 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3634 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3636 /* Create KASUMI operation */
3637 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3638 tdata->cipher_iv.len,
3639 tdata->ciphertext.len,
3640 tdata->validCipherOffsetInBits.len);
3644 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3645 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3646 ut_params->op, 1, 0, 1, 0);
3648 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3650 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3652 ut_params->obuf = ut_params->op->sym->m_dst;
3653 if (ut_params->obuf)
3654 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3656 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3658 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3660 const uint8_t *reference_plaintext = tdata->plaintext.data +
3661 (tdata->validCipherOffsetInBits.len >> 3);
3663 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3665 reference_plaintext,
3666 tdata->validCipherLenInBits.len,
3667 "KASUMI Plaintext data not as expected");
3672 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3674 struct crypto_testsuite_params *ts_params = &testsuite_params;
3675 struct crypto_unittest_params *ut_params = &unittest_params;
3678 uint8_t *plaintext, *ciphertext;
3679 unsigned plaintext_pad_len;
3680 unsigned plaintext_len;
3681 struct rte_cryptodev_info dev_info;
3683 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3684 uint64_t feat_flags = dev_info.feature_flags;
3686 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3687 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3688 printf("Device doesn't support RAW data-path APIs.\n");
3692 /* Verify the capabilities */
3693 struct rte_cryptodev_sym_capability_idx cap_idx;
3694 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3695 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3696 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3700 /* Create SNOW 3G session */
3701 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3702 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3703 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3704 tdata->key.data, tdata->key.len,
3705 tdata->cipher_iv.len);
3709 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3711 /* Clear mbuf payload */
3712 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3713 rte_pktmbuf_tailroom(ut_params->ibuf));
3715 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3716 /* Append data which is padded to a multiple of */
3717 /* the algorithms block size */
3718 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3719 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3721 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3723 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3725 /* Create SNOW 3G operation */
3726 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3727 tdata->cipher_iv.len,
3728 tdata->validCipherLenInBits.len,
3733 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3734 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3735 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3739 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3741 ut_params->obuf = ut_params->op->sym->m_dst;
3742 if (ut_params->obuf)
3743 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3745 ciphertext = plaintext;
3747 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3750 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3752 tdata->ciphertext.data,
3753 tdata->validDataLenInBits.len,
3754 "SNOW 3G Ciphertext data not as expected");
3760 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3762 struct crypto_testsuite_params *ts_params = &testsuite_params;
3763 struct crypto_unittest_params *ut_params = &unittest_params;
3764 uint8_t *plaintext, *ciphertext;
3767 unsigned plaintext_pad_len;
3768 unsigned plaintext_len;
3770 /* Verify the capabilities */
3771 struct rte_cryptodev_sym_capability_idx cap_idx;
3772 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3773 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3774 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3778 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3781 /* Create SNOW 3G session */
3782 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3783 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3784 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3785 tdata->key.data, tdata->key.len,
3786 tdata->cipher_iv.len);
3790 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3791 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3793 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3794 "Failed to allocate input buffer in mempool");
3795 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3796 "Failed to allocate output buffer in mempool");
3798 /* Clear mbuf payload */
3799 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3800 rte_pktmbuf_tailroom(ut_params->ibuf));
3802 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3803 /* Append data which is padded to a multiple of */
3804 /* the algorithms block size */
3805 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3806 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3808 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3809 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3811 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3813 /* Create SNOW 3G operation */
3814 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3815 tdata->cipher_iv.len,
3816 tdata->validCipherLenInBits.len,
3821 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3825 ut_params->obuf = ut_params->op->sym->m_dst;
3826 if (ut_params->obuf)
3827 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3829 ciphertext = plaintext;
3831 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3834 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3836 tdata->ciphertext.data,
3837 tdata->validDataLenInBits.len,
3838 "SNOW 3G Ciphertext data not as expected");
3843 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3845 struct crypto_testsuite_params *ts_params = &testsuite_params;
3846 struct crypto_unittest_params *ut_params = &unittest_params;
3849 unsigned int plaintext_pad_len;
3850 unsigned int plaintext_len;
3851 uint8_t buffer[10000];
3852 const uint8_t *ciphertext;
3854 struct rte_cryptodev_info dev_info;
3856 /* Verify the capabilities */
3857 struct rte_cryptodev_sym_capability_idx cap_idx;
3858 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3859 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3860 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3864 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3867 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3869 uint64_t feat_flags = dev_info.feature_flags;
3871 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3872 printf("Device doesn't support out-of-place scatter-gather "
3873 "in both input and output mbufs. "
3878 /* Create SNOW 3G session */
3879 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3880 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3881 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3882 tdata->key.data, tdata->key.len,
3883 tdata->cipher_iv.len);
3887 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3888 /* Append data which is padded to a multiple of */
3889 /* the algorithms block size */
3890 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3892 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3893 plaintext_pad_len, 10, 0);
3894 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3895 plaintext_pad_len, 3, 0);
3897 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3898 "Failed to allocate input buffer in mempool");
3899 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3900 "Failed to allocate output buffer in mempool");
3902 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3904 /* Create SNOW 3G operation */
3905 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3906 tdata->cipher_iv.len,
3907 tdata->validCipherLenInBits.len,
3912 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3914 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3916 ut_params->obuf = ut_params->op->sym->m_dst;
3917 if (ut_params->obuf)
3918 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3919 plaintext_len, buffer);
3921 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3922 plaintext_len, buffer);
3924 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3927 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3929 tdata->ciphertext.data,
3930 tdata->validDataLenInBits.len,
3931 "SNOW 3G Ciphertext data not as expected");
3936 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3938 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3940 uint8_t curr_byte, prev_byte;
3941 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3942 uint8_t lower_byte_mask = (1 << offset) - 1;
3945 prev_byte = buffer[0];
3946 buffer[0] >>= offset;
3948 for (i = 1; i < length_in_bytes; i++) {
3949 curr_byte = buffer[i];
3950 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3951 (curr_byte >> offset);
3952 prev_byte = curr_byte;
3957 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3959 struct crypto_testsuite_params *ts_params = &testsuite_params;
3960 struct crypto_unittest_params *ut_params = &unittest_params;
3961 uint8_t *plaintext, *ciphertext;
3963 uint32_t plaintext_len;
3964 uint32_t plaintext_pad_len;
3965 uint8_t extra_offset = 4;
3966 uint8_t *expected_ciphertext_shifted;
3967 struct rte_cryptodev_info dev_info;
3969 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3970 uint64_t feat_flags = dev_info.feature_flags;
3972 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3973 ((tdata->validDataLenInBits.len % 8) != 0)) {
3974 printf("Device doesn't support NON-Byte Aligned Data.\n");
3978 /* Verify the capabilities */
3979 struct rte_cryptodev_sym_capability_idx cap_idx;
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 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3989 /* Create SNOW 3G session */
3990 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3991 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3992 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3993 tdata->key.data, tdata->key.len,
3994 tdata->cipher_iv.len);
3998 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3999 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4001 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4002 "Failed to allocate input buffer in mempool");
4003 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4004 "Failed to allocate output buffer in mempool");
4006 /* Clear mbuf payload */
4007 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4008 rte_pktmbuf_tailroom(ut_params->ibuf));
4010 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4012 * Append data which is padded to a
4013 * multiple of the algorithms block size
4015 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4017 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4020 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4022 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4023 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4025 #ifdef RTE_APP_TEST_DEBUG
4026 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4028 /* Create SNOW 3G operation */
4029 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4030 tdata->cipher_iv.len,
4031 tdata->validCipherLenInBits.len,
4036 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4038 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4040 ut_params->obuf = ut_params->op->sym->m_dst;
4041 if (ut_params->obuf)
4042 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4044 ciphertext = plaintext;
4046 #ifdef RTE_APP_TEST_DEBUG
4047 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4050 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4052 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4053 "failed to reserve memory for ciphertext shifted\n");
4055 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4056 ceil_byte_length(tdata->ciphertext.len));
4057 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4060 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4062 expected_ciphertext_shifted,
4063 tdata->validDataLenInBits.len,
4065 "SNOW 3G Ciphertext data not as expected");
4069 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4071 struct crypto_testsuite_params *ts_params = &testsuite_params;
4072 struct crypto_unittest_params *ut_params = &unittest_params;
4076 uint8_t *plaintext, *ciphertext;
4077 unsigned ciphertext_pad_len;
4078 unsigned ciphertext_len;
4079 struct rte_cryptodev_info dev_info;
4081 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4082 uint64_t feat_flags = dev_info.feature_flags;
4084 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4085 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4086 printf("Device doesn't support RAW data-path APIs.\n");
4090 /* Verify the capabilities */
4091 struct rte_cryptodev_sym_capability_idx cap_idx;
4092 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4093 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4094 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4098 /* Create SNOW 3G session */
4099 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4100 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4101 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4102 tdata->key.data, tdata->key.len,
4103 tdata->cipher_iv.len);
4107 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4109 /* Clear mbuf payload */
4110 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4111 rte_pktmbuf_tailroom(ut_params->ibuf));
4113 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4114 /* Append data which is padded to a multiple of */
4115 /* the algorithms block size */
4116 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4117 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4118 ciphertext_pad_len);
4119 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4121 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4123 /* Create SNOW 3G operation */
4124 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4125 tdata->cipher_iv.len,
4126 tdata->validCipherLenInBits.len,
4127 tdata->cipher.offset_bits);
4131 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4132 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4133 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4135 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4137 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4138 ut_params->obuf = ut_params->op->sym->m_dst;
4139 if (ut_params->obuf)
4140 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4142 plaintext = ciphertext;
4144 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4147 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4148 tdata->plaintext.data,
4149 tdata->validDataLenInBits.len,
4150 "SNOW 3G Plaintext data not as expected");
4154 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4156 struct crypto_testsuite_params *ts_params = &testsuite_params;
4157 struct crypto_unittest_params *ut_params = &unittest_params;
4161 uint8_t *plaintext, *ciphertext;
4162 unsigned ciphertext_pad_len;
4163 unsigned ciphertext_len;
4165 /* Verify the capabilities */
4166 struct rte_cryptodev_sym_capability_idx cap_idx;
4167 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4168 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4169 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4173 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4176 /* Create SNOW 3G session */
4177 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4178 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4179 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4180 tdata->key.data, tdata->key.len,
4181 tdata->cipher_iv.len);
4185 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4186 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4188 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4189 "Failed to allocate input buffer");
4190 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4191 "Failed to allocate output buffer");
4193 /* Clear mbuf payload */
4194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4195 rte_pktmbuf_tailroom(ut_params->ibuf));
4197 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4198 rte_pktmbuf_tailroom(ut_params->obuf));
4200 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4201 /* Append data which is padded to a multiple of */
4202 /* the algorithms block size */
4203 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4204 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4205 ciphertext_pad_len);
4206 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4207 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4209 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4211 /* Create SNOW 3G operation */
4212 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4213 tdata->cipher_iv.len,
4214 tdata->validCipherLenInBits.len,
4219 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4221 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4222 ut_params->obuf = ut_params->op->sym->m_dst;
4223 if (ut_params->obuf)
4224 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4226 plaintext = ciphertext;
4228 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4231 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4232 tdata->plaintext.data,
4233 tdata->validDataLenInBits.len,
4234 "SNOW 3G Plaintext data not as expected");
4239 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4241 struct crypto_testsuite_params *ts_params = &testsuite_params;
4242 struct crypto_unittest_params *ut_params = &unittest_params;
4246 uint8_t *plaintext, *ciphertext;
4247 unsigned int plaintext_pad_len;
4248 unsigned int plaintext_len;
4250 struct rte_cryptodev_info dev_info;
4251 struct rte_cryptodev_sym_capability_idx cap_idx;
4253 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4254 uint64_t feat_flags = dev_info.feature_flags;
4256 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4257 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4258 (tdata->validDataLenInBits.len % 8 != 0))) {
4259 printf("Device doesn't support NON-Byte Aligned Data.\n");
4263 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4264 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4265 printf("Device doesn't support RAW data-path APIs.\n");
4269 /* Check if device supports ZUC EEA3 */
4270 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4271 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4273 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4277 /* Check if device supports ZUC EIA3 */
4278 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4279 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4281 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4285 /* Create ZUC session */
4286 retval = create_zuc_cipher_auth_encrypt_generate_session(
4287 ts_params->valid_devs[0],
4291 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4293 /* clear mbuf payload */
4294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4295 rte_pktmbuf_tailroom(ut_params->ibuf));
4297 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4298 /* Append data which is padded to a multiple of */
4299 /* the algorithms block size */
4300 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4301 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4303 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4305 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4307 /* Create ZUC operation */
4308 retval = create_zuc_cipher_hash_generate_operation(tdata);
4312 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4313 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4314 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4316 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4318 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4319 ut_params->obuf = ut_params->op->sym->m_src;
4320 if (ut_params->obuf)
4321 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4323 ciphertext = plaintext;
4325 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4327 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4329 tdata->ciphertext.data,
4330 tdata->validDataLenInBits.len,
4331 "ZUC Ciphertext data not as expected");
4333 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4334 + plaintext_pad_len;
4337 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4341 "ZUC Generated auth tag not as expected");
4346 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4348 struct crypto_testsuite_params *ts_params = &testsuite_params;
4349 struct crypto_unittest_params *ut_params = &unittest_params;
4353 uint8_t *plaintext, *ciphertext;
4354 unsigned plaintext_pad_len;
4355 unsigned plaintext_len;
4356 struct rte_cryptodev_info dev_info;
4358 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4359 uint64_t feat_flags = dev_info.feature_flags;
4361 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4362 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4363 printf("Device doesn't support RAW data-path APIs.\n");
4367 /* Verify the capabilities */
4368 struct rte_cryptodev_sym_capability_idx cap_idx;
4369 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4370 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4371 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4374 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4375 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4376 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4380 /* Create SNOW 3G session */
4381 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4382 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4383 RTE_CRYPTO_AUTH_OP_GENERATE,
4384 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4385 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4386 tdata->key.data, tdata->key.len,
4387 tdata->auth_iv.len, tdata->digest.len,
4388 tdata->cipher_iv.len);
4391 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4393 /* clear mbuf payload */
4394 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4395 rte_pktmbuf_tailroom(ut_params->ibuf));
4397 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4398 /* Append data which is padded to a multiple of */
4399 /* the algorithms block size */
4400 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4401 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4403 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4405 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4407 /* Create SNOW 3G operation */
4408 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4409 tdata->digest.len, tdata->auth_iv.data,
4411 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4412 tdata->cipher_iv.data, tdata->cipher_iv.len,
4413 tdata->validCipherLenInBits.len,
4415 tdata->validAuthLenInBits.len,
4421 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4422 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4423 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4425 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4427 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4428 ut_params->obuf = ut_params->op->sym->m_src;
4429 if (ut_params->obuf)
4430 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4432 ciphertext = plaintext;
4434 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4436 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4438 tdata->ciphertext.data,
4439 tdata->validDataLenInBits.len,
4440 "SNOW 3G Ciphertext data not as expected");
4442 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4443 + plaintext_pad_len;
4446 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4449 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4450 "SNOW 3G Generated auth tag not as expected");
4455 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4456 uint8_t op_mode, uint8_t verify)
4458 struct crypto_testsuite_params *ts_params = &testsuite_params;
4459 struct crypto_unittest_params *ut_params = &unittest_params;
4463 uint8_t *plaintext = NULL, *ciphertext = NULL;
4464 unsigned int plaintext_pad_len;
4465 unsigned int plaintext_len;
4466 unsigned int ciphertext_pad_len;
4467 unsigned int ciphertext_len;
4469 struct rte_cryptodev_info dev_info;
4471 /* Verify the capabilities */
4472 struct rte_cryptodev_sym_capability_idx cap_idx;
4473 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4474 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4475 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4478 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4479 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4480 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4484 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4486 uint64_t feat_flags = dev_info.feature_flags;
4488 if (op_mode == OUT_OF_PLACE) {
4489 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4490 printf("Device doesn't support digest encrypted.\n");
4493 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4497 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4498 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4499 printf("Device doesn't support RAW data-path APIs.\n");
4503 /* Create SNOW 3G session */
4504 retval = create_wireless_algo_auth_cipher_session(
4505 ts_params->valid_devs[0],
4506 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4507 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4508 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4509 : RTE_CRYPTO_AUTH_OP_GENERATE),
4510 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4511 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4512 tdata->key.data, tdata->key.len,
4513 tdata->auth_iv.len, tdata->digest.len,
4514 tdata->cipher_iv.len);
4519 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4520 if (op_mode == OUT_OF_PLACE)
4521 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4523 /* clear mbuf payload */
4524 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4525 rte_pktmbuf_tailroom(ut_params->ibuf));
4526 if (op_mode == OUT_OF_PLACE)
4527 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4528 rte_pktmbuf_tailroom(ut_params->obuf));
4530 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4531 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4532 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4533 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4536 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4537 ciphertext_pad_len);
4538 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4539 if (op_mode == OUT_OF_PLACE)
4540 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4541 debug_hexdump(stdout, "ciphertext:", ciphertext,
4544 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4546 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4547 if (op_mode == OUT_OF_PLACE)
4548 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4549 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4552 /* Create SNOW 3G operation */
4553 retval = create_wireless_algo_auth_cipher_operation(
4554 tdata->digest.data, tdata->digest.len,
4555 tdata->cipher_iv.data, tdata->cipher_iv.len,
4556 tdata->auth_iv.data, tdata->auth_iv.len,
4557 (tdata->digest.offset_bytes == 0 ?
4558 (verify ? ciphertext_pad_len : plaintext_pad_len)
4559 : tdata->digest.offset_bytes),
4560 tdata->validCipherLenInBits.len,
4561 tdata->cipher.offset_bits,
4562 tdata->validAuthLenInBits.len,
4563 tdata->auth.offset_bits,
4564 op_mode, 0, verify);
4569 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4570 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4571 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4573 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4576 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4578 ut_params->obuf = (op_mode == IN_PLACE ?
4579 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4582 if (ut_params->obuf)
4583 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4586 plaintext = ciphertext +
4587 (tdata->cipher.offset_bits >> 3);
4589 debug_hexdump(stdout, "plaintext:", plaintext,
4590 (tdata->plaintext.len >> 3) - tdata->digest.len);
4591 debug_hexdump(stdout, "plaintext expected:",
4592 tdata->plaintext.data,
4593 (tdata->plaintext.len >> 3) - tdata->digest.len);
4595 if (ut_params->obuf)
4596 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4599 ciphertext = plaintext;
4601 debug_hexdump(stdout, "ciphertext:", ciphertext,
4603 debug_hexdump(stdout, "ciphertext expected:",
4604 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4606 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4607 + (tdata->digest.offset_bytes == 0 ?
4608 plaintext_pad_len : tdata->digest.offset_bytes);
4610 debug_hexdump(stdout, "digest:", ut_params->digest,
4612 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4618 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4620 tdata->plaintext.data,
4621 tdata->plaintext.len >> 3,
4622 "SNOW 3G Plaintext data not as expected");
4624 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4626 tdata->ciphertext.data,
4627 tdata->validDataLenInBits.len,
4628 "SNOW 3G Ciphertext data not as expected");
4630 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4633 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4634 "SNOW 3G Generated auth tag not as expected");
4640 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4641 uint8_t op_mode, uint8_t verify)
4643 struct crypto_testsuite_params *ts_params = &testsuite_params;
4644 struct crypto_unittest_params *ut_params = &unittest_params;
4648 const uint8_t *plaintext = NULL;
4649 const uint8_t *ciphertext = NULL;
4650 const uint8_t *digest = NULL;
4651 unsigned int plaintext_pad_len;
4652 unsigned int plaintext_len;
4653 unsigned int ciphertext_pad_len;
4654 unsigned int ciphertext_len;
4655 uint8_t buffer[10000];
4656 uint8_t digest_buffer[10000];
4658 struct rte_cryptodev_info dev_info;
4660 /* Verify the capabilities */
4661 struct rte_cryptodev_sym_capability_idx cap_idx;
4662 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4663 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4664 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4667 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4668 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4669 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4673 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4675 uint64_t feat_flags = dev_info.feature_flags;
4677 if (op_mode == IN_PLACE) {
4678 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4679 printf("Device doesn't support in-place scatter-gather "
4680 "in both input and output mbufs.\n");
4683 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4684 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4685 printf("Device doesn't support RAW data-path APIs.\n");
4689 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4691 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4692 printf("Device doesn't support out-of-place scatter-gather "
4693 "in both input and output mbufs.\n");
4696 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4697 printf("Device doesn't support digest encrypted.\n");
4702 /* Create SNOW 3G session */
4703 retval = create_wireless_algo_auth_cipher_session(
4704 ts_params->valid_devs[0],
4705 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4706 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4707 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4708 : RTE_CRYPTO_AUTH_OP_GENERATE),
4709 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4710 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4711 tdata->key.data, tdata->key.len,
4712 tdata->auth_iv.len, tdata->digest.len,
4713 tdata->cipher_iv.len);
4718 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4719 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4720 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4721 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4723 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4724 plaintext_pad_len, 15, 0);
4725 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4726 "Failed to allocate input buffer in mempool");
4728 if (op_mode == OUT_OF_PLACE) {
4729 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4730 plaintext_pad_len, 15, 0);
4731 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4732 "Failed to allocate output buffer in mempool");
4736 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4737 tdata->ciphertext.data);
4738 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4739 ciphertext_len, buffer);
4740 debug_hexdump(stdout, "ciphertext:", ciphertext,
4743 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4744 tdata->plaintext.data);
4745 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4746 plaintext_len, buffer);
4747 debug_hexdump(stdout, "plaintext:", plaintext,
4750 memset(buffer, 0, sizeof(buffer));
4752 /* Create SNOW 3G operation */
4753 retval = create_wireless_algo_auth_cipher_operation(
4754 tdata->digest.data, tdata->digest.len,
4755 tdata->cipher_iv.data, tdata->cipher_iv.len,
4756 tdata->auth_iv.data, tdata->auth_iv.len,
4757 (tdata->digest.offset_bytes == 0 ?
4758 (verify ? ciphertext_pad_len : plaintext_pad_len)
4759 : tdata->digest.offset_bytes),
4760 tdata->validCipherLenInBits.len,
4761 tdata->cipher.offset_bits,
4762 tdata->validAuthLenInBits.len,
4763 tdata->auth.offset_bits,
4764 op_mode, 1, verify);
4769 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4770 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4771 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4773 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4776 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4778 ut_params->obuf = (op_mode == IN_PLACE ?
4779 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4782 if (ut_params->obuf)
4783 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4784 plaintext_len, buffer);
4786 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4787 plaintext_len, buffer);
4789 debug_hexdump(stdout, "plaintext:", plaintext,
4790 (tdata->plaintext.len >> 3) - tdata->digest.len);
4791 debug_hexdump(stdout, "plaintext expected:",
4792 tdata->plaintext.data,
4793 (tdata->plaintext.len >> 3) - tdata->digest.len);
4795 if (ut_params->obuf)
4796 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4797 ciphertext_len, buffer);
4799 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4800 ciphertext_len, buffer);
4802 debug_hexdump(stdout, "ciphertext:", ciphertext,
4804 debug_hexdump(stdout, "ciphertext expected:",
4805 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4807 if (ut_params->obuf)
4808 digest = rte_pktmbuf_read(ut_params->obuf,
4809 (tdata->digest.offset_bytes == 0 ?
4810 plaintext_pad_len : tdata->digest.offset_bytes),
4811 tdata->digest.len, digest_buffer);
4813 digest = rte_pktmbuf_read(ut_params->ibuf,
4814 (tdata->digest.offset_bytes == 0 ?
4815 plaintext_pad_len : tdata->digest.offset_bytes),
4816 tdata->digest.len, digest_buffer);
4818 debug_hexdump(stdout, "digest:", digest,
4820 debug_hexdump(stdout, "digest expected:",
4821 tdata->digest.data, tdata->digest.len);
4826 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4828 tdata->plaintext.data,
4829 tdata->plaintext.len >> 3,
4830 "SNOW 3G Plaintext data not as expected");
4832 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4834 tdata->ciphertext.data,
4835 tdata->validDataLenInBits.len,
4836 "SNOW 3G Ciphertext data not as expected");
4838 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4841 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4842 "SNOW 3G Generated auth tag not as expected");
4848 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4849 uint8_t op_mode, uint8_t verify)
4851 struct crypto_testsuite_params *ts_params = &testsuite_params;
4852 struct crypto_unittest_params *ut_params = &unittest_params;
4856 uint8_t *plaintext = NULL, *ciphertext = NULL;
4857 unsigned int plaintext_pad_len;
4858 unsigned int plaintext_len;
4859 unsigned int ciphertext_pad_len;
4860 unsigned int ciphertext_len;
4862 struct rte_cryptodev_info dev_info;
4864 /* Verify the capabilities */
4865 struct rte_cryptodev_sym_capability_idx cap_idx;
4866 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4867 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4868 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4871 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4872 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4873 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4877 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4879 uint64_t feat_flags = dev_info.feature_flags;
4881 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4882 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4883 printf("Device doesn't support RAW data-path APIs.\n");
4887 if (op_mode == OUT_OF_PLACE) {
4888 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4890 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4891 printf("Device doesn't support digest encrypted.\n");
4896 /* Create KASUMI session */
4897 retval = create_wireless_algo_auth_cipher_session(
4898 ts_params->valid_devs[0],
4899 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4900 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4901 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4902 : RTE_CRYPTO_AUTH_OP_GENERATE),
4903 RTE_CRYPTO_AUTH_KASUMI_F9,
4904 RTE_CRYPTO_CIPHER_KASUMI_F8,
4905 tdata->key.data, tdata->key.len,
4906 0, tdata->digest.len,
4907 tdata->cipher_iv.len);
4912 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4913 if (op_mode == OUT_OF_PLACE)
4914 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4916 /* clear mbuf payload */
4917 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4918 rte_pktmbuf_tailroom(ut_params->ibuf));
4919 if (op_mode == OUT_OF_PLACE)
4920 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4921 rte_pktmbuf_tailroom(ut_params->obuf));
4923 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4924 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4925 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4926 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4929 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4930 ciphertext_pad_len);
4931 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4932 if (op_mode == OUT_OF_PLACE)
4933 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4934 debug_hexdump(stdout, "ciphertext:", ciphertext,
4937 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4939 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4940 if (op_mode == OUT_OF_PLACE)
4941 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4942 debug_hexdump(stdout, "plaintext:", plaintext,
4946 /* Create KASUMI operation */
4947 retval = create_wireless_algo_auth_cipher_operation(
4948 tdata->digest.data, tdata->digest.len,
4949 tdata->cipher_iv.data, tdata->cipher_iv.len,
4951 (tdata->digest.offset_bytes == 0 ?
4952 (verify ? ciphertext_pad_len : plaintext_pad_len)
4953 : tdata->digest.offset_bytes),
4954 tdata->validCipherLenInBits.len,
4955 tdata->validCipherOffsetInBits.len,
4956 tdata->validAuthLenInBits.len,
4958 op_mode, 0, verify);
4963 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4964 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4965 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4967 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4970 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4972 ut_params->obuf = (op_mode == IN_PLACE ?
4973 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4977 if (ut_params->obuf)
4978 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4981 plaintext = ciphertext;
4983 debug_hexdump(stdout, "plaintext:", plaintext,
4984 (tdata->plaintext.len >> 3) - tdata->digest.len);
4985 debug_hexdump(stdout, "plaintext expected:",
4986 tdata->plaintext.data,
4987 (tdata->plaintext.len >> 3) - tdata->digest.len);
4989 if (ut_params->obuf)
4990 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4993 ciphertext = plaintext;
4995 debug_hexdump(stdout, "ciphertext:", ciphertext,
4997 debug_hexdump(stdout, "ciphertext expected:",
4998 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5000 ut_params->digest = rte_pktmbuf_mtod(
5001 ut_params->obuf, uint8_t *) +
5002 (tdata->digest.offset_bytes == 0 ?
5003 plaintext_pad_len : tdata->digest.offset_bytes);
5005 debug_hexdump(stdout, "digest:", ut_params->digest,
5007 debug_hexdump(stdout, "digest expected:",
5008 tdata->digest.data, tdata->digest.len);
5013 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5015 tdata->plaintext.data,
5016 tdata->plaintext.len >> 3,
5017 "KASUMI Plaintext data not as expected");
5019 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5021 tdata->ciphertext.data,
5022 tdata->ciphertext.len >> 3,
5023 "KASUMI Ciphertext data not as expected");
5025 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5028 DIGEST_BYTE_LENGTH_KASUMI_F9,
5029 "KASUMI Generated auth tag not as expected");
5035 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5036 uint8_t op_mode, uint8_t verify)
5038 struct crypto_testsuite_params *ts_params = &testsuite_params;
5039 struct crypto_unittest_params *ut_params = &unittest_params;
5043 const uint8_t *plaintext = NULL;
5044 const uint8_t *ciphertext = NULL;
5045 const uint8_t *digest = NULL;
5046 unsigned int plaintext_pad_len;
5047 unsigned int plaintext_len;
5048 unsigned int ciphertext_pad_len;
5049 unsigned int ciphertext_len;
5050 uint8_t buffer[10000];
5051 uint8_t digest_buffer[10000];
5053 struct rte_cryptodev_info dev_info;
5055 /* Verify the capabilities */
5056 struct rte_cryptodev_sym_capability_idx cap_idx;
5057 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5058 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5059 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5062 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5063 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5064 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5068 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5070 uint64_t feat_flags = dev_info.feature_flags;
5072 if (op_mode == IN_PLACE) {
5073 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5074 printf("Device doesn't support in-place scatter-gather "
5075 "in both input and output mbufs.\n");
5078 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5079 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5080 printf("Device doesn't support RAW data-path APIs.\n");
5084 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5086 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5087 printf("Device doesn't support out-of-place scatter-gather "
5088 "in both input and output mbufs.\n");
5091 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5092 printf("Device doesn't support digest encrypted.\n");
5097 /* Create KASUMI session */
5098 retval = create_wireless_algo_auth_cipher_session(
5099 ts_params->valid_devs[0],
5100 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5101 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5102 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5103 : RTE_CRYPTO_AUTH_OP_GENERATE),
5104 RTE_CRYPTO_AUTH_KASUMI_F9,
5105 RTE_CRYPTO_CIPHER_KASUMI_F8,
5106 tdata->key.data, tdata->key.len,
5107 0, tdata->digest.len,
5108 tdata->cipher_iv.len);
5113 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5114 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5115 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5116 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5118 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5119 plaintext_pad_len, 15, 0);
5120 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5121 "Failed to allocate input buffer in mempool");
5123 if (op_mode == OUT_OF_PLACE) {
5124 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5125 plaintext_pad_len, 15, 0);
5126 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5127 "Failed to allocate output buffer in mempool");
5131 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5132 tdata->ciphertext.data);
5133 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5134 ciphertext_len, buffer);
5135 debug_hexdump(stdout, "ciphertext:", ciphertext,
5138 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5139 tdata->plaintext.data);
5140 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5141 plaintext_len, buffer);
5142 debug_hexdump(stdout, "plaintext:", plaintext,
5145 memset(buffer, 0, sizeof(buffer));
5147 /* Create KASUMI operation */
5148 retval = create_wireless_algo_auth_cipher_operation(
5149 tdata->digest.data, tdata->digest.len,
5150 tdata->cipher_iv.data, tdata->cipher_iv.len,
5152 (tdata->digest.offset_bytes == 0 ?
5153 (verify ? ciphertext_pad_len : plaintext_pad_len)
5154 : tdata->digest.offset_bytes),
5155 tdata->validCipherLenInBits.len,
5156 tdata->validCipherOffsetInBits.len,
5157 tdata->validAuthLenInBits.len,
5159 op_mode, 1, verify);
5164 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5165 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5166 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5168 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5171 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5173 ut_params->obuf = (op_mode == IN_PLACE ?
5174 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5177 if (ut_params->obuf)
5178 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5179 plaintext_len, buffer);
5181 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5182 plaintext_len, buffer);
5184 debug_hexdump(stdout, "plaintext:", plaintext,
5185 (tdata->plaintext.len >> 3) - tdata->digest.len);
5186 debug_hexdump(stdout, "plaintext expected:",
5187 tdata->plaintext.data,
5188 (tdata->plaintext.len >> 3) - tdata->digest.len);
5190 if (ut_params->obuf)
5191 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5192 ciphertext_len, buffer);
5194 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5195 ciphertext_len, buffer);
5197 debug_hexdump(stdout, "ciphertext:", ciphertext,
5199 debug_hexdump(stdout, "ciphertext expected:",
5200 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5202 if (ut_params->obuf)
5203 digest = rte_pktmbuf_read(ut_params->obuf,
5204 (tdata->digest.offset_bytes == 0 ?
5205 plaintext_pad_len : tdata->digest.offset_bytes),
5206 tdata->digest.len, digest_buffer);
5208 digest = rte_pktmbuf_read(ut_params->ibuf,
5209 (tdata->digest.offset_bytes == 0 ?
5210 plaintext_pad_len : tdata->digest.offset_bytes),
5211 tdata->digest.len, digest_buffer);
5213 debug_hexdump(stdout, "digest:", digest,
5215 debug_hexdump(stdout, "digest expected:",
5216 tdata->digest.data, tdata->digest.len);
5221 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5223 tdata->plaintext.data,
5224 tdata->plaintext.len >> 3,
5225 "KASUMI Plaintext data not as expected");
5227 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5229 tdata->ciphertext.data,
5230 tdata->validDataLenInBits.len,
5231 "KASUMI Ciphertext data not as expected");
5233 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5236 DIGEST_BYTE_LENGTH_KASUMI_F9,
5237 "KASUMI Generated auth tag not as expected");
5243 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5245 struct crypto_testsuite_params *ts_params = &testsuite_params;
5246 struct crypto_unittest_params *ut_params = &unittest_params;
5250 uint8_t *plaintext, *ciphertext;
5251 unsigned plaintext_pad_len;
5252 unsigned plaintext_len;
5253 struct rte_cryptodev_info dev_info;
5255 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5256 uint64_t feat_flags = dev_info.feature_flags;
5258 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5259 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5260 printf("Device doesn't support RAW data-path APIs.\n");
5264 /* Verify the capabilities */
5265 struct rte_cryptodev_sym_capability_idx cap_idx;
5266 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5267 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5268 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5271 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5272 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5273 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5277 /* Create KASUMI session */
5278 retval = create_wireless_algo_cipher_auth_session(
5279 ts_params->valid_devs[0],
5280 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5281 RTE_CRYPTO_AUTH_OP_GENERATE,
5282 RTE_CRYPTO_AUTH_KASUMI_F9,
5283 RTE_CRYPTO_CIPHER_KASUMI_F8,
5284 tdata->key.data, tdata->key.len,
5285 0, tdata->digest.len,
5286 tdata->cipher_iv.len);
5290 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5292 /* clear mbuf payload */
5293 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5294 rte_pktmbuf_tailroom(ut_params->ibuf));
5296 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5297 /* Append data which is padded to a multiple of */
5298 /* the algorithms block size */
5299 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5300 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5302 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5304 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5306 /* Create KASUMI operation */
5307 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5308 tdata->digest.len, NULL, 0,
5309 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5310 tdata->cipher_iv.data, tdata->cipher_iv.len,
5311 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5312 tdata->validCipherOffsetInBits.len,
5313 tdata->validAuthLenInBits.len,
5319 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5320 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5321 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5323 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5325 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5327 if (ut_params->op->sym->m_dst)
5328 ut_params->obuf = ut_params->op->sym->m_dst;
5330 ut_params->obuf = ut_params->op->sym->m_src;
5332 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5333 tdata->validCipherOffsetInBits.len >> 3);
5335 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5336 + plaintext_pad_len;
5338 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5339 (tdata->validCipherOffsetInBits.len >> 3);
5341 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5343 reference_ciphertext,
5344 tdata->validCipherLenInBits.len,
5345 "KASUMI Ciphertext data not as expected");
5348 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5351 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5352 "KASUMI Generated auth tag not as expected");
5357 test_zuc_encryption(const struct wireless_test_data *tdata)
5359 struct crypto_testsuite_params *ts_params = &testsuite_params;
5360 struct crypto_unittest_params *ut_params = &unittest_params;
5363 uint8_t *plaintext, *ciphertext;
5364 unsigned plaintext_pad_len;
5365 unsigned plaintext_len;
5366 struct rte_cryptodev_info dev_info;
5368 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5369 uint64_t feat_flags = dev_info.feature_flags;
5371 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5372 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5373 printf("Device doesn't support RAW data-path APIs.\n");
5377 struct rte_cryptodev_sym_capability_idx cap_idx;
5379 /* Check if device supports ZUC EEA3 */
5380 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5381 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5383 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5387 /* Create ZUC session */
5388 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5389 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5390 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5391 tdata->key.data, tdata->key.len,
5392 tdata->cipher_iv.len);
5396 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5398 /* Clear mbuf payload */
5399 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5400 rte_pktmbuf_tailroom(ut_params->ibuf));
5402 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5403 /* Append data which is padded to a multiple */
5404 /* of the algorithms block size */
5405 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5406 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5408 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5410 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5412 /* Create ZUC operation */
5413 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5414 tdata->cipher_iv.len,
5415 tdata->plaintext.len,
5420 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5421 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5422 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5424 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5426 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5428 ut_params->obuf = ut_params->op->sym->m_dst;
5429 if (ut_params->obuf)
5430 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5432 ciphertext = plaintext;
5434 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5437 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5439 tdata->ciphertext.data,
5440 tdata->validCipherLenInBits.len,
5441 "ZUC Ciphertext data not as expected");
5446 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5448 struct crypto_testsuite_params *ts_params = &testsuite_params;
5449 struct crypto_unittest_params *ut_params = &unittest_params;
5453 unsigned int plaintext_pad_len;
5454 unsigned int plaintext_len;
5455 const uint8_t *ciphertext;
5456 uint8_t ciphertext_buffer[2048];
5457 struct rte_cryptodev_info dev_info;
5459 struct rte_cryptodev_sym_capability_idx cap_idx;
5461 /* Check if device supports ZUC EEA3 */
5462 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5463 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5469 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5471 uint64_t feat_flags = dev_info.feature_flags;
5473 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5474 printf("Device doesn't support in-place scatter-gather. "
5479 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5480 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5481 printf("Device doesn't support RAW data-path APIs.\n");
5485 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5487 /* Append data which is padded to a multiple */
5488 /* of the algorithms block size */
5489 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5491 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5492 plaintext_pad_len, 10, 0);
5494 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5495 tdata->plaintext.data);
5497 /* Create ZUC session */
5498 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5499 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5500 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5501 tdata->key.data, tdata->key.len,
5502 tdata->cipher_iv.len);
5506 /* Clear mbuf payload */
5508 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5510 /* Create ZUC operation */
5511 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5512 tdata->cipher_iv.len, tdata->plaintext.len,
5517 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5518 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5519 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5521 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5523 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5525 ut_params->obuf = ut_params->op->sym->m_dst;
5526 if (ut_params->obuf)
5527 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5528 0, plaintext_len, ciphertext_buffer);
5530 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5531 0, plaintext_len, ciphertext_buffer);
5534 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5537 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5539 tdata->ciphertext.data,
5540 tdata->validCipherLenInBits.len,
5541 "ZUC Ciphertext data not as expected");
5547 test_zuc_authentication(const struct wireless_test_data *tdata)
5549 struct crypto_testsuite_params *ts_params = &testsuite_params;
5550 struct crypto_unittest_params *ut_params = &unittest_params;
5553 unsigned plaintext_pad_len;
5554 unsigned plaintext_len;
5557 struct rte_cryptodev_sym_capability_idx cap_idx;
5558 struct rte_cryptodev_info dev_info;
5560 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5561 uint64_t feat_flags = dev_info.feature_flags;
5563 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5564 (tdata->validAuthLenInBits.len % 8 != 0)) {
5565 printf("Device doesn't support NON-Byte Aligned Data.\n");
5569 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5570 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5571 printf("Device doesn't support RAW data-path APIs.\n");
5575 /* Check if device supports ZUC EIA3 */
5576 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5577 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5579 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5583 /* Create ZUC session */
5584 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5585 tdata->key.data, tdata->key.len,
5586 tdata->auth_iv.len, tdata->digest.len,
5587 RTE_CRYPTO_AUTH_OP_GENERATE,
5588 RTE_CRYPTO_AUTH_ZUC_EIA3);
5592 /* alloc mbuf and set payload */
5593 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5595 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5596 rte_pktmbuf_tailroom(ut_params->ibuf));
5598 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5599 /* Append data which is padded to a multiple of */
5600 /* the algorithms block size */
5601 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5602 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5604 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5606 /* Create ZUC operation */
5607 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5608 tdata->auth_iv.data, tdata->auth_iv.len,
5609 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5610 tdata->validAuthLenInBits.len,
5615 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5616 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5617 ut_params->op, 0, 1, 1, 0);
5619 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5621 ut_params->obuf = ut_params->op->sym->m_src;
5622 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5623 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5624 + plaintext_pad_len;
5627 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5631 "ZUC Generated auth tag not as expected");
5637 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5638 uint8_t op_mode, uint8_t verify)
5640 struct crypto_testsuite_params *ts_params = &testsuite_params;
5641 struct crypto_unittest_params *ut_params = &unittest_params;
5645 uint8_t *plaintext = NULL, *ciphertext = NULL;
5646 unsigned int plaintext_pad_len;
5647 unsigned int plaintext_len;
5648 unsigned int ciphertext_pad_len;
5649 unsigned int ciphertext_len;
5651 struct rte_cryptodev_info dev_info;
5652 struct rte_cryptodev_sym_capability_idx cap_idx;
5654 /* Check if device supports ZUC EIA3 */
5655 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5656 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5658 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5662 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5664 uint64_t feat_flags = dev_info.feature_flags;
5666 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5667 printf("Device doesn't support digest encrypted.\n");
5670 if (op_mode == IN_PLACE) {
5671 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5672 printf("Device doesn't support in-place scatter-gather "
5673 "in both input and output mbufs.\n");
5677 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5678 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5679 printf("Device doesn't support RAW data-path APIs.\n");
5683 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5685 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5686 printf("Device doesn't support out-of-place scatter-gather "
5687 "in both input and output mbufs.\n");
5692 /* Create ZUC session */
5693 retval = create_wireless_algo_auth_cipher_session(
5694 ts_params->valid_devs[0],
5695 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5696 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5697 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5698 : RTE_CRYPTO_AUTH_OP_GENERATE),
5699 RTE_CRYPTO_AUTH_ZUC_EIA3,
5700 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5701 tdata->key.data, tdata->key.len,
5702 tdata->auth_iv.len, tdata->digest.len,
5703 tdata->cipher_iv.len);
5708 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5709 if (op_mode == OUT_OF_PLACE)
5710 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5712 /* clear mbuf payload */
5713 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5714 rte_pktmbuf_tailroom(ut_params->ibuf));
5715 if (op_mode == OUT_OF_PLACE)
5716 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5717 rte_pktmbuf_tailroom(ut_params->obuf));
5719 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5720 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5721 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5722 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5725 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5726 ciphertext_pad_len);
5727 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5728 if (op_mode == OUT_OF_PLACE)
5729 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5730 debug_hexdump(stdout, "ciphertext:", ciphertext,
5733 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5735 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5736 if (op_mode == OUT_OF_PLACE)
5737 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5738 debug_hexdump(stdout, "plaintext:", plaintext,
5742 /* Create ZUC operation */
5743 retval = create_wireless_algo_auth_cipher_operation(
5744 tdata->digest.data, tdata->digest.len,
5745 tdata->cipher_iv.data, tdata->cipher_iv.len,
5746 tdata->auth_iv.data, tdata->auth_iv.len,
5747 (tdata->digest.offset_bytes == 0 ?
5748 (verify ? ciphertext_pad_len : plaintext_pad_len)
5749 : tdata->digest.offset_bytes),
5750 tdata->validCipherLenInBits.len,
5751 tdata->validCipherOffsetInBits.len,
5752 tdata->validAuthLenInBits.len,
5754 op_mode, 0, verify);
5759 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5760 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5761 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5763 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5766 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5768 ut_params->obuf = (op_mode == IN_PLACE ?
5769 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5773 if (ut_params->obuf)
5774 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5777 plaintext = ciphertext;
5779 debug_hexdump(stdout, "plaintext:", plaintext,
5780 (tdata->plaintext.len >> 3) - tdata->digest.len);
5781 debug_hexdump(stdout, "plaintext expected:",
5782 tdata->plaintext.data,
5783 (tdata->plaintext.len >> 3) - tdata->digest.len);
5785 if (ut_params->obuf)
5786 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5789 ciphertext = plaintext;
5791 debug_hexdump(stdout, "ciphertext:", ciphertext,
5793 debug_hexdump(stdout, "ciphertext expected:",
5794 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5796 ut_params->digest = rte_pktmbuf_mtod(
5797 ut_params->obuf, uint8_t *) +
5798 (tdata->digest.offset_bytes == 0 ?
5799 plaintext_pad_len : tdata->digest.offset_bytes);
5801 debug_hexdump(stdout, "digest:", ut_params->digest,
5803 debug_hexdump(stdout, "digest expected:",
5804 tdata->digest.data, tdata->digest.len);
5809 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5811 tdata->plaintext.data,
5812 tdata->plaintext.len >> 3,
5813 "ZUC Plaintext data not as expected");
5815 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5817 tdata->ciphertext.data,
5818 tdata->ciphertext.len >> 3,
5819 "ZUC Ciphertext data not as expected");
5821 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5824 DIGEST_BYTE_LENGTH_KASUMI_F9,
5825 "ZUC Generated auth tag not as expected");
5831 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5832 uint8_t op_mode, uint8_t verify)
5834 struct crypto_testsuite_params *ts_params = &testsuite_params;
5835 struct crypto_unittest_params *ut_params = &unittest_params;
5839 const uint8_t *plaintext = NULL;
5840 const uint8_t *ciphertext = NULL;
5841 const uint8_t *digest = NULL;
5842 unsigned int plaintext_pad_len;
5843 unsigned int plaintext_len;
5844 unsigned int ciphertext_pad_len;
5845 unsigned int ciphertext_len;
5846 uint8_t buffer[10000];
5847 uint8_t digest_buffer[10000];
5849 struct rte_cryptodev_info dev_info;
5850 struct rte_cryptodev_sym_capability_idx cap_idx;
5852 /* Check if device supports ZUC EIA3 */
5853 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5854 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5856 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5860 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5862 uint64_t feat_flags = dev_info.feature_flags;
5864 if (op_mode == IN_PLACE) {
5865 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5866 printf("Device doesn't support in-place scatter-gather "
5867 "in both input and output mbufs.\n");
5871 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5872 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5873 printf("Device doesn't support RAW data-path APIs.\n");
5877 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5879 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5880 printf("Device doesn't support out-of-place scatter-gather "
5881 "in both input and output mbufs.\n");
5884 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5885 printf("Device doesn't support digest encrypted.\n");
5890 /* Create ZUC session */
5891 retval = create_wireless_algo_auth_cipher_session(
5892 ts_params->valid_devs[0],
5893 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5894 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5895 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5896 : RTE_CRYPTO_AUTH_OP_GENERATE),
5897 RTE_CRYPTO_AUTH_ZUC_EIA3,
5898 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5899 tdata->key.data, tdata->key.len,
5900 tdata->auth_iv.len, tdata->digest.len,
5901 tdata->cipher_iv.len);
5906 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5907 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5908 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5909 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5911 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5912 plaintext_pad_len, 15, 0);
5913 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5914 "Failed to allocate input buffer in mempool");
5916 if (op_mode == OUT_OF_PLACE) {
5917 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5918 plaintext_pad_len, 15, 0);
5919 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5920 "Failed to allocate output buffer in mempool");
5924 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5925 tdata->ciphertext.data);
5926 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5927 ciphertext_len, buffer);
5928 debug_hexdump(stdout, "ciphertext:", ciphertext,
5931 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5932 tdata->plaintext.data);
5933 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5934 plaintext_len, buffer);
5935 debug_hexdump(stdout, "plaintext:", plaintext,
5938 memset(buffer, 0, sizeof(buffer));
5940 /* Create ZUC operation */
5941 retval = create_wireless_algo_auth_cipher_operation(
5942 tdata->digest.data, tdata->digest.len,
5943 tdata->cipher_iv.data, tdata->cipher_iv.len,
5945 (tdata->digest.offset_bytes == 0 ?
5946 (verify ? ciphertext_pad_len : plaintext_pad_len)
5947 : tdata->digest.offset_bytes),
5948 tdata->validCipherLenInBits.len,
5949 tdata->validCipherOffsetInBits.len,
5950 tdata->validAuthLenInBits.len,
5952 op_mode, 1, verify);
5957 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5958 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5959 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5961 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5964 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5966 ut_params->obuf = (op_mode == IN_PLACE ?
5967 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5970 if (ut_params->obuf)
5971 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5972 plaintext_len, buffer);
5974 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5975 plaintext_len, buffer);
5977 debug_hexdump(stdout, "plaintext:", plaintext,
5978 (tdata->plaintext.len >> 3) - tdata->digest.len);
5979 debug_hexdump(stdout, "plaintext expected:",
5980 tdata->plaintext.data,
5981 (tdata->plaintext.len >> 3) - tdata->digest.len);
5983 if (ut_params->obuf)
5984 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5985 ciphertext_len, buffer);
5987 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5988 ciphertext_len, buffer);
5990 debug_hexdump(stdout, "ciphertext:", ciphertext,
5992 debug_hexdump(stdout, "ciphertext expected:",
5993 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5995 if (ut_params->obuf)
5996 digest = rte_pktmbuf_read(ut_params->obuf,
5997 (tdata->digest.offset_bytes == 0 ?
5998 plaintext_pad_len : tdata->digest.offset_bytes),
5999 tdata->digest.len, digest_buffer);
6001 digest = rte_pktmbuf_read(ut_params->ibuf,
6002 (tdata->digest.offset_bytes == 0 ?
6003 plaintext_pad_len : tdata->digest.offset_bytes),
6004 tdata->digest.len, digest_buffer);
6006 debug_hexdump(stdout, "digest:", digest,
6008 debug_hexdump(stdout, "digest expected:",
6009 tdata->digest.data, tdata->digest.len);
6014 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6016 tdata->plaintext.data,
6017 tdata->plaintext.len >> 3,
6018 "ZUC Plaintext data not as expected");
6020 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6022 tdata->ciphertext.data,
6023 tdata->validDataLenInBits.len,
6024 "ZUC Ciphertext data not as expected");
6026 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6029 DIGEST_BYTE_LENGTH_KASUMI_F9,
6030 "ZUC Generated auth tag not as expected");
6036 test_kasumi_encryption_test_case_1(void)
6038 return test_kasumi_encryption(&kasumi_test_case_1);
6042 test_kasumi_encryption_test_case_1_sgl(void)
6044 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6048 test_kasumi_encryption_test_case_1_oop(void)
6050 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6054 test_kasumi_encryption_test_case_1_oop_sgl(void)
6056 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6060 test_kasumi_encryption_test_case_2(void)
6062 return test_kasumi_encryption(&kasumi_test_case_2);
6066 test_kasumi_encryption_test_case_3(void)
6068 return test_kasumi_encryption(&kasumi_test_case_3);
6072 test_kasumi_encryption_test_case_4(void)
6074 return test_kasumi_encryption(&kasumi_test_case_4);
6078 test_kasumi_encryption_test_case_5(void)
6080 return test_kasumi_encryption(&kasumi_test_case_5);
6084 test_kasumi_decryption_test_case_1(void)
6086 return test_kasumi_decryption(&kasumi_test_case_1);
6090 test_kasumi_decryption_test_case_1_oop(void)
6092 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6096 test_kasumi_decryption_test_case_2(void)
6098 return test_kasumi_decryption(&kasumi_test_case_2);
6102 test_kasumi_decryption_test_case_3(void)
6104 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6105 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6107 return test_kasumi_decryption(&kasumi_test_case_3);
6111 test_kasumi_decryption_test_case_4(void)
6113 return test_kasumi_decryption(&kasumi_test_case_4);
6117 test_kasumi_decryption_test_case_5(void)
6119 return test_kasumi_decryption(&kasumi_test_case_5);
6122 test_snow3g_encryption_test_case_1(void)
6124 return test_snow3g_encryption(&snow3g_test_case_1);
6128 test_snow3g_encryption_test_case_1_oop(void)
6130 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6134 test_snow3g_encryption_test_case_1_oop_sgl(void)
6136 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6141 test_snow3g_encryption_test_case_1_offset_oop(void)
6143 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6147 test_snow3g_encryption_test_case_2(void)
6149 return test_snow3g_encryption(&snow3g_test_case_2);
6153 test_snow3g_encryption_test_case_3(void)
6155 return test_snow3g_encryption(&snow3g_test_case_3);
6159 test_snow3g_encryption_test_case_4(void)
6161 return test_snow3g_encryption(&snow3g_test_case_4);
6165 test_snow3g_encryption_test_case_5(void)
6167 return test_snow3g_encryption(&snow3g_test_case_5);
6171 test_snow3g_decryption_test_case_1(void)
6173 return test_snow3g_decryption(&snow3g_test_case_1);
6177 test_snow3g_decryption_test_case_1_oop(void)
6179 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6183 test_snow3g_decryption_test_case_2(void)
6185 return test_snow3g_decryption(&snow3g_test_case_2);
6189 test_snow3g_decryption_test_case_3(void)
6191 return test_snow3g_decryption(&snow3g_test_case_3);
6195 test_snow3g_decryption_test_case_4(void)
6197 return test_snow3g_decryption(&snow3g_test_case_4);
6201 test_snow3g_decryption_test_case_5(void)
6203 return test_snow3g_decryption(&snow3g_test_case_5);
6207 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6208 * Pattern digest from snow3g_test_data must be allocated as
6209 * 4 last bytes in plaintext.
6212 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6213 struct snow3g_hash_test_data *output)
6215 if ((pattern != NULL) && (output != NULL)) {
6216 output->key.len = pattern->key.len;
6218 memcpy(output->key.data,
6219 pattern->key.data, pattern->key.len);
6221 output->auth_iv.len = pattern->auth_iv.len;
6223 memcpy(output->auth_iv.data,
6224 pattern->auth_iv.data, pattern->auth_iv.len);
6226 output->plaintext.len = pattern->plaintext.len;
6228 memcpy(output->plaintext.data,
6229 pattern->plaintext.data, pattern->plaintext.len >> 3);
6231 output->digest.len = pattern->digest.len;
6233 memcpy(output->digest.data,
6234 &pattern->plaintext.data[pattern->digest.offset_bytes],
6235 pattern->digest.len);
6237 output->validAuthLenInBits.len =
6238 pattern->validAuthLenInBits.len;
6243 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6246 test_snow3g_decryption_with_digest_test_case_1(void)
6248 struct snow3g_hash_test_data snow3g_hash_data;
6251 * Function prepare data for hash veryfication test case.
6252 * Digest is allocated in 4 last bytes in plaintext, pattern.
6254 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6256 return test_snow3g_decryption(&snow3g_test_case_7) &
6257 test_snow3g_authentication_verify(&snow3g_hash_data);
6261 test_snow3g_cipher_auth_test_case_1(void)
6263 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6267 test_snow3g_auth_cipher_test_case_1(void)
6269 return test_snow3g_auth_cipher(
6270 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6274 test_snow3g_auth_cipher_test_case_2(void)
6276 return test_snow3g_auth_cipher(
6277 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6281 test_snow3g_auth_cipher_test_case_2_oop(void)
6283 return test_snow3g_auth_cipher(
6284 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6288 test_snow3g_auth_cipher_part_digest_enc(void)
6290 return test_snow3g_auth_cipher(
6291 &snow3g_auth_cipher_partial_digest_encryption,
6296 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6298 return test_snow3g_auth_cipher(
6299 &snow3g_auth_cipher_partial_digest_encryption,
6304 test_snow3g_auth_cipher_test_case_3_sgl(void)
6306 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6307 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6309 return test_snow3g_auth_cipher_sgl(
6310 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6314 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6316 return test_snow3g_auth_cipher_sgl(
6317 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6321 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6323 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6324 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6326 return test_snow3g_auth_cipher_sgl(
6327 &snow3g_auth_cipher_partial_digest_encryption,
6332 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6334 return test_snow3g_auth_cipher_sgl(
6335 &snow3g_auth_cipher_partial_digest_encryption,
6340 test_snow3g_auth_cipher_verify_test_case_1(void)
6342 return test_snow3g_auth_cipher(
6343 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6347 test_snow3g_auth_cipher_verify_test_case_2(void)
6349 return test_snow3g_auth_cipher(
6350 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6354 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6356 return test_snow3g_auth_cipher(
6357 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6361 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6363 return test_snow3g_auth_cipher(
6364 &snow3g_auth_cipher_partial_digest_encryption,
6369 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6371 return test_snow3g_auth_cipher(
6372 &snow3g_auth_cipher_partial_digest_encryption,
6377 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6379 return test_snow3g_auth_cipher_sgl(
6380 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6384 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6386 return test_snow3g_auth_cipher_sgl(
6387 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6391 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6393 return test_snow3g_auth_cipher_sgl(
6394 &snow3g_auth_cipher_partial_digest_encryption,
6399 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6401 return test_snow3g_auth_cipher_sgl(
6402 &snow3g_auth_cipher_partial_digest_encryption,
6407 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6409 return test_snow3g_auth_cipher(
6410 &snow3g_test_case_7, IN_PLACE, 0);
6414 test_kasumi_auth_cipher_test_case_1(void)
6416 return test_kasumi_auth_cipher(
6417 &kasumi_test_case_3, IN_PLACE, 0);
6421 test_kasumi_auth_cipher_test_case_2(void)
6423 return test_kasumi_auth_cipher(
6424 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6428 test_kasumi_auth_cipher_test_case_2_oop(void)
6430 return test_kasumi_auth_cipher(
6431 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6435 test_kasumi_auth_cipher_test_case_2_sgl(void)
6437 return test_kasumi_auth_cipher_sgl(
6438 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6442 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6444 return test_kasumi_auth_cipher_sgl(
6445 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6449 test_kasumi_auth_cipher_verify_test_case_1(void)
6451 return test_kasumi_auth_cipher(
6452 &kasumi_test_case_3, IN_PLACE, 1);
6456 test_kasumi_auth_cipher_verify_test_case_2(void)
6458 return test_kasumi_auth_cipher(
6459 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6463 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6465 return test_kasumi_auth_cipher(
6466 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6470 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6472 return test_kasumi_auth_cipher_sgl(
6473 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6477 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6479 return test_kasumi_auth_cipher_sgl(
6480 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6484 test_kasumi_cipher_auth_test_case_1(void)
6486 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6490 test_zuc_encryption_test_case_1(void)
6492 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6496 test_zuc_encryption_test_case_2(void)
6498 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6502 test_zuc_encryption_test_case_3(void)
6504 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6508 test_zuc_encryption_test_case_4(void)
6510 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6514 test_zuc_encryption_test_case_5(void)
6516 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6520 test_zuc_encryption_test_case_6_sgl(void)
6522 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6526 test_zuc_hash_generate_test_case_1(void)
6528 return test_zuc_authentication(&zuc_test_case_auth_1b);
6532 test_zuc_hash_generate_test_case_2(void)
6534 return test_zuc_authentication(&zuc_test_case_auth_90b);
6538 test_zuc_hash_generate_test_case_3(void)
6540 return test_zuc_authentication(&zuc_test_case_auth_577b);
6544 test_zuc_hash_generate_test_case_4(void)
6546 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6550 test_zuc_hash_generate_test_case_5(void)
6552 return test_zuc_authentication(&zuc_test_auth_5670b);
6556 test_zuc_hash_generate_test_case_6(void)
6558 return test_zuc_authentication(&zuc_test_case_auth_128b);
6562 test_zuc_hash_generate_test_case_7(void)
6564 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6568 test_zuc_hash_generate_test_case_8(void)
6570 return test_zuc_authentication(&zuc_test_case_auth_584b);
6574 test_zuc_cipher_auth_test_case_1(void)
6576 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6580 test_zuc_cipher_auth_test_case_2(void)
6582 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6586 test_zuc_auth_cipher_test_case_1(void)
6588 return test_zuc_auth_cipher(
6589 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6593 test_zuc_auth_cipher_test_case_1_oop(void)
6595 return test_zuc_auth_cipher(
6596 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6600 test_zuc_auth_cipher_test_case_1_sgl(void)
6602 return test_zuc_auth_cipher_sgl(
6603 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6607 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6609 return test_zuc_auth_cipher_sgl(
6610 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6614 test_zuc_auth_cipher_verify_test_case_1(void)
6616 return test_zuc_auth_cipher(
6617 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6621 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6623 return test_zuc_auth_cipher(
6624 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6628 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6630 return test_zuc_auth_cipher_sgl(
6631 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6635 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6637 return test_zuc_auth_cipher_sgl(
6638 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6642 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6644 uint8_t dev_id = testsuite_params.valid_devs[0];
6646 struct rte_cryptodev_sym_capability_idx cap_idx;
6648 /* Check if device supports particular cipher algorithm */
6649 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6650 cap_idx.algo.cipher = tdata->cipher_algo;
6651 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6654 /* Check if device supports particular hash algorithm */
6655 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6656 cap_idx.algo.auth = tdata->auth_algo;
6657 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6664 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6665 uint8_t op_mode, uint8_t verify)
6667 struct crypto_testsuite_params *ts_params = &testsuite_params;
6668 struct crypto_unittest_params *ut_params = &unittest_params;
6672 uint8_t *plaintext = NULL, *ciphertext = NULL;
6673 unsigned int plaintext_pad_len;
6674 unsigned int plaintext_len;
6675 unsigned int ciphertext_pad_len;
6676 unsigned int ciphertext_len;
6678 struct rte_cryptodev_info dev_info;
6680 /* Check if device supports particular algorithms separately */
6681 if (test_mixed_check_if_unsupported(tdata))
6683 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6686 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6688 uint64_t feat_flags = dev_info.feature_flags;
6690 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6691 printf("Device doesn't support digest encrypted.\n");
6695 if (op_mode == OUT_OF_PLACE)
6698 /* Create the session */
6700 retval = create_wireless_algo_cipher_auth_session(
6701 ts_params->valid_devs[0],
6702 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6703 RTE_CRYPTO_AUTH_OP_VERIFY,
6706 tdata->auth_key.data, tdata->auth_key.len,
6707 tdata->auth_iv.len, tdata->digest_enc.len,
6708 tdata->cipher_iv.len);
6710 retval = create_wireless_algo_auth_cipher_session(
6711 ts_params->valid_devs[0],
6712 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6713 RTE_CRYPTO_AUTH_OP_GENERATE,
6716 tdata->auth_key.data, tdata->auth_key.len,
6717 tdata->auth_iv.len, tdata->digest_enc.len,
6718 tdata->cipher_iv.len);
6722 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6723 if (op_mode == OUT_OF_PLACE)
6724 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6726 /* clear mbuf payload */
6727 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6728 rte_pktmbuf_tailroom(ut_params->ibuf));
6729 if (op_mode == OUT_OF_PLACE) {
6731 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6732 rte_pktmbuf_tailroom(ut_params->obuf));
6735 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6736 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6737 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6738 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6741 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6742 ciphertext_pad_len);
6743 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6744 if (op_mode == OUT_OF_PLACE)
6745 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6746 debug_hexdump(stdout, "ciphertext:", ciphertext,
6749 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6751 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6752 if (op_mode == OUT_OF_PLACE)
6753 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6754 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6757 /* Create the operation */
6758 retval = create_wireless_algo_auth_cipher_operation(
6759 tdata->digest_enc.data, tdata->digest_enc.len,
6760 tdata->cipher_iv.data, tdata->cipher_iv.len,
6761 tdata->auth_iv.data, tdata->auth_iv.len,
6762 (tdata->digest_enc.offset == 0 ?
6764 : tdata->digest_enc.offset),
6765 tdata->validCipherLen.len_bits,
6766 tdata->cipher.offset_bits,
6767 tdata->validAuthLen.len_bits,
6768 tdata->auth.offset_bits,
6769 op_mode, 0, verify);
6774 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6777 /* Check if the op failed because the device doesn't */
6778 /* support this particular combination of algorithms */
6779 if (ut_params->op == NULL && ut_params->op->status ==
6780 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6781 printf("Device doesn't support this mixed combination. "
6786 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6788 ut_params->obuf = (op_mode == IN_PLACE ?
6789 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6792 if (ut_params->obuf)
6793 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6796 plaintext = ciphertext +
6797 (tdata->cipher.offset_bits >> 3);
6799 debug_hexdump(stdout, "plaintext:", plaintext,
6800 tdata->plaintext.len_bits >> 3);
6801 debug_hexdump(stdout, "plaintext expected:",
6802 tdata->plaintext.data,
6803 tdata->plaintext.len_bits >> 3);
6805 if (ut_params->obuf)
6806 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6809 ciphertext = plaintext;
6811 debug_hexdump(stdout, "ciphertext:", ciphertext,
6813 debug_hexdump(stdout, "ciphertext expected:",
6814 tdata->ciphertext.data,
6815 tdata->ciphertext.len_bits >> 3);
6817 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6818 + (tdata->digest_enc.offset == 0 ?
6819 plaintext_pad_len : tdata->digest_enc.offset);
6821 debug_hexdump(stdout, "digest:", ut_params->digest,
6822 tdata->digest_enc.len);
6823 debug_hexdump(stdout, "digest expected:",
6824 tdata->digest_enc.data,
6825 tdata->digest_enc.len);
6830 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6832 tdata->plaintext.data,
6833 tdata->plaintext.len_bits >> 3,
6834 "Plaintext data not as expected");
6836 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6838 tdata->ciphertext.data,
6839 tdata->validDataLen.len_bits,
6840 "Ciphertext data not as expected");
6842 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6844 tdata->digest_enc.data,
6845 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6846 "Generated auth tag not as expected");
6849 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6850 "crypto op processing failed");
6856 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6857 uint8_t op_mode, uint8_t verify)
6859 struct crypto_testsuite_params *ts_params = &testsuite_params;
6860 struct crypto_unittest_params *ut_params = &unittest_params;
6864 const uint8_t *plaintext = NULL;
6865 const uint8_t *ciphertext = NULL;
6866 const uint8_t *digest = NULL;
6867 unsigned int plaintext_pad_len;
6868 unsigned int plaintext_len;
6869 unsigned int ciphertext_pad_len;
6870 unsigned int ciphertext_len;
6871 uint8_t buffer[10000];
6872 uint8_t digest_buffer[10000];
6874 struct rte_cryptodev_info dev_info;
6876 /* Check if device supports particular algorithms */
6877 if (test_mixed_check_if_unsupported(tdata))
6879 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6882 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6884 uint64_t feat_flags = dev_info.feature_flags;
6886 if (op_mode == IN_PLACE) {
6887 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6888 printf("Device doesn't support in-place scatter-gather "
6889 "in both input and output mbufs.\n");
6893 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6894 printf("Device doesn't support out-of-place scatter-gather "
6895 "in both input and output mbufs.\n");
6898 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6899 printf("Device doesn't support digest encrypted.\n");
6904 /* Create the session */
6906 retval = create_wireless_algo_cipher_auth_session(
6907 ts_params->valid_devs[0],
6908 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6909 RTE_CRYPTO_AUTH_OP_VERIFY,
6912 tdata->auth_key.data, tdata->auth_key.len,
6913 tdata->auth_iv.len, tdata->digest_enc.len,
6914 tdata->cipher_iv.len);
6916 retval = create_wireless_algo_auth_cipher_session(
6917 ts_params->valid_devs[0],
6918 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6919 RTE_CRYPTO_AUTH_OP_GENERATE,
6922 tdata->auth_key.data, tdata->auth_key.len,
6923 tdata->auth_iv.len, tdata->digest_enc.len,
6924 tdata->cipher_iv.len);
6928 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6929 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6930 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6931 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6933 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6934 ciphertext_pad_len, 15, 0);
6935 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6936 "Failed to allocate input buffer in mempool");
6938 if (op_mode == OUT_OF_PLACE) {
6939 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6940 plaintext_pad_len, 15, 0);
6941 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6942 "Failed to allocate output buffer in mempool");
6946 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6947 tdata->ciphertext.data);
6948 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6949 ciphertext_len, buffer);
6950 debug_hexdump(stdout, "ciphertext:", ciphertext,
6953 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6954 tdata->plaintext.data);
6955 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6956 plaintext_len, buffer);
6957 debug_hexdump(stdout, "plaintext:", plaintext,
6960 memset(buffer, 0, sizeof(buffer));
6962 /* Create the operation */
6963 retval = create_wireless_algo_auth_cipher_operation(
6964 tdata->digest_enc.data, tdata->digest_enc.len,
6965 tdata->cipher_iv.data, tdata->cipher_iv.len,
6966 tdata->auth_iv.data, tdata->auth_iv.len,
6967 (tdata->digest_enc.offset == 0 ?
6969 : tdata->digest_enc.offset),
6970 tdata->validCipherLen.len_bits,
6971 tdata->cipher.offset_bits,
6972 tdata->validAuthLen.len_bits,
6973 tdata->auth.offset_bits,
6974 op_mode, 1, verify);
6979 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6982 /* Check if the op failed because the device doesn't */
6983 /* support this particular combination of algorithms */
6984 if (ut_params->op == NULL && ut_params->op->status ==
6985 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6986 printf("Device doesn't support this mixed combination. "
6991 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6993 ut_params->obuf = (op_mode == IN_PLACE ?
6994 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6997 if (ut_params->obuf)
6998 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6999 plaintext_len, buffer);
7001 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7002 plaintext_len, buffer);
7004 debug_hexdump(stdout, "plaintext:", plaintext,
7005 (tdata->plaintext.len_bits >> 3) -
7006 tdata->digest_enc.len);
7007 debug_hexdump(stdout, "plaintext expected:",
7008 tdata->plaintext.data,
7009 (tdata->plaintext.len_bits >> 3) -
7010 tdata->digest_enc.len);
7012 if (ut_params->obuf)
7013 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7014 ciphertext_len, buffer);
7016 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7017 ciphertext_len, buffer);
7019 debug_hexdump(stdout, "ciphertext:", ciphertext,
7021 debug_hexdump(stdout, "ciphertext expected:",
7022 tdata->ciphertext.data,
7023 tdata->ciphertext.len_bits >> 3);
7025 if (ut_params->obuf)
7026 digest = rte_pktmbuf_read(ut_params->obuf,
7027 (tdata->digest_enc.offset == 0 ?
7029 tdata->digest_enc.offset),
7030 tdata->digest_enc.len, digest_buffer);
7032 digest = rte_pktmbuf_read(ut_params->ibuf,
7033 (tdata->digest_enc.offset == 0 ?
7035 tdata->digest_enc.offset),
7036 tdata->digest_enc.len, digest_buffer);
7038 debug_hexdump(stdout, "digest:", digest,
7039 tdata->digest_enc.len);
7040 debug_hexdump(stdout, "digest expected:",
7041 tdata->digest_enc.data, tdata->digest_enc.len);
7046 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7048 tdata->plaintext.data,
7049 tdata->plaintext.len_bits >> 3,
7050 "Plaintext data not as expected");
7052 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7054 tdata->ciphertext.data,
7055 tdata->validDataLen.len_bits,
7056 "Ciphertext data not as expected");
7057 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7059 tdata->digest_enc.data,
7060 tdata->digest_enc.len,
7061 "Generated auth tag not as expected");
7064 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7065 "crypto op processing failed");
7070 /** AUTH AES CMAC + CIPHER AES CTR */
7073 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7075 return test_mixed_auth_cipher(
7076 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7080 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7082 return test_mixed_auth_cipher(
7083 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7087 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7089 return test_mixed_auth_cipher_sgl(
7090 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7094 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7096 return test_mixed_auth_cipher_sgl(
7097 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7101 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7103 return test_mixed_auth_cipher(
7104 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7108 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7110 return test_mixed_auth_cipher(
7111 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7115 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7117 return test_mixed_auth_cipher_sgl(
7118 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7122 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7124 return test_mixed_auth_cipher_sgl(
7125 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7128 /** MIXED AUTH + CIPHER */
7131 test_auth_zuc_cipher_snow_test_case_1(void)
7133 return test_mixed_auth_cipher(
7134 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7138 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7140 return test_mixed_auth_cipher(
7141 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7145 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7147 return test_mixed_auth_cipher(
7148 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7152 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7154 return test_mixed_auth_cipher(
7155 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7159 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7161 return test_mixed_auth_cipher(
7162 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7166 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7168 return test_mixed_auth_cipher(
7169 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7173 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7175 return test_mixed_auth_cipher(
7176 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7180 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7182 return test_mixed_auth_cipher(
7183 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7187 test_auth_snow_cipher_zuc_test_case_1(void)
7189 return test_mixed_auth_cipher(
7190 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7194 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7196 return test_mixed_auth_cipher(
7197 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7201 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7203 return test_mixed_auth_cipher(
7204 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7208 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7210 return test_mixed_auth_cipher(
7211 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7215 test_auth_null_cipher_snow_test_case_1(void)
7217 return test_mixed_auth_cipher(
7218 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7222 test_verify_auth_null_cipher_snow_test_case_1(void)
7224 return test_mixed_auth_cipher(
7225 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7229 test_auth_null_cipher_zuc_test_case_1(void)
7231 return test_mixed_auth_cipher(
7232 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7236 test_verify_auth_null_cipher_zuc_test_case_1(void)
7238 return test_mixed_auth_cipher(
7239 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7243 test_auth_snow_cipher_null_test_case_1(void)
7245 return test_mixed_auth_cipher(
7246 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7250 test_verify_auth_snow_cipher_null_test_case_1(void)
7252 return test_mixed_auth_cipher(
7253 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7257 test_auth_zuc_cipher_null_test_case_1(void)
7259 return test_mixed_auth_cipher(
7260 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7264 test_verify_auth_zuc_cipher_null_test_case_1(void)
7266 return test_mixed_auth_cipher(
7267 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7271 test_auth_null_cipher_aes_ctr_test_case_1(void)
7273 return test_mixed_auth_cipher(
7274 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7278 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7280 return test_mixed_auth_cipher(
7281 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7285 test_auth_aes_cmac_cipher_null_test_case_1(void)
7287 return test_mixed_auth_cipher(
7288 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7292 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7294 return test_mixed_auth_cipher(
7295 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7298 /* ***** AEAD algorithm Tests ***** */
7301 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7302 enum rte_crypto_aead_operation op,
7303 const uint8_t *key, const uint8_t key_len,
7304 const uint16_t aad_len, const uint8_t auth_len,
7307 uint8_t aead_key[key_len];
7309 struct crypto_testsuite_params *ts_params = &testsuite_params;
7310 struct crypto_unittest_params *ut_params = &unittest_params;
7312 memcpy(aead_key, key, key_len);
7314 /* Setup AEAD Parameters */
7315 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7316 ut_params->aead_xform.next = NULL;
7317 ut_params->aead_xform.aead.algo = algo;
7318 ut_params->aead_xform.aead.op = op;
7319 ut_params->aead_xform.aead.key.data = aead_key;
7320 ut_params->aead_xform.aead.key.length = key_len;
7321 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7322 ut_params->aead_xform.aead.iv.length = iv_len;
7323 ut_params->aead_xform.aead.digest_length = auth_len;
7324 ut_params->aead_xform.aead.aad_length = aad_len;
7326 debug_hexdump(stdout, "key:", key, key_len);
7328 /* Create Crypto session*/
7329 ut_params->sess = rte_cryptodev_sym_session_create(
7330 ts_params->session_mpool);
7332 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7333 &ut_params->aead_xform,
7334 ts_params->session_priv_mpool);
7336 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7342 create_aead_xform(struct rte_crypto_op *op,
7343 enum rte_crypto_aead_algorithm algo,
7344 enum rte_crypto_aead_operation aead_op,
7345 uint8_t *key, const uint8_t key_len,
7346 const uint8_t aad_len, const uint8_t auth_len,
7349 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7350 "failed to allocate space for crypto transform");
7352 struct rte_crypto_sym_op *sym_op = op->sym;
7354 /* Setup AEAD Parameters */
7355 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7356 sym_op->xform->next = NULL;
7357 sym_op->xform->aead.algo = algo;
7358 sym_op->xform->aead.op = aead_op;
7359 sym_op->xform->aead.key.data = key;
7360 sym_op->xform->aead.key.length = key_len;
7361 sym_op->xform->aead.iv.offset = IV_OFFSET;
7362 sym_op->xform->aead.iv.length = iv_len;
7363 sym_op->xform->aead.digest_length = auth_len;
7364 sym_op->xform->aead.aad_length = aad_len;
7366 debug_hexdump(stdout, "key:", key, key_len);
7372 create_aead_operation(enum rte_crypto_aead_operation op,
7373 const struct aead_test_data *tdata)
7375 struct crypto_testsuite_params *ts_params = &testsuite_params;
7376 struct crypto_unittest_params *ut_params = &unittest_params;
7378 uint8_t *plaintext, *ciphertext;
7379 unsigned int aad_pad_len, plaintext_pad_len;
7381 /* Generate Crypto op data structure */
7382 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7383 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7384 TEST_ASSERT_NOT_NULL(ut_params->op,
7385 "Failed to allocate symmetric crypto operation struct");
7387 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7389 /* Append aad data */
7390 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7391 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7392 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7394 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7395 "no room to append aad");
7397 sym_op->aead.aad.phys_addr =
7398 rte_pktmbuf_iova(ut_params->ibuf);
7399 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7400 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7401 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7404 /* Append IV at the end of the crypto operation*/
7405 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7406 uint8_t *, IV_OFFSET);
7408 /* Copy IV 1 byte after the IV pointer, according to the API */
7409 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7410 debug_hexdump(stdout, "iv:", iv_ptr,
7413 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7414 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7416 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7417 "no room to append aad");
7419 sym_op->aead.aad.phys_addr =
7420 rte_pktmbuf_iova(ut_params->ibuf);
7421 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7422 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7425 /* Append IV at the end of the crypto operation*/
7426 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7427 uint8_t *, IV_OFFSET);
7429 if (tdata->iv.len == 0) {
7430 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7431 debug_hexdump(stdout, "iv:", iv_ptr,
7434 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7435 debug_hexdump(stdout, "iv:", iv_ptr,
7440 /* Append plaintext/ciphertext */
7441 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7442 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7443 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7445 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7447 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7448 debug_hexdump(stdout, "plaintext:", plaintext,
7449 tdata->plaintext.len);
7451 if (ut_params->obuf) {
7452 ciphertext = (uint8_t *)rte_pktmbuf_append(
7454 plaintext_pad_len + aad_pad_len);
7455 TEST_ASSERT_NOT_NULL(ciphertext,
7456 "no room to append ciphertext");
7458 memset(ciphertext + aad_pad_len, 0,
7459 tdata->ciphertext.len);
7462 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7463 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7465 TEST_ASSERT_NOT_NULL(ciphertext,
7466 "no room to append ciphertext");
7468 memcpy(ciphertext, tdata->ciphertext.data,
7469 tdata->ciphertext.len);
7470 debug_hexdump(stdout, "ciphertext:", ciphertext,
7471 tdata->ciphertext.len);
7473 if (ut_params->obuf) {
7474 plaintext = (uint8_t *)rte_pktmbuf_append(
7476 plaintext_pad_len + aad_pad_len);
7477 TEST_ASSERT_NOT_NULL(plaintext,
7478 "no room to append plaintext");
7480 memset(plaintext + aad_pad_len, 0,
7481 tdata->plaintext.len);
7485 /* Append digest data */
7486 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7487 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7488 ut_params->obuf ? ut_params->obuf :
7490 tdata->auth_tag.len);
7491 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7492 "no room to append digest");
7493 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7494 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7495 ut_params->obuf ? ut_params->obuf :
7500 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7501 ut_params->ibuf, tdata->auth_tag.len);
7502 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7503 "no room to append digest");
7504 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7506 plaintext_pad_len + aad_pad_len);
7508 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7509 tdata->auth_tag.len);
7510 debug_hexdump(stdout, "digest:",
7511 sym_op->aead.digest.data,
7512 tdata->auth_tag.len);
7515 sym_op->aead.data.length = tdata->plaintext.len;
7516 sym_op->aead.data.offset = aad_pad_len;
7522 test_authenticated_encryption(const struct aead_test_data *tdata)
7524 struct crypto_testsuite_params *ts_params = &testsuite_params;
7525 struct crypto_unittest_params *ut_params = &unittest_params;
7528 uint8_t *ciphertext, *auth_tag;
7529 uint16_t plaintext_pad_len;
7531 struct rte_cryptodev_info dev_info;
7533 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7534 uint64_t feat_flags = dev_info.feature_flags;
7536 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7537 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7538 printf("Device doesn't support RAW data-path APIs.\n");
7542 /* Verify the capabilities */
7543 struct rte_cryptodev_sym_capability_idx cap_idx;
7544 const struct rte_cryptodev_symmetric_capability *capability;
7545 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7546 cap_idx.algo.aead = tdata->algo;
7547 capability = rte_cryptodev_sym_capability_get(
7548 ts_params->valid_devs[0], &cap_idx);
7549 if (capability == NULL)
7551 if (rte_cryptodev_sym_capability_check_aead(
7552 capability, tdata->key.len, tdata->auth_tag.len,
7553 tdata->aad.len, tdata->iv.len))
7556 /* Create AEAD session */
7557 retval = create_aead_session(ts_params->valid_devs[0],
7559 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7560 tdata->key.data, tdata->key.len,
7561 tdata->aad.len, tdata->auth_tag.len,
7566 if (tdata->aad.len > MBUF_SIZE) {
7567 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7568 /* Populate full size of add data */
7569 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7570 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7574 /* clear mbuf payload */
7575 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7576 rte_pktmbuf_tailroom(ut_params->ibuf));
7578 /* Create AEAD operation */
7579 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7583 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7585 ut_params->op->sym->m_src = ut_params->ibuf;
7587 /* Process crypto operation */
7588 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7589 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7590 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7591 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
7592 ut_params->op, 0, 0, 0, 0);
7594 TEST_ASSERT_NOT_NULL(
7595 process_crypto_request(ts_params->valid_devs[0],
7596 ut_params->op), "failed to process sym crypto op");
7598 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7599 "crypto op processing failed");
7601 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7603 if (ut_params->op->sym->m_dst) {
7604 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7606 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7607 uint8_t *, plaintext_pad_len);
7609 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7611 ut_params->op->sym->cipher.data.offset);
7612 auth_tag = ciphertext + plaintext_pad_len;
7615 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7616 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7619 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7621 tdata->ciphertext.data,
7622 tdata->ciphertext.len,
7623 "Ciphertext data not as expected");
7625 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7627 tdata->auth_tag.data,
7628 tdata->auth_tag.len,
7629 "Generated auth tag not as expected");
7635 #ifdef RTE_LIBRTE_SECURITY
7637 security_proto_supported(enum rte_security_session_action_type action,
7638 enum rte_security_session_protocol proto)
7640 struct crypto_testsuite_params *ts_params = &testsuite_params;
7642 const struct rte_security_capability *capabilities;
7643 const struct rte_security_capability *capability;
7646 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7647 rte_cryptodev_get_sec_ctx(
7648 ts_params->valid_devs[0]);
7651 capabilities = rte_security_capabilities_get(ctx);
7653 if (capabilities == NULL)
7656 while ((capability = &capabilities[i++])->action !=
7657 RTE_SECURITY_ACTION_TYPE_NONE) {
7658 if (capability->action == action &&
7659 capability->protocol == proto)
7666 /* Basic algorithm run function for async inplace mode.
7667 * Creates a session from input parameters and runs one operation
7668 * on input_vec. Checks the output of the crypto operation against
7671 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
7672 enum rte_crypto_auth_operation opa,
7673 const uint8_t *input_vec, unsigned int input_vec_len,
7674 const uint8_t *output_vec,
7675 unsigned int output_vec_len,
7676 enum rte_crypto_cipher_algorithm cipher_alg,
7677 const uint8_t *cipher_key, uint32_t cipher_key_len,
7678 enum rte_crypto_auth_algorithm auth_alg,
7679 const uint8_t *auth_key, uint32_t auth_key_len,
7680 uint8_t bearer, enum rte_security_pdcp_domain domain,
7681 uint8_t packet_direction, uint8_t sn_size,
7682 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
7684 struct crypto_testsuite_params *ts_params = &testsuite_params;
7685 struct crypto_unittest_params *ut_params = &unittest_params;
7687 int ret = TEST_SUCCESS;
7688 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7689 rte_cryptodev_get_sec_ctx(
7690 ts_params->valid_devs[0]);
7692 /* Verify the capabilities */
7693 struct rte_security_capability_idx sec_cap_idx;
7695 sec_cap_idx.action = ut_params->type;
7696 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7697 sec_cap_idx.pdcp.domain = domain;
7698 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7701 /* Generate test mbuf data */
7702 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7704 /* clear mbuf payload */
7705 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7706 rte_pktmbuf_tailroom(ut_params->ibuf));
7708 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7710 memcpy(plaintext, input_vec, input_vec_len);
7712 /* Out of place support */
7715 * For out-op-place we need to alloc another mbuf
7717 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7718 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7721 /* Setup Cipher Parameters */
7722 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7723 ut_params->cipher_xform.cipher.algo = cipher_alg;
7724 ut_params->cipher_xform.cipher.op = opc;
7725 ut_params->cipher_xform.cipher.key.data = cipher_key;
7726 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
7727 ut_params->cipher_xform.cipher.iv.length =
7728 packet_direction ? 4 : 0;
7729 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7731 /* Setup HMAC Parameters if ICV header is required */
7732 if (auth_alg != 0) {
7733 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7734 ut_params->auth_xform.next = NULL;
7735 ut_params->auth_xform.auth.algo = auth_alg;
7736 ut_params->auth_xform.auth.op = opa;
7737 ut_params->auth_xform.auth.key.data = auth_key;
7738 ut_params->auth_xform.auth.key.length = auth_key_len;
7740 ut_params->cipher_xform.next = &ut_params->auth_xform;
7742 ut_params->cipher_xform.next = NULL;
7745 struct rte_security_session_conf sess_conf = {
7746 .action_type = ut_params->type,
7747 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7751 .pkt_dir = packet_direction,
7753 .hfn = packet_direction ? 0 : hfn,
7755 * hfn can be set as pdcp_test_hfn[i]
7756 * if hfn_ovrd is not set. Here, PDCP
7757 * packet direction is just used to
7758 * run half of the cases with session
7759 * HFN and other half with per packet
7762 .hfn_threshold = hfn_threshold,
7763 .hfn_ovrd = packet_direction ? 1 : 0,
7764 .sdap_enabled = sdap,
7766 .crypto_xform = &ut_params->cipher_xform
7769 /* Create security session */
7770 ut_params->sec_session = rte_security_session_create(ctx,
7771 &sess_conf, ts_params->session_mpool,
7772 ts_params->session_priv_mpool);
7774 if (!ut_params->sec_session) {
7775 printf("TestCase %s()-%d line %d failed %s: ",
7776 __func__, i, __LINE__, "Failed to allocate session");
7781 /* Generate crypto op data structure */
7782 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7783 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7784 if (!ut_params->op) {
7785 printf("TestCase %s()-%d line %d failed %s: ",
7786 __func__, i, __LINE__,
7787 "Failed to allocate symmetric crypto operation struct");
7792 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7793 uint32_t *, IV_OFFSET);
7794 *per_pkt_hfn = packet_direction ? hfn : 0;
7796 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7798 /* set crypto operation source mbuf */
7799 ut_params->op->sym->m_src = ut_params->ibuf;
7801 ut_params->op->sym->m_dst = ut_params->obuf;
7803 /* Process crypto operation */
7804 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7806 printf("TestCase %s()-%d line %d failed %s: ",
7807 __func__, i, __LINE__,
7808 "failed to process sym crypto op");
7813 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7814 printf("TestCase %s()-%d line %d failed %s: ",
7815 __func__, i, __LINE__, "crypto op processing failed");
7821 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7824 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7828 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7829 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7830 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7831 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7837 rte_crypto_op_free(ut_params->op);
7838 ut_params->op = NULL;
7840 if (ut_params->sec_session)
7841 rte_security_session_destroy(ctx, ut_params->sec_session);
7842 ut_params->sec_session = NULL;
7844 rte_pktmbuf_free(ut_params->ibuf);
7845 ut_params->ibuf = NULL;
7847 rte_pktmbuf_free(ut_params->obuf);
7848 ut_params->obuf = NULL;
7855 test_pdcp_proto_SGL(int i, int oop,
7856 enum rte_crypto_cipher_operation opc,
7857 enum rte_crypto_auth_operation opa,
7859 unsigned int input_vec_len,
7860 uint8_t *output_vec,
7861 unsigned int output_vec_len,
7863 uint32_t fragsz_oop)
7865 struct crypto_testsuite_params *ts_params = &testsuite_params;
7866 struct crypto_unittest_params *ut_params = &unittest_params;
7868 struct rte_mbuf *buf, *buf_oop = NULL;
7869 int ret = TEST_SUCCESS;
7873 unsigned int trn_data = 0;
7874 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7875 rte_cryptodev_get_sec_ctx(
7876 ts_params->valid_devs[0]);
7878 /* Verify the capabilities */
7879 struct rte_security_capability_idx sec_cap_idx;
7881 sec_cap_idx.action = ut_params->type;
7882 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7883 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7884 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7887 if (fragsz > input_vec_len)
7888 fragsz = input_vec_len;
7890 uint16_t plaintext_len = fragsz;
7891 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7893 if (fragsz_oop > output_vec_len)
7894 frag_size_oop = output_vec_len;
7897 if (input_vec_len % fragsz != 0) {
7898 if (input_vec_len / fragsz + 1 > 16)
7900 } else if (input_vec_len / fragsz > 16)
7903 /* Out of place support */
7906 * For out-op-place we need to alloc another mbuf
7908 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7909 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7910 buf_oop = ut_params->obuf;
7913 /* Generate test mbuf data */
7914 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7916 /* clear mbuf payload */
7917 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7918 rte_pktmbuf_tailroom(ut_params->ibuf));
7920 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7922 memcpy(plaintext, input_vec, plaintext_len);
7923 trn_data += plaintext_len;
7925 buf = ut_params->ibuf;
7928 * Loop until no more fragments
7931 while (trn_data < input_vec_len) {
7933 to_trn = (input_vec_len - trn_data < fragsz) ?
7934 (input_vec_len - trn_data) : fragsz;
7936 to_trn_tbl[ecx++] = to_trn;
7938 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7941 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7942 rte_pktmbuf_tailroom(buf));
7945 if (oop && !fragsz_oop) {
7947 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7948 buf_oop = buf_oop->next;
7949 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7950 0, rte_pktmbuf_tailroom(buf_oop));
7951 rte_pktmbuf_append(buf_oop, to_trn);
7954 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7957 memcpy(plaintext, input_vec + trn_data, to_trn);
7961 ut_params->ibuf->nb_segs = segs;
7964 if (fragsz_oop && oop) {
7968 trn_data = frag_size_oop;
7969 while (trn_data < output_vec_len) {
7972 (output_vec_len - trn_data <
7974 (output_vec_len - trn_data) :
7977 to_trn_tbl[ecx++] = to_trn;
7980 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7981 buf_oop = buf_oop->next;
7982 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7983 0, rte_pktmbuf_tailroom(buf_oop));
7984 rte_pktmbuf_append(buf_oop, to_trn);
7988 ut_params->obuf->nb_segs = segs;
7991 /* Setup Cipher Parameters */
7992 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7993 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7994 ut_params->cipher_xform.cipher.op = opc;
7995 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7996 ut_params->cipher_xform.cipher.key.length =
7997 pdcp_test_params[i].cipher_key_len;
7998 ut_params->cipher_xform.cipher.iv.length = 0;
8000 /* Setup HMAC Parameters if ICV header is required */
8001 if (pdcp_test_params[i].auth_alg != 0) {
8002 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8003 ut_params->auth_xform.next = NULL;
8004 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8005 ut_params->auth_xform.auth.op = opa;
8006 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8007 ut_params->auth_xform.auth.key.length =
8008 pdcp_test_params[i].auth_key_len;
8010 ut_params->cipher_xform.next = &ut_params->auth_xform;
8012 ut_params->cipher_xform.next = NULL;
8015 struct rte_security_session_conf sess_conf = {
8016 .action_type = ut_params->type,
8017 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8019 .bearer = pdcp_test_bearer[i],
8020 .domain = pdcp_test_params[i].domain,
8021 .pkt_dir = pdcp_test_packet_direction[i],
8022 .sn_size = pdcp_test_data_sn_size[i],
8023 .hfn = pdcp_test_hfn[i],
8024 .hfn_threshold = pdcp_test_hfn_threshold[i],
8027 .crypto_xform = &ut_params->cipher_xform
8030 /* Create security session */
8031 ut_params->sec_session = rte_security_session_create(ctx,
8032 &sess_conf, ts_params->session_mpool,
8033 ts_params->session_priv_mpool);
8035 if (!ut_params->sec_session) {
8036 printf("TestCase %s()-%d line %d failed %s: ",
8037 __func__, i, __LINE__, "Failed to allocate session");
8042 /* Generate crypto op data structure */
8043 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8044 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8045 if (!ut_params->op) {
8046 printf("TestCase %s()-%d line %d failed %s: ",
8047 __func__, i, __LINE__,
8048 "Failed to allocate symmetric crypto operation struct");
8053 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8055 /* set crypto operation source mbuf */
8056 ut_params->op->sym->m_src = ut_params->ibuf;
8058 ut_params->op->sym->m_dst = ut_params->obuf;
8060 /* Process crypto operation */
8061 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8063 printf("TestCase %s()-%d line %d failed %s: ",
8064 __func__, i, __LINE__,
8065 "failed to process sym crypto op");
8070 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8071 printf("TestCase %s()-%d line %d failed %s: ",
8072 __func__, i, __LINE__, "crypto op processing failed");
8078 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8081 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8085 fragsz = frag_size_oop;
8086 if (memcmp(ciphertext, output_vec, fragsz)) {
8087 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8088 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8089 rte_hexdump(stdout, "reference", output_vec, fragsz);
8094 buf = ut_params->op->sym->m_src->next;
8096 buf = ut_params->op->sym->m_dst->next;
8098 unsigned int off = fragsz;
8102 ciphertext = rte_pktmbuf_mtod(buf,
8104 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8105 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8106 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8107 rte_hexdump(stdout, "reference", output_vec + off,
8112 off += to_trn_tbl[ecx++];
8116 rte_crypto_op_free(ut_params->op);
8117 ut_params->op = NULL;
8119 if (ut_params->sec_session)
8120 rte_security_session_destroy(ctx, ut_params->sec_session);
8121 ut_params->sec_session = NULL;
8123 rte_pktmbuf_free(ut_params->ibuf);
8124 ut_params->ibuf = NULL;
8126 rte_pktmbuf_free(ut_params->obuf);
8127 ut_params->obuf = NULL;
8134 test_pdcp_proto_cplane_encap(int i)
8136 return test_pdcp_proto(
8137 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8138 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8139 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8140 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8141 pdcp_test_params[i].cipher_key_len,
8142 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8143 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8144 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8145 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8146 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8150 test_pdcp_proto_uplane_encap(int i)
8152 return test_pdcp_proto(
8153 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8154 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8155 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8156 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8157 pdcp_test_params[i].cipher_key_len,
8158 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8159 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8160 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8161 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8162 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8166 test_pdcp_proto_uplane_encap_with_int(int i)
8168 return test_pdcp_proto(
8169 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8170 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8171 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8172 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8173 pdcp_test_params[i].cipher_key_len,
8174 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8175 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8176 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8177 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8178 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8182 test_pdcp_proto_cplane_decap(int i)
8184 return test_pdcp_proto(
8185 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8186 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8187 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8188 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8189 pdcp_test_params[i].cipher_key_len,
8190 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8191 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8192 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8193 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8194 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8198 test_pdcp_proto_uplane_decap(int i)
8200 return test_pdcp_proto(
8201 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8202 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8203 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8204 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8205 pdcp_test_params[i].cipher_key_len,
8206 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8207 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8208 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8209 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8210 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8214 test_pdcp_proto_uplane_decap_with_int(int i)
8216 return test_pdcp_proto(
8217 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8218 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8219 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8220 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8221 pdcp_test_params[i].cipher_key_len,
8222 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8223 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8224 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8225 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8226 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8230 test_PDCP_PROTO_SGL_in_place_32B(void)
8232 /* i can be used for running any PDCP case
8233 * In this case it is uplane 12-bit AES-SNOW DL encap
8235 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8236 return test_pdcp_proto_SGL(i, IN_PLACE,
8237 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8238 RTE_CRYPTO_AUTH_OP_GENERATE,
8239 pdcp_test_data_in[i],
8240 pdcp_test_data_in_len[i],
8241 pdcp_test_data_out[i],
8242 pdcp_test_data_in_len[i]+4,
8246 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8248 /* i can be used for running any PDCP case
8249 * In this case it is uplane 18-bit NULL-NULL DL encap
8251 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8252 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8253 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8254 RTE_CRYPTO_AUTH_OP_GENERATE,
8255 pdcp_test_data_in[i],
8256 pdcp_test_data_in_len[i],
8257 pdcp_test_data_out[i],
8258 pdcp_test_data_in_len[i]+4,
8262 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8264 /* i can be used for running any PDCP case
8265 * In this case it is uplane 18-bit AES DL encap
8267 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8269 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8270 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8271 RTE_CRYPTO_AUTH_OP_GENERATE,
8272 pdcp_test_data_in[i],
8273 pdcp_test_data_in_len[i],
8274 pdcp_test_data_out[i],
8275 pdcp_test_data_in_len[i],
8279 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8281 /* i can be used for running any PDCP case
8282 * In this case it is cplane 12-bit AES-ZUC DL encap
8284 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8285 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8286 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8287 RTE_CRYPTO_AUTH_OP_GENERATE,
8288 pdcp_test_data_in[i],
8289 pdcp_test_data_in_len[i],
8290 pdcp_test_data_out[i],
8291 pdcp_test_data_in_len[i]+4,
8296 test_PDCP_SDAP_PROTO_encap_all(void)
8298 int i = 0, size = 0;
8299 int err, all_err = TEST_SUCCESS;
8300 const struct pdcp_sdap_test *cur_test;
8302 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8304 for (i = 0; i < size; i++) {
8305 cur_test = &list_pdcp_sdap_tests[i];
8306 err = test_pdcp_proto(
8307 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8308 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8309 cur_test->in_len, cur_test->data_out,
8310 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8311 cur_test->param.cipher_alg, cur_test->cipher_key,
8312 cur_test->param.cipher_key_len,
8313 cur_test->param.auth_alg,
8314 cur_test->auth_key, cur_test->param.auth_key_len,
8315 cur_test->bearer, cur_test->param.domain,
8316 cur_test->packet_direction, cur_test->sn_size,
8318 cur_test->hfn_threshold, SDAP_ENABLED);
8320 printf("\t%d) %s: Encapsulation failed\n",
8322 cur_test->param.name);
8325 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8326 cur_test->param.name);
8332 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8334 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8338 test_PDCP_SDAP_PROTO_decap_all(void)
8340 int i = 0, size = 0;
8341 int err, all_err = TEST_SUCCESS;
8342 const struct pdcp_sdap_test *cur_test;
8344 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8346 for (i = 0; i < size; i++) {
8347 cur_test = &list_pdcp_sdap_tests[i];
8348 err = test_pdcp_proto(
8349 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8350 RTE_CRYPTO_AUTH_OP_VERIFY,
8352 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8353 cur_test->data_in, cur_test->in_len,
8354 cur_test->param.cipher_alg,
8355 cur_test->cipher_key, cur_test->param.cipher_key_len,
8356 cur_test->param.auth_alg, cur_test->auth_key,
8357 cur_test->param.auth_key_len, cur_test->bearer,
8358 cur_test->param.domain, cur_test->packet_direction,
8359 cur_test->sn_size, cur_test->hfn,
8360 cur_test->hfn_threshold, SDAP_ENABLED);
8362 printf("\t%d) %s: Decapsulation failed\n",
8364 cur_test->param.name);
8367 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8368 cur_test->param.name);
8374 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8376 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8380 test_PDCP_PROTO_all(void)
8382 struct crypto_testsuite_params *ts_params = &testsuite_params;
8383 struct crypto_unittest_params *ut_params = &unittest_params;
8384 struct rte_cryptodev_info dev_info;
8387 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8388 uint64_t feat_flags = dev_info.feature_flags;
8390 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8393 /* Set action type */
8394 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8395 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8398 if (security_proto_supported(ut_params->type,
8399 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8402 status = test_PDCP_PROTO_cplane_encap_all();
8403 status += test_PDCP_PROTO_cplane_decap_all();
8404 status += test_PDCP_PROTO_uplane_encap_all();
8405 status += test_PDCP_PROTO_uplane_decap_all();
8406 status += test_PDCP_PROTO_SGL_in_place_32B();
8407 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8408 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8409 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8410 status += test_PDCP_SDAP_PROTO_encap_all();
8411 status += test_PDCP_SDAP_PROTO_decap_all();
8416 return TEST_SUCCESS;
8420 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8422 struct crypto_testsuite_params *ts_params = &testsuite_params;
8423 struct crypto_unittest_params *ut_params = &unittest_params;
8424 uint8_t *plaintext, *ciphertext;
8426 int32_t cipher_len, crc_len;
8427 uint32_t crc_data_len;
8428 int ret = TEST_SUCCESS;
8430 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8431 rte_cryptodev_get_sec_ctx(
8432 ts_params->valid_devs[0]);
8434 /* Verify the capabilities */
8435 struct rte_security_capability_idx sec_cap_idx;
8436 const struct rte_security_capability *sec_cap;
8437 const struct rte_cryptodev_capabilities *crypto_cap;
8438 const struct rte_cryptodev_symmetric_capability *sym_cap;
8441 sec_cap_idx.action = ut_params->type;
8442 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8443 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8445 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8446 if (sec_cap == NULL)
8449 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8450 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8451 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8452 crypto_cap->sym.xform_type ==
8453 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8454 crypto_cap->sym.cipher.algo ==
8455 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8456 sym_cap = &crypto_cap->sym;
8457 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8464 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8467 /* Setup source mbuf payload */
8468 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8469 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8470 rte_pktmbuf_tailroom(ut_params->ibuf));
8472 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8473 d_td->ciphertext.len);
8475 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8477 /* Setup cipher session parameters */
8478 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8479 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8480 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8481 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8482 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8483 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8484 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8485 ut_params->cipher_xform.next = NULL;
8487 /* Setup DOCSIS session parameters */
8488 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8490 struct rte_security_session_conf sess_conf = {
8491 .action_type = ut_params->type,
8492 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8493 .docsis = ut_params->docsis_xform,
8494 .crypto_xform = &ut_params->cipher_xform,
8497 /* Create security session */
8498 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8499 ts_params->session_mpool,
8500 ts_params->session_priv_mpool);
8502 if (!ut_params->sec_session) {
8503 printf("TestCase %s(%d) line %d: %s\n",
8504 __func__, i, __LINE__, "failed to allocate session");
8509 /* Generate crypto op data structure */
8510 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8511 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8512 if (!ut_params->op) {
8513 printf("TestCase %s(%d) line %d: %s\n",
8514 __func__, i, __LINE__,
8515 "failed to allocate symmetric crypto operation");
8520 /* Setup CRC operation parameters */
8521 crc_len = d_td->ciphertext.no_crc == false ?
8522 (d_td->ciphertext.len -
8523 d_td->ciphertext.crc_offset -
8524 RTE_ETHER_CRC_LEN) :
8526 crc_len = crc_len > 0 ? crc_len : 0;
8527 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8528 ut_params->op->sym->auth.data.length = crc_len;
8529 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8531 /* Setup cipher operation parameters */
8532 cipher_len = d_td->ciphertext.no_cipher == false ?
8533 (d_td->ciphertext.len -
8534 d_td->ciphertext.cipher_offset) :
8536 cipher_len = cipher_len > 0 ? cipher_len : 0;
8537 ut_params->op->sym->cipher.data.length = cipher_len;
8538 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8540 /* Setup cipher IV */
8541 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8542 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8544 /* Attach session to operation */
8545 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8547 /* Set crypto operation mbufs */
8548 ut_params->op->sym->m_src = ut_params->ibuf;
8549 ut_params->op->sym->m_dst = NULL;
8551 /* Process crypto operation */
8552 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8554 printf("TestCase %s(%d) line %d: %s\n",
8555 __func__, i, __LINE__,
8556 "failed to process security crypto op");
8561 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8562 printf("TestCase %s(%d) line %d: %s\n",
8563 __func__, i, __LINE__, "crypto op processing failed");
8568 /* Validate plaintext */
8569 plaintext = ciphertext;
8571 if (memcmp(plaintext, d_td->plaintext.data,
8572 d_td->plaintext.len - crc_data_len)) {
8573 printf("TestCase %s(%d) line %d: %s\n",
8574 __func__, i, __LINE__, "plaintext not as expected\n");
8575 rte_hexdump(stdout, "expected", d_td->plaintext.data,
8576 d_td->plaintext.len);
8577 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
8583 rte_crypto_op_free(ut_params->op);
8584 ut_params->op = NULL;
8586 if (ut_params->sec_session)
8587 rte_security_session_destroy(ctx, ut_params->sec_session);
8588 ut_params->sec_session = NULL;
8590 rte_pktmbuf_free(ut_params->ibuf);
8591 ut_params->ibuf = NULL;
8597 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
8599 struct crypto_testsuite_params *ts_params = &testsuite_params;
8600 struct crypto_unittest_params *ut_params = &unittest_params;
8601 uint8_t *plaintext, *ciphertext;
8603 int32_t cipher_len, crc_len;
8604 int ret = TEST_SUCCESS;
8606 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8607 rte_cryptodev_get_sec_ctx(
8608 ts_params->valid_devs[0]);
8610 /* Verify the capabilities */
8611 struct rte_security_capability_idx sec_cap_idx;
8612 const struct rte_security_capability *sec_cap;
8613 const struct rte_cryptodev_capabilities *crypto_cap;
8614 const struct rte_cryptodev_symmetric_capability *sym_cap;
8617 sec_cap_idx.action = ut_params->type;
8618 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8619 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8621 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8622 if (sec_cap == NULL)
8625 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8626 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8627 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8628 crypto_cap->sym.xform_type ==
8629 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8630 crypto_cap->sym.cipher.algo ==
8631 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8632 sym_cap = &crypto_cap->sym;
8633 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8640 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8643 /* Setup source mbuf payload */
8644 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8645 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8646 rte_pktmbuf_tailroom(ut_params->ibuf));
8648 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8649 d_td->plaintext.len);
8651 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
8653 /* Setup cipher session parameters */
8654 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8655 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8656 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8657 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8658 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8659 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8660 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8661 ut_params->cipher_xform.next = NULL;
8663 /* Setup DOCSIS session parameters */
8664 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8666 struct rte_security_session_conf sess_conf = {
8667 .action_type = ut_params->type,
8668 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8669 .docsis = ut_params->docsis_xform,
8670 .crypto_xform = &ut_params->cipher_xform,
8673 /* Create security session */
8674 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8675 ts_params->session_mpool,
8676 ts_params->session_priv_mpool);
8678 if (!ut_params->sec_session) {
8679 printf("TestCase %s(%d) line %d: %s\n",
8680 __func__, i, __LINE__, "failed to allocate session");
8685 /* Generate crypto op data structure */
8686 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8687 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8688 if (!ut_params->op) {
8689 printf("TestCase %s(%d) line %d: %s\n",
8690 __func__, i, __LINE__,
8691 "failed to allocate security crypto operation");
8696 /* Setup CRC operation parameters */
8697 crc_len = d_td->plaintext.no_crc == false ?
8698 (d_td->plaintext.len -
8699 d_td->plaintext.crc_offset -
8700 RTE_ETHER_CRC_LEN) :
8702 crc_len = crc_len > 0 ? crc_len : 0;
8703 ut_params->op->sym->auth.data.length = crc_len;
8704 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8706 /* Setup cipher operation parameters */
8707 cipher_len = d_td->plaintext.no_cipher == false ?
8708 (d_td->plaintext.len -
8709 d_td->plaintext.cipher_offset) :
8711 cipher_len = cipher_len > 0 ? cipher_len : 0;
8712 ut_params->op->sym->cipher.data.length = cipher_len;
8713 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8715 /* Setup cipher IV */
8716 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8717 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8719 /* Attach session to operation */
8720 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8722 /* Set crypto operation mbufs */
8723 ut_params->op->sym->m_src = ut_params->ibuf;
8724 ut_params->op->sym->m_dst = NULL;
8726 /* Process crypto operation */
8727 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8729 printf("TestCase %s(%d) line %d: %s\n",
8730 __func__, i, __LINE__,
8731 "failed to process security crypto op");
8736 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8737 printf("TestCase %s(%d) line %d: %s\n",
8738 __func__, i, __LINE__, "crypto op processing failed");
8743 /* Validate ciphertext */
8744 ciphertext = plaintext;
8746 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8747 printf("TestCase %s(%d) line %d: %s\n",
8748 __func__, i, __LINE__, "ciphertext not as expected\n");
8749 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8750 d_td->ciphertext.len);
8751 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8757 rte_crypto_op_free(ut_params->op);
8758 ut_params->op = NULL;
8760 if (ut_params->sec_session)
8761 rte_security_session_destroy(ctx, ut_params->sec_session);
8762 ut_params->sec_session = NULL;
8764 rte_pktmbuf_free(ut_params->ibuf);
8765 ut_params->ibuf = NULL;
8770 #define TEST_DOCSIS_COUNT(func) do { \
8772 if (ret == TEST_SUCCESS) { \
8773 printf("\t%2d)", n++); \
8774 printf("+++++ PASSED:" #func"\n"); \
8776 } else if (ret == -ENOTSUP) { \
8777 printf("\t%2d)", n++); \
8778 printf("~~~~~ UNSUPP:" #func"\n"); \
8781 printf("\t%2d)", n++); \
8782 printf("----- FAILED:" #func"\n"); \
8788 test_DOCSIS_PROTO_uplink_all(void)
8790 int p = 0, u = 0, f = 0, n = 0;
8792 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8793 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8794 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8795 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8796 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8797 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8798 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8799 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8800 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8801 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8802 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8803 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8804 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8805 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8806 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8807 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8808 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8809 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8810 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8811 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8812 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8813 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8814 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8815 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8816 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8817 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8820 printf("## %s: %d passed out of %d (%d unsupported)\n",
8827 test_DOCSIS_PROTO_downlink_all(void)
8829 int p = 0, u = 0, f = 0, n = 0;
8831 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8832 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8833 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8834 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8835 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8836 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8837 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8838 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8839 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8840 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8841 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8842 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8843 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8844 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8845 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8846 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8847 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8848 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8849 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8850 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8851 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8852 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8853 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8854 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8855 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8856 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8859 printf("## %s: %d passed out of %d (%d unsupported)\n",
8866 test_DOCSIS_PROTO_all(void)
8868 struct crypto_testsuite_params *ts_params = &testsuite_params;
8869 struct crypto_unittest_params *ut_params = &unittest_params;
8870 struct rte_cryptodev_info dev_info;
8873 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8874 uint64_t feat_flags = dev_info.feature_flags;
8876 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8879 /* Set action type */
8880 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8881 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8884 if (security_proto_supported(ut_params->type,
8885 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8888 status = test_DOCSIS_PROTO_uplink_all();
8889 status += test_DOCSIS_PROTO_downlink_all();
8894 return TEST_SUCCESS;
8899 test_AES_GCM_authenticated_encryption_test_case_1(void)
8901 return test_authenticated_encryption(&gcm_test_case_1);
8905 test_AES_GCM_authenticated_encryption_test_case_2(void)
8907 return test_authenticated_encryption(&gcm_test_case_2);
8911 test_AES_GCM_authenticated_encryption_test_case_3(void)
8913 return test_authenticated_encryption(&gcm_test_case_3);
8917 test_AES_GCM_authenticated_encryption_test_case_4(void)
8919 return test_authenticated_encryption(&gcm_test_case_4);
8923 test_AES_GCM_authenticated_encryption_test_case_5(void)
8925 return test_authenticated_encryption(&gcm_test_case_5);
8929 test_AES_GCM_authenticated_encryption_test_case_6(void)
8931 return test_authenticated_encryption(&gcm_test_case_6);
8935 test_AES_GCM_authenticated_encryption_test_case_7(void)
8937 return test_authenticated_encryption(&gcm_test_case_7);
8941 test_AES_GCM_authenticated_encryption_test_case_8(void)
8943 return test_authenticated_encryption(&gcm_test_case_8);
8947 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
8949 return test_authenticated_encryption(&gcm_J0_test_case_1);
8953 test_AES_GCM_auth_encryption_test_case_192_1(void)
8955 return test_authenticated_encryption(&gcm_test_case_192_1);
8959 test_AES_GCM_auth_encryption_test_case_192_2(void)
8961 return test_authenticated_encryption(&gcm_test_case_192_2);
8965 test_AES_GCM_auth_encryption_test_case_192_3(void)
8967 return test_authenticated_encryption(&gcm_test_case_192_3);
8971 test_AES_GCM_auth_encryption_test_case_192_4(void)
8973 return test_authenticated_encryption(&gcm_test_case_192_4);
8977 test_AES_GCM_auth_encryption_test_case_192_5(void)
8979 return test_authenticated_encryption(&gcm_test_case_192_5);
8983 test_AES_GCM_auth_encryption_test_case_192_6(void)
8985 return test_authenticated_encryption(&gcm_test_case_192_6);
8989 test_AES_GCM_auth_encryption_test_case_192_7(void)
8991 return test_authenticated_encryption(&gcm_test_case_192_7);
8995 test_AES_GCM_auth_encryption_test_case_256_1(void)
8997 return test_authenticated_encryption(&gcm_test_case_256_1);
9001 test_AES_GCM_auth_encryption_test_case_256_2(void)
9003 return test_authenticated_encryption(&gcm_test_case_256_2);
9007 test_AES_GCM_auth_encryption_test_case_256_3(void)
9009 return test_authenticated_encryption(&gcm_test_case_256_3);
9013 test_AES_GCM_auth_encryption_test_case_256_4(void)
9015 return test_authenticated_encryption(&gcm_test_case_256_4);
9019 test_AES_GCM_auth_encryption_test_case_256_5(void)
9021 return test_authenticated_encryption(&gcm_test_case_256_5);
9025 test_AES_GCM_auth_encryption_test_case_256_6(void)
9027 return test_authenticated_encryption(&gcm_test_case_256_6);
9031 test_AES_GCM_auth_encryption_test_case_256_7(void)
9033 return test_authenticated_encryption(&gcm_test_case_256_7);
9037 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9039 return test_authenticated_encryption(&gcm_test_case_aad_1);
9043 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9045 return test_authenticated_encryption(&gcm_test_case_aad_2);
9049 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9051 struct aead_test_data tdata;
9054 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9055 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9056 tdata.iv.data[0] += 1;
9057 res = test_authenticated_encryption(&tdata);
9058 if (res == -ENOTSUP)
9060 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9061 return TEST_SUCCESS;
9065 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9067 struct aead_test_data tdata;
9070 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9071 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9072 tdata.plaintext.data[0] += 1;
9073 res = test_authenticated_encryption(&tdata);
9074 if (res == -ENOTSUP)
9076 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9077 return TEST_SUCCESS;
9081 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9083 struct aead_test_data tdata;
9086 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9087 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9088 tdata.ciphertext.data[0] += 1;
9089 res = test_authenticated_encryption(&tdata);
9090 if (res == -ENOTSUP)
9092 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9093 return TEST_SUCCESS;
9097 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9099 struct aead_test_data tdata;
9102 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9103 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9105 res = test_authenticated_encryption(&tdata);
9106 if (res == -ENOTSUP)
9108 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9109 return TEST_SUCCESS;
9113 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9115 struct aead_test_data tdata;
9116 uint8_t aad[gcm_test_case_7.aad.len];
9119 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9120 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9121 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9123 tdata.aad.data = aad;
9124 res = test_authenticated_encryption(&tdata);
9125 if (res == -ENOTSUP)
9127 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9128 return TEST_SUCCESS;
9132 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9134 struct aead_test_data tdata;
9137 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9138 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9139 tdata.auth_tag.data[0] += 1;
9140 res = test_authenticated_encryption(&tdata);
9141 if (res == -ENOTSUP)
9143 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9144 return TEST_SUCCESS;
9148 test_authenticated_decryption(const struct aead_test_data *tdata)
9150 struct crypto_testsuite_params *ts_params = &testsuite_params;
9151 struct crypto_unittest_params *ut_params = &unittest_params;
9156 struct rte_cryptodev_info dev_info;
9158 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9159 uint64_t feat_flags = dev_info.feature_flags;
9161 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9162 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9163 printf("Device doesn't support RAW data-path APIs.\n");
9167 /* Verify the capabilities */
9168 struct rte_cryptodev_sym_capability_idx cap_idx;
9169 const struct rte_cryptodev_symmetric_capability *capability;
9170 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9171 cap_idx.algo.aead = tdata->algo;
9172 capability = rte_cryptodev_sym_capability_get(
9173 ts_params->valid_devs[0], &cap_idx);
9174 if (capability == NULL)
9176 if (rte_cryptodev_sym_capability_check_aead(
9177 capability, tdata->key.len, tdata->auth_tag.len,
9178 tdata->aad.len, tdata->iv.len))
9181 /* Create AEAD session */
9182 retval = create_aead_session(ts_params->valid_devs[0],
9184 RTE_CRYPTO_AEAD_OP_DECRYPT,
9185 tdata->key.data, tdata->key.len,
9186 tdata->aad.len, tdata->auth_tag.len,
9191 /* alloc mbuf and set payload */
9192 if (tdata->aad.len > MBUF_SIZE) {
9193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9194 /* Populate full size of add data */
9195 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9196 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9198 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9200 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9201 rte_pktmbuf_tailroom(ut_params->ibuf));
9203 /* Create AEAD operation */
9204 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9208 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9210 ut_params->op->sym->m_src = ut_params->ibuf;
9212 /* Process crypto operation */
9213 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9214 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9215 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9216 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9217 ut_params->op, 0, 0, 0, 0);
9219 TEST_ASSERT_NOT_NULL(
9220 process_crypto_request(ts_params->valid_devs[0],
9221 ut_params->op), "failed to process sym crypto op");
9223 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9224 "crypto op processing failed");
9226 if (ut_params->op->sym->m_dst)
9227 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9230 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9232 ut_params->op->sym->cipher.data.offset);
9234 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9237 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9239 tdata->plaintext.data,
9240 tdata->plaintext.len,
9241 "Plaintext data not as expected");
9243 TEST_ASSERT_EQUAL(ut_params->op->status,
9244 RTE_CRYPTO_OP_STATUS_SUCCESS,
9245 "Authentication failed");
9251 test_AES_GCM_authenticated_decryption_test_case_1(void)
9253 return test_authenticated_decryption(&gcm_test_case_1);
9257 test_AES_GCM_authenticated_decryption_test_case_2(void)
9259 return test_authenticated_decryption(&gcm_test_case_2);
9263 test_AES_GCM_authenticated_decryption_test_case_3(void)
9265 return test_authenticated_decryption(&gcm_test_case_3);
9269 test_AES_GCM_authenticated_decryption_test_case_4(void)
9271 return test_authenticated_decryption(&gcm_test_case_4);
9275 test_AES_GCM_authenticated_decryption_test_case_5(void)
9277 return test_authenticated_decryption(&gcm_test_case_5);
9281 test_AES_GCM_authenticated_decryption_test_case_6(void)
9283 return test_authenticated_decryption(&gcm_test_case_6);
9287 test_AES_GCM_authenticated_decryption_test_case_7(void)
9289 return test_authenticated_decryption(&gcm_test_case_7);
9293 test_AES_GCM_authenticated_decryption_test_case_8(void)
9295 return test_authenticated_decryption(&gcm_test_case_8);
9299 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9301 return test_authenticated_decryption(&gcm_J0_test_case_1);
9305 test_AES_GCM_auth_decryption_test_case_192_1(void)
9307 return test_authenticated_decryption(&gcm_test_case_192_1);
9311 test_AES_GCM_auth_decryption_test_case_192_2(void)
9313 return test_authenticated_decryption(&gcm_test_case_192_2);
9317 test_AES_GCM_auth_decryption_test_case_192_3(void)
9319 return test_authenticated_decryption(&gcm_test_case_192_3);
9323 test_AES_GCM_auth_decryption_test_case_192_4(void)
9325 return test_authenticated_decryption(&gcm_test_case_192_4);
9329 test_AES_GCM_auth_decryption_test_case_192_5(void)
9331 return test_authenticated_decryption(&gcm_test_case_192_5);
9335 test_AES_GCM_auth_decryption_test_case_192_6(void)
9337 return test_authenticated_decryption(&gcm_test_case_192_6);
9341 test_AES_GCM_auth_decryption_test_case_192_7(void)
9343 return test_authenticated_decryption(&gcm_test_case_192_7);
9347 test_AES_GCM_auth_decryption_test_case_256_1(void)
9349 return test_authenticated_decryption(&gcm_test_case_256_1);
9353 test_AES_GCM_auth_decryption_test_case_256_2(void)
9355 return test_authenticated_decryption(&gcm_test_case_256_2);
9359 test_AES_GCM_auth_decryption_test_case_256_3(void)
9361 return test_authenticated_decryption(&gcm_test_case_256_3);
9365 test_AES_GCM_auth_decryption_test_case_256_4(void)
9367 return test_authenticated_decryption(&gcm_test_case_256_4);
9371 test_AES_GCM_auth_decryption_test_case_256_5(void)
9373 return test_authenticated_decryption(&gcm_test_case_256_5);
9377 test_AES_GCM_auth_decryption_test_case_256_6(void)
9379 return test_authenticated_decryption(&gcm_test_case_256_6);
9383 test_AES_GCM_auth_decryption_test_case_256_7(void)
9385 return test_authenticated_decryption(&gcm_test_case_256_7);
9389 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9391 return test_authenticated_decryption(&gcm_test_case_aad_1);
9395 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9397 return test_authenticated_decryption(&gcm_test_case_aad_2);
9401 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9403 struct aead_test_data tdata;
9406 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9407 tdata.iv.data[0] += 1;
9408 res = test_authenticated_decryption(&tdata);
9409 if (res == -ENOTSUP)
9411 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9412 return TEST_SUCCESS;
9416 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9418 struct aead_test_data tdata;
9421 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9422 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9423 tdata.plaintext.data[0] += 1;
9424 res = test_authenticated_decryption(&tdata);
9425 if (res == -ENOTSUP)
9427 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9428 return TEST_SUCCESS;
9432 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9434 struct aead_test_data tdata;
9437 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9438 tdata.ciphertext.data[0] += 1;
9439 res = test_authenticated_decryption(&tdata);
9440 if (res == -ENOTSUP)
9442 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9443 return TEST_SUCCESS;
9447 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9449 struct aead_test_data tdata;
9452 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9454 res = test_authenticated_decryption(&tdata);
9455 if (res == -ENOTSUP)
9457 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9458 return TEST_SUCCESS;
9462 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9464 struct aead_test_data tdata;
9465 uint8_t aad[gcm_test_case_7.aad.len];
9468 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9469 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9471 tdata.aad.data = aad;
9472 res = test_authenticated_decryption(&tdata);
9473 if (res == -ENOTSUP)
9475 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9476 return TEST_SUCCESS;
9480 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9482 struct aead_test_data tdata;
9485 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9486 tdata.auth_tag.data[0] += 1;
9487 res = test_authenticated_decryption(&tdata);
9488 if (res == -ENOTSUP)
9490 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9491 return TEST_SUCCESS;
9495 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9497 struct crypto_testsuite_params *ts_params = &testsuite_params;
9498 struct crypto_unittest_params *ut_params = &unittest_params;
9501 uint8_t *ciphertext, *auth_tag;
9502 uint16_t plaintext_pad_len;
9504 /* Verify the capabilities */
9505 struct rte_cryptodev_sym_capability_idx cap_idx;
9506 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9507 cap_idx.algo.aead = tdata->algo;
9508 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9512 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9515 /* not supported with CPU crypto */
9516 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9519 /* Create AEAD session */
9520 retval = create_aead_session(ts_params->valid_devs[0],
9522 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9523 tdata->key.data, tdata->key.len,
9524 tdata->aad.len, tdata->auth_tag.len,
9529 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9530 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9532 /* clear mbuf payload */
9533 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9534 rte_pktmbuf_tailroom(ut_params->ibuf));
9535 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9536 rte_pktmbuf_tailroom(ut_params->obuf));
9538 /* Create AEAD operation */
9539 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9543 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9545 ut_params->op->sym->m_src = ut_params->ibuf;
9546 ut_params->op->sym->m_dst = ut_params->obuf;
9548 /* Process crypto operation */
9549 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9550 ut_params->op), "failed to process sym crypto op");
9552 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9553 "crypto op processing failed");
9555 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9557 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9558 ut_params->op->sym->cipher.data.offset);
9559 auth_tag = ciphertext + plaintext_pad_len;
9561 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9562 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9565 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9567 tdata->ciphertext.data,
9568 tdata->ciphertext.len,
9569 "Ciphertext data not as expected");
9571 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9573 tdata->auth_tag.data,
9574 tdata->auth_tag.len,
9575 "Generated auth tag not as expected");
9582 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9584 return test_authenticated_encryption_oop(&gcm_test_case_5);
9588 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9590 struct crypto_testsuite_params *ts_params = &testsuite_params;
9591 struct crypto_unittest_params *ut_params = &unittest_params;
9596 /* Verify the capabilities */
9597 struct rte_cryptodev_sym_capability_idx cap_idx;
9598 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9599 cap_idx.algo.aead = tdata->algo;
9600 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9604 /* not supported with CPU crypto and raw data-path APIs*/
9605 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
9606 global_api_test_type == CRYPTODEV_RAW_API_TEST)
9609 /* Create AEAD session */
9610 retval = create_aead_session(ts_params->valid_devs[0],
9612 RTE_CRYPTO_AEAD_OP_DECRYPT,
9613 tdata->key.data, tdata->key.len,
9614 tdata->aad.len, tdata->auth_tag.len,
9619 /* alloc mbuf and set payload */
9620 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9621 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9623 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9624 rte_pktmbuf_tailroom(ut_params->ibuf));
9625 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9626 rte_pktmbuf_tailroom(ut_params->obuf));
9628 /* Create AEAD operation */
9629 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9633 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9635 ut_params->op->sym->m_src = ut_params->ibuf;
9636 ut_params->op->sym->m_dst = ut_params->obuf;
9638 /* Process crypto operation */
9639 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9640 ut_params->op), "failed to process sym crypto op");
9642 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9643 "crypto op processing failed");
9645 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9646 ut_params->op->sym->cipher.data.offset);
9648 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9651 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9653 tdata->plaintext.data,
9654 tdata->plaintext.len,
9655 "Plaintext data not as expected");
9657 TEST_ASSERT_EQUAL(ut_params->op->status,
9658 RTE_CRYPTO_OP_STATUS_SUCCESS,
9659 "Authentication failed");
9664 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9666 return test_authenticated_decryption_oop(&gcm_test_case_5);
9670 test_authenticated_encryption_sessionless(
9671 const struct aead_test_data *tdata)
9673 struct crypto_testsuite_params *ts_params = &testsuite_params;
9674 struct crypto_unittest_params *ut_params = &unittest_params;
9677 uint8_t *ciphertext, *auth_tag;
9678 uint16_t plaintext_pad_len;
9679 uint8_t key[tdata->key.len + 1];
9680 struct rte_cryptodev_info dev_info;
9682 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9683 uint64_t feat_flags = dev_info.feature_flags;
9685 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9686 printf("Device doesn't support Sessionless ops.\n");
9690 /* not supported with CPU crypto */
9691 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9694 /* Verify the capabilities */
9695 struct rte_cryptodev_sym_capability_idx cap_idx;
9696 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9697 cap_idx.algo.aead = tdata->algo;
9698 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9702 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9704 /* clear mbuf payload */
9705 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9706 rte_pktmbuf_tailroom(ut_params->ibuf));
9708 /* Create AEAD operation */
9709 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9713 /* Create GCM xform */
9714 memcpy(key, tdata->key.data, tdata->key.len);
9715 retval = create_aead_xform(ut_params->op,
9717 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9718 key, tdata->key.len,
9719 tdata->aad.len, tdata->auth_tag.len,
9724 ut_params->op->sym->m_src = ut_params->ibuf;
9726 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9727 RTE_CRYPTO_OP_SESSIONLESS,
9728 "crypto op session type not sessionless");
9730 /* Process crypto operation */
9731 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9732 ut_params->op), "failed to process sym crypto op");
9734 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9736 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9737 "crypto op status not success");
9739 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9741 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9742 ut_params->op->sym->cipher.data.offset);
9743 auth_tag = ciphertext + plaintext_pad_len;
9745 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9746 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9749 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9751 tdata->ciphertext.data,
9752 tdata->ciphertext.len,
9753 "Ciphertext data not as expected");
9755 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9757 tdata->auth_tag.data,
9758 tdata->auth_tag.len,
9759 "Generated auth tag not as expected");
9766 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9768 return test_authenticated_encryption_sessionless(
9773 test_authenticated_decryption_sessionless(
9774 const struct aead_test_data *tdata)
9776 struct crypto_testsuite_params *ts_params = &testsuite_params;
9777 struct crypto_unittest_params *ut_params = &unittest_params;
9781 uint8_t key[tdata->key.len + 1];
9782 struct rte_cryptodev_info dev_info;
9784 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9785 uint64_t feat_flags = dev_info.feature_flags;
9787 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9788 printf("Device doesn't support Sessionless ops.\n");
9792 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9793 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9794 printf("Device doesn't support RAW data-path APIs.\n");
9798 /* not supported with CPU crypto */
9799 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9802 /* Verify the capabilities */
9803 struct rte_cryptodev_sym_capability_idx cap_idx;
9804 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9805 cap_idx.algo.aead = tdata->algo;
9806 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9810 /* alloc mbuf and set payload */
9811 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9813 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9814 rte_pktmbuf_tailroom(ut_params->ibuf));
9816 /* Create AEAD operation */
9817 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9821 /* Create AEAD xform */
9822 memcpy(key, tdata->key.data, tdata->key.len);
9823 retval = create_aead_xform(ut_params->op,
9825 RTE_CRYPTO_AEAD_OP_DECRYPT,
9826 key, tdata->key.len,
9827 tdata->aad.len, tdata->auth_tag.len,
9832 ut_params->op->sym->m_src = ut_params->ibuf;
9834 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9835 RTE_CRYPTO_OP_SESSIONLESS,
9836 "crypto op session type not sessionless");
9838 /* Process crypto operation */
9839 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9840 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9841 ut_params->op, 0, 0, 0, 0);
9843 TEST_ASSERT_NOT_NULL(process_crypto_request(
9844 ts_params->valid_devs[0], ut_params->op),
9845 "failed to process sym crypto op");
9847 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9849 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9850 "crypto op status not success");
9852 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9853 ut_params->op->sym->cipher.data.offset);
9855 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9858 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9860 tdata->plaintext.data,
9861 tdata->plaintext.len,
9862 "Plaintext data not as expected");
9864 TEST_ASSERT_EQUAL(ut_params->op->status,
9865 RTE_CRYPTO_OP_STATUS_SUCCESS,
9866 "Authentication failed");
9871 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9873 return test_authenticated_decryption_sessionless(
9878 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9880 return test_authenticated_encryption(&ccm_test_case_128_1);
9884 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9886 return test_authenticated_encryption(&ccm_test_case_128_2);
9890 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9892 return test_authenticated_encryption(&ccm_test_case_128_3);
9896 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9898 return test_authenticated_decryption(&ccm_test_case_128_1);
9902 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9904 return test_authenticated_decryption(&ccm_test_case_128_2);
9908 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9910 return test_authenticated_decryption(&ccm_test_case_128_3);
9914 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9916 return test_authenticated_encryption(&ccm_test_case_192_1);
9920 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9922 return test_authenticated_encryption(&ccm_test_case_192_2);
9926 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9928 return test_authenticated_encryption(&ccm_test_case_192_3);
9932 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9934 return test_authenticated_decryption(&ccm_test_case_192_1);
9938 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9940 return test_authenticated_decryption(&ccm_test_case_192_2);
9944 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9946 return test_authenticated_decryption(&ccm_test_case_192_3);
9950 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9952 return test_authenticated_encryption(&ccm_test_case_256_1);
9956 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9958 return test_authenticated_encryption(&ccm_test_case_256_2);
9962 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9964 return test_authenticated_encryption(&ccm_test_case_256_3);
9968 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9970 return test_authenticated_decryption(&ccm_test_case_256_1);
9974 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9976 return test_authenticated_decryption(&ccm_test_case_256_2);
9980 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9982 return test_authenticated_decryption(&ccm_test_case_256_3);
9988 struct crypto_testsuite_params *ts_params = &testsuite_params;
9989 struct rte_cryptodev_stats stats;
9991 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9994 /* Verify the capabilities */
9995 struct rte_cryptodev_sym_capability_idx cap_idx;
9996 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9997 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
9998 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10001 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10002 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10003 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10007 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10011 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10012 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10013 &stats) == -ENODEV),
10014 "rte_cryptodev_stats_get invalid dev failed");
10015 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10016 "rte_cryptodev_stats_get invalid Param failed");
10018 /* Test expected values */
10019 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10020 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10022 "rte_cryptodev_stats_get failed");
10023 TEST_ASSERT((stats.enqueued_count == 1),
10024 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10025 TEST_ASSERT((stats.dequeued_count == 1),
10026 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10027 TEST_ASSERT((stats.enqueue_err_count == 0),
10028 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10029 TEST_ASSERT((stats.dequeue_err_count == 0),
10030 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10032 /* invalid device but should ignore and not reset device stats*/
10033 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10034 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10036 "rte_cryptodev_stats_get failed");
10037 TEST_ASSERT((stats.enqueued_count == 1),
10038 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10040 /* check that a valid reset clears stats */
10041 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10042 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10044 "rte_cryptodev_stats_get failed");
10045 TEST_ASSERT((stats.enqueued_count == 0),
10046 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10047 TEST_ASSERT((stats.dequeued_count == 0),
10048 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10050 return TEST_SUCCESS;
10053 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10054 struct crypto_unittest_params *ut_params,
10055 enum rte_crypto_auth_operation op,
10056 const struct HMAC_MD5_vector *test_case)
10060 memcpy(key, test_case->key.data, test_case->key.len);
10062 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10063 ut_params->auth_xform.next = NULL;
10064 ut_params->auth_xform.auth.op = op;
10066 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10068 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10069 ut_params->auth_xform.auth.key.length = test_case->key.len;
10070 ut_params->auth_xform.auth.key.data = key;
10072 ut_params->sess = rte_cryptodev_sym_session_create(
10073 ts_params->session_mpool);
10075 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10076 ut_params->sess, &ut_params->auth_xform,
10077 ts_params->session_priv_mpool);
10079 if (ut_params->sess == NULL)
10080 return TEST_FAILED;
10082 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10084 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10085 rte_pktmbuf_tailroom(ut_params->ibuf));
10090 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10091 const struct HMAC_MD5_vector *test_case,
10092 uint8_t **plaintext)
10094 uint16_t plaintext_pad_len;
10096 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10098 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10101 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10102 plaintext_pad_len);
10103 memcpy(*plaintext, test_case->plaintext.data,
10104 test_case->plaintext.len);
10106 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10107 ut_params->ibuf, MD5_DIGEST_LEN);
10108 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10109 "no room to append digest");
10110 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10111 ut_params->ibuf, plaintext_pad_len);
10113 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10114 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10115 test_case->auth_tag.len);
10118 sym_op->auth.data.offset = 0;
10119 sym_op->auth.data.length = test_case->plaintext.len;
10121 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10122 ut_params->op->sym->m_src = ut_params->ibuf;
10128 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10130 uint16_t plaintext_pad_len;
10131 uint8_t *plaintext, *auth_tag;
10133 struct crypto_testsuite_params *ts_params = &testsuite_params;
10134 struct crypto_unittest_params *ut_params = &unittest_params;
10135 struct rte_cryptodev_info dev_info;
10137 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10138 uint64_t feat_flags = dev_info.feature_flags;
10140 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10141 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10142 printf("Device doesn't support RAW data-path APIs.\n");
10146 /* Verify the capabilities */
10147 struct rte_cryptodev_sym_capability_idx cap_idx;
10148 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10149 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10150 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10154 if (MD5_HMAC_create_session(ts_params, ut_params,
10155 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10156 return TEST_FAILED;
10158 /* Generate Crypto op data structure */
10159 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10160 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10161 TEST_ASSERT_NOT_NULL(ut_params->op,
10162 "Failed to allocate symmetric crypto operation struct");
10164 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10167 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10168 return TEST_FAILED;
10170 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10171 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10173 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10174 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10175 ut_params->op, 0, 1, 0, 0);
10177 TEST_ASSERT_NOT_NULL(
10178 process_crypto_request(ts_params->valid_devs[0],
10180 "failed to process sym crypto op");
10182 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10183 "crypto op processing failed");
10185 if (ut_params->op->sym->m_dst) {
10186 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10187 uint8_t *, plaintext_pad_len);
10189 auth_tag = plaintext + plaintext_pad_len;
10192 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10194 test_case->auth_tag.data,
10195 test_case->auth_tag.len,
10196 "HMAC_MD5 generated tag not as expected");
10198 return TEST_SUCCESS;
10202 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10204 uint8_t *plaintext;
10206 struct crypto_testsuite_params *ts_params = &testsuite_params;
10207 struct crypto_unittest_params *ut_params = &unittest_params;
10208 struct rte_cryptodev_info dev_info;
10210 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10211 uint64_t feat_flags = dev_info.feature_flags;
10213 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10214 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10215 printf("Device doesn't support RAW data-path APIs.\n");
10219 /* Verify the capabilities */
10220 struct rte_cryptodev_sym_capability_idx cap_idx;
10221 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10222 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10223 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10227 if (MD5_HMAC_create_session(ts_params, ut_params,
10228 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10229 return TEST_FAILED;
10232 /* Generate Crypto op data structure */
10233 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10234 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10235 TEST_ASSERT_NOT_NULL(ut_params->op,
10236 "Failed to allocate symmetric crypto operation struct");
10238 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10239 return TEST_FAILED;
10241 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10242 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10244 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10245 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10246 ut_params->op, 0, 1, 0, 0);
10248 TEST_ASSERT_NOT_NULL(
10249 process_crypto_request(ts_params->valid_devs[0],
10251 "failed to process sym crypto op");
10253 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10254 "HMAC_MD5 crypto op processing failed");
10256 return TEST_SUCCESS;
10260 test_MD5_HMAC_generate_case_1(void)
10262 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10266 test_MD5_HMAC_verify_case_1(void)
10268 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10272 test_MD5_HMAC_generate_case_2(void)
10274 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10278 test_MD5_HMAC_verify_case_2(void)
10280 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10284 test_multi_session(void)
10286 struct crypto_testsuite_params *ts_params = &testsuite_params;
10287 struct crypto_unittest_params *ut_params = &unittest_params;
10289 struct rte_cryptodev_info dev_info;
10290 struct rte_cryptodev_sym_session **sessions;
10294 /* Verify the capabilities */
10295 struct rte_cryptodev_sym_capability_idx cap_idx;
10296 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10297 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10298 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10301 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10302 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10303 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10307 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10308 aes_cbc_key, hmac_sha512_key);
10311 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10313 sessions = rte_malloc(NULL,
10314 (sizeof(struct rte_cryptodev_sym_session *) *
10315 MAX_NB_SESSIONS) + 1, 0);
10317 /* Create multiple crypto sessions*/
10318 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10320 sessions[i] = rte_cryptodev_sym_session_create(
10321 ts_params->session_mpool);
10323 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10324 sessions[i], &ut_params->auth_xform,
10325 ts_params->session_priv_mpool);
10326 TEST_ASSERT_NOT_NULL(sessions[i],
10327 "Session creation failed at session number %u",
10330 /* Attempt to send a request on each session */
10331 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10335 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10336 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10338 "Failed to perform decrypt on request number %u.", i);
10339 /* free crypto operation structure */
10341 rte_crypto_op_free(ut_params->op);
10344 * free mbuf - both obuf and ibuf are usually the same,
10345 * so check if they point at the same address is necessary,
10346 * to avoid freeing the mbuf twice.
10348 if (ut_params->obuf) {
10349 rte_pktmbuf_free(ut_params->obuf);
10350 if (ut_params->ibuf == ut_params->obuf)
10351 ut_params->ibuf = 0;
10352 ut_params->obuf = 0;
10354 if (ut_params->ibuf) {
10355 rte_pktmbuf_free(ut_params->ibuf);
10356 ut_params->ibuf = 0;
10360 /* Next session create should fail */
10361 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10362 sessions[i], &ut_params->auth_xform,
10363 ts_params->session_priv_mpool);
10364 TEST_ASSERT_NULL(sessions[i],
10365 "Session creation succeeded unexpectedly!");
10367 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10368 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10370 rte_cryptodev_sym_session_free(sessions[i]);
10373 rte_free(sessions);
10375 return TEST_SUCCESS;
10378 struct multi_session_params {
10379 struct crypto_unittest_params ut_params;
10380 uint8_t *cipher_key;
10382 const uint8_t *cipher;
10383 const uint8_t *digest;
10387 #define MB_SESSION_NUMBER 3
10390 test_multi_session_random_usage(void)
10392 struct crypto_testsuite_params *ts_params = &testsuite_params;
10393 struct rte_cryptodev_info dev_info;
10394 struct rte_cryptodev_sym_session **sessions;
10396 struct multi_session_params ut_paramz[] = {
10399 .cipher_key = ms_aes_cbc_key0,
10400 .hmac_key = ms_hmac_key0,
10401 .cipher = ms_aes_cbc_cipher0,
10402 .digest = ms_hmac_digest0,
10403 .iv = ms_aes_cbc_iv0
10406 .cipher_key = ms_aes_cbc_key1,
10407 .hmac_key = ms_hmac_key1,
10408 .cipher = ms_aes_cbc_cipher1,
10409 .digest = ms_hmac_digest1,
10410 .iv = ms_aes_cbc_iv1
10413 .cipher_key = ms_aes_cbc_key2,
10414 .hmac_key = ms_hmac_key2,
10415 .cipher = ms_aes_cbc_cipher2,
10416 .digest = ms_hmac_digest2,
10417 .iv = ms_aes_cbc_iv2
10422 /* Verify the capabilities */
10423 struct rte_cryptodev_sym_capability_idx cap_idx;
10424 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10425 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10426 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10429 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10430 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10431 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10435 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10437 sessions = rte_malloc(NULL,
10438 (sizeof(struct rte_cryptodev_sym_session *)
10439 * MAX_NB_SESSIONS) + 1, 0);
10441 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10442 sessions[i] = rte_cryptodev_sym_session_create(
10443 ts_params->session_mpool);
10445 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10446 sizeof(struct crypto_unittest_params));
10448 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10449 &ut_paramz[i].ut_params,
10450 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10452 /* Create multiple crypto sessions*/
10453 rte_cryptodev_sym_session_init(
10454 ts_params->valid_devs[0],
10456 &ut_paramz[i].ut_params.auth_xform,
10457 ts_params->session_priv_mpool);
10459 TEST_ASSERT_NOT_NULL(sessions[i],
10460 "Session creation failed at session number %u",
10466 for (i = 0; i < 40000; i++) {
10468 j = rand() % MB_SESSION_NUMBER;
10470 TEST_ASSERT_SUCCESS(
10471 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10473 &ut_paramz[j].ut_params,
10474 ts_params, ut_paramz[j].cipher,
10475 ut_paramz[j].digest,
10477 "Failed to perform decrypt on request number %u.", i);
10479 if (ut_paramz[j].ut_params.op)
10480 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10483 * free mbuf - both obuf and ibuf are usually the same,
10484 * so check if they point at the same address is necessary,
10485 * to avoid freeing the mbuf twice.
10487 if (ut_paramz[j].ut_params.obuf) {
10488 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10489 if (ut_paramz[j].ut_params.ibuf
10490 == ut_paramz[j].ut_params.obuf)
10491 ut_paramz[j].ut_params.ibuf = 0;
10492 ut_paramz[j].ut_params.obuf = 0;
10494 if (ut_paramz[j].ut_params.ibuf) {
10495 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10496 ut_paramz[j].ut_params.ibuf = 0;
10500 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10501 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10503 rte_cryptodev_sym_session_free(sessions[i]);
10506 rte_free(sessions);
10508 return TEST_SUCCESS;
10511 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10512 0xab, 0xab, 0xab, 0xab,
10513 0xab, 0xab, 0xab, 0xab,
10514 0xab, 0xab, 0xab, 0xab};
10517 test_null_invalid_operation(void)
10519 struct crypto_testsuite_params *ts_params = &testsuite_params;
10520 struct crypto_unittest_params *ut_params = &unittest_params;
10523 /* This test is for NULL PMD only */
10524 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10525 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10528 /* Setup Cipher Parameters */
10529 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10530 ut_params->cipher_xform.next = NULL;
10532 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10533 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10535 ut_params->sess = rte_cryptodev_sym_session_create(
10536 ts_params->session_mpool);
10538 /* Create Crypto session*/
10539 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10540 ut_params->sess, &ut_params->cipher_xform,
10541 ts_params->session_priv_mpool);
10542 TEST_ASSERT(ret < 0,
10543 "Session creation succeeded unexpectedly");
10546 /* Setup HMAC Parameters */
10547 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10548 ut_params->auth_xform.next = NULL;
10550 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10551 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10553 ut_params->sess = rte_cryptodev_sym_session_create(
10554 ts_params->session_mpool);
10556 /* Create Crypto session*/
10557 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10558 ut_params->sess, &ut_params->auth_xform,
10559 ts_params->session_priv_mpool);
10560 TEST_ASSERT(ret < 0,
10561 "Session creation succeeded unexpectedly");
10563 return TEST_SUCCESS;
10567 #define NULL_BURST_LENGTH (32)
10570 test_null_burst_operation(void)
10572 struct crypto_testsuite_params *ts_params = &testsuite_params;
10573 struct crypto_unittest_params *ut_params = &unittest_params;
10575 unsigned i, burst_len = NULL_BURST_LENGTH;
10577 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10578 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10580 /* This test is for NULL PMD only */
10581 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10582 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10585 /* Setup Cipher Parameters */
10586 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10587 ut_params->cipher_xform.next = &ut_params->auth_xform;
10589 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10590 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10592 /* Setup HMAC Parameters */
10593 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10594 ut_params->auth_xform.next = NULL;
10596 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10597 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10599 ut_params->sess = rte_cryptodev_sym_session_create(
10600 ts_params->session_mpool);
10602 /* Create Crypto session*/
10603 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10604 ut_params->sess, &ut_params->cipher_xform,
10605 ts_params->session_priv_mpool);
10606 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10608 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10609 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10610 burst_len, "failed to generate burst of crypto ops");
10612 /* Generate an operation for each mbuf in burst */
10613 for (i = 0; i < burst_len; i++) {
10614 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10616 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10618 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10622 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10624 burst[i]->sym->m_src = m;
10627 /* Process crypto operation */
10628 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10629 0, burst, burst_len),
10631 "Error enqueuing burst");
10633 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10634 0, burst_dequeued, burst_len),
10636 "Error dequeuing burst");
10639 for (i = 0; i < burst_len; i++) {
10641 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10642 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10644 "data not as expected");
10646 rte_pktmbuf_free(burst[i]->sym->m_src);
10647 rte_crypto_op_free(burst[i]);
10650 return TEST_SUCCESS;
10654 generate_gmac_large_plaintext(uint8_t *data)
10658 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10659 memcpy(&data[i], &data[0], 32);
10663 create_gmac_operation(enum rte_crypto_auth_operation op,
10664 const struct gmac_test_data *tdata)
10666 struct crypto_testsuite_params *ts_params = &testsuite_params;
10667 struct crypto_unittest_params *ut_params = &unittest_params;
10668 struct rte_crypto_sym_op *sym_op;
10670 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10672 /* Generate Crypto op data structure */
10673 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10674 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10675 TEST_ASSERT_NOT_NULL(ut_params->op,
10676 "Failed to allocate symmetric crypto operation struct");
10678 sym_op = ut_params->op->sym;
10680 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10681 ut_params->ibuf, tdata->gmac_tag.len);
10682 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10683 "no room to append digest");
10685 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10686 ut_params->ibuf, plaintext_pad_len);
10688 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10689 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10690 tdata->gmac_tag.len);
10691 debug_hexdump(stdout, "digest:",
10692 sym_op->auth.digest.data,
10693 tdata->gmac_tag.len);
10696 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10697 uint8_t *, IV_OFFSET);
10699 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10701 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10703 sym_op->cipher.data.length = 0;
10704 sym_op->cipher.data.offset = 0;
10706 sym_op->auth.data.offset = 0;
10707 sym_op->auth.data.length = tdata->plaintext.len;
10713 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
10714 const struct gmac_test_data *tdata,
10715 void *digest_mem, uint64_t digest_phys)
10717 struct crypto_testsuite_params *ts_params = &testsuite_params;
10718 struct crypto_unittest_params *ut_params = &unittest_params;
10719 struct rte_crypto_sym_op *sym_op;
10721 /* Generate Crypto op data structure */
10722 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10723 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10724 TEST_ASSERT_NOT_NULL(ut_params->op,
10725 "Failed to allocate symmetric crypto operation struct");
10727 sym_op = ut_params->op->sym;
10729 sym_op->auth.digest.data = digest_mem;
10730 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10731 "no room to append digest");
10733 sym_op->auth.digest.phys_addr = digest_phys;
10735 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10736 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10737 tdata->gmac_tag.len);
10738 debug_hexdump(stdout, "digest:",
10739 sym_op->auth.digest.data,
10740 tdata->gmac_tag.len);
10743 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10744 uint8_t *, IV_OFFSET);
10746 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10748 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10750 sym_op->cipher.data.length = 0;
10751 sym_op->cipher.data.offset = 0;
10753 sym_op->auth.data.offset = 0;
10754 sym_op->auth.data.length = tdata->plaintext.len;
10759 static int create_gmac_session(uint8_t dev_id,
10760 const struct gmac_test_data *tdata,
10761 enum rte_crypto_auth_operation auth_op)
10763 uint8_t auth_key[tdata->key.len];
10765 struct crypto_testsuite_params *ts_params = &testsuite_params;
10766 struct crypto_unittest_params *ut_params = &unittest_params;
10768 memcpy(auth_key, tdata->key.data, tdata->key.len);
10770 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10771 ut_params->auth_xform.next = NULL;
10773 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10774 ut_params->auth_xform.auth.op = auth_op;
10775 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10776 ut_params->auth_xform.auth.key.length = tdata->key.len;
10777 ut_params->auth_xform.auth.key.data = auth_key;
10778 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10779 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10782 ut_params->sess = rte_cryptodev_sym_session_create(
10783 ts_params->session_mpool);
10785 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10786 &ut_params->auth_xform,
10787 ts_params->session_priv_mpool);
10789 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10795 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10797 struct crypto_testsuite_params *ts_params = &testsuite_params;
10798 struct crypto_unittest_params *ut_params = &unittest_params;
10799 struct rte_cryptodev_info dev_info;
10801 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10802 uint64_t feat_flags = dev_info.feature_flags;
10804 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10805 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10806 printf("Device doesn't support RAW data-path APIs.\n");
10812 uint8_t *auth_tag, *plaintext;
10813 uint16_t plaintext_pad_len;
10815 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10816 "No GMAC length in the source data");
10818 /* Verify the capabilities */
10819 struct rte_cryptodev_sym_capability_idx cap_idx;
10820 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10821 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10822 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10826 retval = create_gmac_session(ts_params->valid_devs[0],
10827 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10832 if (tdata->plaintext.len > MBUF_SIZE)
10833 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10835 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10836 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10837 "Failed to allocate input buffer in mempool");
10839 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10840 rte_pktmbuf_tailroom(ut_params->ibuf));
10842 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10844 * Runtime generate the large plain text instead of use hard code
10845 * plain text vector. It is done to avoid create huge source file
10846 * with the test vector.
10848 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10849 generate_gmac_large_plaintext(tdata->plaintext.data);
10851 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10852 plaintext_pad_len);
10853 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10855 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10856 debug_hexdump(stdout, "plaintext:", plaintext,
10857 tdata->plaintext.len);
10859 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10865 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10867 ut_params->op->sym->m_src = ut_params->ibuf;
10869 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10870 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10872 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10873 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10874 ut_params->op, 0, 1, 0, 0);
10876 TEST_ASSERT_NOT_NULL(
10877 process_crypto_request(ts_params->valid_devs[0],
10878 ut_params->op), "failed to process sym crypto op");
10880 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10881 "crypto op processing failed");
10883 if (ut_params->op->sym->m_dst) {
10884 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10885 uint8_t *, plaintext_pad_len);
10887 auth_tag = plaintext + plaintext_pad_len;
10890 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10892 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10894 tdata->gmac_tag.data,
10895 tdata->gmac_tag.len,
10896 "GMAC Generated auth tag not as expected");
10902 test_AES_GMAC_authentication_test_case_1(void)
10904 return test_AES_GMAC_authentication(&gmac_test_case_1);
10908 test_AES_GMAC_authentication_test_case_2(void)
10910 return test_AES_GMAC_authentication(&gmac_test_case_2);
10914 test_AES_GMAC_authentication_test_case_3(void)
10916 return test_AES_GMAC_authentication(&gmac_test_case_3);
10920 test_AES_GMAC_authentication_test_case_4(void)
10922 return test_AES_GMAC_authentication(&gmac_test_case_4);
10926 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10928 struct crypto_testsuite_params *ts_params = &testsuite_params;
10929 struct crypto_unittest_params *ut_params = &unittest_params;
10931 uint32_t plaintext_pad_len;
10932 uint8_t *plaintext;
10933 struct rte_cryptodev_info dev_info;
10935 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10936 uint64_t feat_flags = dev_info.feature_flags;
10938 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10939 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10940 printf("Device doesn't support RAW data-path APIs.\n");
10944 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10945 "No GMAC length in the source data");
10947 /* Verify the capabilities */
10948 struct rte_cryptodev_sym_capability_idx cap_idx;
10949 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10950 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10951 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10955 retval = create_gmac_session(ts_params->valid_devs[0],
10956 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10961 if (tdata->plaintext.len > MBUF_SIZE)
10962 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10964 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10965 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10966 "Failed to allocate input buffer in mempool");
10968 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10969 rte_pktmbuf_tailroom(ut_params->ibuf));
10971 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10974 * Runtime generate the large plain text instead of use hard code
10975 * plain text vector. It is done to avoid create huge source file
10976 * with the test vector.
10978 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10979 generate_gmac_large_plaintext(tdata->plaintext.data);
10981 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10982 plaintext_pad_len);
10983 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10985 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10986 debug_hexdump(stdout, "plaintext:", plaintext,
10987 tdata->plaintext.len);
10989 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10995 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10997 ut_params->op->sym->m_src = ut_params->ibuf;
10999 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11000 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11002 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11003 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11004 ut_params->op, 0, 1, 0, 0);
11006 TEST_ASSERT_NOT_NULL(
11007 process_crypto_request(ts_params->valid_devs[0],
11008 ut_params->op), "failed to process sym crypto op");
11010 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11011 "crypto op processing failed");
11018 test_AES_GMAC_authentication_verify_test_case_1(void)
11020 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11024 test_AES_GMAC_authentication_verify_test_case_2(void)
11026 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11030 test_AES_GMAC_authentication_verify_test_case_3(void)
11032 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11036 test_AES_GMAC_authentication_verify_test_case_4(void)
11038 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11042 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11045 struct crypto_testsuite_params *ts_params = &testsuite_params;
11046 struct crypto_unittest_params *ut_params = &unittest_params;
11047 struct rte_cryptodev_info dev_info;
11048 uint64_t feature_flags;
11049 unsigned int trn_data = 0;
11050 void *digest_mem = NULL;
11052 unsigned int to_trn = 0;
11053 struct rte_mbuf *buf = NULL;
11054 uint8_t *auth_tag, *plaintext;
11057 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11058 "No GMAC length in the source data");
11060 /* Verify the capabilities */
11061 struct rte_cryptodev_sym_capability_idx cap_idx;
11062 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11063 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11064 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11068 /* Check for any input SGL support */
11069 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11070 feature_flags = dev_info.feature_flags;
11072 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) &&
11073 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) &&
11074 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11077 if (fragsz > tdata->plaintext.len)
11078 fragsz = tdata->plaintext.len;
11080 uint16_t plaintext_len = fragsz;
11082 retval = create_gmac_session(ts_params->valid_devs[0],
11083 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11088 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11089 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11090 "Failed to allocate input buffer in mempool");
11092 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11093 rte_pktmbuf_tailroom(ut_params->ibuf));
11095 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11097 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11099 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11101 trn_data += plaintext_len;
11103 buf = ut_params->ibuf;
11106 * Loop until no more fragments
11109 while (trn_data < tdata->plaintext.len) {
11111 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11112 (tdata->plaintext.len - trn_data) : fragsz;
11114 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11117 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11118 rte_pktmbuf_tailroom(buf));
11120 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11123 memcpy(plaintext, tdata->plaintext.data + trn_data,
11125 trn_data += to_trn;
11126 if (trn_data == tdata->plaintext.len)
11127 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11128 tdata->gmac_tag.len);
11130 ut_params->ibuf->nb_segs = segs;
11133 * Place digest at the end of the last buffer
11135 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11138 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11139 + tdata->gmac_tag.len);
11140 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11141 tdata->plaintext.len);
11144 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11145 tdata, digest_mem, digest_phys);
11150 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11152 ut_params->op->sym->m_src = ut_params->ibuf;
11154 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11157 TEST_ASSERT_NOT_NULL(
11158 process_crypto_request(ts_params->valid_devs[0],
11159 ut_params->op), "failed to process sym crypto op");
11161 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11162 "crypto op processing failed");
11164 auth_tag = digest_mem;
11165 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11166 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11168 tdata->gmac_tag.data,
11169 tdata->gmac_tag.len,
11170 "GMAC Generated auth tag not as expected");
11175 /* Segment size not multiple of block size (16B) */
11177 test_AES_GMAC_authentication_SGL_40B(void)
11179 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11183 test_AES_GMAC_authentication_SGL_80B(void)
11185 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11189 test_AES_GMAC_authentication_SGL_2048B(void)
11191 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11194 /* Segment size not multiple of block size (16B) */
11196 test_AES_GMAC_authentication_SGL_2047B(void)
11198 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11201 struct test_crypto_vector {
11202 enum rte_crypto_cipher_algorithm crypto_algo;
11203 unsigned int cipher_offset;
11204 unsigned int cipher_len;
11217 const uint8_t *data;
11222 const uint8_t *data;
11226 enum rte_crypto_auth_algorithm auth_algo;
11227 unsigned int auth_offset;
11235 const uint8_t *data;
11245 static const struct test_crypto_vector
11246 hmac_sha1_test_crypto_vector = {
11247 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11249 .data = plaintext_hash,
11254 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11255 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11256 0xDE, 0xF4, 0xDE, 0xAD
11262 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11263 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11264 0x3F, 0x91, 0x64, 0x59
11270 static const struct test_crypto_vector
11271 aes128_gmac_test_vector = {
11272 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11274 .data = plaintext_hash,
11279 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11280 0x08, 0x09, 0x0A, 0x0B
11286 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11287 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11293 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11294 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11300 static const struct test_crypto_vector
11301 aes128cbc_hmac_sha1_test_vector = {
11302 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11303 .cipher_offset = 0,
11307 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11308 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11314 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11315 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11320 .data = plaintext_hash,
11324 .data = ciphertext512_aes128cbc,
11327 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11331 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11332 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11333 0xDE, 0xF4, 0xDE, 0xAD
11339 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
11340 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11341 0x18, 0x8C, 0x1D, 0x32
11347 static const struct test_crypto_vector
11348 aes128cbc_hmac_sha1_aad_test_vector = {
11349 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11350 .cipher_offset = 8,
11354 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11355 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11361 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11362 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11367 .data = plaintext_hash,
11371 .data = ciphertext512_aes128cbc_aad,
11374 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11378 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11379 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11380 0xDE, 0xF4, 0xDE, 0xAD
11386 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
11387 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
11388 0x62, 0x0F, 0xFB, 0x10
11395 data_corruption(uint8_t *data)
11401 tag_corruption(uint8_t *data, unsigned int tag_offset)
11403 data[tag_offset] += 1;
11407 create_auth_session(struct crypto_unittest_params *ut_params,
11409 const struct test_crypto_vector *reference,
11410 enum rte_crypto_auth_operation auth_op)
11412 struct crypto_testsuite_params *ts_params = &testsuite_params;
11413 uint8_t auth_key[reference->auth_key.len + 1];
11415 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11417 /* Setup Authentication Parameters */
11418 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11419 ut_params->auth_xform.auth.op = auth_op;
11420 ut_params->auth_xform.next = NULL;
11421 ut_params->auth_xform.auth.algo = reference->auth_algo;
11422 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11423 ut_params->auth_xform.auth.key.data = auth_key;
11424 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11426 /* Create Crypto session*/
11427 ut_params->sess = rte_cryptodev_sym_session_create(
11428 ts_params->session_mpool);
11430 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11431 &ut_params->auth_xform,
11432 ts_params->session_priv_mpool);
11434 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11440 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
11442 const struct test_crypto_vector *reference,
11443 enum rte_crypto_auth_operation auth_op,
11444 enum rte_crypto_cipher_operation cipher_op)
11446 struct crypto_testsuite_params *ts_params = &testsuite_params;
11447 uint8_t cipher_key[reference->cipher_key.len + 1];
11448 uint8_t auth_key[reference->auth_key.len + 1];
11450 memcpy(cipher_key, reference->cipher_key.data,
11451 reference->cipher_key.len);
11452 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11454 /* Setup Authentication Parameters */
11455 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11456 ut_params->auth_xform.auth.op = auth_op;
11457 ut_params->auth_xform.auth.algo = reference->auth_algo;
11458 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11459 ut_params->auth_xform.auth.key.data = auth_key;
11460 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11462 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
11463 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11464 ut_params->auth_xform.auth.iv.length = reference->iv.len;
11466 ut_params->auth_xform.next = &ut_params->cipher_xform;
11468 /* Setup Cipher Parameters */
11469 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11470 ut_params->cipher_xform.next = NULL;
11471 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11472 ut_params->cipher_xform.cipher.op = cipher_op;
11473 ut_params->cipher_xform.cipher.key.data = cipher_key;
11474 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11475 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11476 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11479 /* Create Crypto session*/
11480 ut_params->sess = rte_cryptodev_sym_session_create(
11481 ts_params->session_mpool);
11483 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11484 &ut_params->auth_xform,
11485 ts_params->session_priv_mpool);
11487 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11493 create_auth_operation(struct crypto_testsuite_params *ts_params,
11494 struct crypto_unittest_params *ut_params,
11495 const struct test_crypto_vector *reference,
11496 unsigned int auth_generate)
11498 /* Generate Crypto op data structure */
11499 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11500 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11501 TEST_ASSERT_NOT_NULL(ut_params->op,
11502 "Failed to allocate pktmbuf offload");
11504 /* Set crypto operation data parameters */
11505 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11507 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11509 /* set crypto operation source mbuf */
11510 sym_op->m_src = ut_params->ibuf;
11513 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11514 ut_params->ibuf, reference->digest.len);
11516 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11517 "no room to append auth tag");
11519 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11520 ut_params->ibuf, reference->plaintext.len);
11523 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11525 memcpy(sym_op->auth.digest.data,
11526 reference->digest.data,
11527 reference->digest.len);
11529 debug_hexdump(stdout, "digest:",
11530 sym_op->auth.digest.data,
11531 reference->digest.len);
11533 sym_op->auth.data.length = reference->plaintext.len;
11534 sym_op->auth.data.offset = 0;
11540 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
11541 struct crypto_unittest_params *ut_params,
11542 const struct test_crypto_vector *reference,
11543 unsigned int auth_generate)
11545 /* Generate Crypto op data structure */
11546 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11547 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11548 TEST_ASSERT_NOT_NULL(ut_params->op,
11549 "Failed to allocate pktmbuf offload");
11551 /* Set crypto operation data parameters */
11552 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11554 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11556 /* set crypto operation source mbuf */
11557 sym_op->m_src = ut_params->ibuf;
11560 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11561 ut_params->ibuf, reference->digest.len);
11563 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11564 "no room to append auth tag");
11566 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11567 ut_params->ibuf, reference->ciphertext.len);
11570 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11572 memcpy(sym_op->auth.digest.data,
11573 reference->digest.data,
11574 reference->digest.len);
11576 debug_hexdump(stdout, "digest:",
11577 sym_op->auth.digest.data,
11578 reference->digest.len);
11580 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11581 reference->iv.data, reference->iv.len);
11583 sym_op->cipher.data.length = 0;
11584 sym_op->cipher.data.offset = 0;
11586 sym_op->auth.data.length = reference->plaintext.len;
11587 sym_op->auth.data.offset = 0;
11593 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11594 struct crypto_unittest_params *ut_params,
11595 const struct test_crypto_vector *reference,
11596 unsigned int auth_generate)
11598 /* Generate Crypto op data structure */
11599 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11600 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11601 TEST_ASSERT_NOT_NULL(ut_params->op,
11602 "Failed to allocate pktmbuf offload");
11604 /* Set crypto operation data parameters */
11605 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11607 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11609 /* set crypto operation source mbuf */
11610 sym_op->m_src = ut_params->ibuf;
11613 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11614 ut_params->ibuf, reference->digest.len);
11616 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11617 "no room to append auth tag");
11619 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11620 ut_params->ibuf, reference->ciphertext.len);
11623 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11625 memcpy(sym_op->auth.digest.data,
11626 reference->digest.data,
11627 reference->digest.len);
11629 debug_hexdump(stdout, "digest:",
11630 sym_op->auth.digest.data,
11631 reference->digest.len);
11633 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11634 reference->iv.data, reference->iv.len);
11636 sym_op->cipher.data.length = reference->cipher_len;
11637 sym_op->cipher.data.offset = reference->cipher_offset;
11639 sym_op->auth.data.length = reference->plaintext.len;
11640 sym_op->auth.data.offset = reference->auth_offset;
11646 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11647 struct crypto_unittest_params *ut_params,
11648 const struct test_crypto_vector *reference)
11650 return create_auth_operation(ts_params, ut_params, reference, 0);
11654 create_auth_verify_GMAC_operation(
11655 struct crypto_testsuite_params *ts_params,
11656 struct crypto_unittest_params *ut_params,
11657 const struct test_crypto_vector *reference)
11659 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11663 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11664 struct crypto_unittest_params *ut_params,
11665 const struct test_crypto_vector *reference)
11667 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11671 test_authentication_verify_fail_when_data_corruption(
11672 struct crypto_testsuite_params *ts_params,
11673 struct crypto_unittest_params *ut_params,
11674 const struct test_crypto_vector *reference,
11675 unsigned int data_corrupted)
11679 uint8_t *plaintext;
11680 struct rte_cryptodev_info dev_info;
11682 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11683 uint64_t feat_flags = dev_info.feature_flags;
11685 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11686 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11687 printf("Device doesn't support RAW data-path APIs.\n");
11691 /* Verify the capabilities */
11692 struct rte_cryptodev_sym_capability_idx cap_idx;
11693 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11694 cap_idx.algo.auth = reference->auth_algo;
11695 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11700 /* Create session */
11701 retval = create_auth_session(ut_params,
11702 ts_params->valid_devs[0],
11704 RTE_CRYPTO_AUTH_OP_VERIFY);
11708 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11709 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11710 "Failed to allocate input buffer in mempool");
11712 /* clear mbuf payload */
11713 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11714 rte_pktmbuf_tailroom(ut_params->ibuf));
11716 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11717 reference->plaintext.len);
11718 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11719 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11721 debug_hexdump(stdout, "plaintext:", plaintext,
11722 reference->plaintext.len);
11724 /* Create operation */
11725 retval = create_auth_verify_operation(ts_params, ut_params, reference);
11730 if (data_corrupted)
11731 data_corruption(plaintext);
11733 tag_corruption(plaintext, reference->plaintext.len);
11735 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11736 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11738 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11739 RTE_CRYPTO_OP_STATUS_SUCCESS,
11740 "authentication not failed");
11741 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11742 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11743 ut_params->op, 0, 1, 0, 0);
11745 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11747 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11754 test_authentication_verify_GMAC_fail_when_corruption(
11755 struct crypto_testsuite_params *ts_params,
11756 struct crypto_unittest_params *ut_params,
11757 const struct test_crypto_vector *reference,
11758 unsigned int data_corrupted)
11761 uint8_t *plaintext;
11762 struct rte_cryptodev_info dev_info;
11764 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11765 uint64_t feat_flags = dev_info.feature_flags;
11767 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11768 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11769 printf("Device doesn't support RAW data-path APIs.\n");
11773 /* Verify the capabilities */
11774 struct rte_cryptodev_sym_capability_idx cap_idx;
11775 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11776 cap_idx.algo.auth = reference->auth_algo;
11777 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11781 /* Create session */
11782 retval = create_auth_cipher_session(ut_params,
11783 ts_params->valid_devs[0],
11785 RTE_CRYPTO_AUTH_OP_VERIFY,
11786 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11790 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11791 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11792 "Failed to allocate input buffer in mempool");
11794 /* clear mbuf payload */
11795 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11796 rte_pktmbuf_tailroom(ut_params->ibuf));
11798 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11799 reference->plaintext.len);
11800 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11801 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11803 debug_hexdump(stdout, "plaintext:", plaintext,
11804 reference->plaintext.len);
11806 /* Create operation */
11807 retval = create_auth_verify_GMAC_operation(ts_params,
11814 if (data_corrupted)
11815 data_corruption(plaintext);
11817 tag_corruption(plaintext, reference->aad.len);
11819 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11820 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11822 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11823 RTE_CRYPTO_OP_STATUS_SUCCESS,
11824 "authentication not failed");
11825 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11826 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11827 ut_params->op, 0, 1, 0, 0);
11829 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11831 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11838 test_authenticated_decryption_fail_when_corruption(
11839 struct crypto_testsuite_params *ts_params,
11840 struct crypto_unittest_params *ut_params,
11841 const struct test_crypto_vector *reference,
11842 unsigned int data_corrupted)
11846 uint8_t *ciphertext;
11847 struct rte_cryptodev_info dev_info;
11849 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11850 uint64_t feat_flags = dev_info.feature_flags;
11852 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11853 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11854 printf("Device doesn't support RAW data-path APIs.\n");
11858 /* Verify the capabilities */
11859 struct rte_cryptodev_sym_capability_idx cap_idx;
11860 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11861 cap_idx.algo.auth = reference->auth_algo;
11862 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11865 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11866 cap_idx.algo.cipher = reference->crypto_algo;
11867 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11871 /* Create session */
11872 retval = create_auth_cipher_session(ut_params,
11873 ts_params->valid_devs[0],
11875 RTE_CRYPTO_AUTH_OP_VERIFY,
11876 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11880 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11881 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11882 "Failed to allocate input buffer in mempool");
11884 /* clear mbuf payload */
11885 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11886 rte_pktmbuf_tailroom(ut_params->ibuf));
11888 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11889 reference->ciphertext.len);
11890 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11891 memcpy(ciphertext, reference->ciphertext.data,
11892 reference->ciphertext.len);
11894 /* Create operation */
11895 retval = create_cipher_auth_verify_operation(ts_params,
11902 if (data_corrupted)
11903 data_corruption(ciphertext);
11905 tag_corruption(ciphertext, reference->ciphertext.len);
11907 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11908 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11910 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11911 RTE_CRYPTO_OP_STATUS_SUCCESS,
11912 "authentication not failed");
11913 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11914 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11915 ut_params->op, 1, 1, 0, 0);
11917 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11919 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11926 test_authenticated_encryt_with_esn(
11927 struct crypto_testsuite_params *ts_params,
11928 struct crypto_unittest_params *ut_params,
11929 const struct test_crypto_vector *reference)
11933 uint8_t *authciphertext, *plaintext, *auth_tag;
11934 uint16_t plaintext_pad_len;
11935 uint8_t cipher_key[reference->cipher_key.len + 1];
11936 uint8_t auth_key[reference->auth_key.len + 1];
11937 struct rte_cryptodev_info dev_info;
11939 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11940 uint64_t feat_flags = dev_info.feature_flags;
11942 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11943 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11944 printf("Device doesn't support RAW data-path APIs.\n");
11948 /* Verify the capabilities */
11949 struct rte_cryptodev_sym_capability_idx cap_idx;
11950 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11951 cap_idx.algo.auth = reference->auth_algo;
11952 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11955 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11956 cap_idx.algo.cipher = reference->crypto_algo;
11957 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11961 /* Create session */
11962 memcpy(cipher_key, reference->cipher_key.data,
11963 reference->cipher_key.len);
11964 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11966 /* Setup Cipher Parameters */
11967 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11968 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11969 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11970 ut_params->cipher_xform.cipher.key.data = cipher_key;
11971 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11972 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11973 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11975 ut_params->cipher_xform.next = &ut_params->auth_xform;
11977 /* Setup Authentication Parameters */
11978 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11979 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11980 ut_params->auth_xform.auth.algo = reference->auth_algo;
11981 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11982 ut_params->auth_xform.auth.key.data = auth_key;
11983 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11984 ut_params->auth_xform.next = NULL;
11986 /* Create Crypto session*/
11987 ut_params->sess = rte_cryptodev_sym_session_create(
11988 ts_params->session_mpool);
11990 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11992 &ut_params->cipher_xform,
11993 ts_params->session_priv_mpool);
11995 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11998 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11999 "Failed to allocate input buffer in mempool");
12001 /* clear mbuf payload */
12002 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12003 rte_pktmbuf_tailroom(ut_params->ibuf));
12005 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12006 reference->plaintext.len);
12007 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12008 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12010 /* Create operation */
12011 retval = create_cipher_auth_operation(ts_params,
12018 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12019 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12021 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12022 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12023 ut_params->op, 1, 1, 0, 0);
12025 ut_params->op = process_crypto_request(
12026 ts_params->valid_devs[0], ut_params->op);
12028 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12030 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12031 "crypto op processing failed");
12033 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12035 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12036 ut_params->op->sym->auth.data.offset);
12037 auth_tag = authciphertext + plaintext_pad_len;
12038 debug_hexdump(stdout, "ciphertext:", authciphertext,
12039 reference->ciphertext.len);
12040 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12042 /* Validate obuf */
12043 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12045 reference->ciphertext.data,
12046 reference->ciphertext.len,
12047 "Ciphertext data not as expected");
12049 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12051 reference->digest.data,
12052 reference->digest.len,
12053 "Generated digest not as expected");
12055 return TEST_SUCCESS;
12060 test_authenticated_decrypt_with_esn(
12061 struct crypto_testsuite_params *ts_params,
12062 struct crypto_unittest_params *ut_params,
12063 const struct test_crypto_vector *reference)
12067 uint8_t *ciphertext;
12068 uint8_t cipher_key[reference->cipher_key.len + 1];
12069 uint8_t auth_key[reference->auth_key.len + 1];
12070 struct rte_cryptodev_info dev_info;
12072 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12073 uint64_t feat_flags = dev_info.feature_flags;
12075 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12076 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12077 printf("Device doesn't support RAW data-path APIs.\n");
12081 /* Verify the capabilities */
12082 struct rte_cryptodev_sym_capability_idx cap_idx;
12083 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12084 cap_idx.algo.auth = reference->auth_algo;
12085 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12088 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12089 cap_idx.algo.cipher = reference->crypto_algo;
12090 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12094 /* Create session */
12095 memcpy(cipher_key, reference->cipher_key.data,
12096 reference->cipher_key.len);
12097 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12099 /* Setup Authentication Parameters */
12100 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12101 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12102 ut_params->auth_xform.auth.algo = reference->auth_algo;
12103 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12104 ut_params->auth_xform.auth.key.data = auth_key;
12105 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12106 ut_params->auth_xform.next = &ut_params->cipher_xform;
12108 /* Setup Cipher Parameters */
12109 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12110 ut_params->cipher_xform.next = NULL;
12111 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12112 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12113 ut_params->cipher_xform.cipher.key.data = cipher_key;
12114 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12115 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12116 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12118 /* Create Crypto session*/
12119 ut_params->sess = rte_cryptodev_sym_session_create(
12120 ts_params->session_mpool);
12122 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12124 &ut_params->auth_xform,
12125 ts_params->session_priv_mpool);
12127 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12129 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12130 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12131 "Failed to allocate input buffer in mempool");
12133 /* clear mbuf payload */
12134 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12135 rte_pktmbuf_tailroom(ut_params->ibuf));
12137 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12138 reference->ciphertext.len);
12139 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12140 memcpy(ciphertext, reference->ciphertext.data,
12141 reference->ciphertext.len);
12143 /* Create operation */
12144 retval = create_cipher_auth_verify_operation(ts_params,
12151 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12152 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12154 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12155 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12156 ut_params->op, 1, 1, 0, 0);
12158 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12161 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12162 TEST_ASSERT_EQUAL(ut_params->op->status,
12163 RTE_CRYPTO_OP_STATUS_SUCCESS,
12164 "crypto op processing passed");
12166 ut_params->obuf = ut_params->op->sym->m_src;
12167 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12173 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12174 const struct aead_test_data *tdata,
12175 void *digest_mem, uint64_t digest_phys)
12177 struct crypto_testsuite_params *ts_params = &testsuite_params;
12178 struct crypto_unittest_params *ut_params = &unittest_params;
12180 const unsigned int auth_tag_len = tdata->auth_tag.len;
12181 const unsigned int iv_len = tdata->iv.len;
12182 unsigned int aad_len = tdata->aad.len;
12183 unsigned int aad_len_pad = 0;
12185 /* Generate Crypto op data structure */
12186 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12187 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12188 TEST_ASSERT_NOT_NULL(ut_params->op,
12189 "Failed to allocate symmetric crypto operation struct");
12191 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12193 sym_op->aead.digest.data = digest_mem;
12195 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12196 "no room to append digest");
12198 sym_op->aead.digest.phys_addr = digest_phys;
12200 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12201 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12203 debug_hexdump(stdout, "digest:",
12204 sym_op->aead.digest.data,
12208 /* Append aad data */
12209 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12210 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12211 uint8_t *, IV_OFFSET);
12213 /* Copy IV 1 byte after the IV pointer, according to the API */
12214 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12216 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12218 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12219 ut_params->ibuf, aad_len);
12220 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12221 "no room to prepend aad");
12222 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12225 memset(sym_op->aead.aad.data, 0, aad_len);
12226 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12227 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12229 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12230 debug_hexdump(stdout, "aad:",
12231 sym_op->aead.aad.data, aad_len);
12233 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12234 uint8_t *, IV_OFFSET);
12236 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12238 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12240 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12241 ut_params->ibuf, aad_len_pad);
12242 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12243 "no room to prepend aad");
12244 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12247 memset(sym_op->aead.aad.data, 0, aad_len);
12248 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12250 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12251 debug_hexdump(stdout, "aad:",
12252 sym_op->aead.aad.data, aad_len);
12255 sym_op->aead.data.length = tdata->plaintext.len;
12256 sym_op->aead.data.offset = aad_len_pad;
12261 #define SGL_MAX_NO 16
12264 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12265 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12267 struct crypto_testsuite_params *ts_params = &testsuite_params;
12268 struct crypto_unittest_params *ut_params = &unittest_params;
12269 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12272 int to_trn_tbl[SGL_MAX_NO];
12274 unsigned int trn_data = 0;
12275 uint8_t *plaintext, *ciphertext, *auth_tag;
12276 struct rte_cryptodev_info dev_info;
12278 /* Verify the capabilities */
12279 struct rte_cryptodev_sym_capability_idx cap_idx;
12280 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12281 cap_idx.algo.aead = tdata->algo;
12282 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12286 /* OOP not supported with CPU crypto */
12287 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12290 /* Detailed check for the particular SGL support flag */
12291 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12293 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12294 if (sgl_in && (!(dev_info.feature_flags &
12295 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12298 uint64_t feat_flags = dev_info.feature_flags;
12300 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12301 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12302 printf("Device doesn't support RAW data-path APIs.\n");
12306 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12307 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12308 tdata->plaintext.len;
12309 /* Raw data path API does not support OOP */
12310 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12312 if (sgl_in && !sgl_out) {
12313 if (!(dev_info.feature_flags &
12314 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12316 } else if (!sgl_in && sgl_out) {
12317 if (!(dev_info.feature_flags &
12318 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12320 } else if (sgl_in && sgl_out) {
12321 if (!(dev_info.feature_flags &
12322 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12327 if (fragsz > tdata->plaintext.len)
12328 fragsz = tdata->plaintext.len;
12330 uint16_t plaintext_len = fragsz;
12331 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
12333 if (fragsz_oop > tdata->plaintext.len)
12334 frag_size_oop = tdata->plaintext.len;
12337 void *digest_mem = NULL;
12339 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
12341 if (tdata->plaintext.len % fragsz != 0) {
12342 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
12345 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
12350 * For out-op-place we need to alloc another mbuf
12353 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12354 rte_pktmbuf_append(ut_params->obuf,
12355 frag_size_oop + prepend_len);
12356 buf_oop = ut_params->obuf;
12359 /* Create AEAD session */
12360 retval = create_aead_session(ts_params->valid_devs[0],
12362 RTE_CRYPTO_AEAD_OP_ENCRYPT,
12363 tdata->key.data, tdata->key.len,
12364 tdata->aad.len, tdata->auth_tag.len,
12369 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12371 /* clear mbuf payload */
12372 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12373 rte_pktmbuf_tailroom(ut_params->ibuf));
12375 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12378 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12380 trn_data += plaintext_len;
12382 buf = ut_params->ibuf;
12385 * Loop until no more fragments
12388 while (trn_data < tdata->plaintext.len) {
12390 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12391 (tdata->plaintext.len - trn_data) : fragsz;
12393 to_trn_tbl[ecx++] = to_trn;
12395 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12398 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12399 rte_pktmbuf_tailroom(buf));
12402 if (oop && !fragsz_oop) {
12403 buf_last_oop = buf_oop->next =
12404 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12405 buf_oop = buf_oop->next;
12406 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12407 0, rte_pktmbuf_tailroom(buf_oop));
12408 rte_pktmbuf_append(buf_oop, to_trn);
12411 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12414 memcpy(plaintext, tdata->plaintext.data + trn_data,
12416 trn_data += to_trn;
12417 if (trn_data == tdata->plaintext.len) {
12420 digest_mem = rte_pktmbuf_append(buf_oop,
12421 tdata->auth_tag.len);
12423 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12424 tdata->auth_tag.len);
12428 uint64_t digest_phys = 0;
12430 ut_params->ibuf->nb_segs = segs;
12433 if (fragsz_oop && oop) {
12437 if (frag_size_oop == tdata->plaintext.len) {
12438 digest_mem = rte_pktmbuf_append(ut_params->obuf,
12439 tdata->auth_tag.len);
12441 digest_phys = rte_pktmbuf_iova_offset(
12443 tdata->plaintext.len + prepend_len);
12446 trn_data = frag_size_oop;
12447 while (trn_data < tdata->plaintext.len) {
12450 (tdata->plaintext.len - trn_data <
12452 (tdata->plaintext.len - trn_data) :
12455 to_trn_tbl[ecx++] = to_trn;
12457 buf_last_oop = buf_oop->next =
12458 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12459 buf_oop = buf_oop->next;
12460 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12461 0, rte_pktmbuf_tailroom(buf_oop));
12462 rte_pktmbuf_append(buf_oop, to_trn);
12464 trn_data += to_trn;
12466 if (trn_data == tdata->plaintext.len) {
12467 digest_mem = rte_pktmbuf_append(buf_oop,
12468 tdata->auth_tag.len);
12472 ut_params->obuf->nb_segs = segs;
12476 * Place digest at the end of the last buffer
12479 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12480 if (oop && buf_last_oop)
12481 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
12483 if (!digest_mem && !oop) {
12484 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12485 + tdata->auth_tag.len);
12486 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12487 tdata->plaintext.len);
12490 /* Create AEAD operation */
12491 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
12492 tdata, digest_mem, digest_phys);
12497 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12499 ut_params->op->sym->m_src = ut_params->ibuf;
12501 ut_params->op->sym->m_dst = ut_params->obuf;
12503 /* Process crypto operation */
12504 if (oop == IN_PLACE &&
12505 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12506 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12507 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12508 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12509 ut_params->op, 0, 0, 0, 0);
12511 TEST_ASSERT_NOT_NULL(
12512 process_crypto_request(ts_params->valid_devs[0],
12513 ut_params->op), "failed to process sym crypto op");
12515 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12516 "crypto op processing failed");
12519 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12520 uint8_t *, prepend_len);
12522 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12523 uint8_t *, prepend_len);
12527 fragsz = fragsz_oop;
12529 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12531 tdata->ciphertext.data,
12533 "Ciphertext data not as expected");
12535 buf = ut_params->op->sym->m_src->next;
12537 buf = ut_params->op->sym->m_dst->next;
12539 unsigned int off = fragsz;
12543 ciphertext = rte_pktmbuf_mtod(buf,
12546 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12548 tdata->ciphertext.data + off,
12550 "Ciphertext data not as expected");
12552 off += to_trn_tbl[ecx++];
12556 auth_tag = digest_mem;
12557 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12559 tdata->auth_tag.data,
12560 tdata->auth_tag.len,
12561 "Generated auth tag not as expected");
12567 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
12569 return test_authenticated_encryption_SGL(
12570 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
12574 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
12576 return test_authenticated_encryption_SGL(
12577 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
12581 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
12583 return test_authenticated_encryption_SGL(
12584 &gcm_test_case_8, OUT_OF_PLACE, 400,
12585 gcm_test_case_8.plaintext.len);
12589 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
12591 /* This test is not for OPENSSL PMD */
12592 if (gbl_driver_id == rte_cryptodev_driver_id_get(
12593 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
12596 return test_authenticated_encryption_SGL(
12597 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
12601 test_authentication_verify_fail_when_data_corrupted(
12602 struct crypto_testsuite_params *ts_params,
12603 struct crypto_unittest_params *ut_params,
12604 const struct test_crypto_vector *reference)
12606 return test_authentication_verify_fail_when_data_corruption(
12607 ts_params, ut_params, reference, 1);
12611 test_authentication_verify_fail_when_tag_corrupted(
12612 struct crypto_testsuite_params *ts_params,
12613 struct crypto_unittest_params *ut_params,
12614 const struct test_crypto_vector *reference)
12616 return test_authentication_verify_fail_when_data_corruption(
12617 ts_params, ut_params, reference, 0);
12621 test_authentication_verify_GMAC_fail_when_data_corrupted(
12622 struct crypto_testsuite_params *ts_params,
12623 struct crypto_unittest_params *ut_params,
12624 const struct test_crypto_vector *reference)
12626 return test_authentication_verify_GMAC_fail_when_corruption(
12627 ts_params, ut_params, reference, 1);
12631 test_authentication_verify_GMAC_fail_when_tag_corrupted(
12632 struct crypto_testsuite_params *ts_params,
12633 struct crypto_unittest_params *ut_params,
12634 const struct test_crypto_vector *reference)
12636 return test_authentication_verify_GMAC_fail_when_corruption(
12637 ts_params, ut_params, reference, 0);
12641 test_authenticated_decryption_fail_when_data_corrupted(
12642 struct crypto_testsuite_params *ts_params,
12643 struct crypto_unittest_params *ut_params,
12644 const struct test_crypto_vector *reference)
12646 return test_authenticated_decryption_fail_when_corruption(
12647 ts_params, ut_params, reference, 1);
12651 test_authenticated_decryption_fail_when_tag_corrupted(
12652 struct crypto_testsuite_params *ts_params,
12653 struct crypto_unittest_params *ut_params,
12654 const struct test_crypto_vector *reference)
12656 return test_authenticated_decryption_fail_when_corruption(
12657 ts_params, ut_params, reference, 0);
12661 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
12663 return test_authentication_verify_fail_when_data_corrupted(
12664 &testsuite_params, &unittest_params,
12665 &hmac_sha1_test_crypto_vector);
12669 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
12671 return test_authentication_verify_fail_when_tag_corrupted(
12672 &testsuite_params, &unittest_params,
12673 &hmac_sha1_test_crypto_vector);
12677 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
12679 return test_authentication_verify_GMAC_fail_when_data_corrupted(
12680 &testsuite_params, &unittest_params,
12681 &aes128_gmac_test_vector);
12685 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
12687 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
12688 &testsuite_params, &unittest_params,
12689 &aes128_gmac_test_vector);
12693 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
12695 return test_authenticated_decryption_fail_when_data_corrupted(
12698 &aes128cbc_hmac_sha1_test_vector);
12702 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
12704 return test_authenticated_decryption_fail_when_tag_corrupted(
12707 &aes128cbc_hmac_sha1_test_vector);
12711 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
12713 return test_authenticated_encryt_with_esn(
12716 &aes128cbc_hmac_sha1_aad_test_vector);
12720 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
12722 return test_authenticated_decrypt_with_esn(
12725 &aes128cbc_hmac_sha1_aad_test_vector);
12729 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
12731 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
12735 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
12737 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
12740 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12742 /* global AESNI worker IDs for the scheduler test */
12743 uint8_t aesni_ids[2];
12746 test_scheduler_attach_slave_op(void)
12748 struct crypto_testsuite_params *ts_params = &testsuite_params;
12749 uint8_t sched_id = ts_params->valid_devs[0];
12750 uint32_t nb_devs, i, nb_devs_attached = 0;
12752 char vdev_name[32];
12754 /* create 2 AESNI_MB if necessary */
12755 nb_devs = rte_cryptodev_device_count_by_driver(
12756 rte_cryptodev_driver_id_get(
12757 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
12759 for (i = nb_devs; i < 2; i++) {
12760 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
12761 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
12763 ret = rte_vdev_init(vdev_name, NULL);
12765 TEST_ASSERT(ret == 0,
12766 "Failed to create instance %u of"
12768 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12772 /* attach 2 AESNI_MB cdevs */
12773 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
12775 struct rte_cryptodev_info info;
12776 unsigned int session_size;
12778 rte_cryptodev_info_get(i, &info);
12779 if (info.driver_id != rte_cryptodev_driver_id_get(
12780 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
12783 session_size = rte_cryptodev_sym_get_private_session_size(i);
12785 * Create the session mempool again, since now there are new devices
12786 * to use the mempool.
12788 if (ts_params->session_mpool) {
12789 rte_mempool_free(ts_params->session_mpool);
12790 ts_params->session_mpool = NULL;
12792 if (ts_params->session_priv_mpool) {
12793 rte_mempool_free(ts_params->session_priv_mpool);
12794 ts_params->session_priv_mpool = NULL;
12797 if (info.sym.max_nb_sessions != 0 &&
12798 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
12799 RTE_LOG(ERR, USER1,
12800 "Device does not support "
12801 "at least %u sessions\n",
12803 return TEST_FAILED;
12806 * Create mempool with maximum number of sessions,
12807 * to include the session headers
12809 if (ts_params->session_mpool == NULL) {
12810 ts_params->session_mpool =
12811 rte_cryptodev_sym_session_pool_create(
12813 MAX_NB_SESSIONS, 0, 0, 0,
12815 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
12816 "session mempool allocation failed");
12820 * Create mempool with maximum number of sessions,
12821 * to include device specific session private data
12823 if (ts_params->session_priv_mpool == NULL) {
12824 ts_params->session_priv_mpool = rte_mempool_create(
12825 "test_sess_mp_priv",
12828 0, 0, NULL, NULL, NULL,
12829 NULL, SOCKET_ID_ANY,
12832 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
12833 "session mempool allocation failed");
12836 ts_params->qp_conf.mp_session = ts_params->session_mpool;
12837 ts_params->qp_conf.mp_session_private =
12838 ts_params->session_priv_mpool;
12840 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
12843 TEST_ASSERT(ret == 0,
12844 "Failed to attach device %u of pmd : %s", i,
12845 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12847 aesni_ids[nb_devs_attached] = (uint8_t)i;
12849 nb_devs_attached++;
12856 test_scheduler_detach_slave_op(void)
12858 struct crypto_testsuite_params *ts_params = &testsuite_params;
12859 uint8_t sched_id = ts_params->valid_devs[0];
12863 for (i = 0; i < 2; i++) {
12864 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
12866 TEST_ASSERT(ret == 0,
12867 "Failed to detach device %u", aesni_ids[i]);
12874 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
12876 struct crypto_testsuite_params *ts_params = &testsuite_params;
12877 uint8_t sched_id = ts_params->valid_devs[0];
12879 return rte_cryptodev_scheduler_mode_set(sched_id,
12884 test_scheduler_mode_roundrobin_op(void)
12886 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
12887 0, "Failed to set roundrobin mode");
12893 test_scheduler_mode_multicore_op(void)
12895 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
12896 0, "Failed to set multicore mode");
12902 test_scheduler_mode_failover_op(void)
12904 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
12905 0, "Failed to set failover mode");
12911 test_scheduler_mode_pkt_size_distr_op(void)
12913 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
12914 0, "Failed to set pktsize mode");
12919 static struct unit_test_suite cryptodev_scheduler_testsuite = {
12920 .suite_name = "Crypto Device Scheduler Unit Test Suite",
12921 .setup = testsuite_setup,
12922 .teardown = testsuite_teardown,
12923 .unit_test_cases = {
12925 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12926 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
12927 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12928 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12929 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12930 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12933 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12934 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
12935 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12936 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12937 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12938 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12941 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12942 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
12943 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12944 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12945 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12946 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12949 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12950 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
12951 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12952 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12953 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12954 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12956 TEST_CASES_END() /**< NULL terminate unit test array */
12960 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
12962 static struct unit_test_suite cryptodev_testsuite = {
12963 .suite_name = "Crypto Unit Test Suite",
12964 .setup = testsuite_setup,
12965 .teardown = testsuite_teardown,
12966 .unit_test_cases = {
12967 TEST_CASE_ST(ut_setup, ut_teardown,
12968 test_device_configure_invalid_dev_id),
12969 TEST_CASE_ST(ut_setup, ut_teardown,
12970 test_queue_pair_descriptor_setup),
12971 TEST_CASE_ST(ut_setup, ut_teardown,
12972 test_device_configure_invalid_queue_pair_ids),
12974 TEST_CASE_ST(ut_setup, ut_teardown,
12975 test_multi_session),
12976 TEST_CASE_ST(ut_setup, ut_teardown,
12977 test_multi_session_random_usage),
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 test_null_invalid_operation),
12981 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
12983 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12984 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12985 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12986 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12987 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
12988 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
12989 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
12990 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12991 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
12993 /** AES CCM Authenticated Encryption 128 bits key */
12994 TEST_CASE_ST(ut_setup, ut_teardown,
12995 test_AES_CCM_authenticated_encryption_test_case_128_1),
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_AES_CCM_authenticated_encryption_test_case_128_2),
12998 TEST_CASE_ST(ut_setup, ut_teardown,
12999 test_AES_CCM_authenticated_encryption_test_case_128_3),
13001 /** AES CCM Authenticated Decryption 128 bits key*/
13002 TEST_CASE_ST(ut_setup, ut_teardown,
13003 test_AES_CCM_authenticated_decryption_test_case_128_1),
13004 TEST_CASE_ST(ut_setup, ut_teardown,
13005 test_AES_CCM_authenticated_decryption_test_case_128_2),
13006 TEST_CASE_ST(ut_setup, ut_teardown,
13007 test_AES_CCM_authenticated_decryption_test_case_128_3),
13009 /** AES CCM Authenticated Encryption 192 bits key */
13010 TEST_CASE_ST(ut_setup, ut_teardown,
13011 test_AES_CCM_authenticated_encryption_test_case_192_1),
13012 TEST_CASE_ST(ut_setup, ut_teardown,
13013 test_AES_CCM_authenticated_encryption_test_case_192_2),
13014 TEST_CASE_ST(ut_setup, ut_teardown,
13015 test_AES_CCM_authenticated_encryption_test_case_192_3),
13017 /** AES CCM Authenticated Decryption 192 bits key*/
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 test_AES_CCM_authenticated_decryption_test_case_192_1),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 test_AES_CCM_authenticated_decryption_test_case_192_2),
13022 TEST_CASE_ST(ut_setup, ut_teardown,
13023 test_AES_CCM_authenticated_decryption_test_case_192_3),
13025 /** AES CCM Authenticated Encryption 256 bits key */
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 test_AES_CCM_authenticated_encryption_test_case_256_1),
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 test_AES_CCM_authenticated_encryption_test_case_256_2),
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_AES_CCM_authenticated_encryption_test_case_256_3),
13033 /** AES CCM Authenticated Decryption 256 bits key*/
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_AES_CCM_authenticated_decryption_test_case_256_1),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_CCM_authenticated_decryption_test_case_256_2),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_AES_CCM_authenticated_decryption_test_case_256_3),
13041 /** AES GCM Authenticated Encryption */
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_AES_GCM_authenticated_encryption_test_case_1),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_AES_GCM_authenticated_encryption_test_case_2),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_AES_GCM_authenticated_encryption_test_case_3),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_AES_GCM_authenticated_encryption_test_case_4),
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_AES_GCM_authenticated_encryption_test_case_5),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_AES_GCM_authenticated_encryption_test_case_6),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_AES_GCM_authenticated_encryption_test_case_7),
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_AES_GCM_authenticated_encryption_test_case_8),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13069 /** AES GCM Authenticated Decryption */
13070 TEST_CASE_ST(ut_setup, ut_teardown,
13071 test_AES_GCM_authenticated_decryption_test_case_1),
13072 TEST_CASE_ST(ut_setup, ut_teardown,
13073 test_AES_GCM_authenticated_decryption_test_case_2),
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_AES_GCM_authenticated_decryption_test_case_3),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_AES_GCM_authenticated_decryption_test_case_4),
13078 TEST_CASE_ST(ut_setup, ut_teardown,
13079 test_AES_GCM_authenticated_decryption_test_case_5),
13080 TEST_CASE_ST(ut_setup, ut_teardown,
13081 test_AES_GCM_authenticated_decryption_test_case_6),
13082 TEST_CASE_ST(ut_setup, ut_teardown,
13083 test_AES_GCM_authenticated_decryption_test_case_7),
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_AES_GCM_authenticated_decryption_test_case_8),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13089 /** AES GCM Authenticated Encryption 192 bits key */
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_AES_GCM_auth_encryption_test_case_192_1),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_AES_GCM_auth_encryption_test_case_192_2),
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_AES_GCM_auth_encryption_test_case_192_3),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_AES_GCM_auth_encryption_test_case_192_4),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_AES_GCM_auth_encryption_test_case_192_5),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_AES_GCM_auth_encryption_test_case_192_6),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_AES_GCM_auth_encryption_test_case_192_7),
13105 /** AES GCM Authenticated Decryption 192 bits key */
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_AES_GCM_auth_decryption_test_case_192_1),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_AES_GCM_auth_decryption_test_case_192_2),
13110 TEST_CASE_ST(ut_setup, ut_teardown,
13111 test_AES_GCM_auth_decryption_test_case_192_3),
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_AES_GCM_auth_decryption_test_case_192_4),
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_AES_GCM_auth_decryption_test_case_192_5),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_AES_GCM_auth_decryption_test_case_192_6),
13118 TEST_CASE_ST(ut_setup, ut_teardown,
13119 test_AES_GCM_auth_decryption_test_case_192_7),
13121 /** AES GCM Authenticated Encryption 256 bits key */
13122 TEST_CASE_ST(ut_setup, ut_teardown,
13123 test_AES_GCM_auth_encryption_test_case_256_1),
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 test_AES_GCM_auth_encryption_test_case_256_2),
13126 TEST_CASE_ST(ut_setup, ut_teardown,
13127 test_AES_GCM_auth_encryption_test_case_256_3),
13128 TEST_CASE_ST(ut_setup, ut_teardown,
13129 test_AES_GCM_auth_encryption_test_case_256_4),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_AES_GCM_auth_encryption_test_case_256_5),
13132 TEST_CASE_ST(ut_setup, ut_teardown,
13133 test_AES_GCM_auth_encryption_test_case_256_6),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_AES_GCM_auth_encryption_test_case_256_7),
13137 /** AES GCM Authenticated Decryption 256 bits key */
13138 TEST_CASE_ST(ut_setup, ut_teardown,
13139 test_AES_GCM_auth_decryption_test_case_256_1),
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_AES_GCM_auth_decryption_test_case_256_2),
13142 TEST_CASE_ST(ut_setup, ut_teardown,
13143 test_AES_GCM_auth_decryption_test_case_256_3),
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_AES_GCM_auth_decryption_test_case_256_4),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 test_AES_GCM_auth_decryption_test_case_256_5),
13148 TEST_CASE_ST(ut_setup, ut_teardown,
13149 test_AES_GCM_auth_decryption_test_case_256_6),
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 test_AES_GCM_auth_decryption_test_case_256_7),
13153 /** AES GCM Authenticated Encryption big aad size */
13154 TEST_CASE_ST(ut_setup, ut_teardown,
13155 test_AES_GCM_auth_encryption_test_case_aad_1),
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_AES_GCM_auth_encryption_test_case_aad_2),
13159 /** AES GCM Authenticated Decryption big aad size */
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_AES_GCM_auth_decryption_test_case_aad_1),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_AES_GCM_auth_decryption_test_case_aad_2),
13165 /** Out of place tests */
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13171 /** Session-less tests */
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13177 /** AES GMAC Authentication */
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_AES_GMAC_authentication_test_case_1),
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 test_AES_GMAC_authentication_verify_test_case_1),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_AES_GMAC_authentication_test_case_2),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_AES_GMAC_authentication_verify_test_case_2),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 test_AES_GMAC_authentication_test_case_3),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_AES_GMAC_authentication_verify_test_case_3),
13190 TEST_CASE_ST(ut_setup, ut_teardown,
13191 test_AES_GMAC_authentication_test_case_4),
13192 TEST_CASE_ST(ut_setup, ut_teardown,
13193 test_AES_GMAC_authentication_verify_test_case_4),
13194 TEST_CASE_ST(ut_setup, ut_teardown,
13195 test_AES_GMAC_authentication_SGL_40B),
13196 TEST_CASE_ST(ut_setup, ut_teardown,
13197 test_AES_GMAC_authentication_SGL_80B),
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 test_AES_GMAC_authentication_SGL_2048B),
13200 TEST_CASE_ST(ut_setup, ut_teardown,
13201 test_AES_GMAC_authentication_SGL_2047B),
13203 /** Chacha20-Poly1305 */
13204 TEST_CASE_ST(ut_setup, ut_teardown,
13205 test_chacha20_poly1305_encrypt_test_case_rfc8439),
13206 TEST_CASE_ST(ut_setup, ut_teardown,
13207 test_chacha20_poly1305_decrypt_test_case_rfc8439),
13208 /** SNOW 3G encrypt only (UEA2) */
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 test_snow3g_encryption_test_case_1),
13211 TEST_CASE_ST(ut_setup, ut_teardown,
13212 test_snow3g_encryption_test_case_2),
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 test_snow3g_encryption_test_case_3),
13215 TEST_CASE_ST(ut_setup, ut_teardown,
13216 test_snow3g_encryption_test_case_4),
13217 TEST_CASE_ST(ut_setup, ut_teardown,
13218 test_snow3g_encryption_test_case_5),
13220 TEST_CASE_ST(ut_setup, ut_teardown,
13221 test_snow3g_encryption_test_case_1_oop),
13222 TEST_CASE_ST(ut_setup, ut_teardown,
13223 test_snow3g_encryption_test_case_1_oop_sgl),
13224 TEST_CASE_ST(ut_setup, ut_teardown,
13225 test_snow3g_encryption_test_case_1_offset_oop),
13226 TEST_CASE_ST(ut_setup, ut_teardown,
13227 test_snow3g_decryption_test_case_1_oop),
13229 /** SNOW 3G generate auth, then encrypt (UEA2) */
13230 TEST_CASE_ST(ut_setup, ut_teardown,
13231 test_snow3g_auth_cipher_test_case_1),
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_snow3g_auth_cipher_test_case_2),
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_snow3g_auth_cipher_test_case_2_oop),
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_snow3g_auth_cipher_part_digest_enc),
13238 TEST_CASE_ST(ut_setup, ut_teardown,
13239 test_snow3g_auth_cipher_part_digest_enc_oop),
13240 TEST_CASE_ST(ut_setup, ut_teardown,
13241 test_snow3g_auth_cipher_test_case_3_sgl),
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_snow3g_auth_cipher_part_digest_enc_sgl),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13249 /** SNOW 3G decrypt (UEA2), then verify auth */
13250 TEST_CASE_ST(ut_setup, ut_teardown,
13251 test_snow3g_auth_cipher_verify_test_case_1),
13252 TEST_CASE_ST(ut_setup, ut_teardown,
13253 test_snow3g_auth_cipher_verify_test_case_2),
13254 TEST_CASE_ST(ut_setup, ut_teardown,
13255 test_snow3g_auth_cipher_verify_test_case_2_oop),
13256 TEST_CASE_ST(ut_setup, ut_teardown,
13257 test_snow3g_auth_cipher_verify_part_digest_enc),
13258 TEST_CASE_ST(ut_setup, ut_teardown,
13259 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13260 TEST_CASE_ST(ut_setup, ut_teardown,
13261 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13262 TEST_CASE_ST(ut_setup, ut_teardown,
13263 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13264 TEST_CASE_ST(ut_setup, ut_teardown,
13265 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13266 TEST_CASE_ST(ut_setup, ut_teardown,
13267 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13269 /** SNOW 3G decrypt only (UEA2) */
13270 TEST_CASE_ST(ut_setup, ut_teardown,
13271 test_snow3g_decryption_test_case_1),
13272 TEST_CASE_ST(ut_setup, ut_teardown,
13273 test_snow3g_decryption_test_case_2),
13274 TEST_CASE_ST(ut_setup, ut_teardown,
13275 test_snow3g_decryption_test_case_3),
13276 TEST_CASE_ST(ut_setup, ut_teardown,
13277 test_snow3g_decryption_test_case_4),
13278 TEST_CASE_ST(ut_setup, ut_teardown,
13279 test_snow3g_decryption_test_case_5),
13280 TEST_CASE_ST(ut_setup, ut_teardown,
13281 test_snow3g_decryption_with_digest_test_case_1),
13282 TEST_CASE_ST(ut_setup, ut_teardown,
13283 test_snow3g_hash_generate_test_case_1),
13284 TEST_CASE_ST(ut_setup, ut_teardown,
13285 test_snow3g_hash_generate_test_case_2),
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_snow3g_hash_generate_test_case_3),
13288 /* Tests with buffers which length is not byte-aligned */
13289 TEST_CASE_ST(ut_setup, ut_teardown,
13290 test_snow3g_hash_generate_test_case_4),
13291 TEST_CASE_ST(ut_setup, ut_teardown,
13292 test_snow3g_hash_generate_test_case_5),
13293 TEST_CASE_ST(ut_setup, ut_teardown,
13294 test_snow3g_hash_generate_test_case_6),
13295 TEST_CASE_ST(ut_setup, ut_teardown,
13296 test_snow3g_hash_verify_test_case_1),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_snow3g_hash_verify_test_case_2),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_snow3g_hash_verify_test_case_3),
13301 /* Tests with buffers which length is not byte-aligned */
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_snow3g_hash_verify_test_case_4),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_snow3g_hash_verify_test_case_5),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_snow3g_hash_verify_test_case_6),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_snow3g_cipher_auth_test_case_1),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_snow3g_auth_cipher_with_digest_test_case_1),
13313 /** ZUC encrypt only (EEA3) */
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 test_zuc_encryption_test_case_1),
13316 TEST_CASE_ST(ut_setup, ut_teardown,
13317 test_zuc_encryption_test_case_2),
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_zuc_encryption_test_case_3),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_zuc_encryption_test_case_4),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 test_zuc_encryption_test_case_5),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_zuc_encryption_test_case_6_sgl),
13327 /** ZUC authenticate (EIA3) */
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_zuc_hash_generate_test_case_1),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_zuc_hash_generate_test_case_2),
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_zuc_hash_generate_test_case_3),
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_zuc_hash_generate_test_case_4),
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_zuc_hash_generate_test_case_5),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 test_zuc_hash_generate_test_case_6),
13340 TEST_CASE_ST(ut_setup, ut_teardown,
13341 test_zuc_hash_generate_test_case_7),
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 test_zuc_hash_generate_test_case_8),
13345 /** ZUC alg-chain (EEA3/EIA3) */
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_zuc_cipher_auth_test_case_1),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_zuc_cipher_auth_test_case_2),
13351 /** ZUC generate auth, then encrypt (EEA3) */
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_zuc_auth_cipher_test_case_1),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_zuc_auth_cipher_test_case_1_oop),
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_zuc_auth_cipher_test_case_1_sgl),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_zuc_auth_cipher_test_case_1_oop_sgl),
13361 /** ZUC decrypt (EEA3), then verify auth */
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_zuc_auth_cipher_verify_test_case_1),
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_zuc_auth_cipher_verify_test_case_1_oop),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_zuc_auth_cipher_verify_test_case_1_sgl),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
13371 /** HMAC_MD5 Authentication */
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_MD5_HMAC_generate_case_1),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_MD5_HMAC_verify_case_1),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_MD5_HMAC_generate_case_2),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_MD5_HMAC_verify_case_2),
13381 /** KASUMI hash only (UIA1) */
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_kasumi_hash_generate_test_case_1),
13384 TEST_CASE_ST(ut_setup, ut_teardown,
13385 test_kasumi_hash_generate_test_case_2),
13386 TEST_CASE_ST(ut_setup, ut_teardown,
13387 test_kasumi_hash_generate_test_case_3),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_kasumi_hash_generate_test_case_4),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_kasumi_hash_generate_test_case_5),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_kasumi_hash_generate_test_case_6),
13395 TEST_CASE_ST(ut_setup, ut_teardown,
13396 test_kasumi_hash_verify_test_case_1),
13397 TEST_CASE_ST(ut_setup, ut_teardown,
13398 test_kasumi_hash_verify_test_case_2),
13399 TEST_CASE_ST(ut_setup, ut_teardown,
13400 test_kasumi_hash_verify_test_case_3),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_kasumi_hash_verify_test_case_4),
13403 TEST_CASE_ST(ut_setup, ut_teardown,
13404 test_kasumi_hash_verify_test_case_5),
13406 /** KASUMI encrypt only (UEA1) */
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_kasumi_encryption_test_case_1),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_kasumi_encryption_test_case_1_sgl),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_kasumi_encryption_test_case_1_oop),
13413 TEST_CASE_ST(ut_setup, ut_teardown,
13414 test_kasumi_encryption_test_case_1_oop_sgl),
13415 TEST_CASE_ST(ut_setup, ut_teardown,
13416 test_kasumi_encryption_test_case_2),
13417 TEST_CASE_ST(ut_setup, ut_teardown,
13418 test_kasumi_encryption_test_case_3),
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 test_kasumi_encryption_test_case_4),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 test_kasumi_encryption_test_case_5),
13424 /** KASUMI decrypt only (UEA1) */
13425 TEST_CASE_ST(ut_setup, ut_teardown,
13426 test_kasumi_decryption_test_case_1),
13427 TEST_CASE_ST(ut_setup, ut_teardown,
13428 test_kasumi_decryption_test_case_2),
13429 TEST_CASE_ST(ut_setup, ut_teardown,
13430 test_kasumi_decryption_test_case_3),
13431 TEST_CASE_ST(ut_setup, ut_teardown,
13432 test_kasumi_decryption_test_case_4),
13433 TEST_CASE_ST(ut_setup, ut_teardown,
13434 test_kasumi_decryption_test_case_5),
13435 TEST_CASE_ST(ut_setup, ut_teardown,
13436 test_kasumi_decryption_test_case_1_oop),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 test_kasumi_cipher_auth_test_case_1),
13441 /** KASUMI generate auth, then encrypt (F8) */
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 test_kasumi_auth_cipher_test_case_1),
13444 TEST_CASE_ST(ut_setup, ut_teardown,
13445 test_kasumi_auth_cipher_test_case_2),
13446 TEST_CASE_ST(ut_setup, ut_teardown,
13447 test_kasumi_auth_cipher_test_case_2_oop),
13448 TEST_CASE_ST(ut_setup, ut_teardown,
13449 test_kasumi_auth_cipher_test_case_2_sgl),
13450 TEST_CASE_ST(ut_setup, ut_teardown,
13451 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13453 /** KASUMI decrypt (F8), then verify auth */
13454 TEST_CASE_ST(ut_setup, ut_teardown,
13455 test_kasumi_auth_cipher_verify_test_case_1),
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 test_kasumi_auth_cipher_verify_test_case_2),
13458 TEST_CASE_ST(ut_setup, ut_teardown,
13459 test_kasumi_auth_cipher_verify_test_case_2_oop),
13460 TEST_CASE_ST(ut_setup, ut_teardown,
13461 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13462 TEST_CASE_ST(ut_setup, ut_teardown,
13463 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13465 /** ESN Testcase */
13466 TEST_CASE_ST(ut_setup, ut_teardown,
13467 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13468 TEST_CASE_ST(ut_setup, ut_teardown,
13469 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13471 /** Negative tests */
13472 TEST_CASE_ST(ut_setup, ut_teardown,
13473 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13474 TEST_CASE_ST(ut_setup, ut_teardown,
13475 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13476 TEST_CASE_ST(ut_setup, ut_teardown,
13477 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13478 TEST_CASE_ST(ut_setup, ut_teardown,
13479 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13480 TEST_CASE_ST(ut_setup, ut_teardown,
13481 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13482 TEST_CASE_ST(ut_setup, ut_teardown,
13483 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13484 TEST_CASE_ST(ut_setup, ut_teardown,
13485 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13486 TEST_CASE_ST(ut_setup, ut_teardown,
13487 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13488 TEST_CASE_ST(ut_setup, ut_teardown,
13489 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13490 TEST_CASE_ST(ut_setup, ut_teardown,
13491 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13492 TEST_CASE_ST(ut_setup, ut_teardown,
13493 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13494 TEST_CASE_ST(ut_setup, ut_teardown,
13495 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13496 TEST_CASE_ST(ut_setup, ut_teardown,
13497 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13498 TEST_CASE_ST(ut_setup, ut_teardown,
13499 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13500 TEST_CASE_ST(ut_setup, ut_teardown,
13501 authentication_verify_AES128_GMAC_fail_data_corrupt),
13502 TEST_CASE_ST(ut_setup, ut_teardown,
13503 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13504 TEST_CASE_ST(ut_setup, ut_teardown,
13505 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13506 TEST_CASE_ST(ut_setup, ut_teardown,
13507 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13509 /** Mixed CIPHER + HASH algorithms */
13510 /** AUTH AES CMAC + CIPHER AES CTR */
13511 TEST_CASE_ST(ut_setup, ut_teardown,
13512 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
13513 TEST_CASE_ST(ut_setup, ut_teardown,
13514 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13515 TEST_CASE_ST(ut_setup, ut_teardown,
13516 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13517 TEST_CASE_ST(ut_setup, ut_teardown,
13518 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13519 TEST_CASE_ST(ut_setup, ut_teardown,
13520 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13523 TEST_CASE_ST(ut_setup, ut_teardown,
13524 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13528 /** AUTH ZUC + CIPHER SNOW3G */
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_auth_zuc_cipher_snow_test_case_1),
13531 TEST_CASE_ST(ut_setup, ut_teardown,
13532 test_verify_auth_zuc_cipher_snow_test_case_1),
13533 /** AUTH AES CMAC + CIPHER SNOW3G */
13534 TEST_CASE_ST(ut_setup, ut_teardown,
13535 test_auth_aes_cmac_cipher_snow_test_case_1),
13536 TEST_CASE_ST(ut_setup, ut_teardown,
13537 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
13538 /** AUTH ZUC + CIPHER AES CTR */
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_auth_zuc_cipher_aes_ctr_test_case_1),
13541 TEST_CASE_ST(ut_setup, ut_teardown,
13542 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
13543 /** AUTH SNOW3G + CIPHER AES CTR */
13544 TEST_CASE_ST(ut_setup, ut_teardown,
13545 test_auth_snow_cipher_aes_ctr_test_case_1),
13546 TEST_CASE_ST(ut_setup, ut_teardown,
13547 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
13548 /** AUTH SNOW3G + CIPHER ZUC */
13549 TEST_CASE_ST(ut_setup, ut_teardown,
13550 test_auth_snow_cipher_zuc_test_case_1),
13551 TEST_CASE_ST(ut_setup, ut_teardown,
13552 test_verify_auth_snow_cipher_zuc_test_case_1),
13553 /** AUTH AES CMAC + CIPHER ZUC */
13554 TEST_CASE_ST(ut_setup, ut_teardown,
13555 test_auth_aes_cmac_cipher_zuc_test_case_1),
13556 TEST_CASE_ST(ut_setup, ut_teardown,
13557 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
13559 /** AUTH NULL + CIPHER SNOW3G */
13560 TEST_CASE_ST(ut_setup, ut_teardown,
13561 test_auth_null_cipher_snow_test_case_1),
13562 TEST_CASE_ST(ut_setup, ut_teardown,
13563 test_verify_auth_null_cipher_snow_test_case_1),
13564 /** AUTH NULL + CIPHER ZUC */
13565 TEST_CASE_ST(ut_setup, ut_teardown,
13566 test_auth_null_cipher_zuc_test_case_1),
13567 TEST_CASE_ST(ut_setup, ut_teardown,
13568 test_verify_auth_null_cipher_zuc_test_case_1),
13569 /** AUTH SNOW3G + CIPHER NULL */
13570 TEST_CASE_ST(ut_setup, ut_teardown,
13571 test_auth_snow_cipher_null_test_case_1),
13572 TEST_CASE_ST(ut_setup, ut_teardown,
13573 test_verify_auth_snow_cipher_null_test_case_1),
13574 /** AUTH ZUC + CIPHER NULL */
13575 TEST_CASE_ST(ut_setup, ut_teardown,
13576 test_auth_zuc_cipher_null_test_case_1),
13577 TEST_CASE_ST(ut_setup, ut_teardown,
13578 test_verify_auth_zuc_cipher_null_test_case_1),
13579 /** AUTH NULL + CIPHER AES CTR */
13580 TEST_CASE_ST(ut_setup, ut_teardown,
13581 test_auth_null_cipher_aes_ctr_test_case_1),
13582 TEST_CASE_ST(ut_setup, ut_teardown,
13583 test_verify_auth_null_cipher_aes_ctr_test_case_1),
13584 /** AUTH AES CMAC + CIPHER NULL */
13585 TEST_CASE_ST(ut_setup, ut_teardown,
13586 test_auth_aes_cmac_cipher_null_test_case_1),
13587 TEST_CASE_ST(ut_setup, ut_teardown,
13588 test_verify_auth_aes_cmac_cipher_null_test_case_1),
13590 #ifdef RTE_LIBRTE_SECURITY
13591 TEST_CASE_ST(ut_setup_security, ut_teardown,
13592 test_PDCP_PROTO_all),
13593 TEST_CASE_ST(ut_setup_security, ut_teardown,
13594 test_DOCSIS_PROTO_all),
13596 TEST_CASES_END() /**< NULL terminate unit test array */
13600 static struct unit_test_suite cryptodev_virtio_testsuite = {
13601 .suite_name = "Crypto VIRTIO Unit Test Suite",
13602 .setup = testsuite_setup,
13603 .teardown = testsuite_teardown,
13604 .unit_test_cases = {
13605 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13607 TEST_CASES_END() /**< NULL terminate unit test array */
13611 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13612 .suite_name = "Crypto CAAM JR Unit Test Suite",
13613 .setup = testsuite_setup,
13614 .teardown = testsuite_teardown,
13615 .unit_test_cases = {
13616 TEST_CASE_ST(ut_setup, ut_teardown,
13617 test_device_configure_invalid_dev_id),
13618 TEST_CASE_ST(ut_setup, ut_teardown,
13619 test_multi_session),
13621 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13622 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13623 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13624 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13625 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13627 TEST_CASES_END() /**< NULL terminate unit test array */
13631 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13632 .suite_name = "Crypto Device Marvell Component Test Suite",
13633 .setup = testsuite_setup,
13634 .teardown = testsuite_teardown,
13635 .unit_test_cases = {
13636 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13637 TEST_CASE_ST(ut_setup, ut_teardown,
13638 test_multi_session_random_usage),
13639 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13640 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13641 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13642 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13643 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13645 /** Negative tests */
13646 TEST_CASE_ST(ut_setup, ut_teardown,
13647 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13648 TEST_CASE_ST(ut_setup, ut_teardown,
13649 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13650 TEST_CASE_ST(ut_setup, ut_teardown,
13651 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13652 TEST_CASE_ST(ut_setup, ut_teardown,
13653 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13655 TEST_CASES_END() /**< NULL terminate unit test array */
13659 static struct unit_test_suite cryptodev_ccp_testsuite = {
13660 .suite_name = "Crypto Device CCP Unit Test Suite",
13661 .setup = testsuite_setup,
13662 .teardown = testsuite_teardown,
13663 .unit_test_cases = {
13664 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13665 TEST_CASE_ST(ut_setup, ut_teardown,
13666 test_multi_session_random_usage),
13667 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13668 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13669 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13670 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13671 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13673 /** Negative tests */
13674 TEST_CASE_ST(ut_setup, ut_teardown,
13675 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13676 TEST_CASE_ST(ut_setup, ut_teardown,
13677 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13678 TEST_CASE_ST(ut_setup, ut_teardown,
13679 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13680 TEST_CASE_ST(ut_setup, ut_teardown,
13681 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13683 TEST_CASES_END() /**< NULL terminate unit test array */
13688 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13690 gbl_driver_id = rte_cryptodev_driver_id_get(
13691 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13693 if (gbl_driver_id == -1) {
13694 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
13695 return TEST_SKIPPED;
13698 return unit_test_suite_runner(&cryptodev_testsuite);
13702 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13704 gbl_driver_id = rte_cryptodev_driver_id_get(
13705 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13707 if (gbl_driver_id == -1) {
13708 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
13709 return TEST_FAILED;
13712 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13716 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13718 gbl_driver_id = rte_cryptodev_driver_id_get(
13719 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13721 if (gbl_driver_id == -1) {
13722 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13723 return TEST_SKIPPED;
13726 return unit_test_suite_runner(&cryptodev_testsuite);
13730 test_cryptodev_cpu_aesni_mb(void)
13733 enum rte_security_session_action_type at;
13735 gbl_driver_id = rte_cryptodev_driver_id_get(
13736 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13738 if (gbl_driver_id == -1) {
13739 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13740 return TEST_SKIPPED;
13743 at = gbl_action_type;
13744 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13745 rc = unit_test_suite_runner(&cryptodev_testsuite);
13746 gbl_action_type = at;
13751 test_cryptodev_openssl(void)
13753 gbl_driver_id = rte_cryptodev_driver_id_get(
13754 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13756 if (gbl_driver_id == -1) {
13757 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
13758 return TEST_SKIPPED;
13761 return unit_test_suite_runner(&cryptodev_testsuite);
13765 test_cryptodev_aesni_gcm(void)
13767 gbl_driver_id = rte_cryptodev_driver_id_get(
13768 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13770 if (gbl_driver_id == -1) {
13771 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
13772 return TEST_SKIPPED;
13775 return unit_test_suite_runner(&cryptodev_testsuite);
13779 test_cryptodev_cpu_aesni_gcm(void)
13782 enum rte_security_session_action_type at;
13784 gbl_driver_id = rte_cryptodev_driver_id_get(
13785 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13787 if (gbl_driver_id == -1) {
13788 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
13789 return TEST_SKIPPED;
13792 at = gbl_action_type;
13793 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13794 rc = unit_test_suite_runner(&cryptodev_testsuite);
13795 gbl_action_type = at;
13800 test_cryptodev_null(void)
13802 gbl_driver_id = rte_cryptodev_driver_id_get(
13803 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13805 if (gbl_driver_id == -1) {
13806 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
13807 return TEST_SKIPPED;
13810 return unit_test_suite_runner(&cryptodev_testsuite);
13814 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13816 gbl_driver_id = rte_cryptodev_driver_id_get(
13817 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13819 if (gbl_driver_id == -1) {
13820 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
13821 return TEST_SKIPPED;
13824 return unit_test_suite_runner(&cryptodev_testsuite);
13828 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13830 gbl_driver_id = rte_cryptodev_driver_id_get(
13831 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13833 if (gbl_driver_id == -1) {
13834 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
13835 return TEST_SKIPPED;
13838 return unit_test_suite_runner(&cryptodev_testsuite);
13842 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13844 gbl_driver_id = rte_cryptodev_driver_id_get(
13845 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13847 if (gbl_driver_id == -1) {
13848 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
13849 return TEST_SKIPPED;
13852 return unit_test_suite_runner(&cryptodev_testsuite);
13856 test_cryptodev_armv8(void)
13858 gbl_driver_id = rte_cryptodev_driver_id_get(
13859 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13861 if (gbl_driver_id == -1) {
13862 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
13863 return TEST_SKIPPED;
13866 return unit_test_suite_runner(&cryptodev_testsuite);
13870 test_cryptodev_mrvl(void)
13872 gbl_driver_id = rte_cryptodev_driver_id_get(
13873 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13875 if (gbl_driver_id == -1) {
13876 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
13877 return TEST_SKIPPED;
13880 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13883 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13886 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13888 gbl_driver_id = rte_cryptodev_driver_id_get(
13889 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13891 if (gbl_driver_id == -1) {
13892 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
13893 return TEST_SKIPPED;
13896 if (rte_cryptodev_driver_id_get(
13897 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13898 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13899 return TEST_SKIPPED;
13901 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13904 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13909 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13911 gbl_driver_id = rte_cryptodev_driver_id_get(
13912 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13914 if (gbl_driver_id == -1) {
13915 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
13916 return TEST_SKIPPED;
13919 return unit_test_suite_runner(&cryptodev_testsuite);
13923 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13925 gbl_driver_id = rte_cryptodev_driver_id_get(
13926 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13928 if (gbl_driver_id == -1) {
13929 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
13930 return TEST_SKIPPED;
13933 return unit_test_suite_runner(&cryptodev_testsuite);
13937 test_cryptodev_ccp(void)
13939 gbl_driver_id = rte_cryptodev_driver_id_get(
13940 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13942 if (gbl_driver_id == -1) {
13943 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
13944 return TEST_FAILED;
13947 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13951 test_cryptodev_octeontx(void)
13953 gbl_driver_id = rte_cryptodev_driver_id_get(
13954 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13955 if (gbl_driver_id == -1) {
13956 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
13957 return TEST_FAILED;
13959 return unit_test_suite_runner(&cryptodev_testsuite);
13963 test_cryptodev_octeontx2(void)
13965 gbl_driver_id = rte_cryptodev_driver_id_get(
13966 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13967 if (gbl_driver_id == -1) {
13968 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
13969 return TEST_FAILED;
13971 return unit_test_suite_runner(&cryptodev_testsuite);
13975 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13977 gbl_driver_id = rte_cryptodev_driver_id_get(
13978 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13980 if (gbl_driver_id == -1) {
13981 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
13982 return TEST_FAILED;
13985 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13989 test_cryptodev_nitrox(void)
13991 gbl_driver_id = rte_cryptodev_driver_id_get(
13992 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13994 if (gbl_driver_id == -1) {
13995 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
13996 return TEST_FAILED;
13999 return unit_test_suite_runner(&cryptodev_testsuite);
14003 test_cryptodev_bcmfs(void)
14005 gbl_driver_id = rte_cryptodev_driver_id_get(
14006 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14008 if (gbl_driver_id == -1) {
14009 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
14010 return TEST_FAILED;
14013 return unit_test_suite_runner(&cryptodev_testsuite);
14017 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14021 gbl_driver_id = rte_cryptodev_driver_id_get(
14022 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14024 if (gbl_driver_id == -1) {
14025 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14026 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14027 "are enabled in config file to run this testsuite.\n");
14028 return TEST_SKIPPED;
14031 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14032 ret = unit_test_suite_runner(&cryptodev_testsuite);
14033 global_api_test_type = CRYPTODEV_API_TEST;
14038 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14039 test_cryptodev_qat_raw_api);
14040 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14041 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14042 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14043 test_cryptodev_cpu_aesni_mb);
14044 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14045 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14046 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14047 test_cryptodev_cpu_aesni_gcm);
14048 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14049 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14050 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14051 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14052 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14053 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14054 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14055 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14056 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14057 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14058 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14059 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14060 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14061 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14062 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);