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);
786 * Create mempool with maximum number of sessions * 2,
787 * to include the session headers
789 if (info.sym.max_nb_sessions != 0 &&
790 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
791 RTE_LOG(ERR, USER1, "Device does not support "
792 "at least %u sessions\n",
797 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
798 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
800 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
801 "session mempool allocation failed");
803 ts_params->session_priv_mpool = rte_mempool_create(
807 0, 0, NULL, NULL, NULL,
810 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
811 "session mempool allocation failed");
815 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
817 "Failed to configure cryptodev %u with %u qps",
818 dev_id, ts_params->conf.nb_queue_pairs);
820 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
821 ts_params->qp_conf.mp_session = ts_params->session_mpool;
822 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
824 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
825 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
826 dev_id, qp_id, &ts_params->qp_conf,
827 rte_cryptodev_socket_id(dev_id)),
828 "Failed to setup queue pair %u on cryptodev %u",
836 testsuite_teardown(void)
838 struct crypto_testsuite_params *ts_params = &testsuite_params;
840 if (ts_params->mbuf_pool != NULL) {
841 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
842 rte_mempool_avail_count(ts_params->mbuf_pool));
845 if (ts_params->op_mpool != NULL) {
846 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
847 rte_mempool_avail_count(ts_params->op_mpool));
850 /* Free session mempools */
851 if (ts_params->session_priv_mpool != NULL) {
852 rte_mempool_free(ts_params->session_priv_mpool);
853 ts_params->session_priv_mpool = NULL;
856 if (ts_params->session_mpool != NULL) {
857 rte_mempool_free(ts_params->session_mpool);
858 ts_params->session_mpool = NULL;
863 dev_configure_and_start(uint64_t ff_disable)
865 struct crypto_testsuite_params *ts_params = &testsuite_params;
866 struct crypto_unittest_params *ut_params = &unittest_params;
870 /* Clear unit test parameters before running test */
871 memset(ut_params, 0, sizeof(*ut_params));
873 /* Reconfigure device to default parameters */
874 ts_params->conf.socket_id = SOCKET_ID_ANY;
875 ts_params->conf.ff_disable = ff_disable;
876 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
877 ts_params->qp_conf.mp_session = ts_params->session_mpool;
878 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
880 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
882 "Failed to configure cryptodev %u",
883 ts_params->valid_devs[0]);
885 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
886 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
887 ts_params->valid_devs[0], qp_id,
889 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
890 "Failed to setup queue pair %u on cryptodev %u",
891 qp_id, ts_params->valid_devs[0]);
895 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
897 /* Start the device */
898 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
899 "Failed to start cryptodev %u",
900 ts_params->valid_devs[0]);
908 /* Configure and start the device with security feature disabled */
909 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
913 ut_setup_security(void)
915 /* Configure and start the device with no features disabled */
916 return dev_configure_and_start(0);
922 struct crypto_testsuite_params *ts_params = &testsuite_params;
923 struct crypto_unittest_params *ut_params = &unittest_params;
924 struct rte_cryptodev_stats stats;
926 /* free crypto session structure */
927 #ifdef RTE_LIBRTE_SECURITY
928 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
929 if (ut_params->sec_session) {
930 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
931 (ts_params->valid_devs[0]),
932 ut_params->sec_session);
933 ut_params->sec_session = NULL;
938 if (ut_params->sess) {
939 rte_cryptodev_sym_session_clear(
940 ts_params->valid_devs[0],
942 rte_cryptodev_sym_session_free(ut_params->sess);
943 ut_params->sess = NULL;
947 /* free crypto operation structure */
949 rte_crypto_op_free(ut_params->op);
952 * free mbuf - both obuf and ibuf are usually the same,
953 * so check if they point at the same address is necessary,
954 * to avoid freeing the mbuf twice.
956 if (ut_params->obuf) {
957 rte_pktmbuf_free(ut_params->obuf);
958 if (ut_params->ibuf == ut_params->obuf)
962 if (ut_params->ibuf) {
963 rte_pktmbuf_free(ut_params->ibuf);
967 if (ts_params->mbuf_pool != NULL)
968 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
969 rte_mempool_avail_count(ts_params->mbuf_pool));
971 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
973 /* Stop the device */
974 rte_cryptodev_stop(ts_params->valid_devs[0]);
978 test_device_configure_invalid_dev_id(void)
980 struct crypto_testsuite_params *ts_params = &testsuite_params;
981 uint16_t dev_id, num_devs = 0;
983 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
984 "Need at least %d devices for test", 1);
986 /* valid dev_id values */
987 dev_id = ts_params->valid_devs[0];
989 /* Stop the device in case it's started so it can be configured */
990 rte_cryptodev_stop(dev_id);
992 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
993 "Failed test for rte_cryptodev_configure: "
994 "invalid dev_num %u", dev_id);
996 /* invalid dev_id values */
999 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1000 "Failed test for rte_cryptodev_configure: "
1001 "invalid dev_num %u", dev_id);
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);
1009 return TEST_SUCCESS;
1013 test_device_configure_invalid_queue_pair_ids(void)
1015 struct crypto_testsuite_params *ts_params = &testsuite_params;
1016 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1018 /* Stop the device in case it's started so it can be configured */
1019 rte_cryptodev_stop(ts_params->valid_devs[0]);
1021 /* valid - max value queue pairs */
1022 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1024 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1026 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1027 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1029 /* valid - one queue pairs */
1030 ts_params->conf.nb_queue_pairs = 1;
1032 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1034 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1035 ts_params->valid_devs[0],
1036 ts_params->conf.nb_queue_pairs);
1039 /* invalid - zero queue pairs */
1040 ts_params->conf.nb_queue_pairs = 0;
1042 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1044 "Failed test for rte_cryptodev_configure, dev_id %u,"
1046 ts_params->valid_devs[0],
1047 ts_params->conf.nb_queue_pairs);
1050 /* invalid - max value supported by field queue pairs */
1051 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1053 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1055 "Failed test for rte_cryptodev_configure, dev_id %u,"
1057 ts_params->valid_devs[0],
1058 ts_params->conf.nb_queue_pairs);
1061 /* invalid - max value + 1 queue pairs */
1062 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1064 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1066 "Failed test for rte_cryptodev_configure, dev_id %u,"
1068 ts_params->valid_devs[0],
1069 ts_params->conf.nb_queue_pairs);
1071 /* revert to original testsuite value */
1072 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1074 return TEST_SUCCESS;
1078 test_queue_pair_descriptor_setup(void)
1080 struct crypto_testsuite_params *ts_params = &testsuite_params;
1081 struct rte_cryptodev_qp_conf qp_conf = {
1082 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1086 /* Stop the device in case it's started so it can be configured */
1087 rte_cryptodev_stop(ts_params->valid_devs[0]);
1089 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1091 "Failed to configure cryptodev %u",
1092 ts_params->valid_devs[0]);
1095 * Test various ring sizes on this device. memzones can't be
1096 * freed so are re-used if ring is released and re-created.
1098 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1099 qp_conf.mp_session = ts_params->session_mpool;
1100 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1102 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1103 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1104 ts_params->valid_devs[0], qp_id, &qp_conf,
1105 rte_cryptodev_socket_id(
1106 ts_params->valid_devs[0])),
1108 "rte_cryptodev_queue_pair_setup: num_inflights "
1109 "%u on qp %u on cryptodev %u",
1110 qp_conf.nb_descriptors, qp_id,
1111 ts_params->valid_devs[0]);
1114 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1116 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1117 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1118 ts_params->valid_devs[0], qp_id, &qp_conf,
1119 rte_cryptodev_socket_id(
1120 ts_params->valid_devs[0])),
1122 " rte_cryptodev_queue_pair_setup: num_inflights"
1123 " %u on qp %u on cryptodev %u",
1124 qp_conf.nb_descriptors, qp_id,
1125 ts_params->valid_devs[0]);
1128 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1130 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1131 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1132 ts_params->valid_devs[0], qp_id, &qp_conf,
1133 rte_cryptodev_socket_id(
1134 ts_params->valid_devs[0])),
1136 "rte_cryptodev_queue_pair_setup: num_inflights"
1137 " %u on qp %u on cryptodev %u",
1138 qp_conf.nb_descriptors, qp_id,
1139 ts_params->valid_devs[0]);
1142 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1144 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1145 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1146 ts_params->valid_devs[0], qp_id, &qp_conf,
1147 rte_cryptodev_socket_id(
1148 ts_params->valid_devs[0])),
1150 " rte_cryptodev_queue_pair_setup:"
1151 "num_inflights %u on qp %u on cryptodev %u",
1152 qp_conf.nb_descriptors, qp_id,
1153 ts_params->valid_devs[0]);
1156 /* test invalid queue pair id */
1157 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1159 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1161 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1162 ts_params->valid_devs[0],
1164 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1165 "Failed test for rte_cryptodev_queue_pair_setup:"
1166 "invalid qp %u on cryptodev %u",
1167 qp_id, ts_params->valid_devs[0]);
1169 qp_id = 0xffff; /*invalid*/
1171 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1172 ts_params->valid_devs[0],
1174 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1175 "Failed test for rte_cryptodev_queue_pair_setup:"
1176 "invalid qp %u on cryptodev %u",
1177 qp_id, ts_params->valid_devs[0]);
1179 return TEST_SUCCESS;
1182 /* ***** Plaintext data for tests ***** */
1184 const char catch_22_quote_1[] =
1185 "There was only one catch and that was Catch-22, which "
1186 "specified that a concern for one's safety in the face of "
1187 "dangers that were real and immediate was the process of a "
1188 "rational mind. Orr was crazy and could be grounded. All he "
1189 "had to do was ask; and as soon as he did, he would no longer "
1190 "be crazy and would have to fly more missions. Orr would be "
1191 "crazy to fly more missions and sane if he didn't, but if he "
1192 "was sane he had to fly them. If he flew them he was crazy "
1193 "and didn't have to; but if he didn't want to he was sane and "
1194 "had to. Yossarian was moved very deeply by the absolute "
1195 "simplicity of this clause of Catch-22 and let out a "
1196 "respectful whistle. \"That's some catch, that Catch-22\", he "
1197 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1199 const char catch_22_quote[] =
1200 "What a lousy earth! He wondered how many people were "
1201 "destitute that same night even in his own prosperous country, "
1202 "how many homes were shanties, how many husbands were drunk "
1203 "and wives socked, and how many children were bullied, abused, "
1204 "or abandoned. How many families hungered for food they could "
1205 "not afford to buy? How many hearts were broken? How many "
1206 "suicides would take place that same night, how many people "
1207 "would go insane? How many cockroaches and landlords would "
1208 "triumph? How many winners were losers, successes failures, "
1209 "and rich men poor men? How many wise guys were stupid? How "
1210 "many happy endings were unhappy endings? How many honest men "
1211 "were liars, brave men cowards, loyal men traitors, how many "
1212 "sainted men were corrupt, how many people in positions of "
1213 "trust had sold their souls to bodyguards, how many had never "
1214 "had souls? How many straight-and-narrow paths were crooked "
1215 "paths? How many best families were worst families and how "
1216 "many good people were bad people? When you added them all up "
1217 "and then subtracted, you might be left with only the children, "
1218 "and perhaps with Albert Einstein and an old violinist or "
1219 "sculptor somewhere.";
1221 #define QUOTE_480_BYTES (480)
1222 #define QUOTE_512_BYTES (512)
1223 #define QUOTE_768_BYTES (768)
1224 #define QUOTE_1024_BYTES (1024)
1228 /* ***** SHA1 Hash Tests ***** */
1230 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1232 static uint8_t hmac_sha1_key[] = {
1233 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1234 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1235 0xDE, 0xF4, 0xDE, 0xAD };
1237 /* ***** SHA224 Hash Tests ***** */
1239 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1242 /* ***** AES-CBC Cipher Tests ***** */
1244 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1245 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1247 static uint8_t aes_cbc_key[] = {
1248 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1249 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1251 static uint8_t aes_cbc_iv[] = {
1252 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1253 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1256 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1258 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1259 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1260 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1261 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1262 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1263 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1264 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1265 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1266 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1267 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1268 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1269 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1270 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1271 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1272 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1273 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1274 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1275 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1276 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1277 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1278 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1279 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1280 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1281 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1282 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1283 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1284 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1285 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1286 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1287 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1288 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1289 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1290 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1291 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1292 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1293 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1294 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1295 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1296 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1297 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1298 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1299 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1300 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1301 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1302 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1303 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1304 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1305 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1306 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1307 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1308 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1309 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1310 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1311 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1312 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1313 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1314 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1315 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1316 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1317 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1318 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1319 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1320 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1321 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1322 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1325 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1326 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1327 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1328 0x18, 0x8c, 0x1d, 0x32
1332 /* Multisession Vector context Test */
1333 /*Begin Session 0 */
1334 static uint8_t ms_aes_cbc_key0[] = {
1335 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1336 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1339 static uint8_t ms_aes_cbc_iv0[] = {
1340 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1341 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1344 static const uint8_t ms_aes_cbc_cipher0[] = {
1345 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1346 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1347 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1348 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1349 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1350 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1351 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1352 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1353 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1354 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1355 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1356 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1357 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1358 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1359 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1360 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1361 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1362 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1363 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1364 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1365 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1366 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1367 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1368 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1369 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1370 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1371 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1372 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1373 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1374 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1375 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1376 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1377 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1378 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1379 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1380 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1381 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1382 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1383 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1384 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1385 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1386 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1387 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1388 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1389 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1390 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1391 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1392 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1393 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1394 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1395 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1396 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1397 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1398 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1399 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1400 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1401 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1402 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1403 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1404 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1405 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1406 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1407 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1408 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1412 static uint8_t ms_hmac_key0[] = {
1413 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1414 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1415 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1416 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1417 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1418 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1419 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1420 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1423 static const uint8_t ms_hmac_digest0[] = {
1424 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1425 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1426 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1427 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1428 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1429 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1430 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1431 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1435 /* Begin session 1 */
1437 static uint8_t ms_aes_cbc_key1[] = {
1438 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1439 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1442 static uint8_t ms_aes_cbc_iv1[] = {
1443 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1444 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1447 static const uint8_t ms_aes_cbc_cipher1[] = {
1448 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1449 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1450 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1451 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1452 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1453 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1454 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1455 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1456 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1457 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1458 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1459 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1460 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1461 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1462 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1463 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1464 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1465 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1466 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1467 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1468 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1469 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1470 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1471 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1472 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1473 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1474 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1475 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1476 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1477 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1478 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1479 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1480 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1481 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1482 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1483 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1484 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1485 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1486 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1487 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1488 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1489 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1490 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1491 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1492 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1493 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1494 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1495 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1496 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1497 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1498 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1499 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1500 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1501 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1502 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1503 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1504 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1505 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1506 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1507 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1508 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1509 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1510 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1511 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1515 static uint8_t ms_hmac_key1[] = {
1516 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1517 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1518 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1519 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1520 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1521 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1522 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1523 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1526 static const uint8_t ms_hmac_digest1[] = {
1527 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1528 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1529 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1530 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1531 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1532 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1533 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1534 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1537 /* Begin Session 2 */
1538 static uint8_t ms_aes_cbc_key2[] = {
1539 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1540 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1543 static uint8_t ms_aes_cbc_iv2[] = {
1544 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1545 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1548 static const uint8_t ms_aes_cbc_cipher2[] = {
1549 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1550 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1551 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1552 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1553 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1554 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1555 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1556 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1557 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1558 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1559 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1560 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1561 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1562 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1563 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1564 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1565 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1566 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1567 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1568 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1569 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1570 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1571 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1572 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1573 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1574 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1575 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1576 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1577 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1578 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1579 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1580 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1581 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1582 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1583 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1584 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1585 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1586 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1587 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1588 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1589 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1590 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1591 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1592 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1593 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1594 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1595 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1596 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1597 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1598 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1599 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1600 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1601 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1602 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1603 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1604 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1605 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1606 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1607 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1608 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1609 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1610 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1611 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1612 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1615 static uint8_t ms_hmac_key2[] = {
1616 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1617 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1618 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1619 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1620 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1621 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1622 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1623 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1626 static const uint8_t ms_hmac_digest2[] = {
1627 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1628 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1629 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1630 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1631 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1632 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1633 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1634 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1641 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1643 struct crypto_testsuite_params *ts_params = &testsuite_params;
1644 struct crypto_unittest_params *ut_params = &unittest_params;
1646 /* Verify the capabilities */
1647 struct rte_cryptodev_sym_capability_idx cap_idx;
1648 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1649 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1650 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1653 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1654 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1655 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1659 /* Generate test mbuf data and space for digest */
1660 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1661 catch_22_quote, QUOTE_512_BYTES, 0);
1663 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1664 DIGEST_BYTE_LENGTH_SHA1);
1665 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1667 /* Setup Cipher Parameters */
1668 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1669 ut_params->cipher_xform.next = &ut_params->auth_xform;
1671 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1672 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1673 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1674 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1675 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1676 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1678 /* Setup HMAC Parameters */
1679 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1681 ut_params->auth_xform.next = NULL;
1683 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1684 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1685 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1686 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1687 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1689 ut_params->sess = rte_cryptodev_sym_session_create(
1690 ts_params->session_mpool);
1692 /* Create crypto session*/
1693 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1694 ut_params->sess, &ut_params->cipher_xform,
1695 ts_params->session_priv_mpool);
1696 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1698 /* Generate crypto op data structure */
1699 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1700 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1701 TEST_ASSERT_NOT_NULL(ut_params->op,
1702 "Failed to allocate symmetric crypto operation struct");
1704 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1706 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1708 /* set crypto operation source mbuf */
1709 sym_op->m_src = ut_params->ibuf;
1711 /* Set crypto operation authentication parameters */
1712 sym_op->auth.digest.data = ut_params->digest;
1713 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1714 ut_params->ibuf, QUOTE_512_BYTES);
1716 sym_op->auth.data.offset = 0;
1717 sym_op->auth.data.length = QUOTE_512_BYTES;
1719 /* Copy IV at the end of the crypto operation */
1720 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1721 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1723 /* Set crypto operation cipher parameters */
1724 sym_op->cipher.data.offset = 0;
1725 sym_op->cipher.data.length = QUOTE_512_BYTES;
1727 /* Process crypto operation */
1728 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1729 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1732 TEST_ASSERT_NOT_NULL(
1733 process_crypto_request(ts_params->valid_devs[0],
1735 "failed to process sym crypto op");
1737 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1738 "crypto op processing failed");
1741 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1744 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1745 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1747 "ciphertext data not as expected");
1749 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1751 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1752 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1753 gbl_driver_id == rte_cryptodev_driver_id_get(
1754 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1755 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1756 DIGEST_BYTE_LENGTH_SHA1,
1757 "Generated digest data not as expected");
1759 return TEST_SUCCESS;
1762 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1764 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1766 static uint8_t hmac_sha512_key[] = {
1767 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1768 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1769 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1770 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1771 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1772 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1773 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1774 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1776 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1777 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1778 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1779 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1780 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1781 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1782 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1783 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1784 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1789 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1790 struct crypto_unittest_params *ut_params,
1791 uint8_t *cipher_key,
1795 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1796 struct crypto_unittest_params *ut_params,
1797 struct crypto_testsuite_params *ts_params,
1798 const uint8_t *cipher,
1799 const uint8_t *digest,
1804 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1805 struct crypto_unittest_params *ut_params,
1806 uint8_t *cipher_key,
1810 /* Setup Cipher Parameters */
1811 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1812 ut_params->cipher_xform.next = NULL;
1814 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1815 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1816 ut_params->cipher_xform.cipher.key.data = cipher_key;
1817 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1818 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1819 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1821 /* Setup HMAC Parameters */
1822 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1823 ut_params->auth_xform.next = &ut_params->cipher_xform;
1825 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1826 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1827 ut_params->auth_xform.auth.key.data = hmac_key;
1828 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1829 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1831 return TEST_SUCCESS;
1836 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1837 struct crypto_unittest_params *ut_params,
1838 struct crypto_testsuite_params *ts_params,
1839 const uint8_t *cipher,
1840 const uint8_t *digest,
1843 /* Generate test mbuf data and digest */
1844 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1847 QUOTE_512_BYTES, 0);
1849 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1850 DIGEST_BYTE_LENGTH_SHA512);
1851 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1853 rte_memcpy(ut_params->digest,
1855 DIGEST_BYTE_LENGTH_SHA512);
1857 /* Generate Crypto op data structure */
1858 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1859 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1860 TEST_ASSERT_NOT_NULL(ut_params->op,
1861 "Failed to allocate symmetric crypto operation struct");
1863 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1865 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1867 /* set crypto operation source mbuf */
1868 sym_op->m_src = ut_params->ibuf;
1870 sym_op->auth.digest.data = ut_params->digest;
1871 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1872 ut_params->ibuf, QUOTE_512_BYTES);
1874 sym_op->auth.data.offset = 0;
1875 sym_op->auth.data.length = QUOTE_512_BYTES;
1877 /* Copy IV at the end of the crypto operation */
1878 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1879 iv, CIPHER_IV_LENGTH_AES_CBC);
1881 sym_op->cipher.data.offset = 0;
1882 sym_op->cipher.data.length = QUOTE_512_BYTES;
1884 /* Process crypto operation */
1885 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1886 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1888 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1889 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
1890 ut_params->op, 1, 1, 0, 0);
1892 TEST_ASSERT_NOT_NULL(
1893 process_crypto_request(ts_params->valid_devs[0],
1895 "failed to process sym crypto op");
1897 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1898 "crypto op processing failed");
1900 ut_params->obuf = ut_params->op->sym->m_src;
1903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1904 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1907 "Plaintext data not as expected");
1910 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1911 "Digest verification failed");
1913 return TEST_SUCCESS;
1917 test_blockcipher(enum blockcipher_test_type test_type)
1919 struct crypto_testsuite_params *ts_params = &testsuite_params;
1922 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1923 ts_params->op_mpool,
1924 ts_params->session_mpool, ts_params->session_priv_mpool,
1925 ts_params->valid_devs[0],
1928 if (status == -ENOTSUP)
1931 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1933 return TEST_SUCCESS;
1937 test_AES_cipheronly_all(void)
1939 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1943 test_AES_docsis_all(void)
1945 /* Data-path service does not support DOCSIS yet */
1946 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1948 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1952 test_DES_docsis_all(void)
1954 /* Data-path service does not support DOCSIS yet */
1955 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1957 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1961 test_DES_cipheronly_all(void)
1963 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1967 test_authonly_all(void)
1969 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1973 test_AES_chain_all(void)
1975 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1979 test_3DES_chain_all(void)
1981 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1985 test_3DES_cipheronly_all(void)
1987 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1990 /* ***** SNOW 3G Tests ***** */
1992 create_wireless_algo_hash_session(uint8_t dev_id,
1993 const uint8_t *key, const uint8_t key_len,
1994 const uint8_t iv_len, const uint8_t auth_len,
1995 enum rte_crypto_auth_operation op,
1996 enum rte_crypto_auth_algorithm algo)
1998 uint8_t hash_key[key_len];
2001 struct crypto_testsuite_params *ts_params = &testsuite_params;
2002 struct crypto_unittest_params *ut_params = &unittest_params;
2004 memcpy(hash_key, key, key_len);
2006 debug_hexdump(stdout, "key:", key, key_len);
2008 /* Setup Authentication Parameters */
2009 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2010 ut_params->auth_xform.next = NULL;
2012 ut_params->auth_xform.auth.op = op;
2013 ut_params->auth_xform.auth.algo = algo;
2014 ut_params->auth_xform.auth.key.length = key_len;
2015 ut_params->auth_xform.auth.key.data = hash_key;
2016 ut_params->auth_xform.auth.digest_length = auth_len;
2017 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2018 ut_params->auth_xform.auth.iv.length = iv_len;
2019 ut_params->sess = rte_cryptodev_sym_session_create(
2020 ts_params->session_mpool);
2022 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2023 &ut_params->auth_xform,
2024 ts_params->session_priv_mpool);
2025 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2026 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2031 create_wireless_algo_cipher_session(uint8_t dev_id,
2032 enum rte_crypto_cipher_operation op,
2033 enum rte_crypto_cipher_algorithm algo,
2034 const uint8_t *key, const uint8_t key_len,
2037 uint8_t cipher_key[key_len];
2039 struct crypto_testsuite_params *ts_params = &testsuite_params;
2040 struct crypto_unittest_params *ut_params = &unittest_params;
2042 memcpy(cipher_key, key, key_len);
2044 /* Setup Cipher Parameters */
2045 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2046 ut_params->cipher_xform.next = NULL;
2048 ut_params->cipher_xform.cipher.algo = algo;
2049 ut_params->cipher_xform.cipher.op = op;
2050 ut_params->cipher_xform.cipher.key.data = cipher_key;
2051 ut_params->cipher_xform.cipher.key.length = key_len;
2052 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2053 ut_params->cipher_xform.cipher.iv.length = iv_len;
2055 debug_hexdump(stdout, "key:", key, key_len);
2057 /* Create Crypto session */
2058 ut_params->sess = rte_cryptodev_sym_session_create(
2059 ts_params->session_mpool);
2061 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2062 &ut_params->cipher_xform,
2063 ts_params->session_priv_mpool);
2064 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2065 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2070 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2071 unsigned int cipher_len,
2072 unsigned int cipher_offset)
2074 struct crypto_testsuite_params *ts_params = &testsuite_params;
2075 struct crypto_unittest_params *ut_params = &unittest_params;
2077 /* Generate Crypto op data structure */
2078 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2079 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2080 TEST_ASSERT_NOT_NULL(ut_params->op,
2081 "Failed to allocate pktmbuf offload");
2083 /* Set crypto operation data parameters */
2084 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2086 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2088 /* set crypto operation source mbuf */
2089 sym_op->m_src = ut_params->ibuf;
2092 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2094 sym_op->cipher.data.length = cipher_len;
2095 sym_op->cipher.data.offset = cipher_offset;
2100 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2101 unsigned int cipher_len,
2102 unsigned int cipher_offset)
2104 struct crypto_testsuite_params *ts_params = &testsuite_params;
2105 struct crypto_unittest_params *ut_params = &unittest_params;
2107 /* Generate Crypto op data structure */
2108 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2109 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2110 TEST_ASSERT_NOT_NULL(ut_params->op,
2111 "Failed to allocate pktmbuf offload");
2113 /* Set crypto operation data parameters */
2114 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2116 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2118 /* set crypto operation source mbuf */
2119 sym_op->m_src = ut_params->ibuf;
2120 sym_op->m_dst = ut_params->obuf;
2123 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2125 sym_op->cipher.data.length = cipher_len;
2126 sym_op->cipher.data.offset = cipher_offset;
2131 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2132 enum rte_crypto_cipher_operation cipher_op,
2133 enum rte_crypto_auth_operation auth_op,
2134 enum rte_crypto_auth_algorithm auth_algo,
2135 enum rte_crypto_cipher_algorithm cipher_algo,
2136 const uint8_t *key, uint8_t key_len,
2137 uint8_t auth_iv_len, uint8_t auth_len,
2138 uint8_t cipher_iv_len)
2141 uint8_t cipher_auth_key[key_len];
2144 struct crypto_testsuite_params *ts_params = &testsuite_params;
2145 struct crypto_unittest_params *ut_params = &unittest_params;
2147 memcpy(cipher_auth_key, key, key_len);
2149 /* Setup Authentication Parameters */
2150 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2151 ut_params->auth_xform.next = NULL;
2153 ut_params->auth_xform.auth.op = auth_op;
2154 ut_params->auth_xform.auth.algo = auth_algo;
2155 ut_params->auth_xform.auth.key.length = key_len;
2156 /* Hash key = cipher key */
2157 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2158 ut_params->auth_xform.auth.digest_length = auth_len;
2159 /* Auth IV will be after cipher IV */
2160 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2161 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2163 /* Setup Cipher Parameters */
2164 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2165 ut_params->cipher_xform.next = &ut_params->auth_xform;
2167 ut_params->cipher_xform.cipher.algo = cipher_algo;
2168 ut_params->cipher_xform.cipher.op = cipher_op;
2169 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2170 ut_params->cipher_xform.cipher.key.length = key_len;
2171 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2172 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2174 debug_hexdump(stdout, "key:", key, key_len);
2176 /* Create Crypto session*/
2177 ut_params->sess = rte_cryptodev_sym_session_create(
2178 ts_params->session_mpool);
2179 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2181 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2182 &ut_params->cipher_xform,
2183 ts_params->session_priv_mpool);
2184 if (status == -ENOTSUP)
2187 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2192 create_wireless_cipher_auth_session(uint8_t dev_id,
2193 enum rte_crypto_cipher_operation cipher_op,
2194 enum rte_crypto_auth_operation auth_op,
2195 enum rte_crypto_auth_algorithm auth_algo,
2196 enum rte_crypto_cipher_algorithm cipher_algo,
2197 const struct wireless_test_data *tdata)
2199 const uint8_t key_len = tdata->key.len;
2200 uint8_t cipher_auth_key[key_len];
2203 struct crypto_testsuite_params *ts_params = &testsuite_params;
2204 struct crypto_unittest_params *ut_params = &unittest_params;
2205 const uint8_t *key = tdata->key.data;
2206 const uint8_t auth_len = tdata->digest.len;
2207 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2208 uint8_t auth_iv_len = tdata->auth_iv.len;
2210 memcpy(cipher_auth_key, key, key_len);
2212 /* Setup Authentication Parameters */
2213 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2214 ut_params->auth_xform.next = NULL;
2216 ut_params->auth_xform.auth.op = auth_op;
2217 ut_params->auth_xform.auth.algo = auth_algo;
2218 ut_params->auth_xform.auth.key.length = key_len;
2219 /* Hash key = cipher key */
2220 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2221 ut_params->auth_xform.auth.digest_length = auth_len;
2222 /* Auth IV will be after cipher IV */
2223 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2224 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2226 /* Setup Cipher Parameters */
2227 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2228 ut_params->cipher_xform.next = &ut_params->auth_xform;
2230 ut_params->cipher_xform.cipher.algo = cipher_algo;
2231 ut_params->cipher_xform.cipher.op = cipher_op;
2232 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2233 ut_params->cipher_xform.cipher.key.length = key_len;
2234 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2235 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2238 debug_hexdump(stdout, "key:", key, key_len);
2240 /* Create Crypto session*/
2241 ut_params->sess = rte_cryptodev_sym_session_create(
2242 ts_params->session_mpool);
2244 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2245 &ut_params->cipher_xform,
2246 ts_params->session_priv_mpool);
2247 if (status == -ENOTSUP)
2250 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2251 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2256 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2257 const struct wireless_test_data *tdata)
2259 return create_wireless_cipher_auth_session(dev_id,
2260 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2261 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2262 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2266 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2267 enum rte_crypto_cipher_operation cipher_op,
2268 enum rte_crypto_auth_operation auth_op,
2269 enum rte_crypto_auth_algorithm auth_algo,
2270 enum rte_crypto_cipher_algorithm cipher_algo,
2271 const uint8_t *key, const uint8_t key_len,
2272 uint8_t auth_iv_len, uint8_t auth_len,
2273 uint8_t cipher_iv_len)
2275 uint8_t auth_cipher_key[key_len];
2277 struct crypto_testsuite_params *ts_params = &testsuite_params;
2278 struct crypto_unittest_params *ut_params = &unittest_params;
2280 memcpy(auth_cipher_key, key, key_len);
2282 /* Setup Authentication Parameters */
2283 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2284 ut_params->auth_xform.auth.op = auth_op;
2285 ut_params->auth_xform.next = &ut_params->cipher_xform;
2286 ut_params->auth_xform.auth.algo = auth_algo;
2287 ut_params->auth_xform.auth.key.length = key_len;
2288 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2289 ut_params->auth_xform.auth.digest_length = auth_len;
2290 /* Auth IV will be after cipher IV */
2291 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2292 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2294 /* Setup Cipher Parameters */
2295 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2296 ut_params->cipher_xform.next = NULL;
2297 ut_params->cipher_xform.cipher.algo = cipher_algo;
2298 ut_params->cipher_xform.cipher.op = cipher_op;
2299 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2300 ut_params->cipher_xform.cipher.key.length = key_len;
2301 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2302 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2304 debug_hexdump(stdout, "key:", key, key_len);
2306 /* Create Crypto session*/
2307 ut_params->sess = rte_cryptodev_sym_session_create(
2308 ts_params->session_mpool);
2309 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2311 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2312 ut_params->auth_xform.next = NULL;
2313 ut_params->cipher_xform.next = &ut_params->auth_xform;
2314 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2315 &ut_params->cipher_xform,
2316 ts_params->session_priv_mpool);
2319 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2320 &ut_params->auth_xform,
2321 ts_params->session_priv_mpool);
2323 if (status == -ENOTSUP)
2326 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2332 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2333 unsigned int auth_tag_len,
2334 const uint8_t *iv, unsigned int iv_len,
2335 unsigned int data_pad_len,
2336 enum rte_crypto_auth_operation op,
2337 unsigned int auth_len, unsigned int auth_offset)
2339 struct crypto_testsuite_params *ts_params = &testsuite_params;
2341 struct crypto_unittest_params *ut_params = &unittest_params;
2343 /* Generate Crypto op data structure */
2344 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2345 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2346 TEST_ASSERT_NOT_NULL(ut_params->op,
2347 "Failed to allocate pktmbuf offload");
2349 /* Set crypto operation data parameters */
2350 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2352 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2354 /* set crypto operation source mbuf */
2355 sym_op->m_src = ut_params->ibuf;
2358 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2361 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2362 ut_params->ibuf, auth_tag_len);
2364 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2365 "no room to append auth tag");
2366 ut_params->digest = sym_op->auth.digest.data;
2367 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2368 ut_params->ibuf, data_pad_len);
2369 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2370 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2372 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2374 debug_hexdump(stdout, "digest:",
2375 sym_op->auth.digest.data,
2378 sym_op->auth.data.length = auth_len;
2379 sym_op->auth.data.offset = auth_offset;
2385 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2386 enum rte_crypto_auth_operation op)
2388 struct crypto_testsuite_params *ts_params = &testsuite_params;
2389 struct crypto_unittest_params *ut_params = &unittest_params;
2391 const uint8_t *auth_tag = tdata->digest.data;
2392 const unsigned int auth_tag_len = tdata->digest.len;
2393 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2394 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2396 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2397 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2398 const uint8_t *auth_iv = tdata->auth_iv.data;
2399 const uint8_t auth_iv_len = tdata->auth_iv.len;
2400 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2401 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2403 /* Generate Crypto op data structure */
2404 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2405 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2406 TEST_ASSERT_NOT_NULL(ut_params->op,
2407 "Failed to allocate pktmbuf offload");
2408 /* Set crypto operation data parameters */
2409 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2411 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2413 /* set crypto operation source mbuf */
2414 sym_op->m_src = ut_params->ibuf;
2417 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2418 ut_params->ibuf, auth_tag_len);
2420 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2421 "no room to append auth tag");
2422 ut_params->digest = sym_op->auth.digest.data;
2423 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2424 ut_params->ibuf, data_pad_len);
2425 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2426 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2428 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2430 debug_hexdump(stdout, "digest:",
2431 sym_op->auth.digest.data,
2434 /* Copy cipher and auth IVs at the end of the crypto operation */
2435 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2437 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2438 iv_ptr += cipher_iv_len;
2439 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2441 sym_op->cipher.data.length = cipher_len;
2442 sym_op->cipher.data.offset = 0;
2443 sym_op->auth.data.length = auth_len;
2444 sym_op->auth.data.offset = 0;
2450 create_zuc_cipher_hash_generate_operation(
2451 const struct wireless_test_data *tdata)
2453 return create_wireless_cipher_hash_operation(tdata,
2454 RTE_CRYPTO_AUTH_OP_GENERATE);
2458 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2459 const unsigned auth_tag_len,
2460 const uint8_t *auth_iv, uint8_t auth_iv_len,
2461 unsigned data_pad_len,
2462 enum rte_crypto_auth_operation op,
2463 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2464 const unsigned cipher_len, const unsigned cipher_offset,
2465 const unsigned auth_len, const unsigned auth_offset)
2467 struct crypto_testsuite_params *ts_params = &testsuite_params;
2468 struct crypto_unittest_params *ut_params = &unittest_params;
2470 enum rte_crypto_cipher_algorithm cipher_algo =
2471 ut_params->cipher_xform.cipher.algo;
2472 enum rte_crypto_auth_algorithm auth_algo =
2473 ut_params->auth_xform.auth.algo;
2475 /* Generate Crypto op data structure */
2476 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2477 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2478 TEST_ASSERT_NOT_NULL(ut_params->op,
2479 "Failed to allocate pktmbuf offload");
2480 /* Set crypto operation data parameters */
2481 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2483 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2485 /* set crypto operation source mbuf */
2486 sym_op->m_src = ut_params->ibuf;
2489 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2490 ut_params->ibuf, auth_tag_len);
2492 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2493 "no room to append auth tag");
2494 ut_params->digest = sym_op->auth.digest.data;
2496 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2497 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2498 ut_params->ibuf, data_pad_len);
2500 struct rte_mbuf *m = ut_params->ibuf;
2501 unsigned int offset = data_pad_len;
2503 while (offset > m->data_len && m->next != NULL) {
2504 offset -= m->data_len;
2507 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2511 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2512 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2514 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2516 debug_hexdump(stdout, "digest:",
2517 sym_op->auth.digest.data,
2520 /* Copy cipher and auth IVs at the end of the crypto operation */
2521 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2523 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2524 iv_ptr += cipher_iv_len;
2525 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2527 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2528 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2529 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2530 sym_op->cipher.data.length = cipher_len;
2531 sym_op->cipher.data.offset = cipher_offset;
2533 sym_op->cipher.data.length = cipher_len >> 3;
2534 sym_op->cipher.data.offset = cipher_offset >> 3;
2537 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2538 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2539 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2540 sym_op->auth.data.length = auth_len;
2541 sym_op->auth.data.offset = auth_offset;
2543 sym_op->auth.data.length = auth_len >> 3;
2544 sym_op->auth.data.offset = auth_offset >> 3;
2551 create_wireless_algo_auth_cipher_operation(
2552 const uint8_t *auth_tag, unsigned int auth_tag_len,
2553 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2554 const uint8_t *auth_iv, uint8_t auth_iv_len,
2555 unsigned int data_pad_len,
2556 unsigned int cipher_len, unsigned int cipher_offset,
2557 unsigned int auth_len, unsigned int auth_offset,
2558 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2560 struct crypto_testsuite_params *ts_params = &testsuite_params;
2561 struct crypto_unittest_params *ut_params = &unittest_params;
2563 enum rte_crypto_cipher_algorithm cipher_algo =
2564 ut_params->cipher_xform.cipher.algo;
2565 enum rte_crypto_auth_algorithm auth_algo =
2566 ut_params->auth_xform.auth.algo;
2568 /* Generate Crypto op data structure */
2569 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2570 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2571 TEST_ASSERT_NOT_NULL(ut_params->op,
2572 "Failed to allocate pktmbuf offload");
2574 /* Set crypto operation data parameters */
2575 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2577 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2579 /* set crypto operation mbufs */
2580 sym_op->m_src = ut_params->ibuf;
2581 if (op_mode == OUT_OF_PLACE)
2582 sym_op->m_dst = ut_params->obuf;
2586 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2587 (op_mode == IN_PLACE ?
2588 ut_params->ibuf : ut_params->obuf),
2589 uint8_t *, data_pad_len);
2590 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2591 (op_mode == IN_PLACE ?
2592 ut_params->ibuf : ut_params->obuf),
2594 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2596 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2597 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2598 sym_op->m_src : sym_op->m_dst);
2599 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2600 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2601 sgl_buf = sgl_buf->next;
2603 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2604 uint8_t *, remaining_off);
2605 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2607 memset(sym_op->auth.digest.data, 0, remaining_off);
2608 while (sgl_buf->next != NULL) {
2609 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2610 0, rte_pktmbuf_data_len(sgl_buf));
2611 sgl_buf = sgl_buf->next;
2615 /* Copy digest for the verification */
2617 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2619 /* Copy cipher and auth IVs at the end of the crypto operation */
2620 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2621 ut_params->op, uint8_t *, IV_OFFSET);
2623 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2624 iv_ptr += cipher_iv_len;
2625 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2627 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2628 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2629 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2630 sym_op->cipher.data.length = cipher_len;
2631 sym_op->cipher.data.offset = cipher_offset;
2633 sym_op->cipher.data.length = cipher_len >> 3;
2634 sym_op->cipher.data.offset = cipher_offset >> 3;
2637 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2638 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2639 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2640 sym_op->auth.data.length = auth_len;
2641 sym_op->auth.data.offset = auth_offset;
2643 sym_op->auth.data.length = auth_len >> 3;
2644 sym_op->auth.data.offset = auth_offset >> 3;
2651 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2653 struct crypto_testsuite_params *ts_params = &testsuite_params;
2654 struct crypto_unittest_params *ut_params = &unittest_params;
2657 unsigned plaintext_pad_len;
2658 unsigned plaintext_len;
2660 struct rte_cryptodev_info dev_info;
2662 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2663 uint64_t feat_flags = dev_info.feature_flags;
2665 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2666 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2667 printf("Device doesn't support NON-Byte Aligned Data.\n");
2671 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2672 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2673 printf("Device doesn't support RAW data-path APIs.\n");
2677 /* Verify the capabilities */
2678 struct rte_cryptodev_sym_capability_idx cap_idx;
2679 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2680 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2681 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2685 /* Create SNOW 3G session */
2686 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2687 tdata->key.data, tdata->key.len,
2688 tdata->auth_iv.len, tdata->digest.len,
2689 RTE_CRYPTO_AUTH_OP_GENERATE,
2690 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2694 /* alloc mbuf and set payload */
2695 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2697 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2698 rte_pktmbuf_tailroom(ut_params->ibuf));
2700 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2701 /* Append data which is padded to a multiple of */
2702 /* the algorithms block size */
2703 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2704 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2706 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2708 /* Create SNOW 3G operation */
2709 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2710 tdata->auth_iv.data, tdata->auth_iv.len,
2711 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2712 tdata->validAuthLenInBits.len,
2717 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2718 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2719 ut_params->op, 0, 1, 1, 0);
2721 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2723 ut_params->obuf = ut_params->op->sym->m_src;
2724 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2725 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2726 + plaintext_pad_len;
2729 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2732 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2733 "SNOW 3G Generated auth tag not as expected");
2739 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2741 struct crypto_testsuite_params *ts_params = &testsuite_params;
2742 struct crypto_unittest_params *ut_params = &unittest_params;
2745 unsigned plaintext_pad_len;
2746 unsigned plaintext_len;
2748 struct rte_cryptodev_info dev_info;
2750 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2751 uint64_t feat_flags = dev_info.feature_flags;
2753 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2754 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2755 printf("Device doesn't support NON-Byte Aligned Data.\n");
2759 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2760 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2761 printf("Device doesn't support RAW data-path APIs.\n");
2765 /* Verify the capabilities */
2766 struct rte_cryptodev_sym_capability_idx cap_idx;
2767 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2768 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2769 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2773 /* Create SNOW 3G session */
2774 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2775 tdata->key.data, tdata->key.len,
2776 tdata->auth_iv.len, tdata->digest.len,
2777 RTE_CRYPTO_AUTH_OP_VERIFY,
2778 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2781 /* alloc mbuf and set payload */
2782 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2784 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2785 rte_pktmbuf_tailroom(ut_params->ibuf));
2787 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2788 /* Append data which is padded to a multiple of */
2789 /* the algorithms block size */
2790 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2791 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2793 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2795 /* Create SNOW 3G operation */
2796 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2798 tdata->auth_iv.data, tdata->auth_iv.len,
2800 RTE_CRYPTO_AUTH_OP_VERIFY,
2801 tdata->validAuthLenInBits.len,
2806 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2807 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2808 ut_params->op, 0, 1, 1, 0);
2810 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2812 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2813 ut_params->obuf = ut_params->op->sym->m_src;
2814 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2815 + plaintext_pad_len;
2818 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2827 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2829 struct crypto_testsuite_params *ts_params = &testsuite_params;
2830 struct crypto_unittest_params *ut_params = &unittest_params;
2833 unsigned plaintext_pad_len;
2834 unsigned plaintext_len;
2836 struct rte_cryptodev_info dev_info;
2838 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2839 uint64_t feat_flags = dev_info.feature_flags;
2841 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2842 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2843 printf("Device doesn't support RAW data-path APIs.\n");
2847 /* Verify the capabilities */
2848 struct rte_cryptodev_sym_capability_idx cap_idx;
2849 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2850 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2851 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2855 /* Create KASUMI session */
2856 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2857 tdata->key.data, tdata->key.len,
2858 0, tdata->digest.len,
2859 RTE_CRYPTO_AUTH_OP_GENERATE,
2860 RTE_CRYPTO_AUTH_KASUMI_F9);
2864 /* alloc mbuf and set payload */
2865 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2867 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2868 rte_pktmbuf_tailroom(ut_params->ibuf));
2870 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2871 /* Append data which is padded to a multiple of */
2872 /* the algorithms block size */
2873 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2874 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2876 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2878 /* Create KASUMI operation */
2879 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2881 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2882 tdata->plaintext.len,
2887 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2888 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2890 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2891 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2892 ut_params->op, 0, 1, 1, 0);
2894 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2897 ut_params->obuf = ut_params->op->sym->m_src;
2898 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2899 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2900 + plaintext_pad_len;
2903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2906 DIGEST_BYTE_LENGTH_KASUMI_F9,
2907 "KASUMI Generated auth tag not as expected");
2913 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2915 struct crypto_testsuite_params *ts_params = &testsuite_params;
2916 struct crypto_unittest_params *ut_params = &unittest_params;
2919 unsigned plaintext_pad_len;
2920 unsigned plaintext_len;
2922 struct rte_cryptodev_info dev_info;
2924 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2925 uint64_t feat_flags = dev_info.feature_flags;
2927 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2928 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2929 printf("Device doesn't support RAW data-path APIs.\n");
2933 /* Verify the capabilities */
2934 struct rte_cryptodev_sym_capability_idx cap_idx;
2935 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2936 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2937 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2941 /* Create KASUMI session */
2942 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2943 tdata->key.data, tdata->key.len,
2944 0, tdata->digest.len,
2945 RTE_CRYPTO_AUTH_OP_VERIFY,
2946 RTE_CRYPTO_AUTH_KASUMI_F9);
2949 /* alloc mbuf and set payload */
2950 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2952 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2953 rte_pktmbuf_tailroom(ut_params->ibuf));
2955 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2956 /* Append data which is padded to a multiple */
2957 /* of the algorithms block size */
2958 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2959 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2961 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2963 /* Create KASUMI operation */
2964 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2968 RTE_CRYPTO_AUTH_OP_VERIFY,
2969 tdata->plaintext.len,
2974 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2975 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2976 ut_params->op, 0, 1, 1, 0);
2978 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2980 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2981 ut_params->obuf = ut_params->op->sym->m_src;
2982 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2983 + plaintext_pad_len;
2986 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2995 test_snow3g_hash_generate_test_case_1(void)
2997 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3001 test_snow3g_hash_generate_test_case_2(void)
3003 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3007 test_snow3g_hash_generate_test_case_3(void)
3009 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3013 test_snow3g_hash_generate_test_case_4(void)
3015 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3019 test_snow3g_hash_generate_test_case_5(void)
3021 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3025 test_snow3g_hash_generate_test_case_6(void)
3027 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3031 test_snow3g_hash_verify_test_case_1(void)
3033 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3038 test_snow3g_hash_verify_test_case_2(void)
3040 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3044 test_snow3g_hash_verify_test_case_3(void)
3046 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3050 test_snow3g_hash_verify_test_case_4(void)
3052 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3056 test_snow3g_hash_verify_test_case_5(void)
3058 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3062 test_snow3g_hash_verify_test_case_6(void)
3064 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3068 test_kasumi_hash_generate_test_case_1(void)
3070 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3074 test_kasumi_hash_generate_test_case_2(void)
3076 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3080 test_kasumi_hash_generate_test_case_3(void)
3082 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3086 test_kasumi_hash_generate_test_case_4(void)
3088 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3092 test_kasumi_hash_generate_test_case_5(void)
3094 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3098 test_kasumi_hash_generate_test_case_6(void)
3100 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3104 test_kasumi_hash_verify_test_case_1(void)
3106 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3110 test_kasumi_hash_verify_test_case_2(void)
3112 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3116 test_kasumi_hash_verify_test_case_3(void)
3118 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3122 test_kasumi_hash_verify_test_case_4(void)
3124 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3128 test_kasumi_hash_verify_test_case_5(void)
3130 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3134 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3136 struct crypto_testsuite_params *ts_params = &testsuite_params;
3137 struct crypto_unittest_params *ut_params = &unittest_params;
3140 uint8_t *plaintext, *ciphertext;
3141 unsigned plaintext_pad_len;
3142 unsigned plaintext_len;
3143 struct rte_cryptodev_info dev_info;
3145 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3146 uint64_t feat_flags = dev_info.feature_flags;
3148 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3149 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3150 printf("Device doesn't support RAW data-path APIs.\n");
3154 /* Verify the capabilities */
3155 struct rte_cryptodev_sym_capability_idx cap_idx;
3156 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3157 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3158 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3162 /* Create KASUMI session */
3163 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3164 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3165 RTE_CRYPTO_CIPHER_KASUMI_F8,
3166 tdata->key.data, tdata->key.len,
3167 tdata->cipher_iv.len);
3171 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3173 /* Clear mbuf payload */
3174 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3175 rte_pktmbuf_tailroom(ut_params->ibuf));
3177 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3178 /* Append data which is padded to a multiple */
3179 /* of the algorithms block size */
3180 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3181 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3183 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3185 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3187 /* Create KASUMI operation */
3188 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3189 tdata->cipher_iv.len,
3190 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3191 tdata->validCipherOffsetInBits.len);
3195 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3196 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3197 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3199 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3201 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3203 ut_params->obuf = ut_params->op->sym->m_dst;
3204 if (ut_params->obuf)
3205 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3207 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3209 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3211 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3212 (tdata->validCipherOffsetInBits.len >> 3);
3214 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3216 reference_ciphertext,
3217 tdata->validCipherLenInBits.len,
3218 "KASUMI Ciphertext data not as expected");
3223 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3225 struct crypto_testsuite_params *ts_params = &testsuite_params;
3226 struct crypto_unittest_params *ut_params = &unittest_params;
3230 unsigned int plaintext_pad_len;
3231 unsigned int plaintext_len;
3233 uint8_t buffer[10000];
3234 const uint8_t *ciphertext;
3236 struct rte_cryptodev_info dev_info;
3238 /* Verify the capabilities */
3239 struct rte_cryptodev_sym_capability_idx cap_idx;
3240 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3241 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3242 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3246 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3248 uint64_t feat_flags = dev_info.feature_flags;
3250 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3251 printf("Device doesn't support in-place scatter-gather. "
3256 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3257 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3258 printf("Device doesn't support RAW data-path APIs.\n");
3262 /* Create KASUMI session */
3263 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3264 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3265 RTE_CRYPTO_CIPHER_KASUMI_F8,
3266 tdata->key.data, tdata->key.len,
3267 tdata->cipher_iv.len);
3271 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3274 /* Append data which is padded to a multiple */
3275 /* of the algorithms block size */
3276 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3278 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3279 plaintext_pad_len, 10, 0);
3281 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3283 /* Create KASUMI operation */
3284 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3285 tdata->cipher_iv.len,
3286 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3287 tdata->validCipherOffsetInBits.len);
3291 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3292 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3293 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3295 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3297 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3299 ut_params->obuf = ut_params->op->sym->m_dst;
3301 if (ut_params->obuf)
3302 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3303 plaintext_len, buffer);
3305 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3306 tdata->validCipherOffsetInBits.len >> 3,
3307 plaintext_len, buffer);
3310 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3312 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3313 (tdata->validCipherOffsetInBits.len >> 3);
3315 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3317 reference_ciphertext,
3318 tdata->validCipherLenInBits.len,
3319 "KASUMI Ciphertext data not as expected");
3324 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3326 struct crypto_testsuite_params *ts_params = &testsuite_params;
3327 struct crypto_unittest_params *ut_params = &unittest_params;
3330 uint8_t *plaintext, *ciphertext;
3331 unsigned plaintext_pad_len;
3332 unsigned plaintext_len;
3334 /* Verify the capabilities */
3335 struct rte_cryptodev_sym_capability_idx cap_idx;
3336 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3337 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3338 /* Data-path service does not support OOP */
3339 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3343 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3346 /* Create KASUMI session */
3347 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3348 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3349 RTE_CRYPTO_CIPHER_KASUMI_F8,
3350 tdata->key.data, tdata->key.len,
3351 tdata->cipher_iv.len);
3355 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3356 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3358 /* Clear mbuf payload */
3359 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3360 rte_pktmbuf_tailroom(ut_params->ibuf));
3362 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3363 /* Append data which is padded to a multiple */
3364 /* of the algorithms block size */
3365 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3366 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3368 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3369 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3371 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3373 /* Create KASUMI operation */
3374 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3375 tdata->cipher_iv.len,
3376 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3377 tdata->validCipherOffsetInBits.len);
3381 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3383 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3385 ut_params->obuf = ut_params->op->sym->m_dst;
3386 if (ut_params->obuf)
3387 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3389 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3391 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3393 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3394 (tdata->validCipherOffsetInBits.len >> 3);
3396 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3398 reference_ciphertext,
3399 tdata->validCipherLenInBits.len,
3400 "KASUMI Ciphertext data not as expected");
3405 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3407 struct crypto_testsuite_params *ts_params = &testsuite_params;
3408 struct crypto_unittest_params *ut_params = &unittest_params;
3411 unsigned int plaintext_pad_len;
3412 unsigned int plaintext_len;
3414 const uint8_t *ciphertext;
3415 uint8_t buffer[2048];
3417 struct rte_cryptodev_info dev_info;
3419 /* Verify the capabilities */
3420 struct rte_cryptodev_sym_capability_idx cap_idx;
3421 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3422 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3423 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3427 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3430 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3432 uint64_t feat_flags = dev_info.feature_flags;
3433 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3434 printf("Device doesn't support out-of-place scatter-gather "
3435 "in both input and output mbufs. "
3440 /* Create KASUMI session */
3441 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3442 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3443 RTE_CRYPTO_CIPHER_KASUMI_F8,
3444 tdata->key.data, tdata->key.len,
3445 tdata->cipher_iv.len);
3449 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3450 /* Append data which is padded to a multiple */
3451 /* of the algorithms block size */
3452 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3454 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3455 plaintext_pad_len, 10, 0);
3456 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3457 plaintext_pad_len, 3, 0);
3459 /* Append data which is padded to a multiple */
3460 /* of the algorithms block size */
3461 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3463 /* Create KASUMI operation */
3464 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3465 tdata->cipher_iv.len,
3466 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3467 tdata->validCipherOffsetInBits.len);
3471 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3473 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3475 ut_params->obuf = ut_params->op->sym->m_dst;
3476 if (ut_params->obuf)
3477 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3478 plaintext_pad_len, buffer);
3480 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3481 tdata->validCipherOffsetInBits.len >> 3,
3482 plaintext_pad_len, buffer);
3484 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3485 (tdata->validCipherOffsetInBits.len >> 3);
3487 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3489 reference_ciphertext,
3490 tdata->validCipherLenInBits.len,
3491 "KASUMI Ciphertext data not as expected");
3497 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3499 struct crypto_testsuite_params *ts_params = &testsuite_params;
3500 struct crypto_unittest_params *ut_params = &unittest_params;
3503 uint8_t *ciphertext, *plaintext;
3504 unsigned ciphertext_pad_len;
3505 unsigned ciphertext_len;
3507 /* Verify the capabilities */
3508 struct rte_cryptodev_sym_capability_idx cap_idx;
3509 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3510 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3511 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3515 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3518 /* Create KASUMI session */
3519 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3520 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3521 RTE_CRYPTO_CIPHER_KASUMI_F8,
3522 tdata->key.data, tdata->key.len,
3523 tdata->cipher_iv.len);
3527 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3528 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3530 /* Clear mbuf payload */
3531 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3532 rte_pktmbuf_tailroom(ut_params->ibuf));
3534 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3535 /* Append data which is padded to a multiple */
3536 /* of the algorithms block size */
3537 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3538 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3539 ciphertext_pad_len);
3540 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3541 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3543 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3545 /* Create KASUMI operation */
3546 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3547 tdata->cipher_iv.len,
3548 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3549 tdata->validCipherOffsetInBits.len);
3553 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3555 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3557 ut_params->obuf = ut_params->op->sym->m_dst;
3558 if (ut_params->obuf)
3559 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3561 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3563 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3565 const uint8_t *reference_plaintext = tdata->plaintext.data +
3566 (tdata->validCipherOffsetInBits.len >> 3);
3568 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3570 reference_plaintext,
3571 tdata->validCipherLenInBits.len,
3572 "KASUMI Plaintext data not as expected");
3577 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3579 struct crypto_testsuite_params *ts_params = &testsuite_params;
3580 struct crypto_unittest_params *ut_params = &unittest_params;
3583 uint8_t *ciphertext, *plaintext;
3584 unsigned ciphertext_pad_len;
3585 unsigned ciphertext_len;
3586 struct rte_cryptodev_info dev_info;
3588 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3589 uint64_t feat_flags = dev_info.feature_flags;
3591 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3592 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3593 printf("Device doesn't support RAW data-path APIs.\n");
3597 /* Verify the capabilities */
3598 struct rte_cryptodev_sym_capability_idx cap_idx;
3599 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3600 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3601 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3605 /* Create KASUMI session */
3606 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3607 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3608 RTE_CRYPTO_CIPHER_KASUMI_F8,
3609 tdata->key.data, tdata->key.len,
3610 tdata->cipher_iv.len);
3614 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3616 /* Clear mbuf payload */
3617 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3618 rte_pktmbuf_tailroom(ut_params->ibuf));
3620 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3621 /* Append data which is padded to a multiple */
3622 /* of the algorithms block size */
3623 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3624 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3625 ciphertext_pad_len);
3626 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3628 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3630 /* Create KASUMI operation */
3631 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3632 tdata->cipher_iv.len,
3633 tdata->ciphertext.len,
3634 tdata->validCipherOffsetInBits.len);
3638 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3639 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3640 ut_params->op, 1, 0, 1, 0);
3642 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3644 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3646 ut_params->obuf = ut_params->op->sym->m_dst;
3647 if (ut_params->obuf)
3648 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3650 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3652 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3654 const uint8_t *reference_plaintext = tdata->plaintext.data +
3655 (tdata->validCipherOffsetInBits.len >> 3);
3657 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3659 reference_plaintext,
3660 tdata->validCipherLenInBits.len,
3661 "KASUMI Plaintext data not as expected");
3666 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3668 struct crypto_testsuite_params *ts_params = &testsuite_params;
3669 struct crypto_unittest_params *ut_params = &unittest_params;
3672 uint8_t *plaintext, *ciphertext;
3673 unsigned plaintext_pad_len;
3674 unsigned plaintext_len;
3675 struct rte_cryptodev_info dev_info;
3677 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3678 uint64_t feat_flags = dev_info.feature_flags;
3680 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3681 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3682 printf("Device doesn't support RAW data-path APIs.\n");
3686 /* Verify the capabilities */
3687 struct rte_cryptodev_sym_capability_idx cap_idx;
3688 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3689 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3690 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3694 /* Create SNOW 3G session */
3695 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3697 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3698 tdata->key.data, tdata->key.len,
3699 tdata->cipher_iv.len);
3703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3705 /* Clear mbuf payload */
3706 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3707 rte_pktmbuf_tailroom(ut_params->ibuf));
3709 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3710 /* Append data which is padded to a multiple of */
3711 /* the algorithms block size */
3712 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3713 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3715 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3717 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3719 /* Create SNOW 3G operation */
3720 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3721 tdata->cipher_iv.len,
3722 tdata->validCipherLenInBits.len,
3727 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3728 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3729 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3731 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3733 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3735 ut_params->obuf = ut_params->op->sym->m_dst;
3736 if (ut_params->obuf)
3737 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3739 ciphertext = plaintext;
3741 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3744 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3746 tdata->ciphertext.data,
3747 tdata->validDataLenInBits.len,
3748 "SNOW 3G Ciphertext data not as expected");
3754 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3756 struct crypto_testsuite_params *ts_params = &testsuite_params;
3757 struct crypto_unittest_params *ut_params = &unittest_params;
3758 uint8_t *plaintext, *ciphertext;
3761 unsigned plaintext_pad_len;
3762 unsigned plaintext_len;
3764 /* Verify the capabilities */
3765 struct rte_cryptodev_sym_capability_idx cap_idx;
3766 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3767 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3768 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3772 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3775 /* Create SNOW 3G session */
3776 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3777 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3778 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3779 tdata->key.data, tdata->key.len,
3780 tdata->cipher_iv.len);
3784 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3785 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3787 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3788 "Failed to allocate input buffer in mempool");
3789 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3790 "Failed to allocate output buffer in mempool");
3792 /* Clear mbuf payload */
3793 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3794 rte_pktmbuf_tailroom(ut_params->ibuf));
3796 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3797 /* Append data which is padded to a multiple of */
3798 /* the algorithms block size */
3799 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3800 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3802 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3803 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3805 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3807 /* Create SNOW 3G operation */
3808 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3809 tdata->cipher_iv.len,
3810 tdata->validCipherLenInBits.len,
3815 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3817 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3819 ut_params->obuf = ut_params->op->sym->m_dst;
3820 if (ut_params->obuf)
3821 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3823 ciphertext = plaintext;
3825 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3828 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3830 tdata->ciphertext.data,
3831 tdata->validDataLenInBits.len,
3832 "SNOW 3G Ciphertext data not as expected");
3837 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3839 struct crypto_testsuite_params *ts_params = &testsuite_params;
3840 struct crypto_unittest_params *ut_params = &unittest_params;
3843 unsigned int plaintext_pad_len;
3844 unsigned int plaintext_len;
3845 uint8_t buffer[10000];
3846 const uint8_t *ciphertext;
3848 struct rte_cryptodev_info dev_info;
3850 /* Verify the capabilities */
3851 struct rte_cryptodev_sym_capability_idx cap_idx;
3852 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3853 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3854 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3858 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3861 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3863 uint64_t feat_flags = dev_info.feature_flags;
3865 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3866 printf("Device doesn't support out-of-place scatter-gather "
3867 "in both input and output mbufs. "
3872 /* Create SNOW 3G session */
3873 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3874 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3875 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3876 tdata->key.data, tdata->key.len,
3877 tdata->cipher_iv.len);
3881 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3882 /* Append data which is padded to a multiple of */
3883 /* the algorithms block size */
3884 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3886 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3887 plaintext_pad_len, 10, 0);
3888 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3889 plaintext_pad_len, 3, 0);
3891 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3892 "Failed to allocate input buffer in mempool");
3893 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3894 "Failed to allocate output buffer in mempool");
3896 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3898 /* Create SNOW 3G operation */
3899 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3900 tdata->cipher_iv.len,
3901 tdata->validCipherLenInBits.len,
3906 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3908 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3910 ut_params->obuf = ut_params->op->sym->m_dst;
3911 if (ut_params->obuf)
3912 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3913 plaintext_len, buffer);
3915 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3916 plaintext_len, buffer);
3918 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3921 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3923 tdata->ciphertext.data,
3924 tdata->validDataLenInBits.len,
3925 "SNOW 3G Ciphertext data not as expected");
3930 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3932 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3934 uint8_t curr_byte, prev_byte;
3935 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3936 uint8_t lower_byte_mask = (1 << offset) - 1;
3939 prev_byte = buffer[0];
3940 buffer[0] >>= offset;
3942 for (i = 1; i < length_in_bytes; i++) {
3943 curr_byte = buffer[i];
3944 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3945 (curr_byte >> offset);
3946 prev_byte = curr_byte;
3951 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3953 struct crypto_testsuite_params *ts_params = &testsuite_params;
3954 struct crypto_unittest_params *ut_params = &unittest_params;
3955 uint8_t *plaintext, *ciphertext;
3957 uint32_t plaintext_len;
3958 uint32_t plaintext_pad_len;
3959 uint8_t extra_offset = 4;
3960 uint8_t *expected_ciphertext_shifted;
3961 struct rte_cryptodev_info dev_info;
3963 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3964 uint64_t feat_flags = dev_info.feature_flags;
3966 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3967 ((tdata->validDataLenInBits.len % 8) != 0)) {
3968 printf("Device doesn't support NON-Byte Aligned Data.\n");
3972 /* Verify the capabilities */
3973 struct rte_cryptodev_sym_capability_idx cap_idx;
3974 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3975 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3976 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3980 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3983 /* Create SNOW 3G session */
3984 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3985 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3986 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3987 tdata->key.data, tdata->key.len,
3988 tdata->cipher_iv.len);
3992 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3993 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3995 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3996 "Failed to allocate input buffer in mempool");
3997 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3998 "Failed to allocate output buffer in mempool");
4000 /* Clear mbuf payload */
4001 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4002 rte_pktmbuf_tailroom(ut_params->ibuf));
4004 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4006 * Append data which is padded to a
4007 * multiple of the algorithms block size
4009 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4011 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4014 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4016 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4017 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4019 #ifdef RTE_APP_TEST_DEBUG
4020 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4022 /* Create SNOW 3G operation */
4023 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4024 tdata->cipher_iv.len,
4025 tdata->validCipherLenInBits.len,
4030 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4034 ut_params->obuf = ut_params->op->sym->m_dst;
4035 if (ut_params->obuf)
4036 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4038 ciphertext = plaintext;
4040 #ifdef RTE_APP_TEST_DEBUG
4041 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4044 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4046 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4047 "failed to reserve memory for ciphertext shifted\n");
4049 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4050 ceil_byte_length(tdata->ciphertext.len));
4051 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4054 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4056 expected_ciphertext_shifted,
4057 tdata->validDataLenInBits.len,
4059 "SNOW 3G Ciphertext data not as expected");
4063 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4065 struct crypto_testsuite_params *ts_params = &testsuite_params;
4066 struct crypto_unittest_params *ut_params = &unittest_params;
4070 uint8_t *plaintext, *ciphertext;
4071 unsigned ciphertext_pad_len;
4072 unsigned ciphertext_len;
4073 struct rte_cryptodev_info dev_info;
4075 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4076 uint64_t feat_flags = dev_info.feature_flags;
4078 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4079 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4080 printf("Device doesn't support RAW data-path APIs.\n");
4084 /* Verify the capabilities */
4085 struct rte_cryptodev_sym_capability_idx cap_idx;
4086 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4087 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4088 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4092 /* Create SNOW 3G session */
4093 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4094 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4095 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4096 tdata->key.data, tdata->key.len,
4097 tdata->cipher_iv.len);
4101 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4103 /* Clear mbuf payload */
4104 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4105 rte_pktmbuf_tailroom(ut_params->ibuf));
4107 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4108 /* Append data which is padded to a multiple of */
4109 /* the algorithms block size */
4110 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4111 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4112 ciphertext_pad_len);
4113 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4115 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4117 /* Create SNOW 3G operation */
4118 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4119 tdata->cipher_iv.len,
4120 tdata->validCipherLenInBits.len,
4121 tdata->cipher.offset_bits);
4125 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4126 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4127 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4129 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4131 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4132 ut_params->obuf = ut_params->op->sym->m_dst;
4133 if (ut_params->obuf)
4134 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4136 plaintext = ciphertext;
4138 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4141 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4142 tdata->plaintext.data,
4143 tdata->validDataLenInBits.len,
4144 "SNOW 3G Plaintext data not as expected");
4148 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4150 struct crypto_testsuite_params *ts_params = &testsuite_params;
4151 struct crypto_unittest_params *ut_params = &unittest_params;
4155 uint8_t *plaintext, *ciphertext;
4156 unsigned ciphertext_pad_len;
4157 unsigned ciphertext_len;
4159 /* Verify the capabilities */
4160 struct rte_cryptodev_sym_capability_idx cap_idx;
4161 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4162 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4163 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4167 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4170 /* Create SNOW 3G session */
4171 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4172 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4173 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4174 tdata->key.data, tdata->key.len,
4175 tdata->cipher_iv.len);
4179 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4180 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4182 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4183 "Failed to allocate input buffer");
4184 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4185 "Failed to allocate output buffer");
4187 /* Clear mbuf payload */
4188 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4189 rte_pktmbuf_tailroom(ut_params->ibuf));
4191 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4192 rte_pktmbuf_tailroom(ut_params->obuf));
4194 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4195 /* Append data which is padded to a multiple of */
4196 /* the algorithms block size */
4197 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4198 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4199 ciphertext_pad_len);
4200 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4201 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4203 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4205 /* Create SNOW 3G operation */
4206 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4207 tdata->cipher_iv.len,
4208 tdata->validCipherLenInBits.len,
4213 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4215 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4216 ut_params->obuf = ut_params->op->sym->m_dst;
4217 if (ut_params->obuf)
4218 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4220 plaintext = ciphertext;
4222 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4225 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4226 tdata->plaintext.data,
4227 tdata->validDataLenInBits.len,
4228 "SNOW 3G Plaintext data not as expected");
4233 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4235 struct crypto_testsuite_params *ts_params = &testsuite_params;
4236 struct crypto_unittest_params *ut_params = &unittest_params;
4240 uint8_t *plaintext, *ciphertext;
4241 unsigned int plaintext_pad_len;
4242 unsigned int plaintext_len;
4244 struct rte_cryptodev_info dev_info;
4245 struct rte_cryptodev_sym_capability_idx cap_idx;
4247 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4248 uint64_t feat_flags = dev_info.feature_flags;
4250 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4251 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4252 (tdata->validDataLenInBits.len % 8 != 0))) {
4253 printf("Device doesn't support NON-Byte Aligned Data.\n");
4257 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4258 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4259 printf("Device doesn't support RAW data-path APIs.\n");
4263 /* Check if device supports ZUC EEA3 */
4264 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4265 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4267 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4271 /* Check if device supports ZUC EIA3 */
4272 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4273 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4275 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4279 /* Create ZUC session */
4280 retval = create_zuc_cipher_auth_encrypt_generate_session(
4281 ts_params->valid_devs[0],
4285 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4287 /* clear mbuf payload */
4288 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4289 rte_pktmbuf_tailroom(ut_params->ibuf));
4291 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4292 /* Append data which is padded to a multiple of */
4293 /* the algorithms block size */
4294 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4295 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4297 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4299 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4301 /* Create ZUC operation */
4302 retval = create_zuc_cipher_hash_generate_operation(tdata);
4306 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4307 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4308 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4310 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4312 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4313 ut_params->obuf = ut_params->op->sym->m_src;
4314 if (ut_params->obuf)
4315 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4317 ciphertext = plaintext;
4319 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4321 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4323 tdata->ciphertext.data,
4324 tdata->validDataLenInBits.len,
4325 "ZUC Ciphertext data not as expected");
4327 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4328 + plaintext_pad_len;
4331 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4335 "ZUC Generated auth tag not as expected");
4340 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4342 struct crypto_testsuite_params *ts_params = &testsuite_params;
4343 struct crypto_unittest_params *ut_params = &unittest_params;
4347 uint8_t *plaintext, *ciphertext;
4348 unsigned plaintext_pad_len;
4349 unsigned plaintext_len;
4350 struct rte_cryptodev_info dev_info;
4352 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4353 uint64_t feat_flags = dev_info.feature_flags;
4355 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4356 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4357 printf("Device doesn't support RAW data-path APIs.\n");
4361 /* Verify the capabilities */
4362 struct rte_cryptodev_sym_capability_idx cap_idx;
4363 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4364 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4365 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4368 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4369 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4370 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4374 /* Create SNOW 3G session */
4375 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4376 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4377 RTE_CRYPTO_AUTH_OP_GENERATE,
4378 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4379 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4380 tdata->key.data, tdata->key.len,
4381 tdata->auth_iv.len, tdata->digest.len,
4382 tdata->cipher_iv.len);
4385 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4387 /* clear mbuf payload */
4388 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4389 rte_pktmbuf_tailroom(ut_params->ibuf));
4391 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4392 /* Append data which is padded to a multiple of */
4393 /* the algorithms block size */
4394 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4395 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4397 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4399 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4401 /* Create SNOW 3G operation */
4402 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4403 tdata->digest.len, tdata->auth_iv.data,
4405 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4406 tdata->cipher_iv.data, tdata->cipher_iv.len,
4407 tdata->validCipherLenInBits.len,
4409 tdata->validAuthLenInBits.len,
4415 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4416 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4417 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4419 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4421 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4422 ut_params->obuf = ut_params->op->sym->m_src;
4423 if (ut_params->obuf)
4424 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4426 ciphertext = plaintext;
4428 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4430 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4432 tdata->ciphertext.data,
4433 tdata->validDataLenInBits.len,
4434 "SNOW 3G Ciphertext data not as expected");
4436 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4437 + plaintext_pad_len;
4440 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4443 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4444 "SNOW 3G Generated auth tag not as expected");
4449 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4450 uint8_t op_mode, uint8_t verify)
4452 struct crypto_testsuite_params *ts_params = &testsuite_params;
4453 struct crypto_unittest_params *ut_params = &unittest_params;
4457 uint8_t *plaintext = NULL, *ciphertext = NULL;
4458 unsigned int plaintext_pad_len;
4459 unsigned int plaintext_len;
4460 unsigned int ciphertext_pad_len;
4461 unsigned int ciphertext_len;
4463 struct rte_cryptodev_info dev_info;
4465 /* Verify the capabilities */
4466 struct rte_cryptodev_sym_capability_idx cap_idx;
4467 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4468 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4469 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4472 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4473 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4474 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4478 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4480 uint64_t feat_flags = dev_info.feature_flags;
4482 if (op_mode == OUT_OF_PLACE) {
4483 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4484 printf("Device doesn't support digest encrypted.\n");
4487 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4491 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4492 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4493 printf("Device doesn't support RAW data-path APIs.\n");
4497 /* Create SNOW 3G session */
4498 retval = create_wireless_algo_auth_cipher_session(
4499 ts_params->valid_devs[0],
4500 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4501 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4502 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4503 : RTE_CRYPTO_AUTH_OP_GENERATE),
4504 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4505 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4506 tdata->key.data, tdata->key.len,
4507 tdata->auth_iv.len, tdata->digest.len,
4508 tdata->cipher_iv.len);
4513 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4514 if (op_mode == OUT_OF_PLACE)
4515 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4517 /* clear mbuf payload */
4518 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4519 rte_pktmbuf_tailroom(ut_params->ibuf));
4520 if (op_mode == OUT_OF_PLACE)
4521 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4522 rte_pktmbuf_tailroom(ut_params->obuf));
4524 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4525 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4526 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4527 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4530 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4531 ciphertext_pad_len);
4532 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4533 if (op_mode == OUT_OF_PLACE)
4534 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4535 debug_hexdump(stdout, "ciphertext:", ciphertext,
4538 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4540 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4541 if (op_mode == OUT_OF_PLACE)
4542 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4543 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4546 /* Create SNOW 3G operation */
4547 retval = create_wireless_algo_auth_cipher_operation(
4548 tdata->digest.data, tdata->digest.len,
4549 tdata->cipher_iv.data, tdata->cipher_iv.len,
4550 tdata->auth_iv.data, tdata->auth_iv.len,
4551 (tdata->digest.offset_bytes == 0 ?
4552 (verify ? ciphertext_pad_len : plaintext_pad_len)
4553 : tdata->digest.offset_bytes),
4554 tdata->validCipherLenInBits.len,
4555 tdata->cipher.offset_bits,
4556 tdata->validAuthLenInBits.len,
4557 tdata->auth.offset_bits,
4558 op_mode, 0, verify);
4563 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4564 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4565 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4567 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4570 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4572 ut_params->obuf = (op_mode == IN_PLACE ?
4573 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4576 if (ut_params->obuf)
4577 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4580 plaintext = ciphertext +
4581 (tdata->cipher.offset_bits >> 3);
4583 debug_hexdump(stdout, "plaintext:", plaintext,
4584 (tdata->plaintext.len >> 3) - tdata->digest.len);
4585 debug_hexdump(stdout, "plaintext expected:",
4586 tdata->plaintext.data,
4587 (tdata->plaintext.len >> 3) - tdata->digest.len);
4589 if (ut_params->obuf)
4590 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4593 ciphertext = plaintext;
4595 debug_hexdump(stdout, "ciphertext:", ciphertext,
4597 debug_hexdump(stdout, "ciphertext expected:",
4598 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4600 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4601 + (tdata->digest.offset_bytes == 0 ?
4602 plaintext_pad_len : tdata->digest.offset_bytes);
4604 debug_hexdump(stdout, "digest:", ut_params->digest,
4606 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4612 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4614 tdata->plaintext.data,
4615 tdata->plaintext.len >> 3,
4616 "SNOW 3G Plaintext data not as expected");
4618 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4620 tdata->ciphertext.data,
4621 tdata->validDataLenInBits.len,
4622 "SNOW 3G Ciphertext data not as expected");
4624 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4627 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4628 "SNOW 3G Generated auth tag not as expected");
4634 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4635 uint8_t op_mode, uint8_t verify)
4637 struct crypto_testsuite_params *ts_params = &testsuite_params;
4638 struct crypto_unittest_params *ut_params = &unittest_params;
4642 const uint8_t *plaintext = NULL;
4643 const uint8_t *ciphertext = NULL;
4644 const uint8_t *digest = NULL;
4645 unsigned int plaintext_pad_len;
4646 unsigned int plaintext_len;
4647 unsigned int ciphertext_pad_len;
4648 unsigned int ciphertext_len;
4649 uint8_t buffer[10000];
4650 uint8_t digest_buffer[10000];
4652 struct rte_cryptodev_info dev_info;
4654 /* Verify the capabilities */
4655 struct rte_cryptodev_sym_capability_idx cap_idx;
4656 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4657 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4658 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4661 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4662 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4663 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4667 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4669 uint64_t feat_flags = dev_info.feature_flags;
4671 if (op_mode == IN_PLACE) {
4672 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4673 printf("Device doesn't support in-place scatter-gather "
4674 "in both input and output mbufs.\n");
4677 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4678 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4679 printf("Device doesn't support RAW data-path APIs.\n");
4683 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4685 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4686 printf("Device doesn't support out-of-place scatter-gather "
4687 "in both input and output mbufs.\n");
4690 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4691 printf("Device doesn't support digest encrypted.\n");
4696 /* Create SNOW 3G session */
4697 retval = create_wireless_algo_auth_cipher_session(
4698 ts_params->valid_devs[0],
4699 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4700 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4701 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4702 : RTE_CRYPTO_AUTH_OP_GENERATE),
4703 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4704 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4705 tdata->key.data, tdata->key.len,
4706 tdata->auth_iv.len, tdata->digest.len,
4707 tdata->cipher_iv.len);
4712 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4713 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4714 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4715 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4717 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4718 plaintext_pad_len, 15, 0);
4719 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4720 "Failed to allocate input buffer in mempool");
4722 if (op_mode == OUT_OF_PLACE) {
4723 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4724 plaintext_pad_len, 15, 0);
4725 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4726 "Failed to allocate output buffer in mempool");
4730 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4731 tdata->ciphertext.data);
4732 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4733 ciphertext_len, buffer);
4734 debug_hexdump(stdout, "ciphertext:", ciphertext,
4737 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4738 tdata->plaintext.data);
4739 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4740 plaintext_len, buffer);
4741 debug_hexdump(stdout, "plaintext:", plaintext,
4744 memset(buffer, 0, sizeof(buffer));
4746 /* Create SNOW 3G operation */
4747 retval = create_wireless_algo_auth_cipher_operation(
4748 tdata->digest.data, tdata->digest.len,
4749 tdata->cipher_iv.data, tdata->cipher_iv.len,
4750 tdata->auth_iv.data, tdata->auth_iv.len,
4751 (tdata->digest.offset_bytes == 0 ?
4752 (verify ? ciphertext_pad_len : plaintext_pad_len)
4753 : tdata->digest.offset_bytes),
4754 tdata->validCipherLenInBits.len,
4755 tdata->cipher.offset_bits,
4756 tdata->validAuthLenInBits.len,
4757 tdata->auth.offset_bits,
4758 op_mode, 1, verify);
4763 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4764 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4765 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4767 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4770 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4772 ut_params->obuf = (op_mode == IN_PLACE ?
4773 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4776 if (ut_params->obuf)
4777 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4778 plaintext_len, buffer);
4780 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4781 plaintext_len, buffer);
4783 debug_hexdump(stdout, "plaintext:", plaintext,
4784 (tdata->plaintext.len >> 3) - tdata->digest.len);
4785 debug_hexdump(stdout, "plaintext expected:",
4786 tdata->plaintext.data,
4787 (tdata->plaintext.len >> 3) - tdata->digest.len);
4789 if (ut_params->obuf)
4790 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4791 ciphertext_len, buffer);
4793 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4794 ciphertext_len, buffer);
4796 debug_hexdump(stdout, "ciphertext:", ciphertext,
4798 debug_hexdump(stdout, "ciphertext expected:",
4799 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4801 if (ut_params->obuf)
4802 digest = rte_pktmbuf_read(ut_params->obuf,
4803 (tdata->digest.offset_bytes == 0 ?
4804 plaintext_pad_len : tdata->digest.offset_bytes),
4805 tdata->digest.len, digest_buffer);
4807 digest = rte_pktmbuf_read(ut_params->ibuf,
4808 (tdata->digest.offset_bytes == 0 ?
4809 plaintext_pad_len : tdata->digest.offset_bytes),
4810 tdata->digest.len, digest_buffer);
4812 debug_hexdump(stdout, "digest:", digest,
4814 debug_hexdump(stdout, "digest expected:",
4815 tdata->digest.data, tdata->digest.len);
4820 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4822 tdata->plaintext.data,
4823 tdata->plaintext.len >> 3,
4824 "SNOW 3G Plaintext data not as expected");
4826 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4828 tdata->ciphertext.data,
4829 tdata->validDataLenInBits.len,
4830 "SNOW 3G Ciphertext data not as expected");
4832 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4835 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4836 "SNOW 3G Generated auth tag not as expected");
4842 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4843 uint8_t op_mode, uint8_t verify)
4845 struct crypto_testsuite_params *ts_params = &testsuite_params;
4846 struct crypto_unittest_params *ut_params = &unittest_params;
4850 uint8_t *plaintext = NULL, *ciphertext = NULL;
4851 unsigned int plaintext_pad_len;
4852 unsigned int plaintext_len;
4853 unsigned int ciphertext_pad_len;
4854 unsigned int ciphertext_len;
4856 struct rte_cryptodev_info dev_info;
4858 /* Verify the capabilities */
4859 struct rte_cryptodev_sym_capability_idx cap_idx;
4860 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4861 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4862 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4865 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4866 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4867 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4871 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4873 uint64_t feat_flags = dev_info.feature_flags;
4875 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4876 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4877 printf("Device doesn't support RAW data-path APIs.\n");
4881 if (op_mode == OUT_OF_PLACE) {
4882 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4884 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4885 printf("Device doesn't support digest encrypted.\n");
4890 /* Create KASUMI session */
4891 retval = create_wireless_algo_auth_cipher_session(
4892 ts_params->valid_devs[0],
4893 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4894 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4895 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4896 : RTE_CRYPTO_AUTH_OP_GENERATE),
4897 RTE_CRYPTO_AUTH_KASUMI_F9,
4898 RTE_CRYPTO_CIPHER_KASUMI_F8,
4899 tdata->key.data, tdata->key.len,
4900 0, tdata->digest.len,
4901 tdata->cipher_iv.len);
4906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4907 if (op_mode == OUT_OF_PLACE)
4908 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4910 /* clear mbuf payload */
4911 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4912 rte_pktmbuf_tailroom(ut_params->ibuf));
4913 if (op_mode == OUT_OF_PLACE)
4914 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4915 rte_pktmbuf_tailroom(ut_params->obuf));
4917 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4918 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4919 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4920 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4923 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4924 ciphertext_pad_len);
4925 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4926 if (op_mode == OUT_OF_PLACE)
4927 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4928 debug_hexdump(stdout, "ciphertext:", ciphertext,
4931 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4933 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4934 if (op_mode == OUT_OF_PLACE)
4935 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4936 debug_hexdump(stdout, "plaintext:", plaintext,
4940 /* Create KASUMI operation */
4941 retval = create_wireless_algo_auth_cipher_operation(
4942 tdata->digest.data, tdata->digest.len,
4943 tdata->cipher_iv.data, tdata->cipher_iv.len,
4945 (tdata->digest.offset_bytes == 0 ?
4946 (verify ? ciphertext_pad_len : plaintext_pad_len)
4947 : tdata->digest.offset_bytes),
4948 tdata->validCipherLenInBits.len,
4949 tdata->validCipherOffsetInBits.len,
4950 tdata->validAuthLenInBits.len,
4952 op_mode, 0, verify);
4957 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4958 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4959 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4961 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4964 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4966 ut_params->obuf = (op_mode == IN_PLACE ?
4967 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4971 if (ut_params->obuf)
4972 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4975 plaintext = ciphertext;
4977 debug_hexdump(stdout, "plaintext:", plaintext,
4978 (tdata->plaintext.len >> 3) - tdata->digest.len);
4979 debug_hexdump(stdout, "plaintext expected:",
4980 tdata->plaintext.data,
4981 (tdata->plaintext.len >> 3) - tdata->digest.len);
4983 if (ut_params->obuf)
4984 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4987 ciphertext = plaintext;
4989 debug_hexdump(stdout, "ciphertext:", ciphertext,
4991 debug_hexdump(stdout, "ciphertext expected:",
4992 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4994 ut_params->digest = rte_pktmbuf_mtod(
4995 ut_params->obuf, uint8_t *) +
4996 (tdata->digest.offset_bytes == 0 ?
4997 plaintext_pad_len : tdata->digest.offset_bytes);
4999 debug_hexdump(stdout, "digest:", ut_params->digest,
5001 debug_hexdump(stdout, "digest expected:",
5002 tdata->digest.data, tdata->digest.len);
5007 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5009 tdata->plaintext.data,
5010 tdata->plaintext.len >> 3,
5011 "KASUMI Plaintext data not as expected");
5013 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5015 tdata->ciphertext.data,
5016 tdata->ciphertext.len >> 3,
5017 "KASUMI Ciphertext data not as expected");
5019 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5022 DIGEST_BYTE_LENGTH_KASUMI_F9,
5023 "KASUMI Generated auth tag not as expected");
5029 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5030 uint8_t op_mode, uint8_t verify)
5032 struct crypto_testsuite_params *ts_params = &testsuite_params;
5033 struct crypto_unittest_params *ut_params = &unittest_params;
5037 const uint8_t *plaintext = NULL;
5038 const uint8_t *ciphertext = NULL;
5039 const uint8_t *digest = NULL;
5040 unsigned int plaintext_pad_len;
5041 unsigned int plaintext_len;
5042 unsigned int ciphertext_pad_len;
5043 unsigned int ciphertext_len;
5044 uint8_t buffer[10000];
5045 uint8_t digest_buffer[10000];
5047 struct rte_cryptodev_info dev_info;
5049 /* Verify the capabilities */
5050 struct rte_cryptodev_sym_capability_idx cap_idx;
5051 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5052 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5053 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5056 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5057 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5058 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5062 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5064 uint64_t feat_flags = dev_info.feature_flags;
5066 if (op_mode == IN_PLACE) {
5067 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5068 printf("Device doesn't support in-place scatter-gather "
5069 "in both input and output mbufs.\n");
5072 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5073 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5074 printf("Device doesn't support RAW data-path APIs.\n");
5078 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5080 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5081 printf("Device doesn't support out-of-place scatter-gather "
5082 "in both input and output mbufs.\n");
5085 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5086 printf("Device doesn't support digest encrypted.\n");
5091 /* Create KASUMI session */
5092 retval = create_wireless_algo_auth_cipher_session(
5093 ts_params->valid_devs[0],
5094 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5095 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5096 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5097 : RTE_CRYPTO_AUTH_OP_GENERATE),
5098 RTE_CRYPTO_AUTH_KASUMI_F9,
5099 RTE_CRYPTO_CIPHER_KASUMI_F8,
5100 tdata->key.data, tdata->key.len,
5101 0, tdata->digest.len,
5102 tdata->cipher_iv.len);
5107 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5108 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5109 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5110 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5112 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5113 plaintext_pad_len, 15, 0);
5114 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5115 "Failed to allocate input buffer in mempool");
5117 if (op_mode == OUT_OF_PLACE) {
5118 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5119 plaintext_pad_len, 15, 0);
5120 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5121 "Failed to allocate output buffer in mempool");
5125 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5126 tdata->ciphertext.data);
5127 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5128 ciphertext_len, buffer);
5129 debug_hexdump(stdout, "ciphertext:", ciphertext,
5132 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5133 tdata->plaintext.data);
5134 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5135 plaintext_len, buffer);
5136 debug_hexdump(stdout, "plaintext:", plaintext,
5139 memset(buffer, 0, sizeof(buffer));
5141 /* Create KASUMI operation */
5142 retval = create_wireless_algo_auth_cipher_operation(
5143 tdata->digest.data, tdata->digest.len,
5144 tdata->cipher_iv.data, tdata->cipher_iv.len,
5146 (tdata->digest.offset_bytes == 0 ?
5147 (verify ? ciphertext_pad_len : plaintext_pad_len)
5148 : tdata->digest.offset_bytes),
5149 tdata->validCipherLenInBits.len,
5150 tdata->validCipherOffsetInBits.len,
5151 tdata->validAuthLenInBits.len,
5153 op_mode, 1, verify);
5158 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5159 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5160 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5162 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5165 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5167 ut_params->obuf = (op_mode == IN_PLACE ?
5168 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5171 if (ut_params->obuf)
5172 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5173 plaintext_len, buffer);
5175 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5176 plaintext_len, buffer);
5178 debug_hexdump(stdout, "plaintext:", plaintext,
5179 (tdata->plaintext.len >> 3) - tdata->digest.len);
5180 debug_hexdump(stdout, "plaintext expected:",
5181 tdata->plaintext.data,
5182 (tdata->plaintext.len >> 3) - tdata->digest.len);
5184 if (ut_params->obuf)
5185 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5186 ciphertext_len, buffer);
5188 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5189 ciphertext_len, buffer);
5191 debug_hexdump(stdout, "ciphertext:", ciphertext,
5193 debug_hexdump(stdout, "ciphertext expected:",
5194 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5196 if (ut_params->obuf)
5197 digest = rte_pktmbuf_read(ut_params->obuf,
5198 (tdata->digest.offset_bytes == 0 ?
5199 plaintext_pad_len : tdata->digest.offset_bytes),
5200 tdata->digest.len, digest_buffer);
5202 digest = rte_pktmbuf_read(ut_params->ibuf,
5203 (tdata->digest.offset_bytes == 0 ?
5204 plaintext_pad_len : tdata->digest.offset_bytes),
5205 tdata->digest.len, digest_buffer);
5207 debug_hexdump(stdout, "digest:", digest,
5209 debug_hexdump(stdout, "digest expected:",
5210 tdata->digest.data, tdata->digest.len);
5215 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5217 tdata->plaintext.data,
5218 tdata->plaintext.len >> 3,
5219 "KASUMI Plaintext data not as expected");
5221 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5223 tdata->ciphertext.data,
5224 tdata->validDataLenInBits.len,
5225 "KASUMI Ciphertext data not as expected");
5227 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5230 DIGEST_BYTE_LENGTH_KASUMI_F9,
5231 "KASUMI Generated auth tag not as expected");
5237 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5239 struct crypto_testsuite_params *ts_params = &testsuite_params;
5240 struct crypto_unittest_params *ut_params = &unittest_params;
5244 uint8_t *plaintext, *ciphertext;
5245 unsigned plaintext_pad_len;
5246 unsigned plaintext_len;
5247 struct rte_cryptodev_info dev_info;
5249 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5250 uint64_t feat_flags = dev_info.feature_flags;
5252 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5253 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5254 printf("Device doesn't support RAW data-path APIs.\n");
5258 /* Verify the capabilities */
5259 struct rte_cryptodev_sym_capability_idx cap_idx;
5260 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5261 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5262 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5265 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5266 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5267 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5271 /* Create KASUMI session */
5272 retval = create_wireless_algo_cipher_auth_session(
5273 ts_params->valid_devs[0],
5274 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5275 RTE_CRYPTO_AUTH_OP_GENERATE,
5276 RTE_CRYPTO_AUTH_KASUMI_F9,
5277 RTE_CRYPTO_CIPHER_KASUMI_F8,
5278 tdata->key.data, tdata->key.len,
5279 0, tdata->digest.len,
5280 tdata->cipher_iv.len);
5284 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5286 /* clear mbuf payload */
5287 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5288 rte_pktmbuf_tailroom(ut_params->ibuf));
5290 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5291 /* Append data which is padded to a multiple of */
5292 /* the algorithms block size */
5293 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5294 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5296 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5298 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5300 /* Create KASUMI operation */
5301 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5302 tdata->digest.len, NULL, 0,
5303 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5304 tdata->cipher_iv.data, tdata->cipher_iv.len,
5305 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5306 tdata->validCipherOffsetInBits.len,
5307 tdata->validAuthLenInBits.len,
5313 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5314 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5315 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5317 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5319 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5321 if (ut_params->op->sym->m_dst)
5322 ut_params->obuf = ut_params->op->sym->m_dst;
5324 ut_params->obuf = ut_params->op->sym->m_src;
5326 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5327 tdata->validCipherOffsetInBits.len >> 3);
5329 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5330 + plaintext_pad_len;
5332 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5333 (tdata->validCipherOffsetInBits.len >> 3);
5335 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5337 reference_ciphertext,
5338 tdata->validCipherLenInBits.len,
5339 "KASUMI Ciphertext data not as expected");
5342 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5345 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5346 "KASUMI Generated auth tag not as expected");
5351 test_zuc_encryption(const struct wireless_test_data *tdata)
5353 struct crypto_testsuite_params *ts_params = &testsuite_params;
5354 struct crypto_unittest_params *ut_params = &unittest_params;
5357 uint8_t *plaintext, *ciphertext;
5358 unsigned plaintext_pad_len;
5359 unsigned plaintext_len;
5360 struct rte_cryptodev_info dev_info;
5362 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5363 uint64_t feat_flags = dev_info.feature_flags;
5365 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5366 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5367 printf("Device doesn't support RAW data-path APIs.\n");
5371 struct rte_cryptodev_sym_capability_idx cap_idx;
5373 /* Check if device supports ZUC EEA3 */
5374 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5375 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5377 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5381 /* Create ZUC session */
5382 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5383 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5384 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5385 tdata->key.data, tdata->key.len,
5386 tdata->cipher_iv.len);
5390 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5392 /* Clear mbuf payload */
5393 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5394 rte_pktmbuf_tailroom(ut_params->ibuf));
5396 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5397 /* Append data which is padded to a multiple */
5398 /* of the algorithms block size */
5399 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5400 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5402 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5404 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5406 /* Create ZUC operation */
5407 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5408 tdata->cipher_iv.len,
5409 tdata->plaintext.len,
5414 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5415 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5416 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5418 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5420 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5422 ut_params->obuf = ut_params->op->sym->m_dst;
5423 if (ut_params->obuf)
5424 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5426 ciphertext = plaintext;
5428 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5431 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5433 tdata->ciphertext.data,
5434 tdata->validCipherLenInBits.len,
5435 "ZUC Ciphertext data not as expected");
5440 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5442 struct crypto_testsuite_params *ts_params = &testsuite_params;
5443 struct crypto_unittest_params *ut_params = &unittest_params;
5447 unsigned int plaintext_pad_len;
5448 unsigned int plaintext_len;
5449 const uint8_t *ciphertext;
5450 uint8_t ciphertext_buffer[2048];
5451 struct rte_cryptodev_info dev_info;
5453 struct rte_cryptodev_sym_capability_idx cap_idx;
5455 /* Check if device supports ZUC EEA3 */
5456 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5457 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5459 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5463 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5465 uint64_t feat_flags = dev_info.feature_flags;
5467 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5468 printf("Device doesn't support in-place scatter-gather. "
5473 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5474 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5475 printf("Device doesn't support RAW data-path APIs.\n");
5479 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5481 /* Append data which is padded to a multiple */
5482 /* of the algorithms block size */
5483 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5485 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5486 plaintext_pad_len, 10, 0);
5488 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5489 tdata->plaintext.data);
5491 /* Create ZUC session */
5492 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5493 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5494 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5495 tdata->key.data, tdata->key.len,
5496 tdata->cipher_iv.len);
5500 /* Clear mbuf payload */
5502 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5504 /* Create ZUC operation */
5505 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5506 tdata->cipher_iv.len, tdata->plaintext.len,
5511 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5512 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5513 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5517 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5519 ut_params->obuf = ut_params->op->sym->m_dst;
5520 if (ut_params->obuf)
5521 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5522 0, plaintext_len, ciphertext_buffer);
5524 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5525 0, plaintext_len, ciphertext_buffer);
5528 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5531 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5533 tdata->ciphertext.data,
5534 tdata->validCipherLenInBits.len,
5535 "ZUC Ciphertext data not as expected");
5541 test_zuc_authentication(const struct wireless_test_data *tdata)
5543 struct crypto_testsuite_params *ts_params = &testsuite_params;
5544 struct crypto_unittest_params *ut_params = &unittest_params;
5547 unsigned plaintext_pad_len;
5548 unsigned plaintext_len;
5551 struct rte_cryptodev_sym_capability_idx cap_idx;
5552 struct rte_cryptodev_info dev_info;
5554 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5555 uint64_t feat_flags = dev_info.feature_flags;
5557 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5558 (tdata->validAuthLenInBits.len % 8 != 0)) {
5559 printf("Device doesn't support NON-Byte Aligned Data.\n");
5563 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5564 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5565 printf("Device doesn't support RAW data-path APIs.\n");
5569 /* Check if device supports ZUC EIA3 */
5570 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5571 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5573 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5577 /* Create ZUC session */
5578 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5579 tdata->key.data, tdata->key.len,
5580 tdata->auth_iv.len, tdata->digest.len,
5581 RTE_CRYPTO_AUTH_OP_GENERATE,
5582 RTE_CRYPTO_AUTH_ZUC_EIA3);
5586 /* alloc mbuf and set payload */
5587 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5589 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5590 rte_pktmbuf_tailroom(ut_params->ibuf));
5592 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5593 /* Append data which is padded to a multiple of */
5594 /* the algorithms block size */
5595 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5596 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5598 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5600 /* Create ZUC operation */
5601 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5602 tdata->auth_iv.data, tdata->auth_iv.len,
5603 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5604 tdata->validAuthLenInBits.len,
5609 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5610 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5611 ut_params->op, 0, 1, 1, 0);
5613 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5615 ut_params->obuf = ut_params->op->sym->m_src;
5616 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5617 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5618 + plaintext_pad_len;
5621 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5625 "ZUC Generated auth tag not as expected");
5631 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5632 uint8_t op_mode, uint8_t verify)
5634 struct crypto_testsuite_params *ts_params = &testsuite_params;
5635 struct crypto_unittest_params *ut_params = &unittest_params;
5639 uint8_t *plaintext = NULL, *ciphertext = NULL;
5640 unsigned int plaintext_pad_len;
5641 unsigned int plaintext_len;
5642 unsigned int ciphertext_pad_len;
5643 unsigned int ciphertext_len;
5645 struct rte_cryptodev_info dev_info;
5646 struct rte_cryptodev_sym_capability_idx cap_idx;
5648 /* Check if device supports ZUC EIA3 */
5649 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5650 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5652 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5656 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5658 uint64_t feat_flags = dev_info.feature_flags;
5660 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5661 printf("Device doesn't support digest encrypted.\n");
5664 if (op_mode == IN_PLACE) {
5665 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5666 printf("Device doesn't support in-place scatter-gather "
5667 "in both input and output mbufs.\n");
5671 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5672 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5673 printf("Device doesn't support RAW data-path APIs.\n");
5677 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5679 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5680 printf("Device doesn't support out-of-place scatter-gather "
5681 "in both input and output mbufs.\n");
5686 /* Create ZUC session */
5687 retval = create_wireless_algo_auth_cipher_session(
5688 ts_params->valid_devs[0],
5689 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5690 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5691 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5692 : RTE_CRYPTO_AUTH_OP_GENERATE),
5693 RTE_CRYPTO_AUTH_ZUC_EIA3,
5694 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5695 tdata->key.data, tdata->key.len,
5696 tdata->auth_iv.len, tdata->digest.len,
5697 tdata->cipher_iv.len);
5702 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5703 if (op_mode == OUT_OF_PLACE)
5704 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5706 /* clear mbuf payload */
5707 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5708 rte_pktmbuf_tailroom(ut_params->ibuf));
5709 if (op_mode == OUT_OF_PLACE)
5710 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5711 rte_pktmbuf_tailroom(ut_params->obuf));
5713 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5714 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5715 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5716 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5719 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5720 ciphertext_pad_len);
5721 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5722 if (op_mode == OUT_OF_PLACE)
5723 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5724 debug_hexdump(stdout, "ciphertext:", ciphertext,
5727 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5729 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5730 if (op_mode == OUT_OF_PLACE)
5731 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5732 debug_hexdump(stdout, "plaintext:", plaintext,
5736 /* Create ZUC operation */
5737 retval = create_wireless_algo_auth_cipher_operation(
5738 tdata->digest.data, tdata->digest.len,
5739 tdata->cipher_iv.data, tdata->cipher_iv.len,
5740 tdata->auth_iv.data, tdata->auth_iv.len,
5741 (tdata->digest.offset_bytes == 0 ?
5742 (verify ? ciphertext_pad_len : plaintext_pad_len)
5743 : tdata->digest.offset_bytes),
5744 tdata->validCipherLenInBits.len,
5745 tdata->validCipherOffsetInBits.len,
5746 tdata->validAuthLenInBits.len,
5748 op_mode, 0, verify);
5753 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5754 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5755 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5757 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5760 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5762 ut_params->obuf = (op_mode == IN_PLACE ?
5763 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5767 if (ut_params->obuf)
5768 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5771 plaintext = ciphertext;
5773 debug_hexdump(stdout, "plaintext:", plaintext,
5774 (tdata->plaintext.len >> 3) - tdata->digest.len);
5775 debug_hexdump(stdout, "plaintext expected:",
5776 tdata->plaintext.data,
5777 (tdata->plaintext.len >> 3) - tdata->digest.len);
5779 if (ut_params->obuf)
5780 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5783 ciphertext = plaintext;
5785 debug_hexdump(stdout, "ciphertext:", ciphertext,
5787 debug_hexdump(stdout, "ciphertext expected:",
5788 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5790 ut_params->digest = rte_pktmbuf_mtod(
5791 ut_params->obuf, uint8_t *) +
5792 (tdata->digest.offset_bytes == 0 ?
5793 plaintext_pad_len : tdata->digest.offset_bytes);
5795 debug_hexdump(stdout, "digest:", ut_params->digest,
5797 debug_hexdump(stdout, "digest expected:",
5798 tdata->digest.data, tdata->digest.len);
5803 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5805 tdata->plaintext.data,
5806 tdata->plaintext.len >> 3,
5807 "ZUC Plaintext data not as expected");
5809 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5811 tdata->ciphertext.data,
5812 tdata->ciphertext.len >> 3,
5813 "ZUC Ciphertext data not as expected");
5815 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5818 DIGEST_BYTE_LENGTH_KASUMI_F9,
5819 "ZUC Generated auth tag not as expected");
5825 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5826 uint8_t op_mode, uint8_t verify)
5828 struct crypto_testsuite_params *ts_params = &testsuite_params;
5829 struct crypto_unittest_params *ut_params = &unittest_params;
5833 const uint8_t *plaintext = NULL;
5834 const uint8_t *ciphertext = NULL;
5835 const uint8_t *digest = NULL;
5836 unsigned int plaintext_pad_len;
5837 unsigned int plaintext_len;
5838 unsigned int ciphertext_pad_len;
5839 unsigned int ciphertext_len;
5840 uint8_t buffer[10000];
5841 uint8_t digest_buffer[10000];
5843 struct rte_cryptodev_info dev_info;
5844 struct rte_cryptodev_sym_capability_idx cap_idx;
5846 /* Check if device supports ZUC EIA3 */
5847 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5848 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5850 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5854 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5856 uint64_t feat_flags = dev_info.feature_flags;
5858 if (op_mode == IN_PLACE) {
5859 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5860 printf("Device doesn't support in-place scatter-gather "
5861 "in both input and output mbufs.\n");
5865 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5866 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5867 printf("Device doesn't support RAW data-path APIs.\n");
5871 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5873 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5874 printf("Device doesn't support out-of-place scatter-gather "
5875 "in both input and output mbufs.\n");
5878 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5879 printf("Device doesn't support digest encrypted.\n");
5884 /* Create ZUC session */
5885 retval = create_wireless_algo_auth_cipher_session(
5886 ts_params->valid_devs[0],
5887 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5888 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5889 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5890 : RTE_CRYPTO_AUTH_OP_GENERATE),
5891 RTE_CRYPTO_AUTH_ZUC_EIA3,
5892 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5893 tdata->key.data, tdata->key.len,
5894 tdata->auth_iv.len, tdata->digest.len,
5895 tdata->cipher_iv.len);
5900 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5901 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5902 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5903 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5905 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5906 plaintext_pad_len, 15, 0);
5907 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5908 "Failed to allocate input buffer in mempool");
5910 if (op_mode == OUT_OF_PLACE) {
5911 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5912 plaintext_pad_len, 15, 0);
5913 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5914 "Failed to allocate output buffer in mempool");
5918 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5919 tdata->ciphertext.data);
5920 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5921 ciphertext_len, buffer);
5922 debug_hexdump(stdout, "ciphertext:", ciphertext,
5925 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5926 tdata->plaintext.data);
5927 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5928 plaintext_len, buffer);
5929 debug_hexdump(stdout, "plaintext:", plaintext,
5932 memset(buffer, 0, sizeof(buffer));
5934 /* Create ZUC operation */
5935 retval = create_wireless_algo_auth_cipher_operation(
5936 tdata->digest.data, tdata->digest.len,
5937 tdata->cipher_iv.data, tdata->cipher_iv.len,
5939 (tdata->digest.offset_bytes == 0 ?
5940 (verify ? ciphertext_pad_len : plaintext_pad_len)
5941 : tdata->digest.offset_bytes),
5942 tdata->validCipherLenInBits.len,
5943 tdata->validCipherOffsetInBits.len,
5944 tdata->validAuthLenInBits.len,
5946 op_mode, 1, verify);
5951 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5952 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5953 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5955 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5958 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5960 ut_params->obuf = (op_mode == IN_PLACE ?
5961 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5964 if (ut_params->obuf)
5965 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5966 plaintext_len, buffer);
5968 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5969 plaintext_len, buffer);
5971 debug_hexdump(stdout, "plaintext:", plaintext,
5972 (tdata->plaintext.len >> 3) - tdata->digest.len);
5973 debug_hexdump(stdout, "plaintext expected:",
5974 tdata->plaintext.data,
5975 (tdata->plaintext.len >> 3) - tdata->digest.len);
5977 if (ut_params->obuf)
5978 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5979 ciphertext_len, buffer);
5981 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5982 ciphertext_len, buffer);
5984 debug_hexdump(stdout, "ciphertext:", ciphertext,
5986 debug_hexdump(stdout, "ciphertext expected:",
5987 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5989 if (ut_params->obuf)
5990 digest = rte_pktmbuf_read(ut_params->obuf,
5991 (tdata->digest.offset_bytes == 0 ?
5992 plaintext_pad_len : tdata->digest.offset_bytes),
5993 tdata->digest.len, digest_buffer);
5995 digest = rte_pktmbuf_read(ut_params->ibuf,
5996 (tdata->digest.offset_bytes == 0 ?
5997 plaintext_pad_len : tdata->digest.offset_bytes),
5998 tdata->digest.len, digest_buffer);
6000 debug_hexdump(stdout, "digest:", digest,
6002 debug_hexdump(stdout, "digest expected:",
6003 tdata->digest.data, tdata->digest.len);
6008 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6010 tdata->plaintext.data,
6011 tdata->plaintext.len >> 3,
6012 "ZUC Plaintext data not as expected");
6014 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6016 tdata->ciphertext.data,
6017 tdata->validDataLenInBits.len,
6018 "ZUC Ciphertext data not as expected");
6020 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6023 DIGEST_BYTE_LENGTH_KASUMI_F9,
6024 "ZUC Generated auth tag not as expected");
6030 test_kasumi_encryption_test_case_1(void)
6032 return test_kasumi_encryption(&kasumi_test_case_1);
6036 test_kasumi_encryption_test_case_1_sgl(void)
6038 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6042 test_kasumi_encryption_test_case_1_oop(void)
6044 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6048 test_kasumi_encryption_test_case_1_oop_sgl(void)
6050 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6054 test_kasumi_encryption_test_case_2(void)
6056 return test_kasumi_encryption(&kasumi_test_case_2);
6060 test_kasumi_encryption_test_case_3(void)
6062 return test_kasumi_encryption(&kasumi_test_case_3);
6066 test_kasumi_encryption_test_case_4(void)
6068 return test_kasumi_encryption(&kasumi_test_case_4);
6072 test_kasumi_encryption_test_case_5(void)
6074 return test_kasumi_encryption(&kasumi_test_case_5);
6078 test_kasumi_decryption_test_case_1(void)
6080 return test_kasumi_decryption(&kasumi_test_case_1);
6084 test_kasumi_decryption_test_case_1_oop(void)
6086 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6090 test_kasumi_decryption_test_case_2(void)
6092 return test_kasumi_decryption(&kasumi_test_case_2);
6096 test_kasumi_decryption_test_case_3(void)
6098 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6099 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6101 return test_kasumi_decryption(&kasumi_test_case_3);
6105 test_kasumi_decryption_test_case_4(void)
6107 return test_kasumi_decryption(&kasumi_test_case_4);
6111 test_kasumi_decryption_test_case_5(void)
6113 return test_kasumi_decryption(&kasumi_test_case_5);
6116 test_snow3g_encryption_test_case_1(void)
6118 return test_snow3g_encryption(&snow3g_test_case_1);
6122 test_snow3g_encryption_test_case_1_oop(void)
6124 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6128 test_snow3g_encryption_test_case_1_oop_sgl(void)
6130 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6135 test_snow3g_encryption_test_case_1_offset_oop(void)
6137 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6141 test_snow3g_encryption_test_case_2(void)
6143 return test_snow3g_encryption(&snow3g_test_case_2);
6147 test_snow3g_encryption_test_case_3(void)
6149 return test_snow3g_encryption(&snow3g_test_case_3);
6153 test_snow3g_encryption_test_case_4(void)
6155 return test_snow3g_encryption(&snow3g_test_case_4);
6159 test_snow3g_encryption_test_case_5(void)
6161 return test_snow3g_encryption(&snow3g_test_case_5);
6165 test_snow3g_decryption_test_case_1(void)
6167 return test_snow3g_decryption(&snow3g_test_case_1);
6171 test_snow3g_decryption_test_case_1_oop(void)
6173 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6177 test_snow3g_decryption_test_case_2(void)
6179 return test_snow3g_decryption(&snow3g_test_case_2);
6183 test_snow3g_decryption_test_case_3(void)
6185 return test_snow3g_decryption(&snow3g_test_case_3);
6189 test_snow3g_decryption_test_case_4(void)
6191 return test_snow3g_decryption(&snow3g_test_case_4);
6195 test_snow3g_decryption_test_case_5(void)
6197 return test_snow3g_decryption(&snow3g_test_case_5);
6201 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6202 * Pattern digest from snow3g_test_data must be allocated as
6203 * 4 last bytes in plaintext.
6206 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6207 struct snow3g_hash_test_data *output)
6209 if ((pattern != NULL) && (output != NULL)) {
6210 output->key.len = pattern->key.len;
6212 memcpy(output->key.data,
6213 pattern->key.data, pattern->key.len);
6215 output->auth_iv.len = pattern->auth_iv.len;
6217 memcpy(output->auth_iv.data,
6218 pattern->auth_iv.data, pattern->auth_iv.len);
6220 output->plaintext.len = pattern->plaintext.len;
6222 memcpy(output->plaintext.data,
6223 pattern->plaintext.data, pattern->plaintext.len >> 3);
6225 output->digest.len = pattern->digest.len;
6227 memcpy(output->digest.data,
6228 &pattern->plaintext.data[pattern->digest.offset_bytes],
6229 pattern->digest.len);
6231 output->validAuthLenInBits.len =
6232 pattern->validAuthLenInBits.len;
6237 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6240 test_snow3g_decryption_with_digest_test_case_1(void)
6242 struct snow3g_hash_test_data snow3g_hash_data;
6245 * Function prepare data for hash veryfication test case.
6246 * Digest is allocated in 4 last bytes in plaintext, pattern.
6248 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6250 return test_snow3g_decryption(&snow3g_test_case_7) &
6251 test_snow3g_authentication_verify(&snow3g_hash_data);
6255 test_snow3g_cipher_auth_test_case_1(void)
6257 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6261 test_snow3g_auth_cipher_test_case_1(void)
6263 return test_snow3g_auth_cipher(
6264 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6268 test_snow3g_auth_cipher_test_case_2(void)
6270 return test_snow3g_auth_cipher(
6271 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6275 test_snow3g_auth_cipher_test_case_2_oop(void)
6277 return test_snow3g_auth_cipher(
6278 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6282 test_snow3g_auth_cipher_part_digest_enc(void)
6284 return test_snow3g_auth_cipher(
6285 &snow3g_auth_cipher_partial_digest_encryption,
6290 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6292 return test_snow3g_auth_cipher(
6293 &snow3g_auth_cipher_partial_digest_encryption,
6298 test_snow3g_auth_cipher_test_case_3_sgl(void)
6300 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6301 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6303 return test_snow3g_auth_cipher_sgl(
6304 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6308 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6310 return test_snow3g_auth_cipher_sgl(
6311 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6315 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6317 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6318 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6320 return test_snow3g_auth_cipher_sgl(
6321 &snow3g_auth_cipher_partial_digest_encryption,
6326 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6328 return test_snow3g_auth_cipher_sgl(
6329 &snow3g_auth_cipher_partial_digest_encryption,
6334 test_snow3g_auth_cipher_verify_test_case_1(void)
6336 return test_snow3g_auth_cipher(
6337 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6341 test_snow3g_auth_cipher_verify_test_case_2(void)
6343 return test_snow3g_auth_cipher(
6344 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6348 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6350 return test_snow3g_auth_cipher(
6351 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6355 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6357 return test_snow3g_auth_cipher(
6358 &snow3g_auth_cipher_partial_digest_encryption,
6363 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6365 return test_snow3g_auth_cipher(
6366 &snow3g_auth_cipher_partial_digest_encryption,
6371 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6373 return test_snow3g_auth_cipher_sgl(
6374 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6378 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6380 return test_snow3g_auth_cipher_sgl(
6381 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6385 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6387 return test_snow3g_auth_cipher_sgl(
6388 &snow3g_auth_cipher_partial_digest_encryption,
6393 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6395 return test_snow3g_auth_cipher_sgl(
6396 &snow3g_auth_cipher_partial_digest_encryption,
6401 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6403 return test_snow3g_auth_cipher(
6404 &snow3g_test_case_7, IN_PLACE, 0);
6408 test_kasumi_auth_cipher_test_case_1(void)
6410 return test_kasumi_auth_cipher(
6411 &kasumi_test_case_3, IN_PLACE, 0);
6415 test_kasumi_auth_cipher_test_case_2(void)
6417 return test_kasumi_auth_cipher(
6418 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6422 test_kasumi_auth_cipher_test_case_2_oop(void)
6424 return test_kasumi_auth_cipher(
6425 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6429 test_kasumi_auth_cipher_test_case_2_sgl(void)
6431 return test_kasumi_auth_cipher_sgl(
6432 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6436 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6438 return test_kasumi_auth_cipher_sgl(
6439 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6443 test_kasumi_auth_cipher_verify_test_case_1(void)
6445 return test_kasumi_auth_cipher(
6446 &kasumi_test_case_3, IN_PLACE, 1);
6450 test_kasumi_auth_cipher_verify_test_case_2(void)
6452 return test_kasumi_auth_cipher(
6453 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6457 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6459 return test_kasumi_auth_cipher(
6460 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6464 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6466 return test_kasumi_auth_cipher_sgl(
6467 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6471 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6473 return test_kasumi_auth_cipher_sgl(
6474 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6478 test_kasumi_cipher_auth_test_case_1(void)
6480 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6484 test_zuc_encryption_test_case_1(void)
6486 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6490 test_zuc_encryption_test_case_2(void)
6492 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6496 test_zuc_encryption_test_case_3(void)
6498 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6502 test_zuc_encryption_test_case_4(void)
6504 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6508 test_zuc_encryption_test_case_5(void)
6510 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6514 test_zuc_encryption_test_case_6_sgl(void)
6516 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6520 test_zuc_hash_generate_test_case_1(void)
6522 return test_zuc_authentication(&zuc_test_case_auth_1b);
6526 test_zuc_hash_generate_test_case_2(void)
6528 return test_zuc_authentication(&zuc_test_case_auth_90b);
6532 test_zuc_hash_generate_test_case_3(void)
6534 return test_zuc_authentication(&zuc_test_case_auth_577b);
6538 test_zuc_hash_generate_test_case_4(void)
6540 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6544 test_zuc_hash_generate_test_case_5(void)
6546 return test_zuc_authentication(&zuc_test_auth_5670b);
6550 test_zuc_hash_generate_test_case_6(void)
6552 return test_zuc_authentication(&zuc_test_case_auth_128b);
6556 test_zuc_hash_generate_test_case_7(void)
6558 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6562 test_zuc_hash_generate_test_case_8(void)
6564 return test_zuc_authentication(&zuc_test_case_auth_584b);
6568 test_zuc_cipher_auth_test_case_1(void)
6570 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6574 test_zuc_cipher_auth_test_case_2(void)
6576 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6580 test_zuc_auth_cipher_test_case_1(void)
6582 return test_zuc_auth_cipher(
6583 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6587 test_zuc_auth_cipher_test_case_1_oop(void)
6589 return test_zuc_auth_cipher(
6590 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6594 test_zuc_auth_cipher_test_case_1_sgl(void)
6596 return test_zuc_auth_cipher_sgl(
6597 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6601 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6603 return test_zuc_auth_cipher_sgl(
6604 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6608 test_zuc_auth_cipher_verify_test_case_1(void)
6610 return test_zuc_auth_cipher(
6611 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6615 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6617 return test_zuc_auth_cipher(
6618 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6622 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6624 return test_zuc_auth_cipher_sgl(
6625 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6629 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6631 return test_zuc_auth_cipher_sgl(
6632 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6636 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6638 uint8_t dev_id = testsuite_params.valid_devs[0];
6640 struct rte_cryptodev_sym_capability_idx cap_idx;
6642 /* Check if device supports particular cipher algorithm */
6643 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6644 cap_idx.algo.cipher = tdata->cipher_algo;
6645 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6648 /* Check if device supports particular hash algorithm */
6649 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6650 cap_idx.algo.auth = tdata->auth_algo;
6651 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6658 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6659 uint8_t op_mode, uint8_t verify)
6661 struct crypto_testsuite_params *ts_params = &testsuite_params;
6662 struct crypto_unittest_params *ut_params = &unittest_params;
6666 uint8_t *plaintext = NULL, *ciphertext = NULL;
6667 unsigned int plaintext_pad_len;
6668 unsigned int plaintext_len;
6669 unsigned int ciphertext_pad_len;
6670 unsigned int ciphertext_len;
6672 struct rte_cryptodev_info dev_info;
6674 /* Check if device supports particular algorithms separately */
6675 if (test_mixed_check_if_unsupported(tdata))
6677 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6680 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6682 uint64_t feat_flags = dev_info.feature_flags;
6684 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6685 printf("Device doesn't support digest encrypted.\n");
6689 if (op_mode == OUT_OF_PLACE)
6692 /* Create the session */
6694 retval = create_wireless_algo_cipher_auth_session(
6695 ts_params->valid_devs[0],
6696 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6697 RTE_CRYPTO_AUTH_OP_VERIFY,
6700 tdata->auth_key.data, tdata->auth_key.len,
6701 tdata->auth_iv.len, tdata->digest_enc.len,
6702 tdata->cipher_iv.len);
6704 retval = create_wireless_algo_auth_cipher_session(
6705 ts_params->valid_devs[0],
6706 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6707 RTE_CRYPTO_AUTH_OP_GENERATE,
6710 tdata->auth_key.data, tdata->auth_key.len,
6711 tdata->auth_iv.len, tdata->digest_enc.len,
6712 tdata->cipher_iv.len);
6716 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6717 if (op_mode == OUT_OF_PLACE)
6718 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6720 /* clear mbuf payload */
6721 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6722 rte_pktmbuf_tailroom(ut_params->ibuf));
6723 if (op_mode == OUT_OF_PLACE) {
6725 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6726 rte_pktmbuf_tailroom(ut_params->obuf));
6729 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6730 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6731 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6732 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6735 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6736 ciphertext_pad_len);
6737 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6738 if (op_mode == OUT_OF_PLACE)
6739 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6740 debug_hexdump(stdout, "ciphertext:", ciphertext,
6743 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6745 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6746 if (op_mode == OUT_OF_PLACE)
6747 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6748 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6751 /* Create the operation */
6752 retval = create_wireless_algo_auth_cipher_operation(
6753 tdata->digest_enc.data, tdata->digest_enc.len,
6754 tdata->cipher_iv.data, tdata->cipher_iv.len,
6755 tdata->auth_iv.data, tdata->auth_iv.len,
6756 (tdata->digest_enc.offset == 0 ?
6758 : tdata->digest_enc.offset),
6759 tdata->validCipherLen.len_bits,
6760 tdata->cipher.offset_bits,
6761 tdata->validAuthLen.len_bits,
6762 tdata->auth.offset_bits,
6763 op_mode, 0, verify);
6768 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6771 /* Check if the op failed because the device doesn't */
6772 /* support this particular combination of algorithms */
6773 if (ut_params->op == NULL && ut_params->op->status ==
6774 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6775 printf("Device doesn't support this mixed combination. "
6780 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6782 ut_params->obuf = (op_mode == IN_PLACE ?
6783 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6786 if (ut_params->obuf)
6787 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6790 plaintext = ciphertext +
6791 (tdata->cipher.offset_bits >> 3);
6793 debug_hexdump(stdout, "plaintext:", plaintext,
6794 tdata->plaintext.len_bits >> 3);
6795 debug_hexdump(stdout, "plaintext expected:",
6796 tdata->plaintext.data,
6797 tdata->plaintext.len_bits >> 3);
6799 if (ut_params->obuf)
6800 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6803 ciphertext = plaintext;
6805 debug_hexdump(stdout, "ciphertext:", ciphertext,
6807 debug_hexdump(stdout, "ciphertext expected:",
6808 tdata->ciphertext.data,
6809 tdata->ciphertext.len_bits >> 3);
6811 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6812 + (tdata->digest_enc.offset == 0 ?
6813 plaintext_pad_len : tdata->digest_enc.offset);
6815 debug_hexdump(stdout, "digest:", ut_params->digest,
6816 tdata->digest_enc.len);
6817 debug_hexdump(stdout, "digest expected:",
6818 tdata->digest_enc.data,
6819 tdata->digest_enc.len);
6824 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6826 tdata->plaintext.data,
6827 tdata->plaintext.len_bits >> 3,
6828 "Plaintext data not as expected");
6830 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6832 tdata->ciphertext.data,
6833 tdata->validDataLen.len_bits,
6834 "Ciphertext data not as expected");
6836 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6838 tdata->digest_enc.data,
6839 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6840 "Generated auth tag not as expected");
6843 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6844 "crypto op processing failed");
6850 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6851 uint8_t op_mode, uint8_t verify)
6853 struct crypto_testsuite_params *ts_params = &testsuite_params;
6854 struct crypto_unittest_params *ut_params = &unittest_params;
6858 const uint8_t *plaintext = NULL;
6859 const uint8_t *ciphertext = NULL;
6860 const uint8_t *digest = NULL;
6861 unsigned int plaintext_pad_len;
6862 unsigned int plaintext_len;
6863 unsigned int ciphertext_pad_len;
6864 unsigned int ciphertext_len;
6865 uint8_t buffer[10000];
6866 uint8_t digest_buffer[10000];
6868 struct rte_cryptodev_info dev_info;
6870 /* Check if device supports particular algorithms */
6871 if (test_mixed_check_if_unsupported(tdata))
6873 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6876 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6878 uint64_t feat_flags = dev_info.feature_flags;
6880 if (op_mode == IN_PLACE) {
6881 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6882 printf("Device doesn't support in-place scatter-gather "
6883 "in both input and output mbufs.\n");
6887 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6888 printf("Device doesn't support out-of-place scatter-gather "
6889 "in both input and output mbufs.\n");
6892 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6893 printf("Device doesn't support digest encrypted.\n");
6898 /* Create the session */
6900 retval = create_wireless_algo_cipher_auth_session(
6901 ts_params->valid_devs[0],
6902 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6903 RTE_CRYPTO_AUTH_OP_VERIFY,
6906 tdata->auth_key.data, tdata->auth_key.len,
6907 tdata->auth_iv.len, tdata->digest_enc.len,
6908 tdata->cipher_iv.len);
6910 retval = create_wireless_algo_auth_cipher_session(
6911 ts_params->valid_devs[0],
6912 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6913 RTE_CRYPTO_AUTH_OP_GENERATE,
6916 tdata->auth_key.data, tdata->auth_key.len,
6917 tdata->auth_iv.len, tdata->digest_enc.len,
6918 tdata->cipher_iv.len);
6922 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6923 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6924 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6925 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6927 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6928 ciphertext_pad_len, 15, 0);
6929 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6930 "Failed to allocate input buffer in mempool");
6932 if (op_mode == OUT_OF_PLACE) {
6933 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6934 plaintext_pad_len, 15, 0);
6935 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6936 "Failed to allocate output buffer in mempool");
6940 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6941 tdata->ciphertext.data);
6942 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6943 ciphertext_len, buffer);
6944 debug_hexdump(stdout, "ciphertext:", ciphertext,
6947 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6948 tdata->plaintext.data);
6949 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6950 plaintext_len, buffer);
6951 debug_hexdump(stdout, "plaintext:", plaintext,
6954 memset(buffer, 0, sizeof(buffer));
6956 /* Create the operation */
6957 retval = create_wireless_algo_auth_cipher_operation(
6958 tdata->digest_enc.data, tdata->digest_enc.len,
6959 tdata->cipher_iv.data, tdata->cipher_iv.len,
6960 tdata->auth_iv.data, tdata->auth_iv.len,
6961 (tdata->digest_enc.offset == 0 ?
6963 : tdata->digest_enc.offset),
6964 tdata->validCipherLen.len_bits,
6965 tdata->cipher.offset_bits,
6966 tdata->validAuthLen.len_bits,
6967 tdata->auth.offset_bits,
6968 op_mode, 1, verify);
6973 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6976 /* Check if the op failed because the device doesn't */
6977 /* support this particular combination of algorithms */
6978 if (ut_params->op == NULL && ut_params->op->status ==
6979 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6980 printf("Device doesn't support this mixed combination. "
6985 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6987 ut_params->obuf = (op_mode == IN_PLACE ?
6988 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6991 if (ut_params->obuf)
6992 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6993 plaintext_len, buffer);
6995 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6996 plaintext_len, buffer);
6998 debug_hexdump(stdout, "plaintext:", plaintext,
6999 (tdata->plaintext.len_bits >> 3) -
7000 tdata->digest_enc.len);
7001 debug_hexdump(stdout, "plaintext expected:",
7002 tdata->plaintext.data,
7003 (tdata->plaintext.len_bits >> 3) -
7004 tdata->digest_enc.len);
7006 if (ut_params->obuf)
7007 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7008 ciphertext_len, buffer);
7010 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7011 ciphertext_len, buffer);
7013 debug_hexdump(stdout, "ciphertext:", ciphertext,
7015 debug_hexdump(stdout, "ciphertext expected:",
7016 tdata->ciphertext.data,
7017 tdata->ciphertext.len_bits >> 3);
7019 if (ut_params->obuf)
7020 digest = rte_pktmbuf_read(ut_params->obuf,
7021 (tdata->digest_enc.offset == 0 ?
7023 tdata->digest_enc.offset),
7024 tdata->digest_enc.len, digest_buffer);
7026 digest = rte_pktmbuf_read(ut_params->ibuf,
7027 (tdata->digest_enc.offset == 0 ?
7029 tdata->digest_enc.offset),
7030 tdata->digest_enc.len, digest_buffer);
7032 debug_hexdump(stdout, "digest:", digest,
7033 tdata->digest_enc.len);
7034 debug_hexdump(stdout, "digest expected:",
7035 tdata->digest_enc.data, tdata->digest_enc.len);
7040 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7042 tdata->plaintext.data,
7043 tdata->plaintext.len_bits >> 3,
7044 "Plaintext data not as expected");
7046 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7048 tdata->ciphertext.data,
7049 tdata->validDataLen.len_bits,
7050 "Ciphertext data not as expected");
7051 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7053 tdata->digest_enc.data,
7054 tdata->digest_enc.len,
7055 "Generated auth tag not as expected");
7058 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7059 "crypto op processing failed");
7064 /** AUTH AES CMAC + CIPHER AES CTR */
7067 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7069 return test_mixed_auth_cipher(
7070 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7074 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7076 return test_mixed_auth_cipher(
7077 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7081 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7083 return test_mixed_auth_cipher_sgl(
7084 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7088 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7090 return test_mixed_auth_cipher_sgl(
7091 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7095 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7097 return test_mixed_auth_cipher(
7098 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7102 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7104 return test_mixed_auth_cipher(
7105 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7109 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7111 return test_mixed_auth_cipher_sgl(
7112 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7116 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7118 return test_mixed_auth_cipher_sgl(
7119 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7122 /** MIXED AUTH + CIPHER */
7125 test_auth_zuc_cipher_snow_test_case_1(void)
7127 return test_mixed_auth_cipher(
7128 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7132 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7134 return test_mixed_auth_cipher(
7135 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7139 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7141 return test_mixed_auth_cipher(
7142 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7146 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7148 return test_mixed_auth_cipher(
7149 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7153 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7155 return test_mixed_auth_cipher(
7156 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7160 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7162 return test_mixed_auth_cipher(
7163 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7167 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7169 return test_mixed_auth_cipher(
7170 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7174 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7176 return test_mixed_auth_cipher(
7177 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7181 test_auth_snow_cipher_zuc_test_case_1(void)
7183 return test_mixed_auth_cipher(
7184 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7188 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7190 return test_mixed_auth_cipher(
7191 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7195 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7197 return test_mixed_auth_cipher(
7198 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7202 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7204 return test_mixed_auth_cipher(
7205 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7209 test_auth_null_cipher_snow_test_case_1(void)
7211 return test_mixed_auth_cipher(
7212 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7216 test_verify_auth_null_cipher_snow_test_case_1(void)
7218 return test_mixed_auth_cipher(
7219 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7223 test_auth_null_cipher_zuc_test_case_1(void)
7225 return test_mixed_auth_cipher(
7226 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7230 test_verify_auth_null_cipher_zuc_test_case_1(void)
7232 return test_mixed_auth_cipher(
7233 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7237 test_auth_snow_cipher_null_test_case_1(void)
7239 return test_mixed_auth_cipher(
7240 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7244 test_verify_auth_snow_cipher_null_test_case_1(void)
7246 return test_mixed_auth_cipher(
7247 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7251 test_auth_zuc_cipher_null_test_case_1(void)
7253 return test_mixed_auth_cipher(
7254 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7258 test_verify_auth_zuc_cipher_null_test_case_1(void)
7260 return test_mixed_auth_cipher(
7261 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7265 test_auth_null_cipher_aes_ctr_test_case_1(void)
7267 return test_mixed_auth_cipher(
7268 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7272 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7274 return test_mixed_auth_cipher(
7275 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7279 test_auth_aes_cmac_cipher_null_test_case_1(void)
7281 return test_mixed_auth_cipher(
7282 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7286 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7288 return test_mixed_auth_cipher(
7289 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7292 /* ***** AEAD algorithm Tests ***** */
7295 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7296 enum rte_crypto_aead_operation op,
7297 const uint8_t *key, const uint8_t key_len,
7298 const uint16_t aad_len, const uint8_t auth_len,
7301 uint8_t aead_key[key_len];
7303 struct crypto_testsuite_params *ts_params = &testsuite_params;
7304 struct crypto_unittest_params *ut_params = &unittest_params;
7306 memcpy(aead_key, key, key_len);
7308 /* Setup AEAD Parameters */
7309 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7310 ut_params->aead_xform.next = NULL;
7311 ut_params->aead_xform.aead.algo = algo;
7312 ut_params->aead_xform.aead.op = op;
7313 ut_params->aead_xform.aead.key.data = aead_key;
7314 ut_params->aead_xform.aead.key.length = key_len;
7315 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7316 ut_params->aead_xform.aead.iv.length = iv_len;
7317 ut_params->aead_xform.aead.digest_length = auth_len;
7318 ut_params->aead_xform.aead.aad_length = aad_len;
7320 debug_hexdump(stdout, "key:", key, key_len);
7322 /* Create Crypto session*/
7323 ut_params->sess = rte_cryptodev_sym_session_create(
7324 ts_params->session_mpool);
7326 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7327 &ut_params->aead_xform,
7328 ts_params->session_priv_mpool);
7330 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7336 create_aead_xform(struct rte_crypto_op *op,
7337 enum rte_crypto_aead_algorithm algo,
7338 enum rte_crypto_aead_operation aead_op,
7339 uint8_t *key, const uint8_t key_len,
7340 const uint8_t aad_len, const uint8_t auth_len,
7343 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7344 "failed to allocate space for crypto transform");
7346 struct rte_crypto_sym_op *sym_op = op->sym;
7348 /* Setup AEAD Parameters */
7349 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7350 sym_op->xform->next = NULL;
7351 sym_op->xform->aead.algo = algo;
7352 sym_op->xform->aead.op = aead_op;
7353 sym_op->xform->aead.key.data = key;
7354 sym_op->xform->aead.key.length = key_len;
7355 sym_op->xform->aead.iv.offset = IV_OFFSET;
7356 sym_op->xform->aead.iv.length = iv_len;
7357 sym_op->xform->aead.digest_length = auth_len;
7358 sym_op->xform->aead.aad_length = aad_len;
7360 debug_hexdump(stdout, "key:", key, key_len);
7366 create_aead_operation(enum rte_crypto_aead_operation op,
7367 const struct aead_test_data *tdata)
7369 struct crypto_testsuite_params *ts_params = &testsuite_params;
7370 struct crypto_unittest_params *ut_params = &unittest_params;
7372 uint8_t *plaintext, *ciphertext;
7373 unsigned int aad_pad_len, plaintext_pad_len;
7375 /* Generate Crypto op data structure */
7376 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7377 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7378 TEST_ASSERT_NOT_NULL(ut_params->op,
7379 "Failed to allocate symmetric crypto operation struct");
7381 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7383 /* Append aad data */
7384 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7385 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7386 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7388 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7389 "no room to append aad");
7391 sym_op->aead.aad.phys_addr =
7392 rte_pktmbuf_iova(ut_params->ibuf);
7393 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7394 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7395 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7398 /* Append IV at the end of the crypto operation*/
7399 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7400 uint8_t *, IV_OFFSET);
7402 /* Copy IV 1 byte after the IV pointer, according to the API */
7403 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7404 debug_hexdump(stdout, "iv:", iv_ptr,
7407 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7408 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7410 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7411 "no room to append aad");
7413 sym_op->aead.aad.phys_addr =
7414 rte_pktmbuf_iova(ut_params->ibuf);
7415 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7416 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7419 /* Append IV at the end of the crypto operation*/
7420 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7421 uint8_t *, IV_OFFSET);
7423 if (tdata->iv.len == 0) {
7424 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7425 debug_hexdump(stdout, "iv:", iv_ptr,
7428 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7429 debug_hexdump(stdout, "iv:", iv_ptr,
7434 /* Append plaintext/ciphertext */
7435 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7436 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7437 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7439 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7441 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7442 debug_hexdump(stdout, "plaintext:", plaintext,
7443 tdata->plaintext.len);
7445 if (ut_params->obuf) {
7446 ciphertext = (uint8_t *)rte_pktmbuf_append(
7448 plaintext_pad_len + aad_pad_len);
7449 TEST_ASSERT_NOT_NULL(ciphertext,
7450 "no room to append ciphertext");
7452 memset(ciphertext + aad_pad_len, 0,
7453 tdata->ciphertext.len);
7456 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7457 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7459 TEST_ASSERT_NOT_NULL(ciphertext,
7460 "no room to append ciphertext");
7462 memcpy(ciphertext, tdata->ciphertext.data,
7463 tdata->ciphertext.len);
7464 debug_hexdump(stdout, "ciphertext:", ciphertext,
7465 tdata->ciphertext.len);
7467 if (ut_params->obuf) {
7468 plaintext = (uint8_t *)rte_pktmbuf_append(
7470 plaintext_pad_len + aad_pad_len);
7471 TEST_ASSERT_NOT_NULL(plaintext,
7472 "no room to append plaintext");
7474 memset(plaintext + aad_pad_len, 0,
7475 tdata->plaintext.len);
7479 /* Append digest data */
7480 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7481 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7482 ut_params->obuf ? ut_params->obuf :
7484 tdata->auth_tag.len);
7485 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7486 "no room to append digest");
7487 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7488 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7489 ut_params->obuf ? ut_params->obuf :
7494 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7495 ut_params->ibuf, tdata->auth_tag.len);
7496 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7497 "no room to append digest");
7498 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7500 plaintext_pad_len + aad_pad_len);
7502 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7503 tdata->auth_tag.len);
7504 debug_hexdump(stdout, "digest:",
7505 sym_op->aead.digest.data,
7506 tdata->auth_tag.len);
7509 sym_op->aead.data.length = tdata->plaintext.len;
7510 sym_op->aead.data.offset = aad_pad_len;
7516 test_authenticated_encryption(const struct aead_test_data *tdata)
7518 struct crypto_testsuite_params *ts_params = &testsuite_params;
7519 struct crypto_unittest_params *ut_params = &unittest_params;
7522 uint8_t *ciphertext, *auth_tag;
7523 uint16_t plaintext_pad_len;
7525 struct rte_cryptodev_info dev_info;
7527 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7528 uint64_t feat_flags = dev_info.feature_flags;
7530 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7531 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7532 printf("Device doesn't support RAW data-path APIs.\n");
7536 /* Verify the capabilities */
7537 struct rte_cryptodev_sym_capability_idx cap_idx;
7538 const struct rte_cryptodev_symmetric_capability *capability;
7539 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7540 cap_idx.algo.aead = tdata->algo;
7541 capability = rte_cryptodev_sym_capability_get(
7542 ts_params->valid_devs[0], &cap_idx);
7543 if (capability == NULL)
7545 if (rte_cryptodev_sym_capability_check_aead(
7546 capability, tdata->key.len, tdata->auth_tag.len,
7547 tdata->aad.len, tdata->iv.len))
7550 /* Create AEAD session */
7551 retval = create_aead_session(ts_params->valid_devs[0],
7553 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7554 tdata->key.data, tdata->key.len,
7555 tdata->aad.len, tdata->auth_tag.len,
7560 if (tdata->aad.len > MBUF_SIZE) {
7561 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7562 /* Populate full size of add data */
7563 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7564 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7566 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7568 /* clear mbuf payload */
7569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7570 rte_pktmbuf_tailroom(ut_params->ibuf));
7572 /* Create AEAD operation */
7573 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7577 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7579 ut_params->op->sym->m_src = ut_params->ibuf;
7581 /* Process crypto operation */
7582 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7583 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7584 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7585 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
7586 ut_params->op, 0, 0, 0, 0);
7588 TEST_ASSERT_NOT_NULL(
7589 process_crypto_request(ts_params->valid_devs[0],
7590 ut_params->op), "failed to process sym crypto op");
7592 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7593 "crypto op processing failed");
7595 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7597 if (ut_params->op->sym->m_dst) {
7598 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7600 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7601 uint8_t *, plaintext_pad_len);
7603 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7605 ut_params->op->sym->cipher.data.offset);
7606 auth_tag = ciphertext + plaintext_pad_len;
7609 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7610 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7613 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7615 tdata->ciphertext.data,
7616 tdata->ciphertext.len,
7617 "Ciphertext data not as expected");
7619 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7621 tdata->auth_tag.data,
7622 tdata->auth_tag.len,
7623 "Generated auth tag not as expected");
7629 #ifdef RTE_LIBRTE_SECURITY
7631 security_proto_supported(enum rte_security_session_action_type action,
7632 enum rte_security_session_protocol proto)
7634 struct crypto_testsuite_params *ts_params = &testsuite_params;
7636 const struct rte_security_capability *capabilities;
7637 const struct rte_security_capability *capability;
7640 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7641 rte_cryptodev_get_sec_ctx(
7642 ts_params->valid_devs[0]);
7645 capabilities = rte_security_capabilities_get(ctx);
7647 if (capabilities == NULL)
7650 while ((capability = &capabilities[i++])->action !=
7651 RTE_SECURITY_ACTION_TYPE_NONE) {
7652 if (capability->action == action &&
7653 capability->protocol == proto)
7660 /* Basic algorithm run function for async inplace mode.
7661 * Creates a session from input parameters and runs one operation
7662 * on input_vec. Checks the output of the crypto operation against
7665 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
7666 enum rte_crypto_auth_operation opa,
7667 const uint8_t *input_vec, unsigned int input_vec_len,
7668 const uint8_t *output_vec,
7669 unsigned int output_vec_len,
7670 enum rte_crypto_cipher_algorithm cipher_alg,
7671 const uint8_t *cipher_key, uint32_t cipher_key_len,
7672 enum rte_crypto_auth_algorithm auth_alg,
7673 const uint8_t *auth_key, uint32_t auth_key_len,
7674 uint8_t bearer, enum rte_security_pdcp_domain domain,
7675 uint8_t packet_direction, uint8_t sn_size,
7676 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
7678 struct crypto_testsuite_params *ts_params = &testsuite_params;
7679 struct crypto_unittest_params *ut_params = &unittest_params;
7681 int ret = TEST_SUCCESS;
7682 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7683 rte_cryptodev_get_sec_ctx(
7684 ts_params->valid_devs[0]);
7686 /* Verify the capabilities */
7687 struct rte_security_capability_idx sec_cap_idx;
7689 sec_cap_idx.action = ut_params->type;
7690 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7691 sec_cap_idx.pdcp.domain = domain;
7692 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7695 /* Generate test mbuf data */
7696 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7698 /* clear mbuf payload */
7699 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7700 rte_pktmbuf_tailroom(ut_params->ibuf));
7702 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7704 memcpy(plaintext, input_vec, input_vec_len);
7706 /* Out of place support */
7709 * For out-op-place we need to alloc another mbuf
7711 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7712 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7715 /* Setup Cipher Parameters */
7716 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7717 ut_params->cipher_xform.cipher.algo = cipher_alg;
7718 ut_params->cipher_xform.cipher.op = opc;
7719 ut_params->cipher_xform.cipher.key.data = cipher_key;
7720 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
7721 ut_params->cipher_xform.cipher.iv.length =
7722 packet_direction ? 4 : 0;
7723 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7725 /* Setup HMAC Parameters if ICV header is required */
7726 if (auth_alg != 0) {
7727 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7728 ut_params->auth_xform.next = NULL;
7729 ut_params->auth_xform.auth.algo = auth_alg;
7730 ut_params->auth_xform.auth.op = opa;
7731 ut_params->auth_xform.auth.key.data = auth_key;
7732 ut_params->auth_xform.auth.key.length = auth_key_len;
7734 ut_params->cipher_xform.next = &ut_params->auth_xform;
7736 ut_params->cipher_xform.next = NULL;
7739 struct rte_security_session_conf sess_conf = {
7740 .action_type = ut_params->type,
7741 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7745 .pkt_dir = packet_direction,
7747 .hfn = packet_direction ? 0 : hfn,
7749 * hfn can be set as pdcp_test_hfn[i]
7750 * if hfn_ovrd is not set. Here, PDCP
7751 * packet direction is just used to
7752 * run half of the cases with session
7753 * HFN and other half with per packet
7756 .hfn_threshold = hfn_threshold,
7757 .hfn_ovrd = packet_direction ? 1 : 0,
7758 .sdap_enabled = sdap,
7760 .crypto_xform = &ut_params->cipher_xform
7763 /* Create security session */
7764 ut_params->sec_session = rte_security_session_create(ctx,
7765 &sess_conf, ts_params->session_priv_mpool);
7767 if (!ut_params->sec_session) {
7768 printf("TestCase %s()-%d line %d failed %s: ",
7769 __func__, i, __LINE__, "Failed to allocate session");
7774 /* Generate crypto op data structure */
7775 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7776 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7777 if (!ut_params->op) {
7778 printf("TestCase %s()-%d line %d failed %s: ",
7779 __func__, i, __LINE__,
7780 "Failed to allocate symmetric crypto operation struct");
7785 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7786 uint32_t *, IV_OFFSET);
7787 *per_pkt_hfn = packet_direction ? hfn : 0;
7789 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7791 /* set crypto operation source mbuf */
7792 ut_params->op->sym->m_src = ut_params->ibuf;
7794 ut_params->op->sym->m_dst = ut_params->obuf;
7796 /* Process crypto operation */
7797 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7799 printf("TestCase %s()-%d line %d failed %s: ",
7800 __func__, i, __LINE__,
7801 "failed to process sym crypto op");
7806 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7807 printf("TestCase %s()-%d line %d failed %s: ",
7808 __func__, i, __LINE__, "crypto op processing failed");
7814 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7817 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7821 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7822 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7823 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7824 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7830 rte_crypto_op_free(ut_params->op);
7831 ut_params->op = NULL;
7833 if (ut_params->sec_session)
7834 rte_security_session_destroy(ctx, ut_params->sec_session);
7835 ut_params->sec_session = NULL;
7837 rte_pktmbuf_free(ut_params->ibuf);
7838 ut_params->ibuf = NULL;
7840 rte_pktmbuf_free(ut_params->obuf);
7841 ut_params->obuf = NULL;
7848 test_pdcp_proto_SGL(int i, int oop,
7849 enum rte_crypto_cipher_operation opc,
7850 enum rte_crypto_auth_operation opa,
7852 unsigned int input_vec_len,
7853 uint8_t *output_vec,
7854 unsigned int output_vec_len,
7856 uint32_t fragsz_oop)
7858 struct crypto_testsuite_params *ts_params = &testsuite_params;
7859 struct crypto_unittest_params *ut_params = &unittest_params;
7861 struct rte_mbuf *buf, *buf_oop = NULL;
7862 int ret = TEST_SUCCESS;
7866 unsigned int trn_data = 0;
7867 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7868 rte_cryptodev_get_sec_ctx(
7869 ts_params->valid_devs[0]);
7871 /* Verify the capabilities */
7872 struct rte_security_capability_idx sec_cap_idx;
7874 sec_cap_idx.action = ut_params->type;
7875 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7876 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7877 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7880 if (fragsz > input_vec_len)
7881 fragsz = input_vec_len;
7883 uint16_t plaintext_len = fragsz;
7884 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7886 if (fragsz_oop > output_vec_len)
7887 frag_size_oop = output_vec_len;
7890 if (input_vec_len % fragsz != 0) {
7891 if (input_vec_len / fragsz + 1 > 16)
7893 } else if (input_vec_len / fragsz > 16)
7896 /* Out of place support */
7899 * For out-op-place we need to alloc another mbuf
7901 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7902 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7903 buf_oop = ut_params->obuf;
7906 /* Generate test mbuf data */
7907 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7909 /* clear mbuf payload */
7910 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7911 rte_pktmbuf_tailroom(ut_params->ibuf));
7913 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7915 memcpy(plaintext, input_vec, plaintext_len);
7916 trn_data += plaintext_len;
7918 buf = ut_params->ibuf;
7921 * Loop until no more fragments
7924 while (trn_data < input_vec_len) {
7926 to_trn = (input_vec_len - trn_data < fragsz) ?
7927 (input_vec_len - trn_data) : fragsz;
7929 to_trn_tbl[ecx++] = to_trn;
7931 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7934 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7935 rte_pktmbuf_tailroom(buf));
7938 if (oop && !fragsz_oop) {
7940 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7941 buf_oop = buf_oop->next;
7942 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7943 0, rte_pktmbuf_tailroom(buf_oop));
7944 rte_pktmbuf_append(buf_oop, to_trn);
7947 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7950 memcpy(plaintext, input_vec + trn_data, to_trn);
7954 ut_params->ibuf->nb_segs = segs;
7957 if (fragsz_oop && oop) {
7961 trn_data = frag_size_oop;
7962 while (trn_data < output_vec_len) {
7965 (output_vec_len - trn_data <
7967 (output_vec_len - trn_data) :
7970 to_trn_tbl[ecx++] = to_trn;
7973 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7974 buf_oop = buf_oop->next;
7975 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7976 0, rte_pktmbuf_tailroom(buf_oop));
7977 rte_pktmbuf_append(buf_oop, to_trn);
7981 ut_params->obuf->nb_segs = segs;
7984 /* Setup Cipher Parameters */
7985 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7986 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7987 ut_params->cipher_xform.cipher.op = opc;
7988 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7989 ut_params->cipher_xform.cipher.key.length =
7990 pdcp_test_params[i].cipher_key_len;
7991 ut_params->cipher_xform.cipher.iv.length = 0;
7993 /* Setup HMAC Parameters if ICV header is required */
7994 if (pdcp_test_params[i].auth_alg != 0) {
7995 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7996 ut_params->auth_xform.next = NULL;
7997 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7998 ut_params->auth_xform.auth.op = opa;
7999 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8000 ut_params->auth_xform.auth.key.length =
8001 pdcp_test_params[i].auth_key_len;
8003 ut_params->cipher_xform.next = &ut_params->auth_xform;
8005 ut_params->cipher_xform.next = NULL;
8008 struct rte_security_session_conf sess_conf = {
8009 .action_type = ut_params->type,
8010 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8012 .bearer = pdcp_test_bearer[i],
8013 .domain = pdcp_test_params[i].domain,
8014 .pkt_dir = pdcp_test_packet_direction[i],
8015 .sn_size = pdcp_test_data_sn_size[i],
8016 .hfn = pdcp_test_hfn[i],
8017 .hfn_threshold = pdcp_test_hfn_threshold[i],
8020 .crypto_xform = &ut_params->cipher_xform
8023 /* Create security session */
8024 ut_params->sec_session = rte_security_session_create(ctx,
8025 &sess_conf, ts_params->session_priv_mpool);
8027 if (!ut_params->sec_session) {
8028 printf("TestCase %s()-%d line %d failed %s: ",
8029 __func__, i, __LINE__, "Failed to allocate session");
8034 /* Generate crypto op data structure */
8035 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8036 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8037 if (!ut_params->op) {
8038 printf("TestCase %s()-%d line %d failed %s: ",
8039 __func__, i, __LINE__,
8040 "Failed to allocate symmetric crypto operation struct");
8045 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8047 /* set crypto operation source mbuf */
8048 ut_params->op->sym->m_src = ut_params->ibuf;
8050 ut_params->op->sym->m_dst = ut_params->obuf;
8052 /* Process crypto operation */
8053 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8055 printf("TestCase %s()-%d line %d failed %s: ",
8056 __func__, i, __LINE__,
8057 "failed to process sym crypto op");
8062 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8063 printf("TestCase %s()-%d line %d failed %s: ",
8064 __func__, i, __LINE__, "crypto op processing failed");
8070 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8073 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8077 fragsz = frag_size_oop;
8078 if (memcmp(ciphertext, output_vec, fragsz)) {
8079 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8080 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8081 rte_hexdump(stdout, "reference", output_vec, fragsz);
8086 buf = ut_params->op->sym->m_src->next;
8088 buf = ut_params->op->sym->m_dst->next;
8090 unsigned int off = fragsz;
8094 ciphertext = rte_pktmbuf_mtod(buf,
8096 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8097 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8098 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8099 rte_hexdump(stdout, "reference", output_vec + off,
8104 off += to_trn_tbl[ecx++];
8108 rte_crypto_op_free(ut_params->op);
8109 ut_params->op = NULL;
8111 if (ut_params->sec_session)
8112 rte_security_session_destroy(ctx, ut_params->sec_session);
8113 ut_params->sec_session = NULL;
8115 rte_pktmbuf_free(ut_params->ibuf);
8116 ut_params->ibuf = NULL;
8118 rte_pktmbuf_free(ut_params->obuf);
8119 ut_params->obuf = NULL;
8126 test_pdcp_proto_cplane_encap(int i)
8128 return test_pdcp_proto(
8129 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8130 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8131 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8132 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8133 pdcp_test_params[i].cipher_key_len,
8134 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8135 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8136 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8137 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8138 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8142 test_pdcp_proto_uplane_encap(int i)
8144 return test_pdcp_proto(
8145 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8146 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8147 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8148 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8149 pdcp_test_params[i].cipher_key_len,
8150 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8151 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8152 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8153 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8154 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8158 test_pdcp_proto_uplane_encap_with_int(int i)
8160 return test_pdcp_proto(
8161 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8162 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8163 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8164 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8165 pdcp_test_params[i].cipher_key_len,
8166 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8167 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8168 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8169 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8170 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8174 test_pdcp_proto_cplane_decap(int i)
8176 return test_pdcp_proto(
8177 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8178 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8179 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8180 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8181 pdcp_test_params[i].cipher_key_len,
8182 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8183 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8184 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8185 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8186 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8190 test_pdcp_proto_uplane_decap(int i)
8192 return test_pdcp_proto(
8193 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8194 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8195 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8196 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8197 pdcp_test_params[i].cipher_key_len,
8198 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8199 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8200 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8201 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8202 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8206 test_pdcp_proto_uplane_decap_with_int(int i)
8208 return test_pdcp_proto(
8209 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8210 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8211 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8212 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8213 pdcp_test_params[i].cipher_key_len,
8214 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8215 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8216 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8217 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8218 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8222 test_PDCP_PROTO_SGL_in_place_32B(void)
8224 /* i can be used for running any PDCP case
8225 * In this case it is uplane 12-bit AES-SNOW DL encap
8227 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8228 return test_pdcp_proto_SGL(i, IN_PLACE,
8229 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8230 RTE_CRYPTO_AUTH_OP_GENERATE,
8231 pdcp_test_data_in[i],
8232 pdcp_test_data_in_len[i],
8233 pdcp_test_data_out[i],
8234 pdcp_test_data_in_len[i]+4,
8238 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8240 /* i can be used for running any PDCP case
8241 * In this case it is uplane 18-bit NULL-NULL DL encap
8243 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8244 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8245 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8246 RTE_CRYPTO_AUTH_OP_GENERATE,
8247 pdcp_test_data_in[i],
8248 pdcp_test_data_in_len[i],
8249 pdcp_test_data_out[i],
8250 pdcp_test_data_in_len[i]+4,
8254 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8256 /* i can be used for running any PDCP case
8257 * In this case it is uplane 18-bit AES DL encap
8259 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8261 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8262 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8263 RTE_CRYPTO_AUTH_OP_GENERATE,
8264 pdcp_test_data_in[i],
8265 pdcp_test_data_in_len[i],
8266 pdcp_test_data_out[i],
8267 pdcp_test_data_in_len[i],
8271 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8273 /* i can be used for running any PDCP case
8274 * In this case it is cplane 12-bit AES-ZUC DL encap
8276 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8277 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8278 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8279 RTE_CRYPTO_AUTH_OP_GENERATE,
8280 pdcp_test_data_in[i],
8281 pdcp_test_data_in_len[i],
8282 pdcp_test_data_out[i],
8283 pdcp_test_data_in_len[i]+4,
8288 test_PDCP_SDAP_PROTO_encap_all(void)
8290 int i = 0, size = 0;
8291 int err, all_err = TEST_SUCCESS;
8292 const struct pdcp_sdap_test *cur_test;
8294 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8296 for (i = 0; i < size; i++) {
8297 cur_test = &list_pdcp_sdap_tests[i];
8298 err = test_pdcp_proto(
8299 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8300 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8301 cur_test->in_len, cur_test->data_out,
8302 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8303 cur_test->param.cipher_alg, cur_test->cipher_key,
8304 cur_test->param.cipher_key_len,
8305 cur_test->param.auth_alg,
8306 cur_test->auth_key, cur_test->param.auth_key_len,
8307 cur_test->bearer, cur_test->param.domain,
8308 cur_test->packet_direction, cur_test->sn_size,
8310 cur_test->hfn_threshold, SDAP_ENABLED);
8312 printf("\t%d) %s: Encapsulation failed\n",
8314 cur_test->param.name);
8317 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8318 cur_test->param.name);
8324 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8326 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8330 test_PDCP_SDAP_PROTO_decap_all(void)
8332 int i = 0, size = 0;
8333 int err, all_err = TEST_SUCCESS;
8334 const struct pdcp_sdap_test *cur_test;
8336 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8338 for (i = 0; i < size; i++) {
8339 cur_test = &list_pdcp_sdap_tests[i];
8340 err = test_pdcp_proto(
8341 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8342 RTE_CRYPTO_AUTH_OP_VERIFY,
8344 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8345 cur_test->data_in, cur_test->in_len,
8346 cur_test->param.cipher_alg,
8347 cur_test->cipher_key, cur_test->param.cipher_key_len,
8348 cur_test->param.auth_alg, cur_test->auth_key,
8349 cur_test->param.auth_key_len, cur_test->bearer,
8350 cur_test->param.domain, cur_test->packet_direction,
8351 cur_test->sn_size, cur_test->hfn,
8352 cur_test->hfn_threshold, SDAP_ENABLED);
8354 printf("\t%d) %s: Decapsulation failed\n",
8356 cur_test->param.name);
8359 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8360 cur_test->param.name);
8366 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8368 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8372 test_PDCP_PROTO_all(void)
8374 struct crypto_testsuite_params *ts_params = &testsuite_params;
8375 struct crypto_unittest_params *ut_params = &unittest_params;
8376 struct rte_cryptodev_info dev_info;
8379 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8380 uint64_t feat_flags = dev_info.feature_flags;
8382 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8385 /* Set action type */
8386 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8387 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8390 if (security_proto_supported(ut_params->type,
8391 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8394 status = test_PDCP_PROTO_cplane_encap_all();
8395 status += test_PDCP_PROTO_cplane_decap_all();
8396 status += test_PDCP_PROTO_uplane_encap_all();
8397 status += test_PDCP_PROTO_uplane_decap_all();
8398 status += test_PDCP_PROTO_SGL_in_place_32B();
8399 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8400 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8401 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8402 status += test_PDCP_SDAP_PROTO_encap_all();
8403 status += test_PDCP_SDAP_PROTO_decap_all();
8408 return TEST_SUCCESS;
8412 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8414 struct crypto_testsuite_params *ts_params = &testsuite_params;
8415 struct crypto_unittest_params *ut_params = &unittest_params;
8416 uint8_t *plaintext, *ciphertext;
8418 int32_t cipher_len, crc_len;
8419 uint32_t crc_data_len;
8420 int ret = TEST_SUCCESS;
8422 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8423 rte_cryptodev_get_sec_ctx(
8424 ts_params->valid_devs[0]);
8426 /* Verify the capabilities */
8427 struct rte_security_capability_idx sec_cap_idx;
8428 const struct rte_security_capability *sec_cap;
8429 const struct rte_cryptodev_capabilities *crypto_cap;
8430 const struct rte_cryptodev_symmetric_capability *sym_cap;
8433 sec_cap_idx.action = ut_params->type;
8434 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8435 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8437 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8438 if (sec_cap == NULL)
8441 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8442 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8443 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8444 crypto_cap->sym.xform_type ==
8445 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8446 crypto_cap->sym.cipher.algo ==
8447 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8448 sym_cap = &crypto_cap->sym;
8449 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8456 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8459 /* Setup source mbuf payload */
8460 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8461 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8462 rte_pktmbuf_tailroom(ut_params->ibuf));
8464 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8465 d_td->ciphertext.len);
8467 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8469 /* Setup cipher session parameters */
8470 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8471 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8472 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8473 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8474 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8475 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8476 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8477 ut_params->cipher_xform.next = NULL;
8479 /* Setup DOCSIS session parameters */
8480 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8482 struct rte_security_session_conf sess_conf = {
8483 .action_type = ut_params->type,
8484 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8485 .docsis = ut_params->docsis_xform,
8486 .crypto_xform = &ut_params->cipher_xform,
8489 /* Create security session */
8490 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8491 ts_params->session_priv_mpool);
8493 if (!ut_params->sec_session) {
8494 printf("TestCase %s(%d) line %d: %s\n",
8495 __func__, i, __LINE__, "failed to allocate session");
8500 /* Generate crypto op data structure */
8501 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8502 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8503 if (!ut_params->op) {
8504 printf("TestCase %s(%d) line %d: %s\n",
8505 __func__, i, __LINE__,
8506 "failed to allocate symmetric crypto operation");
8511 /* Setup CRC operation parameters */
8512 crc_len = d_td->ciphertext.no_crc == false ?
8513 (d_td->ciphertext.len -
8514 d_td->ciphertext.crc_offset -
8515 RTE_ETHER_CRC_LEN) :
8517 crc_len = crc_len > 0 ? crc_len : 0;
8518 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8519 ut_params->op->sym->auth.data.length = crc_len;
8520 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8522 /* Setup cipher operation parameters */
8523 cipher_len = d_td->ciphertext.no_cipher == false ?
8524 (d_td->ciphertext.len -
8525 d_td->ciphertext.cipher_offset) :
8527 cipher_len = cipher_len > 0 ? cipher_len : 0;
8528 ut_params->op->sym->cipher.data.length = cipher_len;
8529 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8531 /* Setup cipher IV */
8532 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8533 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8535 /* Attach session to operation */
8536 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8538 /* Set crypto operation mbufs */
8539 ut_params->op->sym->m_src = ut_params->ibuf;
8540 ut_params->op->sym->m_dst = NULL;
8542 /* Process crypto operation */
8543 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8545 printf("TestCase %s(%d) line %d: %s\n",
8546 __func__, i, __LINE__,
8547 "failed to process security crypto op");
8552 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8553 printf("TestCase %s(%d) line %d: %s\n",
8554 __func__, i, __LINE__, "crypto op processing failed");
8559 /* Validate plaintext */
8560 plaintext = ciphertext;
8562 if (memcmp(plaintext, d_td->plaintext.data,
8563 d_td->plaintext.len - crc_data_len)) {
8564 printf("TestCase %s(%d) line %d: %s\n",
8565 __func__, i, __LINE__, "plaintext not as expected\n");
8566 rte_hexdump(stdout, "expected", d_td->plaintext.data,
8567 d_td->plaintext.len);
8568 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
8574 rte_crypto_op_free(ut_params->op);
8575 ut_params->op = NULL;
8577 if (ut_params->sec_session)
8578 rte_security_session_destroy(ctx, ut_params->sec_session);
8579 ut_params->sec_session = NULL;
8581 rte_pktmbuf_free(ut_params->ibuf);
8582 ut_params->ibuf = NULL;
8588 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
8590 struct crypto_testsuite_params *ts_params = &testsuite_params;
8591 struct crypto_unittest_params *ut_params = &unittest_params;
8592 uint8_t *plaintext, *ciphertext;
8594 int32_t cipher_len, crc_len;
8595 int ret = TEST_SUCCESS;
8597 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8598 rte_cryptodev_get_sec_ctx(
8599 ts_params->valid_devs[0]);
8601 /* Verify the capabilities */
8602 struct rte_security_capability_idx sec_cap_idx;
8603 const struct rte_security_capability *sec_cap;
8604 const struct rte_cryptodev_capabilities *crypto_cap;
8605 const struct rte_cryptodev_symmetric_capability *sym_cap;
8608 sec_cap_idx.action = ut_params->type;
8609 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8610 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8612 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8613 if (sec_cap == NULL)
8616 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8617 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8618 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8619 crypto_cap->sym.xform_type ==
8620 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8621 crypto_cap->sym.cipher.algo ==
8622 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8623 sym_cap = &crypto_cap->sym;
8624 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8631 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8634 /* Setup source mbuf payload */
8635 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8636 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8637 rte_pktmbuf_tailroom(ut_params->ibuf));
8639 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8640 d_td->plaintext.len);
8642 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
8644 /* Setup cipher session parameters */
8645 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8646 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8647 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8648 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8649 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8650 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8651 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8652 ut_params->cipher_xform.next = NULL;
8654 /* Setup DOCSIS session parameters */
8655 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8657 struct rte_security_session_conf sess_conf = {
8658 .action_type = ut_params->type,
8659 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8660 .docsis = ut_params->docsis_xform,
8661 .crypto_xform = &ut_params->cipher_xform,
8664 /* Create security session */
8665 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8666 ts_params->session_priv_mpool);
8668 if (!ut_params->sec_session) {
8669 printf("TestCase %s(%d) line %d: %s\n",
8670 __func__, i, __LINE__, "failed to allocate session");
8675 /* Generate crypto op data structure */
8676 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8677 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8678 if (!ut_params->op) {
8679 printf("TestCase %s(%d) line %d: %s\n",
8680 __func__, i, __LINE__,
8681 "failed to allocate security crypto operation");
8686 /* Setup CRC operation parameters */
8687 crc_len = d_td->plaintext.no_crc == false ?
8688 (d_td->plaintext.len -
8689 d_td->plaintext.crc_offset -
8690 RTE_ETHER_CRC_LEN) :
8692 crc_len = crc_len > 0 ? crc_len : 0;
8693 ut_params->op->sym->auth.data.length = crc_len;
8694 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8696 /* Setup cipher operation parameters */
8697 cipher_len = d_td->plaintext.no_cipher == false ?
8698 (d_td->plaintext.len -
8699 d_td->plaintext.cipher_offset) :
8701 cipher_len = cipher_len > 0 ? cipher_len : 0;
8702 ut_params->op->sym->cipher.data.length = cipher_len;
8703 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8705 /* Setup cipher IV */
8706 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8707 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8709 /* Attach session to operation */
8710 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8712 /* Set crypto operation mbufs */
8713 ut_params->op->sym->m_src = ut_params->ibuf;
8714 ut_params->op->sym->m_dst = NULL;
8716 /* Process crypto operation */
8717 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8719 printf("TestCase %s(%d) line %d: %s\n",
8720 __func__, i, __LINE__,
8721 "failed to process security crypto op");
8726 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8727 printf("TestCase %s(%d) line %d: %s\n",
8728 __func__, i, __LINE__, "crypto op processing failed");
8733 /* Validate ciphertext */
8734 ciphertext = plaintext;
8736 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8737 printf("TestCase %s(%d) line %d: %s\n",
8738 __func__, i, __LINE__, "ciphertext not as expected\n");
8739 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8740 d_td->ciphertext.len);
8741 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8747 rte_crypto_op_free(ut_params->op);
8748 ut_params->op = NULL;
8750 if (ut_params->sec_session)
8751 rte_security_session_destroy(ctx, ut_params->sec_session);
8752 ut_params->sec_session = NULL;
8754 rte_pktmbuf_free(ut_params->ibuf);
8755 ut_params->ibuf = NULL;
8760 #define TEST_DOCSIS_COUNT(func) do { \
8762 if (ret == TEST_SUCCESS) { \
8763 printf("\t%2d)", n++); \
8764 printf("+++++ PASSED:" #func"\n"); \
8766 } else if (ret == -ENOTSUP) { \
8767 printf("\t%2d)", n++); \
8768 printf("~~~~~ UNSUPP:" #func"\n"); \
8771 printf("\t%2d)", n++); \
8772 printf("----- FAILED:" #func"\n"); \
8778 test_DOCSIS_PROTO_uplink_all(void)
8780 int p = 0, u = 0, f = 0, n = 0;
8782 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8783 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8784 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8785 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8786 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8787 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8788 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8789 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8790 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8791 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8792 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8793 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8794 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8795 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8796 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8797 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8798 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8799 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8800 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8801 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8802 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8803 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8804 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8805 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8806 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8807 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8810 printf("## %s: %d passed out of %d (%d unsupported)\n",
8817 test_DOCSIS_PROTO_downlink_all(void)
8819 int p = 0, u = 0, f = 0, n = 0;
8821 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8822 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8823 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8824 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8825 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8826 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8827 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8828 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8829 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8830 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8831 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8832 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8833 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8834 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8835 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8836 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8837 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8838 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8839 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8840 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8841 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8842 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8843 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8844 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8845 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8846 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8849 printf("## %s: %d passed out of %d (%d unsupported)\n",
8856 test_DOCSIS_PROTO_all(void)
8858 struct crypto_testsuite_params *ts_params = &testsuite_params;
8859 struct crypto_unittest_params *ut_params = &unittest_params;
8860 struct rte_cryptodev_info dev_info;
8863 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8864 uint64_t feat_flags = dev_info.feature_flags;
8866 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8869 /* Set action type */
8870 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8871 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8874 if (security_proto_supported(ut_params->type,
8875 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8878 status = test_DOCSIS_PROTO_uplink_all();
8879 status += test_DOCSIS_PROTO_downlink_all();
8884 return TEST_SUCCESS;
8889 test_AES_GCM_authenticated_encryption_test_case_1(void)
8891 return test_authenticated_encryption(&gcm_test_case_1);
8895 test_AES_GCM_authenticated_encryption_test_case_2(void)
8897 return test_authenticated_encryption(&gcm_test_case_2);
8901 test_AES_GCM_authenticated_encryption_test_case_3(void)
8903 return test_authenticated_encryption(&gcm_test_case_3);
8907 test_AES_GCM_authenticated_encryption_test_case_4(void)
8909 return test_authenticated_encryption(&gcm_test_case_4);
8913 test_AES_GCM_authenticated_encryption_test_case_5(void)
8915 return test_authenticated_encryption(&gcm_test_case_5);
8919 test_AES_GCM_authenticated_encryption_test_case_6(void)
8921 return test_authenticated_encryption(&gcm_test_case_6);
8925 test_AES_GCM_authenticated_encryption_test_case_7(void)
8927 return test_authenticated_encryption(&gcm_test_case_7);
8931 test_AES_GCM_authenticated_encryption_test_case_8(void)
8933 return test_authenticated_encryption(&gcm_test_case_8);
8937 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
8939 return test_authenticated_encryption(&gcm_J0_test_case_1);
8943 test_AES_GCM_auth_encryption_test_case_192_1(void)
8945 return test_authenticated_encryption(&gcm_test_case_192_1);
8949 test_AES_GCM_auth_encryption_test_case_192_2(void)
8951 return test_authenticated_encryption(&gcm_test_case_192_2);
8955 test_AES_GCM_auth_encryption_test_case_192_3(void)
8957 return test_authenticated_encryption(&gcm_test_case_192_3);
8961 test_AES_GCM_auth_encryption_test_case_192_4(void)
8963 return test_authenticated_encryption(&gcm_test_case_192_4);
8967 test_AES_GCM_auth_encryption_test_case_192_5(void)
8969 return test_authenticated_encryption(&gcm_test_case_192_5);
8973 test_AES_GCM_auth_encryption_test_case_192_6(void)
8975 return test_authenticated_encryption(&gcm_test_case_192_6);
8979 test_AES_GCM_auth_encryption_test_case_192_7(void)
8981 return test_authenticated_encryption(&gcm_test_case_192_7);
8985 test_AES_GCM_auth_encryption_test_case_256_1(void)
8987 return test_authenticated_encryption(&gcm_test_case_256_1);
8991 test_AES_GCM_auth_encryption_test_case_256_2(void)
8993 return test_authenticated_encryption(&gcm_test_case_256_2);
8997 test_AES_GCM_auth_encryption_test_case_256_3(void)
8999 return test_authenticated_encryption(&gcm_test_case_256_3);
9003 test_AES_GCM_auth_encryption_test_case_256_4(void)
9005 return test_authenticated_encryption(&gcm_test_case_256_4);
9009 test_AES_GCM_auth_encryption_test_case_256_5(void)
9011 return test_authenticated_encryption(&gcm_test_case_256_5);
9015 test_AES_GCM_auth_encryption_test_case_256_6(void)
9017 return test_authenticated_encryption(&gcm_test_case_256_6);
9021 test_AES_GCM_auth_encryption_test_case_256_7(void)
9023 return test_authenticated_encryption(&gcm_test_case_256_7);
9027 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9029 return test_authenticated_encryption(&gcm_test_case_aad_1);
9033 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9035 return test_authenticated_encryption(&gcm_test_case_aad_2);
9039 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9041 struct aead_test_data tdata;
9044 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9045 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9046 tdata.iv.data[0] += 1;
9047 res = test_authenticated_encryption(&tdata);
9048 if (res == -ENOTSUP)
9050 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9051 return TEST_SUCCESS;
9055 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9057 struct aead_test_data tdata;
9060 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9061 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9062 tdata.plaintext.data[0] += 1;
9063 res = test_authenticated_encryption(&tdata);
9064 if (res == -ENOTSUP)
9066 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9067 return TEST_SUCCESS;
9071 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9073 struct aead_test_data tdata;
9076 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9077 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9078 tdata.ciphertext.data[0] += 1;
9079 res = test_authenticated_encryption(&tdata);
9080 if (res == -ENOTSUP)
9082 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9083 return TEST_SUCCESS;
9087 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9089 struct aead_test_data tdata;
9092 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9093 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9095 res = test_authenticated_encryption(&tdata);
9096 if (res == -ENOTSUP)
9098 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9099 return TEST_SUCCESS;
9103 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9105 struct aead_test_data tdata;
9106 uint8_t aad[gcm_test_case_7.aad.len];
9109 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9110 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9111 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9113 tdata.aad.data = aad;
9114 res = test_authenticated_encryption(&tdata);
9115 if (res == -ENOTSUP)
9117 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9118 return TEST_SUCCESS;
9122 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9124 struct aead_test_data tdata;
9127 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9128 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9129 tdata.auth_tag.data[0] += 1;
9130 res = test_authenticated_encryption(&tdata);
9131 if (res == -ENOTSUP)
9133 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9134 return TEST_SUCCESS;
9138 test_authenticated_decryption(const struct aead_test_data *tdata)
9140 struct crypto_testsuite_params *ts_params = &testsuite_params;
9141 struct crypto_unittest_params *ut_params = &unittest_params;
9146 struct rte_cryptodev_info dev_info;
9148 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9149 uint64_t feat_flags = dev_info.feature_flags;
9151 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9152 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9153 printf("Device doesn't support RAW data-path APIs.\n");
9157 /* Verify the capabilities */
9158 struct rte_cryptodev_sym_capability_idx cap_idx;
9159 const struct rte_cryptodev_symmetric_capability *capability;
9160 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9161 cap_idx.algo.aead = tdata->algo;
9162 capability = rte_cryptodev_sym_capability_get(
9163 ts_params->valid_devs[0], &cap_idx);
9164 if (capability == NULL)
9166 if (rte_cryptodev_sym_capability_check_aead(
9167 capability, tdata->key.len, tdata->auth_tag.len,
9168 tdata->aad.len, tdata->iv.len))
9171 /* Create AEAD session */
9172 retval = create_aead_session(ts_params->valid_devs[0],
9174 RTE_CRYPTO_AEAD_OP_DECRYPT,
9175 tdata->key.data, tdata->key.len,
9176 tdata->aad.len, tdata->auth_tag.len,
9181 /* alloc mbuf and set payload */
9182 if (tdata->aad.len > MBUF_SIZE) {
9183 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9184 /* Populate full size of add data */
9185 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9186 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9188 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9190 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9191 rte_pktmbuf_tailroom(ut_params->ibuf));
9193 /* Create AEAD operation */
9194 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9198 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9200 ut_params->op->sym->m_src = ut_params->ibuf;
9202 /* Process crypto operation */
9203 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9204 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9205 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9206 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9207 ut_params->op, 0, 0, 0, 0);
9209 TEST_ASSERT_NOT_NULL(
9210 process_crypto_request(ts_params->valid_devs[0],
9211 ut_params->op), "failed to process sym crypto op");
9213 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9214 "crypto op processing failed");
9216 if (ut_params->op->sym->m_dst)
9217 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9220 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9222 ut_params->op->sym->cipher.data.offset);
9224 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9227 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9229 tdata->plaintext.data,
9230 tdata->plaintext.len,
9231 "Plaintext data not as expected");
9233 TEST_ASSERT_EQUAL(ut_params->op->status,
9234 RTE_CRYPTO_OP_STATUS_SUCCESS,
9235 "Authentication failed");
9241 test_AES_GCM_authenticated_decryption_test_case_1(void)
9243 return test_authenticated_decryption(&gcm_test_case_1);
9247 test_AES_GCM_authenticated_decryption_test_case_2(void)
9249 return test_authenticated_decryption(&gcm_test_case_2);
9253 test_AES_GCM_authenticated_decryption_test_case_3(void)
9255 return test_authenticated_decryption(&gcm_test_case_3);
9259 test_AES_GCM_authenticated_decryption_test_case_4(void)
9261 return test_authenticated_decryption(&gcm_test_case_4);
9265 test_AES_GCM_authenticated_decryption_test_case_5(void)
9267 return test_authenticated_decryption(&gcm_test_case_5);
9271 test_AES_GCM_authenticated_decryption_test_case_6(void)
9273 return test_authenticated_decryption(&gcm_test_case_6);
9277 test_AES_GCM_authenticated_decryption_test_case_7(void)
9279 return test_authenticated_decryption(&gcm_test_case_7);
9283 test_AES_GCM_authenticated_decryption_test_case_8(void)
9285 return test_authenticated_decryption(&gcm_test_case_8);
9289 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9291 return test_authenticated_decryption(&gcm_J0_test_case_1);
9295 test_AES_GCM_auth_decryption_test_case_192_1(void)
9297 return test_authenticated_decryption(&gcm_test_case_192_1);
9301 test_AES_GCM_auth_decryption_test_case_192_2(void)
9303 return test_authenticated_decryption(&gcm_test_case_192_2);
9307 test_AES_GCM_auth_decryption_test_case_192_3(void)
9309 return test_authenticated_decryption(&gcm_test_case_192_3);
9313 test_AES_GCM_auth_decryption_test_case_192_4(void)
9315 return test_authenticated_decryption(&gcm_test_case_192_4);
9319 test_AES_GCM_auth_decryption_test_case_192_5(void)
9321 return test_authenticated_decryption(&gcm_test_case_192_5);
9325 test_AES_GCM_auth_decryption_test_case_192_6(void)
9327 return test_authenticated_decryption(&gcm_test_case_192_6);
9331 test_AES_GCM_auth_decryption_test_case_192_7(void)
9333 return test_authenticated_decryption(&gcm_test_case_192_7);
9337 test_AES_GCM_auth_decryption_test_case_256_1(void)
9339 return test_authenticated_decryption(&gcm_test_case_256_1);
9343 test_AES_GCM_auth_decryption_test_case_256_2(void)
9345 return test_authenticated_decryption(&gcm_test_case_256_2);
9349 test_AES_GCM_auth_decryption_test_case_256_3(void)
9351 return test_authenticated_decryption(&gcm_test_case_256_3);
9355 test_AES_GCM_auth_decryption_test_case_256_4(void)
9357 return test_authenticated_decryption(&gcm_test_case_256_4);
9361 test_AES_GCM_auth_decryption_test_case_256_5(void)
9363 return test_authenticated_decryption(&gcm_test_case_256_5);
9367 test_AES_GCM_auth_decryption_test_case_256_6(void)
9369 return test_authenticated_decryption(&gcm_test_case_256_6);
9373 test_AES_GCM_auth_decryption_test_case_256_7(void)
9375 return test_authenticated_decryption(&gcm_test_case_256_7);
9379 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9381 return test_authenticated_decryption(&gcm_test_case_aad_1);
9385 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9387 return test_authenticated_decryption(&gcm_test_case_aad_2);
9391 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9393 struct aead_test_data tdata;
9396 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9397 tdata.iv.data[0] += 1;
9398 res = test_authenticated_decryption(&tdata);
9399 if (res == -ENOTSUP)
9401 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9402 return TEST_SUCCESS;
9406 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9408 struct aead_test_data tdata;
9411 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9412 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9413 tdata.plaintext.data[0] += 1;
9414 res = test_authenticated_decryption(&tdata);
9415 if (res == -ENOTSUP)
9417 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9418 return TEST_SUCCESS;
9422 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9424 struct aead_test_data tdata;
9427 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9428 tdata.ciphertext.data[0] += 1;
9429 res = test_authenticated_decryption(&tdata);
9430 if (res == -ENOTSUP)
9432 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9433 return TEST_SUCCESS;
9437 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9439 struct aead_test_data tdata;
9442 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9444 res = test_authenticated_decryption(&tdata);
9445 if (res == -ENOTSUP)
9447 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9448 return TEST_SUCCESS;
9452 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9454 struct aead_test_data tdata;
9455 uint8_t aad[gcm_test_case_7.aad.len];
9458 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9459 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9461 tdata.aad.data = aad;
9462 res = test_authenticated_decryption(&tdata);
9463 if (res == -ENOTSUP)
9465 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9466 return TEST_SUCCESS;
9470 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9472 struct aead_test_data tdata;
9475 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9476 tdata.auth_tag.data[0] += 1;
9477 res = test_authenticated_decryption(&tdata);
9478 if (res == -ENOTSUP)
9480 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9481 return TEST_SUCCESS;
9485 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9487 struct crypto_testsuite_params *ts_params = &testsuite_params;
9488 struct crypto_unittest_params *ut_params = &unittest_params;
9491 uint8_t *ciphertext, *auth_tag;
9492 uint16_t plaintext_pad_len;
9494 /* Verify the capabilities */
9495 struct rte_cryptodev_sym_capability_idx cap_idx;
9496 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9497 cap_idx.algo.aead = tdata->algo;
9498 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9502 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9505 /* not supported with CPU crypto */
9506 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9509 /* Create AEAD session */
9510 retval = create_aead_session(ts_params->valid_devs[0],
9512 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9513 tdata->key.data, tdata->key.len,
9514 tdata->aad.len, tdata->auth_tag.len,
9519 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9520 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9522 /* clear mbuf payload */
9523 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9524 rte_pktmbuf_tailroom(ut_params->ibuf));
9525 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9526 rte_pktmbuf_tailroom(ut_params->obuf));
9528 /* Create AEAD operation */
9529 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9533 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9535 ut_params->op->sym->m_src = ut_params->ibuf;
9536 ut_params->op->sym->m_dst = ut_params->obuf;
9538 /* Process crypto operation */
9539 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9540 ut_params->op), "failed to process sym crypto op");
9542 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9543 "crypto op processing failed");
9545 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9547 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9548 ut_params->op->sym->cipher.data.offset);
9549 auth_tag = ciphertext + plaintext_pad_len;
9551 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9552 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9555 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9557 tdata->ciphertext.data,
9558 tdata->ciphertext.len,
9559 "Ciphertext data not as expected");
9561 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9563 tdata->auth_tag.data,
9564 tdata->auth_tag.len,
9565 "Generated auth tag not as expected");
9572 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9574 return test_authenticated_encryption_oop(&gcm_test_case_5);
9578 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9580 struct crypto_testsuite_params *ts_params = &testsuite_params;
9581 struct crypto_unittest_params *ut_params = &unittest_params;
9586 /* Verify the capabilities */
9587 struct rte_cryptodev_sym_capability_idx cap_idx;
9588 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9589 cap_idx.algo.aead = tdata->algo;
9590 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9594 /* not supported with CPU crypto and raw data-path APIs*/
9595 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
9596 global_api_test_type == CRYPTODEV_RAW_API_TEST)
9599 /* Create AEAD session */
9600 retval = create_aead_session(ts_params->valid_devs[0],
9602 RTE_CRYPTO_AEAD_OP_DECRYPT,
9603 tdata->key.data, tdata->key.len,
9604 tdata->aad.len, tdata->auth_tag.len,
9609 /* alloc mbuf and set payload */
9610 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9611 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9613 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9614 rte_pktmbuf_tailroom(ut_params->ibuf));
9615 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9616 rte_pktmbuf_tailroom(ut_params->obuf));
9618 /* Create AEAD operation */
9619 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9623 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9625 ut_params->op->sym->m_src = ut_params->ibuf;
9626 ut_params->op->sym->m_dst = ut_params->obuf;
9628 /* Process crypto operation */
9629 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9630 ut_params->op), "failed to process sym crypto op");
9632 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9633 "crypto op processing failed");
9635 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9636 ut_params->op->sym->cipher.data.offset);
9638 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9641 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9643 tdata->plaintext.data,
9644 tdata->plaintext.len,
9645 "Plaintext data not as expected");
9647 TEST_ASSERT_EQUAL(ut_params->op->status,
9648 RTE_CRYPTO_OP_STATUS_SUCCESS,
9649 "Authentication failed");
9654 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9656 return test_authenticated_decryption_oop(&gcm_test_case_5);
9660 test_authenticated_encryption_sessionless(
9661 const struct aead_test_data *tdata)
9663 struct crypto_testsuite_params *ts_params = &testsuite_params;
9664 struct crypto_unittest_params *ut_params = &unittest_params;
9667 uint8_t *ciphertext, *auth_tag;
9668 uint16_t plaintext_pad_len;
9669 uint8_t key[tdata->key.len + 1];
9670 struct rte_cryptodev_info dev_info;
9672 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9673 uint64_t feat_flags = dev_info.feature_flags;
9675 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9676 printf("Device doesn't support Sessionless ops.\n");
9680 /* not supported with CPU crypto */
9681 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9684 /* Verify the capabilities */
9685 struct rte_cryptodev_sym_capability_idx cap_idx;
9686 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9687 cap_idx.algo.aead = tdata->algo;
9688 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9692 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9694 /* clear mbuf payload */
9695 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9696 rte_pktmbuf_tailroom(ut_params->ibuf));
9698 /* Create AEAD operation */
9699 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9703 /* Create GCM xform */
9704 memcpy(key, tdata->key.data, tdata->key.len);
9705 retval = create_aead_xform(ut_params->op,
9707 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9708 key, tdata->key.len,
9709 tdata->aad.len, tdata->auth_tag.len,
9714 ut_params->op->sym->m_src = ut_params->ibuf;
9716 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9717 RTE_CRYPTO_OP_SESSIONLESS,
9718 "crypto op session type not sessionless");
9720 /* Process crypto operation */
9721 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9722 ut_params->op), "failed to process sym crypto op");
9724 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9726 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9727 "crypto op status not success");
9729 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9731 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9732 ut_params->op->sym->cipher.data.offset);
9733 auth_tag = ciphertext + plaintext_pad_len;
9735 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9736 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9739 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9741 tdata->ciphertext.data,
9742 tdata->ciphertext.len,
9743 "Ciphertext data not as expected");
9745 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9747 tdata->auth_tag.data,
9748 tdata->auth_tag.len,
9749 "Generated auth tag not as expected");
9756 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9758 return test_authenticated_encryption_sessionless(
9763 test_authenticated_decryption_sessionless(
9764 const struct aead_test_data *tdata)
9766 struct crypto_testsuite_params *ts_params = &testsuite_params;
9767 struct crypto_unittest_params *ut_params = &unittest_params;
9771 uint8_t key[tdata->key.len + 1];
9772 struct rte_cryptodev_info dev_info;
9774 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9775 uint64_t feat_flags = dev_info.feature_flags;
9777 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9778 printf("Device doesn't support Sessionless ops.\n");
9782 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9783 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9784 printf("Device doesn't support RAW data-path APIs.\n");
9788 /* not supported with CPU crypto */
9789 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9792 /* Verify the capabilities */
9793 struct rte_cryptodev_sym_capability_idx cap_idx;
9794 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9795 cap_idx.algo.aead = tdata->algo;
9796 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9800 /* alloc mbuf and set payload */
9801 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9803 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9804 rte_pktmbuf_tailroom(ut_params->ibuf));
9806 /* Create AEAD operation */
9807 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9811 /* Create AEAD xform */
9812 memcpy(key, tdata->key.data, tdata->key.len);
9813 retval = create_aead_xform(ut_params->op,
9815 RTE_CRYPTO_AEAD_OP_DECRYPT,
9816 key, tdata->key.len,
9817 tdata->aad.len, tdata->auth_tag.len,
9822 ut_params->op->sym->m_src = ut_params->ibuf;
9824 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9825 RTE_CRYPTO_OP_SESSIONLESS,
9826 "crypto op session type not sessionless");
9828 /* Process crypto operation */
9829 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9830 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9831 ut_params->op, 0, 0, 0, 0);
9833 TEST_ASSERT_NOT_NULL(process_crypto_request(
9834 ts_params->valid_devs[0], ut_params->op),
9835 "failed to process sym crypto op");
9837 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9839 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9840 "crypto op status not success");
9842 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9843 ut_params->op->sym->cipher.data.offset);
9845 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9848 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9850 tdata->plaintext.data,
9851 tdata->plaintext.len,
9852 "Plaintext data not as expected");
9854 TEST_ASSERT_EQUAL(ut_params->op->status,
9855 RTE_CRYPTO_OP_STATUS_SUCCESS,
9856 "Authentication failed");
9861 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9863 return test_authenticated_decryption_sessionless(
9868 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9870 return test_authenticated_encryption(&ccm_test_case_128_1);
9874 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9876 return test_authenticated_encryption(&ccm_test_case_128_2);
9880 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9882 return test_authenticated_encryption(&ccm_test_case_128_3);
9886 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9888 return test_authenticated_decryption(&ccm_test_case_128_1);
9892 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9894 return test_authenticated_decryption(&ccm_test_case_128_2);
9898 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9900 return test_authenticated_decryption(&ccm_test_case_128_3);
9904 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9906 return test_authenticated_encryption(&ccm_test_case_192_1);
9910 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9912 return test_authenticated_encryption(&ccm_test_case_192_2);
9916 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9918 return test_authenticated_encryption(&ccm_test_case_192_3);
9922 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9924 return test_authenticated_decryption(&ccm_test_case_192_1);
9928 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9930 return test_authenticated_decryption(&ccm_test_case_192_2);
9934 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9936 return test_authenticated_decryption(&ccm_test_case_192_3);
9940 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9942 return test_authenticated_encryption(&ccm_test_case_256_1);
9946 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9948 return test_authenticated_encryption(&ccm_test_case_256_2);
9952 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9954 return test_authenticated_encryption(&ccm_test_case_256_3);
9958 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9960 return test_authenticated_decryption(&ccm_test_case_256_1);
9964 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9966 return test_authenticated_decryption(&ccm_test_case_256_2);
9970 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9972 return test_authenticated_decryption(&ccm_test_case_256_3);
9978 struct crypto_testsuite_params *ts_params = &testsuite_params;
9979 struct rte_cryptodev_stats stats;
9981 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9984 /* Verify the capabilities */
9985 struct rte_cryptodev_sym_capability_idx cap_idx;
9986 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9987 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
9988 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9991 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9992 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9993 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9997 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10001 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10002 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10003 &stats) == -ENODEV),
10004 "rte_cryptodev_stats_get invalid dev failed");
10005 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10006 "rte_cryptodev_stats_get invalid Param failed");
10008 /* Test expected values */
10009 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10010 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10012 "rte_cryptodev_stats_get failed");
10013 TEST_ASSERT((stats.enqueued_count == 1),
10014 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10015 TEST_ASSERT((stats.dequeued_count == 1),
10016 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10017 TEST_ASSERT((stats.enqueue_err_count == 0),
10018 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10019 TEST_ASSERT((stats.dequeue_err_count == 0),
10020 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10022 /* invalid device but should ignore and not reset device stats*/
10023 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10024 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10026 "rte_cryptodev_stats_get failed");
10027 TEST_ASSERT((stats.enqueued_count == 1),
10028 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10030 /* check that a valid reset clears stats */
10031 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10032 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10034 "rte_cryptodev_stats_get failed");
10035 TEST_ASSERT((stats.enqueued_count == 0),
10036 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10037 TEST_ASSERT((stats.dequeued_count == 0),
10038 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10040 return TEST_SUCCESS;
10043 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10044 struct crypto_unittest_params *ut_params,
10045 enum rte_crypto_auth_operation op,
10046 const struct HMAC_MD5_vector *test_case)
10050 memcpy(key, test_case->key.data, test_case->key.len);
10052 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10053 ut_params->auth_xform.next = NULL;
10054 ut_params->auth_xform.auth.op = op;
10056 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10058 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10059 ut_params->auth_xform.auth.key.length = test_case->key.len;
10060 ut_params->auth_xform.auth.key.data = key;
10062 ut_params->sess = rte_cryptodev_sym_session_create(
10063 ts_params->session_mpool);
10065 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10066 ut_params->sess, &ut_params->auth_xform,
10067 ts_params->session_priv_mpool);
10069 if (ut_params->sess == NULL)
10070 return TEST_FAILED;
10072 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10074 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10075 rte_pktmbuf_tailroom(ut_params->ibuf));
10080 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10081 const struct HMAC_MD5_vector *test_case,
10082 uint8_t **plaintext)
10084 uint16_t plaintext_pad_len;
10086 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10088 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10091 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10092 plaintext_pad_len);
10093 memcpy(*plaintext, test_case->plaintext.data,
10094 test_case->plaintext.len);
10096 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10097 ut_params->ibuf, MD5_DIGEST_LEN);
10098 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10099 "no room to append digest");
10100 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10101 ut_params->ibuf, plaintext_pad_len);
10103 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10104 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10105 test_case->auth_tag.len);
10108 sym_op->auth.data.offset = 0;
10109 sym_op->auth.data.length = test_case->plaintext.len;
10111 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10112 ut_params->op->sym->m_src = ut_params->ibuf;
10118 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10120 uint16_t plaintext_pad_len;
10121 uint8_t *plaintext, *auth_tag;
10123 struct crypto_testsuite_params *ts_params = &testsuite_params;
10124 struct crypto_unittest_params *ut_params = &unittest_params;
10125 struct rte_cryptodev_info dev_info;
10127 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10128 uint64_t feat_flags = dev_info.feature_flags;
10130 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10131 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10132 printf("Device doesn't support RAW data-path APIs.\n");
10136 /* Verify the capabilities */
10137 struct rte_cryptodev_sym_capability_idx cap_idx;
10138 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10139 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10140 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10144 if (MD5_HMAC_create_session(ts_params, ut_params,
10145 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10146 return TEST_FAILED;
10148 /* Generate Crypto op data structure */
10149 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10150 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10151 TEST_ASSERT_NOT_NULL(ut_params->op,
10152 "Failed to allocate symmetric crypto operation struct");
10154 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10157 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10158 return TEST_FAILED;
10160 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10161 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10163 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10164 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10165 ut_params->op, 0, 1, 0, 0);
10167 TEST_ASSERT_NOT_NULL(
10168 process_crypto_request(ts_params->valid_devs[0],
10170 "failed to process sym crypto op");
10172 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10173 "crypto op processing failed");
10175 if (ut_params->op->sym->m_dst) {
10176 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10177 uint8_t *, plaintext_pad_len);
10179 auth_tag = plaintext + plaintext_pad_len;
10182 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10184 test_case->auth_tag.data,
10185 test_case->auth_tag.len,
10186 "HMAC_MD5 generated tag not as expected");
10188 return TEST_SUCCESS;
10192 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10194 uint8_t *plaintext;
10196 struct crypto_testsuite_params *ts_params = &testsuite_params;
10197 struct crypto_unittest_params *ut_params = &unittest_params;
10198 struct rte_cryptodev_info dev_info;
10200 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10201 uint64_t feat_flags = dev_info.feature_flags;
10203 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10204 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10205 printf("Device doesn't support RAW data-path APIs.\n");
10209 /* Verify the capabilities */
10210 struct rte_cryptodev_sym_capability_idx cap_idx;
10211 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10212 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10213 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10217 if (MD5_HMAC_create_session(ts_params, ut_params,
10218 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10219 return TEST_FAILED;
10222 /* Generate Crypto op data structure */
10223 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10224 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10225 TEST_ASSERT_NOT_NULL(ut_params->op,
10226 "Failed to allocate symmetric crypto operation struct");
10228 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10229 return TEST_FAILED;
10231 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10232 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10234 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10235 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10236 ut_params->op, 0, 1, 0, 0);
10238 TEST_ASSERT_NOT_NULL(
10239 process_crypto_request(ts_params->valid_devs[0],
10241 "failed to process sym crypto op");
10243 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10244 "HMAC_MD5 crypto op processing failed");
10246 return TEST_SUCCESS;
10250 test_MD5_HMAC_generate_case_1(void)
10252 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10256 test_MD5_HMAC_verify_case_1(void)
10258 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10262 test_MD5_HMAC_generate_case_2(void)
10264 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10268 test_MD5_HMAC_verify_case_2(void)
10270 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10274 test_multi_session(void)
10276 struct crypto_testsuite_params *ts_params = &testsuite_params;
10277 struct crypto_unittest_params *ut_params = &unittest_params;
10279 struct rte_cryptodev_info dev_info;
10280 struct rte_cryptodev_sym_session **sessions;
10284 /* Verify the capabilities */
10285 struct rte_cryptodev_sym_capability_idx cap_idx;
10286 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10287 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10288 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10291 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10292 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10293 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10297 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10298 aes_cbc_key, hmac_sha512_key);
10301 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10303 sessions = rte_malloc(NULL,
10304 (sizeof(struct rte_cryptodev_sym_session *) *
10305 MAX_NB_SESSIONS) + 1, 0);
10307 /* Create multiple crypto sessions*/
10308 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10310 sessions[i] = rte_cryptodev_sym_session_create(
10311 ts_params->session_mpool);
10313 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10314 sessions[i], &ut_params->auth_xform,
10315 ts_params->session_priv_mpool);
10316 TEST_ASSERT_NOT_NULL(sessions[i],
10317 "Session creation failed at session number %u",
10320 /* Attempt to send a request on each session */
10321 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10325 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10326 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10328 "Failed to perform decrypt on request number %u.", i);
10329 /* free crypto operation structure */
10331 rte_crypto_op_free(ut_params->op);
10334 * free mbuf - both obuf and ibuf are usually the same,
10335 * so check if they point at the same address is necessary,
10336 * to avoid freeing the mbuf twice.
10338 if (ut_params->obuf) {
10339 rte_pktmbuf_free(ut_params->obuf);
10340 if (ut_params->ibuf == ut_params->obuf)
10341 ut_params->ibuf = 0;
10342 ut_params->obuf = 0;
10344 if (ut_params->ibuf) {
10345 rte_pktmbuf_free(ut_params->ibuf);
10346 ut_params->ibuf = 0;
10350 /* Next session create should fail */
10351 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10352 sessions[i], &ut_params->auth_xform,
10353 ts_params->session_priv_mpool);
10354 TEST_ASSERT_NULL(sessions[i],
10355 "Session creation succeeded unexpectedly!");
10357 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10358 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10360 rte_cryptodev_sym_session_free(sessions[i]);
10363 rte_free(sessions);
10365 return TEST_SUCCESS;
10368 struct multi_session_params {
10369 struct crypto_unittest_params ut_params;
10370 uint8_t *cipher_key;
10372 const uint8_t *cipher;
10373 const uint8_t *digest;
10377 #define MB_SESSION_NUMBER 3
10380 test_multi_session_random_usage(void)
10382 struct crypto_testsuite_params *ts_params = &testsuite_params;
10383 struct rte_cryptodev_info dev_info;
10384 struct rte_cryptodev_sym_session **sessions;
10386 struct multi_session_params ut_paramz[] = {
10389 .cipher_key = ms_aes_cbc_key0,
10390 .hmac_key = ms_hmac_key0,
10391 .cipher = ms_aes_cbc_cipher0,
10392 .digest = ms_hmac_digest0,
10393 .iv = ms_aes_cbc_iv0
10396 .cipher_key = ms_aes_cbc_key1,
10397 .hmac_key = ms_hmac_key1,
10398 .cipher = ms_aes_cbc_cipher1,
10399 .digest = ms_hmac_digest1,
10400 .iv = ms_aes_cbc_iv1
10403 .cipher_key = ms_aes_cbc_key2,
10404 .hmac_key = ms_hmac_key2,
10405 .cipher = ms_aes_cbc_cipher2,
10406 .digest = ms_hmac_digest2,
10407 .iv = ms_aes_cbc_iv2
10412 /* Verify the capabilities */
10413 struct rte_cryptodev_sym_capability_idx cap_idx;
10414 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10415 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10416 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10419 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10420 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10421 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10425 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10427 sessions = rte_malloc(NULL,
10428 (sizeof(struct rte_cryptodev_sym_session *)
10429 * MAX_NB_SESSIONS) + 1, 0);
10431 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10432 sessions[i] = rte_cryptodev_sym_session_create(
10433 ts_params->session_mpool);
10435 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10436 sizeof(struct crypto_unittest_params));
10438 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10439 &ut_paramz[i].ut_params,
10440 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10442 /* Create multiple crypto sessions*/
10443 rte_cryptodev_sym_session_init(
10444 ts_params->valid_devs[0],
10446 &ut_paramz[i].ut_params.auth_xform,
10447 ts_params->session_priv_mpool);
10449 TEST_ASSERT_NOT_NULL(sessions[i],
10450 "Session creation failed at session number %u",
10456 for (i = 0; i < 40000; i++) {
10458 j = rand() % MB_SESSION_NUMBER;
10460 TEST_ASSERT_SUCCESS(
10461 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10463 &ut_paramz[j].ut_params,
10464 ts_params, ut_paramz[j].cipher,
10465 ut_paramz[j].digest,
10467 "Failed to perform decrypt on request number %u.", i);
10469 if (ut_paramz[j].ut_params.op)
10470 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10473 * free mbuf - both obuf and ibuf are usually the same,
10474 * so check if they point at the same address is necessary,
10475 * to avoid freeing the mbuf twice.
10477 if (ut_paramz[j].ut_params.obuf) {
10478 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10479 if (ut_paramz[j].ut_params.ibuf
10480 == ut_paramz[j].ut_params.obuf)
10481 ut_paramz[j].ut_params.ibuf = 0;
10482 ut_paramz[j].ut_params.obuf = 0;
10484 if (ut_paramz[j].ut_params.ibuf) {
10485 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10486 ut_paramz[j].ut_params.ibuf = 0;
10490 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10491 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10493 rte_cryptodev_sym_session_free(sessions[i]);
10496 rte_free(sessions);
10498 return TEST_SUCCESS;
10501 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10502 0xab, 0xab, 0xab, 0xab,
10503 0xab, 0xab, 0xab, 0xab,
10504 0xab, 0xab, 0xab, 0xab};
10507 test_null_invalid_operation(void)
10509 struct crypto_testsuite_params *ts_params = &testsuite_params;
10510 struct crypto_unittest_params *ut_params = &unittest_params;
10513 /* This test is for NULL PMD only */
10514 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10515 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10518 /* Setup Cipher Parameters */
10519 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10520 ut_params->cipher_xform.next = NULL;
10522 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10523 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10525 ut_params->sess = rte_cryptodev_sym_session_create(
10526 ts_params->session_mpool);
10528 /* Create Crypto session*/
10529 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10530 ut_params->sess, &ut_params->cipher_xform,
10531 ts_params->session_priv_mpool);
10532 TEST_ASSERT(ret < 0,
10533 "Session creation succeeded unexpectedly");
10536 /* Setup HMAC Parameters */
10537 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10538 ut_params->auth_xform.next = NULL;
10540 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10541 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10543 ut_params->sess = rte_cryptodev_sym_session_create(
10544 ts_params->session_mpool);
10546 /* Create Crypto session*/
10547 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10548 ut_params->sess, &ut_params->auth_xform,
10549 ts_params->session_priv_mpool);
10550 TEST_ASSERT(ret < 0,
10551 "Session creation succeeded unexpectedly");
10553 return TEST_SUCCESS;
10557 #define NULL_BURST_LENGTH (32)
10560 test_null_burst_operation(void)
10562 struct crypto_testsuite_params *ts_params = &testsuite_params;
10563 struct crypto_unittest_params *ut_params = &unittest_params;
10565 unsigned i, burst_len = NULL_BURST_LENGTH;
10567 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10568 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10570 /* This test is for NULL PMD only */
10571 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10572 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10575 /* Setup Cipher Parameters */
10576 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10577 ut_params->cipher_xform.next = &ut_params->auth_xform;
10579 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10580 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10582 /* Setup HMAC Parameters */
10583 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10584 ut_params->auth_xform.next = NULL;
10586 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10587 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10589 ut_params->sess = rte_cryptodev_sym_session_create(
10590 ts_params->session_mpool);
10592 /* Create Crypto session*/
10593 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10594 ut_params->sess, &ut_params->cipher_xform,
10595 ts_params->session_priv_mpool);
10596 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10598 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10599 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10600 burst_len, "failed to generate burst of crypto ops");
10602 /* Generate an operation for each mbuf in burst */
10603 for (i = 0; i < burst_len; i++) {
10604 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10606 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10608 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10612 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10614 burst[i]->sym->m_src = m;
10617 /* Process crypto operation */
10618 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10619 0, burst, burst_len),
10621 "Error enqueuing burst");
10623 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10624 0, burst_dequeued, burst_len),
10626 "Error dequeuing burst");
10629 for (i = 0; i < burst_len; i++) {
10631 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10632 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10634 "data not as expected");
10636 rte_pktmbuf_free(burst[i]->sym->m_src);
10637 rte_crypto_op_free(burst[i]);
10640 return TEST_SUCCESS;
10644 generate_gmac_large_plaintext(uint8_t *data)
10648 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10649 memcpy(&data[i], &data[0], 32);
10653 create_gmac_operation(enum rte_crypto_auth_operation op,
10654 const struct gmac_test_data *tdata)
10656 struct crypto_testsuite_params *ts_params = &testsuite_params;
10657 struct crypto_unittest_params *ut_params = &unittest_params;
10658 struct rte_crypto_sym_op *sym_op;
10660 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10662 /* Generate Crypto op data structure */
10663 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10664 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10665 TEST_ASSERT_NOT_NULL(ut_params->op,
10666 "Failed to allocate symmetric crypto operation struct");
10668 sym_op = ut_params->op->sym;
10670 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10671 ut_params->ibuf, tdata->gmac_tag.len);
10672 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10673 "no room to append digest");
10675 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10676 ut_params->ibuf, plaintext_pad_len);
10678 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10679 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10680 tdata->gmac_tag.len);
10681 debug_hexdump(stdout, "digest:",
10682 sym_op->auth.digest.data,
10683 tdata->gmac_tag.len);
10686 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10687 uint8_t *, IV_OFFSET);
10689 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10691 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10693 sym_op->cipher.data.length = 0;
10694 sym_op->cipher.data.offset = 0;
10696 sym_op->auth.data.offset = 0;
10697 sym_op->auth.data.length = tdata->plaintext.len;
10703 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
10704 const struct gmac_test_data *tdata,
10705 void *digest_mem, uint64_t digest_phys)
10707 struct crypto_testsuite_params *ts_params = &testsuite_params;
10708 struct crypto_unittest_params *ut_params = &unittest_params;
10709 struct rte_crypto_sym_op *sym_op;
10711 /* Generate Crypto op data structure */
10712 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10713 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10714 TEST_ASSERT_NOT_NULL(ut_params->op,
10715 "Failed to allocate symmetric crypto operation struct");
10717 sym_op = ut_params->op->sym;
10719 sym_op->auth.digest.data = digest_mem;
10720 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10721 "no room to append digest");
10723 sym_op->auth.digest.phys_addr = digest_phys;
10725 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10726 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10727 tdata->gmac_tag.len);
10728 debug_hexdump(stdout, "digest:",
10729 sym_op->auth.digest.data,
10730 tdata->gmac_tag.len);
10733 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10734 uint8_t *, IV_OFFSET);
10736 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10738 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10740 sym_op->cipher.data.length = 0;
10741 sym_op->cipher.data.offset = 0;
10743 sym_op->auth.data.offset = 0;
10744 sym_op->auth.data.length = tdata->plaintext.len;
10749 static int create_gmac_session(uint8_t dev_id,
10750 const struct gmac_test_data *tdata,
10751 enum rte_crypto_auth_operation auth_op)
10753 uint8_t auth_key[tdata->key.len];
10755 struct crypto_testsuite_params *ts_params = &testsuite_params;
10756 struct crypto_unittest_params *ut_params = &unittest_params;
10758 memcpy(auth_key, tdata->key.data, tdata->key.len);
10760 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10761 ut_params->auth_xform.next = NULL;
10763 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10764 ut_params->auth_xform.auth.op = auth_op;
10765 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10766 ut_params->auth_xform.auth.key.length = tdata->key.len;
10767 ut_params->auth_xform.auth.key.data = auth_key;
10768 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10769 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10772 ut_params->sess = rte_cryptodev_sym_session_create(
10773 ts_params->session_mpool);
10775 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10776 &ut_params->auth_xform,
10777 ts_params->session_priv_mpool);
10779 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10785 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10787 struct crypto_testsuite_params *ts_params = &testsuite_params;
10788 struct crypto_unittest_params *ut_params = &unittest_params;
10789 struct rte_cryptodev_info dev_info;
10791 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10792 uint64_t feat_flags = dev_info.feature_flags;
10794 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10795 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10796 printf("Device doesn't support RAW data-path APIs.\n");
10802 uint8_t *auth_tag, *plaintext;
10803 uint16_t plaintext_pad_len;
10805 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10806 "No GMAC length in the source data");
10808 /* Verify the capabilities */
10809 struct rte_cryptodev_sym_capability_idx cap_idx;
10810 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10811 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10812 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10816 retval = create_gmac_session(ts_params->valid_devs[0],
10817 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10822 if (tdata->plaintext.len > MBUF_SIZE)
10823 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10825 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10826 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10827 "Failed to allocate input buffer in mempool");
10829 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10830 rte_pktmbuf_tailroom(ut_params->ibuf));
10832 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10834 * Runtime generate the large plain text instead of use hard code
10835 * plain text vector. It is done to avoid create huge source file
10836 * with the test vector.
10838 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10839 generate_gmac_large_plaintext(tdata->plaintext.data);
10841 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10842 plaintext_pad_len);
10843 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10845 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10846 debug_hexdump(stdout, "plaintext:", plaintext,
10847 tdata->plaintext.len);
10849 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10855 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10857 ut_params->op->sym->m_src = ut_params->ibuf;
10859 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10860 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10862 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10863 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10864 ut_params->op, 0, 1, 0, 0);
10866 TEST_ASSERT_NOT_NULL(
10867 process_crypto_request(ts_params->valid_devs[0],
10868 ut_params->op), "failed to process sym crypto op");
10870 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10871 "crypto op processing failed");
10873 if (ut_params->op->sym->m_dst) {
10874 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10875 uint8_t *, plaintext_pad_len);
10877 auth_tag = plaintext + plaintext_pad_len;
10880 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10882 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10884 tdata->gmac_tag.data,
10885 tdata->gmac_tag.len,
10886 "GMAC Generated auth tag not as expected");
10892 test_AES_GMAC_authentication_test_case_1(void)
10894 return test_AES_GMAC_authentication(&gmac_test_case_1);
10898 test_AES_GMAC_authentication_test_case_2(void)
10900 return test_AES_GMAC_authentication(&gmac_test_case_2);
10904 test_AES_GMAC_authentication_test_case_3(void)
10906 return test_AES_GMAC_authentication(&gmac_test_case_3);
10910 test_AES_GMAC_authentication_test_case_4(void)
10912 return test_AES_GMAC_authentication(&gmac_test_case_4);
10916 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10918 struct crypto_testsuite_params *ts_params = &testsuite_params;
10919 struct crypto_unittest_params *ut_params = &unittest_params;
10921 uint32_t plaintext_pad_len;
10922 uint8_t *plaintext;
10923 struct rte_cryptodev_info dev_info;
10925 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10926 uint64_t feat_flags = dev_info.feature_flags;
10928 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10929 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10930 printf("Device doesn't support RAW data-path APIs.\n");
10934 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10935 "No GMAC length in the source data");
10937 /* Verify the capabilities */
10938 struct rte_cryptodev_sym_capability_idx cap_idx;
10939 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10940 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10941 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10945 retval = create_gmac_session(ts_params->valid_devs[0],
10946 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10951 if (tdata->plaintext.len > MBUF_SIZE)
10952 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10954 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10955 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10956 "Failed to allocate input buffer in mempool");
10958 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10959 rte_pktmbuf_tailroom(ut_params->ibuf));
10961 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10964 * Runtime generate the large plain text instead of use hard code
10965 * plain text vector. It is done to avoid create huge source file
10966 * with the test vector.
10968 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10969 generate_gmac_large_plaintext(tdata->plaintext.data);
10971 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10972 plaintext_pad_len);
10973 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10975 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10976 debug_hexdump(stdout, "plaintext:", plaintext,
10977 tdata->plaintext.len);
10979 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10985 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10987 ut_params->op->sym->m_src = ut_params->ibuf;
10989 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10990 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10992 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10993 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10994 ut_params->op, 0, 1, 0, 0);
10996 TEST_ASSERT_NOT_NULL(
10997 process_crypto_request(ts_params->valid_devs[0],
10998 ut_params->op), "failed to process sym crypto op");
11000 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11001 "crypto op processing failed");
11008 test_AES_GMAC_authentication_verify_test_case_1(void)
11010 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11014 test_AES_GMAC_authentication_verify_test_case_2(void)
11016 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11020 test_AES_GMAC_authentication_verify_test_case_3(void)
11022 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11026 test_AES_GMAC_authentication_verify_test_case_4(void)
11028 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11032 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11035 struct crypto_testsuite_params *ts_params = &testsuite_params;
11036 struct crypto_unittest_params *ut_params = &unittest_params;
11037 struct rte_cryptodev_info dev_info;
11038 uint64_t feature_flags;
11039 unsigned int trn_data = 0;
11040 void *digest_mem = NULL;
11042 unsigned int to_trn = 0;
11043 struct rte_mbuf *buf = NULL;
11044 uint8_t *auth_tag, *plaintext;
11047 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11048 "No GMAC length in the source data");
11050 /* Verify the capabilities */
11051 struct rte_cryptodev_sym_capability_idx cap_idx;
11052 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11053 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11054 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11058 /* Check for any input SGL support */
11059 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11060 feature_flags = dev_info.feature_flags;
11062 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) &&
11063 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) &&
11064 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11067 if (fragsz > tdata->plaintext.len)
11068 fragsz = tdata->plaintext.len;
11070 uint16_t plaintext_len = fragsz;
11072 retval = create_gmac_session(ts_params->valid_devs[0],
11073 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11078 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11079 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11080 "Failed to allocate input buffer in mempool");
11082 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11083 rte_pktmbuf_tailroom(ut_params->ibuf));
11085 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11087 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11089 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11091 trn_data += plaintext_len;
11093 buf = ut_params->ibuf;
11096 * Loop until no more fragments
11099 while (trn_data < tdata->plaintext.len) {
11101 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11102 (tdata->plaintext.len - trn_data) : fragsz;
11104 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11107 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11108 rte_pktmbuf_tailroom(buf));
11110 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11113 memcpy(plaintext, tdata->plaintext.data + trn_data,
11115 trn_data += to_trn;
11116 if (trn_data == tdata->plaintext.len)
11117 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11118 tdata->gmac_tag.len);
11120 ut_params->ibuf->nb_segs = segs;
11123 * Place digest at the end of the last buffer
11125 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11128 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11129 + tdata->gmac_tag.len);
11130 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11131 tdata->plaintext.len);
11134 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11135 tdata, digest_mem, digest_phys);
11140 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11142 ut_params->op->sym->m_src = ut_params->ibuf;
11144 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11147 TEST_ASSERT_NOT_NULL(
11148 process_crypto_request(ts_params->valid_devs[0],
11149 ut_params->op), "failed to process sym crypto op");
11151 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11152 "crypto op processing failed");
11154 auth_tag = digest_mem;
11155 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11156 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11158 tdata->gmac_tag.data,
11159 tdata->gmac_tag.len,
11160 "GMAC Generated auth tag not as expected");
11165 /* Segment size not multiple of block size (16B) */
11167 test_AES_GMAC_authentication_SGL_40B(void)
11169 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11173 test_AES_GMAC_authentication_SGL_80B(void)
11175 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11179 test_AES_GMAC_authentication_SGL_2048B(void)
11181 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11184 /* Segment size not multiple of block size (16B) */
11186 test_AES_GMAC_authentication_SGL_2047B(void)
11188 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11191 struct test_crypto_vector {
11192 enum rte_crypto_cipher_algorithm crypto_algo;
11193 unsigned int cipher_offset;
11194 unsigned int cipher_len;
11207 const uint8_t *data;
11212 const uint8_t *data;
11216 enum rte_crypto_auth_algorithm auth_algo;
11217 unsigned int auth_offset;
11225 const uint8_t *data;
11235 static const struct test_crypto_vector
11236 hmac_sha1_test_crypto_vector = {
11237 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11239 .data = plaintext_hash,
11244 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11245 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11246 0xDE, 0xF4, 0xDE, 0xAD
11252 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11253 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11254 0x3F, 0x91, 0x64, 0x59
11260 static const struct test_crypto_vector
11261 aes128_gmac_test_vector = {
11262 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11264 .data = plaintext_hash,
11269 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11270 0x08, 0x09, 0x0A, 0x0B
11276 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11277 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11283 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11284 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11290 static const struct test_crypto_vector
11291 aes128cbc_hmac_sha1_test_vector = {
11292 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11293 .cipher_offset = 0,
11297 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11298 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11304 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11305 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11310 .data = plaintext_hash,
11314 .data = ciphertext512_aes128cbc,
11317 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11321 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11322 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11323 0xDE, 0xF4, 0xDE, 0xAD
11329 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
11330 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11331 0x18, 0x8C, 0x1D, 0x32
11337 static const struct test_crypto_vector
11338 aes128cbc_hmac_sha1_aad_test_vector = {
11339 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11340 .cipher_offset = 8,
11344 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11345 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11351 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11352 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11357 .data = plaintext_hash,
11361 .data = ciphertext512_aes128cbc_aad,
11364 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11368 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11369 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11370 0xDE, 0xF4, 0xDE, 0xAD
11376 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
11377 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
11378 0x62, 0x0F, 0xFB, 0x10
11385 data_corruption(uint8_t *data)
11391 tag_corruption(uint8_t *data, unsigned int tag_offset)
11393 data[tag_offset] += 1;
11397 create_auth_session(struct crypto_unittest_params *ut_params,
11399 const struct test_crypto_vector *reference,
11400 enum rte_crypto_auth_operation auth_op)
11402 struct crypto_testsuite_params *ts_params = &testsuite_params;
11403 uint8_t auth_key[reference->auth_key.len + 1];
11405 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11407 /* Setup Authentication Parameters */
11408 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11409 ut_params->auth_xform.auth.op = auth_op;
11410 ut_params->auth_xform.next = NULL;
11411 ut_params->auth_xform.auth.algo = reference->auth_algo;
11412 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11413 ut_params->auth_xform.auth.key.data = auth_key;
11414 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11416 /* Create Crypto session*/
11417 ut_params->sess = rte_cryptodev_sym_session_create(
11418 ts_params->session_mpool);
11420 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11421 &ut_params->auth_xform,
11422 ts_params->session_priv_mpool);
11424 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11430 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
11432 const struct test_crypto_vector *reference,
11433 enum rte_crypto_auth_operation auth_op,
11434 enum rte_crypto_cipher_operation cipher_op)
11436 struct crypto_testsuite_params *ts_params = &testsuite_params;
11437 uint8_t cipher_key[reference->cipher_key.len + 1];
11438 uint8_t auth_key[reference->auth_key.len + 1];
11440 memcpy(cipher_key, reference->cipher_key.data,
11441 reference->cipher_key.len);
11442 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11444 /* Setup Authentication Parameters */
11445 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11446 ut_params->auth_xform.auth.op = auth_op;
11447 ut_params->auth_xform.auth.algo = reference->auth_algo;
11448 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11449 ut_params->auth_xform.auth.key.data = auth_key;
11450 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11452 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
11453 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11454 ut_params->auth_xform.auth.iv.length = reference->iv.len;
11456 ut_params->auth_xform.next = &ut_params->cipher_xform;
11458 /* Setup Cipher Parameters */
11459 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11460 ut_params->cipher_xform.next = NULL;
11461 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11462 ut_params->cipher_xform.cipher.op = cipher_op;
11463 ut_params->cipher_xform.cipher.key.data = cipher_key;
11464 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11465 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11466 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11469 /* Create Crypto session*/
11470 ut_params->sess = rte_cryptodev_sym_session_create(
11471 ts_params->session_mpool);
11473 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11474 &ut_params->auth_xform,
11475 ts_params->session_priv_mpool);
11477 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11483 create_auth_operation(struct crypto_testsuite_params *ts_params,
11484 struct crypto_unittest_params *ut_params,
11485 const struct test_crypto_vector *reference,
11486 unsigned int auth_generate)
11488 /* Generate Crypto op data structure */
11489 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11490 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11491 TEST_ASSERT_NOT_NULL(ut_params->op,
11492 "Failed to allocate pktmbuf offload");
11494 /* Set crypto operation data parameters */
11495 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11497 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11499 /* set crypto operation source mbuf */
11500 sym_op->m_src = ut_params->ibuf;
11503 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11504 ut_params->ibuf, reference->digest.len);
11506 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11507 "no room to append auth tag");
11509 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11510 ut_params->ibuf, reference->plaintext.len);
11513 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11515 memcpy(sym_op->auth.digest.data,
11516 reference->digest.data,
11517 reference->digest.len);
11519 debug_hexdump(stdout, "digest:",
11520 sym_op->auth.digest.data,
11521 reference->digest.len);
11523 sym_op->auth.data.length = reference->plaintext.len;
11524 sym_op->auth.data.offset = 0;
11530 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
11531 struct crypto_unittest_params *ut_params,
11532 const struct test_crypto_vector *reference,
11533 unsigned int auth_generate)
11535 /* Generate Crypto op data structure */
11536 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11537 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11538 TEST_ASSERT_NOT_NULL(ut_params->op,
11539 "Failed to allocate pktmbuf offload");
11541 /* Set crypto operation data parameters */
11542 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11544 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11546 /* set crypto operation source mbuf */
11547 sym_op->m_src = ut_params->ibuf;
11550 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11551 ut_params->ibuf, reference->digest.len);
11553 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11554 "no room to append auth tag");
11556 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11557 ut_params->ibuf, reference->ciphertext.len);
11560 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11562 memcpy(sym_op->auth.digest.data,
11563 reference->digest.data,
11564 reference->digest.len);
11566 debug_hexdump(stdout, "digest:",
11567 sym_op->auth.digest.data,
11568 reference->digest.len);
11570 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11571 reference->iv.data, reference->iv.len);
11573 sym_op->cipher.data.length = 0;
11574 sym_op->cipher.data.offset = 0;
11576 sym_op->auth.data.length = reference->plaintext.len;
11577 sym_op->auth.data.offset = 0;
11583 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11584 struct crypto_unittest_params *ut_params,
11585 const struct test_crypto_vector *reference,
11586 unsigned int auth_generate)
11588 /* Generate Crypto op data structure */
11589 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11590 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11591 TEST_ASSERT_NOT_NULL(ut_params->op,
11592 "Failed to allocate pktmbuf offload");
11594 /* Set crypto operation data parameters */
11595 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11597 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11599 /* set crypto operation source mbuf */
11600 sym_op->m_src = ut_params->ibuf;
11603 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11604 ut_params->ibuf, reference->digest.len);
11606 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11607 "no room to append auth tag");
11609 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11610 ut_params->ibuf, reference->ciphertext.len);
11613 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11615 memcpy(sym_op->auth.digest.data,
11616 reference->digest.data,
11617 reference->digest.len);
11619 debug_hexdump(stdout, "digest:",
11620 sym_op->auth.digest.data,
11621 reference->digest.len);
11623 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11624 reference->iv.data, reference->iv.len);
11626 sym_op->cipher.data.length = reference->cipher_len;
11627 sym_op->cipher.data.offset = reference->cipher_offset;
11629 sym_op->auth.data.length = reference->plaintext.len;
11630 sym_op->auth.data.offset = reference->auth_offset;
11636 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11637 struct crypto_unittest_params *ut_params,
11638 const struct test_crypto_vector *reference)
11640 return create_auth_operation(ts_params, ut_params, reference, 0);
11644 create_auth_verify_GMAC_operation(
11645 struct crypto_testsuite_params *ts_params,
11646 struct crypto_unittest_params *ut_params,
11647 const struct test_crypto_vector *reference)
11649 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11653 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11654 struct crypto_unittest_params *ut_params,
11655 const struct test_crypto_vector *reference)
11657 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11661 test_authentication_verify_fail_when_data_corruption(
11662 struct crypto_testsuite_params *ts_params,
11663 struct crypto_unittest_params *ut_params,
11664 const struct test_crypto_vector *reference,
11665 unsigned int data_corrupted)
11669 uint8_t *plaintext;
11670 struct rte_cryptodev_info dev_info;
11672 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11673 uint64_t feat_flags = dev_info.feature_flags;
11675 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11676 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11677 printf("Device doesn't support RAW data-path APIs.\n");
11681 /* Verify the capabilities */
11682 struct rte_cryptodev_sym_capability_idx cap_idx;
11683 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11684 cap_idx.algo.auth = reference->auth_algo;
11685 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11690 /* Create session */
11691 retval = create_auth_session(ut_params,
11692 ts_params->valid_devs[0],
11694 RTE_CRYPTO_AUTH_OP_VERIFY);
11698 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11699 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11700 "Failed to allocate input buffer in mempool");
11702 /* clear mbuf payload */
11703 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11704 rte_pktmbuf_tailroom(ut_params->ibuf));
11706 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11707 reference->plaintext.len);
11708 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11709 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11711 debug_hexdump(stdout, "plaintext:", plaintext,
11712 reference->plaintext.len);
11714 /* Create operation */
11715 retval = create_auth_verify_operation(ts_params, ut_params, reference);
11720 if (data_corrupted)
11721 data_corruption(plaintext);
11723 tag_corruption(plaintext, reference->plaintext.len);
11725 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11726 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11728 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11729 RTE_CRYPTO_OP_STATUS_SUCCESS,
11730 "authentication not failed");
11731 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11732 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11733 ut_params->op, 0, 1, 0, 0);
11735 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11737 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11744 test_authentication_verify_GMAC_fail_when_corruption(
11745 struct crypto_testsuite_params *ts_params,
11746 struct crypto_unittest_params *ut_params,
11747 const struct test_crypto_vector *reference,
11748 unsigned int data_corrupted)
11751 uint8_t *plaintext;
11752 struct rte_cryptodev_info dev_info;
11754 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11755 uint64_t feat_flags = dev_info.feature_flags;
11757 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11758 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11759 printf("Device doesn't support RAW data-path APIs.\n");
11763 /* Verify the capabilities */
11764 struct rte_cryptodev_sym_capability_idx cap_idx;
11765 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11766 cap_idx.algo.auth = reference->auth_algo;
11767 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11771 /* Create session */
11772 retval = create_auth_cipher_session(ut_params,
11773 ts_params->valid_devs[0],
11775 RTE_CRYPTO_AUTH_OP_VERIFY,
11776 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11780 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11781 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11782 "Failed to allocate input buffer in mempool");
11784 /* clear mbuf payload */
11785 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11786 rte_pktmbuf_tailroom(ut_params->ibuf));
11788 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11789 reference->plaintext.len);
11790 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11791 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11793 debug_hexdump(stdout, "plaintext:", plaintext,
11794 reference->plaintext.len);
11796 /* Create operation */
11797 retval = create_auth_verify_GMAC_operation(ts_params,
11804 if (data_corrupted)
11805 data_corruption(plaintext);
11807 tag_corruption(plaintext, reference->aad.len);
11809 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11810 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11812 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11813 RTE_CRYPTO_OP_STATUS_SUCCESS,
11814 "authentication not failed");
11815 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11816 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11817 ut_params->op, 0, 1, 0, 0);
11819 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11821 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11828 test_authenticated_decryption_fail_when_corruption(
11829 struct crypto_testsuite_params *ts_params,
11830 struct crypto_unittest_params *ut_params,
11831 const struct test_crypto_vector *reference,
11832 unsigned int data_corrupted)
11836 uint8_t *ciphertext;
11837 struct rte_cryptodev_info dev_info;
11839 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11840 uint64_t feat_flags = dev_info.feature_flags;
11842 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11843 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11844 printf("Device doesn't support RAW data-path APIs.\n");
11848 /* Verify the capabilities */
11849 struct rte_cryptodev_sym_capability_idx cap_idx;
11850 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11851 cap_idx.algo.auth = reference->auth_algo;
11852 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11855 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11856 cap_idx.algo.cipher = reference->crypto_algo;
11857 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11861 /* Create session */
11862 retval = create_auth_cipher_session(ut_params,
11863 ts_params->valid_devs[0],
11865 RTE_CRYPTO_AUTH_OP_VERIFY,
11866 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11870 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11871 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11872 "Failed to allocate input buffer in mempool");
11874 /* clear mbuf payload */
11875 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11876 rte_pktmbuf_tailroom(ut_params->ibuf));
11878 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11879 reference->ciphertext.len);
11880 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11881 memcpy(ciphertext, reference->ciphertext.data,
11882 reference->ciphertext.len);
11884 /* Create operation */
11885 retval = create_cipher_auth_verify_operation(ts_params,
11892 if (data_corrupted)
11893 data_corruption(ciphertext);
11895 tag_corruption(ciphertext, reference->ciphertext.len);
11897 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11898 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11900 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11901 RTE_CRYPTO_OP_STATUS_SUCCESS,
11902 "authentication not failed");
11903 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11904 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11905 ut_params->op, 1, 1, 0, 0);
11907 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11909 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11916 test_authenticated_encryt_with_esn(
11917 struct crypto_testsuite_params *ts_params,
11918 struct crypto_unittest_params *ut_params,
11919 const struct test_crypto_vector *reference)
11923 uint8_t *authciphertext, *plaintext, *auth_tag;
11924 uint16_t plaintext_pad_len;
11925 uint8_t cipher_key[reference->cipher_key.len + 1];
11926 uint8_t auth_key[reference->auth_key.len + 1];
11927 struct rte_cryptodev_info dev_info;
11929 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11930 uint64_t feat_flags = dev_info.feature_flags;
11932 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11933 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11934 printf("Device doesn't support RAW data-path APIs.\n");
11938 /* Verify the capabilities */
11939 struct rte_cryptodev_sym_capability_idx cap_idx;
11940 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11941 cap_idx.algo.auth = reference->auth_algo;
11942 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11945 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11946 cap_idx.algo.cipher = reference->crypto_algo;
11947 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11951 /* Create session */
11952 memcpy(cipher_key, reference->cipher_key.data,
11953 reference->cipher_key.len);
11954 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11956 /* Setup Cipher Parameters */
11957 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11958 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11959 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11960 ut_params->cipher_xform.cipher.key.data = cipher_key;
11961 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11962 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11963 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11965 ut_params->cipher_xform.next = &ut_params->auth_xform;
11967 /* Setup Authentication Parameters */
11968 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11969 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11970 ut_params->auth_xform.auth.algo = reference->auth_algo;
11971 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11972 ut_params->auth_xform.auth.key.data = auth_key;
11973 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11974 ut_params->auth_xform.next = NULL;
11976 /* Create Crypto session*/
11977 ut_params->sess = rte_cryptodev_sym_session_create(
11978 ts_params->session_mpool);
11980 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11982 &ut_params->cipher_xform,
11983 ts_params->session_priv_mpool);
11985 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11987 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11988 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11989 "Failed to allocate input buffer in mempool");
11991 /* clear mbuf payload */
11992 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11993 rte_pktmbuf_tailroom(ut_params->ibuf));
11995 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11996 reference->plaintext.len);
11997 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11998 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12000 /* Create operation */
12001 retval = create_cipher_auth_operation(ts_params,
12008 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12009 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12011 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12012 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12013 ut_params->op, 1, 1, 0, 0);
12015 ut_params->op = process_crypto_request(
12016 ts_params->valid_devs[0], ut_params->op);
12018 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12020 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12021 "crypto op processing failed");
12023 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12025 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12026 ut_params->op->sym->auth.data.offset);
12027 auth_tag = authciphertext + plaintext_pad_len;
12028 debug_hexdump(stdout, "ciphertext:", authciphertext,
12029 reference->ciphertext.len);
12030 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12032 /* Validate obuf */
12033 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12035 reference->ciphertext.data,
12036 reference->ciphertext.len,
12037 "Ciphertext data not as expected");
12039 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12041 reference->digest.data,
12042 reference->digest.len,
12043 "Generated digest not as expected");
12045 return TEST_SUCCESS;
12050 test_authenticated_decrypt_with_esn(
12051 struct crypto_testsuite_params *ts_params,
12052 struct crypto_unittest_params *ut_params,
12053 const struct test_crypto_vector *reference)
12057 uint8_t *ciphertext;
12058 uint8_t cipher_key[reference->cipher_key.len + 1];
12059 uint8_t auth_key[reference->auth_key.len + 1];
12060 struct rte_cryptodev_info dev_info;
12062 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12063 uint64_t feat_flags = dev_info.feature_flags;
12065 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12066 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12067 printf("Device doesn't support RAW data-path APIs.\n");
12071 /* Verify the capabilities */
12072 struct rte_cryptodev_sym_capability_idx cap_idx;
12073 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12074 cap_idx.algo.auth = reference->auth_algo;
12075 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12078 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12079 cap_idx.algo.cipher = reference->crypto_algo;
12080 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12084 /* Create session */
12085 memcpy(cipher_key, reference->cipher_key.data,
12086 reference->cipher_key.len);
12087 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12089 /* Setup Authentication Parameters */
12090 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12091 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12092 ut_params->auth_xform.auth.algo = reference->auth_algo;
12093 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12094 ut_params->auth_xform.auth.key.data = auth_key;
12095 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12096 ut_params->auth_xform.next = &ut_params->cipher_xform;
12098 /* Setup Cipher Parameters */
12099 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12100 ut_params->cipher_xform.next = NULL;
12101 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12102 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12103 ut_params->cipher_xform.cipher.key.data = cipher_key;
12104 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12105 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12106 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12108 /* Create Crypto session*/
12109 ut_params->sess = rte_cryptodev_sym_session_create(
12110 ts_params->session_mpool);
12112 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12114 &ut_params->auth_xform,
12115 ts_params->session_priv_mpool);
12117 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12119 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12120 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12121 "Failed to allocate input buffer in mempool");
12123 /* clear mbuf payload */
12124 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12125 rte_pktmbuf_tailroom(ut_params->ibuf));
12127 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12128 reference->ciphertext.len);
12129 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12130 memcpy(ciphertext, reference->ciphertext.data,
12131 reference->ciphertext.len);
12133 /* Create operation */
12134 retval = create_cipher_auth_verify_operation(ts_params,
12141 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12142 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12144 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12145 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12146 ut_params->op, 1, 1, 0, 0);
12148 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12151 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12152 TEST_ASSERT_EQUAL(ut_params->op->status,
12153 RTE_CRYPTO_OP_STATUS_SUCCESS,
12154 "crypto op processing passed");
12156 ut_params->obuf = ut_params->op->sym->m_src;
12157 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12163 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12164 const struct aead_test_data *tdata,
12165 void *digest_mem, uint64_t digest_phys)
12167 struct crypto_testsuite_params *ts_params = &testsuite_params;
12168 struct crypto_unittest_params *ut_params = &unittest_params;
12170 const unsigned int auth_tag_len = tdata->auth_tag.len;
12171 const unsigned int iv_len = tdata->iv.len;
12172 unsigned int aad_len = tdata->aad.len;
12173 unsigned int aad_len_pad = 0;
12175 /* Generate Crypto op data structure */
12176 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12177 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12178 TEST_ASSERT_NOT_NULL(ut_params->op,
12179 "Failed to allocate symmetric crypto operation struct");
12181 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12183 sym_op->aead.digest.data = digest_mem;
12185 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12186 "no room to append digest");
12188 sym_op->aead.digest.phys_addr = digest_phys;
12190 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12191 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12193 debug_hexdump(stdout, "digest:",
12194 sym_op->aead.digest.data,
12198 /* Append aad data */
12199 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12200 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12201 uint8_t *, IV_OFFSET);
12203 /* Copy IV 1 byte after the IV pointer, according to the API */
12204 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12206 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12208 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12209 ut_params->ibuf, aad_len);
12210 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12211 "no room to prepend aad");
12212 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12215 memset(sym_op->aead.aad.data, 0, aad_len);
12216 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12217 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12219 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12220 debug_hexdump(stdout, "aad:",
12221 sym_op->aead.aad.data, aad_len);
12223 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12224 uint8_t *, IV_OFFSET);
12226 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12228 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12230 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12231 ut_params->ibuf, aad_len_pad);
12232 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12233 "no room to prepend aad");
12234 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12237 memset(sym_op->aead.aad.data, 0, aad_len);
12238 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12240 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12241 debug_hexdump(stdout, "aad:",
12242 sym_op->aead.aad.data, aad_len);
12245 sym_op->aead.data.length = tdata->plaintext.len;
12246 sym_op->aead.data.offset = aad_len_pad;
12251 #define SGL_MAX_NO 16
12254 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12255 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12257 struct crypto_testsuite_params *ts_params = &testsuite_params;
12258 struct crypto_unittest_params *ut_params = &unittest_params;
12259 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12262 int to_trn_tbl[SGL_MAX_NO];
12264 unsigned int trn_data = 0;
12265 uint8_t *plaintext, *ciphertext, *auth_tag;
12266 struct rte_cryptodev_info dev_info;
12268 /* Verify the capabilities */
12269 struct rte_cryptodev_sym_capability_idx cap_idx;
12270 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12271 cap_idx.algo.aead = tdata->algo;
12272 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12276 /* OOP not supported with CPU crypto */
12277 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12280 /* Detailed check for the particular SGL support flag */
12281 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12283 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12284 if (sgl_in && (!(dev_info.feature_flags &
12285 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12288 uint64_t feat_flags = dev_info.feature_flags;
12290 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12291 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12292 printf("Device doesn't support RAW data-path APIs.\n");
12296 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12297 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12298 tdata->plaintext.len;
12299 /* Raw data path API does not support OOP */
12300 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12302 if (sgl_in && !sgl_out) {
12303 if (!(dev_info.feature_flags &
12304 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12306 } else if (!sgl_in && sgl_out) {
12307 if (!(dev_info.feature_flags &
12308 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12310 } else if (sgl_in && sgl_out) {
12311 if (!(dev_info.feature_flags &
12312 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12317 if (fragsz > tdata->plaintext.len)
12318 fragsz = tdata->plaintext.len;
12320 uint16_t plaintext_len = fragsz;
12321 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
12323 if (fragsz_oop > tdata->plaintext.len)
12324 frag_size_oop = tdata->plaintext.len;
12327 void *digest_mem = NULL;
12329 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
12331 if (tdata->plaintext.len % fragsz != 0) {
12332 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
12335 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
12340 * For out-op-place we need to alloc another mbuf
12343 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12344 rte_pktmbuf_append(ut_params->obuf,
12345 frag_size_oop + prepend_len);
12346 buf_oop = ut_params->obuf;
12349 /* Create AEAD session */
12350 retval = create_aead_session(ts_params->valid_devs[0],
12352 RTE_CRYPTO_AEAD_OP_ENCRYPT,
12353 tdata->key.data, tdata->key.len,
12354 tdata->aad.len, tdata->auth_tag.len,
12359 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12361 /* clear mbuf payload */
12362 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12363 rte_pktmbuf_tailroom(ut_params->ibuf));
12365 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12368 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12370 trn_data += plaintext_len;
12372 buf = ut_params->ibuf;
12375 * Loop until no more fragments
12378 while (trn_data < tdata->plaintext.len) {
12380 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12381 (tdata->plaintext.len - trn_data) : fragsz;
12383 to_trn_tbl[ecx++] = to_trn;
12385 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12388 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12389 rte_pktmbuf_tailroom(buf));
12392 if (oop && !fragsz_oop) {
12393 buf_last_oop = buf_oop->next =
12394 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12395 buf_oop = buf_oop->next;
12396 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12397 0, rte_pktmbuf_tailroom(buf_oop));
12398 rte_pktmbuf_append(buf_oop, to_trn);
12401 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12404 memcpy(plaintext, tdata->plaintext.data + trn_data,
12406 trn_data += to_trn;
12407 if (trn_data == tdata->plaintext.len) {
12410 digest_mem = rte_pktmbuf_append(buf_oop,
12411 tdata->auth_tag.len);
12413 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12414 tdata->auth_tag.len);
12418 uint64_t digest_phys = 0;
12420 ut_params->ibuf->nb_segs = segs;
12423 if (fragsz_oop && oop) {
12427 if (frag_size_oop == tdata->plaintext.len) {
12428 digest_mem = rte_pktmbuf_append(ut_params->obuf,
12429 tdata->auth_tag.len);
12431 digest_phys = rte_pktmbuf_iova_offset(
12433 tdata->plaintext.len + prepend_len);
12436 trn_data = frag_size_oop;
12437 while (trn_data < tdata->plaintext.len) {
12440 (tdata->plaintext.len - trn_data <
12442 (tdata->plaintext.len - trn_data) :
12445 to_trn_tbl[ecx++] = to_trn;
12447 buf_last_oop = buf_oop->next =
12448 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12449 buf_oop = buf_oop->next;
12450 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12451 0, rte_pktmbuf_tailroom(buf_oop));
12452 rte_pktmbuf_append(buf_oop, to_trn);
12454 trn_data += to_trn;
12456 if (trn_data == tdata->plaintext.len) {
12457 digest_mem = rte_pktmbuf_append(buf_oop,
12458 tdata->auth_tag.len);
12462 ut_params->obuf->nb_segs = segs;
12466 * Place digest at the end of the last buffer
12469 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12470 if (oop && buf_last_oop)
12471 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
12473 if (!digest_mem && !oop) {
12474 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12475 + tdata->auth_tag.len);
12476 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12477 tdata->plaintext.len);
12480 /* Create AEAD operation */
12481 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
12482 tdata, digest_mem, digest_phys);
12487 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12489 ut_params->op->sym->m_src = ut_params->ibuf;
12491 ut_params->op->sym->m_dst = ut_params->obuf;
12493 /* Process crypto operation */
12494 if (oop == IN_PLACE &&
12495 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12496 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12497 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12498 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12499 ut_params->op, 0, 0, 0, 0);
12501 TEST_ASSERT_NOT_NULL(
12502 process_crypto_request(ts_params->valid_devs[0],
12503 ut_params->op), "failed to process sym crypto op");
12505 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12506 "crypto op processing failed");
12509 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12510 uint8_t *, prepend_len);
12512 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12513 uint8_t *, prepend_len);
12517 fragsz = fragsz_oop;
12519 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12521 tdata->ciphertext.data,
12523 "Ciphertext data not as expected");
12525 buf = ut_params->op->sym->m_src->next;
12527 buf = ut_params->op->sym->m_dst->next;
12529 unsigned int off = fragsz;
12533 ciphertext = rte_pktmbuf_mtod(buf,
12536 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12538 tdata->ciphertext.data + off,
12540 "Ciphertext data not as expected");
12542 off += to_trn_tbl[ecx++];
12546 auth_tag = digest_mem;
12547 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12549 tdata->auth_tag.data,
12550 tdata->auth_tag.len,
12551 "Generated auth tag not as expected");
12557 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
12559 return test_authenticated_encryption_SGL(
12560 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
12564 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
12566 return test_authenticated_encryption_SGL(
12567 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
12571 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
12573 return test_authenticated_encryption_SGL(
12574 &gcm_test_case_8, OUT_OF_PLACE, 400,
12575 gcm_test_case_8.plaintext.len);
12579 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
12581 /* This test is not for OPENSSL PMD */
12582 if (gbl_driver_id == rte_cryptodev_driver_id_get(
12583 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
12586 return test_authenticated_encryption_SGL(
12587 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
12591 test_authentication_verify_fail_when_data_corrupted(
12592 struct crypto_testsuite_params *ts_params,
12593 struct crypto_unittest_params *ut_params,
12594 const struct test_crypto_vector *reference)
12596 return test_authentication_verify_fail_when_data_corruption(
12597 ts_params, ut_params, reference, 1);
12601 test_authentication_verify_fail_when_tag_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, 0);
12611 test_authentication_verify_GMAC_fail_when_data_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_GMAC_fail_when_corruption(
12617 ts_params, ut_params, reference, 1);
12621 test_authentication_verify_GMAC_fail_when_tag_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, 0);
12631 test_authenticated_decryption_fail_when_data_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_authenticated_decryption_fail_when_corruption(
12637 ts_params, ut_params, reference, 1);
12641 test_authenticated_decryption_fail_when_tag_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, 0);
12651 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
12653 return test_authentication_verify_fail_when_data_corrupted(
12654 &testsuite_params, &unittest_params,
12655 &hmac_sha1_test_crypto_vector);
12659 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
12661 return test_authentication_verify_fail_when_tag_corrupted(
12662 &testsuite_params, &unittest_params,
12663 &hmac_sha1_test_crypto_vector);
12667 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
12669 return test_authentication_verify_GMAC_fail_when_data_corrupted(
12670 &testsuite_params, &unittest_params,
12671 &aes128_gmac_test_vector);
12675 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
12677 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
12678 &testsuite_params, &unittest_params,
12679 &aes128_gmac_test_vector);
12683 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
12685 return test_authenticated_decryption_fail_when_data_corrupted(
12688 &aes128cbc_hmac_sha1_test_vector);
12692 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
12694 return test_authenticated_decryption_fail_when_tag_corrupted(
12697 &aes128cbc_hmac_sha1_test_vector);
12701 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
12703 return test_authenticated_encryt_with_esn(
12706 &aes128cbc_hmac_sha1_aad_test_vector);
12710 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
12712 return test_authenticated_decrypt_with_esn(
12715 &aes128cbc_hmac_sha1_aad_test_vector);
12719 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
12721 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
12725 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
12727 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
12730 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12732 /* global AESNI worker IDs for the scheduler test */
12733 uint8_t aesni_ids[2];
12736 test_scheduler_attach_slave_op(void)
12738 struct crypto_testsuite_params *ts_params = &testsuite_params;
12739 uint8_t sched_id = ts_params->valid_devs[0];
12740 uint32_t nb_devs, i, nb_devs_attached = 0;
12742 char vdev_name[32];
12744 /* create 2 AESNI_MB if necessary */
12745 nb_devs = rte_cryptodev_device_count_by_driver(
12746 rte_cryptodev_driver_id_get(
12747 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
12749 for (i = nb_devs; i < 2; i++) {
12750 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
12751 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
12753 ret = rte_vdev_init(vdev_name, NULL);
12755 TEST_ASSERT(ret == 0,
12756 "Failed to create instance %u of"
12758 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12762 /* attach 2 AESNI_MB cdevs */
12763 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
12765 struct rte_cryptodev_info info;
12766 unsigned int session_size;
12768 rte_cryptodev_info_get(i, &info);
12769 if (info.driver_id != rte_cryptodev_driver_id_get(
12770 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
12773 session_size = rte_cryptodev_sym_get_private_session_size(i);
12775 * Create the session mempool again, since now there are new devices
12776 * to use the mempool.
12778 if (ts_params->session_mpool) {
12779 rte_mempool_free(ts_params->session_mpool);
12780 ts_params->session_mpool = NULL;
12782 if (ts_params->session_priv_mpool) {
12783 rte_mempool_free(ts_params->session_priv_mpool);
12784 ts_params->session_priv_mpool = NULL;
12787 if (info.sym.max_nb_sessions != 0 &&
12788 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
12789 RTE_LOG(ERR, USER1,
12790 "Device does not support "
12791 "at least %u sessions\n",
12793 return TEST_FAILED;
12796 * Create mempool with maximum number of sessions,
12797 * to include the session headers
12799 if (ts_params->session_mpool == NULL) {
12800 ts_params->session_mpool =
12801 rte_cryptodev_sym_session_pool_create(
12803 MAX_NB_SESSIONS, 0, 0, 0,
12805 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
12806 "session mempool allocation failed");
12810 * Create mempool with maximum number of sessions,
12811 * to include device specific session private data
12813 if (ts_params->session_priv_mpool == NULL) {
12814 ts_params->session_priv_mpool = rte_mempool_create(
12815 "test_sess_mp_priv",
12818 0, 0, NULL, NULL, NULL,
12819 NULL, SOCKET_ID_ANY,
12822 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
12823 "session mempool allocation failed");
12826 ts_params->qp_conf.mp_session = ts_params->session_mpool;
12827 ts_params->qp_conf.mp_session_private =
12828 ts_params->session_priv_mpool;
12830 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
12833 TEST_ASSERT(ret == 0,
12834 "Failed to attach device %u of pmd : %s", i,
12835 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12837 aesni_ids[nb_devs_attached] = (uint8_t)i;
12839 nb_devs_attached++;
12846 test_scheduler_detach_slave_op(void)
12848 struct crypto_testsuite_params *ts_params = &testsuite_params;
12849 uint8_t sched_id = ts_params->valid_devs[0];
12853 for (i = 0; i < 2; i++) {
12854 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
12856 TEST_ASSERT(ret == 0,
12857 "Failed to detach device %u", aesni_ids[i]);
12864 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
12866 struct crypto_testsuite_params *ts_params = &testsuite_params;
12867 uint8_t sched_id = ts_params->valid_devs[0];
12869 return rte_cryptodev_scheduler_mode_set(sched_id,
12874 test_scheduler_mode_roundrobin_op(void)
12876 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
12877 0, "Failed to set roundrobin mode");
12883 test_scheduler_mode_multicore_op(void)
12885 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
12886 0, "Failed to set multicore mode");
12892 test_scheduler_mode_failover_op(void)
12894 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
12895 0, "Failed to set failover mode");
12901 test_scheduler_mode_pkt_size_distr_op(void)
12903 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
12904 0, "Failed to set pktsize mode");
12909 static struct unit_test_suite cryptodev_scheduler_testsuite = {
12910 .suite_name = "Crypto Device Scheduler Unit Test Suite",
12911 .setup = testsuite_setup,
12912 .teardown = testsuite_teardown,
12913 .unit_test_cases = {
12915 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12916 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
12917 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12918 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12919 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12920 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12923 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12924 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
12925 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12926 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12927 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12928 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12931 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12932 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
12933 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12934 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12935 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12936 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12939 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12940 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
12941 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12942 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12943 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12944 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12946 TEST_CASES_END() /**< NULL terminate unit test array */
12950 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
12952 static struct unit_test_suite cryptodev_testsuite = {
12953 .suite_name = "Crypto Unit Test Suite",
12954 .setup = testsuite_setup,
12955 .teardown = testsuite_teardown,
12956 .unit_test_cases = {
12957 TEST_CASE_ST(ut_setup, ut_teardown,
12958 test_device_configure_invalid_dev_id),
12959 TEST_CASE_ST(ut_setup, ut_teardown,
12960 test_queue_pair_descriptor_setup),
12961 TEST_CASE_ST(ut_setup, ut_teardown,
12962 test_device_configure_invalid_queue_pair_ids),
12964 TEST_CASE_ST(ut_setup, ut_teardown,
12965 test_multi_session),
12966 TEST_CASE_ST(ut_setup, ut_teardown,
12967 test_multi_session_random_usage),
12969 TEST_CASE_ST(ut_setup, ut_teardown,
12970 test_null_invalid_operation),
12971 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
12973 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12974 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12975 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12976 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12977 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
12978 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
12979 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
12980 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12981 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
12983 /** AES CCM Authenticated Encryption 128 bits key */
12984 TEST_CASE_ST(ut_setup, ut_teardown,
12985 test_AES_CCM_authenticated_encryption_test_case_128_1),
12986 TEST_CASE_ST(ut_setup, ut_teardown,
12987 test_AES_CCM_authenticated_encryption_test_case_128_2),
12988 TEST_CASE_ST(ut_setup, ut_teardown,
12989 test_AES_CCM_authenticated_encryption_test_case_128_3),
12991 /** AES CCM Authenticated Decryption 128 bits key*/
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 test_AES_CCM_authenticated_decryption_test_case_128_1),
12994 TEST_CASE_ST(ut_setup, ut_teardown,
12995 test_AES_CCM_authenticated_decryption_test_case_128_2),
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_AES_CCM_authenticated_decryption_test_case_128_3),
12999 /** AES CCM Authenticated Encryption 192 bits key */
13000 TEST_CASE_ST(ut_setup, ut_teardown,
13001 test_AES_CCM_authenticated_encryption_test_case_192_1),
13002 TEST_CASE_ST(ut_setup, ut_teardown,
13003 test_AES_CCM_authenticated_encryption_test_case_192_2),
13004 TEST_CASE_ST(ut_setup, ut_teardown,
13005 test_AES_CCM_authenticated_encryption_test_case_192_3),
13007 /** AES CCM Authenticated Decryption 192 bits key*/
13008 TEST_CASE_ST(ut_setup, ut_teardown,
13009 test_AES_CCM_authenticated_decryption_test_case_192_1),
13010 TEST_CASE_ST(ut_setup, ut_teardown,
13011 test_AES_CCM_authenticated_decryption_test_case_192_2),
13012 TEST_CASE_ST(ut_setup, ut_teardown,
13013 test_AES_CCM_authenticated_decryption_test_case_192_3),
13015 /** AES CCM Authenticated Encryption 256 bits key */
13016 TEST_CASE_ST(ut_setup, ut_teardown,
13017 test_AES_CCM_authenticated_encryption_test_case_256_1),
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 test_AES_CCM_authenticated_encryption_test_case_256_2),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 test_AES_CCM_authenticated_encryption_test_case_256_3),
13023 /** AES CCM Authenticated Decryption 256 bits key*/
13024 TEST_CASE_ST(ut_setup, ut_teardown,
13025 test_AES_CCM_authenticated_decryption_test_case_256_1),
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 test_AES_CCM_authenticated_decryption_test_case_256_2),
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 test_AES_CCM_authenticated_decryption_test_case_256_3),
13031 /** AES GCM Authenticated Encryption */
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13034 TEST_CASE_ST(ut_setup, ut_teardown,
13035 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13040 TEST_CASE_ST(ut_setup, ut_teardown,
13041 test_AES_GCM_authenticated_encryption_test_case_1),
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 test_AES_GCM_authenticated_encryption_test_case_2),
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_AES_GCM_authenticated_encryption_test_case_3),
13046 TEST_CASE_ST(ut_setup, ut_teardown,
13047 test_AES_GCM_authenticated_encryption_test_case_4),
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_AES_GCM_authenticated_encryption_test_case_5),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_AES_GCM_authenticated_encryption_test_case_6),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_AES_GCM_authenticated_encryption_test_case_7),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_AES_GCM_authenticated_encryption_test_case_8),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13059 /** AES GCM Authenticated Decryption */
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_AES_GCM_authenticated_decryption_test_case_1),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_AES_GCM_authenticated_decryption_test_case_2),
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_AES_GCM_authenticated_decryption_test_case_3),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_AES_GCM_authenticated_decryption_test_case_4),
13068 TEST_CASE_ST(ut_setup, ut_teardown,
13069 test_AES_GCM_authenticated_decryption_test_case_5),
13070 TEST_CASE_ST(ut_setup, ut_teardown,
13071 test_AES_GCM_authenticated_decryption_test_case_6),
13072 TEST_CASE_ST(ut_setup, ut_teardown,
13073 test_AES_GCM_authenticated_decryption_test_case_7),
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_AES_GCM_authenticated_decryption_test_case_8),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13079 /** AES GCM Authenticated Encryption 192 bits key */
13080 TEST_CASE_ST(ut_setup, ut_teardown,
13081 test_AES_GCM_auth_encryption_test_case_192_1),
13082 TEST_CASE_ST(ut_setup, ut_teardown,
13083 test_AES_GCM_auth_encryption_test_case_192_2),
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_AES_GCM_auth_encryption_test_case_192_3),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_AES_GCM_auth_encryption_test_case_192_4),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_AES_GCM_auth_encryption_test_case_192_5),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_AES_GCM_auth_encryption_test_case_192_6),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_AES_GCM_auth_encryption_test_case_192_7),
13095 /** AES GCM Authenticated Decryption 192 bits key */
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_AES_GCM_auth_decryption_test_case_192_1),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_AES_GCM_auth_decryption_test_case_192_2),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_AES_GCM_auth_decryption_test_case_192_3),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_AES_GCM_auth_decryption_test_case_192_4),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_AES_GCM_auth_decryption_test_case_192_5),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_AES_GCM_auth_decryption_test_case_192_6),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_AES_GCM_auth_decryption_test_case_192_7),
13111 /** AES GCM Authenticated Encryption 256 bits key */
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_AES_GCM_auth_encryption_test_case_256_1),
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_AES_GCM_auth_encryption_test_case_256_2),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_AES_GCM_auth_encryption_test_case_256_3),
13118 TEST_CASE_ST(ut_setup, ut_teardown,
13119 test_AES_GCM_auth_encryption_test_case_256_4),
13120 TEST_CASE_ST(ut_setup, ut_teardown,
13121 test_AES_GCM_auth_encryption_test_case_256_5),
13122 TEST_CASE_ST(ut_setup, ut_teardown,
13123 test_AES_GCM_auth_encryption_test_case_256_6),
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 test_AES_GCM_auth_encryption_test_case_256_7),
13127 /** AES GCM Authenticated Decryption 256 bits key */
13128 TEST_CASE_ST(ut_setup, ut_teardown,
13129 test_AES_GCM_auth_decryption_test_case_256_1),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_AES_GCM_auth_decryption_test_case_256_2),
13132 TEST_CASE_ST(ut_setup, ut_teardown,
13133 test_AES_GCM_auth_decryption_test_case_256_3),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_AES_GCM_auth_decryption_test_case_256_4),
13136 TEST_CASE_ST(ut_setup, ut_teardown,
13137 test_AES_GCM_auth_decryption_test_case_256_5),
13138 TEST_CASE_ST(ut_setup, ut_teardown,
13139 test_AES_GCM_auth_decryption_test_case_256_6),
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_AES_GCM_auth_decryption_test_case_256_7),
13143 /** AES GCM Authenticated Encryption big aad size */
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_AES_GCM_auth_encryption_test_case_aad_1),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 test_AES_GCM_auth_encryption_test_case_aad_2),
13149 /** AES GCM Authenticated Decryption big aad size */
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 test_AES_GCM_auth_decryption_test_case_aad_1),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 test_AES_GCM_auth_decryption_test_case_aad_2),
13155 /** Out of place tests */
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13161 /** Session-less tests */
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13167 /** AES GMAC Authentication */
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_AES_GMAC_authentication_test_case_1),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_AES_GMAC_authentication_verify_test_case_1),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_AES_GMAC_authentication_test_case_2),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_AES_GMAC_authentication_verify_test_case_2),
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_AES_GMAC_authentication_test_case_3),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_AES_GMAC_authentication_verify_test_case_3),
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 test_AES_GMAC_authentication_test_case_4),
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_AES_GMAC_authentication_verify_test_case_4),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_AES_GMAC_authentication_SGL_40B),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 test_AES_GMAC_authentication_SGL_80B),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_AES_GMAC_authentication_SGL_2048B),
13190 TEST_CASE_ST(ut_setup, ut_teardown,
13191 test_AES_GMAC_authentication_SGL_2047B),
13193 /** Chacha20-Poly1305 */
13194 TEST_CASE_ST(ut_setup, ut_teardown,
13195 test_chacha20_poly1305_encrypt_test_case_rfc8439),
13196 TEST_CASE_ST(ut_setup, ut_teardown,
13197 test_chacha20_poly1305_decrypt_test_case_rfc8439),
13198 /** SNOW 3G encrypt only (UEA2) */
13199 TEST_CASE_ST(ut_setup, ut_teardown,
13200 test_snow3g_encryption_test_case_1),
13201 TEST_CASE_ST(ut_setup, ut_teardown,
13202 test_snow3g_encryption_test_case_2),
13203 TEST_CASE_ST(ut_setup, ut_teardown,
13204 test_snow3g_encryption_test_case_3),
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 test_snow3g_encryption_test_case_4),
13207 TEST_CASE_ST(ut_setup, ut_teardown,
13208 test_snow3g_encryption_test_case_5),
13210 TEST_CASE_ST(ut_setup, ut_teardown,
13211 test_snow3g_encryption_test_case_1_oop),
13212 TEST_CASE_ST(ut_setup, ut_teardown,
13213 test_snow3g_encryption_test_case_1_oop_sgl),
13214 TEST_CASE_ST(ut_setup, ut_teardown,
13215 test_snow3g_encryption_test_case_1_offset_oop),
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 test_snow3g_decryption_test_case_1_oop),
13219 /** SNOW 3G generate auth, then encrypt (UEA2) */
13220 TEST_CASE_ST(ut_setup, ut_teardown,
13221 test_snow3g_auth_cipher_test_case_1),
13222 TEST_CASE_ST(ut_setup, ut_teardown,
13223 test_snow3g_auth_cipher_test_case_2),
13224 TEST_CASE_ST(ut_setup, ut_teardown,
13225 test_snow3g_auth_cipher_test_case_2_oop),
13226 TEST_CASE_ST(ut_setup, ut_teardown,
13227 test_snow3g_auth_cipher_part_digest_enc),
13228 TEST_CASE_ST(ut_setup, ut_teardown,
13229 test_snow3g_auth_cipher_part_digest_enc_oop),
13230 TEST_CASE_ST(ut_setup, ut_teardown,
13231 test_snow3g_auth_cipher_test_case_3_sgl),
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_snow3g_auth_cipher_part_digest_enc_sgl),
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13239 /** SNOW 3G decrypt (UEA2), then verify auth */
13240 TEST_CASE_ST(ut_setup, ut_teardown,
13241 test_snow3g_auth_cipher_verify_test_case_1),
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_snow3g_auth_cipher_verify_test_case_2),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_snow3g_auth_cipher_verify_test_case_2_oop),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_snow3g_auth_cipher_verify_part_digest_enc),
13248 TEST_CASE_ST(ut_setup, ut_teardown,
13249 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13250 TEST_CASE_ST(ut_setup, ut_teardown,
13251 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13252 TEST_CASE_ST(ut_setup, ut_teardown,
13253 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13254 TEST_CASE_ST(ut_setup, ut_teardown,
13255 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13256 TEST_CASE_ST(ut_setup, ut_teardown,
13257 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13259 /** SNOW 3G decrypt only (UEA2) */
13260 TEST_CASE_ST(ut_setup, ut_teardown,
13261 test_snow3g_decryption_test_case_1),
13262 TEST_CASE_ST(ut_setup, ut_teardown,
13263 test_snow3g_decryption_test_case_2),
13264 TEST_CASE_ST(ut_setup, ut_teardown,
13265 test_snow3g_decryption_test_case_3),
13266 TEST_CASE_ST(ut_setup, ut_teardown,
13267 test_snow3g_decryption_test_case_4),
13268 TEST_CASE_ST(ut_setup, ut_teardown,
13269 test_snow3g_decryption_test_case_5),
13270 TEST_CASE_ST(ut_setup, ut_teardown,
13271 test_snow3g_decryption_with_digest_test_case_1),
13272 TEST_CASE_ST(ut_setup, ut_teardown,
13273 test_snow3g_hash_generate_test_case_1),
13274 TEST_CASE_ST(ut_setup, ut_teardown,
13275 test_snow3g_hash_generate_test_case_2),
13276 TEST_CASE_ST(ut_setup, ut_teardown,
13277 test_snow3g_hash_generate_test_case_3),
13278 /* Tests with buffers which length is not byte-aligned */
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_snow3g_hash_generate_test_case_4),
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_snow3g_hash_generate_test_case_5),
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_snow3g_hash_generate_test_case_6),
13285 TEST_CASE_ST(ut_setup, ut_teardown,
13286 test_snow3g_hash_verify_test_case_1),
13287 TEST_CASE_ST(ut_setup, ut_teardown,
13288 test_snow3g_hash_verify_test_case_2),
13289 TEST_CASE_ST(ut_setup, ut_teardown,
13290 test_snow3g_hash_verify_test_case_3),
13291 /* Tests with buffers which length is not byte-aligned */
13292 TEST_CASE_ST(ut_setup, ut_teardown,
13293 test_snow3g_hash_verify_test_case_4),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_snow3g_hash_verify_test_case_5),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_snow3g_hash_verify_test_case_6),
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_snow3g_cipher_auth_test_case_1),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_snow3g_auth_cipher_with_digest_test_case_1),
13303 /** ZUC encrypt only (EEA3) */
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_zuc_encryption_test_case_1),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_zuc_encryption_test_case_2),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_zuc_encryption_test_case_3),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_zuc_encryption_test_case_4),
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 test_zuc_encryption_test_case_5),
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 test_zuc_encryption_test_case_6_sgl),
13317 /** ZUC authenticate (EIA3) */
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_zuc_hash_generate_test_case_1),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_zuc_hash_generate_test_case_2),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 test_zuc_hash_generate_test_case_3),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_zuc_hash_generate_test_case_4),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_zuc_hash_generate_test_case_5),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_zuc_hash_generate_test_case_6),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_zuc_hash_generate_test_case_7),
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_zuc_hash_generate_test_case_8),
13335 /** ZUC alg-chain (EEA3/EIA3) */
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_zuc_cipher_auth_test_case_1),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 test_zuc_cipher_auth_test_case_2),
13341 /** ZUC generate auth, then encrypt (EEA3) */
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 test_zuc_auth_cipher_test_case_1),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 test_zuc_auth_cipher_test_case_1_oop),
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_zuc_auth_cipher_test_case_1_sgl),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_zuc_auth_cipher_test_case_1_oop_sgl),
13351 /** ZUC decrypt (EEA3), then verify auth */
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_zuc_auth_cipher_verify_test_case_1),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_zuc_auth_cipher_verify_test_case_1_oop),
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_zuc_auth_cipher_verify_test_case_1_sgl),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
13361 /** HMAC_MD5 Authentication */
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_MD5_HMAC_generate_case_1),
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_MD5_HMAC_verify_case_1),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_MD5_HMAC_generate_case_2),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_MD5_HMAC_verify_case_2),
13371 /** KASUMI hash only (UIA1) */
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_kasumi_hash_generate_test_case_1),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_kasumi_hash_generate_test_case_2),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_kasumi_hash_generate_test_case_3),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_kasumi_hash_generate_test_case_4),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_kasumi_hash_generate_test_case_5),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_kasumi_hash_generate_test_case_6),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_kasumi_hash_verify_test_case_1),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_kasumi_hash_verify_test_case_2),
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_kasumi_hash_verify_test_case_3),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_kasumi_hash_verify_test_case_4),
13393 TEST_CASE_ST(ut_setup, ut_teardown,
13394 test_kasumi_hash_verify_test_case_5),
13396 /** KASUMI encrypt only (UEA1) */
13397 TEST_CASE_ST(ut_setup, ut_teardown,
13398 test_kasumi_encryption_test_case_1),
13399 TEST_CASE_ST(ut_setup, ut_teardown,
13400 test_kasumi_encryption_test_case_1_sgl),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_kasumi_encryption_test_case_1_oop),
13403 TEST_CASE_ST(ut_setup, ut_teardown,
13404 test_kasumi_encryption_test_case_1_oop_sgl),
13405 TEST_CASE_ST(ut_setup, ut_teardown,
13406 test_kasumi_encryption_test_case_2),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_kasumi_encryption_test_case_3),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_kasumi_encryption_test_case_4),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_kasumi_encryption_test_case_5),
13414 /** KASUMI decrypt only (UEA1) */
13415 TEST_CASE_ST(ut_setup, ut_teardown,
13416 test_kasumi_decryption_test_case_1),
13417 TEST_CASE_ST(ut_setup, ut_teardown,
13418 test_kasumi_decryption_test_case_2),
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 test_kasumi_decryption_test_case_3),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 test_kasumi_decryption_test_case_4),
13423 TEST_CASE_ST(ut_setup, ut_teardown,
13424 test_kasumi_decryption_test_case_5),
13425 TEST_CASE_ST(ut_setup, ut_teardown,
13426 test_kasumi_decryption_test_case_1_oop),
13428 TEST_CASE_ST(ut_setup, ut_teardown,
13429 test_kasumi_cipher_auth_test_case_1),
13431 /** KASUMI generate auth, then encrypt (F8) */
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_kasumi_auth_cipher_test_case_1),
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 test_kasumi_auth_cipher_test_case_2),
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 test_kasumi_auth_cipher_test_case_2_oop),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 test_kasumi_auth_cipher_test_case_2_sgl),
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13443 /** KASUMI decrypt (F8), then verify auth */
13444 TEST_CASE_ST(ut_setup, ut_teardown,
13445 test_kasumi_auth_cipher_verify_test_case_1),
13446 TEST_CASE_ST(ut_setup, ut_teardown,
13447 test_kasumi_auth_cipher_verify_test_case_2),
13448 TEST_CASE_ST(ut_setup, ut_teardown,
13449 test_kasumi_auth_cipher_verify_test_case_2_oop),
13450 TEST_CASE_ST(ut_setup, ut_teardown,
13451 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13452 TEST_CASE_ST(ut_setup, ut_teardown,
13453 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13455 /** ESN Testcase */
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13458 TEST_CASE_ST(ut_setup, ut_teardown,
13459 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13461 /** Negative tests */
13462 TEST_CASE_ST(ut_setup, ut_teardown,
13463 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13464 TEST_CASE_ST(ut_setup, ut_teardown,
13465 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13466 TEST_CASE_ST(ut_setup, ut_teardown,
13467 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13468 TEST_CASE_ST(ut_setup, ut_teardown,
13469 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13470 TEST_CASE_ST(ut_setup, ut_teardown,
13471 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13472 TEST_CASE_ST(ut_setup, ut_teardown,
13473 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13474 TEST_CASE_ST(ut_setup, ut_teardown,
13475 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13476 TEST_CASE_ST(ut_setup, ut_teardown,
13477 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13478 TEST_CASE_ST(ut_setup, ut_teardown,
13479 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13480 TEST_CASE_ST(ut_setup, ut_teardown,
13481 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13482 TEST_CASE_ST(ut_setup, ut_teardown,
13483 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13484 TEST_CASE_ST(ut_setup, ut_teardown,
13485 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13486 TEST_CASE_ST(ut_setup, ut_teardown,
13487 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13488 TEST_CASE_ST(ut_setup, ut_teardown,
13489 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13490 TEST_CASE_ST(ut_setup, ut_teardown,
13491 authentication_verify_AES128_GMAC_fail_data_corrupt),
13492 TEST_CASE_ST(ut_setup, ut_teardown,
13493 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13494 TEST_CASE_ST(ut_setup, ut_teardown,
13495 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13496 TEST_CASE_ST(ut_setup, ut_teardown,
13497 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13499 /** Mixed CIPHER + HASH algorithms */
13500 /** AUTH AES CMAC + CIPHER AES CTR */
13501 TEST_CASE_ST(ut_setup, ut_teardown,
13502 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
13503 TEST_CASE_ST(ut_setup, ut_teardown,
13504 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13505 TEST_CASE_ST(ut_setup, ut_teardown,
13506 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13507 TEST_CASE_ST(ut_setup, ut_teardown,
13508 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13509 TEST_CASE_ST(ut_setup, ut_teardown,
13510 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
13511 TEST_CASE_ST(ut_setup, ut_teardown,
13512 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13513 TEST_CASE_ST(ut_setup, ut_teardown,
13514 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13515 TEST_CASE_ST(ut_setup, ut_teardown,
13516 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13518 /** AUTH ZUC + CIPHER SNOW3G */
13519 TEST_CASE_ST(ut_setup, ut_teardown,
13520 test_auth_zuc_cipher_snow_test_case_1),
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_verify_auth_zuc_cipher_snow_test_case_1),
13523 /** AUTH AES CMAC + CIPHER SNOW3G */
13524 TEST_CASE_ST(ut_setup, ut_teardown,
13525 test_auth_aes_cmac_cipher_snow_test_case_1),
13526 TEST_CASE_ST(ut_setup, ut_teardown,
13527 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
13528 /** AUTH ZUC + CIPHER AES CTR */
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_auth_zuc_cipher_aes_ctr_test_case_1),
13531 TEST_CASE_ST(ut_setup, ut_teardown,
13532 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
13533 /** AUTH SNOW3G + CIPHER AES CTR */
13534 TEST_CASE_ST(ut_setup, ut_teardown,
13535 test_auth_snow_cipher_aes_ctr_test_case_1),
13536 TEST_CASE_ST(ut_setup, ut_teardown,
13537 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
13538 /** AUTH SNOW3G + CIPHER ZUC */
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_auth_snow_cipher_zuc_test_case_1),
13541 TEST_CASE_ST(ut_setup, ut_teardown,
13542 test_verify_auth_snow_cipher_zuc_test_case_1),
13543 /** AUTH AES CMAC + CIPHER ZUC */
13544 TEST_CASE_ST(ut_setup, ut_teardown,
13545 test_auth_aes_cmac_cipher_zuc_test_case_1),
13546 TEST_CASE_ST(ut_setup, ut_teardown,
13547 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
13549 /** AUTH NULL + CIPHER SNOW3G */
13550 TEST_CASE_ST(ut_setup, ut_teardown,
13551 test_auth_null_cipher_snow_test_case_1),
13552 TEST_CASE_ST(ut_setup, ut_teardown,
13553 test_verify_auth_null_cipher_snow_test_case_1),
13554 /** AUTH NULL + CIPHER ZUC */
13555 TEST_CASE_ST(ut_setup, ut_teardown,
13556 test_auth_null_cipher_zuc_test_case_1),
13557 TEST_CASE_ST(ut_setup, ut_teardown,
13558 test_verify_auth_null_cipher_zuc_test_case_1),
13559 /** AUTH SNOW3G + CIPHER NULL */
13560 TEST_CASE_ST(ut_setup, ut_teardown,
13561 test_auth_snow_cipher_null_test_case_1),
13562 TEST_CASE_ST(ut_setup, ut_teardown,
13563 test_verify_auth_snow_cipher_null_test_case_1),
13564 /** AUTH ZUC + CIPHER NULL */
13565 TEST_CASE_ST(ut_setup, ut_teardown,
13566 test_auth_zuc_cipher_null_test_case_1),
13567 TEST_CASE_ST(ut_setup, ut_teardown,
13568 test_verify_auth_zuc_cipher_null_test_case_1),
13569 /** AUTH NULL + CIPHER AES CTR */
13570 TEST_CASE_ST(ut_setup, ut_teardown,
13571 test_auth_null_cipher_aes_ctr_test_case_1),
13572 TEST_CASE_ST(ut_setup, ut_teardown,
13573 test_verify_auth_null_cipher_aes_ctr_test_case_1),
13574 /** AUTH AES CMAC + CIPHER NULL */
13575 TEST_CASE_ST(ut_setup, ut_teardown,
13576 test_auth_aes_cmac_cipher_null_test_case_1),
13577 TEST_CASE_ST(ut_setup, ut_teardown,
13578 test_verify_auth_aes_cmac_cipher_null_test_case_1),
13580 #ifdef RTE_LIBRTE_SECURITY
13581 TEST_CASE_ST(ut_setup_security, ut_teardown,
13582 test_PDCP_PROTO_all),
13583 TEST_CASE_ST(ut_setup_security, ut_teardown,
13584 test_DOCSIS_PROTO_all),
13586 TEST_CASES_END() /**< NULL terminate unit test array */
13590 static struct unit_test_suite cryptodev_virtio_testsuite = {
13591 .suite_name = "Crypto VIRTIO Unit Test Suite",
13592 .setup = testsuite_setup,
13593 .teardown = testsuite_teardown,
13594 .unit_test_cases = {
13595 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13597 TEST_CASES_END() /**< NULL terminate unit test array */
13601 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13602 .suite_name = "Crypto CAAM JR Unit Test Suite",
13603 .setup = testsuite_setup,
13604 .teardown = testsuite_teardown,
13605 .unit_test_cases = {
13606 TEST_CASE_ST(ut_setup, ut_teardown,
13607 test_device_configure_invalid_dev_id),
13608 TEST_CASE_ST(ut_setup, ut_teardown,
13609 test_multi_session),
13611 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13612 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13613 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13614 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13615 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13617 TEST_CASES_END() /**< NULL terminate unit test array */
13621 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13622 .suite_name = "Crypto Device Marvell Component Test Suite",
13623 .setup = testsuite_setup,
13624 .teardown = testsuite_teardown,
13625 .unit_test_cases = {
13626 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13627 TEST_CASE_ST(ut_setup, ut_teardown,
13628 test_multi_session_random_usage),
13629 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13630 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13631 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13632 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13633 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13635 /** Negative tests */
13636 TEST_CASE_ST(ut_setup, ut_teardown,
13637 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13638 TEST_CASE_ST(ut_setup, ut_teardown,
13639 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13640 TEST_CASE_ST(ut_setup, ut_teardown,
13641 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13642 TEST_CASE_ST(ut_setup, ut_teardown,
13643 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13645 TEST_CASES_END() /**< NULL terminate unit test array */
13649 static struct unit_test_suite cryptodev_ccp_testsuite = {
13650 .suite_name = "Crypto Device CCP Unit Test Suite",
13651 .setup = testsuite_setup,
13652 .teardown = testsuite_teardown,
13653 .unit_test_cases = {
13654 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13655 TEST_CASE_ST(ut_setup, ut_teardown,
13656 test_multi_session_random_usage),
13657 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13658 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13659 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13660 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13661 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13663 /** Negative tests */
13664 TEST_CASE_ST(ut_setup, ut_teardown,
13665 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13666 TEST_CASE_ST(ut_setup, ut_teardown,
13667 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13668 TEST_CASE_ST(ut_setup, ut_teardown,
13669 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13670 TEST_CASE_ST(ut_setup, ut_teardown,
13671 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13673 TEST_CASES_END() /**< NULL terminate unit test array */
13678 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13680 gbl_driver_id = rte_cryptodev_driver_id_get(
13681 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13683 if (gbl_driver_id == -1) {
13684 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
13685 return TEST_SKIPPED;
13688 return unit_test_suite_runner(&cryptodev_testsuite);
13692 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13694 gbl_driver_id = rte_cryptodev_driver_id_get(
13695 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13697 if (gbl_driver_id == -1) {
13698 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
13699 return TEST_FAILED;
13702 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13706 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13708 gbl_driver_id = rte_cryptodev_driver_id_get(
13709 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13711 if (gbl_driver_id == -1) {
13712 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13713 return TEST_SKIPPED;
13716 return unit_test_suite_runner(&cryptodev_testsuite);
13720 test_cryptodev_cpu_aesni_mb(void)
13723 enum rte_security_session_action_type at;
13725 gbl_driver_id = rte_cryptodev_driver_id_get(
13726 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13728 if (gbl_driver_id == -1) {
13729 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13730 return TEST_SKIPPED;
13733 at = gbl_action_type;
13734 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13735 rc = unit_test_suite_runner(&cryptodev_testsuite);
13736 gbl_action_type = at;
13741 test_cryptodev_openssl(void)
13743 gbl_driver_id = rte_cryptodev_driver_id_get(
13744 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13746 if (gbl_driver_id == -1) {
13747 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
13748 return TEST_SKIPPED;
13751 return unit_test_suite_runner(&cryptodev_testsuite);
13755 test_cryptodev_aesni_gcm(void)
13757 gbl_driver_id = rte_cryptodev_driver_id_get(
13758 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13760 if (gbl_driver_id == -1) {
13761 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
13762 return TEST_SKIPPED;
13765 return unit_test_suite_runner(&cryptodev_testsuite);
13769 test_cryptodev_cpu_aesni_gcm(void)
13772 enum rte_security_session_action_type at;
13774 gbl_driver_id = rte_cryptodev_driver_id_get(
13775 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13777 if (gbl_driver_id == -1) {
13778 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
13779 return TEST_SKIPPED;
13782 at = gbl_action_type;
13783 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13784 rc = unit_test_suite_runner(&cryptodev_testsuite);
13785 gbl_action_type = at;
13790 test_cryptodev_null(void)
13792 gbl_driver_id = rte_cryptodev_driver_id_get(
13793 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13795 if (gbl_driver_id == -1) {
13796 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
13797 return TEST_SKIPPED;
13800 return unit_test_suite_runner(&cryptodev_testsuite);
13804 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13806 gbl_driver_id = rte_cryptodev_driver_id_get(
13807 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13809 if (gbl_driver_id == -1) {
13810 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
13811 return TEST_SKIPPED;
13814 return unit_test_suite_runner(&cryptodev_testsuite);
13818 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13820 gbl_driver_id = rte_cryptodev_driver_id_get(
13821 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13823 if (gbl_driver_id == -1) {
13824 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
13825 return TEST_SKIPPED;
13828 return unit_test_suite_runner(&cryptodev_testsuite);
13832 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13834 gbl_driver_id = rte_cryptodev_driver_id_get(
13835 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13837 if (gbl_driver_id == -1) {
13838 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
13839 return TEST_SKIPPED;
13842 return unit_test_suite_runner(&cryptodev_testsuite);
13846 test_cryptodev_armv8(void)
13848 gbl_driver_id = rte_cryptodev_driver_id_get(
13849 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13851 if (gbl_driver_id == -1) {
13852 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
13853 return TEST_SKIPPED;
13856 return unit_test_suite_runner(&cryptodev_testsuite);
13860 test_cryptodev_mrvl(void)
13862 gbl_driver_id = rte_cryptodev_driver_id_get(
13863 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13865 if (gbl_driver_id == -1) {
13866 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
13867 return TEST_SKIPPED;
13870 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13873 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13876 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13878 gbl_driver_id = rte_cryptodev_driver_id_get(
13879 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13881 if (gbl_driver_id == -1) {
13882 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
13883 return TEST_SKIPPED;
13886 if (rte_cryptodev_driver_id_get(
13887 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13888 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13889 return TEST_SKIPPED;
13891 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13894 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13899 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13901 gbl_driver_id = rte_cryptodev_driver_id_get(
13902 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13904 if (gbl_driver_id == -1) {
13905 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
13906 return TEST_SKIPPED;
13909 return unit_test_suite_runner(&cryptodev_testsuite);
13913 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13915 gbl_driver_id = rte_cryptodev_driver_id_get(
13916 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13918 if (gbl_driver_id == -1) {
13919 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
13920 return TEST_SKIPPED;
13923 return unit_test_suite_runner(&cryptodev_testsuite);
13927 test_cryptodev_ccp(void)
13929 gbl_driver_id = rte_cryptodev_driver_id_get(
13930 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13932 if (gbl_driver_id == -1) {
13933 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
13934 return TEST_FAILED;
13937 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13941 test_cryptodev_octeontx(void)
13943 gbl_driver_id = rte_cryptodev_driver_id_get(
13944 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13945 if (gbl_driver_id == -1) {
13946 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
13947 return TEST_FAILED;
13949 return unit_test_suite_runner(&cryptodev_testsuite);
13953 test_cryptodev_octeontx2(void)
13955 gbl_driver_id = rte_cryptodev_driver_id_get(
13956 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13957 if (gbl_driver_id == -1) {
13958 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
13959 return TEST_FAILED;
13961 return unit_test_suite_runner(&cryptodev_testsuite);
13965 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13967 gbl_driver_id = rte_cryptodev_driver_id_get(
13968 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13970 if (gbl_driver_id == -1) {
13971 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
13972 return TEST_FAILED;
13975 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13979 test_cryptodev_nitrox(void)
13981 gbl_driver_id = rte_cryptodev_driver_id_get(
13982 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13984 if (gbl_driver_id == -1) {
13985 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
13986 return TEST_FAILED;
13989 return unit_test_suite_runner(&cryptodev_testsuite);
13993 test_cryptodev_bcmfs(void)
13995 gbl_driver_id = rte_cryptodev_driver_id_get(
13996 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
13998 if (gbl_driver_id == -1) {
13999 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
14000 return TEST_FAILED;
14003 return unit_test_suite_runner(&cryptodev_testsuite);
14007 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14011 gbl_driver_id = rte_cryptodev_driver_id_get(
14012 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14014 if (gbl_driver_id == -1) {
14015 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14016 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14017 "are enabled in config file to run this testsuite.\n");
14018 return TEST_SKIPPED;
14021 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14022 ret = unit_test_suite_runner(&cryptodev_testsuite);
14023 global_api_test_type = CRYPTODEV_API_TEST;
14028 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14029 test_cryptodev_qat_raw_api);
14030 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14031 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14032 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14033 test_cryptodev_cpu_aesni_mb);
14034 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14035 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14036 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14037 test_cryptodev_cpu_aesni_gcm);
14038 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14039 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14040 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14041 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14042 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14043 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14044 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14045 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14046 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14047 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14048 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14049 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14050 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14051 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14052 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);