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 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
167 uint8_t is_op_success)
169 struct rte_crypto_op *op = user_data;
170 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
171 RTE_CRYPTO_OP_STATUS_ERROR;
175 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
176 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
177 uint8_t len_in_bits, uint8_t cipher_iv_len)
179 struct rte_crypto_sym_op *sop = op->sym;
180 struct rte_crypto_op *ret_op = NULL;
181 struct rte_crypto_vec data_vec[UINT8_MAX];
182 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
183 union rte_crypto_sym_ofs ofs;
184 struct rte_crypto_sym_vec vec;
185 struct rte_crypto_sgl sgl;
187 union rte_cryptodev_session_ctx sess;
189 struct rte_crypto_raw_dp_ctx *ctx;
190 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
194 int ctx_service_size;
196 int enqueue_status, dequeue_status;
198 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
199 if (ctx_service_size < 0) {
200 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
204 ctx = malloc(ctx_service_size);
206 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
210 /* Both are enums, setting crypto_sess will suit any session type */
211 sess.crypto_sess = op->sym->session;
213 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
214 op->sess_type, sess, 0) < 0) {
215 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
221 aad_auth_iv.iova = 0;
222 aad_auth_iv.va = NULL;
229 vec.digest = &digest;
230 vec.aad = &aad_auth_iv;
231 vec.status = &status;
235 if (is_cipher && is_auth) {
236 cipher_offset = sop->cipher.data.offset;
237 cipher_len = sop->cipher.data.length;
238 auth_offset = sop->auth.data.offset;
239 auth_len = sop->auth.data.length;
240 max_len = RTE_MAX(cipher_offset + cipher_len,
241 auth_offset + auth_len);
243 max_len = max_len >> 3;
244 cipher_offset = cipher_offset >> 3;
245 auth_offset = auth_offset >> 3;
246 cipher_len = cipher_len >> 3;
247 auth_len = auth_len >> 3;
249 ofs.ofs.cipher.head = cipher_offset;
250 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
251 ofs.ofs.auth.head = auth_offset;
252 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
253 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
254 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
255 aad_auth_iv.va = rte_crypto_op_ctod_offset(
256 op, void *, IV_OFFSET + cipher_iv_len);
257 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
259 digest.va = (void *)sop->auth.digest.data;
260 digest.iova = sop->auth.digest.phys_addr;
262 } else if (is_cipher) {
263 cipher_offset = sop->cipher.data.offset;
264 cipher_len = sop->cipher.data.length;
265 max_len = cipher_len + cipher_offset;
267 max_len = max_len >> 3;
268 cipher_offset = cipher_offset >> 3;
269 cipher_len = cipher_len >> 3;
271 ofs.ofs.cipher.head = cipher_offset;
272 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
273 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
274 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
276 } else if (is_auth) {
277 auth_offset = sop->auth.data.offset;
278 auth_len = sop->auth.data.length;
279 max_len = auth_len + auth_offset;
281 max_len = max_len >> 3;
282 auth_offset = auth_offset >> 3;
283 auth_len = auth_len >> 3;
285 ofs.ofs.auth.head = auth_offset;
286 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
287 aad_auth_iv.va = rte_crypto_op_ctod_offset(
288 op, void *, IV_OFFSET + cipher_iv_len);
289 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
291 digest.va = (void *)sop->auth.digest.data;
292 digest.iova = sop->auth.digest.phys_addr;
295 cipher_offset = sop->aead.data.offset;
296 cipher_len = sop->aead.data.length;
297 max_len = cipher_len + cipher_offset;
299 max_len = max_len >> 3;
300 cipher_offset = cipher_offset >> 3;
301 cipher_len = cipher_len >> 3;
303 ofs.ofs.cipher.head = cipher_offset;
304 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
305 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
306 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
307 aad_auth_iv.va = (void *)sop->aead.aad.data;
308 aad_auth_iv.iova = sop->aead.aad.phys_addr;
309 digest.va = (void *)sop->aead.digest.data;
310 digest.iova = sop->aead.digest.phys_addr;
313 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
314 data_vec, RTE_DIM(data_vec));
315 if (n < 0 || n > sop->m_src->nb_segs) {
316 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
322 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
323 &enqueue_status) < 1) {
324 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
328 if (enqueue_status == 0) {
329 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
331 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
334 } else if (enqueue_status < 0) {
335 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
340 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
341 n = rte_cryptodev_raw_dequeue_burst(ctx,
342 NULL, 1, post_process_raw_dp_op,
343 (void **)&ret_op, 0, &n_success,
345 if (dequeue_status < 0) {
346 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
353 if (n == 1 && dequeue_status == 0) {
354 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
355 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
360 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
361 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
362 RTE_CRYPTO_OP_STATUS_SUCCESS;
369 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
372 struct rte_crypto_sym_op *sop;
373 union rte_crypto_sym_ofs ofs;
374 struct rte_crypto_sgl sgl;
375 struct rte_crypto_sym_vec symvec;
376 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
377 struct rte_crypto_vec vec[UINT8_MAX];
381 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
382 sop->aead.data.length, vec, RTE_DIM(vec));
384 if (n < 0 || n != sop->m_src->nb_segs) {
385 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
393 symvec.digest = &digest_ptr;
394 symvec.aad = &aad_ptr;
398 /* for CPU crypto the IOVA address is not required */
399 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
400 digest_ptr.va = (void *)sop->aead.digest.data;
401 aad_ptr.va = (void *)sop->aead.aad.data;
405 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
409 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
411 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
415 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
418 struct rte_crypto_sym_op *sop;
419 union rte_crypto_sym_ofs ofs;
420 struct rte_crypto_sgl sgl;
421 struct rte_crypto_sym_vec symvec;
422 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
423 struct rte_crypto_vec vec[UINT8_MAX];
427 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
428 sop->auth.data.length, vec, RTE_DIM(vec));
430 if (n < 0 || n != sop->m_src->nb_segs) {
431 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
439 symvec.digest = &digest_ptr;
443 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
444 digest_ptr.va = (void *)sop->auth.digest.data;
447 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
448 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
449 (sop->cipher.data.offset + sop->cipher.data.length);
451 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
455 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
457 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
460 static struct rte_crypto_op *
461 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
464 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
466 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
467 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
473 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
476 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
477 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
484 static struct crypto_testsuite_params testsuite_params = { NULL };
485 static struct crypto_unittest_params unittest_params;
488 testsuite_setup(void)
490 struct crypto_testsuite_params *ts_params = &testsuite_params;
491 struct rte_cryptodev_info info;
492 uint32_t i = 0, nb_devs, dev_id;
496 memset(ts_params, 0, sizeof(*ts_params));
498 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
499 if (ts_params->mbuf_pool == NULL) {
500 /* Not already created so create */
501 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
503 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
505 if (ts_params->mbuf_pool == NULL) {
506 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
511 ts_params->large_mbuf_pool = rte_mempool_lookup(
512 "CRYPTO_LARGE_MBUFPOOL");
513 if (ts_params->large_mbuf_pool == NULL) {
514 /* Not already created so create */
515 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
516 "CRYPTO_LARGE_MBUFPOOL",
519 if (ts_params->large_mbuf_pool == NULL) {
521 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
526 ts_params->op_mpool = rte_crypto_op_pool_create(
527 "MBUF_CRYPTO_SYM_OP_POOL",
528 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
529 NUM_MBUFS, MBUF_CACHE_SIZE,
531 sizeof(struct rte_crypto_sym_xform) +
534 if (ts_params->op_mpool == NULL) {
535 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
539 /* Create an AESNI MB device if required */
540 if (gbl_driver_id == rte_cryptodev_driver_id_get(
541 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
542 nb_devs = rte_cryptodev_device_count_by_driver(
543 rte_cryptodev_driver_id_get(
544 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
547 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
549 TEST_ASSERT(ret == 0,
550 "Failed to create instance of"
552 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
556 /* Create an AESNI GCM device if required */
557 if (gbl_driver_id == rte_cryptodev_driver_id_get(
558 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
559 nb_devs = rte_cryptodev_device_count_by_driver(
560 rte_cryptodev_driver_id_get(
561 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
563 TEST_ASSERT_SUCCESS(rte_vdev_init(
564 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
565 "Failed to create instance of"
567 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
571 /* Create a SNOW 3G device if required */
572 if (gbl_driver_id == rte_cryptodev_driver_id_get(
573 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
574 nb_devs = rte_cryptodev_device_count_by_driver(
575 rte_cryptodev_driver_id_get(
576 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
578 TEST_ASSERT_SUCCESS(rte_vdev_init(
579 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
580 "Failed to create instance of"
582 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
586 /* Create a KASUMI device if required */
587 if (gbl_driver_id == rte_cryptodev_driver_id_get(
588 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
589 nb_devs = rte_cryptodev_device_count_by_driver(
590 rte_cryptodev_driver_id_get(
591 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
593 TEST_ASSERT_SUCCESS(rte_vdev_init(
594 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
595 "Failed to create instance of"
597 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
601 /* Create a ZUC device if required */
602 if (gbl_driver_id == rte_cryptodev_driver_id_get(
603 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
604 nb_devs = rte_cryptodev_device_count_by_driver(
605 rte_cryptodev_driver_id_get(
606 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
608 TEST_ASSERT_SUCCESS(rte_vdev_init(
609 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
610 "Failed to create instance of"
612 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
616 /* Create a NULL device if required */
617 if (gbl_driver_id == rte_cryptodev_driver_id_get(
618 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
619 nb_devs = rte_cryptodev_device_count_by_driver(
620 rte_cryptodev_driver_id_get(
621 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
624 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
626 TEST_ASSERT(ret == 0,
627 "Failed to create instance of"
629 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
633 /* Create an OPENSSL device if required */
634 if (gbl_driver_id == rte_cryptodev_driver_id_get(
635 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
636 nb_devs = rte_cryptodev_device_count_by_driver(
637 rte_cryptodev_driver_id_get(
638 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
641 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
644 TEST_ASSERT(ret == 0, "Failed to create "
645 "instance of pmd : %s",
646 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
650 /* Create a ARMv8 device if required */
651 if (gbl_driver_id == rte_cryptodev_driver_id_get(
652 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
653 nb_devs = rte_cryptodev_device_count_by_driver(
654 rte_cryptodev_driver_id_get(
655 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
658 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
661 TEST_ASSERT(ret == 0, "Failed to create "
662 "instance of pmd : %s",
663 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
667 /* Create a MVSAM device if required */
668 if (gbl_driver_id == rte_cryptodev_driver_id_get(
669 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
670 nb_devs = rte_cryptodev_device_count_by_driver(
671 rte_cryptodev_driver_id_get(
672 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
675 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
678 TEST_ASSERT(ret == 0, "Failed to create "
679 "instance of pmd : %s",
680 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
684 /* Create an CCP device if required */
685 if (gbl_driver_id == rte_cryptodev_driver_id_get(
686 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
687 nb_devs = rte_cryptodev_device_count_by_driver(
688 rte_cryptodev_driver_id_get(
689 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
692 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
695 TEST_ASSERT(ret == 0, "Failed to create "
696 "instance of pmd : %s",
697 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
701 #ifdef RTE_CRYPTO_SCHEDULER
702 char vdev_args[VDEV_ARGS_SIZE] = {""};
703 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
704 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
705 uint16_t worker_core_count = 0;
706 uint16_t socket_id = 0;
708 if (gbl_driver_id == rte_cryptodev_driver_id_get(
709 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
711 /* Identify the Worker Cores
712 * Use 2 worker cores for the device args
714 RTE_LCORE_FOREACH_WORKER(i) {
715 if (worker_core_count > 1)
717 snprintf(vdev_args, sizeof(vdev_args),
718 "%s%d", temp_str, i);
719 strcpy(temp_str, vdev_args);
720 strlcat(temp_str, ";", sizeof(temp_str));
722 socket_id = rte_lcore_to_socket_id(i);
724 if (worker_core_count != 2) {
726 "Cryptodev scheduler test require at least "
727 "two worker cores to run. "
728 "Please use the correct coremask.\n");
731 strcpy(temp_str, vdev_args);
732 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
733 temp_str, socket_id);
734 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
735 nb_devs = rte_cryptodev_device_count_by_driver(
736 rte_cryptodev_driver_id_get(
737 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
740 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
742 TEST_ASSERT(ret == 0,
743 "Failed to create instance %u of"
745 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
748 #endif /* RTE_CRYPTO_SCHEDULER */
750 nb_devs = rte_cryptodev_count();
752 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
756 /* Create list of valid crypto devs */
757 for (i = 0; i < nb_devs; i++) {
758 rte_cryptodev_info_get(i, &info);
759 if (info.driver_id == gbl_driver_id)
760 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
763 if (ts_params->valid_dev_count < 1)
766 /* Set up all the qps on the first of the valid devices found */
768 dev_id = ts_params->valid_devs[0];
770 rte_cryptodev_info_get(dev_id, &info);
772 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
773 ts_params->conf.socket_id = SOCKET_ID_ANY;
774 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
776 unsigned int session_size =
777 rte_cryptodev_sym_get_private_session_size(dev_id);
779 #ifdef RTE_LIB_SECURITY
780 unsigned int security_session_size = rte_security_session_get_size(
781 rte_cryptodev_get_sec_ctx(dev_id));
783 if (session_size < security_session_size)
784 session_size = security_session_size;
787 * Create mempool with maximum number of sessions.
789 if (info.sym.max_nb_sessions != 0 &&
790 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
791 RTE_LOG(ERR, USER1, "Device does not support "
792 "at least %u sessions\n",
797 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
798 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
800 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
801 "session mempool allocation failed");
803 ts_params->session_priv_mpool = rte_mempool_create(
807 0, 0, NULL, NULL, NULL,
810 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
811 "session mempool allocation failed");
815 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
817 "Failed to configure cryptodev %u with %u qps",
818 dev_id, ts_params->conf.nb_queue_pairs);
820 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
821 ts_params->qp_conf.mp_session = ts_params->session_mpool;
822 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
824 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
825 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
826 dev_id, qp_id, &ts_params->qp_conf,
827 rte_cryptodev_socket_id(dev_id)),
828 "Failed to setup queue pair %u on cryptodev %u",
836 testsuite_teardown(void)
838 struct crypto_testsuite_params *ts_params = &testsuite_params;
841 if (ts_params->mbuf_pool != NULL) {
842 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
843 rte_mempool_avail_count(ts_params->mbuf_pool));
846 if (ts_params->op_mpool != NULL) {
847 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
848 rte_mempool_avail_count(ts_params->op_mpool));
851 /* Free session mempools */
852 if (ts_params->session_priv_mpool != NULL) {
853 rte_mempool_free(ts_params->session_priv_mpool);
854 ts_params->session_priv_mpool = NULL;
857 if (ts_params->session_mpool != NULL) {
858 rte_mempool_free(ts_params->session_mpool);
859 ts_params->session_mpool = NULL;
862 res = rte_cryptodev_close(ts_params->valid_devs[0]);
864 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
868 dev_configure_and_start(uint64_t ff_disable)
870 struct crypto_testsuite_params *ts_params = &testsuite_params;
871 struct crypto_unittest_params *ut_params = &unittest_params;
875 /* Clear unit test parameters before running test */
876 memset(ut_params, 0, sizeof(*ut_params));
878 /* Reconfigure device to default parameters */
879 ts_params->conf.socket_id = SOCKET_ID_ANY;
880 ts_params->conf.ff_disable = ff_disable;
881 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
882 ts_params->qp_conf.mp_session = ts_params->session_mpool;
883 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
885 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
887 "Failed to configure cryptodev %u",
888 ts_params->valid_devs[0]);
890 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
891 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
892 ts_params->valid_devs[0], qp_id,
894 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
895 "Failed to setup queue pair %u on cryptodev %u",
896 qp_id, ts_params->valid_devs[0]);
900 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
902 /* Start the device */
903 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
904 "Failed to start cryptodev %u",
905 ts_params->valid_devs[0]);
913 /* Configure and start the device with security feature disabled */
914 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
918 ut_setup_security(void)
920 /* Configure and start the device with no features disabled */
921 return dev_configure_and_start(0);
927 struct crypto_testsuite_params *ts_params = &testsuite_params;
928 struct crypto_unittest_params *ut_params = &unittest_params;
929 struct rte_cryptodev_stats stats;
931 /* free crypto session structure */
932 #ifdef RTE_LIB_SECURITY
933 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
934 if (ut_params->sec_session) {
935 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
936 (ts_params->valid_devs[0]),
937 ut_params->sec_session);
938 ut_params->sec_session = NULL;
943 if (ut_params->sess) {
944 rte_cryptodev_sym_session_clear(
945 ts_params->valid_devs[0],
947 rte_cryptodev_sym_session_free(ut_params->sess);
948 ut_params->sess = NULL;
952 /* free crypto operation structure */
954 rte_crypto_op_free(ut_params->op);
957 * free mbuf - both obuf and ibuf are usually the same,
958 * so check if they point at the same address is necessary,
959 * to avoid freeing the mbuf twice.
961 if (ut_params->obuf) {
962 rte_pktmbuf_free(ut_params->obuf);
963 if (ut_params->ibuf == ut_params->obuf)
967 if (ut_params->ibuf) {
968 rte_pktmbuf_free(ut_params->ibuf);
972 if (ts_params->mbuf_pool != NULL)
973 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
974 rte_mempool_avail_count(ts_params->mbuf_pool));
976 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
978 /* Stop the device */
979 rte_cryptodev_stop(ts_params->valid_devs[0]);
983 test_device_configure_invalid_dev_id(void)
985 struct crypto_testsuite_params *ts_params = &testsuite_params;
986 uint16_t dev_id, num_devs = 0;
988 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
989 "Need at least %d devices for test", 1);
991 /* valid dev_id values */
992 dev_id = ts_params->valid_devs[0];
994 /* Stop the device in case it's started so it can be configured */
995 rte_cryptodev_stop(dev_id);
997 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
998 "Failed test for rte_cryptodev_configure: "
999 "invalid dev_num %u", dev_id);
1001 /* invalid dev_id values */
1004 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1005 "Failed test for rte_cryptodev_configure: "
1006 "invalid dev_num %u", dev_id);
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);
1014 return TEST_SUCCESS;
1018 test_device_configure_invalid_queue_pair_ids(void)
1020 struct crypto_testsuite_params *ts_params = &testsuite_params;
1021 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1023 /* Stop the device in case it's started so it can be configured */
1024 rte_cryptodev_stop(ts_params->valid_devs[0]);
1026 /* valid - max value queue pairs */
1027 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1029 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1031 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1032 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1034 /* valid - one queue pairs */
1035 ts_params->conf.nb_queue_pairs = 1;
1037 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1039 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1040 ts_params->valid_devs[0],
1041 ts_params->conf.nb_queue_pairs);
1044 /* invalid - zero queue pairs */
1045 ts_params->conf.nb_queue_pairs = 0;
1047 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1049 "Failed test for rte_cryptodev_configure, dev_id %u,"
1051 ts_params->valid_devs[0],
1052 ts_params->conf.nb_queue_pairs);
1055 /* invalid - max value supported by field queue pairs */
1056 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1058 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1060 "Failed test for rte_cryptodev_configure, dev_id %u,"
1062 ts_params->valid_devs[0],
1063 ts_params->conf.nb_queue_pairs);
1066 /* invalid - max value + 1 queue pairs */
1067 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1069 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1071 "Failed test for rte_cryptodev_configure, dev_id %u,"
1073 ts_params->valid_devs[0],
1074 ts_params->conf.nb_queue_pairs);
1076 /* revert to original testsuite value */
1077 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1079 return TEST_SUCCESS;
1083 test_queue_pair_descriptor_setup(void)
1085 struct crypto_testsuite_params *ts_params = &testsuite_params;
1086 struct rte_cryptodev_qp_conf qp_conf = {
1087 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1091 /* Stop the device in case it's started so it can be configured */
1092 rte_cryptodev_stop(ts_params->valid_devs[0]);
1094 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1096 "Failed to configure cryptodev %u",
1097 ts_params->valid_devs[0]);
1100 * Test various ring sizes on this device. memzones can't be
1101 * freed so are re-used if ring is released and re-created.
1103 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1104 qp_conf.mp_session = ts_params->session_mpool;
1105 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1107 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1108 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1109 ts_params->valid_devs[0], qp_id, &qp_conf,
1110 rte_cryptodev_socket_id(
1111 ts_params->valid_devs[0])),
1113 "rte_cryptodev_queue_pair_setup: num_inflights "
1114 "%u on qp %u on cryptodev %u",
1115 qp_conf.nb_descriptors, qp_id,
1116 ts_params->valid_devs[0]);
1119 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1121 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1122 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1123 ts_params->valid_devs[0], qp_id, &qp_conf,
1124 rte_cryptodev_socket_id(
1125 ts_params->valid_devs[0])),
1127 " rte_cryptodev_queue_pair_setup: num_inflights"
1128 " %u on qp %u on cryptodev %u",
1129 qp_conf.nb_descriptors, qp_id,
1130 ts_params->valid_devs[0]);
1133 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1135 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1136 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1137 ts_params->valid_devs[0], qp_id, &qp_conf,
1138 rte_cryptodev_socket_id(
1139 ts_params->valid_devs[0])),
1141 "rte_cryptodev_queue_pair_setup: num_inflights"
1142 " %u on qp %u on cryptodev %u",
1143 qp_conf.nb_descriptors, qp_id,
1144 ts_params->valid_devs[0]);
1147 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1149 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1150 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1151 ts_params->valid_devs[0], qp_id, &qp_conf,
1152 rte_cryptodev_socket_id(
1153 ts_params->valid_devs[0])),
1155 " rte_cryptodev_queue_pair_setup:"
1156 "num_inflights %u on qp %u on cryptodev %u",
1157 qp_conf.nb_descriptors, qp_id,
1158 ts_params->valid_devs[0]);
1161 /* test invalid queue pair id */
1162 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1164 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1166 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1167 ts_params->valid_devs[0],
1169 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1170 "Failed test for rte_cryptodev_queue_pair_setup:"
1171 "invalid qp %u on cryptodev %u",
1172 qp_id, ts_params->valid_devs[0]);
1174 qp_id = 0xffff; /*invalid*/
1176 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1177 ts_params->valid_devs[0],
1179 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1180 "Failed test for rte_cryptodev_queue_pair_setup:"
1181 "invalid qp %u on cryptodev %u",
1182 qp_id, ts_params->valid_devs[0]);
1184 return TEST_SUCCESS;
1187 /* ***** Plaintext data for tests ***** */
1189 const char catch_22_quote_1[] =
1190 "There was only one catch and that was Catch-22, which "
1191 "specified that a concern for one's safety in the face of "
1192 "dangers that were real and immediate was the process of a "
1193 "rational mind. Orr was crazy and could be grounded. All he "
1194 "had to do was ask; and as soon as he did, he would no longer "
1195 "be crazy and would have to fly more missions. Orr would be "
1196 "crazy to fly more missions and sane if he didn't, but if he "
1197 "was sane he had to fly them. If he flew them he was crazy "
1198 "and didn't have to; but if he didn't want to he was sane and "
1199 "had to. Yossarian was moved very deeply by the absolute "
1200 "simplicity of this clause of Catch-22 and let out a "
1201 "respectful whistle. \"That's some catch, that Catch-22\", he "
1202 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1204 const char catch_22_quote[] =
1205 "What a lousy earth! He wondered how many people were "
1206 "destitute that same night even in his own prosperous country, "
1207 "how many homes were shanties, how many husbands were drunk "
1208 "and wives socked, and how many children were bullied, abused, "
1209 "or abandoned. How many families hungered for food they could "
1210 "not afford to buy? How many hearts were broken? How many "
1211 "suicides would take place that same night, how many people "
1212 "would go insane? How many cockroaches and landlords would "
1213 "triumph? How many winners were losers, successes failures, "
1214 "and rich men poor men? How many wise guys were stupid? How "
1215 "many happy endings were unhappy endings? How many honest men "
1216 "were liars, brave men cowards, loyal men traitors, how many "
1217 "sainted men were corrupt, how many people in positions of "
1218 "trust had sold their souls to bodyguards, how many had never "
1219 "had souls? How many straight-and-narrow paths were crooked "
1220 "paths? How many best families were worst families and how "
1221 "many good people were bad people? When you added them all up "
1222 "and then subtracted, you might be left with only the children, "
1223 "and perhaps with Albert Einstein and an old violinist or "
1224 "sculptor somewhere.";
1226 #define QUOTE_480_BYTES (480)
1227 #define QUOTE_512_BYTES (512)
1228 #define QUOTE_768_BYTES (768)
1229 #define QUOTE_1024_BYTES (1024)
1233 /* ***** SHA1 Hash Tests ***** */
1235 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1237 static uint8_t hmac_sha1_key[] = {
1238 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1239 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1240 0xDE, 0xF4, 0xDE, 0xAD };
1242 /* ***** SHA224 Hash Tests ***** */
1244 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1247 /* ***** AES-CBC Cipher Tests ***** */
1249 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1250 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1252 static uint8_t aes_cbc_key[] = {
1253 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1254 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1256 static uint8_t aes_cbc_iv[] = {
1257 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1258 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1261 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1263 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1264 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1265 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1266 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1267 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1268 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1269 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1270 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1271 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1272 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1273 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1274 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1275 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1276 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1277 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1278 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1279 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1280 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1281 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1282 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1283 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1284 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1285 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1286 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1287 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1288 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1289 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1290 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1291 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1292 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1293 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1294 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1295 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1296 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1297 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1298 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1299 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1300 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1301 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1302 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1303 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1304 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1305 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1306 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1307 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1308 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1309 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1310 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1311 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1312 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1313 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1314 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1315 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1316 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1317 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1318 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1319 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1320 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1321 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1322 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1323 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1324 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1325 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1326 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1327 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1330 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1331 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1332 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1333 0x18, 0x8c, 0x1d, 0x32
1337 /* Multisession Vector context Test */
1338 /*Begin Session 0 */
1339 static uint8_t ms_aes_cbc_key0[] = {
1340 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1341 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1344 static uint8_t ms_aes_cbc_iv0[] = {
1345 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1346 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1349 static const uint8_t ms_aes_cbc_cipher0[] = {
1350 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1351 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1352 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1353 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1354 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1355 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1356 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1357 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1358 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1359 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1360 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1361 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1362 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1363 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1364 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1365 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1366 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1367 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1368 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1369 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1370 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1371 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1372 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1373 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1374 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1375 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1376 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1377 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1378 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1379 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1380 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1381 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1382 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1383 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1384 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1385 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1386 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1387 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1388 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1389 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1390 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1391 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1392 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1393 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1394 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1395 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1396 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1397 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1398 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1399 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1400 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1401 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1402 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1403 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1404 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1405 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1406 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1407 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1408 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1409 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1410 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1411 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1412 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1413 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1417 static uint8_t ms_hmac_key0[] = {
1418 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1419 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1420 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1421 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1422 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1423 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1424 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1425 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1428 static const uint8_t ms_hmac_digest0[] = {
1429 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1430 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1431 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1432 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1433 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1434 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1435 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1436 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1440 /* Begin session 1 */
1442 static uint8_t ms_aes_cbc_key1[] = {
1443 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1444 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1447 static uint8_t ms_aes_cbc_iv1[] = {
1448 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1449 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1452 static const uint8_t ms_aes_cbc_cipher1[] = {
1453 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1454 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1455 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1456 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1457 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1458 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1459 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1460 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1461 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1462 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1463 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1464 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1465 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1466 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1467 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1468 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1469 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1470 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1471 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1472 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1473 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1474 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1475 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1476 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1477 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1478 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1479 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1480 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1481 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1482 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1483 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1484 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1485 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1486 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1487 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1488 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1489 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1490 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1491 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1492 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1493 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1494 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1495 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1496 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1497 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1498 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1499 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1500 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1501 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1502 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1503 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1504 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1505 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1506 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1507 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1508 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1509 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1510 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1511 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1512 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1513 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1514 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1515 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1516 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1520 static uint8_t ms_hmac_key1[] = {
1521 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1522 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1523 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1524 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1525 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1526 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1527 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1528 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1531 static const uint8_t ms_hmac_digest1[] = {
1532 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1533 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1534 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1535 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1536 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1537 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1538 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1539 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1542 /* Begin Session 2 */
1543 static uint8_t ms_aes_cbc_key2[] = {
1544 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1545 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1548 static uint8_t ms_aes_cbc_iv2[] = {
1549 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1550 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1553 static const uint8_t ms_aes_cbc_cipher2[] = {
1554 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1555 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1556 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1557 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1558 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1559 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1560 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1561 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1562 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1563 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1564 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1565 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1566 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1567 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1568 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1569 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1570 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1571 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1572 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1573 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1574 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1575 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1576 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1577 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1578 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1579 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1580 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1581 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1582 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1583 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1584 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1585 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1586 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1587 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1588 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1589 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1590 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1591 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1592 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1593 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1594 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1595 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1596 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1597 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1598 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1599 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1600 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1601 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1602 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1603 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1604 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1605 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1606 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1607 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1608 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1609 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1610 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1611 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1612 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1613 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1614 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1615 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1616 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1617 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1620 static uint8_t ms_hmac_key2[] = {
1621 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1622 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1623 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1624 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1625 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1626 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1627 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1628 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1631 static const uint8_t ms_hmac_digest2[] = {
1632 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1633 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1634 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1635 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1636 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1637 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1638 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1639 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1646 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1648 struct crypto_testsuite_params *ts_params = &testsuite_params;
1649 struct crypto_unittest_params *ut_params = &unittest_params;
1651 /* Verify the capabilities */
1652 struct rte_cryptodev_sym_capability_idx cap_idx;
1653 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1654 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1655 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1658 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1659 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1660 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1664 /* Generate test mbuf data and space for digest */
1665 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1666 catch_22_quote, QUOTE_512_BYTES, 0);
1668 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1669 DIGEST_BYTE_LENGTH_SHA1);
1670 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1672 /* Setup Cipher Parameters */
1673 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1674 ut_params->cipher_xform.next = &ut_params->auth_xform;
1676 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1677 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1678 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1679 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1680 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1681 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1683 /* Setup HMAC Parameters */
1684 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1686 ut_params->auth_xform.next = NULL;
1688 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1689 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1690 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1691 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1692 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1694 ut_params->sess = rte_cryptodev_sym_session_create(
1695 ts_params->session_mpool);
1697 /* Create crypto session*/
1698 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1699 ut_params->sess, &ut_params->cipher_xform,
1700 ts_params->session_priv_mpool);
1701 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1703 /* Generate crypto op data structure */
1704 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1705 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1706 TEST_ASSERT_NOT_NULL(ut_params->op,
1707 "Failed to allocate symmetric crypto operation struct");
1709 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1711 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1713 /* set crypto operation source mbuf */
1714 sym_op->m_src = ut_params->ibuf;
1716 /* Set crypto operation authentication parameters */
1717 sym_op->auth.digest.data = ut_params->digest;
1718 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1719 ut_params->ibuf, QUOTE_512_BYTES);
1721 sym_op->auth.data.offset = 0;
1722 sym_op->auth.data.length = QUOTE_512_BYTES;
1724 /* Copy IV at the end of the crypto operation */
1725 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1726 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1728 /* Set crypto operation cipher parameters */
1729 sym_op->cipher.data.offset = 0;
1730 sym_op->cipher.data.length = QUOTE_512_BYTES;
1732 /* Process crypto operation */
1733 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1734 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1737 TEST_ASSERT_NOT_NULL(
1738 process_crypto_request(ts_params->valid_devs[0],
1740 "failed to process sym crypto op");
1742 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1743 "crypto op processing failed");
1746 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1749 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1750 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1752 "ciphertext data not as expected");
1754 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1756 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1757 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1758 gbl_driver_id == rte_cryptodev_driver_id_get(
1759 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1760 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1761 DIGEST_BYTE_LENGTH_SHA1,
1762 "Generated digest data not as expected");
1764 return TEST_SUCCESS;
1767 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1769 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1771 static uint8_t hmac_sha512_key[] = {
1772 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1773 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1774 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1775 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1776 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1777 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1778 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1779 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1781 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1782 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1783 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1784 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1785 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1786 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1787 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1788 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1789 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1794 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1795 struct crypto_unittest_params *ut_params,
1796 uint8_t *cipher_key,
1800 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1801 struct crypto_unittest_params *ut_params,
1802 struct crypto_testsuite_params *ts_params,
1803 const uint8_t *cipher,
1804 const uint8_t *digest,
1809 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1810 struct crypto_unittest_params *ut_params,
1811 uint8_t *cipher_key,
1815 /* Setup Cipher Parameters */
1816 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1817 ut_params->cipher_xform.next = NULL;
1819 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1820 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1821 ut_params->cipher_xform.cipher.key.data = cipher_key;
1822 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1823 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1824 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1826 /* Setup HMAC Parameters */
1827 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1828 ut_params->auth_xform.next = &ut_params->cipher_xform;
1830 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1831 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1832 ut_params->auth_xform.auth.key.data = hmac_key;
1833 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1834 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1836 return TEST_SUCCESS;
1841 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1842 struct crypto_unittest_params *ut_params,
1843 struct crypto_testsuite_params *ts_params,
1844 const uint8_t *cipher,
1845 const uint8_t *digest,
1848 /* Generate test mbuf data and digest */
1849 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1852 QUOTE_512_BYTES, 0);
1854 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1855 DIGEST_BYTE_LENGTH_SHA512);
1856 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1858 rte_memcpy(ut_params->digest,
1860 DIGEST_BYTE_LENGTH_SHA512);
1862 /* Generate Crypto op data structure */
1863 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1864 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1865 TEST_ASSERT_NOT_NULL(ut_params->op,
1866 "Failed to allocate symmetric crypto operation struct");
1868 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1870 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1872 /* set crypto operation source mbuf */
1873 sym_op->m_src = ut_params->ibuf;
1875 sym_op->auth.digest.data = ut_params->digest;
1876 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1877 ut_params->ibuf, QUOTE_512_BYTES);
1879 sym_op->auth.data.offset = 0;
1880 sym_op->auth.data.length = QUOTE_512_BYTES;
1882 /* Copy IV at the end of the crypto operation */
1883 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1884 iv, CIPHER_IV_LENGTH_AES_CBC);
1886 sym_op->cipher.data.offset = 0;
1887 sym_op->cipher.data.length = QUOTE_512_BYTES;
1889 /* Process crypto operation */
1890 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1891 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1893 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1894 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
1895 ut_params->op, 1, 1, 0, 0);
1897 TEST_ASSERT_NOT_NULL(
1898 process_crypto_request(ts_params->valid_devs[0],
1900 "failed to process sym crypto op");
1902 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1903 "crypto op processing failed");
1905 ut_params->obuf = ut_params->op->sym->m_src;
1908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1909 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1912 "Plaintext data not as expected");
1915 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1916 "Digest verification failed");
1918 return TEST_SUCCESS;
1922 test_blockcipher(enum blockcipher_test_type test_type)
1924 struct crypto_testsuite_params *ts_params = &testsuite_params;
1927 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1928 ts_params->op_mpool,
1929 ts_params->session_mpool, ts_params->session_priv_mpool,
1930 ts_params->valid_devs[0],
1933 if (status == -ENOTSUP)
1936 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1938 return TEST_SUCCESS;
1942 test_AES_cipheronly_all(void)
1944 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1948 test_AES_docsis_all(void)
1950 /* Data-path service does not support DOCSIS yet */
1951 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1953 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1957 test_DES_docsis_all(void)
1959 /* Data-path service does not support DOCSIS yet */
1960 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1962 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1966 test_DES_cipheronly_all(void)
1968 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1972 test_authonly_all(void)
1974 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1978 test_AES_chain_all(void)
1980 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1984 test_3DES_chain_all(void)
1986 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1990 test_3DES_cipheronly_all(void)
1992 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1995 /* ***** SNOW 3G Tests ***** */
1997 create_wireless_algo_hash_session(uint8_t dev_id,
1998 const uint8_t *key, const uint8_t key_len,
1999 const uint8_t iv_len, const uint8_t auth_len,
2000 enum rte_crypto_auth_operation op,
2001 enum rte_crypto_auth_algorithm algo)
2003 uint8_t hash_key[key_len];
2006 struct crypto_testsuite_params *ts_params = &testsuite_params;
2007 struct crypto_unittest_params *ut_params = &unittest_params;
2009 memcpy(hash_key, key, key_len);
2011 debug_hexdump(stdout, "key:", key, key_len);
2013 /* Setup Authentication Parameters */
2014 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2015 ut_params->auth_xform.next = NULL;
2017 ut_params->auth_xform.auth.op = op;
2018 ut_params->auth_xform.auth.algo = algo;
2019 ut_params->auth_xform.auth.key.length = key_len;
2020 ut_params->auth_xform.auth.key.data = hash_key;
2021 ut_params->auth_xform.auth.digest_length = auth_len;
2022 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2023 ut_params->auth_xform.auth.iv.length = iv_len;
2024 ut_params->sess = rte_cryptodev_sym_session_create(
2025 ts_params->session_mpool);
2027 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2028 &ut_params->auth_xform,
2029 ts_params->session_priv_mpool);
2030 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2031 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2036 create_wireless_algo_cipher_session(uint8_t dev_id,
2037 enum rte_crypto_cipher_operation op,
2038 enum rte_crypto_cipher_algorithm algo,
2039 const uint8_t *key, const uint8_t key_len,
2042 uint8_t cipher_key[key_len];
2044 struct crypto_testsuite_params *ts_params = &testsuite_params;
2045 struct crypto_unittest_params *ut_params = &unittest_params;
2047 memcpy(cipher_key, key, key_len);
2049 /* Setup Cipher Parameters */
2050 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2051 ut_params->cipher_xform.next = NULL;
2053 ut_params->cipher_xform.cipher.algo = algo;
2054 ut_params->cipher_xform.cipher.op = op;
2055 ut_params->cipher_xform.cipher.key.data = cipher_key;
2056 ut_params->cipher_xform.cipher.key.length = key_len;
2057 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2058 ut_params->cipher_xform.cipher.iv.length = iv_len;
2060 debug_hexdump(stdout, "key:", key, key_len);
2062 /* Create Crypto session */
2063 ut_params->sess = rte_cryptodev_sym_session_create(
2064 ts_params->session_mpool);
2066 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2067 &ut_params->cipher_xform,
2068 ts_params->session_priv_mpool);
2069 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2070 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2075 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2076 unsigned int cipher_len,
2077 unsigned int cipher_offset)
2079 struct crypto_testsuite_params *ts_params = &testsuite_params;
2080 struct crypto_unittest_params *ut_params = &unittest_params;
2082 /* Generate Crypto op data structure */
2083 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2084 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2085 TEST_ASSERT_NOT_NULL(ut_params->op,
2086 "Failed to allocate pktmbuf offload");
2088 /* Set crypto operation data parameters */
2089 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2091 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2093 /* set crypto operation source mbuf */
2094 sym_op->m_src = ut_params->ibuf;
2097 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2099 sym_op->cipher.data.length = cipher_len;
2100 sym_op->cipher.data.offset = cipher_offset;
2105 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2106 unsigned int cipher_len,
2107 unsigned int cipher_offset)
2109 struct crypto_testsuite_params *ts_params = &testsuite_params;
2110 struct crypto_unittest_params *ut_params = &unittest_params;
2112 /* Generate Crypto op data structure */
2113 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2114 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2115 TEST_ASSERT_NOT_NULL(ut_params->op,
2116 "Failed to allocate pktmbuf offload");
2118 /* Set crypto operation data parameters */
2119 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2121 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2123 /* set crypto operation source mbuf */
2124 sym_op->m_src = ut_params->ibuf;
2125 sym_op->m_dst = ut_params->obuf;
2128 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2130 sym_op->cipher.data.length = cipher_len;
2131 sym_op->cipher.data.offset = cipher_offset;
2136 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2137 enum rte_crypto_cipher_operation cipher_op,
2138 enum rte_crypto_auth_operation auth_op,
2139 enum rte_crypto_auth_algorithm auth_algo,
2140 enum rte_crypto_cipher_algorithm cipher_algo,
2141 const uint8_t *key, uint8_t key_len,
2142 uint8_t auth_iv_len, uint8_t auth_len,
2143 uint8_t cipher_iv_len)
2146 uint8_t cipher_auth_key[key_len];
2149 struct crypto_testsuite_params *ts_params = &testsuite_params;
2150 struct crypto_unittest_params *ut_params = &unittest_params;
2152 memcpy(cipher_auth_key, key, key_len);
2154 /* Setup Authentication Parameters */
2155 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2156 ut_params->auth_xform.next = NULL;
2158 ut_params->auth_xform.auth.op = auth_op;
2159 ut_params->auth_xform.auth.algo = auth_algo;
2160 ut_params->auth_xform.auth.key.length = key_len;
2161 /* Hash key = cipher key */
2162 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2163 ut_params->auth_xform.auth.digest_length = auth_len;
2164 /* Auth IV will be after cipher IV */
2165 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2166 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2168 /* Setup Cipher Parameters */
2169 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2170 ut_params->cipher_xform.next = &ut_params->auth_xform;
2172 ut_params->cipher_xform.cipher.algo = cipher_algo;
2173 ut_params->cipher_xform.cipher.op = cipher_op;
2174 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2175 ut_params->cipher_xform.cipher.key.length = key_len;
2176 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2177 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2179 debug_hexdump(stdout, "key:", key, key_len);
2181 /* Create Crypto session*/
2182 ut_params->sess = rte_cryptodev_sym_session_create(
2183 ts_params->session_mpool);
2184 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2186 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2187 &ut_params->cipher_xform,
2188 ts_params->session_priv_mpool);
2189 if (status == -ENOTSUP)
2192 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2197 create_wireless_cipher_auth_session(uint8_t dev_id,
2198 enum rte_crypto_cipher_operation cipher_op,
2199 enum rte_crypto_auth_operation auth_op,
2200 enum rte_crypto_auth_algorithm auth_algo,
2201 enum rte_crypto_cipher_algorithm cipher_algo,
2202 const struct wireless_test_data *tdata)
2204 const uint8_t key_len = tdata->key.len;
2205 uint8_t cipher_auth_key[key_len];
2208 struct crypto_testsuite_params *ts_params = &testsuite_params;
2209 struct crypto_unittest_params *ut_params = &unittest_params;
2210 const uint8_t *key = tdata->key.data;
2211 const uint8_t auth_len = tdata->digest.len;
2212 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2213 uint8_t auth_iv_len = tdata->auth_iv.len;
2215 memcpy(cipher_auth_key, key, key_len);
2217 /* Setup Authentication Parameters */
2218 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2219 ut_params->auth_xform.next = NULL;
2221 ut_params->auth_xform.auth.op = auth_op;
2222 ut_params->auth_xform.auth.algo = auth_algo;
2223 ut_params->auth_xform.auth.key.length = key_len;
2224 /* Hash key = cipher key */
2225 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2226 ut_params->auth_xform.auth.digest_length = auth_len;
2227 /* Auth IV will be after cipher IV */
2228 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2229 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2231 /* Setup Cipher Parameters */
2232 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2233 ut_params->cipher_xform.next = &ut_params->auth_xform;
2235 ut_params->cipher_xform.cipher.algo = cipher_algo;
2236 ut_params->cipher_xform.cipher.op = cipher_op;
2237 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2238 ut_params->cipher_xform.cipher.key.length = key_len;
2239 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2240 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2243 debug_hexdump(stdout, "key:", key, key_len);
2245 /* Create Crypto session*/
2246 ut_params->sess = rte_cryptodev_sym_session_create(
2247 ts_params->session_mpool);
2249 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2250 &ut_params->cipher_xform,
2251 ts_params->session_priv_mpool);
2252 if (status == -ENOTSUP)
2255 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2256 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2261 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2262 const struct wireless_test_data *tdata)
2264 return create_wireless_cipher_auth_session(dev_id,
2265 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2266 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2267 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2271 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2272 enum rte_crypto_cipher_operation cipher_op,
2273 enum rte_crypto_auth_operation auth_op,
2274 enum rte_crypto_auth_algorithm auth_algo,
2275 enum rte_crypto_cipher_algorithm cipher_algo,
2276 const uint8_t *key, const uint8_t key_len,
2277 uint8_t auth_iv_len, uint8_t auth_len,
2278 uint8_t cipher_iv_len)
2280 uint8_t auth_cipher_key[key_len];
2282 struct crypto_testsuite_params *ts_params = &testsuite_params;
2283 struct crypto_unittest_params *ut_params = &unittest_params;
2285 memcpy(auth_cipher_key, key, key_len);
2287 /* Setup Authentication Parameters */
2288 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2289 ut_params->auth_xform.auth.op = auth_op;
2290 ut_params->auth_xform.next = &ut_params->cipher_xform;
2291 ut_params->auth_xform.auth.algo = auth_algo;
2292 ut_params->auth_xform.auth.key.length = key_len;
2293 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2294 ut_params->auth_xform.auth.digest_length = auth_len;
2295 /* Auth IV will be after cipher IV */
2296 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2297 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2299 /* Setup Cipher Parameters */
2300 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2301 ut_params->cipher_xform.next = NULL;
2302 ut_params->cipher_xform.cipher.algo = cipher_algo;
2303 ut_params->cipher_xform.cipher.op = cipher_op;
2304 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2305 ut_params->cipher_xform.cipher.key.length = key_len;
2306 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2307 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2309 debug_hexdump(stdout, "key:", key, key_len);
2311 /* Create Crypto session*/
2312 ut_params->sess = rte_cryptodev_sym_session_create(
2313 ts_params->session_mpool);
2314 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2316 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2317 ut_params->auth_xform.next = NULL;
2318 ut_params->cipher_xform.next = &ut_params->auth_xform;
2319 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2320 &ut_params->cipher_xform,
2321 ts_params->session_priv_mpool);
2324 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2325 &ut_params->auth_xform,
2326 ts_params->session_priv_mpool);
2328 if (status == -ENOTSUP)
2331 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2337 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2338 unsigned int auth_tag_len,
2339 const uint8_t *iv, unsigned int iv_len,
2340 unsigned int data_pad_len,
2341 enum rte_crypto_auth_operation op,
2342 unsigned int auth_len, unsigned int auth_offset)
2344 struct crypto_testsuite_params *ts_params = &testsuite_params;
2346 struct crypto_unittest_params *ut_params = &unittest_params;
2348 /* Generate Crypto op data structure */
2349 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2350 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2351 TEST_ASSERT_NOT_NULL(ut_params->op,
2352 "Failed to allocate pktmbuf offload");
2354 /* Set crypto operation data parameters */
2355 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2357 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2359 /* set crypto operation source mbuf */
2360 sym_op->m_src = ut_params->ibuf;
2363 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2366 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2367 ut_params->ibuf, auth_tag_len);
2369 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2370 "no room to append auth tag");
2371 ut_params->digest = sym_op->auth.digest.data;
2372 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2373 ut_params->ibuf, data_pad_len);
2374 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2375 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2377 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2379 debug_hexdump(stdout, "digest:",
2380 sym_op->auth.digest.data,
2383 sym_op->auth.data.length = auth_len;
2384 sym_op->auth.data.offset = auth_offset;
2390 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2391 enum rte_crypto_auth_operation op)
2393 struct crypto_testsuite_params *ts_params = &testsuite_params;
2394 struct crypto_unittest_params *ut_params = &unittest_params;
2396 const uint8_t *auth_tag = tdata->digest.data;
2397 const unsigned int auth_tag_len = tdata->digest.len;
2398 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2399 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2401 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2402 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2403 const uint8_t *auth_iv = tdata->auth_iv.data;
2404 const uint8_t auth_iv_len = tdata->auth_iv.len;
2405 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2406 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2408 /* Generate Crypto op data structure */
2409 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2410 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2411 TEST_ASSERT_NOT_NULL(ut_params->op,
2412 "Failed to allocate pktmbuf offload");
2413 /* Set crypto operation data parameters */
2414 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2416 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2418 /* set crypto operation source mbuf */
2419 sym_op->m_src = ut_params->ibuf;
2422 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2423 ut_params->ibuf, auth_tag_len);
2425 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2426 "no room to append auth tag");
2427 ut_params->digest = sym_op->auth.digest.data;
2428 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2429 ut_params->ibuf, data_pad_len);
2430 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2431 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2433 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2435 debug_hexdump(stdout, "digest:",
2436 sym_op->auth.digest.data,
2439 /* Copy cipher and auth IVs at the end of the crypto operation */
2440 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2442 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2443 iv_ptr += cipher_iv_len;
2444 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2446 sym_op->cipher.data.length = cipher_len;
2447 sym_op->cipher.data.offset = 0;
2448 sym_op->auth.data.length = auth_len;
2449 sym_op->auth.data.offset = 0;
2455 create_zuc_cipher_hash_generate_operation(
2456 const struct wireless_test_data *tdata)
2458 return create_wireless_cipher_hash_operation(tdata,
2459 RTE_CRYPTO_AUTH_OP_GENERATE);
2463 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2464 const unsigned auth_tag_len,
2465 const uint8_t *auth_iv, uint8_t auth_iv_len,
2466 unsigned data_pad_len,
2467 enum rte_crypto_auth_operation op,
2468 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2469 const unsigned cipher_len, const unsigned cipher_offset,
2470 const unsigned auth_len, const unsigned auth_offset)
2472 struct crypto_testsuite_params *ts_params = &testsuite_params;
2473 struct crypto_unittest_params *ut_params = &unittest_params;
2475 enum rte_crypto_cipher_algorithm cipher_algo =
2476 ut_params->cipher_xform.cipher.algo;
2477 enum rte_crypto_auth_algorithm auth_algo =
2478 ut_params->auth_xform.auth.algo;
2480 /* Generate Crypto op data structure */
2481 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2482 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2483 TEST_ASSERT_NOT_NULL(ut_params->op,
2484 "Failed to allocate pktmbuf offload");
2485 /* Set crypto operation data parameters */
2486 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2488 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2490 /* set crypto operation source mbuf */
2491 sym_op->m_src = ut_params->ibuf;
2494 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2495 ut_params->ibuf, auth_tag_len);
2497 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2498 "no room to append auth tag");
2499 ut_params->digest = sym_op->auth.digest.data;
2501 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2502 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2503 ut_params->ibuf, data_pad_len);
2505 struct rte_mbuf *m = ut_params->ibuf;
2506 unsigned int offset = data_pad_len;
2508 while (offset > m->data_len && m->next != NULL) {
2509 offset -= m->data_len;
2512 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2516 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2517 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2519 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2521 debug_hexdump(stdout, "digest:",
2522 sym_op->auth.digest.data,
2525 /* Copy cipher and auth IVs at the end of the crypto operation */
2526 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2528 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2529 iv_ptr += cipher_iv_len;
2530 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2532 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2533 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2534 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2535 sym_op->cipher.data.length = cipher_len;
2536 sym_op->cipher.data.offset = cipher_offset;
2538 sym_op->cipher.data.length = cipher_len >> 3;
2539 sym_op->cipher.data.offset = cipher_offset >> 3;
2542 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2543 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2544 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2545 sym_op->auth.data.length = auth_len;
2546 sym_op->auth.data.offset = auth_offset;
2548 sym_op->auth.data.length = auth_len >> 3;
2549 sym_op->auth.data.offset = auth_offset >> 3;
2556 create_wireless_algo_auth_cipher_operation(
2557 const uint8_t *auth_tag, unsigned int auth_tag_len,
2558 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2559 const uint8_t *auth_iv, uint8_t auth_iv_len,
2560 unsigned int data_pad_len,
2561 unsigned int cipher_len, unsigned int cipher_offset,
2562 unsigned int auth_len, unsigned int auth_offset,
2563 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2565 struct crypto_testsuite_params *ts_params = &testsuite_params;
2566 struct crypto_unittest_params *ut_params = &unittest_params;
2568 enum rte_crypto_cipher_algorithm cipher_algo =
2569 ut_params->cipher_xform.cipher.algo;
2570 enum rte_crypto_auth_algorithm auth_algo =
2571 ut_params->auth_xform.auth.algo;
2573 /* Generate Crypto op data structure */
2574 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2575 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2576 TEST_ASSERT_NOT_NULL(ut_params->op,
2577 "Failed to allocate pktmbuf offload");
2579 /* Set crypto operation data parameters */
2580 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2582 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2584 /* set crypto operation mbufs */
2585 sym_op->m_src = ut_params->ibuf;
2586 if (op_mode == OUT_OF_PLACE)
2587 sym_op->m_dst = ut_params->obuf;
2591 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2592 (op_mode == IN_PLACE ?
2593 ut_params->ibuf : ut_params->obuf),
2594 uint8_t *, data_pad_len);
2595 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2596 (op_mode == IN_PLACE ?
2597 ut_params->ibuf : ut_params->obuf),
2599 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2601 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2602 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2603 sym_op->m_src : sym_op->m_dst);
2604 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2605 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2606 sgl_buf = sgl_buf->next;
2608 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2609 uint8_t *, remaining_off);
2610 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2612 memset(sym_op->auth.digest.data, 0, remaining_off);
2613 while (sgl_buf->next != NULL) {
2614 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2615 0, rte_pktmbuf_data_len(sgl_buf));
2616 sgl_buf = sgl_buf->next;
2620 /* Copy digest for the verification */
2622 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2624 /* Copy cipher and auth IVs at the end of the crypto operation */
2625 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2626 ut_params->op, uint8_t *, IV_OFFSET);
2628 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2629 iv_ptr += cipher_iv_len;
2630 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2632 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2633 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2634 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2635 sym_op->cipher.data.length = cipher_len;
2636 sym_op->cipher.data.offset = cipher_offset;
2638 sym_op->cipher.data.length = cipher_len >> 3;
2639 sym_op->cipher.data.offset = cipher_offset >> 3;
2642 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2643 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2644 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2645 sym_op->auth.data.length = auth_len;
2646 sym_op->auth.data.offset = auth_offset;
2648 sym_op->auth.data.length = auth_len >> 3;
2649 sym_op->auth.data.offset = auth_offset >> 3;
2656 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2658 struct crypto_testsuite_params *ts_params = &testsuite_params;
2659 struct crypto_unittest_params *ut_params = &unittest_params;
2662 unsigned plaintext_pad_len;
2663 unsigned plaintext_len;
2665 struct rte_cryptodev_info dev_info;
2667 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2668 uint64_t feat_flags = dev_info.feature_flags;
2670 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2671 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2672 printf("Device doesn't support NON-Byte Aligned Data.\n");
2676 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2677 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2678 printf("Device doesn't support RAW data-path APIs.\n");
2682 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2685 /* Verify the capabilities */
2686 struct rte_cryptodev_sym_capability_idx cap_idx;
2687 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2688 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2689 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2693 /* Create SNOW 3G session */
2694 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2695 tdata->key.data, tdata->key.len,
2696 tdata->auth_iv.len, tdata->digest.len,
2697 RTE_CRYPTO_AUTH_OP_GENERATE,
2698 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2702 /* alloc mbuf and set payload */
2703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2705 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2706 rte_pktmbuf_tailroom(ut_params->ibuf));
2708 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2709 /* Append data which is padded to a multiple of */
2710 /* the algorithms block size */
2711 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2712 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2714 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2716 /* Create SNOW 3G operation */
2717 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2718 tdata->auth_iv.data, tdata->auth_iv.len,
2719 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2720 tdata->validAuthLenInBits.len,
2725 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2726 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2727 ut_params->op, 0, 1, 1, 0);
2729 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2731 ut_params->obuf = ut_params->op->sym->m_src;
2732 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2733 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2734 + plaintext_pad_len;
2737 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2740 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2741 "SNOW 3G Generated auth tag not as expected");
2747 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2749 struct crypto_testsuite_params *ts_params = &testsuite_params;
2750 struct crypto_unittest_params *ut_params = &unittest_params;
2753 unsigned plaintext_pad_len;
2754 unsigned plaintext_len;
2756 struct rte_cryptodev_info dev_info;
2758 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2759 uint64_t feat_flags = dev_info.feature_flags;
2761 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2762 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2763 printf("Device doesn't support NON-Byte Aligned Data.\n");
2767 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2768 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2769 printf("Device doesn't support RAW data-path APIs.\n");
2773 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2776 /* Verify the capabilities */
2777 struct rte_cryptodev_sym_capability_idx cap_idx;
2778 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2779 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2780 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2784 /* Create SNOW 3G session */
2785 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2786 tdata->key.data, tdata->key.len,
2787 tdata->auth_iv.len, tdata->digest.len,
2788 RTE_CRYPTO_AUTH_OP_VERIFY,
2789 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2792 /* alloc mbuf and set payload */
2793 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2795 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2796 rte_pktmbuf_tailroom(ut_params->ibuf));
2798 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2799 /* Append data which is padded to a multiple of */
2800 /* the algorithms block size */
2801 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2802 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2804 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2806 /* Create SNOW 3G operation */
2807 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2809 tdata->auth_iv.data, tdata->auth_iv.len,
2811 RTE_CRYPTO_AUTH_OP_VERIFY,
2812 tdata->validAuthLenInBits.len,
2817 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2818 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2819 ut_params->op, 0, 1, 1, 0);
2821 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2824 ut_params->obuf = ut_params->op->sym->m_src;
2825 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2826 + plaintext_pad_len;
2829 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2838 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2840 struct crypto_testsuite_params *ts_params = &testsuite_params;
2841 struct crypto_unittest_params *ut_params = &unittest_params;
2844 unsigned plaintext_pad_len;
2845 unsigned plaintext_len;
2847 struct rte_cryptodev_info dev_info;
2849 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2850 uint64_t feat_flags = dev_info.feature_flags;
2852 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2853 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2854 printf("Device doesn't support RAW data-path APIs.\n");
2858 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2861 /* Verify the capabilities */
2862 struct rte_cryptodev_sym_capability_idx cap_idx;
2863 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2864 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2865 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2869 /* Create KASUMI session */
2870 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2871 tdata->key.data, tdata->key.len,
2872 0, tdata->digest.len,
2873 RTE_CRYPTO_AUTH_OP_GENERATE,
2874 RTE_CRYPTO_AUTH_KASUMI_F9);
2878 /* alloc mbuf and set payload */
2879 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2881 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2882 rte_pktmbuf_tailroom(ut_params->ibuf));
2884 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2885 /* Append data which is padded to a multiple of */
2886 /* the algorithms block size */
2887 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2888 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2890 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2892 /* Create KASUMI operation */
2893 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2895 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2896 tdata->plaintext.len,
2901 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2902 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2904 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2905 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2906 ut_params->op, 0, 1, 1, 0);
2908 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2911 ut_params->obuf = ut_params->op->sym->m_src;
2912 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2913 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2914 + plaintext_pad_len;
2917 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2920 DIGEST_BYTE_LENGTH_KASUMI_F9,
2921 "KASUMI Generated auth tag not as expected");
2927 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2929 struct crypto_testsuite_params *ts_params = &testsuite_params;
2930 struct crypto_unittest_params *ut_params = &unittest_params;
2933 unsigned plaintext_pad_len;
2934 unsigned plaintext_len;
2936 struct rte_cryptodev_info dev_info;
2938 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2939 uint64_t feat_flags = dev_info.feature_flags;
2941 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2942 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2943 printf("Device doesn't support RAW data-path APIs.\n");
2947 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2950 /* Verify the capabilities */
2951 struct rte_cryptodev_sym_capability_idx cap_idx;
2952 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2953 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2954 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2958 /* Create KASUMI session */
2959 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2960 tdata->key.data, tdata->key.len,
2961 0, tdata->digest.len,
2962 RTE_CRYPTO_AUTH_OP_VERIFY,
2963 RTE_CRYPTO_AUTH_KASUMI_F9);
2966 /* alloc mbuf and set payload */
2967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2969 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2970 rte_pktmbuf_tailroom(ut_params->ibuf));
2972 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2973 /* Append data which is padded to a multiple */
2974 /* of the algorithms block size */
2975 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2976 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2978 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2980 /* Create KASUMI operation */
2981 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2985 RTE_CRYPTO_AUTH_OP_VERIFY,
2986 tdata->plaintext.len,
2991 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2992 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2993 ut_params->op, 0, 1, 1, 0);
2995 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2997 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2998 ut_params->obuf = ut_params->op->sym->m_src;
2999 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3000 + plaintext_pad_len;
3003 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3012 test_snow3g_hash_generate_test_case_1(void)
3014 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3018 test_snow3g_hash_generate_test_case_2(void)
3020 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3024 test_snow3g_hash_generate_test_case_3(void)
3026 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3030 test_snow3g_hash_generate_test_case_4(void)
3032 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3036 test_snow3g_hash_generate_test_case_5(void)
3038 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3042 test_snow3g_hash_generate_test_case_6(void)
3044 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3048 test_snow3g_hash_verify_test_case_1(void)
3050 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3055 test_snow3g_hash_verify_test_case_2(void)
3057 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3061 test_snow3g_hash_verify_test_case_3(void)
3063 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3067 test_snow3g_hash_verify_test_case_4(void)
3069 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3073 test_snow3g_hash_verify_test_case_5(void)
3075 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3079 test_snow3g_hash_verify_test_case_6(void)
3081 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3085 test_kasumi_hash_generate_test_case_1(void)
3087 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3091 test_kasumi_hash_generate_test_case_2(void)
3093 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3097 test_kasumi_hash_generate_test_case_3(void)
3099 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3103 test_kasumi_hash_generate_test_case_4(void)
3105 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3109 test_kasumi_hash_generate_test_case_5(void)
3111 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3115 test_kasumi_hash_generate_test_case_6(void)
3117 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3121 test_kasumi_hash_verify_test_case_1(void)
3123 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3127 test_kasumi_hash_verify_test_case_2(void)
3129 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3133 test_kasumi_hash_verify_test_case_3(void)
3135 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3139 test_kasumi_hash_verify_test_case_4(void)
3141 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3145 test_kasumi_hash_verify_test_case_5(void)
3147 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3151 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3153 struct crypto_testsuite_params *ts_params = &testsuite_params;
3154 struct crypto_unittest_params *ut_params = &unittest_params;
3157 uint8_t *plaintext, *ciphertext;
3158 unsigned plaintext_pad_len;
3159 unsigned plaintext_len;
3160 struct rte_cryptodev_info dev_info;
3162 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3163 uint64_t feat_flags = dev_info.feature_flags;
3165 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3166 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3167 printf("Device doesn't support RAW data-path APIs.\n");
3171 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3174 /* Verify the capabilities */
3175 struct rte_cryptodev_sym_capability_idx cap_idx;
3176 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3177 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3178 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3182 /* Create KASUMI session */
3183 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3184 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3185 RTE_CRYPTO_CIPHER_KASUMI_F8,
3186 tdata->key.data, tdata->key.len,
3187 tdata->cipher_iv.len);
3191 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3193 /* Clear mbuf payload */
3194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3195 rte_pktmbuf_tailroom(ut_params->ibuf));
3197 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3198 /* Append data which is padded to a multiple */
3199 /* of the algorithms block size */
3200 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3201 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3203 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3205 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3207 /* Create KASUMI operation */
3208 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3209 tdata->cipher_iv.len,
3210 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3211 tdata->validCipherOffsetInBits.len);
3215 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3216 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3217 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3219 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3221 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3223 ut_params->obuf = ut_params->op->sym->m_dst;
3224 if (ut_params->obuf)
3225 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3227 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3229 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3231 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3232 (tdata->validCipherOffsetInBits.len >> 3);
3234 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3236 reference_ciphertext,
3237 tdata->validCipherLenInBits.len,
3238 "KASUMI Ciphertext data not as expected");
3243 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3245 struct crypto_testsuite_params *ts_params = &testsuite_params;
3246 struct crypto_unittest_params *ut_params = &unittest_params;
3250 unsigned int plaintext_pad_len;
3251 unsigned int plaintext_len;
3253 uint8_t buffer[10000];
3254 const uint8_t *ciphertext;
3256 struct rte_cryptodev_info dev_info;
3258 /* Verify the capabilities */
3259 struct rte_cryptodev_sym_capability_idx cap_idx;
3260 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3261 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3262 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3266 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3268 uint64_t feat_flags = dev_info.feature_flags;
3270 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3271 printf("Device doesn't support in-place scatter-gather. "
3276 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3277 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3278 printf("Device doesn't support RAW data-path APIs.\n");
3282 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3285 /* Create KASUMI session */
3286 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3287 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3288 RTE_CRYPTO_CIPHER_KASUMI_F8,
3289 tdata->key.data, tdata->key.len,
3290 tdata->cipher_iv.len);
3294 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3297 /* Append data which is padded to a multiple */
3298 /* of the algorithms block size */
3299 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3301 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3302 plaintext_pad_len, 10, 0);
3304 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3306 /* Create KASUMI operation */
3307 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3308 tdata->cipher_iv.len,
3309 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3310 tdata->validCipherOffsetInBits.len);
3314 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3315 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3316 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3318 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3320 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3322 ut_params->obuf = ut_params->op->sym->m_dst;
3324 if (ut_params->obuf)
3325 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3326 plaintext_len, buffer);
3328 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3329 tdata->validCipherOffsetInBits.len >> 3,
3330 plaintext_len, buffer);
3333 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3335 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3336 (tdata->validCipherOffsetInBits.len >> 3);
3338 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3340 reference_ciphertext,
3341 tdata->validCipherLenInBits.len,
3342 "KASUMI Ciphertext data not as expected");
3347 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3349 struct crypto_testsuite_params *ts_params = &testsuite_params;
3350 struct crypto_unittest_params *ut_params = &unittest_params;
3353 uint8_t *plaintext, *ciphertext;
3354 unsigned plaintext_pad_len;
3355 unsigned plaintext_len;
3357 /* Verify the capabilities */
3358 struct rte_cryptodev_sym_capability_idx cap_idx;
3359 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3360 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3361 /* Data-path service does not support OOP */
3362 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3366 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3369 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3372 /* Create KASUMI session */
3373 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3374 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3375 RTE_CRYPTO_CIPHER_KASUMI_F8,
3376 tdata->key.data, tdata->key.len,
3377 tdata->cipher_iv.len);
3381 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3382 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3384 /* Clear mbuf payload */
3385 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3386 rte_pktmbuf_tailroom(ut_params->ibuf));
3388 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3389 /* Append data which is padded to a multiple */
3390 /* of the algorithms block size */
3391 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3392 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3394 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3395 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3397 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3399 /* Create KASUMI operation */
3400 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3401 tdata->cipher_iv.len,
3402 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3403 tdata->validCipherOffsetInBits.len);
3407 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3409 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3411 ut_params->obuf = ut_params->op->sym->m_dst;
3412 if (ut_params->obuf)
3413 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3415 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3417 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3419 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3420 (tdata->validCipherOffsetInBits.len >> 3);
3422 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3424 reference_ciphertext,
3425 tdata->validCipherLenInBits.len,
3426 "KASUMI Ciphertext data not as expected");
3431 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3433 struct crypto_testsuite_params *ts_params = &testsuite_params;
3434 struct crypto_unittest_params *ut_params = &unittest_params;
3437 unsigned int plaintext_pad_len;
3438 unsigned int plaintext_len;
3440 const uint8_t *ciphertext;
3441 uint8_t buffer[2048];
3443 struct rte_cryptodev_info dev_info;
3445 /* Verify the capabilities */
3446 struct rte_cryptodev_sym_capability_idx cap_idx;
3447 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3448 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3449 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3453 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3456 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3459 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3461 uint64_t feat_flags = dev_info.feature_flags;
3462 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3463 printf("Device doesn't support out-of-place scatter-gather "
3464 "in both input and output mbufs. "
3469 /* Create KASUMI session */
3470 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3471 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3472 RTE_CRYPTO_CIPHER_KASUMI_F8,
3473 tdata->key.data, tdata->key.len,
3474 tdata->cipher_iv.len);
3478 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3479 /* Append data which is padded to a multiple */
3480 /* of the algorithms block size */
3481 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3483 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3484 plaintext_pad_len, 10, 0);
3485 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3486 plaintext_pad_len, 3, 0);
3488 /* Append data which is padded to a multiple */
3489 /* of the algorithms block size */
3490 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3492 /* Create KASUMI operation */
3493 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3494 tdata->cipher_iv.len,
3495 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3496 tdata->validCipherOffsetInBits.len);
3500 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3502 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3504 ut_params->obuf = ut_params->op->sym->m_dst;
3505 if (ut_params->obuf)
3506 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3507 plaintext_pad_len, buffer);
3509 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3510 tdata->validCipherOffsetInBits.len >> 3,
3511 plaintext_pad_len, buffer);
3513 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3514 (tdata->validCipherOffsetInBits.len >> 3);
3516 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3518 reference_ciphertext,
3519 tdata->validCipherLenInBits.len,
3520 "KASUMI Ciphertext data not as expected");
3526 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3528 struct crypto_testsuite_params *ts_params = &testsuite_params;
3529 struct crypto_unittest_params *ut_params = &unittest_params;
3532 uint8_t *ciphertext, *plaintext;
3533 unsigned ciphertext_pad_len;
3534 unsigned ciphertext_len;
3536 /* Verify the capabilities */
3537 struct rte_cryptodev_sym_capability_idx cap_idx;
3538 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3539 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3540 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3544 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3547 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3550 /* Create KASUMI session */
3551 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3552 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3553 RTE_CRYPTO_CIPHER_KASUMI_F8,
3554 tdata->key.data, tdata->key.len,
3555 tdata->cipher_iv.len);
3559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3560 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3562 /* Clear mbuf payload */
3563 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3564 rte_pktmbuf_tailroom(ut_params->ibuf));
3566 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3567 /* Append data which is padded to a multiple */
3568 /* of the algorithms block size */
3569 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3570 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3571 ciphertext_pad_len);
3572 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3573 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3575 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3577 /* Create KASUMI operation */
3578 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3579 tdata->cipher_iv.len,
3580 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3581 tdata->validCipherOffsetInBits.len);
3585 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3587 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3589 ut_params->obuf = ut_params->op->sym->m_dst;
3590 if (ut_params->obuf)
3591 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3593 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3595 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3597 const uint8_t *reference_plaintext = tdata->plaintext.data +
3598 (tdata->validCipherOffsetInBits.len >> 3);
3600 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3602 reference_plaintext,
3603 tdata->validCipherLenInBits.len,
3604 "KASUMI Plaintext data not as expected");
3609 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3611 struct crypto_testsuite_params *ts_params = &testsuite_params;
3612 struct crypto_unittest_params *ut_params = &unittest_params;
3615 uint8_t *ciphertext, *plaintext;
3616 unsigned ciphertext_pad_len;
3617 unsigned ciphertext_len;
3618 struct rte_cryptodev_info dev_info;
3620 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3621 uint64_t feat_flags = dev_info.feature_flags;
3623 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3624 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3625 printf("Device doesn't support RAW data-path APIs.\n");
3629 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3632 /* Verify the capabilities */
3633 struct rte_cryptodev_sym_capability_idx cap_idx;
3634 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3635 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3636 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3640 /* Create KASUMI session */
3641 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3642 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3643 RTE_CRYPTO_CIPHER_KASUMI_F8,
3644 tdata->key.data, tdata->key.len,
3645 tdata->cipher_iv.len);
3649 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3651 /* Clear mbuf payload */
3652 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3653 rte_pktmbuf_tailroom(ut_params->ibuf));
3655 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3656 /* Append data which is padded to a multiple */
3657 /* of the algorithms block size */
3658 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3659 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3660 ciphertext_pad_len);
3661 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3663 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3665 /* Create KASUMI operation */
3666 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3667 tdata->cipher_iv.len,
3668 tdata->ciphertext.len,
3669 tdata->validCipherOffsetInBits.len);
3673 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3674 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3675 ut_params->op, 1, 0, 1, 0);
3677 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3679 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3681 ut_params->obuf = ut_params->op->sym->m_dst;
3682 if (ut_params->obuf)
3683 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3685 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3687 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3689 const uint8_t *reference_plaintext = tdata->plaintext.data +
3690 (tdata->validCipherOffsetInBits.len >> 3);
3692 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3694 reference_plaintext,
3695 tdata->validCipherLenInBits.len,
3696 "KASUMI Plaintext data not as expected");
3701 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3703 struct crypto_testsuite_params *ts_params = &testsuite_params;
3704 struct crypto_unittest_params *ut_params = &unittest_params;
3707 uint8_t *plaintext, *ciphertext;
3708 unsigned plaintext_pad_len;
3709 unsigned plaintext_len;
3710 struct rte_cryptodev_info dev_info;
3712 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3713 uint64_t feat_flags = dev_info.feature_flags;
3715 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3716 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3717 printf("Device doesn't support RAW data-path APIs.\n");
3721 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3724 /* Verify the capabilities */
3725 struct rte_cryptodev_sym_capability_idx cap_idx;
3726 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3727 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3728 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3732 /* Create SNOW 3G session */
3733 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3734 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3735 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3736 tdata->key.data, tdata->key.len,
3737 tdata->cipher_iv.len);
3741 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3743 /* Clear mbuf payload */
3744 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3745 rte_pktmbuf_tailroom(ut_params->ibuf));
3747 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3748 /* Append data which is padded to a multiple of */
3749 /* the algorithms block size */
3750 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3751 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3753 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3755 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3757 /* Create SNOW 3G operation */
3758 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3759 tdata->cipher_iv.len,
3760 tdata->validCipherLenInBits.len,
3765 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3766 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3767 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3769 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3771 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3773 ut_params->obuf = ut_params->op->sym->m_dst;
3774 if (ut_params->obuf)
3775 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3777 ciphertext = plaintext;
3779 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3782 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3784 tdata->ciphertext.data,
3785 tdata->validDataLenInBits.len,
3786 "SNOW 3G Ciphertext data not as expected");
3792 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3794 struct crypto_testsuite_params *ts_params = &testsuite_params;
3795 struct crypto_unittest_params *ut_params = &unittest_params;
3796 uint8_t *plaintext, *ciphertext;
3799 unsigned plaintext_pad_len;
3800 unsigned plaintext_len;
3802 /* Verify the capabilities */
3803 struct rte_cryptodev_sym_capability_idx cap_idx;
3804 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3805 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3806 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3810 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3813 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3816 /* Create SNOW 3G session */
3817 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3818 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3819 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3820 tdata->key.data, tdata->key.len,
3821 tdata->cipher_iv.len);
3825 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3826 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3828 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3829 "Failed to allocate input buffer in mempool");
3830 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3831 "Failed to allocate output buffer in mempool");
3833 /* Clear mbuf payload */
3834 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3835 rte_pktmbuf_tailroom(ut_params->ibuf));
3837 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3838 /* Append data which is padded to a multiple of */
3839 /* the algorithms block size */
3840 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3841 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3843 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3844 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3846 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3848 /* Create SNOW 3G operation */
3849 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3850 tdata->cipher_iv.len,
3851 tdata->validCipherLenInBits.len,
3856 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3858 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3860 ut_params->obuf = ut_params->op->sym->m_dst;
3861 if (ut_params->obuf)
3862 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3864 ciphertext = plaintext;
3866 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3869 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3871 tdata->ciphertext.data,
3872 tdata->validDataLenInBits.len,
3873 "SNOW 3G Ciphertext data not as expected");
3878 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3880 struct crypto_testsuite_params *ts_params = &testsuite_params;
3881 struct crypto_unittest_params *ut_params = &unittest_params;
3884 unsigned int plaintext_pad_len;
3885 unsigned int plaintext_len;
3886 uint8_t buffer[10000];
3887 const uint8_t *ciphertext;
3889 struct rte_cryptodev_info dev_info;
3891 /* Verify the capabilities */
3892 struct rte_cryptodev_sym_capability_idx cap_idx;
3893 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3894 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3895 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3899 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3902 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3905 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3907 uint64_t feat_flags = dev_info.feature_flags;
3909 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3910 printf("Device doesn't support out-of-place scatter-gather "
3911 "in both input and output mbufs. "
3916 /* Create SNOW 3G session */
3917 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3918 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3919 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3920 tdata->key.data, tdata->key.len,
3921 tdata->cipher_iv.len);
3925 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3926 /* Append data which is padded to a multiple of */
3927 /* the algorithms block size */
3928 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3930 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3931 plaintext_pad_len, 10, 0);
3932 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3933 plaintext_pad_len, 3, 0);
3935 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3936 "Failed to allocate input buffer in mempool");
3937 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3938 "Failed to allocate output buffer in mempool");
3940 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3942 /* Create SNOW 3G operation */
3943 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3944 tdata->cipher_iv.len,
3945 tdata->validCipherLenInBits.len,
3950 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3952 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3954 ut_params->obuf = ut_params->op->sym->m_dst;
3955 if (ut_params->obuf)
3956 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3957 plaintext_len, buffer);
3959 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3960 plaintext_len, buffer);
3962 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3965 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3967 tdata->ciphertext.data,
3968 tdata->validDataLenInBits.len,
3969 "SNOW 3G Ciphertext data not as expected");
3974 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3976 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3978 uint8_t curr_byte, prev_byte;
3979 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3980 uint8_t lower_byte_mask = (1 << offset) - 1;
3983 prev_byte = buffer[0];
3984 buffer[0] >>= offset;
3986 for (i = 1; i < length_in_bytes; i++) {
3987 curr_byte = buffer[i];
3988 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3989 (curr_byte >> offset);
3990 prev_byte = curr_byte;
3995 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3997 struct crypto_testsuite_params *ts_params = &testsuite_params;
3998 struct crypto_unittest_params *ut_params = &unittest_params;
3999 uint8_t *plaintext, *ciphertext;
4001 uint32_t plaintext_len;
4002 uint32_t plaintext_pad_len;
4003 uint8_t extra_offset = 4;
4004 uint8_t *expected_ciphertext_shifted;
4005 struct rte_cryptodev_info dev_info;
4007 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4008 uint64_t feat_flags = dev_info.feature_flags;
4010 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4011 ((tdata->validDataLenInBits.len % 8) != 0)) {
4012 printf("Device doesn't support NON-Byte Aligned Data.\n");
4016 /* Verify the capabilities */
4017 struct rte_cryptodev_sym_capability_idx cap_idx;
4018 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4019 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4020 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4024 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4027 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4030 /* Create SNOW 3G session */
4031 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4032 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4033 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4034 tdata->key.data, tdata->key.len,
4035 tdata->cipher_iv.len);
4039 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4040 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4042 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4043 "Failed to allocate input buffer in mempool");
4044 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4045 "Failed to allocate output buffer in mempool");
4047 /* Clear mbuf payload */
4048 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4049 rte_pktmbuf_tailroom(ut_params->ibuf));
4051 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4053 * Append data which is padded to a
4054 * multiple of the algorithms block size
4056 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4058 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4061 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4063 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4064 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4066 #ifdef RTE_APP_TEST_DEBUG
4067 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4069 /* Create SNOW 3G operation */
4070 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4071 tdata->cipher_iv.len,
4072 tdata->validCipherLenInBits.len,
4077 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4079 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4081 ut_params->obuf = ut_params->op->sym->m_dst;
4082 if (ut_params->obuf)
4083 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4085 ciphertext = plaintext;
4087 #ifdef RTE_APP_TEST_DEBUG
4088 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4091 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4093 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4094 "failed to reserve memory for ciphertext shifted\n");
4096 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4097 ceil_byte_length(tdata->ciphertext.len));
4098 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4101 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4103 expected_ciphertext_shifted,
4104 tdata->validDataLenInBits.len,
4106 "SNOW 3G Ciphertext data not as expected");
4110 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4112 struct crypto_testsuite_params *ts_params = &testsuite_params;
4113 struct crypto_unittest_params *ut_params = &unittest_params;
4117 uint8_t *plaintext, *ciphertext;
4118 unsigned ciphertext_pad_len;
4119 unsigned ciphertext_len;
4120 struct rte_cryptodev_info dev_info;
4122 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4123 uint64_t feat_flags = dev_info.feature_flags;
4125 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4126 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4127 printf("Device doesn't support RAW data-path APIs.\n");
4131 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4134 /* Verify the capabilities */
4135 struct rte_cryptodev_sym_capability_idx cap_idx;
4136 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4137 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4138 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4142 /* Create SNOW 3G session */
4143 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4144 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4145 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4146 tdata->key.data, tdata->key.len,
4147 tdata->cipher_iv.len);
4151 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4153 /* Clear mbuf payload */
4154 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4155 rte_pktmbuf_tailroom(ut_params->ibuf));
4157 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4158 /* Append data which is padded to a multiple of */
4159 /* the algorithms block size */
4160 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4161 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4162 ciphertext_pad_len);
4163 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4165 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4167 /* Create SNOW 3G operation */
4168 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4169 tdata->cipher_iv.len,
4170 tdata->validCipherLenInBits.len,
4171 tdata->cipher.offset_bits);
4175 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4176 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4177 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4179 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4181 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4182 ut_params->obuf = ut_params->op->sym->m_dst;
4183 if (ut_params->obuf)
4184 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4186 plaintext = ciphertext;
4188 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4191 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4192 tdata->plaintext.data,
4193 tdata->validDataLenInBits.len,
4194 "SNOW 3G Plaintext data not as expected");
4198 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4200 struct crypto_testsuite_params *ts_params = &testsuite_params;
4201 struct crypto_unittest_params *ut_params = &unittest_params;
4205 uint8_t *plaintext, *ciphertext;
4206 unsigned ciphertext_pad_len;
4207 unsigned ciphertext_len;
4209 /* Verify the capabilities */
4210 struct rte_cryptodev_sym_capability_idx cap_idx;
4211 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4212 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4213 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4217 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4220 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4223 /* Create SNOW 3G session */
4224 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4225 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4226 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4227 tdata->key.data, tdata->key.len,
4228 tdata->cipher_iv.len);
4232 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4233 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4235 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4236 "Failed to allocate input buffer");
4237 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4238 "Failed to allocate output buffer");
4240 /* Clear mbuf payload */
4241 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4242 rte_pktmbuf_tailroom(ut_params->ibuf));
4244 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4245 rte_pktmbuf_tailroom(ut_params->obuf));
4247 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4248 /* Append data which is padded to a multiple of */
4249 /* the algorithms block size */
4250 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4251 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4252 ciphertext_pad_len);
4253 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4254 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4256 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4258 /* Create SNOW 3G operation */
4259 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4260 tdata->cipher_iv.len,
4261 tdata->validCipherLenInBits.len,
4266 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4268 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4269 ut_params->obuf = ut_params->op->sym->m_dst;
4270 if (ut_params->obuf)
4271 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4273 plaintext = ciphertext;
4275 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4278 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4279 tdata->plaintext.data,
4280 tdata->validDataLenInBits.len,
4281 "SNOW 3G Plaintext data not as expected");
4286 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4288 struct crypto_testsuite_params *ts_params = &testsuite_params;
4289 struct crypto_unittest_params *ut_params = &unittest_params;
4293 uint8_t *plaintext, *ciphertext;
4294 unsigned int plaintext_pad_len;
4295 unsigned int plaintext_len;
4297 struct rte_cryptodev_info dev_info;
4298 struct rte_cryptodev_sym_capability_idx cap_idx;
4300 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4301 uint64_t feat_flags = dev_info.feature_flags;
4303 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4304 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4305 (tdata->validDataLenInBits.len % 8 != 0))) {
4306 printf("Device doesn't support NON-Byte Aligned Data.\n");
4310 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4311 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4312 printf("Device doesn't support RAW data-path APIs.\n");
4316 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4319 /* Check if device supports ZUC EEA3 */
4320 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4321 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4323 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4327 /* Check if device supports ZUC EIA3 */
4328 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4329 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4331 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4335 /* Create ZUC session */
4336 retval = create_zuc_cipher_auth_encrypt_generate_session(
4337 ts_params->valid_devs[0],
4341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4343 /* clear mbuf payload */
4344 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4345 rte_pktmbuf_tailroom(ut_params->ibuf));
4347 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4348 /* Append data which is padded to a multiple of */
4349 /* the algorithms block size */
4350 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4351 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4353 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4355 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4357 /* Create ZUC operation */
4358 retval = create_zuc_cipher_hash_generate_operation(tdata);
4362 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4363 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4364 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4366 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4368 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4369 ut_params->obuf = ut_params->op->sym->m_src;
4370 if (ut_params->obuf)
4371 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4373 ciphertext = plaintext;
4375 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4377 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4379 tdata->ciphertext.data,
4380 tdata->validDataLenInBits.len,
4381 "ZUC Ciphertext data not as expected");
4383 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4384 + plaintext_pad_len;
4387 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4391 "ZUC Generated auth tag not as expected");
4396 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4398 struct crypto_testsuite_params *ts_params = &testsuite_params;
4399 struct crypto_unittest_params *ut_params = &unittest_params;
4403 uint8_t *plaintext, *ciphertext;
4404 unsigned plaintext_pad_len;
4405 unsigned plaintext_len;
4406 struct rte_cryptodev_info dev_info;
4408 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4409 uint64_t feat_flags = dev_info.feature_flags;
4411 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4412 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4413 printf("Device doesn't support RAW data-path APIs.\n");
4417 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4420 /* Verify the capabilities */
4421 struct rte_cryptodev_sym_capability_idx cap_idx;
4422 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4423 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4424 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4427 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4428 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4429 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4433 /* Create SNOW 3G session */
4434 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4435 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4436 RTE_CRYPTO_AUTH_OP_GENERATE,
4437 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4438 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4439 tdata->key.data, tdata->key.len,
4440 tdata->auth_iv.len, tdata->digest.len,
4441 tdata->cipher_iv.len);
4444 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4446 /* clear mbuf payload */
4447 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4448 rte_pktmbuf_tailroom(ut_params->ibuf));
4450 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4451 /* Append data which is padded to a multiple of */
4452 /* the algorithms block size */
4453 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4454 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4456 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4458 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4460 /* Create SNOW 3G operation */
4461 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4462 tdata->digest.len, tdata->auth_iv.data,
4464 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4465 tdata->cipher_iv.data, tdata->cipher_iv.len,
4466 tdata->validCipherLenInBits.len,
4468 tdata->validAuthLenInBits.len,
4474 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4475 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4476 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4478 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4480 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4481 ut_params->obuf = ut_params->op->sym->m_src;
4482 if (ut_params->obuf)
4483 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4485 ciphertext = plaintext;
4487 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4489 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4491 tdata->ciphertext.data,
4492 tdata->validDataLenInBits.len,
4493 "SNOW 3G Ciphertext data not as expected");
4495 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4496 + plaintext_pad_len;
4499 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4502 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4503 "SNOW 3G Generated auth tag not as expected");
4508 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4509 uint8_t op_mode, uint8_t verify)
4511 struct crypto_testsuite_params *ts_params = &testsuite_params;
4512 struct crypto_unittest_params *ut_params = &unittest_params;
4516 uint8_t *plaintext = NULL, *ciphertext = NULL;
4517 unsigned int plaintext_pad_len;
4518 unsigned int plaintext_len;
4519 unsigned int ciphertext_pad_len;
4520 unsigned int ciphertext_len;
4522 struct rte_cryptodev_info dev_info;
4524 /* Verify the capabilities */
4525 struct rte_cryptodev_sym_capability_idx cap_idx;
4526 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4527 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4528 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4531 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4532 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4533 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4537 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4540 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4542 uint64_t feat_flags = dev_info.feature_flags;
4544 if (op_mode == OUT_OF_PLACE) {
4545 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4546 printf("Device doesn't support digest encrypted.\n");
4549 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4553 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4554 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4555 printf("Device doesn't support RAW data-path APIs.\n");
4559 /* Create SNOW 3G session */
4560 retval = create_wireless_algo_auth_cipher_session(
4561 ts_params->valid_devs[0],
4562 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4563 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4564 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4565 : RTE_CRYPTO_AUTH_OP_GENERATE),
4566 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4567 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4568 tdata->key.data, tdata->key.len,
4569 tdata->auth_iv.len, tdata->digest.len,
4570 tdata->cipher_iv.len);
4575 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4576 if (op_mode == OUT_OF_PLACE)
4577 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4579 /* clear mbuf payload */
4580 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4581 rte_pktmbuf_tailroom(ut_params->ibuf));
4582 if (op_mode == OUT_OF_PLACE)
4583 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4584 rte_pktmbuf_tailroom(ut_params->obuf));
4586 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4587 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4588 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4589 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4592 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4593 ciphertext_pad_len);
4594 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4595 if (op_mode == OUT_OF_PLACE)
4596 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4597 debug_hexdump(stdout, "ciphertext:", ciphertext,
4600 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4602 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4603 if (op_mode == OUT_OF_PLACE)
4604 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4605 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4608 /* Create SNOW 3G operation */
4609 retval = create_wireless_algo_auth_cipher_operation(
4610 tdata->digest.data, tdata->digest.len,
4611 tdata->cipher_iv.data, tdata->cipher_iv.len,
4612 tdata->auth_iv.data, tdata->auth_iv.len,
4613 (tdata->digest.offset_bytes == 0 ?
4614 (verify ? ciphertext_pad_len : plaintext_pad_len)
4615 : tdata->digest.offset_bytes),
4616 tdata->validCipherLenInBits.len,
4617 tdata->cipher.offset_bits,
4618 tdata->validAuthLenInBits.len,
4619 tdata->auth.offset_bits,
4620 op_mode, 0, verify);
4625 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4626 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4627 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4629 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4632 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4634 ut_params->obuf = (op_mode == IN_PLACE ?
4635 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4638 if (ut_params->obuf)
4639 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4642 plaintext = ciphertext +
4643 (tdata->cipher.offset_bits >> 3);
4645 debug_hexdump(stdout, "plaintext:", plaintext,
4646 (tdata->plaintext.len >> 3) - tdata->digest.len);
4647 debug_hexdump(stdout, "plaintext expected:",
4648 tdata->plaintext.data,
4649 (tdata->plaintext.len >> 3) - tdata->digest.len);
4651 if (ut_params->obuf)
4652 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4655 ciphertext = plaintext;
4657 debug_hexdump(stdout, "ciphertext:", ciphertext,
4659 debug_hexdump(stdout, "ciphertext expected:",
4660 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4662 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4663 + (tdata->digest.offset_bytes == 0 ?
4664 plaintext_pad_len : tdata->digest.offset_bytes);
4666 debug_hexdump(stdout, "digest:", ut_params->digest,
4668 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4674 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4676 tdata->plaintext.data,
4677 tdata->plaintext.len >> 3,
4678 "SNOW 3G Plaintext data not as expected");
4680 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4682 tdata->ciphertext.data,
4683 tdata->validDataLenInBits.len,
4684 "SNOW 3G Ciphertext data not as expected");
4686 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4689 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4690 "SNOW 3G Generated auth tag not as expected");
4696 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4697 uint8_t op_mode, uint8_t verify)
4699 struct crypto_testsuite_params *ts_params = &testsuite_params;
4700 struct crypto_unittest_params *ut_params = &unittest_params;
4704 const uint8_t *plaintext = NULL;
4705 const uint8_t *ciphertext = NULL;
4706 const uint8_t *digest = NULL;
4707 unsigned int plaintext_pad_len;
4708 unsigned int plaintext_len;
4709 unsigned int ciphertext_pad_len;
4710 unsigned int ciphertext_len;
4711 uint8_t buffer[10000];
4712 uint8_t digest_buffer[10000];
4714 struct rte_cryptodev_info dev_info;
4716 /* Verify the capabilities */
4717 struct rte_cryptodev_sym_capability_idx cap_idx;
4718 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4719 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4720 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4723 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4724 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4725 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4729 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4732 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4734 uint64_t feat_flags = dev_info.feature_flags;
4736 if (op_mode == IN_PLACE) {
4737 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4738 printf("Device doesn't support in-place scatter-gather "
4739 "in both input and output mbufs.\n");
4742 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4743 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4744 printf("Device doesn't support RAW data-path APIs.\n");
4748 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4750 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4751 printf("Device doesn't support out-of-place scatter-gather "
4752 "in both input and output mbufs.\n");
4755 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4756 printf("Device doesn't support digest encrypted.\n");
4761 /* Create SNOW 3G session */
4762 retval = create_wireless_algo_auth_cipher_session(
4763 ts_params->valid_devs[0],
4764 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4765 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4766 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4767 : RTE_CRYPTO_AUTH_OP_GENERATE),
4768 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4769 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4770 tdata->key.data, tdata->key.len,
4771 tdata->auth_iv.len, tdata->digest.len,
4772 tdata->cipher_iv.len);
4777 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4778 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4779 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4780 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4782 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4783 plaintext_pad_len, 15, 0);
4784 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4785 "Failed to allocate input buffer in mempool");
4787 if (op_mode == OUT_OF_PLACE) {
4788 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4789 plaintext_pad_len, 15, 0);
4790 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4791 "Failed to allocate output buffer in mempool");
4795 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4796 tdata->ciphertext.data);
4797 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4798 ciphertext_len, buffer);
4799 debug_hexdump(stdout, "ciphertext:", ciphertext,
4802 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4803 tdata->plaintext.data);
4804 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4805 plaintext_len, buffer);
4806 debug_hexdump(stdout, "plaintext:", plaintext,
4809 memset(buffer, 0, sizeof(buffer));
4811 /* Create SNOW 3G operation */
4812 retval = create_wireless_algo_auth_cipher_operation(
4813 tdata->digest.data, tdata->digest.len,
4814 tdata->cipher_iv.data, tdata->cipher_iv.len,
4815 tdata->auth_iv.data, tdata->auth_iv.len,
4816 (tdata->digest.offset_bytes == 0 ?
4817 (verify ? ciphertext_pad_len : plaintext_pad_len)
4818 : tdata->digest.offset_bytes),
4819 tdata->validCipherLenInBits.len,
4820 tdata->cipher.offset_bits,
4821 tdata->validAuthLenInBits.len,
4822 tdata->auth.offset_bits,
4823 op_mode, 1, verify);
4828 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4829 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4830 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4832 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4835 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4837 ut_params->obuf = (op_mode == IN_PLACE ?
4838 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4841 if (ut_params->obuf)
4842 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4843 plaintext_len, buffer);
4845 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4846 plaintext_len, buffer);
4848 debug_hexdump(stdout, "plaintext:", plaintext,
4849 (tdata->plaintext.len >> 3) - tdata->digest.len);
4850 debug_hexdump(stdout, "plaintext expected:",
4851 tdata->plaintext.data,
4852 (tdata->plaintext.len >> 3) - tdata->digest.len);
4854 if (ut_params->obuf)
4855 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4856 ciphertext_len, buffer);
4858 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4859 ciphertext_len, buffer);
4861 debug_hexdump(stdout, "ciphertext:", ciphertext,
4863 debug_hexdump(stdout, "ciphertext expected:",
4864 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4866 if (ut_params->obuf)
4867 digest = rte_pktmbuf_read(ut_params->obuf,
4868 (tdata->digest.offset_bytes == 0 ?
4869 plaintext_pad_len : tdata->digest.offset_bytes),
4870 tdata->digest.len, digest_buffer);
4872 digest = rte_pktmbuf_read(ut_params->ibuf,
4873 (tdata->digest.offset_bytes == 0 ?
4874 plaintext_pad_len : tdata->digest.offset_bytes),
4875 tdata->digest.len, digest_buffer);
4877 debug_hexdump(stdout, "digest:", digest,
4879 debug_hexdump(stdout, "digest expected:",
4880 tdata->digest.data, tdata->digest.len);
4885 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4887 tdata->plaintext.data,
4888 tdata->plaintext.len >> 3,
4889 "SNOW 3G Plaintext data not as expected");
4891 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4893 tdata->ciphertext.data,
4894 tdata->validDataLenInBits.len,
4895 "SNOW 3G Ciphertext data not as expected");
4897 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4900 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4901 "SNOW 3G Generated auth tag not as expected");
4907 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4908 uint8_t op_mode, uint8_t verify)
4910 struct crypto_testsuite_params *ts_params = &testsuite_params;
4911 struct crypto_unittest_params *ut_params = &unittest_params;
4915 uint8_t *plaintext = NULL, *ciphertext = NULL;
4916 unsigned int plaintext_pad_len;
4917 unsigned int plaintext_len;
4918 unsigned int ciphertext_pad_len;
4919 unsigned int ciphertext_len;
4921 struct rte_cryptodev_info dev_info;
4923 /* Verify the capabilities */
4924 struct rte_cryptodev_sym_capability_idx cap_idx;
4925 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4926 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4927 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4930 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4931 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4932 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4936 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4938 uint64_t feat_flags = dev_info.feature_flags;
4940 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4941 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4942 printf("Device doesn't support RAW data-path APIs.\n");
4946 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4949 if (op_mode == OUT_OF_PLACE) {
4950 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4952 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4953 printf("Device doesn't support digest encrypted.\n");
4958 /* Create KASUMI session */
4959 retval = create_wireless_algo_auth_cipher_session(
4960 ts_params->valid_devs[0],
4961 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4962 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4963 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4964 : RTE_CRYPTO_AUTH_OP_GENERATE),
4965 RTE_CRYPTO_AUTH_KASUMI_F9,
4966 RTE_CRYPTO_CIPHER_KASUMI_F8,
4967 tdata->key.data, tdata->key.len,
4968 0, tdata->digest.len,
4969 tdata->cipher_iv.len);
4974 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4975 if (op_mode == OUT_OF_PLACE)
4976 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4978 /* clear mbuf payload */
4979 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4980 rte_pktmbuf_tailroom(ut_params->ibuf));
4981 if (op_mode == OUT_OF_PLACE)
4982 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4983 rte_pktmbuf_tailroom(ut_params->obuf));
4985 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4986 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4987 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4988 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4991 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4992 ciphertext_pad_len);
4993 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4994 if (op_mode == OUT_OF_PLACE)
4995 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4996 debug_hexdump(stdout, "ciphertext:", ciphertext,
4999 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5001 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5002 if (op_mode == OUT_OF_PLACE)
5003 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5004 debug_hexdump(stdout, "plaintext:", plaintext,
5008 /* Create KASUMI operation */
5009 retval = create_wireless_algo_auth_cipher_operation(
5010 tdata->digest.data, tdata->digest.len,
5011 tdata->cipher_iv.data, tdata->cipher_iv.len,
5013 (tdata->digest.offset_bytes == 0 ?
5014 (verify ? ciphertext_pad_len : plaintext_pad_len)
5015 : tdata->digest.offset_bytes),
5016 tdata->validCipherLenInBits.len,
5017 tdata->validCipherOffsetInBits.len,
5018 tdata->validAuthLenInBits.len,
5020 op_mode, 0, verify);
5025 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5026 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5027 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5029 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5034 ut_params->obuf = (op_mode == IN_PLACE ?
5035 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5039 if (ut_params->obuf)
5040 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5043 plaintext = ciphertext;
5045 debug_hexdump(stdout, "plaintext:", plaintext,
5046 (tdata->plaintext.len >> 3) - tdata->digest.len);
5047 debug_hexdump(stdout, "plaintext expected:",
5048 tdata->plaintext.data,
5049 (tdata->plaintext.len >> 3) - tdata->digest.len);
5051 if (ut_params->obuf)
5052 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5055 ciphertext = plaintext;
5057 debug_hexdump(stdout, "ciphertext:", ciphertext,
5059 debug_hexdump(stdout, "ciphertext expected:",
5060 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5062 ut_params->digest = rte_pktmbuf_mtod(
5063 ut_params->obuf, uint8_t *) +
5064 (tdata->digest.offset_bytes == 0 ?
5065 plaintext_pad_len : tdata->digest.offset_bytes);
5067 debug_hexdump(stdout, "digest:", ut_params->digest,
5069 debug_hexdump(stdout, "digest expected:",
5070 tdata->digest.data, tdata->digest.len);
5075 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5077 tdata->plaintext.data,
5078 tdata->plaintext.len >> 3,
5079 "KASUMI Plaintext data not as expected");
5081 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5083 tdata->ciphertext.data,
5084 tdata->ciphertext.len >> 3,
5085 "KASUMI Ciphertext data not as expected");
5087 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5090 DIGEST_BYTE_LENGTH_KASUMI_F9,
5091 "KASUMI Generated auth tag not as expected");
5097 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5098 uint8_t op_mode, uint8_t verify)
5100 struct crypto_testsuite_params *ts_params = &testsuite_params;
5101 struct crypto_unittest_params *ut_params = &unittest_params;
5105 const uint8_t *plaintext = NULL;
5106 const uint8_t *ciphertext = NULL;
5107 const uint8_t *digest = NULL;
5108 unsigned int plaintext_pad_len;
5109 unsigned int plaintext_len;
5110 unsigned int ciphertext_pad_len;
5111 unsigned int ciphertext_len;
5112 uint8_t buffer[10000];
5113 uint8_t digest_buffer[10000];
5115 struct rte_cryptodev_info dev_info;
5117 /* Verify the capabilities */
5118 struct rte_cryptodev_sym_capability_idx cap_idx;
5119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5120 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5121 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5124 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5125 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5126 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5130 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5133 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5135 uint64_t feat_flags = dev_info.feature_flags;
5137 if (op_mode == IN_PLACE) {
5138 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5139 printf("Device doesn't support in-place scatter-gather "
5140 "in both input and output mbufs.\n");
5143 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5144 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5145 printf("Device doesn't support RAW data-path APIs.\n");
5149 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5151 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5152 printf("Device doesn't support out-of-place scatter-gather "
5153 "in both input and output mbufs.\n");
5156 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5157 printf("Device doesn't support digest encrypted.\n");
5162 /* Create KASUMI session */
5163 retval = create_wireless_algo_auth_cipher_session(
5164 ts_params->valid_devs[0],
5165 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5166 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5167 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5168 : RTE_CRYPTO_AUTH_OP_GENERATE),
5169 RTE_CRYPTO_AUTH_KASUMI_F9,
5170 RTE_CRYPTO_CIPHER_KASUMI_F8,
5171 tdata->key.data, tdata->key.len,
5172 0, tdata->digest.len,
5173 tdata->cipher_iv.len);
5178 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5179 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5180 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5181 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5183 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5184 plaintext_pad_len, 15, 0);
5185 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5186 "Failed to allocate input buffer in mempool");
5188 if (op_mode == OUT_OF_PLACE) {
5189 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5190 plaintext_pad_len, 15, 0);
5191 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5192 "Failed to allocate output buffer in mempool");
5196 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5197 tdata->ciphertext.data);
5198 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5199 ciphertext_len, buffer);
5200 debug_hexdump(stdout, "ciphertext:", ciphertext,
5203 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5204 tdata->plaintext.data);
5205 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5206 plaintext_len, buffer);
5207 debug_hexdump(stdout, "plaintext:", plaintext,
5210 memset(buffer, 0, sizeof(buffer));
5212 /* Create KASUMI operation */
5213 retval = create_wireless_algo_auth_cipher_operation(
5214 tdata->digest.data, tdata->digest.len,
5215 tdata->cipher_iv.data, tdata->cipher_iv.len,
5217 (tdata->digest.offset_bytes == 0 ?
5218 (verify ? ciphertext_pad_len : plaintext_pad_len)
5219 : tdata->digest.offset_bytes),
5220 tdata->validCipherLenInBits.len,
5221 tdata->validCipherOffsetInBits.len,
5222 tdata->validAuthLenInBits.len,
5224 op_mode, 1, verify);
5229 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5230 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5231 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5233 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5236 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5238 ut_params->obuf = (op_mode == IN_PLACE ?
5239 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5242 if (ut_params->obuf)
5243 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5244 plaintext_len, buffer);
5246 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5247 plaintext_len, buffer);
5249 debug_hexdump(stdout, "plaintext:", plaintext,
5250 (tdata->plaintext.len >> 3) - tdata->digest.len);
5251 debug_hexdump(stdout, "plaintext expected:",
5252 tdata->plaintext.data,
5253 (tdata->plaintext.len >> 3) - tdata->digest.len);
5255 if (ut_params->obuf)
5256 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5257 ciphertext_len, buffer);
5259 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5260 ciphertext_len, buffer);
5262 debug_hexdump(stdout, "ciphertext:", ciphertext,
5264 debug_hexdump(stdout, "ciphertext expected:",
5265 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5267 if (ut_params->obuf)
5268 digest = rte_pktmbuf_read(ut_params->obuf,
5269 (tdata->digest.offset_bytes == 0 ?
5270 plaintext_pad_len : tdata->digest.offset_bytes),
5271 tdata->digest.len, digest_buffer);
5273 digest = rte_pktmbuf_read(ut_params->ibuf,
5274 (tdata->digest.offset_bytes == 0 ?
5275 plaintext_pad_len : tdata->digest.offset_bytes),
5276 tdata->digest.len, digest_buffer);
5278 debug_hexdump(stdout, "digest:", digest,
5280 debug_hexdump(stdout, "digest expected:",
5281 tdata->digest.data, tdata->digest.len);
5286 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5288 tdata->plaintext.data,
5289 tdata->plaintext.len >> 3,
5290 "KASUMI Plaintext data not as expected");
5292 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5294 tdata->ciphertext.data,
5295 tdata->validDataLenInBits.len,
5296 "KASUMI Ciphertext data not as expected");
5298 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5301 DIGEST_BYTE_LENGTH_KASUMI_F9,
5302 "KASUMI Generated auth tag not as expected");
5308 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5310 struct crypto_testsuite_params *ts_params = &testsuite_params;
5311 struct crypto_unittest_params *ut_params = &unittest_params;
5315 uint8_t *plaintext, *ciphertext;
5316 unsigned plaintext_pad_len;
5317 unsigned plaintext_len;
5318 struct rte_cryptodev_info dev_info;
5320 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5321 uint64_t feat_flags = dev_info.feature_flags;
5323 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5324 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5325 printf("Device doesn't support RAW data-path APIs.\n");
5329 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5332 /* Verify the capabilities */
5333 struct rte_cryptodev_sym_capability_idx cap_idx;
5334 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5335 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5336 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5339 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5340 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5341 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5345 /* Create KASUMI session */
5346 retval = create_wireless_algo_cipher_auth_session(
5347 ts_params->valid_devs[0],
5348 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5349 RTE_CRYPTO_AUTH_OP_GENERATE,
5350 RTE_CRYPTO_AUTH_KASUMI_F9,
5351 RTE_CRYPTO_CIPHER_KASUMI_F8,
5352 tdata->key.data, tdata->key.len,
5353 0, tdata->digest.len,
5354 tdata->cipher_iv.len);
5358 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5360 /* clear mbuf payload */
5361 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5362 rte_pktmbuf_tailroom(ut_params->ibuf));
5364 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5365 /* Append data which is padded to a multiple of */
5366 /* the algorithms block size */
5367 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5368 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5370 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5372 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5374 /* Create KASUMI operation */
5375 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5376 tdata->digest.len, NULL, 0,
5377 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5378 tdata->cipher_iv.data, tdata->cipher_iv.len,
5379 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5380 tdata->validCipherOffsetInBits.len,
5381 tdata->validAuthLenInBits.len,
5387 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5388 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5389 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5391 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5393 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5395 if (ut_params->op->sym->m_dst)
5396 ut_params->obuf = ut_params->op->sym->m_dst;
5398 ut_params->obuf = ut_params->op->sym->m_src;
5400 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5401 tdata->validCipherOffsetInBits.len >> 3);
5403 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5404 + plaintext_pad_len;
5406 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5407 (tdata->validCipherOffsetInBits.len >> 3);
5409 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5411 reference_ciphertext,
5412 tdata->validCipherLenInBits.len,
5413 "KASUMI Ciphertext data not as expected");
5416 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5419 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5420 "KASUMI Generated auth tag not as expected");
5425 test_zuc_encryption(const struct wireless_test_data *tdata)
5427 struct crypto_testsuite_params *ts_params = &testsuite_params;
5428 struct crypto_unittest_params *ut_params = &unittest_params;
5431 uint8_t *plaintext, *ciphertext;
5432 unsigned plaintext_pad_len;
5433 unsigned plaintext_len;
5434 struct rte_cryptodev_info dev_info;
5436 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5437 uint64_t feat_flags = dev_info.feature_flags;
5439 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5440 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5441 printf("Device doesn't support RAW data-path APIs.\n");
5445 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5448 struct rte_cryptodev_sym_capability_idx cap_idx;
5450 /* Check if device supports ZUC EEA3 */
5451 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5452 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5454 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5458 /* Create ZUC session */
5459 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5460 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5461 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5462 tdata->key.data, tdata->key.len,
5463 tdata->cipher_iv.len);
5467 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5469 /* Clear mbuf payload */
5470 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5471 rte_pktmbuf_tailroom(ut_params->ibuf));
5473 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5474 /* Append data which is padded to a multiple */
5475 /* of the algorithms block size */
5476 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5477 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5479 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5481 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5483 /* Create ZUC operation */
5484 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5485 tdata->cipher_iv.len,
5486 tdata->plaintext.len,
5491 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5492 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5493 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5495 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5497 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5499 ut_params->obuf = ut_params->op->sym->m_dst;
5500 if (ut_params->obuf)
5501 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5503 ciphertext = plaintext;
5505 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5508 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5510 tdata->ciphertext.data,
5511 tdata->validCipherLenInBits.len,
5512 "ZUC Ciphertext data not as expected");
5517 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5519 struct crypto_testsuite_params *ts_params = &testsuite_params;
5520 struct crypto_unittest_params *ut_params = &unittest_params;
5524 unsigned int plaintext_pad_len;
5525 unsigned int plaintext_len;
5526 const uint8_t *ciphertext;
5527 uint8_t ciphertext_buffer[2048];
5528 struct rte_cryptodev_info dev_info;
5530 struct rte_cryptodev_sym_capability_idx cap_idx;
5532 /* Check if device supports ZUC EEA3 */
5533 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5534 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5536 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5540 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5543 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5545 uint64_t feat_flags = dev_info.feature_flags;
5547 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5548 printf("Device doesn't support in-place scatter-gather. "
5553 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5554 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5555 printf("Device doesn't support RAW data-path APIs.\n");
5559 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5561 /* Append data which is padded to a multiple */
5562 /* of the algorithms block size */
5563 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5565 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5566 plaintext_pad_len, 10, 0);
5568 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5569 tdata->plaintext.data);
5571 /* Create ZUC session */
5572 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5573 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5574 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5575 tdata->key.data, tdata->key.len,
5576 tdata->cipher_iv.len);
5580 /* Clear mbuf payload */
5582 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5584 /* Create ZUC operation */
5585 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5586 tdata->cipher_iv.len, tdata->plaintext.len,
5591 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5592 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5593 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5595 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5597 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5599 ut_params->obuf = ut_params->op->sym->m_dst;
5600 if (ut_params->obuf)
5601 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5602 0, plaintext_len, ciphertext_buffer);
5604 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5605 0, plaintext_len, ciphertext_buffer);
5608 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5611 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5613 tdata->ciphertext.data,
5614 tdata->validCipherLenInBits.len,
5615 "ZUC Ciphertext data not as expected");
5621 test_zuc_authentication(const struct wireless_test_data *tdata)
5623 struct crypto_testsuite_params *ts_params = &testsuite_params;
5624 struct crypto_unittest_params *ut_params = &unittest_params;
5627 unsigned plaintext_pad_len;
5628 unsigned plaintext_len;
5631 struct rte_cryptodev_sym_capability_idx cap_idx;
5632 struct rte_cryptodev_info dev_info;
5634 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5635 uint64_t feat_flags = dev_info.feature_flags;
5637 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5638 (tdata->validAuthLenInBits.len % 8 != 0)) {
5639 printf("Device doesn't support NON-Byte Aligned Data.\n");
5643 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5644 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5645 printf("Device doesn't support RAW data-path APIs.\n");
5649 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5652 /* Check if device supports ZUC EIA3 */
5653 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5654 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5656 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5660 /* Create ZUC session */
5661 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5662 tdata->key.data, tdata->key.len,
5663 tdata->auth_iv.len, tdata->digest.len,
5664 RTE_CRYPTO_AUTH_OP_GENERATE,
5665 RTE_CRYPTO_AUTH_ZUC_EIA3);
5669 /* alloc mbuf and set payload */
5670 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5672 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5673 rte_pktmbuf_tailroom(ut_params->ibuf));
5675 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5676 /* Append data which is padded to a multiple of */
5677 /* the algorithms block size */
5678 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5679 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5681 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5683 /* Create ZUC operation */
5684 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5685 tdata->auth_iv.data, tdata->auth_iv.len,
5686 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5687 tdata->validAuthLenInBits.len,
5692 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5693 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5694 ut_params->op, 0, 1, 1, 0);
5696 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5698 ut_params->obuf = ut_params->op->sym->m_src;
5699 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5700 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5701 + plaintext_pad_len;
5704 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5708 "ZUC Generated auth tag not as expected");
5714 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5715 uint8_t op_mode, uint8_t verify)
5717 struct crypto_testsuite_params *ts_params = &testsuite_params;
5718 struct crypto_unittest_params *ut_params = &unittest_params;
5722 uint8_t *plaintext = NULL, *ciphertext = NULL;
5723 unsigned int plaintext_pad_len;
5724 unsigned int plaintext_len;
5725 unsigned int ciphertext_pad_len;
5726 unsigned int ciphertext_len;
5728 struct rte_cryptodev_info dev_info;
5729 struct rte_cryptodev_sym_capability_idx cap_idx;
5731 /* Check if device supports ZUC EIA3 */
5732 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5733 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5735 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5739 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5741 uint64_t feat_flags = dev_info.feature_flags;
5743 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5744 printf("Device doesn't support digest encrypted.\n");
5747 if (op_mode == IN_PLACE) {
5748 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5749 printf("Device doesn't support in-place scatter-gather "
5750 "in both input and output mbufs.\n");
5754 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5755 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5756 printf("Device doesn't support RAW data-path APIs.\n");
5760 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5762 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5763 printf("Device doesn't support out-of-place scatter-gather "
5764 "in both input and output mbufs.\n");
5769 /* Create ZUC session */
5770 retval = create_wireless_algo_auth_cipher_session(
5771 ts_params->valid_devs[0],
5772 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5773 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5774 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5775 : RTE_CRYPTO_AUTH_OP_GENERATE),
5776 RTE_CRYPTO_AUTH_ZUC_EIA3,
5777 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5778 tdata->key.data, tdata->key.len,
5779 tdata->auth_iv.len, tdata->digest.len,
5780 tdata->cipher_iv.len);
5785 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5786 if (op_mode == OUT_OF_PLACE)
5787 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5789 /* clear mbuf payload */
5790 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5791 rte_pktmbuf_tailroom(ut_params->ibuf));
5792 if (op_mode == OUT_OF_PLACE)
5793 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5794 rte_pktmbuf_tailroom(ut_params->obuf));
5796 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5797 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5798 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5799 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5802 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5803 ciphertext_pad_len);
5804 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5805 if (op_mode == OUT_OF_PLACE)
5806 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5807 debug_hexdump(stdout, "ciphertext:", ciphertext,
5810 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5812 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5813 if (op_mode == OUT_OF_PLACE)
5814 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5815 debug_hexdump(stdout, "plaintext:", plaintext,
5819 /* Create ZUC operation */
5820 retval = create_wireless_algo_auth_cipher_operation(
5821 tdata->digest.data, tdata->digest.len,
5822 tdata->cipher_iv.data, tdata->cipher_iv.len,
5823 tdata->auth_iv.data, tdata->auth_iv.len,
5824 (tdata->digest.offset_bytes == 0 ?
5825 (verify ? ciphertext_pad_len : plaintext_pad_len)
5826 : tdata->digest.offset_bytes),
5827 tdata->validCipherLenInBits.len,
5828 tdata->validCipherOffsetInBits.len,
5829 tdata->validAuthLenInBits.len,
5831 op_mode, 0, verify);
5836 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5837 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5838 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5840 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5843 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5845 ut_params->obuf = (op_mode == IN_PLACE ?
5846 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5850 if (ut_params->obuf)
5851 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5854 plaintext = ciphertext;
5856 debug_hexdump(stdout, "plaintext:", plaintext,
5857 (tdata->plaintext.len >> 3) - tdata->digest.len);
5858 debug_hexdump(stdout, "plaintext expected:",
5859 tdata->plaintext.data,
5860 (tdata->plaintext.len >> 3) - tdata->digest.len);
5862 if (ut_params->obuf)
5863 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5866 ciphertext = plaintext;
5868 debug_hexdump(stdout, "ciphertext:", ciphertext,
5870 debug_hexdump(stdout, "ciphertext expected:",
5871 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5873 ut_params->digest = rte_pktmbuf_mtod(
5874 ut_params->obuf, uint8_t *) +
5875 (tdata->digest.offset_bytes == 0 ?
5876 plaintext_pad_len : tdata->digest.offset_bytes);
5878 debug_hexdump(stdout, "digest:", ut_params->digest,
5880 debug_hexdump(stdout, "digest expected:",
5881 tdata->digest.data, tdata->digest.len);
5886 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5888 tdata->plaintext.data,
5889 tdata->plaintext.len >> 3,
5890 "ZUC Plaintext data not as expected");
5892 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5894 tdata->ciphertext.data,
5895 tdata->ciphertext.len >> 3,
5896 "ZUC Ciphertext data not as expected");
5898 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5901 DIGEST_BYTE_LENGTH_KASUMI_F9,
5902 "ZUC Generated auth tag not as expected");
5908 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5909 uint8_t op_mode, uint8_t verify)
5911 struct crypto_testsuite_params *ts_params = &testsuite_params;
5912 struct crypto_unittest_params *ut_params = &unittest_params;
5916 const uint8_t *plaintext = NULL;
5917 const uint8_t *ciphertext = NULL;
5918 const uint8_t *digest = NULL;
5919 unsigned int plaintext_pad_len;
5920 unsigned int plaintext_len;
5921 unsigned int ciphertext_pad_len;
5922 unsigned int ciphertext_len;
5923 uint8_t buffer[10000];
5924 uint8_t digest_buffer[10000];
5926 struct rte_cryptodev_info dev_info;
5927 struct rte_cryptodev_sym_capability_idx cap_idx;
5929 /* Check if device supports ZUC EIA3 */
5930 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5931 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5933 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5937 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5939 uint64_t feat_flags = dev_info.feature_flags;
5941 if (op_mode == IN_PLACE) {
5942 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5943 printf("Device doesn't support in-place scatter-gather "
5944 "in both input and output mbufs.\n");
5948 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5949 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5950 printf("Device doesn't support RAW data-path APIs.\n");
5954 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5956 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5957 printf("Device doesn't support out-of-place scatter-gather "
5958 "in both input and output mbufs.\n");
5961 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5962 printf("Device doesn't support digest encrypted.\n");
5967 /* Create ZUC session */
5968 retval = create_wireless_algo_auth_cipher_session(
5969 ts_params->valid_devs[0],
5970 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5971 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5972 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5973 : RTE_CRYPTO_AUTH_OP_GENERATE),
5974 RTE_CRYPTO_AUTH_ZUC_EIA3,
5975 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5976 tdata->key.data, tdata->key.len,
5977 tdata->auth_iv.len, tdata->digest.len,
5978 tdata->cipher_iv.len);
5983 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5984 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5985 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5986 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5988 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5989 plaintext_pad_len, 15, 0);
5990 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5991 "Failed to allocate input buffer in mempool");
5993 if (op_mode == OUT_OF_PLACE) {
5994 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5995 plaintext_pad_len, 15, 0);
5996 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5997 "Failed to allocate output buffer in mempool");
6001 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6002 tdata->ciphertext.data);
6003 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6004 ciphertext_len, buffer);
6005 debug_hexdump(stdout, "ciphertext:", ciphertext,
6008 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6009 tdata->plaintext.data);
6010 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6011 plaintext_len, buffer);
6012 debug_hexdump(stdout, "plaintext:", plaintext,
6015 memset(buffer, 0, sizeof(buffer));
6017 /* Create ZUC operation */
6018 retval = create_wireless_algo_auth_cipher_operation(
6019 tdata->digest.data, tdata->digest.len,
6020 tdata->cipher_iv.data, tdata->cipher_iv.len,
6022 (tdata->digest.offset_bytes == 0 ?
6023 (verify ? ciphertext_pad_len : plaintext_pad_len)
6024 : tdata->digest.offset_bytes),
6025 tdata->validCipherLenInBits.len,
6026 tdata->validCipherOffsetInBits.len,
6027 tdata->validAuthLenInBits.len,
6029 op_mode, 1, verify);
6034 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6035 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6036 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6038 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6041 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6043 ut_params->obuf = (op_mode == IN_PLACE ?
6044 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6047 if (ut_params->obuf)
6048 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6049 plaintext_len, buffer);
6051 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6052 plaintext_len, buffer);
6054 debug_hexdump(stdout, "plaintext:", plaintext,
6055 (tdata->plaintext.len >> 3) - tdata->digest.len);
6056 debug_hexdump(stdout, "plaintext expected:",
6057 tdata->plaintext.data,
6058 (tdata->plaintext.len >> 3) - tdata->digest.len);
6060 if (ut_params->obuf)
6061 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6062 ciphertext_len, buffer);
6064 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6065 ciphertext_len, buffer);
6067 debug_hexdump(stdout, "ciphertext:", ciphertext,
6069 debug_hexdump(stdout, "ciphertext expected:",
6070 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6072 if (ut_params->obuf)
6073 digest = rte_pktmbuf_read(ut_params->obuf,
6074 (tdata->digest.offset_bytes == 0 ?
6075 plaintext_pad_len : tdata->digest.offset_bytes),
6076 tdata->digest.len, digest_buffer);
6078 digest = rte_pktmbuf_read(ut_params->ibuf,
6079 (tdata->digest.offset_bytes == 0 ?
6080 plaintext_pad_len : tdata->digest.offset_bytes),
6081 tdata->digest.len, digest_buffer);
6083 debug_hexdump(stdout, "digest:", digest,
6085 debug_hexdump(stdout, "digest expected:",
6086 tdata->digest.data, tdata->digest.len);
6091 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6093 tdata->plaintext.data,
6094 tdata->plaintext.len >> 3,
6095 "ZUC Plaintext data not as expected");
6097 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6099 tdata->ciphertext.data,
6100 tdata->validDataLenInBits.len,
6101 "ZUC Ciphertext data not as expected");
6103 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6106 DIGEST_BYTE_LENGTH_KASUMI_F9,
6107 "ZUC Generated auth tag not as expected");
6113 test_kasumi_encryption_test_case_1(void)
6115 return test_kasumi_encryption(&kasumi_test_case_1);
6119 test_kasumi_encryption_test_case_1_sgl(void)
6121 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6125 test_kasumi_encryption_test_case_1_oop(void)
6127 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6131 test_kasumi_encryption_test_case_1_oop_sgl(void)
6133 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6137 test_kasumi_encryption_test_case_2(void)
6139 return test_kasumi_encryption(&kasumi_test_case_2);
6143 test_kasumi_encryption_test_case_3(void)
6145 return test_kasumi_encryption(&kasumi_test_case_3);
6149 test_kasumi_encryption_test_case_4(void)
6151 return test_kasumi_encryption(&kasumi_test_case_4);
6155 test_kasumi_encryption_test_case_5(void)
6157 return test_kasumi_encryption(&kasumi_test_case_5);
6161 test_kasumi_decryption_test_case_1(void)
6163 return test_kasumi_decryption(&kasumi_test_case_1);
6167 test_kasumi_decryption_test_case_1_oop(void)
6169 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6173 test_kasumi_decryption_test_case_2(void)
6175 return test_kasumi_decryption(&kasumi_test_case_2);
6179 test_kasumi_decryption_test_case_3(void)
6181 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6182 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6184 return test_kasumi_decryption(&kasumi_test_case_3);
6188 test_kasumi_decryption_test_case_4(void)
6190 return test_kasumi_decryption(&kasumi_test_case_4);
6194 test_kasumi_decryption_test_case_5(void)
6196 return test_kasumi_decryption(&kasumi_test_case_5);
6199 test_snow3g_encryption_test_case_1(void)
6201 return test_snow3g_encryption(&snow3g_test_case_1);
6205 test_snow3g_encryption_test_case_1_oop(void)
6207 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6211 test_snow3g_encryption_test_case_1_oop_sgl(void)
6213 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6218 test_snow3g_encryption_test_case_1_offset_oop(void)
6220 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6224 test_snow3g_encryption_test_case_2(void)
6226 return test_snow3g_encryption(&snow3g_test_case_2);
6230 test_snow3g_encryption_test_case_3(void)
6232 return test_snow3g_encryption(&snow3g_test_case_3);
6236 test_snow3g_encryption_test_case_4(void)
6238 return test_snow3g_encryption(&snow3g_test_case_4);
6242 test_snow3g_encryption_test_case_5(void)
6244 return test_snow3g_encryption(&snow3g_test_case_5);
6248 test_snow3g_decryption_test_case_1(void)
6250 return test_snow3g_decryption(&snow3g_test_case_1);
6254 test_snow3g_decryption_test_case_1_oop(void)
6256 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6260 test_snow3g_decryption_test_case_2(void)
6262 return test_snow3g_decryption(&snow3g_test_case_2);
6266 test_snow3g_decryption_test_case_3(void)
6268 return test_snow3g_decryption(&snow3g_test_case_3);
6272 test_snow3g_decryption_test_case_4(void)
6274 return test_snow3g_decryption(&snow3g_test_case_4);
6278 test_snow3g_decryption_test_case_5(void)
6280 return test_snow3g_decryption(&snow3g_test_case_5);
6284 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6285 * Pattern digest from snow3g_test_data must be allocated as
6286 * 4 last bytes in plaintext.
6289 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6290 struct snow3g_hash_test_data *output)
6292 if ((pattern != NULL) && (output != NULL)) {
6293 output->key.len = pattern->key.len;
6295 memcpy(output->key.data,
6296 pattern->key.data, pattern->key.len);
6298 output->auth_iv.len = pattern->auth_iv.len;
6300 memcpy(output->auth_iv.data,
6301 pattern->auth_iv.data, pattern->auth_iv.len);
6303 output->plaintext.len = pattern->plaintext.len;
6305 memcpy(output->plaintext.data,
6306 pattern->plaintext.data, pattern->plaintext.len >> 3);
6308 output->digest.len = pattern->digest.len;
6310 memcpy(output->digest.data,
6311 &pattern->plaintext.data[pattern->digest.offset_bytes],
6312 pattern->digest.len);
6314 output->validAuthLenInBits.len =
6315 pattern->validAuthLenInBits.len;
6320 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6323 test_snow3g_decryption_with_digest_test_case_1(void)
6325 struct snow3g_hash_test_data snow3g_hash_data;
6326 struct rte_cryptodev_info dev_info;
6327 struct crypto_testsuite_params *ts_params = &testsuite_params;
6329 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6330 uint64_t feat_flags = dev_info.feature_flags;
6332 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6333 printf("Device doesn't support encrypted digest operations.\n");
6338 * Function prepare data for hash veryfication test case.
6339 * Digest is allocated in 4 last bytes in plaintext, pattern.
6341 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6343 return test_snow3g_decryption(&snow3g_test_case_7) &
6344 test_snow3g_authentication_verify(&snow3g_hash_data);
6348 test_snow3g_cipher_auth_test_case_1(void)
6350 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6354 test_snow3g_auth_cipher_test_case_1(void)
6356 return test_snow3g_auth_cipher(
6357 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6361 test_snow3g_auth_cipher_test_case_2(void)
6363 return test_snow3g_auth_cipher(
6364 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6368 test_snow3g_auth_cipher_test_case_2_oop(void)
6370 return test_snow3g_auth_cipher(
6371 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6375 test_snow3g_auth_cipher_part_digest_enc(void)
6377 return test_snow3g_auth_cipher(
6378 &snow3g_auth_cipher_partial_digest_encryption,
6383 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6385 return test_snow3g_auth_cipher(
6386 &snow3g_auth_cipher_partial_digest_encryption,
6391 test_snow3g_auth_cipher_test_case_3_sgl(void)
6393 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6394 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6396 return test_snow3g_auth_cipher_sgl(
6397 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6401 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6403 return test_snow3g_auth_cipher_sgl(
6404 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6408 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6410 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6411 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6413 return test_snow3g_auth_cipher_sgl(
6414 &snow3g_auth_cipher_partial_digest_encryption,
6419 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6421 return test_snow3g_auth_cipher_sgl(
6422 &snow3g_auth_cipher_partial_digest_encryption,
6427 test_snow3g_auth_cipher_verify_test_case_1(void)
6429 return test_snow3g_auth_cipher(
6430 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6434 test_snow3g_auth_cipher_verify_test_case_2(void)
6436 return test_snow3g_auth_cipher(
6437 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6441 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6443 return test_snow3g_auth_cipher(
6444 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6448 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6450 return test_snow3g_auth_cipher(
6451 &snow3g_auth_cipher_partial_digest_encryption,
6456 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6458 return test_snow3g_auth_cipher(
6459 &snow3g_auth_cipher_partial_digest_encryption,
6464 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6466 return test_snow3g_auth_cipher_sgl(
6467 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6471 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6473 return test_snow3g_auth_cipher_sgl(
6474 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6478 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6480 return test_snow3g_auth_cipher_sgl(
6481 &snow3g_auth_cipher_partial_digest_encryption,
6486 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6488 return test_snow3g_auth_cipher_sgl(
6489 &snow3g_auth_cipher_partial_digest_encryption,
6494 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6496 return test_snow3g_auth_cipher(
6497 &snow3g_test_case_7, IN_PLACE, 0);
6501 test_kasumi_auth_cipher_test_case_1(void)
6503 return test_kasumi_auth_cipher(
6504 &kasumi_test_case_3, IN_PLACE, 0);
6508 test_kasumi_auth_cipher_test_case_2(void)
6510 return test_kasumi_auth_cipher(
6511 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6515 test_kasumi_auth_cipher_test_case_2_oop(void)
6517 return test_kasumi_auth_cipher(
6518 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6522 test_kasumi_auth_cipher_test_case_2_sgl(void)
6524 return test_kasumi_auth_cipher_sgl(
6525 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6529 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6531 return test_kasumi_auth_cipher_sgl(
6532 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6536 test_kasumi_auth_cipher_verify_test_case_1(void)
6538 return test_kasumi_auth_cipher(
6539 &kasumi_test_case_3, IN_PLACE, 1);
6543 test_kasumi_auth_cipher_verify_test_case_2(void)
6545 return test_kasumi_auth_cipher(
6546 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6550 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6552 return test_kasumi_auth_cipher(
6553 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6557 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6559 return test_kasumi_auth_cipher_sgl(
6560 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6564 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6566 return test_kasumi_auth_cipher_sgl(
6567 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6571 test_kasumi_cipher_auth_test_case_1(void)
6573 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6577 test_zuc_encryption_test_case_1(void)
6579 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6583 test_zuc_encryption_test_case_2(void)
6585 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6589 test_zuc_encryption_test_case_3(void)
6591 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6595 test_zuc_encryption_test_case_4(void)
6597 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6601 test_zuc_encryption_test_case_5(void)
6603 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6607 test_zuc_encryption_test_case_6_sgl(void)
6609 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6613 test_zuc_hash_generate_test_case_1(void)
6615 return test_zuc_authentication(&zuc_test_case_auth_1b);
6619 test_zuc_hash_generate_test_case_2(void)
6621 return test_zuc_authentication(&zuc_test_case_auth_90b);
6625 test_zuc_hash_generate_test_case_3(void)
6627 return test_zuc_authentication(&zuc_test_case_auth_577b);
6631 test_zuc_hash_generate_test_case_4(void)
6633 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6637 test_zuc_hash_generate_test_case_5(void)
6639 return test_zuc_authentication(&zuc_test_auth_5670b);
6643 test_zuc_hash_generate_test_case_6(void)
6645 return test_zuc_authentication(&zuc_test_case_auth_128b);
6649 test_zuc_hash_generate_test_case_7(void)
6651 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6655 test_zuc_hash_generate_test_case_8(void)
6657 return test_zuc_authentication(&zuc_test_case_auth_584b);
6661 test_zuc_cipher_auth_test_case_1(void)
6663 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6667 test_zuc_cipher_auth_test_case_2(void)
6669 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6673 test_zuc_auth_cipher_test_case_1(void)
6675 return test_zuc_auth_cipher(
6676 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6680 test_zuc_auth_cipher_test_case_1_oop(void)
6682 return test_zuc_auth_cipher(
6683 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6687 test_zuc_auth_cipher_test_case_1_sgl(void)
6689 return test_zuc_auth_cipher_sgl(
6690 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6694 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6696 return test_zuc_auth_cipher_sgl(
6697 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6701 test_zuc_auth_cipher_verify_test_case_1(void)
6703 return test_zuc_auth_cipher(
6704 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6708 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6710 return test_zuc_auth_cipher(
6711 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6715 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6717 return test_zuc_auth_cipher_sgl(
6718 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6722 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6724 return test_zuc_auth_cipher_sgl(
6725 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6729 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6731 uint8_t dev_id = testsuite_params.valid_devs[0];
6733 struct rte_cryptodev_sym_capability_idx cap_idx;
6735 /* Check if device supports particular cipher algorithm */
6736 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6737 cap_idx.algo.cipher = tdata->cipher_algo;
6738 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6741 /* Check if device supports particular hash algorithm */
6742 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6743 cap_idx.algo.auth = tdata->auth_algo;
6744 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6751 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6752 uint8_t op_mode, uint8_t verify)
6754 struct crypto_testsuite_params *ts_params = &testsuite_params;
6755 struct crypto_unittest_params *ut_params = &unittest_params;
6759 uint8_t *plaintext = NULL, *ciphertext = NULL;
6760 unsigned int plaintext_pad_len;
6761 unsigned int plaintext_len;
6762 unsigned int ciphertext_pad_len;
6763 unsigned int ciphertext_len;
6765 struct rte_cryptodev_info dev_info;
6766 struct rte_crypto_op *op;
6768 /* Check if device supports particular algorithms separately */
6769 if (test_mixed_check_if_unsupported(tdata))
6771 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6774 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6776 uint64_t feat_flags = dev_info.feature_flags;
6778 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6779 printf("Device doesn't support digest encrypted.\n");
6783 /* Create the session */
6785 retval = create_wireless_algo_cipher_auth_session(
6786 ts_params->valid_devs[0],
6787 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6788 RTE_CRYPTO_AUTH_OP_VERIFY,
6791 tdata->auth_key.data, tdata->auth_key.len,
6792 tdata->auth_iv.len, tdata->digest_enc.len,
6793 tdata->cipher_iv.len);
6795 retval = create_wireless_algo_auth_cipher_session(
6796 ts_params->valid_devs[0],
6797 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6798 RTE_CRYPTO_AUTH_OP_GENERATE,
6801 tdata->auth_key.data, tdata->auth_key.len,
6802 tdata->auth_iv.len, tdata->digest_enc.len,
6803 tdata->cipher_iv.len);
6807 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6808 if (op_mode == OUT_OF_PLACE)
6809 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6811 /* clear mbuf payload */
6812 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6813 rte_pktmbuf_tailroom(ut_params->ibuf));
6814 if (op_mode == OUT_OF_PLACE) {
6816 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6817 rte_pktmbuf_tailroom(ut_params->obuf));
6820 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6821 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6822 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6823 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6826 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6827 ciphertext_pad_len);
6828 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6829 if (op_mode == OUT_OF_PLACE)
6830 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6831 debug_hexdump(stdout, "ciphertext:", ciphertext,
6834 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6836 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6837 if (op_mode == OUT_OF_PLACE)
6838 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6839 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6842 /* Create the operation */
6843 retval = create_wireless_algo_auth_cipher_operation(
6844 tdata->digest_enc.data, tdata->digest_enc.len,
6845 tdata->cipher_iv.data, tdata->cipher_iv.len,
6846 tdata->auth_iv.data, tdata->auth_iv.len,
6847 (tdata->digest_enc.offset == 0 ?
6849 : tdata->digest_enc.offset),
6850 tdata->validCipherLen.len_bits,
6851 tdata->cipher.offset_bits,
6852 tdata->validAuthLen.len_bits,
6853 tdata->auth.offset_bits,
6854 op_mode, 0, verify);
6859 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
6861 /* Check if the op failed because the device doesn't */
6862 /* support this particular combination of algorithms */
6863 if (op == NULL && ut_params->op->status ==
6864 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6865 printf("Device doesn't support this mixed combination. "
6871 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6873 ut_params->obuf = (op_mode == IN_PLACE ?
6874 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6877 if (ut_params->obuf)
6878 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6881 plaintext = ciphertext +
6882 (tdata->cipher.offset_bits >> 3);
6884 debug_hexdump(stdout, "plaintext:", plaintext,
6885 tdata->plaintext.len_bits >> 3);
6886 debug_hexdump(stdout, "plaintext expected:",
6887 tdata->plaintext.data,
6888 tdata->plaintext.len_bits >> 3);
6890 if (ut_params->obuf)
6891 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6894 ciphertext = plaintext;
6896 debug_hexdump(stdout, "ciphertext:", ciphertext,
6898 debug_hexdump(stdout, "ciphertext expected:",
6899 tdata->ciphertext.data,
6900 tdata->ciphertext.len_bits >> 3);
6902 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6903 + (tdata->digest_enc.offset == 0 ?
6904 plaintext_pad_len : tdata->digest_enc.offset);
6906 debug_hexdump(stdout, "digest:", ut_params->digest,
6907 tdata->digest_enc.len);
6908 debug_hexdump(stdout, "digest expected:",
6909 tdata->digest_enc.data,
6910 tdata->digest_enc.len);
6915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6917 tdata->plaintext.data,
6918 tdata->plaintext.len_bits >> 3,
6919 "Plaintext data not as expected");
6921 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6923 tdata->ciphertext.data,
6924 tdata->validDataLen.len_bits,
6925 "Ciphertext data not as expected");
6927 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6929 tdata->digest_enc.data,
6930 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6931 "Generated auth tag not as expected");
6934 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6935 "crypto op processing failed");
6941 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6942 uint8_t op_mode, uint8_t verify)
6944 struct crypto_testsuite_params *ts_params = &testsuite_params;
6945 struct crypto_unittest_params *ut_params = &unittest_params;
6949 const uint8_t *plaintext = NULL;
6950 const uint8_t *ciphertext = NULL;
6951 const uint8_t *digest = NULL;
6952 unsigned int plaintext_pad_len;
6953 unsigned int plaintext_len;
6954 unsigned int ciphertext_pad_len;
6955 unsigned int ciphertext_len;
6956 uint8_t buffer[10000];
6957 uint8_t digest_buffer[10000];
6959 struct rte_cryptodev_info dev_info;
6960 struct rte_crypto_op *op;
6962 /* Check if device supports particular algorithms */
6963 if (test_mixed_check_if_unsupported(tdata))
6965 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6968 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6970 uint64_t feat_flags = dev_info.feature_flags;
6972 if (op_mode == IN_PLACE) {
6973 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6974 printf("Device doesn't support in-place scatter-gather "
6975 "in both input and output mbufs.\n");
6979 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6980 printf("Device doesn't support out-of-place scatter-gather "
6981 "in both input and output mbufs.\n");
6984 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6985 printf("Device doesn't support digest encrypted.\n");
6990 /* Create the session */
6992 retval = create_wireless_algo_cipher_auth_session(
6993 ts_params->valid_devs[0],
6994 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6995 RTE_CRYPTO_AUTH_OP_VERIFY,
6998 tdata->auth_key.data, tdata->auth_key.len,
6999 tdata->auth_iv.len, tdata->digest_enc.len,
7000 tdata->cipher_iv.len);
7002 retval = create_wireless_algo_auth_cipher_session(
7003 ts_params->valid_devs[0],
7004 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7005 RTE_CRYPTO_AUTH_OP_GENERATE,
7008 tdata->auth_key.data, tdata->auth_key.len,
7009 tdata->auth_iv.len, tdata->digest_enc.len,
7010 tdata->cipher_iv.len);
7014 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7015 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7016 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7017 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7019 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7020 ciphertext_pad_len, 15, 0);
7021 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7022 "Failed to allocate input buffer in mempool");
7024 if (op_mode == OUT_OF_PLACE) {
7025 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7026 plaintext_pad_len, 15, 0);
7027 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7028 "Failed to allocate output buffer in mempool");
7032 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7033 tdata->ciphertext.data);
7034 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7035 ciphertext_len, buffer);
7036 debug_hexdump(stdout, "ciphertext:", ciphertext,
7039 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7040 tdata->plaintext.data);
7041 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7042 plaintext_len, buffer);
7043 debug_hexdump(stdout, "plaintext:", plaintext,
7046 memset(buffer, 0, sizeof(buffer));
7048 /* Create the operation */
7049 retval = create_wireless_algo_auth_cipher_operation(
7050 tdata->digest_enc.data, tdata->digest_enc.len,
7051 tdata->cipher_iv.data, tdata->cipher_iv.len,
7052 tdata->auth_iv.data, tdata->auth_iv.len,
7053 (tdata->digest_enc.offset == 0 ?
7055 : tdata->digest_enc.offset),
7056 tdata->validCipherLen.len_bits,
7057 tdata->cipher.offset_bits,
7058 tdata->validAuthLen.len_bits,
7059 tdata->auth.offset_bits,
7060 op_mode, 1, verify);
7065 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7067 /* Check if the op failed because the device doesn't */
7068 /* support this particular combination of algorithms */
7069 if (op == NULL && ut_params->op->status ==
7070 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7071 printf("Device doesn't support this mixed combination. "
7077 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7079 ut_params->obuf = (op_mode == IN_PLACE ?
7080 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7083 if (ut_params->obuf)
7084 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7085 plaintext_len, buffer);
7087 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7088 plaintext_len, buffer);
7090 debug_hexdump(stdout, "plaintext:", plaintext,
7091 (tdata->plaintext.len_bits >> 3) -
7092 tdata->digest_enc.len);
7093 debug_hexdump(stdout, "plaintext expected:",
7094 tdata->plaintext.data,
7095 (tdata->plaintext.len_bits >> 3) -
7096 tdata->digest_enc.len);
7098 if (ut_params->obuf)
7099 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7100 ciphertext_len, buffer);
7102 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7103 ciphertext_len, buffer);
7105 debug_hexdump(stdout, "ciphertext:", ciphertext,
7107 debug_hexdump(stdout, "ciphertext expected:",
7108 tdata->ciphertext.data,
7109 tdata->ciphertext.len_bits >> 3);
7111 if (ut_params->obuf)
7112 digest = rte_pktmbuf_read(ut_params->obuf,
7113 (tdata->digest_enc.offset == 0 ?
7115 tdata->digest_enc.offset),
7116 tdata->digest_enc.len, digest_buffer);
7118 digest = rte_pktmbuf_read(ut_params->ibuf,
7119 (tdata->digest_enc.offset == 0 ?
7121 tdata->digest_enc.offset),
7122 tdata->digest_enc.len, digest_buffer);
7124 debug_hexdump(stdout, "digest:", digest,
7125 tdata->digest_enc.len);
7126 debug_hexdump(stdout, "digest expected:",
7127 tdata->digest_enc.data, tdata->digest_enc.len);
7132 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7134 tdata->plaintext.data,
7135 tdata->plaintext.len_bits >> 3,
7136 "Plaintext data not as expected");
7138 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7140 tdata->ciphertext.data,
7141 tdata->validDataLen.len_bits,
7142 "Ciphertext data not as expected");
7143 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7145 tdata->digest_enc.data,
7146 tdata->digest_enc.len,
7147 "Generated auth tag not as expected");
7150 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7151 "crypto op processing failed");
7156 /** AUTH AES CMAC + CIPHER AES CTR */
7159 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7161 return test_mixed_auth_cipher(
7162 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7166 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7168 return test_mixed_auth_cipher(
7169 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7173 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7175 return test_mixed_auth_cipher_sgl(
7176 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7180 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7182 return test_mixed_auth_cipher_sgl(
7183 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7187 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7189 return test_mixed_auth_cipher(
7190 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7194 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7196 return test_mixed_auth_cipher(
7197 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7201 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7203 return test_mixed_auth_cipher_sgl(
7204 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7208 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7210 return test_mixed_auth_cipher_sgl(
7211 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7214 /** MIXED AUTH + CIPHER */
7217 test_auth_zuc_cipher_snow_test_case_1(void)
7219 return test_mixed_auth_cipher(
7220 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7224 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7226 return test_mixed_auth_cipher(
7227 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7231 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7233 return test_mixed_auth_cipher(
7234 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7238 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7240 return test_mixed_auth_cipher(
7241 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7245 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7247 return test_mixed_auth_cipher(
7248 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7252 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7254 return test_mixed_auth_cipher(
7255 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7259 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7261 return test_mixed_auth_cipher(
7262 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7266 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7268 return test_mixed_auth_cipher(
7269 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7273 test_auth_snow_cipher_zuc_test_case_1(void)
7275 return test_mixed_auth_cipher(
7276 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7280 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7282 return test_mixed_auth_cipher(
7283 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7287 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7289 return test_mixed_auth_cipher(
7290 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7294 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7296 return test_mixed_auth_cipher(
7297 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7301 test_auth_null_cipher_snow_test_case_1(void)
7303 return test_mixed_auth_cipher(
7304 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7308 test_verify_auth_null_cipher_snow_test_case_1(void)
7310 return test_mixed_auth_cipher(
7311 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7315 test_auth_null_cipher_zuc_test_case_1(void)
7317 return test_mixed_auth_cipher(
7318 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7322 test_verify_auth_null_cipher_zuc_test_case_1(void)
7324 return test_mixed_auth_cipher(
7325 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7329 test_auth_snow_cipher_null_test_case_1(void)
7331 return test_mixed_auth_cipher(
7332 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7336 test_verify_auth_snow_cipher_null_test_case_1(void)
7338 return test_mixed_auth_cipher(
7339 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7343 test_auth_zuc_cipher_null_test_case_1(void)
7345 return test_mixed_auth_cipher(
7346 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7350 test_verify_auth_zuc_cipher_null_test_case_1(void)
7352 return test_mixed_auth_cipher(
7353 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7357 test_auth_null_cipher_aes_ctr_test_case_1(void)
7359 return test_mixed_auth_cipher(
7360 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7364 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7366 return test_mixed_auth_cipher(
7367 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7371 test_auth_aes_cmac_cipher_null_test_case_1(void)
7373 return test_mixed_auth_cipher(
7374 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7378 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7380 return test_mixed_auth_cipher(
7381 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7384 /* ***** AEAD algorithm Tests ***** */
7387 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7388 enum rte_crypto_aead_operation op,
7389 const uint8_t *key, const uint8_t key_len,
7390 const uint16_t aad_len, const uint8_t auth_len,
7393 uint8_t aead_key[key_len];
7395 struct crypto_testsuite_params *ts_params = &testsuite_params;
7396 struct crypto_unittest_params *ut_params = &unittest_params;
7398 memcpy(aead_key, key, key_len);
7400 /* Setup AEAD Parameters */
7401 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7402 ut_params->aead_xform.next = NULL;
7403 ut_params->aead_xform.aead.algo = algo;
7404 ut_params->aead_xform.aead.op = op;
7405 ut_params->aead_xform.aead.key.data = aead_key;
7406 ut_params->aead_xform.aead.key.length = key_len;
7407 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7408 ut_params->aead_xform.aead.iv.length = iv_len;
7409 ut_params->aead_xform.aead.digest_length = auth_len;
7410 ut_params->aead_xform.aead.aad_length = aad_len;
7412 debug_hexdump(stdout, "key:", key, key_len);
7414 /* Create Crypto session*/
7415 ut_params->sess = rte_cryptodev_sym_session_create(
7416 ts_params->session_mpool);
7418 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7419 &ut_params->aead_xform,
7420 ts_params->session_priv_mpool);
7422 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7428 create_aead_xform(struct rte_crypto_op *op,
7429 enum rte_crypto_aead_algorithm algo,
7430 enum rte_crypto_aead_operation aead_op,
7431 uint8_t *key, const uint8_t key_len,
7432 const uint8_t aad_len, const uint8_t auth_len,
7435 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7436 "failed to allocate space for crypto transform");
7438 struct rte_crypto_sym_op *sym_op = op->sym;
7440 /* Setup AEAD Parameters */
7441 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7442 sym_op->xform->next = NULL;
7443 sym_op->xform->aead.algo = algo;
7444 sym_op->xform->aead.op = aead_op;
7445 sym_op->xform->aead.key.data = key;
7446 sym_op->xform->aead.key.length = key_len;
7447 sym_op->xform->aead.iv.offset = IV_OFFSET;
7448 sym_op->xform->aead.iv.length = iv_len;
7449 sym_op->xform->aead.digest_length = auth_len;
7450 sym_op->xform->aead.aad_length = aad_len;
7452 debug_hexdump(stdout, "key:", key, key_len);
7458 create_aead_operation(enum rte_crypto_aead_operation op,
7459 const struct aead_test_data *tdata)
7461 struct crypto_testsuite_params *ts_params = &testsuite_params;
7462 struct crypto_unittest_params *ut_params = &unittest_params;
7464 uint8_t *plaintext, *ciphertext;
7465 unsigned int aad_pad_len, plaintext_pad_len;
7467 /* Generate Crypto op data structure */
7468 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7469 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7470 TEST_ASSERT_NOT_NULL(ut_params->op,
7471 "Failed to allocate symmetric crypto operation struct");
7473 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7475 /* Append aad data */
7476 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7477 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7478 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7480 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7481 "no room to append aad");
7483 sym_op->aead.aad.phys_addr =
7484 rte_pktmbuf_iova(ut_params->ibuf);
7485 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7486 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7487 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7490 /* Append IV at the end of the crypto operation*/
7491 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7492 uint8_t *, IV_OFFSET);
7494 /* Copy IV 1 byte after the IV pointer, according to the API */
7495 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7496 debug_hexdump(stdout, "iv:", iv_ptr,
7499 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7500 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7502 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7503 "no room to append aad");
7505 sym_op->aead.aad.phys_addr =
7506 rte_pktmbuf_iova(ut_params->ibuf);
7507 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7508 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7511 /* Append IV at the end of the crypto operation*/
7512 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7513 uint8_t *, IV_OFFSET);
7515 if (tdata->iv.len == 0) {
7516 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7517 debug_hexdump(stdout, "iv:", iv_ptr,
7520 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7521 debug_hexdump(stdout, "iv:", iv_ptr,
7526 /* Append plaintext/ciphertext */
7527 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7528 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7529 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7531 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7533 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7534 debug_hexdump(stdout, "plaintext:", plaintext,
7535 tdata->plaintext.len);
7537 if (ut_params->obuf) {
7538 ciphertext = (uint8_t *)rte_pktmbuf_append(
7540 plaintext_pad_len + aad_pad_len);
7541 TEST_ASSERT_NOT_NULL(ciphertext,
7542 "no room to append ciphertext");
7544 memset(ciphertext + aad_pad_len, 0,
7545 tdata->ciphertext.len);
7548 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7549 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7551 TEST_ASSERT_NOT_NULL(ciphertext,
7552 "no room to append ciphertext");
7554 memcpy(ciphertext, tdata->ciphertext.data,
7555 tdata->ciphertext.len);
7556 debug_hexdump(stdout, "ciphertext:", ciphertext,
7557 tdata->ciphertext.len);
7559 if (ut_params->obuf) {
7560 plaintext = (uint8_t *)rte_pktmbuf_append(
7562 plaintext_pad_len + aad_pad_len);
7563 TEST_ASSERT_NOT_NULL(plaintext,
7564 "no room to append plaintext");
7566 memset(plaintext + aad_pad_len, 0,
7567 tdata->plaintext.len);
7571 /* Append digest data */
7572 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7573 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7574 ut_params->obuf ? ut_params->obuf :
7576 tdata->auth_tag.len);
7577 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7578 "no room to append digest");
7579 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7580 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7581 ut_params->obuf ? ut_params->obuf :
7586 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7587 ut_params->ibuf, tdata->auth_tag.len);
7588 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7589 "no room to append digest");
7590 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7592 plaintext_pad_len + aad_pad_len);
7594 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7595 tdata->auth_tag.len);
7596 debug_hexdump(stdout, "digest:",
7597 sym_op->aead.digest.data,
7598 tdata->auth_tag.len);
7601 sym_op->aead.data.length = tdata->plaintext.len;
7602 sym_op->aead.data.offset = aad_pad_len;
7608 test_authenticated_encryption(const struct aead_test_data *tdata)
7610 struct crypto_testsuite_params *ts_params = &testsuite_params;
7611 struct crypto_unittest_params *ut_params = &unittest_params;
7614 uint8_t *ciphertext, *auth_tag;
7615 uint16_t plaintext_pad_len;
7617 struct rte_cryptodev_info dev_info;
7619 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7620 uint64_t feat_flags = dev_info.feature_flags;
7622 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7623 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7624 printf("Device doesn't support RAW data-path APIs.\n");
7628 /* Verify the capabilities */
7629 struct rte_cryptodev_sym_capability_idx cap_idx;
7630 const struct rte_cryptodev_symmetric_capability *capability;
7631 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7632 cap_idx.algo.aead = tdata->algo;
7633 capability = rte_cryptodev_sym_capability_get(
7634 ts_params->valid_devs[0], &cap_idx);
7635 if (capability == NULL)
7637 if (rte_cryptodev_sym_capability_check_aead(
7638 capability, tdata->key.len, tdata->auth_tag.len,
7639 tdata->aad.len, tdata->iv.len))
7642 /* Create AEAD session */
7643 retval = create_aead_session(ts_params->valid_devs[0],
7645 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7646 tdata->key.data, tdata->key.len,
7647 tdata->aad.len, tdata->auth_tag.len,
7652 if (tdata->aad.len > MBUF_SIZE) {
7653 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7654 /* Populate full size of add data */
7655 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7656 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7658 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7660 /* clear mbuf payload */
7661 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7662 rte_pktmbuf_tailroom(ut_params->ibuf));
7664 /* Create AEAD operation */
7665 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7669 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7671 ut_params->op->sym->m_src = ut_params->ibuf;
7673 /* Process crypto operation */
7674 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7675 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7676 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7677 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
7678 ut_params->op, 0, 0, 0, 0);
7680 TEST_ASSERT_NOT_NULL(
7681 process_crypto_request(ts_params->valid_devs[0],
7682 ut_params->op), "failed to process sym crypto op");
7684 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7685 "crypto op processing failed");
7687 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7689 if (ut_params->op->sym->m_dst) {
7690 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7692 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7693 uint8_t *, plaintext_pad_len);
7695 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7697 ut_params->op->sym->cipher.data.offset);
7698 auth_tag = ciphertext + plaintext_pad_len;
7701 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7702 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7705 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7707 tdata->ciphertext.data,
7708 tdata->ciphertext.len,
7709 "Ciphertext data not as expected");
7711 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7713 tdata->auth_tag.data,
7714 tdata->auth_tag.len,
7715 "Generated auth tag not as expected");
7721 #ifdef RTE_LIB_SECURITY
7723 security_proto_supported(enum rte_security_session_action_type action,
7724 enum rte_security_session_protocol proto)
7726 struct crypto_testsuite_params *ts_params = &testsuite_params;
7728 const struct rte_security_capability *capabilities;
7729 const struct rte_security_capability *capability;
7732 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7733 rte_cryptodev_get_sec_ctx(
7734 ts_params->valid_devs[0]);
7737 capabilities = rte_security_capabilities_get(ctx);
7739 if (capabilities == NULL)
7742 while ((capability = &capabilities[i++])->action !=
7743 RTE_SECURITY_ACTION_TYPE_NONE) {
7744 if (capability->action == action &&
7745 capability->protocol == proto)
7752 /* Basic algorithm run function for async inplace mode.
7753 * Creates a session from input parameters and runs one operation
7754 * on input_vec. Checks the output of the crypto operation against
7757 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
7758 enum rte_crypto_auth_operation opa,
7759 const uint8_t *input_vec, unsigned int input_vec_len,
7760 const uint8_t *output_vec,
7761 unsigned int output_vec_len,
7762 enum rte_crypto_cipher_algorithm cipher_alg,
7763 const uint8_t *cipher_key, uint32_t cipher_key_len,
7764 enum rte_crypto_auth_algorithm auth_alg,
7765 const uint8_t *auth_key, uint32_t auth_key_len,
7766 uint8_t bearer, enum rte_security_pdcp_domain domain,
7767 uint8_t packet_direction, uint8_t sn_size,
7768 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
7770 struct crypto_testsuite_params *ts_params = &testsuite_params;
7771 struct crypto_unittest_params *ut_params = &unittest_params;
7773 int ret = TEST_SUCCESS;
7774 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7775 rte_cryptodev_get_sec_ctx(
7776 ts_params->valid_devs[0]);
7778 /* Verify the capabilities */
7779 struct rte_security_capability_idx sec_cap_idx;
7781 sec_cap_idx.action = ut_params->type;
7782 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7783 sec_cap_idx.pdcp.domain = domain;
7784 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7787 /* Generate test mbuf data */
7788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7790 /* clear mbuf payload */
7791 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7792 rte_pktmbuf_tailroom(ut_params->ibuf));
7794 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7796 memcpy(plaintext, input_vec, input_vec_len);
7798 /* Out of place support */
7801 * For out-op-place we need to alloc another mbuf
7803 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7804 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7807 /* Setup Cipher Parameters */
7808 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7809 ut_params->cipher_xform.cipher.algo = cipher_alg;
7810 ut_params->cipher_xform.cipher.op = opc;
7811 ut_params->cipher_xform.cipher.key.data = cipher_key;
7812 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
7813 ut_params->cipher_xform.cipher.iv.length =
7814 packet_direction ? 4 : 0;
7815 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7817 /* Setup HMAC Parameters if ICV header is required */
7818 if (auth_alg != 0) {
7819 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7820 ut_params->auth_xform.next = NULL;
7821 ut_params->auth_xform.auth.algo = auth_alg;
7822 ut_params->auth_xform.auth.op = opa;
7823 ut_params->auth_xform.auth.key.data = auth_key;
7824 ut_params->auth_xform.auth.key.length = auth_key_len;
7826 ut_params->cipher_xform.next = &ut_params->auth_xform;
7828 ut_params->cipher_xform.next = NULL;
7831 struct rte_security_session_conf sess_conf = {
7832 .action_type = ut_params->type,
7833 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7837 .pkt_dir = packet_direction,
7839 .hfn = packet_direction ? 0 : hfn,
7841 * hfn can be set as pdcp_test_hfn[i]
7842 * if hfn_ovrd is not set. Here, PDCP
7843 * packet direction is just used to
7844 * run half of the cases with session
7845 * HFN and other half with per packet
7848 .hfn_threshold = hfn_threshold,
7849 .hfn_ovrd = packet_direction ? 1 : 0,
7850 .sdap_enabled = sdap,
7852 .crypto_xform = &ut_params->cipher_xform
7855 /* Create security session */
7856 ut_params->sec_session = rte_security_session_create(ctx,
7857 &sess_conf, ts_params->session_mpool,
7858 ts_params->session_priv_mpool);
7860 if (!ut_params->sec_session) {
7861 printf("TestCase %s()-%d line %d failed %s: ",
7862 __func__, i, __LINE__, "Failed to allocate session");
7867 /* Generate crypto op data structure */
7868 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7869 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7870 if (!ut_params->op) {
7871 printf("TestCase %s()-%d line %d failed %s: ",
7872 __func__, i, __LINE__,
7873 "Failed to allocate symmetric crypto operation struct");
7878 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7879 uint32_t *, IV_OFFSET);
7880 *per_pkt_hfn = packet_direction ? hfn : 0;
7882 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7884 /* set crypto operation source mbuf */
7885 ut_params->op->sym->m_src = ut_params->ibuf;
7887 ut_params->op->sym->m_dst = ut_params->obuf;
7889 /* Process crypto operation */
7890 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7892 printf("TestCase %s()-%d line %d failed %s: ",
7893 __func__, i, __LINE__,
7894 "failed to process sym crypto op");
7899 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7900 printf("TestCase %s()-%d line %d failed %s: ",
7901 __func__, i, __LINE__, "crypto op processing failed");
7907 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7910 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7914 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7915 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7916 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7917 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7923 rte_crypto_op_free(ut_params->op);
7924 ut_params->op = NULL;
7926 if (ut_params->sec_session)
7927 rte_security_session_destroy(ctx, ut_params->sec_session);
7928 ut_params->sec_session = NULL;
7930 rte_pktmbuf_free(ut_params->ibuf);
7931 ut_params->ibuf = NULL;
7933 rte_pktmbuf_free(ut_params->obuf);
7934 ut_params->obuf = NULL;
7941 test_pdcp_proto_SGL(int i, int oop,
7942 enum rte_crypto_cipher_operation opc,
7943 enum rte_crypto_auth_operation opa,
7945 unsigned int input_vec_len,
7946 uint8_t *output_vec,
7947 unsigned int output_vec_len,
7949 uint32_t fragsz_oop)
7951 struct crypto_testsuite_params *ts_params = &testsuite_params;
7952 struct crypto_unittest_params *ut_params = &unittest_params;
7954 struct rte_mbuf *buf, *buf_oop = NULL;
7955 int ret = TEST_SUCCESS;
7959 unsigned int trn_data = 0;
7960 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7961 rte_cryptodev_get_sec_ctx(
7962 ts_params->valid_devs[0]);
7964 /* Verify the capabilities */
7965 struct rte_security_capability_idx sec_cap_idx;
7967 sec_cap_idx.action = ut_params->type;
7968 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7969 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7970 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7973 if (fragsz > input_vec_len)
7974 fragsz = input_vec_len;
7976 uint16_t plaintext_len = fragsz;
7977 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7979 if (fragsz_oop > output_vec_len)
7980 frag_size_oop = output_vec_len;
7983 if (input_vec_len % fragsz != 0) {
7984 if (input_vec_len / fragsz + 1 > 16)
7986 } else if (input_vec_len / fragsz > 16)
7989 /* Out of place support */
7992 * For out-op-place we need to alloc another mbuf
7994 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7995 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7996 buf_oop = ut_params->obuf;
7999 /* Generate test mbuf data */
8000 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8002 /* clear mbuf payload */
8003 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8004 rte_pktmbuf_tailroom(ut_params->ibuf));
8006 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8008 memcpy(plaintext, input_vec, plaintext_len);
8009 trn_data += plaintext_len;
8011 buf = ut_params->ibuf;
8014 * Loop until no more fragments
8017 while (trn_data < input_vec_len) {
8019 to_trn = (input_vec_len - trn_data < fragsz) ?
8020 (input_vec_len - trn_data) : fragsz;
8022 to_trn_tbl[ecx++] = to_trn;
8024 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8027 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8028 rte_pktmbuf_tailroom(buf));
8031 if (oop && !fragsz_oop) {
8033 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8034 buf_oop = buf_oop->next;
8035 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8036 0, rte_pktmbuf_tailroom(buf_oop));
8037 rte_pktmbuf_append(buf_oop, to_trn);
8040 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8043 memcpy(plaintext, input_vec + trn_data, to_trn);
8047 ut_params->ibuf->nb_segs = segs;
8050 if (fragsz_oop && oop) {
8054 trn_data = frag_size_oop;
8055 while (trn_data < output_vec_len) {
8058 (output_vec_len - trn_data <
8060 (output_vec_len - trn_data) :
8063 to_trn_tbl[ecx++] = to_trn;
8066 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8067 buf_oop = buf_oop->next;
8068 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8069 0, rte_pktmbuf_tailroom(buf_oop));
8070 rte_pktmbuf_append(buf_oop, to_trn);
8074 ut_params->obuf->nb_segs = segs;
8077 /* Setup Cipher Parameters */
8078 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8079 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8080 ut_params->cipher_xform.cipher.op = opc;
8081 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8082 ut_params->cipher_xform.cipher.key.length =
8083 pdcp_test_params[i].cipher_key_len;
8084 ut_params->cipher_xform.cipher.iv.length = 0;
8086 /* Setup HMAC Parameters if ICV header is required */
8087 if (pdcp_test_params[i].auth_alg != 0) {
8088 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8089 ut_params->auth_xform.next = NULL;
8090 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8091 ut_params->auth_xform.auth.op = opa;
8092 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8093 ut_params->auth_xform.auth.key.length =
8094 pdcp_test_params[i].auth_key_len;
8096 ut_params->cipher_xform.next = &ut_params->auth_xform;
8098 ut_params->cipher_xform.next = NULL;
8101 struct rte_security_session_conf sess_conf = {
8102 .action_type = ut_params->type,
8103 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8105 .bearer = pdcp_test_bearer[i],
8106 .domain = pdcp_test_params[i].domain,
8107 .pkt_dir = pdcp_test_packet_direction[i],
8108 .sn_size = pdcp_test_data_sn_size[i],
8109 .hfn = pdcp_test_hfn[i],
8110 .hfn_threshold = pdcp_test_hfn_threshold[i],
8113 .crypto_xform = &ut_params->cipher_xform
8116 /* Create security session */
8117 ut_params->sec_session = rte_security_session_create(ctx,
8118 &sess_conf, ts_params->session_mpool,
8119 ts_params->session_priv_mpool);
8121 if (!ut_params->sec_session) {
8122 printf("TestCase %s()-%d line %d failed %s: ",
8123 __func__, i, __LINE__, "Failed to allocate session");
8128 /* Generate crypto op data structure */
8129 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8130 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8131 if (!ut_params->op) {
8132 printf("TestCase %s()-%d line %d failed %s: ",
8133 __func__, i, __LINE__,
8134 "Failed to allocate symmetric crypto operation struct");
8139 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8141 /* set crypto operation source mbuf */
8142 ut_params->op->sym->m_src = ut_params->ibuf;
8144 ut_params->op->sym->m_dst = ut_params->obuf;
8146 /* Process crypto operation */
8147 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8149 printf("TestCase %s()-%d line %d failed %s: ",
8150 __func__, i, __LINE__,
8151 "failed to process sym crypto op");
8156 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8157 printf("TestCase %s()-%d line %d failed %s: ",
8158 __func__, i, __LINE__, "crypto op processing failed");
8164 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8167 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8171 fragsz = frag_size_oop;
8172 if (memcmp(ciphertext, output_vec, fragsz)) {
8173 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8174 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8175 rte_hexdump(stdout, "reference", output_vec, fragsz);
8180 buf = ut_params->op->sym->m_src->next;
8182 buf = ut_params->op->sym->m_dst->next;
8184 unsigned int off = fragsz;
8188 ciphertext = rte_pktmbuf_mtod(buf,
8190 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8191 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8192 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8193 rte_hexdump(stdout, "reference", output_vec + off,
8198 off += to_trn_tbl[ecx++];
8202 rte_crypto_op_free(ut_params->op);
8203 ut_params->op = NULL;
8205 if (ut_params->sec_session)
8206 rte_security_session_destroy(ctx, ut_params->sec_session);
8207 ut_params->sec_session = NULL;
8209 rte_pktmbuf_free(ut_params->ibuf);
8210 ut_params->ibuf = NULL;
8212 rte_pktmbuf_free(ut_params->obuf);
8213 ut_params->obuf = NULL;
8220 test_pdcp_proto_cplane_encap(int i)
8222 return test_pdcp_proto(
8223 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8224 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8225 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8226 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8227 pdcp_test_params[i].cipher_key_len,
8228 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8229 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8230 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8231 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8232 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8236 test_pdcp_proto_uplane_encap(int i)
8238 return test_pdcp_proto(
8239 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8240 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8241 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8242 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8243 pdcp_test_params[i].cipher_key_len,
8244 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8245 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8246 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8247 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8248 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8252 test_pdcp_proto_uplane_encap_with_int(int i)
8254 return test_pdcp_proto(
8255 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8256 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8257 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8258 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8259 pdcp_test_params[i].cipher_key_len,
8260 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8261 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8262 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8263 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8264 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8268 test_pdcp_proto_cplane_decap(int i)
8270 return test_pdcp_proto(
8271 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8272 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8273 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8274 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8275 pdcp_test_params[i].cipher_key_len,
8276 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8277 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8278 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8279 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8280 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8284 test_pdcp_proto_uplane_decap(int i)
8286 return test_pdcp_proto(
8287 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8288 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8289 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8290 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8291 pdcp_test_params[i].cipher_key_len,
8292 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8293 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8294 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8295 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8296 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8300 test_pdcp_proto_uplane_decap_with_int(int i)
8302 return test_pdcp_proto(
8303 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8304 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8305 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8306 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8307 pdcp_test_params[i].cipher_key_len,
8308 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8309 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8310 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8311 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8312 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8316 test_PDCP_PROTO_SGL_in_place_32B(void)
8318 /* i can be used for running any PDCP case
8319 * In this case it is uplane 12-bit AES-SNOW DL encap
8321 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8322 return test_pdcp_proto_SGL(i, IN_PLACE,
8323 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8324 RTE_CRYPTO_AUTH_OP_GENERATE,
8325 pdcp_test_data_in[i],
8326 pdcp_test_data_in_len[i],
8327 pdcp_test_data_out[i],
8328 pdcp_test_data_in_len[i]+4,
8332 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8334 /* i can be used for running any PDCP case
8335 * In this case it is uplane 18-bit NULL-NULL DL encap
8337 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8338 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8339 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8340 RTE_CRYPTO_AUTH_OP_GENERATE,
8341 pdcp_test_data_in[i],
8342 pdcp_test_data_in_len[i],
8343 pdcp_test_data_out[i],
8344 pdcp_test_data_in_len[i]+4,
8348 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8350 /* i can be used for running any PDCP case
8351 * In this case it is uplane 18-bit AES DL encap
8353 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8355 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8356 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8357 RTE_CRYPTO_AUTH_OP_GENERATE,
8358 pdcp_test_data_in[i],
8359 pdcp_test_data_in_len[i],
8360 pdcp_test_data_out[i],
8361 pdcp_test_data_in_len[i],
8365 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8367 /* i can be used for running any PDCP case
8368 * In this case it is cplane 12-bit AES-ZUC DL encap
8370 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8371 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8372 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8373 RTE_CRYPTO_AUTH_OP_GENERATE,
8374 pdcp_test_data_in[i],
8375 pdcp_test_data_in_len[i],
8376 pdcp_test_data_out[i],
8377 pdcp_test_data_in_len[i]+4,
8382 test_PDCP_SDAP_PROTO_encap_all(void)
8384 int i = 0, size = 0;
8385 int err, all_err = TEST_SUCCESS;
8386 const struct pdcp_sdap_test *cur_test;
8388 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8390 for (i = 0; i < size; i++) {
8391 cur_test = &list_pdcp_sdap_tests[i];
8392 err = test_pdcp_proto(
8393 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8394 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8395 cur_test->in_len, cur_test->data_out,
8396 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8397 cur_test->param.cipher_alg, cur_test->cipher_key,
8398 cur_test->param.cipher_key_len,
8399 cur_test->param.auth_alg,
8400 cur_test->auth_key, cur_test->param.auth_key_len,
8401 cur_test->bearer, cur_test->param.domain,
8402 cur_test->packet_direction, cur_test->sn_size,
8404 cur_test->hfn_threshold, SDAP_ENABLED);
8406 printf("\t%d) %s: Encapsulation failed\n",
8408 cur_test->param.name);
8411 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8412 cur_test->param.name);
8418 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8420 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8424 test_PDCP_SDAP_PROTO_decap_all(void)
8426 int i = 0, size = 0;
8427 int err, all_err = TEST_SUCCESS;
8428 const struct pdcp_sdap_test *cur_test;
8430 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8432 for (i = 0; i < size; i++) {
8433 cur_test = &list_pdcp_sdap_tests[i];
8434 err = test_pdcp_proto(
8435 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8436 RTE_CRYPTO_AUTH_OP_VERIFY,
8438 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8439 cur_test->data_in, cur_test->in_len,
8440 cur_test->param.cipher_alg,
8441 cur_test->cipher_key, cur_test->param.cipher_key_len,
8442 cur_test->param.auth_alg, cur_test->auth_key,
8443 cur_test->param.auth_key_len, cur_test->bearer,
8444 cur_test->param.domain, cur_test->packet_direction,
8445 cur_test->sn_size, cur_test->hfn,
8446 cur_test->hfn_threshold, SDAP_ENABLED);
8448 printf("\t%d) %s: Decapsulation failed\n",
8450 cur_test->param.name);
8453 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8454 cur_test->param.name);
8460 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8462 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8466 test_PDCP_PROTO_all(void)
8468 struct crypto_testsuite_params *ts_params = &testsuite_params;
8469 struct crypto_unittest_params *ut_params = &unittest_params;
8470 struct rte_cryptodev_info dev_info;
8473 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8474 uint64_t feat_flags = dev_info.feature_flags;
8476 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8479 /* Set action type */
8480 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8481 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8484 if (security_proto_supported(ut_params->type,
8485 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8488 status = test_PDCP_PROTO_cplane_encap_all();
8489 status += test_PDCP_PROTO_cplane_decap_all();
8490 status += test_PDCP_PROTO_uplane_encap_all();
8491 status += test_PDCP_PROTO_uplane_decap_all();
8492 status += test_PDCP_PROTO_SGL_in_place_32B();
8493 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8494 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8495 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8496 status += test_PDCP_SDAP_PROTO_encap_all();
8497 status += test_PDCP_SDAP_PROTO_decap_all();
8502 return TEST_SUCCESS;
8506 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8508 struct crypto_testsuite_params *ts_params = &testsuite_params;
8509 struct crypto_unittest_params *ut_params = &unittest_params;
8510 uint8_t *plaintext, *ciphertext;
8512 int32_t cipher_len, crc_len;
8513 uint32_t crc_data_len;
8514 int ret = TEST_SUCCESS;
8516 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8517 rte_cryptodev_get_sec_ctx(
8518 ts_params->valid_devs[0]);
8520 /* Verify the capabilities */
8521 struct rte_security_capability_idx sec_cap_idx;
8522 const struct rte_security_capability *sec_cap;
8523 const struct rte_cryptodev_capabilities *crypto_cap;
8524 const struct rte_cryptodev_symmetric_capability *sym_cap;
8527 sec_cap_idx.action = ut_params->type;
8528 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8529 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8531 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8532 if (sec_cap == NULL)
8535 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8536 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8537 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8538 crypto_cap->sym.xform_type ==
8539 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8540 crypto_cap->sym.cipher.algo ==
8541 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8542 sym_cap = &crypto_cap->sym;
8543 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8550 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8553 /* Setup source mbuf payload */
8554 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8555 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8556 rte_pktmbuf_tailroom(ut_params->ibuf));
8558 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8559 d_td->ciphertext.len);
8561 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8563 /* Setup cipher session parameters */
8564 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8565 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8566 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8567 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8568 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8569 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8570 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8571 ut_params->cipher_xform.next = NULL;
8573 /* Setup DOCSIS session parameters */
8574 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8576 struct rte_security_session_conf sess_conf = {
8577 .action_type = ut_params->type,
8578 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8579 .docsis = ut_params->docsis_xform,
8580 .crypto_xform = &ut_params->cipher_xform,
8583 /* Create security session */
8584 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8585 ts_params->session_mpool,
8586 ts_params->session_priv_mpool);
8588 if (!ut_params->sec_session) {
8589 printf("TestCase %s(%d) line %d: %s\n",
8590 __func__, i, __LINE__, "failed to allocate session");
8595 /* Generate crypto op data structure */
8596 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8597 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8598 if (!ut_params->op) {
8599 printf("TestCase %s(%d) line %d: %s\n",
8600 __func__, i, __LINE__,
8601 "failed to allocate symmetric crypto operation");
8606 /* Setup CRC operation parameters */
8607 crc_len = d_td->ciphertext.no_crc == false ?
8608 (d_td->ciphertext.len -
8609 d_td->ciphertext.crc_offset -
8610 RTE_ETHER_CRC_LEN) :
8612 crc_len = crc_len > 0 ? crc_len : 0;
8613 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8614 ut_params->op->sym->auth.data.length = crc_len;
8615 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8617 /* Setup cipher operation parameters */
8618 cipher_len = d_td->ciphertext.no_cipher == false ?
8619 (d_td->ciphertext.len -
8620 d_td->ciphertext.cipher_offset) :
8622 cipher_len = cipher_len > 0 ? cipher_len : 0;
8623 ut_params->op->sym->cipher.data.length = cipher_len;
8624 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8626 /* Setup cipher IV */
8627 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8628 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8630 /* Attach session to operation */
8631 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8633 /* Set crypto operation mbufs */
8634 ut_params->op->sym->m_src = ut_params->ibuf;
8635 ut_params->op->sym->m_dst = NULL;
8637 /* Process crypto operation */
8638 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8640 printf("TestCase %s(%d) line %d: %s\n",
8641 __func__, i, __LINE__,
8642 "failed to process security crypto op");
8647 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8648 printf("TestCase %s(%d) line %d: %s\n",
8649 __func__, i, __LINE__, "crypto op processing failed");
8654 /* Validate plaintext */
8655 plaintext = ciphertext;
8657 if (memcmp(plaintext, d_td->plaintext.data,
8658 d_td->plaintext.len - crc_data_len)) {
8659 printf("TestCase %s(%d) line %d: %s\n",
8660 __func__, i, __LINE__, "plaintext not as expected\n");
8661 rte_hexdump(stdout, "expected", d_td->plaintext.data,
8662 d_td->plaintext.len);
8663 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
8669 rte_crypto_op_free(ut_params->op);
8670 ut_params->op = NULL;
8672 if (ut_params->sec_session)
8673 rte_security_session_destroy(ctx, ut_params->sec_session);
8674 ut_params->sec_session = NULL;
8676 rte_pktmbuf_free(ut_params->ibuf);
8677 ut_params->ibuf = NULL;
8683 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
8685 struct crypto_testsuite_params *ts_params = &testsuite_params;
8686 struct crypto_unittest_params *ut_params = &unittest_params;
8687 uint8_t *plaintext, *ciphertext;
8689 int32_t cipher_len, crc_len;
8690 int ret = TEST_SUCCESS;
8692 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8693 rte_cryptodev_get_sec_ctx(
8694 ts_params->valid_devs[0]);
8696 /* Verify the capabilities */
8697 struct rte_security_capability_idx sec_cap_idx;
8698 const struct rte_security_capability *sec_cap;
8699 const struct rte_cryptodev_capabilities *crypto_cap;
8700 const struct rte_cryptodev_symmetric_capability *sym_cap;
8703 sec_cap_idx.action = ut_params->type;
8704 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8705 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8707 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8708 if (sec_cap == NULL)
8711 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8712 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8713 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8714 crypto_cap->sym.xform_type ==
8715 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8716 crypto_cap->sym.cipher.algo ==
8717 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8718 sym_cap = &crypto_cap->sym;
8719 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8726 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8729 /* Setup source mbuf payload */
8730 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8731 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8732 rte_pktmbuf_tailroom(ut_params->ibuf));
8734 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8735 d_td->plaintext.len);
8737 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
8739 /* Setup cipher session parameters */
8740 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8741 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8742 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8743 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8744 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8745 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8746 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8747 ut_params->cipher_xform.next = NULL;
8749 /* Setup DOCSIS session parameters */
8750 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8752 struct rte_security_session_conf sess_conf = {
8753 .action_type = ut_params->type,
8754 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8755 .docsis = ut_params->docsis_xform,
8756 .crypto_xform = &ut_params->cipher_xform,
8759 /* Create security session */
8760 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8761 ts_params->session_mpool,
8762 ts_params->session_priv_mpool);
8764 if (!ut_params->sec_session) {
8765 printf("TestCase %s(%d) line %d: %s\n",
8766 __func__, i, __LINE__, "failed to allocate session");
8771 /* Generate crypto op data structure */
8772 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8773 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8774 if (!ut_params->op) {
8775 printf("TestCase %s(%d) line %d: %s\n",
8776 __func__, i, __LINE__,
8777 "failed to allocate security crypto operation");
8782 /* Setup CRC operation parameters */
8783 crc_len = d_td->plaintext.no_crc == false ?
8784 (d_td->plaintext.len -
8785 d_td->plaintext.crc_offset -
8786 RTE_ETHER_CRC_LEN) :
8788 crc_len = crc_len > 0 ? crc_len : 0;
8789 ut_params->op->sym->auth.data.length = crc_len;
8790 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8792 /* Setup cipher operation parameters */
8793 cipher_len = d_td->plaintext.no_cipher == false ?
8794 (d_td->plaintext.len -
8795 d_td->plaintext.cipher_offset) :
8797 cipher_len = cipher_len > 0 ? cipher_len : 0;
8798 ut_params->op->sym->cipher.data.length = cipher_len;
8799 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8801 /* Setup cipher IV */
8802 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8803 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8805 /* Attach session to operation */
8806 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8808 /* Set crypto operation mbufs */
8809 ut_params->op->sym->m_src = ut_params->ibuf;
8810 ut_params->op->sym->m_dst = NULL;
8812 /* Process crypto operation */
8813 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8815 printf("TestCase %s(%d) line %d: %s\n",
8816 __func__, i, __LINE__,
8817 "failed to process security crypto op");
8822 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8823 printf("TestCase %s(%d) line %d: %s\n",
8824 __func__, i, __LINE__, "crypto op processing failed");
8829 /* Validate ciphertext */
8830 ciphertext = plaintext;
8832 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8833 printf("TestCase %s(%d) line %d: %s\n",
8834 __func__, i, __LINE__, "ciphertext not as expected\n");
8835 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8836 d_td->ciphertext.len);
8837 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8843 rte_crypto_op_free(ut_params->op);
8844 ut_params->op = NULL;
8846 if (ut_params->sec_session)
8847 rte_security_session_destroy(ctx, ut_params->sec_session);
8848 ut_params->sec_session = NULL;
8850 rte_pktmbuf_free(ut_params->ibuf);
8851 ut_params->ibuf = NULL;
8856 #define TEST_DOCSIS_COUNT(func) do { \
8858 if (ret == TEST_SUCCESS) { \
8859 printf("\t%2d)", n++); \
8860 printf("+++++ PASSED:" #func"\n"); \
8862 } else if (ret == -ENOTSUP) { \
8863 printf("\t%2d)", n++); \
8864 printf("~~~~~ UNSUPP:" #func"\n"); \
8867 printf("\t%2d)", n++); \
8868 printf("----- FAILED:" #func"\n"); \
8874 test_DOCSIS_PROTO_uplink_all(void)
8876 int p = 0, u = 0, f = 0, n = 0;
8878 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8879 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8880 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8881 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8882 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8883 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8884 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8885 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8886 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8887 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8888 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8889 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8890 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8891 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8892 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8893 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8894 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8895 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8896 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8897 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8898 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8899 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8900 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8901 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8902 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8903 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8906 printf("## %s: %d passed out of %d (%d unsupported)\n",
8913 test_DOCSIS_PROTO_downlink_all(void)
8915 int p = 0, u = 0, f = 0, n = 0;
8917 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8918 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8919 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8920 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8921 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8922 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8923 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8924 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8925 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8926 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8927 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8928 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8929 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8930 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8931 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8932 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8933 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8934 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8935 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8936 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8937 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8938 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8939 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8940 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8941 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8942 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8945 printf("## %s: %d passed out of %d (%d unsupported)\n",
8952 test_DOCSIS_PROTO_all(void)
8954 struct crypto_testsuite_params *ts_params = &testsuite_params;
8955 struct crypto_unittest_params *ut_params = &unittest_params;
8956 struct rte_cryptodev_info dev_info;
8959 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8960 uint64_t feat_flags = dev_info.feature_flags;
8962 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8965 /* Set action type */
8966 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8967 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8970 if (security_proto_supported(ut_params->type,
8971 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8974 status = test_DOCSIS_PROTO_uplink_all();
8975 status += test_DOCSIS_PROTO_downlink_all();
8980 return TEST_SUCCESS;
8985 test_AES_GCM_authenticated_encryption_test_case_1(void)
8987 return test_authenticated_encryption(&gcm_test_case_1);
8991 test_AES_GCM_authenticated_encryption_test_case_2(void)
8993 return test_authenticated_encryption(&gcm_test_case_2);
8997 test_AES_GCM_authenticated_encryption_test_case_3(void)
8999 return test_authenticated_encryption(&gcm_test_case_3);
9003 test_AES_GCM_authenticated_encryption_test_case_4(void)
9005 return test_authenticated_encryption(&gcm_test_case_4);
9009 test_AES_GCM_authenticated_encryption_test_case_5(void)
9011 return test_authenticated_encryption(&gcm_test_case_5);
9015 test_AES_GCM_authenticated_encryption_test_case_6(void)
9017 return test_authenticated_encryption(&gcm_test_case_6);
9021 test_AES_GCM_authenticated_encryption_test_case_7(void)
9023 return test_authenticated_encryption(&gcm_test_case_7);
9027 test_AES_GCM_authenticated_encryption_test_case_8(void)
9029 return test_authenticated_encryption(&gcm_test_case_8);
9033 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9035 return test_authenticated_encryption(&gcm_J0_test_case_1);
9039 test_AES_GCM_auth_encryption_test_case_192_1(void)
9041 return test_authenticated_encryption(&gcm_test_case_192_1);
9045 test_AES_GCM_auth_encryption_test_case_192_2(void)
9047 return test_authenticated_encryption(&gcm_test_case_192_2);
9051 test_AES_GCM_auth_encryption_test_case_192_3(void)
9053 return test_authenticated_encryption(&gcm_test_case_192_3);
9057 test_AES_GCM_auth_encryption_test_case_192_4(void)
9059 return test_authenticated_encryption(&gcm_test_case_192_4);
9063 test_AES_GCM_auth_encryption_test_case_192_5(void)
9065 return test_authenticated_encryption(&gcm_test_case_192_5);
9069 test_AES_GCM_auth_encryption_test_case_192_6(void)
9071 return test_authenticated_encryption(&gcm_test_case_192_6);
9075 test_AES_GCM_auth_encryption_test_case_192_7(void)
9077 return test_authenticated_encryption(&gcm_test_case_192_7);
9081 test_AES_GCM_auth_encryption_test_case_256_1(void)
9083 return test_authenticated_encryption(&gcm_test_case_256_1);
9087 test_AES_GCM_auth_encryption_test_case_256_2(void)
9089 return test_authenticated_encryption(&gcm_test_case_256_2);
9093 test_AES_GCM_auth_encryption_test_case_256_3(void)
9095 return test_authenticated_encryption(&gcm_test_case_256_3);
9099 test_AES_GCM_auth_encryption_test_case_256_4(void)
9101 return test_authenticated_encryption(&gcm_test_case_256_4);
9105 test_AES_GCM_auth_encryption_test_case_256_5(void)
9107 return test_authenticated_encryption(&gcm_test_case_256_5);
9111 test_AES_GCM_auth_encryption_test_case_256_6(void)
9113 return test_authenticated_encryption(&gcm_test_case_256_6);
9117 test_AES_GCM_auth_encryption_test_case_256_7(void)
9119 return test_authenticated_encryption(&gcm_test_case_256_7);
9123 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9125 return test_authenticated_encryption(&gcm_test_case_aad_1);
9129 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9131 return test_authenticated_encryption(&gcm_test_case_aad_2);
9135 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9137 struct aead_test_data tdata;
9140 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9141 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9142 tdata.iv.data[0] += 1;
9143 res = test_authenticated_encryption(&tdata);
9144 if (res == -ENOTSUP)
9146 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9147 return TEST_SUCCESS;
9151 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9153 struct aead_test_data tdata;
9156 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9157 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9158 tdata.plaintext.data[0] += 1;
9159 res = test_authenticated_encryption(&tdata);
9160 if (res == -ENOTSUP)
9162 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9163 return TEST_SUCCESS;
9167 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9169 struct aead_test_data tdata;
9172 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9173 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9174 tdata.ciphertext.data[0] += 1;
9175 res = test_authenticated_encryption(&tdata);
9176 if (res == -ENOTSUP)
9178 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9179 return TEST_SUCCESS;
9183 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9185 struct aead_test_data tdata;
9188 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9189 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9191 res = test_authenticated_encryption(&tdata);
9192 if (res == -ENOTSUP)
9194 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9195 return TEST_SUCCESS;
9199 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9201 struct aead_test_data tdata;
9202 uint8_t aad[gcm_test_case_7.aad.len];
9205 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9206 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9207 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9209 tdata.aad.data = aad;
9210 res = test_authenticated_encryption(&tdata);
9211 if (res == -ENOTSUP)
9213 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9214 return TEST_SUCCESS;
9218 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9220 struct aead_test_data tdata;
9223 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9224 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9225 tdata.auth_tag.data[0] += 1;
9226 res = test_authenticated_encryption(&tdata);
9227 if (res == -ENOTSUP)
9229 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9230 return TEST_SUCCESS;
9234 test_authenticated_decryption(const struct aead_test_data *tdata)
9236 struct crypto_testsuite_params *ts_params = &testsuite_params;
9237 struct crypto_unittest_params *ut_params = &unittest_params;
9242 struct rte_cryptodev_info dev_info;
9244 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9245 uint64_t feat_flags = dev_info.feature_flags;
9247 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9248 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9249 printf("Device doesn't support RAW data-path APIs.\n");
9253 /* Verify the capabilities */
9254 struct rte_cryptodev_sym_capability_idx cap_idx;
9255 const struct rte_cryptodev_symmetric_capability *capability;
9256 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9257 cap_idx.algo.aead = tdata->algo;
9258 capability = rte_cryptodev_sym_capability_get(
9259 ts_params->valid_devs[0], &cap_idx);
9260 if (capability == NULL)
9262 if (rte_cryptodev_sym_capability_check_aead(
9263 capability, tdata->key.len, tdata->auth_tag.len,
9264 tdata->aad.len, tdata->iv.len))
9267 /* Create AEAD session */
9268 retval = create_aead_session(ts_params->valid_devs[0],
9270 RTE_CRYPTO_AEAD_OP_DECRYPT,
9271 tdata->key.data, tdata->key.len,
9272 tdata->aad.len, tdata->auth_tag.len,
9277 /* alloc mbuf and set payload */
9278 if (tdata->aad.len > MBUF_SIZE) {
9279 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9280 /* Populate full size of add data */
9281 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9282 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9284 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9286 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9287 rte_pktmbuf_tailroom(ut_params->ibuf));
9289 /* Create AEAD operation */
9290 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9294 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9296 ut_params->op->sym->m_src = ut_params->ibuf;
9298 /* Process crypto operation */
9299 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9300 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9301 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9302 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9303 ut_params->op, 0, 0, 0, 0);
9305 TEST_ASSERT_NOT_NULL(
9306 process_crypto_request(ts_params->valid_devs[0],
9307 ut_params->op), "failed to process sym crypto op");
9309 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9310 "crypto op processing failed");
9312 if (ut_params->op->sym->m_dst)
9313 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9316 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9318 ut_params->op->sym->cipher.data.offset);
9320 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9323 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9325 tdata->plaintext.data,
9326 tdata->plaintext.len,
9327 "Plaintext data not as expected");
9329 TEST_ASSERT_EQUAL(ut_params->op->status,
9330 RTE_CRYPTO_OP_STATUS_SUCCESS,
9331 "Authentication failed");
9337 test_AES_GCM_authenticated_decryption_test_case_1(void)
9339 return test_authenticated_decryption(&gcm_test_case_1);
9343 test_AES_GCM_authenticated_decryption_test_case_2(void)
9345 return test_authenticated_decryption(&gcm_test_case_2);
9349 test_AES_GCM_authenticated_decryption_test_case_3(void)
9351 return test_authenticated_decryption(&gcm_test_case_3);
9355 test_AES_GCM_authenticated_decryption_test_case_4(void)
9357 return test_authenticated_decryption(&gcm_test_case_4);
9361 test_AES_GCM_authenticated_decryption_test_case_5(void)
9363 return test_authenticated_decryption(&gcm_test_case_5);
9367 test_AES_GCM_authenticated_decryption_test_case_6(void)
9369 return test_authenticated_decryption(&gcm_test_case_6);
9373 test_AES_GCM_authenticated_decryption_test_case_7(void)
9375 return test_authenticated_decryption(&gcm_test_case_7);
9379 test_AES_GCM_authenticated_decryption_test_case_8(void)
9381 return test_authenticated_decryption(&gcm_test_case_8);
9385 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9387 return test_authenticated_decryption(&gcm_J0_test_case_1);
9391 test_AES_GCM_auth_decryption_test_case_192_1(void)
9393 return test_authenticated_decryption(&gcm_test_case_192_1);
9397 test_AES_GCM_auth_decryption_test_case_192_2(void)
9399 return test_authenticated_decryption(&gcm_test_case_192_2);
9403 test_AES_GCM_auth_decryption_test_case_192_3(void)
9405 return test_authenticated_decryption(&gcm_test_case_192_3);
9409 test_AES_GCM_auth_decryption_test_case_192_4(void)
9411 return test_authenticated_decryption(&gcm_test_case_192_4);
9415 test_AES_GCM_auth_decryption_test_case_192_5(void)
9417 return test_authenticated_decryption(&gcm_test_case_192_5);
9421 test_AES_GCM_auth_decryption_test_case_192_6(void)
9423 return test_authenticated_decryption(&gcm_test_case_192_6);
9427 test_AES_GCM_auth_decryption_test_case_192_7(void)
9429 return test_authenticated_decryption(&gcm_test_case_192_7);
9433 test_AES_GCM_auth_decryption_test_case_256_1(void)
9435 return test_authenticated_decryption(&gcm_test_case_256_1);
9439 test_AES_GCM_auth_decryption_test_case_256_2(void)
9441 return test_authenticated_decryption(&gcm_test_case_256_2);
9445 test_AES_GCM_auth_decryption_test_case_256_3(void)
9447 return test_authenticated_decryption(&gcm_test_case_256_3);
9451 test_AES_GCM_auth_decryption_test_case_256_4(void)
9453 return test_authenticated_decryption(&gcm_test_case_256_4);
9457 test_AES_GCM_auth_decryption_test_case_256_5(void)
9459 return test_authenticated_decryption(&gcm_test_case_256_5);
9463 test_AES_GCM_auth_decryption_test_case_256_6(void)
9465 return test_authenticated_decryption(&gcm_test_case_256_6);
9469 test_AES_GCM_auth_decryption_test_case_256_7(void)
9471 return test_authenticated_decryption(&gcm_test_case_256_7);
9475 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9477 return test_authenticated_decryption(&gcm_test_case_aad_1);
9481 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9483 return test_authenticated_decryption(&gcm_test_case_aad_2);
9487 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9489 struct aead_test_data tdata;
9492 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9493 tdata.iv.data[0] += 1;
9494 res = test_authenticated_decryption(&tdata);
9495 if (res == -ENOTSUP)
9497 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9498 return TEST_SUCCESS;
9502 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9504 struct aead_test_data tdata;
9507 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9508 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9509 tdata.plaintext.data[0] += 1;
9510 res = test_authenticated_decryption(&tdata);
9511 if (res == -ENOTSUP)
9513 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9514 return TEST_SUCCESS;
9518 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9520 struct aead_test_data tdata;
9523 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9524 tdata.ciphertext.data[0] += 1;
9525 res = test_authenticated_decryption(&tdata);
9526 if (res == -ENOTSUP)
9528 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9529 return TEST_SUCCESS;
9533 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9535 struct aead_test_data tdata;
9538 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9540 res = test_authenticated_decryption(&tdata);
9541 if (res == -ENOTSUP)
9543 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9544 return TEST_SUCCESS;
9548 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9550 struct aead_test_data tdata;
9551 uint8_t aad[gcm_test_case_7.aad.len];
9554 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9555 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9557 tdata.aad.data = aad;
9558 res = test_authenticated_decryption(&tdata);
9559 if (res == -ENOTSUP)
9561 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9562 return TEST_SUCCESS;
9566 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9568 struct aead_test_data tdata;
9571 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9572 tdata.auth_tag.data[0] += 1;
9573 res = test_authenticated_decryption(&tdata);
9574 if (res == -ENOTSUP)
9576 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9577 return TEST_SUCCESS;
9581 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9583 struct crypto_testsuite_params *ts_params = &testsuite_params;
9584 struct crypto_unittest_params *ut_params = &unittest_params;
9587 uint8_t *ciphertext, *auth_tag;
9588 uint16_t plaintext_pad_len;
9590 /* Verify the capabilities */
9591 struct rte_cryptodev_sym_capability_idx cap_idx;
9592 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9593 cap_idx.algo.aead = tdata->algo;
9594 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9598 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9601 /* not supported with CPU crypto */
9602 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9605 /* Create AEAD session */
9606 retval = create_aead_session(ts_params->valid_devs[0],
9608 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9609 tdata->key.data, tdata->key.len,
9610 tdata->aad.len, tdata->auth_tag.len,
9615 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9616 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9618 /* clear mbuf payload */
9619 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9620 rte_pktmbuf_tailroom(ut_params->ibuf));
9621 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9622 rte_pktmbuf_tailroom(ut_params->obuf));
9624 /* Create AEAD operation */
9625 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9629 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9631 ut_params->op->sym->m_src = ut_params->ibuf;
9632 ut_params->op->sym->m_dst = ut_params->obuf;
9634 /* Process crypto operation */
9635 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9636 ut_params->op), "failed to process sym crypto op");
9638 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9639 "crypto op processing failed");
9641 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9643 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9644 ut_params->op->sym->cipher.data.offset);
9645 auth_tag = ciphertext + plaintext_pad_len;
9647 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9648 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9651 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9653 tdata->ciphertext.data,
9654 tdata->ciphertext.len,
9655 "Ciphertext data not as expected");
9657 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9659 tdata->auth_tag.data,
9660 tdata->auth_tag.len,
9661 "Generated auth tag not as expected");
9668 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9670 return test_authenticated_encryption_oop(&gcm_test_case_5);
9674 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9676 struct crypto_testsuite_params *ts_params = &testsuite_params;
9677 struct crypto_unittest_params *ut_params = &unittest_params;
9682 /* Verify the capabilities */
9683 struct rte_cryptodev_sym_capability_idx cap_idx;
9684 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9685 cap_idx.algo.aead = tdata->algo;
9686 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9690 /* not supported with CPU crypto and raw data-path APIs*/
9691 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
9692 global_api_test_type == CRYPTODEV_RAW_API_TEST)
9695 /* Create AEAD session */
9696 retval = create_aead_session(ts_params->valid_devs[0],
9698 RTE_CRYPTO_AEAD_OP_DECRYPT,
9699 tdata->key.data, tdata->key.len,
9700 tdata->aad.len, tdata->auth_tag.len,
9705 /* alloc mbuf and set payload */
9706 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9707 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9709 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9710 rte_pktmbuf_tailroom(ut_params->ibuf));
9711 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9712 rte_pktmbuf_tailroom(ut_params->obuf));
9714 /* Create AEAD operation */
9715 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9719 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9721 ut_params->op->sym->m_src = ut_params->ibuf;
9722 ut_params->op->sym->m_dst = ut_params->obuf;
9724 /* Process crypto operation */
9725 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9726 ut_params->op), "failed to process sym crypto op");
9728 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9729 "crypto op processing failed");
9731 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9732 ut_params->op->sym->cipher.data.offset);
9734 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9737 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9739 tdata->plaintext.data,
9740 tdata->plaintext.len,
9741 "Plaintext data not as expected");
9743 TEST_ASSERT_EQUAL(ut_params->op->status,
9744 RTE_CRYPTO_OP_STATUS_SUCCESS,
9745 "Authentication failed");
9750 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9752 return test_authenticated_decryption_oop(&gcm_test_case_5);
9756 test_authenticated_encryption_sessionless(
9757 const struct aead_test_data *tdata)
9759 struct crypto_testsuite_params *ts_params = &testsuite_params;
9760 struct crypto_unittest_params *ut_params = &unittest_params;
9763 uint8_t *ciphertext, *auth_tag;
9764 uint16_t plaintext_pad_len;
9765 uint8_t key[tdata->key.len + 1];
9766 struct rte_cryptodev_info dev_info;
9768 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9769 uint64_t feat_flags = dev_info.feature_flags;
9771 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9772 printf("Device doesn't support Sessionless ops.\n");
9776 /* not supported with CPU crypto */
9777 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9780 /* Verify the capabilities */
9781 struct rte_cryptodev_sym_capability_idx cap_idx;
9782 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9783 cap_idx.algo.aead = tdata->algo;
9784 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9790 /* clear mbuf payload */
9791 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9792 rte_pktmbuf_tailroom(ut_params->ibuf));
9794 /* Create AEAD operation */
9795 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9799 /* Create GCM xform */
9800 memcpy(key, tdata->key.data, tdata->key.len);
9801 retval = create_aead_xform(ut_params->op,
9803 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9804 key, tdata->key.len,
9805 tdata->aad.len, tdata->auth_tag.len,
9810 ut_params->op->sym->m_src = ut_params->ibuf;
9812 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9813 RTE_CRYPTO_OP_SESSIONLESS,
9814 "crypto op session type not sessionless");
9816 /* Process crypto operation */
9817 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9818 ut_params->op), "failed to process sym crypto op");
9820 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9822 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9823 "crypto op status not success");
9825 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9827 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9828 ut_params->op->sym->cipher.data.offset);
9829 auth_tag = ciphertext + plaintext_pad_len;
9831 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9832 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9835 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9837 tdata->ciphertext.data,
9838 tdata->ciphertext.len,
9839 "Ciphertext data not as expected");
9841 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9843 tdata->auth_tag.data,
9844 tdata->auth_tag.len,
9845 "Generated auth tag not as expected");
9852 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9854 return test_authenticated_encryption_sessionless(
9859 test_authenticated_decryption_sessionless(
9860 const struct aead_test_data *tdata)
9862 struct crypto_testsuite_params *ts_params = &testsuite_params;
9863 struct crypto_unittest_params *ut_params = &unittest_params;
9867 uint8_t key[tdata->key.len + 1];
9868 struct rte_cryptodev_info dev_info;
9870 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9871 uint64_t feat_flags = dev_info.feature_flags;
9873 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9874 printf("Device doesn't support Sessionless ops.\n");
9878 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9879 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9880 printf("Device doesn't support RAW data-path APIs.\n");
9884 /* not supported with CPU crypto */
9885 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9888 /* Verify the capabilities */
9889 struct rte_cryptodev_sym_capability_idx cap_idx;
9890 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9891 cap_idx.algo.aead = tdata->algo;
9892 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9896 /* alloc mbuf and set payload */
9897 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9899 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9900 rte_pktmbuf_tailroom(ut_params->ibuf));
9902 /* Create AEAD operation */
9903 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9907 /* Create AEAD xform */
9908 memcpy(key, tdata->key.data, tdata->key.len);
9909 retval = create_aead_xform(ut_params->op,
9911 RTE_CRYPTO_AEAD_OP_DECRYPT,
9912 key, tdata->key.len,
9913 tdata->aad.len, tdata->auth_tag.len,
9918 ut_params->op->sym->m_src = ut_params->ibuf;
9920 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9921 RTE_CRYPTO_OP_SESSIONLESS,
9922 "crypto op session type not sessionless");
9924 /* Process crypto operation */
9925 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9926 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9927 ut_params->op, 0, 0, 0, 0);
9929 TEST_ASSERT_NOT_NULL(process_crypto_request(
9930 ts_params->valid_devs[0], ut_params->op),
9931 "failed to process sym crypto op");
9933 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9935 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9936 "crypto op status not success");
9938 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9939 ut_params->op->sym->cipher.data.offset);
9941 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9944 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9946 tdata->plaintext.data,
9947 tdata->plaintext.len,
9948 "Plaintext data not as expected");
9950 TEST_ASSERT_EQUAL(ut_params->op->status,
9951 RTE_CRYPTO_OP_STATUS_SUCCESS,
9952 "Authentication failed");
9957 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9959 return test_authenticated_decryption_sessionless(
9964 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9966 return test_authenticated_encryption(&ccm_test_case_128_1);
9970 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9972 return test_authenticated_encryption(&ccm_test_case_128_2);
9976 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9978 return test_authenticated_encryption(&ccm_test_case_128_3);
9982 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9984 return test_authenticated_decryption(&ccm_test_case_128_1);
9988 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9990 return test_authenticated_decryption(&ccm_test_case_128_2);
9994 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9996 return test_authenticated_decryption(&ccm_test_case_128_3);
10000 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10002 return test_authenticated_encryption(&ccm_test_case_192_1);
10006 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10008 return test_authenticated_encryption(&ccm_test_case_192_2);
10012 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10014 return test_authenticated_encryption(&ccm_test_case_192_3);
10018 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10020 return test_authenticated_decryption(&ccm_test_case_192_1);
10024 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10026 return test_authenticated_decryption(&ccm_test_case_192_2);
10030 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10032 return test_authenticated_decryption(&ccm_test_case_192_3);
10036 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10038 return test_authenticated_encryption(&ccm_test_case_256_1);
10042 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10044 return test_authenticated_encryption(&ccm_test_case_256_2);
10048 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10050 return test_authenticated_encryption(&ccm_test_case_256_3);
10054 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10056 return test_authenticated_decryption(&ccm_test_case_256_1);
10060 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10062 return test_authenticated_decryption(&ccm_test_case_256_2);
10066 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10068 return test_authenticated_decryption(&ccm_test_case_256_3);
10074 struct crypto_testsuite_params *ts_params = &testsuite_params;
10075 struct rte_cryptodev_stats stats;
10077 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10080 /* Verify the capabilities */
10081 struct rte_cryptodev_sym_capability_idx cap_idx;
10082 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10083 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10084 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10087 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10088 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10089 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10093 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10097 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10098 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10099 &stats) == -ENODEV),
10100 "rte_cryptodev_stats_get invalid dev failed");
10101 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10102 "rte_cryptodev_stats_get invalid Param failed");
10104 /* Test expected values */
10105 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10106 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10108 "rte_cryptodev_stats_get failed");
10109 TEST_ASSERT((stats.enqueued_count == 1),
10110 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10111 TEST_ASSERT((stats.dequeued_count == 1),
10112 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10113 TEST_ASSERT((stats.enqueue_err_count == 0),
10114 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10115 TEST_ASSERT((stats.dequeue_err_count == 0),
10116 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10118 /* invalid device but should ignore and not reset device stats*/
10119 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10120 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10122 "rte_cryptodev_stats_get failed");
10123 TEST_ASSERT((stats.enqueued_count == 1),
10124 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10126 /* check that a valid reset clears stats */
10127 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10128 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10130 "rte_cryptodev_stats_get failed");
10131 TEST_ASSERT((stats.enqueued_count == 0),
10132 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10133 TEST_ASSERT((stats.dequeued_count == 0),
10134 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10136 return TEST_SUCCESS;
10139 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10140 struct crypto_unittest_params *ut_params,
10141 enum rte_crypto_auth_operation op,
10142 const struct HMAC_MD5_vector *test_case)
10146 memcpy(key, test_case->key.data, test_case->key.len);
10148 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10149 ut_params->auth_xform.next = NULL;
10150 ut_params->auth_xform.auth.op = op;
10152 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10154 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10155 ut_params->auth_xform.auth.key.length = test_case->key.len;
10156 ut_params->auth_xform.auth.key.data = key;
10158 ut_params->sess = rte_cryptodev_sym_session_create(
10159 ts_params->session_mpool);
10161 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10162 ut_params->sess, &ut_params->auth_xform,
10163 ts_params->session_priv_mpool);
10165 if (ut_params->sess == NULL)
10166 return TEST_FAILED;
10168 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10170 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10171 rte_pktmbuf_tailroom(ut_params->ibuf));
10176 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10177 const struct HMAC_MD5_vector *test_case,
10178 uint8_t **plaintext)
10180 uint16_t plaintext_pad_len;
10182 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10184 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10187 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10188 plaintext_pad_len);
10189 memcpy(*plaintext, test_case->plaintext.data,
10190 test_case->plaintext.len);
10192 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10193 ut_params->ibuf, MD5_DIGEST_LEN);
10194 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10195 "no room to append digest");
10196 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10197 ut_params->ibuf, plaintext_pad_len);
10199 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10200 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10201 test_case->auth_tag.len);
10204 sym_op->auth.data.offset = 0;
10205 sym_op->auth.data.length = test_case->plaintext.len;
10207 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10208 ut_params->op->sym->m_src = ut_params->ibuf;
10214 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10216 uint16_t plaintext_pad_len;
10217 uint8_t *plaintext, *auth_tag;
10219 struct crypto_testsuite_params *ts_params = &testsuite_params;
10220 struct crypto_unittest_params *ut_params = &unittest_params;
10221 struct rte_cryptodev_info dev_info;
10223 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10224 uint64_t feat_flags = dev_info.feature_flags;
10226 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10227 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10228 printf("Device doesn't support RAW data-path APIs.\n");
10232 /* Verify the capabilities */
10233 struct rte_cryptodev_sym_capability_idx cap_idx;
10234 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10235 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10236 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10240 if (MD5_HMAC_create_session(ts_params, ut_params,
10241 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10242 return TEST_FAILED;
10244 /* Generate Crypto op data structure */
10245 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10246 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10247 TEST_ASSERT_NOT_NULL(ut_params->op,
10248 "Failed to allocate symmetric crypto operation struct");
10250 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10253 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10254 return TEST_FAILED;
10256 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10257 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10259 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10260 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10261 ut_params->op, 0, 1, 0, 0);
10263 TEST_ASSERT_NOT_NULL(
10264 process_crypto_request(ts_params->valid_devs[0],
10266 "failed to process sym crypto op");
10268 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10269 "crypto op processing failed");
10271 if (ut_params->op->sym->m_dst) {
10272 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10273 uint8_t *, plaintext_pad_len);
10275 auth_tag = plaintext + plaintext_pad_len;
10278 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10280 test_case->auth_tag.data,
10281 test_case->auth_tag.len,
10282 "HMAC_MD5 generated tag not as expected");
10284 return TEST_SUCCESS;
10288 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10290 uint8_t *plaintext;
10292 struct crypto_testsuite_params *ts_params = &testsuite_params;
10293 struct crypto_unittest_params *ut_params = &unittest_params;
10294 struct rte_cryptodev_info dev_info;
10296 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10297 uint64_t feat_flags = dev_info.feature_flags;
10299 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10300 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10301 printf("Device doesn't support RAW data-path APIs.\n");
10305 /* Verify the capabilities */
10306 struct rte_cryptodev_sym_capability_idx cap_idx;
10307 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10308 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10309 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10313 if (MD5_HMAC_create_session(ts_params, ut_params,
10314 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10315 return TEST_FAILED;
10318 /* Generate Crypto op data structure */
10319 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10320 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10321 TEST_ASSERT_NOT_NULL(ut_params->op,
10322 "Failed to allocate symmetric crypto operation struct");
10324 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10325 return TEST_FAILED;
10327 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10328 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10330 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10331 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10332 ut_params->op, 0, 1, 0, 0);
10334 TEST_ASSERT_NOT_NULL(
10335 process_crypto_request(ts_params->valid_devs[0],
10337 "failed to process sym crypto op");
10339 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10340 "HMAC_MD5 crypto op processing failed");
10342 return TEST_SUCCESS;
10346 test_MD5_HMAC_generate_case_1(void)
10348 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10352 test_MD5_HMAC_verify_case_1(void)
10354 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10358 test_MD5_HMAC_generate_case_2(void)
10360 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10364 test_MD5_HMAC_verify_case_2(void)
10366 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10370 test_multi_session(void)
10372 struct crypto_testsuite_params *ts_params = &testsuite_params;
10373 struct crypto_unittest_params *ut_params = &unittest_params;
10375 struct rte_cryptodev_info dev_info;
10376 struct rte_cryptodev_sym_session **sessions;
10380 /* Verify the capabilities */
10381 struct rte_cryptodev_sym_capability_idx cap_idx;
10382 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10383 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10384 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10387 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10388 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10389 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10393 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10394 aes_cbc_key, hmac_sha512_key);
10397 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10399 sessions = rte_malloc(NULL,
10400 (sizeof(struct rte_cryptodev_sym_session *) *
10401 MAX_NB_SESSIONS) + 1, 0);
10403 /* Create multiple crypto sessions*/
10404 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10406 sessions[i] = rte_cryptodev_sym_session_create(
10407 ts_params->session_mpool);
10409 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10410 sessions[i], &ut_params->auth_xform,
10411 ts_params->session_priv_mpool);
10412 TEST_ASSERT_NOT_NULL(sessions[i],
10413 "Session creation failed at session number %u",
10416 /* Attempt to send a request on each session */
10417 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10421 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10422 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10424 "Failed to perform decrypt on request number %u.", i);
10425 /* free crypto operation structure */
10427 rte_crypto_op_free(ut_params->op);
10430 * free mbuf - both obuf and ibuf are usually the same,
10431 * so check if they point at the same address is necessary,
10432 * to avoid freeing the mbuf twice.
10434 if (ut_params->obuf) {
10435 rte_pktmbuf_free(ut_params->obuf);
10436 if (ut_params->ibuf == ut_params->obuf)
10437 ut_params->ibuf = 0;
10438 ut_params->obuf = 0;
10440 if (ut_params->ibuf) {
10441 rte_pktmbuf_free(ut_params->ibuf);
10442 ut_params->ibuf = 0;
10446 /* Next session create should fail */
10447 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10448 sessions[i], &ut_params->auth_xform,
10449 ts_params->session_priv_mpool);
10450 TEST_ASSERT_NULL(sessions[i],
10451 "Session creation succeeded unexpectedly!");
10453 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10454 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10456 rte_cryptodev_sym_session_free(sessions[i]);
10459 rte_free(sessions);
10461 return TEST_SUCCESS;
10464 struct multi_session_params {
10465 struct crypto_unittest_params ut_params;
10466 uint8_t *cipher_key;
10468 const uint8_t *cipher;
10469 const uint8_t *digest;
10473 #define MB_SESSION_NUMBER 3
10476 test_multi_session_random_usage(void)
10478 struct crypto_testsuite_params *ts_params = &testsuite_params;
10479 struct rte_cryptodev_info dev_info;
10480 struct rte_cryptodev_sym_session **sessions;
10482 struct multi_session_params ut_paramz[] = {
10485 .cipher_key = ms_aes_cbc_key0,
10486 .hmac_key = ms_hmac_key0,
10487 .cipher = ms_aes_cbc_cipher0,
10488 .digest = ms_hmac_digest0,
10489 .iv = ms_aes_cbc_iv0
10492 .cipher_key = ms_aes_cbc_key1,
10493 .hmac_key = ms_hmac_key1,
10494 .cipher = ms_aes_cbc_cipher1,
10495 .digest = ms_hmac_digest1,
10496 .iv = ms_aes_cbc_iv1
10499 .cipher_key = ms_aes_cbc_key2,
10500 .hmac_key = ms_hmac_key2,
10501 .cipher = ms_aes_cbc_cipher2,
10502 .digest = ms_hmac_digest2,
10503 .iv = ms_aes_cbc_iv2
10508 /* Verify the capabilities */
10509 struct rte_cryptodev_sym_capability_idx cap_idx;
10510 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10511 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10512 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10515 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10516 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10517 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10521 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10523 sessions = rte_malloc(NULL,
10524 (sizeof(struct rte_cryptodev_sym_session *)
10525 * MAX_NB_SESSIONS) + 1, 0);
10527 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10528 sessions[i] = rte_cryptodev_sym_session_create(
10529 ts_params->session_mpool);
10531 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10532 sizeof(struct crypto_unittest_params));
10534 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10535 &ut_paramz[i].ut_params,
10536 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10538 /* Create multiple crypto sessions*/
10539 rte_cryptodev_sym_session_init(
10540 ts_params->valid_devs[0],
10542 &ut_paramz[i].ut_params.auth_xform,
10543 ts_params->session_priv_mpool);
10545 TEST_ASSERT_NOT_NULL(sessions[i],
10546 "Session creation failed at session number %u",
10552 for (i = 0; i < 40000; i++) {
10554 j = rand() % MB_SESSION_NUMBER;
10556 TEST_ASSERT_SUCCESS(
10557 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10559 &ut_paramz[j].ut_params,
10560 ts_params, ut_paramz[j].cipher,
10561 ut_paramz[j].digest,
10563 "Failed to perform decrypt on request number %u.", i);
10565 if (ut_paramz[j].ut_params.op)
10566 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10569 * free mbuf - both obuf and ibuf are usually the same,
10570 * so check if they point at the same address is necessary,
10571 * to avoid freeing the mbuf twice.
10573 if (ut_paramz[j].ut_params.obuf) {
10574 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10575 if (ut_paramz[j].ut_params.ibuf
10576 == ut_paramz[j].ut_params.obuf)
10577 ut_paramz[j].ut_params.ibuf = 0;
10578 ut_paramz[j].ut_params.obuf = 0;
10580 if (ut_paramz[j].ut_params.ibuf) {
10581 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10582 ut_paramz[j].ut_params.ibuf = 0;
10586 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10587 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10589 rte_cryptodev_sym_session_free(sessions[i]);
10592 rte_free(sessions);
10594 return TEST_SUCCESS;
10597 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10598 0xab, 0xab, 0xab, 0xab,
10599 0xab, 0xab, 0xab, 0xab,
10600 0xab, 0xab, 0xab, 0xab};
10603 test_null_invalid_operation(void)
10605 struct crypto_testsuite_params *ts_params = &testsuite_params;
10606 struct crypto_unittest_params *ut_params = &unittest_params;
10609 /* This test is for NULL PMD only */
10610 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10611 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10614 /* Setup Cipher Parameters */
10615 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10616 ut_params->cipher_xform.next = NULL;
10618 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10619 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10621 ut_params->sess = rte_cryptodev_sym_session_create(
10622 ts_params->session_mpool);
10624 /* Create Crypto session*/
10625 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10626 ut_params->sess, &ut_params->cipher_xform,
10627 ts_params->session_priv_mpool);
10628 TEST_ASSERT(ret < 0,
10629 "Session creation succeeded unexpectedly");
10632 /* Setup HMAC Parameters */
10633 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10634 ut_params->auth_xform.next = NULL;
10636 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10637 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10639 ut_params->sess = rte_cryptodev_sym_session_create(
10640 ts_params->session_mpool);
10642 /* Create Crypto session*/
10643 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10644 ut_params->sess, &ut_params->auth_xform,
10645 ts_params->session_priv_mpool);
10646 TEST_ASSERT(ret < 0,
10647 "Session creation succeeded unexpectedly");
10649 return TEST_SUCCESS;
10653 #define NULL_BURST_LENGTH (32)
10656 test_null_burst_operation(void)
10658 struct crypto_testsuite_params *ts_params = &testsuite_params;
10659 struct crypto_unittest_params *ut_params = &unittest_params;
10661 unsigned i, burst_len = NULL_BURST_LENGTH;
10663 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10664 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10666 /* This test is for NULL PMD only */
10667 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10668 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10671 /* Setup Cipher Parameters */
10672 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10673 ut_params->cipher_xform.next = &ut_params->auth_xform;
10675 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10676 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10678 /* Setup HMAC Parameters */
10679 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10680 ut_params->auth_xform.next = NULL;
10682 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10683 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10685 ut_params->sess = rte_cryptodev_sym_session_create(
10686 ts_params->session_mpool);
10688 /* Create Crypto session*/
10689 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10690 ut_params->sess, &ut_params->cipher_xform,
10691 ts_params->session_priv_mpool);
10692 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10694 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10695 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10696 burst_len, "failed to generate burst of crypto ops");
10698 /* Generate an operation for each mbuf in burst */
10699 for (i = 0; i < burst_len; i++) {
10700 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10702 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10704 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10708 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10710 burst[i]->sym->m_src = m;
10713 /* Process crypto operation */
10714 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10715 0, burst, burst_len),
10717 "Error enqueuing burst");
10719 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10720 0, burst_dequeued, burst_len),
10722 "Error dequeuing burst");
10725 for (i = 0; i < burst_len; i++) {
10727 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10728 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10730 "data not as expected");
10732 rte_pktmbuf_free(burst[i]->sym->m_src);
10733 rte_crypto_op_free(burst[i]);
10736 return TEST_SUCCESS;
10740 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10741 uint16_t nb_ops, void *user_param)
10743 RTE_SET_USED(dev_id);
10744 RTE_SET_USED(qp_id);
10746 RTE_SET_USED(user_param);
10748 printf("crypto enqueue callback called\n");
10753 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10754 uint16_t nb_ops, void *user_param)
10756 RTE_SET_USED(dev_id);
10757 RTE_SET_USED(qp_id);
10759 RTE_SET_USED(user_param);
10761 printf("crypto dequeue callback called\n");
10766 * Thread using enqueue/dequeue callback with RCU.
10769 test_enqdeq_callback_thread(void *arg)
10772 /* DP thread calls rte_cryptodev_enqueue_burst()/
10773 * rte_cryptodev_dequeue_burst() and invokes callback.
10775 test_null_burst_operation();
10780 test_enq_callback_setup(void)
10782 struct crypto_testsuite_params *ts_params = &testsuite_params;
10783 struct rte_cryptodev_info dev_info;
10784 struct rte_cryptodev_qp_conf qp_conf = {
10785 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10788 struct rte_cryptodev_cb *cb;
10789 uint16_t qp_id = 0;
10791 /* Stop the device in case it's started so it can be configured */
10792 rte_cryptodev_stop(ts_params->valid_devs[0]);
10794 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10796 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10798 "Failed to configure cryptodev %u",
10799 ts_params->valid_devs[0]);
10801 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10802 qp_conf.mp_session = ts_params->session_mpool;
10803 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10805 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10806 ts_params->valid_devs[0], qp_id, &qp_conf,
10807 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10809 "rte_cryptodev_queue_pair_setup: num_inflights "
10810 "%u on qp %u on cryptodev %u",
10811 qp_conf.nb_descriptors, qp_id,
10812 ts_params->valid_devs[0]);
10814 /* Test with invalid crypto device */
10815 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
10816 qp_id, test_enq_callback, NULL);
10817 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10818 "cryptodev %u did not fail",
10819 qp_id, RTE_CRYPTO_MAX_DEVS);
10821 /* Test with invalid queue pair */
10822 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10823 dev_info.max_nb_queue_pairs + 1,
10824 test_enq_callback, NULL);
10825 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10826 "cryptodev %u did not fail",
10827 dev_info.max_nb_queue_pairs + 1,
10828 ts_params->valid_devs[0]);
10830 /* Test with NULL callback */
10831 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10832 qp_id, NULL, NULL);
10833 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10834 "cryptodev %u did not fail",
10835 qp_id, ts_params->valid_devs[0]);
10837 /* Test with valid configuration */
10838 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10839 qp_id, test_enq_callback, NULL);
10840 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10841 "qp %u on cryptodev %u",
10842 qp_id, ts_params->valid_devs[0]);
10844 rte_cryptodev_start(ts_params->valid_devs[0]);
10846 /* Launch a thread */
10847 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10848 rte_get_next_lcore(-1, 1, 0));
10850 /* Wait until reader exited. */
10851 rte_eal_mp_wait_lcore();
10853 /* Test with invalid crypto device */
10854 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10855 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10856 "Expected call to fail as crypto device is invalid");
10858 /* Test with invalid queue pair */
10859 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10860 ts_params->valid_devs[0],
10861 dev_info.max_nb_queue_pairs + 1, cb),
10862 "Expected call to fail as queue pair is invalid");
10864 /* Test with NULL callback */
10865 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10866 ts_params->valid_devs[0], qp_id, NULL),
10867 "Expected call to fail as callback is NULL");
10869 /* Test with valid configuration */
10870 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
10871 ts_params->valid_devs[0], qp_id, cb),
10872 "Failed test to remove callback on "
10873 "qp %u on cryptodev %u",
10874 qp_id, ts_params->valid_devs[0]);
10876 return TEST_SUCCESS;
10880 test_deq_callback_setup(void)
10882 struct crypto_testsuite_params *ts_params = &testsuite_params;
10883 struct rte_cryptodev_info dev_info;
10884 struct rte_cryptodev_qp_conf qp_conf = {
10885 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10888 struct rte_cryptodev_cb *cb;
10889 uint16_t qp_id = 0;
10891 /* Stop the device in case it's started so it can be configured */
10892 rte_cryptodev_stop(ts_params->valid_devs[0]);
10894 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10896 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10898 "Failed to configure cryptodev %u",
10899 ts_params->valid_devs[0]);
10901 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10902 qp_conf.mp_session = ts_params->session_mpool;
10903 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10905 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10906 ts_params->valid_devs[0], qp_id, &qp_conf,
10907 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10909 "rte_cryptodev_queue_pair_setup: num_inflights "
10910 "%u on qp %u on cryptodev %u",
10911 qp_conf.nb_descriptors, qp_id,
10912 ts_params->valid_devs[0]);
10914 /* Test with invalid crypto device */
10915 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
10916 qp_id, test_deq_callback, NULL);
10917 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10918 "cryptodev %u did not fail",
10919 qp_id, RTE_CRYPTO_MAX_DEVS);
10921 /* Test with invalid queue pair */
10922 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10923 dev_info.max_nb_queue_pairs + 1,
10924 test_deq_callback, NULL);
10925 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10926 "cryptodev %u did not fail",
10927 dev_info.max_nb_queue_pairs + 1,
10928 ts_params->valid_devs[0]);
10930 /* Test with NULL callback */
10931 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10932 qp_id, NULL, NULL);
10933 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10934 "cryptodev %u did not fail",
10935 qp_id, ts_params->valid_devs[0]);
10937 /* Test with valid configuration */
10938 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10939 qp_id, test_deq_callback, NULL);
10940 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10941 "qp %u on cryptodev %u",
10942 qp_id, ts_params->valid_devs[0]);
10944 rte_cryptodev_start(ts_params->valid_devs[0]);
10946 /* Launch a thread */
10947 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10948 rte_get_next_lcore(-1, 1, 0));
10950 /* Wait until reader exited. */
10951 rte_eal_mp_wait_lcore();
10953 /* Test with invalid crypto device */
10954 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10955 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10956 "Expected call to fail as crypto device is invalid");
10958 /* Test with invalid queue pair */
10959 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10960 ts_params->valid_devs[0],
10961 dev_info.max_nb_queue_pairs + 1, cb),
10962 "Expected call to fail as queue pair is invalid");
10964 /* Test with NULL callback */
10965 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10966 ts_params->valid_devs[0], qp_id, NULL),
10967 "Expected call to fail as callback is NULL");
10969 /* Test with valid configuration */
10970 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
10971 ts_params->valid_devs[0], qp_id, cb),
10972 "Failed test to remove callback on "
10973 "qp %u on cryptodev %u",
10974 qp_id, ts_params->valid_devs[0]);
10976 return TEST_SUCCESS;
10980 generate_gmac_large_plaintext(uint8_t *data)
10984 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10985 memcpy(&data[i], &data[0], 32);
10989 create_gmac_operation(enum rte_crypto_auth_operation op,
10990 const struct gmac_test_data *tdata)
10992 struct crypto_testsuite_params *ts_params = &testsuite_params;
10993 struct crypto_unittest_params *ut_params = &unittest_params;
10994 struct rte_crypto_sym_op *sym_op;
10996 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10998 /* Generate Crypto op data structure */
10999 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11000 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11001 TEST_ASSERT_NOT_NULL(ut_params->op,
11002 "Failed to allocate symmetric crypto operation struct");
11004 sym_op = ut_params->op->sym;
11006 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11007 ut_params->ibuf, tdata->gmac_tag.len);
11008 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11009 "no room to append digest");
11011 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11012 ut_params->ibuf, plaintext_pad_len);
11014 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11015 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11016 tdata->gmac_tag.len);
11017 debug_hexdump(stdout, "digest:",
11018 sym_op->auth.digest.data,
11019 tdata->gmac_tag.len);
11022 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11023 uint8_t *, IV_OFFSET);
11025 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11027 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11029 sym_op->cipher.data.length = 0;
11030 sym_op->cipher.data.offset = 0;
11032 sym_op->auth.data.offset = 0;
11033 sym_op->auth.data.length = tdata->plaintext.len;
11039 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11040 const struct gmac_test_data *tdata,
11041 void *digest_mem, uint64_t digest_phys)
11043 struct crypto_testsuite_params *ts_params = &testsuite_params;
11044 struct crypto_unittest_params *ut_params = &unittest_params;
11045 struct rte_crypto_sym_op *sym_op;
11047 /* Generate Crypto op data structure */
11048 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11049 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11050 TEST_ASSERT_NOT_NULL(ut_params->op,
11051 "Failed to allocate symmetric crypto operation struct");
11053 sym_op = ut_params->op->sym;
11055 sym_op->auth.digest.data = digest_mem;
11056 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11057 "no room to append digest");
11059 sym_op->auth.digest.phys_addr = digest_phys;
11061 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11062 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11063 tdata->gmac_tag.len);
11064 debug_hexdump(stdout, "digest:",
11065 sym_op->auth.digest.data,
11066 tdata->gmac_tag.len);
11069 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11070 uint8_t *, IV_OFFSET);
11072 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11074 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11076 sym_op->cipher.data.length = 0;
11077 sym_op->cipher.data.offset = 0;
11079 sym_op->auth.data.offset = 0;
11080 sym_op->auth.data.length = tdata->plaintext.len;
11085 static int create_gmac_session(uint8_t dev_id,
11086 const struct gmac_test_data *tdata,
11087 enum rte_crypto_auth_operation auth_op)
11089 uint8_t auth_key[tdata->key.len];
11091 struct crypto_testsuite_params *ts_params = &testsuite_params;
11092 struct crypto_unittest_params *ut_params = &unittest_params;
11094 memcpy(auth_key, tdata->key.data, tdata->key.len);
11096 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11097 ut_params->auth_xform.next = NULL;
11099 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11100 ut_params->auth_xform.auth.op = auth_op;
11101 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11102 ut_params->auth_xform.auth.key.length = tdata->key.len;
11103 ut_params->auth_xform.auth.key.data = auth_key;
11104 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11105 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11108 ut_params->sess = rte_cryptodev_sym_session_create(
11109 ts_params->session_mpool);
11111 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11112 &ut_params->auth_xform,
11113 ts_params->session_priv_mpool);
11115 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11121 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11123 struct crypto_testsuite_params *ts_params = &testsuite_params;
11124 struct crypto_unittest_params *ut_params = &unittest_params;
11125 struct rte_cryptodev_info dev_info;
11127 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11128 uint64_t feat_flags = dev_info.feature_flags;
11130 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11131 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11132 printf("Device doesn't support RAW data-path APIs.\n");
11138 uint8_t *auth_tag, *plaintext;
11139 uint16_t plaintext_pad_len;
11141 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11142 "No GMAC length in the source data");
11144 /* Verify the capabilities */
11145 struct rte_cryptodev_sym_capability_idx cap_idx;
11146 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11147 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11148 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11152 retval = create_gmac_session(ts_params->valid_devs[0],
11153 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11158 if (tdata->plaintext.len > MBUF_SIZE)
11159 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11161 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11162 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11163 "Failed to allocate input buffer in mempool");
11165 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11166 rte_pktmbuf_tailroom(ut_params->ibuf));
11168 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11170 * Runtime generate the large plain text instead of use hard code
11171 * plain text vector. It is done to avoid create huge source file
11172 * with the test vector.
11174 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11175 generate_gmac_large_plaintext(tdata->plaintext.data);
11177 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11178 plaintext_pad_len);
11179 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11181 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11182 debug_hexdump(stdout, "plaintext:", plaintext,
11183 tdata->plaintext.len);
11185 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11191 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11193 ut_params->op->sym->m_src = ut_params->ibuf;
11195 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11196 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11198 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11199 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11200 ut_params->op, 0, 1, 0, 0);
11202 TEST_ASSERT_NOT_NULL(
11203 process_crypto_request(ts_params->valid_devs[0],
11204 ut_params->op), "failed to process sym crypto op");
11206 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11207 "crypto op processing failed");
11209 if (ut_params->op->sym->m_dst) {
11210 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11211 uint8_t *, plaintext_pad_len);
11213 auth_tag = plaintext + plaintext_pad_len;
11216 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11218 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11220 tdata->gmac_tag.data,
11221 tdata->gmac_tag.len,
11222 "GMAC Generated auth tag not as expected");
11228 test_AES_GMAC_authentication_test_case_1(void)
11230 return test_AES_GMAC_authentication(&gmac_test_case_1);
11234 test_AES_GMAC_authentication_test_case_2(void)
11236 return test_AES_GMAC_authentication(&gmac_test_case_2);
11240 test_AES_GMAC_authentication_test_case_3(void)
11242 return test_AES_GMAC_authentication(&gmac_test_case_3);
11246 test_AES_GMAC_authentication_test_case_4(void)
11248 return test_AES_GMAC_authentication(&gmac_test_case_4);
11252 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11254 struct crypto_testsuite_params *ts_params = &testsuite_params;
11255 struct crypto_unittest_params *ut_params = &unittest_params;
11257 uint32_t plaintext_pad_len;
11258 uint8_t *plaintext;
11259 struct rte_cryptodev_info dev_info;
11261 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11262 uint64_t feat_flags = dev_info.feature_flags;
11264 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11265 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11266 printf("Device doesn't support RAW data-path APIs.\n");
11270 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11271 "No GMAC length in the source data");
11273 /* Verify the capabilities */
11274 struct rte_cryptodev_sym_capability_idx cap_idx;
11275 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11276 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11277 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11281 retval = create_gmac_session(ts_params->valid_devs[0],
11282 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11287 if (tdata->plaintext.len > MBUF_SIZE)
11288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11290 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11291 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11292 "Failed to allocate input buffer in mempool");
11294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11295 rte_pktmbuf_tailroom(ut_params->ibuf));
11297 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11300 * Runtime generate the large plain text instead of use hard code
11301 * plain text vector. It is done to avoid create huge source file
11302 * with the test vector.
11304 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11305 generate_gmac_large_plaintext(tdata->plaintext.data);
11307 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11308 plaintext_pad_len);
11309 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11311 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11312 debug_hexdump(stdout, "plaintext:", plaintext,
11313 tdata->plaintext.len);
11315 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11321 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11323 ut_params->op->sym->m_src = ut_params->ibuf;
11325 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11326 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11328 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11329 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11330 ut_params->op, 0, 1, 0, 0);
11332 TEST_ASSERT_NOT_NULL(
11333 process_crypto_request(ts_params->valid_devs[0],
11334 ut_params->op), "failed to process sym crypto op");
11336 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11337 "crypto op processing failed");
11344 test_AES_GMAC_authentication_verify_test_case_1(void)
11346 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11350 test_AES_GMAC_authentication_verify_test_case_2(void)
11352 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11356 test_AES_GMAC_authentication_verify_test_case_3(void)
11358 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11362 test_AES_GMAC_authentication_verify_test_case_4(void)
11364 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11368 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11371 struct crypto_testsuite_params *ts_params = &testsuite_params;
11372 struct crypto_unittest_params *ut_params = &unittest_params;
11373 struct rte_cryptodev_info dev_info;
11374 uint64_t feature_flags;
11375 unsigned int trn_data = 0;
11376 void *digest_mem = NULL;
11378 unsigned int to_trn = 0;
11379 struct rte_mbuf *buf = NULL;
11380 uint8_t *auth_tag, *plaintext;
11383 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11384 "No GMAC length in the source data");
11386 /* Verify the capabilities */
11387 struct rte_cryptodev_sym_capability_idx cap_idx;
11388 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11389 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11390 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11394 /* Check for any input SGL support */
11395 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11396 feature_flags = dev_info.feature_flags;
11398 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11399 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11400 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11403 if (fragsz > tdata->plaintext.len)
11404 fragsz = tdata->plaintext.len;
11406 uint16_t plaintext_len = fragsz;
11408 retval = create_gmac_session(ts_params->valid_devs[0],
11409 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11414 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11415 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11416 "Failed to allocate input buffer in mempool");
11418 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11419 rte_pktmbuf_tailroom(ut_params->ibuf));
11421 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11423 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11425 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11427 trn_data += plaintext_len;
11429 buf = ut_params->ibuf;
11432 * Loop until no more fragments
11435 while (trn_data < tdata->plaintext.len) {
11437 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11438 (tdata->plaintext.len - trn_data) : fragsz;
11440 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11443 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11444 rte_pktmbuf_tailroom(buf));
11446 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11449 memcpy(plaintext, tdata->plaintext.data + trn_data,
11451 trn_data += to_trn;
11452 if (trn_data == tdata->plaintext.len)
11453 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11454 tdata->gmac_tag.len);
11456 ut_params->ibuf->nb_segs = segs;
11459 * Place digest at the end of the last buffer
11461 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11464 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11465 + tdata->gmac_tag.len);
11466 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11467 tdata->plaintext.len);
11470 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11471 tdata, digest_mem, digest_phys);
11476 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11478 ut_params->op->sym->m_src = ut_params->ibuf;
11480 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11483 TEST_ASSERT_NOT_NULL(
11484 process_crypto_request(ts_params->valid_devs[0],
11485 ut_params->op), "failed to process sym crypto op");
11487 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11488 "crypto op processing failed");
11490 auth_tag = digest_mem;
11491 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11492 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11494 tdata->gmac_tag.data,
11495 tdata->gmac_tag.len,
11496 "GMAC Generated auth tag not as expected");
11501 /* Segment size not multiple of block size (16B) */
11503 test_AES_GMAC_authentication_SGL_40B(void)
11505 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11509 test_AES_GMAC_authentication_SGL_80B(void)
11511 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11515 test_AES_GMAC_authentication_SGL_2048B(void)
11517 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11520 /* Segment size not multiple of block size (16B) */
11522 test_AES_GMAC_authentication_SGL_2047B(void)
11524 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11527 struct test_crypto_vector {
11528 enum rte_crypto_cipher_algorithm crypto_algo;
11529 unsigned int cipher_offset;
11530 unsigned int cipher_len;
11543 const uint8_t *data;
11548 const uint8_t *data;
11552 enum rte_crypto_auth_algorithm auth_algo;
11553 unsigned int auth_offset;
11561 const uint8_t *data;
11571 static const struct test_crypto_vector
11572 hmac_sha1_test_crypto_vector = {
11573 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11575 .data = plaintext_hash,
11580 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11581 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11582 0xDE, 0xF4, 0xDE, 0xAD
11588 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11589 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11590 0x3F, 0x91, 0x64, 0x59
11596 static const struct test_crypto_vector
11597 aes128_gmac_test_vector = {
11598 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11600 .data = plaintext_hash,
11605 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11606 0x08, 0x09, 0x0A, 0x0B
11612 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11613 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11619 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11620 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11626 static const struct test_crypto_vector
11627 aes128cbc_hmac_sha1_test_vector = {
11628 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11629 .cipher_offset = 0,
11633 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11634 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11640 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11641 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11646 .data = plaintext_hash,
11650 .data = ciphertext512_aes128cbc,
11653 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11657 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11658 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11659 0xDE, 0xF4, 0xDE, 0xAD
11665 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
11666 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11667 0x18, 0x8C, 0x1D, 0x32
11673 static const struct test_crypto_vector
11674 aes128cbc_hmac_sha1_aad_test_vector = {
11675 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11676 .cipher_offset = 8,
11680 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11681 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11687 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11688 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11693 .data = plaintext_hash,
11697 .data = ciphertext512_aes128cbc_aad,
11700 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11704 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11705 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11706 0xDE, 0xF4, 0xDE, 0xAD
11712 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
11713 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
11714 0x62, 0x0F, 0xFB, 0x10
11721 data_corruption(uint8_t *data)
11727 tag_corruption(uint8_t *data, unsigned int tag_offset)
11729 data[tag_offset] += 1;
11733 create_auth_session(struct crypto_unittest_params *ut_params,
11735 const struct test_crypto_vector *reference,
11736 enum rte_crypto_auth_operation auth_op)
11738 struct crypto_testsuite_params *ts_params = &testsuite_params;
11739 uint8_t auth_key[reference->auth_key.len + 1];
11741 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11743 /* Setup Authentication Parameters */
11744 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11745 ut_params->auth_xform.auth.op = auth_op;
11746 ut_params->auth_xform.next = NULL;
11747 ut_params->auth_xform.auth.algo = reference->auth_algo;
11748 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11749 ut_params->auth_xform.auth.key.data = auth_key;
11750 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11752 /* Create Crypto session*/
11753 ut_params->sess = rte_cryptodev_sym_session_create(
11754 ts_params->session_mpool);
11756 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11757 &ut_params->auth_xform,
11758 ts_params->session_priv_mpool);
11760 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11766 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
11768 const struct test_crypto_vector *reference,
11769 enum rte_crypto_auth_operation auth_op,
11770 enum rte_crypto_cipher_operation cipher_op)
11772 struct crypto_testsuite_params *ts_params = &testsuite_params;
11773 uint8_t cipher_key[reference->cipher_key.len + 1];
11774 uint8_t auth_key[reference->auth_key.len + 1];
11776 memcpy(cipher_key, reference->cipher_key.data,
11777 reference->cipher_key.len);
11778 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11780 /* Setup Authentication Parameters */
11781 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11782 ut_params->auth_xform.auth.op = auth_op;
11783 ut_params->auth_xform.auth.algo = reference->auth_algo;
11784 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11785 ut_params->auth_xform.auth.key.data = auth_key;
11786 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11788 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
11789 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11790 ut_params->auth_xform.auth.iv.length = reference->iv.len;
11792 ut_params->auth_xform.next = &ut_params->cipher_xform;
11794 /* Setup Cipher Parameters */
11795 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11796 ut_params->cipher_xform.next = NULL;
11797 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11798 ut_params->cipher_xform.cipher.op = cipher_op;
11799 ut_params->cipher_xform.cipher.key.data = cipher_key;
11800 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11801 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11802 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11805 /* Create Crypto session*/
11806 ut_params->sess = rte_cryptodev_sym_session_create(
11807 ts_params->session_mpool);
11809 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11810 &ut_params->auth_xform,
11811 ts_params->session_priv_mpool);
11813 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11819 create_auth_operation(struct crypto_testsuite_params *ts_params,
11820 struct crypto_unittest_params *ut_params,
11821 const struct test_crypto_vector *reference,
11822 unsigned int auth_generate)
11824 /* Generate Crypto op data structure */
11825 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11826 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11827 TEST_ASSERT_NOT_NULL(ut_params->op,
11828 "Failed to allocate pktmbuf offload");
11830 /* Set crypto operation data parameters */
11831 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11833 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11835 /* set crypto operation source mbuf */
11836 sym_op->m_src = ut_params->ibuf;
11839 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11840 ut_params->ibuf, reference->digest.len);
11842 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11843 "no room to append auth tag");
11845 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11846 ut_params->ibuf, reference->plaintext.len);
11849 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11851 memcpy(sym_op->auth.digest.data,
11852 reference->digest.data,
11853 reference->digest.len);
11855 debug_hexdump(stdout, "digest:",
11856 sym_op->auth.digest.data,
11857 reference->digest.len);
11859 sym_op->auth.data.length = reference->plaintext.len;
11860 sym_op->auth.data.offset = 0;
11866 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
11867 struct crypto_unittest_params *ut_params,
11868 const struct test_crypto_vector *reference,
11869 unsigned int auth_generate)
11871 /* Generate Crypto op data structure */
11872 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11873 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11874 TEST_ASSERT_NOT_NULL(ut_params->op,
11875 "Failed to allocate pktmbuf offload");
11877 /* Set crypto operation data parameters */
11878 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11880 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11882 /* set crypto operation source mbuf */
11883 sym_op->m_src = ut_params->ibuf;
11886 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11887 ut_params->ibuf, reference->digest.len);
11889 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11890 "no room to append auth tag");
11892 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11893 ut_params->ibuf, reference->ciphertext.len);
11896 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11898 memcpy(sym_op->auth.digest.data,
11899 reference->digest.data,
11900 reference->digest.len);
11902 debug_hexdump(stdout, "digest:",
11903 sym_op->auth.digest.data,
11904 reference->digest.len);
11906 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11907 reference->iv.data, reference->iv.len);
11909 sym_op->cipher.data.length = 0;
11910 sym_op->cipher.data.offset = 0;
11912 sym_op->auth.data.length = reference->plaintext.len;
11913 sym_op->auth.data.offset = 0;
11919 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11920 struct crypto_unittest_params *ut_params,
11921 const struct test_crypto_vector *reference,
11922 unsigned int auth_generate)
11924 /* Generate Crypto op data structure */
11925 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11926 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11927 TEST_ASSERT_NOT_NULL(ut_params->op,
11928 "Failed to allocate pktmbuf offload");
11930 /* Set crypto operation data parameters */
11931 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11933 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11935 /* set crypto operation source mbuf */
11936 sym_op->m_src = ut_params->ibuf;
11939 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11940 ut_params->ibuf, reference->digest.len);
11942 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11943 "no room to append auth tag");
11945 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11946 ut_params->ibuf, reference->ciphertext.len);
11949 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11951 memcpy(sym_op->auth.digest.data,
11952 reference->digest.data,
11953 reference->digest.len);
11955 debug_hexdump(stdout, "digest:",
11956 sym_op->auth.digest.data,
11957 reference->digest.len);
11959 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11960 reference->iv.data, reference->iv.len);
11962 sym_op->cipher.data.length = reference->cipher_len;
11963 sym_op->cipher.data.offset = reference->cipher_offset;
11965 sym_op->auth.data.length = reference->plaintext.len;
11966 sym_op->auth.data.offset = reference->auth_offset;
11972 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11973 struct crypto_unittest_params *ut_params,
11974 const struct test_crypto_vector *reference)
11976 return create_auth_operation(ts_params, ut_params, reference, 0);
11980 create_auth_verify_GMAC_operation(
11981 struct crypto_testsuite_params *ts_params,
11982 struct crypto_unittest_params *ut_params,
11983 const struct test_crypto_vector *reference)
11985 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11989 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11990 struct crypto_unittest_params *ut_params,
11991 const struct test_crypto_vector *reference)
11993 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11997 test_authentication_verify_fail_when_data_corruption(
11998 struct crypto_testsuite_params *ts_params,
11999 struct crypto_unittest_params *ut_params,
12000 const struct test_crypto_vector *reference,
12001 unsigned int data_corrupted)
12005 uint8_t *plaintext;
12006 struct rte_cryptodev_info dev_info;
12008 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12009 uint64_t feat_flags = dev_info.feature_flags;
12011 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12012 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12013 printf("Device doesn't support RAW data-path APIs.\n");
12017 /* Verify the capabilities */
12018 struct rte_cryptodev_sym_capability_idx cap_idx;
12019 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12020 cap_idx.algo.auth = reference->auth_algo;
12021 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12026 /* Create session */
12027 retval = create_auth_session(ut_params,
12028 ts_params->valid_devs[0],
12030 RTE_CRYPTO_AUTH_OP_VERIFY);
12034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12035 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12036 "Failed to allocate input buffer in mempool");
12038 /* clear mbuf payload */
12039 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12040 rte_pktmbuf_tailroom(ut_params->ibuf));
12042 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12043 reference->plaintext.len);
12044 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12045 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12047 debug_hexdump(stdout, "plaintext:", plaintext,
12048 reference->plaintext.len);
12050 /* Create operation */
12051 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12056 if (data_corrupted)
12057 data_corruption(plaintext);
12059 tag_corruption(plaintext, reference->plaintext.len);
12061 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12062 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12064 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12065 RTE_CRYPTO_OP_STATUS_SUCCESS,
12066 "authentication not failed");
12067 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12068 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12069 ut_params->op, 0, 1, 0, 0);
12071 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12073 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12080 test_authentication_verify_GMAC_fail_when_corruption(
12081 struct crypto_testsuite_params *ts_params,
12082 struct crypto_unittest_params *ut_params,
12083 const struct test_crypto_vector *reference,
12084 unsigned int data_corrupted)
12087 uint8_t *plaintext;
12088 struct rte_cryptodev_info dev_info;
12090 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12091 uint64_t feat_flags = dev_info.feature_flags;
12093 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12094 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12095 printf("Device doesn't support RAW data-path APIs.\n");
12099 /* Verify the capabilities */
12100 struct rte_cryptodev_sym_capability_idx cap_idx;
12101 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12102 cap_idx.algo.auth = reference->auth_algo;
12103 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12107 /* Create session */
12108 retval = create_auth_cipher_session(ut_params,
12109 ts_params->valid_devs[0],
12111 RTE_CRYPTO_AUTH_OP_VERIFY,
12112 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12116 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12117 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12118 "Failed to allocate input buffer in mempool");
12120 /* clear mbuf payload */
12121 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12122 rte_pktmbuf_tailroom(ut_params->ibuf));
12124 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12125 reference->plaintext.len);
12126 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12127 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12129 debug_hexdump(stdout, "plaintext:", plaintext,
12130 reference->plaintext.len);
12132 /* Create operation */
12133 retval = create_auth_verify_GMAC_operation(ts_params,
12140 if (data_corrupted)
12141 data_corruption(plaintext);
12143 tag_corruption(plaintext, reference->aad.len);
12145 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12146 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12148 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12149 RTE_CRYPTO_OP_STATUS_SUCCESS,
12150 "authentication not failed");
12151 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12152 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12153 ut_params->op, 0, 1, 0, 0);
12155 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12157 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12164 test_authenticated_decryption_fail_when_corruption(
12165 struct crypto_testsuite_params *ts_params,
12166 struct crypto_unittest_params *ut_params,
12167 const struct test_crypto_vector *reference,
12168 unsigned int data_corrupted)
12172 uint8_t *ciphertext;
12173 struct rte_cryptodev_info dev_info;
12175 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12176 uint64_t feat_flags = dev_info.feature_flags;
12178 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12179 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12180 printf("Device doesn't support RAW data-path APIs.\n");
12184 /* Verify the capabilities */
12185 struct rte_cryptodev_sym_capability_idx cap_idx;
12186 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12187 cap_idx.algo.auth = reference->auth_algo;
12188 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12191 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12192 cap_idx.algo.cipher = reference->crypto_algo;
12193 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12197 /* Create session */
12198 retval = create_auth_cipher_session(ut_params,
12199 ts_params->valid_devs[0],
12201 RTE_CRYPTO_AUTH_OP_VERIFY,
12202 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12206 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12207 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12208 "Failed to allocate input buffer in mempool");
12210 /* clear mbuf payload */
12211 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12212 rte_pktmbuf_tailroom(ut_params->ibuf));
12214 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12215 reference->ciphertext.len);
12216 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12217 memcpy(ciphertext, reference->ciphertext.data,
12218 reference->ciphertext.len);
12220 /* Create operation */
12221 retval = create_cipher_auth_verify_operation(ts_params,
12228 if (data_corrupted)
12229 data_corruption(ciphertext);
12231 tag_corruption(ciphertext, reference->ciphertext.len);
12233 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12234 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12236 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12237 RTE_CRYPTO_OP_STATUS_SUCCESS,
12238 "authentication not failed");
12239 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12240 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12241 ut_params->op, 1, 1, 0, 0);
12243 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12245 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12252 test_authenticated_encryt_with_esn(
12253 struct crypto_testsuite_params *ts_params,
12254 struct crypto_unittest_params *ut_params,
12255 const struct test_crypto_vector *reference)
12259 uint8_t *authciphertext, *plaintext, *auth_tag;
12260 uint16_t plaintext_pad_len;
12261 uint8_t cipher_key[reference->cipher_key.len + 1];
12262 uint8_t auth_key[reference->auth_key.len + 1];
12263 struct rte_cryptodev_info dev_info;
12265 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12266 uint64_t feat_flags = dev_info.feature_flags;
12268 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12269 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12270 printf("Device doesn't support RAW data-path APIs.\n");
12274 /* Verify the capabilities */
12275 struct rte_cryptodev_sym_capability_idx cap_idx;
12276 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12277 cap_idx.algo.auth = reference->auth_algo;
12278 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12281 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12282 cap_idx.algo.cipher = reference->crypto_algo;
12283 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12287 /* Create session */
12288 memcpy(cipher_key, reference->cipher_key.data,
12289 reference->cipher_key.len);
12290 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12292 /* Setup Cipher Parameters */
12293 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12294 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12295 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12296 ut_params->cipher_xform.cipher.key.data = cipher_key;
12297 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12298 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12299 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12301 ut_params->cipher_xform.next = &ut_params->auth_xform;
12303 /* Setup Authentication Parameters */
12304 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12305 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12306 ut_params->auth_xform.auth.algo = reference->auth_algo;
12307 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12308 ut_params->auth_xform.auth.key.data = auth_key;
12309 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12310 ut_params->auth_xform.next = NULL;
12312 /* Create Crypto session*/
12313 ut_params->sess = rte_cryptodev_sym_session_create(
12314 ts_params->session_mpool);
12316 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12318 &ut_params->cipher_xform,
12319 ts_params->session_priv_mpool);
12321 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12323 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12324 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12325 "Failed to allocate input buffer in mempool");
12327 /* clear mbuf payload */
12328 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12329 rte_pktmbuf_tailroom(ut_params->ibuf));
12331 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12332 reference->plaintext.len);
12333 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12334 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12336 /* Create operation */
12337 retval = create_cipher_auth_operation(ts_params,
12344 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12345 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12347 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12348 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12349 ut_params->op, 1, 1, 0, 0);
12351 ut_params->op = process_crypto_request(
12352 ts_params->valid_devs[0], ut_params->op);
12354 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12356 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12357 "crypto op processing failed");
12359 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12361 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12362 ut_params->op->sym->auth.data.offset);
12363 auth_tag = authciphertext + plaintext_pad_len;
12364 debug_hexdump(stdout, "ciphertext:", authciphertext,
12365 reference->ciphertext.len);
12366 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12368 /* Validate obuf */
12369 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12371 reference->ciphertext.data,
12372 reference->ciphertext.len,
12373 "Ciphertext data not as expected");
12375 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12377 reference->digest.data,
12378 reference->digest.len,
12379 "Generated digest not as expected");
12381 return TEST_SUCCESS;
12386 test_authenticated_decrypt_with_esn(
12387 struct crypto_testsuite_params *ts_params,
12388 struct crypto_unittest_params *ut_params,
12389 const struct test_crypto_vector *reference)
12393 uint8_t *ciphertext;
12394 uint8_t cipher_key[reference->cipher_key.len + 1];
12395 uint8_t auth_key[reference->auth_key.len + 1];
12396 struct rte_cryptodev_info dev_info;
12398 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12399 uint64_t feat_flags = dev_info.feature_flags;
12401 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12402 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12403 printf("Device doesn't support RAW data-path APIs.\n");
12407 /* Verify the capabilities */
12408 struct rte_cryptodev_sym_capability_idx cap_idx;
12409 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12410 cap_idx.algo.auth = reference->auth_algo;
12411 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12414 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12415 cap_idx.algo.cipher = reference->crypto_algo;
12416 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12420 /* Create session */
12421 memcpy(cipher_key, reference->cipher_key.data,
12422 reference->cipher_key.len);
12423 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12425 /* Setup Authentication Parameters */
12426 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12427 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12428 ut_params->auth_xform.auth.algo = reference->auth_algo;
12429 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12430 ut_params->auth_xform.auth.key.data = auth_key;
12431 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12432 ut_params->auth_xform.next = &ut_params->cipher_xform;
12434 /* Setup Cipher Parameters */
12435 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12436 ut_params->cipher_xform.next = NULL;
12437 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12438 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12439 ut_params->cipher_xform.cipher.key.data = cipher_key;
12440 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12441 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12442 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12444 /* Create Crypto session*/
12445 ut_params->sess = rte_cryptodev_sym_session_create(
12446 ts_params->session_mpool);
12448 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12450 &ut_params->auth_xform,
12451 ts_params->session_priv_mpool);
12453 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12455 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12456 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12457 "Failed to allocate input buffer in mempool");
12459 /* clear mbuf payload */
12460 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12461 rte_pktmbuf_tailroom(ut_params->ibuf));
12463 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12464 reference->ciphertext.len);
12465 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12466 memcpy(ciphertext, reference->ciphertext.data,
12467 reference->ciphertext.len);
12469 /* Create operation */
12470 retval = create_cipher_auth_verify_operation(ts_params,
12477 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12478 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12480 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12481 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12482 ut_params->op, 1, 1, 0, 0);
12484 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12488 TEST_ASSERT_EQUAL(ut_params->op->status,
12489 RTE_CRYPTO_OP_STATUS_SUCCESS,
12490 "crypto op processing passed");
12492 ut_params->obuf = ut_params->op->sym->m_src;
12493 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12499 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12500 const struct aead_test_data *tdata,
12501 void *digest_mem, uint64_t digest_phys)
12503 struct crypto_testsuite_params *ts_params = &testsuite_params;
12504 struct crypto_unittest_params *ut_params = &unittest_params;
12506 const unsigned int auth_tag_len = tdata->auth_tag.len;
12507 const unsigned int iv_len = tdata->iv.len;
12508 unsigned int aad_len = tdata->aad.len;
12509 unsigned int aad_len_pad = 0;
12511 /* Generate Crypto op data structure */
12512 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12513 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12514 TEST_ASSERT_NOT_NULL(ut_params->op,
12515 "Failed to allocate symmetric crypto operation struct");
12517 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12519 sym_op->aead.digest.data = digest_mem;
12521 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12522 "no room to append digest");
12524 sym_op->aead.digest.phys_addr = digest_phys;
12526 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12527 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12529 debug_hexdump(stdout, "digest:",
12530 sym_op->aead.digest.data,
12534 /* Append aad data */
12535 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12536 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12537 uint8_t *, IV_OFFSET);
12539 /* Copy IV 1 byte after the IV pointer, according to the API */
12540 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12542 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12544 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12545 ut_params->ibuf, aad_len);
12546 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12547 "no room to prepend aad");
12548 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12551 memset(sym_op->aead.aad.data, 0, aad_len);
12552 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12553 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12555 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12556 debug_hexdump(stdout, "aad:",
12557 sym_op->aead.aad.data, aad_len);
12559 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12560 uint8_t *, IV_OFFSET);
12562 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12564 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12566 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12567 ut_params->ibuf, aad_len_pad);
12568 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12569 "no room to prepend aad");
12570 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12573 memset(sym_op->aead.aad.data, 0, aad_len);
12574 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12576 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12577 debug_hexdump(stdout, "aad:",
12578 sym_op->aead.aad.data, aad_len);
12581 sym_op->aead.data.length = tdata->plaintext.len;
12582 sym_op->aead.data.offset = aad_len_pad;
12587 #define SGL_MAX_NO 16
12590 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12591 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12593 struct crypto_testsuite_params *ts_params = &testsuite_params;
12594 struct crypto_unittest_params *ut_params = &unittest_params;
12595 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12598 int to_trn_tbl[SGL_MAX_NO];
12600 unsigned int trn_data = 0;
12601 uint8_t *plaintext, *ciphertext, *auth_tag;
12602 struct rte_cryptodev_info dev_info;
12604 /* Verify the capabilities */
12605 struct rte_cryptodev_sym_capability_idx cap_idx;
12606 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12607 cap_idx.algo.aead = tdata->algo;
12608 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12612 /* OOP not supported with CPU crypto */
12613 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12616 /* Detailed check for the particular SGL support flag */
12617 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12619 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12620 if (sgl_in && (!(dev_info.feature_flags &
12621 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12624 uint64_t feat_flags = dev_info.feature_flags;
12626 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12627 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12628 printf("Device doesn't support RAW data-path APIs.\n");
12632 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12633 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12634 tdata->plaintext.len;
12635 /* Raw data path API does not support OOP */
12636 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12638 if (sgl_in && !sgl_out) {
12639 if (!(dev_info.feature_flags &
12640 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12642 } else if (!sgl_in && sgl_out) {
12643 if (!(dev_info.feature_flags &
12644 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12646 } else if (sgl_in && sgl_out) {
12647 if (!(dev_info.feature_flags &
12648 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12653 if (fragsz > tdata->plaintext.len)
12654 fragsz = tdata->plaintext.len;
12656 uint16_t plaintext_len = fragsz;
12657 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
12659 if (fragsz_oop > tdata->plaintext.len)
12660 frag_size_oop = tdata->plaintext.len;
12663 void *digest_mem = NULL;
12665 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
12667 if (tdata->plaintext.len % fragsz != 0) {
12668 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
12671 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
12676 * For out-op-place we need to alloc another mbuf
12679 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12680 rte_pktmbuf_append(ut_params->obuf,
12681 frag_size_oop + prepend_len);
12682 buf_oop = ut_params->obuf;
12685 /* Create AEAD session */
12686 retval = create_aead_session(ts_params->valid_devs[0],
12688 RTE_CRYPTO_AEAD_OP_ENCRYPT,
12689 tdata->key.data, tdata->key.len,
12690 tdata->aad.len, tdata->auth_tag.len,
12695 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12697 /* clear mbuf payload */
12698 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12699 rte_pktmbuf_tailroom(ut_params->ibuf));
12701 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12704 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12706 trn_data += plaintext_len;
12708 buf = ut_params->ibuf;
12711 * Loop until no more fragments
12714 while (trn_data < tdata->plaintext.len) {
12716 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12717 (tdata->plaintext.len - trn_data) : fragsz;
12719 to_trn_tbl[ecx++] = to_trn;
12721 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12724 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12725 rte_pktmbuf_tailroom(buf));
12728 if (oop && !fragsz_oop) {
12729 buf_last_oop = buf_oop->next =
12730 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12731 buf_oop = buf_oop->next;
12732 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12733 0, rte_pktmbuf_tailroom(buf_oop));
12734 rte_pktmbuf_append(buf_oop, to_trn);
12737 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12740 memcpy(plaintext, tdata->plaintext.data + trn_data,
12742 trn_data += to_trn;
12743 if (trn_data == tdata->plaintext.len) {
12746 digest_mem = rte_pktmbuf_append(buf_oop,
12747 tdata->auth_tag.len);
12749 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12750 tdata->auth_tag.len);
12754 uint64_t digest_phys = 0;
12756 ut_params->ibuf->nb_segs = segs;
12759 if (fragsz_oop && oop) {
12763 if (frag_size_oop == tdata->plaintext.len) {
12764 digest_mem = rte_pktmbuf_append(ut_params->obuf,
12765 tdata->auth_tag.len);
12767 digest_phys = rte_pktmbuf_iova_offset(
12769 tdata->plaintext.len + prepend_len);
12772 trn_data = frag_size_oop;
12773 while (trn_data < tdata->plaintext.len) {
12776 (tdata->plaintext.len - trn_data <
12778 (tdata->plaintext.len - trn_data) :
12781 to_trn_tbl[ecx++] = to_trn;
12783 buf_last_oop = buf_oop->next =
12784 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12785 buf_oop = buf_oop->next;
12786 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12787 0, rte_pktmbuf_tailroom(buf_oop));
12788 rte_pktmbuf_append(buf_oop, to_trn);
12790 trn_data += to_trn;
12792 if (trn_data == tdata->plaintext.len) {
12793 digest_mem = rte_pktmbuf_append(buf_oop,
12794 tdata->auth_tag.len);
12798 ut_params->obuf->nb_segs = segs;
12802 * Place digest at the end of the last buffer
12805 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12806 if (oop && buf_last_oop)
12807 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
12809 if (!digest_mem && !oop) {
12810 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12811 + tdata->auth_tag.len);
12812 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12813 tdata->plaintext.len);
12816 /* Create AEAD operation */
12817 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
12818 tdata, digest_mem, digest_phys);
12823 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12825 ut_params->op->sym->m_src = ut_params->ibuf;
12827 ut_params->op->sym->m_dst = ut_params->obuf;
12829 /* Process crypto operation */
12830 if (oop == IN_PLACE &&
12831 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12832 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12833 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12834 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12835 ut_params->op, 0, 0, 0, 0);
12837 TEST_ASSERT_NOT_NULL(
12838 process_crypto_request(ts_params->valid_devs[0],
12839 ut_params->op), "failed to process sym crypto op");
12841 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12842 "crypto op processing failed");
12845 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12846 uint8_t *, prepend_len);
12848 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12849 uint8_t *, prepend_len);
12853 fragsz = fragsz_oop;
12855 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12857 tdata->ciphertext.data,
12859 "Ciphertext data not as expected");
12861 buf = ut_params->op->sym->m_src->next;
12863 buf = ut_params->op->sym->m_dst->next;
12865 unsigned int off = fragsz;
12869 ciphertext = rte_pktmbuf_mtod(buf,
12872 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12874 tdata->ciphertext.data + off,
12876 "Ciphertext data not as expected");
12878 off += to_trn_tbl[ecx++];
12882 auth_tag = digest_mem;
12883 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12885 tdata->auth_tag.data,
12886 tdata->auth_tag.len,
12887 "Generated auth tag not as expected");
12893 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
12895 return test_authenticated_encryption_SGL(
12896 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
12900 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
12902 return test_authenticated_encryption_SGL(
12903 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
12907 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
12909 return test_authenticated_encryption_SGL(
12910 &gcm_test_case_8, OUT_OF_PLACE, 400,
12911 gcm_test_case_8.plaintext.len);
12915 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
12917 /* This test is not for OPENSSL PMD */
12918 if (gbl_driver_id == rte_cryptodev_driver_id_get(
12919 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
12922 return test_authenticated_encryption_SGL(
12923 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
12927 test_authentication_verify_fail_when_data_corrupted(
12928 struct crypto_testsuite_params *ts_params,
12929 struct crypto_unittest_params *ut_params,
12930 const struct test_crypto_vector *reference)
12932 return test_authentication_verify_fail_when_data_corruption(
12933 ts_params, ut_params, reference, 1);
12937 test_authentication_verify_fail_when_tag_corrupted(
12938 struct crypto_testsuite_params *ts_params,
12939 struct crypto_unittest_params *ut_params,
12940 const struct test_crypto_vector *reference)
12942 return test_authentication_verify_fail_when_data_corruption(
12943 ts_params, ut_params, reference, 0);
12947 test_authentication_verify_GMAC_fail_when_data_corrupted(
12948 struct crypto_testsuite_params *ts_params,
12949 struct crypto_unittest_params *ut_params,
12950 const struct test_crypto_vector *reference)
12952 return test_authentication_verify_GMAC_fail_when_corruption(
12953 ts_params, ut_params, reference, 1);
12957 test_authentication_verify_GMAC_fail_when_tag_corrupted(
12958 struct crypto_testsuite_params *ts_params,
12959 struct crypto_unittest_params *ut_params,
12960 const struct test_crypto_vector *reference)
12962 return test_authentication_verify_GMAC_fail_when_corruption(
12963 ts_params, ut_params, reference, 0);
12967 test_authenticated_decryption_fail_when_data_corrupted(
12968 struct crypto_testsuite_params *ts_params,
12969 struct crypto_unittest_params *ut_params,
12970 const struct test_crypto_vector *reference)
12972 return test_authenticated_decryption_fail_when_corruption(
12973 ts_params, ut_params, reference, 1);
12977 test_authenticated_decryption_fail_when_tag_corrupted(
12978 struct crypto_testsuite_params *ts_params,
12979 struct crypto_unittest_params *ut_params,
12980 const struct test_crypto_vector *reference)
12982 return test_authenticated_decryption_fail_when_corruption(
12983 ts_params, ut_params, reference, 0);
12987 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
12989 return test_authentication_verify_fail_when_data_corrupted(
12990 &testsuite_params, &unittest_params,
12991 &hmac_sha1_test_crypto_vector);
12995 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
12997 return test_authentication_verify_fail_when_tag_corrupted(
12998 &testsuite_params, &unittest_params,
12999 &hmac_sha1_test_crypto_vector);
13003 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13005 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13006 &testsuite_params, &unittest_params,
13007 &aes128_gmac_test_vector);
13011 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13013 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13014 &testsuite_params, &unittest_params,
13015 &aes128_gmac_test_vector);
13019 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13021 return test_authenticated_decryption_fail_when_data_corrupted(
13024 &aes128cbc_hmac_sha1_test_vector);
13028 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13030 return test_authenticated_decryption_fail_when_tag_corrupted(
13033 &aes128cbc_hmac_sha1_test_vector);
13037 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13039 return test_authenticated_encryt_with_esn(
13042 &aes128cbc_hmac_sha1_aad_test_vector);
13046 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13048 return test_authenticated_decrypt_with_esn(
13051 &aes128cbc_hmac_sha1_aad_test_vector);
13055 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13057 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13061 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13063 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13066 #ifdef RTE_CRYPTO_SCHEDULER
13068 /* global AESNI worker IDs for the scheduler test */
13069 uint8_t aesni_ids[2];
13072 test_scheduler_attach_slave_op(void)
13074 struct crypto_testsuite_params *ts_params = &testsuite_params;
13075 uint8_t sched_id = ts_params->valid_devs[0];
13076 uint32_t nb_devs, i, nb_devs_attached = 0;
13078 char vdev_name[32];
13080 /* create 2 AESNI_MB if necessary */
13081 nb_devs = rte_cryptodev_device_count_by_driver(
13082 rte_cryptodev_driver_id_get(
13083 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13085 for (i = nb_devs; i < 2; i++) {
13086 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13087 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13089 ret = rte_vdev_init(vdev_name, NULL);
13091 TEST_ASSERT(ret == 0,
13092 "Failed to create instance %u of"
13094 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13098 /* attach 2 AESNI_MB cdevs */
13099 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13101 struct rte_cryptodev_info info;
13102 unsigned int session_size;
13104 rte_cryptodev_info_get(i, &info);
13105 if (info.driver_id != rte_cryptodev_driver_id_get(
13106 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13109 session_size = rte_cryptodev_sym_get_private_session_size(i);
13111 * Create the session mempool again, since now there are new devices
13112 * to use the mempool.
13114 if (ts_params->session_mpool) {
13115 rte_mempool_free(ts_params->session_mpool);
13116 ts_params->session_mpool = NULL;
13118 if (ts_params->session_priv_mpool) {
13119 rte_mempool_free(ts_params->session_priv_mpool);
13120 ts_params->session_priv_mpool = NULL;
13123 if (info.sym.max_nb_sessions != 0 &&
13124 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13125 RTE_LOG(ERR, USER1,
13126 "Device does not support "
13127 "at least %u sessions\n",
13129 return TEST_FAILED;
13132 * Create mempool with maximum number of sessions,
13133 * to include the session headers
13135 if (ts_params->session_mpool == NULL) {
13136 ts_params->session_mpool =
13137 rte_cryptodev_sym_session_pool_create(
13139 MAX_NB_SESSIONS, 0, 0, 0,
13141 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13142 "session mempool allocation failed");
13146 * Create mempool with maximum number of sessions,
13147 * to include device specific session private data
13149 if (ts_params->session_priv_mpool == NULL) {
13150 ts_params->session_priv_mpool = rte_mempool_create(
13151 "test_sess_mp_priv",
13154 0, 0, NULL, NULL, NULL,
13155 NULL, SOCKET_ID_ANY,
13158 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13159 "session mempool allocation failed");
13162 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13163 ts_params->qp_conf.mp_session_private =
13164 ts_params->session_priv_mpool;
13166 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13169 TEST_ASSERT(ret == 0,
13170 "Failed to attach device %u of pmd : %s", i,
13171 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13173 aesni_ids[nb_devs_attached] = (uint8_t)i;
13175 nb_devs_attached++;
13182 test_scheduler_detach_slave_op(void)
13184 struct crypto_testsuite_params *ts_params = &testsuite_params;
13185 uint8_t sched_id = ts_params->valid_devs[0];
13189 for (i = 0; i < 2; i++) {
13190 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13192 TEST_ASSERT(ret == 0,
13193 "Failed to detach device %u", aesni_ids[i]);
13200 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13202 struct crypto_testsuite_params *ts_params = &testsuite_params;
13203 uint8_t sched_id = ts_params->valid_devs[0];
13205 return rte_cryptodev_scheduler_mode_set(sched_id,
13210 test_scheduler_mode_roundrobin_op(void)
13212 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13213 0, "Failed to set roundrobin mode");
13219 test_scheduler_mode_multicore_op(void)
13221 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13222 0, "Failed to set multicore mode");
13228 test_scheduler_mode_failover_op(void)
13230 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13231 0, "Failed to set failover mode");
13237 test_scheduler_mode_pkt_size_distr_op(void)
13239 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13240 0, "Failed to set pktsize mode");
13245 static struct unit_test_suite cryptodev_scheduler_testsuite = {
13246 .suite_name = "Crypto Device Scheduler Unit Test Suite",
13247 .setup = testsuite_setup,
13248 .teardown = testsuite_teardown,
13249 .unit_test_cases = {
13251 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13252 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
13253 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13254 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13255 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13256 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13259 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13260 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
13261 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13262 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13263 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13264 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13267 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13268 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
13269 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13270 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13271 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13272 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13275 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13276 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
13277 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13278 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13279 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13280 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13282 TEST_CASES_END() /**< NULL terminate unit test array */
13286 #endif /* RTE_CRYPTO_SCHEDULER */
13288 static struct unit_test_suite cryptodev_testsuite = {
13289 .suite_name = "Crypto Unit Test Suite",
13290 .setup = testsuite_setup,
13291 .teardown = testsuite_teardown,
13292 .unit_test_cases = {
13293 TEST_CASE_ST(ut_setup, ut_teardown,
13294 test_device_configure_invalid_dev_id),
13295 TEST_CASE_ST(ut_setup, ut_teardown,
13296 test_queue_pair_descriptor_setup),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_device_configure_invalid_queue_pair_ids),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_multi_session),
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_multi_session_random_usage),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_null_invalid_operation),
13306 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13307 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13308 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13309 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13310 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13311 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
13312 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
13313 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
13314 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13315 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13317 /** AES CCM Authenticated Encryption 128 bits key */
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_AES_CCM_authenticated_encryption_test_case_128_1),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_AES_CCM_authenticated_encryption_test_case_128_2),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 test_AES_CCM_authenticated_encryption_test_case_128_3),
13325 /** AES CCM Authenticated Decryption 128 bits key*/
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_AES_CCM_authenticated_decryption_test_case_128_1),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_AES_CCM_authenticated_decryption_test_case_128_2),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_AES_CCM_authenticated_decryption_test_case_128_3),
13333 /** AES CCM Authenticated Encryption 192 bits key */
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_AES_CCM_authenticated_encryption_test_case_192_1),
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_AES_CCM_authenticated_encryption_test_case_192_2),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 test_AES_CCM_authenticated_encryption_test_case_192_3),
13341 /** AES CCM Authenticated Decryption 192 bits key*/
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 test_AES_CCM_authenticated_decryption_test_case_192_1),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 test_AES_CCM_authenticated_decryption_test_case_192_2),
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_AES_CCM_authenticated_decryption_test_case_192_3),
13349 /** AES CCM Authenticated Encryption 256 bits key */
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_AES_CCM_authenticated_encryption_test_case_256_1),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_AES_CCM_authenticated_encryption_test_case_256_2),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_AES_CCM_authenticated_encryption_test_case_256_3),
13357 /** AES CCM Authenticated Decryption 256 bits key*/
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_AES_CCM_authenticated_decryption_test_case_256_1),
13360 TEST_CASE_ST(ut_setup, ut_teardown,
13361 test_AES_CCM_authenticated_decryption_test_case_256_2),
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_AES_CCM_authenticated_decryption_test_case_256_3),
13365 /** AES GCM Authenticated Encryption */
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_AES_GCM_authenticated_encryption_test_case_1),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_AES_GCM_authenticated_encryption_test_case_2),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_AES_GCM_authenticated_encryption_test_case_3),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_AES_GCM_authenticated_encryption_test_case_4),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_AES_GCM_authenticated_encryption_test_case_5),
13384 TEST_CASE_ST(ut_setup, ut_teardown,
13385 test_AES_GCM_authenticated_encryption_test_case_6),
13386 TEST_CASE_ST(ut_setup, ut_teardown,
13387 test_AES_GCM_authenticated_encryption_test_case_7),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_AES_GCM_authenticated_encryption_test_case_8),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13393 /** AES GCM Authenticated Decryption */
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_AES_GCM_authenticated_decryption_test_case_1),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_AES_GCM_authenticated_decryption_test_case_2),
13398 TEST_CASE_ST(ut_setup, ut_teardown,
13399 test_AES_GCM_authenticated_decryption_test_case_3),
13400 TEST_CASE_ST(ut_setup, ut_teardown,
13401 test_AES_GCM_authenticated_decryption_test_case_4),
13402 TEST_CASE_ST(ut_setup, ut_teardown,
13403 test_AES_GCM_authenticated_decryption_test_case_5),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_AES_GCM_authenticated_decryption_test_case_6),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 test_AES_GCM_authenticated_decryption_test_case_7),
13408 TEST_CASE_ST(ut_setup, ut_teardown,
13409 test_AES_GCM_authenticated_decryption_test_case_8),
13410 TEST_CASE_ST(ut_setup, ut_teardown,
13411 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13413 /** AES GCM Authenticated Encryption 192 bits key */
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_AES_GCM_auth_encryption_test_case_192_1),
13416 TEST_CASE_ST(ut_setup, ut_teardown,
13417 test_AES_GCM_auth_encryption_test_case_192_2),
13418 TEST_CASE_ST(ut_setup, ut_teardown,
13419 test_AES_GCM_auth_encryption_test_case_192_3),
13420 TEST_CASE_ST(ut_setup, ut_teardown,
13421 test_AES_GCM_auth_encryption_test_case_192_4),
13422 TEST_CASE_ST(ut_setup, ut_teardown,
13423 test_AES_GCM_auth_encryption_test_case_192_5),
13424 TEST_CASE_ST(ut_setup, ut_teardown,
13425 test_AES_GCM_auth_encryption_test_case_192_6),
13426 TEST_CASE_ST(ut_setup, ut_teardown,
13427 test_AES_GCM_auth_encryption_test_case_192_7),
13429 /** AES GCM Authenticated Decryption 192 bits key */
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_AES_GCM_auth_decryption_test_case_192_1),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_AES_GCM_auth_decryption_test_case_192_2),
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 test_AES_GCM_auth_decryption_test_case_192_3),
13436 TEST_CASE_ST(ut_setup, ut_teardown,
13437 test_AES_GCM_auth_decryption_test_case_192_4),
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 test_AES_GCM_auth_decryption_test_case_192_5),
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 test_AES_GCM_auth_decryption_test_case_192_6),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 test_AES_GCM_auth_decryption_test_case_192_7),
13445 /** AES GCM Authenticated Encryption 256 bits key */
13446 TEST_CASE_ST(ut_setup, ut_teardown,
13447 test_AES_GCM_auth_encryption_test_case_256_1),
13448 TEST_CASE_ST(ut_setup, ut_teardown,
13449 test_AES_GCM_auth_encryption_test_case_256_2),
13450 TEST_CASE_ST(ut_setup, ut_teardown,
13451 test_AES_GCM_auth_encryption_test_case_256_3),
13452 TEST_CASE_ST(ut_setup, ut_teardown,
13453 test_AES_GCM_auth_encryption_test_case_256_4),
13454 TEST_CASE_ST(ut_setup, ut_teardown,
13455 test_AES_GCM_auth_encryption_test_case_256_5),
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 test_AES_GCM_auth_encryption_test_case_256_6),
13458 TEST_CASE_ST(ut_setup, ut_teardown,
13459 test_AES_GCM_auth_encryption_test_case_256_7),
13461 /** AES GCM Authenticated Decryption 256 bits key */
13462 TEST_CASE_ST(ut_setup, ut_teardown,
13463 test_AES_GCM_auth_decryption_test_case_256_1),
13464 TEST_CASE_ST(ut_setup, ut_teardown,
13465 test_AES_GCM_auth_decryption_test_case_256_2),
13466 TEST_CASE_ST(ut_setup, ut_teardown,
13467 test_AES_GCM_auth_decryption_test_case_256_3),
13468 TEST_CASE_ST(ut_setup, ut_teardown,
13469 test_AES_GCM_auth_decryption_test_case_256_4),
13470 TEST_CASE_ST(ut_setup, ut_teardown,
13471 test_AES_GCM_auth_decryption_test_case_256_5),
13472 TEST_CASE_ST(ut_setup, ut_teardown,
13473 test_AES_GCM_auth_decryption_test_case_256_6),
13474 TEST_CASE_ST(ut_setup, ut_teardown,
13475 test_AES_GCM_auth_decryption_test_case_256_7),
13477 /** AES GCM Authenticated Encryption big aad size */
13478 TEST_CASE_ST(ut_setup, ut_teardown,
13479 test_AES_GCM_auth_encryption_test_case_aad_1),
13480 TEST_CASE_ST(ut_setup, ut_teardown,
13481 test_AES_GCM_auth_encryption_test_case_aad_2),
13483 /** AES GCM Authenticated Decryption big aad size */
13484 TEST_CASE_ST(ut_setup, ut_teardown,
13485 test_AES_GCM_auth_decryption_test_case_aad_1),
13486 TEST_CASE_ST(ut_setup, ut_teardown,
13487 test_AES_GCM_auth_decryption_test_case_aad_2),
13489 /** Out of place tests */
13490 TEST_CASE_ST(ut_setup, ut_teardown,
13491 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13492 TEST_CASE_ST(ut_setup, ut_teardown,
13493 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13495 /** Session-less tests */
13496 TEST_CASE_ST(ut_setup, ut_teardown,
13497 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13498 TEST_CASE_ST(ut_setup, ut_teardown,
13499 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13501 /** AES GMAC Authentication */
13502 TEST_CASE_ST(ut_setup, ut_teardown,
13503 test_AES_GMAC_authentication_test_case_1),
13504 TEST_CASE_ST(ut_setup, ut_teardown,
13505 test_AES_GMAC_authentication_verify_test_case_1),
13506 TEST_CASE_ST(ut_setup, ut_teardown,
13507 test_AES_GMAC_authentication_test_case_2),
13508 TEST_CASE_ST(ut_setup, ut_teardown,
13509 test_AES_GMAC_authentication_verify_test_case_2),
13510 TEST_CASE_ST(ut_setup, ut_teardown,
13511 test_AES_GMAC_authentication_test_case_3),
13512 TEST_CASE_ST(ut_setup, ut_teardown,
13513 test_AES_GMAC_authentication_verify_test_case_3),
13514 TEST_CASE_ST(ut_setup, ut_teardown,
13515 test_AES_GMAC_authentication_test_case_4),
13516 TEST_CASE_ST(ut_setup, ut_teardown,
13517 test_AES_GMAC_authentication_verify_test_case_4),
13518 TEST_CASE_ST(ut_setup, ut_teardown,
13519 test_AES_GMAC_authentication_SGL_40B),
13520 TEST_CASE_ST(ut_setup, ut_teardown,
13521 test_AES_GMAC_authentication_SGL_80B),
13522 TEST_CASE_ST(ut_setup, ut_teardown,
13523 test_AES_GMAC_authentication_SGL_2048B),
13524 TEST_CASE_ST(ut_setup, ut_teardown,
13525 test_AES_GMAC_authentication_SGL_2047B),
13527 /** Chacha20-Poly1305 */
13528 TEST_CASE_ST(ut_setup, ut_teardown,
13529 test_chacha20_poly1305_encrypt_test_case_rfc8439),
13530 TEST_CASE_ST(ut_setup, ut_teardown,
13531 test_chacha20_poly1305_decrypt_test_case_rfc8439),
13532 /** SNOW 3G encrypt only (UEA2) */
13533 TEST_CASE_ST(ut_setup, ut_teardown,
13534 test_snow3g_encryption_test_case_1),
13535 TEST_CASE_ST(ut_setup, ut_teardown,
13536 test_snow3g_encryption_test_case_2),
13537 TEST_CASE_ST(ut_setup, ut_teardown,
13538 test_snow3g_encryption_test_case_3),
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_snow3g_encryption_test_case_4),
13541 TEST_CASE_ST(ut_setup, ut_teardown,
13542 test_snow3g_encryption_test_case_5),
13544 TEST_CASE_ST(ut_setup, ut_teardown,
13545 test_snow3g_encryption_test_case_1_oop),
13546 TEST_CASE_ST(ut_setup, ut_teardown,
13547 test_snow3g_encryption_test_case_1_oop_sgl),
13548 TEST_CASE_ST(ut_setup, ut_teardown,
13549 test_snow3g_encryption_test_case_1_offset_oop),
13550 TEST_CASE_ST(ut_setup, ut_teardown,
13551 test_snow3g_decryption_test_case_1_oop),
13553 /** SNOW 3G generate auth, then encrypt (UEA2) */
13554 TEST_CASE_ST(ut_setup, ut_teardown,
13555 test_snow3g_auth_cipher_test_case_1),
13556 TEST_CASE_ST(ut_setup, ut_teardown,
13557 test_snow3g_auth_cipher_test_case_2),
13558 TEST_CASE_ST(ut_setup, ut_teardown,
13559 test_snow3g_auth_cipher_test_case_2_oop),
13560 TEST_CASE_ST(ut_setup, ut_teardown,
13561 test_snow3g_auth_cipher_part_digest_enc),
13562 TEST_CASE_ST(ut_setup, ut_teardown,
13563 test_snow3g_auth_cipher_part_digest_enc_oop),
13564 TEST_CASE_ST(ut_setup, ut_teardown,
13565 test_snow3g_auth_cipher_test_case_3_sgl),
13566 TEST_CASE_ST(ut_setup, ut_teardown,
13567 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13568 TEST_CASE_ST(ut_setup, ut_teardown,
13569 test_snow3g_auth_cipher_part_digest_enc_sgl),
13570 TEST_CASE_ST(ut_setup, ut_teardown,
13571 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13573 /** SNOW 3G decrypt (UEA2), then verify auth */
13574 TEST_CASE_ST(ut_setup, ut_teardown,
13575 test_snow3g_auth_cipher_verify_test_case_1),
13576 TEST_CASE_ST(ut_setup, ut_teardown,
13577 test_snow3g_auth_cipher_verify_test_case_2),
13578 TEST_CASE_ST(ut_setup, ut_teardown,
13579 test_snow3g_auth_cipher_verify_test_case_2_oop),
13580 TEST_CASE_ST(ut_setup, ut_teardown,
13581 test_snow3g_auth_cipher_verify_part_digest_enc),
13582 TEST_CASE_ST(ut_setup, ut_teardown,
13583 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13584 TEST_CASE_ST(ut_setup, ut_teardown,
13585 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13586 TEST_CASE_ST(ut_setup, ut_teardown,
13587 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13588 TEST_CASE_ST(ut_setup, ut_teardown,
13589 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13590 TEST_CASE_ST(ut_setup, ut_teardown,
13591 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13593 /** SNOW 3G decrypt only (UEA2) */
13594 TEST_CASE_ST(ut_setup, ut_teardown,
13595 test_snow3g_decryption_test_case_1),
13596 TEST_CASE_ST(ut_setup, ut_teardown,
13597 test_snow3g_decryption_test_case_2),
13598 TEST_CASE_ST(ut_setup, ut_teardown,
13599 test_snow3g_decryption_test_case_3),
13600 TEST_CASE_ST(ut_setup, ut_teardown,
13601 test_snow3g_decryption_test_case_4),
13602 TEST_CASE_ST(ut_setup, ut_teardown,
13603 test_snow3g_decryption_test_case_5),
13604 TEST_CASE_ST(ut_setup, ut_teardown,
13605 test_snow3g_decryption_with_digest_test_case_1),
13606 TEST_CASE_ST(ut_setup, ut_teardown,
13607 test_snow3g_hash_generate_test_case_1),
13608 TEST_CASE_ST(ut_setup, ut_teardown,
13609 test_snow3g_hash_generate_test_case_2),
13610 TEST_CASE_ST(ut_setup, ut_teardown,
13611 test_snow3g_hash_generate_test_case_3),
13612 /* Tests with buffers which length is not byte-aligned */
13613 TEST_CASE_ST(ut_setup, ut_teardown,
13614 test_snow3g_hash_generate_test_case_4),
13615 TEST_CASE_ST(ut_setup, ut_teardown,
13616 test_snow3g_hash_generate_test_case_5),
13617 TEST_CASE_ST(ut_setup, ut_teardown,
13618 test_snow3g_hash_generate_test_case_6),
13619 TEST_CASE_ST(ut_setup, ut_teardown,
13620 test_snow3g_hash_verify_test_case_1),
13621 TEST_CASE_ST(ut_setup, ut_teardown,
13622 test_snow3g_hash_verify_test_case_2),
13623 TEST_CASE_ST(ut_setup, ut_teardown,
13624 test_snow3g_hash_verify_test_case_3),
13625 /* Tests with buffers which length is not byte-aligned */
13626 TEST_CASE_ST(ut_setup, ut_teardown,
13627 test_snow3g_hash_verify_test_case_4),
13628 TEST_CASE_ST(ut_setup, ut_teardown,
13629 test_snow3g_hash_verify_test_case_5),
13630 TEST_CASE_ST(ut_setup, ut_teardown,
13631 test_snow3g_hash_verify_test_case_6),
13632 TEST_CASE_ST(ut_setup, ut_teardown,
13633 test_snow3g_cipher_auth_test_case_1),
13634 TEST_CASE_ST(ut_setup, ut_teardown,
13635 test_snow3g_auth_cipher_with_digest_test_case_1),
13637 /** ZUC encrypt only (EEA3) */
13638 TEST_CASE_ST(ut_setup, ut_teardown,
13639 test_zuc_encryption_test_case_1),
13640 TEST_CASE_ST(ut_setup, ut_teardown,
13641 test_zuc_encryption_test_case_2),
13642 TEST_CASE_ST(ut_setup, ut_teardown,
13643 test_zuc_encryption_test_case_3),
13644 TEST_CASE_ST(ut_setup, ut_teardown,
13645 test_zuc_encryption_test_case_4),
13646 TEST_CASE_ST(ut_setup, ut_teardown,
13647 test_zuc_encryption_test_case_5),
13648 TEST_CASE_ST(ut_setup, ut_teardown,
13649 test_zuc_encryption_test_case_6_sgl),
13651 /** ZUC authenticate (EIA3) */
13652 TEST_CASE_ST(ut_setup, ut_teardown,
13653 test_zuc_hash_generate_test_case_1),
13654 TEST_CASE_ST(ut_setup, ut_teardown,
13655 test_zuc_hash_generate_test_case_2),
13656 TEST_CASE_ST(ut_setup, ut_teardown,
13657 test_zuc_hash_generate_test_case_3),
13658 TEST_CASE_ST(ut_setup, ut_teardown,
13659 test_zuc_hash_generate_test_case_4),
13660 TEST_CASE_ST(ut_setup, ut_teardown,
13661 test_zuc_hash_generate_test_case_5),
13662 TEST_CASE_ST(ut_setup, ut_teardown,
13663 test_zuc_hash_generate_test_case_6),
13664 TEST_CASE_ST(ut_setup, ut_teardown,
13665 test_zuc_hash_generate_test_case_7),
13666 TEST_CASE_ST(ut_setup, ut_teardown,
13667 test_zuc_hash_generate_test_case_8),
13669 /** ZUC alg-chain (EEA3/EIA3) */
13670 TEST_CASE_ST(ut_setup, ut_teardown,
13671 test_zuc_cipher_auth_test_case_1),
13672 TEST_CASE_ST(ut_setup, ut_teardown,
13673 test_zuc_cipher_auth_test_case_2),
13675 /** ZUC generate auth, then encrypt (EEA3) */
13676 TEST_CASE_ST(ut_setup, ut_teardown,
13677 test_zuc_auth_cipher_test_case_1),
13678 TEST_CASE_ST(ut_setup, ut_teardown,
13679 test_zuc_auth_cipher_test_case_1_oop),
13680 TEST_CASE_ST(ut_setup, ut_teardown,
13681 test_zuc_auth_cipher_test_case_1_sgl),
13682 TEST_CASE_ST(ut_setup, ut_teardown,
13683 test_zuc_auth_cipher_test_case_1_oop_sgl),
13685 /** ZUC decrypt (EEA3), then verify auth */
13686 TEST_CASE_ST(ut_setup, ut_teardown,
13687 test_zuc_auth_cipher_verify_test_case_1),
13688 TEST_CASE_ST(ut_setup, ut_teardown,
13689 test_zuc_auth_cipher_verify_test_case_1_oop),
13690 TEST_CASE_ST(ut_setup, ut_teardown,
13691 test_zuc_auth_cipher_verify_test_case_1_sgl),
13692 TEST_CASE_ST(ut_setup, ut_teardown,
13693 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
13695 /** HMAC_MD5 Authentication */
13696 TEST_CASE_ST(ut_setup, ut_teardown,
13697 test_MD5_HMAC_generate_case_1),
13698 TEST_CASE_ST(ut_setup, ut_teardown,
13699 test_MD5_HMAC_verify_case_1),
13700 TEST_CASE_ST(ut_setup, ut_teardown,
13701 test_MD5_HMAC_generate_case_2),
13702 TEST_CASE_ST(ut_setup, ut_teardown,
13703 test_MD5_HMAC_verify_case_2),
13705 /** KASUMI hash only (UIA1) */
13706 TEST_CASE_ST(ut_setup, ut_teardown,
13707 test_kasumi_hash_generate_test_case_1),
13708 TEST_CASE_ST(ut_setup, ut_teardown,
13709 test_kasumi_hash_generate_test_case_2),
13710 TEST_CASE_ST(ut_setup, ut_teardown,
13711 test_kasumi_hash_generate_test_case_3),
13712 TEST_CASE_ST(ut_setup, ut_teardown,
13713 test_kasumi_hash_generate_test_case_4),
13714 TEST_CASE_ST(ut_setup, ut_teardown,
13715 test_kasumi_hash_generate_test_case_5),
13716 TEST_CASE_ST(ut_setup, ut_teardown,
13717 test_kasumi_hash_generate_test_case_6),
13719 TEST_CASE_ST(ut_setup, ut_teardown,
13720 test_kasumi_hash_verify_test_case_1),
13721 TEST_CASE_ST(ut_setup, ut_teardown,
13722 test_kasumi_hash_verify_test_case_2),
13723 TEST_CASE_ST(ut_setup, ut_teardown,
13724 test_kasumi_hash_verify_test_case_3),
13725 TEST_CASE_ST(ut_setup, ut_teardown,
13726 test_kasumi_hash_verify_test_case_4),
13727 TEST_CASE_ST(ut_setup, ut_teardown,
13728 test_kasumi_hash_verify_test_case_5),
13730 /** KASUMI encrypt only (UEA1) */
13731 TEST_CASE_ST(ut_setup, ut_teardown,
13732 test_kasumi_encryption_test_case_1),
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 test_kasumi_encryption_test_case_1_sgl),
13735 TEST_CASE_ST(ut_setup, ut_teardown,
13736 test_kasumi_encryption_test_case_1_oop),
13737 TEST_CASE_ST(ut_setup, ut_teardown,
13738 test_kasumi_encryption_test_case_1_oop_sgl),
13739 TEST_CASE_ST(ut_setup, ut_teardown,
13740 test_kasumi_encryption_test_case_2),
13741 TEST_CASE_ST(ut_setup, ut_teardown,
13742 test_kasumi_encryption_test_case_3),
13743 TEST_CASE_ST(ut_setup, ut_teardown,
13744 test_kasumi_encryption_test_case_4),
13745 TEST_CASE_ST(ut_setup, ut_teardown,
13746 test_kasumi_encryption_test_case_5),
13748 /** KASUMI decrypt only (UEA1) */
13749 TEST_CASE_ST(ut_setup, ut_teardown,
13750 test_kasumi_decryption_test_case_1),
13751 TEST_CASE_ST(ut_setup, ut_teardown,
13752 test_kasumi_decryption_test_case_2),
13753 TEST_CASE_ST(ut_setup, ut_teardown,
13754 test_kasumi_decryption_test_case_3),
13755 TEST_CASE_ST(ut_setup, ut_teardown,
13756 test_kasumi_decryption_test_case_4),
13757 TEST_CASE_ST(ut_setup, ut_teardown,
13758 test_kasumi_decryption_test_case_5),
13759 TEST_CASE_ST(ut_setup, ut_teardown,
13760 test_kasumi_decryption_test_case_1_oop),
13762 TEST_CASE_ST(ut_setup, ut_teardown,
13763 test_kasumi_cipher_auth_test_case_1),
13765 /** KASUMI generate auth, then encrypt (F8) */
13766 TEST_CASE_ST(ut_setup, ut_teardown,
13767 test_kasumi_auth_cipher_test_case_1),
13768 TEST_CASE_ST(ut_setup, ut_teardown,
13769 test_kasumi_auth_cipher_test_case_2),
13770 TEST_CASE_ST(ut_setup, ut_teardown,
13771 test_kasumi_auth_cipher_test_case_2_oop),
13772 TEST_CASE_ST(ut_setup, ut_teardown,
13773 test_kasumi_auth_cipher_test_case_2_sgl),
13774 TEST_CASE_ST(ut_setup, ut_teardown,
13775 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13777 /** KASUMI decrypt (F8), then verify auth */
13778 TEST_CASE_ST(ut_setup, ut_teardown,
13779 test_kasumi_auth_cipher_verify_test_case_1),
13780 TEST_CASE_ST(ut_setup, ut_teardown,
13781 test_kasumi_auth_cipher_verify_test_case_2),
13782 TEST_CASE_ST(ut_setup, ut_teardown,
13783 test_kasumi_auth_cipher_verify_test_case_2_oop),
13784 TEST_CASE_ST(ut_setup, ut_teardown,
13785 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13786 TEST_CASE_ST(ut_setup, ut_teardown,
13787 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13789 /** ESN Testcase */
13790 TEST_CASE_ST(ut_setup, ut_teardown,
13791 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13792 TEST_CASE_ST(ut_setup, ut_teardown,
13793 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13795 /** Negative tests */
13796 TEST_CASE_ST(ut_setup, ut_teardown,
13797 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13798 TEST_CASE_ST(ut_setup, ut_teardown,
13799 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13800 TEST_CASE_ST(ut_setup, ut_teardown,
13801 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13802 TEST_CASE_ST(ut_setup, ut_teardown,
13803 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13804 TEST_CASE_ST(ut_setup, ut_teardown,
13805 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13806 TEST_CASE_ST(ut_setup, ut_teardown,
13807 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13810 TEST_CASE_ST(ut_setup, ut_teardown,
13811 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13812 TEST_CASE_ST(ut_setup, ut_teardown,
13813 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13814 TEST_CASE_ST(ut_setup, ut_teardown,
13815 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13816 TEST_CASE_ST(ut_setup, ut_teardown,
13817 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13818 TEST_CASE_ST(ut_setup, ut_teardown,
13819 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13820 TEST_CASE_ST(ut_setup, ut_teardown,
13821 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13822 TEST_CASE_ST(ut_setup, ut_teardown,
13823 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13824 TEST_CASE_ST(ut_setup, ut_teardown,
13825 authentication_verify_AES128_GMAC_fail_data_corrupt),
13826 TEST_CASE_ST(ut_setup, ut_teardown,
13827 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13828 TEST_CASE_ST(ut_setup, ut_teardown,
13829 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13830 TEST_CASE_ST(ut_setup, ut_teardown,
13831 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13833 /** Mixed CIPHER + HASH algorithms */
13834 /** AUTH AES CMAC + CIPHER AES CTR */
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
13837 TEST_CASE_ST(ut_setup, ut_teardown,
13838 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13839 TEST_CASE_ST(ut_setup, ut_teardown,
13840 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13841 TEST_CASE_ST(ut_setup, ut_teardown,
13842 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13843 TEST_CASE_ST(ut_setup, ut_teardown,
13844 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
13845 TEST_CASE_ST(ut_setup, ut_teardown,
13846 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13847 TEST_CASE_ST(ut_setup, ut_teardown,
13848 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13849 TEST_CASE_ST(ut_setup, ut_teardown,
13850 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13852 /** AUTH ZUC + CIPHER SNOW3G */
13853 TEST_CASE_ST(ut_setup, ut_teardown,
13854 test_auth_zuc_cipher_snow_test_case_1),
13855 TEST_CASE_ST(ut_setup, ut_teardown,
13856 test_verify_auth_zuc_cipher_snow_test_case_1),
13857 /** AUTH AES CMAC + CIPHER SNOW3G */
13858 TEST_CASE_ST(ut_setup, ut_teardown,
13859 test_auth_aes_cmac_cipher_snow_test_case_1),
13860 TEST_CASE_ST(ut_setup, ut_teardown,
13861 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
13862 /** AUTH ZUC + CIPHER AES CTR */
13863 TEST_CASE_ST(ut_setup, ut_teardown,
13864 test_auth_zuc_cipher_aes_ctr_test_case_1),
13865 TEST_CASE_ST(ut_setup, ut_teardown,
13866 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
13867 /** AUTH SNOW3G + CIPHER AES CTR */
13868 TEST_CASE_ST(ut_setup, ut_teardown,
13869 test_auth_snow_cipher_aes_ctr_test_case_1),
13870 TEST_CASE_ST(ut_setup, ut_teardown,
13871 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
13872 /** AUTH SNOW3G + CIPHER ZUC */
13873 TEST_CASE_ST(ut_setup, ut_teardown,
13874 test_auth_snow_cipher_zuc_test_case_1),
13875 TEST_CASE_ST(ut_setup, ut_teardown,
13876 test_verify_auth_snow_cipher_zuc_test_case_1),
13877 /** AUTH AES CMAC + CIPHER ZUC */
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_auth_aes_cmac_cipher_zuc_test_case_1),
13880 TEST_CASE_ST(ut_setup, ut_teardown,
13881 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
13883 /** AUTH NULL + CIPHER SNOW3G */
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_auth_null_cipher_snow_test_case_1),
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_verify_auth_null_cipher_snow_test_case_1),
13888 /** AUTH NULL + CIPHER ZUC */
13889 TEST_CASE_ST(ut_setup, ut_teardown,
13890 test_auth_null_cipher_zuc_test_case_1),
13891 TEST_CASE_ST(ut_setup, ut_teardown,
13892 test_verify_auth_null_cipher_zuc_test_case_1),
13893 /** AUTH SNOW3G + CIPHER NULL */
13894 TEST_CASE_ST(ut_setup, ut_teardown,
13895 test_auth_snow_cipher_null_test_case_1),
13896 TEST_CASE_ST(ut_setup, ut_teardown,
13897 test_verify_auth_snow_cipher_null_test_case_1),
13898 /** AUTH ZUC + CIPHER NULL */
13899 TEST_CASE_ST(ut_setup, ut_teardown,
13900 test_auth_zuc_cipher_null_test_case_1),
13901 TEST_CASE_ST(ut_setup, ut_teardown,
13902 test_verify_auth_zuc_cipher_null_test_case_1),
13903 /** AUTH NULL + CIPHER AES CTR */
13904 TEST_CASE_ST(ut_setup, ut_teardown,
13905 test_auth_null_cipher_aes_ctr_test_case_1),
13906 TEST_CASE_ST(ut_setup, ut_teardown,
13907 test_verify_auth_null_cipher_aes_ctr_test_case_1),
13908 /** AUTH AES CMAC + CIPHER NULL */
13909 TEST_CASE_ST(ut_setup, ut_teardown,
13910 test_auth_aes_cmac_cipher_null_test_case_1),
13911 TEST_CASE_ST(ut_setup, ut_teardown,
13912 test_verify_auth_aes_cmac_cipher_null_test_case_1),
13914 #ifdef RTE_LIB_SECURITY
13915 TEST_CASE_ST(ut_setup_security, ut_teardown,
13916 test_PDCP_PROTO_all),
13917 TEST_CASE_ST(ut_setup_security, ut_teardown,
13918 test_DOCSIS_PROTO_all),
13920 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13921 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13922 TEST_CASES_END() /**< NULL terminate unit test array */
13926 static struct unit_test_suite cryptodev_virtio_testsuite = {
13927 .suite_name = "Crypto VIRTIO Unit Test Suite",
13928 .setup = testsuite_setup,
13929 .teardown = testsuite_teardown,
13930 .unit_test_cases = {
13931 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13933 TEST_CASES_END() /**< NULL terminate unit test array */
13937 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13938 .suite_name = "Crypto CAAM JR Unit Test Suite",
13939 .setup = testsuite_setup,
13940 .teardown = testsuite_teardown,
13941 .unit_test_cases = {
13942 TEST_CASE_ST(ut_setup, ut_teardown,
13943 test_device_configure_invalid_dev_id),
13944 TEST_CASE_ST(ut_setup, ut_teardown,
13945 test_multi_session),
13947 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13948 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13949 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13950 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13951 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13953 TEST_CASES_END() /**< NULL terminate unit test array */
13957 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13958 .suite_name = "Crypto Device Marvell Component Test Suite",
13959 .setup = testsuite_setup,
13960 .teardown = testsuite_teardown,
13961 .unit_test_cases = {
13962 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13963 TEST_CASE_ST(ut_setup, ut_teardown,
13964 test_multi_session_random_usage),
13965 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13966 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13967 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13968 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13969 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13971 /** Negative tests */
13972 TEST_CASE_ST(ut_setup, ut_teardown,
13973 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13974 TEST_CASE_ST(ut_setup, ut_teardown,
13975 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13976 TEST_CASE_ST(ut_setup, ut_teardown,
13977 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13978 TEST_CASE_ST(ut_setup, ut_teardown,
13979 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13981 TEST_CASES_END() /**< NULL terminate unit test array */
13985 static struct unit_test_suite cryptodev_ccp_testsuite = {
13986 .suite_name = "Crypto Device CCP Unit Test Suite",
13987 .setup = testsuite_setup,
13988 .teardown = testsuite_teardown,
13989 .unit_test_cases = {
13990 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13991 TEST_CASE_ST(ut_setup, ut_teardown,
13992 test_multi_session_random_usage),
13993 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13994 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13995 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13996 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13997 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13999 /** Negative tests */
14000 TEST_CASE_ST(ut_setup, ut_teardown,
14001 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14002 TEST_CASE_ST(ut_setup, ut_teardown,
14003 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14004 TEST_CASE_ST(ut_setup, ut_teardown,
14005 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14006 TEST_CASE_ST(ut_setup, ut_teardown,
14007 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14009 TEST_CASES_END() /**< NULL terminate unit test array */
14014 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14016 gbl_driver_id = rte_cryptodev_driver_id_get(
14017 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14019 if (gbl_driver_id == -1) {
14020 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14021 return TEST_SKIPPED;
14024 return unit_test_suite_runner(&cryptodev_testsuite);
14028 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14030 gbl_driver_id = rte_cryptodev_driver_id_get(
14031 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14033 if (gbl_driver_id == -1) {
14034 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
14035 return TEST_FAILED;
14038 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14042 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14044 gbl_driver_id = rte_cryptodev_driver_id_get(
14045 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14047 if (gbl_driver_id == -1) {
14048 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14049 return TEST_SKIPPED;
14052 return unit_test_suite_runner(&cryptodev_testsuite);
14056 test_cryptodev_cpu_aesni_mb(void)
14059 enum rte_security_session_action_type at;
14061 gbl_driver_id = rte_cryptodev_driver_id_get(
14062 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14064 if (gbl_driver_id == -1) {
14065 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14066 return TEST_SKIPPED;
14069 at = gbl_action_type;
14070 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14071 rc = unit_test_suite_runner(&cryptodev_testsuite);
14072 gbl_action_type = at;
14077 test_cryptodev_openssl(void)
14079 gbl_driver_id = rte_cryptodev_driver_id_get(
14080 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14082 if (gbl_driver_id == -1) {
14083 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
14084 return TEST_SKIPPED;
14087 return unit_test_suite_runner(&cryptodev_testsuite);
14091 test_cryptodev_aesni_gcm(void)
14093 gbl_driver_id = rte_cryptodev_driver_id_get(
14094 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14096 if (gbl_driver_id == -1) {
14097 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14098 return TEST_SKIPPED;
14101 return unit_test_suite_runner(&cryptodev_testsuite);
14105 test_cryptodev_cpu_aesni_gcm(void)
14108 enum rte_security_session_action_type at;
14110 gbl_driver_id = rte_cryptodev_driver_id_get(
14111 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14113 if (gbl_driver_id == -1) {
14114 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14115 return TEST_SKIPPED;
14118 at = gbl_action_type;
14119 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14120 rc = unit_test_suite_runner(&cryptodev_testsuite);
14121 gbl_action_type = at;
14126 test_cryptodev_null(void)
14128 gbl_driver_id = rte_cryptodev_driver_id_get(
14129 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14131 if (gbl_driver_id == -1) {
14132 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
14133 return TEST_SKIPPED;
14136 return unit_test_suite_runner(&cryptodev_testsuite);
14140 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14142 gbl_driver_id = rte_cryptodev_driver_id_get(
14143 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14145 if (gbl_driver_id == -1) {
14146 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
14147 return TEST_SKIPPED;
14150 return unit_test_suite_runner(&cryptodev_testsuite);
14154 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14156 gbl_driver_id = rte_cryptodev_driver_id_get(
14157 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14159 if (gbl_driver_id == -1) {
14160 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14161 return TEST_SKIPPED;
14164 return unit_test_suite_runner(&cryptodev_testsuite);
14168 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14170 gbl_driver_id = rte_cryptodev_driver_id_get(
14171 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14173 if (gbl_driver_id == -1) {
14174 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14175 return TEST_SKIPPED;
14178 return unit_test_suite_runner(&cryptodev_testsuite);
14182 test_cryptodev_armv8(void)
14184 gbl_driver_id = rte_cryptodev_driver_id_get(
14185 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14187 if (gbl_driver_id == -1) {
14188 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
14189 return TEST_SKIPPED;
14192 return unit_test_suite_runner(&cryptodev_testsuite);
14196 test_cryptodev_mrvl(void)
14198 gbl_driver_id = rte_cryptodev_driver_id_get(
14199 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14201 if (gbl_driver_id == -1) {
14202 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
14203 return TEST_SKIPPED;
14206 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14209 #ifdef RTE_CRYPTO_SCHEDULER
14212 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14214 gbl_driver_id = rte_cryptodev_driver_id_get(
14215 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14217 if (gbl_driver_id == -1) {
14218 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14219 return TEST_SKIPPED;
14222 if (rte_cryptodev_driver_id_get(
14223 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14224 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14225 return TEST_SKIPPED;
14227 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14230 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14235 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14237 gbl_driver_id = rte_cryptodev_driver_id_get(
14238 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14240 if (gbl_driver_id == -1) {
14241 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
14242 return TEST_SKIPPED;
14245 return unit_test_suite_runner(&cryptodev_testsuite);
14249 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14251 gbl_driver_id = rte_cryptodev_driver_id_get(
14252 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14254 if (gbl_driver_id == -1) {
14255 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
14256 return TEST_SKIPPED;
14259 return unit_test_suite_runner(&cryptodev_testsuite);
14263 test_cryptodev_ccp(void)
14265 gbl_driver_id = rte_cryptodev_driver_id_get(
14266 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14268 if (gbl_driver_id == -1) {
14269 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
14270 return TEST_FAILED;
14273 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14277 test_cryptodev_octeontx(void)
14279 gbl_driver_id = rte_cryptodev_driver_id_get(
14280 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14281 if (gbl_driver_id == -1) {
14282 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
14283 return TEST_FAILED;
14285 return unit_test_suite_runner(&cryptodev_testsuite);
14289 test_cryptodev_octeontx2(void)
14291 gbl_driver_id = rte_cryptodev_driver_id_get(
14292 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14293 if (gbl_driver_id == -1) {
14294 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
14295 return TEST_FAILED;
14297 return unit_test_suite_runner(&cryptodev_testsuite);
14301 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14303 gbl_driver_id = rte_cryptodev_driver_id_get(
14304 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14306 if (gbl_driver_id == -1) {
14307 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
14308 return TEST_FAILED;
14311 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14315 test_cryptodev_nitrox(void)
14317 gbl_driver_id = rte_cryptodev_driver_id_get(
14318 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14320 if (gbl_driver_id == -1) {
14321 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
14322 return TEST_FAILED;
14325 return unit_test_suite_runner(&cryptodev_testsuite);
14329 test_cryptodev_bcmfs(void)
14331 gbl_driver_id = rte_cryptodev_driver_id_get(
14332 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14334 if (gbl_driver_id == -1) {
14335 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
14336 return TEST_FAILED;
14339 return unit_test_suite_runner(&cryptodev_testsuite);
14343 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14347 gbl_driver_id = rte_cryptodev_driver_id_get(
14348 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14350 if (gbl_driver_id == -1) {
14351 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14352 return TEST_SKIPPED;
14355 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14356 ret = unit_test_suite_runner(&cryptodev_testsuite);
14357 global_api_test_type = CRYPTODEV_API_TEST;
14362 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14363 test_cryptodev_qat_raw_api);
14364 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14365 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14366 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14367 test_cryptodev_cpu_aesni_mb);
14368 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14369 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14370 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14371 test_cryptodev_cpu_aesni_gcm);
14372 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14373 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14374 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14375 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14376 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14377 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14378 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14379 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14380 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14381 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14382 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14383 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14384 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14385 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14386 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);