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;
847 if (ts_params->mbuf_pool != NULL) {
848 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
849 rte_mempool_avail_count(ts_params->mbuf_pool));
852 if (ts_params->op_mpool != NULL) {
853 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
854 rte_mempool_avail_count(ts_params->op_mpool));
857 /* Free session mempools */
858 if (ts_params->session_priv_mpool != NULL) {
859 rte_mempool_free(ts_params->session_priv_mpool);
860 ts_params->session_priv_mpool = NULL;
863 if (ts_params->session_mpool != NULL) {
864 rte_mempool_free(ts_params->session_mpool);
865 ts_params->session_mpool = NULL;
868 res = rte_cryptodev_close(ts_params->valid_devs[0]);
870 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
874 dev_configure_and_start(uint64_t ff_disable)
876 struct crypto_testsuite_params *ts_params = &testsuite_params;
877 struct crypto_unittest_params *ut_params = &unittest_params;
881 /* Clear unit test parameters before running test */
882 memset(ut_params, 0, sizeof(*ut_params));
884 /* Reconfigure device to default parameters */
885 ts_params->conf.socket_id = SOCKET_ID_ANY;
886 ts_params->conf.ff_disable = ff_disable;
887 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
888 ts_params->qp_conf.mp_session = ts_params->session_mpool;
889 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
891 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
893 "Failed to configure cryptodev %u",
894 ts_params->valid_devs[0]);
896 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
897 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
898 ts_params->valid_devs[0], qp_id,
900 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
901 "Failed to setup queue pair %u on cryptodev %u",
902 qp_id, ts_params->valid_devs[0]);
906 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
908 /* Start the device */
909 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
910 "Failed to start cryptodev %u",
911 ts_params->valid_devs[0]);
919 /* Configure and start the device with security feature disabled */
920 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
924 ut_setup_security(void)
926 /* Configure and start the device with no features disabled */
927 return dev_configure_and_start(0);
933 struct crypto_testsuite_params *ts_params = &testsuite_params;
934 struct crypto_unittest_params *ut_params = &unittest_params;
935 struct rte_cryptodev_stats stats;
937 /* free crypto session structure */
938 #ifdef RTE_LIB_SECURITY
939 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
940 if (ut_params->sec_session) {
941 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
942 (ts_params->valid_devs[0]),
943 ut_params->sec_session);
944 ut_params->sec_session = NULL;
949 if (ut_params->sess) {
950 rte_cryptodev_sym_session_clear(
951 ts_params->valid_devs[0],
953 rte_cryptodev_sym_session_free(ut_params->sess);
954 ut_params->sess = NULL;
958 /* free crypto operation structure */
960 rte_crypto_op_free(ut_params->op);
963 * free mbuf - both obuf and ibuf are usually the same,
964 * so check if they point at the same address is necessary,
965 * to avoid freeing the mbuf twice.
967 if (ut_params->obuf) {
968 rte_pktmbuf_free(ut_params->obuf);
969 if (ut_params->ibuf == ut_params->obuf)
973 if (ut_params->ibuf) {
974 rte_pktmbuf_free(ut_params->ibuf);
978 if (ts_params->mbuf_pool != NULL)
979 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
980 rte_mempool_avail_count(ts_params->mbuf_pool));
982 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
984 /* Stop the device */
985 rte_cryptodev_stop(ts_params->valid_devs[0]);
989 test_device_configure_invalid_dev_id(void)
991 struct crypto_testsuite_params *ts_params = &testsuite_params;
992 uint16_t dev_id, num_devs = 0;
994 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
995 "Need at least %d devices for test", 1);
997 /* valid dev_id values */
998 dev_id = ts_params->valid_devs[0];
1000 /* Stop the device in case it's started so it can be configured */
1001 rte_cryptodev_stop(dev_id);
1003 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1004 "Failed test for rte_cryptodev_configure: "
1005 "invalid dev_num %u", dev_id);
1007 /* invalid dev_id values */
1010 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1011 "Failed test for rte_cryptodev_configure: "
1012 "invalid dev_num %u", dev_id);
1016 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1017 "Failed test for rte_cryptodev_configure:"
1018 "invalid dev_num %u", dev_id);
1020 return TEST_SUCCESS;
1024 test_device_configure_invalid_queue_pair_ids(void)
1026 struct crypto_testsuite_params *ts_params = &testsuite_params;
1027 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1029 /* Stop the device in case it's started so it can be configured */
1030 rte_cryptodev_stop(ts_params->valid_devs[0]);
1032 /* valid - max value queue pairs */
1033 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1035 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1037 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1038 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1040 /* valid - one queue pairs */
1041 ts_params->conf.nb_queue_pairs = 1;
1043 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1045 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1046 ts_params->valid_devs[0],
1047 ts_params->conf.nb_queue_pairs);
1050 /* invalid - zero queue pairs */
1051 ts_params->conf.nb_queue_pairs = 0;
1053 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1055 "Failed test for rte_cryptodev_configure, dev_id %u,"
1057 ts_params->valid_devs[0],
1058 ts_params->conf.nb_queue_pairs);
1061 /* invalid - max value supported by field queue pairs */
1062 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1064 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1066 "Failed test for rte_cryptodev_configure, dev_id %u,"
1068 ts_params->valid_devs[0],
1069 ts_params->conf.nb_queue_pairs);
1072 /* invalid - max value + 1 queue pairs */
1073 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1075 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1077 "Failed test for rte_cryptodev_configure, dev_id %u,"
1079 ts_params->valid_devs[0],
1080 ts_params->conf.nb_queue_pairs);
1082 /* revert to original testsuite value */
1083 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1085 return TEST_SUCCESS;
1089 test_queue_pair_descriptor_setup(void)
1091 struct crypto_testsuite_params *ts_params = &testsuite_params;
1092 struct rte_cryptodev_qp_conf qp_conf = {
1093 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1097 /* Stop the device in case it's started so it can be configured */
1098 rte_cryptodev_stop(ts_params->valid_devs[0]);
1100 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1102 "Failed to configure cryptodev %u",
1103 ts_params->valid_devs[0]);
1106 * Test various ring sizes on this device. memzones can't be
1107 * freed so are re-used if ring is released and re-created.
1109 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1110 qp_conf.mp_session = ts_params->session_mpool;
1111 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1113 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1114 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1115 ts_params->valid_devs[0], qp_id, &qp_conf,
1116 rte_cryptodev_socket_id(
1117 ts_params->valid_devs[0])),
1119 "rte_cryptodev_queue_pair_setup: num_inflights "
1120 "%u on qp %u on cryptodev %u",
1121 qp_conf.nb_descriptors, qp_id,
1122 ts_params->valid_devs[0]);
1125 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1127 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1128 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1129 ts_params->valid_devs[0], qp_id, &qp_conf,
1130 rte_cryptodev_socket_id(
1131 ts_params->valid_devs[0])),
1133 " rte_cryptodev_queue_pair_setup: num_inflights"
1134 " %u on qp %u on cryptodev %u",
1135 qp_conf.nb_descriptors, qp_id,
1136 ts_params->valid_devs[0]);
1139 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1141 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1142 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1143 ts_params->valid_devs[0], qp_id, &qp_conf,
1144 rte_cryptodev_socket_id(
1145 ts_params->valid_devs[0])),
1147 "rte_cryptodev_queue_pair_setup: num_inflights"
1148 " %u on qp %u on cryptodev %u",
1149 qp_conf.nb_descriptors, qp_id,
1150 ts_params->valid_devs[0]);
1153 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1155 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1156 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1157 ts_params->valid_devs[0], qp_id, &qp_conf,
1158 rte_cryptodev_socket_id(
1159 ts_params->valid_devs[0])),
1161 " rte_cryptodev_queue_pair_setup:"
1162 "num_inflights %u on qp %u on cryptodev %u",
1163 qp_conf.nb_descriptors, qp_id,
1164 ts_params->valid_devs[0]);
1167 /* test invalid queue pair id */
1168 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1170 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1172 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1173 ts_params->valid_devs[0],
1175 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1176 "Failed test for rte_cryptodev_queue_pair_setup:"
1177 "invalid qp %u on cryptodev %u",
1178 qp_id, ts_params->valid_devs[0]);
1180 qp_id = 0xffff; /*invalid*/
1182 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1183 ts_params->valid_devs[0],
1185 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1186 "Failed test for rte_cryptodev_queue_pair_setup:"
1187 "invalid qp %u on cryptodev %u",
1188 qp_id, ts_params->valid_devs[0]);
1190 return TEST_SUCCESS;
1193 /* ***** Plaintext data for tests ***** */
1195 const char catch_22_quote_1[] =
1196 "There was only one catch and that was Catch-22, which "
1197 "specified that a concern for one's safety in the face of "
1198 "dangers that were real and immediate was the process of a "
1199 "rational mind. Orr was crazy and could be grounded. All he "
1200 "had to do was ask; and as soon as he did, he would no longer "
1201 "be crazy and would have to fly more missions. Orr would be "
1202 "crazy to fly more missions and sane if he didn't, but if he "
1203 "was sane he had to fly them. If he flew them he was crazy "
1204 "and didn't have to; but if he didn't want to he was sane and "
1205 "had to. Yossarian was moved very deeply by the absolute "
1206 "simplicity of this clause of Catch-22 and let out a "
1207 "respectful whistle. \"That's some catch, that Catch-22\", he "
1208 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1210 const char catch_22_quote[] =
1211 "What a lousy earth! He wondered how many people were "
1212 "destitute that same night even in his own prosperous country, "
1213 "how many homes were shanties, how many husbands were drunk "
1214 "and wives socked, and how many children were bullied, abused, "
1215 "or abandoned. How many families hungered for food they could "
1216 "not afford to buy? How many hearts were broken? How many "
1217 "suicides would take place that same night, how many people "
1218 "would go insane? How many cockroaches and landlords would "
1219 "triumph? How many winners were losers, successes failures, "
1220 "and rich men poor men? How many wise guys were stupid? How "
1221 "many happy endings were unhappy endings? How many honest men "
1222 "were liars, brave men cowards, loyal men traitors, how many "
1223 "sainted men were corrupt, how many people in positions of "
1224 "trust had sold their souls to bodyguards, how many had never "
1225 "had souls? How many straight-and-narrow paths were crooked "
1226 "paths? How many best families were worst families and how "
1227 "many good people were bad people? When you added them all up "
1228 "and then subtracted, you might be left with only the children, "
1229 "and perhaps with Albert Einstein and an old violinist or "
1230 "sculptor somewhere.";
1232 #define QUOTE_480_BYTES (480)
1233 #define QUOTE_512_BYTES (512)
1234 #define QUOTE_768_BYTES (768)
1235 #define QUOTE_1024_BYTES (1024)
1239 /* ***** SHA1 Hash Tests ***** */
1241 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1243 static uint8_t hmac_sha1_key[] = {
1244 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1245 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1246 0xDE, 0xF4, 0xDE, 0xAD };
1248 /* ***** SHA224 Hash Tests ***** */
1250 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1253 /* ***** AES-CBC Cipher Tests ***** */
1255 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1256 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1258 static uint8_t aes_cbc_key[] = {
1259 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1260 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1262 static uint8_t aes_cbc_iv[] = {
1263 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1264 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1267 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1269 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1270 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1271 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1272 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1273 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1274 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1275 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1276 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1277 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1278 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1279 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1280 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1281 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1282 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1283 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1284 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1285 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1286 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1287 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1288 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1289 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1290 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1291 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1292 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1293 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1294 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1295 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1296 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1297 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1298 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1299 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1300 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1301 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1302 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1303 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1304 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1305 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1306 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1307 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1308 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1309 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1310 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1311 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1312 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1313 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1314 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1315 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1316 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1317 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1318 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1319 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1320 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1321 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1322 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1323 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1324 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1325 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1326 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1327 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1328 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1329 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1330 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1331 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1332 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1333 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1336 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1337 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1338 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1339 0x18, 0x8c, 0x1d, 0x32
1343 /* Multisession Vector context Test */
1344 /*Begin Session 0 */
1345 static uint8_t ms_aes_cbc_key0[] = {
1346 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1347 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1350 static uint8_t ms_aes_cbc_iv0[] = {
1351 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1352 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1355 static const uint8_t ms_aes_cbc_cipher0[] = {
1356 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1357 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1358 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1359 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1360 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1361 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1362 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1363 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1364 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1365 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1366 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1367 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1368 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1369 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1370 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1371 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1372 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1373 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1374 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1375 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1376 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1377 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1378 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1379 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1380 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1381 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1382 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1383 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1384 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1385 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1386 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1387 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1388 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1389 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1390 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1391 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1392 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1393 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1394 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1395 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1396 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1397 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1398 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1399 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1400 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1401 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1402 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1403 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1404 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1405 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1406 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1407 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1408 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1409 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1410 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1411 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1412 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1413 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1414 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1415 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1416 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1417 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1418 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1419 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1423 static uint8_t ms_hmac_key0[] = {
1424 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1425 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1426 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1427 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1428 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1429 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1430 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1431 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1434 static const uint8_t ms_hmac_digest0[] = {
1435 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1436 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1437 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1438 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1439 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1440 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1441 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1442 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1446 /* Begin session 1 */
1448 static uint8_t ms_aes_cbc_key1[] = {
1449 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1450 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1453 static uint8_t ms_aes_cbc_iv1[] = {
1454 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1455 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1458 static const uint8_t ms_aes_cbc_cipher1[] = {
1459 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1460 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1461 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1462 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1463 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1464 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1465 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1466 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1467 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1468 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1469 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1470 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1471 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1472 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1473 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1474 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1475 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1476 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1477 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1478 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1479 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1480 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1481 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1482 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1483 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1484 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1485 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1486 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1487 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1488 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1489 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1490 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1491 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1492 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1493 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1494 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1495 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1496 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1497 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1498 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1499 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1500 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1501 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1502 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1503 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1504 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1505 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1506 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1507 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1508 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1509 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1510 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1511 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1512 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1513 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1514 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1515 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1516 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1517 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1518 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1519 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1520 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1521 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1522 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1526 static uint8_t ms_hmac_key1[] = {
1527 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1528 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1529 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1530 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1531 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1532 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1533 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1534 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1537 static const uint8_t ms_hmac_digest1[] = {
1538 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1539 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1540 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1541 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1542 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1543 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1544 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1545 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1548 /* Begin Session 2 */
1549 static uint8_t ms_aes_cbc_key2[] = {
1550 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1551 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1554 static uint8_t ms_aes_cbc_iv2[] = {
1555 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1556 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1559 static const uint8_t ms_aes_cbc_cipher2[] = {
1560 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1561 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1562 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1563 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1564 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1565 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1566 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1567 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1568 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1569 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1570 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1571 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1572 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1573 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1574 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1575 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1576 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1577 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1578 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1579 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1580 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1581 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1582 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1583 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1584 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1585 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1586 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1587 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1588 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1589 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1590 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1591 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1592 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1593 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1594 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1595 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1596 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1597 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1598 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1599 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1600 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1601 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1602 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1603 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1604 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1605 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1606 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1607 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1608 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1609 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1610 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1611 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1612 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1613 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1614 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1615 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1616 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1617 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1618 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1619 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1620 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1621 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1622 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1623 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1626 static uint8_t ms_hmac_key2[] = {
1627 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1628 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1629 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1630 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1631 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1632 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1633 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1634 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1637 static const uint8_t ms_hmac_digest2[] = {
1638 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1639 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1640 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1641 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1642 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1643 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1644 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1645 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1652 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1654 struct crypto_testsuite_params *ts_params = &testsuite_params;
1655 struct crypto_unittest_params *ut_params = &unittest_params;
1657 /* Verify the capabilities */
1658 struct rte_cryptodev_sym_capability_idx cap_idx;
1659 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1660 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1661 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1664 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1665 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1666 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1670 /* Generate test mbuf data and space for digest */
1671 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1672 catch_22_quote, QUOTE_512_BYTES, 0);
1674 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1675 DIGEST_BYTE_LENGTH_SHA1);
1676 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1678 /* Setup Cipher Parameters */
1679 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1680 ut_params->cipher_xform.next = &ut_params->auth_xform;
1682 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1683 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1684 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1685 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1686 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1687 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1689 /* Setup HMAC Parameters */
1690 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1692 ut_params->auth_xform.next = NULL;
1694 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1695 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1696 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1697 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1698 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1700 ut_params->sess = rte_cryptodev_sym_session_create(
1701 ts_params->session_mpool);
1703 /* Create crypto session*/
1704 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1705 ut_params->sess, &ut_params->cipher_xform,
1706 ts_params->session_priv_mpool);
1707 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1709 /* Generate crypto op data structure */
1710 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1711 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1712 TEST_ASSERT_NOT_NULL(ut_params->op,
1713 "Failed to allocate symmetric crypto operation struct");
1715 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1717 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1719 /* set crypto operation source mbuf */
1720 sym_op->m_src = ut_params->ibuf;
1722 /* Set crypto operation authentication parameters */
1723 sym_op->auth.digest.data = ut_params->digest;
1724 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1725 ut_params->ibuf, QUOTE_512_BYTES);
1727 sym_op->auth.data.offset = 0;
1728 sym_op->auth.data.length = QUOTE_512_BYTES;
1730 /* Copy IV at the end of the crypto operation */
1731 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1732 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1734 /* Set crypto operation cipher parameters */
1735 sym_op->cipher.data.offset = 0;
1736 sym_op->cipher.data.length = QUOTE_512_BYTES;
1738 /* Process crypto operation */
1739 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1740 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1743 TEST_ASSERT_NOT_NULL(
1744 process_crypto_request(ts_params->valid_devs[0],
1746 "failed to process sym crypto op");
1748 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1749 "crypto op processing failed");
1752 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1755 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1756 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1758 "ciphertext data not as expected");
1760 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1762 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1763 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1764 gbl_driver_id == rte_cryptodev_driver_id_get(
1765 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1766 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1767 DIGEST_BYTE_LENGTH_SHA1,
1768 "Generated digest data not as expected");
1770 return TEST_SUCCESS;
1773 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1775 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1777 static uint8_t hmac_sha512_key[] = {
1778 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1779 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1780 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1781 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1782 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1783 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1784 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1785 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1787 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1788 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1789 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1790 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1791 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1792 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1793 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1794 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1795 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1800 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1801 struct crypto_unittest_params *ut_params,
1802 uint8_t *cipher_key,
1806 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1807 struct crypto_unittest_params *ut_params,
1808 struct crypto_testsuite_params *ts_params,
1809 const uint8_t *cipher,
1810 const uint8_t *digest,
1815 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1816 struct crypto_unittest_params *ut_params,
1817 uint8_t *cipher_key,
1821 /* Setup Cipher Parameters */
1822 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1823 ut_params->cipher_xform.next = NULL;
1825 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1826 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1827 ut_params->cipher_xform.cipher.key.data = cipher_key;
1828 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1829 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1830 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1832 /* Setup HMAC Parameters */
1833 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1834 ut_params->auth_xform.next = &ut_params->cipher_xform;
1836 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1837 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1838 ut_params->auth_xform.auth.key.data = hmac_key;
1839 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1840 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1842 return TEST_SUCCESS;
1847 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1848 struct crypto_unittest_params *ut_params,
1849 struct crypto_testsuite_params *ts_params,
1850 const uint8_t *cipher,
1851 const uint8_t *digest,
1854 /* Generate test mbuf data and digest */
1855 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1858 QUOTE_512_BYTES, 0);
1860 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1861 DIGEST_BYTE_LENGTH_SHA512);
1862 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1864 rte_memcpy(ut_params->digest,
1866 DIGEST_BYTE_LENGTH_SHA512);
1868 /* Generate Crypto op data structure */
1869 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1870 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1871 TEST_ASSERT_NOT_NULL(ut_params->op,
1872 "Failed to allocate symmetric crypto operation struct");
1874 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1876 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1878 /* set crypto operation source mbuf */
1879 sym_op->m_src = ut_params->ibuf;
1881 sym_op->auth.digest.data = ut_params->digest;
1882 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1883 ut_params->ibuf, QUOTE_512_BYTES);
1885 sym_op->auth.data.offset = 0;
1886 sym_op->auth.data.length = QUOTE_512_BYTES;
1888 /* Copy IV at the end of the crypto operation */
1889 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1890 iv, CIPHER_IV_LENGTH_AES_CBC);
1892 sym_op->cipher.data.offset = 0;
1893 sym_op->cipher.data.length = QUOTE_512_BYTES;
1895 /* Process crypto operation */
1896 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1897 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1899 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1900 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
1901 ut_params->op, 1, 1, 0, 0);
1903 TEST_ASSERT_NOT_NULL(
1904 process_crypto_request(ts_params->valid_devs[0],
1906 "failed to process sym crypto op");
1908 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1909 "crypto op processing failed");
1911 ut_params->obuf = ut_params->op->sym->m_src;
1914 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1915 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1918 "Plaintext data not as expected");
1921 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1922 "Digest verification failed");
1924 return TEST_SUCCESS;
1928 test_blockcipher(enum blockcipher_test_type test_type)
1930 struct crypto_testsuite_params *ts_params = &testsuite_params;
1933 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1934 ts_params->op_mpool,
1935 ts_params->session_mpool, ts_params->session_priv_mpool,
1936 ts_params->valid_devs[0],
1939 if (status == -ENOTSUP)
1942 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1944 return TEST_SUCCESS;
1948 test_AES_cipheronly_all(void)
1950 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1954 test_AES_docsis_all(void)
1956 /* Data-path service does not support DOCSIS yet */
1957 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1959 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1963 test_DES_docsis_all(void)
1965 /* Data-path service does not support DOCSIS yet */
1966 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1968 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1972 test_DES_cipheronly_all(void)
1974 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1978 test_authonly_all(void)
1980 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1984 test_AES_chain_all(void)
1986 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1990 test_3DES_chain_all(void)
1992 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1996 test_3DES_cipheronly_all(void)
1998 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
2001 /* ***** SNOW 3G Tests ***** */
2003 create_wireless_algo_hash_session(uint8_t dev_id,
2004 const uint8_t *key, const uint8_t key_len,
2005 const uint8_t iv_len, const uint8_t auth_len,
2006 enum rte_crypto_auth_operation op,
2007 enum rte_crypto_auth_algorithm algo)
2009 uint8_t hash_key[key_len];
2012 struct crypto_testsuite_params *ts_params = &testsuite_params;
2013 struct crypto_unittest_params *ut_params = &unittest_params;
2015 memcpy(hash_key, key, key_len);
2017 debug_hexdump(stdout, "key:", key, key_len);
2019 /* Setup Authentication Parameters */
2020 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2021 ut_params->auth_xform.next = NULL;
2023 ut_params->auth_xform.auth.op = op;
2024 ut_params->auth_xform.auth.algo = algo;
2025 ut_params->auth_xform.auth.key.length = key_len;
2026 ut_params->auth_xform.auth.key.data = hash_key;
2027 ut_params->auth_xform.auth.digest_length = auth_len;
2028 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2029 ut_params->auth_xform.auth.iv.length = iv_len;
2030 ut_params->sess = rte_cryptodev_sym_session_create(
2031 ts_params->session_mpool);
2033 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2034 &ut_params->auth_xform,
2035 ts_params->session_priv_mpool);
2036 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2037 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2042 create_wireless_algo_cipher_session(uint8_t dev_id,
2043 enum rte_crypto_cipher_operation op,
2044 enum rte_crypto_cipher_algorithm algo,
2045 const uint8_t *key, const uint8_t key_len,
2048 uint8_t cipher_key[key_len];
2050 struct crypto_testsuite_params *ts_params = &testsuite_params;
2051 struct crypto_unittest_params *ut_params = &unittest_params;
2053 memcpy(cipher_key, key, key_len);
2055 /* Setup Cipher Parameters */
2056 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2057 ut_params->cipher_xform.next = NULL;
2059 ut_params->cipher_xform.cipher.algo = algo;
2060 ut_params->cipher_xform.cipher.op = op;
2061 ut_params->cipher_xform.cipher.key.data = cipher_key;
2062 ut_params->cipher_xform.cipher.key.length = key_len;
2063 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2064 ut_params->cipher_xform.cipher.iv.length = iv_len;
2066 debug_hexdump(stdout, "key:", key, key_len);
2068 /* Create Crypto session */
2069 ut_params->sess = rte_cryptodev_sym_session_create(
2070 ts_params->session_mpool);
2072 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2073 &ut_params->cipher_xform,
2074 ts_params->session_priv_mpool);
2075 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2076 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2081 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2082 unsigned int cipher_len,
2083 unsigned int cipher_offset)
2085 struct crypto_testsuite_params *ts_params = &testsuite_params;
2086 struct crypto_unittest_params *ut_params = &unittest_params;
2088 /* Generate Crypto op data structure */
2089 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2090 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2091 TEST_ASSERT_NOT_NULL(ut_params->op,
2092 "Failed to allocate pktmbuf offload");
2094 /* Set crypto operation data parameters */
2095 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2097 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2099 /* set crypto operation source mbuf */
2100 sym_op->m_src = ut_params->ibuf;
2103 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2105 sym_op->cipher.data.length = cipher_len;
2106 sym_op->cipher.data.offset = cipher_offset;
2111 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2112 unsigned int cipher_len,
2113 unsigned int cipher_offset)
2115 struct crypto_testsuite_params *ts_params = &testsuite_params;
2116 struct crypto_unittest_params *ut_params = &unittest_params;
2118 /* Generate Crypto op data structure */
2119 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2120 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2121 TEST_ASSERT_NOT_NULL(ut_params->op,
2122 "Failed to allocate pktmbuf offload");
2124 /* Set crypto operation data parameters */
2125 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2127 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2129 /* set crypto operation source mbuf */
2130 sym_op->m_src = ut_params->ibuf;
2131 sym_op->m_dst = ut_params->obuf;
2134 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2136 sym_op->cipher.data.length = cipher_len;
2137 sym_op->cipher.data.offset = cipher_offset;
2142 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2143 enum rte_crypto_cipher_operation cipher_op,
2144 enum rte_crypto_auth_operation auth_op,
2145 enum rte_crypto_auth_algorithm auth_algo,
2146 enum rte_crypto_cipher_algorithm cipher_algo,
2147 const uint8_t *key, uint8_t key_len,
2148 uint8_t auth_iv_len, uint8_t auth_len,
2149 uint8_t cipher_iv_len)
2152 uint8_t cipher_auth_key[key_len];
2155 struct crypto_testsuite_params *ts_params = &testsuite_params;
2156 struct crypto_unittest_params *ut_params = &unittest_params;
2158 memcpy(cipher_auth_key, key, key_len);
2160 /* Setup Authentication Parameters */
2161 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2162 ut_params->auth_xform.next = NULL;
2164 ut_params->auth_xform.auth.op = auth_op;
2165 ut_params->auth_xform.auth.algo = auth_algo;
2166 ut_params->auth_xform.auth.key.length = key_len;
2167 /* Hash key = cipher key */
2168 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2169 ut_params->auth_xform.auth.digest_length = auth_len;
2170 /* Auth IV will be after cipher IV */
2171 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2172 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2174 /* Setup Cipher Parameters */
2175 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2176 ut_params->cipher_xform.next = &ut_params->auth_xform;
2178 ut_params->cipher_xform.cipher.algo = cipher_algo;
2179 ut_params->cipher_xform.cipher.op = cipher_op;
2180 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2181 ut_params->cipher_xform.cipher.key.length = key_len;
2182 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2183 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2185 debug_hexdump(stdout, "key:", key, key_len);
2187 /* Create Crypto session*/
2188 ut_params->sess = rte_cryptodev_sym_session_create(
2189 ts_params->session_mpool);
2190 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2192 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2193 &ut_params->cipher_xform,
2194 ts_params->session_priv_mpool);
2195 if (status == -ENOTSUP)
2198 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2203 create_wireless_cipher_auth_session(uint8_t dev_id,
2204 enum rte_crypto_cipher_operation cipher_op,
2205 enum rte_crypto_auth_operation auth_op,
2206 enum rte_crypto_auth_algorithm auth_algo,
2207 enum rte_crypto_cipher_algorithm cipher_algo,
2208 const struct wireless_test_data *tdata)
2210 const uint8_t key_len = tdata->key.len;
2211 uint8_t cipher_auth_key[key_len];
2214 struct crypto_testsuite_params *ts_params = &testsuite_params;
2215 struct crypto_unittest_params *ut_params = &unittest_params;
2216 const uint8_t *key = tdata->key.data;
2217 const uint8_t auth_len = tdata->digest.len;
2218 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2219 uint8_t auth_iv_len = tdata->auth_iv.len;
2221 memcpy(cipher_auth_key, key, key_len);
2223 /* Setup Authentication Parameters */
2224 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2225 ut_params->auth_xform.next = NULL;
2227 ut_params->auth_xform.auth.op = auth_op;
2228 ut_params->auth_xform.auth.algo = auth_algo;
2229 ut_params->auth_xform.auth.key.length = key_len;
2230 /* Hash key = cipher key */
2231 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2232 ut_params->auth_xform.auth.digest_length = auth_len;
2233 /* Auth IV will be after cipher IV */
2234 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2235 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2237 /* Setup Cipher Parameters */
2238 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2239 ut_params->cipher_xform.next = &ut_params->auth_xform;
2241 ut_params->cipher_xform.cipher.algo = cipher_algo;
2242 ut_params->cipher_xform.cipher.op = cipher_op;
2243 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2244 ut_params->cipher_xform.cipher.key.length = key_len;
2245 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2246 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2249 debug_hexdump(stdout, "key:", key, key_len);
2251 /* Create Crypto session*/
2252 ut_params->sess = rte_cryptodev_sym_session_create(
2253 ts_params->session_mpool);
2255 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2256 &ut_params->cipher_xform,
2257 ts_params->session_priv_mpool);
2258 if (status == -ENOTSUP)
2261 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2262 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2267 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2268 const struct wireless_test_data *tdata)
2270 return create_wireless_cipher_auth_session(dev_id,
2271 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2272 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2273 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2277 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2278 enum rte_crypto_cipher_operation cipher_op,
2279 enum rte_crypto_auth_operation auth_op,
2280 enum rte_crypto_auth_algorithm auth_algo,
2281 enum rte_crypto_cipher_algorithm cipher_algo,
2282 const uint8_t *key, const uint8_t key_len,
2283 uint8_t auth_iv_len, uint8_t auth_len,
2284 uint8_t cipher_iv_len)
2286 uint8_t auth_cipher_key[key_len];
2288 struct crypto_testsuite_params *ts_params = &testsuite_params;
2289 struct crypto_unittest_params *ut_params = &unittest_params;
2291 memcpy(auth_cipher_key, key, key_len);
2293 /* Setup Authentication Parameters */
2294 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2295 ut_params->auth_xform.auth.op = auth_op;
2296 ut_params->auth_xform.next = &ut_params->cipher_xform;
2297 ut_params->auth_xform.auth.algo = auth_algo;
2298 ut_params->auth_xform.auth.key.length = key_len;
2299 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2300 ut_params->auth_xform.auth.digest_length = auth_len;
2301 /* Auth IV will be after cipher IV */
2302 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2303 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2305 /* Setup Cipher Parameters */
2306 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2307 ut_params->cipher_xform.next = NULL;
2308 ut_params->cipher_xform.cipher.algo = cipher_algo;
2309 ut_params->cipher_xform.cipher.op = cipher_op;
2310 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2311 ut_params->cipher_xform.cipher.key.length = key_len;
2312 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2313 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2315 debug_hexdump(stdout, "key:", key, key_len);
2317 /* Create Crypto session*/
2318 ut_params->sess = rte_cryptodev_sym_session_create(
2319 ts_params->session_mpool);
2320 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2322 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2323 ut_params->auth_xform.next = NULL;
2324 ut_params->cipher_xform.next = &ut_params->auth_xform;
2325 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2326 &ut_params->cipher_xform,
2327 ts_params->session_priv_mpool);
2330 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2331 &ut_params->auth_xform,
2332 ts_params->session_priv_mpool);
2334 if (status == -ENOTSUP)
2337 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2343 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2344 unsigned int auth_tag_len,
2345 const uint8_t *iv, unsigned int iv_len,
2346 unsigned int data_pad_len,
2347 enum rte_crypto_auth_operation op,
2348 unsigned int auth_len, unsigned int auth_offset)
2350 struct crypto_testsuite_params *ts_params = &testsuite_params;
2352 struct crypto_unittest_params *ut_params = &unittest_params;
2354 /* Generate Crypto op data structure */
2355 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2356 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2357 TEST_ASSERT_NOT_NULL(ut_params->op,
2358 "Failed to allocate pktmbuf offload");
2360 /* Set crypto operation data parameters */
2361 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2363 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2365 /* set crypto operation source mbuf */
2366 sym_op->m_src = ut_params->ibuf;
2369 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2372 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2373 ut_params->ibuf, auth_tag_len);
2375 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2376 "no room to append auth tag");
2377 ut_params->digest = sym_op->auth.digest.data;
2378 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2379 ut_params->ibuf, data_pad_len);
2380 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2381 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2383 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2385 debug_hexdump(stdout, "digest:",
2386 sym_op->auth.digest.data,
2389 sym_op->auth.data.length = auth_len;
2390 sym_op->auth.data.offset = auth_offset;
2396 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2397 enum rte_crypto_auth_operation op)
2399 struct crypto_testsuite_params *ts_params = &testsuite_params;
2400 struct crypto_unittest_params *ut_params = &unittest_params;
2402 const uint8_t *auth_tag = tdata->digest.data;
2403 const unsigned int auth_tag_len = tdata->digest.len;
2404 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2405 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2407 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2408 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2409 const uint8_t *auth_iv = tdata->auth_iv.data;
2410 const uint8_t auth_iv_len = tdata->auth_iv.len;
2411 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2412 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2414 /* Generate Crypto op data structure */
2415 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2416 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2417 TEST_ASSERT_NOT_NULL(ut_params->op,
2418 "Failed to allocate pktmbuf offload");
2419 /* Set crypto operation data parameters */
2420 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2422 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2424 /* set crypto operation source mbuf */
2425 sym_op->m_src = ut_params->ibuf;
2428 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2429 ut_params->ibuf, auth_tag_len);
2431 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2432 "no room to append auth tag");
2433 ut_params->digest = sym_op->auth.digest.data;
2434 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2435 ut_params->ibuf, data_pad_len);
2436 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2437 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2439 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2441 debug_hexdump(stdout, "digest:",
2442 sym_op->auth.digest.data,
2445 /* Copy cipher and auth IVs at the end of the crypto operation */
2446 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2448 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2449 iv_ptr += cipher_iv_len;
2450 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2452 sym_op->cipher.data.length = cipher_len;
2453 sym_op->cipher.data.offset = 0;
2454 sym_op->auth.data.length = auth_len;
2455 sym_op->auth.data.offset = 0;
2461 create_zuc_cipher_hash_generate_operation(
2462 const struct wireless_test_data *tdata)
2464 return create_wireless_cipher_hash_operation(tdata,
2465 RTE_CRYPTO_AUTH_OP_GENERATE);
2469 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2470 const unsigned auth_tag_len,
2471 const uint8_t *auth_iv, uint8_t auth_iv_len,
2472 unsigned data_pad_len,
2473 enum rte_crypto_auth_operation op,
2474 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2475 const unsigned cipher_len, const unsigned cipher_offset,
2476 const unsigned auth_len, const unsigned auth_offset)
2478 struct crypto_testsuite_params *ts_params = &testsuite_params;
2479 struct crypto_unittest_params *ut_params = &unittest_params;
2481 enum rte_crypto_cipher_algorithm cipher_algo =
2482 ut_params->cipher_xform.cipher.algo;
2483 enum rte_crypto_auth_algorithm auth_algo =
2484 ut_params->auth_xform.auth.algo;
2486 /* Generate Crypto op data structure */
2487 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2488 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2489 TEST_ASSERT_NOT_NULL(ut_params->op,
2490 "Failed to allocate pktmbuf offload");
2491 /* Set crypto operation data parameters */
2492 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2494 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2496 /* set crypto operation source mbuf */
2497 sym_op->m_src = ut_params->ibuf;
2500 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2501 ut_params->ibuf, auth_tag_len);
2503 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2504 "no room to append auth tag");
2505 ut_params->digest = sym_op->auth.digest.data;
2507 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2508 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2509 ut_params->ibuf, data_pad_len);
2511 struct rte_mbuf *m = ut_params->ibuf;
2512 unsigned int offset = data_pad_len;
2514 while (offset > m->data_len && m->next != NULL) {
2515 offset -= m->data_len;
2518 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2522 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2523 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2525 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2527 debug_hexdump(stdout, "digest:",
2528 sym_op->auth.digest.data,
2531 /* Copy cipher and auth IVs at the end of the crypto operation */
2532 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2534 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2535 iv_ptr += cipher_iv_len;
2536 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2538 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2539 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2540 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2541 sym_op->cipher.data.length = cipher_len;
2542 sym_op->cipher.data.offset = cipher_offset;
2544 sym_op->cipher.data.length = cipher_len >> 3;
2545 sym_op->cipher.data.offset = cipher_offset >> 3;
2548 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2549 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2550 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2551 sym_op->auth.data.length = auth_len;
2552 sym_op->auth.data.offset = auth_offset;
2554 sym_op->auth.data.length = auth_len >> 3;
2555 sym_op->auth.data.offset = auth_offset >> 3;
2562 create_wireless_algo_auth_cipher_operation(
2563 const uint8_t *auth_tag, unsigned int auth_tag_len,
2564 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2565 const uint8_t *auth_iv, uint8_t auth_iv_len,
2566 unsigned int data_pad_len,
2567 unsigned int cipher_len, unsigned int cipher_offset,
2568 unsigned int auth_len, unsigned int auth_offset,
2569 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2571 struct crypto_testsuite_params *ts_params = &testsuite_params;
2572 struct crypto_unittest_params *ut_params = &unittest_params;
2574 enum rte_crypto_cipher_algorithm cipher_algo =
2575 ut_params->cipher_xform.cipher.algo;
2576 enum rte_crypto_auth_algorithm auth_algo =
2577 ut_params->auth_xform.auth.algo;
2579 /* Generate Crypto op data structure */
2580 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2581 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2582 TEST_ASSERT_NOT_NULL(ut_params->op,
2583 "Failed to allocate pktmbuf offload");
2585 /* Set crypto operation data parameters */
2586 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2588 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2590 /* set crypto operation mbufs */
2591 sym_op->m_src = ut_params->ibuf;
2592 if (op_mode == OUT_OF_PLACE)
2593 sym_op->m_dst = ut_params->obuf;
2597 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2598 (op_mode == IN_PLACE ?
2599 ut_params->ibuf : ut_params->obuf),
2600 uint8_t *, data_pad_len);
2601 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2602 (op_mode == IN_PLACE ?
2603 ut_params->ibuf : ut_params->obuf),
2605 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2607 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2608 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2609 sym_op->m_src : sym_op->m_dst);
2610 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2611 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2612 sgl_buf = sgl_buf->next;
2614 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2615 uint8_t *, remaining_off);
2616 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2618 memset(sym_op->auth.digest.data, 0, remaining_off);
2619 while (sgl_buf->next != NULL) {
2620 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2621 0, rte_pktmbuf_data_len(sgl_buf));
2622 sgl_buf = sgl_buf->next;
2626 /* Copy digest for the verification */
2628 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2630 /* Copy cipher and auth IVs at the end of the crypto operation */
2631 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2632 ut_params->op, uint8_t *, IV_OFFSET);
2634 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2635 iv_ptr += cipher_iv_len;
2636 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2638 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2639 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2640 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2641 sym_op->cipher.data.length = cipher_len;
2642 sym_op->cipher.data.offset = cipher_offset;
2644 sym_op->cipher.data.length = cipher_len >> 3;
2645 sym_op->cipher.data.offset = cipher_offset >> 3;
2648 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2649 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2650 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2651 sym_op->auth.data.length = auth_len;
2652 sym_op->auth.data.offset = auth_offset;
2654 sym_op->auth.data.length = auth_len >> 3;
2655 sym_op->auth.data.offset = auth_offset >> 3;
2662 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2664 struct crypto_testsuite_params *ts_params = &testsuite_params;
2665 struct crypto_unittest_params *ut_params = &unittest_params;
2668 unsigned plaintext_pad_len;
2669 unsigned plaintext_len;
2671 struct rte_cryptodev_info dev_info;
2673 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2674 uint64_t feat_flags = dev_info.feature_flags;
2676 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2677 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2678 printf("Device doesn't support NON-Byte Aligned Data.\n");
2682 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2683 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2684 printf("Device doesn't support RAW data-path APIs.\n");
2688 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2691 /* Verify the capabilities */
2692 struct rte_cryptodev_sym_capability_idx cap_idx;
2693 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2694 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2695 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2699 /* Create SNOW 3G session */
2700 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2701 tdata->key.data, tdata->key.len,
2702 tdata->auth_iv.len, tdata->digest.len,
2703 RTE_CRYPTO_AUTH_OP_GENERATE,
2704 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2708 /* alloc mbuf and set payload */
2709 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2711 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2712 rte_pktmbuf_tailroom(ut_params->ibuf));
2714 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2715 /* Append data which is padded to a multiple of */
2716 /* the algorithms block size */
2717 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2718 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2720 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2722 /* Create SNOW 3G operation */
2723 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2724 tdata->auth_iv.data, tdata->auth_iv.len,
2725 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2726 tdata->validAuthLenInBits.len,
2731 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2732 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2733 ut_params->op, 0, 1, 1, 0);
2735 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2737 ut_params->obuf = ut_params->op->sym->m_src;
2738 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2739 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2740 + plaintext_pad_len;
2743 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2746 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2747 "SNOW 3G Generated auth tag not as expected");
2753 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2755 struct crypto_testsuite_params *ts_params = &testsuite_params;
2756 struct crypto_unittest_params *ut_params = &unittest_params;
2759 unsigned plaintext_pad_len;
2760 unsigned plaintext_len;
2762 struct rte_cryptodev_info dev_info;
2764 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2765 uint64_t feat_flags = dev_info.feature_flags;
2767 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2768 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2769 printf("Device doesn't support NON-Byte Aligned Data.\n");
2773 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2774 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2775 printf("Device doesn't support RAW data-path APIs.\n");
2779 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2782 /* Verify the capabilities */
2783 struct rte_cryptodev_sym_capability_idx cap_idx;
2784 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2785 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2786 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2790 /* Create SNOW 3G session */
2791 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2792 tdata->key.data, tdata->key.len,
2793 tdata->auth_iv.len, tdata->digest.len,
2794 RTE_CRYPTO_AUTH_OP_VERIFY,
2795 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2798 /* alloc mbuf and set payload */
2799 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2801 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2802 rte_pktmbuf_tailroom(ut_params->ibuf));
2804 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2805 /* Append data which is padded to a multiple of */
2806 /* the algorithms block size */
2807 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2808 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2810 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2812 /* Create SNOW 3G operation */
2813 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2815 tdata->auth_iv.data, tdata->auth_iv.len,
2817 RTE_CRYPTO_AUTH_OP_VERIFY,
2818 tdata->validAuthLenInBits.len,
2823 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2824 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2825 ut_params->op, 0, 1, 1, 0);
2827 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2829 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2830 ut_params->obuf = ut_params->op->sym->m_src;
2831 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2832 + plaintext_pad_len;
2835 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2844 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2846 struct crypto_testsuite_params *ts_params = &testsuite_params;
2847 struct crypto_unittest_params *ut_params = &unittest_params;
2850 unsigned plaintext_pad_len;
2851 unsigned plaintext_len;
2853 struct rte_cryptodev_info dev_info;
2855 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2856 uint64_t feat_flags = dev_info.feature_flags;
2858 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2859 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2860 printf("Device doesn't support RAW data-path APIs.\n");
2864 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2867 /* Verify the capabilities */
2868 struct rte_cryptodev_sym_capability_idx cap_idx;
2869 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2870 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2871 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2875 /* Create KASUMI session */
2876 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2877 tdata->key.data, tdata->key.len,
2878 0, tdata->digest.len,
2879 RTE_CRYPTO_AUTH_OP_GENERATE,
2880 RTE_CRYPTO_AUTH_KASUMI_F9);
2884 /* alloc mbuf and set payload */
2885 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2887 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2888 rte_pktmbuf_tailroom(ut_params->ibuf));
2890 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2891 /* Append data which is padded to a multiple of */
2892 /* the algorithms block size */
2893 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2894 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2896 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2898 /* Create KASUMI operation */
2899 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2901 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2902 tdata->plaintext.len,
2907 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2908 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2910 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2911 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2912 ut_params->op, 0, 1, 1, 0);
2914 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2917 ut_params->obuf = ut_params->op->sym->m_src;
2918 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2919 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2920 + plaintext_pad_len;
2923 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2926 DIGEST_BYTE_LENGTH_KASUMI_F9,
2927 "KASUMI Generated auth tag not as expected");
2933 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2935 struct crypto_testsuite_params *ts_params = &testsuite_params;
2936 struct crypto_unittest_params *ut_params = &unittest_params;
2939 unsigned plaintext_pad_len;
2940 unsigned plaintext_len;
2942 struct rte_cryptodev_info dev_info;
2944 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2945 uint64_t feat_flags = dev_info.feature_flags;
2947 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2948 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2949 printf("Device doesn't support RAW data-path APIs.\n");
2953 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2956 /* Verify the capabilities */
2957 struct rte_cryptodev_sym_capability_idx cap_idx;
2958 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2959 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2960 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2964 /* Create KASUMI session */
2965 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2966 tdata->key.data, tdata->key.len,
2967 0, tdata->digest.len,
2968 RTE_CRYPTO_AUTH_OP_VERIFY,
2969 RTE_CRYPTO_AUTH_KASUMI_F9);
2972 /* alloc mbuf and set payload */
2973 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2975 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2976 rte_pktmbuf_tailroom(ut_params->ibuf));
2978 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2979 /* Append data which is padded to a multiple */
2980 /* of the algorithms block size */
2981 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2982 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2984 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2986 /* Create KASUMI operation */
2987 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2991 RTE_CRYPTO_AUTH_OP_VERIFY,
2992 tdata->plaintext.len,
2997 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2998 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2999 ut_params->op, 0, 1, 1, 0);
3001 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3003 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3004 ut_params->obuf = ut_params->op->sym->m_src;
3005 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3006 + plaintext_pad_len;
3009 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3018 test_snow3g_hash_generate_test_case_1(void)
3020 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3024 test_snow3g_hash_generate_test_case_2(void)
3026 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3030 test_snow3g_hash_generate_test_case_3(void)
3032 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3036 test_snow3g_hash_generate_test_case_4(void)
3038 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3042 test_snow3g_hash_generate_test_case_5(void)
3044 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3048 test_snow3g_hash_generate_test_case_6(void)
3050 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3054 test_snow3g_hash_verify_test_case_1(void)
3056 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3061 test_snow3g_hash_verify_test_case_2(void)
3063 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3067 test_snow3g_hash_verify_test_case_3(void)
3069 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3073 test_snow3g_hash_verify_test_case_4(void)
3075 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3079 test_snow3g_hash_verify_test_case_5(void)
3081 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3085 test_snow3g_hash_verify_test_case_6(void)
3087 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3091 test_kasumi_hash_generate_test_case_1(void)
3093 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3097 test_kasumi_hash_generate_test_case_2(void)
3099 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3103 test_kasumi_hash_generate_test_case_3(void)
3105 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3109 test_kasumi_hash_generate_test_case_4(void)
3111 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3115 test_kasumi_hash_generate_test_case_5(void)
3117 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3121 test_kasumi_hash_generate_test_case_6(void)
3123 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3127 test_kasumi_hash_verify_test_case_1(void)
3129 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3133 test_kasumi_hash_verify_test_case_2(void)
3135 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3139 test_kasumi_hash_verify_test_case_3(void)
3141 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3145 test_kasumi_hash_verify_test_case_4(void)
3147 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3151 test_kasumi_hash_verify_test_case_5(void)
3153 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3157 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3159 struct crypto_testsuite_params *ts_params = &testsuite_params;
3160 struct crypto_unittest_params *ut_params = &unittest_params;
3163 uint8_t *plaintext, *ciphertext;
3164 unsigned plaintext_pad_len;
3165 unsigned plaintext_len;
3166 struct rte_cryptodev_info dev_info;
3168 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3169 uint64_t feat_flags = dev_info.feature_flags;
3171 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3172 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3173 printf("Device doesn't support RAW data-path APIs.\n");
3177 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3180 /* Verify the capabilities */
3181 struct rte_cryptodev_sym_capability_idx cap_idx;
3182 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3183 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3184 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3188 /* Create KASUMI session */
3189 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3190 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3191 RTE_CRYPTO_CIPHER_KASUMI_F8,
3192 tdata->key.data, tdata->key.len,
3193 tdata->cipher_iv.len);
3197 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3199 /* Clear mbuf payload */
3200 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3201 rte_pktmbuf_tailroom(ut_params->ibuf));
3203 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3204 /* Append data which is padded to a multiple */
3205 /* of the algorithms block size */
3206 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3207 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3209 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3211 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3213 /* Create KASUMI operation */
3214 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3215 tdata->cipher_iv.len,
3216 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3217 tdata->validCipherOffsetInBits.len);
3221 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3222 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3223 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3225 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3227 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3229 ut_params->obuf = ut_params->op->sym->m_dst;
3230 if (ut_params->obuf)
3231 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3233 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3235 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3237 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3238 (tdata->validCipherOffsetInBits.len >> 3);
3240 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3242 reference_ciphertext,
3243 tdata->validCipherLenInBits.len,
3244 "KASUMI Ciphertext data not as expected");
3249 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3251 struct crypto_testsuite_params *ts_params = &testsuite_params;
3252 struct crypto_unittest_params *ut_params = &unittest_params;
3256 unsigned int plaintext_pad_len;
3257 unsigned int plaintext_len;
3259 uint8_t buffer[10000];
3260 const uint8_t *ciphertext;
3262 struct rte_cryptodev_info dev_info;
3264 /* Verify the capabilities */
3265 struct rte_cryptodev_sym_capability_idx cap_idx;
3266 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3267 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3268 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3272 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3274 uint64_t feat_flags = dev_info.feature_flags;
3276 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3277 printf("Device doesn't support in-place scatter-gather. "
3282 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3283 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3284 printf("Device doesn't support RAW data-path APIs.\n");
3288 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3291 /* Create KASUMI session */
3292 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3293 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3294 RTE_CRYPTO_CIPHER_KASUMI_F8,
3295 tdata->key.data, tdata->key.len,
3296 tdata->cipher_iv.len);
3300 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3303 /* Append data which is padded to a multiple */
3304 /* of the algorithms block size */
3305 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3307 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3308 plaintext_pad_len, 10, 0);
3310 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3312 /* Create KASUMI operation */
3313 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3314 tdata->cipher_iv.len,
3315 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3316 tdata->validCipherOffsetInBits.len);
3320 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3321 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3322 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3324 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3326 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3328 ut_params->obuf = ut_params->op->sym->m_dst;
3330 if (ut_params->obuf)
3331 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3332 plaintext_len, buffer);
3334 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3335 tdata->validCipherOffsetInBits.len >> 3,
3336 plaintext_len, buffer);
3339 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3341 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3342 (tdata->validCipherOffsetInBits.len >> 3);
3344 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3346 reference_ciphertext,
3347 tdata->validCipherLenInBits.len,
3348 "KASUMI Ciphertext data not as expected");
3353 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3355 struct crypto_testsuite_params *ts_params = &testsuite_params;
3356 struct crypto_unittest_params *ut_params = &unittest_params;
3359 uint8_t *plaintext, *ciphertext;
3360 unsigned plaintext_pad_len;
3361 unsigned plaintext_len;
3363 /* Verify the capabilities */
3364 struct rte_cryptodev_sym_capability_idx cap_idx;
3365 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3366 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3367 /* Data-path service does not support OOP */
3368 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3372 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3375 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3378 /* Create KASUMI session */
3379 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3380 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3381 RTE_CRYPTO_CIPHER_KASUMI_F8,
3382 tdata->key.data, tdata->key.len,
3383 tdata->cipher_iv.len);
3387 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3388 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3390 /* Clear mbuf payload */
3391 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3392 rte_pktmbuf_tailroom(ut_params->ibuf));
3394 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3395 /* Append data which is padded to a multiple */
3396 /* of the algorithms block size */
3397 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3398 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3400 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3401 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3403 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3405 /* Create KASUMI operation */
3406 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3407 tdata->cipher_iv.len,
3408 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3409 tdata->validCipherOffsetInBits.len);
3413 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3415 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3417 ut_params->obuf = ut_params->op->sym->m_dst;
3418 if (ut_params->obuf)
3419 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3421 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3423 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3425 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3426 (tdata->validCipherOffsetInBits.len >> 3);
3428 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3430 reference_ciphertext,
3431 tdata->validCipherLenInBits.len,
3432 "KASUMI Ciphertext data not as expected");
3437 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3439 struct crypto_testsuite_params *ts_params = &testsuite_params;
3440 struct crypto_unittest_params *ut_params = &unittest_params;
3443 unsigned int plaintext_pad_len;
3444 unsigned int plaintext_len;
3446 const uint8_t *ciphertext;
3447 uint8_t buffer[2048];
3449 struct rte_cryptodev_info dev_info;
3451 /* Verify the capabilities */
3452 struct rte_cryptodev_sym_capability_idx cap_idx;
3453 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3454 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3455 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3459 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3462 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3465 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3467 uint64_t feat_flags = dev_info.feature_flags;
3468 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3469 printf("Device doesn't support out-of-place scatter-gather "
3470 "in both input and output mbufs. "
3475 /* Create KASUMI session */
3476 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3477 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3478 RTE_CRYPTO_CIPHER_KASUMI_F8,
3479 tdata->key.data, tdata->key.len,
3480 tdata->cipher_iv.len);
3484 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3485 /* Append data which is padded to a multiple */
3486 /* of the algorithms block size */
3487 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3489 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3490 plaintext_pad_len, 10, 0);
3491 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3492 plaintext_pad_len, 3, 0);
3494 /* Append data which is padded to a multiple */
3495 /* of the algorithms block size */
3496 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3498 /* Create KASUMI operation */
3499 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3500 tdata->cipher_iv.len,
3501 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3502 tdata->validCipherOffsetInBits.len);
3506 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3508 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3510 ut_params->obuf = ut_params->op->sym->m_dst;
3511 if (ut_params->obuf)
3512 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3513 plaintext_pad_len, buffer);
3515 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3516 tdata->validCipherOffsetInBits.len >> 3,
3517 plaintext_pad_len, buffer);
3519 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3520 (tdata->validCipherOffsetInBits.len >> 3);
3522 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3524 reference_ciphertext,
3525 tdata->validCipherLenInBits.len,
3526 "KASUMI Ciphertext data not as expected");
3532 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3534 struct crypto_testsuite_params *ts_params = &testsuite_params;
3535 struct crypto_unittest_params *ut_params = &unittest_params;
3538 uint8_t *ciphertext, *plaintext;
3539 unsigned ciphertext_pad_len;
3540 unsigned ciphertext_len;
3542 /* Verify the capabilities */
3543 struct rte_cryptodev_sym_capability_idx cap_idx;
3544 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3545 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3546 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3550 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3553 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3556 /* Create KASUMI session */
3557 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3558 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3559 RTE_CRYPTO_CIPHER_KASUMI_F8,
3560 tdata->key.data, tdata->key.len,
3561 tdata->cipher_iv.len);
3565 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3566 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3568 /* Clear mbuf payload */
3569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3570 rte_pktmbuf_tailroom(ut_params->ibuf));
3572 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3573 /* Append data which is padded to a multiple */
3574 /* of the algorithms block size */
3575 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3576 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3577 ciphertext_pad_len);
3578 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3579 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3581 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3583 /* Create KASUMI operation */
3584 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3585 tdata->cipher_iv.len,
3586 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3587 tdata->validCipherOffsetInBits.len);
3591 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3593 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3595 ut_params->obuf = ut_params->op->sym->m_dst;
3596 if (ut_params->obuf)
3597 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3599 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3601 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3603 const uint8_t *reference_plaintext = tdata->plaintext.data +
3604 (tdata->validCipherOffsetInBits.len >> 3);
3606 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3608 reference_plaintext,
3609 tdata->validCipherLenInBits.len,
3610 "KASUMI Plaintext data not as expected");
3615 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3617 struct crypto_testsuite_params *ts_params = &testsuite_params;
3618 struct crypto_unittest_params *ut_params = &unittest_params;
3621 uint8_t *ciphertext, *plaintext;
3622 unsigned ciphertext_pad_len;
3623 unsigned ciphertext_len;
3624 struct rte_cryptodev_info dev_info;
3626 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3627 uint64_t feat_flags = dev_info.feature_flags;
3629 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3630 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3631 printf("Device doesn't support RAW data-path APIs.\n");
3635 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3638 /* Verify the capabilities */
3639 struct rte_cryptodev_sym_capability_idx cap_idx;
3640 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3641 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3642 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3646 /* Create KASUMI session */
3647 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3648 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3649 RTE_CRYPTO_CIPHER_KASUMI_F8,
3650 tdata->key.data, tdata->key.len,
3651 tdata->cipher_iv.len);
3655 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3657 /* Clear mbuf payload */
3658 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3659 rte_pktmbuf_tailroom(ut_params->ibuf));
3661 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3662 /* Append data which is padded to a multiple */
3663 /* of the algorithms block size */
3664 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3665 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3666 ciphertext_pad_len);
3667 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3669 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3671 /* Create KASUMI operation */
3672 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3673 tdata->cipher_iv.len,
3674 tdata->ciphertext.len,
3675 tdata->validCipherOffsetInBits.len);
3679 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3680 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3681 ut_params->op, 1, 0, 1, 0);
3683 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3685 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3687 ut_params->obuf = ut_params->op->sym->m_dst;
3688 if (ut_params->obuf)
3689 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3691 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3693 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3695 const uint8_t *reference_plaintext = tdata->plaintext.data +
3696 (tdata->validCipherOffsetInBits.len >> 3);
3698 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3700 reference_plaintext,
3701 tdata->validCipherLenInBits.len,
3702 "KASUMI Plaintext data not as expected");
3707 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3709 struct crypto_testsuite_params *ts_params = &testsuite_params;
3710 struct crypto_unittest_params *ut_params = &unittest_params;
3713 uint8_t *plaintext, *ciphertext;
3714 unsigned plaintext_pad_len;
3715 unsigned plaintext_len;
3716 struct rte_cryptodev_info dev_info;
3718 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3719 uint64_t feat_flags = dev_info.feature_flags;
3721 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3722 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3723 printf("Device doesn't support RAW data-path APIs.\n");
3727 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3730 /* Verify the capabilities */
3731 struct rte_cryptodev_sym_capability_idx cap_idx;
3732 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3733 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3734 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3738 /* Create SNOW 3G session */
3739 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3740 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3741 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3742 tdata->key.data, tdata->key.len,
3743 tdata->cipher_iv.len);
3747 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3749 /* Clear mbuf payload */
3750 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3751 rte_pktmbuf_tailroom(ut_params->ibuf));
3753 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3754 /* Append data which is padded to a multiple of */
3755 /* the algorithms block size */
3756 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3757 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3759 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3761 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3763 /* Create SNOW 3G operation */
3764 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3765 tdata->cipher_iv.len,
3766 tdata->validCipherLenInBits.len,
3771 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3772 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3773 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3775 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3777 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3779 ut_params->obuf = ut_params->op->sym->m_dst;
3780 if (ut_params->obuf)
3781 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3783 ciphertext = plaintext;
3785 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3788 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3790 tdata->ciphertext.data,
3791 tdata->validDataLenInBits.len,
3792 "SNOW 3G Ciphertext data not as expected");
3798 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3800 struct crypto_testsuite_params *ts_params = &testsuite_params;
3801 struct crypto_unittest_params *ut_params = &unittest_params;
3802 uint8_t *plaintext, *ciphertext;
3805 unsigned plaintext_pad_len;
3806 unsigned plaintext_len;
3808 /* Verify the capabilities */
3809 struct rte_cryptodev_sym_capability_idx cap_idx;
3810 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3811 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3812 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3816 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3819 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3822 /* Create SNOW 3G session */
3823 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3824 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3825 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3826 tdata->key.data, tdata->key.len,
3827 tdata->cipher_iv.len);
3831 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3832 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3834 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3835 "Failed to allocate input buffer in mempool");
3836 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3837 "Failed to allocate output buffer in mempool");
3839 /* Clear mbuf payload */
3840 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3841 rte_pktmbuf_tailroom(ut_params->ibuf));
3843 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3844 /* Append data which is padded to a multiple of */
3845 /* the algorithms block size */
3846 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3847 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3849 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3850 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3852 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3854 /* Create SNOW 3G operation */
3855 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3856 tdata->cipher_iv.len,
3857 tdata->validCipherLenInBits.len,
3862 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3864 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3866 ut_params->obuf = ut_params->op->sym->m_dst;
3867 if (ut_params->obuf)
3868 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3870 ciphertext = plaintext;
3872 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3875 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3877 tdata->ciphertext.data,
3878 tdata->validDataLenInBits.len,
3879 "SNOW 3G Ciphertext data not as expected");
3884 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3886 struct crypto_testsuite_params *ts_params = &testsuite_params;
3887 struct crypto_unittest_params *ut_params = &unittest_params;
3890 unsigned int plaintext_pad_len;
3891 unsigned int plaintext_len;
3892 uint8_t buffer[10000];
3893 const uint8_t *ciphertext;
3895 struct rte_cryptodev_info dev_info;
3897 /* Verify the capabilities */
3898 struct rte_cryptodev_sym_capability_idx cap_idx;
3899 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3900 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3901 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3905 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3908 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3911 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3913 uint64_t feat_flags = dev_info.feature_flags;
3915 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3916 printf("Device doesn't support out-of-place scatter-gather "
3917 "in both input and output mbufs. "
3922 /* Create SNOW 3G session */
3923 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3924 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3925 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3926 tdata->key.data, tdata->key.len,
3927 tdata->cipher_iv.len);
3931 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3932 /* Append data which is padded to a multiple of */
3933 /* the algorithms block size */
3934 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3936 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3937 plaintext_pad_len, 10, 0);
3938 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3939 plaintext_pad_len, 3, 0);
3941 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3942 "Failed to allocate input buffer in mempool");
3943 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3944 "Failed to allocate output buffer in mempool");
3946 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3948 /* Create SNOW 3G operation */
3949 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3950 tdata->cipher_iv.len,
3951 tdata->validCipherLenInBits.len,
3956 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3958 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3960 ut_params->obuf = ut_params->op->sym->m_dst;
3961 if (ut_params->obuf)
3962 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3963 plaintext_len, buffer);
3965 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3966 plaintext_len, buffer);
3968 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3971 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3973 tdata->ciphertext.data,
3974 tdata->validDataLenInBits.len,
3975 "SNOW 3G Ciphertext data not as expected");
3980 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3982 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3984 uint8_t curr_byte, prev_byte;
3985 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3986 uint8_t lower_byte_mask = (1 << offset) - 1;
3989 prev_byte = buffer[0];
3990 buffer[0] >>= offset;
3992 for (i = 1; i < length_in_bytes; i++) {
3993 curr_byte = buffer[i];
3994 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3995 (curr_byte >> offset);
3996 prev_byte = curr_byte;
4001 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4003 struct crypto_testsuite_params *ts_params = &testsuite_params;
4004 struct crypto_unittest_params *ut_params = &unittest_params;
4005 uint8_t *plaintext, *ciphertext;
4007 uint32_t plaintext_len;
4008 uint32_t plaintext_pad_len;
4009 uint8_t extra_offset = 4;
4010 uint8_t *expected_ciphertext_shifted;
4011 struct rte_cryptodev_info dev_info;
4013 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4014 uint64_t feat_flags = dev_info.feature_flags;
4016 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4017 ((tdata->validDataLenInBits.len % 8) != 0)) {
4018 printf("Device doesn't support NON-Byte Aligned Data.\n");
4022 /* Verify the capabilities */
4023 struct rte_cryptodev_sym_capability_idx cap_idx;
4024 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4025 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4026 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4030 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4033 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4036 /* Create SNOW 3G session */
4037 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4038 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4039 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4040 tdata->key.data, tdata->key.len,
4041 tdata->cipher_iv.len);
4045 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4046 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4048 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4049 "Failed to allocate input buffer in mempool");
4050 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4051 "Failed to allocate output buffer in mempool");
4053 /* Clear mbuf payload */
4054 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4055 rte_pktmbuf_tailroom(ut_params->ibuf));
4057 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4059 * Append data which is padded to a
4060 * multiple of the algorithms block size
4062 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4064 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4067 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4069 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4070 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4072 #ifdef RTE_APP_TEST_DEBUG
4073 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4075 /* Create SNOW 3G operation */
4076 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4077 tdata->cipher_iv.len,
4078 tdata->validCipherLenInBits.len,
4083 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4085 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4087 ut_params->obuf = ut_params->op->sym->m_dst;
4088 if (ut_params->obuf)
4089 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4091 ciphertext = plaintext;
4093 #ifdef RTE_APP_TEST_DEBUG
4094 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4097 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4099 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4100 "failed to reserve memory for ciphertext shifted\n");
4102 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4103 ceil_byte_length(tdata->ciphertext.len));
4104 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4107 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4109 expected_ciphertext_shifted,
4110 tdata->validDataLenInBits.len,
4112 "SNOW 3G Ciphertext data not as expected");
4116 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4118 struct crypto_testsuite_params *ts_params = &testsuite_params;
4119 struct crypto_unittest_params *ut_params = &unittest_params;
4123 uint8_t *plaintext, *ciphertext;
4124 unsigned ciphertext_pad_len;
4125 unsigned ciphertext_len;
4126 struct rte_cryptodev_info dev_info;
4128 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4129 uint64_t feat_flags = dev_info.feature_flags;
4131 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4132 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4133 printf("Device doesn't support RAW data-path APIs.\n");
4137 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4140 /* Verify the capabilities */
4141 struct rte_cryptodev_sym_capability_idx cap_idx;
4142 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4143 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4144 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4148 /* Create SNOW 3G session */
4149 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4150 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4151 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4152 tdata->key.data, tdata->key.len,
4153 tdata->cipher_iv.len);
4157 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4159 /* Clear mbuf payload */
4160 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4161 rte_pktmbuf_tailroom(ut_params->ibuf));
4163 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4164 /* Append data which is padded to a multiple of */
4165 /* the algorithms block size */
4166 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4167 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4168 ciphertext_pad_len);
4169 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4171 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4173 /* Create SNOW 3G operation */
4174 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4175 tdata->cipher_iv.len,
4176 tdata->validCipherLenInBits.len,
4177 tdata->cipher.offset_bits);
4181 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4182 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4183 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4185 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4187 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4188 ut_params->obuf = ut_params->op->sym->m_dst;
4189 if (ut_params->obuf)
4190 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4192 plaintext = ciphertext;
4194 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4197 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4198 tdata->plaintext.data,
4199 tdata->validDataLenInBits.len,
4200 "SNOW 3G Plaintext data not as expected");
4204 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4206 struct crypto_testsuite_params *ts_params = &testsuite_params;
4207 struct crypto_unittest_params *ut_params = &unittest_params;
4211 uint8_t *plaintext, *ciphertext;
4212 unsigned ciphertext_pad_len;
4213 unsigned ciphertext_len;
4215 /* Verify the capabilities */
4216 struct rte_cryptodev_sym_capability_idx cap_idx;
4217 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4218 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4219 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4223 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4226 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4229 /* Create SNOW 3G session */
4230 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4231 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4232 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4233 tdata->key.data, tdata->key.len,
4234 tdata->cipher_iv.len);
4238 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4239 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4241 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4242 "Failed to allocate input buffer");
4243 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4244 "Failed to allocate output buffer");
4246 /* Clear mbuf payload */
4247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4248 rte_pktmbuf_tailroom(ut_params->ibuf));
4250 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4251 rte_pktmbuf_tailroom(ut_params->obuf));
4253 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4254 /* Append data which is padded to a multiple of */
4255 /* the algorithms block size */
4256 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4257 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4258 ciphertext_pad_len);
4259 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4260 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4262 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4264 /* Create SNOW 3G operation */
4265 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4266 tdata->cipher_iv.len,
4267 tdata->validCipherLenInBits.len,
4272 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4274 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4275 ut_params->obuf = ut_params->op->sym->m_dst;
4276 if (ut_params->obuf)
4277 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4279 plaintext = ciphertext;
4281 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4284 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4285 tdata->plaintext.data,
4286 tdata->validDataLenInBits.len,
4287 "SNOW 3G Plaintext data not as expected");
4292 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4294 struct crypto_testsuite_params *ts_params = &testsuite_params;
4295 struct crypto_unittest_params *ut_params = &unittest_params;
4299 uint8_t *plaintext, *ciphertext;
4300 unsigned int plaintext_pad_len;
4301 unsigned int plaintext_len;
4303 struct rte_cryptodev_info dev_info;
4304 struct rte_cryptodev_sym_capability_idx cap_idx;
4306 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4307 uint64_t feat_flags = dev_info.feature_flags;
4309 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4310 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4311 (tdata->validDataLenInBits.len % 8 != 0))) {
4312 printf("Device doesn't support NON-Byte Aligned Data.\n");
4316 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4317 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4318 printf("Device doesn't support RAW data-path APIs.\n");
4322 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4325 /* Check if device supports ZUC EEA3 */
4326 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4327 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4329 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4333 /* Check if device supports ZUC EIA3 */
4334 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4335 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4337 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4341 /* Create ZUC session */
4342 retval = create_zuc_cipher_auth_encrypt_generate_session(
4343 ts_params->valid_devs[0],
4347 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4349 /* clear mbuf payload */
4350 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4351 rte_pktmbuf_tailroom(ut_params->ibuf));
4353 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4354 /* Append data which is padded to a multiple of */
4355 /* the algorithms block size */
4356 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4357 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4359 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4361 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4363 /* Create ZUC operation */
4364 retval = create_zuc_cipher_hash_generate_operation(tdata);
4368 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4369 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4370 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4372 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4374 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4375 ut_params->obuf = ut_params->op->sym->m_src;
4376 if (ut_params->obuf)
4377 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4379 ciphertext = plaintext;
4381 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4383 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4385 tdata->ciphertext.data,
4386 tdata->validDataLenInBits.len,
4387 "ZUC Ciphertext data not as expected");
4389 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4390 + plaintext_pad_len;
4393 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4397 "ZUC Generated auth tag not as expected");
4402 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4404 struct crypto_testsuite_params *ts_params = &testsuite_params;
4405 struct crypto_unittest_params *ut_params = &unittest_params;
4409 uint8_t *plaintext, *ciphertext;
4410 unsigned plaintext_pad_len;
4411 unsigned plaintext_len;
4412 struct rte_cryptodev_info dev_info;
4414 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4415 uint64_t feat_flags = dev_info.feature_flags;
4417 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4418 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4419 printf("Device doesn't support RAW data-path APIs.\n");
4423 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4426 /* Verify the capabilities */
4427 struct rte_cryptodev_sym_capability_idx cap_idx;
4428 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4429 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4430 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4433 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4434 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4435 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4439 /* Create SNOW 3G session */
4440 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4441 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4442 RTE_CRYPTO_AUTH_OP_GENERATE,
4443 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4444 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4445 tdata->key.data, tdata->key.len,
4446 tdata->auth_iv.len, tdata->digest.len,
4447 tdata->cipher_iv.len);
4450 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4452 /* clear mbuf payload */
4453 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4454 rte_pktmbuf_tailroom(ut_params->ibuf));
4456 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4457 /* Append data which is padded to a multiple of */
4458 /* the algorithms block size */
4459 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4460 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4462 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4464 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4466 /* Create SNOW 3G operation */
4467 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4468 tdata->digest.len, tdata->auth_iv.data,
4470 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4471 tdata->cipher_iv.data, tdata->cipher_iv.len,
4472 tdata->validCipherLenInBits.len,
4474 tdata->validAuthLenInBits.len,
4480 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4481 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4482 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4484 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4486 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4487 ut_params->obuf = ut_params->op->sym->m_src;
4488 if (ut_params->obuf)
4489 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4491 ciphertext = plaintext;
4493 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4495 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4497 tdata->ciphertext.data,
4498 tdata->validDataLenInBits.len,
4499 "SNOW 3G Ciphertext data not as expected");
4501 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4502 + plaintext_pad_len;
4505 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4508 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4509 "SNOW 3G Generated auth tag not as expected");
4514 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4515 uint8_t op_mode, uint8_t verify)
4517 struct crypto_testsuite_params *ts_params = &testsuite_params;
4518 struct crypto_unittest_params *ut_params = &unittest_params;
4522 uint8_t *plaintext = NULL, *ciphertext = NULL;
4523 unsigned int plaintext_pad_len;
4524 unsigned int plaintext_len;
4525 unsigned int ciphertext_pad_len;
4526 unsigned int ciphertext_len;
4528 struct rte_cryptodev_info dev_info;
4530 /* Verify the capabilities */
4531 struct rte_cryptodev_sym_capability_idx cap_idx;
4532 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4533 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4534 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4537 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4538 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4539 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4543 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4546 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4548 uint64_t feat_flags = dev_info.feature_flags;
4550 if (op_mode == OUT_OF_PLACE) {
4551 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4552 printf("Device doesn't support digest encrypted.\n");
4555 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4559 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4560 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4561 printf("Device doesn't support RAW data-path APIs.\n");
4565 /* Create SNOW 3G session */
4566 retval = create_wireless_algo_auth_cipher_session(
4567 ts_params->valid_devs[0],
4568 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4569 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4570 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4571 : RTE_CRYPTO_AUTH_OP_GENERATE),
4572 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4573 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4574 tdata->key.data, tdata->key.len,
4575 tdata->auth_iv.len, tdata->digest.len,
4576 tdata->cipher_iv.len);
4581 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4582 if (op_mode == OUT_OF_PLACE)
4583 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4585 /* clear mbuf payload */
4586 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4587 rte_pktmbuf_tailroom(ut_params->ibuf));
4588 if (op_mode == OUT_OF_PLACE)
4589 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4590 rte_pktmbuf_tailroom(ut_params->obuf));
4592 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4593 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4594 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4595 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4598 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4599 ciphertext_pad_len);
4600 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4601 if (op_mode == OUT_OF_PLACE)
4602 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4603 debug_hexdump(stdout, "ciphertext:", ciphertext,
4606 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4608 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4609 if (op_mode == OUT_OF_PLACE)
4610 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4611 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4614 /* Create SNOW 3G operation */
4615 retval = create_wireless_algo_auth_cipher_operation(
4616 tdata->digest.data, tdata->digest.len,
4617 tdata->cipher_iv.data, tdata->cipher_iv.len,
4618 tdata->auth_iv.data, tdata->auth_iv.len,
4619 (tdata->digest.offset_bytes == 0 ?
4620 (verify ? ciphertext_pad_len : plaintext_pad_len)
4621 : tdata->digest.offset_bytes),
4622 tdata->validCipherLenInBits.len,
4623 tdata->cipher.offset_bits,
4624 tdata->validAuthLenInBits.len,
4625 tdata->auth.offset_bits,
4626 op_mode, 0, verify);
4631 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4632 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4633 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4635 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4638 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4640 ut_params->obuf = (op_mode == IN_PLACE ?
4641 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4644 if (ut_params->obuf)
4645 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4648 plaintext = ciphertext +
4649 (tdata->cipher.offset_bits >> 3);
4651 debug_hexdump(stdout, "plaintext:", plaintext,
4652 (tdata->plaintext.len >> 3) - tdata->digest.len);
4653 debug_hexdump(stdout, "plaintext expected:",
4654 tdata->plaintext.data,
4655 (tdata->plaintext.len >> 3) - tdata->digest.len);
4657 if (ut_params->obuf)
4658 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4661 ciphertext = plaintext;
4663 debug_hexdump(stdout, "ciphertext:", ciphertext,
4665 debug_hexdump(stdout, "ciphertext expected:",
4666 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4668 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4669 + (tdata->digest.offset_bytes == 0 ?
4670 plaintext_pad_len : tdata->digest.offset_bytes);
4672 debug_hexdump(stdout, "digest:", ut_params->digest,
4674 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4680 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4682 tdata->plaintext.data,
4683 tdata->plaintext.len >> 3,
4684 "SNOW 3G Plaintext data not as expected");
4686 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4688 tdata->ciphertext.data,
4689 tdata->validDataLenInBits.len,
4690 "SNOW 3G Ciphertext data not as expected");
4692 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4695 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4696 "SNOW 3G Generated auth tag not as expected");
4702 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4703 uint8_t op_mode, uint8_t verify)
4705 struct crypto_testsuite_params *ts_params = &testsuite_params;
4706 struct crypto_unittest_params *ut_params = &unittest_params;
4710 const uint8_t *plaintext = NULL;
4711 const uint8_t *ciphertext = NULL;
4712 const uint8_t *digest = NULL;
4713 unsigned int plaintext_pad_len;
4714 unsigned int plaintext_len;
4715 unsigned int ciphertext_pad_len;
4716 unsigned int ciphertext_len;
4717 uint8_t buffer[10000];
4718 uint8_t digest_buffer[10000];
4720 struct rte_cryptodev_info dev_info;
4722 /* Verify the capabilities */
4723 struct rte_cryptodev_sym_capability_idx cap_idx;
4724 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4725 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4726 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4729 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4730 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4731 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4735 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4738 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4740 uint64_t feat_flags = dev_info.feature_flags;
4742 if (op_mode == IN_PLACE) {
4743 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4744 printf("Device doesn't support in-place scatter-gather "
4745 "in both input and output mbufs.\n");
4748 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4749 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4750 printf("Device doesn't support RAW data-path APIs.\n");
4754 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4756 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4757 printf("Device doesn't support out-of-place scatter-gather "
4758 "in both input and output mbufs.\n");
4761 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4762 printf("Device doesn't support digest encrypted.\n");
4767 /* Create SNOW 3G session */
4768 retval = create_wireless_algo_auth_cipher_session(
4769 ts_params->valid_devs[0],
4770 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4771 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4772 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4773 : RTE_CRYPTO_AUTH_OP_GENERATE),
4774 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4775 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4776 tdata->key.data, tdata->key.len,
4777 tdata->auth_iv.len, tdata->digest.len,
4778 tdata->cipher_iv.len);
4783 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4784 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4785 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4786 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4788 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4789 plaintext_pad_len, 15, 0);
4790 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4791 "Failed to allocate input buffer in mempool");
4793 if (op_mode == OUT_OF_PLACE) {
4794 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4795 plaintext_pad_len, 15, 0);
4796 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4797 "Failed to allocate output buffer in mempool");
4801 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4802 tdata->ciphertext.data);
4803 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4804 ciphertext_len, buffer);
4805 debug_hexdump(stdout, "ciphertext:", ciphertext,
4808 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4809 tdata->plaintext.data);
4810 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4811 plaintext_len, buffer);
4812 debug_hexdump(stdout, "plaintext:", plaintext,
4815 memset(buffer, 0, sizeof(buffer));
4817 /* Create SNOW 3G operation */
4818 retval = create_wireless_algo_auth_cipher_operation(
4819 tdata->digest.data, tdata->digest.len,
4820 tdata->cipher_iv.data, tdata->cipher_iv.len,
4821 tdata->auth_iv.data, tdata->auth_iv.len,
4822 (tdata->digest.offset_bytes == 0 ?
4823 (verify ? ciphertext_pad_len : plaintext_pad_len)
4824 : tdata->digest.offset_bytes),
4825 tdata->validCipherLenInBits.len,
4826 tdata->cipher.offset_bits,
4827 tdata->validAuthLenInBits.len,
4828 tdata->auth.offset_bits,
4829 op_mode, 1, verify);
4834 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4835 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4836 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4838 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4841 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4843 ut_params->obuf = (op_mode == IN_PLACE ?
4844 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4847 if (ut_params->obuf)
4848 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4849 plaintext_len, buffer);
4851 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4852 plaintext_len, buffer);
4854 debug_hexdump(stdout, "plaintext:", plaintext,
4855 (tdata->plaintext.len >> 3) - tdata->digest.len);
4856 debug_hexdump(stdout, "plaintext expected:",
4857 tdata->plaintext.data,
4858 (tdata->plaintext.len >> 3) - tdata->digest.len);
4860 if (ut_params->obuf)
4861 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4862 ciphertext_len, buffer);
4864 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4865 ciphertext_len, buffer);
4867 debug_hexdump(stdout, "ciphertext:", ciphertext,
4869 debug_hexdump(stdout, "ciphertext expected:",
4870 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4872 if (ut_params->obuf)
4873 digest = rte_pktmbuf_read(ut_params->obuf,
4874 (tdata->digest.offset_bytes == 0 ?
4875 plaintext_pad_len : tdata->digest.offset_bytes),
4876 tdata->digest.len, digest_buffer);
4878 digest = rte_pktmbuf_read(ut_params->ibuf,
4879 (tdata->digest.offset_bytes == 0 ?
4880 plaintext_pad_len : tdata->digest.offset_bytes),
4881 tdata->digest.len, digest_buffer);
4883 debug_hexdump(stdout, "digest:", digest,
4885 debug_hexdump(stdout, "digest expected:",
4886 tdata->digest.data, tdata->digest.len);
4891 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4893 tdata->plaintext.data,
4894 tdata->plaintext.len >> 3,
4895 "SNOW 3G Plaintext data not as expected");
4897 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4899 tdata->ciphertext.data,
4900 tdata->validDataLenInBits.len,
4901 "SNOW 3G Ciphertext data not as expected");
4903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4906 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4907 "SNOW 3G Generated auth tag not as expected");
4913 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4914 uint8_t op_mode, uint8_t verify)
4916 struct crypto_testsuite_params *ts_params = &testsuite_params;
4917 struct crypto_unittest_params *ut_params = &unittest_params;
4921 uint8_t *plaintext = NULL, *ciphertext = NULL;
4922 unsigned int plaintext_pad_len;
4923 unsigned int plaintext_len;
4924 unsigned int ciphertext_pad_len;
4925 unsigned int ciphertext_len;
4927 struct rte_cryptodev_info dev_info;
4929 /* Verify the capabilities */
4930 struct rte_cryptodev_sym_capability_idx cap_idx;
4931 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4932 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4933 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4936 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4937 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4938 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4942 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4944 uint64_t feat_flags = dev_info.feature_flags;
4946 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4947 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4948 printf("Device doesn't support RAW data-path APIs.\n");
4952 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4955 if (op_mode == OUT_OF_PLACE) {
4956 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4958 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4959 printf("Device doesn't support digest encrypted.\n");
4964 /* Create KASUMI session */
4965 retval = create_wireless_algo_auth_cipher_session(
4966 ts_params->valid_devs[0],
4967 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4968 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4969 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4970 : RTE_CRYPTO_AUTH_OP_GENERATE),
4971 RTE_CRYPTO_AUTH_KASUMI_F9,
4972 RTE_CRYPTO_CIPHER_KASUMI_F8,
4973 tdata->key.data, tdata->key.len,
4974 0, tdata->digest.len,
4975 tdata->cipher_iv.len);
4980 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4981 if (op_mode == OUT_OF_PLACE)
4982 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4984 /* clear mbuf payload */
4985 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4986 rte_pktmbuf_tailroom(ut_params->ibuf));
4987 if (op_mode == OUT_OF_PLACE)
4988 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4989 rte_pktmbuf_tailroom(ut_params->obuf));
4991 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4992 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4993 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4994 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4997 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4998 ciphertext_pad_len);
4999 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5000 if (op_mode == OUT_OF_PLACE)
5001 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5002 debug_hexdump(stdout, "ciphertext:", ciphertext,
5005 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5007 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5008 if (op_mode == OUT_OF_PLACE)
5009 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5010 debug_hexdump(stdout, "plaintext:", plaintext,
5014 /* Create KASUMI operation */
5015 retval = create_wireless_algo_auth_cipher_operation(
5016 tdata->digest.data, tdata->digest.len,
5017 tdata->cipher_iv.data, tdata->cipher_iv.len,
5019 (tdata->digest.offset_bytes == 0 ?
5020 (verify ? ciphertext_pad_len : plaintext_pad_len)
5021 : tdata->digest.offset_bytes),
5022 tdata->validCipherLenInBits.len,
5023 tdata->validCipherOffsetInBits.len,
5024 tdata->validAuthLenInBits.len,
5026 op_mode, 0, verify);
5031 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5032 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5033 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5035 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5038 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5040 ut_params->obuf = (op_mode == IN_PLACE ?
5041 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5045 if (ut_params->obuf)
5046 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5049 plaintext = ciphertext;
5051 debug_hexdump(stdout, "plaintext:", plaintext,
5052 (tdata->plaintext.len >> 3) - tdata->digest.len);
5053 debug_hexdump(stdout, "plaintext expected:",
5054 tdata->plaintext.data,
5055 (tdata->plaintext.len >> 3) - tdata->digest.len);
5057 if (ut_params->obuf)
5058 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5061 ciphertext = plaintext;
5063 debug_hexdump(stdout, "ciphertext:", ciphertext,
5065 debug_hexdump(stdout, "ciphertext expected:",
5066 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5068 ut_params->digest = rte_pktmbuf_mtod(
5069 ut_params->obuf, uint8_t *) +
5070 (tdata->digest.offset_bytes == 0 ?
5071 plaintext_pad_len : tdata->digest.offset_bytes);
5073 debug_hexdump(stdout, "digest:", ut_params->digest,
5075 debug_hexdump(stdout, "digest expected:",
5076 tdata->digest.data, tdata->digest.len);
5081 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5083 tdata->plaintext.data,
5084 tdata->plaintext.len >> 3,
5085 "KASUMI Plaintext data not as expected");
5087 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5089 tdata->ciphertext.data,
5090 tdata->ciphertext.len >> 3,
5091 "KASUMI Ciphertext data not as expected");
5093 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5096 DIGEST_BYTE_LENGTH_KASUMI_F9,
5097 "KASUMI Generated auth tag not as expected");
5103 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5104 uint8_t op_mode, uint8_t verify)
5106 struct crypto_testsuite_params *ts_params = &testsuite_params;
5107 struct crypto_unittest_params *ut_params = &unittest_params;
5111 const uint8_t *plaintext = NULL;
5112 const uint8_t *ciphertext = NULL;
5113 const uint8_t *digest = NULL;
5114 unsigned int plaintext_pad_len;
5115 unsigned int plaintext_len;
5116 unsigned int ciphertext_pad_len;
5117 unsigned int ciphertext_len;
5118 uint8_t buffer[10000];
5119 uint8_t digest_buffer[10000];
5121 struct rte_cryptodev_info dev_info;
5123 /* Verify the capabilities */
5124 struct rte_cryptodev_sym_capability_idx cap_idx;
5125 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5126 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5127 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5130 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5131 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5132 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5136 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5139 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5141 uint64_t feat_flags = dev_info.feature_flags;
5143 if (op_mode == IN_PLACE) {
5144 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5145 printf("Device doesn't support in-place scatter-gather "
5146 "in both input and output mbufs.\n");
5149 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5150 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5151 printf("Device doesn't support RAW data-path APIs.\n");
5155 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5157 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5158 printf("Device doesn't support out-of-place scatter-gather "
5159 "in both input and output mbufs.\n");
5162 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5163 printf("Device doesn't support digest encrypted.\n");
5168 /* Create KASUMI session */
5169 retval = create_wireless_algo_auth_cipher_session(
5170 ts_params->valid_devs[0],
5171 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5172 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5173 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5174 : RTE_CRYPTO_AUTH_OP_GENERATE),
5175 RTE_CRYPTO_AUTH_KASUMI_F9,
5176 RTE_CRYPTO_CIPHER_KASUMI_F8,
5177 tdata->key.data, tdata->key.len,
5178 0, tdata->digest.len,
5179 tdata->cipher_iv.len);
5184 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5185 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5186 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5187 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5189 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5190 plaintext_pad_len, 15, 0);
5191 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5192 "Failed to allocate input buffer in mempool");
5194 if (op_mode == OUT_OF_PLACE) {
5195 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5196 plaintext_pad_len, 15, 0);
5197 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5198 "Failed to allocate output buffer in mempool");
5202 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5203 tdata->ciphertext.data);
5204 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5205 ciphertext_len, buffer);
5206 debug_hexdump(stdout, "ciphertext:", ciphertext,
5209 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5210 tdata->plaintext.data);
5211 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5212 plaintext_len, buffer);
5213 debug_hexdump(stdout, "plaintext:", plaintext,
5216 memset(buffer, 0, sizeof(buffer));
5218 /* Create KASUMI operation */
5219 retval = create_wireless_algo_auth_cipher_operation(
5220 tdata->digest.data, tdata->digest.len,
5221 tdata->cipher_iv.data, tdata->cipher_iv.len,
5223 (tdata->digest.offset_bytes == 0 ?
5224 (verify ? ciphertext_pad_len : plaintext_pad_len)
5225 : tdata->digest.offset_bytes),
5226 tdata->validCipherLenInBits.len,
5227 tdata->validCipherOffsetInBits.len,
5228 tdata->validAuthLenInBits.len,
5230 op_mode, 1, verify);
5235 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5236 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5237 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5239 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5242 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5244 ut_params->obuf = (op_mode == IN_PLACE ?
5245 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5248 if (ut_params->obuf)
5249 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5250 plaintext_len, buffer);
5252 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5253 plaintext_len, buffer);
5255 debug_hexdump(stdout, "plaintext:", plaintext,
5256 (tdata->plaintext.len >> 3) - tdata->digest.len);
5257 debug_hexdump(stdout, "plaintext expected:",
5258 tdata->plaintext.data,
5259 (tdata->plaintext.len >> 3) - tdata->digest.len);
5261 if (ut_params->obuf)
5262 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5263 ciphertext_len, buffer);
5265 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5266 ciphertext_len, buffer);
5268 debug_hexdump(stdout, "ciphertext:", ciphertext,
5270 debug_hexdump(stdout, "ciphertext expected:",
5271 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5273 if (ut_params->obuf)
5274 digest = rte_pktmbuf_read(ut_params->obuf,
5275 (tdata->digest.offset_bytes == 0 ?
5276 plaintext_pad_len : tdata->digest.offset_bytes),
5277 tdata->digest.len, digest_buffer);
5279 digest = rte_pktmbuf_read(ut_params->ibuf,
5280 (tdata->digest.offset_bytes == 0 ?
5281 plaintext_pad_len : tdata->digest.offset_bytes),
5282 tdata->digest.len, digest_buffer);
5284 debug_hexdump(stdout, "digest:", digest,
5286 debug_hexdump(stdout, "digest expected:",
5287 tdata->digest.data, tdata->digest.len);
5292 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5294 tdata->plaintext.data,
5295 tdata->plaintext.len >> 3,
5296 "KASUMI Plaintext data not as expected");
5298 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5300 tdata->ciphertext.data,
5301 tdata->validDataLenInBits.len,
5302 "KASUMI Ciphertext data not as expected");
5304 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5307 DIGEST_BYTE_LENGTH_KASUMI_F9,
5308 "KASUMI Generated auth tag not as expected");
5314 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5316 struct crypto_testsuite_params *ts_params = &testsuite_params;
5317 struct crypto_unittest_params *ut_params = &unittest_params;
5321 uint8_t *plaintext, *ciphertext;
5322 unsigned plaintext_pad_len;
5323 unsigned plaintext_len;
5324 struct rte_cryptodev_info dev_info;
5326 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5327 uint64_t feat_flags = dev_info.feature_flags;
5329 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5330 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5331 printf("Device doesn't support RAW data-path APIs.\n");
5335 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5338 /* Verify the capabilities */
5339 struct rte_cryptodev_sym_capability_idx cap_idx;
5340 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5341 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5342 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5345 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5346 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5347 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5351 /* Create KASUMI session */
5352 retval = create_wireless_algo_cipher_auth_session(
5353 ts_params->valid_devs[0],
5354 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5355 RTE_CRYPTO_AUTH_OP_GENERATE,
5356 RTE_CRYPTO_AUTH_KASUMI_F9,
5357 RTE_CRYPTO_CIPHER_KASUMI_F8,
5358 tdata->key.data, tdata->key.len,
5359 0, tdata->digest.len,
5360 tdata->cipher_iv.len);
5364 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5366 /* clear mbuf payload */
5367 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5368 rte_pktmbuf_tailroom(ut_params->ibuf));
5370 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5371 /* Append data which is padded to a multiple of */
5372 /* the algorithms block size */
5373 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5374 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5376 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5378 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5380 /* Create KASUMI operation */
5381 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5382 tdata->digest.len, NULL, 0,
5383 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5384 tdata->cipher_iv.data, tdata->cipher_iv.len,
5385 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5386 tdata->validCipherOffsetInBits.len,
5387 tdata->validAuthLenInBits.len,
5393 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5394 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5395 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5397 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5399 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5401 if (ut_params->op->sym->m_dst)
5402 ut_params->obuf = ut_params->op->sym->m_dst;
5404 ut_params->obuf = ut_params->op->sym->m_src;
5406 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5407 tdata->validCipherOffsetInBits.len >> 3);
5409 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5410 + plaintext_pad_len;
5412 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5413 (tdata->validCipherOffsetInBits.len >> 3);
5415 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5417 reference_ciphertext,
5418 tdata->validCipherLenInBits.len,
5419 "KASUMI Ciphertext data not as expected");
5422 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5425 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5426 "KASUMI Generated auth tag not as expected");
5431 test_zuc_encryption(const struct wireless_test_data *tdata)
5433 struct crypto_testsuite_params *ts_params = &testsuite_params;
5434 struct crypto_unittest_params *ut_params = &unittest_params;
5437 uint8_t *plaintext, *ciphertext;
5438 unsigned plaintext_pad_len;
5439 unsigned plaintext_len;
5440 struct rte_cryptodev_info dev_info;
5442 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5443 uint64_t feat_flags = dev_info.feature_flags;
5445 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5446 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5447 printf("Device doesn't support RAW data-path APIs.\n");
5451 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5454 struct rte_cryptodev_sym_capability_idx cap_idx;
5456 /* Check if device supports ZUC EEA3 */
5457 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5458 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5460 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5464 /* Create ZUC session */
5465 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5466 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5467 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5468 tdata->key.data, tdata->key.len,
5469 tdata->cipher_iv.len);
5473 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5475 /* Clear mbuf payload */
5476 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5477 rte_pktmbuf_tailroom(ut_params->ibuf));
5479 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5480 /* Append data which is padded to a multiple */
5481 /* of the algorithms block size */
5482 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5483 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5485 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5487 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5489 /* Create ZUC operation */
5490 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5491 tdata->cipher_iv.len,
5492 tdata->plaintext.len,
5497 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5498 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5499 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5501 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5503 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5505 ut_params->obuf = ut_params->op->sym->m_dst;
5506 if (ut_params->obuf)
5507 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5509 ciphertext = plaintext;
5511 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5514 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5516 tdata->ciphertext.data,
5517 tdata->validCipherLenInBits.len,
5518 "ZUC Ciphertext data not as expected");
5523 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5525 struct crypto_testsuite_params *ts_params = &testsuite_params;
5526 struct crypto_unittest_params *ut_params = &unittest_params;
5530 unsigned int plaintext_pad_len;
5531 unsigned int plaintext_len;
5532 const uint8_t *ciphertext;
5533 uint8_t ciphertext_buffer[2048];
5534 struct rte_cryptodev_info dev_info;
5536 struct rte_cryptodev_sym_capability_idx cap_idx;
5538 /* Check if device supports ZUC EEA3 */
5539 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5540 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5542 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5546 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5549 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5551 uint64_t feat_flags = dev_info.feature_flags;
5553 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5554 printf("Device doesn't support in-place scatter-gather. "
5559 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5560 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5561 printf("Device doesn't support RAW data-path APIs.\n");
5565 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5567 /* Append data which is padded to a multiple */
5568 /* of the algorithms block size */
5569 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5571 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5572 plaintext_pad_len, 10, 0);
5574 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5575 tdata->plaintext.data);
5577 /* Create ZUC session */
5578 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5579 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5580 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5581 tdata->key.data, tdata->key.len,
5582 tdata->cipher_iv.len);
5586 /* Clear mbuf payload */
5588 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5590 /* Create ZUC operation */
5591 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5592 tdata->cipher_iv.len, tdata->plaintext.len,
5597 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5598 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5599 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5601 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5603 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5605 ut_params->obuf = ut_params->op->sym->m_dst;
5606 if (ut_params->obuf)
5607 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5608 0, plaintext_len, ciphertext_buffer);
5610 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5611 0, plaintext_len, ciphertext_buffer);
5614 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5617 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5619 tdata->ciphertext.data,
5620 tdata->validCipherLenInBits.len,
5621 "ZUC Ciphertext data not as expected");
5627 test_zuc_authentication(const struct wireless_test_data *tdata)
5629 struct crypto_testsuite_params *ts_params = &testsuite_params;
5630 struct crypto_unittest_params *ut_params = &unittest_params;
5633 unsigned plaintext_pad_len;
5634 unsigned plaintext_len;
5637 struct rte_cryptodev_sym_capability_idx cap_idx;
5638 struct rte_cryptodev_info dev_info;
5640 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5641 uint64_t feat_flags = dev_info.feature_flags;
5643 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5644 (tdata->validAuthLenInBits.len % 8 != 0)) {
5645 printf("Device doesn't support NON-Byte Aligned Data.\n");
5649 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5650 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5651 printf("Device doesn't support RAW data-path APIs.\n");
5655 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5658 /* Check if device supports ZUC EIA3 */
5659 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5660 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5662 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5666 /* Create ZUC session */
5667 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5668 tdata->key.data, tdata->key.len,
5669 tdata->auth_iv.len, tdata->digest.len,
5670 RTE_CRYPTO_AUTH_OP_GENERATE,
5671 RTE_CRYPTO_AUTH_ZUC_EIA3);
5675 /* alloc mbuf and set payload */
5676 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5678 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5679 rte_pktmbuf_tailroom(ut_params->ibuf));
5681 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5682 /* Append data which is padded to a multiple of */
5683 /* the algorithms block size */
5684 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5685 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5687 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5689 /* Create ZUC operation */
5690 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5691 tdata->auth_iv.data, tdata->auth_iv.len,
5692 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5693 tdata->validAuthLenInBits.len,
5698 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5699 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5700 ut_params->op, 0, 1, 1, 0);
5702 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5704 ut_params->obuf = ut_params->op->sym->m_src;
5705 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5706 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5707 + plaintext_pad_len;
5710 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5714 "ZUC Generated auth tag not as expected");
5720 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5721 uint8_t op_mode, uint8_t verify)
5723 struct crypto_testsuite_params *ts_params = &testsuite_params;
5724 struct crypto_unittest_params *ut_params = &unittest_params;
5728 uint8_t *plaintext = NULL, *ciphertext = NULL;
5729 unsigned int plaintext_pad_len;
5730 unsigned int plaintext_len;
5731 unsigned int ciphertext_pad_len;
5732 unsigned int ciphertext_len;
5734 struct rte_cryptodev_info dev_info;
5735 struct rte_cryptodev_sym_capability_idx cap_idx;
5737 /* Check if device supports ZUC EIA3 */
5738 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5739 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5741 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5745 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5747 uint64_t feat_flags = dev_info.feature_flags;
5749 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5750 printf("Device doesn't support digest encrypted.\n");
5753 if (op_mode == IN_PLACE) {
5754 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5755 printf("Device doesn't support in-place scatter-gather "
5756 "in both input and output mbufs.\n");
5760 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5761 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5762 printf("Device doesn't support RAW data-path APIs.\n");
5766 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5768 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5769 printf("Device doesn't support out-of-place scatter-gather "
5770 "in both input and output mbufs.\n");
5775 /* Create ZUC session */
5776 retval = create_wireless_algo_auth_cipher_session(
5777 ts_params->valid_devs[0],
5778 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5779 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5780 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5781 : RTE_CRYPTO_AUTH_OP_GENERATE),
5782 RTE_CRYPTO_AUTH_ZUC_EIA3,
5783 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5784 tdata->key.data, tdata->key.len,
5785 tdata->auth_iv.len, tdata->digest.len,
5786 tdata->cipher_iv.len);
5791 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5792 if (op_mode == OUT_OF_PLACE)
5793 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5795 /* clear mbuf payload */
5796 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5797 rte_pktmbuf_tailroom(ut_params->ibuf));
5798 if (op_mode == OUT_OF_PLACE)
5799 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5800 rte_pktmbuf_tailroom(ut_params->obuf));
5802 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5803 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5804 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5805 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5808 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5809 ciphertext_pad_len);
5810 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5811 if (op_mode == OUT_OF_PLACE)
5812 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5813 debug_hexdump(stdout, "ciphertext:", ciphertext,
5816 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5818 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5819 if (op_mode == OUT_OF_PLACE)
5820 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5821 debug_hexdump(stdout, "plaintext:", plaintext,
5825 /* Create ZUC operation */
5826 retval = create_wireless_algo_auth_cipher_operation(
5827 tdata->digest.data, tdata->digest.len,
5828 tdata->cipher_iv.data, tdata->cipher_iv.len,
5829 tdata->auth_iv.data, tdata->auth_iv.len,
5830 (tdata->digest.offset_bytes == 0 ?
5831 (verify ? ciphertext_pad_len : plaintext_pad_len)
5832 : tdata->digest.offset_bytes),
5833 tdata->validCipherLenInBits.len,
5834 tdata->validCipherOffsetInBits.len,
5835 tdata->validAuthLenInBits.len,
5837 op_mode, 0, verify);
5842 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5843 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5844 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5846 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5849 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5851 ut_params->obuf = (op_mode == IN_PLACE ?
5852 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5856 if (ut_params->obuf)
5857 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5860 plaintext = ciphertext;
5862 debug_hexdump(stdout, "plaintext:", plaintext,
5863 (tdata->plaintext.len >> 3) - tdata->digest.len);
5864 debug_hexdump(stdout, "plaintext expected:",
5865 tdata->plaintext.data,
5866 (tdata->plaintext.len >> 3) - tdata->digest.len);
5868 if (ut_params->obuf)
5869 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5872 ciphertext = plaintext;
5874 debug_hexdump(stdout, "ciphertext:", ciphertext,
5876 debug_hexdump(stdout, "ciphertext expected:",
5877 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5879 ut_params->digest = rte_pktmbuf_mtod(
5880 ut_params->obuf, uint8_t *) +
5881 (tdata->digest.offset_bytes == 0 ?
5882 plaintext_pad_len : tdata->digest.offset_bytes);
5884 debug_hexdump(stdout, "digest:", ut_params->digest,
5886 debug_hexdump(stdout, "digest expected:",
5887 tdata->digest.data, tdata->digest.len);
5892 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5894 tdata->plaintext.data,
5895 tdata->plaintext.len >> 3,
5896 "ZUC Plaintext data not as expected");
5898 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5900 tdata->ciphertext.data,
5901 tdata->ciphertext.len >> 3,
5902 "ZUC Ciphertext data not as expected");
5904 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5907 DIGEST_BYTE_LENGTH_KASUMI_F9,
5908 "ZUC Generated auth tag not as expected");
5914 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5915 uint8_t op_mode, uint8_t verify)
5917 struct crypto_testsuite_params *ts_params = &testsuite_params;
5918 struct crypto_unittest_params *ut_params = &unittest_params;
5922 const uint8_t *plaintext = NULL;
5923 const uint8_t *ciphertext = NULL;
5924 const uint8_t *digest = NULL;
5925 unsigned int plaintext_pad_len;
5926 unsigned int plaintext_len;
5927 unsigned int ciphertext_pad_len;
5928 unsigned int ciphertext_len;
5929 uint8_t buffer[10000];
5930 uint8_t digest_buffer[10000];
5932 struct rte_cryptodev_info dev_info;
5933 struct rte_cryptodev_sym_capability_idx cap_idx;
5935 /* Check if device supports ZUC EIA3 */
5936 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5937 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5939 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5943 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5945 uint64_t feat_flags = dev_info.feature_flags;
5947 if (op_mode == IN_PLACE) {
5948 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5949 printf("Device doesn't support in-place scatter-gather "
5950 "in both input and output mbufs.\n");
5954 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5955 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5956 printf("Device doesn't support RAW data-path APIs.\n");
5960 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5962 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5963 printf("Device doesn't support out-of-place scatter-gather "
5964 "in both input and output mbufs.\n");
5967 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5968 printf("Device doesn't support digest encrypted.\n");
5973 /* Create ZUC session */
5974 retval = create_wireless_algo_auth_cipher_session(
5975 ts_params->valid_devs[0],
5976 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5977 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5978 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5979 : RTE_CRYPTO_AUTH_OP_GENERATE),
5980 RTE_CRYPTO_AUTH_ZUC_EIA3,
5981 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5982 tdata->key.data, tdata->key.len,
5983 tdata->auth_iv.len, tdata->digest.len,
5984 tdata->cipher_iv.len);
5989 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5990 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5991 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5992 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5994 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5995 plaintext_pad_len, 15, 0);
5996 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5997 "Failed to allocate input buffer in mempool");
5999 if (op_mode == OUT_OF_PLACE) {
6000 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6001 plaintext_pad_len, 15, 0);
6002 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6003 "Failed to allocate output buffer in mempool");
6007 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6008 tdata->ciphertext.data);
6009 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6010 ciphertext_len, buffer);
6011 debug_hexdump(stdout, "ciphertext:", ciphertext,
6014 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6015 tdata->plaintext.data);
6016 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6017 plaintext_len, buffer);
6018 debug_hexdump(stdout, "plaintext:", plaintext,
6021 memset(buffer, 0, sizeof(buffer));
6023 /* Create ZUC operation */
6024 retval = create_wireless_algo_auth_cipher_operation(
6025 tdata->digest.data, tdata->digest.len,
6026 tdata->cipher_iv.data, tdata->cipher_iv.len,
6028 (tdata->digest.offset_bytes == 0 ?
6029 (verify ? ciphertext_pad_len : plaintext_pad_len)
6030 : tdata->digest.offset_bytes),
6031 tdata->validCipherLenInBits.len,
6032 tdata->validCipherOffsetInBits.len,
6033 tdata->validAuthLenInBits.len,
6035 op_mode, 1, verify);
6040 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6041 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6042 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6044 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6047 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6049 ut_params->obuf = (op_mode == IN_PLACE ?
6050 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6053 if (ut_params->obuf)
6054 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6055 plaintext_len, buffer);
6057 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6058 plaintext_len, buffer);
6060 debug_hexdump(stdout, "plaintext:", plaintext,
6061 (tdata->plaintext.len >> 3) - tdata->digest.len);
6062 debug_hexdump(stdout, "plaintext expected:",
6063 tdata->plaintext.data,
6064 (tdata->plaintext.len >> 3) - tdata->digest.len);
6066 if (ut_params->obuf)
6067 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6068 ciphertext_len, buffer);
6070 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6071 ciphertext_len, buffer);
6073 debug_hexdump(stdout, "ciphertext:", ciphertext,
6075 debug_hexdump(stdout, "ciphertext expected:",
6076 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6078 if (ut_params->obuf)
6079 digest = rte_pktmbuf_read(ut_params->obuf,
6080 (tdata->digest.offset_bytes == 0 ?
6081 plaintext_pad_len : tdata->digest.offset_bytes),
6082 tdata->digest.len, digest_buffer);
6084 digest = rte_pktmbuf_read(ut_params->ibuf,
6085 (tdata->digest.offset_bytes == 0 ?
6086 plaintext_pad_len : tdata->digest.offset_bytes),
6087 tdata->digest.len, digest_buffer);
6089 debug_hexdump(stdout, "digest:", digest,
6091 debug_hexdump(stdout, "digest expected:",
6092 tdata->digest.data, tdata->digest.len);
6097 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6099 tdata->plaintext.data,
6100 tdata->plaintext.len >> 3,
6101 "ZUC Plaintext data not as expected");
6103 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6105 tdata->ciphertext.data,
6106 tdata->validDataLenInBits.len,
6107 "ZUC Ciphertext data not as expected");
6109 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6112 DIGEST_BYTE_LENGTH_KASUMI_F9,
6113 "ZUC Generated auth tag not as expected");
6119 test_kasumi_encryption_test_case_1(void)
6121 return test_kasumi_encryption(&kasumi_test_case_1);
6125 test_kasumi_encryption_test_case_1_sgl(void)
6127 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6131 test_kasumi_encryption_test_case_1_oop(void)
6133 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6137 test_kasumi_encryption_test_case_1_oop_sgl(void)
6139 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6143 test_kasumi_encryption_test_case_2(void)
6145 return test_kasumi_encryption(&kasumi_test_case_2);
6149 test_kasumi_encryption_test_case_3(void)
6151 return test_kasumi_encryption(&kasumi_test_case_3);
6155 test_kasumi_encryption_test_case_4(void)
6157 return test_kasumi_encryption(&kasumi_test_case_4);
6161 test_kasumi_encryption_test_case_5(void)
6163 return test_kasumi_encryption(&kasumi_test_case_5);
6167 test_kasumi_decryption_test_case_1(void)
6169 return test_kasumi_decryption(&kasumi_test_case_1);
6173 test_kasumi_decryption_test_case_1_oop(void)
6175 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6179 test_kasumi_decryption_test_case_2(void)
6181 return test_kasumi_decryption(&kasumi_test_case_2);
6185 test_kasumi_decryption_test_case_3(void)
6187 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6188 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6190 return test_kasumi_decryption(&kasumi_test_case_3);
6194 test_kasumi_decryption_test_case_4(void)
6196 return test_kasumi_decryption(&kasumi_test_case_4);
6200 test_kasumi_decryption_test_case_5(void)
6202 return test_kasumi_decryption(&kasumi_test_case_5);
6205 test_snow3g_encryption_test_case_1(void)
6207 return test_snow3g_encryption(&snow3g_test_case_1);
6211 test_snow3g_encryption_test_case_1_oop(void)
6213 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6217 test_snow3g_encryption_test_case_1_oop_sgl(void)
6219 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6224 test_snow3g_encryption_test_case_1_offset_oop(void)
6226 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6230 test_snow3g_encryption_test_case_2(void)
6232 return test_snow3g_encryption(&snow3g_test_case_2);
6236 test_snow3g_encryption_test_case_3(void)
6238 return test_snow3g_encryption(&snow3g_test_case_3);
6242 test_snow3g_encryption_test_case_4(void)
6244 return test_snow3g_encryption(&snow3g_test_case_4);
6248 test_snow3g_encryption_test_case_5(void)
6250 return test_snow3g_encryption(&snow3g_test_case_5);
6254 test_snow3g_decryption_test_case_1(void)
6256 return test_snow3g_decryption(&snow3g_test_case_1);
6260 test_snow3g_decryption_test_case_1_oop(void)
6262 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6266 test_snow3g_decryption_test_case_2(void)
6268 return test_snow3g_decryption(&snow3g_test_case_2);
6272 test_snow3g_decryption_test_case_3(void)
6274 return test_snow3g_decryption(&snow3g_test_case_3);
6278 test_snow3g_decryption_test_case_4(void)
6280 return test_snow3g_decryption(&snow3g_test_case_4);
6284 test_snow3g_decryption_test_case_5(void)
6286 return test_snow3g_decryption(&snow3g_test_case_5);
6290 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6291 * Pattern digest from snow3g_test_data must be allocated as
6292 * 4 last bytes in plaintext.
6295 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6296 struct snow3g_hash_test_data *output)
6298 if ((pattern != NULL) && (output != NULL)) {
6299 output->key.len = pattern->key.len;
6301 memcpy(output->key.data,
6302 pattern->key.data, pattern->key.len);
6304 output->auth_iv.len = pattern->auth_iv.len;
6306 memcpy(output->auth_iv.data,
6307 pattern->auth_iv.data, pattern->auth_iv.len);
6309 output->plaintext.len = pattern->plaintext.len;
6311 memcpy(output->plaintext.data,
6312 pattern->plaintext.data, pattern->plaintext.len >> 3);
6314 output->digest.len = pattern->digest.len;
6316 memcpy(output->digest.data,
6317 &pattern->plaintext.data[pattern->digest.offset_bytes],
6318 pattern->digest.len);
6320 output->validAuthLenInBits.len =
6321 pattern->validAuthLenInBits.len;
6326 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6329 test_snow3g_decryption_with_digest_test_case_1(void)
6331 struct snow3g_hash_test_data snow3g_hash_data;
6332 struct rte_cryptodev_info dev_info;
6333 struct crypto_testsuite_params *ts_params = &testsuite_params;
6335 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6336 uint64_t feat_flags = dev_info.feature_flags;
6338 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6339 printf("Device doesn't support encrypted digest operations.\n");
6344 * Function prepare data for hash veryfication test case.
6345 * Digest is allocated in 4 last bytes in plaintext, pattern.
6347 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6349 return test_snow3g_decryption(&snow3g_test_case_7) &
6350 test_snow3g_authentication_verify(&snow3g_hash_data);
6354 test_snow3g_cipher_auth_test_case_1(void)
6356 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6360 test_snow3g_auth_cipher_test_case_1(void)
6362 return test_snow3g_auth_cipher(
6363 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6367 test_snow3g_auth_cipher_test_case_2(void)
6369 return test_snow3g_auth_cipher(
6370 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6374 test_snow3g_auth_cipher_test_case_2_oop(void)
6376 return test_snow3g_auth_cipher(
6377 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6381 test_snow3g_auth_cipher_part_digest_enc(void)
6383 return test_snow3g_auth_cipher(
6384 &snow3g_auth_cipher_partial_digest_encryption,
6389 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6391 return test_snow3g_auth_cipher(
6392 &snow3g_auth_cipher_partial_digest_encryption,
6397 test_snow3g_auth_cipher_test_case_3_sgl(void)
6399 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6400 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6402 return test_snow3g_auth_cipher_sgl(
6403 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6407 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6409 return test_snow3g_auth_cipher_sgl(
6410 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6414 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6416 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6417 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6419 return test_snow3g_auth_cipher_sgl(
6420 &snow3g_auth_cipher_partial_digest_encryption,
6425 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6427 return test_snow3g_auth_cipher_sgl(
6428 &snow3g_auth_cipher_partial_digest_encryption,
6433 test_snow3g_auth_cipher_verify_test_case_1(void)
6435 return test_snow3g_auth_cipher(
6436 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6440 test_snow3g_auth_cipher_verify_test_case_2(void)
6442 return test_snow3g_auth_cipher(
6443 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6447 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6449 return test_snow3g_auth_cipher(
6450 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6454 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6456 return test_snow3g_auth_cipher(
6457 &snow3g_auth_cipher_partial_digest_encryption,
6462 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6464 return test_snow3g_auth_cipher(
6465 &snow3g_auth_cipher_partial_digest_encryption,
6470 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6472 return test_snow3g_auth_cipher_sgl(
6473 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6477 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6479 return test_snow3g_auth_cipher_sgl(
6480 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6484 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6486 return test_snow3g_auth_cipher_sgl(
6487 &snow3g_auth_cipher_partial_digest_encryption,
6492 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6494 return test_snow3g_auth_cipher_sgl(
6495 &snow3g_auth_cipher_partial_digest_encryption,
6500 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6502 return test_snow3g_auth_cipher(
6503 &snow3g_test_case_7, IN_PLACE, 0);
6507 test_kasumi_auth_cipher_test_case_1(void)
6509 return test_kasumi_auth_cipher(
6510 &kasumi_test_case_3, IN_PLACE, 0);
6514 test_kasumi_auth_cipher_test_case_2(void)
6516 return test_kasumi_auth_cipher(
6517 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6521 test_kasumi_auth_cipher_test_case_2_oop(void)
6523 return test_kasumi_auth_cipher(
6524 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6528 test_kasumi_auth_cipher_test_case_2_sgl(void)
6530 return test_kasumi_auth_cipher_sgl(
6531 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6535 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6537 return test_kasumi_auth_cipher_sgl(
6538 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6542 test_kasumi_auth_cipher_verify_test_case_1(void)
6544 return test_kasumi_auth_cipher(
6545 &kasumi_test_case_3, IN_PLACE, 1);
6549 test_kasumi_auth_cipher_verify_test_case_2(void)
6551 return test_kasumi_auth_cipher(
6552 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6556 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6558 return test_kasumi_auth_cipher(
6559 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6563 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6565 return test_kasumi_auth_cipher_sgl(
6566 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6570 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6572 return test_kasumi_auth_cipher_sgl(
6573 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6577 test_kasumi_cipher_auth_test_case_1(void)
6579 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6583 test_zuc_encryption_test_case_1(void)
6585 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6589 test_zuc_encryption_test_case_2(void)
6591 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6595 test_zuc_encryption_test_case_3(void)
6597 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6601 test_zuc_encryption_test_case_4(void)
6603 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6607 test_zuc_encryption_test_case_5(void)
6609 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6613 test_zuc_encryption_test_case_6_sgl(void)
6615 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6619 test_zuc_hash_generate_test_case_1(void)
6621 return test_zuc_authentication(&zuc_test_case_auth_1b);
6625 test_zuc_hash_generate_test_case_2(void)
6627 return test_zuc_authentication(&zuc_test_case_auth_90b);
6631 test_zuc_hash_generate_test_case_3(void)
6633 return test_zuc_authentication(&zuc_test_case_auth_577b);
6637 test_zuc_hash_generate_test_case_4(void)
6639 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6643 test_zuc_hash_generate_test_case_5(void)
6645 return test_zuc_authentication(&zuc_test_auth_5670b);
6649 test_zuc_hash_generate_test_case_6(void)
6651 return test_zuc_authentication(&zuc_test_case_auth_128b);
6655 test_zuc_hash_generate_test_case_7(void)
6657 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6661 test_zuc_hash_generate_test_case_8(void)
6663 return test_zuc_authentication(&zuc_test_case_auth_584b);
6667 test_zuc_cipher_auth_test_case_1(void)
6669 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6673 test_zuc_cipher_auth_test_case_2(void)
6675 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6679 test_zuc_auth_cipher_test_case_1(void)
6681 return test_zuc_auth_cipher(
6682 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6686 test_zuc_auth_cipher_test_case_1_oop(void)
6688 return test_zuc_auth_cipher(
6689 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6693 test_zuc_auth_cipher_test_case_1_sgl(void)
6695 return test_zuc_auth_cipher_sgl(
6696 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6700 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6702 return test_zuc_auth_cipher_sgl(
6703 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6707 test_zuc_auth_cipher_verify_test_case_1(void)
6709 return test_zuc_auth_cipher(
6710 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6714 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6716 return test_zuc_auth_cipher(
6717 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6721 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6723 return test_zuc_auth_cipher_sgl(
6724 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6728 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6730 return test_zuc_auth_cipher_sgl(
6731 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6735 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6737 uint8_t dev_id = testsuite_params.valid_devs[0];
6739 struct rte_cryptodev_sym_capability_idx cap_idx;
6741 /* Check if device supports particular cipher algorithm */
6742 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6743 cap_idx.algo.cipher = tdata->cipher_algo;
6744 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6747 /* Check if device supports particular hash algorithm */
6748 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6749 cap_idx.algo.auth = tdata->auth_algo;
6750 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6757 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6758 uint8_t op_mode, uint8_t verify)
6760 struct crypto_testsuite_params *ts_params = &testsuite_params;
6761 struct crypto_unittest_params *ut_params = &unittest_params;
6765 uint8_t *plaintext = NULL, *ciphertext = NULL;
6766 unsigned int plaintext_pad_len;
6767 unsigned int plaintext_len;
6768 unsigned int ciphertext_pad_len;
6769 unsigned int ciphertext_len;
6771 struct rte_cryptodev_info dev_info;
6772 struct rte_crypto_op *op;
6774 /* Check if device supports particular algorithms separately */
6775 if (test_mixed_check_if_unsupported(tdata))
6777 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6780 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6782 uint64_t feat_flags = dev_info.feature_flags;
6784 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6785 printf("Device doesn't support digest encrypted.\n");
6789 /* Create the session */
6791 retval = create_wireless_algo_cipher_auth_session(
6792 ts_params->valid_devs[0],
6793 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6794 RTE_CRYPTO_AUTH_OP_VERIFY,
6797 tdata->auth_key.data, tdata->auth_key.len,
6798 tdata->auth_iv.len, tdata->digest_enc.len,
6799 tdata->cipher_iv.len);
6801 retval = create_wireless_algo_auth_cipher_session(
6802 ts_params->valid_devs[0],
6803 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6804 RTE_CRYPTO_AUTH_OP_GENERATE,
6807 tdata->auth_key.data, tdata->auth_key.len,
6808 tdata->auth_iv.len, tdata->digest_enc.len,
6809 tdata->cipher_iv.len);
6813 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6814 if (op_mode == OUT_OF_PLACE)
6815 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6817 /* clear mbuf payload */
6818 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6819 rte_pktmbuf_tailroom(ut_params->ibuf));
6820 if (op_mode == OUT_OF_PLACE) {
6822 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6823 rte_pktmbuf_tailroom(ut_params->obuf));
6826 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6827 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6828 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6829 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6832 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6833 ciphertext_pad_len);
6834 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6835 if (op_mode == OUT_OF_PLACE)
6836 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6837 debug_hexdump(stdout, "ciphertext:", ciphertext,
6840 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6842 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6843 if (op_mode == OUT_OF_PLACE)
6844 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6845 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6848 /* Create the operation */
6849 retval = create_wireless_algo_auth_cipher_operation(
6850 tdata->digest_enc.data, tdata->digest_enc.len,
6851 tdata->cipher_iv.data, tdata->cipher_iv.len,
6852 tdata->auth_iv.data, tdata->auth_iv.len,
6853 (tdata->digest_enc.offset == 0 ?
6855 : tdata->digest_enc.offset),
6856 tdata->validCipherLen.len_bits,
6857 tdata->cipher.offset_bits,
6858 tdata->validAuthLen.len_bits,
6859 tdata->auth.offset_bits,
6860 op_mode, 0, verify);
6865 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
6867 /* Check if the op failed because the device doesn't */
6868 /* support this particular combination of algorithms */
6869 if (op == NULL && ut_params->op->status ==
6870 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6871 printf("Device doesn't support this mixed combination. "
6877 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6879 ut_params->obuf = (op_mode == IN_PLACE ?
6880 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6883 if (ut_params->obuf)
6884 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6887 plaintext = ciphertext +
6888 (tdata->cipher.offset_bits >> 3);
6890 debug_hexdump(stdout, "plaintext:", plaintext,
6891 tdata->plaintext.len_bits >> 3);
6892 debug_hexdump(stdout, "plaintext expected:",
6893 tdata->plaintext.data,
6894 tdata->plaintext.len_bits >> 3);
6896 if (ut_params->obuf)
6897 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6900 ciphertext = plaintext;
6902 debug_hexdump(stdout, "ciphertext:", ciphertext,
6904 debug_hexdump(stdout, "ciphertext expected:",
6905 tdata->ciphertext.data,
6906 tdata->ciphertext.len_bits >> 3);
6908 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6909 + (tdata->digest_enc.offset == 0 ?
6910 plaintext_pad_len : tdata->digest_enc.offset);
6912 debug_hexdump(stdout, "digest:", ut_params->digest,
6913 tdata->digest_enc.len);
6914 debug_hexdump(stdout, "digest expected:",
6915 tdata->digest_enc.data,
6916 tdata->digest_enc.len);
6921 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6923 tdata->plaintext.data,
6924 tdata->plaintext.len_bits >> 3,
6925 "Plaintext data not as expected");
6927 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6929 tdata->ciphertext.data,
6930 tdata->validDataLen.len_bits,
6931 "Ciphertext data not as expected");
6933 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6935 tdata->digest_enc.data,
6936 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6937 "Generated auth tag not as expected");
6940 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6941 "crypto op processing failed");
6947 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6948 uint8_t op_mode, uint8_t verify)
6950 struct crypto_testsuite_params *ts_params = &testsuite_params;
6951 struct crypto_unittest_params *ut_params = &unittest_params;
6955 const uint8_t *plaintext = NULL;
6956 const uint8_t *ciphertext = NULL;
6957 const uint8_t *digest = NULL;
6958 unsigned int plaintext_pad_len;
6959 unsigned int plaintext_len;
6960 unsigned int ciphertext_pad_len;
6961 unsigned int ciphertext_len;
6962 uint8_t buffer[10000];
6963 uint8_t digest_buffer[10000];
6965 struct rte_cryptodev_info dev_info;
6966 struct rte_crypto_op *op;
6968 /* Check if device supports particular algorithms */
6969 if (test_mixed_check_if_unsupported(tdata))
6971 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6974 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6976 uint64_t feat_flags = dev_info.feature_flags;
6978 if (op_mode == IN_PLACE) {
6979 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6980 printf("Device doesn't support in-place scatter-gather "
6981 "in both input and output mbufs.\n");
6985 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6986 printf("Device doesn't support out-of-place scatter-gather "
6987 "in both input and output mbufs.\n");
6990 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6991 printf("Device doesn't support digest encrypted.\n");
6996 /* Create the session */
6998 retval = create_wireless_algo_cipher_auth_session(
6999 ts_params->valid_devs[0],
7000 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7001 RTE_CRYPTO_AUTH_OP_VERIFY,
7004 tdata->auth_key.data, tdata->auth_key.len,
7005 tdata->auth_iv.len, tdata->digest_enc.len,
7006 tdata->cipher_iv.len);
7008 retval = create_wireless_algo_auth_cipher_session(
7009 ts_params->valid_devs[0],
7010 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7011 RTE_CRYPTO_AUTH_OP_GENERATE,
7014 tdata->auth_key.data, tdata->auth_key.len,
7015 tdata->auth_iv.len, tdata->digest_enc.len,
7016 tdata->cipher_iv.len);
7020 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7021 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7022 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7023 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7025 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7026 ciphertext_pad_len, 15, 0);
7027 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7028 "Failed to allocate input buffer in mempool");
7030 if (op_mode == OUT_OF_PLACE) {
7031 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7032 plaintext_pad_len, 15, 0);
7033 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7034 "Failed to allocate output buffer in mempool");
7038 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7039 tdata->ciphertext.data);
7040 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7041 ciphertext_len, buffer);
7042 debug_hexdump(stdout, "ciphertext:", ciphertext,
7045 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7046 tdata->plaintext.data);
7047 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7048 plaintext_len, buffer);
7049 debug_hexdump(stdout, "plaintext:", plaintext,
7052 memset(buffer, 0, sizeof(buffer));
7054 /* Create the operation */
7055 retval = create_wireless_algo_auth_cipher_operation(
7056 tdata->digest_enc.data, tdata->digest_enc.len,
7057 tdata->cipher_iv.data, tdata->cipher_iv.len,
7058 tdata->auth_iv.data, tdata->auth_iv.len,
7059 (tdata->digest_enc.offset == 0 ?
7061 : tdata->digest_enc.offset),
7062 tdata->validCipherLen.len_bits,
7063 tdata->cipher.offset_bits,
7064 tdata->validAuthLen.len_bits,
7065 tdata->auth.offset_bits,
7066 op_mode, 1, verify);
7071 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7073 /* Check if the op failed because the device doesn't */
7074 /* support this particular combination of algorithms */
7075 if (op == NULL && ut_params->op->status ==
7076 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7077 printf("Device doesn't support this mixed combination. "
7083 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7085 ut_params->obuf = (op_mode == IN_PLACE ?
7086 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7089 if (ut_params->obuf)
7090 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7091 plaintext_len, buffer);
7093 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7094 plaintext_len, buffer);
7096 debug_hexdump(stdout, "plaintext:", plaintext,
7097 (tdata->plaintext.len_bits >> 3) -
7098 tdata->digest_enc.len);
7099 debug_hexdump(stdout, "plaintext expected:",
7100 tdata->plaintext.data,
7101 (tdata->plaintext.len_bits >> 3) -
7102 tdata->digest_enc.len);
7104 if (ut_params->obuf)
7105 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7106 ciphertext_len, buffer);
7108 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7109 ciphertext_len, buffer);
7111 debug_hexdump(stdout, "ciphertext:", ciphertext,
7113 debug_hexdump(stdout, "ciphertext expected:",
7114 tdata->ciphertext.data,
7115 tdata->ciphertext.len_bits >> 3);
7117 if (ut_params->obuf)
7118 digest = rte_pktmbuf_read(ut_params->obuf,
7119 (tdata->digest_enc.offset == 0 ?
7121 tdata->digest_enc.offset),
7122 tdata->digest_enc.len, digest_buffer);
7124 digest = rte_pktmbuf_read(ut_params->ibuf,
7125 (tdata->digest_enc.offset == 0 ?
7127 tdata->digest_enc.offset),
7128 tdata->digest_enc.len, digest_buffer);
7130 debug_hexdump(stdout, "digest:", digest,
7131 tdata->digest_enc.len);
7132 debug_hexdump(stdout, "digest expected:",
7133 tdata->digest_enc.data, tdata->digest_enc.len);
7138 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7140 tdata->plaintext.data,
7141 tdata->plaintext.len_bits >> 3,
7142 "Plaintext data not as expected");
7144 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7146 tdata->ciphertext.data,
7147 tdata->validDataLen.len_bits,
7148 "Ciphertext data not as expected");
7149 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7151 tdata->digest_enc.data,
7152 tdata->digest_enc.len,
7153 "Generated auth tag not as expected");
7156 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7157 "crypto op processing failed");
7162 /** AUTH AES CMAC + CIPHER AES CTR */
7165 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7167 return test_mixed_auth_cipher(
7168 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7172 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7174 return test_mixed_auth_cipher(
7175 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7179 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7181 return test_mixed_auth_cipher_sgl(
7182 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7186 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7188 return test_mixed_auth_cipher_sgl(
7189 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7193 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7195 return test_mixed_auth_cipher(
7196 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7200 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7202 return test_mixed_auth_cipher(
7203 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7207 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7209 return test_mixed_auth_cipher_sgl(
7210 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7214 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7216 return test_mixed_auth_cipher_sgl(
7217 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7220 /** MIXED AUTH + CIPHER */
7223 test_auth_zuc_cipher_snow_test_case_1(void)
7225 return test_mixed_auth_cipher(
7226 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7230 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7232 return test_mixed_auth_cipher(
7233 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7237 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7239 return test_mixed_auth_cipher(
7240 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7244 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7246 return test_mixed_auth_cipher(
7247 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7251 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7253 return test_mixed_auth_cipher(
7254 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7258 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7260 return test_mixed_auth_cipher(
7261 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7265 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7267 return test_mixed_auth_cipher(
7268 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7272 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7274 return test_mixed_auth_cipher(
7275 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7279 test_auth_snow_cipher_zuc_test_case_1(void)
7281 return test_mixed_auth_cipher(
7282 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7286 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7288 return test_mixed_auth_cipher(
7289 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7293 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7295 return test_mixed_auth_cipher(
7296 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7300 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7302 return test_mixed_auth_cipher(
7303 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7307 test_auth_null_cipher_snow_test_case_1(void)
7309 return test_mixed_auth_cipher(
7310 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7314 test_verify_auth_null_cipher_snow_test_case_1(void)
7316 return test_mixed_auth_cipher(
7317 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7321 test_auth_null_cipher_zuc_test_case_1(void)
7323 return test_mixed_auth_cipher(
7324 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7328 test_verify_auth_null_cipher_zuc_test_case_1(void)
7330 return test_mixed_auth_cipher(
7331 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7335 test_auth_snow_cipher_null_test_case_1(void)
7337 return test_mixed_auth_cipher(
7338 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7342 test_verify_auth_snow_cipher_null_test_case_1(void)
7344 return test_mixed_auth_cipher(
7345 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7349 test_auth_zuc_cipher_null_test_case_1(void)
7351 return test_mixed_auth_cipher(
7352 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7356 test_verify_auth_zuc_cipher_null_test_case_1(void)
7358 return test_mixed_auth_cipher(
7359 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7363 test_auth_null_cipher_aes_ctr_test_case_1(void)
7365 return test_mixed_auth_cipher(
7366 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7370 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7372 return test_mixed_auth_cipher(
7373 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7377 test_auth_aes_cmac_cipher_null_test_case_1(void)
7379 return test_mixed_auth_cipher(
7380 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7384 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7386 return test_mixed_auth_cipher(
7387 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7390 /* ***** AEAD algorithm Tests ***** */
7393 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7394 enum rte_crypto_aead_operation op,
7395 const uint8_t *key, const uint8_t key_len,
7396 const uint16_t aad_len, const uint8_t auth_len,
7399 uint8_t aead_key[key_len];
7401 struct crypto_testsuite_params *ts_params = &testsuite_params;
7402 struct crypto_unittest_params *ut_params = &unittest_params;
7404 memcpy(aead_key, key, key_len);
7406 /* Setup AEAD Parameters */
7407 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7408 ut_params->aead_xform.next = NULL;
7409 ut_params->aead_xform.aead.algo = algo;
7410 ut_params->aead_xform.aead.op = op;
7411 ut_params->aead_xform.aead.key.data = aead_key;
7412 ut_params->aead_xform.aead.key.length = key_len;
7413 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7414 ut_params->aead_xform.aead.iv.length = iv_len;
7415 ut_params->aead_xform.aead.digest_length = auth_len;
7416 ut_params->aead_xform.aead.aad_length = aad_len;
7418 debug_hexdump(stdout, "key:", key, key_len);
7420 /* Create Crypto session*/
7421 ut_params->sess = rte_cryptodev_sym_session_create(
7422 ts_params->session_mpool);
7424 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7425 &ut_params->aead_xform,
7426 ts_params->session_priv_mpool);
7428 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7434 create_aead_xform(struct rte_crypto_op *op,
7435 enum rte_crypto_aead_algorithm algo,
7436 enum rte_crypto_aead_operation aead_op,
7437 uint8_t *key, const uint8_t key_len,
7438 const uint8_t aad_len, const uint8_t auth_len,
7441 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7442 "failed to allocate space for crypto transform");
7444 struct rte_crypto_sym_op *sym_op = op->sym;
7446 /* Setup AEAD Parameters */
7447 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7448 sym_op->xform->next = NULL;
7449 sym_op->xform->aead.algo = algo;
7450 sym_op->xform->aead.op = aead_op;
7451 sym_op->xform->aead.key.data = key;
7452 sym_op->xform->aead.key.length = key_len;
7453 sym_op->xform->aead.iv.offset = IV_OFFSET;
7454 sym_op->xform->aead.iv.length = iv_len;
7455 sym_op->xform->aead.digest_length = auth_len;
7456 sym_op->xform->aead.aad_length = aad_len;
7458 debug_hexdump(stdout, "key:", key, key_len);
7464 create_aead_operation(enum rte_crypto_aead_operation op,
7465 const struct aead_test_data *tdata)
7467 struct crypto_testsuite_params *ts_params = &testsuite_params;
7468 struct crypto_unittest_params *ut_params = &unittest_params;
7470 uint8_t *plaintext, *ciphertext;
7471 unsigned int aad_pad_len, plaintext_pad_len;
7473 /* Generate Crypto op data structure */
7474 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7475 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7476 TEST_ASSERT_NOT_NULL(ut_params->op,
7477 "Failed to allocate symmetric crypto operation struct");
7479 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7481 /* Append aad data */
7482 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7483 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7484 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7486 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7487 "no room to append aad");
7489 sym_op->aead.aad.phys_addr =
7490 rte_pktmbuf_iova(ut_params->ibuf);
7491 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7492 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7493 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7496 /* Append IV at the end of the crypto operation*/
7497 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7498 uint8_t *, IV_OFFSET);
7500 /* Copy IV 1 byte after the IV pointer, according to the API */
7501 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7502 debug_hexdump(stdout, "iv:", iv_ptr,
7505 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7506 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7508 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7509 "no room to append aad");
7511 sym_op->aead.aad.phys_addr =
7512 rte_pktmbuf_iova(ut_params->ibuf);
7513 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7514 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7517 /* Append IV at the end of the crypto operation*/
7518 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7519 uint8_t *, IV_OFFSET);
7521 if (tdata->iv.len == 0) {
7522 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7523 debug_hexdump(stdout, "iv:", iv_ptr,
7526 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7527 debug_hexdump(stdout, "iv:", iv_ptr,
7532 /* Append plaintext/ciphertext */
7533 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7534 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7535 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7537 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7539 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7540 debug_hexdump(stdout, "plaintext:", plaintext,
7541 tdata->plaintext.len);
7543 if (ut_params->obuf) {
7544 ciphertext = (uint8_t *)rte_pktmbuf_append(
7546 plaintext_pad_len + aad_pad_len);
7547 TEST_ASSERT_NOT_NULL(ciphertext,
7548 "no room to append ciphertext");
7550 memset(ciphertext + aad_pad_len, 0,
7551 tdata->ciphertext.len);
7554 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7555 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7557 TEST_ASSERT_NOT_NULL(ciphertext,
7558 "no room to append ciphertext");
7560 memcpy(ciphertext, tdata->ciphertext.data,
7561 tdata->ciphertext.len);
7562 debug_hexdump(stdout, "ciphertext:", ciphertext,
7563 tdata->ciphertext.len);
7565 if (ut_params->obuf) {
7566 plaintext = (uint8_t *)rte_pktmbuf_append(
7568 plaintext_pad_len + aad_pad_len);
7569 TEST_ASSERT_NOT_NULL(plaintext,
7570 "no room to append plaintext");
7572 memset(plaintext + aad_pad_len, 0,
7573 tdata->plaintext.len);
7577 /* Append digest data */
7578 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7579 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7580 ut_params->obuf ? ut_params->obuf :
7582 tdata->auth_tag.len);
7583 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7584 "no room to append digest");
7585 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7586 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7587 ut_params->obuf ? ut_params->obuf :
7592 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7593 ut_params->ibuf, tdata->auth_tag.len);
7594 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7595 "no room to append digest");
7596 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7598 plaintext_pad_len + aad_pad_len);
7600 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7601 tdata->auth_tag.len);
7602 debug_hexdump(stdout, "digest:",
7603 sym_op->aead.digest.data,
7604 tdata->auth_tag.len);
7607 sym_op->aead.data.length = tdata->plaintext.len;
7608 sym_op->aead.data.offset = aad_pad_len;
7614 test_authenticated_encryption(const struct aead_test_data *tdata)
7616 struct crypto_testsuite_params *ts_params = &testsuite_params;
7617 struct crypto_unittest_params *ut_params = &unittest_params;
7620 uint8_t *ciphertext, *auth_tag;
7621 uint16_t plaintext_pad_len;
7623 struct rte_cryptodev_info dev_info;
7625 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7626 uint64_t feat_flags = dev_info.feature_flags;
7628 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7629 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7630 printf("Device doesn't support RAW data-path APIs.\n");
7634 /* Verify the capabilities */
7635 struct rte_cryptodev_sym_capability_idx cap_idx;
7636 const struct rte_cryptodev_symmetric_capability *capability;
7637 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7638 cap_idx.algo.aead = tdata->algo;
7639 capability = rte_cryptodev_sym_capability_get(
7640 ts_params->valid_devs[0], &cap_idx);
7641 if (capability == NULL)
7643 if (rte_cryptodev_sym_capability_check_aead(
7644 capability, tdata->key.len, tdata->auth_tag.len,
7645 tdata->aad.len, tdata->iv.len))
7648 /* Create AEAD session */
7649 retval = create_aead_session(ts_params->valid_devs[0],
7651 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7652 tdata->key.data, tdata->key.len,
7653 tdata->aad.len, tdata->auth_tag.len,
7658 if (tdata->aad.len > MBUF_SIZE) {
7659 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7660 /* Populate full size of add data */
7661 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7662 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7664 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7666 /* clear mbuf payload */
7667 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7668 rte_pktmbuf_tailroom(ut_params->ibuf));
7670 /* Create AEAD operation */
7671 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7675 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7677 ut_params->op->sym->m_src = ut_params->ibuf;
7679 /* Process crypto operation */
7680 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7681 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7682 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7683 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
7684 ut_params->op, 0, 0, 0, 0);
7686 TEST_ASSERT_NOT_NULL(
7687 process_crypto_request(ts_params->valid_devs[0],
7688 ut_params->op), "failed to process sym crypto op");
7690 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7691 "crypto op processing failed");
7693 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7695 if (ut_params->op->sym->m_dst) {
7696 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7698 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7699 uint8_t *, plaintext_pad_len);
7701 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7703 ut_params->op->sym->cipher.data.offset);
7704 auth_tag = ciphertext + plaintext_pad_len;
7707 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7708 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7711 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7713 tdata->ciphertext.data,
7714 tdata->ciphertext.len,
7715 "Ciphertext data not as expected");
7717 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7719 tdata->auth_tag.data,
7720 tdata->auth_tag.len,
7721 "Generated auth tag not as expected");
7727 #ifdef RTE_LIB_SECURITY
7729 security_proto_supported(enum rte_security_session_action_type action,
7730 enum rte_security_session_protocol proto)
7732 struct crypto_testsuite_params *ts_params = &testsuite_params;
7734 const struct rte_security_capability *capabilities;
7735 const struct rte_security_capability *capability;
7738 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7739 rte_cryptodev_get_sec_ctx(
7740 ts_params->valid_devs[0]);
7743 capabilities = rte_security_capabilities_get(ctx);
7745 if (capabilities == NULL)
7748 while ((capability = &capabilities[i++])->action !=
7749 RTE_SECURITY_ACTION_TYPE_NONE) {
7750 if (capability->action == action &&
7751 capability->protocol == proto)
7758 /* Basic algorithm run function for async inplace mode.
7759 * Creates a session from input parameters and runs one operation
7760 * on input_vec. Checks the output of the crypto operation against
7763 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
7764 enum rte_crypto_auth_operation opa,
7765 const uint8_t *input_vec, unsigned int input_vec_len,
7766 const uint8_t *output_vec,
7767 unsigned int output_vec_len,
7768 enum rte_crypto_cipher_algorithm cipher_alg,
7769 const uint8_t *cipher_key, uint32_t cipher_key_len,
7770 enum rte_crypto_auth_algorithm auth_alg,
7771 const uint8_t *auth_key, uint32_t auth_key_len,
7772 uint8_t bearer, enum rte_security_pdcp_domain domain,
7773 uint8_t packet_direction, uint8_t sn_size,
7774 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
7776 struct crypto_testsuite_params *ts_params = &testsuite_params;
7777 struct crypto_unittest_params *ut_params = &unittest_params;
7779 int ret = TEST_SUCCESS;
7780 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7781 rte_cryptodev_get_sec_ctx(
7782 ts_params->valid_devs[0]);
7784 /* Verify the capabilities */
7785 struct rte_security_capability_idx sec_cap_idx;
7787 sec_cap_idx.action = ut_params->type;
7788 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7789 sec_cap_idx.pdcp.domain = domain;
7790 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7793 /* Generate test mbuf data */
7794 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7796 /* clear mbuf payload */
7797 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7798 rte_pktmbuf_tailroom(ut_params->ibuf));
7800 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7802 memcpy(plaintext, input_vec, input_vec_len);
7804 /* Out of place support */
7807 * For out-op-place we need to alloc another mbuf
7809 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7810 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7813 /* Setup Cipher Parameters */
7814 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7815 ut_params->cipher_xform.cipher.algo = cipher_alg;
7816 ut_params->cipher_xform.cipher.op = opc;
7817 ut_params->cipher_xform.cipher.key.data = cipher_key;
7818 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
7819 ut_params->cipher_xform.cipher.iv.length =
7820 packet_direction ? 4 : 0;
7821 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7823 /* Setup HMAC Parameters if ICV header is required */
7824 if (auth_alg != 0) {
7825 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7826 ut_params->auth_xform.next = NULL;
7827 ut_params->auth_xform.auth.algo = auth_alg;
7828 ut_params->auth_xform.auth.op = opa;
7829 ut_params->auth_xform.auth.key.data = auth_key;
7830 ut_params->auth_xform.auth.key.length = auth_key_len;
7832 ut_params->cipher_xform.next = &ut_params->auth_xform;
7834 ut_params->cipher_xform.next = NULL;
7837 struct rte_security_session_conf sess_conf = {
7838 .action_type = ut_params->type,
7839 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7843 .pkt_dir = packet_direction,
7845 .hfn = packet_direction ? 0 : hfn,
7847 * hfn can be set as pdcp_test_hfn[i]
7848 * if hfn_ovrd is not set. Here, PDCP
7849 * packet direction is just used to
7850 * run half of the cases with session
7851 * HFN and other half with per packet
7854 .hfn_threshold = hfn_threshold,
7855 .hfn_ovrd = packet_direction ? 1 : 0,
7856 .sdap_enabled = sdap,
7858 .crypto_xform = &ut_params->cipher_xform
7861 /* Create security session */
7862 ut_params->sec_session = rte_security_session_create(ctx,
7863 &sess_conf, ts_params->session_mpool,
7864 ts_params->session_priv_mpool);
7866 if (!ut_params->sec_session) {
7867 printf("TestCase %s()-%d line %d failed %s: ",
7868 __func__, i, __LINE__, "Failed to allocate session");
7873 /* Generate crypto op data structure */
7874 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7875 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7876 if (!ut_params->op) {
7877 printf("TestCase %s()-%d line %d failed %s: ",
7878 __func__, i, __LINE__,
7879 "Failed to allocate symmetric crypto operation struct");
7884 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7885 uint32_t *, IV_OFFSET);
7886 *per_pkt_hfn = packet_direction ? hfn : 0;
7888 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7890 /* set crypto operation source mbuf */
7891 ut_params->op->sym->m_src = ut_params->ibuf;
7893 ut_params->op->sym->m_dst = ut_params->obuf;
7895 /* Process crypto operation */
7896 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7898 printf("TestCase %s()-%d line %d failed %s: ",
7899 __func__, i, __LINE__,
7900 "failed to process sym crypto op");
7905 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7906 printf("TestCase %s()-%d line %d failed %s: ",
7907 __func__, i, __LINE__, "crypto op processing failed");
7913 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7916 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7920 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7921 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7922 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7923 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7929 rte_crypto_op_free(ut_params->op);
7930 ut_params->op = NULL;
7932 if (ut_params->sec_session)
7933 rte_security_session_destroy(ctx, ut_params->sec_session);
7934 ut_params->sec_session = NULL;
7936 rte_pktmbuf_free(ut_params->ibuf);
7937 ut_params->ibuf = NULL;
7939 rte_pktmbuf_free(ut_params->obuf);
7940 ut_params->obuf = NULL;
7947 test_pdcp_proto_SGL(int i, int oop,
7948 enum rte_crypto_cipher_operation opc,
7949 enum rte_crypto_auth_operation opa,
7951 unsigned int input_vec_len,
7952 uint8_t *output_vec,
7953 unsigned int output_vec_len,
7955 uint32_t fragsz_oop)
7957 struct crypto_testsuite_params *ts_params = &testsuite_params;
7958 struct crypto_unittest_params *ut_params = &unittest_params;
7960 struct rte_mbuf *buf, *buf_oop = NULL;
7961 int ret = TEST_SUCCESS;
7965 unsigned int trn_data = 0;
7966 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7967 rte_cryptodev_get_sec_ctx(
7968 ts_params->valid_devs[0]);
7970 /* Verify the capabilities */
7971 struct rte_security_capability_idx sec_cap_idx;
7973 sec_cap_idx.action = ut_params->type;
7974 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7975 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7976 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7979 if (fragsz > input_vec_len)
7980 fragsz = input_vec_len;
7982 uint16_t plaintext_len = fragsz;
7983 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7985 if (fragsz_oop > output_vec_len)
7986 frag_size_oop = output_vec_len;
7989 if (input_vec_len % fragsz != 0) {
7990 if (input_vec_len / fragsz + 1 > 16)
7992 } else if (input_vec_len / fragsz > 16)
7995 /* Out of place support */
7998 * For out-op-place we need to alloc another mbuf
8000 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8001 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8002 buf_oop = ut_params->obuf;
8005 /* Generate test mbuf data */
8006 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8008 /* clear mbuf payload */
8009 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8010 rte_pktmbuf_tailroom(ut_params->ibuf));
8012 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8014 memcpy(plaintext, input_vec, plaintext_len);
8015 trn_data += plaintext_len;
8017 buf = ut_params->ibuf;
8020 * Loop until no more fragments
8023 while (trn_data < input_vec_len) {
8025 to_trn = (input_vec_len - trn_data < fragsz) ?
8026 (input_vec_len - trn_data) : fragsz;
8028 to_trn_tbl[ecx++] = to_trn;
8030 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8033 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8034 rte_pktmbuf_tailroom(buf));
8037 if (oop && !fragsz_oop) {
8039 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8040 buf_oop = buf_oop->next;
8041 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8042 0, rte_pktmbuf_tailroom(buf_oop));
8043 rte_pktmbuf_append(buf_oop, to_trn);
8046 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8049 memcpy(plaintext, input_vec + trn_data, to_trn);
8053 ut_params->ibuf->nb_segs = segs;
8056 if (fragsz_oop && oop) {
8060 trn_data = frag_size_oop;
8061 while (trn_data < output_vec_len) {
8064 (output_vec_len - trn_data <
8066 (output_vec_len - trn_data) :
8069 to_trn_tbl[ecx++] = to_trn;
8072 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8073 buf_oop = buf_oop->next;
8074 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8075 0, rte_pktmbuf_tailroom(buf_oop));
8076 rte_pktmbuf_append(buf_oop, to_trn);
8080 ut_params->obuf->nb_segs = segs;
8083 /* Setup Cipher Parameters */
8084 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8085 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8086 ut_params->cipher_xform.cipher.op = opc;
8087 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8088 ut_params->cipher_xform.cipher.key.length =
8089 pdcp_test_params[i].cipher_key_len;
8090 ut_params->cipher_xform.cipher.iv.length = 0;
8092 /* Setup HMAC Parameters if ICV header is required */
8093 if (pdcp_test_params[i].auth_alg != 0) {
8094 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8095 ut_params->auth_xform.next = NULL;
8096 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8097 ut_params->auth_xform.auth.op = opa;
8098 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8099 ut_params->auth_xform.auth.key.length =
8100 pdcp_test_params[i].auth_key_len;
8102 ut_params->cipher_xform.next = &ut_params->auth_xform;
8104 ut_params->cipher_xform.next = NULL;
8107 struct rte_security_session_conf sess_conf = {
8108 .action_type = ut_params->type,
8109 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8111 .bearer = pdcp_test_bearer[i],
8112 .domain = pdcp_test_params[i].domain,
8113 .pkt_dir = pdcp_test_packet_direction[i],
8114 .sn_size = pdcp_test_data_sn_size[i],
8115 .hfn = pdcp_test_hfn[i],
8116 .hfn_threshold = pdcp_test_hfn_threshold[i],
8119 .crypto_xform = &ut_params->cipher_xform
8122 /* Create security session */
8123 ut_params->sec_session = rte_security_session_create(ctx,
8124 &sess_conf, ts_params->session_mpool,
8125 ts_params->session_priv_mpool);
8127 if (!ut_params->sec_session) {
8128 printf("TestCase %s()-%d line %d failed %s: ",
8129 __func__, i, __LINE__, "Failed to allocate session");
8134 /* Generate crypto op data structure */
8135 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8136 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8137 if (!ut_params->op) {
8138 printf("TestCase %s()-%d line %d failed %s: ",
8139 __func__, i, __LINE__,
8140 "Failed to allocate symmetric crypto operation struct");
8145 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8147 /* set crypto operation source mbuf */
8148 ut_params->op->sym->m_src = ut_params->ibuf;
8150 ut_params->op->sym->m_dst = ut_params->obuf;
8152 /* Process crypto operation */
8153 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8155 printf("TestCase %s()-%d line %d failed %s: ",
8156 __func__, i, __LINE__,
8157 "failed to process sym crypto op");
8162 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8163 printf("TestCase %s()-%d line %d failed %s: ",
8164 __func__, i, __LINE__, "crypto op processing failed");
8170 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8173 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8177 fragsz = frag_size_oop;
8178 if (memcmp(ciphertext, output_vec, fragsz)) {
8179 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8180 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8181 rte_hexdump(stdout, "reference", output_vec, fragsz);
8186 buf = ut_params->op->sym->m_src->next;
8188 buf = ut_params->op->sym->m_dst->next;
8190 unsigned int off = fragsz;
8194 ciphertext = rte_pktmbuf_mtod(buf,
8196 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8197 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8198 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8199 rte_hexdump(stdout, "reference", output_vec + off,
8204 off += to_trn_tbl[ecx++];
8208 rte_crypto_op_free(ut_params->op);
8209 ut_params->op = NULL;
8211 if (ut_params->sec_session)
8212 rte_security_session_destroy(ctx, ut_params->sec_session);
8213 ut_params->sec_session = NULL;
8215 rte_pktmbuf_free(ut_params->ibuf);
8216 ut_params->ibuf = NULL;
8218 rte_pktmbuf_free(ut_params->obuf);
8219 ut_params->obuf = NULL;
8226 test_pdcp_proto_cplane_encap(int i)
8228 return test_pdcp_proto(
8229 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8230 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8231 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8232 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8233 pdcp_test_params[i].cipher_key_len,
8234 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8235 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8236 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8237 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8238 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8242 test_pdcp_proto_uplane_encap(int i)
8244 return test_pdcp_proto(
8245 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8246 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8247 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8248 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8249 pdcp_test_params[i].cipher_key_len,
8250 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8251 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8252 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8253 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8254 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8258 test_pdcp_proto_uplane_encap_with_int(int i)
8260 return test_pdcp_proto(
8261 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8262 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8263 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8264 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8265 pdcp_test_params[i].cipher_key_len,
8266 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8267 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8268 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8269 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8270 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8274 test_pdcp_proto_cplane_decap(int i)
8276 return test_pdcp_proto(
8277 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8278 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8279 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8280 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8281 pdcp_test_params[i].cipher_key_len,
8282 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8283 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8284 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8285 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8286 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8290 test_pdcp_proto_uplane_decap(int i)
8292 return test_pdcp_proto(
8293 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8294 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8295 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8296 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8297 pdcp_test_params[i].cipher_key_len,
8298 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8299 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8300 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8301 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8302 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8306 test_pdcp_proto_uplane_decap_with_int(int i)
8308 return test_pdcp_proto(
8309 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8310 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8311 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8312 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8313 pdcp_test_params[i].cipher_key_len,
8314 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8315 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8316 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8317 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8318 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8322 test_PDCP_PROTO_SGL_in_place_32B(void)
8324 /* i can be used for running any PDCP case
8325 * In this case it is uplane 12-bit AES-SNOW DL encap
8327 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8328 return test_pdcp_proto_SGL(i, IN_PLACE,
8329 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8330 RTE_CRYPTO_AUTH_OP_GENERATE,
8331 pdcp_test_data_in[i],
8332 pdcp_test_data_in_len[i],
8333 pdcp_test_data_out[i],
8334 pdcp_test_data_in_len[i]+4,
8338 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8340 /* i can be used for running any PDCP case
8341 * In this case it is uplane 18-bit NULL-NULL DL encap
8343 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8344 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8345 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8346 RTE_CRYPTO_AUTH_OP_GENERATE,
8347 pdcp_test_data_in[i],
8348 pdcp_test_data_in_len[i],
8349 pdcp_test_data_out[i],
8350 pdcp_test_data_in_len[i]+4,
8354 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8356 /* i can be used for running any PDCP case
8357 * In this case it is uplane 18-bit AES DL encap
8359 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8361 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8362 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8363 RTE_CRYPTO_AUTH_OP_GENERATE,
8364 pdcp_test_data_in[i],
8365 pdcp_test_data_in_len[i],
8366 pdcp_test_data_out[i],
8367 pdcp_test_data_in_len[i],
8371 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8373 /* i can be used for running any PDCP case
8374 * In this case it is cplane 12-bit AES-ZUC DL encap
8376 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8377 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8378 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8379 RTE_CRYPTO_AUTH_OP_GENERATE,
8380 pdcp_test_data_in[i],
8381 pdcp_test_data_in_len[i],
8382 pdcp_test_data_out[i],
8383 pdcp_test_data_in_len[i]+4,
8388 test_PDCP_SDAP_PROTO_encap_all(void)
8390 int i = 0, size = 0;
8391 int err, all_err = TEST_SUCCESS;
8392 const struct pdcp_sdap_test *cur_test;
8394 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8396 for (i = 0; i < size; i++) {
8397 cur_test = &list_pdcp_sdap_tests[i];
8398 err = test_pdcp_proto(
8399 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8400 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8401 cur_test->in_len, cur_test->data_out,
8402 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8403 cur_test->param.cipher_alg, cur_test->cipher_key,
8404 cur_test->param.cipher_key_len,
8405 cur_test->param.auth_alg,
8406 cur_test->auth_key, cur_test->param.auth_key_len,
8407 cur_test->bearer, cur_test->param.domain,
8408 cur_test->packet_direction, cur_test->sn_size,
8410 cur_test->hfn_threshold, SDAP_ENABLED);
8412 printf("\t%d) %s: Encapsulation failed\n",
8414 cur_test->param.name);
8417 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8418 cur_test->param.name);
8424 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8426 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8430 test_PDCP_SDAP_PROTO_decap_all(void)
8432 int i = 0, size = 0;
8433 int err, all_err = TEST_SUCCESS;
8434 const struct pdcp_sdap_test *cur_test;
8436 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8438 for (i = 0; i < size; i++) {
8439 cur_test = &list_pdcp_sdap_tests[i];
8440 err = test_pdcp_proto(
8441 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8442 RTE_CRYPTO_AUTH_OP_VERIFY,
8444 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8445 cur_test->data_in, cur_test->in_len,
8446 cur_test->param.cipher_alg,
8447 cur_test->cipher_key, cur_test->param.cipher_key_len,
8448 cur_test->param.auth_alg, cur_test->auth_key,
8449 cur_test->param.auth_key_len, cur_test->bearer,
8450 cur_test->param.domain, cur_test->packet_direction,
8451 cur_test->sn_size, cur_test->hfn,
8452 cur_test->hfn_threshold, SDAP_ENABLED);
8454 printf("\t%d) %s: Decapsulation failed\n",
8456 cur_test->param.name);
8459 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8460 cur_test->param.name);
8466 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8468 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8472 test_PDCP_PROTO_all(void)
8474 struct crypto_testsuite_params *ts_params = &testsuite_params;
8475 struct crypto_unittest_params *ut_params = &unittest_params;
8476 struct rte_cryptodev_info dev_info;
8479 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8480 uint64_t feat_flags = dev_info.feature_flags;
8482 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8485 /* Set action type */
8486 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8487 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8490 if (security_proto_supported(ut_params->type,
8491 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8494 status = test_PDCP_PROTO_cplane_encap_all();
8495 status += test_PDCP_PROTO_cplane_decap_all();
8496 status += test_PDCP_PROTO_uplane_encap_all();
8497 status += test_PDCP_PROTO_uplane_decap_all();
8498 status += test_PDCP_PROTO_SGL_in_place_32B();
8499 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8500 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8501 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8502 status += test_PDCP_SDAP_PROTO_encap_all();
8503 status += test_PDCP_SDAP_PROTO_decap_all();
8508 return TEST_SUCCESS;
8512 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8514 struct crypto_testsuite_params *ts_params = &testsuite_params;
8515 struct crypto_unittest_params *ut_params = &unittest_params;
8516 uint8_t *plaintext, *ciphertext;
8518 int32_t cipher_len, crc_len;
8519 uint32_t crc_data_len;
8520 int ret = TEST_SUCCESS;
8522 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8523 rte_cryptodev_get_sec_ctx(
8524 ts_params->valid_devs[0]);
8526 /* Verify the capabilities */
8527 struct rte_security_capability_idx sec_cap_idx;
8528 const struct rte_security_capability *sec_cap;
8529 const struct rte_cryptodev_capabilities *crypto_cap;
8530 const struct rte_cryptodev_symmetric_capability *sym_cap;
8533 sec_cap_idx.action = ut_params->type;
8534 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8535 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8537 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8538 if (sec_cap == NULL)
8541 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8542 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8543 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8544 crypto_cap->sym.xform_type ==
8545 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8546 crypto_cap->sym.cipher.algo ==
8547 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8548 sym_cap = &crypto_cap->sym;
8549 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8556 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8559 /* Setup source mbuf payload */
8560 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8561 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8562 rte_pktmbuf_tailroom(ut_params->ibuf));
8564 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8565 d_td->ciphertext.len);
8567 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8569 /* Setup cipher session parameters */
8570 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8571 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8572 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8573 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8574 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8575 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8576 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8577 ut_params->cipher_xform.next = NULL;
8579 /* Setup DOCSIS session parameters */
8580 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8582 struct rte_security_session_conf sess_conf = {
8583 .action_type = ut_params->type,
8584 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8585 .docsis = ut_params->docsis_xform,
8586 .crypto_xform = &ut_params->cipher_xform,
8589 /* Create security session */
8590 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8591 ts_params->session_mpool,
8592 ts_params->session_priv_mpool);
8594 if (!ut_params->sec_session) {
8595 printf("TestCase %s(%d) line %d: %s\n",
8596 __func__, i, __LINE__, "failed to allocate session");
8601 /* Generate crypto op data structure */
8602 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8603 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8604 if (!ut_params->op) {
8605 printf("TestCase %s(%d) line %d: %s\n",
8606 __func__, i, __LINE__,
8607 "failed to allocate symmetric crypto operation");
8612 /* Setup CRC operation parameters */
8613 crc_len = d_td->ciphertext.no_crc == false ?
8614 (d_td->ciphertext.len -
8615 d_td->ciphertext.crc_offset -
8616 RTE_ETHER_CRC_LEN) :
8618 crc_len = crc_len > 0 ? crc_len : 0;
8619 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8620 ut_params->op->sym->auth.data.length = crc_len;
8621 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8623 /* Setup cipher operation parameters */
8624 cipher_len = d_td->ciphertext.no_cipher == false ?
8625 (d_td->ciphertext.len -
8626 d_td->ciphertext.cipher_offset) :
8628 cipher_len = cipher_len > 0 ? cipher_len : 0;
8629 ut_params->op->sym->cipher.data.length = cipher_len;
8630 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8632 /* Setup cipher IV */
8633 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8634 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8636 /* Attach session to operation */
8637 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8639 /* Set crypto operation mbufs */
8640 ut_params->op->sym->m_src = ut_params->ibuf;
8641 ut_params->op->sym->m_dst = NULL;
8643 /* Process crypto operation */
8644 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8646 printf("TestCase %s(%d) line %d: %s\n",
8647 __func__, i, __LINE__,
8648 "failed to process security crypto op");
8653 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8654 printf("TestCase %s(%d) line %d: %s\n",
8655 __func__, i, __LINE__, "crypto op processing failed");
8660 /* Validate plaintext */
8661 plaintext = ciphertext;
8663 if (memcmp(plaintext, d_td->plaintext.data,
8664 d_td->plaintext.len - crc_data_len)) {
8665 printf("TestCase %s(%d) line %d: %s\n",
8666 __func__, i, __LINE__, "plaintext not as expected\n");
8667 rte_hexdump(stdout, "expected", d_td->plaintext.data,
8668 d_td->plaintext.len);
8669 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
8675 rte_crypto_op_free(ut_params->op);
8676 ut_params->op = NULL;
8678 if (ut_params->sec_session)
8679 rte_security_session_destroy(ctx, ut_params->sec_session);
8680 ut_params->sec_session = NULL;
8682 rte_pktmbuf_free(ut_params->ibuf);
8683 ut_params->ibuf = NULL;
8689 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
8691 struct crypto_testsuite_params *ts_params = &testsuite_params;
8692 struct crypto_unittest_params *ut_params = &unittest_params;
8693 uint8_t *plaintext, *ciphertext;
8695 int32_t cipher_len, crc_len;
8696 int ret = TEST_SUCCESS;
8698 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8699 rte_cryptodev_get_sec_ctx(
8700 ts_params->valid_devs[0]);
8702 /* Verify the capabilities */
8703 struct rte_security_capability_idx sec_cap_idx;
8704 const struct rte_security_capability *sec_cap;
8705 const struct rte_cryptodev_capabilities *crypto_cap;
8706 const struct rte_cryptodev_symmetric_capability *sym_cap;
8709 sec_cap_idx.action = ut_params->type;
8710 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8711 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8713 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8714 if (sec_cap == NULL)
8717 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8718 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8719 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8720 crypto_cap->sym.xform_type ==
8721 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8722 crypto_cap->sym.cipher.algo ==
8723 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8724 sym_cap = &crypto_cap->sym;
8725 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8732 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8735 /* Setup source mbuf payload */
8736 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8737 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8738 rte_pktmbuf_tailroom(ut_params->ibuf));
8740 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8741 d_td->plaintext.len);
8743 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
8745 /* Setup cipher session parameters */
8746 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8747 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8748 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8749 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8750 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8751 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8752 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8753 ut_params->cipher_xform.next = NULL;
8755 /* Setup DOCSIS session parameters */
8756 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8758 struct rte_security_session_conf sess_conf = {
8759 .action_type = ut_params->type,
8760 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8761 .docsis = ut_params->docsis_xform,
8762 .crypto_xform = &ut_params->cipher_xform,
8765 /* Create security session */
8766 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8767 ts_params->session_mpool,
8768 ts_params->session_priv_mpool);
8770 if (!ut_params->sec_session) {
8771 printf("TestCase %s(%d) line %d: %s\n",
8772 __func__, i, __LINE__, "failed to allocate session");
8777 /* Generate crypto op data structure */
8778 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8779 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8780 if (!ut_params->op) {
8781 printf("TestCase %s(%d) line %d: %s\n",
8782 __func__, i, __LINE__,
8783 "failed to allocate security crypto operation");
8788 /* Setup CRC operation parameters */
8789 crc_len = d_td->plaintext.no_crc == false ?
8790 (d_td->plaintext.len -
8791 d_td->plaintext.crc_offset -
8792 RTE_ETHER_CRC_LEN) :
8794 crc_len = crc_len > 0 ? crc_len : 0;
8795 ut_params->op->sym->auth.data.length = crc_len;
8796 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8798 /* Setup cipher operation parameters */
8799 cipher_len = d_td->plaintext.no_cipher == false ?
8800 (d_td->plaintext.len -
8801 d_td->plaintext.cipher_offset) :
8803 cipher_len = cipher_len > 0 ? cipher_len : 0;
8804 ut_params->op->sym->cipher.data.length = cipher_len;
8805 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8807 /* Setup cipher IV */
8808 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8809 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8811 /* Attach session to operation */
8812 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8814 /* Set crypto operation mbufs */
8815 ut_params->op->sym->m_src = ut_params->ibuf;
8816 ut_params->op->sym->m_dst = NULL;
8818 /* Process crypto operation */
8819 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8821 printf("TestCase %s(%d) line %d: %s\n",
8822 __func__, i, __LINE__,
8823 "failed to process security crypto op");
8828 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8829 printf("TestCase %s(%d) line %d: %s\n",
8830 __func__, i, __LINE__, "crypto op processing failed");
8835 /* Validate ciphertext */
8836 ciphertext = plaintext;
8838 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8839 printf("TestCase %s(%d) line %d: %s\n",
8840 __func__, i, __LINE__, "ciphertext not as expected\n");
8841 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8842 d_td->ciphertext.len);
8843 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8849 rte_crypto_op_free(ut_params->op);
8850 ut_params->op = NULL;
8852 if (ut_params->sec_session)
8853 rte_security_session_destroy(ctx, ut_params->sec_session);
8854 ut_params->sec_session = NULL;
8856 rte_pktmbuf_free(ut_params->ibuf);
8857 ut_params->ibuf = NULL;
8862 #define TEST_DOCSIS_COUNT(func) do { \
8864 if (ret == TEST_SUCCESS) { \
8865 printf("\t%2d)", n++); \
8866 printf("+++++ PASSED:" #func"\n"); \
8868 } else if (ret == -ENOTSUP) { \
8869 printf("\t%2d)", n++); \
8870 printf("~~~~~ UNSUPP:" #func"\n"); \
8873 printf("\t%2d)", n++); \
8874 printf("----- FAILED:" #func"\n"); \
8880 test_DOCSIS_PROTO_uplink_all(void)
8882 int p = 0, u = 0, f = 0, n = 0;
8884 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8885 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8886 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8887 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8888 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8889 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8890 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8891 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8892 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8893 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8894 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8895 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8896 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8897 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8898 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8899 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8900 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8901 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8902 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8903 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8904 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8905 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8906 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8907 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8908 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8909 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8912 printf("## %s: %d passed out of %d (%d unsupported)\n",
8919 test_DOCSIS_PROTO_downlink_all(void)
8921 int p = 0, u = 0, f = 0, n = 0;
8923 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8924 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8925 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8926 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8927 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8928 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8929 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8930 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8931 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8932 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8933 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8934 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8935 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8936 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8937 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8938 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8939 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8940 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8941 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8942 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8943 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8944 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8945 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8946 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8947 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8948 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8951 printf("## %s: %d passed out of %d (%d unsupported)\n",
8958 test_DOCSIS_PROTO_all(void)
8960 struct crypto_testsuite_params *ts_params = &testsuite_params;
8961 struct crypto_unittest_params *ut_params = &unittest_params;
8962 struct rte_cryptodev_info dev_info;
8965 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8966 uint64_t feat_flags = dev_info.feature_flags;
8968 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8971 /* Set action type */
8972 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8973 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8976 if (security_proto_supported(ut_params->type,
8977 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8980 status = test_DOCSIS_PROTO_uplink_all();
8981 status += test_DOCSIS_PROTO_downlink_all();
8986 return TEST_SUCCESS;
8991 test_AES_GCM_authenticated_encryption_test_case_1(void)
8993 return test_authenticated_encryption(&gcm_test_case_1);
8997 test_AES_GCM_authenticated_encryption_test_case_2(void)
8999 return test_authenticated_encryption(&gcm_test_case_2);
9003 test_AES_GCM_authenticated_encryption_test_case_3(void)
9005 return test_authenticated_encryption(&gcm_test_case_3);
9009 test_AES_GCM_authenticated_encryption_test_case_4(void)
9011 return test_authenticated_encryption(&gcm_test_case_4);
9015 test_AES_GCM_authenticated_encryption_test_case_5(void)
9017 return test_authenticated_encryption(&gcm_test_case_5);
9021 test_AES_GCM_authenticated_encryption_test_case_6(void)
9023 return test_authenticated_encryption(&gcm_test_case_6);
9027 test_AES_GCM_authenticated_encryption_test_case_7(void)
9029 return test_authenticated_encryption(&gcm_test_case_7);
9033 test_AES_GCM_authenticated_encryption_test_case_8(void)
9035 return test_authenticated_encryption(&gcm_test_case_8);
9039 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9041 return test_authenticated_encryption(&gcm_J0_test_case_1);
9045 test_AES_GCM_auth_encryption_test_case_192_1(void)
9047 return test_authenticated_encryption(&gcm_test_case_192_1);
9051 test_AES_GCM_auth_encryption_test_case_192_2(void)
9053 return test_authenticated_encryption(&gcm_test_case_192_2);
9057 test_AES_GCM_auth_encryption_test_case_192_3(void)
9059 return test_authenticated_encryption(&gcm_test_case_192_3);
9063 test_AES_GCM_auth_encryption_test_case_192_4(void)
9065 return test_authenticated_encryption(&gcm_test_case_192_4);
9069 test_AES_GCM_auth_encryption_test_case_192_5(void)
9071 return test_authenticated_encryption(&gcm_test_case_192_5);
9075 test_AES_GCM_auth_encryption_test_case_192_6(void)
9077 return test_authenticated_encryption(&gcm_test_case_192_6);
9081 test_AES_GCM_auth_encryption_test_case_192_7(void)
9083 return test_authenticated_encryption(&gcm_test_case_192_7);
9087 test_AES_GCM_auth_encryption_test_case_256_1(void)
9089 return test_authenticated_encryption(&gcm_test_case_256_1);
9093 test_AES_GCM_auth_encryption_test_case_256_2(void)
9095 return test_authenticated_encryption(&gcm_test_case_256_2);
9099 test_AES_GCM_auth_encryption_test_case_256_3(void)
9101 return test_authenticated_encryption(&gcm_test_case_256_3);
9105 test_AES_GCM_auth_encryption_test_case_256_4(void)
9107 return test_authenticated_encryption(&gcm_test_case_256_4);
9111 test_AES_GCM_auth_encryption_test_case_256_5(void)
9113 return test_authenticated_encryption(&gcm_test_case_256_5);
9117 test_AES_GCM_auth_encryption_test_case_256_6(void)
9119 return test_authenticated_encryption(&gcm_test_case_256_6);
9123 test_AES_GCM_auth_encryption_test_case_256_7(void)
9125 return test_authenticated_encryption(&gcm_test_case_256_7);
9129 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9131 return test_authenticated_encryption(&gcm_test_case_aad_1);
9135 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9137 return test_authenticated_encryption(&gcm_test_case_aad_2);
9141 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9143 struct aead_test_data tdata;
9146 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9147 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9148 tdata.iv.data[0] += 1;
9149 res = test_authenticated_encryption(&tdata);
9150 if (res == -ENOTSUP)
9152 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9153 return TEST_SUCCESS;
9157 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9159 struct aead_test_data tdata;
9162 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9163 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9164 tdata.plaintext.data[0] += 1;
9165 res = test_authenticated_encryption(&tdata);
9166 if (res == -ENOTSUP)
9168 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9169 return TEST_SUCCESS;
9173 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9175 struct aead_test_data tdata;
9178 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9179 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9180 tdata.ciphertext.data[0] += 1;
9181 res = test_authenticated_encryption(&tdata);
9182 if (res == -ENOTSUP)
9184 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9185 return TEST_SUCCESS;
9189 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9191 struct aead_test_data tdata;
9194 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9195 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9197 res = test_authenticated_encryption(&tdata);
9198 if (res == -ENOTSUP)
9200 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9201 return TEST_SUCCESS;
9205 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9207 struct aead_test_data tdata;
9208 uint8_t aad[gcm_test_case_7.aad.len];
9211 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9212 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9213 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9215 tdata.aad.data = aad;
9216 res = test_authenticated_encryption(&tdata);
9217 if (res == -ENOTSUP)
9219 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9220 return TEST_SUCCESS;
9224 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9226 struct aead_test_data tdata;
9229 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9230 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9231 tdata.auth_tag.data[0] += 1;
9232 res = test_authenticated_encryption(&tdata);
9233 if (res == -ENOTSUP)
9235 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9236 return TEST_SUCCESS;
9240 test_authenticated_decryption(const struct aead_test_data *tdata)
9242 struct crypto_testsuite_params *ts_params = &testsuite_params;
9243 struct crypto_unittest_params *ut_params = &unittest_params;
9248 struct rte_cryptodev_info dev_info;
9250 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9251 uint64_t feat_flags = dev_info.feature_flags;
9253 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9254 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9255 printf("Device doesn't support RAW data-path APIs.\n");
9259 /* Verify the capabilities */
9260 struct rte_cryptodev_sym_capability_idx cap_idx;
9261 const struct rte_cryptodev_symmetric_capability *capability;
9262 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9263 cap_idx.algo.aead = tdata->algo;
9264 capability = rte_cryptodev_sym_capability_get(
9265 ts_params->valid_devs[0], &cap_idx);
9266 if (capability == NULL)
9268 if (rte_cryptodev_sym_capability_check_aead(
9269 capability, tdata->key.len, tdata->auth_tag.len,
9270 tdata->aad.len, tdata->iv.len))
9273 /* Create AEAD session */
9274 retval = create_aead_session(ts_params->valid_devs[0],
9276 RTE_CRYPTO_AEAD_OP_DECRYPT,
9277 tdata->key.data, tdata->key.len,
9278 tdata->aad.len, tdata->auth_tag.len,
9283 /* alloc mbuf and set payload */
9284 if (tdata->aad.len > MBUF_SIZE) {
9285 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9286 /* Populate full size of add data */
9287 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9288 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9290 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9292 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9293 rte_pktmbuf_tailroom(ut_params->ibuf));
9295 /* Create AEAD operation */
9296 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9300 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9302 ut_params->op->sym->m_src = ut_params->ibuf;
9304 /* Process crypto operation */
9305 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9306 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9307 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9308 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9309 ut_params->op, 0, 0, 0, 0);
9311 TEST_ASSERT_NOT_NULL(
9312 process_crypto_request(ts_params->valid_devs[0],
9313 ut_params->op), "failed to process sym crypto op");
9315 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9316 "crypto op processing failed");
9318 if (ut_params->op->sym->m_dst)
9319 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9322 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9324 ut_params->op->sym->cipher.data.offset);
9326 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9329 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9331 tdata->plaintext.data,
9332 tdata->plaintext.len,
9333 "Plaintext data not as expected");
9335 TEST_ASSERT_EQUAL(ut_params->op->status,
9336 RTE_CRYPTO_OP_STATUS_SUCCESS,
9337 "Authentication failed");
9343 test_AES_GCM_authenticated_decryption_test_case_1(void)
9345 return test_authenticated_decryption(&gcm_test_case_1);
9349 test_AES_GCM_authenticated_decryption_test_case_2(void)
9351 return test_authenticated_decryption(&gcm_test_case_2);
9355 test_AES_GCM_authenticated_decryption_test_case_3(void)
9357 return test_authenticated_decryption(&gcm_test_case_3);
9361 test_AES_GCM_authenticated_decryption_test_case_4(void)
9363 return test_authenticated_decryption(&gcm_test_case_4);
9367 test_AES_GCM_authenticated_decryption_test_case_5(void)
9369 return test_authenticated_decryption(&gcm_test_case_5);
9373 test_AES_GCM_authenticated_decryption_test_case_6(void)
9375 return test_authenticated_decryption(&gcm_test_case_6);
9379 test_AES_GCM_authenticated_decryption_test_case_7(void)
9381 return test_authenticated_decryption(&gcm_test_case_7);
9385 test_AES_GCM_authenticated_decryption_test_case_8(void)
9387 return test_authenticated_decryption(&gcm_test_case_8);
9391 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9393 return test_authenticated_decryption(&gcm_J0_test_case_1);
9397 test_AES_GCM_auth_decryption_test_case_192_1(void)
9399 return test_authenticated_decryption(&gcm_test_case_192_1);
9403 test_AES_GCM_auth_decryption_test_case_192_2(void)
9405 return test_authenticated_decryption(&gcm_test_case_192_2);
9409 test_AES_GCM_auth_decryption_test_case_192_3(void)
9411 return test_authenticated_decryption(&gcm_test_case_192_3);
9415 test_AES_GCM_auth_decryption_test_case_192_4(void)
9417 return test_authenticated_decryption(&gcm_test_case_192_4);
9421 test_AES_GCM_auth_decryption_test_case_192_5(void)
9423 return test_authenticated_decryption(&gcm_test_case_192_5);
9427 test_AES_GCM_auth_decryption_test_case_192_6(void)
9429 return test_authenticated_decryption(&gcm_test_case_192_6);
9433 test_AES_GCM_auth_decryption_test_case_192_7(void)
9435 return test_authenticated_decryption(&gcm_test_case_192_7);
9439 test_AES_GCM_auth_decryption_test_case_256_1(void)
9441 return test_authenticated_decryption(&gcm_test_case_256_1);
9445 test_AES_GCM_auth_decryption_test_case_256_2(void)
9447 return test_authenticated_decryption(&gcm_test_case_256_2);
9451 test_AES_GCM_auth_decryption_test_case_256_3(void)
9453 return test_authenticated_decryption(&gcm_test_case_256_3);
9457 test_AES_GCM_auth_decryption_test_case_256_4(void)
9459 return test_authenticated_decryption(&gcm_test_case_256_4);
9463 test_AES_GCM_auth_decryption_test_case_256_5(void)
9465 return test_authenticated_decryption(&gcm_test_case_256_5);
9469 test_AES_GCM_auth_decryption_test_case_256_6(void)
9471 return test_authenticated_decryption(&gcm_test_case_256_6);
9475 test_AES_GCM_auth_decryption_test_case_256_7(void)
9477 return test_authenticated_decryption(&gcm_test_case_256_7);
9481 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9483 return test_authenticated_decryption(&gcm_test_case_aad_1);
9487 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9489 return test_authenticated_decryption(&gcm_test_case_aad_2);
9493 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9495 struct aead_test_data tdata;
9498 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9499 tdata.iv.data[0] += 1;
9500 res = test_authenticated_decryption(&tdata);
9501 if (res == -ENOTSUP)
9503 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9504 return TEST_SUCCESS;
9508 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9510 struct aead_test_data tdata;
9513 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9514 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9515 tdata.plaintext.data[0] += 1;
9516 res = test_authenticated_decryption(&tdata);
9517 if (res == -ENOTSUP)
9519 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9520 return TEST_SUCCESS;
9524 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9526 struct aead_test_data tdata;
9529 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9530 tdata.ciphertext.data[0] += 1;
9531 res = test_authenticated_decryption(&tdata);
9532 if (res == -ENOTSUP)
9534 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9535 return TEST_SUCCESS;
9539 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9541 struct aead_test_data tdata;
9544 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9546 res = test_authenticated_decryption(&tdata);
9547 if (res == -ENOTSUP)
9549 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9550 return TEST_SUCCESS;
9554 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9556 struct aead_test_data tdata;
9557 uint8_t aad[gcm_test_case_7.aad.len];
9560 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9561 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9563 tdata.aad.data = aad;
9564 res = test_authenticated_decryption(&tdata);
9565 if (res == -ENOTSUP)
9567 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9568 return TEST_SUCCESS;
9572 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9574 struct aead_test_data tdata;
9577 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9578 tdata.auth_tag.data[0] += 1;
9579 res = test_authenticated_decryption(&tdata);
9580 if (res == -ENOTSUP)
9582 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9583 return TEST_SUCCESS;
9587 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9589 struct crypto_testsuite_params *ts_params = &testsuite_params;
9590 struct crypto_unittest_params *ut_params = &unittest_params;
9593 uint8_t *ciphertext, *auth_tag;
9594 uint16_t plaintext_pad_len;
9596 /* Verify the capabilities */
9597 struct rte_cryptodev_sym_capability_idx cap_idx;
9598 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9599 cap_idx.algo.aead = tdata->algo;
9600 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9604 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9607 /* not supported with CPU crypto */
9608 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9611 /* Create AEAD session */
9612 retval = create_aead_session(ts_params->valid_devs[0],
9614 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9615 tdata->key.data, tdata->key.len,
9616 tdata->aad.len, tdata->auth_tag.len,
9621 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9622 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9624 /* clear mbuf payload */
9625 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9626 rte_pktmbuf_tailroom(ut_params->ibuf));
9627 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9628 rte_pktmbuf_tailroom(ut_params->obuf));
9630 /* Create AEAD operation */
9631 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9635 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9637 ut_params->op->sym->m_src = ut_params->ibuf;
9638 ut_params->op->sym->m_dst = ut_params->obuf;
9640 /* Process crypto operation */
9641 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9642 ut_params->op), "failed to process sym crypto op");
9644 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9645 "crypto op processing failed");
9647 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9649 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9650 ut_params->op->sym->cipher.data.offset);
9651 auth_tag = ciphertext + plaintext_pad_len;
9653 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9654 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9657 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9659 tdata->ciphertext.data,
9660 tdata->ciphertext.len,
9661 "Ciphertext data not as expected");
9663 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9665 tdata->auth_tag.data,
9666 tdata->auth_tag.len,
9667 "Generated auth tag not as expected");
9674 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9676 return test_authenticated_encryption_oop(&gcm_test_case_5);
9680 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9682 struct crypto_testsuite_params *ts_params = &testsuite_params;
9683 struct crypto_unittest_params *ut_params = &unittest_params;
9688 /* Verify the capabilities */
9689 struct rte_cryptodev_sym_capability_idx cap_idx;
9690 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9691 cap_idx.algo.aead = tdata->algo;
9692 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9696 /* not supported with CPU crypto and raw data-path APIs*/
9697 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
9698 global_api_test_type == CRYPTODEV_RAW_API_TEST)
9701 /* Create AEAD session */
9702 retval = create_aead_session(ts_params->valid_devs[0],
9704 RTE_CRYPTO_AEAD_OP_DECRYPT,
9705 tdata->key.data, tdata->key.len,
9706 tdata->aad.len, tdata->auth_tag.len,
9711 /* alloc mbuf and set payload */
9712 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9713 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9715 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9716 rte_pktmbuf_tailroom(ut_params->ibuf));
9717 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9718 rte_pktmbuf_tailroom(ut_params->obuf));
9720 /* Create AEAD operation */
9721 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9725 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9727 ut_params->op->sym->m_src = ut_params->ibuf;
9728 ut_params->op->sym->m_dst = ut_params->obuf;
9730 /* Process crypto operation */
9731 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9732 ut_params->op), "failed to process sym crypto op");
9734 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9735 "crypto op processing failed");
9737 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9738 ut_params->op->sym->cipher.data.offset);
9740 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9743 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9745 tdata->plaintext.data,
9746 tdata->plaintext.len,
9747 "Plaintext data not as expected");
9749 TEST_ASSERT_EQUAL(ut_params->op->status,
9750 RTE_CRYPTO_OP_STATUS_SUCCESS,
9751 "Authentication failed");
9756 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9758 return test_authenticated_decryption_oop(&gcm_test_case_5);
9762 test_authenticated_encryption_sessionless(
9763 const struct aead_test_data *tdata)
9765 struct crypto_testsuite_params *ts_params = &testsuite_params;
9766 struct crypto_unittest_params *ut_params = &unittest_params;
9769 uint8_t *ciphertext, *auth_tag;
9770 uint16_t plaintext_pad_len;
9771 uint8_t key[tdata->key.len + 1];
9772 struct rte_cryptodev_info dev_info;
9774 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9775 uint64_t feat_flags = dev_info.feature_flags;
9777 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9778 printf("Device doesn't support Sessionless ops.\n");
9782 /* not supported with CPU crypto */
9783 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9786 /* Verify the capabilities */
9787 struct rte_cryptodev_sym_capability_idx cap_idx;
9788 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9789 cap_idx.algo.aead = tdata->algo;
9790 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9794 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9796 /* clear mbuf payload */
9797 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9798 rte_pktmbuf_tailroom(ut_params->ibuf));
9800 /* Create AEAD operation */
9801 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9805 /* Create GCM xform */
9806 memcpy(key, tdata->key.data, tdata->key.len);
9807 retval = create_aead_xform(ut_params->op,
9809 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9810 key, tdata->key.len,
9811 tdata->aad.len, tdata->auth_tag.len,
9816 ut_params->op->sym->m_src = ut_params->ibuf;
9818 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9819 RTE_CRYPTO_OP_SESSIONLESS,
9820 "crypto op session type not sessionless");
9822 /* Process crypto operation */
9823 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9824 ut_params->op), "failed to process sym crypto op");
9826 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9828 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9829 "crypto op status not success");
9831 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9833 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9834 ut_params->op->sym->cipher.data.offset);
9835 auth_tag = ciphertext + plaintext_pad_len;
9837 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9838 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9841 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9843 tdata->ciphertext.data,
9844 tdata->ciphertext.len,
9845 "Ciphertext data not as expected");
9847 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9849 tdata->auth_tag.data,
9850 tdata->auth_tag.len,
9851 "Generated auth tag not as expected");
9858 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9860 return test_authenticated_encryption_sessionless(
9865 test_authenticated_decryption_sessionless(
9866 const struct aead_test_data *tdata)
9868 struct crypto_testsuite_params *ts_params = &testsuite_params;
9869 struct crypto_unittest_params *ut_params = &unittest_params;
9873 uint8_t key[tdata->key.len + 1];
9874 struct rte_cryptodev_info dev_info;
9876 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9877 uint64_t feat_flags = dev_info.feature_flags;
9879 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9880 printf("Device doesn't support Sessionless ops.\n");
9884 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9885 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9886 printf("Device doesn't support RAW data-path APIs.\n");
9890 /* not supported with CPU crypto */
9891 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9894 /* Verify the capabilities */
9895 struct rte_cryptodev_sym_capability_idx cap_idx;
9896 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9897 cap_idx.algo.aead = tdata->algo;
9898 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9902 /* alloc mbuf and set payload */
9903 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9905 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9906 rte_pktmbuf_tailroom(ut_params->ibuf));
9908 /* Create AEAD operation */
9909 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9913 /* Create AEAD xform */
9914 memcpy(key, tdata->key.data, tdata->key.len);
9915 retval = create_aead_xform(ut_params->op,
9917 RTE_CRYPTO_AEAD_OP_DECRYPT,
9918 key, tdata->key.len,
9919 tdata->aad.len, tdata->auth_tag.len,
9924 ut_params->op->sym->m_src = ut_params->ibuf;
9926 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9927 RTE_CRYPTO_OP_SESSIONLESS,
9928 "crypto op session type not sessionless");
9930 /* Process crypto operation */
9931 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9932 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9933 ut_params->op, 0, 0, 0, 0);
9935 TEST_ASSERT_NOT_NULL(process_crypto_request(
9936 ts_params->valid_devs[0], ut_params->op),
9937 "failed to process sym crypto op");
9939 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9941 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9942 "crypto op status not success");
9944 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9945 ut_params->op->sym->cipher.data.offset);
9947 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9950 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9952 tdata->plaintext.data,
9953 tdata->plaintext.len,
9954 "Plaintext data not as expected");
9956 TEST_ASSERT_EQUAL(ut_params->op->status,
9957 RTE_CRYPTO_OP_STATUS_SUCCESS,
9958 "Authentication failed");
9963 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9965 return test_authenticated_decryption_sessionless(
9970 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9972 return test_authenticated_encryption(&ccm_test_case_128_1);
9976 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9978 return test_authenticated_encryption(&ccm_test_case_128_2);
9982 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9984 return test_authenticated_encryption(&ccm_test_case_128_3);
9988 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9990 return test_authenticated_decryption(&ccm_test_case_128_1);
9994 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9996 return test_authenticated_decryption(&ccm_test_case_128_2);
10000 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10002 return test_authenticated_decryption(&ccm_test_case_128_3);
10006 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10008 return test_authenticated_encryption(&ccm_test_case_192_1);
10012 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10014 return test_authenticated_encryption(&ccm_test_case_192_2);
10018 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10020 return test_authenticated_encryption(&ccm_test_case_192_3);
10024 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10026 return test_authenticated_decryption(&ccm_test_case_192_1);
10030 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10032 return test_authenticated_decryption(&ccm_test_case_192_2);
10036 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10038 return test_authenticated_decryption(&ccm_test_case_192_3);
10042 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10044 return test_authenticated_encryption(&ccm_test_case_256_1);
10048 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10050 return test_authenticated_encryption(&ccm_test_case_256_2);
10054 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10056 return test_authenticated_encryption(&ccm_test_case_256_3);
10060 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10062 return test_authenticated_decryption(&ccm_test_case_256_1);
10066 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10068 return test_authenticated_decryption(&ccm_test_case_256_2);
10072 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10074 return test_authenticated_decryption(&ccm_test_case_256_3);
10080 struct crypto_testsuite_params *ts_params = &testsuite_params;
10081 struct rte_cryptodev_stats stats;
10083 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10086 /* Verify the capabilities */
10087 struct rte_cryptodev_sym_capability_idx cap_idx;
10088 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10089 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10090 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10093 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10094 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10095 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10099 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10103 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10104 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10105 &stats) == -ENODEV),
10106 "rte_cryptodev_stats_get invalid dev failed");
10107 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10108 "rte_cryptodev_stats_get invalid Param failed");
10110 /* Test expected values */
10111 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10112 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10114 "rte_cryptodev_stats_get failed");
10115 TEST_ASSERT((stats.enqueued_count == 1),
10116 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10117 TEST_ASSERT((stats.dequeued_count == 1),
10118 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10119 TEST_ASSERT((stats.enqueue_err_count == 0),
10120 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10121 TEST_ASSERT((stats.dequeue_err_count == 0),
10122 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10124 /* invalid device but should ignore and not reset device stats*/
10125 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10126 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10128 "rte_cryptodev_stats_get failed");
10129 TEST_ASSERT((stats.enqueued_count == 1),
10130 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10132 /* check that a valid reset clears stats */
10133 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10134 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10136 "rte_cryptodev_stats_get failed");
10137 TEST_ASSERT((stats.enqueued_count == 0),
10138 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10139 TEST_ASSERT((stats.dequeued_count == 0),
10140 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10142 return TEST_SUCCESS;
10145 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10146 struct crypto_unittest_params *ut_params,
10147 enum rte_crypto_auth_operation op,
10148 const struct HMAC_MD5_vector *test_case)
10152 memcpy(key, test_case->key.data, test_case->key.len);
10154 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10155 ut_params->auth_xform.next = NULL;
10156 ut_params->auth_xform.auth.op = op;
10158 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10160 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10161 ut_params->auth_xform.auth.key.length = test_case->key.len;
10162 ut_params->auth_xform.auth.key.data = key;
10164 ut_params->sess = rte_cryptodev_sym_session_create(
10165 ts_params->session_mpool);
10167 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10168 ut_params->sess, &ut_params->auth_xform,
10169 ts_params->session_priv_mpool);
10171 if (ut_params->sess == NULL)
10172 return TEST_FAILED;
10174 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10176 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10177 rte_pktmbuf_tailroom(ut_params->ibuf));
10182 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10183 const struct HMAC_MD5_vector *test_case,
10184 uint8_t **plaintext)
10186 uint16_t plaintext_pad_len;
10188 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10190 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10193 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10194 plaintext_pad_len);
10195 memcpy(*plaintext, test_case->plaintext.data,
10196 test_case->plaintext.len);
10198 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10199 ut_params->ibuf, MD5_DIGEST_LEN);
10200 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10201 "no room to append digest");
10202 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10203 ut_params->ibuf, plaintext_pad_len);
10205 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10206 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10207 test_case->auth_tag.len);
10210 sym_op->auth.data.offset = 0;
10211 sym_op->auth.data.length = test_case->plaintext.len;
10213 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10214 ut_params->op->sym->m_src = ut_params->ibuf;
10220 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10222 uint16_t plaintext_pad_len;
10223 uint8_t *plaintext, *auth_tag;
10225 struct crypto_testsuite_params *ts_params = &testsuite_params;
10226 struct crypto_unittest_params *ut_params = &unittest_params;
10227 struct rte_cryptodev_info dev_info;
10229 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10230 uint64_t feat_flags = dev_info.feature_flags;
10232 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10233 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10234 printf("Device doesn't support RAW data-path APIs.\n");
10238 /* Verify the capabilities */
10239 struct rte_cryptodev_sym_capability_idx cap_idx;
10240 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10241 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10242 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10246 if (MD5_HMAC_create_session(ts_params, ut_params,
10247 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10248 return TEST_FAILED;
10250 /* Generate Crypto op data structure */
10251 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10252 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10253 TEST_ASSERT_NOT_NULL(ut_params->op,
10254 "Failed to allocate symmetric crypto operation struct");
10256 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10259 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10260 return TEST_FAILED;
10262 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10263 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10265 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10266 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10267 ut_params->op, 0, 1, 0, 0);
10269 TEST_ASSERT_NOT_NULL(
10270 process_crypto_request(ts_params->valid_devs[0],
10272 "failed to process sym crypto op");
10274 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10275 "crypto op processing failed");
10277 if (ut_params->op->sym->m_dst) {
10278 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10279 uint8_t *, plaintext_pad_len);
10281 auth_tag = plaintext + plaintext_pad_len;
10284 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10286 test_case->auth_tag.data,
10287 test_case->auth_tag.len,
10288 "HMAC_MD5 generated tag not as expected");
10290 return TEST_SUCCESS;
10294 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10296 uint8_t *plaintext;
10298 struct crypto_testsuite_params *ts_params = &testsuite_params;
10299 struct crypto_unittest_params *ut_params = &unittest_params;
10300 struct rte_cryptodev_info dev_info;
10302 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10303 uint64_t feat_flags = dev_info.feature_flags;
10305 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10306 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10307 printf("Device doesn't support RAW data-path APIs.\n");
10311 /* Verify the capabilities */
10312 struct rte_cryptodev_sym_capability_idx cap_idx;
10313 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10314 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10315 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10319 if (MD5_HMAC_create_session(ts_params, ut_params,
10320 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10321 return TEST_FAILED;
10324 /* Generate Crypto op data structure */
10325 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10326 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10327 TEST_ASSERT_NOT_NULL(ut_params->op,
10328 "Failed to allocate symmetric crypto operation struct");
10330 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10331 return TEST_FAILED;
10333 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10334 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10336 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10337 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10338 ut_params->op, 0, 1, 0, 0);
10340 TEST_ASSERT_NOT_NULL(
10341 process_crypto_request(ts_params->valid_devs[0],
10343 "failed to process sym crypto op");
10345 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10346 "HMAC_MD5 crypto op processing failed");
10348 return TEST_SUCCESS;
10352 test_MD5_HMAC_generate_case_1(void)
10354 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10358 test_MD5_HMAC_verify_case_1(void)
10360 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10364 test_MD5_HMAC_generate_case_2(void)
10366 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10370 test_MD5_HMAC_verify_case_2(void)
10372 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10376 test_multi_session(void)
10378 struct crypto_testsuite_params *ts_params = &testsuite_params;
10379 struct crypto_unittest_params *ut_params = &unittest_params;
10381 struct rte_cryptodev_info dev_info;
10382 struct rte_cryptodev_sym_session **sessions;
10386 /* Verify the capabilities */
10387 struct rte_cryptodev_sym_capability_idx cap_idx;
10388 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10389 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10390 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10393 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10394 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10395 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10399 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10400 aes_cbc_key, hmac_sha512_key);
10403 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10405 sessions = rte_malloc(NULL,
10406 (sizeof(struct rte_cryptodev_sym_session *) *
10407 MAX_NB_SESSIONS) + 1, 0);
10409 /* Create multiple crypto sessions*/
10410 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10412 sessions[i] = rte_cryptodev_sym_session_create(
10413 ts_params->session_mpool);
10415 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10416 sessions[i], &ut_params->auth_xform,
10417 ts_params->session_priv_mpool);
10418 TEST_ASSERT_NOT_NULL(sessions[i],
10419 "Session creation failed at session number %u",
10422 /* Attempt to send a request on each session */
10423 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10427 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10428 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10430 "Failed to perform decrypt on request number %u.", i);
10431 /* free crypto operation structure */
10433 rte_crypto_op_free(ut_params->op);
10436 * free mbuf - both obuf and ibuf are usually the same,
10437 * so check if they point at the same address is necessary,
10438 * to avoid freeing the mbuf twice.
10440 if (ut_params->obuf) {
10441 rte_pktmbuf_free(ut_params->obuf);
10442 if (ut_params->ibuf == ut_params->obuf)
10443 ut_params->ibuf = 0;
10444 ut_params->obuf = 0;
10446 if (ut_params->ibuf) {
10447 rte_pktmbuf_free(ut_params->ibuf);
10448 ut_params->ibuf = 0;
10452 /* Next session create should fail */
10453 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10454 sessions[i], &ut_params->auth_xform,
10455 ts_params->session_priv_mpool);
10456 TEST_ASSERT_NULL(sessions[i],
10457 "Session creation succeeded unexpectedly!");
10459 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10460 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10462 rte_cryptodev_sym_session_free(sessions[i]);
10465 rte_free(sessions);
10467 return TEST_SUCCESS;
10470 struct multi_session_params {
10471 struct crypto_unittest_params ut_params;
10472 uint8_t *cipher_key;
10474 const uint8_t *cipher;
10475 const uint8_t *digest;
10479 #define MB_SESSION_NUMBER 3
10482 test_multi_session_random_usage(void)
10484 struct crypto_testsuite_params *ts_params = &testsuite_params;
10485 struct rte_cryptodev_info dev_info;
10486 struct rte_cryptodev_sym_session **sessions;
10488 struct multi_session_params ut_paramz[] = {
10491 .cipher_key = ms_aes_cbc_key0,
10492 .hmac_key = ms_hmac_key0,
10493 .cipher = ms_aes_cbc_cipher0,
10494 .digest = ms_hmac_digest0,
10495 .iv = ms_aes_cbc_iv0
10498 .cipher_key = ms_aes_cbc_key1,
10499 .hmac_key = ms_hmac_key1,
10500 .cipher = ms_aes_cbc_cipher1,
10501 .digest = ms_hmac_digest1,
10502 .iv = ms_aes_cbc_iv1
10505 .cipher_key = ms_aes_cbc_key2,
10506 .hmac_key = ms_hmac_key2,
10507 .cipher = ms_aes_cbc_cipher2,
10508 .digest = ms_hmac_digest2,
10509 .iv = ms_aes_cbc_iv2
10514 /* Verify the capabilities */
10515 struct rte_cryptodev_sym_capability_idx cap_idx;
10516 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10517 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10518 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10521 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10522 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10523 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10527 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10529 sessions = rte_malloc(NULL,
10530 (sizeof(struct rte_cryptodev_sym_session *)
10531 * MAX_NB_SESSIONS) + 1, 0);
10533 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10534 sessions[i] = rte_cryptodev_sym_session_create(
10535 ts_params->session_mpool);
10537 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10538 sizeof(struct crypto_unittest_params));
10540 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10541 &ut_paramz[i].ut_params,
10542 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10544 /* Create multiple crypto sessions*/
10545 rte_cryptodev_sym_session_init(
10546 ts_params->valid_devs[0],
10548 &ut_paramz[i].ut_params.auth_xform,
10549 ts_params->session_priv_mpool);
10551 TEST_ASSERT_NOT_NULL(sessions[i],
10552 "Session creation failed at session number %u",
10558 for (i = 0; i < 40000; i++) {
10560 j = rand() % MB_SESSION_NUMBER;
10562 TEST_ASSERT_SUCCESS(
10563 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10565 &ut_paramz[j].ut_params,
10566 ts_params, ut_paramz[j].cipher,
10567 ut_paramz[j].digest,
10569 "Failed to perform decrypt on request number %u.", i);
10571 if (ut_paramz[j].ut_params.op)
10572 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10575 * free mbuf - both obuf and ibuf are usually the same,
10576 * so check if they point at the same address is necessary,
10577 * to avoid freeing the mbuf twice.
10579 if (ut_paramz[j].ut_params.obuf) {
10580 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10581 if (ut_paramz[j].ut_params.ibuf
10582 == ut_paramz[j].ut_params.obuf)
10583 ut_paramz[j].ut_params.ibuf = 0;
10584 ut_paramz[j].ut_params.obuf = 0;
10586 if (ut_paramz[j].ut_params.ibuf) {
10587 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10588 ut_paramz[j].ut_params.ibuf = 0;
10592 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10593 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10595 rte_cryptodev_sym_session_free(sessions[i]);
10598 rte_free(sessions);
10600 return TEST_SUCCESS;
10603 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10604 0xab, 0xab, 0xab, 0xab,
10605 0xab, 0xab, 0xab, 0xab,
10606 0xab, 0xab, 0xab, 0xab};
10609 test_null_invalid_operation(void)
10611 struct crypto_testsuite_params *ts_params = &testsuite_params;
10612 struct crypto_unittest_params *ut_params = &unittest_params;
10615 /* This test is for NULL PMD only */
10616 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10617 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10620 /* Setup Cipher Parameters */
10621 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10622 ut_params->cipher_xform.next = NULL;
10624 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10625 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10627 ut_params->sess = rte_cryptodev_sym_session_create(
10628 ts_params->session_mpool);
10630 /* Create Crypto session*/
10631 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10632 ut_params->sess, &ut_params->cipher_xform,
10633 ts_params->session_priv_mpool);
10634 TEST_ASSERT(ret < 0,
10635 "Session creation succeeded unexpectedly");
10638 /* Setup HMAC Parameters */
10639 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10640 ut_params->auth_xform.next = NULL;
10642 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10643 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10645 ut_params->sess = rte_cryptodev_sym_session_create(
10646 ts_params->session_mpool);
10648 /* Create Crypto session*/
10649 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10650 ut_params->sess, &ut_params->auth_xform,
10651 ts_params->session_priv_mpool);
10652 TEST_ASSERT(ret < 0,
10653 "Session creation succeeded unexpectedly");
10655 return TEST_SUCCESS;
10659 #define NULL_BURST_LENGTH (32)
10662 test_null_burst_operation(void)
10664 struct crypto_testsuite_params *ts_params = &testsuite_params;
10665 struct crypto_unittest_params *ut_params = &unittest_params;
10667 unsigned i, burst_len = NULL_BURST_LENGTH;
10669 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10670 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10672 /* This test is for NULL PMD only */
10673 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10674 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10677 /* Setup Cipher Parameters */
10678 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10679 ut_params->cipher_xform.next = &ut_params->auth_xform;
10681 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10682 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10684 /* Setup HMAC Parameters */
10685 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10686 ut_params->auth_xform.next = NULL;
10688 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10689 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10691 ut_params->sess = rte_cryptodev_sym_session_create(
10692 ts_params->session_mpool);
10694 /* Create Crypto session*/
10695 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10696 ut_params->sess, &ut_params->cipher_xform,
10697 ts_params->session_priv_mpool);
10698 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10700 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10701 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10702 burst_len, "failed to generate burst of crypto ops");
10704 /* Generate an operation for each mbuf in burst */
10705 for (i = 0; i < burst_len; i++) {
10706 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10708 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10710 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10714 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10716 burst[i]->sym->m_src = m;
10719 /* Process crypto operation */
10720 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10721 0, burst, burst_len),
10723 "Error enqueuing burst");
10725 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10726 0, burst_dequeued, burst_len),
10728 "Error dequeuing burst");
10731 for (i = 0; i < burst_len; i++) {
10733 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10734 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10736 "data not as expected");
10738 rte_pktmbuf_free(burst[i]->sym->m_src);
10739 rte_crypto_op_free(burst[i]);
10742 return TEST_SUCCESS;
10746 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10747 uint16_t nb_ops, void *user_param)
10749 RTE_SET_USED(dev_id);
10750 RTE_SET_USED(qp_id);
10752 RTE_SET_USED(user_param);
10754 printf("crypto enqueue callback called\n");
10759 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10760 uint16_t nb_ops, void *user_param)
10762 RTE_SET_USED(dev_id);
10763 RTE_SET_USED(qp_id);
10765 RTE_SET_USED(user_param);
10767 printf("crypto dequeue callback called\n");
10772 * Thread using enqueue/dequeue callback with RCU.
10775 test_enqdeq_callback_thread(void *arg)
10778 /* DP thread calls rte_cryptodev_enqueue_burst()/
10779 * rte_cryptodev_dequeue_burst() and invokes callback.
10781 test_null_burst_operation();
10786 test_enq_callback_setup(void)
10788 struct crypto_testsuite_params *ts_params = &testsuite_params;
10789 struct rte_cryptodev_info dev_info;
10790 struct rte_cryptodev_qp_conf qp_conf = {
10791 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10794 struct rte_cryptodev_cb *cb;
10795 uint16_t qp_id = 0;
10797 /* Stop the device in case it's started so it can be configured */
10798 rte_cryptodev_stop(ts_params->valid_devs[0]);
10800 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10802 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10804 "Failed to configure cryptodev %u",
10805 ts_params->valid_devs[0]);
10807 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10808 qp_conf.mp_session = ts_params->session_mpool;
10809 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10811 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10812 ts_params->valid_devs[0], qp_id, &qp_conf,
10813 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10815 "rte_cryptodev_queue_pair_setup: num_inflights "
10816 "%u on qp %u on cryptodev %u",
10817 qp_conf.nb_descriptors, qp_id,
10818 ts_params->valid_devs[0]);
10820 /* Test with invalid crypto device */
10821 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
10822 qp_id, test_enq_callback, NULL);
10823 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10824 "cryptodev %u did not fail",
10825 qp_id, RTE_CRYPTO_MAX_DEVS);
10827 /* Test with invalid queue pair */
10828 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10829 dev_info.max_nb_queue_pairs + 1,
10830 test_enq_callback, NULL);
10831 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10832 "cryptodev %u did not fail",
10833 dev_info.max_nb_queue_pairs + 1,
10834 ts_params->valid_devs[0]);
10836 /* Test with NULL callback */
10837 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10838 qp_id, NULL, NULL);
10839 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10840 "cryptodev %u did not fail",
10841 qp_id, ts_params->valid_devs[0]);
10843 /* Test with valid configuration */
10844 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10845 qp_id, test_enq_callback, NULL);
10846 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10847 "qp %u on cryptodev %u",
10848 qp_id, ts_params->valid_devs[0]);
10850 rte_cryptodev_start(ts_params->valid_devs[0]);
10852 /* Launch a thread */
10853 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10854 rte_get_next_lcore(-1, 1, 0));
10856 /* Wait until reader exited. */
10857 rte_eal_mp_wait_lcore();
10859 /* Test with invalid crypto device */
10860 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10861 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10862 "Expected call to fail as crypto device is invalid");
10864 /* Test with invalid queue pair */
10865 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10866 ts_params->valid_devs[0],
10867 dev_info.max_nb_queue_pairs + 1, cb),
10868 "Expected call to fail as queue pair is invalid");
10870 /* Test with NULL callback */
10871 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10872 ts_params->valid_devs[0], qp_id, NULL),
10873 "Expected call to fail as callback is NULL");
10875 /* Test with valid configuration */
10876 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
10877 ts_params->valid_devs[0], qp_id, cb),
10878 "Failed test to remove callback on "
10879 "qp %u on cryptodev %u",
10880 qp_id, ts_params->valid_devs[0]);
10882 return TEST_SUCCESS;
10886 test_deq_callback_setup(void)
10888 struct crypto_testsuite_params *ts_params = &testsuite_params;
10889 struct rte_cryptodev_info dev_info;
10890 struct rte_cryptodev_qp_conf qp_conf = {
10891 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10894 struct rte_cryptodev_cb *cb;
10895 uint16_t qp_id = 0;
10897 /* Stop the device in case it's started so it can be configured */
10898 rte_cryptodev_stop(ts_params->valid_devs[0]);
10900 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10902 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10904 "Failed to configure cryptodev %u",
10905 ts_params->valid_devs[0]);
10907 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10908 qp_conf.mp_session = ts_params->session_mpool;
10909 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10911 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10912 ts_params->valid_devs[0], qp_id, &qp_conf,
10913 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10915 "rte_cryptodev_queue_pair_setup: num_inflights "
10916 "%u on qp %u on cryptodev %u",
10917 qp_conf.nb_descriptors, qp_id,
10918 ts_params->valid_devs[0]);
10920 /* Test with invalid crypto device */
10921 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
10922 qp_id, test_deq_callback, NULL);
10923 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10924 "cryptodev %u did not fail",
10925 qp_id, RTE_CRYPTO_MAX_DEVS);
10927 /* Test with invalid queue pair */
10928 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10929 dev_info.max_nb_queue_pairs + 1,
10930 test_deq_callback, NULL);
10931 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10932 "cryptodev %u did not fail",
10933 dev_info.max_nb_queue_pairs + 1,
10934 ts_params->valid_devs[0]);
10936 /* Test with NULL callback */
10937 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10938 qp_id, NULL, NULL);
10939 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10940 "cryptodev %u did not fail",
10941 qp_id, ts_params->valid_devs[0]);
10943 /* Test with valid configuration */
10944 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10945 qp_id, test_deq_callback, NULL);
10946 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10947 "qp %u on cryptodev %u",
10948 qp_id, ts_params->valid_devs[0]);
10950 rte_cryptodev_start(ts_params->valid_devs[0]);
10952 /* Launch a thread */
10953 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10954 rte_get_next_lcore(-1, 1, 0));
10956 /* Wait until reader exited. */
10957 rte_eal_mp_wait_lcore();
10959 /* Test with invalid crypto device */
10960 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10961 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10962 "Expected call to fail as crypto device is invalid");
10964 /* Test with invalid queue pair */
10965 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10966 ts_params->valid_devs[0],
10967 dev_info.max_nb_queue_pairs + 1, cb),
10968 "Expected call to fail as queue pair is invalid");
10970 /* Test with NULL callback */
10971 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10972 ts_params->valid_devs[0], qp_id, NULL),
10973 "Expected call to fail as callback is NULL");
10975 /* Test with valid configuration */
10976 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
10977 ts_params->valid_devs[0], qp_id, cb),
10978 "Failed test to remove callback on "
10979 "qp %u on cryptodev %u",
10980 qp_id, ts_params->valid_devs[0]);
10982 return TEST_SUCCESS;
10986 generate_gmac_large_plaintext(uint8_t *data)
10990 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10991 memcpy(&data[i], &data[0], 32);
10995 create_gmac_operation(enum rte_crypto_auth_operation op,
10996 const struct gmac_test_data *tdata)
10998 struct crypto_testsuite_params *ts_params = &testsuite_params;
10999 struct crypto_unittest_params *ut_params = &unittest_params;
11000 struct rte_crypto_sym_op *sym_op;
11002 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11004 /* Generate Crypto op data structure */
11005 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11006 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11007 TEST_ASSERT_NOT_NULL(ut_params->op,
11008 "Failed to allocate symmetric crypto operation struct");
11010 sym_op = ut_params->op->sym;
11012 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11013 ut_params->ibuf, tdata->gmac_tag.len);
11014 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11015 "no room to append digest");
11017 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11018 ut_params->ibuf, plaintext_pad_len);
11020 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11021 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11022 tdata->gmac_tag.len);
11023 debug_hexdump(stdout, "digest:",
11024 sym_op->auth.digest.data,
11025 tdata->gmac_tag.len);
11028 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11029 uint8_t *, IV_OFFSET);
11031 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11033 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11035 sym_op->cipher.data.length = 0;
11036 sym_op->cipher.data.offset = 0;
11038 sym_op->auth.data.offset = 0;
11039 sym_op->auth.data.length = tdata->plaintext.len;
11045 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11046 const struct gmac_test_data *tdata,
11047 void *digest_mem, uint64_t digest_phys)
11049 struct crypto_testsuite_params *ts_params = &testsuite_params;
11050 struct crypto_unittest_params *ut_params = &unittest_params;
11051 struct rte_crypto_sym_op *sym_op;
11053 /* Generate Crypto op data structure */
11054 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11055 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11056 TEST_ASSERT_NOT_NULL(ut_params->op,
11057 "Failed to allocate symmetric crypto operation struct");
11059 sym_op = ut_params->op->sym;
11061 sym_op->auth.digest.data = digest_mem;
11062 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11063 "no room to append digest");
11065 sym_op->auth.digest.phys_addr = digest_phys;
11067 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11068 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11069 tdata->gmac_tag.len);
11070 debug_hexdump(stdout, "digest:",
11071 sym_op->auth.digest.data,
11072 tdata->gmac_tag.len);
11075 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11076 uint8_t *, IV_OFFSET);
11078 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11080 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11082 sym_op->cipher.data.length = 0;
11083 sym_op->cipher.data.offset = 0;
11085 sym_op->auth.data.offset = 0;
11086 sym_op->auth.data.length = tdata->plaintext.len;
11091 static int create_gmac_session(uint8_t dev_id,
11092 const struct gmac_test_data *tdata,
11093 enum rte_crypto_auth_operation auth_op)
11095 uint8_t auth_key[tdata->key.len];
11097 struct crypto_testsuite_params *ts_params = &testsuite_params;
11098 struct crypto_unittest_params *ut_params = &unittest_params;
11100 memcpy(auth_key, tdata->key.data, tdata->key.len);
11102 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11103 ut_params->auth_xform.next = NULL;
11105 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11106 ut_params->auth_xform.auth.op = auth_op;
11107 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11108 ut_params->auth_xform.auth.key.length = tdata->key.len;
11109 ut_params->auth_xform.auth.key.data = auth_key;
11110 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11111 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11114 ut_params->sess = rte_cryptodev_sym_session_create(
11115 ts_params->session_mpool);
11117 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11118 &ut_params->auth_xform,
11119 ts_params->session_priv_mpool);
11121 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11127 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11129 struct crypto_testsuite_params *ts_params = &testsuite_params;
11130 struct crypto_unittest_params *ut_params = &unittest_params;
11131 struct rte_cryptodev_info dev_info;
11133 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11134 uint64_t feat_flags = dev_info.feature_flags;
11136 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11137 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11138 printf("Device doesn't support RAW data-path APIs.\n");
11144 uint8_t *auth_tag, *plaintext;
11145 uint16_t plaintext_pad_len;
11147 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11148 "No GMAC length in the source data");
11150 /* Verify the capabilities */
11151 struct rte_cryptodev_sym_capability_idx cap_idx;
11152 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11153 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11154 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11158 retval = create_gmac_session(ts_params->valid_devs[0],
11159 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11164 if (tdata->plaintext.len > MBUF_SIZE)
11165 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11167 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11168 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11169 "Failed to allocate input buffer in mempool");
11171 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11172 rte_pktmbuf_tailroom(ut_params->ibuf));
11174 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11176 * Runtime generate the large plain text instead of use hard code
11177 * plain text vector. It is done to avoid create huge source file
11178 * with the test vector.
11180 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11181 generate_gmac_large_plaintext(tdata->plaintext.data);
11183 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11184 plaintext_pad_len);
11185 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11187 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11188 debug_hexdump(stdout, "plaintext:", plaintext,
11189 tdata->plaintext.len);
11191 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11197 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11199 ut_params->op->sym->m_src = ut_params->ibuf;
11201 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11202 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11204 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11205 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11206 ut_params->op, 0, 1, 0, 0);
11208 TEST_ASSERT_NOT_NULL(
11209 process_crypto_request(ts_params->valid_devs[0],
11210 ut_params->op), "failed to process sym crypto op");
11212 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11213 "crypto op processing failed");
11215 if (ut_params->op->sym->m_dst) {
11216 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11217 uint8_t *, plaintext_pad_len);
11219 auth_tag = plaintext + plaintext_pad_len;
11222 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11224 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11226 tdata->gmac_tag.data,
11227 tdata->gmac_tag.len,
11228 "GMAC Generated auth tag not as expected");
11234 test_AES_GMAC_authentication_test_case_1(void)
11236 return test_AES_GMAC_authentication(&gmac_test_case_1);
11240 test_AES_GMAC_authentication_test_case_2(void)
11242 return test_AES_GMAC_authentication(&gmac_test_case_2);
11246 test_AES_GMAC_authentication_test_case_3(void)
11248 return test_AES_GMAC_authentication(&gmac_test_case_3);
11252 test_AES_GMAC_authentication_test_case_4(void)
11254 return test_AES_GMAC_authentication(&gmac_test_case_4);
11258 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11260 struct crypto_testsuite_params *ts_params = &testsuite_params;
11261 struct crypto_unittest_params *ut_params = &unittest_params;
11263 uint32_t plaintext_pad_len;
11264 uint8_t *plaintext;
11265 struct rte_cryptodev_info dev_info;
11267 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11268 uint64_t feat_flags = dev_info.feature_flags;
11270 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11271 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11272 printf("Device doesn't support RAW data-path APIs.\n");
11276 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11277 "No GMAC length in the source data");
11279 /* Verify the capabilities */
11280 struct rte_cryptodev_sym_capability_idx cap_idx;
11281 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11282 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11283 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11287 retval = create_gmac_session(ts_params->valid_devs[0],
11288 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11293 if (tdata->plaintext.len > MBUF_SIZE)
11294 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11296 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11297 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11298 "Failed to allocate input buffer in mempool");
11300 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11301 rte_pktmbuf_tailroom(ut_params->ibuf));
11303 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11306 * Runtime generate the large plain text instead of use hard code
11307 * plain text vector. It is done to avoid create huge source file
11308 * with the test vector.
11310 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11311 generate_gmac_large_plaintext(tdata->plaintext.data);
11313 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11314 plaintext_pad_len);
11315 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11317 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11318 debug_hexdump(stdout, "plaintext:", plaintext,
11319 tdata->plaintext.len);
11321 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11327 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11329 ut_params->op->sym->m_src = ut_params->ibuf;
11331 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11332 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11334 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11335 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11336 ut_params->op, 0, 1, 0, 0);
11338 TEST_ASSERT_NOT_NULL(
11339 process_crypto_request(ts_params->valid_devs[0],
11340 ut_params->op), "failed to process sym crypto op");
11342 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11343 "crypto op processing failed");
11350 test_AES_GMAC_authentication_verify_test_case_1(void)
11352 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11356 test_AES_GMAC_authentication_verify_test_case_2(void)
11358 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11362 test_AES_GMAC_authentication_verify_test_case_3(void)
11364 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11368 test_AES_GMAC_authentication_verify_test_case_4(void)
11370 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11374 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11377 struct crypto_testsuite_params *ts_params = &testsuite_params;
11378 struct crypto_unittest_params *ut_params = &unittest_params;
11379 struct rte_cryptodev_info dev_info;
11380 uint64_t feature_flags;
11381 unsigned int trn_data = 0;
11382 void *digest_mem = NULL;
11384 unsigned int to_trn = 0;
11385 struct rte_mbuf *buf = NULL;
11386 uint8_t *auth_tag, *plaintext;
11389 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11390 "No GMAC length in the source data");
11392 /* Verify the capabilities */
11393 struct rte_cryptodev_sym_capability_idx cap_idx;
11394 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11395 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11396 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11400 /* Check for any input SGL support */
11401 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11402 feature_flags = dev_info.feature_flags;
11404 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11405 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11406 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11409 if (fragsz > tdata->plaintext.len)
11410 fragsz = tdata->plaintext.len;
11412 uint16_t plaintext_len = fragsz;
11414 retval = create_gmac_session(ts_params->valid_devs[0],
11415 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11420 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11421 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11422 "Failed to allocate input buffer in mempool");
11424 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11425 rte_pktmbuf_tailroom(ut_params->ibuf));
11427 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11429 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11431 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11433 trn_data += plaintext_len;
11435 buf = ut_params->ibuf;
11438 * Loop until no more fragments
11441 while (trn_data < tdata->plaintext.len) {
11443 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11444 (tdata->plaintext.len - trn_data) : fragsz;
11446 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11449 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11450 rte_pktmbuf_tailroom(buf));
11452 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11455 memcpy(plaintext, tdata->plaintext.data + trn_data,
11457 trn_data += to_trn;
11458 if (trn_data == tdata->plaintext.len)
11459 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11460 tdata->gmac_tag.len);
11462 ut_params->ibuf->nb_segs = segs;
11465 * Place digest at the end of the last buffer
11467 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11470 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11471 + tdata->gmac_tag.len);
11472 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11473 tdata->plaintext.len);
11476 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11477 tdata, digest_mem, digest_phys);
11482 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11484 ut_params->op->sym->m_src = ut_params->ibuf;
11486 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11489 TEST_ASSERT_NOT_NULL(
11490 process_crypto_request(ts_params->valid_devs[0],
11491 ut_params->op), "failed to process sym crypto op");
11493 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11494 "crypto op processing failed");
11496 auth_tag = digest_mem;
11497 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11498 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11500 tdata->gmac_tag.data,
11501 tdata->gmac_tag.len,
11502 "GMAC Generated auth tag not as expected");
11507 /* Segment size not multiple of block size (16B) */
11509 test_AES_GMAC_authentication_SGL_40B(void)
11511 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11515 test_AES_GMAC_authentication_SGL_80B(void)
11517 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11521 test_AES_GMAC_authentication_SGL_2048B(void)
11523 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11526 /* Segment size not multiple of block size (16B) */
11528 test_AES_GMAC_authentication_SGL_2047B(void)
11530 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11533 struct test_crypto_vector {
11534 enum rte_crypto_cipher_algorithm crypto_algo;
11535 unsigned int cipher_offset;
11536 unsigned int cipher_len;
11549 const uint8_t *data;
11554 const uint8_t *data;
11558 enum rte_crypto_auth_algorithm auth_algo;
11559 unsigned int auth_offset;
11567 const uint8_t *data;
11577 static const struct test_crypto_vector
11578 hmac_sha1_test_crypto_vector = {
11579 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11581 .data = plaintext_hash,
11586 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11587 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11588 0xDE, 0xF4, 0xDE, 0xAD
11594 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11595 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11596 0x3F, 0x91, 0x64, 0x59
11602 static const struct test_crypto_vector
11603 aes128_gmac_test_vector = {
11604 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11606 .data = plaintext_hash,
11611 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11612 0x08, 0x09, 0x0A, 0x0B
11618 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11619 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11625 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11626 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11632 static const struct test_crypto_vector
11633 aes128cbc_hmac_sha1_test_vector = {
11634 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11635 .cipher_offset = 0,
11639 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11640 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11646 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11647 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11652 .data = plaintext_hash,
11656 .data = ciphertext512_aes128cbc,
11659 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11663 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11664 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11665 0xDE, 0xF4, 0xDE, 0xAD
11671 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
11672 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11673 0x18, 0x8C, 0x1D, 0x32
11679 static const struct test_crypto_vector
11680 aes128cbc_hmac_sha1_aad_test_vector = {
11681 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11682 .cipher_offset = 8,
11686 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11687 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11693 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11694 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11699 .data = plaintext_hash,
11703 .data = ciphertext512_aes128cbc_aad,
11706 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11710 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11711 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11712 0xDE, 0xF4, 0xDE, 0xAD
11718 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
11719 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
11720 0x62, 0x0F, 0xFB, 0x10
11727 data_corruption(uint8_t *data)
11733 tag_corruption(uint8_t *data, unsigned int tag_offset)
11735 data[tag_offset] += 1;
11739 create_auth_session(struct crypto_unittest_params *ut_params,
11741 const struct test_crypto_vector *reference,
11742 enum rte_crypto_auth_operation auth_op)
11744 struct crypto_testsuite_params *ts_params = &testsuite_params;
11745 uint8_t auth_key[reference->auth_key.len + 1];
11747 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11749 /* Setup Authentication Parameters */
11750 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11751 ut_params->auth_xform.auth.op = auth_op;
11752 ut_params->auth_xform.next = NULL;
11753 ut_params->auth_xform.auth.algo = reference->auth_algo;
11754 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11755 ut_params->auth_xform.auth.key.data = auth_key;
11756 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11758 /* Create Crypto session*/
11759 ut_params->sess = rte_cryptodev_sym_session_create(
11760 ts_params->session_mpool);
11762 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11763 &ut_params->auth_xform,
11764 ts_params->session_priv_mpool);
11766 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11772 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
11774 const struct test_crypto_vector *reference,
11775 enum rte_crypto_auth_operation auth_op,
11776 enum rte_crypto_cipher_operation cipher_op)
11778 struct crypto_testsuite_params *ts_params = &testsuite_params;
11779 uint8_t cipher_key[reference->cipher_key.len + 1];
11780 uint8_t auth_key[reference->auth_key.len + 1];
11782 memcpy(cipher_key, reference->cipher_key.data,
11783 reference->cipher_key.len);
11784 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11786 /* Setup Authentication Parameters */
11787 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11788 ut_params->auth_xform.auth.op = auth_op;
11789 ut_params->auth_xform.auth.algo = reference->auth_algo;
11790 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11791 ut_params->auth_xform.auth.key.data = auth_key;
11792 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11794 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
11795 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11796 ut_params->auth_xform.auth.iv.length = reference->iv.len;
11798 ut_params->auth_xform.next = &ut_params->cipher_xform;
11800 /* Setup Cipher Parameters */
11801 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11802 ut_params->cipher_xform.next = NULL;
11803 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11804 ut_params->cipher_xform.cipher.op = cipher_op;
11805 ut_params->cipher_xform.cipher.key.data = cipher_key;
11806 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11807 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11808 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11811 /* Create Crypto session*/
11812 ut_params->sess = rte_cryptodev_sym_session_create(
11813 ts_params->session_mpool);
11815 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11816 &ut_params->auth_xform,
11817 ts_params->session_priv_mpool);
11819 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11825 create_auth_operation(struct crypto_testsuite_params *ts_params,
11826 struct crypto_unittest_params *ut_params,
11827 const struct test_crypto_vector *reference,
11828 unsigned int auth_generate)
11830 /* Generate Crypto op data structure */
11831 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11832 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11833 TEST_ASSERT_NOT_NULL(ut_params->op,
11834 "Failed to allocate pktmbuf offload");
11836 /* Set crypto operation data parameters */
11837 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11839 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11841 /* set crypto operation source mbuf */
11842 sym_op->m_src = ut_params->ibuf;
11845 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11846 ut_params->ibuf, reference->digest.len);
11848 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11849 "no room to append auth tag");
11851 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11852 ut_params->ibuf, reference->plaintext.len);
11855 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11857 memcpy(sym_op->auth.digest.data,
11858 reference->digest.data,
11859 reference->digest.len);
11861 debug_hexdump(stdout, "digest:",
11862 sym_op->auth.digest.data,
11863 reference->digest.len);
11865 sym_op->auth.data.length = reference->plaintext.len;
11866 sym_op->auth.data.offset = 0;
11872 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
11873 struct crypto_unittest_params *ut_params,
11874 const struct test_crypto_vector *reference,
11875 unsigned int auth_generate)
11877 /* Generate Crypto op data structure */
11878 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11879 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11880 TEST_ASSERT_NOT_NULL(ut_params->op,
11881 "Failed to allocate pktmbuf offload");
11883 /* Set crypto operation data parameters */
11884 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11886 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11888 /* set crypto operation source mbuf */
11889 sym_op->m_src = ut_params->ibuf;
11892 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11893 ut_params->ibuf, reference->digest.len);
11895 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11896 "no room to append auth tag");
11898 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11899 ut_params->ibuf, reference->ciphertext.len);
11902 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11904 memcpy(sym_op->auth.digest.data,
11905 reference->digest.data,
11906 reference->digest.len);
11908 debug_hexdump(stdout, "digest:",
11909 sym_op->auth.digest.data,
11910 reference->digest.len);
11912 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11913 reference->iv.data, reference->iv.len);
11915 sym_op->cipher.data.length = 0;
11916 sym_op->cipher.data.offset = 0;
11918 sym_op->auth.data.length = reference->plaintext.len;
11919 sym_op->auth.data.offset = 0;
11925 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11926 struct crypto_unittest_params *ut_params,
11927 const struct test_crypto_vector *reference,
11928 unsigned int auth_generate)
11930 /* Generate Crypto op data structure */
11931 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11932 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11933 TEST_ASSERT_NOT_NULL(ut_params->op,
11934 "Failed to allocate pktmbuf offload");
11936 /* Set crypto operation data parameters */
11937 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11939 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11941 /* set crypto operation source mbuf */
11942 sym_op->m_src = ut_params->ibuf;
11945 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11946 ut_params->ibuf, reference->digest.len);
11948 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11949 "no room to append auth tag");
11951 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11952 ut_params->ibuf, reference->ciphertext.len);
11955 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11957 memcpy(sym_op->auth.digest.data,
11958 reference->digest.data,
11959 reference->digest.len);
11961 debug_hexdump(stdout, "digest:",
11962 sym_op->auth.digest.data,
11963 reference->digest.len);
11965 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11966 reference->iv.data, reference->iv.len);
11968 sym_op->cipher.data.length = reference->cipher_len;
11969 sym_op->cipher.data.offset = reference->cipher_offset;
11971 sym_op->auth.data.length = reference->plaintext.len;
11972 sym_op->auth.data.offset = reference->auth_offset;
11978 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11979 struct crypto_unittest_params *ut_params,
11980 const struct test_crypto_vector *reference)
11982 return create_auth_operation(ts_params, ut_params, reference, 0);
11986 create_auth_verify_GMAC_operation(
11987 struct crypto_testsuite_params *ts_params,
11988 struct crypto_unittest_params *ut_params,
11989 const struct test_crypto_vector *reference)
11991 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11995 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11996 struct crypto_unittest_params *ut_params,
11997 const struct test_crypto_vector *reference)
11999 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12003 test_authentication_verify_fail_when_data_corruption(
12004 struct crypto_testsuite_params *ts_params,
12005 struct crypto_unittest_params *ut_params,
12006 const struct test_crypto_vector *reference,
12007 unsigned int data_corrupted)
12011 uint8_t *plaintext;
12012 struct rte_cryptodev_info dev_info;
12014 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12015 uint64_t feat_flags = dev_info.feature_flags;
12017 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12018 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12019 printf("Device doesn't support RAW data-path APIs.\n");
12023 /* Verify the capabilities */
12024 struct rte_cryptodev_sym_capability_idx cap_idx;
12025 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12026 cap_idx.algo.auth = reference->auth_algo;
12027 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12032 /* Create session */
12033 retval = create_auth_session(ut_params,
12034 ts_params->valid_devs[0],
12036 RTE_CRYPTO_AUTH_OP_VERIFY);
12040 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12041 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12042 "Failed to allocate input buffer in mempool");
12044 /* clear mbuf payload */
12045 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12046 rte_pktmbuf_tailroom(ut_params->ibuf));
12048 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12049 reference->plaintext.len);
12050 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12051 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12053 debug_hexdump(stdout, "plaintext:", plaintext,
12054 reference->plaintext.len);
12056 /* Create operation */
12057 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12062 if (data_corrupted)
12063 data_corruption(plaintext);
12065 tag_corruption(plaintext, reference->plaintext.len);
12067 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12068 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12070 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12071 RTE_CRYPTO_OP_STATUS_SUCCESS,
12072 "authentication not failed");
12073 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12074 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12075 ut_params->op, 0, 1, 0, 0);
12077 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12079 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12086 test_authentication_verify_GMAC_fail_when_corruption(
12087 struct crypto_testsuite_params *ts_params,
12088 struct crypto_unittest_params *ut_params,
12089 const struct test_crypto_vector *reference,
12090 unsigned int data_corrupted)
12093 uint8_t *plaintext;
12094 struct rte_cryptodev_info dev_info;
12096 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12097 uint64_t feat_flags = dev_info.feature_flags;
12099 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12100 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12101 printf("Device doesn't support RAW data-path APIs.\n");
12105 /* Verify the capabilities */
12106 struct rte_cryptodev_sym_capability_idx cap_idx;
12107 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12108 cap_idx.algo.auth = reference->auth_algo;
12109 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12113 /* Create session */
12114 retval = create_auth_cipher_session(ut_params,
12115 ts_params->valid_devs[0],
12117 RTE_CRYPTO_AUTH_OP_VERIFY,
12118 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12122 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12123 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12124 "Failed to allocate input buffer in mempool");
12126 /* clear mbuf payload */
12127 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12128 rte_pktmbuf_tailroom(ut_params->ibuf));
12130 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12131 reference->plaintext.len);
12132 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12133 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12135 debug_hexdump(stdout, "plaintext:", plaintext,
12136 reference->plaintext.len);
12138 /* Create operation */
12139 retval = create_auth_verify_GMAC_operation(ts_params,
12146 if (data_corrupted)
12147 data_corruption(plaintext);
12149 tag_corruption(plaintext, reference->aad.len);
12151 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12152 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12154 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12155 RTE_CRYPTO_OP_STATUS_SUCCESS,
12156 "authentication not failed");
12157 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12158 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12159 ut_params->op, 0, 1, 0, 0);
12161 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12163 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12170 test_authenticated_decryption_fail_when_corruption(
12171 struct crypto_testsuite_params *ts_params,
12172 struct crypto_unittest_params *ut_params,
12173 const struct test_crypto_vector *reference,
12174 unsigned int data_corrupted)
12178 uint8_t *ciphertext;
12179 struct rte_cryptodev_info dev_info;
12181 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12182 uint64_t feat_flags = dev_info.feature_flags;
12184 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12185 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12186 printf("Device doesn't support RAW data-path APIs.\n");
12190 /* Verify the capabilities */
12191 struct rte_cryptodev_sym_capability_idx cap_idx;
12192 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12193 cap_idx.algo.auth = reference->auth_algo;
12194 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12197 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12198 cap_idx.algo.cipher = reference->crypto_algo;
12199 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12203 /* Create session */
12204 retval = create_auth_cipher_session(ut_params,
12205 ts_params->valid_devs[0],
12207 RTE_CRYPTO_AUTH_OP_VERIFY,
12208 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12212 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12213 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12214 "Failed to allocate input buffer in mempool");
12216 /* clear mbuf payload */
12217 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12218 rte_pktmbuf_tailroom(ut_params->ibuf));
12220 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12221 reference->ciphertext.len);
12222 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12223 memcpy(ciphertext, reference->ciphertext.data,
12224 reference->ciphertext.len);
12226 /* Create operation */
12227 retval = create_cipher_auth_verify_operation(ts_params,
12234 if (data_corrupted)
12235 data_corruption(ciphertext);
12237 tag_corruption(ciphertext, reference->ciphertext.len);
12239 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12240 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12242 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12243 RTE_CRYPTO_OP_STATUS_SUCCESS,
12244 "authentication not failed");
12245 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12246 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12247 ut_params->op, 1, 1, 0, 0);
12249 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12251 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12258 test_authenticated_encryt_with_esn(
12259 struct crypto_testsuite_params *ts_params,
12260 struct crypto_unittest_params *ut_params,
12261 const struct test_crypto_vector *reference)
12265 uint8_t *authciphertext, *plaintext, *auth_tag;
12266 uint16_t plaintext_pad_len;
12267 uint8_t cipher_key[reference->cipher_key.len + 1];
12268 uint8_t auth_key[reference->auth_key.len + 1];
12269 struct rte_cryptodev_info dev_info;
12271 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12272 uint64_t feat_flags = dev_info.feature_flags;
12274 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12275 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12276 printf("Device doesn't support RAW data-path APIs.\n");
12280 /* Verify the capabilities */
12281 struct rte_cryptodev_sym_capability_idx cap_idx;
12282 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12283 cap_idx.algo.auth = reference->auth_algo;
12284 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12287 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12288 cap_idx.algo.cipher = reference->crypto_algo;
12289 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12293 /* Create session */
12294 memcpy(cipher_key, reference->cipher_key.data,
12295 reference->cipher_key.len);
12296 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12298 /* Setup Cipher Parameters */
12299 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12300 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12301 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12302 ut_params->cipher_xform.cipher.key.data = cipher_key;
12303 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12304 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12305 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12307 ut_params->cipher_xform.next = &ut_params->auth_xform;
12309 /* Setup Authentication Parameters */
12310 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12311 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12312 ut_params->auth_xform.auth.algo = reference->auth_algo;
12313 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12314 ut_params->auth_xform.auth.key.data = auth_key;
12315 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12316 ut_params->auth_xform.next = NULL;
12318 /* Create Crypto session*/
12319 ut_params->sess = rte_cryptodev_sym_session_create(
12320 ts_params->session_mpool);
12322 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12324 &ut_params->cipher_xform,
12325 ts_params->session_priv_mpool);
12327 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12330 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12331 "Failed to allocate input buffer in mempool");
12333 /* clear mbuf payload */
12334 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12335 rte_pktmbuf_tailroom(ut_params->ibuf));
12337 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12338 reference->plaintext.len);
12339 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12340 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12342 /* Create operation */
12343 retval = create_cipher_auth_operation(ts_params,
12350 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12351 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12353 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12354 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12355 ut_params->op, 1, 1, 0, 0);
12357 ut_params->op = process_crypto_request(
12358 ts_params->valid_devs[0], ut_params->op);
12360 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12362 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12363 "crypto op processing failed");
12365 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12367 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12368 ut_params->op->sym->auth.data.offset);
12369 auth_tag = authciphertext + plaintext_pad_len;
12370 debug_hexdump(stdout, "ciphertext:", authciphertext,
12371 reference->ciphertext.len);
12372 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12374 /* Validate obuf */
12375 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12377 reference->ciphertext.data,
12378 reference->ciphertext.len,
12379 "Ciphertext data not as expected");
12381 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12383 reference->digest.data,
12384 reference->digest.len,
12385 "Generated digest not as expected");
12387 return TEST_SUCCESS;
12392 test_authenticated_decrypt_with_esn(
12393 struct crypto_testsuite_params *ts_params,
12394 struct crypto_unittest_params *ut_params,
12395 const struct test_crypto_vector *reference)
12399 uint8_t *ciphertext;
12400 uint8_t cipher_key[reference->cipher_key.len + 1];
12401 uint8_t auth_key[reference->auth_key.len + 1];
12402 struct rte_cryptodev_info dev_info;
12404 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12405 uint64_t feat_flags = dev_info.feature_flags;
12407 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12408 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12409 printf("Device doesn't support RAW data-path APIs.\n");
12413 /* Verify the capabilities */
12414 struct rte_cryptodev_sym_capability_idx cap_idx;
12415 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12416 cap_idx.algo.auth = reference->auth_algo;
12417 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12420 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12421 cap_idx.algo.cipher = reference->crypto_algo;
12422 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12426 /* Create session */
12427 memcpy(cipher_key, reference->cipher_key.data,
12428 reference->cipher_key.len);
12429 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12431 /* Setup Authentication Parameters */
12432 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12433 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12434 ut_params->auth_xform.auth.algo = reference->auth_algo;
12435 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12436 ut_params->auth_xform.auth.key.data = auth_key;
12437 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12438 ut_params->auth_xform.next = &ut_params->cipher_xform;
12440 /* Setup Cipher Parameters */
12441 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12442 ut_params->cipher_xform.next = NULL;
12443 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12444 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12445 ut_params->cipher_xform.cipher.key.data = cipher_key;
12446 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12447 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12448 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12450 /* Create Crypto session*/
12451 ut_params->sess = rte_cryptodev_sym_session_create(
12452 ts_params->session_mpool);
12454 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12456 &ut_params->auth_xform,
12457 ts_params->session_priv_mpool);
12459 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12461 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12462 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12463 "Failed to allocate input buffer in mempool");
12465 /* clear mbuf payload */
12466 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12467 rte_pktmbuf_tailroom(ut_params->ibuf));
12469 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12470 reference->ciphertext.len);
12471 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12472 memcpy(ciphertext, reference->ciphertext.data,
12473 reference->ciphertext.len);
12475 /* Create operation */
12476 retval = create_cipher_auth_verify_operation(ts_params,
12483 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12484 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12486 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12487 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12488 ut_params->op, 1, 1, 0, 0);
12490 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12493 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12494 TEST_ASSERT_EQUAL(ut_params->op->status,
12495 RTE_CRYPTO_OP_STATUS_SUCCESS,
12496 "crypto op processing passed");
12498 ut_params->obuf = ut_params->op->sym->m_src;
12499 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12505 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12506 const struct aead_test_data *tdata,
12507 void *digest_mem, uint64_t digest_phys)
12509 struct crypto_testsuite_params *ts_params = &testsuite_params;
12510 struct crypto_unittest_params *ut_params = &unittest_params;
12512 const unsigned int auth_tag_len = tdata->auth_tag.len;
12513 const unsigned int iv_len = tdata->iv.len;
12514 unsigned int aad_len = tdata->aad.len;
12515 unsigned int aad_len_pad = 0;
12517 /* Generate Crypto op data structure */
12518 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12519 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12520 TEST_ASSERT_NOT_NULL(ut_params->op,
12521 "Failed to allocate symmetric crypto operation struct");
12523 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12525 sym_op->aead.digest.data = digest_mem;
12527 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12528 "no room to append digest");
12530 sym_op->aead.digest.phys_addr = digest_phys;
12532 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12533 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12535 debug_hexdump(stdout, "digest:",
12536 sym_op->aead.digest.data,
12540 /* Append aad data */
12541 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12542 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12543 uint8_t *, IV_OFFSET);
12545 /* Copy IV 1 byte after the IV pointer, according to the API */
12546 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12548 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12550 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12551 ut_params->ibuf, aad_len);
12552 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12553 "no room to prepend aad");
12554 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12557 memset(sym_op->aead.aad.data, 0, aad_len);
12558 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12559 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12561 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12562 debug_hexdump(stdout, "aad:",
12563 sym_op->aead.aad.data, aad_len);
12565 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12566 uint8_t *, IV_OFFSET);
12568 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12570 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12572 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12573 ut_params->ibuf, aad_len_pad);
12574 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12575 "no room to prepend aad");
12576 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12579 memset(sym_op->aead.aad.data, 0, aad_len);
12580 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12582 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12583 debug_hexdump(stdout, "aad:",
12584 sym_op->aead.aad.data, aad_len);
12587 sym_op->aead.data.length = tdata->plaintext.len;
12588 sym_op->aead.data.offset = aad_len_pad;
12593 #define SGL_MAX_NO 16
12596 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12597 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12599 struct crypto_testsuite_params *ts_params = &testsuite_params;
12600 struct crypto_unittest_params *ut_params = &unittest_params;
12601 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12604 int to_trn_tbl[SGL_MAX_NO];
12606 unsigned int trn_data = 0;
12607 uint8_t *plaintext, *ciphertext, *auth_tag;
12608 struct rte_cryptodev_info dev_info;
12610 /* Verify the capabilities */
12611 struct rte_cryptodev_sym_capability_idx cap_idx;
12612 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12613 cap_idx.algo.aead = tdata->algo;
12614 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12618 /* OOP not supported with CPU crypto */
12619 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12622 /* Detailed check for the particular SGL support flag */
12623 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12625 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12626 if (sgl_in && (!(dev_info.feature_flags &
12627 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12630 uint64_t feat_flags = dev_info.feature_flags;
12632 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12633 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12634 printf("Device doesn't support RAW data-path APIs.\n");
12638 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12639 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12640 tdata->plaintext.len;
12641 /* Raw data path API does not support OOP */
12642 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12644 if (sgl_in && !sgl_out) {
12645 if (!(dev_info.feature_flags &
12646 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12648 } else if (!sgl_in && sgl_out) {
12649 if (!(dev_info.feature_flags &
12650 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12652 } else if (sgl_in && sgl_out) {
12653 if (!(dev_info.feature_flags &
12654 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12659 if (fragsz > tdata->plaintext.len)
12660 fragsz = tdata->plaintext.len;
12662 uint16_t plaintext_len = fragsz;
12663 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
12665 if (fragsz_oop > tdata->plaintext.len)
12666 frag_size_oop = tdata->plaintext.len;
12669 void *digest_mem = NULL;
12671 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
12673 if (tdata->plaintext.len % fragsz != 0) {
12674 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
12677 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
12682 * For out-op-place we need to alloc another mbuf
12685 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12686 rte_pktmbuf_append(ut_params->obuf,
12687 frag_size_oop + prepend_len);
12688 buf_oop = ut_params->obuf;
12691 /* Create AEAD session */
12692 retval = create_aead_session(ts_params->valid_devs[0],
12694 RTE_CRYPTO_AEAD_OP_ENCRYPT,
12695 tdata->key.data, tdata->key.len,
12696 tdata->aad.len, tdata->auth_tag.len,
12701 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12703 /* clear mbuf payload */
12704 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12705 rte_pktmbuf_tailroom(ut_params->ibuf));
12707 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12710 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12712 trn_data += plaintext_len;
12714 buf = ut_params->ibuf;
12717 * Loop until no more fragments
12720 while (trn_data < tdata->plaintext.len) {
12722 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12723 (tdata->plaintext.len - trn_data) : fragsz;
12725 to_trn_tbl[ecx++] = to_trn;
12727 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12730 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12731 rte_pktmbuf_tailroom(buf));
12734 if (oop && !fragsz_oop) {
12735 buf_last_oop = buf_oop->next =
12736 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12737 buf_oop = buf_oop->next;
12738 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12739 0, rte_pktmbuf_tailroom(buf_oop));
12740 rte_pktmbuf_append(buf_oop, to_trn);
12743 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12746 memcpy(plaintext, tdata->plaintext.data + trn_data,
12748 trn_data += to_trn;
12749 if (trn_data == tdata->plaintext.len) {
12752 digest_mem = rte_pktmbuf_append(buf_oop,
12753 tdata->auth_tag.len);
12755 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12756 tdata->auth_tag.len);
12760 uint64_t digest_phys = 0;
12762 ut_params->ibuf->nb_segs = segs;
12765 if (fragsz_oop && oop) {
12769 if (frag_size_oop == tdata->plaintext.len) {
12770 digest_mem = rte_pktmbuf_append(ut_params->obuf,
12771 tdata->auth_tag.len);
12773 digest_phys = rte_pktmbuf_iova_offset(
12775 tdata->plaintext.len + prepend_len);
12778 trn_data = frag_size_oop;
12779 while (trn_data < tdata->plaintext.len) {
12782 (tdata->plaintext.len - trn_data <
12784 (tdata->plaintext.len - trn_data) :
12787 to_trn_tbl[ecx++] = to_trn;
12789 buf_last_oop = buf_oop->next =
12790 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12791 buf_oop = buf_oop->next;
12792 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12793 0, rte_pktmbuf_tailroom(buf_oop));
12794 rte_pktmbuf_append(buf_oop, to_trn);
12796 trn_data += to_trn;
12798 if (trn_data == tdata->plaintext.len) {
12799 digest_mem = rte_pktmbuf_append(buf_oop,
12800 tdata->auth_tag.len);
12804 ut_params->obuf->nb_segs = segs;
12808 * Place digest at the end of the last buffer
12811 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12812 if (oop && buf_last_oop)
12813 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
12815 if (!digest_mem && !oop) {
12816 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12817 + tdata->auth_tag.len);
12818 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12819 tdata->plaintext.len);
12822 /* Create AEAD operation */
12823 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
12824 tdata, digest_mem, digest_phys);
12829 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12831 ut_params->op->sym->m_src = ut_params->ibuf;
12833 ut_params->op->sym->m_dst = ut_params->obuf;
12835 /* Process crypto operation */
12836 if (oop == IN_PLACE &&
12837 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12838 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12839 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12840 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12841 ut_params->op, 0, 0, 0, 0);
12843 TEST_ASSERT_NOT_NULL(
12844 process_crypto_request(ts_params->valid_devs[0],
12845 ut_params->op), "failed to process sym crypto op");
12847 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12848 "crypto op processing failed");
12851 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12852 uint8_t *, prepend_len);
12854 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12855 uint8_t *, prepend_len);
12859 fragsz = fragsz_oop;
12861 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12863 tdata->ciphertext.data,
12865 "Ciphertext data not as expected");
12867 buf = ut_params->op->sym->m_src->next;
12869 buf = ut_params->op->sym->m_dst->next;
12871 unsigned int off = fragsz;
12875 ciphertext = rte_pktmbuf_mtod(buf,
12878 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12880 tdata->ciphertext.data + off,
12882 "Ciphertext data not as expected");
12884 off += to_trn_tbl[ecx++];
12888 auth_tag = digest_mem;
12889 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12891 tdata->auth_tag.data,
12892 tdata->auth_tag.len,
12893 "Generated auth tag not as expected");
12899 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
12901 return test_authenticated_encryption_SGL(
12902 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
12906 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
12908 return test_authenticated_encryption_SGL(
12909 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
12913 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
12915 return test_authenticated_encryption_SGL(
12916 &gcm_test_case_8, OUT_OF_PLACE, 400,
12917 gcm_test_case_8.plaintext.len);
12921 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
12923 /* This test is not for OPENSSL PMD */
12924 if (gbl_driver_id == rte_cryptodev_driver_id_get(
12925 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
12928 return test_authenticated_encryption_SGL(
12929 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
12933 test_authentication_verify_fail_when_data_corrupted(
12934 struct crypto_testsuite_params *ts_params,
12935 struct crypto_unittest_params *ut_params,
12936 const struct test_crypto_vector *reference)
12938 return test_authentication_verify_fail_when_data_corruption(
12939 ts_params, ut_params, reference, 1);
12943 test_authentication_verify_fail_when_tag_corrupted(
12944 struct crypto_testsuite_params *ts_params,
12945 struct crypto_unittest_params *ut_params,
12946 const struct test_crypto_vector *reference)
12948 return test_authentication_verify_fail_when_data_corruption(
12949 ts_params, ut_params, reference, 0);
12953 test_authentication_verify_GMAC_fail_when_data_corrupted(
12954 struct crypto_testsuite_params *ts_params,
12955 struct crypto_unittest_params *ut_params,
12956 const struct test_crypto_vector *reference)
12958 return test_authentication_verify_GMAC_fail_when_corruption(
12959 ts_params, ut_params, reference, 1);
12963 test_authentication_verify_GMAC_fail_when_tag_corrupted(
12964 struct crypto_testsuite_params *ts_params,
12965 struct crypto_unittest_params *ut_params,
12966 const struct test_crypto_vector *reference)
12968 return test_authentication_verify_GMAC_fail_when_corruption(
12969 ts_params, ut_params, reference, 0);
12973 test_authenticated_decryption_fail_when_data_corrupted(
12974 struct crypto_testsuite_params *ts_params,
12975 struct crypto_unittest_params *ut_params,
12976 const struct test_crypto_vector *reference)
12978 return test_authenticated_decryption_fail_when_corruption(
12979 ts_params, ut_params, reference, 1);
12983 test_authenticated_decryption_fail_when_tag_corrupted(
12984 struct crypto_testsuite_params *ts_params,
12985 struct crypto_unittest_params *ut_params,
12986 const struct test_crypto_vector *reference)
12988 return test_authenticated_decryption_fail_when_corruption(
12989 ts_params, ut_params, reference, 0);
12993 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
12995 return test_authentication_verify_fail_when_data_corrupted(
12996 &testsuite_params, &unittest_params,
12997 &hmac_sha1_test_crypto_vector);
13001 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13003 return test_authentication_verify_fail_when_tag_corrupted(
13004 &testsuite_params, &unittest_params,
13005 &hmac_sha1_test_crypto_vector);
13009 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13011 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13012 &testsuite_params, &unittest_params,
13013 &aes128_gmac_test_vector);
13017 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13019 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13020 &testsuite_params, &unittest_params,
13021 &aes128_gmac_test_vector);
13025 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13027 return test_authenticated_decryption_fail_when_data_corrupted(
13030 &aes128cbc_hmac_sha1_test_vector);
13034 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13036 return test_authenticated_decryption_fail_when_tag_corrupted(
13039 &aes128cbc_hmac_sha1_test_vector);
13043 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13045 return test_authenticated_encryt_with_esn(
13048 &aes128cbc_hmac_sha1_aad_test_vector);
13052 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13054 return test_authenticated_decrypt_with_esn(
13057 &aes128cbc_hmac_sha1_aad_test_vector);
13061 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13063 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13067 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13069 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13072 #ifdef RTE_CRYPTO_SCHEDULER
13074 /* global AESNI worker IDs for the scheduler test */
13075 uint8_t aesni_ids[2];
13078 test_scheduler_attach_slave_op(void)
13080 struct crypto_testsuite_params *ts_params = &testsuite_params;
13081 uint8_t sched_id = ts_params->valid_devs[0];
13082 uint32_t nb_devs, i, nb_devs_attached = 0;
13084 char vdev_name[32];
13086 /* create 2 AESNI_MB if necessary */
13087 nb_devs = rte_cryptodev_device_count_by_driver(
13088 rte_cryptodev_driver_id_get(
13089 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13091 for (i = nb_devs; i < 2; i++) {
13092 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13093 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13095 ret = rte_vdev_init(vdev_name, NULL);
13097 TEST_ASSERT(ret == 0,
13098 "Failed to create instance %u of"
13100 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13104 /* attach 2 AESNI_MB cdevs */
13105 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13107 struct rte_cryptodev_info info;
13108 unsigned int session_size;
13110 rte_cryptodev_info_get(i, &info);
13111 if (info.driver_id != rte_cryptodev_driver_id_get(
13112 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13115 session_size = rte_cryptodev_sym_get_private_session_size(i);
13117 * Create the session mempool again, since now there are new devices
13118 * to use the mempool.
13120 if (ts_params->session_mpool) {
13121 rte_mempool_free(ts_params->session_mpool);
13122 ts_params->session_mpool = NULL;
13124 if (ts_params->session_priv_mpool) {
13125 rte_mempool_free(ts_params->session_priv_mpool);
13126 ts_params->session_priv_mpool = NULL;
13129 if (info.sym.max_nb_sessions != 0 &&
13130 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13131 RTE_LOG(ERR, USER1,
13132 "Device does not support "
13133 "at least %u sessions\n",
13135 return TEST_FAILED;
13138 * Create mempool with maximum number of sessions,
13139 * to include the session headers
13141 if (ts_params->session_mpool == NULL) {
13142 ts_params->session_mpool =
13143 rte_cryptodev_sym_session_pool_create(
13145 MAX_NB_SESSIONS, 0, 0, 0,
13147 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13148 "session mempool allocation failed");
13152 * Create mempool with maximum number of sessions,
13153 * to include device specific session private data
13155 if (ts_params->session_priv_mpool == NULL) {
13156 ts_params->session_priv_mpool = rte_mempool_create(
13157 "test_sess_mp_priv",
13160 0, 0, NULL, NULL, NULL,
13161 NULL, SOCKET_ID_ANY,
13164 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13165 "session mempool allocation failed");
13168 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13169 ts_params->qp_conf.mp_session_private =
13170 ts_params->session_priv_mpool;
13172 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13175 TEST_ASSERT(ret == 0,
13176 "Failed to attach device %u of pmd : %s", i,
13177 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13179 aesni_ids[nb_devs_attached] = (uint8_t)i;
13181 nb_devs_attached++;
13188 test_scheduler_detach_slave_op(void)
13190 struct crypto_testsuite_params *ts_params = &testsuite_params;
13191 uint8_t sched_id = ts_params->valid_devs[0];
13195 for (i = 0; i < 2; i++) {
13196 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13198 TEST_ASSERT(ret == 0,
13199 "Failed to detach device %u", aesni_ids[i]);
13206 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13208 struct crypto_testsuite_params *ts_params = &testsuite_params;
13209 uint8_t sched_id = ts_params->valid_devs[0];
13211 return rte_cryptodev_scheduler_mode_set(sched_id,
13216 test_scheduler_mode_roundrobin_op(void)
13218 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13219 0, "Failed to set roundrobin mode");
13225 test_scheduler_mode_multicore_op(void)
13227 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13228 0, "Failed to set multicore mode");
13234 test_scheduler_mode_failover_op(void)
13236 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13237 0, "Failed to set failover mode");
13243 test_scheduler_mode_pkt_size_distr_op(void)
13245 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13246 0, "Failed to set pktsize mode");
13251 static struct unit_test_suite cryptodev_scheduler_testsuite = {
13252 .suite_name = "Crypto Device Scheduler Unit Test Suite",
13253 .setup = testsuite_setup,
13254 .teardown = testsuite_teardown,
13255 .unit_test_cases = {
13257 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13258 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
13259 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13260 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13261 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13262 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13265 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13266 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
13267 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13268 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13269 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13270 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13273 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13274 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
13275 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13276 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13277 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13278 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13281 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13282 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
13283 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13284 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13285 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13286 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13288 TEST_CASES_END() /**< NULL terminate unit test array */
13292 #endif /* RTE_CRYPTO_SCHEDULER */
13294 static struct unit_test_suite cryptodev_testsuite = {
13295 .suite_name = "Crypto Unit Test Suite",
13296 .setup = testsuite_setup,
13297 .teardown = testsuite_teardown,
13298 .unit_test_cases = {
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_device_configure_invalid_dev_id),
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_queue_pair_descriptor_setup),
13303 TEST_CASE_ST(ut_setup, ut_teardown,
13304 test_device_configure_invalid_queue_pair_ids),
13305 TEST_CASE_ST(ut_setup, ut_teardown,
13306 test_multi_session),
13307 TEST_CASE_ST(ut_setup, ut_teardown,
13308 test_multi_session_random_usage),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_null_invalid_operation),
13312 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13313 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13314 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13315 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13316 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13317 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
13318 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
13319 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
13320 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13321 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13323 /** AES CCM Authenticated Encryption 128 bits key */
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_AES_CCM_authenticated_encryption_test_case_128_1),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_AES_CCM_authenticated_encryption_test_case_128_2),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_AES_CCM_authenticated_encryption_test_case_128_3),
13331 /** AES CCM Authenticated Decryption 128 bits key*/
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_AES_CCM_authenticated_decryption_test_case_128_1),
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_AES_CCM_authenticated_decryption_test_case_128_2),
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_AES_CCM_authenticated_decryption_test_case_128_3),
13339 /** AES CCM Authenticated Encryption 192 bits key */
13340 TEST_CASE_ST(ut_setup, ut_teardown,
13341 test_AES_CCM_authenticated_encryption_test_case_192_1),
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 test_AES_CCM_authenticated_encryption_test_case_192_2),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 test_AES_CCM_authenticated_encryption_test_case_192_3),
13347 /** AES CCM Authenticated Decryption 192 bits key*/
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_AES_CCM_authenticated_decryption_test_case_192_1),
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_AES_CCM_authenticated_decryption_test_case_192_2),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_AES_CCM_authenticated_decryption_test_case_192_3),
13355 /** AES CCM Authenticated Encryption 256 bits key */
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_AES_CCM_authenticated_encryption_test_case_256_1),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_AES_CCM_authenticated_encryption_test_case_256_2),
13360 TEST_CASE_ST(ut_setup, ut_teardown,
13361 test_AES_CCM_authenticated_encryption_test_case_256_3),
13363 /** AES CCM Authenticated Decryption 256 bits key*/
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_AES_CCM_authenticated_decryption_test_case_256_1),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_AES_CCM_authenticated_decryption_test_case_256_2),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_AES_CCM_authenticated_decryption_test_case_256_3),
13371 /** AES GCM Authenticated Encryption */
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_AES_GCM_authenticated_encryption_test_case_1),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_AES_GCM_authenticated_encryption_test_case_2),
13384 TEST_CASE_ST(ut_setup, ut_teardown,
13385 test_AES_GCM_authenticated_encryption_test_case_3),
13386 TEST_CASE_ST(ut_setup, ut_teardown,
13387 test_AES_GCM_authenticated_encryption_test_case_4),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_AES_GCM_authenticated_encryption_test_case_5),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_AES_GCM_authenticated_encryption_test_case_6),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_AES_GCM_authenticated_encryption_test_case_7),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_AES_GCM_authenticated_encryption_test_case_8),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13399 /** AES GCM Authenticated Decryption */
13400 TEST_CASE_ST(ut_setup, ut_teardown,
13401 test_AES_GCM_authenticated_decryption_test_case_1),
13402 TEST_CASE_ST(ut_setup, ut_teardown,
13403 test_AES_GCM_authenticated_decryption_test_case_2),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_AES_GCM_authenticated_decryption_test_case_3),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 test_AES_GCM_authenticated_decryption_test_case_4),
13408 TEST_CASE_ST(ut_setup, ut_teardown,
13409 test_AES_GCM_authenticated_decryption_test_case_5),
13410 TEST_CASE_ST(ut_setup, ut_teardown,
13411 test_AES_GCM_authenticated_decryption_test_case_6),
13412 TEST_CASE_ST(ut_setup, ut_teardown,
13413 test_AES_GCM_authenticated_decryption_test_case_7),
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_AES_GCM_authenticated_decryption_test_case_8),
13416 TEST_CASE_ST(ut_setup, ut_teardown,
13417 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13419 /** AES GCM Authenticated Encryption 192 bits key */
13420 TEST_CASE_ST(ut_setup, ut_teardown,
13421 test_AES_GCM_auth_encryption_test_case_192_1),
13422 TEST_CASE_ST(ut_setup, ut_teardown,
13423 test_AES_GCM_auth_encryption_test_case_192_2),
13424 TEST_CASE_ST(ut_setup, ut_teardown,
13425 test_AES_GCM_auth_encryption_test_case_192_3),
13426 TEST_CASE_ST(ut_setup, ut_teardown,
13427 test_AES_GCM_auth_encryption_test_case_192_4),
13428 TEST_CASE_ST(ut_setup, ut_teardown,
13429 test_AES_GCM_auth_encryption_test_case_192_5),
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_AES_GCM_auth_encryption_test_case_192_6),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_AES_GCM_auth_encryption_test_case_192_7),
13435 /** AES GCM Authenticated Decryption 192 bits key */
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 test_AES_GCM_auth_decryption_test_case_192_1),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 test_AES_GCM_auth_decryption_test_case_192_2),
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 test_AES_GCM_auth_decryption_test_case_192_3),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 test_AES_GCM_auth_decryption_test_case_192_4),
13444 TEST_CASE_ST(ut_setup, ut_teardown,
13445 test_AES_GCM_auth_decryption_test_case_192_5),
13446 TEST_CASE_ST(ut_setup, ut_teardown,
13447 test_AES_GCM_auth_decryption_test_case_192_6),
13448 TEST_CASE_ST(ut_setup, ut_teardown,
13449 test_AES_GCM_auth_decryption_test_case_192_7),
13451 /** AES GCM Authenticated Encryption 256 bits key */
13452 TEST_CASE_ST(ut_setup, ut_teardown,
13453 test_AES_GCM_auth_encryption_test_case_256_1),
13454 TEST_CASE_ST(ut_setup, ut_teardown,
13455 test_AES_GCM_auth_encryption_test_case_256_2),
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 test_AES_GCM_auth_encryption_test_case_256_3),
13458 TEST_CASE_ST(ut_setup, ut_teardown,
13459 test_AES_GCM_auth_encryption_test_case_256_4),
13460 TEST_CASE_ST(ut_setup, ut_teardown,
13461 test_AES_GCM_auth_encryption_test_case_256_5),
13462 TEST_CASE_ST(ut_setup, ut_teardown,
13463 test_AES_GCM_auth_encryption_test_case_256_6),
13464 TEST_CASE_ST(ut_setup, ut_teardown,
13465 test_AES_GCM_auth_encryption_test_case_256_7),
13467 /** AES GCM Authenticated Decryption 256 bits key */
13468 TEST_CASE_ST(ut_setup, ut_teardown,
13469 test_AES_GCM_auth_decryption_test_case_256_1),
13470 TEST_CASE_ST(ut_setup, ut_teardown,
13471 test_AES_GCM_auth_decryption_test_case_256_2),
13472 TEST_CASE_ST(ut_setup, ut_teardown,
13473 test_AES_GCM_auth_decryption_test_case_256_3),
13474 TEST_CASE_ST(ut_setup, ut_teardown,
13475 test_AES_GCM_auth_decryption_test_case_256_4),
13476 TEST_CASE_ST(ut_setup, ut_teardown,
13477 test_AES_GCM_auth_decryption_test_case_256_5),
13478 TEST_CASE_ST(ut_setup, ut_teardown,
13479 test_AES_GCM_auth_decryption_test_case_256_6),
13480 TEST_CASE_ST(ut_setup, ut_teardown,
13481 test_AES_GCM_auth_decryption_test_case_256_7),
13483 /** AES GCM Authenticated Encryption big aad size */
13484 TEST_CASE_ST(ut_setup, ut_teardown,
13485 test_AES_GCM_auth_encryption_test_case_aad_1),
13486 TEST_CASE_ST(ut_setup, ut_teardown,
13487 test_AES_GCM_auth_encryption_test_case_aad_2),
13489 /** AES GCM Authenticated Decryption big aad size */
13490 TEST_CASE_ST(ut_setup, ut_teardown,
13491 test_AES_GCM_auth_decryption_test_case_aad_1),
13492 TEST_CASE_ST(ut_setup, ut_teardown,
13493 test_AES_GCM_auth_decryption_test_case_aad_2),
13495 /** Out of place tests */
13496 TEST_CASE_ST(ut_setup, ut_teardown,
13497 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13498 TEST_CASE_ST(ut_setup, ut_teardown,
13499 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13501 /** Session-less tests */
13502 TEST_CASE_ST(ut_setup, ut_teardown,
13503 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13504 TEST_CASE_ST(ut_setup, ut_teardown,
13505 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13507 /** AES GMAC Authentication */
13508 TEST_CASE_ST(ut_setup, ut_teardown,
13509 test_AES_GMAC_authentication_test_case_1),
13510 TEST_CASE_ST(ut_setup, ut_teardown,
13511 test_AES_GMAC_authentication_verify_test_case_1),
13512 TEST_CASE_ST(ut_setup, ut_teardown,
13513 test_AES_GMAC_authentication_test_case_2),
13514 TEST_CASE_ST(ut_setup, ut_teardown,
13515 test_AES_GMAC_authentication_verify_test_case_2),
13516 TEST_CASE_ST(ut_setup, ut_teardown,
13517 test_AES_GMAC_authentication_test_case_3),
13518 TEST_CASE_ST(ut_setup, ut_teardown,
13519 test_AES_GMAC_authentication_verify_test_case_3),
13520 TEST_CASE_ST(ut_setup, ut_teardown,
13521 test_AES_GMAC_authentication_test_case_4),
13522 TEST_CASE_ST(ut_setup, ut_teardown,
13523 test_AES_GMAC_authentication_verify_test_case_4),
13524 TEST_CASE_ST(ut_setup, ut_teardown,
13525 test_AES_GMAC_authentication_SGL_40B),
13526 TEST_CASE_ST(ut_setup, ut_teardown,
13527 test_AES_GMAC_authentication_SGL_80B),
13528 TEST_CASE_ST(ut_setup, ut_teardown,
13529 test_AES_GMAC_authentication_SGL_2048B),
13530 TEST_CASE_ST(ut_setup, ut_teardown,
13531 test_AES_GMAC_authentication_SGL_2047B),
13533 /** Chacha20-Poly1305 */
13534 TEST_CASE_ST(ut_setup, ut_teardown,
13535 test_chacha20_poly1305_encrypt_test_case_rfc8439),
13536 TEST_CASE_ST(ut_setup, ut_teardown,
13537 test_chacha20_poly1305_decrypt_test_case_rfc8439),
13538 /** SNOW 3G encrypt only (UEA2) */
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_snow3g_encryption_test_case_1),
13541 TEST_CASE_ST(ut_setup, ut_teardown,
13542 test_snow3g_encryption_test_case_2),
13543 TEST_CASE_ST(ut_setup, ut_teardown,
13544 test_snow3g_encryption_test_case_3),
13545 TEST_CASE_ST(ut_setup, ut_teardown,
13546 test_snow3g_encryption_test_case_4),
13547 TEST_CASE_ST(ut_setup, ut_teardown,
13548 test_snow3g_encryption_test_case_5),
13550 TEST_CASE_ST(ut_setup, ut_teardown,
13551 test_snow3g_encryption_test_case_1_oop),
13552 TEST_CASE_ST(ut_setup, ut_teardown,
13553 test_snow3g_encryption_test_case_1_oop_sgl),
13554 TEST_CASE_ST(ut_setup, ut_teardown,
13555 test_snow3g_encryption_test_case_1_offset_oop),
13556 TEST_CASE_ST(ut_setup, ut_teardown,
13557 test_snow3g_decryption_test_case_1_oop),
13559 /** SNOW 3G generate auth, then encrypt (UEA2) */
13560 TEST_CASE_ST(ut_setup, ut_teardown,
13561 test_snow3g_auth_cipher_test_case_1),
13562 TEST_CASE_ST(ut_setup, ut_teardown,
13563 test_snow3g_auth_cipher_test_case_2),
13564 TEST_CASE_ST(ut_setup, ut_teardown,
13565 test_snow3g_auth_cipher_test_case_2_oop),
13566 TEST_CASE_ST(ut_setup, ut_teardown,
13567 test_snow3g_auth_cipher_part_digest_enc),
13568 TEST_CASE_ST(ut_setup, ut_teardown,
13569 test_snow3g_auth_cipher_part_digest_enc_oop),
13570 TEST_CASE_ST(ut_setup, ut_teardown,
13571 test_snow3g_auth_cipher_test_case_3_sgl),
13572 TEST_CASE_ST(ut_setup, ut_teardown,
13573 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13574 TEST_CASE_ST(ut_setup, ut_teardown,
13575 test_snow3g_auth_cipher_part_digest_enc_sgl),
13576 TEST_CASE_ST(ut_setup, ut_teardown,
13577 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13579 /** SNOW 3G decrypt (UEA2), then verify auth */
13580 TEST_CASE_ST(ut_setup, ut_teardown,
13581 test_snow3g_auth_cipher_verify_test_case_1),
13582 TEST_CASE_ST(ut_setup, ut_teardown,
13583 test_snow3g_auth_cipher_verify_test_case_2),
13584 TEST_CASE_ST(ut_setup, ut_teardown,
13585 test_snow3g_auth_cipher_verify_test_case_2_oop),
13586 TEST_CASE_ST(ut_setup, ut_teardown,
13587 test_snow3g_auth_cipher_verify_part_digest_enc),
13588 TEST_CASE_ST(ut_setup, ut_teardown,
13589 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13590 TEST_CASE_ST(ut_setup, ut_teardown,
13591 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13592 TEST_CASE_ST(ut_setup, ut_teardown,
13593 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13594 TEST_CASE_ST(ut_setup, ut_teardown,
13595 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13596 TEST_CASE_ST(ut_setup, ut_teardown,
13597 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13599 /** SNOW 3G decrypt only (UEA2) */
13600 TEST_CASE_ST(ut_setup, ut_teardown,
13601 test_snow3g_decryption_test_case_1),
13602 TEST_CASE_ST(ut_setup, ut_teardown,
13603 test_snow3g_decryption_test_case_2),
13604 TEST_CASE_ST(ut_setup, ut_teardown,
13605 test_snow3g_decryption_test_case_3),
13606 TEST_CASE_ST(ut_setup, ut_teardown,
13607 test_snow3g_decryption_test_case_4),
13608 TEST_CASE_ST(ut_setup, ut_teardown,
13609 test_snow3g_decryption_test_case_5),
13610 TEST_CASE_ST(ut_setup, ut_teardown,
13611 test_snow3g_decryption_with_digest_test_case_1),
13612 TEST_CASE_ST(ut_setup, ut_teardown,
13613 test_snow3g_hash_generate_test_case_1),
13614 TEST_CASE_ST(ut_setup, ut_teardown,
13615 test_snow3g_hash_generate_test_case_2),
13616 TEST_CASE_ST(ut_setup, ut_teardown,
13617 test_snow3g_hash_generate_test_case_3),
13618 /* Tests with buffers which length is not byte-aligned */
13619 TEST_CASE_ST(ut_setup, ut_teardown,
13620 test_snow3g_hash_generate_test_case_4),
13621 TEST_CASE_ST(ut_setup, ut_teardown,
13622 test_snow3g_hash_generate_test_case_5),
13623 TEST_CASE_ST(ut_setup, ut_teardown,
13624 test_snow3g_hash_generate_test_case_6),
13625 TEST_CASE_ST(ut_setup, ut_teardown,
13626 test_snow3g_hash_verify_test_case_1),
13627 TEST_CASE_ST(ut_setup, ut_teardown,
13628 test_snow3g_hash_verify_test_case_2),
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 test_snow3g_hash_verify_test_case_3),
13631 /* Tests with buffers which length is not byte-aligned */
13632 TEST_CASE_ST(ut_setup, ut_teardown,
13633 test_snow3g_hash_verify_test_case_4),
13634 TEST_CASE_ST(ut_setup, ut_teardown,
13635 test_snow3g_hash_verify_test_case_5),
13636 TEST_CASE_ST(ut_setup, ut_teardown,
13637 test_snow3g_hash_verify_test_case_6),
13638 TEST_CASE_ST(ut_setup, ut_teardown,
13639 test_snow3g_cipher_auth_test_case_1),
13640 TEST_CASE_ST(ut_setup, ut_teardown,
13641 test_snow3g_auth_cipher_with_digest_test_case_1),
13643 /** ZUC encrypt only (EEA3) */
13644 TEST_CASE_ST(ut_setup, ut_teardown,
13645 test_zuc_encryption_test_case_1),
13646 TEST_CASE_ST(ut_setup, ut_teardown,
13647 test_zuc_encryption_test_case_2),
13648 TEST_CASE_ST(ut_setup, ut_teardown,
13649 test_zuc_encryption_test_case_3),
13650 TEST_CASE_ST(ut_setup, ut_teardown,
13651 test_zuc_encryption_test_case_4),
13652 TEST_CASE_ST(ut_setup, ut_teardown,
13653 test_zuc_encryption_test_case_5),
13654 TEST_CASE_ST(ut_setup, ut_teardown,
13655 test_zuc_encryption_test_case_6_sgl),
13657 /** ZUC authenticate (EIA3) */
13658 TEST_CASE_ST(ut_setup, ut_teardown,
13659 test_zuc_hash_generate_test_case_1),
13660 TEST_CASE_ST(ut_setup, ut_teardown,
13661 test_zuc_hash_generate_test_case_2),
13662 TEST_CASE_ST(ut_setup, ut_teardown,
13663 test_zuc_hash_generate_test_case_3),
13664 TEST_CASE_ST(ut_setup, ut_teardown,
13665 test_zuc_hash_generate_test_case_4),
13666 TEST_CASE_ST(ut_setup, ut_teardown,
13667 test_zuc_hash_generate_test_case_5),
13668 TEST_CASE_ST(ut_setup, ut_teardown,
13669 test_zuc_hash_generate_test_case_6),
13670 TEST_CASE_ST(ut_setup, ut_teardown,
13671 test_zuc_hash_generate_test_case_7),
13672 TEST_CASE_ST(ut_setup, ut_teardown,
13673 test_zuc_hash_generate_test_case_8),
13675 /** ZUC alg-chain (EEA3/EIA3) */
13676 TEST_CASE_ST(ut_setup, ut_teardown,
13677 test_zuc_cipher_auth_test_case_1),
13678 TEST_CASE_ST(ut_setup, ut_teardown,
13679 test_zuc_cipher_auth_test_case_2),
13681 /** ZUC generate auth, then encrypt (EEA3) */
13682 TEST_CASE_ST(ut_setup, ut_teardown,
13683 test_zuc_auth_cipher_test_case_1),
13684 TEST_CASE_ST(ut_setup, ut_teardown,
13685 test_zuc_auth_cipher_test_case_1_oop),
13686 TEST_CASE_ST(ut_setup, ut_teardown,
13687 test_zuc_auth_cipher_test_case_1_sgl),
13688 TEST_CASE_ST(ut_setup, ut_teardown,
13689 test_zuc_auth_cipher_test_case_1_oop_sgl),
13691 /** ZUC decrypt (EEA3), then verify auth */
13692 TEST_CASE_ST(ut_setup, ut_teardown,
13693 test_zuc_auth_cipher_verify_test_case_1),
13694 TEST_CASE_ST(ut_setup, ut_teardown,
13695 test_zuc_auth_cipher_verify_test_case_1_oop),
13696 TEST_CASE_ST(ut_setup, ut_teardown,
13697 test_zuc_auth_cipher_verify_test_case_1_sgl),
13698 TEST_CASE_ST(ut_setup, ut_teardown,
13699 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
13701 /** HMAC_MD5 Authentication */
13702 TEST_CASE_ST(ut_setup, ut_teardown,
13703 test_MD5_HMAC_generate_case_1),
13704 TEST_CASE_ST(ut_setup, ut_teardown,
13705 test_MD5_HMAC_verify_case_1),
13706 TEST_CASE_ST(ut_setup, ut_teardown,
13707 test_MD5_HMAC_generate_case_2),
13708 TEST_CASE_ST(ut_setup, ut_teardown,
13709 test_MD5_HMAC_verify_case_2),
13711 /** KASUMI hash only (UIA1) */
13712 TEST_CASE_ST(ut_setup, ut_teardown,
13713 test_kasumi_hash_generate_test_case_1),
13714 TEST_CASE_ST(ut_setup, ut_teardown,
13715 test_kasumi_hash_generate_test_case_2),
13716 TEST_CASE_ST(ut_setup, ut_teardown,
13717 test_kasumi_hash_generate_test_case_3),
13718 TEST_CASE_ST(ut_setup, ut_teardown,
13719 test_kasumi_hash_generate_test_case_4),
13720 TEST_CASE_ST(ut_setup, ut_teardown,
13721 test_kasumi_hash_generate_test_case_5),
13722 TEST_CASE_ST(ut_setup, ut_teardown,
13723 test_kasumi_hash_generate_test_case_6),
13725 TEST_CASE_ST(ut_setup, ut_teardown,
13726 test_kasumi_hash_verify_test_case_1),
13727 TEST_CASE_ST(ut_setup, ut_teardown,
13728 test_kasumi_hash_verify_test_case_2),
13729 TEST_CASE_ST(ut_setup, ut_teardown,
13730 test_kasumi_hash_verify_test_case_3),
13731 TEST_CASE_ST(ut_setup, ut_teardown,
13732 test_kasumi_hash_verify_test_case_4),
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 test_kasumi_hash_verify_test_case_5),
13736 /** KASUMI encrypt only (UEA1) */
13737 TEST_CASE_ST(ut_setup, ut_teardown,
13738 test_kasumi_encryption_test_case_1),
13739 TEST_CASE_ST(ut_setup, ut_teardown,
13740 test_kasumi_encryption_test_case_1_sgl),
13741 TEST_CASE_ST(ut_setup, ut_teardown,
13742 test_kasumi_encryption_test_case_1_oop),
13743 TEST_CASE_ST(ut_setup, ut_teardown,
13744 test_kasumi_encryption_test_case_1_oop_sgl),
13745 TEST_CASE_ST(ut_setup, ut_teardown,
13746 test_kasumi_encryption_test_case_2),
13747 TEST_CASE_ST(ut_setup, ut_teardown,
13748 test_kasumi_encryption_test_case_3),
13749 TEST_CASE_ST(ut_setup, ut_teardown,
13750 test_kasumi_encryption_test_case_4),
13751 TEST_CASE_ST(ut_setup, ut_teardown,
13752 test_kasumi_encryption_test_case_5),
13754 /** KASUMI decrypt only (UEA1) */
13755 TEST_CASE_ST(ut_setup, ut_teardown,
13756 test_kasumi_decryption_test_case_1),
13757 TEST_CASE_ST(ut_setup, ut_teardown,
13758 test_kasumi_decryption_test_case_2),
13759 TEST_CASE_ST(ut_setup, ut_teardown,
13760 test_kasumi_decryption_test_case_3),
13761 TEST_CASE_ST(ut_setup, ut_teardown,
13762 test_kasumi_decryption_test_case_4),
13763 TEST_CASE_ST(ut_setup, ut_teardown,
13764 test_kasumi_decryption_test_case_5),
13765 TEST_CASE_ST(ut_setup, ut_teardown,
13766 test_kasumi_decryption_test_case_1_oop),
13768 TEST_CASE_ST(ut_setup, ut_teardown,
13769 test_kasumi_cipher_auth_test_case_1),
13771 /** KASUMI generate auth, then encrypt (F8) */
13772 TEST_CASE_ST(ut_setup, ut_teardown,
13773 test_kasumi_auth_cipher_test_case_1),
13774 TEST_CASE_ST(ut_setup, ut_teardown,
13775 test_kasumi_auth_cipher_test_case_2),
13776 TEST_CASE_ST(ut_setup, ut_teardown,
13777 test_kasumi_auth_cipher_test_case_2_oop),
13778 TEST_CASE_ST(ut_setup, ut_teardown,
13779 test_kasumi_auth_cipher_test_case_2_sgl),
13780 TEST_CASE_ST(ut_setup, ut_teardown,
13781 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13783 /** KASUMI decrypt (F8), then verify auth */
13784 TEST_CASE_ST(ut_setup, ut_teardown,
13785 test_kasumi_auth_cipher_verify_test_case_1),
13786 TEST_CASE_ST(ut_setup, ut_teardown,
13787 test_kasumi_auth_cipher_verify_test_case_2),
13788 TEST_CASE_ST(ut_setup, ut_teardown,
13789 test_kasumi_auth_cipher_verify_test_case_2_oop),
13790 TEST_CASE_ST(ut_setup, ut_teardown,
13791 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13792 TEST_CASE_ST(ut_setup, ut_teardown,
13793 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13795 /** ESN Testcase */
13796 TEST_CASE_ST(ut_setup, ut_teardown,
13797 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13798 TEST_CASE_ST(ut_setup, ut_teardown,
13799 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13801 /** Negative tests */
13802 TEST_CASE_ST(ut_setup, ut_teardown,
13803 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13804 TEST_CASE_ST(ut_setup, ut_teardown,
13805 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13806 TEST_CASE_ST(ut_setup, ut_teardown,
13807 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13810 TEST_CASE_ST(ut_setup, ut_teardown,
13811 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13812 TEST_CASE_ST(ut_setup, ut_teardown,
13813 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13814 TEST_CASE_ST(ut_setup, ut_teardown,
13815 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13816 TEST_CASE_ST(ut_setup, ut_teardown,
13817 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13818 TEST_CASE_ST(ut_setup, ut_teardown,
13819 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13820 TEST_CASE_ST(ut_setup, ut_teardown,
13821 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13822 TEST_CASE_ST(ut_setup, ut_teardown,
13823 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13824 TEST_CASE_ST(ut_setup, ut_teardown,
13825 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13826 TEST_CASE_ST(ut_setup, ut_teardown,
13827 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13828 TEST_CASE_ST(ut_setup, ut_teardown,
13829 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13830 TEST_CASE_ST(ut_setup, ut_teardown,
13831 authentication_verify_AES128_GMAC_fail_data_corrupt),
13832 TEST_CASE_ST(ut_setup, ut_teardown,
13833 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13834 TEST_CASE_ST(ut_setup, ut_teardown,
13835 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13836 TEST_CASE_ST(ut_setup, ut_teardown,
13837 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13839 /** Mixed CIPHER + HASH algorithms */
13840 /** AUTH AES CMAC + CIPHER AES CTR */
13841 TEST_CASE_ST(ut_setup, ut_teardown,
13842 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
13843 TEST_CASE_ST(ut_setup, ut_teardown,
13844 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13845 TEST_CASE_ST(ut_setup, ut_teardown,
13846 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13847 TEST_CASE_ST(ut_setup, ut_teardown,
13848 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13849 TEST_CASE_ST(ut_setup, ut_teardown,
13850 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
13851 TEST_CASE_ST(ut_setup, ut_teardown,
13852 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13853 TEST_CASE_ST(ut_setup, ut_teardown,
13854 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13855 TEST_CASE_ST(ut_setup, ut_teardown,
13856 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13858 /** AUTH ZUC + CIPHER SNOW3G */
13859 TEST_CASE_ST(ut_setup, ut_teardown,
13860 test_auth_zuc_cipher_snow_test_case_1),
13861 TEST_CASE_ST(ut_setup, ut_teardown,
13862 test_verify_auth_zuc_cipher_snow_test_case_1),
13863 /** AUTH AES CMAC + CIPHER SNOW3G */
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_auth_aes_cmac_cipher_snow_test_case_1),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
13868 /** AUTH ZUC + CIPHER AES CTR */
13869 TEST_CASE_ST(ut_setup, ut_teardown,
13870 test_auth_zuc_cipher_aes_ctr_test_case_1),
13871 TEST_CASE_ST(ut_setup, ut_teardown,
13872 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
13873 /** AUTH SNOW3G + CIPHER AES CTR */
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_auth_snow_cipher_aes_ctr_test_case_1),
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
13878 /** AUTH SNOW3G + CIPHER ZUC */
13879 TEST_CASE_ST(ut_setup, ut_teardown,
13880 test_auth_snow_cipher_zuc_test_case_1),
13881 TEST_CASE_ST(ut_setup, ut_teardown,
13882 test_verify_auth_snow_cipher_zuc_test_case_1),
13883 /** AUTH AES CMAC + CIPHER ZUC */
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_auth_aes_cmac_cipher_zuc_test_case_1),
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
13889 /** AUTH NULL + CIPHER SNOW3G */
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_auth_null_cipher_snow_test_case_1),
13892 TEST_CASE_ST(ut_setup, ut_teardown,
13893 test_verify_auth_null_cipher_snow_test_case_1),
13894 /** AUTH NULL + CIPHER ZUC */
13895 TEST_CASE_ST(ut_setup, ut_teardown,
13896 test_auth_null_cipher_zuc_test_case_1),
13897 TEST_CASE_ST(ut_setup, ut_teardown,
13898 test_verify_auth_null_cipher_zuc_test_case_1),
13899 /** AUTH SNOW3G + CIPHER NULL */
13900 TEST_CASE_ST(ut_setup, ut_teardown,
13901 test_auth_snow_cipher_null_test_case_1),
13902 TEST_CASE_ST(ut_setup, ut_teardown,
13903 test_verify_auth_snow_cipher_null_test_case_1),
13904 /** AUTH ZUC + CIPHER NULL */
13905 TEST_CASE_ST(ut_setup, ut_teardown,
13906 test_auth_zuc_cipher_null_test_case_1),
13907 TEST_CASE_ST(ut_setup, ut_teardown,
13908 test_verify_auth_zuc_cipher_null_test_case_1),
13909 /** AUTH NULL + CIPHER AES CTR */
13910 TEST_CASE_ST(ut_setup, ut_teardown,
13911 test_auth_null_cipher_aes_ctr_test_case_1),
13912 TEST_CASE_ST(ut_setup, ut_teardown,
13913 test_verify_auth_null_cipher_aes_ctr_test_case_1),
13914 /** AUTH AES CMAC + CIPHER NULL */
13915 TEST_CASE_ST(ut_setup, ut_teardown,
13916 test_auth_aes_cmac_cipher_null_test_case_1),
13917 TEST_CASE_ST(ut_setup, ut_teardown,
13918 test_verify_auth_aes_cmac_cipher_null_test_case_1),
13920 #ifdef RTE_LIB_SECURITY
13921 TEST_CASE_ST(ut_setup_security, ut_teardown,
13922 test_PDCP_PROTO_all),
13923 TEST_CASE_ST(ut_setup_security, ut_teardown,
13924 test_DOCSIS_PROTO_all),
13926 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13927 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13928 TEST_CASES_END() /**< NULL terminate unit test array */
13932 static struct unit_test_suite cryptodev_virtio_testsuite = {
13933 .suite_name = "Crypto VIRTIO Unit Test Suite",
13934 .setup = testsuite_setup,
13935 .teardown = testsuite_teardown,
13936 .unit_test_cases = {
13937 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13939 TEST_CASES_END() /**< NULL terminate unit test array */
13943 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13944 .suite_name = "Crypto CAAM JR Unit Test Suite",
13945 .setup = testsuite_setup,
13946 .teardown = testsuite_teardown,
13947 .unit_test_cases = {
13948 TEST_CASE_ST(ut_setup, ut_teardown,
13949 test_device_configure_invalid_dev_id),
13950 TEST_CASE_ST(ut_setup, ut_teardown,
13951 test_multi_session),
13953 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13954 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13955 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13956 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13957 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13959 TEST_CASES_END() /**< NULL terminate unit test array */
13963 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13964 .suite_name = "Crypto Device Marvell Component Test Suite",
13965 .setup = testsuite_setup,
13966 .teardown = testsuite_teardown,
13967 .unit_test_cases = {
13968 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13969 TEST_CASE_ST(ut_setup, ut_teardown,
13970 test_multi_session_random_usage),
13971 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13972 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13973 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13974 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13975 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13977 /** Negative tests */
13978 TEST_CASE_ST(ut_setup, ut_teardown,
13979 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13980 TEST_CASE_ST(ut_setup, ut_teardown,
13981 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13982 TEST_CASE_ST(ut_setup, ut_teardown,
13983 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13984 TEST_CASE_ST(ut_setup, ut_teardown,
13985 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13987 TEST_CASES_END() /**< NULL terminate unit test array */
13991 static struct unit_test_suite cryptodev_ccp_testsuite = {
13992 .suite_name = "Crypto Device CCP Unit Test Suite",
13993 .setup = testsuite_setup,
13994 .teardown = testsuite_teardown,
13995 .unit_test_cases = {
13996 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13997 TEST_CASE_ST(ut_setup, ut_teardown,
13998 test_multi_session_random_usage),
13999 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14000 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
14001 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
14002 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
14003 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14005 /** Negative tests */
14006 TEST_CASE_ST(ut_setup, ut_teardown,
14007 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14008 TEST_CASE_ST(ut_setup, ut_teardown,
14009 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14010 TEST_CASE_ST(ut_setup, ut_teardown,
14011 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14012 TEST_CASE_ST(ut_setup, ut_teardown,
14013 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14015 TEST_CASES_END() /**< NULL terminate unit test array */
14020 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14022 gbl_driver_id = rte_cryptodev_driver_id_get(
14023 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14025 if (gbl_driver_id == -1) {
14026 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14027 return TEST_SKIPPED;
14030 return unit_test_suite_runner(&cryptodev_testsuite);
14034 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14036 gbl_driver_id = rte_cryptodev_driver_id_get(
14037 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14039 if (gbl_driver_id == -1) {
14040 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
14041 return TEST_FAILED;
14044 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14048 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14050 gbl_driver_id = rte_cryptodev_driver_id_get(
14051 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14053 if (gbl_driver_id == -1) {
14054 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14055 return TEST_SKIPPED;
14058 return unit_test_suite_runner(&cryptodev_testsuite);
14062 test_cryptodev_cpu_aesni_mb(void)
14065 enum rte_security_session_action_type at;
14067 gbl_driver_id = rte_cryptodev_driver_id_get(
14068 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14070 if (gbl_driver_id == -1) {
14071 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14072 return TEST_SKIPPED;
14075 at = gbl_action_type;
14076 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14077 rc = unit_test_suite_runner(&cryptodev_testsuite);
14078 gbl_action_type = at;
14083 test_cryptodev_openssl(void)
14085 gbl_driver_id = rte_cryptodev_driver_id_get(
14086 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14088 if (gbl_driver_id == -1) {
14089 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
14090 return TEST_SKIPPED;
14093 return unit_test_suite_runner(&cryptodev_testsuite);
14097 test_cryptodev_aesni_gcm(void)
14099 gbl_driver_id = rte_cryptodev_driver_id_get(
14100 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14102 if (gbl_driver_id == -1) {
14103 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14104 return TEST_SKIPPED;
14107 return unit_test_suite_runner(&cryptodev_testsuite);
14111 test_cryptodev_cpu_aesni_gcm(void)
14114 enum rte_security_session_action_type at;
14116 gbl_driver_id = rte_cryptodev_driver_id_get(
14117 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14119 if (gbl_driver_id == -1) {
14120 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14121 return TEST_SKIPPED;
14124 at = gbl_action_type;
14125 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14126 rc = unit_test_suite_runner(&cryptodev_testsuite);
14127 gbl_action_type = at;
14132 test_cryptodev_null(void)
14134 gbl_driver_id = rte_cryptodev_driver_id_get(
14135 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14137 if (gbl_driver_id == -1) {
14138 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
14139 return TEST_SKIPPED;
14142 return unit_test_suite_runner(&cryptodev_testsuite);
14146 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14148 gbl_driver_id = rte_cryptodev_driver_id_get(
14149 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14151 if (gbl_driver_id == -1) {
14152 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
14153 return TEST_SKIPPED;
14156 return unit_test_suite_runner(&cryptodev_testsuite);
14160 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14162 gbl_driver_id = rte_cryptodev_driver_id_get(
14163 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14165 if (gbl_driver_id == -1) {
14166 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14167 return TEST_SKIPPED;
14170 return unit_test_suite_runner(&cryptodev_testsuite);
14174 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14176 gbl_driver_id = rte_cryptodev_driver_id_get(
14177 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14179 if (gbl_driver_id == -1) {
14180 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14181 return TEST_SKIPPED;
14184 return unit_test_suite_runner(&cryptodev_testsuite);
14188 test_cryptodev_armv8(void)
14190 gbl_driver_id = rte_cryptodev_driver_id_get(
14191 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14193 if (gbl_driver_id == -1) {
14194 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
14195 return TEST_SKIPPED;
14198 return unit_test_suite_runner(&cryptodev_testsuite);
14202 test_cryptodev_mrvl(void)
14204 gbl_driver_id = rte_cryptodev_driver_id_get(
14205 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14207 if (gbl_driver_id == -1) {
14208 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
14209 return TEST_SKIPPED;
14212 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14215 #ifdef RTE_CRYPTO_SCHEDULER
14218 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14220 gbl_driver_id = rte_cryptodev_driver_id_get(
14221 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14223 if (gbl_driver_id == -1) {
14224 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14225 return TEST_SKIPPED;
14228 if (rte_cryptodev_driver_id_get(
14229 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14230 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14231 return TEST_SKIPPED;
14233 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14236 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14241 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14243 gbl_driver_id = rte_cryptodev_driver_id_get(
14244 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14246 if (gbl_driver_id == -1) {
14247 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
14248 return TEST_SKIPPED;
14251 return unit_test_suite_runner(&cryptodev_testsuite);
14255 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14257 gbl_driver_id = rte_cryptodev_driver_id_get(
14258 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14260 if (gbl_driver_id == -1) {
14261 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
14262 return TEST_SKIPPED;
14265 return unit_test_suite_runner(&cryptodev_testsuite);
14269 test_cryptodev_ccp(void)
14271 gbl_driver_id = rte_cryptodev_driver_id_get(
14272 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14274 if (gbl_driver_id == -1) {
14275 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
14276 return TEST_FAILED;
14279 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14283 test_cryptodev_octeontx(void)
14285 gbl_driver_id = rte_cryptodev_driver_id_get(
14286 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14287 if (gbl_driver_id == -1) {
14288 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
14289 return TEST_FAILED;
14291 return unit_test_suite_runner(&cryptodev_testsuite);
14295 test_cryptodev_octeontx2(void)
14297 gbl_driver_id = rte_cryptodev_driver_id_get(
14298 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14299 if (gbl_driver_id == -1) {
14300 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
14301 return TEST_FAILED;
14303 return unit_test_suite_runner(&cryptodev_testsuite);
14307 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14309 gbl_driver_id = rte_cryptodev_driver_id_get(
14310 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14312 if (gbl_driver_id == -1) {
14313 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
14314 return TEST_FAILED;
14317 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14321 test_cryptodev_nitrox(void)
14323 gbl_driver_id = rte_cryptodev_driver_id_get(
14324 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14326 if (gbl_driver_id == -1) {
14327 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
14328 return TEST_FAILED;
14331 return unit_test_suite_runner(&cryptodev_testsuite);
14335 test_cryptodev_bcmfs(void)
14337 gbl_driver_id = rte_cryptodev_driver_id_get(
14338 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14340 if (gbl_driver_id == -1) {
14341 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
14342 return TEST_FAILED;
14345 return unit_test_suite_runner(&cryptodev_testsuite);
14349 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14353 gbl_driver_id = rte_cryptodev_driver_id_get(
14354 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14356 if (gbl_driver_id == -1) {
14357 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14358 return TEST_SKIPPED;
14361 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14362 ret = unit_test_suite_runner(&cryptodev_testsuite);
14363 global_api_test_type = CRYPTODEV_API_TEST;
14368 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14369 test_cryptodev_qat_raw_api);
14370 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14371 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14372 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14373 test_cryptodev_cpu_aesni_mb);
14374 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14375 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14376 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14377 test_cryptodev_cpu_aesni_gcm);
14378 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14379 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14380 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14381 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14382 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14383 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14384 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14385 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14386 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14387 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14388 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14389 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14390 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14391 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14392 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);