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_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_LIB_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_LIB_SECURITY
93 struct rte_security_docsis_xform docsis_xform;
97 struct rte_cryptodev_sym_session *sess;
98 #ifdef RTE_LIB_SECURITY
99 struct rte_security_session *sec_session;
102 #ifdef RTE_LIB_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_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_WORKER(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_CRYPTO_SCHEDULER */
756 nb_devs = rte_cryptodev_count();
758 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
762 /* Create list of valid crypto devs */
763 for (i = 0; i < nb_devs; i++) {
764 rte_cryptodev_info_get(i, &info);
765 if (info.driver_id == gbl_driver_id)
766 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
769 if (ts_params->valid_dev_count < 1)
772 /* Set up all the qps on the first of the valid devices found */
774 dev_id = ts_params->valid_devs[0];
776 rte_cryptodev_info_get(dev_id, &info);
778 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
779 ts_params->conf.socket_id = SOCKET_ID_ANY;
780 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
782 unsigned int session_size =
783 rte_cryptodev_sym_get_private_session_size(dev_id);
785 #ifdef RTE_LIB_SECURITY
786 unsigned int security_session_size = rte_security_session_get_size(
787 rte_cryptodev_get_sec_ctx(dev_id));
789 if (session_size < security_session_size)
790 session_size = security_session_size;
793 * Create mempool with maximum number of sessions.
795 if (info.sym.max_nb_sessions != 0 &&
796 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
797 RTE_LOG(ERR, USER1, "Device does not support "
798 "at least %u sessions\n",
803 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
804 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
806 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
807 "session mempool allocation failed");
809 ts_params->session_priv_mpool = rte_mempool_create(
813 0, 0, NULL, NULL, NULL,
816 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
817 "session mempool allocation failed");
821 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
823 "Failed to configure cryptodev %u with %u qps",
824 dev_id, ts_params->conf.nb_queue_pairs);
826 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
827 ts_params->qp_conf.mp_session = ts_params->session_mpool;
828 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
830 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
831 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
832 dev_id, qp_id, &ts_params->qp_conf,
833 rte_cryptodev_socket_id(dev_id)),
834 "Failed to setup queue pair %u on cryptodev %u",
842 testsuite_teardown(void)
844 struct crypto_testsuite_params *ts_params = &testsuite_params;
846 if (ts_params->mbuf_pool != NULL) {
847 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
848 rte_mempool_avail_count(ts_params->mbuf_pool));
851 if (ts_params->op_mpool != NULL) {
852 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
853 rte_mempool_avail_count(ts_params->op_mpool));
856 /* Free session mempools */
857 if (ts_params->session_priv_mpool != NULL) {
858 rte_mempool_free(ts_params->session_priv_mpool);
859 ts_params->session_priv_mpool = NULL;
862 if (ts_params->session_mpool != NULL) {
863 rte_mempool_free(ts_params->session_mpool);
864 ts_params->session_mpool = NULL;
869 dev_configure_and_start(uint64_t ff_disable)
871 struct crypto_testsuite_params *ts_params = &testsuite_params;
872 struct crypto_unittest_params *ut_params = &unittest_params;
876 /* Clear unit test parameters before running test */
877 memset(ut_params, 0, sizeof(*ut_params));
879 /* Reconfigure device to default parameters */
880 ts_params->conf.socket_id = SOCKET_ID_ANY;
881 ts_params->conf.ff_disable = ff_disable;
882 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
883 ts_params->qp_conf.mp_session = ts_params->session_mpool;
884 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
886 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
888 "Failed to configure cryptodev %u",
889 ts_params->valid_devs[0]);
891 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
892 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
893 ts_params->valid_devs[0], qp_id,
895 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
896 "Failed to setup queue pair %u on cryptodev %u",
897 qp_id, ts_params->valid_devs[0]);
901 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
903 /* Start the device */
904 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
905 "Failed to start cryptodev %u",
906 ts_params->valid_devs[0]);
914 /* Configure and start the device with security feature disabled */
915 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
919 ut_setup_security(void)
921 /* Configure and start the device with no features disabled */
922 return dev_configure_and_start(0);
928 struct crypto_testsuite_params *ts_params = &testsuite_params;
929 struct crypto_unittest_params *ut_params = &unittest_params;
930 struct rte_cryptodev_stats stats;
932 /* free crypto session structure */
933 #ifdef RTE_LIB_SECURITY
934 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
935 if (ut_params->sec_session) {
936 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
937 (ts_params->valid_devs[0]),
938 ut_params->sec_session);
939 ut_params->sec_session = NULL;
944 if (ut_params->sess) {
945 rte_cryptodev_sym_session_clear(
946 ts_params->valid_devs[0],
948 rte_cryptodev_sym_session_free(ut_params->sess);
949 ut_params->sess = NULL;
953 /* free crypto operation structure */
955 rte_crypto_op_free(ut_params->op);
958 * free mbuf - both obuf and ibuf are usually the same,
959 * so check if they point at the same address is necessary,
960 * to avoid freeing the mbuf twice.
962 if (ut_params->obuf) {
963 rte_pktmbuf_free(ut_params->obuf);
964 if (ut_params->ibuf == ut_params->obuf)
968 if (ut_params->ibuf) {
969 rte_pktmbuf_free(ut_params->ibuf);
973 if (ts_params->mbuf_pool != NULL)
974 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
975 rte_mempool_avail_count(ts_params->mbuf_pool));
977 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
979 /* Stop the device */
980 rte_cryptodev_stop(ts_params->valid_devs[0]);
984 test_device_configure_invalid_dev_id(void)
986 struct crypto_testsuite_params *ts_params = &testsuite_params;
987 uint16_t dev_id, num_devs = 0;
989 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
990 "Need at least %d devices for test", 1);
992 /* valid dev_id values */
993 dev_id = ts_params->valid_devs[0];
995 /* Stop the device in case it's started so it can be configured */
996 rte_cryptodev_stop(dev_id);
998 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
999 "Failed test for rte_cryptodev_configure: "
1000 "invalid dev_num %u", dev_id);
1002 /* invalid dev_id values */
1005 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1006 "Failed test for rte_cryptodev_configure: "
1007 "invalid dev_num %u", dev_id);
1011 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1012 "Failed test for rte_cryptodev_configure:"
1013 "invalid dev_num %u", dev_id);
1015 return TEST_SUCCESS;
1019 test_device_configure_invalid_queue_pair_ids(void)
1021 struct crypto_testsuite_params *ts_params = &testsuite_params;
1022 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1024 /* Stop the device in case it's started so it can be configured */
1025 rte_cryptodev_stop(ts_params->valid_devs[0]);
1027 /* valid - max value queue pairs */
1028 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1030 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1032 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1033 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1035 /* valid - one queue pairs */
1036 ts_params->conf.nb_queue_pairs = 1;
1038 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1040 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1041 ts_params->valid_devs[0],
1042 ts_params->conf.nb_queue_pairs);
1045 /* invalid - zero queue pairs */
1046 ts_params->conf.nb_queue_pairs = 0;
1048 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1050 "Failed test for rte_cryptodev_configure, dev_id %u,"
1052 ts_params->valid_devs[0],
1053 ts_params->conf.nb_queue_pairs);
1056 /* invalid - max value supported by field queue pairs */
1057 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1059 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1061 "Failed test for rte_cryptodev_configure, dev_id %u,"
1063 ts_params->valid_devs[0],
1064 ts_params->conf.nb_queue_pairs);
1067 /* invalid - max value + 1 queue pairs */
1068 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1070 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1072 "Failed test for rte_cryptodev_configure, dev_id %u,"
1074 ts_params->valid_devs[0],
1075 ts_params->conf.nb_queue_pairs);
1077 /* revert to original testsuite value */
1078 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1080 return TEST_SUCCESS;
1084 test_queue_pair_descriptor_setup(void)
1086 struct crypto_testsuite_params *ts_params = &testsuite_params;
1087 struct rte_cryptodev_qp_conf qp_conf = {
1088 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1092 /* Stop the device in case it's started so it can be configured */
1093 rte_cryptodev_stop(ts_params->valid_devs[0]);
1095 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1097 "Failed to configure cryptodev %u",
1098 ts_params->valid_devs[0]);
1101 * Test various ring sizes on this device. memzones can't be
1102 * freed so are re-used if ring is released and re-created.
1104 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1105 qp_conf.mp_session = ts_params->session_mpool;
1106 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1108 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1109 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1110 ts_params->valid_devs[0], qp_id, &qp_conf,
1111 rte_cryptodev_socket_id(
1112 ts_params->valid_devs[0])),
1114 "rte_cryptodev_queue_pair_setup: num_inflights "
1115 "%u on qp %u on cryptodev %u",
1116 qp_conf.nb_descriptors, qp_id,
1117 ts_params->valid_devs[0]);
1120 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1122 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1123 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1124 ts_params->valid_devs[0], qp_id, &qp_conf,
1125 rte_cryptodev_socket_id(
1126 ts_params->valid_devs[0])),
1128 " rte_cryptodev_queue_pair_setup: num_inflights"
1129 " %u on qp %u on cryptodev %u",
1130 qp_conf.nb_descriptors, qp_id,
1131 ts_params->valid_devs[0]);
1134 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1136 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1137 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1138 ts_params->valid_devs[0], qp_id, &qp_conf,
1139 rte_cryptodev_socket_id(
1140 ts_params->valid_devs[0])),
1142 "rte_cryptodev_queue_pair_setup: num_inflights"
1143 " %u on qp %u on cryptodev %u",
1144 qp_conf.nb_descriptors, qp_id,
1145 ts_params->valid_devs[0]);
1148 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1150 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1151 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1152 ts_params->valid_devs[0], qp_id, &qp_conf,
1153 rte_cryptodev_socket_id(
1154 ts_params->valid_devs[0])),
1156 " rte_cryptodev_queue_pair_setup:"
1157 "num_inflights %u on qp %u on cryptodev %u",
1158 qp_conf.nb_descriptors, qp_id,
1159 ts_params->valid_devs[0]);
1162 /* test invalid queue pair id */
1163 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1165 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1167 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1168 ts_params->valid_devs[0],
1170 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1171 "Failed test for rte_cryptodev_queue_pair_setup:"
1172 "invalid qp %u on cryptodev %u",
1173 qp_id, ts_params->valid_devs[0]);
1175 qp_id = 0xffff; /*invalid*/
1177 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1178 ts_params->valid_devs[0],
1180 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1181 "Failed test for rte_cryptodev_queue_pair_setup:"
1182 "invalid qp %u on cryptodev %u",
1183 qp_id, ts_params->valid_devs[0]);
1185 return TEST_SUCCESS;
1188 /* ***** Plaintext data for tests ***** */
1190 const char catch_22_quote_1[] =
1191 "There was only one catch and that was Catch-22, which "
1192 "specified that a concern for one's safety in the face of "
1193 "dangers that were real and immediate was the process of a "
1194 "rational mind. Orr was crazy and could be grounded. All he "
1195 "had to do was ask; and as soon as he did, he would no longer "
1196 "be crazy and would have to fly more missions. Orr would be "
1197 "crazy to fly more missions and sane if he didn't, but if he "
1198 "was sane he had to fly them. If he flew them he was crazy "
1199 "and didn't have to; but if he didn't want to he was sane and "
1200 "had to. Yossarian was moved very deeply by the absolute "
1201 "simplicity of this clause of Catch-22 and let out a "
1202 "respectful whistle. \"That's some catch, that Catch-22\", he "
1203 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1205 const char catch_22_quote[] =
1206 "What a lousy earth! He wondered how many people were "
1207 "destitute that same night even in his own prosperous country, "
1208 "how many homes were shanties, how many husbands were drunk "
1209 "and wives socked, and how many children were bullied, abused, "
1210 "or abandoned. How many families hungered for food they could "
1211 "not afford to buy? How many hearts were broken? How many "
1212 "suicides would take place that same night, how many people "
1213 "would go insane? How many cockroaches and landlords would "
1214 "triumph? How many winners were losers, successes failures, "
1215 "and rich men poor men? How many wise guys were stupid? How "
1216 "many happy endings were unhappy endings? How many honest men "
1217 "were liars, brave men cowards, loyal men traitors, how many "
1218 "sainted men were corrupt, how many people in positions of "
1219 "trust had sold their souls to bodyguards, how many had never "
1220 "had souls? How many straight-and-narrow paths were crooked "
1221 "paths? How many best families were worst families and how "
1222 "many good people were bad people? When you added them all up "
1223 "and then subtracted, you might be left with only the children, "
1224 "and perhaps with Albert Einstein and an old violinist or "
1225 "sculptor somewhere.";
1227 #define QUOTE_480_BYTES (480)
1228 #define QUOTE_512_BYTES (512)
1229 #define QUOTE_768_BYTES (768)
1230 #define QUOTE_1024_BYTES (1024)
1234 /* ***** SHA1 Hash Tests ***** */
1236 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1238 static uint8_t hmac_sha1_key[] = {
1239 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1240 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1241 0xDE, 0xF4, 0xDE, 0xAD };
1243 /* ***** SHA224 Hash Tests ***** */
1245 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1248 /* ***** AES-CBC Cipher Tests ***** */
1250 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1251 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1253 static uint8_t aes_cbc_key[] = {
1254 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1255 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1257 static uint8_t aes_cbc_iv[] = {
1258 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1259 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1262 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1264 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1265 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1266 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1267 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1268 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1269 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1270 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1271 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1272 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1273 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1274 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1275 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1276 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1277 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1278 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1279 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1280 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1281 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1282 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1283 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1284 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1285 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1286 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1287 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1288 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1289 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1290 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1291 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1292 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1293 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1294 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1295 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1296 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1297 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1298 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1299 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1300 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1301 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1302 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1303 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1304 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1305 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1306 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1307 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1308 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1309 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1310 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1311 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1312 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1313 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1314 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1315 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1316 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1317 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1318 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1319 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1320 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1321 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1322 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1323 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1324 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1325 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1326 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1327 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1328 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1331 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1332 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1333 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1334 0x18, 0x8c, 0x1d, 0x32
1338 /* Multisession Vector context Test */
1339 /*Begin Session 0 */
1340 static uint8_t ms_aes_cbc_key0[] = {
1341 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1342 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1345 static uint8_t ms_aes_cbc_iv0[] = {
1346 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1347 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1350 static const uint8_t ms_aes_cbc_cipher0[] = {
1351 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1352 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1353 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1354 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1355 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1356 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1357 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1358 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1359 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1360 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1361 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1362 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1363 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1364 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1365 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1366 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1367 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1368 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1369 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1370 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1371 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1372 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1373 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1374 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1375 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1376 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1377 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1378 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1379 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1380 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1381 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1382 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1383 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1384 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1385 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1386 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1387 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1388 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1389 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1390 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1391 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1392 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1393 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1394 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1395 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1396 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1397 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1398 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1399 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1400 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1401 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1402 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1403 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1404 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1405 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1406 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1407 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1408 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1409 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1410 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1411 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1412 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1413 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1414 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1418 static uint8_t ms_hmac_key0[] = {
1419 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1420 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1421 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1422 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1423 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1424 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1425 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1426 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1429 static const uint8_t ms_hmac_digest0[] = {
1430 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1431 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1432 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1433 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1434 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1435 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1436 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1437 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1441 /* Begin session 1 */
1443 static uint8_t ms_aes_cbc_key1[] = {
1444 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1445 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1448 static uint8_t ms_aes_cbc_iv1[] = {
1449 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1450 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1453 static const uint8_t ms_aes_cbc_cipher1[] = {
1454 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1455 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1456 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1457 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1458 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1459 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1460 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1461 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1462 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1463 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1464 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1465 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1466 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1467 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1468 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1469 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1470 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1471 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1472 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1473 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1474 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1475 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1476 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1477 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1478 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1479 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1480 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1481 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1482 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1483 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1484 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1485 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1486 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1487 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1488 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1489 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1490 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1491 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1492 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1493 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1494 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1495 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1496 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1497 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1498 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1499 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1500 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1501 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1502 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1503 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1504 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1505 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1506 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1507 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1508 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1509 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1510 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1511 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1512 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1513 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1514 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1515 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1516 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1517 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1521 static uint8_t ms_hmac_key1[] = {
1522 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1523 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1524 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1525 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1526 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1527 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1528 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1529 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1532 static const uint8_t ms_hmac_digest1[] = {
1533 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1534 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1535 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1536 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1537 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1538 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1539 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1540 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1543 /* Begin Session 2 */
1544 static uint8_t ms_aes_cbc_key2[] = {
1545 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1546 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1549 static uint8_t ms_aes_cbc_iv2[] = {
1550 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1551 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1554 static const uint8_t ms_aes_cbc_cipher2[] = {
1555 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1556 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1557 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1558 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1559 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1560 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1561 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1562 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1563 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1564 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1565 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1566 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1567 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1568 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1569 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1570 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1571 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1572 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1573 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1574 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1575 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1576 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1577 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1578 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1579 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1580 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1581 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1582 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1583 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1584 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1585 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1586 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1587 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1588 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1589 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1590 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1591 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1592 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1593 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1594 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1595 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1596 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1597 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1598 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1599 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1600 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1601 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1602 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1603 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1604 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1605 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1606 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1607 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1608 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1609 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1610 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1611 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1612 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1613 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1614 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1615 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1616 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1617 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1618 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1621 static uint8_t ms_hmac_key2[] = {
1622 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1623 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1624 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1625 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1626 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1627 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1628 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1629 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1632 static const uint8_t ms_hmac_digest2[] = {
1633 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1634 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1635 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1636 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1637 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1638 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1639 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1640 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1647 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1649 struct crypto_testsuite_params *ts_params = &testsuite_params;
1650 struct crypto_unittest_params *ut_params = &unittest_params;
1652 /* Verify the capabilities */
1653 struct rte_cryptodev_sym_capability_idx cap_idx;
1654 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1655 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1656 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1659 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1660 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1661 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1665 /* Generate test mbuf data and space for digest */
1666 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1667 catch_22_quote, QUOTE_512_BYTES, 0);
1669 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1670 DIGEST_BYTE_LENGTH_SHA1);
1671 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1673 /* Setup Cipher Parameters */
1674 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1675 ut_params->cipher_xform.next = &ut_params->auth_xform;
1677 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1678 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1679 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1680 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1681 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1682 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1684 /* Setup HMAC Parameters */
1685 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1687 ut_params->auth_xform.next = NULL;
1689 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1690 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1691 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1692 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1693 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1695 ut_params->sess = rte_cryptodev_sym_session_create(
1696 ts_params->session_mpool);
1698 /* Create crypto session*/
1699 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1700 ut_params->sess, &ut_params->cipher_xform,
1701 ts_params->session_priv_mpool);
1702 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1704 /* Generate crypto op data structure */
1705 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1706 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1707 TEST_ASSERT_NOT_NULL(ut_params->op,
1708 "Failed to allocate symmetric crypto operation struct");
1710 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1712 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1714 /* set crypto operation source mbuf */
1715 sym_op->m_src = ut_params->ibuf;
1717 /* Set crypto operation authentication parameters */
1718 sym_op->auth.digest.data = ut_params->digest;
1719 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1720 ut_params->ibuf, QUOTE_512_BYTES);
1722 sym_op->auth.data.offset = 0;
1723 sym_op->auth.data.length = QUOTE_512_BYTES;
1725 /* Copy IV at the end of the crypto operation */
1726 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1727 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1729 /* Set crypto operation cipher parameters */
1730 sym_op->cipher.data.offset = 0;
1731 sym_op->cipher.data.length = QUOTE_512_BYTES;
1733 /* Process crypto operation */
1734 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1735 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1738 TEST_ASSERT_NOT_NULL(
1739 process_crypto_request(ts_params->valid_devs[0],
1741 "failed to process sym crypto op");
1743 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1744 "crypto op processing failed");
1747 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1750 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1751 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1753 "ciphertext data not as expected");
1755 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1757 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1758 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1759 gbl_driver_id == rte_cryptodev_driver_id_get(
1760 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1761 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1762 DIGEST_BYTE_LENGTH_SHA1,
1763 "Generated digest data not as expected");
1765 return TEST_SUCCESS;
1768 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1770 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1772 static uint8_t hmac_sha512_key[] = {
1773 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1774 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1775 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1776 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1777 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1778 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1779 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1780 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1782 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1783 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1784 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1785 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1786 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1787 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1788 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1789 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1790 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1795 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1796 struct crypto_unittest_params *ut_params,
1797 uint8_t *cipher_key,
1801 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1802 struct crypto_unittest_params *ut_params,
1803 struct crypto_testsuite_params *ts_params,
1804 const uint8_t *cipher,
1805 const uint8_t *digest,
1810 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1811 struct crypto_unittest_params *ut_params,
1812 uint8_t *cipher_key,
1816 /* Setup Cipher Parameters */
1817 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1818 ut_params->cipher_xform.next = NULL;
1820 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1821 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1822 ut_params->cipher_xform.cipher.key.data = cipher_key;
1823 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1824 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1825 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1827 /* Setup HMAC Parameters */
1828 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1829 ut_params->auth_xform.next = &ut_params->cipher_xform;
1831 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1832 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1833 ut_params->auth_xform.auth.key.data = hmac_key;
1834 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1835 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1837 return TEST_SUCCESS;
1842 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1843 struct crypto_unittest_params *ut_params,
1844 struct crypto_testsuite_params *ts_params,
1845 const uint8_t *cipher,
1846 const uint8_t *digest,
1849 /* Generate test mbuf data and digest */
1850 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1853 QUOTE_512_BYTES, 0);
1855 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1856 DIGEST_BYTE_LENGTH_SHA512);
1857 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1859 rte_memcpy(ut_params->digest,
1861 DIGEST_BYTE_LENGTH_SHA512);
1863 /* Generate Crypto op data structure */
1864 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1865 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1866 TEST_ASSERT_NOT_NULL(ut_params->op,
1867 "Failed to allocate symmetric crypto operation struct");
1869 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1871 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1873 /* set crypto operation source mbuf */
1874 sym_op->m_src = ut_params->ibuf;
1876 sym_op->auth.digest.data = ut_params->digest;
1877 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1878 ut_params->ibuf, QUOTE_512_BYTES);
1880 sym_op->auth.data.offset = 0;
1881 sym_op->auth.data.length = QUOTE_512_BYTES;
1883 /* Copy IV at the end of the crypto operation */
1884 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1885 iv, CIPHER_IV_LENGTH_AES_CBC);
1887 sym_op->cipher.data.offset = 0;
1888 sym_op->cipher.data.length = QUOTE_512_BYTES;
1890 /* Process crypto operation */
1891 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1892 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1894 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1895 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
1896 ut_params->op, 1, 1, 0, 0);
1898 TEST_ASSERT_NOT_NULL(
1899 process_crypto_request(ts_params->valid_devs[0],
1901 "failed to process sym crypto op");
1903 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1904 "crypto op processing failed");
1906 ut_params->obuf = ut_params->op->sym->m_src;
1909 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1910 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1913 "Plaintext data not as expected");
1916 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1917 "Digest verification failed");
1919 return TEST_SUCCESS;
1923 test_blockcipher(enum blockcipher_test_type test_type)
1925 struct crypto_testsuite_params *ts_params = &testsuite_params;
1928 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1929 ts_params->op_mpool,
1930 ts_params->session_mpool, ts_params->session_priv_mpool,
1931 ts_params->valid_devs[0],
1934 if (status == -ENOTSUP)
1937 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1939 return TEST_SUCCESS;
1943 test_AES_cipheronly_all(void)
1945 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1949 test_AES_docsis_all(void)
1951 /* Data-path service does not support DOCSIS yet */
1952 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1954 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1958 test_DES_docsis_all(void)
1960 /* Data-path service does not support DOCSIS yet */
1961 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1963 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1967 test_DES_cipheronly_all(void)
1969 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1973 test_authonly_all(void)
1975 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1979 test_AES_chain_all(void)
1981 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1985 test_3DES_chain_all(void)
1987 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1991 test_3DES_cipheronly_all(void)
1993 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1996 /* ***** SNOW 3G Tests ***** */
1998 create_wireless_algo_hash_session(uint8_t dev_id,
1999 const uint8_t *key, const uint8_t key_len,
2000 const uint8_t iv_len, const uint8_t auth_len,
2001 enum rte_crypto_auth_operation op,
2002 enum rte_crypto_auth_algorithm algo)
2004 uint8_t hash_key[key_len];
2007 struct crypto_testsuite_params *ts_params = &testsuite_params;
2008 struct crypto_unittest_params *ut_params = &unittest_params;
2010 memcpy(hash_key, key, key_len);
2012 debug_hexdump(stdout, "key:", key, key_len);
2014 /* Setup Authentication Parameters */
2015 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2016 ut_params->auth_xform.next = NULL;
2018 ut_params->auth_xform.auth.op = op;
2019 ut_params->auth_xform.auth.algo = algo;
2020 ut_params->auth_xform.auth.key.length = key_len;
2021 ut_params->auth_xform.auth.key.data = hash_key;
2022 ut_params->auth_xform.auth.digest_length = auth_len;
2023 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2024 ut_params->auth_xform.auth.iv.length = iv_len;
2025 ut_params->sess = rte_cryptodev_sym_session_create(
2026 ts_params->session_mpool);
2028 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2029 &ut_params->auth_xform,
2030 ts_params->session_priv_mpool);
2031 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2032 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2037 create_wireless_algo_cipher_session(uint8_t dev_id,
2038 enum rte_crypto_cipher_operation op,
2039 enum rte_crypto_cipher_algorithm algo,
2040 const uint8_t *key, const uint8_t key_len,
2043 uint8_t cipher_key[key_len];
2045 struct crypto_testsuite_params *ts_params = &testsuite_params;
2046 struct crypto_unittest_params *ut_params = &unittest_params;
2048 memcpy(cipher_key, key, key_len);
2050 /* Setup Cipher Parameters */
2051 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2052 ut_params->cipher_xform.next = NULL;
2054 ut_params->cipher_xform.cipher.algo = algo;
2055 ut_params->cipher_xform.cipher.op = op;
2056 ut_params->cipher_xform.cipher.key.data = cipher_key;
2057 ut_params->cipher_xform.cipher.key.length = key_len;
2058 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2059 ut_params->cipher_xform.cipher.iv.length = iv_len;
2061 debug_hexdump(stdout, "key:", key, key_len);
2063 /* Create Crypto session */
2064 ut_params->sess = rte_cryptodev_sym_session_create(
2065 ts_params->session_mpool);
2067 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2068 &ut_params->cipher_xform,
2069 ts_params->session_priv_mpool);
2070 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2071 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2076 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2077 unsigned int cipher_len,
2078 unsigned int cipher_offset)
2080 struct crypto_testsuite_params *ts_params = &testsuite_params;
2081 struct crypto_unittest_params *ut_params = &unittest_params;
2083 /* Generate Crypto op data structure */
2084 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2085 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2086 TEST_ASSERT_NOT_NULL(ut_params->op,
2087 "Failed to allocate pktmbuf offload");
2089 /* Set crypto operation data parameters */
2090 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2092 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2094 /* set crypto operation source mbuf */
2095 sym_op->m_src = ut_params->ibuf;
2098 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2100 sym_op->cipher.data.length = cipher_len;
2101 sym_op->cipher.data.offset = cipher_offset;
2106 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2107 unsigned int cipher_len,
2108 unsigned int cipher_offset)
2110 struct crypto_testsuite_params *ts_params = &testsuite_params;
2111 struct crypto_unittest_params *ut_params = &unittest_params;
2113 /* Generate Crypto op data structure */
2114 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2115 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2116 TEST_ASSERT_NOT_NULL(ut_params->op,
2117 "Failed to allocate pktmbuf offload");
2119 /* Set crypto operation data parameters */
2120 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2122 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2124 /* set crypto operation source mbuf */
2125 sym_op->m_src = ut_params->ibuf;
2126 sym_op->m_dst = ut_params->obuf;
2129 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2131 sym_op->cipher.data.length = cipher_len;
2132 sym_op->cipher.data.offset = cipher_offset;
2137 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2138 enum rte_crypto_cipher_operation cipher_op,
2139 enum rte_crypto_auth_operation auth_op,
2140 enum rte_crypto_auth_algorithm auth_algo,
2141 enum rte_crypto_cipher_algorithm cipher_algo,
2142 const uint8_t *key, uint8_t key_len,
2143 uint8_t auth_iv_len, uint8_t auth_len,
2144 uint8_t cipher_iv_len)
2147 uint8_t cipher_auth_key[key_len];
2150 struct crypto_testsuite_params *ts_params = &testsuite_params;
2151 struct crypto_unittest_params *ut_params = &unittest_params;
2153 memcpy(cipher_auth_key, key, key_len);
2155 /* Setup Authentication Parameters */
2156 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2157 ut_params->auth_xform.next = NULL;
2159 ut_params->auth_xform.auth.op = auth_op;
2160 ut_params->auth_xform.auth.algo = auth_algo;
2161 ut_params->auth_xform.auth.key.length = key_len;
2162 /* Hash key = cipher key */
2163 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2164 ut_params->auth_xform.auth.digest_length = auth_len;
2165 /* Auth IV will be after cipher IV */
2166 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2167 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2169 /* Setup Cipher Parameters */
2170 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2171 ut_params->cipher_xform.next = &ut_params->auth_xform;
2173 ut_params->cipher_xform.cipher.algo = cipher_algo;
2174 ut_params->cipher_xform.cipher.op = cipher_op;
2175 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2176 ut_params->cipher_xform.cipher.key.length = key_len;
2177 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2178 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2180 debug_hexdump(stdout, "key:", key, key_len);
2182 /* Create Crypto session*/
2183 ut_params->sess = rte_cryptodev_sym_session_create(
2184 ts_params->session_mpool);
2185 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2187 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2188 &ut_params->cipher_xform,
2189 ts_params->session_priv_mpool);
2190 if (status == -ENOTSUP)
2193 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2198 create_wireless_cipher_auth_session(uint8_t dev_id,
2199 enum rte_crypto_cipher_operation cipher_op,
2200 enum rte_crypto_auth_operation auth_op,
2201 enum rte_crypto_auth_algorithm auth_algo,
2202 enum rte_crypto_cipher_algorithm cipher_algo,
2203 const struct wireless_test_data *tdata)
2205 const uint8_t key_len = tdata->key.len;
2206 uint8_t cipher_auth_key[key_len];
2209 struct crypto_testsuite_params *ts_params = &testsuite_params;
2210 struct crypto_unittest_params *ut_params = &unittest_params;
2211 const uint8_t *key = tdata->key.data;
2212 const uint8_t auth_len = tdata->digest.len;
2213 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2214 uint8_t auth_iv_len = tdata->auth_iv.len;
2216 memcpy(cipher_auth_key, key, key_len);
2218 /* Setup Authentication Parameters */
2219 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2220 ut_params->auth_xform.next = NULL;
2222 ut_params->auth_xform.auth.op = auth_op;
2223 ut_params->auth_xform.auth.algo = auth_algo;
2224 ut_params->auth_xform.auth.key.length = key_len;
2225 /* Hash key = cipher key */
2226 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2227 ut_params->auth_xform.auth.digest_length = auth_len;
2228 /* Auth IV will be after cipher IV */
2229 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2230 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2232 /* Setup Cipher Parameters */
2233 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2234 ut_params->cipher_xform.next = &ut_params->auth_xform;
2236 ut_params->cipher_xform.cipher.algo = cipher_algo;
2237 ut_params->cipher_xform.cipher.op = cipher_op;
2238 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2239 ut_params->cipher_xform.cipher.key.length = key_len;
2240 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2241 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2244 debug_hexdump(stdout, "key:", key, key_len);
2246 /* Create Crypto session*/
2247 ut_params->sess = rte_cryptodev_sym_session_create(
2248 ts_params->session_mpool);
2250 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2251 &ut_params->cipher_xform,
2252 ts_params->session_priv_mpool);
2253 if (status == -ENOTSUP)
2256 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2257 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2262 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2263 const struct wireless_test_data *tdata)
2265 return create_wireless_cipher_auth_session(dev_id,
2266 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2267 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2268 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2272 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2273 enum rte_crypto_cipher_operation cipher_op,
2274 enum rte_crypto_auth_operation auth_op,
2275 enum rte_crypto_auth_algorithm auth_algo,
2276 enum rte_crypto_cipher_algorithm cipher_algo,
2277 const uint8_t *key, const uint8_t key_len,
2278 uint8_t auth_iv_len, uint8_t auth_len,
2279 uint8_t cipher_iv_len)
2281 uint8_t auth_cipher_key[key_len];
2283 struct crypto_testsuite_params *ts_params = &testsuite_params;
2284 struct crypto_unittest_params *ut_params = &unittest_params;
2286 memcpy(auth_cipher_key, key, key_len);
2288 /* Setup Authentication Parameters */
2289 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2290 ut_params->auth_xform.auth.op = auth_op;
2291 ut_params->auth_xform.next = &ut_params->cipher_xform;
2292 ut_params->auth_xform.auth.algo = auth_algo;
2293 ut_params->auth_xform.auth.key.length = key_len;
2294 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2295 ut_params->auth_xform.auth.digest_length = auth_len;
2296 /* Auth IV will be after cipher IV */
2297 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2298 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2300 /* Setup Cipher Parameters */
2301 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2302 ut_params->cipher_xform.next = NULL;
2303 ut_params->cipher_xform.cipher.algo = cipher_algo;
2304 ut_params->cipher_xform.cipher.op = cipher_op;
2305 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2306 ut_params->cipher_xform.cipher.key.length = key_len;
2307 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2308 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2310 debug_hexdump(stdout, "key:", key, key_len);
2312 /* Create Crypto session*/
2313 ut_params->sess = rte_cryptodev_sym_session_create(
2314 ts_params->session_mpool);
2315 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2317 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2318 ut_params->auth_xform.next = NULL;
2319 ut_params->cipher_xform.next = &ut_params->auth_xform;
2320 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2321 &ut_params->cipher_xform,
2322 ts_params->session_priv_mpool);
2325 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2326 &ut_params->auth_xform,
2327 ts_params->session_priv_mpool);
2329 if (status == -ENOTSUP)
2332 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2338 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2339 unsigned int auth_tag_len,
2340 const uint8_t *iv, unsigned int iv_len,
2341 unsigned int data_pad_len,
2342 enum rte_crypto_auth_operation op,
2343 unsigned int auth_len, unsigned int auth_offset)
2345 struct crypto_testsuite_params *ts_params = &testsuite_params;
2347 struct crypto_unittest_params *ut_params = &unittest_params;
2349 /* Generate Crypto op data structure */
2350 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2351 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2352 TEST_ASSERT_NOT_NULL(ut_params->op,
2353 "Failed to allocate pktmbuf offload");
2355 /* Set crypto operation data parameters */
2356 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2358 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2360 /* set crypto operation source mbuf */
2361 sym_op->m_src = ut_params->ibuf;
2364 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2367 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2368 ut_params->ibuf, auth_tag_len);
2370 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2371 "no room to append auth tag");
2372 ut_params->digest = sym_op->auth.digest.data;
2373 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2374 ut_params->ibuf, data_pad_len);
2375 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2376 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2378 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2380 debug_hexdump(stdout, "digest:",
2381 sym_op->auth.digest.data,
2384 sym_op->auth.data.length = auth_len;
2385 sym_op->auth.data.offset = auth_offset;
2391 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2392 enum rte_crypto_auth_operation op)
2394 struct crypto_testsuite_params *ts_params = &testsuite_params;
2395 struct crypto_unittest_params *ut_params = &unittest_params;
2397 const uint8_t *auth_tag = tdata->digest.data;
2398 const unsigned int auth_tag_len = tdata->digest.len;
2399 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2400 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2402 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2403 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2404 const uint8_t *auth_iv = tdata->auth_iv.data;
2405 const uint8_t auth_iv_len = tdata->auth_iv.len;
2406 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2407 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2409 /* Generate Crypto op data structure */
2410 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2411 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2412 TEST_ASSERT_NOT_NULL(ut_params->op,
2413 "Failed to allocate pktmbuf offload");
2414 /* Set crypto operation data parameters */
2415 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2417 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2419 /* set crypto operation source mbuf */
2420 sym_op->m_src = ut_params->ibuf;
2423 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2424 ut_params->ibuf, auth_tag_len);
2426 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2427 "no room to append auth tag");
2428 ut_params->digest = sym_op->auth.digest.data;
2429 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2430 ut_params->ibuf, data_pad_len);
2431 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2432 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2434 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2436 debug_hexdump(stdout, "digest:",
2437 sym_op->auth.digest.data,
2440 /* Copy cipher and auth IVs at the end of the crypto operation */
2441 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2443 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2444 iv_ptr += cipher_iv_len;
2445 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2447 sym_op->cipher.data.length = cipher_len;
2448 sym_op->cipher.data.offset = 0;
2449 sym_op->auth.data.length = auth_len;
2450 sym_op->auth.data.offset = 0;
2456 create_zuc_cipher_hash_generate_operation(
2457 const struct wireless_test_data *tdata)
2459 return create_wireless_cipher_hash_operation(tdata,
2460 RTE_CRYPTO_AUTH_OP_GENERATE);
2464 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2465 const unsigned auth_tag_len,
2466 const uint8_t *auth_iv, uint8_t auth_iv_len,
2467 unsigned data_pad_len,
2468 enum rte_crypto_auth_operation op,
2469 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2470 const unsigned cipher_len, const unsigned cipher_offset,
2471 const unsigned auth_len, const unsigned auth_offset)
2473 struct crypto_testsuite_params *ts_params = &testsuite_params;
2474 struct crypto_unittest_params *ut_params = &unittest_params;
2476 enum rte_crypto_cipher_algorithm cipher_algo =
2477 ut_params->cipher_xform.cipher.algo;
2478 enum rte_crypto_auth_algorithm auth_algo =
2479 ut_params->auth_xform.auth.algo;
2481 /* Generate Crypto op data structure */
2482 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2483 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2484 TEST_ASSERT_NOT_NULL(ut_params->op,
2485 "Failed to allocate pktmbuf offload");
2486 /* Set crypto operation data parameters */
2487 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2489 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2491 /* set crypto operation source mbuf */
2492 sym_op->m_src = ut_params->ibuf;
2495 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2496 ut_params->ibuf, auth_tag_len);
2498 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2499 "no room to append auth tag");
2500 ut_params->digest = sym_op->auth.digest.data;
2502 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2503 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2504 ut_params->ibuf, data_pad_len);
2506 struct rte_mbuf *m = ut_params->ibuf;
2507 unsigned int offset = data_pad_len;
2509 while (offset > m->data_len && m->next != NULL) {
2510 offset -= m->data_len;
2513 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2517 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2518 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2520 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2522 debug_hexdump(stdout, "digest:",
2523 sym_op->auth.digest.data,
2526 /* Copy cipher and auth IVs at the end of the crypto operation */
2527 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2529 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2530 iv_ptr += cipher_iv_len;
2531 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2533 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2534 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2535 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2536 sym_op->cipher.data.length = cipher_len;
2537 sym_op->cipher.data.offset = cipher_offset;
2539 sym_op->cipher.data.length = cipher_len >> 3;
2540 sym_op->cipher.data.offset = cipher_offset >> 3;
2543 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2544 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2545 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2546 sym_op->auth.data.length = auth_len;
2547 sym_op->auth.data.offset = auth_offset;
2549 sym_op->auth.data.length = auth_len >> 3;
2550 sym_op->auth.data.offset = auth_offset >> 3;
2557 create_wireless_algo_auth_cipher_operation(
2558 const uint8_t *auth_tag, unsigned int auth_tag_len,
2559 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2560 const uint8_t *auth_iv, uint8_t auth_iv_len,
2561 unsigned int data_pad_len,
2562 unsigned int cipher_len, unsigned int cipher_offset,
2563 unsigned int auth_len, unsigned int auth_offset,
2564 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2566 struct crypto_testsuite_params *ts_params = &testsuite_params;
2567 struct crypto_unittest_params *ut_params = &unittest_params;
2569 enum rte_crypto_cipher_algorithm cipher_algo =
2570 ut_params->cipher_xform.cipher.algo;
2571 enum rte_crypto_auth_algorithm auth_algo =
2572 ut_params->auth_xform.auth.algo;
2574 /* Generate Crypto op data structure */
2575 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2576 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2577 TEST_ASSERT_NOT_NULL(ut_params->op,
2578 "Failed to allocate pktmbuf offload");
2580 /* Set crypto operation data parameters */
2581 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2583 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2585 /* set crypto operation mbufs */
2586 sym_op->m_src = ut_params->ibuf;
2587 if (op_mode == OUT_OF_PLACE)
2588 sym_op->m_dst = ut_params->obuf;
2592 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2593 (op_mode == IN_PLACE ?
2594 ut_params->ibuf : ut_params->obuf),
2595 uint8_t *, data_pad_len);
2596 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2597 (op_mode == IN_PLACE ?
2598 ut_params->ibuf : ut_params->obuf),
2600 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2602 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2603 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2604 sym_op->m_src : sym_op->m_dst);
2605 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2606 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2607 sgl_buf = sgl_buf->next;
2609 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2610 uint8_t *, remaining_off);
2611 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2613 memset(sym_op->auth.digest.data, 0, remaining_off);
2614 while (sgl_buf->next != NULL) {
2615 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2616 0, rte_pktmbuf_data_len(sgl_buf));
2617 sgl_buf = sgl_buf->next;
2621 /* Copy digest for the verification */
2623 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2625 /* Copy cipher and auth IVs at the end of the crypto operation */
2626 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2627 ut_params->op, uint8_t *, IV_OFFSET);
2629 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2630 iv_ptr += cipher_iv_len;
2631 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2633 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2634 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2635 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2636 sym_op->cipher.data.length = cipher_len;
2637 sym_op->cipher.data.offset = cipher_offset;
2639 sym_op->cipher.data.length = cipher_len >> 3;
2640 sym_op->cipher.data.offset = cipher_offset >> 3;
2643 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2644 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2645 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2646 sym_op->auth.data.length = auth_len;
2647 sym_op->auth.data.offset = auth_offset;
2649 sym_op->auth.data.length = auth_len >> 3;
2650 sym_op->auth.data.offset = auth_offset >> 3;
2657 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2659 struct crypto_testsuite_params *ts_params = &testsuite_params;
2660 struct crypto_unittest_params *ut_params = &unittest_params;
2663 unsigned plaintext_pad_len;
2664 unsigned plaintext_len;
2666 struct rte_cryptodev_info dev_info;
2668 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2669 uint64_t feat_flags = dev_info.feature_flags;
2671 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2672 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2673 printf("Device doesn't support NON-Byte Aligned Data.\n");
2677 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2678 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2679 printf("Device doesn't support RAW data-path APIs.\n");
2683 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2686 /* Verify the capabilities */
2687 struct rte_cryptodev_sym_capability_idx cap_idx;
2688 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2689 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2690 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2694 /* Create SNOW 3G session */
2695 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2696 tdata->key.data, tdata->key.len,
2697 tdata->auth_iv.len, tdata->digest.len,
2698 RTE_CRYPTO_AUTH_OP_GENERATE,
2699 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2703 /* alloc mbuf and set payload */
2704 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2706 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2707 rte_pktmbuf_tailroom(ut_params->ibuf));
2709 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2710 /* Append data which is padded to a multiple of */
2711 /* the algorithms block size */
2712 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2713 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2715 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2717 /* Create SNOW 3G operation */
2718 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2719 tdata->auth_iv.data, tdata->auth_iv.len,
2720 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2721 tdata->validAuthLenInBits.len,
2726 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2727 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2728 ut_params->op, 0, 1, 1, 0);
2730 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2732 ut_params->obuf = ut_params->op->sym->m_src;
2733 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2734 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2735 + plaintext_pad_len;
2738 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2741 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2742 "SNOW 3G Generated auth tag not as expected");
2748 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2750 struct crypto_testsuite_params *ts_params = &testsuite_params;
2751 struct crypto_unittest_params *ut_params = &unittest_params;
2754 unsigned plaintext_pad_len;
2755 unsigned plaintext_len;
2757 struct rte_cryptodev_info dev_info;
2759 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2760 uint64_t feat_flags = dev_info.feature_flags;
2762 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2763 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2764 printf("Device doesn't support NON-Byte Aligned Data.\n");
2768 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2769 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2770 printf("Device doesn't support RAW data-path APIs.\n");
2774 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2777 /* Verify the capabilities */
2778 struct rte_cryptodev_sym_capability_idx cap_idx;
2779 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2780 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2781 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2785 /* Create SNOW 3G session */
2786 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2787 tdata->key.data, tdata->key.len,
2788 tdata->auth_iv.len, tdata->digest.len,
2789 RTE_CRYPTO_AUTH_OP_VERIFY,
2790 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2793 /* alloc mbuf and set payload */
2794 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2796 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2797 rte_pktmbuf_tailroom(ut_params->ibuf));
2799 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2800 /* Append data which is padded to a multiple of */
2801 /* the algorithms block size */
2802 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2803 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2805 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2807 /* Create SNOW 3G operation */
2808 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2810 tdata->auth_iv.data, tdata->auth_iv.len,
2812 RTE_CRYPTO_AUTH_OP_VERIFY,
2813 tdata->validAuthLenInBits.len,
2818 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2819 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2820 ut_params->op, 0, 1, 1, 0);
2822 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2824 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2825 ut_params->obuf = ut_params->op->sym->m_src;
2826 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2827 + plaintext_pad_len;
2830 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2839 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2841 struct crypto_testsuite_params *ts_params = &testsuite_params;
2842 struct crypto_unittest_params *ut_params = &unittest_params;
2845 unsigned plaintext_pad_len;
2846 unsigned plaintext_len;
2848 struct rte_cryptodev_info dev_info;
2850 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2851 uint64_t feat_flags = dev_info.feature_flags;
2853 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2854 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2855 printf("Device doesn't support RAW data-path APIs.\n");
2859 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2862 /* Verify the capabilities */
2863 struct rte_cryptodev_sym_capability_idx cap_idx;
2864 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2865 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2866 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2870 /* Create KASUMI session */
2871 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2872 tdata->key.data, tdata->key.len,
2873 0, tdata->digest.len,
2874 RTE_CRYPTO_AUTH_OP_GENERATE,
2875 RTE_CRYPTO_AUTH_KASUMI_F9);
2879 /* alloc mbuf and set payload */
2880 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2882 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2883 rte_pktmbuf_tailroom(ut_params->ibuf));
2885 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2886 /* Append data which is padded to a multiple of */
2887 /* the algorithms block size */
2888 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2889 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2891 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2893 /* Create KASUMI operation */
2894 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2896 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2897 tdata->plaintext.len,
2902 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2903 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2905 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2906 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2907 ut_params->op, 0, 1, 1, 0);
2909 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2912 ut_params->obuf = ut_params->op->sym->m_src;
2913 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2914 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2915 + plaintext_pad_len;
2918 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2921 DIGEST_BYTE_LENGTH_KASUMI_F9,
2922 "KASUMI Generated auth tag not as expected");
2928 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2930 struct crypto_testsuite_params *ts_params = &testsuite_params;
2931 struct crypto_unittest_params *ut_params = &unittest_params;
2934 unsigned plaintext_pad_len;
2935 unsigned plaintext_len;
2937 struct rte_cryptodev_info dev_info;
2939 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2940 uint64_t feat_flags = dev_info.feature_flags;
2942 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2943 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2944 printf("Device doesn't support RAW data-path APIs.\n");
2948 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2951 /* Verify the capabilities */
2952 struct rte_cryptodev_sym_capability_idx cap_idx;
2953 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2954 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2955 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2959 /* Create KASUMI session */
2960 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2961 tdata->key.data, tdata->key.len,
2962 0, tdata->digest.len,
2963 RTE_CRYPTO_AUTH_OP_VERIFY,
2964 RTE_CRYPTO_AUTH_KASUMI_F9);
2967 /* alloc mbuf and set payload */
2968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2971 rte_pktmbuf_tailroom(ut_params->ibuf));
2973 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2974 /* Append data which is padded to a multiple */
2975 /* of the algorithms block size */
2976 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2977 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2979 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2981 /* Create KASUMI operation */
2982 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2986 RTE_CRYPTO_AUTH_OP_VERIFY,
2987 tdata->plaintext.len,
2992 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2993 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2994 ut_params->op, 0, 1, 1, 0);
2996 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2998 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2999 ut_params->obuf = ut_params->op->sym->m_src;
3000 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3001 + plaintext_pad_len;
3004 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3013 test_snow3g_hash_generate_test_case_1(void)
3015 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3019 test_snow3g_hash_generate_test_case_2(void)
3021 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3025 test_snow3g_hash_generate_test_case_3(void)
3027 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3031 test_snow3g_hash_generate_test_case_4(void)
3033 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3037 test_snow3g_hash_generate_test_case_5(void)
3039 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3043 test_snow3g_hash_generate_test_case_6(void)
3045 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3049 test_snow3g_hash_verify_test_case_1(void)
3051 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3056 test_snow3g_hash_verify_test_case_2(void)
3058 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3062 test_snow3g_hash_verify_test_case_3(void)
3064 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3068 test_snow3g_hash_verify_test_case_4(void)
3070 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3074 test_snow3g_hash_verify_test_case_5(void)
3076 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3080 test_snow3g_hash_verify_test_case_6(void)
3082 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3086 test_kasumi_hash_generate_test_case_1(void)
3088 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3092 test_kasumi_hash_generate_test_case_2(void)
3094 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3098 test_kasumi_hash_generate_test_case_3(void)
3100 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3104 test_kasumi_hash_generate_test_case_4(void)
3106 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3110 test_kasumi_hash_generate_test_case_5(void)
3112 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3116 test_kasumi_hash_generate_test_case_6(void)
3118 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3122 test_kasumi_hash_verify_test_case_1(void)
3124 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3128 test_kasumi_hash_verify_test_case_2(void)
3130 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3134 test_kasumi_hash_verify_test_case_3(void)
3136 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3140 test_kasumi_hash_verify_test_case_4(void)
3142 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3146 test_kasumi_hash_verify_test_case_5(void)
3148 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3152 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3154 struct crypto_testsuite_params *ts_params = &testsuite_params;
3155 struct crypto_unittest_params *ut_params = &unittest_params;
3158 uint8_t *plaintext, *ciphertext;
3159 unsigned plaintext_pad_len;
3160 unsigned plaintext_len;
3161 struct rte_cryptodev_info dev_info;
3163 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3164 uint64_t feat_flags = dev_info.feature_flags;
3166 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3167 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3168 printf("Device doesn't support RAW data-path APIs.\n");
3172 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3175 /* Verify the capabilities */
3176 struct rte_cryptodev_sym_capability_idx cap_idx;
3177 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3178 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3179 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3183 /* Create KASUMI session */
3184 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3185 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3186 RTE_CRYPTO_CIPHER_KASUMI_F8,
3187 tdata->key.data, tdata->key.len,
3188 tdata->cipher_iv.len);
3192 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3194 /* Clear mbuf payload */
3195 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3196 rte_pktmbuf_tailroom(ut_params->ibuf));
3198 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3199 /* Append data which is padded to a multiple */
3200 /* of the algorithms block size */
3201 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3202 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3204 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3206 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3208 /* Create KASUMI operation */
3209 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3210 tdata->cipher_iv.len,
3211 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3212 tdata->validCipherOffsetInBits.len);
3216 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3217 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3218 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3220 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3222 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3224 ut_params->obuf = ut_params->op->sym->m_dst;
3225 if (ut_params->obuf)
3226 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3228 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3230 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3232 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3233 (tdata->validCipherOffsetInBits.len >> 3);
3235 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3237 reference_ciphertext,
3238 tdata->validCipherLenInBits.len,
3239 "KASUMI Ciphertext data not as expected");
3244 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3246 struct crypto_testsuite_params *ts_params = &testsuite_params;
3247 struct crypto_unittest_params *ut_params = &unittest_params;
3251 unsigned int plaintext_pad_len;
3252 unsigned int plaintext_len;
3254 uint8_t buffer[10000];
3255 const uint8_t *ciphertext;
3257 struct rte_cryptodev_info dev_info;
3259 /* Verify the capabilities */
3260 struct rte_cryptodev_sym_capability_idx cap_idx;
3261 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3262 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3263 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3267 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3269 uint64_t feat_flags = dev_info.feature_flags;
3271 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3272 printf("Device doesn't support in-place scatter-gather. "
3277 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3278 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3279 printf("Device doesn't support RAW data-path APIs.\n");
3283 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3286 /* Create KASUMI session */
3287 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3288 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3289 RTE_CRYPTO_CIPHER_KASUMI_F8,
3290 tdata->key.data, tdata->key.len,
3291 tdata->cipher_iv.len);
3295 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3298 /* Append data which is padded to a multiple */
3299 /* of the algorithms block size */
3300 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3302 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3303 plaintext_pad_len, 10, 0);
3305 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3307 /* Create KASUMI operation */
3308 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3309 tdata->cipher_iv.len,
3310 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3311 tdata->validCipherOffsetInBits.len);
3315 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3316 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3317 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3319 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3321 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3323 ut_params->obuf = ut_params->op->sym->m_dst;
3325 if (ut_params->obuf)
3326 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3327 plaintext_len, buffer);
3329 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3330 tdata->validCipherOffsetInBits.len >> 3,
3331 plaintext_len, buffer);
3334 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3336 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3337 (tdata->validCipherOffsetInBits.len >> 3);
3339 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3341 reference_ciphertext,
3342 tdata->validCipherLenInBits.len,
3343 "KASUMI Ciphertext data not as expected");
3348 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3350 struct crypto_testsuite_params *ts_params = &testsuite_params;
3351 struct crypto_unittest_params *ut_params = &unittest_params;
3354 uint8_t *plaintext, *ciphertext;
3355 unsigned plaintext_pad_len;
3356 unsigned plaintext_len;
3358 /* Verify the capabilities */
3359 struct rte_cryptodev_sym_capability_idx cap_idx;
3360 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3361 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3362 /* Data-path service does not support OOP */
3363 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3367 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3370 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3373 /* Create KASUMI session */
3374 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3375 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3376 RTE_CRYPTO_CIPHER_KASUMI_F8,
3377 tdata->key.data, tdata->key.len,
3378 tdata->cipher_iv.len);
3382 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3383 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3385 /* Clear mbuf payload */
3386 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3387 rte_pktmbuf_tailroom(ut_params->ibuf));
3389 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3390 /* Append data which is padded to a multiple */
3391 /* of the algorithms block size */
3392 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3393 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3395 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3396 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3398 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3400 /* Create KASUMI operation */
3401 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3402 tdata->cipher_iv.len,
3403 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3404 tdata->validCipherOffsetInBits.len);
3408 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3410 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3412 ut_params->obuf = ut_params->op->sym->m_dst;
3413 if (ut_params->obuf)
3414 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3416 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3418 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3420 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3421 (tdata->validCipherOffsetInBits.len >> 3);
3423 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3425 reference_ciphertext,
3426 tdata->validCipherLenInBits.len,
3427 "KASUMI Ciphertext data not as expected");
3432 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3434 struct crypto_testsuite_params *ts_params = &testsuite_params;
3435 struct crypto_unittest_params *ut_params = &unittest_params;
3438 unsigned int plaintext_pad_len;
3439 unsigned int plaintext_len;
3441 const uint8_t *ciphertext;
3442 uint8_t buffer[2048];
3444 struct rte_cryptodev_info dev_info;
3446 /* Verify the capabilities */
3447 struct rte_cryptodev_sym_capability_idx cap_idx;
3448 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3449 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3450 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3454 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3457 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3460 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3462 uint64_t feat_flags = dev_info.feature_flags;
3463 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3464 printf("Device doesn't support out-of-place scatter-gather "
3465 "in both input and output mbufs. "
3470 /* Create KASUMI session */
3471 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3472 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3473 RTE_CRYPTO_CIPHER_KASUMI_F8,
3474 tdata->key.data, tdata->key.len,
3475 tdata->cipher_iv.len);
3479 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3480 /* Append data which is padded to a multiple */
3481 /* of the algorithms block size */
3482 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3484 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3485 plaintext_pad_len, 10, 0);
3486 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3487 plaintext_pad_len, 3, 0);
3489 /* Append data which is padded to a multiple */
3490 /* of the algorithms block size */
3491 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3493 /* Create KASUMI operation */
3494 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3495 tdata->cipher_iv.len,
3496 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3497 tdata->validCipherOffsetInBits.len);
3501 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3503 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3505 ut_params->obuf = ut_params->op->sym->m_dst;
3506 if (ut_params->obuf)
3507 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3508 plaintext_pad_len, buffer);
3510 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3511 tdata->validCipherOffsetInBits.len >> 3,
3512 plaintext_pad_len, buffer);
3514 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3515 (tdata->validCipherOffsetInBits.len >> 3);
3517 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3519 reference_ciphertext,
3520 tdata->validCipherLenInBits.len,
3521 "KASUMI Ciphertext data not as expected");
3527 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3529 struct crypto_testsuite_params *ts_params = &testsuite_params;
3530 struct crypto_unittest_params *ut_params = &unittest_params;
3533 uint8_t *ciphertext, *plaintext;
3534 unsigned ciphertext_pad_len;
3535 unsigned ciphertext_len;
3537 /* Verify the capabilities */
3538 struct rte_cryptodev_sym_capability_idx cap_idx;
3539 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3540 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3541 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3545 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3548 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3551 /* Create KASUMI session */
3552 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3553 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3554 RTE_CRYPTO_CIPHER_KASUMI_F8,
3555 tdata->key.data, tdata->key.len,
3556 tdata->cipher_iv.len);
3560 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3561 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3563 /* Clear mbuf payload */
3564 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3565 rte_pktmbuf_tailroom(ut_params->ibuf));
3567 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3568 /* Append data which is padded to a multiple */
3569 /* of the algorithms block size */
3570 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3571 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3572 ciphertext_pad_len);
3573 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3574 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3576 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3578 /* Create KASUMI operation */
3579 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3580 tdata->cipher_iv.len,
3581 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3582 tdata->validCipherOffsetInBits.len);
3586 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3588 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3590 ut_params->obuf = ut_params->op->sym->m_dst;
3591 if (ut_params->obuf)
3592 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3594 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3596 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3598 const uint8_t *reference_plaintext = tdata->plaintext.data +
3599 (tdata->validCipherOffsetInBits.len >> 3);
3601 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3603 reference_plaintext,
3604 tdata->validCipherLenInBits.len,
3605 "KASUMI Plaintext data not as expected");
3610 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3612 struct crypto_testsuite_params *ts_params = &testsuite_params;
3613 struct crypto_unittest_params *ut_params = &unittest_params;
3616 uint8_t *ciphertext, *plaintext;
3617 unsigned ciphertext_pad_len;
3618 unsigned ciphertext_len;
3619 struct rte_cryptodev_info dev_info;
3621 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3622 uint64_t feat_flags = dev_info.feature_flags;
3624 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3625 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3626 printf("Device doesn't support RAW data-path APIs.\n");
3630 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3633 /* Verify the capabilities */
3634 struct rte_cryptodev_sym_capability_idx cap_idx;
3635 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3636 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3637 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3641 /* Create KASUMI session */
3642 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3643 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3644 RTE_CRYPTO_CIPHER_KASUMI_F8,
3645 tdata->key.data, tdata->key.len,
3646 tdata->cipher_iv.len);
3650 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3652 /* Clear mbuf payload */
3653 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3654 rte_pktmbuf_tailroom(ut_params->ibuf));
3656 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3657 /* Append data which is padded to a multiple */
3658 /* of the algorithms block size */
3659 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3660 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3661 ciphertext_pad_len);
3662 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3664 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3666 /* Create KASUMI operation */
3667 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3668 tdata->cipher_iv.len,
3669 tdata->ciphertext.len,
3670 tdata->validCipherOffsetInBits.len);
3674 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3675 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3676 ut_params->op, 1, 0, 1, 0);
3678 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3680 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3682 ut_params->obuf = ut_params->op->sym->m_dst;
3683 if (ut_params->obuf)
3684 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3686 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3688 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3690 const uint8_t *reference_plaintext = tdata->plaintext.data +
3691 (tdata->validCipherOffsetInBits.len >> 3);
3693 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3695 reference_plaintext,
3696 tdata->validCipherLenInBits.len,
3697 "KASUMI Plaintext data not as expected");
3702 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3704 struct crypto_testsuite_params *ts_params = &testsuite_params;
3705 struct crypto_unittest_params *ut_params = &unittest_params;
3708 uint8_t *plaintext, *ciphertext;
3709 unsigned plaintext_pad_len;
3710 unsigned plaintext_len;
3711 struct rte_cryptodev_info dev_info;
3713 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3714 uint64_t feat_flags = dev_info.feature_flags;
3716 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3717 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3718 printf("Device doesn't support RAW data-path APIs.\n");
3722 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3725 /* Verify the capabilities */
3726 struct rte_cryptodev_sym_capability_idx cap_idx;
3727 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3728 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3729 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3733 /* Create SNOW 3G session */
3734 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3735 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3736 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3737 tdata->key.data, tdata->key.len,
3738 tdata->cipher_iv.len);
3742 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3744 /* Clear mbuf payload */
3745 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3746 rte_pktmbuf_tailroom(ut_params->ibuf));
3748 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3749 /* Append data which is padded to a multiple of */
3750 /* the algorithms block size */
3751 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3752 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3754 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3756 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3758 /* Create SNOW 3G operation */
3759 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3760 tdata->cipher_iv.len,
3761 tdata->validCipherLenInBits.len,
3766 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3767 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3768 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3770 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3772 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3774 ut_params->obuf = ut_params->op->sym->m_dst;
3775 if (ut_params->obuf)
3776 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3778 ciphertext = plaintext;
3780 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3783 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3785 tdata->ciphertext.data,
3786 tdata->validDataLenInBits.len,
3787 "SNOW 3G Ciphertext data not as expected");
3793 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3795 struct crypto_testsuite_params *ts_params = &testsuite_params;
3796 struct crypto_unittest_params *ut_params = &unittest_params;
3797 uint8_t *plaintext, *ciphertext;
3800 unsigned plaintext_pad_len;
3801 unsigned plaintext_len;
3803 /* Verify the capabilities */
3804 struct rte_cryptodev_sym_capability_idx cap_idx;
3805 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3806 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3807 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3811 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3814 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3817 /* Create SNOW 3G session */
3818 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3819 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3820 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3821 tdata->key.data, tdata->key.len,
3822 tdata->cipher_iv.len);
3826 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3827 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3829 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3830 "Failed to allocate input buffer in mempool");
3831 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3832 "Failed to allocate output buffer in mempool");
3834 /* Clear mbuf payload */
3835 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3836 rte_pktmbuf_tailroom(ut_params->ibuf));
3838 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3839 /* Append data which is padded to a multiple of */
3840 /* the algorithms block size */
3841 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3842 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3844 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3845 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3847 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3849 /* Create SNOW 3G operation */
3850 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3851 tdata->cipher_iv.len,
3852 tdata->validCipherLenInBits.len,
3857 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3859 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3861 ut_params->obuf = ut_params->op->sym->m_dst;
3862 if (ut_params->obuf)
3863 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3865 ciphertext = plaintext;
3867 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3870 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3872 tdata->ciphertext.data,
3873 tdata->validDataLenInBits.len,
3874 "SNOW 3G Ciphertext data not as expected");
3879 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3881 struct crypto_testsuite_params *ts_params = &testsuite_params;
3882 struct crypto_unittest_params *ut_params = &unittest_params;
3885 unsigned int plaintext_pad_len;
3886 unsigned int plaintext_len;
3887 uint8_t buffer[10000];
3888 const uint8_t *ciphertext;
3890 struct rte_cryptodev_info dev_info;
3892 /* Verify the capabilities */
3893 struct rte_cryptodev_sym_capability_idx cap_idx;
3894 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3895 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3896 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3900 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3903 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3906 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3908 uint64_t feat_flags = dev_info.feature_flags;
3910 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3911 printf("Device doesn't support out-of-place scatter-gather "
3912 "in both input and output mbufs. "
3917 /* Create SNOW 3G session */
3918 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3919 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3920 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3921 tdata->key.data, tdata->key.len,
3922 tdata->cipher_iv.len);
3926 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3927 /* Append data which is padded to a multiple of */
3928 /* the algorithms block size */
3929 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3931 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3932 plaintext_pad_len, 10, 0);
3933 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3934 plaintext_pad_len, 3, 0);
3936 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3937 "Failed to allocate input buffer in mempool");
3938 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3939 "Failed to allocate output buffer in mempool");
3941 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3943 /* Create SNOW 3G operation */
3944 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3945 tdata->cipher_iv.len,
3946 tdata->validCipherLenInBits.len,
3951 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3953 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3955 ut_params->obuf = ut_params->op->sym->m_dst;
3956 if (ut_params->obuf)
3957 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3958 plaintext_len, buffer);
3960 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3961 plaintext_len, buffer);
3963 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3966 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3968 tdata->ciphertext.data,
3969 tdata->validDataLenInBits.len,
3970 "SNOW 3G Ciphertext data not as expected");
3975 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3977 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3979 uint8_t curr_byte, prev_byte;
3980 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3981 uint8_t lower_byte_mask = (1 << offset) - 1;
3984 prev_byte = buffer[0];
3985 buffer[0] >>= offset;
3987 for (i = 1; i < length_in_bytes; i++) {
3988 curr_byte = buffer[i];
3989 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3990 (curr_byte >> offset);
3991 prev_byte = curr_byte;
3996 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3998 struct crypto_testsuite_params *ts_params = &testsuite_params;
3999 struct crypto_unittest_params *ut_params = &unittest_params;
4000 uint8_t *plaintext, *ciphertext;
4002 uint32_t plaintext_len;
4003 uint32_t plaintext_pad_len;
4004 uint8_t extra_offset = 4;
4005 uint8_t *expected_ciphertext_shifted;
4006 struct rte_cryptodev_info dev_info;
4008 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4009 uint64_t feat_flags = dev_info.feature_flags;
4011 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4012 ((tdata->validDataLenInBits.len % 8) != 0)) {
4013 printf("Device doesn't support NON-Byte Aligned Data.\n");
4017 /* Verify the capabilities */
4018 struct rte_cryptodev_sym_capability_idx cap_idx;
4019 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4020 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4021 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4025 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4028 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4031 /* Create SNOW 3G session */
4032 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4033 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4034 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4035 tdata->key.data, tdata->key.len,
4036 tdata->cipher_iv.len);
4040 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4041 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4043 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4044 "Failed to allocate input buffer in mempool");
4045 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4046 "Failed to allocate output buffer in mempool");
4048 /* Clear mbuf payload */
4049 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4050 rte_pktmbuf_tailroom(ut_params->ibuf));
4052 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4054 * Append data which is padded to a
4055 * multiple of the algorithms block size
4057 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4059 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4062 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4064 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4065 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4067 #ifdef RTE_APP_TEST_DEBUG
4068 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4070 /* Create SNOW 3G operation */
4071 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4072 tdata->cipher_iv.len,
4073 tdata->validCipherLenInBits.len,
4078 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4080 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4082 ut_params->obuf = ut_params->op->sym->m_dst;
4083 if (ut_params->obuf)
4084 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4086 ciphertext = plaintext;
4088 #ifdef RTE_APP_TEST_DEBUG
4089 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4092 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4094 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4095 "failed to reserve memory for ciphertext shifted\n");
4097 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4098 ceil_byte_length(tdata->ciphertext.len));
4099 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4102 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4104 expected_ciphertext_shifted,
4105 tdata->validDataLenInBits.len,
4107 "SNOW 3G Ciphertext data not as expected");
4111 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4113 struct crypto_testsuite_params *ts_params = &testsuite_params;
4114 struct crypto_unittest_params *ut_params = &unittest_params;
4118 uint8_t *plaintext, *ciphertext;
4119 unsigned ciphertext_pad_len;
4120 unsigned ciphertext_len;
4121 struct rte_cryptodev_info dev_info;
4123 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4124 uint64_t feat_flags = dev_info.feature_flags;
4126 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4127 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4128 printf("Device doesn't support RAW data-path APIs.\n");
4132 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4135 /* Verify the capabilities */
4136 struct rte_cryptodev_sym_capability_idx cap_idx;
4137 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4138 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4139 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4143 /* Create SNOW 3G session */
4144 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4145 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4146 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4147 tdata->key.data, tdata->key.len,
4148 tdata->cipher_iv.len);
4152 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4154 /* Clear mbuf payload */
4155 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4156 rte_pktmbuf_tailroom(ut_params->ibuf));
4158 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4159 /* Append data which is padded to a multiple of */
4160 /* the algorithms block size */
4161 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4162 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4163 ciphertext_pad_len);
4164 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4166 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4168 /* Create SNOW 3G operation */
4169 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4170 tdata->cipher_iv.len,
4171 tdata->validCipherLenInBits.len,
4172 tdata->cipher.offset_bits);
4176 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4177 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4178 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4180 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4182 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4183 ut_params->obuf = ut_params->op->sym->m_dst;
4184 if (ut_params->obuf)
4185 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4187 plaintext = ciphertext;
4189 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4192 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4193 tdata->plaintext.data,
4194 tdata->validDataLenInBits.len,
4195 "SNOW 3G Plaintext data not as expected");
4199 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4201 struct crypto_testsuite_params *ts_params = &testsuite_params;
4202 struct crypto_unittest_params *ut_params = &unittest_params;
4206 uint8_t *plaintext, *ciphertext;
4207 unsigned ciphertext_pad_len;
4208 unsigned ciphertext_len;
4210 /* Verify the capabilities */
4211 struct rte_cryptodev_sym_capability_idx cap_idx;
4212 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4213 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4214 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4218 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4221 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4224 /* Create SNOW 3G session */
4225 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4226 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4227 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4228 tdata->key.data, tdata->key.len,
4229 tdata->cipher_iv.len);
4233 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4234 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4236 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4237 "Failed to allocate input buffer");
4238 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4239 "Failed to allocate output buffer");
4241 /* Clear mbuf payload */
4242 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4243 rte_pktmbuf_tailroom(ut_params->ibuf));
4245 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4246 rte_pktmbuf_tailroom(ut_params->obuf));
4248 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4249 /* Append data which is padded to a multiple of */
4250 /* the algorithms block size */
4251 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4252 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4253 ciphertext_pad_len);
4254 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4255 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4257 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4259 /* Create SNOW 3G operation */
4260 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4261 tdata->cipher_iv.len,
4262 tdata->validCipherLenInBits.len,
4267 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4269 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4270 ut_params->obuf = ut_params->op->sym->m_dst;
4271 if (ut_params->obuf)
4272 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4274 plaintext = ciphertext;
4276 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4279 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4280 tdata->plaintext.data,
4281 tdata->validDataLenInBits.len,
4282 "SNOW 3G Plaintext data not as expected");
4287 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4289 struct crypto_testsuite_params *ts_params = &testsuite_params;
4290 struct crypto_unittest_params *ut_params = &unittest_params;
4294 uint8_t *plaintext, *ciphertext;
4295 unsigned int plaintext_pad_len;
4296 unsigned int plaintext_len;
4298 struct rte_cryptodev_info dev_info;
4299 struct rte_cryptodev_sym_capability_idx cap_idx;
4301 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4302 uint64_t feat_flags = dev_info.feature_flags;
4304 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4305 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4306 (tdata->validDataLenInBits.len % 8 != 0))) {
4307 printf("Device doesn't support NON-Byte Aligned Data.\n");
4311 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4312 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4313 printf("Device doesn't support RAW data-path APIs.\n");
4317 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4320 /* Check if device supports ZUC EEA3 */
4321 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4322 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4324 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4328 /* Check if device supports ZUC EIA3 */
4329 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4330 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4332 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4336 /* Create ZUC session */
4337 retval = create_zuc_cipher_auth_encrypt_generate_session(
4338 ts_params->valid_devs[0],
4342 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4344 /* clear mbuf payload */
4345 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4346 rte_pktmbuf_tailroom(ut_params->ibuf));
4348 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4349 /* Append data which is padded to a multiple of */
4350 /* the algorithms block size */
4351 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4352 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4354 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4356 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4358 /* Create ZUC operation */
4359 retval = create_zuc_cipher_hash_generate_operation(tdata);
4363 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4364 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4365 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4367 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4369 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4370 ut_params->obuf = ut_params->op->sym->m_src;
4371 if (ut_params->obuf)
4372 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4374 ciphertext = plaintext;
4376 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4378 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4380 tdata->ciphertext.data,
4381 tdata->validDataLenInBits.len,
4382 "ZUC Ciphertext data not as expected");
4384 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4385 + plaintext_pad_len;
4388 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4392 "ZUC Generated auth tag not as expected");
4397 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4399 struct crypto_testsuite_params *ts_params = &testsuite_params;
4400 struct crypto_unittest_params *ut_params = &unittest_params;
4404 uint8_t *plaintext, *ciphertext;
4405 unsigned plaintext_pad_len;
4406 unsigned plaintext_len;
4407 struct rte_cryptodev_info dev_info;
4409 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4410 uint64_t feat_flags = dev_info.feature_flags;
4412 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4413 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4414 printf("Device doesn't support RAW data-path APIs.\n");
4418 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4421 /* Verify the capabilities */
4422 struct rte_cryptodev_sym_capability_idx cap_idx;
4423 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4424 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4425 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4428 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4429 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4430 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4434 /* Create SNOW 3G session */
4435 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4436 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4437 RTE_CRYPTO_AUTH_OP_GENERATE,
4438 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4439 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4440 tdata->key.data, tdata->key.len,
4441 tdata->auth_iv.len, tdata->digest.len,
4442 tdata->cipher_iv.len);
4445 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4447 /* clear mbuf payload */
4448 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4449 rte_pktmbuf_tailroom(ut_params->ibuf));
4451 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4452 /* Append data which is padded to a multiple of */
4453 /* the algorithms block size */
4454 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4455 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4457 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4459 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4461 /* Create SNOW 3G operation */
4462 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4463 tdata->digest.len, tdata->auth_iv.data,
4465 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4466 tdata->cipher_iv.data, tdata->cipher_iv.len,
4467 tdata->validCipherLenInBits.len,
4469 tdata->validAuthLenInBits.len,
4475 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4476 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4477 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4479 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4481 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4482 ut_params->obuf = ut_params->op->sym->m_src;
4483 if (ut_params->obuf)
4484 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4486 ciphertext = plaintext;
4488 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4490 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4492 tdata->ciphertext.data,
4493 tdata->validDataLenInBits.len,
4494 "SNOW 3G Ciphertext data not as expected");
4496 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4497 + plaintext_pad_len;
4500 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4503 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4504 "SNOW 3G Generated auth tag not as expected");
4509 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4510 uint8_t op_mode, uint8_t verify)
4512 struct crypto_testsuite_params *ts_params = &testsuite_params;
4513 struct crypto_unittest_params *ut_params = &unittest_params;
4517 uint8_t *plaintext = NULL, *ciphertext = NULL;
4518 unsigned int plaintext_pad_len;
4519 unsigned int plaintext_len;
4520 unsigned int ciphertext_pad_len;
4521 unsigned int ciphertext_len;
4523 struct rte_cryptodev_info dev_info;
4525 /* Verify the capabilities */
4526 struct rte_cryptodev_sym_capability_idx cap_idx;
4527 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4528 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4529 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4532 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4533 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4534 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4538 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4541 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4543 uint64_t feat_flags = dev_info.feature_flags;
4545 if (op_mode == OUT_OF_PLACE) {
4546 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4547 printf("Device doesn't support digest encrypted.\n");
4550 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4554 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4555 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4556 printf("Device doesn't support RAW data-path APIs.\n");
4560 /* Create SNOW 3G session */
4561 retval = create_wireless_algo_auth_cipher_session(
4562 ts_params->valid_devs[0],
4563 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4564 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4565 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4566 : RTE_CRYPTO_AUTH_OP_GENERATE),
4567 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4568 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4569 tdata->key.data, tdata->key.len,
4570 tdata->auth_iv.len, tdata->digest.len,
4571 tdata->cipher_iv.len);
4576 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4577 if (op_mode == OUT_OF_PLACE)
4578 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4580 /* clear mbuf payload */
4581 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4582 rte_pktmbuf_tailroom(ut_params->ibuf));
4583 if (op_mode == OUT_OF_PLACE)
4584 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4585 rte_pktmbuf_tailroom(ut_params->obuf));
4587 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4588 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4589 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4590 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4593 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4594 ciphertext_pad_len);
4595 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4596 if (op_mode == OUT_OF_PLACE)
4597 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4598 debug_hexdump(stdout, "ciphertext:", ciphertext,
4601 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4603 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4604 if (op_mode == OUT_OF_PLACE)
4605 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4606 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4609 /* Create SNOW 3G operation */
4610 retval = create_wireless_algo_auth_cipher_operation(
4611 tdata->digest.data, tdata->digest.len,
4612 tdata->cipher_iv.data, tdata->cipher_iv.len,
4613 tdata->auth_iv.data, tdata->auth_iv.len,
4614 (tdata->digest.offset_bytes == 0 ?
4615 (verify ? ciphertext_pad_len : plaintext_pad_len)
4616 : tdata->digest.offset_bytes),
4617 tdata->validCipherLenInBits.len,
4618 tdata->cipher.offset_bits,
4619 tdata->validAuthLenInBits.len,
4620 tdata->auth.offset_bits,
4621 op_mode, 0, verify);
4626 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4627 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4628 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4630 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4633 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4635 ut_params->obuf = (op_mode == IN_PLACE ?
4636 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4639 if (ut_params->obuf)
4640 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4643 plaintext = ciphertext +
4644 (tdata->cipher.offset_bits >> 3);
4646 debug_hexdump(stdout, "plaintext:", plaintext,
4647 (tdata->plaintext.len >> 3) - tdata->digest.len);
4648 debug_hexdump(stdout, "plaintext expected:",
4649 tdata->plaintext.data,
4650 (tdata->plaintext.len >> 3) - tdata->digest.len);
4652 if (ut_params->obuf)
4653 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4656 ciphertext = plaintext;
4658 debug_hexdump(stdout, "ciphertext:", ciphertext,
4660 debug_hexdump(stdout, "ciphertext expected:",
4661 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4663 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4664 + (tdata->digest.offset_bytes == 0 ?
4665 plaintext_pad_len : tdata->digest.offset_bytes);
4667 debug_hexdump(stdout, "digest:", ut_params->digest,
4669 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4675 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4677 tdata->plaintext.data,
4678 tdata->plaintext.len >> 3,
4679 "SNOW 3G Plaintext data not as expected");
4681 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4683 tdata->ciphertext.data,
4684 tdata->validDataLenInBits.len,
4685 "SNOW 3G Ciphertext data not as expected");
4687 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4690 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4691 "SNOW 3G Generated auth tag not as expected");
4697 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4698 uint8_t op_mode, uint8_t verify)
4700 struct crypto_testsuite_params *ts_params = &testsuite_params;
4701 struct crypto_unittest_params *ut_params = &unittest_params;
4705 const uint8_t *plaintext = NULL;
4706 const uint8_t *ciphertext = NULL;
4707 const uint8_t *digest = NULL;
4708 unsigned int plaintext_pad_len;
4709 unsigned int plaintext_len;
4710 unsigned int ciphertext_pad_len;
4711 unsigned int ciphertext_len;
4712 uint8_t buffer[10000];
4713 uint8_t digest_buffer[10000];
4715 struct rte_cryptodev_info dev_info;
4717 /* Verify the capabilities */
4718 struct rte_cryptodev_sym_capability_idx cap_idx;
4719 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4720 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4721 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4724 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4725 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4726 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4730 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4733 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4735 uint64_t feat_flags = dev_info.feature_flags;
4737 if (op_mode == IN_PLACE) {
4738 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4739 printf("Device doesn't support in-place scatter-gather "
4740 "in both input and output mbufs.\n");
4743 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4744 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4745 printf("Device doesn't support RAW data-path APIs.\n");
4749 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4751 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4752 printf("Device doesn't support out-of-place scatter-gather "
4753 "in both input and output mbufs.\n");
4756 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4757 printf("Device doesn't support digest encrypted.\n");
4762 /* Create SNOW 3G session */
4763 retval = create_wireless_algo_auth_cipher_session(
4764 ts_params->valid_devs[0],
4765 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4766 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4767 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4768 : RTE_CRYPTO_AUTH_OP_GENERATE),
4769 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4770 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4771 tdata->key.data, tdata->key.len,
4772 tdata->auth_iv.len, tdata->digest.len,
4773 tdata->cipher_iv.len);
4778 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4779 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4780 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4781 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4783 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4784 plaintext_pad_len, 15, 0);
4785 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4786 "Failed to allocate input buffer in mempool");
4788 if (op_mode == OUT_OF_PLACE) {
4789 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4790 plaintext_pad_len, 15, 0);
4791 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4792 "Failed to allocate output buffer in mempool");
4796 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4797 tdata->ciphertext.data);
4798 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4799 ciphertext_len, buffer);
4800 debug_hexdump(stdout, "ciphertext:", ciphertext,
4803 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4804 tdata->plaintext.data);
4805 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4806 plaintext_len, buffer);
4807 debug_hexdump(stdout, "plaintext:", plaintext,
4810 memset(buffer, 0, sizeof(buffer));
4812 /* Create SNOW 3G operation */
4813 retval = create_wireless_algo_auth_cipher_operation(
4814 tdata->digest.data, tdata->digest.len,
4815 tdata->cipher_iv.data, tdata->cipher_iv.len,
4816 tdata->auth_iv.data, tdata->auth_iv.len,
4817 (tdata->digest.offset_bytes == 0 ?
4818 (verify ? ciphertext_pad_len : plaintext_pad_len)
4819 : tdata->digest.offset_bytes),
4820 tdata->validCipherLenInBits.len,
4821 tdata->cipher.offset_bits,
4822 tdata->validAuthLenInBits.len,
4823 tdata->auth.offset_bits,
4824 op_mode, 1, verify);
4829 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4830 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4831 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4833 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4836 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4838 ut_params->obuf = (op_mode == IN_PLACE ?
4839 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4842 if (ut_params->obuf)
4843 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4844 plaintext_len, buffer);
4846 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4847 plaintext_len, buffer);
4849 debug_hexdump(stdout, "plaintext:", plaintext,
4850 (tdata->plaintext.len >> 3) - tdata->digest.len);
4851 debug_hexdump(stdout, "plaintext expected:",
4852 tdata->plaintext.data,
4853 (tdata->plaintext.len >> 3) - tdata->digest.len);
4855 if (ut_params->obuf)
4856 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4857 ciphertext_len, buffer);
4859 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4860 ciphertext_len, buffer);
4862 debug_hexdump(stdout, "ciphertext:", ciphertext,
4864 debug_hexdump(stdout, "ciphertext expected:",
4865 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4867 if (ut_params->obuf)
4868 digest = rte_pktmbuf_read(ut_params->obuf,
4869 (tdata->digest.offset_bytes == 0 ?
4870 plaintext_pad_len : tdata->digest.offset_bytes),
4871 tdata->digest.len, digest_buffer);
4873 digest = rte_pktmbuf_read(ut_params->ibuf,
4874 (tdata->digest.offset_bytes == 0 ?
4875 plaintext_pad_len : tdata->digest.offset_bytes),
4876 tdata->digest.len, digest_buffer);
4878 debug_hexdump(stdout, "digest:", digest,
4880 debug_hexdump(stdout, "digest expected:",
4881 tdata->digest.data, tdata->digest.len);
4886 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4888 tdata->plaintext.data,
4889 tdata->plaintext.len >> 3,
4890 "SNOW 3G Plaintext data not as expected");
4892 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4894 tdata->ciphertext.data,
4895 tdata->validDataLenInBits.len,
4896 "SNOW 3G Ciphertext data not as expected");
4898 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4901 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4902 "SNOW 3G Generated auth tag not as expected");
4908 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4909 uint8_t op_mode, uint8_t verify)
4911 struct crypto_testsuite_params *ts_params = &testsuite_params;
4912 struct crypto_unittest_params *ut_params = &unittest_params;
4916 uint8_t *plaintext = NULL, *ciphertext = NULL;
4917 unsigned int plaintext_pad_len;
4918 unsigned int plaintext_len;
4919 unsigned int ciphertext_pad_len;
4920 unsigned int ciphertext_len;
4922 struct rte_cryptodev_info dev_info;
4924 /* Verify the capabilities */
4925 struct rte_cryptodev_sym_capability_idx cap_idx;
4926 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4927 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4928 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4931 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4932 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4933 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4937 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4939 uint64_t feat_flags = dev_info.feature_flags;
4941 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4942 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4943 printf("Device doesn't support RAW data-path APIs.\n");
4947 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4950 if (op_mode == OUT_OF_PLACE) {
4951 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4953 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4954 printf("Device doesn't support digest encrypted.\n");
4959 /* Create KASUMI session */
4960 retval = create_wireless_algo_auth_cipher_session(
4961 ts_params->valid_devs[0],
4962 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4963 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4964 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4965 : RTE_CRYPTO_AUTH_OP_GENERATE),
4966 RTE_CRYPTO_AUTH_KASUMI_F9,
4967 RTE_CRYPTO_CIPHER_KASUMI_F8,
4968 tdata->key.data, tdata->key.len,
4969 0, tdata->digest.len,
4970 tdata->cipher_iv.len);
4975 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4976 if (op_mode == OUT_OF_PLACE)
4977 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4979 /* clear mbuf payload */
4980 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4981 rte_pktmbuf_tailroom(ut_params->ibuf));
4982 if (op_mode == OUT_OF_PLACE)
4983 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4984 rte_pktmbuf_tailroom(ut_params->obuf));
4986 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4987 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4988 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4989 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4992 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4993 ciphertext_pad_len);
4994 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4995 if (op_mode == OUT_OF_PLACE)
4996 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4997 debug_hexdump(stdout, "ciphertext:", ciphertext,
5000 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5002 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5003 if (op_mode == OUT_OF_PLACE)
5004 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5005 debug_hexdump(stdout, "plaintext:", plaintext,
5009 /* Create KASUMI operation */
5010 retval = create_wireless_algo_auth_cipher_operation(
5011 tdata->digest.data, tdata->digest.len,
5012 tdata->cipher_iv.data, tdata->cipher_iv.len,
5014 (tdata->digest.offset_bytes == 0 ?
5015 (verify ? ciphertext_pad_len : plaintext_pad_len)
5016 : tdata->digest.offset_bytes),
5017 tdata->validCipherLenInBits.len,
5018 tdata->validCipherOffsetInBits.len,
5019 tdata->validAuthLenInBits.len,
5021 op_mode, 0, verify);
5026 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5027 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5028 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5030 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5033 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5035 ut_params->obuf = (op_mode == IN_PLACE ?
5036 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5040 if (ut_params->obuf)
5041 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5044 plaintext = ciphertext;
5046 debug_hexdump(stdout, "plaintext:", plaintext,
5047 (tdata->plaintext.len >> 3) - tdata->digest.len);
5048 debug_hexdump(stdout, "plaintext expected:",
5049 tdata->plaintext.data,
5050 (tdata->plaintext.len >> 3) - tdata->digest.len);
5052 if (ut_params->obuf)
5053 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5056 ciphertext = plaintext;
5058 debug_hexdump(stdout, "ciphertext:", ciphertext,
5060 debug_hexdump(stdout, "ciphertext expected:",
5061 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5063 ut_params->digest = rte_pktmbuf_mtod(
5064 ut_params->obuf, uint8_t *) +
5065 (tdata->digest.offset_bytes == 0 ?
5066 plaintext_pad_len : tdata->digest.offset_bytes);
5068 debug_hexdump(stdout, "digest:", ut_params->digest,
5070 debug_hexdump(stdout, "digest expected:",
5071 tdata->digest.data, tdata->digest.len);
5076 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5078 tdata->plaintext.data,
5079 tdata->plaintext.len >> 3,
5080 "KASUMI Plaintext data not as expected");
5082 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5084 tdata->ciphertext.data,
5085 tdata->ciphertext.len >> 3,
5086 "KASUMI Ciphertext data not as expected");
5088 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5091 DIGEST_BYTE_LENGTH_KASUMI_F9,
5092 "KASUMI Generated auth tag not as expected");
5098 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5099 uint8_t op_mode, uint8_t verify)
5101 struct crypto_testsuite_params *ts_params = &testsuite_params;
5102 struct crypto_unittest_params *ut_params = &unittest_params;
5106 const uint8_t *plaintext = NULL;
5107 const uint8_t *ciphertext = NULL;
5108 const uint8_t *digest = NULL;
5109 unsigned int plaintext_pad_len;
5110 unsigned int plaintext_len;
5111 unsigned int ciphertext_pad_len;
5112 unsigned int ciphertext_len;
5113 uint8_t buffer[10000];
5114 uint8_t digest_buffer[10000];
5116 struct rte_cryptodev_info dev_info;
5118 /* Verify the capabilities */
5119 struct rte_cryptodev_sym_capability_idx cap_idx;
5120 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5121 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5122 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5126 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5127 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5131 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5134 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5136 uint64_t feat_flags = dev_info.feature_flags;
5138 if (op_mode == IN_PLACE) {
5139 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5140 printf("Device doesn't support in-place scatter-gather "
5141 "in both input and output mbufs.\n");
5144 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5145 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5146 printf("Device doesn't support RAW data-path APIs.\n");
5150 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5152 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5153 printf("Device doesn't support out-of-place scatter-gather "
5154 "in both input and output mbufs.\n");
5157 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5158 printf("Device doesn't support digest encrypted.\n");
5163 /* Create KASUMI session */
5164 retval = create_wireless_algo_auth_cipher_session(
5165 ts_params->valid_devs[0],
5166 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5167 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5168 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5169 : RTE_CRYPTO_AUTH_OP_GENERATE),
5170 RTE_CRYPTO_AUTH_KASUMI_F9,
5171 RTE_CRYPTO_CIPHER_KASUMI_F8,
5172 tdata->key.data, tdata->key.len,
5173 0, tdata->digest.len,
5174 tdata->cipher_iv.len);
5179 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5180 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5181 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5182 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5184 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5185 plaintext_pad_len, 15, 0);
5186 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5187 "Failed to allocate input buffer in mempool");
5189 if (op_mode == OUT_OF_PLACE) {
5190 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5191 plaintext_pad_len, 15, 0);
5192 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5193 "Failed to allocate output buffer in mempool");
5197 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5198 tdata->ciphertext.data);
5199 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5200 ciphertext_len, buffer);
5201 debug_hexdump(stdout, "ciphertext:", ciphertext,
5204 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5205 tdata->plaintext.data);
5206 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5207 plaintext_len, buffer);
5208 debug_hexdump(stdout, "plaintext:", plaintext,
5211 memset(buffer, 0, sizeof(buffer));
5213 /* Create KASUMI operation */
5214 retval = create_wireless_algo_auth_cipher_operation(
5215 tdata->digest.data, tdata->digest.len,
5216 tdata->cipher_iv.data, tdata->cipher_iv.len,
5218 (tdata->digest.offset_bytes == 0 ?
5219 (verify ? ciphertext_pad_len : plaintext_pad_len)
5220 : tdata->digest.offset_bytes),
5221 tdata->validCipherLenInBits.len,
5222 tdata->validCipherOffsetInBits.len,
5223 tdata->validAuthLenInBits.len,
5225 op_mode, 1, verify);
5230 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5231 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5232 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5237 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5239 ut_params->obuf = (op_mode == IN_PLACE ?
5240 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5243 if (ut_params->obuf)
5244 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5245 plaintext_len, buffer);
5247 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5248 plaintext_len, buffer);
5250 debug_hexdump(stdout, "plaintext:", plaintext,
5251 (tdata->plaintext.len >> 3) - tdata->digest.len);
5252 debug_hexdump(stdout, "plaintext expected:",
5253 tdata->plaintext.data,
5254 (tdata->plaintext.len >> 3) - tdata->digest.len);
5256 if (ut_params->obuf)
5257 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5258 ciphertext_len, buffer);
5260 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5261 ciphertext_len, buffer);
5263 debug_hexdump(stdout, "ciphertext:", ciphertext,
5265 debug_hexdump(stdout, "ciphertext expected:",
5266 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5268 if (ut_params->obuf)
5269 digest = rte_pktmbuf_read(ut_params->obuf,
5270 (tdata->digest.offset_bytes == 0 ?
5271 plaintext_pad_len : tdata->digest.offset_bytes),
5272 tdata->digest.len, digest_buffer);
5274 digest = rte_pktmbuf_read(ut_params->ibuf,
5275 (tdata->digest.offset_bytes == 0 ?
5276 plaintext_pad_len : tdata->digest.offset_bytes),
5277 tdata->digest.len, digest_buffer);
5279 debug_hexdump(stdout, "digest:", digest,
5281 debug_hexdump(stdout, "digest expected:",
5282 tdata->digest.data, tdata->digest.len);
5287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5289 tdata->plaintext.data,
5290 tdata->plaintext.len >> 3,
5291 "KASUMI Plaintext data not as expected");
5293 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5295 tdata->ciphertext.data,
5296 tdata->validDataLenInBits.len,
5297 "KASUMI Ciphertext data not as expected");
5299 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5302 DIGEST_BYTE_LENGTH_KASUMI_F9,
5303 "KASUMI Generated auth tag not as expected");
5309 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5311 struct crypto_testsuite_params *ts_params = &testsuite_params;
5312 struct crypto_unittest_params *ut_params = &unittest_params;
5316 uint8_t *plaintext, *ciphertext;
5317 unsigned plaintext_pad_len;
5318 unsigned plaintext_len;
5319 struct rte_cryptodev_info dev_info;
5321 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5322 uint64_t feat_flags = dev_info.feature_flags;
5324 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5325 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5326 printf("Device doesn't support RAW data-path APIs.\n");
5330 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5333 /* Verify the capabilities */
5334 struct rte_cryptodev_sym_capability_idx cap_idx;
5335 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5336 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5337 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5340 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5341 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5342 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5346 /* Create KASUMI session */
5347 retval = create_wireless_algo_cipher_auth_session(
5348 ts_params->valid_devs[0],
5349 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5350 RTE_CRYPTO_AUTH_OP_GENERATE,
5351 RTE_CRYPTO_AUTH_KASUMI_F9,
5352 RTE_CRYPTO_CIPHER_KASUMI_F8,
5353 tdata->key.data, tdata->key.len,
5354 0, tdata->digest.len,
5355 tdata->cipher_iv.len);
5359 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5361 /* clear mbuf payload */
5362 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5363 rte_pktmbuf_tailroom(ut_params->ibuf));
5365 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5366 /* Append data which is padded to a multiple of */
5367 /* the algorithms block size */
5368 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5369 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5371 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5373 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5375 /* Create KASUMI operation */
5376 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5377 tdata->digest.len, NULL, 0,
5378 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5379 tdata->cipher_iv.data, tdata->cipher_iv.len,
5380 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5381 tdata->validCipherOffsetInBits.len,
5382 tdata->validAuthLenInBits.len,
5388 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5389 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5390 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5392 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5394 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5396 if (ut_params->op->sym->m_dst)
5397 ut_params->obuf = ut_params->op->sym->m_dst;
5399 ut_params->obuf = ut_params->op->sym->m_src;
5401 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5402 tdata->validCipherOffsetInBits.len >> 3);
5404 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5405 + plaintext_pad_len;
5407 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5408 (tdata->validCipherOffsetInBits.len >> 3);
5410 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5412 reference_ciphertext,
5413 tdata->validCipherLenInBits.len,
5414 "KASUMI Ciphertext data not as expected");
5417 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5420 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5421 "KASUMI Generated auth tag not as expected");
5426 test_zuc_encryption(const struct wireless_test_data *tdata)
5428 struct crypto_testsuite_params *ts_params = &testsuite_params;
5429 struct crypto_unittest_params *ut_params = &unittest_params;
5432 uint8_t *plaintext, *ciphertext;
5433 unsigned plaintext_pad_len;
5434 unsigned plaintext_len;
5435 struct rte_cryptodev_info dev_info;
5437 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5438 uint64_t feat_flags = dev_info.feature_flags;
5440 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5441 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5442 printf("Device doesn't support RAW data-path APIs.\n");
5446 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5449 struct rte_cryptodev_sym_capability_idx cap_idx;
5451 /* Check if device supports ZUC EEA3 */
5452 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5453 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5455 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5459 /* Create ZUC session */
5460 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5461 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5462 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5463 tdata->key.data, tdata->key.len,
5464 tdata->cipher_iv.len);
5468 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5470 /* Clear mbuf payload */
5471 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5472 rte_pktmbuf_tailroom(ut_params->ibuf));
5474 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5475 /* Append data which is padded to a multiple */
5476 /* of the algorithms block size */
5477 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5478 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5480 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5482 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5484 /* Create ZUC operation */
5485 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5486 tdata->cipher_iv.len,
5487 tdata->plaintext.len,
5492 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5493 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5494 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5496 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5498 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5500 ut_params->obuf = ut_params->op->sym->m_dst;
5501 if (ut_params->obuf)
5502 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5504 ciphertext = plaintext;
5506 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5509 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5511 tdata->ciphertext.data,
5512 tdata->validCipherLenInBits.len,
5513 "ZUC Ciphertext data not as expected");
5518 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5520 struct crypto_testsuite_params *ts_params = &testsuite_params;
5521 struct crypto_unittest_params *ut_params = &unittest_params;
5525 unsigned int plaintext_pad_len;
5526 unsigned int plaintext_len;
5527 const uint8_t *ciphertext;
5528 uint8_t ciphertext_buffer[2048];
5529 struct rte_cryptodev_info dev_info;
5531 struct rte_cryptodev_sym_capability_idx cap_idx;
5533 /* Check if device supports ZUC EEA3 */
5534 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5535 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5537 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5541 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5544 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5546 uint64_t feat_flags = dev_info.feature_flags;
5548 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5549 printf("Device doesn't support in-place scatter-gather. "
5554 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5555 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5556 printf("Device doesn't support RAW data-path APIs.\n");
5560 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5562 /* Append data which is padded to a multiple */
5563 /* of the algorithms block size */
5564 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5566 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5567 plaintext_pad_len, 10, 0);
5569 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5570 tdata->plaintext.data);
5572 /* Create ZUC session */
5573 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5574 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5575 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5576 tdata->key.data, tdata->key.len,
5577 tdata->cipher_iv.len);
5581 /* Clear mbuf payload */
5583 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5585 /* Create ZUC operation */
5586 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5587 tdata->cipher_iv.len, tdata->plaintext.len,
5592 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5593 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5594 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5600 ut_params->obuf = ut_params->op->sym->m_dst;
5601 if (ut_params->obuf)
5602 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5603 0, plaintext_len, ciphertext_buffer);
5605 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5606 0, plaintext_len, ciphertext_buffer);
5609 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5612 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5614 tdata->ciphertext.data,
5615 tdata->validCipherLenInBits.len,
5616 "ZUC Ciphertext data not as expected");
5622 test_zuc_authentication(const struct wireless_test_data *tdata)
5624 struct crypto_testsuite_params *ts_params = &testsuite_params;
5625 struct crypto_unittest_params *ut_params = &unittest_params;
5628 unsigned plaintext_pad_len;
5629 unsigned plaintext_len;
5632 struct rte_cryptodev_sym_capability_idx cap_idx;
5633 struct rte_cryptodev_info dev_info;
5635 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5636 uint64_t feat_flags = dev_info.feature_flags;
5638 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5639 (tdata->validAuthLenInBits.len % 8 != 0)) {
5640 printf("Device doesn't support NON-Byte Aligned Data.\n");
5644 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5645 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5646 printf("Device doesn't support RAW data-path APIs.\n");
5650 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5653 /* Check if device supports ZUC EIA3 */
5654 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5655 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5657 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5661 /* Create ZUC session */
5662 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5663 tdata->key.data, tdata->key.len,
5664 tdata->auth_iv.len, tdata->digest.len,
5665 RTE_CRYPTO_AUTH_OP_GENERATE,
5666 RTE_CRYPTO_AUTH_ZUC_EIA3);
5670 /* alloc mbuf and set payload */
5671 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5673 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5674 rte_pktmbuf_tailroom(ut_params->ibuf));
5676 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5677 /* Append data which is padded to a multiple of */
5678 /* the algorithms block size */
5679 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5680 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5682 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5684 /* Create ZUC operation */
5685 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5686 tdata->auth_iv.data, tdata->auth_iv.len,
5687 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5688 tdata->validAuthLenInBits.len,
5693 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5694 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5695 ut_params->op, 0, 1, 1, 0);
5697 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5699 ut_params->obuf = ut_params->op->sym->m_src;
5700 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5701 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5702 + plaintext_pad_len;
5705 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5709 "ZUC Generated auth tag not as expected");
5715 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5716 uint8_t op_mode, uint8_t verify)
5718 struct crypto_testsuite_params *ts_params = &testsuite_params;
5719 struct crypto_unittest_params *ut_params = &unittest_params;
5723 uint8_t *plaintext = NULL, *ciphertext = NULL;
5724 unsigned int plaintext_pad_len;
5725 unsigned int plaintext_len;
5726 unsigned int ciphertext_pad_len;
5727 unsigned int ciphertext_len;
5729 struct rte_cryptodev_info dev_info;
5730 struct rte_cryptodev_sym_capability_idx cap_idx;
5732 /* Check if device supports ZUC EIA3 */
5733 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5734 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5736 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5740 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5742 uint64_t feat_flags = dev_info.feature_flags;
5744 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5745 printf("Device doesn't support digest encrypted.\n");
5748 if (op_mode == IN_PLACE) {
5749 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5750 printf("Device doesn't support in-place scatter-gather "
5751 "in both input and output mbufs.\n");
5755 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5756 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5757 printf("Device doesn't support RAW data-path APIs.\n");
5761 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5763 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5764 printf("Device doesn't support out-of-place scatter-gather "
5765 "in both input and output mbufs.\n");
5770 /* Create ZUC session */
5771 retval = create_wireless_algo_auth_cipher_session(
5772 ts_params->valid_devs[0],
5773 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5774 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5775 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5776 : RTE_CRYPTO_AUTH_OP_GENERATE),
5777 RTE_CRYPTO_AUTH_ZUC_EIA3,
5778 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5779 tdata->key.data, tdata->key.len,
5780 tdata->auth_iv.len, tdata->digest.len,
5781 tdata->cipher_iv.len);
5786 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5787 if (op_mode == OUT_OF_PLACE)
5788 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5790 /* clear mbuf payload */
5791 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5792 rte_pktmbuf_tailroom(ut_params->ibuf));
5793 if (op_mode == OUT_OF_PLACE)
5794 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5795 rte_pktmbuf_tailroom(ut_params->obuf));
5797 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5798 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5799 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5800 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5803 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5804 ciphertext_pad_len);
5805 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5806 if (op_mode == OUT_OF_PLACE)
5807 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5808 debug_hexdump(stdout, "ciphertext:", ciphertext,
5811 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5813 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5814 if (op_mode == OUT_OF_PLACE)
5815 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5816 debug_hexdump(stdout, "plaintext:", plaintext,
5820 /* Create ZUC operation */
5821 retval = create_wireless_algo_auth_cipher_operation(
5822 tdata->digest.data, tdata->digest.len,
5823 tdata->cipher_iv.data, tdata->cipher_iv.len,
5824 tdata->auth_iv.data, tdata->auth_iv.len,
5825 (tdata->digest.offset_bytes == 0 ?
5826 (verify ? ciphertext_pad_len : plaintext_pad_len)
5827 : tdata->digest.offset_bytes),
5828 tdata->validCipherLenInBits.len,
5829 tdata->validCipherOffsetInBits.len,
5830 tdata->validAuthLenInBits.len,
5832 op_mode, 0, verify);
5837 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5838 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5839 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5841 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5844 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5846 ut_params->obuf = (op_mode == IN_PLACE ?
5847 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5851 if (ut_params->obuf)
5852 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5855 plaintext = ciphertext;
5857 debug_hexdump(stdout, "plaintext:", plaintext,
5858 (tdata->plaintext.len >> 3) - tdata->digest.len);
5859 debug_hexdump(stdout, "plaintext expected:",
5860 tdata->plaintext.data,
5861 (tdata->plaintext.len >> 3) - tdata->digest.len);
5863 if (ut_params->obuf)
5864 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5867 ciphertext = plaintext;
5869 debug_hexdump(stdout, "ciphertext:", ciphertext,
5871 debug_hexdump(stdout, "ciphertext expected:",
5872 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5874 ut_params->digest = rte_pktmbuf_mtod(
5875 ut_params->obuf, uint8_t *) +
5876 (tdata->digest.offset_bytes == 0 ?
5877 plaintext_pad_len : tdata->digest.offset_bytes);
5879 debug_hexdump(stdout, "digest:", ut_params->digest,
5881 debug_hexdump(stdout, "digest expected:",
5882 tdata->digest.data, tdata->digest.len);
5887 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5889 tdata->plaintext.data,
5890 tdata->plaintext.len >> 3,
5891 "ZUC Plaintext data not as expected");
5893 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5895 tdata->ciphertext.data,
5896 tdata->ciphertext.len >> 3,
5897 "ZUC Ciphertext data not as expected");
5899 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5902 DIGEST_BYTE_LENGTH_KASUMI_F9,
5903 "ZUC Generated auth tag not as expected");
5909 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5910 uint8_t op_mode, uint8_t verify)
5912 struct crypto_testsuite_params *ts_params = &testsuite_params;
5913 struct crypto_unittest_params *ut_params = &unittest_params;
5917 const uint8_t *plaintext = NULL;
5918 const uint8_t *ciphertext = NULL;
5919 const uint8_t *digest = NULL;
5920 unsigned int plaintext_pad_len;
5921 unsigned int plaintext_len;
5922 unsigned int ciphertext_pad_len;
5923 unsigned int ciphertext_len;
5924 uint8_t buffer[10000];
5925 uint8_t digest_buffer[10000];
5927 struct rte_cryptodev_info dev_info;
5928 struct rte_cryptodev_sym_capability_idx cap_idx;
5930 /* Check if device supports ZUC EIA3 */
5931 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5932 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5934 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5938 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5940 uint64_t feat_flags = dev_info.feature_flags;
5942 if (op_mode == IN_PLACE) {
5943 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5944 printf("Device doesn't support in-place scatter-gather "
5945 "in both input and output mbufs.\n");
5949 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5950 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5951 printf("Device doesn't support RAW data-path APIs.\n");
5955 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5957 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5958 printf("Device doesn't support out-of-place scatter-gather "
5959 "in both input and output mbufs.\n");
5962 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5963 printf("Device doesn't support digest encrypted.\n");
5968 /* Create ZUC session */
5969 retval = create_wireless_algo_auth_cipher_session(
5970 ts_params->valid_devs[0],
5971 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5972 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5973 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5974 : RTE_CRYPTO_AUTH_OP_GENERATE),
5975 RTE_CRYPTO_AUTH_ZUC_EIA3,
5976 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5977 tdata->key.data, tdata->key.len,
5978 tdata->auth_iv.len, tdata->digest.len,
5979 tdata->cipher_iv.len);
5984 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5985 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5986 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5987 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5989 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5990 plaintext_pad_len, 15, 0);
5991 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5992 "Failed to allocate input buffer in mempool");
5994 if (op_mode == OUT_OF_PLACE) {
5995 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5996 plaintext_pad_len, 15, 0);
5997 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5998 "Failed to allocate output buffer in mempool");
6002 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6003 tdata->ciphertext.data);
6004 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6005 ciphertext_len, buffer);
6006 debug_hexdump(stdout, "ciphertext:", ciphertext,
6009 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6010 tdata->plaintext.data);
6011 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6012 plaintext_len, buffer);
6013 debug_hexdump(stdout, "plaintext:", plaintext,
6016 memset(buffer, 0, sizeof(buffer));
6018 /* Create ZUC operation */
6019 retval = create_wireless_algo_auth_cipher_operation(
6020 tdata->digest.data, tdata->digest.len,
6021 tdata->cipher_iv.data, tdata->cipher_iv.len,
6023 (tdata->digest.offset_bytes == 0 ?
6024 (verify ? ciphertext_pad_len : plaintext_pad_len)
6025 : tdata->digest.offset_bytes),
6026 tdata->validCipherLenInBits.len,
6027 tdata->validCipherOffsetInBits.len,
6028 tdata->validAuthLenInBits.len,
6030 op_mode, 1, verify);
6035 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6036 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6037 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6039 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6042 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6044 ut_params->obuf = (op_mode == IN_PLACE ?
6045 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6048 if (ut_params->obuf)
6049 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6050 plaintext_len, buffer);
6052 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6053 plaintext_len, buffer);
6055 debug_hexdump(stdout, "plaintext:", plaintext,
6056 (tdata->plaintext.len >> 3) - tdata->digest.len);
6057 debug_hexdump(stdout, "plaintext expected:",
6058 tdata->plaintext.data,
6059 (tdata->plaintext.len >> 3) - tdata->digest.len);
6061 if (ut_params->obuf)
6062 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6063 ciphertext_len, buffer);
6065 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6066 ciphertext_len, buffer);
6068 debug_hexdump(stdout, "ciphertext:", ciphertext,
6070 debug_hexdump(stdout, "ciphertext expected:",
6071 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6073 if (ut_params->obuf)
6074 digest = rte_pktmbuf_read(ut_params->obuf,
6075 (tdata->digest.offset_bytes == 0 ?
6076 plaintext_pad_len : tdata->digest.offset_bytes),
6077 tdata->digest.len, digest_buffer);
6079 digest = rte_pktmbuf_read(ut_params->ibuf,
6080 (tdata->digest.offset_bytes == 0 ?
6081 plaintext_pad_len : tdata->digest.offset_bytes),
6082 tdata->digest.len, digest_buffer);
6084 debug_hexdump(stdout, "digest:", digest,
6086 debug_hexdump(stdout, "digest expected:",
6087 tdata->digest.data, tdata->digest.len);
6092 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6094 tdata->plaintext.data,
6095 tdata->plaintext.len >> 3,
6096 "ZUC Plaintext data not as expected");
6098 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6100 tdata->ciphertext.data,
6101 tdata->validDataLenInBits.len,
6102 "ZUC Ciphertext data not as expected");
6104 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6107 DIGEST_BYTE_LENGTH_KASUMI_F9,
6108 "ZUC Generated auth tag not as expected");
6114 test_kasumi_encryption_test_case_1(void)
6116 return test_kasumi_encryption(&kasumi_test_case_1);
6120 test_kasumi_encryption_test_case_1_sgl(void)
6122 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6126 test_kasumi_encryption_test_case_1_oop(void)
6128 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6132 test_kasumi_encryption_test_case_1_oop_sgl(void)
6134 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6138 test_kasumi_encryption_test_case_2(void)
6140 return test_kasumi_encryption(&kasumi_test_case_2);
6144 test_kasumi_encryption_test_case_3(void)
6146 return test_kasumi_encryption(&kasumi_test_case_3);
6150 test_kasumi_encryption_test_case_4(void)
6152 return test_kasumi_encryption(&kasumi_test_case_4);
6156 test_kasumi_encryption_test_case_5(void)
6158 return test_kasumi_encryption(&kasumi_test_case_5);
6162 test_kasumi_decryption_test_case_1(void)
6164 return test_kasumi_decryption(&kasumi_test_case_1);
6168 test_kasumi_decryption_test_case_1_oop(void)
6170 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6174 test_kasumi_decryption_test_case_2(void)
6176 return test_kasumi_decryption(&kasumi_test_case_2);
6180 test_kasumi_decryption_test_case_3(void)
6182 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6183 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6185 return test_kasumi_decryption(&kasumi_test_case_3);
6189 test_kasumi_decryption_test_case_4(void)
6191 return test_kasumi_decryption(&kasumi_test_case_4);
6195 test_kasumi_decryption_test_case_5(void)
6197 return test_kasumi_decryption(&kasumi_test_case_5);
6200 test_snow3g_encryption_test_case_1(void)
6202 return test_snow3g_encryption(&snow3g_test_case_1);
6206 test_snow3g_encryption_test_case_1_oop(void)
6208 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6212 test_snow3g_encryption_test_case_1_oop_sgl(void)
6214 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6219 test_snow3g_encryption_test_case_1_offset_oop(void)
6221 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6225 test_snow3g_encryption_test_case_2(void)
6227 return test_snow3g_encryption(&snow3g_test_case_2);
6231 test_snow3g_encryption_test_case_3(void)
6233 return test_snow3g_encryption(&snow3g_test_case_3);
6237 test_snow3g_encryption_test_case_4(void)
6239 return test_snow3g_encryption(&snow3g_test_case_4);
6243 test_snow3g_encryption_test_case_5(void)
6245 return test_snow3g_encryption(&snow3g_test_case_5);
6249 test_snow3g_decryption_test_case_1(void)
6251 return test_snow3g_decryption(&snow3g_test_case_1);
6255 test_snow3g_decryption_test_case_1_oop(void)
6257 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6261 test_snow3g_decryption_test_case_2(void)
6263 return test_snow3g_decryption(&snow3g_test_case_2);
6267 test_snow3g_decryption_test_case_3(void)
6269 return test_snow3g_decryption(&snow3g_test_case_3);
6273 test_snow3g_decryption_test_case_4(void)
6275 return test_snow3g_decryption(&snow3g_test_case_4);
6279 test_snow3g_decryption_test_case_5(void)
6281 return test_snow3g_decryption(&snow3g_test_case_5);
6285 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6286 * Pattern digest from snow3g_test_data must be allocated as
6287 * 4 last bytes in plaintext.
6290 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6291 struct snow3g_hash_test_data *output)
6293 if ((pattern != NULL) && (output != NULL)) {
6294 output->key.len = pattern->key.len;
6296 memcpy(output->key.data,
6297 pattern->key.data, pattern->key.len);
6299 output->auth_iv.len = pattern->auth_iv.len;
6301 memcpy(output->auth_iv.data,
6302 pattern->auth_iv.data, pattern->auth_iv.len);
6304 output->plaintext.len = pattern->plaintext.len;
6306 memcpy(output->plaintext.data,
6307 pattern->plaintext.data, pattern->plaintext.len >> 3);
6309 output->digest.len = pattern->digest.len;
6311 memcpy(output->digest.data,
6312 &pattern->plaintext.data[pattern->digest.offset_bytes],
6313 pattern->digest.len);
6315 output->validAuthLenInBits.len =
6316 pattern->validAuthLenInBits.len;
6321 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6324 test_snow3g_decryption_with_digest_test_case_1(void)
6326 struct snow3g_hash_test_data snow3g_hash_data;
6327 struct rte_cryptodev_info dev_info;
6328 struct crypto_testsuite_params *ts_params = &testsuite_params;
6330 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6331 uint64_t feat_flags = dev_info.feature_flags;
6333 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6334 printf("Device doesn't support encrypted digest operations.\n");
6339 * Function prepare data for hash veryfication test case.
6340 * Digest is allocated in 4 last bytes in plaintext, pattern.
6342 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6344 return test_snow3g_decryption(&snow3g_test_case_7) &
6345 test_snow3g_authentication_verify(&snow3g_hash_data);
6349 test_snow3g_cipher_auth_test_case_1(void)
6351 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6355 test_snow3g_auth_cipher_test_case_1(void)
6357 return test_snow3g_auth_cipher(
6358 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6362 test_snow3g_auth_cipher_test_case_2(void)
6364 return test_snow3g_auth_cipher(
6365 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6369 test_snow3g_auth_cipher_test_case_2_oop(void)
6371 return test_snow3g_auth_cipher(
6372 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6376 test_snow3g_auth_cipher_part_digest_enc(void)
6378 return test_snow3g_auth_cipher(
6379 &snow3g_auth_cipher_partial_digest_encryption,
6384 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6386 return test_snow3g_auth_cipher(
6387 &snow3g_auth_cipher_partial_digest_encryption,
6392 test_snow3g_auth_cipher_test_case_3_sgl(void)
6394 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6395 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6397 return test_snow3g_auth_cipher_sgl(
6398 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6402 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6404 return test_snow3g_auth_cipher_sgl(
6405 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6409 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6411 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6412 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6414 return test_snow3g_auth_cipher_sgl(
6415 &snow3g_auth_cipher_partial_digest_encryption,
6420 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6422 return test_snow3g_auth_cipher_sgl(
6423 &snow3g_auth_cipher_partial_digest_encryption,
6428 test_snow3g_auth_cipher_verify_test_case_1(void)
6430 return test_snow3g_auth_cipher(
6431 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6435 test_snow3g_auth_cipher_verify_test_case_2(void)
6437 return test_snow3g_auth_cipher(
6438 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6442 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6444 return test_snow3g_auth_cipher(
6445 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6449 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6451 return test_snow3g_auth_cipher(
6452 &snow3g_auth_cipher_partial_digest_encryption,
6457 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6459 return test_snow3g_auth_cipher(
6460 &snow3g_auth_cipher_partial_digest_encryption,
6465 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6467 return test_snow3g_auth_cipher_sgl(
6468 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6472 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6474 return test_snow3g_auth_cipher_sgl(
6475 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6479 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6481 return test_snow3g_auth_cipher_sgl(
6482 &snow3g_auth_cipher_partial_digest_encryption,
6487 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6489 return test_snow3g_auth_cipher_sgl(
6490 &snow3g_auth_cipher_partial_digest_encryption,
6495 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6497 return test_snow3g_auth_cipher(
6498 &snow3g_test_case_7, IN_PLACE, 0);
6502 test_kasumi_auth_cipher_test_case_1(void)
6504 return test_kasumi_auth_cipher(
6505 &kasumi_test_case_3, IN_PLACE, 0);
6509 test_kasumi_auth_cipher_test_case_2(void)
6511 return test_kasumi_auth_cipher(
6512 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6516 test_kasumi_auth_cipher_test_case_2_oop(void)
6518 return test_kasumi_auth_cipher(
6519 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6523 test_kasumi_auth_cipher_test_case_2_sgl(void)
6525 return test_kasumi_auth_cipher_sgl(
6526 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6530 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6532 return test_kasumi_auth_cipher_sgl(
6533 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6537 test_kasumi_auth_cipher_verify_test_case_1(void)
6539 return test_kasumi_auth_cipher(
6540 &kasumi_test_case_3, IN_PLACE, 1);
6544 test_kasumi_auth_cipher_verify_test_case_2(void)
6546 return test_kasumi_auth_cipher(
6547 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6551 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6553 return test_kasumi_auth_cipher(
6554 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6558 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6560 return test_kasumi_auth_cipher_sgl(
6561 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6565 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6567 return test_kasumi_auth_cipher_sgl(
6568 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6572 test_kasumi_cipher_auth_test_case_1(void)
6574 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6578 test_zuc_encryption_test_case_1(void)
6580 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6584 test_zuc_encryption_test_case_2(void)
6586 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6590 test_zuc_encryption_test_case_3(void)
6592 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6596 test_zuc_encryption_test_case_4(void)
6598 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6602 test_zuc_encryption_test_case_5(void)
6604 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6608 test_zuc_encryption_test_case_6_sgl(void)
6610 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6614 test_zuc_hash_generate_test_case_1(void)
6616 return test_zuc_authentication(&zuc_test_case_auth_1b);
6620 test_zuc_hash_generate_test_case_2(void)
6622 return test_zuc_authentication(&zuc_test_case_auth_90b);
6626 test_zuc_hash_generate_test_case_3(void)
6628 return test_zuc_authentication(&zuc_test_case_auth_577b);
6632 test_zuc_hash_generate_test_case_4(void)
6634 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6638 test_zuc_hash_generate_test_case_5(void)
6640 return test_zuc_authentication(&zuc_test_auth_5670b);
6644 test_zuc_hash_generate_test_case_6(void)
6646 return test_zuc_authentication(&zuc_test_case_auth_128b);
6650 test_zuc_hash_generate_test_case_7(void)
6652 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6656 test_zuc_hash_generate_test_case_8(void)
6658 return test_zuc_authentication(&zuc_test_case_auth_584b);
6662 test_zuc_cipher_auth_test_case_1(void)
6664 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6668 test_zuc_cipher_auth_test_case_2(void)
6670 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6674 test_zuc_auth_cipher_test_case_1(void)
6676 return test_zuc_auth_cipher(
6677 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6681 test_zuc_auth_cipher_test_case_1_oop(void)
6683 return test_zuc_auth_cipher(
6684 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6688 test_zuc_auth_cipher_test_case_1_sgl(void)
6690 return test_zuc_auth_cipher_sgl(
6691 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6695 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6697 return test_zuc_auth_cipher_sgl(
6698 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6702 test_zuc_auth_cipher_verify_test_case_1(void)
6704 return test_zuc_auth_cipher(
6705 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6709 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6711 return test_zuc_auth_cipher(
6712 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6716 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6718 return test_zuc_auth_cipher_sgl(
6719 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6723 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6725 return test_zuc_auth_cipher_sgl(
6726 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6730 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6732 uint8_t dev_id = testsuite_params.valid_devs[0];
6734 struct rte_cryptodev_sym_capability_idx cap_idx;
6736 /* Check if device supports particular cipher algorithm */
6737 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6738 cap_idx.algo.cipher = tdata->cipher_algo;
6739 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6742 /* Check if device supports particular hash algorithm */
6743 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6744 cap_idx.algo.auth = tdata->auth_algo;
6745 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6752 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6753 uint8_t op_mode, uint8_t verify)
6755 struct crypto_testsuite_params *ts_params = &testsuite_params;
6756 struct crypto_unittest_params *ut_params = &unittest_params;
6760 uint8_t *plaintext = NULL, *ciphertext = NULL;
6761 unsigned int plaintext_pad_len;
6762 unsigned int plaintext_len;
6763 unsigned int ciphertext_pad_len;
6764 unsigned int ciphertext_len;
6766 struct rte_cryptodev_info dev_info;
6767 struct rte_crypto_op *op;
6769 /* Check if device supports particular algorithms separately */
6770 if (test_mixed_check_if_unsupported(tdata))
6772 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6775 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6777 uint64_t feat_flags = dev_info.feature_flags;
6779 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6780 printf("Device doesn't support digest encrypted.\n");
6784 /* Create the session */
6786 retval = create_wireless_algo_cipher_auth_session(
6787 ts_params->valid_devs[0],
6788 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6789 RTE_CRYPTO_AUTH_OP_VERIFY,
6792 tdata->auth_key.data, tdata->auth_key.len,
6793 tdata->auth_iv.len, tdata->digest_enc.len,
6794 tdata->cipher_iv.len);
6796 retval = create_wireless_algo_auth_cipher_session(
6797 ts_params->valid_devs[0],
6798 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6799 RTE_CRYPTO_AUTH_OP_GENERATE,
6802 tdata->auth_key.data, tdata->auth_key.len,
6803 tdata->auth_iv.len, tdata->digest_enc.len,
6804 tdata->cipher_iv.len);
6808 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6809 if (op_mode == OUT_OF_PLACE)
6810 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6812 /* clear mbuf payload */
6813 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6814 rte_pktmbuf_tailroom(ut_params->ibuf));
6815 if (op_mode == OUT_OF_PLACE) {
6817 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6818 rte_pktmbuf_tailroom(ut_params->obuf));
6821 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6822 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6823 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6824 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6827 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6828 ciphertext_pad_len);
6829 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6830 if (op_mode == OUT_OF_PLACE)
6831 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6832 debug_hexdump(stdout, "ciphertext:", ciphertext,
6835 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6837 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6838 if (op_mode == OUT_OF_PLACE)
6839 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6840 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6843 /* Create the operation */
6844 retval = create_wireless_algo_auth_cipher_operation(
6845 tdata->digest_enc.data, tdata->digest_enc.len,
6846 tdata->cipher_iv.data, tdata->cipher_iv.len,
6847 tdata->auth_iv.data, tdata->auth_iv.len,
6848 (tdata->digest_enc.offset == 0 ?
6850 : tdata->digest_enc.offset),
6851 tdata->validCipherLen.len_bits,
6852 tdata->cipher.offset_bits,
6853 tdata->validAuthLen.len_bits,
6854 tdata->auth.offset_bits,
6855 op_mode, 0, verify);
6860 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
6862 /* Check if the op failed because the device doesn't */
6863 /* support this particular combination of algorithms */
6864 if (op == NULL && ut_params->op->status ==
6865 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6866 printf("Device doesn't support this mixed combination. "
6872 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6874 ut_params->obuf = (op_mode == IN_PLACE ?
6875 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6878 if (ut_params->obuf)
6879 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6882 plaintext = ciphertext +
6883 (tdata->cipher.offset_bits >> 3);
6885 debug_hexdump(stdout, "plaintext:", plaintext,
6886 tdata->plaintext.len_bits >> 3);
6887 debug_hexdump(stdout, "plaintext expected:",
6888 tdata->plaintext.data,
6889 tdata->plaintext.len_bits >> 3);
6891 if (ut_params->obuf)
6892 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6895 ciphertext = plaintext;
6897 debug_hexdump(stdout, "ciphertext:", ciphertext,
6899 debug_hexdump(stdout, "ciphertext expected:",
6900 tdata->ciphertext.data,
6901 tdata->ciphertext.len_bits >> 3);
6903 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6904 + (tdata->digest_enc.offset == 0 ?
6905 plaintext_pad_len : tdata->digest_enc.offset);
6907 debug_hexdump(stdout, "digest:", ut_params->digest,
6908 tdata->digest_enc.len);
6909 debug_hexdump(stdout, "digest expected:",
6910 tdata->digest_enc.data,
6911 tdata->digest_enc.len);
6916 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6918 tdata->plaintext.data,
6919 tdata->plaintext.len_bits >> 3,
6920 "Plaintext data not as expected");
6922 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6924 tdata->ciphertext.data,
6925 tdata->validDataLen.len_bits,
6926 "Ciphertext data not as expected");
6928 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6930 tdata->digest_enc.data,
6931 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6932 "Generated auth tag not as expected");
6935 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6936 "crypto op processing failed");
6942 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6943 uint8_t op_mode, uint8_t verify)
6945 struct crypto_testsuite_params *ts_params = &testsuite_params;
6946 struct crypto_unittest_params *ut_params = &unittest_params;
6950 const uint8_t *plaintext = NULL;
6951 const uint8_t *ciphertext = NULL;
6952 const uint8_t *digest = NULL;
6953 unsigned int plaintext_pad_len;
6954 unsigned int plaintext_len;
6955 unsigned int ciphertext_pad_len;
6956 unsigned int ciphertext_len;
6957 uint8_t buffer[10000];
6958 uint8_t digest_buffer[10000];
6960 struct rte_cryptodev_info dev_info;
6961 struct rte_crypto_op *op;
6963 /* Check if device supports particular algorithms */
6964 if (test_mixed_check_if_unsupported(tdata))
6966 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6969 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6971 uint64_t feat_flags = dev_info.feature_flags;
6973 if (op_mode == IN_PLACE) {
6974 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6975 printf("Device doesn't support in-place scatter-gather "
6976 "in both input and output mbufs.\n");
6980 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6981 printf("Device doesn't support out-of-place scatter-gather "
6982 "in both input and output mbufs.\n");
6985 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6986 printf("Device doesn't support digest encrypted.\n");
6991 /* Create the session */
6993 retval = create_wireless_algo_cipher_auth_session(
6994 ts_params->valid_devs[0],
6995 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6996 RTE_CRYPTO_AUTH_OP_VERIFY,
6999 tdata->auth_key.data, tdata->auth_key.len,
7000 tdata->auth_iv.len, tdata->digest_enc.len,
7001 tdata->cipher_iv.len);
7003 retval = create_wireless_algo_auth_cipher_session(
7004 ts_params->valid_devs[0],
7005 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7006 RTE_CRYPTO_AUTH_OP_GENERATE,
7009 tdata->auth_key.data, tdata->auth_key.len,
7010 tdata->auth_iv.len, tdata->digest_enc.len,
7011 tdata->cipher_iv.len);
7015 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7016 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7017 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7018 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7020 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7021 ciphertext_pad_len, 15, 0);
7022 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7023 "Failed to allocate input buffer in mempool");
7025 if (op_mode == OUT_OF_PLACE) {
7026 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7027 plaintext_pad_len, 15, 0);
7028 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7029 "Failed to allocate output buffer in mempool");
7033 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7034 tdata->ciphertext.data);
7035 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7036 ciphertext_len, buffer);
7037 debug_hexdump(stdout, "ciphertext:", ciphertext,
7040 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7041 tdata->plaintext.data);
7042 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7043 plaintext_len, buffer);
7044 debug_hexdump(stdout, "plaintext:", plaintext,
7047 memset(buffer, 0, sizeof(buffer));
7049 /* Create the operation */
7050 retval = create_wireless_algo_auth_cipher_operation(
7051 tdata->digest_enc.data, tdata->digest_enc.len,
7052 tdata->cipher_iv.data, tdata->cipher_iv.len,
7053 tdata->auth_iv.data, tdata->auth_iv.len,
7054 (tdata->digest_enc.offset == 0 ?
7056 : tdata->digest_enc.offset),
7057 tdata->validCipherLen.len_bits,
7058 tdata->cipher.offset_bits,
7059 tdata->validAuthLen.len_bits,
7060 tdata->auth.offset_bits,
7061 op_mode, 1, verify);
7066 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7068 /* Check if the op failed because the device doesn't */
7069 /* support this particular combination of algorithms */
7070 if (op == NULL && ut_params->op->status ==
7071 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7072 printf("Device doesn't support this mixed combination. "
7078 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7080 ut_params->obuf = (op_mode == IN_PLACE ?
7081 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7084 if (ut_params->obuf)
7085 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7086 plaintext_len, buffer);
7088 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7089 plaintext_len, buffer);
7091 debug_hexdump(stdout, "plaintext:", plaintext,
7092 (tdata->plaintext.len_bits >> 3) -
7093 tdata->digest_enc.len);
7094 debug_hexdump(stdout, "plaintext expected:",
7095 tdata->plaintext.data,
7096 (tdata->plaintext.len_bits >> 3) -
7097 tdata->digest_enc.len);
7099 if (ut_params->obuf)
7100 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7101 ciphertext_len, buffer);
7103 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7104 ciphertext_len, buffer);
7106 debug_hexdump(stdout, "ciphertext:", ciphertext,
7108 debug_hexdump(stdout, "ciphertext expected:",
7109 tdata->ciphertext.data,
7110 tdata->ciphertext.len_bits >> 3);
7112 if (ut_params->obuf)
7113 digest = rte_pktmbuf_read(ut_params->obuf,
7114 (tdata->digest_enc.offset == 0 ?
7116 tdata->digest_enc.offset),
7117 tdata->digest_enc.len, digest_buffer);
7119 digest = rte_pktmbuf_read(ut_params->ibuf,
7120 (tdata->digest_enc.offset == 0 ?
7122 tdata->digest_enc.offset),
7123 tdata->digest_enc.len, digest_buffer);
7125 debug_hexdump(stdout, "digest:", digest,
7126 tdata->digest_enc.len);
7127 debug_hexdump(stdout, "digest expected:",
7128 tdata->digest_enc.data, tdata->digest_enc.len);
7133 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7135 tdata->plaintext.data,
7136 tdata->plaintext.len_bits >> 3,
7137 "Plaintext data not as expected");
7139 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7141 tdata->ciphertext.data,
7142 tdata->validDataLen.len_bits,
7143 "Ciphertext data not as expected");
7144 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7146 tdata->digest_enc.data,
7147 tdata->digest_enc.len,
7148 "Generated auth tag not as expected");
7151 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7152 "crypto op processing failed");
7157 /** AUTH AES CMAC + CIPHER AES CTR */
7160 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7162 return test_mixed_auth_cipher(
7163 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7167 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7169 return test_mixed_auth_cipher(
7170 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7174 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7176 return test_mixed_auth_cipher_sgl(
7177 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7181 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7183 return test_mixed_auth_cipher_sgl(
7184 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7188 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7190 return test_mixed_auth_cipher(
7191 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7195 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7197 return test_mixed_auth_cipher(
7198 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7202 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7204 return test_mixed_auth_cipher_sgl(
7205 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7209 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7211 return test_mixed_auth_cipher_sgl(
7212 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7215 /** MIXED AUTH + CIPHER */
7218 test_auth_zuc_cipher_snow_test_case_1(void)
7220 return test_mixed_auth_cipher(
7221 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7225 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7227 return test_mixed_auth_cipher(
7228 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7232 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7234 return test_mixed_auth_cipher(
7235 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7239 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7241 return test_mixed_auth_cipher(
7242 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7246 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7248 return test_mixed_auth_cipher(
7249 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7253 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7255 return test_mixed_auth_cipher(
7256 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7260 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7262 return test_mixed_auth_cipher(
7263 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7267 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7269 return test_mixed_auth_cipher(
7270 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7274 test_auth_snow_cipher_zuc_test_case_1(void)
7276 return test_mixed_auth_cipher(
7277 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7281 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7283 return test_mixed_auth_cipher(
7284 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7288 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7290 return test_mixed_auth_cipher(
7291 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7295 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7297 return test_mixed_auth_cipher(
7298 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7302 test_auth_null_cipher_snow_test_case_1(void)
7304 return test_mixed_auth_cipher(
7305 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7309 test_verify_auth_null_cipher_snow_test_case_1(void)
7311 return test_mixed_auth_cipher(
7312 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7316 test_auth_null_cipher_zuc_test_case_1(void)
7318 return test_mixed_auth_cipher(
7319 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7323 test_verify_auth_null_cipher_zuc_test_case_1(void)
7325 return test_mixed_auth_cipher(
7326 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7330 test_auth_snow_cipher_null_test_case_1(void)
7332 return test_mixed_auth_cipher(
7333 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7337 test_verify_auth_snow_cipher_null_test_case_1(void)
7339 return test_mixed_auth_cipher(
7340 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7344 test_auth_zuc_cipher_null_test_case_1(void)
7346 return test_mixed_auth_cipher(
7347 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7351 test_verify_auth_zuc_cipher_null_test_case_1(void)
7353 return test_mixed_auth_cipher(
7354 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7358 test_auth_null_cipher_aes_ctr_test_case_1(void)
7360 return test_mixed_auth_cipher(
7361 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7365 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7367 return test_mixed_auth_cipher(
7368 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7372 test_auth_aes_cmac_cipher_null_test_case_1(void)
7374 return test_mixed_auth_cipher(
7375 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7379 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7381 return test_mixed_auth_cipher(
7382 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7385 /* ***** AEAD algorithm Tests ***** */
7388 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7389 enum rte_crypto_aead_operation op,
7390 const uint8_t *key, const uint8_t key_len,
7391 const uint16_t aad_len, const uint8_t auth_len,
7394 uint8_t aead_key[key_len];
7396 struct crypto_testsuite_params *ts_params = &testsuite_params;
7397 struct crypto_unittest_params *ut_params = &unittest_params;
7399 memcpy(aead_key, key, key_len);
7401 /* Setup AEAD Parameters */
7402 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7403 ut_params->aead_xform.next = NULL;
7404 ut_params->aead_xform.aead.algo = algo;
7405 ut_params->aead_xform.aead.op = op;
7406 ut_params->aead_xform.aead.key.data = aead_key;
7407 ut_params->aead_xform.aead.key.length = key_len;
7408 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7409 ut_params->aead_xform.aead.iv.length = iv_len;
7410 ut_params->aead_xform.aead.digest_length = auth_len;
7411 ut_params->aead_xform.aead.aad_length = aad_len;
7413 debug_hexdump(stdout, "key:", key, key_len);
7415 /* Create Crypto session*/
7416 ut_params->sess = rte_cryptodev_sym_session_create(
7417 ts_params->session_mpool);
7419 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7420 &ut_params->aead_xform,
7421 ts_params->session_priv_mpool);
7423 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7429 create_aead_xform(struct rte_crypto_op *op,
7430 enum rte_crypto_aead_algorithm algo,
7431 enum rte_crypto_aead_operation aead_op,
7432 uint8_t *key, const uint8_t key_len,
7433 const uint8_t aad_len, const uint8_t auth_len,
7436 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7437 "failed to allocate space for crypto transform");
7439 struct rte_crypto_sym_op *sym_op = op->sym;
7441 /* Setup AEAD Parameters */
7442 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7443 sym_op->xform->next = NULL;
7444 sym_op->xform->aead.algo = algo;
7445 sym_op->xform->aead.op = aead_op;
7446 sym_op->xform->aead.key.data = key;
7447 sym_op->xform->aead.key.length = key_len;
7448 sym_op->xform->aead.iv.offset = IV_OFFSET;
7449 sym_op->xform->aead.iv.length = iv_len;
7450 sym_op->xform->aead.digest_length = auth_len;
7451 sym_op->xform->aead.aad_length = aad_len;
7453 debug_hexdump(stdout, "key:", key, key_len);
7459 create_aead_operation(enum rte_crypto_aead_operation op,
7460 const struct aead_test_data *tdata)
7462 struct crypto_testsuite_params *ts_params = &testsuite_params;
7463 struct crypto_unittest_params *ut_params = &unittest_params;
7465 uint8_t *plaintext, *ciphertext;
7466 unsigned int aad_pad_len, plaintext_pad_len;
7468 /* Generate Crypto op data structure */
7469 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7470 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7471 TEST_ASSERT_NOT_NULL(ut_params->op,
7472 "Failed to allocate symmetric crypto operation struct");
7474 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7476 /* Append aad data */
7477 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7478 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7479 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7481 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7482 "no room to append aad");
7484 sym_op->aead.aad.phys_addr =
7485 rte_pktmbuf_iova(ut_params->ibuf);
7486 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7487 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7488 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7491 /* Append IV at the end of the crypto operation*/
7492 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7493 uint8_t *, IV_OFFSET);
7495 /* Copy IV 1 byte after the IV pointer, according to the API */
7496 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7497 debug_hexdump(stdout, "iv:", iv_ptr,
7500 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7501 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7503 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7504 "no room to append aad");
7506 sym_op->aead.aad.phys_addr =
7507 rte_pktmbuf_iova(ut_params->ibuf);
7508 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7509 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7512 /* Append IV at the end of the crypto operation*/
7513 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7514 uint8_t *, IV_OFFSET);
7516 if (tdata->iv.len == 0) {
7517 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7518 debug_hexdump(stdout, "iv:", iv_ptr,
7521 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7522 debug_hexdump(stdout, "iv:", iv_ptr,
7527 /* Append plaintext/ciphertext */
7528 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7529 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7530 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7532 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7534 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7535 debug_hexdump(stdout, "plaintext:", plaintext,
7536 tdata->plaintext.len);
7538 if (ut_params->obuf) {
7539 ciphertext = (uint8_t *)rte_pktmbuf_append(
7541 plaintext_pad_len + aad_pad_len);
7542 TEST_ASSERT_NOT_NULL(ciphertext,
7543 "no room to append ciphertext");
7545 memset(ciphertext + aad_pad_len, 0,
7546 tdata->ciphertext.len);
7549 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7550 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7552 TEST_ASSERT_NOT_NULL(ciphertext,
7553 "no room to append ciphertext");
7555 memcpy(ciphertext, tdata->ciphertext.data,
7556 tdata->ciphertext.len);
7557 debug_hexdump(stdout, "ciphertext:", ciphertext,
7558 tdata->ciphertext.len);
7560 if (ut_params->obuf) {
7561 plaintext = (uint8_t *)rte_pktmbuf_append(
7563 plaintext_pad_len + aad_pad_len);
7564 TEST_ASSERT_NOT_NULL(plaintext,
7565 "no room to append plaintext");
7567 memset(plaintext + aad_pad_len, 0,
7568 tdata->plaintext.len);
7572 /* Append digest data */
7573 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7574 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7575 ut_params->obuf ? ut_params->obuf :
7577 tdata->auth_tag.len);
7578 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7579 "no room to append digest");
7580 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7581 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7582 ut_params->obuf ? ut_params->obuf :
7587 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7588 ut_params->ibuf, tdata->auth_tag.len);
7589 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7590 "no room to append digest");
7591 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7593 plaintext_pad_len + aad_pad_len);
7595 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7596 tdata->auth_tag.len);
7597 debug_hexdump(stdout, "digest:",
7598 sym_op->aead.digest.data,
7599 tdata->auth_tag.len);
7602 sym_op->aead.data.length = tdata->plaintext.len;
7603 sym_op->aead.data.offset = aad_pad_len;
7609 test_authenticated_encryption(const struct aead_test_data *tdata)
7611 struct crypto_testsuite_params *ts_params = &testsuite_params;
7612 struct crypto_unittest_params *ut_params = &unittest_params;
7615 uint8_t *ciphertext, *auth_tag;
7616 uint16_t plaintext_pad_len;
7618 struct rte_cryptodev_info dev_info;
7620 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7621 uint64_t feat_flags = dev_info.feature_flags;
7623 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7624 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7625 printf("Device doesn't support RAW data-path APIs.\n");
7629 /* Verify the capabilities */
7630 struct rte_cryptodev_sym_capability_idx cap_idx;
7631 const struct rte_cryptodev_symmetric_capability *capability;
7632 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7633 cap_idx.algo.aead = tdata->algo;
7634 capability = rte_cryptodev_sym_capability_get(
7635 ts_params->valid_devs[0], &cap_idx);
7636 if (capability == NULL)
7638 if (rte_cryptodev_sym_capability_check_aead(
7639 capability, tdata->key.len, tdata->auth_tag.len,
7640 tdata->aad.len, tdata->iv.len))
7643 /* Create AEAD session */
7644 retval = create_aead_session(ts_params->valid_devs[0],
7646 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7647 tdata->key.data, tdata->key.len,
7648 tdata->aad.len, tdata->auth_tag.len,
7653 if (tdata->aad.len > MBUF_SIZE) {
7654 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7655 /* Populate full size of add data */
7656 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7657 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7659 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7661 /* clear mbuf payload */
7662 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7663 rte_pktmbuf_tailroom(ut_params->ibuf));
7665 /* Create AEAD operation */
7666 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7670 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7672 ut_params->op->sym->m_src = ut_params->ibuf;
7674 /* Process crypto operation */
7675 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7676 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7677 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7678 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
7679 ut_params->op, 0, 0, 0, 0);
7681 TEST_ASSERT_NOT_NULL(
7682 process_crypto_request(ts_params->valid_devs[0],
7683 ut_params->op), "failed to process sym crypto op");
7685 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7686 "crypto op processing failed");
7688 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7690 if (ut_params->op->sym->m_dst) {
7691 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7693 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7694 uint8_t *, plaintext_pad_len);
7696 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7698 ut_params->op->sym->cipher.data.offset);
7699 auth_tag = ciphertext + plaintext_pad_len;
7702 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7703 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7706 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7708 tdata->ciphertext.data,
7709 tdata->ciphertext.len,
7710 "Ciphertext data not as expected");
7712 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7714 tdata->auth_tag.data,
7715 tdata->auth_tag.len,
7716 "Generated auth tag not as expected");
7722 #ifdef RTE_LIB_SECURITY
7724 security_proto_supported(enum rte_security_session_action_type action,
7725 enum rte_security_session_protocol proto)
7727 struct crypto_testsuite_params *ts_params = &testsuite_params;
7729 const struct rte_security_capability *capabilities;
7730 const struct rte_security_capability *capability;
7733 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7734 rte_cryptodev_get_sec_ctx(
7735 ts_params->valid_devs[0]);
7738 capabilities = rte_security_capabilities_get(ctx);
7740 if (capabilities == NULL)
7743 while ((capability = &capabilities[i++])->action !=
7744 RTE_SECURITY_ACTION_TYPE_NONE) {
7745 if (capability->action == action &&
7746 capability->protocol == proto)
7753 /* Basic algorithm run function for async inplace mode.
7754 * Creates a session from input parameters and runs one operation
7755 * on input_vec. Checks the output of the crypto operation against
7758 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
7759 enum rte_crypto_auth_operation opa,
7760 const uint8_t *input_vec, unsigned int input_vec_len,
7761 const uint8_t *output_vec,
7762 unsigned int output_vec_len,
7763 enum rte_crypto_cipher_algorithm cipher_alg,
7764 const uint8_t *cipher_key, uint32_t cipher_key_len,
7765 enum rte_crypto_auth_algorithm auth_alg,
7766 const uint8_t *auth_key, uint32_t auth_key_len,
7767 uint8_t bearer, enum rte_security_pdcp_domain domain,
7768 uint8_t packet_direction, uint8_t sn_size,
7769 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
7771 struct crypto_testsuite_params *ts_params = &testsuite_params;
7772 struct crypto_unittest_params *ut_params = &unittest_params;
7774 int ret = TEST_SUCCESS;
7775 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7776 rte_cryptodev_get_sec_ctx(
7777 ts_params->valid_devs[0]);
7779 /* Verify the capabilities */
7780 struct rte_security_capability_idx sec_cap_idx;
7782 sec_cap_idx.action = ut_params->type;
7783 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7784 sec_cap_idx.pdcp.domain = domain;
7785 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7788 /* Generate test mbuf data */
7789 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7791 /* clear mbuf payload */
7792 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7793 rte_pktmbuf_tailroom(ut_params->ibuf));
7795 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7797 memcpy(plaintext, input_vec, input_vec_len);
7799 /* Out of place support */
7802 * For out-op-place we need to alloc another mbuf
7804 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7805 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7808 /* Setup Cipher Parameters */
7809 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7810 ut_params->cipher_xform.cipher.algo = cipher_alg;
7811 ut_params->cipher_xform.cipher.op = opc;
7812 ut_params->cipher_xform.cipher.key.data = cipher_key;
7813 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
7814 ut_params->cipher_xform.cipher.iv.length =
7815 packet_direction ? 4 : 0;
7816 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7818 /* Setup HMAC Parameters if ICV header is required */
7819 if (auth_alg != 0) {
7820 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7821 ut_params->auth_xform.next = NULL;
7822 ut_params->auth_xform.auth.algo = auth_alg;
7823 ut_params->auth_xform.auth.op = opa;
7824 ut_params->auth_xform.auth.key.data = auth_key;
7825 ut_params->auth_xform.auth.key.length = auth_key_len;
7827 ut_params->cipher_xform.next = &ut_params->auth_xform;
7829 ut_params->cipher_xform.next = NULL;
7832 struct rte_security_session_conf sess_conf = {
7833 .action_type = ut_params->type,
7834 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7838 .pkt_dir = packet_direction,
7840 .hfn = packet_direction ? 0 : hfn,
7842 * hfn can be set as pdcp_test_hfn[i]
7843 * if hfn_ovrd is not set. Here, PDCP
7844 * packet direction is just used to
7845 * run half of the cases with session
7846 * HFN and other half with per packet
7849 .hfn_threshold = hfn_threshold,
7850 .hfn_ovrd = packet_direction ? 1 : 0,
7851 .sdap_enabled = sdap,
7853 .crypto_xform = &ut_params->cipher_xform
7856 /* Create security session */
7857 ut_params->sec_session = rte_security_session_create(ctx,
7858 &sess_conf, ts_params->session_mpool,
7859 ts_params->session_priv_mpool);
7861 if (!ut_params->sec_session) {
7862 printf("TestCase %s()-%d line %d failed %s: ",
7863 __func__, i, __LINE__, "Failed to allocate session");
7868 /* Generate crypto op data structure */
7869 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7870 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7871 if (!ut_params->op) {
7872 printf("TestCase %s()-%d line %d failed %s: ",
7873 __func__, i, __LINE__,
7874 "Failed to allocate symmetric crypto operation struct");
7879 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7880 uint32_t *, IV_OFFSET);
7881 *per_pkt_hfn = packet_direction ? hfn : 0;
7883 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7885 /* set crypto operation source mbuf */
7886 ut_params->op->sym->m_src = ut_params->ibuf;
7888 ut_params->op->sym->m_dst = ut_params->obuf;
7890 /* Process crypto operation */
7891 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7893 printf("TestCase %s()-%d line %d failed %s: ",
7894 __func__, i, __LINE__,
7895 "failed to process sym crypto op");
7900 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7901 printf("TestCase %s()-%d line %d failed %s: ",
7902 __func__, i, __LINE__, "crypto op processing failed");
7908 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7911 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7915 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7916 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7917 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7918 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7924 rte_crypto_op_free(ut_params->op);
7925 ut_params->op = NULL;
7927 if (ut_params->sec_session)
7928 rte_security_session_destroy(ctx, ut_params->sec_session);
7929 ut_params->sec_session = NULL;
7931 rte_pktmbuf_free(ut_params->ibuf);
7932 ut_params->ibuf = NULL;
7934 rte_pktmbuf_free(ut_params->obuf);
7935 ut_params->obuf = NULL;
7942 test_pdcp_proto_SGL(int i, int oop,
7943 enum rte_crypto_cipher_operation opc,
7944 enum rte_crypto_auth_operation opa,
7946 unsigned int input_vec_len,
7947 uint8_t *output_vec,
7948 unsigned int output_vec_len,
7950 uint32_t fragsz_oop)
7952 struct crypto_testsuite_params *ts_params = &testsuite_params;
7953 struct crypto_unittest_params *ut_params = &unittest_params;
7955 struct rte_mbuf *buf, *buf_oop = NULL;
7956 int ret = TEST_SUCCESS;
7960 unsigned int trn_data = 0;
7961 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7962 rte_cryptodev_get_sec_ctx(
7963 ts_params->valid_devs[0]);
7965 /* Verify the capabilities */
7966 struct rte_security_capability_idx sec_cap_idx;
7968 sec_cap_idx.action = ut_params->type;
7969 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7970 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7971 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7974 if (fragsz > input_vec_len)
7975 fragsz = input_vec_len;
7977 uint16_t plaintext_len = fragsz;
7978 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7980 if (fragsz_oop > output_vec_len)
7981 frag_size_oop = output_vec_len;
7984 if (input_vec_len % fragsz != 0) {
7985 if (input_vec_len / fragsz + 1 > 16)
7987 } else if (input_vec_len / fragsz > 16)
7990 /* Out of place support */
7993 * For out-op-place we need to alloc another mbuf
7995 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7996 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7997 buf_oop = ut_params->obuf;
8000 /* Generate test mbuf data */
8001 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8003 /* clear mbuf payload */
8004 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8005 rte_pktmbuf_tailroom(ut_params->ibuf));
8007 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8009 memcpy(plaintext, input_vec, plaintext_len);
8010 trn_data += plaintext_len;
8012 buf = ut_params->ibuf;
8015 * Loop until no more fragments
8018 while (trn_data < input_vec_len) {
8020 to_trn = (input_vec_len - trn_data < fragsz) ?
8021 (input_vec_len - trn_data) : fragsz;
8023 to_trn_tbl[ecx++] = to_trn;
8025 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8028 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8029 rte_pktmbuf_tailroom(buf));
8032 if (oop && !fragsz_oop) {
8034 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8035 buf_oop = buf_oop->next;
8036 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8037 0, rte_pktmbuf_tailroom(buf_oop));
8038 rte_pktmbuf_append(buf_oop, to_trn);
8041 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8044 memcpy(plaintext, input_vec + trn_data, to_trn);
8048 ut_params->ibuf->nb_segs = segs;
8051 if (fragsz_oop && oop) {
8055 trn_data = frag_size_oop;
8056 while (trn_data < output_vec_len) {
8059 (output_vec_len - trn_data <
8061 (output_vec_len - trn_data) :
8064 to_trn_tbl[ecx++] = to_trn;
8067 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8068 buf_oop = buf_oop->next;
8069 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8070 0, rte_pktmbuf_tailroom(buf_oop));
8071 rte_pktmbuf_append(buf_oop, to_trn);
8075 ut_params->obuf->nb_segs = segs;
8078 /* Setup Cipher Parameters */
8079 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8080 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8081 ut_params->cipher_xform.cipher.op = opc;
8082 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8083 ut_params->cipher_xform.cipher.key.length =
8084 pdcp_test_params[i].cipher_key_len;
8085 ut_params->cipher_xform.cipher.iv.length = 0;
8087 /* Setup HMAC Parameters if ICV header is required */
8088 if (pdcp_test_params[i].auth_alg != 0) {
8089 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8090 ut_params->auth_xform.next = NULL;
8091 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8092 ut_params->auth_xform.auth.op = opa;
8093 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8094 ut_params->auth_xform.auth.key.length =
8095 pdcp_test_params[i].auth_key_len;
8097 ut_params->cipher_xform.next = &ut_params->auth_xform;
8099 ut_params->cipher_xform.next = NULL;
8102 struct rte_security_session_conf sess_conf = {
8103 .action_type = ut_params->type,
8104 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8106 .bearer = pdcp_test_bearer[i],
8107 .domain = pdcp_test_params[i].domain,
8108 .pkt_dir = pdcp_test_packet_direction[i],
8109 .sn_size = pdcp_test_data_sn_size[i],
8110 .hfn = pdcp_test_hfn[i],
8111 .hfn_threshold = pdcp_test_hfn_threshold[i],
8114 .crypto_xform = &ut_params->cipher_xform
8117 /* Create security session */
8118 ut_params->sec_session = rte_security_session_create(ctx,
8119 &sess_conf, ts_params->session_mpool,
8120 ts_params->session_priv_mpool);
8122 if (!ut_params->sec_session) {
8123 printf("TestCase %s()-%d line %d failed %s: ",
8124 __func__, i, __LINE__, "Failed to allocate session");
8129 /* Generate crypto op data structure */
8130 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8131 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8132 if (!ut_params->op) {
8133 printf("TestCase %s()-%d line %d failed %s: ",
8134 __func__, i, __LINE__,
8135 "Failed to allocate symmetric crypto operation struct");
8140 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8142 /* set crypto operation source mbuf */
8143 ut_params->op->sym->m_src = ut_params->ibuf;
8145 ut_params->op->sym->m_dst = ut_params->obuf;
8147 /* Process crypto operation */
8148 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8150 printf("TestCase %s()-%d line %d failed %s: ",
8151 __func__, i, __LINE__,
8152 "failed to process sym crypto op");
8157 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8158 printf("TestCase %s()-%d line %d failed %s: ",
8159 __func__, i, __LINE__, "crypto op processing failed");
8165 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8168 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8172 fragsz = frag_size_oop;
8173 if (memcmp(ciphertext, output_vec, fragsz)) {
8174 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8175 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8176 rte_hexdump(stdout, "reference", output_vec, fragsz);
8181 buf = ut_params->op->sym->m_src->next;
8183 buf = ut_params->op->sym->m_dst->next;
8185 unsigned int off = fragsz;
8189 ciphertext = rte_pktmbuf_mtod(buf,
8191 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8192 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8193 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8194 rte_hexdump(stdout, "reference", output_vec + off,
8199 off += to_trn_tbl[ecx++];
8203 rte_crypto_op_free(ut_params->op);
8204 ut_params->op = NULL;
8206 if (ut_params->sec_session)
8207 rte_security_session_destroy(ctx, ut_params->sec_session);
8208 ut_params->sec_session = NULL;
8210 rte_pktmbuf_free(ut_params->ibuf);
8211 ut_params->ibuf = NULL;
8213 rte_pktmbuf_free(ut_params->obuf);
8214 ut_params->obuf = NULL;
8221 test_pdcp_proto_cplane_encap(int i)
8223 return test_pdcp_proto(
8224 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8225 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8226 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8227 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8228 pdcp_test_params[i].cipher_key_len,
8229 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8230 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8231 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8232 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8233 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8237 test_pdcp_proto_uplane_encap(int i)
8239 return test_pdcp_proto(
8240 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8241 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8242 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8243 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8244 pdcp_test_params[i].cipher_key_len,
8245 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8246 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8247 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8248 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8249 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8253 test_pdcp_proto_uplane_encap_with_int(int i)
8255 return test_pdcp_proto(
8256 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8257 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8258 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8259 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8260 pdcp_test_params[i].cipher_key_len,
8261 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8262 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8263 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8264 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8265 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8269 test_pdcp_proto_cplane_decap(int i)
8271 return test_pdcp_proto(
8272 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8273 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8274 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8275 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8276 pdcp_test_params[i].cipher_key_len,
8277 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8278 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8279 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8280 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8281 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8285 test_pdcp_proto_uplane_decap(int i)
8287 return test_pdcp_proto(
8288 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8289 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8290 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8291 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8292 pdcp_test_params[i].cipher_key_len,
8293 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8294 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8295 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8296 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8297 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8301 test_pdcp_proto_uplane_decap_with_int(int i)
8303 return test_pdcp_proto(
8304 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8305 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8306 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8307 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8308 pdcp_test_params[i].cipher_key_len,
8309 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8310 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8311 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8312 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8313 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8317 test_PDCP_PROTO_SGL_in_place_32B(void)
8319 /* i can be used for running any PDCP case
8320 * In this case it is uplane 12-bit AES-SNOW DL encap
8322 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8323 return test_pdcp_proto_SGL(i, IN_PLACE,
8324 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8325 RTE_CRYPTO_AUTH_OP_GENERATE,
8326 pdcp_test_data_in[i],
8327 pdcp_test_data_in_len[i],
8328 pdcp_test_data_out[i],
8329 pdcp_test_data_in_len[i]+4,
8333 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8335 /* i can be used for running any PDCP case
8336 * In this case it is uplane 18-bit NULL-NULL DL encap
8338 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8339 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8340 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8341 RTE_CRYPTO_AUTH_OP_GENERATE,
8342 pdcp_test_data_in[i],
8343 pdcp_test_data_in_len[i],
8344 pdcp_test_data_out[i],
8345 pdcp_test_data_in_len[i]+4,
8349 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8351 /* i can be used for running any PDCP case
8352 * In this case it is uplane 18-bit AES DL encap
8354 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8356 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8357 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8358 RTE_CRYPTO_AUTH_OP_GENERATE,
8359 pdcp_test_data_in[i],
8360 pdcp_test_data_in_len[i],
8361 pdcp_test_data_out[i],
8362 pdcp_test_data_in_len[i],
8366 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8368 /* i can be used for running any PDCP case
8369 * In this case it is cplane 12-bit AES-ZUC DL encap
8371 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8372 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8373 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8374 RTE_CRYPTO_AUTH_OP_GENERATE,
8375 pdcp_test_data_in[i],
8376 pdcp_test_data_in_len[i],
8377 pdcp_test_data_out[i],
8378 pdcp_test_data_in_len[i]+4,
8383 test_PDCP_SDAP_PROTO_encap_all(void)
8385 int i = 0, size = 0;
8386 int err, all_err = TEST_SUCCESS;
8387 const struct pdcp_sdap_test *cur_test;
8389 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8391 for (i = 0; i < size; i++) {
8392 cur_test = &list_pdcp_sdap_tests[i];
8393 err = test_pdcp_proto(
8394 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8395 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8396 cur_test->in_len, cur_test->data_out,
8397 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8398 cur_test->param.cipher_alg, cur_test->cipher_key,
8399 cur_test->param.cipher_key_len,
8400 cur_test->param.auth_alg,
8401 cur_test->auth_key, cur_test->param.auth_key_len,
8402 cur_test->bearer, cur_test->param.domain,
8403 cur_test->packet_direction, cur_test->sn_size,
8405 cur_test->hfn_threshold, SDAP_ENABLED);
8407 printf("\t%d) %s: Encapsulation failed\n",
8409 cur_test->param.name);
8412 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8413 cur_test->param.name);
8419 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8421 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8425 test_PDCP_SDAP_PROTO_decap_all(void)
8427 int i = 0, size = 0;
8428 int err, all_err = TEST_SUCCESS;
8429 const struct pdcp_sdap_test *cur_test;
8431 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8433 for (i = 0; i < size; i++) {
8434 cur_test = &list_pdcp_sdap_tests[i];
8435 err = test_pdcp_proto(
8436 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8437 RTE_CRYPTO_AUTH_OP_VERIFY,
8439 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8440 cur_test->data_in, cur_test->in_len,
8441 cur_test->param.cipher_alg,
8442 cur_test->cipher_key, cur_test->param.cipher_key_len,
8443 cur_test->param.auth_alg, cur_test->auth_key,
8444 cur_test->param.auth_key_len, cur_test->bearer,
8445 cur_test->param.domain, cur_test->packet_direction,
8446 cur_test->sn_size, cur_test->hfn,
8447 cur_test->hfn_threshold, SDAP_ENABLED);
8449 printf("\t%d) %s: Decapsulation failed\n",
8451 cur_test->param.name);
8454 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8455 cur_test->param.name);
8461 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8463 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8467 test_PDCP_PROTO_all(void)
8469 struct crypto_testsuite_params *ts_params = &testsuite_params;
8470 struct crypto_unittest_params *ut_params = &unittest_params;
8471 struct rte_cryptodev_info dev_info;
8474 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8475 uint64_t feat_flags = dev_info.feature_flags;
8477 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8480 /* Set action type */
8481 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8482 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8485 if (security_proto_supported(ut_params->type,
8486 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8489 status = test_PDCP_PROTO_cplane_encap_all();
8490 status += test_PDCP_PROTO_cplane_decap_all();
8491 status += test_PDCP_PROTO_uplane_encap_all();
8492 status += test_PDCP_PROTO_uplane_decap_all();
8493 status += test_PDCP_PROTO_SGL_in_place_32B();
8494 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8495 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8496 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8497 status += test_PDCP_SDAP_PROTO_encap_all();
8498 status += test_PDCP_SDAP_PROTO_decap_all();
8503 return TEST_SUCCESS;
8507 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8509 struct crypto_testsuite_params *ts_params = &testsuite_params;
8510 struct crypto_unittest_params *ut_params = &unittest_params;
8511 uint8_t *plaintext, *ciphertext;
8513 int32_t cipher_len, crc_len;
8514 uint32_t crc_data_len;
8515 int ret = TEST_SUCCESS;
8517 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8518 rte_cryptodev_get_sec_ctx(
8519 ts_params->valid_devs[0]);
8521 /* Verify the capabilities */
8522 struct rte_security_capability_idx sec_cap_idx;
8523 const struct rte_security_capability *sec_cap;
8524 const struct rte_cryptodev_capabilities *crypto_cap;
8525 const struct rte_cryptodev_symmetric_capability *sym_cap;
8528 sec_cap_idx.action = ut_params->type;
8529 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8530 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8532 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8533 if (sec_cap == NULL)
8536 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8537 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8538 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8539 crypto_cap->sym.xform_type ==
8540 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8541 crypto_cap->sym.cipher.algo ==
8542 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8543 sym_cap = &crypto_cap->sym;
8544 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8551 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8554 /* Setup source mbuf payload */
8555 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8556 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8557 rte_pktmbuf_tailroom(ut_params->ibuf));
8559 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8560 d_td->ciphertext.len);
8562 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8564 /* Setup cipher session parameters */
8565 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8566 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8567 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8568 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8569 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8570 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8571 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8572 ut_params->cipher_xform.next = NULL;
8574 /* Setup DOCSIS session parameters */
8575 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8577 struct rte_security_session_conf sess_conf = {
8578 .action_type = ut_params->type,
8579 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8580 .docsis = ut_params->docsis_xform,
8581 .crypto_xform = &ut_params->cipher_xform,
8584 /* Create security session */
8585 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8586 ts_params->session_mpool,
8587 ts_params->session_priv_mpool);
8589 if (!ut_params->sec_session) {
8590 printf("TestCase %s(%d) line %d: %s\n",
8591 __func__, i, __LINE__, "failed to allocate session");
8596 /* Generate crypto op data structure */
8597 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8598 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8599 if (!ut_params->op) {
8600 printf("TestCase %s(%d) line %d: %s\n",
8601 __func__, i, __LINE__,
8602 "failed to allocate symmetric crypto operation");
8607 /* Setup CRC operation parameters */
8608 crc_len = d_td->ciphertext.no_crc == false ?
8609 (d_td->ciphertext.len -
8610 d_td->ciphertext.crc_offset -
8611 RTE_ETHER_CRC_LEN) :
8613 crc_len = crc_len > 0 ? crc_len : 0;
8614 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8615 ut_params->op->sym->auth.data.length = crc_len;
8616 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8618 /* Setup cipher operation parameters */
8619 cipher_len = d_td->ciphertext.no_cipher == false ?
8620 (d_td->ciphertext.len -
8621 d_td->ciphertext.cipher_offset) :
8623 cipher_len = cipher_len > 0 ? cipher_len : 0;
8624 ut_params->op->sym->cipher.data.length = cipher_len;
8625 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8627 /* Setup cipher IV */
8628 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8629 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8631 /* Attach session to operation */
8632 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8634 /* Set crypto operation mbufs */
8635 ut_params->op->sym->m_src = ut_params->ibuf;
8636 ut_params->op->sym->m_dst = NULL;
8638 /* Process crypto operation */
8639 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8641 printf("TestCase %s(%d) line %d: %s\n",
8642 __func__, i, __LINE__,
8643 "failed to process security crypto op");
8648 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8649 printf("TestCase %s(%d) line %d: %s\n",
8650 __func__, i, __LINE__, "crypto op processing failed");
8655 /* Validate plaintext */
8656 plaintext = ciphertext;
8658 if (memcmp(plaintext, d_td->plaintext.data,
8659 d_td->plaintext.len - crc_data_len)) {
8660 printf("TestCase %s(%d) line %d: %s\n",
8661 __func__, i, __LINE__, "plaintext not as expected\n");
8662 rte_hexdump(stdout, "expected", d_td->plaintext.data,
8663 d_td->plaintext.len);
8664 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
8670 rte_crypto_op_free(ut_params->op);
8671 ut_params->op = NULL;
8673 if (ut_params->sec_session)
8674 rte_security_session_destroy(ctx, ut_params->sec_session);
8675 ut_params->sec_session = NULL;
8677 rte_pktmbuf_free(ut_params->ibuf);
8678 ut_params->ibuf = NULL;
8684 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
8686 struct crypto_testsuite_params *ts_params = &testsuite_params;
8687 struct crypto_unittest_params *ut_params = &unittest_params;
8688 uint8_t *plaintext, *ciphertext;
8690 int32_t cipher_len, crc_len;
8691 int ret = TEST_SUCCESS;
8693 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8694 rte_cryptodev_get_sec_ctx(
8695 ts_params->valid_devs[0]);
8697 /* Verify the capabilities */
8698 struct rte_security_capability_idx sec_cap_idx;
8699 const struct rte_security_capability *sec_cap;
8700 const struct rte_cryptodev_capabilities *crypto_cap;
8701 const struct rte_cryptodev_symmetric_capability *sym_cap;
8704 sec_cap_idx.action = ut_params->type;
8705 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8706 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8708 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8709 if (sec_cap == NULL)
8712 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8713 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8714 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8715 crypto_cap->sym.xform_type ==
8716 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8717 crypto_cap->sym.cipher.algo ==
8718 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8719 sym_cap = &crypto_cap->sym;
8720 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8727 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8730 /* Setup source mbuf payload */
8731 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8732 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8733 rte_pktmbuf_tailroom(ut_params->ibuf));
8735 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8736 d_td->plaintext.len);
8738 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
8740 /* Setup cipher session parameters */
8741 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8742 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8743 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8744 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8745 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8746 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8747 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8748 ut_params->cipher_xform.next = NULL;
8750 /* Setup DOCSIS session parameters */
8751 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8753 struct rte_security_session_conf sess_conf = {
8754 .action_type = ut_params->type,
8755 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8756 .docsis = ut_params->docsis_xform,
8757 .crypto_xform = &ut_params->cipher_xform,
8760 /* Create security session */
8761 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8762 ts_params->session_mpool,
8763 ts_params->session_priv_mpool);
8765 if (!ut_params->sec_session) {
8766 printf("TestCase %s(%d) line %d: %s\n",
8767 __func__, i, __LINE__, "failed to allocate session");
8772 /* Generate crypto op data structure */
8773 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8774 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8775 if (!ut_params->op) {
8776 printf("TestCase %s(%d) line %d: %s\n",
8777 __func__, i, __LINE__,
8778 "failed to allocate security crypto operation");
8783 /* Setup CRC operation parameters */
8784 crc_len = d_td->plaintext.no_crc == false ?
8785 (d_td->plaintext.len -
8786 d_td->plaintext.crc_offset -
8787 RTE_ETHER_CRC_LEN) :
8789 crc_len = crc_len > 0 ? crc_len : 0;
8790 ut_params->op->sym->auth.data.length = crc_len;
8791 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8793 /* Setup cipher operation parameters */
8794 cipher_len = d_td->plaintext.no_cipher == false ?
8795 (d_td->plaintext.len -
8796 d_td->plaintext.cipher_offset) :
8798 cipher_len = cipher_len > 0 ? cipher_len : 0;
8799 ut_params->op->sym->cipher.data.length = cipher_len;
8800 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8802 /* Setup cipher IV */
8803 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8804 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8806 /* Attach session to operation */
8807 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8809 /* Set crypto operation mbufs */
8810 ut_params->op->sym->m_src = ut_params->ibuf;
8811 ut_params->op->sym->m_dst = NULL;
8813 /* Process crypto operation */
8814 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8816 printf("TestCase %s(%d) line %d: %s\n",
8817 __func__, i, __LINE__,
8818 "failed to process security crypto op");
8823 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8824 printf("TestCase %s(%d) line %d: %s\n",
8825 __func__, i, __LINE__, "crypto op processing failed");
8830 /* Validate ciphertext */
8831 ciphertext = plaintext;
8833 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8834 printf("TestCase %s(%d) line %d: %s\n",
8835 __func__, i, __LINE__, "ciphertext not as expected\n");
8836 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8837 d_td->ciphertext.len);
8838 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8844 rte_crypto_op_free(ut_params->op);
8845 ut_params->op = NULL;
8847 if (ut_params->sec_session)
8848 rte_security_session_destroy(ctx, ut_params->sec_session);
8849 ut_params->sec_session = NULL;
8851 rte_pktmbuf_free(ut_params->ibuf);
8852 ut_params->ibuf = NULL;
8857 #define TEST_DOCSIS_COUNT(func) do { \
8859 if (ret == TEST_SUCCESS) { \
8860 printf("\t%2d)", n++); \
8861 printf("+++++ PASSED:" #func"\n"); \
8863 } else if (ret == -ENOTSUP) { \
8864 printf("\t%2d)", n++); \
8865 printf("~~~~~ UNSUPP:" #func"\n"); \
8868 printf("\t%2d)", n++); \
8869 printf("----- FAILED:" #func"\n"); \
8875 test_DOCSIS_PROTO_uplink_all(void)
8877 int p = 0, u = 0, f = 0, n = 0;
8879 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8880 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8881 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8882 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8883 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8884 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8885 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8886 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8887 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8888 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8889 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8890 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8891 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8892 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8893 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8894 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8895 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8896 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8897 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8898 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8899 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8900 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8901 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8902 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8903 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8904 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8907 printf("## %s: %d passed out of %d (%d unsupported)\n",
8914 test_DOCSIS_PROTO_downlink_all(void)
8916 int p = 0, u = 0, f = 0, n = 0;
8918 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8919 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8920 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8921 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8922 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8923 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8924 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8925 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8926 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8927 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8928 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8929 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8930 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8931 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8932 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8933 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8934 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8935 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8936 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8937 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8938 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8939 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8940 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8941 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8942 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8943 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8946 printf("## %s: %d passed out of %d (%d unsupported)\n",
8953 test_DOCSIS_PROTO_all(void)
8955 struct crypto_testsuite_params *ts_params = &testsuite_params;
8956 struct crypto_unittest_params *ut_params = &unittest_params;
8957 struct rte_cryptodev_info dev_info;
8960 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8961 uint64_t feat_flags = dev_info.feature_flags;
8963 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8966 /* Set action type */
8967 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8968 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8971 if (security_proto_supported(ut_params->type,
8972 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8975 status = test_DOCSIS_PROTO_uplink_all();
8976 status += test_DOCSIS_PROTO_downlink_all();
8981 return TEST_SUCCESS;
8986 test_AES_GCM_authenticated_encryption_test_case_1(void)
8988 return test_authenticated_encryption(&gcm_test_case_1);
8992 test_AES_GCM_authenticated_encryption_test_case_2(void)
8994 return test_authenticated_encryption(&gcm_test_case_2);
8998 test_AES_GCM_authenticated_encryption_test_case_3(void)
9000 return test_authenticated_encryption(&gcm_test_case_3);
9004 test_AES_GCM_authenticated_encryption_test_case_4(void)
9006 return test_authenticated_encryption(&gcm_test_case_4);
9010 test_AES_GCM_authenticated_encryption_test_case_5(void)
9012 return test_authenticated_encryption(&gcm_test_case_5);
9016 test_AES_GCM_authenticated_encryption_test_case_6(void)
9018 return test_authenticated_encryption(&gcm_test_case_6);
9022 test_AES_GCM_authenticated_encryption_test_case_7(void)
9024 return test_authenticated_encryption(&gcm_test_case_7);
9028 test_AES_GCM_authenticated_encryption_test_case_8(void)
9030 return test_authenticated_encryption(&gcm_test_case_8);
9034 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9036 return test_authenticated_encryption(&gcm_J0_test_case_1);
9040 test_AES_GCM_auth_encryption_test_case_192_1(void)
9042 return test_authenticated_encryption(&gcm_test_case_192_1);
9046 test_AES_GCM_auth_encryption_test_case_192_2(void)
9048 return test_authenticated_encryption(&gcm_test_case_192_2);
9052 test_AES_GCM_auth_encryption_test_case_192_3(void)
9054 return test_authenticated_encryption(&gcm_test_case_192_3);
9058 test_AES_GCM_auth_encryption_test_case_192_4(void)
9060 return test_authenticated_encryption(&gcm_test_case_192_4);
9064 test_AES_GCM_auth_encryption_test_case_192_5(void)
9066 return test_authenticated_encryption(&gcm_test_case_192_5);
9070 test_AES_GCM_auth_encryption_test_case_192_6(void)
9072 return test_authenticated_encryption(&gcm_test_case_192_6);
9076 test_AES_GCM_auth_encryption_test_case_192_7(void)
9078 return test_authenticated_encryption(&gcm_test_case_192_7);
9082 test_AES_GCM_auth_encryption_test_case_256_1(void)
9084 return test_authenticated_encryption(&gcm_test_case_256_1);
9088 test_AES_GCM_auth_encryption_test_case_256_2(void)
9090 return test_authenticated_encryption(&gcm_test_case_256_2);
9094 test_AES_GCM_auth_encryption_test_case_256_3(void)
9096 return test_authenticated_encryption(&gcm_test_case_256_3);
9100 test_AES_GCM_auth_encryption_test_case_256_4(void)
9102 return test_authenticated_encryption(&gcm_test_case_256_4);
9106 test_AES_GCM_auth_encryption_test_case_256_5(void)
9108 return test_authenticated_encryption(&gcm_test_case_256_5);
9112 test_AES_GCM_auth_encryption_test_case_256_6(void)
9114 return test_authenticated_encryption(&gcm_test_case_256_6);
9118 test_AES_GCM_auth_encryption_test_case_256_7(void)
9120 return test_authenticated_encryption(&gcm_test_case_256_7);
9124 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9126 return test_authenticated_encryption(&gcm_test_case_aad_1);
9130 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9132 return test_authenticated_encryption(&gcm_test_case_aad_2);
9136 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9138 struct aead_test_data tdata;
9141 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9142 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9143 tdata.iv.data[0] += 1;
9144 res = test_authenticated_encryption(&tdata);
9145 if (res == -ENOTSUP)
9147 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9148 return TEST_SUCCESS;
9152 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9154 struct aead_test_data tdata;
9157 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9158 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9159 tdata.plaintext.data[0] += 1;
9160 res = test_authenticated_encryption(&tdata);
9161 if (res == -ENOTSUP)
9163 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9164 return TEST_SUCCESS;
9168 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9170 struct aead_test_data tdata;
9173 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9174 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9175 tdata.ciphertext.data[0] += 1;
9176 res = test_authenticated_encryption(&tdata);
9177 if (res == -ENOTSUP)
9179 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9180 return TEST_SUCCESS;
9184 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9186 struct aead_test_data tdata;
9189 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9190 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9192 res = test_authenticated_encryption(&tdata);
9193 if (res == -ENOTSUP)
9195 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9196 return TEST_SUCCESS;
9200 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9202 struct aead_test_data tdata;
9203 uint8_t aad[gcm_test_case_7.aad.len];
9206 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9207 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9208 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9210 tdata.aad.data = aad;
9211 res = test_authenticated_encryption(&tdata);
9212 if (res == -ENOTSUP)
9214 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9215 return TEST_SUCCESS;
9219 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9221 struct aead_test_data tdata;
9224 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9225 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9226 tdata.auth_tag.data[0] += 1;
9227 res = test_authenticated_encryption(&tdata);
9228 if (res == -ENOTSUP)
9230 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9231 return TEST_SUCCESS;
9235 test_authenticated_decryption(const struct aead_test_data *tdata)
9237 struct crypto_testsuite_params *ts_params = &testsuite_params;
9238 struct crypto_unittest_params *ut_params = &unittest_params;
9243 struct rte_cryptodev_info dev_info;
9245 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9246 uint64_t feat_flags = dev_info.feature_flags;
9248 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9249 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9250 printf("Device doesn't support RAW data-path APIs.\n");
9254 /* Verify the capabilities */
9255 struct rte_cryptodev_sym_capability_idx cap_idx;
9256 const struct rte_cryptodev_symmetric_capability *capability;
9257 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9258 cap_idx.algo.aead = tdata->algo;
9259 capability = rte_cryptodev_sym_capability_get(
9260 ts_params->valid_devs[0], &cap_idx);
9261 if (capability == NULL)
9263 if (rte_cryptodev_sym_capability_check_aead(
9264 capability, tdata->key.len, tdata->auth_tag.len,
9265 tdata->aad.len, tdata->iv.len))
9268 /* Create AEAD session */
9269 retval = create_aead_session(ts_params->valid_devs[0],
9271 RTE_CRYPTO_AEAD_OP_DECRYPT,
9272 tdata->key.data, tdata->key.len,
9273 tdata->aad.len, tdata->auth_tag.len,
9278 /* alloc mbuf and set payload */
9279 if (tdata->aad.len > MBUF_SIZE) {
9280 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9281 /* Populate full size of add data */
9282 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9283 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9285 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9287 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9288 rte_pktmbuf_tailroom(ut_params->ibuf));
9290 /* Create AEAD operation */
9291 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9295 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9297 ut_params->op->sym->m_src = ut_params->ibuf;
9299 /* Process crypto operation */
9300 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9301 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9302 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9303 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9304 ut_params->op, 0, 0, 0, 0);
9306 TEST_ASSERT_NOT_NULL(
9307 process_crypto_request(ts_params->valid_devs[0],
9308 ut_params->op), "failed to process sym crypto op");
9310 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9311 "crypto op processing failed");
9313 if (ut_params->op->sym->m_dst)
9314 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9317 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9319 ut_params->op->sym->cipher.data.offset);
9321 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9324 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9326 tdata->plaintext.data,
9327 tdata->plaintext.len,
9328 "Plaintext data not as expected");
9330 TEST_ASSERT_EQUAL(ut_params->op->status,
9331 RTE_CRYPTO_OP_STATUS_SUCCESS,
9332 "Authentication failed");
9338 test_AES_GCM_authenticated_decryption_test_case_1(void)
9340 return test_authenticated_decryption(&gcm_test_case_1);
9344 test_AES_GCM_authenticated_decryption_test_case_2(void)
9346 return test_authenticated_decryption(&gcm_test_case_2);
9350 test_AES_GCM_authenticated_decryption_test_case_3(void)
9352 return test_authenticated_decryption(&gcm_test_case_3);
9356 test_AES_GCM_authenticated_decryption_test_case_4(void)
9358 return test_authenticated_decryption(&gcm_test_case_4);
9362 test_AES_GCM_authenticated_decryption_test_case_5(void)
9364 return test_authenticated_decryption(&gcm_test_case_5);
9368 test_AES_GCM_authenticated_decryption_test_case_6(void)
9370 return test_authenticated_decryption(&gcm_test_case_6);
9374 test_AES_GCM_authenticated_decryption_test_case_7(void)
9376 return test_authenticated_decryption(&gcm_test_case_7);
9380 test_AES_GCM_authenticated_decryption_test_case_8(void)
9382 return test_authenticated_decryption(&gcm_test_case_8);
9386 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9388 return test_authenticated_decryption(&gcm_J0_test_case_1);
9392 test_AES_GCM_auth_decryption_test_case_192_1(void)
9394 return test_authenticated_decryption(&gcm_test_case_192_1);
9398 test_AES_GCM_auth_decryption_test_case_192_2(void)
9400 return test_authenticated_decryption(&gcm_test_case_192_2);
9404 test_AES_GCM_auth_decryption_test_case_192_3(void)
9406 return test_authenticated_decryption(&gcm_test_case_192_3);
9410 test_AES_GCM_auth_decryption_test_case_192_4(void)
9412 return test_authenticated_decryption(&gcm_test_case_192_4);
9416 test_AES_GCM_auth_decryption_test_case_192_5(void)
9418 return test_authenticated_decryption(&gcm_test_case_192_5);
9422 test_AES_GCM_auth_decryption_test_case_192_6(void)
9424 return test_authenticated_decryption(&gcm_test_case_192_6);
9428 test_AES_GCM_auth_decryption_test_case_192_7(void)
9430 return test_authenticated_decryption(&gcm_test_case_192_7);
9434 test_AES_GCM_auth_decryption_test_case_256_1(void)
9436 return test_authenticated_decryption(&gcm_test_case_256_1);
9440 test_AES_GCM_auth_decryption_test_case_256_2(void)
9442 return test_authenticated_decryption(&gcm_test_case_256_2);
9446 test_AES_GCM_auth_decryption_test_case_256_3(void)
9448 return test_authenticated_decryption(&gcm_test_case_256_3);
9452 test_AES_GCM_auth_decryption_test_case_256_4(void)
9454 return test_authenticated_decryption(&gcm_test_case_256_4);
9458 test_AES_GCM_auth_decryption_test_case_256_5(void)
9460 return test_authenticated_decryption(&gcm_test_case_256_5);
9464 test_AES_GCM_auth_decryption_test_case_256_6(void)
9466 return test_authenticated_decryption(&gcm_test_case_256_6);
9470 test_AES_GCM_auth_decryption_test_case_256_7(void)
9472 return test_authenticated_decryption(&gcm_test_case_256_7);
9476 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9478 return test_authenticated_decryption(&gcm_test_case_aad_1);
9482 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9484 return test_authenticated_decryption(&gcm_test_case_aad_2);
9488 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9490 struct aead_test_data tdata;
9493 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9494 tdata.iv.data[0] += 1;
9495 res = test_authenticated_decryption(&tdata);
9496 if (res == -ENOTSUP)
9498 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9499 return TEST_SUCCESS;
9503 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9505 struct aead_test_data tdata;
9508 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9509 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9510 tdata.plaintext.data[0] += 1;
9511 res = test_authenticated_decryption(&tdata);
9512 if (res == -ENOTSUP)
9514 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9515 return TEST_SUCCESS;
9519 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9521 struct aead_test_data tdata;
9524 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9525 tdata.ciphertext.data[0] += 1;
9526 res = test_authenticated_decryption(&tdata);
9527 if (res == -ENOTSUP)
9529 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9530 return TEST_SUCCESS;
9534 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9536 struct aead_test_data tdata;
9539 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9541 res = test_authenticated_decryption(&tdata);
9542 if (res == -ENOTSUP)
9544 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9545 return TEST_SUCCESS;
9549 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9551 struct aead_test_data tdata;
9552 uint8_t aad[gcm_test_case_7.aad.len];
9555 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9556 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9558 tdata.aad.data = aad;
9559 res = test_authenticated_decryption(&tdata);
9560 if (res == -ENOTSUP)
9562 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9563 return TEST_SUCCESS;
9567 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9569 struct aead_test_data tdata;
9572 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9573 tdata.auth_tag.data[0] += 1;
9574 res = test_authenticated_decryption(&tdata);
9575 if (res == -ENOTSUP)
9577 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9578 return TEST_SUCCESS;
9582 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9584 struct crypto_testsuite_params *ts_params = &testsuite_params;
9585 struct crypto_unittest_params *ut_params = &unittest_params;
9588 uint8_t *ciphertext, *auth_tag;
9589 uint16_t plaintext_pad_len;
9591 /* Verify the capabilities */
9592 struct rte_cryptodev_sym_capability_idx cap_idx;
9593 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9594 cap_idx.algo.aead = tdata->algo;
9595 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9599 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9602 /* not supported with CPU crypto */
9603 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9606 /* Create AEAD session */
9607 retval = create_aead_session(ts_params->valid_devs[0],
9609 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9610 tdata->key.data, tdata->key.len,
9611 tdata->aad.len, tdata->auth_tag.len,
9616 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9617 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9619 /* clear mbuf payload */
9620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9621 rte_pktmbuf_tailroom(ut_params->ibuf));
9622 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9623 rte_pktmbuf_tailroom(ut_params->obuf));
9625 /* Create AEAD operation */
9626 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9630 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9632 ut_params->op->sym->m_src = ut_params->ibuf;
9633 ut_params->op->sym->m_dst = ut_params->obuf;
9635 /* Process crypto operation */
9636 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9637 ut_params->op), "failed to process sym crypto op");
9639 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9640 "crypto op processing failed");
9642 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9644 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9645 ut_params->op->sym->cipher.data.offset);
9646 auth_tag = ciphertext + plaintext_pad_len;
9648 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9649 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9652 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9654 tdata->ciphertext.data,
9655 tdata->ciphertext.len,
9656 "Ciphertext data not as expected");
9658 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9660 tdata->auth_tag.data,
9661 tdata->auth_tag.len,
9662 "Generated auth tag not as expected");
9669 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9671 return test_authenticated_encryption_oop(&gcm_test_case_5);
9675 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9677 struct crypto_testsuite_params *ts_params = &testsuite_params;
9678 struct crypto_unittest_params *ut_params = &unittest_params;
9683 /* Verify the capabilities */
9684 struct rte_cryptodev_sym_capability_idx cap_idx;
9685 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9686 cap_idx.algo.aead = tdata->algo;
9687 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9691 /* not supported with CPU crypto and raw data-path APIs*/
9692 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
9693 global_api_test_type == CRYPTODEV_RAW_API_TEST)
9696 /* Create AEAD session */
9697 retval = create_aead_session(ts_params->valid_devs[0],
9699 RTE_CRYPTO_AEAD_OP_DECRYPT,
9700 tdata->key.data, tdata->key.len,
9701 tdata->aad.len, tdata->auth_tag.len,
9706 /* alloc mbuf and set payload */
9707 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9708 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9710 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9711 rte_pktmbuf_tailroom(ut_params->ibuf));
9712 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9713 rte_pktmbuf_tailroom(ut_params->obuf));
9715 /* Create AEAD operation */
9716 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9720 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9722 ut_params->op->sym->m_src = ut_params->ibuf;
9723 ut_params->op->sym->m_dst = ut_params->obuf;
9725 /* Process crypto operation */
9726 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9727 ut_params->op), "failed to process sym crypto op");
9729 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9730 "crypto op processing failed");
9732 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9733 ut_params->op->sym->cipher.data.offset);
9735 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9738 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9740 tdata->plaintext.data,
9741 tdata->plaintext.len,
9742 "Plaintext data not as expected");
9744 TEST_ASSERT_EQUAL(ut_params->op->status,
9745 RTE_CRYPTO_OP_STATUS_SUCCESS,
9746 "Authentication failed");
9751 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9753 return test_authenticated_decryption_oop(&gcm_test_case_5);
9757 test_authenticated_encryption_sessionless(
9758 const struct aead_test_data *tdata)
9760 struct crypto_testsuite_params *ts_params = &testsuite_params;
9761 struct crypto_unittest_params *ut_params = &unittest_params;
9764 uint8_t *ciphertext, *auth_tag;
9765 uint16_t plaintext_pad_len;
9766 uint8_t key[tdata->key.len + 1];
9767 struct rte_cryptodev_info dev_info;
9769 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9770 uint64_t feat_flags = dev_info.feature_flags;
9772 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9773 printf("Device doesn't support Sessionless ops.\n");
9777 /* not supported with CPU crypto */
9778 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9781 /* Verify the capabilities */
9782 struct rte_cryptodev_sym_capability_idx cap_idx;
9783 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9784 cap_idx.algo.aead = tdata->algo;
9785 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9789 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9791 /* clear mbuf payload */
9792 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9793 rte_pktmbuf_tailroom(ut_params->ibuf));
9795 /* Create AEAD operation */
9796 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9800 /* Create GCM xform */
9801 memcpy(key, tdata->key.data, tdata->key.len);
9802 retval = create_aead_xform(ut_params->op,
9804 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9805 key, tdata->key.len,
9806 tdata->aad.len, tdata->auth_tag.len,
9811 ut_params->op->sym->m_src = ut_params->ibuf;
9813 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9814 RTE_CRYPTO_OP_SESSIONLESS,
9815 "crypto op session type not sessionless");
9817 /* Process crypto operation */
9818 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9819 ut_params->op), "failed to process sym crypto op");
9821 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9823 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9824 "crypto op status not success");
9826 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9828 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9829 ut_params->op->sym->cipher.data.offset);
9830 auth_tag = ciphertext + plaintext_pad_len;
9832 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9833 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9836 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9838 tdata->ciphertext.data,
9839 tdata->ciphertext.len,
9840 "Ciphertext data not as expected");
9842 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9844 tdata->auth_tag.data,
9845 tdata->auth_tag.len,
9846 "Generated auth tag not as expected");
9853 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9855 return test_authenticated_encryption_sessionless(
9860 test_authenticated_decryption_sessionless(
9861 const struct aead_test_data *tdata)
9863 struct crypto_testsuite_params *ts_params = &testsuite_params;
9864 struct crypto_unittest_params *ut_params = &unittest_params;
9868 uint8_t key[tdata->key.len + 1];
9869 struct rte_cryptodev_info dev_info;
9871 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9872 uint64_t feat_flags = dev_info.feature_flags;
9874 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9875 printf("Device doesn't support Sessionless ops.\n");
9879 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9880 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9881 printf("Device doesn't support RAW data-path APIs.\n");
9885 /* not supported with CPU crypto */
9886 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9889 /* Verify the capabilities */
9890 struct rte_cryptodev_sym_capability_idx cap_idx;
9891 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9892 cap_idx.algo.aead = tdata->algo;
9893 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9897 /* alloc mbuf and set payload */
9898 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9900 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9901 rte_pktmbuf_tailroom(ut_params->ibuf));
9903 /* Create AEAD operation */
9904 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9908 /* Create AEAD xform */
9909 memcpy(key, tdata->key.data, tdata->key.len);
9910 retval = create_aead_xform(ut_params->op,
9912 RTE_CRYPTO_AEAD_OP_DECRYPT,
9913 key, tdata->key.len,
9914 tdata->aad.len, tdata->auth_tag.len,
9919 ut_params->op->sym->m_src = ut_params->ibuf;
9921 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9922 RTE_CRYPTO_OP_SESSIONLESS,
9923 "crypto op session type not sessionless");
9925 /* Process crypto operation */
9926 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9927 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9928 ut_params->op, 0, 0, 0, 0);
9930 TEST_ASSERT_NOT_NULL(process_crypto_request(
9931 ts_params->valid_devs[0], ut_params->op),
9932 "failed to process sym crypto op");
9934 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9936 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9937 "crypto op status not success");
9939 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9940 ut_params->op->sym->cipher.data.offset);
9942 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9945 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9947 tdata->plaintext.data,
9948 tdata->plaintext.len,
9949 "Plaintext data not as expected");
9951 TEST_ASSERT_EQUAL(ut_params->op->status,
9952 RTE_CRYPTO_OP_STATUS_SUCCESS,
9953 "Authentication failed");
9958 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9960 return test_authenticated_decryption_sessionless(
9965 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9967 return test_authenticated_encryption(&ccm_test_case_128_1);
9971 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9973 return test_authenticated_encryption(&ccm_test_case_128_2);
9977 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9979 return test_authenticated_encryption(&ccm_test_case_128_3);
9983 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9985 return test_authenticated_decryption(&ccm_test_case_128_1);
9989 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9991 return test_authenticated_decryption(&ccm_test_case_128_2);
9995 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9997 return test_authenticated_decryption(&ccm_test_case_128_3);
10001 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10003 return test_authenticated_encryption(&ccm_test_case_192_1);
10007 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10009 return test_authenticated_encryption(&ccm_test_case_192_2);
10013 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10015 return test_authenticated_encryption(&ccm_test_case_192_3);
10019 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10021 return test_authenticated_decryption(&ccm_test_case_192_1);
10025 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10027 return test_authenticated_decryption(&ccm_test_case_192_2);
10031 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10033 return test_authenticated_decryption(&ccm_test_case_192_3);
10037 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10039 return test_authenticated_encryption(&ccm_test_case_256_1);
10043 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10045 return test_authenticated_encryption(&ccm_test_case_256_2);
10049 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10051 return test_authenticated_encryption(&ccm_test_case_256_3);
10055 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10057 return test_authenticated_decryption(&ccm_test_case_256_1);
10061 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10063 return test_authenticated_decryption(&ccm_test_case_256_2);
10067 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10069 return test_authenticated_decryption(&ccm_test_case_256_3);
10075 struct crypto_testsuite_params *ts_params = &testsuite_params;
10076 struct rte_cryptodev_stats stats;
10078 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10081 /* Verify the capabilities */
10082 struct rte_cryptodev_sym_capability_idx cap_idx;
10083 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10084 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10085 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10088 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10089 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10090 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10094 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10098 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10099 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10100 &stats) == -ENODEV),
10101 "rte_cryptodev_stats_get invalid dev failed");
10102 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10103 "rte_cryptodev_stats_get invalid Param failed");
10105 /* Test expected values */
10106 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10107 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10109 "rte_cryptodev_stats_get failed");
10110 TEST_ASSERT((stats.enqueued_count == 1),
10111 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10112 TEST_ASSERT((stats.dequeued_count == 1),
10113 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10114 TEST_ASSERT((stats.enqueue_err_count == 0),
10115 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10116 TEST_ASSERT((stats.dequeue_err_count == 0),
10117 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10119 /* invalid device but should ignore and not reset device stats*/
10120 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10121 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10123 "rte_cryptodev_stats_get failed");
10124 TEST_ASSERT((stats.enqueued_count == 1),
10125 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10127 /* check that a valid reset clears stats */
10128 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10129 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10131 "rte_cryptodev_stats_get failed");
10132 TEST_ASSERT((stats.enqueued_count == 0),
10133 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10134 TEST_ASSERT((stats.dequeued_count == 0),
10135 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10137 return TEST_SUCCESS;
10140 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10141 struct crypto_unittest_params *ut_params,
10142 enum rte_crypto_auth_operation op,
10143 const struct HMAC_MD5_vector *test_case)
10147 memcpy(key, test_case->key.data, test_case->key.len);
10149 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10150 ut_params->auth_xform.next = NULL;
10151 ut_params->auth_xform.auth.op = op;
10153 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10155 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10156 ut_params->auth_xform.auth.key.length = test_case->key.len;
10157 ut_params->auth_xform.auth.key.data = key;
10159 ut_params->sess = rte_cryptodev_sym_session_create(
10160 ts_params->session_mpool);
10162 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10163 ut_params->sess, &ut_params->auth_xform,
10164 ts_params->session_priv_mpool);
10166 if (ut_params->sess == NULL)
10167 return TEST_FAILED;
10169 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10171 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10172 rte_pktmbuf_tailroom(ut_params->ibuf));
10177 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10178 const struct HMAC_MD5_vector *test_case,
10179 uint8_t **plaintext)
10181 uint16_t plaintext_pad_len;
10183 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10185 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10188 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10189 plaintext_pad_len);
10190 memcpy(*plaintext, test_case->plaintext.data,
10191 test_case->plaintext.len);
10193 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10194 ut_params->ibuf, MD5_DIGEST_LEN);
10195 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10196 "no room to append digest");
10197 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10198 ut_params->ibuf, plaintext_pad_len);
10200 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10201 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10202 test_case->auth_tag.len);
10205 sym_op->auth.data.offset = 0;
10206 sym_op->auth.data.length = test_case->plaintext.len;
10208 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10209 ut_params->op->sym->m_src = ut_params->ibuf;
10215 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10217 uint16_t plaintext_pad_len;
10218 uint8_t *plaintext, *auth_tag;
10220 struct crypto_testsuite_params *ts_params = &testsuite_params;
10221 struct crypto_unittest_params *ut_params = &unittest_params;
10222 struct rte_cryptodev_info dev_info;
10224 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10225 uint64_t feat_flags = dev_info.feature_flags;
10227 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10228 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10229 printf("Device doesn't support RAW data-path APIs.\n");
10233 /* Verify the capabilities */
10234 struct rte_cryptodev_sym_capability_idx cap_idx;
10235 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10236 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10237 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10241 if (MD5_HMAC_create_session(ts_params, ut_params,
10242 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10243 return TEST_FAILED;
10245 /* Generate Crypto op data structure */
10246 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10247 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10248 TEST_ASSERT_NOT_NULL(ut_params->op,
10249 "Failed to allocate symmetric crypto operation struct");
10251 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10254 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10255 return TEST_FAILED;
10257 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10258 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10260 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10261 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10262 ut_params->op, 0, 1, 0, 0);
10264 TEST_ASSERT_NOT_NULL(
10265 process_crypto_request(ts_params->valid_devs[0],
10267 "failed to process sym crypto op");
10269 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10270 "crypto op processing failed");
10272 if (ut_params->op->sym->m_dst) {
10273 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10274 uint8_t *, plaintext_pad_len);
10276 auth_tag = plaintext + plaintext_pad_len;
10279 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10281 test_case->auth_tag.data,
10282 test_case->auth_tag.len,
10283 "HMAC_MD5 generated tag not as expected");
10285 return TEST_SUCCESS;
10289 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10291 uint8_t *plaintext;
10293 struct crypto_testsuite_params *ts_params = &testsuite_params;
10294 struct crypto_unittest_params *ut_params = &unittest_params;
10295 struct rte_cryptodev_info dev_info;
10297 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10298 uint64_t feat_flags = dev_info.feature_flags;
10300 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10301 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10302 printf("Device doesn't support RAW data-path APIs.\n");
10306 /* Verify the capabilities */
10307 struct rte_cryptodev_sym_capability_idx cap_idx;
10308 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10309 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10310 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10314 if (MD5_HMAC_create_session(ts_params, ut_params,
10315 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10316 return TEST_FAILED;
10319 /* Generate Crypto op data structure */
10320 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10321 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10322 TEST_ASSERT_NOT_NULL(ut_params->op,
10323 "Failed to allocate symmetric crypto operation struct");
10325 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10326 return TEST_FAILED;
10328 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10329 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10331 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10332 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10333 ut_params->op, 0, 1, 0, 0);
10335 TEST_ASSERT_NOT_NULL(
10336 process_crypto_request(ts_params->valid_devs[0],
10338 "failed to process sym crypto op");
10340 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10341 "HMAC_MD5 crypto op processing failed");
10343 return TEST_SUCCESS;
10347 test_MD5_HMAC_generate_case_1(void)
10349 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10353 test_MD5_HMAC_verify_case_1(void)
10355 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10359 test_MD5_HMAC_generate_case_2(void)
10361 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10365 test_MD5_HMAC_verify_case_2(void)
10367 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10371 test_multi_session(void)
10373 struct crypto_testsuite_params *ts_params = &testsuite_params;
10374 struct crypto_unittest_params *ut_params = &unittest_params;
10376 struct rte_cryptodev_info dev_info;
10377 struct rte_cryptodev_sym_session **sessions;
10381 /* Verify the capabilities */
10382 struct rte_cryptodev_sym_capability_idx cap_idx;
10383 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10384 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10385 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10388 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10389 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10390 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10394 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10395 aes_cbc_key, hmac_sha512_key);
10398 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10400 sessions = rte_malloc(NULL,
10401 (sizeof(struct rte_cryptodev_sym_session *) *
10402 MAX_NB_SESSIONS) + 1, 0);
10404 /* Create multiple crypto sessions*/
10405 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10407 sessions[i] = rte_cryptodev_sym_session_create(
10408 ts_params->session_mpool);
10410 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10411 sessions[i], &ut_params->auth_xform,
10412 ts_params->session_priv_mpool);
10413 TEST_ASSERT_NOT_NULL(sessions[i],
10414 "Session creation failed at session number %u",
10417 /* Attempt to send a request on each session */
10418 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10422 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10423 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10425 "Failed to perform decrypt on request number %u.", i);
10426 /* free crypto operation structure */
10428 rte_crypto_op_free(ut_params->op);
10431 * free mbuf - both obuf and ibuf are usually the same,
10432 * so check if they point at the same address is necessary,
10433 * to avoid freeing the mbuf twice.
10435 if (ut_params->obuf) {
10436 rte_pktmbuf_free(ut_params->obuf);
10437 if (ut_params->ibuf == ut_params->obuf)
10438 ut_params->ibuf = 0;
10439 ut_params->obuf = 0;
10441 if (ut_params->ibuf) {
10442 rte_pktmbuf_free(ut_params->ibuf);
10443 ut_params->ibuf = 0;
10447 /* Next session create should fail */
10448 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10449 sessions[i], &ut_params->auth_xform,
10450 ts_params->session_priv_mpool);
10451 TEST_ASSERT_NULL(sessions[i],
10452 "Session creation succeeded unexpectedly!");
10454 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10455 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10457 rte_cryptodev_sym_session_free(sessions[i]);
10460 rte_free(sessions);
10462 return TEST_SUCCESS;
10465 struct multi_session_params {
10466 struct crypto_unittest_params ut_params;
10467 uint8_t *cipher_key;
10469 const uint8_t *cipher;
10470 const uint8_t *digest;
10474 #define MB_SESSION_NUMBER 3
10477 test_multi_session_random_usage(void)
10479 struct crypto_testsuite_params *ts_params = &testsuite_params;
10480 struct rte_cryptodev_info dev_info;
10481 struct rte_cryptodev_sym_session **sessions;
10483 struct multi_session_params ut_paramz[] = {
10486 .cipher_key = ms_aes_cbc_key0,
10487 .hmac_key = ms_hmac_key0,
10488 .cipher = ms_aes_cbc_cipher0,
10489 .digest = ms_hmac_digest0,
10490 .iv = ms_aes_cbc_iv0
10493 .cipher_key = ms_aes_cbc_key1,
10494 .hmac_key = ms_hmac_key1,
10495 .cipher = ms_aes_cbc_cipher1,
10496 .digest = ms_hmac_digest1,
10497 .iv = ms_aes_cbc_iv1
10500 .cipher_key = ms_aes_cbc_key2,
10501 .hmac_key = ms_hmac_key2,
10502 .cipher = ms_aes_cbc_cipher2,
10503 .digest = ms_hmac_digest2,
10504 .iv = ms_aes_cbc_iv2
10509 /* Verify the capabilities */
10510 struct rte_cryptodev_sym_capability_idx cap_idx;
10511 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10512 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10513 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10516 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10517 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10518 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10522 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10524 sessions = rte_malloc(NULL,
10525 (sizeof(struct rte_cryptodev_sym_session *)
10526 * MAX_NB_SESSIONS) + 1, 0);
10528 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10529 sessions[i] = rte_cryptodev_sym_session_create(
10530 ts_params->session_mpool);
10532 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10533 sizeof(struct crypto_unittest_params));
10535 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10536 &ut_paramz[i].ut_params,
10537 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10539 /* Create multiple crypto sessions*/
10540 rte_cryptodev_sym_session_init(
10541 ts_params->valid_devs[0],
10543 &ut_paramz[i].ut_params.auth_xform,
10544 ts_params->session_priv_mpool);
10546 TEST_ASSERT_NOT_NULL(sessions[i],
10547 "Session creation failed at session number %u",
10553 for (i = 0; i < 40000; i++) {
10555 j = rand() % MB_SESSION_NUMBER;
10557 TEST_ASSERT_SUCCESS(
10558 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10560 &ut_paramz[j].ut_params,
10561 ts_params, ut_paramz[j].cipher,
10562 ut_paramz[j].digest,
10564 "Failed to perform decrypt on request number %u.", i);
10566 if (ut_paramz[j].ut_params.op)
10567 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10570 * free mbuf - both obuf and ibuf are usually the same,
10571 * so check if they point at the same address is necessary,
10572 * to avoid freeing the mbuf twice.
10574 if (ut_paramz[j].ut_params.obuf) {
10575 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10576 if (ut_paramz[j].ut_params.ibuf
10577 == ut_paramz[j].ut_params.obuf)
10578 ut_paramz[j].ut_params.ibuf = 0;
10579 ut_paramz[j].ut_params.obuf = 0;
10581 if (ut_paramz[j].ut_params.ibuf) {
10582 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10583 ut_paramz[j].ut_params.ibuf = 0;
10587 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10588 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10590 rte_cryptodev_sym_session_free(sessions[i]);
10593 rte_free(sessions);
10595 return TEST_SUCCESS;
10598 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10599 0xab, 0xab, 0xab, 0xab,
10600 0xab, 0xab, 0xab, 0xab,
10601 0xab, 0xab, 0xab, 0xab};
10604 test_null_invalid_operation(void)
10606 struct crypto_testsuite_params *ts_params = &testsuite_params;
10607 struct crypto_unittest_params *ut_params = &unittest_params;
10610 /* This test is for NULL PMD only */
10611 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10612 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10615 /* Setup Cipher Parameters */
10616 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10617 ut_params->cipher_xform.next = NULL;
10619 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10620 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10622 ut_params->sess = rte_cryptodev_sym_session_create(
10623 ts_params->session_mpool);
10625 /* Create Crypto session*/
10626 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10627 ut_params->sess, &ut_params->cipher_xform,
10628 ts_params->session_priv_mpool);
10629 TEST_ASSERT(ret < 0,
10630 "Session creation succeeded unexpectedly");
10633 /* Setup HMAC Parameters */
10634 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10635 ut_params->auth_xform.next = NULL;
10637 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10638 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10640 ut_params->sess = rte_cryptodev_sym_session_create(
10641 ts_params->session_mpool);
10643 /* Create Crypto session*/
10644 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10645 ut_params->sess, &ut_params->auth_xform,
10646 ts_params->session_priv_mpool);
10647 TEST_ASSERT(ret < 0,
10648 "Session creation succeeded unexpectedly");
10650 return TEST_SUCCESS;
10654 #define NULL_BURST_LENGTH (32)
10657 test_null_burst_operation(void)
10659 struct crypto_testsuite_params *ts_params = &testsuite_params;
10660 struct crypto_unittest_params *ut_params = &unittest_params;
10662 unsigned i, burst_len = NULL_BURST_LENGTH;
10664 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10665 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10667 /* This test is for NULL PMD only */
10668 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10669 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10672 /* Setup Cipher Parameters */
10673 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10674 ut_params->cipher_xform.next = &ut_params->auth_xform;
10676 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10677 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10679 /* Setup HMAC Parameters */
10680 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10681 ut_params->auth_xform.next = NULL;
10683 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10684 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10686 ut_params->sess = rte_cryptodev_sym_session_create(
10687 ts_params->session_mpool);
10689 /* Create Crypto session*/
10690 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10691 ut_params->sess, &ut_params->cipher_xform,
10692 ts_params->session_priv_mpool);
10693 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10695 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10696 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10697 burst_len, "failed to generate burst of crypto ops");
10699 /* Generate an operation for each mbuf in burst */
10700 for (i = 0; i < burst_len; i++) {
10701 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10703 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10705 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10709 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10711 burst[i]->sym->m_src = m;
10714 /* Process crypto operation */
10715 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10716 0, burst, burst_len),
10718 "Error enqueuing burst");
10720 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10721 0, burst_dequeued, burst_len),
10723 "Error dequeuing burst");
10726 for (i = 0; i < burst_len; i++) {
10728 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10729 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10731 "data not as expected");
10733 rte_pktmbuf_free(burst[i]->sym->m_src);
10734 rte_crypto_op_free(burst[i]);
10737 return TEST_SUCCESS;
10741 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10742 uint16_t nb_ops, void *user_param)
10744 RTE_SET_USED(dev_id);
10745 RTE_SET_USED(qp_id);
10747 RTE_SET_USED(user_param);
10749 printf("crypto enqueue callback called\n");
10754 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10755 uint16_t nb_ops, void *user_param)
10757 RTE_SET_USED(dev_id);
10758 RTE_SET_USED(qp_id);
10760 RTE_SET_USED(user_param);
10762 printf("crypto dequeue callback called\n");
10767 * Thread using enqueue/dequeue callback with RCU.
10770 test_enqdeq_callback_thread(void *arg)
10773 /* DP thread calls rte_cryptodev_enqueue_burst()/
10774 * rte_cryptodev_dequeue_burst() and invokes callback.
10776 test_null_burst_operation();
10781 test_enq_callback_setup(void)
10783 struct crypto_testsuite_params *ts_params = &testsuite_params;
10784 struct rte_cryptodev_info dev_info;
10785 struct rte_cryptodev_qp_conf qp_conf = {
10786 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10789 struct rte_cryptodev_cb *cb;
10790 uint16_t qp_id = 0;
10792 /* Stop the device in case it's started so it can be configured */
10793 rte_cryptodev_stop(ts_params->valid_devs[0]);
10795 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10797 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10799 "Failed to configure cryptodev %u",
10800 ts_params->valid_devs[0]);
10802 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10803 qp_conf.mp_session = ts_params->session_mpool;
10804 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10806 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10807 ts_params->valid_devs[0], qp_id, &qp_conf,
10808 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10810 "rte_cryptodev_queue_pair_setup: num_inflights "
10811 "%u on qp %u on cryptodev %u",
10812 qp_conf.nb_descriptors, qp_id,
10813 ts_params->valid_devs[0]);
10815 /* Test with invalid crypto device */
10816 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
10817 qp_id, test_enq_callback, NULL);
10818 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10819 "cryptodev %u did not fail",
10820 qp_id, RTE_CRYPTO_MAX_DEVS);
10822 /* Test with invalid queue pair */
10823 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10824 dev_info.max_nb_queue_pairs + 1,
10825 test_enq_callback, NULL);
10826 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10827 "cryptodev %u did not fail",
10828 dev_info.max_nb_queue_pairs + 1,
10829 ts_params->valid_devs[0]);
10831 /* Test with NULL callback */
10832 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10833 qp_id, NULL, NULL);
10834 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10835 "cryptodev %u did not fail",
10836 qp_id, ts_params->valid_devs[0]);
10838 /* Test with valid configuration */
10839 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10840 qp_id, test_enq_callback, NULL);
10841 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10842 "qp %u on cryptodev %u",
10843 qp_id, ts_params->valid_devs[0]);
10845 rte_cryptodev_start(ts_params->valid_devs[0]);
10847 /* Launch a thread */
10848 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10849 rte_get_next_lcore(-1, 1, 0));
10851 /* Wait until reader exited. */
10852 rte_eal_mp_wait_lcore();
10854 /* Test with invalid crypto device */
10855 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10856 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10857 "Expected call to fail as crypto device is invalid");
10859 /* Test with invalid queue pair */
10860 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10861 ts_params->valid_devs[0],
10862 dev_info.max_nb_queue_pairs + 1, cb),
10863 "Expected call to fail as queue pair is invalid");
10865 /* Test with NULL callback */
10866 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10867 ts_params->valid_devs[0], qp_id, NULL),
10868 "Expected call to fail as callback is NULL");
10870 /* Test with valid configuration */
10871 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
10872 ts_params->valid_devs[0], qp_id, cb),
10873 "Failed test to remove callback on "
10874 "qp %u on cryptodev %u",
10875 qp_id, ts_params->valid_devs[0]);
10877 return TEST_SUCCESS;
10881 test_deq_callback_setup(void)
10883 struct crypto_testsuite_params *ts_params = &testsuite_params;
10884 struct rte_cryptodev_info dev_info;
10885 struct rte_cryptodev_qp_conf qp_conf = {
10886 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10889 struct rte_cryptodev_cb *cb;
10890 uint16_t qp_id = 0;
10892 /* Stop the device in case it's started so it can be configured */
10893 rte_cryptodev_stop(ts_params->valid_devs[0]);
10895 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10897 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10899 "Failed to configure cryptodev %u",
10900 ts_params->valid_devs[0]);
10902 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10903 qp_conf.mp_session = ts_params->session_mpool;
10904 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10906 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10907 ts_params->valid_devs[0], qp_id, &qp_conf,
10908 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10910 "rte_cryptodev_queue_pair_setup: num_inflights "
10911 "%u on qp %u on cryptodev %u",
10912 qp_conf.nb_descriptors, qp_id,
10913 ts_params->valid_devs[0]);
10915 /* Test with invalid crypto device */
10916 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
10917 qp_id, test_deq_callback, NULL);
10918 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10919 "cryptodev %u did not fail",
10920 qp_id, RTE_CRYPTO_MAX_DEVS);
10922 /* Test with invalid queue pair */
10923 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10924 dev_info.max_nb_queue_pairs + 1,
10925 test_deq_callback, NULL);
10926 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10927 "cryptodev %u did not fail",
10928 dev_info.max_nb_queue_pairs + 1,
10929 ts_params->valid_devs[0]);
10931 /* Test with NULL callback */
10932 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10933 qp_id, NULL, NULL);
10934 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10935 "cryptodev %u did not fail",
10936 qp_id, ts_params->valid_devs[0]);
10938 /* Test with valid configuration */
10939 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10940 qp_id, test_deq_callback, NULL);
10941 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10942 "qp %u on cryptodev %u",
10943 qp_id, ts_params->valid_devs[0]);
10945 rte_cryptodev_start(ts_params->valid_devs[0]);
10947 /* Launch a thread */
10948 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10949 rte_get_next_lcore(-1, 1, 0));
10951 /* Wait until reader exited. */
10952 rte_eal_mp_wait_lcore();
10954 /* Test with invalid crypto device */
10955 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10956 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10957 "Expected call to fail as crypto device is invalid");
10959 /* Test with invalid queue pair */
10960 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10961 ts_params->valid_devs[0],
10962 dev_info.max_nb_queue_pairs + 1, cb),
10963 "Expected call to fail as queue pair is invalid");
10965 /* Test with NULL callback */
10966 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10967 ts_params->valid_devs[0], qp_id, NULL),
10968 "Expected call to fail as callback is NULL");
10970 /* Test with valid configuration */
10971 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
10972 ts_params->valid_devs[0], qp_id, cb),
10973 "Failed test to remove callback on "
10974 "qp %u on cryptodev %u",
10975 qp_id, ts_params->valid_devs[0]);
10977 return TEST_SUCCESS;
10981 generate_gmac_large_plaintext(uint8_t *data)
10985 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10986 memcpy(&data[i], &data[0], 32);
10990 create_gmac_operation(enum rte_crypto_auth_operation op,
10991 const struct gmac_test_data *tdata)
10993 struct crypto_testsuite_params *ts_params = &testsuite_params;
10994 struct crypto_unittest_params *ut_params = &unittest_params;
10995 struct rte_crypto_sym_op *sym_op;
10997 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10999 /* Generate Crypto op data structure */
11000 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11001 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11002 TEST_ASSERT_NOT_NULL(ut_params->op,
11003 "Failed to allocate symmetric crypto operation struct");
11005 sym_op = ut_params->op->sym;
11007 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11008 ut_params->ibuf, tdata->gmac_tag.len);
11009 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11010 "no room to append digest");
11012 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11013 ut_params->ibuf, plaintext_pad_len);
11015 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11016 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11017 tdata->gmac_tag.len);
11018 debug_hexdump(stdout, "digest:",
11019 sym_op->auth.digest.data,
11020 tdata->gmac_tag.len);
11023 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11024 uint8_t *, IV_OFFSET);
11026 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11028 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11030 sym_op->cipher.data.length = 0;
11031 sym_op->cipher.data.offset = 0;
11033 sym_op->auth.data.offset = 0;
11034 sym_op->auth.data.length = tdata->plaintext.len;
11040 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11041 const struct gmac_test_data *tdata,
11042 void *digest_mem, uint64_t digest_phys)
11044 struct crypto_testsuite_params *ts_params = &testsuite_params;
11045 struct crypto_unittest_params *ut_params = &unittest_params;
11046 struct rte_crypto_sym_op *sym_op;
11048 /* Generate Crypto op data structure */
11049 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11050 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11051 TEST_ASSERT_NOT_NULL(ut_params->op,
11052 "Failed to allocate symmetric crypto operation struct");
11054 sym_op = ut_params->op->sym;
11056 sym_op->auth.digest.data = digest_mem;
11057 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11058 "no room to append digest");
11060 sym_op->auth.digest.phys_addr = digest_phys;
11062 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11063 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11064 tdata->gmac_tag.len);
11065 debug_hexdump(stdout, "digest:",
11066 sym_op->auth.digest.data,
11067 tdata->gmac_tag.len);
11070 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11071 uint8_t *, IV_OFFSET);
11073 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11075 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11077 sym_op->cipher.data.length = 0;
11078 sym_op->cipher.data.offset = 0;
11080 sym_op->auth.data.offset = 0;
11081 sym_op->auth.data.length = tdata->plaintext.len;
11086 static int create_gmac_session(uint8_t dev_id,
11087 const struct gmac_test_data *tdata,
11088 enum rte_crypto_auth_operation auth_op)
11090 uint8_t auth_key[tdata->key.len];
11092 struct crypto_testsuite_params *ts_params = &testsuite_params;
11093 struct crypto_unittest_params *ut_params = &unittest_params;
11095 memcpy(auth_key, tdata->key.data, tdata->key.len);
11097 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11098 ut_params->auth_xform.next = NULL;
11100 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11101 ut_params->auth_xform.auth.op = auth_op;
11102 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11103 ut_params->auth_xform.auth.key.length = tdata->key.len;
11104 ut_params->auth_xform.auth.key.data = auth_key;
11105 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11106 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11109 ut_params->sess = rte_cryptodev_sym_session_create(
11110 ts_params->session_mpool);
11112 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11113 &ut_params->auth_xform,
11114 ts_params->session_priv_mpool);
11116 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11122 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11124 struct crypto_testsuite_params *ts_params = &testsuite_params;
11125 struct crypto_unittest_params *ut_params = &unittest_params;
11126 struct rte_cryptodev_info dev_info;
11128 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11129 uint64_t feat_flags = dev_info.feature_flags;
11131 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11132 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11133 printf("Device doesn't support RAW data-path APIs.\n");
11139 uint8_t *auth_tag, *plaintext;
11140 uint16_t plaintext_pad_len;
11142 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11143 "No GMAC length in the source data");
11145 /* Verify the capabilities */
11146 struct rte_cryptodev_sym_capability_idx cap_idx;
11147 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11148 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11149 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11153 retval = create_gmac_session(ts_params->valid_devs[0],
11154 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11159 if (tdata->plaintext.len > MBUF_SIZE)
11160 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11163 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11164 "Failed to allocate input buffer in mempool");
11166 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11167 rte_pktmbuf_tailroom(ut_params->ibuf));
11169 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11171 * Runtime generate the large plain text instead of use hard code
11172 * plain text vector. It is done to avoid create huge source file
11173 * with the test vector.
11175 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11176 generate_gmac_large_plaintext(tdata->plaintext.data);
11178 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11179 plaintext_pad_len);
11180 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11182 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11183 debug_hexdump(stdout, "plaintext:", plaintext,
11184 tdata->plaintext.len);
11186 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11192 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11194 ut_params->op->sym->m_src = ut_params->ibuf;
11196 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11197 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11199 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11200 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11201 ut_params->op, 0, 1, 0, 0);
11203 TEST_ASSERT_NOT_NULL(
11204 process_crypto_request(ts_params->valid_devs[0],
11205 ut_params->op), "failed to process sym crypto op");
11207 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11208 "crypto op processing failed");
11210 if (ut_params->op->sym->m_dst) {
11211 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11212 uint8_t *, plaintext_pad_len);
11214 auth_tag = plaintext + plaintext_pad_len;
11217 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11219 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11221 tdata->gmac_tag.data,
11222 tdata->gmac_tag.len,
11223 "GMAC Generated auth tag not as expected");
11229 test_AES_GMAC_authentication_test_case_1(void)
11231 return test_AES_GMAC_authentication(&gmac_test_case_1);
11235 test_AES_GMAC_authentication_test_case_2(void)
11237 return test_AES_GMAC_authentication(&gmac_test_case_2);
11241 test_AES_GMAC_authentication_test_case_3(void)
11243 return test_AES_GMAC_authentication(&gmac_test_case_3);
11247 test_AES_GMAC_authentication_test_case_4(void)
11249 return test_AES_GMAC_authentication(&gmac_test_case_4);
11253 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11255 struct crypto_testsuite_params *ts_params = &testsuite_params;
11256 struct crypto_unittest_params *ut_params = &unittest_params;
11258 uint32_t plaintext_pad_len;
11259 uint8_t *plaintext;
11260 struct rte_cryptodev_info dev_info;
11262 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11263 uint64_t feat_flags = dev_info.feature_flags;
11265 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11266 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11267 printf("Device doesn't support RAW data-path APIs.\n");
11271 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11272 "No GMAC length in the source data");
11274 /* Verify the capabilities */
11275 struct rte_cryptodev_sym_capability_idx cap_idx;
11276 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11277 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11278 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11282 retval = create_gmac_session(ts_params->valid_devs[0],
11283 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11288 if (tdata->plaintext.len > MBUF_SIZE)
11289 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11291 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11292 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11293 "Failed to allocate input buffer in mempool");
11295 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11296 rte_pktmbuf_tailroom(ut_params->ibuf));
11298 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11301 * Runtime generate the large plain text instead of use hard code
11302 * plain text vector. It is done to avoid create huge source file
11303 * with the test vector.
11305 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11306 generate_gmac_large_plaintext(tdata->plaintext.data);
11308 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11309 plaintext_pad_len);
11310 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11312 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11313 debug_hexdump(stdout, "plaintext:", plaintext,
11314 tdata->plaintext.len);
11316 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11322 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11324 ut_params->op->sym->m_src = ut_params->ibuf;
11326 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11327 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11329 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11330 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11331 ut_params->op, 0, 1, 0, 0);
11333 TEST_ASSERT_NOT_NULL(
11334 process_crypto_request(ts_params->valid_devs[0],
11335 ut_params->op), "failed to process sym crypto op");
11337 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11338 "crypto op processing failed");
11345 test_AES_GMAC_authentication_verify_test_case_1(void)
11347 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11351 test_AES_GMAC_authentication_verify_test_case_2(void)
11353 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11357 test_AES_GMAC_authentication_verify_test_case_3(void)
11359 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11363 test_AES_GMAC_authentication_verify_test_case_4(void)
11365 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11369 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11372 struct crypto_testsuite_params *ts_params = &testsuite_params;
11373 struct crypto_unittest_params *ut_params = &unittest_params;
11374 struct rte_cryptodev_info dev_info;
11375 uint64_t feature_flags;
11376 unsigned int trn_data = 0;
11377 void *digest_mem = NULL;
11379 unsigned int to_trn = 0;
11380 struct rte_mbuf *buf = NULL;
11381 uint8_t *auth_tag, *plaintext;
11384 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11385 "No GMAC length in the source data");
11387 /* Verify the capabilities */
11388 struct rte_cryptodev_sym_capability_idx cap_idx;
11389 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11390 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11391 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11395 /* Check for any input SGL support */
11396 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11397 feature_flags = dev_info.feature_flags;
11399 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11400 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11401 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11404 if (fragsz > tdata->plaintext.len)
11405 fragsz = tdata->plaintext.len;
11407 uint16_t plaintext_len = fragsz;
11409 retval = create_gmac_session(ts_params->valid_devs[0],
11410 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11415 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11416 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11417 "Failed to allocate input buffer in mempool");
11419 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11420 rte_pktmbuf_tailroom(ut_params->ibuf));
11422 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11424 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11426 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11428 trn_data += plaintext_len;
11430 buf = ut_params->ibuf;
11433 * Loop until no more fragments
11436 while (trn_data < tdata->plaintext.len) {
11438 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11439 (tdata->plaintext.len - trn_data) : fragsz;
11441 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11444 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11445 rte_pktmbuf_tailroom(buf));
11447 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11450 memcpy(plaintext, tdata->plaintext.data + trn_data,
11452 trn_data += to_trn;
11453 if (trn_data == tdata->plaintext.len)
11454 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11455 tdata->gmac_tag.len);
11457 ut_params->ibuf->nb_segs = segs;
11460 * Place digest at the end of the last buffer
11462 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11465 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11466 + tdata->gmac_tag.len);
11467 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11468 tdata->plaintext.len);
11471 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11472 tdata, digest_mem, digest_phys);
11477 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11479 ut_params->op->sym->m_src = ut_params->ibuf;
11481 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11484 TEST_ASSERT_NOT_NULL(
11485 process_crypto_request(ts_params->valid_devs[0],
11486 ut_params->op), "failed to process sym crypto op");
11488 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11489 "crypto op processing failed");
11491 auth_tag = digest_mem;
11492 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11493 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11495 tdata->gmac_tag.data,
11496 tdata->gmac_tag.len,
11497 "GMAC Generated auth tag not as expected");
11502 /* Segment size not multiple of block size (16B) */
11504 test_AES_GMAC_authentication_SGL_40B(void)
11506 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11510 test_AES_GMAC_authentication_SGL_80B(void)
11512 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11516 test_AES_GMAC_authentication_SGL_2048B(void)
11518 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11521 /* Segment size not multiple of block size (16B) */
11523 test_AES_GMAC_authentication_SGL_2047B(void)
11525 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11528 struct test_crypto_vector {
11529 enum rte_crypto_cipher_algorithm crypto_algo;
11530 unsigned int cipher_offset;
11531 unsigned int cipher_len;
11544 const uint8_t *data;
11549 const uint8_t *data;
11553 enum rte_crypto_auth_algorithm auth_algo;
11554 unsigned int auth_offset;
11562 const uint8_t *data;
11572 static const struct test_crypto_vector
11573 hmac_sha1_test_crypto_vector = {
11574 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11576 .data = plaintext_hash,
11581 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11582 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11583 0xDE, 0xF4, 0xDE, 0xAD
11589 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11590 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11591 0x3F, 0x91, 0x64, 0x59
11597 static const struct test_crypto_vector
11598 aes128_gmac_test_vector = {
11599 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11601 .data = plaintext_hash,
11606 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11607 0x08, 0x09, 0x0A, 0x0B
11613 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11614 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11620 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11621 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11627 static const struct test_crypto_vector
11628 aes128cbc_hmac_sha1_test_vector = {
11629 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11630 .cipher_offset = 0,
11634 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11635 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11641 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11642 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11647 .data = plaintext_hash,
11651 .data = ciphertext512_aes128cbc,
11654 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11658 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11659 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11660 0xDE, 0xF4, 0xDE, 0xAD
11666 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
11667 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11668 0x18, 0x8C, 0x1D, 0x32
11674 static const struct test_crypto_vector
11675 aes128cbc_hmac_sha1_aad_test_vector = {
11676 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11677 .cipher_offset = 8,
11681 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11682 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11688 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11689 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11694 .data = plaintext_hash,
11698 .data = ciphertext512_aes128cbc_aad,
11701 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11705 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11706 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11707 0xDE, 0xF4, 0xDE, 0xAD
11713 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
11714 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
11715 0x62, 0x0F, 0xFB, 0x10
11722 data_corruption(uint8_t *data)
11728 tag_corruption(uint8_t *data, unsigned int tag_offset)
11730 data[tag_offset] += 1;
11734 create_auth_session(struct crypto_unittest_params *ut_params,
11736 const struct test_crypto_vector *reference,
11737 enum rte_crypto_auth_operation auth_op)
11739 struct crypto_testsuite_params *ts_params = &testsuite_params;
11740 uint8_t auth_key[reference->auth_key.len + 1];
11742 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11744 /* Setup Authentication Parameters */
11745 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11746 ut_params->auth_xform.auth.op = auth_op;
11747 ut_params->auth_xform.next = NULL;
11748 ut_params->auth_xform.auth.algo = reference->auth_algo;
11749 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11750 ut_params->auth_xform.auth.key.data = auth_key;
11751 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11753 /* Create Crypto session*/
11754 ut_params->sess = rte_cryptodev_sym_session_create(
11755 ts_params->session_mpool);
11757 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11758 &ut_params->auth_xform,
11759 ts_params->session_priv_mpool);
11761 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11767 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
11769 const struct test_crypto_vector *reference,
11770 enum rte_crypto_auth_operation auth_op,
11771 enum rte_crypto_cipher_operation cipher_op)
11773 struct crypto_testsuite_params *ts_params = &testsuite_params;
11774 uint8_t cipher_key[reference->cipher_key.len + 1];
11775 uint8_t auth_key[reference->auth_key.len + 1];
11777 memcpy(cipher_key, reference->cipher_key.data,
11778 reference->cipher_key.len);
11779 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11781 /* Setup Authentication Parameters */
11782 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11783 ut_params->auth_xform.auth.op = auth_op;
11784 ut_params->auth_xform.auth.algo = reference->auth_algo;
11785 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11786 ut_params->auth_xform.auth.key.data = auth_key;
11787 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11789 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
11790 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11791 ut_params->auth_xform.auth.iv.length = reference->iv.len;
11793 ut_params->auth_xform.next = &ut_params->cipher_xform;
11795 /* Setup Cipher Parameters */
11796 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11797 ut_params->cipher_xform.next = NULL;
11798 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11799 ut_params->cipher_xform.cipher.op = cipher_op;
11800 ut_params->cipher_xform.cipher.key.data = cipher_key;
11801 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11802 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11803 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11806 /* Create Crypto session*/
11807 ut_params->sess = rte_cryptodev_sym_session_create(
11808 ts_params->session_mpool);
11810 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11811 &ut_params->auth_xform,
11812 ts_params->session_priv_mpool);
11814 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11820 create_auth_operation(struct crypto_testsuite_params *ts_params,
11821 struct crypto_unittest_params *ut_params,
11822 const struct test_crypto_vector *reference,
11823 unsigned int auth_generate)
11825 /* Generate Crypto op data structure */
11826 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11827 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11828 TEST_ASSERT_NOT_NULL(ut_params->op,
11829 "Failed to allocate pktmbuf offload");
11831 /* Set crypto operation data parameters */
11832 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11834 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11836 /* set crypto operation source mbuf */
11837 sym_op->m_src = ut_params->ibuf;
11840 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11841 ut_params->ibuf, reference->digest.len);
11843 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11844 "no room to append auth tag");
11846 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11847 ut_params->ibuf, reference->plaintext.len);
11850 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11852 memcpy(sym_op->auth.digest.data,
11853 reference->digest.data,
11854 reference->digest.len);
11856 debug_hexdump(stdout, "digest:",
11857 sym_op->auth.digest.data,
11858 reference->digest.len);
11860 sym_op->auth.data.length = reference->plaintext.len;
11861 sym_op->auth.data.offset = 0;
11867 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
11868 struct crypto_unittest_params *ut_params,
11869 const struct test_crypto_vector *reference,
11870 unsigned int auth_generate)
11872 /* Generate Crypto op data structure */
11873 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11874 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11875 TEST_ASSERT_NOT_NULL(ut_params->op,
11876 "Failed to allocate pktmbuf offload");
11878 /* Set crypto operation data parameters */
11879 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11881 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11883 /* set crypto operation source mbuf */
11884 sym_op->m_src = ut_params->ibuf;
11887 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11888 ut_params->ibuf, reference->digest.len);
11890 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11891 "no room to append auth tag");
11893 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11894 ut_params->ibuf, reference->ciphertext.len);
11897 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11899 memcpy(sym_op->auth.digest.data,
11900 reference->digest.data,
11901 reference->digest.len);
11903 debug_hexdump(stdout, "digest:",
11904 sym_op->auth.digest.data,
11905 reference->digest.len);
11907 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11908 reference->iv.data, reference->iv.len);
11910 sym_op->cipher.data.length = 0;
11911 sym_op->cipher.data.offset = 0;
11913 sym_op->auth.data.length = reference->plaintext.len;
11914 sym_op->auth.data.offset = 0;
11920 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11921 struct crypto_unittest_params *ut_params,
11922 const struct test_crypto_vector *reference,
11923 unsigned int auth_generate)
11925 /* Generate Crypto op data structure */
11926 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11927 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11928 TEST_ASSERT_NOT_NULL(ut_params->op,
11929 "Failed to allocate pktmbuf offload");
11931 /* Set crypto operation data parameters */
11932 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11934 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11936 /* set crypto operation source mbuf */
11937 sym_op->m_src = ut_params->ibuf;
11940 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11941 ut_params->ibuf, reference->digest.len);
11943 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11944 "no room to append auth tag");
11946 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11947 ut_params->ibuf, reference->ciphertext.len);
11950 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11952 memcpy(sym_op->auth.digest.data,
11953 reference->digest.data,
11954 reference->digest.len);
11956 debug_hexdump(stdout, "digest:",
11957 sym_op->auth.digest.data,
11958 reference->digest.len);
11960 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11961 reference->iv.data, reference->iv.len);
11963 sym_op->cipher.data.length = reference->cipher_len;
11964 sym_op->cipher.data.offset = reference->cipher_offset;
11966 sym_op->auth.data.length = reference->plaintext.len;
11967 sym_op->auth.data.offset = reference->auth_offset;
11973 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11974 struct crypto_unittest_params *ut_params,
11975 const struct test_crypto_vector *reference)
11977 return create_auth_operation(ts_params, ut_params, reference, 0);
11981 create_auth_verify_GMAC_operation(
11982 struct crypto_testsuite_params *ts_params,
11983 struct crypto_unittest_params *ut_params,
11984 const struct test_crypto_vector *reference)
11986 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11990 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11991 struct crypto_unittest_params *ut_params,
11992 const struct test_crypto_vector *reference)
11994 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11998 test_authentication_verify_fail_when_data_corruption(
11999 struct crypto_testsuite_params *ts_params,
12000 struct crypto_unittest_params *ut_params,
12001 const struct test_crypto_vector *reference,
12002 unsigned int data_corrupted)
12006 uint8_t *plaintext;
12007 struct rte_cryptodev_info dev_info;
12009 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12010 uint64_t feat_flags = dev_info.feature_flags;
12012 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12013 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12014 printf("Device doesn't support RAW data-path APIs.\n");
12018 /* Verify the capabilities */
12019 struct rte_cryptodev_sym_capability_idx cap_idx;
12020 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12021 cap_idx.algo.auth = reference->auth_algo;
12022 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12027 /* Create session */
12028 retval = create_auth_session(ut_params,
12029 ts_params->valid_devs[0],
12031 RTE_CRYPTO_AUTH_OP_VERIFY);
12035 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12036 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12037 "Failed to allocate input buffer in mempool");
12039 /* clear mbuf payload */
12040 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12041 rte_pktmbuf_tailroom(ut_params->ibuf));
12043 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12044 reference->plaintext.len);
12045 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12046 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12048 debug_hexdump(stdout, "plaintext:", plaintext,
12049 reference->plaintext.len);
12051 /* Create operation */
12052 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12057 if (data_corrupted)
12058 data_corruption(plaintext);
12060 tag_corruption(plaintext, reference->plaintext.len);
12062 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12063 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12065 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12066 RTE_CRYPTO_OP_STATUS_SUCCESS,
12067 "authentication not failed");
12068 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12069 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12070 ut_params->op, 0, 1, 0, 0);
12072 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12074 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12081 test_authentication_verify_GMAC_fail_when_corruption(
12082 struct crypto_testsuite_params *ts_params,
12083 struct crypto_unittest_params *ut_params,
12084 const struct test_crypto_vector *reference,
12085 unsigned int data_corrupted)
12088 uint8_t *plaintext;
12089 struct rte_cryptodev_info dev_info;
12091 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12092 uint64_t feat_flags = dev_info.feature_flags;
12094 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12095 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12096 printf("Device doesn't support RAW data-path APIs.\n");
12100 /* Verify the capabilities */
12101 struct rte_cryptodev_sym_capability_idx cap_idx;
12102 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12103 cap_idx.algo.auth = reference->auth_algo;
12104 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12108 /* Create session */
12109 retval = create_auth_cipher_session(ut_params,
12110 ts_params->valid_devs[0],
12112 RTE_CRYPTO_AUTH_OP_VERIFY,
12113 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12117 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12118 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12119 "Failed to allocate input buffer in mempool");
12121 /* clear mbuf payload */
12122 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12123 rte_pktmbuf_tailroom(ut_params->ibuf));
12125 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12126 reference->plaintext.len);
12127 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12128 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12130 debug_hexdump(stdout, "plaintext:", plaintext,
12131 reference->plaintext.len);
12133 /* Create operation */
12134 retval = create_auth_verify_GMAC_operation(ts_params,
12141 if (data_corrupted)
12142 data_corruption(plaintext);
12144 tag_corruption(plaintext, reference->aad.len);
12146 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12147 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12149 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12150 RTE_CRYPTO_OP_STATUS_SUCCESS,
12151 "authentication not failed");
12152 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12153 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12154 ut_params->op, 0, 1, 0, 0);
12156 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12158 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12165 test_authenticated_decryption_fail_when_corruption(
12166 struct crypto_testsuite_params *ts_params,
12167 struct crypto_unittest_params *ut_params,
12168 const struct test_crypto_vector *reference,
12169 unsigned int data_corrupted)
12173 uint8_t *ciphertext;
12174 struct rte_cryptodev_info dev_info;
12176 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12177 uint64_t feat_flags = dev_info.feature_flags;
12179 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12180 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12181 printf("Device doesn't support RAW data-path APIs.\n");
12185 /* Verify the capabilities */
12186 struct rte_cryptodev_sym_capability_idx cap_idx;
12187 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12188 cap_idx.algo.auth = reference->auth_algo;
12189 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12192 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12193 cap_idx.algo.cipher = reference->crypto_algo;
12194 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12198 /* Create session */
12199 retval = create_auth_cipher_session(ut_params,
12200 ts_params->valid_devs[0],
12202 RTE_CRYPTO_AUTH_OP_VERIFY,
12203 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12207 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12208 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12209 "Failed to allocate input buffer in mempool");
12211 /* clear mbuf payload */
12212 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12213 rte_pktmbuf_tailroom(ut_params->ibuf));
12215 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12216 reference->ciphertext.len);
12217 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12218 memcpy(ciphertext, reference->ciphertext.data,
12219 reference->ciphertext.len);
12221 /* Create operation */
12222 retval = create_cipher_auth_verify_operation(ts_params,
12229 if (data_corrupted)
12230 data_corruption(ciphertext);
12232 tag_corruption(ciphertext, reference->ciphertext.len);
12234 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12235 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12237 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12238 RTE_CRYPTO_OP_STATUS_SUCCESS,
12239 "authentication not failed");
12240 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12241 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12242 ut_params->op, 1, 1, 0, 0);
12244 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12246 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12253 test_authenticated_encryt_with_esn(
12254 struct crypto_testsuite_params *ts_params,
12255 struct crypto_unittest_params *ut_params,
12256 const struct test_crypto_vector *reference)
12260 uint8_t *authciphertext, *plaintext, *auth_tag;
12261 uint16_t plaintext_pad_len;
12262 uint8_t cipher_key[reference->cipher_key.len + 1];
12263 uint8_t auth_key[reference->auth_key.len + 1];
12264 struct rte_cryptodev_info dev_info;
12266 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12267 uint64_t feat_flags = dev_info.feature_flags;
12269 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12270 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12271 printf("Device doesn't support RAW data-path APIs.\n");
12275 /* Verify the capabilities */
12276 struct rte_cryptodev_sym_capability_idx cap_idx;
12277 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12278 cap_idx.algo.auth = reference->auth_algo;
12279 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12282 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12283 cap_idx.algo.cipher = reference->crypto_algo;
12284 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12288 /* Create session */
12289 memcpy(cipher_key, reference->cipher_key.data,
12290 reference->cipher_key.len);
12291 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12293 /* Setup Cipher Parameters */
12294 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12295 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12296 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12297 ut_params->cipher_xform.cipher.key.data = cipher_key;
12298 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12299 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12300 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12302 ut_params->cipher_xform.next = &ut_params->auth_xform;
12304 /* Setup Authentication Parameters */
12305 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12306 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12307 ut_params->auth_xform.auth.algo = reference->auth_algo;
12308 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12309 ut_params->auth_xform.auth.key.data = auth_key;
12310 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12311 ut_params->auth_xform.next = NULL;
12313 /* Create Crypto session*/
12314 ut_params->sess = rte_cryptodev_sym_session_create(
12315 ts_params->session_mpool);
12317 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12319 &ut_params->cipher_xform,
12320 ts_params->session_priv_mpool);
12322 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12325 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12326 "Failed to allocate input buffer in mempool");
12328 /* clear mbuf payload */
12329 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12330 rte_pktmbuf_tailroom(ut_params->ibuf));
12332 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12333 reference->plaintext.len);
12334 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12335 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12337 /* Create operation */
12338 retval = create_cipher_auth_operation(ts_params,
12345 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12346 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12348 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12349 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12350 ut_params->op, 1, 1, 0, 0);
12352 ut_params->op = process_crypto_request(
12353 ts_params->valid_devs[0], ut_params->op);
12355 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12357 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12358 "crypto op processing failed");
12360 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12362 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12363 ut_params->op->sym->auth.data.offset);
12364 auth_tag = authciphertext + plaintext_pad_len;
12365 debug_hexdump(stdout, "ciphertext:", authciphertext,
12366 reference->ciphertext.len);
12367 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12369 /* Validate obuf */
12370 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12372 reference->ciphertext.data,
12373 reference->ciphertext.len,
12374 "Ciphertext data not as expected");
12376 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12378 reference->digest.data,
12379 reference->digest.len,
12380 "Generated digest not as expected");
12382 return TEST_SUCCESS;
12387 test_authenticated_decrypt_with_esn(
12388 struct crypto_testsuite_params *ts_params,
12389 struct crypto_unittest_params *ut_params,
12390 const struct test_crypto_vector *reference)
12394 uint8_t *ciphertext;
12395 uint8_t cipher_key[reference->cipher_key.len + 1];
12396 uint8_t auth_key[reference->auth_key.len + 1];
12397 struct rte_cryptodev_info dev_info;
12399 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12400 uint64_t feat_flags = dev_info.feature_flags;
12402 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12403 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12404 printf("Device doesn't support RAW data-path APIs.\n");
12408 /* Verify the capabilities */
12409 struct rte_cryptodev_sym_capability_idx cap_idx;
12410 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12411 cap_idx.algo.auth = reference->auth_algo;
12412 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12415 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12416 cap_idx.algo.cipher = reference->crypto_algo;
12417 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12421 /* Create session */
12422 memcpy(cipher_key, reference->cipher_key.data,
12423 reference->cipher_key.len);
12424 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12426 /* Setup Authentication Parameters */
12427 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12428 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12429 ut_params->auth_xform.auth.algo = reference->auth_algo;
12430 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12431 ut_params->auth_xform.auth.key.data = auth_key;
12432 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12433 ut_params->auth_xform.next = &ut_params->cipher_xform;
12435 /* Setup Cipher Parameters */
12436 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12437 ut_params->cipher_xform.next = NULL;
12438 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12439 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12440 ut_params->cipher_xform.cipher.key.data = cipher_key;
12441 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12442 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12443 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12445 /* Create Crypto session*/
12446 ut_params->sess = rte_cryptodev_sym_session_create(
12447 ts_params->session_mpool);
12449 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12451 &ut_params->auth_xform,
12452 ts_params->session_priv_mpool);
12454 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12456 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12457 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12458 "Failed to allocate input buffer in mempool");
12460 /* clear mbuf payload */
12461 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12462 rte_pktmbuf_tailroom(ut_params->ibuf));
12464 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12465 reference->ciphertext.len);
12466 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12467 memcpy(ciphertext, reference->ciphertext.data,
12468 reference->ciphertext.len);
12470 /* Create operation */
12471 retval = create_cipher_auth_verify_operation(ts_params,
12478 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12479 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12481 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12482 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12483 ut_params->op, 1, 1, 0, 0);
12485 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12488 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12489 TEST_ASSERT_EQUAL(ut_params->op->status,
12490 RTE_CRYPTO_OP_STATUS_SUCCESS,
12491 "crypto op processing passed");
12493 ut_params->obuf = ut_params->op->sym->m_src;
12494 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12500 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12501 const struct aead_test_data *tdata,
12502 void *digest_mem, uint64_t digest_phys)
12504 struct crypto_testsuite_params *ts_params = &testsuite_params;
12505 struct crypto_unittest_params *ut_params = &unittest_params;
12507 const unsigned int auth_tag_len = tdata->auth_tag.len;
12508 const unsigned int iv_len = tdata->iv.len;
12509 unsigned int aad_len = tdata->aad.len;
12510 unsigned int aad_len_pad = 0;
12512 /* Generate Crypto op data structure */
12513 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12514 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12515 TEST_ASSERT_NOT_NULL(ut_params->op,
12516 "Failed to allocate symmetric crypto operation struct");
12518 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12520 sym_op->aead.digest.data = digest_mem;
12522 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12523 "no room to append digest");
12525 sym_op->aead.digest.phys_addr = digest_phys;
12527 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12528 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12530 debug_hexdump(stdout, "digest:",
12531 sym_op->aead.digest.data,
12535 /* Append aad data */
12536 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12537 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12538 uint8_t *, IV_OFFSET);
12540 /* Copy IV 1 byte after the IV pointer, according to the API */
12541 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12543 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12545 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12546 ut_params->ibuf, aad_len);
12547 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12548 "no room to prepend aad");
12549 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12552 memset(sym_op->aead.aad.data, 0, aad_len);
12553 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12554 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12556 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12557 debug_hexdump(stdout, "aad:",
12558 sym_op->aead.aad.data, aad_len);
12560 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12561 uint8_t *, IV_OFFSET);
12563 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12565 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12567 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12568 ut_params->ibuf, aad_len_pad);
12569 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12570 "no room to prepend aad");
12571 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12574 memset(sym_op->aead.aad.data, 0, aad_len);
12575 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12577 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12578 debug_hexdump(stdout, "aad:",
12579 sym_op->aead.aad.data, aad_len);
12582 sym_op->aead.data.length = tdata->plaintext.len;
12583 sym_op->aead.data.offset = aad_len_pad;
12588 #define SGL_MAX_NO 16
12591 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12592 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12594 struct crypto_testsuite_params *ts_params = &testsuite_params;
12595 struct crypto_unittest_params *ut_params = &unittest_params;
12596 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12599 int to_trn_tbl[SGL_MAX_NO];
12601 unsigned int trn_data = 0;
12602 uint8_t *plaintext, *ciphertext, *auth_tag;
12603 struct rte_cryptodev_info dev_info;
12605 /* Verify the capabilities */
12606 struct rte_cryptodev_sym_capability_idx cap_idx;
12607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12608 cap_idx.algo.aead = tdata->algo;
12609 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12613 /* OOP not supported with CPU crypto */
12614 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12617 /* Detailed check for the particular SGL support flag */
12618 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12620 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12621 if (sgl_in && (!(dev_info.feature_flags &
12622 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12625 uint64_t feat_flags = dev_info.feature_flags;
12627 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12628 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12629 printf("Device doesn't support RAW data-path APIs.\n");
12633 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12634 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12635 tdata->plaintext.len;
12636 /* Raw data path API does not support OOP */
12637 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12639 if (sgl_in && !sgl_out) {
12640 if (!(dev_info.feature_flags &
12641 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12643 } else if (!sgl_in && sgl_out) {
12644 if (!(dev_info.feature_flags &
12645 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12647 } else if (sgl_in && sgl_out) {
12648 if (!(dev_info.feature_flags &
12649 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12654 if (fragsz > tdata->plaintext.len)
12655 fragsz = tdata->plaintext.len;
12657 uint16_t plaintext_len = fragsz;
12658 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
12660 if (fragsz_oop > tdata->plaintext.len)
12661 frag_size_oop = tdata->plaintext.len;
12664 void *digest_mem = NULL;
12666 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
12668 if (tdata->plaintext.len % fragsz != 0) {
12669 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
12672 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
12677 * For out-op-place we need to alloc another mbuf
12680 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12681 rte_pktmbuf_append(ut_params->obuf,
12682 frag_size_oop + prepend_len);
12683 buf_oop = ut_params->obuf;
12686 /* Create AEAD session */
12687 retval = create_aead_session(ts_params->valid_devs[0],
12689 RTE_CRYPTO_AEAD_OP_ENCRYPT,
12690 tdata->key.data, tdata->key.len,
12691 tdata->aad.len, tdata->auth_tag.len,
12696 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12698 /* clear mbuf payload */
12699 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12700 rte_pktmbuf_tailroom(ut_params->ibuf));
12702 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12705 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12707 trn_data += plaintext_len;
12709 buf = ut_params->ibuf;
12712 * Loop until no more fragments
12715 while (trn_data < tdata->plaintext.len) {
12717 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12718 (tdata->plaintext.len - trn_data) : fragsz;
12720 to_trn_tbl[ecx++] = to_trn;
12722 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12725 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12726 rte_pktmbuf_tailroom(buf));
12729 if (oop && !fragsz_oop) {
12730 buf_last_oop = buf_oop->next =
12731 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12732 buf_oop = buf_oop->next;
12733 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12734 0, rte_pktmbuf_tailroom(buf_oop));
12735 rte_pktmbuf_append(buf_oop, to_trn);
12738 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12741 memcpy(plaintext, tdata->plaintext.data + trn_data,
12743 trn_data += to_trn;
12744 if (trn_data == tdata->plaintext.len) {
12747 digest_mem = rte_pktmbuf_append(buf_oop,
12748 tdata->auth_tag.len);
12750 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12751 tdata->auth_tag.len);
12755 uint64_t digest_phys = 0;
12757 ut_params->ibuf->nb_segs = segs;
12760 if (fragsz_oop && oop) {
12764 if (frag_size_oop == tdata->plaintext.len) {
12765 digest_mem = rte_pktmbuf_append(ut_params->obuf,
12766 tdata->auth_tag.len);
12768 digest_phys = rte_pktmbuf_iova_offset(
12770 tdata->plaintext.len + prepend_len);
12773 trn_data = frag_size_oop;
12774 while (trn_data < tdata->plaintext.len) {
12777 (tdata->plaintext.len - trn_data <
12779 (tdata->plaintext.len - trn_data) :
12782 to_trn_tbl[ecx++] = to_trn;
12784 buf_last_oop = buf_oop->next =
12785 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12786 buf_oop = buf_oop->next;
12787 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12788 0, rte_pktmbuf_tailroom(buf_oop));
12789 rte_pktmbuf_append(buf_oop, to_trn);
12791 trn_data += to_trn;
12793 if (trn_data == tdata->plaintext.len) {
12794 digest_mem = rte_pktmbuf_append(buf_oop,
12795 tdata->auth_tag.len);
12799 ut_params->obuf->nb_segs = segs;
12803 * Place digest at the end of the last buffer
12806 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12807 if (oop && buf_last_oop)
12808 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
12810 if (!digest_mem && !oop) {
12811 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12812 + tdata->auth_tag.len);
12813 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12814 tdata->plaintext.len);
12817 /* Create AEAD operation */
12818 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
12819 tdata, digest_mem, digest_phys);
12824 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12826 ut_params->op->sym->m_src = ut_params->ibuf;
12828 ut_params->op->sym->m_dst = ut_params->obuf;
12830 /* Process crypto operation */
12831 if (oop == IN_PLACE &&
12832 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12833 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12834 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12835 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12836 ut_params->op, 0, 0, 0, 0);
12838 TEST_ASSERT_NOT_NULL(
12839 process_crypto_request(ts_params->valid_devs[0],
12840 ut_params->op), "failed to process sym crypto op");
12842 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12843 "crypto op processing failed");
12846 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12847 uint8_t *, prepend_len);
12849 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12850 uint8_t *, prepend_len);
12854 fragsz = fragsz_oop;
12856 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12858 tdata->ciphertext.data,
12860 "Ciphertext data not as expected");
12862 buf = ut_params->op->sym->m_src->next;
12864 buf = ut_params->op->sym->m_dst->next;
12866 unsigned int off = fragsz;
12870 ciphertext = rte_pktmbuf_mtod(buf,
12873 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12875 tdata->ciphertext.data + off,
12877 "Ciphertext data not as expected");
12879 off += to_trn_tbl[ecx++];
12883 auth_tag = digest_mem;
12884 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12886 tdata->auth_tag.data,
12887 tdata->auth_tag.len,
12888 "Generated auth tag not as expected");
12894 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
12896 return test_authenticated_encryption_SGL(
12897 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
12901 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
12903 return test_authenticated_encryption_SGL(
12904 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
12908 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
12910 return test_authenticated_encryption_SGL(
12911 &gcm_test_case_8, OUT_OF_PLACE, 400,
12912 gcm_test_case_8.plaintext.len);
12916 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
12918 /* This test is not for OPENSSL PMD */
12919 if (gbl_driver_id == rte_cryptodev_driver_id_get(
12920 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
12923 return test_authenticated_encryption_SGL(
12924 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
12928 test_authentication_verify_fail_when_data_corrupted(
12929 struct crypto_testsuite_params *ts_params,
12930 struct crypto_unittest_params *ut_params,
12931 const struct test_crypto_vector *reference)
12933 return test_authentication_verify_fail_when_data_corruption(
12934 ts_params, ut_params, reference, 1);
12938 test_authentication_verify_fail_when_tag_corrupted(
12939 struct crypto_testsuite_params *ts_params,
12940 struct crypto_unittest_params *ut_params,
12941 const struct test_crypto_vector *reference)
12943 return test_authentication_verify_fail_when_data_corruption(
12944 ts_params, ut_params, reference, 0);
12948 test_authentication_verify_GMAC_fail_when_data_corrupted(
12949 struct crypto_testsuite_params *ts_params,
12950 struct crypto_unittest_params *ut_params,
12951 const struct test_crypto_vector *reference)
12953 return test_authentication_verify_GMAC_fail_when_corruption(
12954 ts_params, ut_params, reference, 1);
12958 test_authentication_verify_GMAC_fail_when_tag_corrupted(
12959 struct crypto_testsuite_params *ts_params,
12960 struct crypto_unittest_params *ut_params,
12961 const struct test_crypto_vector *reference)
12963 return test_authentication_verify_GMAC_fail_when_corruption(
12964 ts_params, ut_params, reference, 0);
12968 test_authenticated_decryption_fail_when_data_corrupted(
12969 struct crypto_testsuite_params *ts_params,
12970 struct crypto_unittest_params *ut_params,
12971 const struct test_crypto_vector *reference)
12973 return test_authenticated_decryption_fail_when_corruption(
12974 ts_params, ut_params, reference, 1);
12978 test_authenticated_decryption_fail_when_tag_corrupted(
12979 struct crypto_testsuite_params *ts_params,
12980 struct crypto_unittest_params *ut_params,
12981 const struct test_crypto_vector *reference)
12983 return test_authenticated_decryption_fail_when_corruption(
12984 ts_params, ut_params, reference, 0);
12988 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
12990 return test_authentication_verify_fail_when_data_corrupted(
12991 &testsuite_params, &unittest_params,
12992 &hmac_sha1_test_crypto_vector);
12996 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
12998 return test_authentication_verify_fail_when_tag_corrupted(
12999 &testsuite_params, &unittest_params,
13000 &hmac_sha1_test_crypto_vector);
13004 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13006 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13007 &testsuite_params, &unittest_params,
13008 &aes128_gmac_test_vector);
13012 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13014 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13015 &testsuite_params, &unittest_params,
13016 &aes128_gmac_test_vector);
13020 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13022 return test_authenticated_decryption_fail_when_data_corrupted(
13025 &aes128cbc_hmac_sha1_test_vector);
13029 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13031 return test_authenticated_decryption_fail_when_tag_corrupted(
13034 &aes128cbc_hmac_sha1_test_vector);
13038 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13040 return test_authenticated_encryt_with_esn(
13043 &aes128cbc_hmac_sha1_aad_test_vector);
13047 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13049 return test_authenticated_decrypt_with_esn(
13052 &aes128cbc_hmac_sha1_aad_test_vector);
13056 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13058 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13062 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13064 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13067 #ifdef RTE_CRYPTO_SCHEDULER
13069 /* global AESNI worker IDs for the scheduler test */
13070 uint8_t aesni_ids[2];
13073 test_scheduler_attach_slave_op(void)
13075 struct crypto_testsuite_params *ts_params = &testsuite_params;
13076 uint8_t sched_id = ts_params->valid_devs[0];
13077 uint32_t nb_devs, i, nb_devs_attached = 0;
13079 char vdev_name[32];
13081 /* create 2 AESNI_MB if necessary */
13082 nb_devs = rte_cryptodev_device_count_by_driver(
13083 rte_cryptodev_driver_id_get(
13084 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13086 for (i = nb_devs; i < 2; i++) {
13087 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13088 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13090 ret = rte_vdev_init(vdev_name, NULL);
13092 TEST_ASSERT(ret == 0,
13093 "Failed to create instance %u of"
13095 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13099 /* attach 2 AESNI_MB cdevs */
13100 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13102 struct rte_cryptodev_info info;
13103 unsigned int session_size;
13105 rte_cryptodev_info_get(i, &info);
13106 if (info.driver_id != rte_cryptodev_driver_id_get(
13107 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13110 session_size = rte_cryptodev_sym_get_private_session_size(i);
13112 * Create the session mempool again, since now there are new devices
13113 * to use the mempool.
13115 if (ts_params->session_mpool) {
13116 rte_mempool_free(ts_params->session_mpool);
13117 ts_params->session_mpool = NULL;
13119 if (ts_params->session_priv_mpool) {
13120 rte_mempool_free(ts_params->session_priv_mpool);
13121 ts_params->session_priv_mpool = NULL;
13124 if (info.sym.max_nb_sessions != 0 &&
13125 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13126 RTE_LOG(ERR, USER1,
13127 "Device does not support "
13128 "at least %u sessions\n",
13130 return TEST_FAILED;
13133 * Create mempool with maximum number of sessions,
13134 * to include the session headers
13136 if (ts_params->session_mpool == NULL) {
13137 ts_params->session_mpool =
13138 rte_cryptodev_sym_session_pool_create(
13140 MAX_NB_SESSIONS, 0, 0, 0,
13142 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13143 "session mempool allocation failed");
13147 * Create mempool with maximum number of sessions,
13148 * to include device specific session private data
13150 if (ts_params->session_priv_mpool == NULL) {
13151 ts_params->session_priv_mpool = rte_mempool_create(
13152 "test_sess_mp_priv",
13155 0, 0, NULL, NULL, NULL,
13156 NULL, SOCKET_ID_ANY,
13159 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13160 "session mempool allocation failed");
13163 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13164 ts_params->qp_conf.mp_session_private =
13165 ts_params->session_priv_mpool;
13167 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13170 TEST_ASSERT(ret == 0,
13171 "Failed to attach device %u of pmd : %s", i,
13172 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13174 aesni_ids[nb_devs_attached] = (uint8_t)i;
13176 nb_devs_attached++;
13183 test_scheduler_detach_slave_op(void)
13185 struct crypto_testsuite_params *ts_params = &testsuite_params;
13186 uint8_t sched_id = ts_params->valid_devs[0];
13190 for (i = 0; i < 2; i++) {
13191 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13193 TEST_ASSERT(ret == 0,
13194 "Failed to detach device %u", aesni_ids[i]);
13201 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13203 struct crypto_testsuite_params *ts_params = &testsuite_params;
13204 uint8_t sched_id = ts_params->valid_devs[0];
13206 return rte_cryptodev_scheduler_mode_set(sched_id,
13211 test_scheduler_mode_roundrobin_op(void)
13213 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13214 0, "Failed to set roundrobin mode");
13220 test_scheduler_mode_multicore_op(void)
13222 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13223 0, "Failed to set multicore mode");
13229 test_scheduler_mode_failover_op(void)
13231 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13232 0, "Failed to set failover mode");
13238 test_scheduler_mode_pkt_size_distr_op(void)
13240 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13241 0, "Failed to set pktsize mode");
13246 static struct unit_test_suite cryptodev_scheduler_testsuite = {
13247 .suite_name = "Crypto Device Scheduler Unit Test Suite",
13248 .setup = testsuite_setup,
13249 .teardown = testsuite_teardown,
13250 .unit_test_cases = {
13252 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13253 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
13254 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13255 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13256 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13257 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13260 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13261 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
13262 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13263 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13264 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13265 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13268 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13269 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
13270 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13271 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13272 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13273 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13276 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13277 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
13278 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13279 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13280 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13281 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13283 TEST_CASES_END() /**< NULL terminate unit test array */
13287 #endif /* RTE_CRYPTO_SCHEDULER */
13289 static struct unit_test_suite cryptodev_testsuite = {
13290 .suite_name = "Crypto Unit Test Suite",
13291 .setup = testsuite_setup,
13292 .teardown = testsuite_teardown,
13293 .unit_test_cases = {
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_device_configure_invalid_dev_id),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_queue_pair_descriptor_setup),
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_device_configure_invalid_queue_pair_ids),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_multi_session),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_multi_session_random_usage),
13305 TEST_CASE_ST(ut_setup, ut_teardown,
13306 test_null_invalid_operation),
13307 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13308 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13309 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13310 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13311 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13312 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
13313 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
13314 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
13315 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13316 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13318 /** AES CCM Authenticated Encryption 128 bits key */
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_AES_CCM_authenticated_encryption_test_case_128_1),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_AES_CCM_authenticated_encryption_test_case_128_2),
13323 TEST_CASE_ST(ut_setup, ut_teardown,
13324 test_AES_CCM_authenticated_encryption_test_case_128_3),
13326 /** AES CCM Authenticated Decryption 128 bits key*/
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_AES_CCM_authenticated_decryption_test_case_128_1),
13329 TEST_CASE_ST(ut_setup, ut_teardown,
13330 test_AES_CCM_authenticated_decryption_test_case_128_2),
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_AES_CCM_authenticated_decryption_test_case_128_3),
13334 /** AES CCM Authenticated Encryption 192 bits key */
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_AES_CCM_authenticated_encryption_test_case_192_1),
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_AES_CCM_authenticated_encryption_test_case_192_2),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_AES_CCM_authenticated_encryption_test_case_192_3),
13342 /** AES CCM Authenticated Decryption 192 bits key*/
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_AES_CCM_authenticated_decryption_test_case_192_1),
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 test_AES_CCM_authenticated_decryption_test_case_192_2),
13347 TEST_CASE_ST(ut_setup, ut_teardown,
13348 test_AES_CCM_authenticated_decryption_test_case_192_3),
13350 /** AES CCM Authenticated Encryption 256 bits key */
13351 TEST_CASE_ST(ut_setup, ut_teardown,
13352 test_AES_CCM_authenticated_encryption_test_case_256_1),
13353 TEST_CASE_ST(ut_setup, ut_teardown,
13354 test_AES_CCM_authenticated_encryption_test_case_256_2),
13355 TEST_CASE_ST(ut_setup, ut_teardown,
13356 test_AES_CCM_authenticated_encryption_test_case_256_3),
13358 /** AES CCM Authenticated Decryption 256 bits key*/
13359 TEST_CASE_ST(ut_setup, ut_teardown,
13360 test_AES_CCM_authenticated_decryption_test_case_256_1),
13361 TEST_CASE_ST(ut_setup, ut_teardown,
13362 test_AES_CCM_authenticated_decryption_test_case_256_2),
13363 TEST_CASE_ST(ut_setup, ut_teardown,
13364 test_AES_CCM_authenticated_decryption_test_case_256_3),
13366 /** AES GCM Authenticated Encryption */
13367 TEST_CASE_ST(ut_setup, ut_teardown,
13368 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13369 TEST_CASE_ST(ut_setup, ut_teardown,
13370 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13371 TEST_CASE_ST(ut_setup, ut_teardown,
13372 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13373 TEST_CASE_ST(ut_setup, ut_teardown,
13374 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13375 TEST_CASE_ST(ut_setup, ut_teardown,
13376 test_AES_GCM_authenticated_encryption_test_case_1),
13377 TEST_CASE_ST(ut_setup, ut_teardown,
13378 test_AES_GCM_authenticated_encryption_test_case_2),
13379 TEST_CASE_ST(ut_setup, ut_teardown,
13380 test_AES_GCM_authenticated_encryption_test_case_3),
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_AES_GCM_authenticated_encryption_test_case_4),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_AES_GCM_authenticated_encryption_test_case_5),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_AES_GCM_authenticated_encryption_test_case_6),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_AES_GCM_authenticated_encryption_test_case_7),
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_AES_GCM_authenticated_encryption_test_case_8),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13394 /** AES GCM Authenticated Decryption */
13395 TEST_CASE_ST(ut_setup, ut_teardown,
13396 test_AES_GCM_authenticated_decryption_test_case_1),
13397 TEST_CASE_ST(ut_setup, ut_teardown,
13398 test_AES_GCM_authenticated_decryption_test_case_2),
13399 TEST_CASE_ST(ut_setup, ut_teardown,
13400 test_AES_GCM_authenticated_decryption_test_case_3),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_AES_GCM_authenticated_decryption_test_case_4),
13403 TEST_CASE_ST(ut_setup, ut_teardown,
13404 test_AES_GCM_authenticated_decryption_test_case_5),
13405 TEST_CASE_ST(ut_setup, ut_teardown,
13406 test_AES_GCM_authenticated_decryption_test_case_6),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_AES_GCM_authenticated_decryption_test_case_7),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_AES_GCM_authenticated_decryption_test_case_8),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13414 /** AES GCM Authenticated Encryption 192 bits key */
13415 TEST_CASE_ST(ut_setup, ut_teardown,
13416 test_AES_GCM_auth_encryption_test_case_192_1),
13417 TEST_CASE_ST(ut_setup, ut_teardown,
13418 test_AES_GCM_auth_encryption_test_case_192_2),
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 test_AES_GCM_auth_encryption_test_case_192_3),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 test_AES_GCM_auth_encryption_test_case_192_4),
13423 TEST_CASE_ST(ut_setup, ut_teardown,
13424 test_AES_GCM_auth_encryption_test_case_192_5),
13425 TEST_CASE_ST(ut_setup, ut_teardown,
13426 test_AES_GCM_auth_encryption_test_case_192_6),
13427 TEST_CASE_ST(ut_setup, ut_teardown,
13428 test_AES_GCM_auth_encryption_test_case_192_7),
13430 /** AES GCM Authenticated Decryption 192 bits key */
13431 TEST_CASE_ST(ut_setup, ut_teardown,
13432 test_AES_GCM_auth_decryption_test_case_192_1),
13433 TEST_CASE_ST(ut_setup, ut_teardown,
13434 test_AES_GCM_auth_decryption_test_case_192_2),
13435 TEST_CASE_ST(ut_setup, ut_teardown,
13436 test_AES_GCM_auth_decryption_test_case_192_3),
13437 TEST_CASE_ST(ut_setup, ut_teardown,
13438 test_AES_GCM_auth_decryption_test_case_192_4),
13439 TEST_CASE_ST(ut_setup, ut_teardown,
13440 test_AES_GCM_auth_decryption_test_case_192_5),
13441 TEST_CASE_ST(ut_setup, ut_teardown,
13442 test_AES_GCM_auth_decryption_test_case_192_6),
13443 TEST_CASE_ST(ut_setup, ut_teardown,
13444 test_AES_GCM_auth_decryption_test_case_192_7),
13446 /** AES GCM Authenticated Encryption 256 bits key */
13447 TEST_CASE_ST(ut_setup, ut_teardown,
13448 test_AES_GCM_auth_encryption_test_case_256_1),
13449 TEST_CASE_ST(ut_setup, ut_teardown,
13450 test_AES_GCM_auth_encryption_test_case_256_2),
13451 TEST_CASE_ST(ut_setup, ut_teardown,
13452 test_AES_GCM_auth_encryption_test_case_256_3),
13453 TEST_CASE_ST(ut_setup, ut_teardown,
13454 test_AES_GCM_auth_encryption_test_case_256_4),
13455 TEST_CASE_ST(ut_setup, ut_teardown,
13456 test_AES_GCM_auth_encryption_test_case_256_5),
13457 TEST_CASE_ST(ut_setup, ut_teardown,
13458 test_AES_GCM_auth_encryption_test_case_256_6),
13459 TEST_CASE_ST(ut_setup, ut_teardown,
13460 test_AES_GCM_auth_encryption_test_case_256_7),
13462 /** AES GCM Authenticated Decryption 256 bits key */
13463 TEST_CASE_ST(ut_setup, ut_teardown,
13464 test_AES_GCM_auth_decryption_test_case_256_1),
13465 TEST_CASE_ST(ut_setup, ut_teardown,
13466 test_AES_GCM_auth_decryption_test_case_256_2),
13467 TEST_CASE_ST(ut_setup, ut_teardown,
13468 test_AES_GCM_auth_decryption_test_case_256_3),
13469 TEST_CASE_ST(ut_setup, ut_teardown,
13470 test_AES_GCM_auth_decryption_test_case_256_4),
13471 TEST_CASE_ST(ut_setup, ut_teardown,
13472 test_AES_GCM_auth_decryption_test_case_256_5),
13473 TEST_CASE_ST(ut_setup, ut_teardown,
13474 test_AES_GCM_auth_decryption_test_case_256_6),
13475 TEST_CASE_ST(ut_setup, ut_teardown,
13476 test_AES_GCM_auth_decryption_test_case_256_7),
13478 /** AES GCM Authenticated Encryption big aad size */
13479 TEST_CASE_ST(ut_setup, ut_teardown,
13480 test_AES_GCM_auth_encryption_test_case_aad_1),
13481 TEST_CASE_ST(ut_setup, ut_teardown,
13482 test_AES_GCM_auth_encryption_test_case_aad_2),
13484 /** AES GCM Authenticated Decryption big aad size */
13485 TEST_CASE_ST(ut_setup, ut_teardown,
13486 test_AES_GCM_auth_decryption_test_case_aad_1),
13487 TEST_CASE_ST(ut_setup, ut_teardown,
13488 test_AES_GCM_auth_decryption_test_case_aad_2),
13490 /** Out of place tests */
13491 TEST_CASE_ST(ut_setup, ut_teardown,
13492 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13493 TEST_CASE_ST(ut_setup, ut_teardown,
13494 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13496 /** Session-less tests */
13497 TEST_CASE_ST(ut_setup, ut_teardown,
13498 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13499 TEST_CASE_ST(ut_setup, ut_teardown,
13500 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13502 /** AES GMAC Authentication */
13503 TEST_CASE_ST(ut_setup, ut_teardown,
13504 test_AES_GMAC_authentication_test_case_1),
13505 TEST_CASE_ST(ut_setup, ut_teardown,
13506 test_AES_GMAC_authentication_verify_test_case_1),
13507 TEST_CASE_ST(ut_setup, ut_teardown,
13508 test_AES_GMAC_authentication_test_case_2),
13509 TEST_CASE_ST(ut_setup, ut_teardown,
13510 test_AES_GMAC_authentication_verify_test_case_2),
13511 TEST_CASE_ST(ut_setup, ut_teardown,
13512 test_AES_GMAC_authentication_test_case_3),
13513 TEST_CASE_ST(ut_setup, ut_teardown,
13514 test_AES_GMAC_authentication_verify_test_case_3),
13515 TEST_CASE_ST(ut_setup, ut_teardown,
13516 test_AES_GMAC_authentication_test_case_4),
13517 TEST_CASE_ST(ut_setup, ut_teardown,
13518 test_AES_GMAC_authentication_verify_test_case_4),
13519 TEST_CASE_ST(ut_setup, ut_teardown,
13520 test_AES_GMAC_authentication_SGL_40B),
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_AES_GMAC_authentication_SGL_80B),
13523 TEST_CASE_ST(ut_setup, ut_teardown,
13524 test_AES_GMAC_authentication_SGL_2048B),
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_AES_GMAC_authentication_SGL_2047B),
13528 /** Chacha20-Poly1305 */
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_chacha20_poly1305_encrypt_test_case_rfc8439),
13531 TEST_CASE_ST(ut_setup, ut_teardown,
13532 test_chacha20_poly1305_decrypt_test_case_rfc8439),
13533 /** SNOW 3G encrypt only (UEA2) */
13534 TEST_CASE_ST(ut_setup, ut_teardown,
13535 test_snow3g_encryption_test_case_1),
13536 TEST_CASE_ST(ut_setup, ut_teardown,
13537 test_snow3g_encryption_test_case_2),
13538 TEST_CASE_ST(ut_setup, ut_teardown,
13539 test_snow3g_encryption_test_case_3),
13540 TEST_CASE_ST(ut_setup, ut_teardown,
13541 test_snow3g_encryption_test_case_4),
13542 TEST_CASE_ST(ut_setup, ut_teardown,
13543 test_snow3g_encryption_test_case_5),
13545 TEST_CASE_ST(ut_setup, ut_teardown,
13546 test_snow3g_encryption_test_case_1_oop),
13547 TEST_CASE_ST(ut_setup, ut_teardown,
13548 test_snow3g_encryption_test_case_1_oop_sgl),
13549 TEST_CASE_ST(ut_setup, ut_teardown,
13550 test_snow3g_encryption_test_case_1_offset_oop),
13551 TEST_CASE_ST(ut_setup, ut_teardown,
13552 test_snow3g_decryption_test_case_1_oop),
13554 /** SNOW 3G generate auth, then encrypt (UEA2) */
13555 TEST_CASE_ST(ut_setup, ut_teardown,
13556 test_snow3g_auth_cipher_test_case_1),
13557 TEST_CASE_ST(ut_setup, ut_teardown,
13558 test_snow3g_auth_cipher_test_case_2),
13559 TEST_CASE_ST(ut_setup, ut_teardown,
13560 test_snow3g_auth_cipher_test_case_2_oop),
13561 TEST_CASE_ST(ut_setup, ut_teardown,
13562 test_snow3g_auth_cipher_part_digest_enc),
13563 TEST_CASE_ST(ut_setup, ut_teardown,
13564 test_snow3g_auth_cipher_part_digest_enc_oop),
13565 TEST_CASE_ST(ut_setup, ut_teardown,
13566 test_snow3g_auth_cipher_test_case_3_sgl),
13567 TEST_CASE_ST(ut_setup, ut_teardown,
13568 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13569 TEST_CASE_ST(ut_setup, ut_teardown,
13570 test_snow3g_auth_cipher_part_digest_enc_sgl),
13571 TEST_CASE_ST(ut_setup, ut_teardown,
13572 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13574 /** SNOW 3G decrypt (UEA2), then verify auth */
13575 TEST_CASE_ST(ut_setup, ut_teardown,
13576 test_snow3g_auth_cipher_verify_test_case_1),
13577 TEST_CASE_ST(ut_setup, ut_teardown,
13578 test_snow3g_auth_cipher_verify_test_case_2),
13579 TEST_CASE_ST(ut_setup, ut_teardown,
13580 test_snow3g_auth_cipher_verify_test_case_2_oop),
13581 TEST_CASE_ST(ut_setup, ut_teardown,
13582 test_snow3g_auth_cipher_verify_part_digest_enc),
13583 TEST_CASE_ST(ut_setup, ut_teardown,
13584 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13585 TEST_CASE_ST(ut_setup, ut_teardown,
13586 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13587 TEST_CASE_ST(ut_setup, ut_teardown,
13588 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13589 TEST_CASE_ST(ut_setup, ut_teardown,
13590 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13591 TEST_CASE_ST(ut_setup, ut_teardown,
13592 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13594 /** SNOW 3G decrypt only (UEA2) */
13595 TEST_CASE_ST(ut_setup, ut_teardown,
13596 test_snow3g_decryption_test_case_1),
13597 TEST_CASE_ST(ut_setup, ut_teardown,
13598 test_snow3g_decryption_test_case_2),
13599 TEST_CASE_ST(ut_setup, ut_teardown,
13600 test_snow3g_decryption_test_case_3),
13601 TEST_CASE_ST(ut_setup, ut_teardown,
13602 test_snow3g_decryption_test_case_4),
13603 TEST_CASE_ST(ut_setup, ut_teardown,
13604 test_snow3g_decryption_test_case_5),
13605 TEST_CASE_ST(ut_setup, ut_teardown,
13606 test_snow3g_decryption_with_digest_test_case_1),
13607 TEST_CASE_ST(ut_setup, ut_teardown,
13608 test_snow3g_hash_generate_test_case_1),
13609 TEST_CASE_ST(ut_setup, ut_teardown,
13610 test_snow3g_hash_generate_test_case_2),
13611 TEST_CASE_ST(ut_setup, ut_teardown,
13612 test_snow3g_hash_generate_test_case_3),
13613 /* Tests with buffers which length is not byte-aligned */
13614 TEST_CASE_ST(ut_setup, ut_teardown,
13615 test_snow3g_hash_generate_test_case_4),
13616 TEST_CASE_ST(ut_setup, ut_teardown,
13617 test_snow3g_hash_generate_test_case_5),
13618 TEST_CASE_ST(ut_setup, ut_teardown,
13619 test_snow3g_hash_generate_test_case_6),
13620 TEST_CASE_ST(ut_setup, ut_teardown,
13621 test_snow3g_hash_verify_test_case_1),
13622 TEST_CASE_ST(ut_setup, ut_teardown,
13623 test_snow3g_hash_verify_test_case_2),
13624 TEST_CASE_ST(ut_setup, ut_teardown,
13625 test_snow3g_hash_verify_test_case_3),
13626 /* Tests with buffers which length is not byte-aligned */
13627 TEST_CASE_ST(ut_setup, ut_teardown,
13628 test_snow3g_hash_verify_test_case_4),
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 test_snow3g_hash_verify_test_case_5),
13631 TEST_CASE_ST(ut_setup, ut_teardown,
13632 test_snow3g_hash_verify_test_case_6),
13633 TEST_CASE_ST(ut_setup, ut_teardown,
13634 test_snow3g_cipher_auth_test_case_1),
13635 TEST_CASE_ST(ut_setup, ut_teardown,
13636 test_snow3g_auth_cipher_with_digest_test_case_1),
13638 /** ZUC encrypt only (EEA3) */
13639 TEST_CASE_ST(ut_setup, ut_teardown,
13640 test_zuc_encryption_test_case_1),
13641 TEST_CASE_ST(ut_setup, ut_teardown,
13642 test_zuc_encryption_test_case_2),
13643 TEST_CASE_ST(ut_setup, ut_teardown,
13644 test_zuc_encryption_test_case_3),
13645 TEST_CASE_ST(ut_setup, ut_teardown,
13646 test_zuc_encryption_test_case_4),
13647 TEST_CASE_ST(ut_setup, ut_teardown,
13648 test_zuc_encryption_test_case_5),
13649 TEST_CASE_ST(ut_setup, ut_teardown,
13650 test_zuc_encryption_test_case_6_sgl),
13652 /** ZUC authenticate (EIA3) */
13653 TEST_CASE_ST(ut_setup, ut_teardown,
13654 test_zuc_hash_generate_test_case_1),
13655 TEST_CASE_ST(ut_setup, ut_teardown,
13656 test_zuc_hash_generate_test_case_2),
13657 TEST_CASE_ST(ut_setup, ut_teardown,
13658 test_zuc_hash_generate_test_case_3),
13659 TEST_CASE_ST(ut_setup, ut_teardown,
13660 test_zuc_hash_generate_test_case_4),
13661 TEST_CASE_ST(ut_setup, ut_teardown,
13662 test_zuc_hash_generate_test_case_5),
13663 TEST_CASE_ST(ut_setup, ut_teardown,
13664 test_zuc_hash_generate_test_case_6),
13665 TEST_CASE_ST(ut_setup, ut_teardown,
13666 test_zuc_hash_generate_test_case_7),
13667 TEST_CASE_ST(ut_setup, ut_teardown,
13668 test_zuc_hash_generate_test_case_8),
13670 /** ZUC alg-chain (EEA3/EIA3) */
13671 TEST_CASE_ST(ut_setup, ut_teardown,
13672 test_zuc_cipher_auth_test_case_1),
13673 TEST_CASE_ST(ut_setup, ut_teardown,
13674 test_zuc_cipher_auth_test_case_2),
13676 /** ZUC generate auth, then encrypt (EEA3) */
13677 TEST_CASE_ST(ut_setup, ut_teardown,
13678 test_zuc_auth_cipher_test_case_1),
13679 TEST_CASE_ST(ut_setup, ut_teardown,
13680 test_zuc_auth_cipher_test_case_1_oop),
13681 TEST_CASE_ST(ut_setup, ut_teardown,
13682 test_zuc_auth_cipher_test_case_1_sgl),
13683 TEST_CASE_ST(ut_setup, ut_teardown,
13684 test_zuc_auth_cipher_test_case_1_oop_sgl),
13686 /** ZUC decrypt (EEA3), then verify auth */
13687 TEST_CASE_ST(ut_setup, ut_teardown,
13688 test_zuc_auth_cipher_verify_test_case_1),
13689 TEST_CASE_ST(ut_setup, ut_teardown,
13690 test_zuc_auth_cipher_verify_test_case_1_oop),
13691 TEST_CASE_ST(ut_setup, ut_teardown,
13692 test_zuc_auth_cipher_verify_test_case_1_sgl),
13693 TEST_CASE_ST(ut_setup, ut_teardown,
13694 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
13696 /** HMAC_MD5 Authentication */
13697 TEST_CASE_ST(ut_setup, ut_teardown,
13698 test_MD5_HMAC_generate_case_1),
13699 TEST_CASE_ST(ut_setup, ut_teardown,
13700 test_MD5_HMAC_verify_case_1),
13701 TEST_CASE_ST(ut_setup, ut_teardown,
13702 test_MD5_HMAC_generate_case_2),
13703 TEST_CASE_ST(ut_setup, ut_teardown,
13704 test_MD5_HMAC_verify_case_2),
13706 /** KASUMI hash only (UIA1) */
13707 TEST_CASE_ST(ut_setup, ut_teardown,
13708 test_kasumi_hash_generate_test_case_1),
13709 TEST_CASE_ST(ut_setup, ut_teardown,
13710 test_kasumi_hash_generate_test_case_2),
13711 TEST_CASE_ST(ut_setup, ut_teardown,
13712 test_kasumi_hash_generate_test_case_3),
13713 TEST_CASE_ST(ut_setup, ut_teardown,
13714 test_kasumi_hash_generate_test_case_4),
13715 TEST_CASE_ST(ut_setup, ut_teardown,
13716 test_kasumi_hash_generate_test_case_5),
13717 TEST_CASE_ST(ut_setup, ut_teardown,
13718 test_kasumi_hash_generate_test_case_6),
13720 TEST_CASE_ST(ut_setup, ut_teardown,
13721 test_kasumi_hash_verify_test_case_1),
13722 TEST_CASE_ST(ut_setup, ut_teardown,
13723 test_kasumi_hash_verify_test_case_2),
13724 TEST_CASE_ST(ut_setup, ut_teardown,
13725 test_kasumi_hash_verify_test_case_3),
13726 TEST_CASE_ST(ut_setup, ut_teardown,
13727 test_kasumi_hash_verify_test_case_4),
13728 TEST_CASE_ST(ut_setup, ut_teardown,
13729 test_kasumi_hash_verify_test_case_5),
13731 /** KASUMI encrypt only (UEA1) */
13732 TEST_CASE_ST(ut_setup, ut_teardown,
13733 test_kasumi_encryption_test_case_1),
13734 TEST_CASE_ST(ut_setup, ut_teardown,
13735 test_kasumi_encryption_test_case_1_sgl),
13736 TEST_CASE_ST(ut_setup, ut_teardown,
13737 test_kasumi_encryption_test_case_1_oop),
13738 TEST_CASE_ST(ut_setup, ut_teardown,
13739 test_kasumi_encryption_test_case_1_oop_sgl),
13740 TEST_CASE_ST(ut_setup, ut_teardown,
13741 test_kasumi_encryption_test_case_2),
13742 TEST_CASE_ST(ut_setup, ut_teardown,
13743 test_kasumi_encryption_test_case_3),
13744 TEST_CASE_ST(ut_setup, ut_teardown,
13745 test_kasumi_encryption_test_case_4),
13746 TEST_CASE_ST(ut_setup, ut_teardown,
13747 test_kasumi_encryption_test_case_5),
13749 /** KASUMI decrypt only (UEA1) */
13750 TEST_CASE_ST(ut_setup, ut_teardown,
13751 test_kasumi_decryption_test_case_1),
13752 TEST_CASE_ST(ut_setup, ut_teardown,
13753 test_kasumi_decryption_test_case_2),
13754 TEST_CASE_ST(ut_setup, ut_teardown,
13755 test_kasumi_decryption_test_case_3),
13756 TEST_CASE_ST(ut_setup, ut_teardown,
13757 test_kasumi_decryption_test_case_4),
13758 TEST_CASE_ST(ut_setup, ut_teardown,
13759 test_kasumi_decryption_test_case_5),
13760 TEST_CASE_ST(ut_setup, ut_teardown,
13761 test_kasumi_decryption_test_case_1_oop),
13763 TEST_CASE_ST(ut_setup, ut_teardown,
13764 test_kasumi_cipher_auth_test_case_1),
13766 /** KASUMI generate auth, then encrypt (F8) */
13767 TEST_CASE_ST(ut_setup, ut_teardown,
13768 test_kasumi_auth_cipher_test_case_1),
13769 TEST_CASE_ST(ut_setup, ut_teardown,
13770 test_kasumi_auth_cipher_test_case_2),
13771 TEST_CASE_ST(ut_setup, ut_teardown,
13772 test_kasumi_auth_cipher_test_case_2_oop),
13773 TEST_CASE_ST(ut_setup, ut_teardown,
13774 test_kasumi_auth_cipher_test_case_2_sgl),
13775 TEST_CASE_ST(ut_setup, ut_teardown,
13776 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13778 /** KASUMI decrypt (F8), then verify auth */
13779 TEST_CASE_ST(ut_setup, ut_teardown,
13780 test_kasumi_auth_cipher_verify_test_case_1),
13781 TEST_CASE_ST(ut_setup, ut_teardown,
13782 test_kasumi_auth_cipher_verify_test_case_2),
13783 TEST_CASE_ST(ut_setup, ut_teardown,
13784 test_kasumi_auth_cipher_verify_test_case_2_oop),
13785 TEST_CASE_ST(ut_setup, ut_teardown,
13786 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13787 TEST_CASE_ST(ut_setup, ut_teardown,
13788 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13790 /** ESN Testcase */
13791 TEST_CASE_ST(ut_setup, ut_teardown,
13792 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13793 TEST_CASE_ST(ut_setup, ut_teardown,
13794 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13796 /** Negative tests */
13797 TEST_CASE_ST(ut_setup, ut_teardown,
13798 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13799 TEST_CASE_ST(ut_setup, ut_teardown,
13800 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13801 TEST_CASE_ST(ut_setup, ut_teardown,
13802 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13803 TEST_CASE_ST(ut_setup, ut_teardown,
13804 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13805 TEST_CASE_ST(ut_setup, ut_teardown,
13806 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13807 TEST_CASE_ST(ut_setup, ut_teardown,
13808 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13809 TEST_CASE_ST(ut_setup, ut_teardown,
13810 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13811 TEST_CASE_ST(ut_setup, ut_teardown,
13812 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13813 TEST_CASE_ST(ut_setup, ut_teardown,
13814 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13815 TEST_CASE_ST(ut_setup, ut_teardown,
13816 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13817 TEST_CASE_ST(ut_setup, ut_teardown,
13818 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13819 TEST_CASE_ST(ut_setup, ut_teardown,
13820 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13821 TEST_CASE_ST(ut_setup, ut_teardown,
13822 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13823 TEST_CASE_ST(ut_setup, ut_teardown,
13824 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13825 TEST_CASE_ST(ut_setup, ut_teardown,
13826 authentication_verify_AES128_GMAC_fail_data_corrupt),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13829 TEST_CASE_ST(ut_setup, ut_teardown,
13830 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13834 /** Mixed CIPHER + HASH algorithms */
13835 /** AUTH AES CMAC + CIPHER AES CTR */
13836 TEST_CASE_ST(ut_setup, ut_teardown,
13837 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
13838 TEST_CASE_ST(ut_setup, ut_teardown,
13839 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13840 TEST_CASE_ST(ut_setup, ut_teardown,
13841 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13842 TEST_CASE_ST(ut_setup, ut_teardown,
13843 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13844 TEST_CASE_ST(ut_setup, ut_teardown,
13845 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
13846 TEST_CASE_ST(ut_setup, ut_teardown,
13847 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13848 TEST_CASE_ST(ut_setup, ut_teardown,
13849 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13850 TEST_CASE_ST(ut_setup, ut_teardown,
13851 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13853 /** AUTH ZUC + CIPHER SNOW3G */
13854 TEST_CASE_ST(ut_setup, ut_teardown,
13855 test_auth_zuc_cipher_snow_test_case_1),
13856 TEST_CASE_ST(ut_setup, ut_teardown,
13857 test_verify_auth_zuc_cipher_snow_test_case_1),
13858 /** AUTH AES CMAC + CIPHER SNOW3G */
13859 TEST_CASE_ST(ut_setup, ut_teardown,
13860 test_auth_aes_cmac_cipher_snow_test_case_1),
13861 TEST_CASE_ST(ut_setup, ut_teardown,
13862 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
13863 /** AUTH ZUC + CIPHER AES CTR */
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_auth_zuc_cipher_aes_ctr_test_case_1),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
13868 /** AUTH SNOW3G + CIPHER AES CTR */
13869 TEST_CASE_ST(ut_setup, ut_teardown,
13870 test_auth_snow_cipher_aes_ctr_test_case_1),
13871 TEST_CASE_ST(ut_setup, ut_teardown,
13872 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
13873 /** AUTH SNOW3G + CIPHER ZUC */
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_auth_snow_cipher_zuc_test_case_1),
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_verify_auth_snow_cipher_zuc_test_case_1),
13878 /** AUTH AES CMAC + CIPHER ZUC */
13879 TEST_CASE_ST(ut_setup, ut_teardown,
13880 test_auth_aes_cmac_cipher_zuc_test_case_1),
13881 TEST_CASE_ST(ut_setup, ut_teardown,
13882 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
13884 /** AUTH NULL + CIPHER SNOW3G */
13885 TEST_CASE_ST(ut_setup, ut_teardown,
13886 test_auth_null_cipher_snow_test_case_1),
13887 TEST_CASE_ST(ut_setup, ut_teardown,
13888 test_verify_auth_null_cipher_snow_test_case_1),
13889 /** AUTH NULL + CIPHER ZUC */
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_auth_null_cipher_zuc_test_case_1),
13892 TEST_CASE_ST(ut_setup, ut_teardown,
13893 test_verify_auth_null_cipher_zuc_test_case_1),
13894 /** AUTH SNOW3G + CIPHER NULL */
13895 TEST_CASE_ST(ut_setup, ut_teardown,
13896 test_auth_snow_cipher_null_test_case_1),
13897 TEST_CASE_ST(ut_setup, ut_teardown,
13898 test_verify_auth_snow_cipher_null_test_case_1),
13899 /** AUTH ZUC + CIPHER NULL */
13900 TEST_CASE_ST(ut_setup, ut_teardown,
13901 test_auth_zuc_cipher_null_test_case_1),
13902 TEST_CASE_ST(ut_setup, ut_teardown,
13903 test_verify_auth_zuc_cipher_null_test_case_1),
13904 /** AUTH NULL + CIPHER AES CTR */
13905 TEST_CASE_ST(ut_setup, ut_teardown,
13906 test_auth_null_cipher_aes_ctr_test_case_1),
13907 TEST_CASE_ST(ut_setup, ut_teardown,
13908 test_verify_auth_null_cipher_aes_ctr_test_case_1),
13909 /** AUTH AES CMAC + CIPHER NULL */
13910 TEST_CASE_ST(ut_setup, ut_teardown,
13911 test_auth_aes_cmac_cipher_null_test_case_1),
13912 TEST_CASE_ST(ut_setup, ut_teardown,
13913 test_verify_auth_aes_cmac_cipher_null_test_case_1),
13915 #ifdef RTE_LIB_SECURITY
13916 TEST_CASE_ST(ut_setup_security, ut_teardown,
13917 test_PDCP_PROTO_all),
13918 TEST_CASE_ST(ut_setup_security, ut_teardown,
13919 test_DOCSIS_PROTO_all),
13921 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13922 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13923 TEST_CASES_END() /**< NULL terminate unit test array */
13927 static struct unit_test_suite cryptodev_virtio_testsuite = {
13928 .suite_name = "Crypto VIRTIO Unit Test Suite",
13929 .setup = testsuite_setup,
13930 .teardown = testsuite_teardown,
13931 .unit_test_cases = {
13932 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13934 TEST_CASES_END() /**< NULL terminate unit test array */
13938 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13939 .suite_name = "Crypto CAAM JR Unit Test Suite",
13940 .setup = testsuite_setup,
13941 .teardown = testsuite_teardown,
13942 .unit_test_cases = {
13943 TEST_CASE_ST(ut_setup, ut_teardown,
13944 test_device_configure_invalid_dev_id),
13945 TEST_CASE_ST(ut_setup, ut_teardown,
13946 test_multi_session),
13948 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13949 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13950 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13951 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13952 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13954 TEST_CASES_END() /**< NULL terminate unit test array */
13958 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13959 .suite_name = "Crypto Device Marvell Component Test Suite",
13960 .setup = testsuite_setup,
13961 .teardown = testsuite_teardown,
13962 .unit_test_cases = {
13963 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13964 TEST_CASE_ST(ut_setup, ut_teardown,
13965 test_multi_session_random_usage),
13966 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13967 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13968 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13969 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13970 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13972 /** Negative tests */
13973 TEST_CASE_ST(ut_setup, ut_teardown,
13974 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13975 TEST_CASE_ST(ut_setup, ut_teardown,
13976 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13977 TEST_CASE_ST(ut_setup, ut_teardown,
13978 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13979 TEST_CASE_ST(ut_setup, ut_teardown,
13980 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13982 TEST_CASES_END() /**< NULL terminate unit test array */
13986 static struct unit_test_suite cryptodev_ccp_testsuite = {
13987 .suite_name = "Crypto Device CCP Unit Test Suite",
13988 .setup = testsuite_setup,
13989 .teardown = testsuite_teardown,
13990 .unit_test_cases = {
13991 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13992 TEST_CASE_ST(ut_setup, ut_teardown,
13993 test_multi_session_random_usage),
13994 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13995 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13996 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13997 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13998 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14000 /** Negative tests */
14001 TEST_CASE_ST(ut_setup, ut_teardown,
14002 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14003 TEST_CASE_ST(ut_setup, ut_teardown,
14004 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14005 TEST_CASE_ST(ut_setup, ut_teardown,
14006 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14007 TEST_CASE_ST(ut_setup, ut_teardown,
14008 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14010 TEST_CASES_END() /**< NULL terminate unit test array */
14015 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14017 gbl_driver_id = rte_cryptodev_driver_id_get(
14018 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14020 if (gbl_driver_id == -1) {
14021 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14022 return TEST_SKIPPED;
14025 return unit_test_suite_runner(&cryptodev_testsuite);
14029 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14031 gbl_driver_id = rte_cryptodev_driver_id_get(
14032 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14034 if (gbl_driver_id == -1) {
14035 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
14036 return TEST_FAILED;
14039 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14043 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14045 gbl_driver_id = rte_cryptodev_driver_id_get(
14046 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14048 if (gbl_driver_id == -1) {
14049 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14050 return TEST_SKIPPED;
14053 return unit_test_suite_runner(&cryptodev_testsuite);
14057 test_cryptodev_cpu_aesni_mb(void)
14060 enum rte_security_session_action_type at;
14062 gbl_driver_id = rte_cryptodev_driver_id_get(
14063 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14065 if (gbl_driver_id == -1) {
14066 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14067 return TEST_SKIPPED;
14070 at = gbl_action_type;
14071 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14072 rc = unit_test_suite_runner(&cryptodev_testsuite);
14073 gbl_action_type = at;
14078 test_cryptodev_openssl(void)
14080 gbl_driver_id = rte_cryptodev_driver_id_get(
14081 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14083 if (gbl_driver_id == -1) {
14084 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
14085 return TEST_SKIPPED;
14088 return unit_test_suite_runner(&cryptodev_testsuite);
14092 test_cryptodev_aesni_gcm(void)
14094 gbl_driver_id = rte_cryptodev_driver_id_get(
14095 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14097 if (gbl_driver_id == -1) {
14098 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14099 return TEST_SKIPPED;
14102 return unit_test_suite_runner(&cryptodev_testsuite);
14106 test_cryptodev_cpu_aesni_gcm(void)
14109 enum rte_security_session_action_type at;
14111 gbl_driver_id = rte_cryptodev_driver_id_get(
14112 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14114 if (gbl_driver_id == -1) {
14115 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14116 return TEST_SKIPPED;
14119 at = gbl_action_type;
14120 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14121 rc = unit_test_suite_runner(&cryptodev_testsuite);
14122 gbl_action_type = at;
14127 test_cryptodev_null(void)
14129 gbl_driver_id = rte_cryptodev_driver_id_get(
14130 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14132 if (gbl_driver_id == -1) {
14133 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
14134 return TEST_SKIPPED;
14137 return unit_test_suite_runner(&cryptodev_testsuite);
14141 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14143 gbl_driver_id = rte_cryptodev_driver_id_get(
14144 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14146 if (gbl_driver_id == -1) {
14147 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
14148 return TEST_SKIPPED;
14151 return unit_test_suite_runner(&cryptodev_testsuite);
14155 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14157 gbl_driver_id = rte_cryptodev_driver_id_get(
14158 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14160 if (gbl_driver_id == -1) {
14161 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14162 return TEST_SKIPPED;
14165 return unit_test_suite_runner(&cryptodev_testsuite);
14169 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14171 gbl_driver_id = rte_cryptodev_driver_id_get(
14172 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14174 if (gbl_driver_id == -1) {
14175 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14176 return TEST_SKIPPED;
14179 return unit_test_suite_runner(&cryptodev_testsuite);
14183 test_cryptodev_armv8(void)
14185 gbl_driver_id = rte_cryptodev_driver_id_get(
14186 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14188 if (gbl_driver_id == -1) {
14189 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
14190 return TEST_SKIPPED;
14193 return unit_test_suite_runner(&cryptodev_testsuite);
14197 test_cryptodev_mrvl(void)
14199 gbl_driver_id = rte_cryptodev_driver_id_get(
14200 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14202 if (gbl_driver_id == -1) {
14203 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
14204 return TEST_SKIPPED;
14207 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14210 #ifdef RTE_CRYPTO_SCHEDULER
14213 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14215 gbl_driver_id = rte_cryptodev_driver_id_get(
14216 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14218 if (gbl_driver_id == -1) {
14219 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14220 return TEST_SKIPPED;
14223 if (rte_cryptodev_driver_id_get(
14224 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14225 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14226 return TEST_SKIPPED;
14228 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14231 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14236 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14238 gbl_driver_id = rte_cryptodev_driver_id_get(
14239 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14241 if (gbl_driver_id == -1) {
14242 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
14243 return TEST_SKIPPED;
14246 return unit_test_suite_runner(&cryptodev_testsuite);
14250 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14252 gbl_driver_id = rte_cryptodev_driver_id_get(
14253 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14255 if (gbl_driver_id == -1) {
14256 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
14257 return TEST_SKIPPED;
14260 return unit_test_suite_runner(&cryptodev_testsuite);
14264 test_cryptodev_ccp(void)
14266 gbl_driver_id = rte_cryptodev_driver_id_get(
14267 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14269 if (gbl_driver_id == -1) {
14270 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
14271 return TEST_FAILED;
14274 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14278 test_cryptodev_octeontx(void)
14280 gbl_driver_id = rte_cryptodev_driver_id_get(
14281 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14282 if (gbl_driver_id == -1) {
14283 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
14284 return TEST_FAILED;
14286 return unit_test_suite_runner(&cryptodev_testsuite);
14290 test_cryptodev_octeontx2(void)
14292 gbl_driver_id = rte_cryptodev_driver_id_get(
14293 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14294 if (gbl_driver_id == -1) {
14295 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
14296 return TEST_FAILED;
14298 return unit_test_suite_runner(&cryptodev_testsuite);
14302 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14304 gbl_driver_id = rte_cryptodev_driver_id_get(
14305 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14307 if (gbl_driver_id == -1) {
14308 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
14309 return TEST_FAILED;
14312 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14316 test_cryptodev_nitrox(void)
14318 gbl_driver_id = rte_cryptodev_driver_id_get(
14319 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14321 if (gbl_driver_id == -1) {
14322 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
14323 return TEST_FAILED;
14326 return unit_test_suite_runner(&cryptodev_testsuite);
14330 test_cryptodev_bcmfs(void)
14332 gbl_driver_id = rte_cryptodev_driver_id_get(
14333 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14335 if (gbl_driver_id == -1) {
14336 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
14337 return TEST_FAILED;
14340 return unit_test_suite_runner(&cryptodev_testsuite);
14344 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14348 gbl_driver_id = rte_cryptodev_driver_id_get(
14349 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14351 if (gbl_driver_id == -1) {
14352 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14353 return TEST_SKIPPED;
14356 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14357 ret = unit_test_suite_runner(&cryptodev_testsuite);
14358 global_api_test_type = CRYPTODEV_API_TEST;
14363 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14364 test_cryptodev_qat_raw_api);
14365 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14366 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14367 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14368 test_cryptodev_cpu_aesni_mb);
14369 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14370 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14371 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14372 test_cryptodev_cpu_aesni_gcm);
14373 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14374 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14375 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14376 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14377 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14378 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14379 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14380 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14381 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14382 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14383 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14384 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14385 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14386 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14387 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);