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 /* Only copy over the offset data needed from src to dst in OOP,
2633 * if the auth and cipher offsets are not aligned
2635 if (op_mode == OUT_OF_PLACE) {
2636 if (cipher_offset > auth_offset)
2638 rte_pktmbuf_mtod_offset(
2640 uint8_t *, auth_offset >> 3),
2641 rte_pktmbuf_mtod_offset(
2643 uint8_t *, auth_offset >> 3),
2644 ((cipher_offset >> 3) - (auth_offset >> 3)));
2647 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2648 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2649 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2650 sym_op->cipher.data.length = cipher_len;
2651 sym_op->cipher.data.offset = cipher_offset;
2653 sym_op->cipher.data.length = cipher_len >> 3;
2654 sym_op->cipher.data.offset = cipher_offset >> 3;
2657 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2658 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2659 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2660 sym_op->auth.data.length = auth_len;
2661 sym_op->auth.data.offset = auth_offset;
2663 sym_op->auth.data.length = auth_len >> 3;
2664 sym_op->auth.data.offset = auth_offset >> 3;
2671 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2673 struct crypto_testsuite_params *ts_params = &testsuite_params;
2674 struct crypto_unittest_params *ut_params = &unittest_params;
2677 unsigned plaintext_pad_len;
2678 unsigned plaintext_len;
2680 struct rte_cryptodev_info dev_info;
2682 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2683 uint64_t feat_flags = dev_info.feature_flags;
2685 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2686 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2687 printf("Device doesn't support NON-Byte Aligned Data.\n");
2691 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2692 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2693 printf("Device doesn't support RAW data-path APIs.\n");
2697 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2700 /* Verify the capabilities */
2701 struct rte_cryptodev_sym_capability_idx cap_idx;
2702 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2703 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2704 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2708 /* Create SNOW 3G session */
2709 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2710 tdata->key.data, tdata->key.len,
2711 tdata->auth_iv.len, tdata->digest.len,
2712 RTE_CRYPTO_AUTH_OP_GENERATE,
2713 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2717 /* alloc mbuf and set payload */
2718 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2720 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2721 rte_pktmbuf_tailroom(ut_params->ibuf));
2723 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2724 /* Append data which is padded to a multiple of */
2725 /* the algorithms block size */
2726 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2727 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2729 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2731 /* Create SNOW 3G operation */
2732 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2733 tdata->auth_iv.data, tdata->auth_iv.len,
2734 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2735 tdata->validAuthLenInBits.len,
2740 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2741 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2742 ut_params->op, 0, 1, 1, 0);
2744 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2746 ut_params->obuf = ut_params->op->sym->m_src;
2747 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2748 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2749 + plaintext_pad_len;
2752 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2755 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2756 "SNOW 3G Generated auth tag not as expected");
2762 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2764 struct crypto_testsuite_params *ts_params = &testsuite_params;
2765 struct crypto_unittest_params *ut_params = &unittest_params;
2768 unsigned plaintext_pad_len;
2769 unsigned plaintext_len;
2771 struct rte_cryptodev_info dev_info;
2773 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2774 uint64_t feat_flags = dev_info.feature_flags;
2776 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2777 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2778 printf("Device doesn't support NON-Byte Aligned Data.\n");
2782 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2783 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2784 printf("Device doesn't support RAW data-path APIs.\n");
2788 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2791 /* Verify the capabilities */
2792 struct rte_cryptodev_sym_capability_idx cap_idx;
2793 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2794 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2795 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2799 /* Create SNOW 3G session */
2800 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2801 tdata->key.data, tdata->key.len,
2802 tdata->auth_iv.len, tdata->digest.len,
2803 RTE_CRYPTO_AUTH_OP_VERIFY,
2804 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2807 /* alloc mbuf and set payload */
2808 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2810 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2811 rte_pktmbuf_tailroom(ut_params->ibuf));
2813 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2814 /* Append data which is padded to a multiple of */
2815 /* the algorithms block size */
2816 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2817 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2819 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2821 /* Create SNOW 3G operation */
2822 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2824 tdata->auth_iv.data, tdata->auth_iv.len,
2826 RTE_CRYPTO_AUTH_OP_VERIFY,
2827 tdata->validAuthLenInBits.len,
2832 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2833 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2834 ut_params->op, 0, 1, 1, 0);
2836 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2838 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2839 ut_params->obuf = ut_params->op->sym->m_src;
2840 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2841 + plaintext_pad_len;
2844 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2853 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2855 struct crypto_testsuite_params *ts_params = &testsuite_params;
2856 struct crypto_unittest_params *ut_params = &unittest_params;
2859 unsigned plaintext_pad_len;
2860 unsigned plaintext_len;
2862 struct rte_cryptodev_info dev_info;
2864 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2865 uint64_t feat_flags = dev_info.feature_flags;
2867 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2868 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2869 printf("Device doesn't support RAW data-path APIs.\n");
2873 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2876 /* Verify the capabilities */
2877 struct rte_cryptodev_sym_capability_idx cap_idx;
2878 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2879 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2880 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2884 /* Create KASUMI session */
2885 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2886 tdata->key.data, tdata->key.len,
2887 0, tdata->digest.len,
2888 RTE_CRYPTO_AUTH_OP_GENERATE,
2889 RTE_CRYPTO_AUTH_KASUMI_F9);
2893 /* alloc mbuf and set payload */
2894 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2896 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2897 rte_pktmbuf_tailroom(ut_params->ibuf));
2899 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2900 /* Append data which is padded to a multiple of */
2901 /* the algorithms block size */
2902 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2903 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2905 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2907 /* Create KASUMI operation */
2908 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2910 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2911 tdata->plaintext.len,
2916 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2917 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2919 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2920 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2921 ut_params->op, 0, 1, 1, 0);
2923 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2926 ut_params->obuf = ut_params->op->sym->m_src;
2927 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2928 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2929 + plaintext_pad_len;
2932 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2935 DIGEST_BYTE_LENGTH_KASUMI_F9,
2936 "KASUMI Generated auth tag not as expected");
2942 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2944 struct crypto_testsuite_params *ts_params = &testsuite_params;
2945 struct crypto_unittest_params *ut_params = &unittest_params;
2948 unsigned plaintext_pad_len;
2949 unsigned plaintext_len;
2951 struct rte_cryptodev_info dev_info;
2953 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2954 uint64_t feat_flags = dev_info.feature_flags;
2956 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2957 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2958 printf("Device doesn't support RAW data-path APIs.\n");
2962 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2965 /* Verify the capabilities */
2966 struct rte_cryptodev_sym_capability_idx cap_idx;
2967 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2968 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2969 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2973 /* Create KASUMI session */
2974 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2975 tdata->key.data, tdata->key.len,
2976 0, tdata->digest.len,
2977 RTE_CRYPTO_AUTH_OP_VERIFY,
2978 RTE_CRYPTO_AUTH_KASUMI_F9);
2981 /* alloc mbuf and set payload */
2982 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2984 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2985 rte_pktmbuf_tailroom(ut_params->ibuf));
2987 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2988 /* Append data which is padded to a multiple */
2989 /* of the algorithms block size */
2990 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2991 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2993 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2995 /* Create KASUMI operation */
2996 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3000 RTE_CRYPTO_AUTH_OP_VERIFY,
3001 tdata->plaintext.len,
3006 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3007 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3008 ut_params->op, 0, 1, 1, 0);
3010 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3012 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3013 ut_params->obuf = ut_params->op->sym->m_src;
3014 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3015 + plaintext_pad_len;
3018 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3027 test_snow3g_hash_generate_test_case_1(void)
3029 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3033 test_snow3g_hash_generate_test_case_2(void)
3035 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3039 test_snow3g_hash_generate_test_case_3(void)
3041 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3045 test_snow3g_hash_generate_test_case_4(void)
3047 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3051 test_snow3g_hash_generate_test_case_5(void)
3053 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3057 test_snow3g_hash_generate_test_case_6(void)
3059 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3063 test_snow3g_hash_verify_test_case_1(void)
3065 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3070 test_snow3g_hash_verify_test_case_2(void)
3072 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3076 test_snow3g_hash_verify_test_case_3(void)
3078 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3082 test_snow3g_hash_verify_test_case_4(void)
3084 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3088 test_snow3g_hash_verify_test_case_5(void)
3090 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3094 test_snow3g_hash_verify_test_case_6(void)
3096 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3100 test_kasumi_hash_generate_test_case_1(void)
3102 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3106 test_kasumi_hash_generate_test_case_2(void)
3108 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3112 test_kasumi_hash_generate_test_case_3(void)
3114 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3118 test_kasumi_hash_generate_test_case_4(void)
3120 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3124 test_kasumi_hash_generate_test_case_5(void)
3126 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3130 test_kasumi_hash_generate_test_case_6(void)
3132 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3136 test_kasumi_hash_verify_test_case_1(void)
3138 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3142 test_kasumi_hash_verify_test_case_2(void)
3144 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3148 test_kasumi_hash_verify_test_case_3(void)
3150 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3154 test_kasumi_hash_verify_test_case_4(void)
3156 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3160 test_kasumi_hash_verify_test_case_5(void)
3162 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3166 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3168 struct crypto_testsuite_params *ts_params = &testsuite_params;
3169 struct crypto_unittest_params *ut_params = &unittest_params;
3172 uint8_t *plaintext, *ciphertext;
3173 unsigned plaintext_pad_len;
3174 unsigned plaintext_len;
3175 struct rte_cryptodev_info dev_info;
3177 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3178 uint64_t feat_flags = dev_info.feature_flags;
3180 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3181 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3182 printf("Device doesn't support RAW data-path APIs.\n");
3186 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3189 /* Verify the capabilities */
3190 struct rte_cryptodev_sym_capability_idx cap_idx;
3191 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3192 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3193 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3197 /* Create KASUMI session */
3198 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3199 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3200 RTE_CRYPTO_CIPHER_KASUMI_F8,
3201 tdata->key.data, tdata->key.len,
3202 tdata->cipher_iv.len);
3206 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3208 /* Clear mbuf payload */
3209 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3210 rte_pktmbuf_tailroom(ut_params->ibuf));
3212 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3213 /* Append data which is padded to a multiple */
3214 /* of the algorithms block size */
3215 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3216 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3218 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3220 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3222 /* Create KASUMI operation */
3223 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3224 tdata->cipher_iv.len,
3225 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3226 tdata->validCipherOffsetInBits.len);
3230 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3231 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3232 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3236 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3238 ut_params->obuf = ut_params->op->sym->m_dst;
3239 if (ut_params->obuf)
3240 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3242 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3244 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3246 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3247 (tdata->validCipherOffsetInBits.len >> 3);
3249 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3251 reference_ciphertext,
3252 tdata->validCipherLenInBits.len,
3253 "KASUMI Ciphertext data not as expected");
3258 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3260 struct crypto_testsuite_params *ts_params = &testsuite_params;
3261 struct crypto_unittest_params *ut_params = &unittest_params;
3265 unsigned int plaintext_pad_len;
3266 unsigned int plaintext_len;
3268 uint8_t buffer[10000];
3269 const uint8_t *ciphertext;
3271 struct rte_cryptodev_info dev_info;
3273 /* Verify the capabilities */
3274 struct rte_cryptodev_sym_capability_idx cap_idx;
3275 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3276 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3277 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3281 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3283 uint64_t feat_flags = dev_info.feature_flags;
3285 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3286 printf("Device doesn't support in-place scatter-gather. "
3291 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3292 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3293 printf("Device doesn't support RAW data-path APIs.\n");
3297 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3300 /* Create KASUMI session */
3301 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3302 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3303 RTE_CRYPTO_CIPHER_KASUMI_F8,
3304 tdata->key.data, tdata->key.len,
3305 tdata->cipher_iv.len);
3309 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3312 /* Append data which is padded to a multiple */
3313 /* of the algorithms block size */
3314 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3316 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3317 plaintext_pad_len, 10, 0);
3319 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3321 /* Create KASUMI operation */
3322 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3323 tdata->cipher_iv.len,
3324 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3325 tdata->validCipherOffsetInBits.len);
3329 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3330 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3331 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3333 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3335 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3337 ut_params->obuf = ut_params->op->sym->m_dst;
3339 if (ut_params->obuf)
3340 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3341 plaintext_len, buffer);
3343 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3344 tdata->validCipherOffsetInBits.len >> 3,
3345 plaintext_len, buffer);
3348 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3350 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3351 (tdata->validCipherOffsetInBits.len >> 3);
3353 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3355 reference_ciphertext,
3356 tdata->validCipherLenInBits.len,
3357 "KASUMI Ciphertext data not as expected");
3362 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3364 struct crypto_testsuite_params *ts_params = &testsuite_params;
3365 struct crypto_unittest_params *ut_params = &unittest_params;
3368 uint8_t *plaintext, *ciphertext;
3369 unsigned plaintext_pad_len;
3370 unsigned plaintext_len;
3372 /* Verify the capabilities */
3373 struct rte_cryptodev_sym_capability_idx cap_idx;
3374 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3375 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3376 /* Data-path service does not support OOP */
3377 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3381 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3384 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3387 /* Create KASUMI session */
3388 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3389 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3390 RTE_CRYPTO_CIPHER_KASUMI_F8,
3391 tdata->key.data, tdata->key.len,
3392 tdata->cipher_iv.len);
3396 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3397 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3399 /* Clear mbuf payload */
3400 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3401 rte_pktmbuf_tailroom(ut_params->ibuf));
3403 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3404 /* Append data which is padded to a multiple */
3405 /* of the algorithms block size */
3406 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3407 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3409 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3410 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3412 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3414 /* Create KASUMI operation */
3415 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3416 tdata->cipher_iv.len,
3417 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3418 tdata->validCipherOffsetInBits.len);
3422 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3424 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3426 ut_params->obuf = ut_params->op->sym->m_dst;
3427 if (ut_params->obuf)
3428 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3430 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3432 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3434 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3435 (tdata->validCipherOffsetInBits.len >> 3);
3437 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3439 reference_ciphertext,
3440 tdata->validCipherLenInBits.len,
3441 "KASUMI Ciphertext data not as expected");
3446 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3448 struct crypto_testsuite_params *ts_params = &testsuite_params;
3449 struct crypto_unittest_params *ut_params = &unittest_params;
3452 unsigned int plaintext_pad_len;
3453 unsigned int plaintext_len;
3455 const uint8_t *ciphertext;
3456 uint8_t buffer[2048];
3458 struct rte_cryptodev_info dev_info;
3460 /* Verify the capabilities */
3461 struct rte_cryptodev_sym_capability_idx cap_idx;
3462 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3463 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3464 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3468 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3471 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3474 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3476 uint64_t feat_flags = dev_info.feature_flags;
3477 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3478 printf("Device doesn't support out-of-place scatter-gather "
3479 "in both input and output mbufs. "
3484 /* Create KASUMI session */
3485 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3486 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3487 RTE_CRYPTO_CIPHER_KASUMI_F8,
3488 tdata->key.data, tdata->key.len,
3489 tdata->cipher_iv.len);
3493 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3494 /* Append data which is padded to a multiple */
3495 /* of the algorithms block size */
3496 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3498 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3499 plaintext_pad_len, 10, 0);
3500 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3501 plaintext_pad_len, 3, 0);
3503 /* Append data which is padded to a multiple */
3504 /* of the algorithms block size */
3505 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3507 /* Create KASUMI operation */
3508 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3509 tdata->cipher_iv.len,
3510 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3511 tdata->validCipherOffsetInBits.len);
3515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3517 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3519 ut_params->obuf = ut_params->op->sym->m_dst;
3520 if (ut_params->obuf)
3521 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3522 plaintext_pad_len, buffer);
3524 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3525 tdata->validCipherOffsetInBits.len >> 3,
3526 plaintext_pad_len, buffer);
3528 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3529 (tdata->validCipherOffsetInBits.len >> 3);
3531 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3533 reference_ciphertext,
3534 tdata->validCipherLenInBits.len,
3535 "KASUMI Ciphertext data not as expected");
3541 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3543 struct crypto_testsuite_params *ts_params = &testsuite_params;
3544 struct crypto_unittest_params *ut_params = &unittest_params;
3547 uint8_t *ciphertext, *plaintext;
3548 unsigned ciphertext_pad_len;
3549 unsigned ciphertext_len;
3551 /* Verify the capabilities */
3552 struct rte_cryptodev_sym_capability_idx cap_idx;
3553 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3554 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3555 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3559 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3562 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3565 /* Create KASUMI session */
3566 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3567 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3568 RTE_CRYPTO_CIPHER_KASUMI_F8,
3569 tdata->key.data, tdata->key.len,
3570 tdata->cipher_iv.len);
3574 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3575 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3577 /* Clear mbuf payload */
3578 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3579 rte_pktmbuf_tailroom(ut_params->ibuf));
3581 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3582 /* Append data which is padded to a multiple */
3583 /* of the algorithms block size */
3584 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3585 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3586 ciphertext_pad_len);
3587 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3588 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3590 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3592 /* Create KASUMI operation */
3593 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3594 tdata->cipher_iv.len,
3595 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3596 tdata->validCipherOffsetInBits.len);
3600 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3602 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3604 ut_params->obuf = ut_params->op->sym->m_dst;
3605 if (ut_params->obuf)
3606 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3608 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3610 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3612 const uint8_t *reference_plaintext = tdata->plaintext.data +
3613 (tdata->validCipherOffsetInBits.len >> 3);
3615 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3617 reference_plaintext,
3618 tdata->validCipherLenInBits.len,
3619 "KASUMI Plaintext data not as expected");
3624 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3626 struct crypto_testsuite_params *ts_params = &testsuite_params;
3627 struct crypto_unittest_params *ut_params = &unittest_params;
3630 uint8_t *ciphertext, *plaintext;
3631 unsigned ciphertext_pad_len;
3632 unsigned ciphertext_len;
3633 struct rte_cryptodev_info dev_info;
3635 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3636 uint64_t feat_flags = dev_info.feature_flags;
3638 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3639 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3640 printf("Device doesn't support RAW data-path APIs.\n");
3644 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3647 /* Verify the capabilities */
3648 struct rte_cryptodev_sym_capability_idx cap_idx;
3649 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3650 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3651 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3655 /* Create KASUMI session */
3656 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3657 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3658 RTE_CRYPTO_CIPHER_KASUMI_F8,
3659 tdata->key.data, tdata->key.len,
3660 tdata->cipher_iv.len);
3664 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3666 /* Clear mbuf payload */
3667 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3668 rte_pktmbuf_tailroom(ut_params->ibuf));
3670 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3671 /* Append data which is padded to a multiple */
3672 /* of the algorithms block size */
3673 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3674 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3675 ciphertext_pad_len);
3676 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3678 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3680 /* Create KASUMI operation */
3681 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3682 tdata->cipher_iv.len,
3683 tdata->ciphertext.len,
3684 tdata->validCipherOffsetInBits.len);
3688 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3689 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3690 ut_params->op, 1, 0, 1, 0);
3692 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3694 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3696 ut_params->obuf = ut_params->op->sym->m_dst;
3697 if (ut_params->obuf)
3698 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3700 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3702 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3704 const uint8_t *reference_plaintext = tdata->plaintext.data +
3705 (tdata->validCipherOffsetInBits.len >> 3);
3707 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3709 reference_plaintext,
3710 tdata->validCipherLenInBits.len,
3711 "KASUMI Plaintext data not as expected");
3716 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3718 struct crypto_testsuite_params *ts_params = &testsuite_params;
3719 struct crypto_unittest_params *ut_params = &unittest_params;
3722 uint8_t *plaintext, *ciphertext;
3723 unsigned plaintext_pad_len;
3724 unsigned plaintext_len;
3725 struct rte_cryptodev_info dev_info;
3727 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3728 uint64_t feat_flags = dev_info.feature_flags;
3730 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3731 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3732 printf("Device doesn't support RAW data-path APIs.\n");
3736 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3739 /* Verify the capabilities */
3740 struct rte_cryptodev_sym_capability_idx cap_idx;
3741 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3742 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3743 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3747 /* Create SNOW 3G session */
3748 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3749 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3750 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3751 tdata->key.data, tdata->key.len,
3752 tdata->cipher_iv.len);
3756 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3758 /* Clear mbuf payload */
3759 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3760 rte_pktmbuf_tailroom(ut_params->ibuf));
3762 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3763 /* Append data which is padded to a multiple of */
3764 /* the algorithms block size */
3765 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3766 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3768 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3770 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3772 /* Create SNOW 3G operation */
3773 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3774 tdata->cipher_iv.len,
3775 tdata->validCipherLenInBits.len,
3780 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3781 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3782 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3784 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3786 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3788 ut_params->obuf = ut_params->op->sym->m_dst;
3789 if (ut_params->obuf)
3790 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3792 ciphertext = plaintext;
3794 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3797 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3799 tdata->ciphertext.data,
3800 tdata->validDataLenInBits.len,
3801 "SNOW 3G Ciphertext data not as expected");
3807 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3809 struct crypto_testsuite_params *ts_params = &testsuite_params;
3810 struct crypto_unittest_params *ut_params = &unittest_params;
3811 uint8_t *plaintext, *ciphertext;
3814 unsigned plaintext_pad_len;
3815 unsigned plaintext_len;
3817 /* Verify the capabilities */
3818 struct rte_cryptodev_sym_capability_idx cap_idx;
3819 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3820 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3821 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3825 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3828 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3831 /* Create SNOW 3G session */
3832 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3833 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3834 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3835 tdata->key.data, tdata->key.len,
3836 tdata->cipher_iv.len);
3840 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3841 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3843 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3844 "Failed to allocate input buffer in mempool");
3845 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3846 "Failed to allocate output buffer in mempool");
3848 /* Clear mbuf payload */
3849 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3850 rte_pktmbuf_tailroom(ut_params->ibuf));
3852 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3853 /* Append data which is padded to a multiple of */
3854 /* the algorithms block size */
3855 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3856 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3858 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3859 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3861 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3863 /* Create SNOW 3G operation */
3864 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3865 tdata->cipher_iv.len,
3866 tdata->validCipherLenInBits.len,
3871 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3873 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3875 ut_params->obuf = ut_params->op->sym->m_dst;
3876 if (ut_params->obuf)
3877 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3879 ciphertext = plaintext;
3881 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3884 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3886 tdata->ciphertext.data,
3887 tdata->validDataLenInBits.len,
3888 "SNOW 3G Ciphertext data not as expected");
3893 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3895 struct crypto_testsuite_params *ts_params = &testsuite_params;
3896 struct crypto_unittest_params *ut_params = &unittest_params;
3899 unsigned int plaintext_pad_len;
3900 unsigned int plaintext_len;
3901 uint8_t buffer[10000];
3902 const uint8_t *ciphertext;
3904 struct rte_cryptodev_info dev_info;
3906 /* Verify the capabilities */
3907 struct rte_cryptodev_sym_capability_idx cap_idx;
3908 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3909 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3910 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3914 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3917 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3920 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3922 uint64_t feat_flags = dev_info.feature_flags;
3924 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3925 printf("Device doesn't support out-of-place scatter-gather "
3926 "in both input and output mbufs. "
3931 /* Create SNOW 3G session */
3932 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3933 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3934 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3935 tdata->key.data, tdata->key.len,
3936 tdata->cipher_iv.len);
3940 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3941 /* Append data which is padded to a multiple of */
3942 /* the algorithms block size */
3943 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3945 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3946 plaintext_pad_len, 10, 0);
3947 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3948 plaintext_pad_len, 3, 0);
3950 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3951 "Failed to allocate input buffer in mempool");
3952 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3953 "Failed to allocate output buffer in mempool");
3955 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3957 /* Create SNOW 3G operation */
3958 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3959 tdata->cipher_iv.len,
3960 tdata->validCipherLenInBits.len,
3965 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3967 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3969 ut_params->obuf = ut_params->op->sym->m_dst;
3970 if (ut_params->obuf)
3971 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3972 plaintext_len, buffer);
3974 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3975 plaintext_len, buffer);
3977 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3982 tdata->ciphertext.data,
3983 tdata->validDataLenInBits.len,
3984 "SNOW 3G Ciphertext data not as expected");
3989 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3991 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3993 uint8_t curr_byte, prev_byte;
3994 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3995 uint8_t lower_byte_mask = (1 << offset) - 1;
3998 prev_byte = buffer[0];
3999 buffer[0] >>= offset;
4001 for (i = 1; i < length_in_bytes; i++) {
4002 curr_byte = buffer[i];
4003 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4004 (curr_byte >> offset);
4005 prev_byte = curr_byte;
4010 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4012 struct crypto_testsuite_params *ts_params = &testsuite_params;
4013 struct crypto_unittest_params *ut_params = &unittest_params;
4014 uint8_t *plaintext, *ciphertext;
4016 uint32_t plaintext_len;
4017 uint32_t plaintext_pad_len;
4018 uint8_t extra_offset = 4;
4019 uint8_t *expected_ciphertext_shifted;
4020 struct rte_cryptodev_info dev_info;
4022 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4023 uint64_t feat_flags = dev_info.feature_flags;
4025 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4026 ((tdata->validDataLenInBits.len % 8) != 0)) {
4027 printf("Device doesn't support NON-Byte Aligned Data.\n");
4031 /* Verify the capabilities */
4032 struct rte_cryptodev_sym_capability_idx cap_idx;
4033 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4034 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4035 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4039 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4042 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4045 /* Create SNOW 3G session */
4046 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4047 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4048 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4049 tdata->key.data, tdata->key.len,
4050 tdata->cipher_iv.len);
4054 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4055 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4057 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4058 "Failed to allocate input buffer in mempool");
4059 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4060 "Failed to allocate output buffer in mempool");
4062 /* Clear mbuf payload */
4063 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4064 rte_pktmbuf_tailroom(ut_params->ibuf));
4066 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4068 * Append data which is padded to a
4069 * multiple of the algorithms block size
4071 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4073 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4076 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4078 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4079 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4081 #ifdef RTE_APP_TEST_DEBUG
4082 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4084 /* Create SNOW 3G operation */
4085 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4086 tdata->cipher_iv.len,
4087 tdata->validCipherLenInBits.len,
4092 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4094 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4096 ut_params->obuf = ut_params->op->sym->m_dst;
4097 if (ut_params->obuf)
4098 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4100 ciphertext = plaintext;
4102 #ifdef RTE_APP_TEST_DEBUG
4103 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4106 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4108 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4109 "failed to reserve memory for ciphertext shifted\n");
4111 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4112 ceil_byte_length(tdata->ciphertext.len));
4113 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4116 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4118 expected_ciphertext_shifted,
4119 tdata->validDataLenInBits.len,
4121 "SNOW 3G Ciphertext data not as expected");
4125 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4127 struct crypto_testsuite_params *ts_params = &testsuite_params;
4128 struct crypto_unittest_params *ut_params = &unittest_params;
4132 uint8_t *plaintext, *ciphertext;
4133 unsigned ciphertext_pad_len;
4134 unsigned ciphertext_len;
4135 struct rte_cryptodev_info dev_info;
4137 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4138 uint64_t feat_flags = dev_info.feature_flags;
4140 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4141 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4142 printf("Device doesn't support RAW data-path APIs.\n");
4146 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4149 /* Verify the capabilities */
4150 struct rte_cryptodev_sym_capability_idx cap_idx;
4151 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4152 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4153 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4157 /* Create SNOW 3G session */
4158 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4159 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4160 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4161 tdata->key.data, tdata->key.len,
4162 tdata->cipher_iv.len);
4166 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4168 /* Clear mbuf payload */
4169 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4170 rte_pktmbuf_tailroom(ut_params->ibuf));
4172 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4173 /* Append data which is padded to a multiple of */
4174 /* the algorithms block size */
4175 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4176 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4177 ciphertext_pad_len);
4178 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4180 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4182 /* Create SNOW 3G operation */
4183 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4184 tdata->cipher_iv.len,
4185 tdata->validCipherLenInBits.len,
4186 tdata->cipher.offset_bits);
4190 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4191 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4192 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4194 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4196 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4197 ut_params->obuf = ut_params->op->sym->m_dst;
4198 if (ut_params->obuf)
4199 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4201 plaintext = ciphertext;
4203 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4206 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4207 tdata->plaintext.data,
4208 tdata->validDataLenInBits.len,
4209 "SNOW 3G Plaintext data not as expected");
4213 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4215 struct crypto_testsuite_params *ts_params = &testsuite_params;
4216 struct crypto_unittest_params *ut_params = &unittest_params;
4220 uint8_t *plaintext, *ciphertext;
4221 unsigned ciphertext_pad_len;
4222 unsigned ciphertext_len;
4224 /* Verify the capabilities */
4225 struct rte_cryptodev_sym_capability_idx cap_idx;
4226 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4227 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4228 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4232 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4235 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4238 /* Create SNOW 3G session */
4239 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4240 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4241 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4242 tdata->key.data, tdata->key.len,
4243 tdata->cipher_iv.len);
4247 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4248 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4250 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4251 "Failed to allocate input buffer");
4252 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4253 "Failed to allocate output buffer");
4255 /* Clear mbuf payload */
4256 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4257 rte_pktmbuf_tailroom(ut_params->ibuf));
4259 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4260 rte_pktmbuf_tailroom(ut_params->obuf));
4262 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4263 /* Append data which is padded to a multiple of */
4264 /* the algorithms block size */
4265 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4266 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4267 ciphertext_pad_len);
4268 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4269 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4271 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4273 /* Create SNOW 3G operation */
4274 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4275 tdata->cipher_iv.len,
4276 tdata->validCipherLenInBits.len,
4281 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4283 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4284 ut_params->obuf = ut_params->op->sym->m_dst;
4285 if (ut_params->obuf)
4286 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4288 plaintext = ciphertext;
4290 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4293 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4294 tdata->plaintext.data,
4295 tdata->validDataLenInBits.len,
4296 "SNOW 3G Plaintext data not as expected");
4301 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4303 struct crypto_testsuite_params *ts_params = &testsuite_params;
4304 struct crypto_unittest_params *ut_params = &unittest_params;
4308 uint8_t *plaintext, *ciphertext;
4309 unsigned int plaintext_pad_len;
4310 unsigned int plaintext_len;
4312 struct rte_cryptodev_info dev_info;
4313 struct rte_cryptodev_sym_capability_idx cap_idx;
4315 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4316 uint64_t feat_flags = dev_info.feature_flags;
4318 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4319 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4320 (tdata->validDataLenInBits.len % 8 != 0))) {
4321 printf("Device doesn't support NON-Byte Aligned Data.\n");
4325 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4326 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4327 printf("Device doesn't support RAW data-path APIs.\n");
4331 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4334 /* Check if device supports ZUC EEA3 */
4335 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4336 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4338 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4342 /* Check if device supports ZUC EIA3 */
4343 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4344 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4346 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4350 /* Create ZUC session */
4351 retval = create_zuc_cipher_auth_encrypt_generate_session(
4352 ts_params->valid_devs[0],
4356 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4358 /* clear mbuf payload */
4359 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4360 rte_pktmbuf_tailroom(ut_params->ibuf));
4362 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4363 /* Append data which is padded to a multiple of */
4364 /* the algorithms block size */
4365 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4366 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4368 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4370 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4372 /* Create ZUC operation */
4373 retval = create_zuc_cipher_hash_generate_operation(tdata);
4377 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4378 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4379 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4381 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4383 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4384 ut_params->obuf = ut_params->op->sym->m_src;
4385 if (ut_params->obuf)
4386 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4388 ciphertext = plaintext;
4390 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4392 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4394 tdata->ciphertext.data,
4395 tdata->validDataLenInBits.len,
4396 "ZUC Ciphertext data not as expected");
4398 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4399 + plaintext_pad_len;
4402 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4406 "ZUC Generated auth tag not as expected");
4411 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4413 struct crypto_testsuite_params *ts_params = &testsuite_params;
4414 struct crypto_unittest_params *ut_params = &unittest_params;
4418 uint8_t *plaintext, *ciphertext;
4419 unsigned plaintext_pad_len;
4420 unsigned plaintext_len;
4421 struct rte_cryptodev_info dev_info;
4423 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4424 uint64_t feat_flags = dev_info.feature_flags;
4426 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4427 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4428 printf("Device doesn't support RAW data-path APIs.\n");
4432 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4435 /* Verify the capabilities */
4436 struct rte_cryptodev_sym_capability_idx cap_idx;
4437 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4438 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4439 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4442 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4443 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4444 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4448 /* Create SNOW 3G session */
4449 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4450 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4451 RTE_CRYPTO_AUTH_OP_GENERATE,
4452 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4453 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4454 tdata->key.data, tdata->key.len,
4455 tdata->auth_iv.len, tdata->digest.len,
4456 tdata->cipher_iv.len);
4459 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4461 /* clear mbuf payload */
4462 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4463 rte_pktmbuf_tailroom(ut_params->ibuf));
4465 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4466 /* Append data which is padded to a multiple of */
4467 /* the algorithms block size */
4468 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4469 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4471 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4473 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4475 /* Create SNOW 3G operation */
4476 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4477 tdata->digest.len, tdata->auth_iv.data,
4479 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4480 tdata->cipher_iv.data, tdata->cipher_iv.len,
4481 tdata->validCipherLenInBits.len,
4483 tdata->validAuthLenInBits.len,
4489 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4490 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4491 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4493 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4495 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4496 ut_params->obuf = ut_params->op->sym->m_src;
4497 if (ut_params->obuf)
4498 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4500 ciphertext = plaintext;
4502 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4504 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4506 tdata->ciphertext.data,
4507 tdata->validDataLenInBits.len,
4508 "SNOW 3G Ciphertext data not as expected");
4510 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4511 + plaintext_pad_len;
4514 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4517 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4518 "SNOW 3G Generated auth tag not as expected");
4523 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4524 uint8_t op_mode, uint8_t verify)
4526 struct crypto_testsuite_params *ts_params = &testsuite_params;
4527 struct crypto_unittest_params *ut_params = &unittest_params;
4531 uint8_t *plaintext = NULL, *ciphertext = NULL;
4532 unsigned int plaintext_pad_len;
4533 unsigned int plaintext_len;
4534 unsigned int ciphertext_pad_len;
4535 unsigned int ciphertext_len;
4537 struct rte_cryptodev_info dev_info;
4539 /* Verify the capabilities */
4540 struct rte_cryptodev_sym_capability_idx cap_idx;
4541 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4542 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4543 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4546 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4547 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4548 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4552 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4555 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4557 uint64_t feat_flags = dev_info.feature_flags;
4559 if (op_mode == OUT_OF_PLACE) {
4560 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4561 printf("Device doesn't support digest encrypted.\n");
4564 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4568 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4569 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4570 printf("Device doesn't support RAW data-path APIs.\n");
4574 /* Create SNOW 3G session */
4575 retval = create_wireless_algo_auth_cipher_session(
4576 ts_params->valid_devs[0],
4577 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4578 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4579 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4580 : RTE_CRYPTO_AUTH_OP_GENERATE),
4581 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4582 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4583 tdata->key.data, tdata->key.len,
4584 tdata->auth_iv.len, tdata->digest.len,
4585 tdata->cipher_iv.len);
4590 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4591 if (op_mode == OUT_OF_PLACE)
4592 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4594 /* clear mbuf payload */
4595 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4596 rte_pktmbuf_tailroom(ut_params->ibuf));
4597 if (op_mode == OUT_OF_PLACE)
4598 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4599 rte_pktmbuf_tailroom(ut_params->obuf));
4601 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4602 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4603 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4604 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4607 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4608 ciphertext_pad_len);
4609 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4610 if (op_mode == OUT_OF_PLACE)
4611 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4612 debug_hexdump(stdout, "ciphertext:", ciphertext,
4615 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4617 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4618 if (op_mode == OUT_OF_PLACE)
4619 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4620 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4623 /* Create SNOW 3G operation */
4624 retval = create_wireless_algo_auth_cipher_operation(
4625 tdata->digest.data, tdata->digest.len,
4626 tdata->cipher_iv.data, tdata->cipher_iv.len,
4627 tdata->auth_iv.data, tdata->auth_iv.len,
4628 (tdata->digest.offset_bytes == 0 ?
4629 (verify ? ciphertext_pad_len : plaintext_pad_len)
4630 : tdata->digest.offset_bytes),
4631 tdata->validCipherLenInBits.len,
4632 tdata->cipher.offset_bits,
4633 tdata->validAuthLenInBits.len,
4634 tdata->auth.offset_bits,
4635 op_mode, 0, verify);
4640 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4641 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4642 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4644 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4647 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4649 ut_params->obuf = (op_mode == IN_PLACE ?
4650 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4653 if (ut_params->obuf)
4654 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4657 plaintext = ciphertext +
4658 (tdata->cipher.offset_bits >> 3);
4660 debug_hexdump(stdout, "plaintext:", plaintext,
4661 (tdata->plaintext.len >> 3) - tdata->digest.len);
4662 debug_hexdump(stdout, "plaintext expected:",
4663 tdata->plaintext.data,
4664 (tdata->plaintext.len >> 3) - tdata->digest.len);
4666 if (ut_params->obuf)
4667 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4670 ciphertext = plaintext;
4672 debug_hexdump(stdout, "ciphertext:", ciphertext,
4674 debug_hexdump(stdout, "ciphertext expected:",
4675 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4677 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4678 + (tdata->digest.offset_bytes == 0 ?
4679 plaintext_pad_len : tdata->digest.offset_bytes);
4681 debug_hexdump(stdout, "digest:", ut_params->digest,
4683 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4689 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4691 tdata->plaintext.data,
4692 (tdata->plaintext.len - tdata->cipher.offset_bits -
4693 (tdata->digest.len << 3)),
4694 tdata->cipher.offset_bits,
4695 "SNOW 3G Plaintext data not as expected");
4697 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4699 tdata->ciphertext.data,
4700 (tdata->validDataLenInBits.len -
4701 tdata->cipher.offset_bits),
4702 tdata->cipher.offset_bits,
4703 "SNOW 3G Ciphertext data not as expected");
4705 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4708 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4709 "SNOW 3G Generated auth tag not as expected");
4715 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4716 uint8_t op_mode, uint8_t verify)
4718 struct crypto_testsuite_params *ts_params = &testsuite_params;
4719 struct crypto_unittest_params *ut_params = &unittest_params;
4723 const uint8_t *plaintext = NULL;
4724 const uint8_t *ciphertext = NULL;
4725 const uint8_t *digest = NULL;
4726 unsigned int plaintext_pad_len;
4727 unsigned int plaintext_len;
4728 unsigned int ciphertext_pad_len;
4729 unsigned int ciphertext_len;
4730 uint8_t buffer[10000];
4731 uint8_t digest_buffer[10000];
4733 struct rte_cryptodev_info dev_info;
4735 /* Verify the capabilities */
4736 struct rte_cryptodev_sym_capability_idx cap_idx;
4737 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4738 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4739 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4742 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4743 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4744 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4748 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4751 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4753 uint64_t feat_flags = dev_info.feature_flags;
4755 if (op_mode == IN_PLACE) {
4756 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4757 printf("Device doesn't support in-place scatter-gather "
4758 "in both input and output mbufs.\n");
4761 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4762 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4763 printf("Device doesn't support RAW data-path APIs.\n");
4767 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4769 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4770 printf("Device doesn't support out-of-place scatter-gather "
4771 "in both input and output mbufs.\n");
4774 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4775 printf("Device doesn't support digest encrypted.\n");
4780 /* Create SNOW 3G session */
4781 retval = create_wireless_algo_auth_cipher_session(
4782 ts_params->valid_devs[0],
4783 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4784 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4785 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4786 : RTE_CRYPTO_AUTH_OP_GENERATE),
4787 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4788 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4789 tdata->key.data, tdata->key.len,
4790 tdata->auth_iv.len, tdata->digest.len,
4791 tdata->cipher_iv.len);
4796 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4797 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4798 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4799 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4801 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4802 plaintext_pad_len, 15, 0);
4803 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4804 "Failed to allocate input buffer in mempool");
4806 if (op_mode == OUT_OF_PLACE) {
4807 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4808 plaintext_pad_len, 15, 0);
4809 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4810 "Failed to allocate output buffer in mempool");
4814 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4815 tdata->ciphertext.data);
4816 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4817 ciphertext_len, buffer);
4818 debug_hexdump(stdout, "ciphertext:", ciphertext,
4821 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4822 tdata->plaintext.data);
4823 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4824 plaintext_len, buffer);
4825 debug_hexdump(stdout, "plaintext:", plaintext,
4828 memset(buffer, 0, sizeof(buffer));
4830 /* Create SNOW 3G operation */
4831 retval = create_wireless_algo_auth_cipher_operation(
4832 tdata->digest.data, tdata->digest.len,
4833 tdata->cipher_iv.data, tdata->cipher_iv.len,
4834 tdata->auth_iv.data, tdata->auth_iv.len,
4835 (tdata->digest.offset_bytes == 0 ?
4836 (verify ? ciphertext_pad_len : plaintext_pad_len)
4837 : tdata->digest.offset_bytes),
4838 tdata->validCipherLenInBits.len,
4839 tdata->cipher.offset_bits,
4840 tdata->validAuthLenInBits.len,
4841 tdata->auth.offset_bits,
4842 op_mode, 1, verify);
4847 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4848 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4849 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4851 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4854 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4856 ut_params->obuf = (op_mode == IN_PLACE ?
4857 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4860 if (ut_params->obuf)
4861 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4862 plaintext_len, buffer);
4864 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4865 plaintext_len, buffer);
4867 debug_hexdump(stdout, "plaintext:", plaintext,
4868 (tdata->plaintext.len >> 3) - tdata->digest.len);
4869 debug_hexdump(stdout, "plaintext expected:",
4870 tdata->plaintext.data,
4871 (tdata->plaintext.len >> 3) - tdata->digest.len);
4873 if (ut_params->obuf)
4874 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4875 ciphertext_len, buffer);
4877 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4878 ciphertext_len, buffer);
4880 debug_hexdump(stdout, "ciphertext:", ciphertext,
4882 debug_hexdump(stdout, "ciphertext expected:",
4883 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4885 if (ut_params->obuf)
4886 digest = rte_pktmbuf_read(ut_params->obuf,
4887 (tdata->digest.offset_bytes == 0 ?
4888 plaintext_pad_len : tdata->digest.offset_bytes),
4889 tdata->digest.len, digest_buffer);
4891 digest = rte_pktmbuf_read(ut_params->ibuf,
4892 (tdata->digest.offset_bytes == 0 ?
4893 plaintext_pad_len : tdata->digest.offset_bytes),
4894 tdata->digest.len, digest_buffer);
4896 debug_hexdump(stdout, "digest:", digest,
4898 debug_hexdump(stdout, "digest expected:",
4899 tdata->digest.data, tdata->digest.len);
4904 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4906 tdata->plaintext.data,
4907 (tdata->plaintext.len - tdata->cipher.offset_bits -
4908 (tdata->digest.len << 3)),
4909 tdata->cipher.offset_bits,
4910 "SNOW 3G Plaintext data not as expected");
4912 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4914 tdata->ciphertext.data,
4915 (tdata->validDataLenInBits.len -
4916 tdata->cipher.offset_bits),
4917 tdata->cipher.offset_bits,
4918 "SNOW 3G Ciphertext data not as expected");
4920 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4923 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4924 "SNOW 3G Generated auth tag not as expected");
4930 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4931 uint8_t op_mode, uint8_t verify)
4933 struct crypto_testsuite_params *ts_params = &testsuite_params;
4934 struct crypto_unittest_params *ut_params = &unittest_params;
4938 uint8_t *plaintext = NULL, *ciphertext = NULL;
4939 unsigned int plaintext_pad_len;
4940 unsigned int plaintext_len;
4941 unsigned int ciphertext_pad_len;
4942 unsigned int ciphertext_len;
4944 struct rte_cryptodev_info dev_info;
4946 /* Verify the capabilities */
4947 struct rte_cryptodev_sym_capability_idx cap_idx;
4948 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4949 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4950 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4953 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4954 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4955 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4959 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4961 uint64_t feat_flags = dev_info.feature_flags;
4963 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4964 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4965 printf("Device doesn't support RAW data-path APIs.\n");
4969 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4972 if (op_mode == OUT_OF_PLACE) {
4973 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4975 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4976 printf("Device doesn't support digest encrypted.\n");
4981 /* Create KASUMI session */
4982 retval = create_wireless_algo_auth_cipher_session(
4983 ts_params->valid_devs[0],
4984 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4985 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4986 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4987 : RTE_CRYPTO_AUTH_OP_GENERATE),
4988 RTE_CRYPTO_AUTH_KASUMI_F9,
4989 RTE_CRYPTO_CIPHER_KASUMI_F8,
4990 tdata->key.data, tdata->key.len,
4991 0, tdata->digest.len,
4992 tdata->cipher_iv.len);
4997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4998 if (op_mode == OUT_OF_PLACE)
4999 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5001 /* clear mbuf payload */
5002 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5003 rte_pktmbuf_tailroom(ut_params->ibuf));
5004 if (op_mode == OUT_OF_PLACE)
5005 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5006 rte_pktmbuf_tailroom(ut_params->obuf));
5008 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5009 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5010 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5011 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5014 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5015 ciphertext_pad_len);
5016 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5017 if (op_mode == OUT_OF_PLACE)
5018 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5019 debug_hexdump(stdout, "ciphertext:", ciphertext,
5022 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5024 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5025 if (op_mode == OUT_OF_PLACE)
5026 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5027 debug_hexdump(stdout, "plaintext:", plaintext,
5031 /* Create KASUMI operation */
5032 retval = create_wireless_algo_auth_cipher_operation(
5033 tdata->digest.data, tdata->digest.len,
5034 tdata->cipher_iv.data, tdata->cipher_iv.len,
5036 (tdata->digest.offset_bytes == 0 ?
5037 (verify ? ciphertext_pad_len : plaintext_pad_len)
5038 : tdata->digest.offset_bytes),
5039 tdata->validCipherLenInBits.len,
5040 tdata->validCipherOffsetInBits.len,
5041 tdata->validAuthLenInBits.len,
5043 op_mode, 0, verify);
5048 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5049 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5050 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5052 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5055 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5057 ut_params->obuf = (op_mode == IN_PLACE ?
5058 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5062 if (ut_params->obuf)
5063 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5066 plaintext = ciphertext;
5068 debug_hexdump(stdout, "plaintext:", plaintext,
5069 (tdata->plaintext.len >> 3) - tdata->digest.len);
5070 debug_hexdump(stdout, "plaintext expected:",
5071 tdata->plaintext.data,
5072 (tdata->plaintext.len >> 3) - tdata->digest.len);
5074 if (ut_params->obuf)
5075 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5078 ciphertext = plaintext;
5080 debug_hexdump(stdout, "ciphertext:", ciphertext,
5082 debug_hexdump(stdout, "ciphertext expected:",
5083 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5085 ut_params->digest = rte_pktmbuf_mtod(
5086 ut_params->obuf, uint8_t *) +
5087 (tdata->digest.offset_bytes == 0 ?
5088 plaintext_pad_len : tdata->digest.offset_bytes);
5090 debug_hexdump(stdout, "digest:", ut_params->digest,
5092 debug_hexdump(stdout, "digest expected:",
5093 tdata->digest.data, tdata->digest.len);
5098 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5100 tdata->plaintext.data,
5101 tdata->plaintext.len >> 3,
5102 "KASUMI Plaintext data not as expected");
5104 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5106 tdata->ciphertext.data,
5107 tdata->ciphertext.len >> 3,
5108 "KASUMI Ciphertext data not as expected");
5110 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5113 DIGEST_BYTE_LENGTH_KASUMI_F9,
5114 "KASUMI Generated auth tag not as expected");
5120 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5121 uint8_t op_mode, uint8_t verify)
5123 struct crypto_testsuite_params *ts_params = &testsuite_params;
5124 struct crypto_unittest_params *ut_params = &unittest_params;
5128 const uint8_t *plaintext = NULL;
5129 const uint8_t *ciphertext = NULL;
5130 const uint8_t *digest = NULL;
5131 unsigned int plaintext_pad_len;
5132 unsigned int plaintext_len;
5133 unsigned int ciphertext_pad_len;
5134 unsigned int ciphertext_len;
5135 uint8_t buffer[10000];
5136 uint8_t digest_buffer[10000];
5138 struct rte_cryptodev_info dev_info;
5140 /* Verify the capabilities */
5141 struct rte_cryptodev_sym_capability_idx cap_idx;
5142 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5143 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5144 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5147 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5148 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5149 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5153 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5156 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5158 uint64_t feat_flags = dev_info.feature_flags;
5160 if (op_mode == IN_PLACE) {
5161 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5162 printf("Device doesn't support in-place scatter-gather "
5163 "in both input and output mbufs.\n");
5166 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5167 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5168 printf("Device doesn't support RAW data-path APIs.\n");
5172 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5174 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5175 printf("Device doesn't support out-of-place scatter-gather "
5176 "in both input and output mbufs.\n");
5179 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5180 printf("Device doesn't support digest encrypted.\n");
5185 /* Create KASUMI session */
5186 retval = create_wireless_algo_auth_cipher_session(
5187 ts_params->valid_devs[0],
5188 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5189 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5190 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5191 : RTE_CRYPTO_AUTH_OP_GENERATE),
5192 RTE_CRYPTO_AUTH_KASUMI_F9,
5193 RTE_CRYPTO_CIPHER_KASUMI_F8,
5194 tdata->key.data, tdata->key.len,
5195 0, tdata->digest.len,
5196 tdata->cipher_iv.len);
5201 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5202 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5203 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5204 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5206 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5207 plaintext_pad_len, 15, 0);
5208 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5209 "Failed to allocate input buffer in mempool");
5211 if (op_mode == OUT_OF_PLACE) {
5212 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5213 plaintext_pad_len, 15, 0);
5214 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5215 "Failed to allocate output buffer in mempool");
5219 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5220 tdata->ciphertext.data);
5221 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5222 ciphertext_len, buffer);
5223 debug_hexdump(stdout, "ciphertext:", ciphertext,
5226 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5227 tdata->plaintext.data);
5228 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5229 plaintext_len, buffer);
5230 debug_hexdump(stdout, "plaintext:", plaintext,
5233 memset(buffer, 0, sizeof(buffer));
5235 /* Create KASUMI operation */
5236 retval = create_wireless_algo_auth_cipher_operation(
5237 tdata->digest.data, tdata->digest.len,
5238 tdata->cipher_iv.data, tdata->cipher_iv.len,
5240 (tdata->digest.offset_bytes == 0 ?
5241 (verify ? ciphertext_pad_len : plaintext_pad_len)
5242 : tdata->digest.offset_bytes),
5243 tdata->validCipherLenInBits.len,
5244 tdata->validCipherOffsetInBits.len,
5245 tdata->validAuthLenInBits.len,
5247 op_mode, 1, verify);
5252 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5253 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5254 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5256 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5259 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5261 ut_params->obuf = (op_mode == IN_PLACE ?
5262 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5265 if (ut_params->obuf)
5266 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5267 plaintext_len, buffer);
5269 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5270 plaintext_len, buffer);
5272 debug_hexdump(stdout, "plaintext:", plaintext,
5273 (tdata->plaintext.len >> 3) - tdata->digest.len);
5274 debug_hexdump(stdout, "plaintext expected:",
5275 tdata->plaintext.data,
5276 (tdata->plaintext.len >> 3) - tdata->digest.len);
5278 if (ut_params->obuf)
5279 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5280 ciphertext_len, buffer);
5282 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5283 ciphertext_len, buffer);
5285 debug_hexdump(stdout, "ciphertext:", ciphertext,
5287 debug_hexdump(stdout, "ciphertext expected:",
5288 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5290 if (ut_params->obuf)
5291 digest = rte_pktmbuf_read(ut_params->obuf,
5292 (tdata->digest.offset_bytes == 0 ?
5293 plaintext_pad_len : tdata->digest.offset_bytes),
5294 tdata->digest.len, digest_buffer);
5296 digest = rte_pktmbuf_read(ut_params->ibuf,
5297 (tdata->digest.offset_bytes == 0 ?
5298 plaintext_pad_len : tdata->digest.offset_bytes),
5299 tdata->digest.len, digest_buffer);
5301 debug_hexdump(stdout, "digest:", digest,
5303 debug_hexdump(stdout, "digest expected:",
5304 tdata->digest.data, tdata->digest.len);
5309 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5311 tdata->plaintext.data,
5312 tdata->plaintext.len >> 3,
5313 "KASUMI Plaintext data not as expected");
5315 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5317 tdata->ciphertext.data,
5318 tdata->validDataLenInBits.len,
5319 "KASUMI Ciphertext data not as expected");
5321 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5324 DIGEST_BYTE_LENGTH_KASUMI_F9,
5325 "KASUMI Generated auth tag not as expected");
5331 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5333 struct crypto_testsuite_params *ts_params = &testsuite_params;
5334 struct crypto_unittest_params *ut_params = &unittest_params;
5338 uint8_t *plaintext, *ciphertext;
5339 unsigned plaintext_pad_len;
5340 unsigned plaintext_len;
5341 struct rte_cryptodev_info dev_info;
5343 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5344 uint64_t feat_flags = dev_info.feature_flags;
5346 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5347 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5348 printf("Device doesn't support RAW data-path APIs.\n");
5352 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5355 /* Verify the capabilities */
5356 struct rte_cryptodev_sym_capability_idx cap_idx;
5357 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5358 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5359 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5362 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5363 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5364 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5368 /* Create KASUMI session */
5369 retval = create_wireless_algo_cipher_auth_session(
5370 ts_params->valid_devs[0],
5371 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5372 RTE_CRYPTO_AUTH_OP_GENERATE,
5373 RTE_CRYPTO_AUTH_KASUMI_F9,
5374 RTE_CRYPTO_CIPHER_KASUMI_F8,
5375 tdata->key.data, tdata->key.len,
5376 0, tdata->digest.len,
5377 tdata->cipher_iv.len);
5381 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5383 /* clear mbuf payload */
5384 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5385 rte_pktmbuf_tailroom(ut_params->ibuf));
5387 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5388 /* Append data which is padded to a multiple of */
5389 /* the algorithms block size */
5390 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5391 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5393 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5395 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5397 /* Create KASUMI operation */
5398 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5399 tdata->digest.len, NULL, 0,
5400 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5401 tdata->cipher_iv.data, tdata->cipher_iv.len,
5402 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5403 tdata->validCipherOffsetInBits.len,
5404 tdata->validAuthLenInBits.len,
5410 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5411 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5412 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5414 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5416 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5418 if (ut_params->op->sym->m_dst)
5419 ut_params->obuf = ut_params->op->sym->m_dst;
5421 ut_params->obuf = ut_params->op->sym->m_src;
5423 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5424 tdata->validCipherOffsetInBits.len >> 3);
5426 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5427 + plaintext_pad_len;
5429 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5430 (tdata->validCipherOffsetInBits.len >> 3);
5432 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5434 reference_ciphertext,
5435 tdata->validCipherLenInBits.len,
5436 "KASUMI Ciphertext data not as expected");
5439 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5442 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5443 "KASUMI Generated auth tag not as expected");
5448 test_zuc_encryption(const struct wireless_test_data *tdata)
5450 struct crypto_testsuite_params *ts_params = &testsuite_params;
5451 struct crypto_unittest_params *ut_params = &unittest_params;
5454 uint8_t *plaintext, *ciphertext;
5455 unsigned plaintext_pad_len;
5456 unsigned plaintext_len;
5457 struct rte_cryptodev_info dev_info;
5459 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5460 uint64_t feat_flags = dev_info.feature_flags;
5462 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5463 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5464 printf("Device doesn't support RAW data-path APIs.\n");
5468 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5471 struct rte_cryptodev_sym_capability_idx cap_idx;
5473 /* Check if device supports ZUC EEA3 */
5474 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5475 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5477 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5481 /* Create ZUC session */
5482 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5483 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5484 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5485 tdata->key.data, tdata->key.len,
5486 tdata->cipher_iv.len);
5490 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5492 /* Clear mbuf payload */
5493 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5494 rte_pktmbuf_tailroom(ut_params->ibuf));
5496 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5497 /* Append data which is padded to a multiple */
5498 /* of the algorithms block size */
5499 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5500 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5502 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5504 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5506 /* Create ZUC operation */
5507 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5508 tdata->cipher_iv.len,
5509 tdata->plaintext.len,
5514 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5515 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5516 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5518 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5520 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5522 ut_params->obuf = ut_params->op->sym->m_dst;
5523 if (ut_params->obuf)
5524 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5526 ciphertext = plaintext;
5528 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5531 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5533 tdata->ciphertext.data,
5534 tdata->validCipherLenInBits.len,
5535 "ZUC Ciphertext data not as expected");
5540 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5542 struct crypto_testsuite_params *ts_params = &testsuite_params;
5543 struct crypto_unittest_params *ut_params = &unittest_params;
5547 unsigned int plaintext_pad_len;
5548 unsigned int plaintext_len;
5549 const uint8_t *ciphertext;
5550 uint8_t ciphertext_buffer[2048];
5551 struct rte_cryptodev_info dev_info;
5553 struct rte_cryptodev_sym_capability_idx cap_idx;
5555 /* Check if device supports ZUC EEA3 */
5556 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5557 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5559 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5563 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5566 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5568 uint64_t feat_flags = dev_info.feature_flags;
5570 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5571 printf("Device doesn't support in-place scatter-gather. "
5576 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5577 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5578 printf("Device doesn't support RAW data-path APIs.\n");
5582 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5584 /* Append data which is padded to a multiple */
5585 /* of the algorithms block size */
5586 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5588 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5589 plaintext_pad_len, 10, 0);
5591 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5592 tdata->plaintext.data);
5594 /* Create ZUC session */
5595 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5596 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5597 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5598 tdata->key.data, tdata->key.len,
5599 tdata->cipher_iv.len);
5603 /* Clear mbuf payload */
5605 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5607 /* Create ZUC operation */
5608 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5609 tdata->cipher_iv.len, tdata->plaintext.len,
5614 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5615 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5616 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5618 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5620 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5622 ut_params->obuf = ut_params->op->sym->m_dst;
5623 if (ut_params->obuf)
5624 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5625 0, plaintext_len, ciphertext_buffer);
5627 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5628 0, plaintext_len, ciphertext_buffer);
5631 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5634 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5636 tdata->ciphertext.data,
5637 tdata->validCipherLenInBits.len,
5638 "ZUC Ciphertext data not as expected");
5644 test_zuc_authentication(const struct wireless_test_data *tdata)
5646 struct crypto_testsuite_params *ts_params = &testsuite_params;
5647 struct crypto_unittest_params *ut_params = &unittest_params;
5650 unsigned plaintext_pad_len;
5651 unsigned plaintext_len;
5654 struct rte_cryptodev_sym_capability_idx cap_idx;
5655 struct rte_cryptodev_info dev_info;
5657 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5658 uint64_t feat_flags = dev_info.feature_flags;
5660 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5661 (tdata->validAuthLenInBits.len % 8 != 0)) {
5662 printf("Device doesn't support NON-Byte Aligned Data.\n");
5666 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5667 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5668 printf("Device doesn't support RAW data-path APIs.\n");
5672 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5675 /* Check if device supports ZUC EIA3 */
5676 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5677 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5679 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5683 /* Create ZUC session */
5684 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5685 tdata->key.data, tdata->key.len,
5686 tdata->auth_iv.len, tdata->digest.len,
5687 RTE_CRYPTO_AUTH_OP_GENERATE,
5688 RTE_CRYPTO_AUTH_ZUC_EIA3);
5692 /* alloc mbuf and set payload */
5693 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5695 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5696 rte_pktmbuf_tailroom(ut_params->ibuf));
5698 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5699 /* Append data which is padded to a multiple of */
5700 /* the algorithms block size */
5701 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5702 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5704 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5706 /* Create ZUC operation */
5707 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5708 tdata->auth_iv.data, tdata->auth_iv.len,
5709 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5710 tdata->validAuthLenInBits.len,
5715 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5716 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5717 ut_params->op, 0, 1, 1, 0);
5719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5721 ut_params->obuf = ut_params->op->sym->m_src;
5722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5723 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5724 + plaintext_pad_len;
5727 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5731 "ZUC Generated auth tag not as expected");
5737 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5738 uint8_t op_mode, uint8_t verify)
5740 struct crypto_testsuite_params *ts_params = &testsuite_params;
5741 struct crypto_unittest_params *ut_params = &unittest_params;
5745 uint8_t *plaintext = NULL, *ciphertext = NULL;
5746 unsigned int plaintext_pad_len;
5747 unsigned int plaintext_len;
5748 unsigned int ciphertext_pad_len;
5749 unsigned int ciphertext_len;
5751 struct rte_cryptodev_info dev_info;
5752 struct rte_cryptodev_sym_capability_idx cap_idx;
5754 /* Check if device supports ZUC EIA3 */
5755 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5756 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5758 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5762 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5764 uint64_t feat_flags = dev_info.feature_flags;
5766 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5767 printf("Device doesn't support digest encrypted.\n");
5770 if (op_mode == IN_PLACE) {
5771 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5772 printf("Device doesn't support in-place scatter-gather "
5773 "in both input and output mbufs.\n");
5777 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5778 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5779 printf("Device doesn't support RAW data-path APIs.\n");
5783 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5785 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5786 printf("Device doesn't support out-of-place scatter-gather "
5787 "in both input and output mbufs.\n");
5792 /* Create ZUC session */
5793 retval = create_wireless_algo_auth_cipher_session(
5794 ts_params->valid_devs[0],
5795 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5796 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5797 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5798 : RTE_CRYPTO_AUTH_OP_GENERATE),
5799 RTE_CRYPTO_AUTH_ZUC_EIA3,
5800 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5801 tdata->key.data, tdata->key.len,
5802 tdata->auth_iv.len, tdata->digest.len,
5803 tdata->cipher_iv.len);
5808 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5809 if (op_mode == OUT_OF_PLACE)
5810 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5812 /* clear mbuf payload */
5813 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5814 rte_pktmbuf_tailroom(ut_params->ibuf));
5815 if (op_mode == OUT_OF_PLACE)
5816 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5817 rte_pktmbuf_tailroom(ut_params->obuf));
5819 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5820 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5821 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5822 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5825 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5826 ciphertext_pad_len);
5827 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5828 if (op_mode == OUT_OF_PLACE)
5829 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5830 debug_hexdump(stdout, "ciphertext:", ciphertext,
5833 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5835 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5836 if (op_mode == OUT_OF_PLACE)
5837 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5838 debug_hexdump(stdout, "plaintext:", plaintext,
5842 /* Create ZUC operation */
5843 retval = create_wireless_algo_auth_cipher_operation(
5844 tdata->digest.data, tdata->digest.len,
5845 tdata->cipher_iv.data, tdata->cipher_iv.len,
5846 tdata->auth_iv.data, tdata->auth_iv.len,
5847 (tdata->digest.offset_bytes == 0 ?
5848 (verify ? ciphertext_pad_len : plaintext_pad_len)
5849 : tdata->digest.offset_bytes),
5850 tdata->validCipherLenInBits.len,
5851 tdata->validCipherOffsetInBits.len,
5852 tdata->validAuthLenInBits.len,
5854 op_mode, 0, verify);
5859 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5860 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5861 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5863 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5866 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5868 ut_params->obuf = (op_mode == IN_PLACE ?
5869 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5873 if (ut_params->obuf)
5874 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5877 plaintext = ciphertext;
5879 debug_hexdump(stdout, "plaintext:", plaintext,
5880 (tdata->plaintext.len >> 3) - tdata->digest.len);
5881 debug_hexdump(stdout, "plaintext expected:",
5882 tdata->plaintext.data,
5883 (tdata->plaintext.len >> 3) - tdata->digest.len);
5885 if (ut_params->obuf)
5886 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5889 ciphertext = plaintext;
5891 debug_hexdump(stdout, "ciphertext:", ciphertext,
5893 debug_hexdump(stdout, "ciphertext expected:",
5894 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5896 ut_params->digest = rte_pktmbuf_mtod(
5897 ut_params->obuf, uint8_t *) +
5898 (tdata->digest.offset_bytes == 0 ?
5899 plaintext_pad_len : tdata->digest.offset_bytes);
5901 debug_hexdump(stdout, "digest:", ut_params->digest,
5903 debug_hexdump(stdout, "digest expected:",
5904 tdata->digest.data, tdata->digest.len);
5909 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5911 tdata->plaintext.data,
5912 tdata->plaintext.len >> 3,
5913 "ZUC Plaintext data not as expected");
5915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5917 tdata->ciphertext.data,
5918 tdata->ciphertext.len >> 3,
5919 "ZUC Ciphertext data not as expected");
5921 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5924 DIGEST_BYTE_LENGTH_KASUMI_F9,
5925 "ZUC Generated auth tag not as expected");
5931 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5932 uint8_t op_mode, uint8_t verify)
5934 struct crypto_testsuite_params *ts_params = &testsuite_params;
5935 struct crypto_unittest_params *ut_params = &unittest_params;
5939 const uint8_t *plaintext = NULL;
5940 const uint8_t *ciphertext = NULL;
5941 const uint8_t *digest = NULL;
5942 unsigned int plaintext_pad_len;
5943 unsigned int plaintext_len;
5944 unsigned int ciphertext_pad_len;
5945 unsigned int ciphertext_len;
5946 uint8_t buffer[10000];
5947 uint8_t digest_buffer[10000];
5949 struct rte_cryptodev_info dev_info;
5950 struct rte_cryptodev_sym_capability_idx cap_idx;
5952 /* Check if device supports ZUC EIA3 */
5953 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5954 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5956 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5960 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5962 uint64_t feat_flags = dev_info.feature_flags;
5964 if (op_mode == IN_PLACE) {
5965 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5966 printf("Device doesn't support in-place scatter-gather "
5967 "in both input and output mbufs.\n");
5971 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5972 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5973 printf("Device doesn't support RAW data-path APIs.\n");
5977 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5979 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5980 printf("Device doesn't support out-of-place scatter-gather "
5981 "in both input and output mbufs.\n");
5984 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5985 printf("Device doesn't support digest encrypted.\n");
5990 /* Create ZUC session */
5991 retval = create_wireless_algo_auth_cipher_session(
5992 ts_params->valid_devs[0],
5993 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5994 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5995 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5996 : RTE_CRYPTO_AUTH_OP_GENERATE),
5997 RTE_CRYPTO_AUTH_ZUC_EIA3,
5998 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5999 tdata->key.data, tdata->key.len,
6000 tdata->auth_iv.len, tdata->digest.len,
6001 tdata->cipher_iv.len);
6006 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6007 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6008 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6009 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6011 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6012 plaintext_pad_len, 15, 0);
6013 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6014 "Failed to allocate input buffer in mempool");
6016 if (op_mode == OUT_OF_PLACE) {
6017 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6018 plaintext_pad_len, 15, 0);
6019 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6020 "Failed to allocate output buffer in mempool");
6024 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6025 tdata->ciphertext.data);
6026 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6027 ciphertext_len, buffer);
6028 debug_hexdump(stdout, "ciphertext:", ciphertext,
6031 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6032 tdata->plaintext.data);
6033 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6034 plaintext_len, buffer);
6035 debug_hexdump(stdout, "plaintext:", plaintext,
6038 memset(buffer, 0, sizeof(buffer));
6040 /* Create ZUC operation */
6041 retval = create_wireless_algo_auth_cipher_operation(
6042 tdata->digest.data, tdata->digest.len,
6043 tdata->cipher_iv.data, tdata->cipher_iv.len,
6045 (tdata->digest.offset_bytes == 0 ?
6046 (verify ? ciphertext_pad_len : plaintext_pad_len)
6047 : tdata->digest.offset_bytes),
6048 tdata->validCipherLenInBits.len,
6049 tdata->validCipherOffsetInBits.len,
6050 tdata->validAuthLenInBits.len,
6052 op_mode, 1, verify);
6057 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6058 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6059 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6061 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6064 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6066 ut_params->obuf = (op_mode == IN_PLACE ?
6067 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6070 if (ut_params->obuf)
6071 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6072 plaintext_len, buffer);
6074 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6075 plaintext_len, buffer);
6077 debug_hexdump(stdout, "plaintext:", plaintext,
6078 (tdata->plaintext.len >> 3) - tdata->digest.len);
6079 debug_hexdump(stdout, "plaintext expected:",
6080 tdata->plaintext.data,
6081 (tdata->plaintext.len >> 3) - tdata->digest.len);
6083 if (ut_params->obuf)
6084 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6085 ciphertext_len, buffer);
6087 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6088 ciphertext_len, buffer);
6090 debug_hexdump(stdout, "ciphertext:", ciphertext,
6092 debug_hexdump(stdout, "ciphertext expected:",
6093 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6095 if (ut_params->obuf)
6096 digest = rte_pktmbuf_read(ut_params->obuf,
6097 (tdata->digest.offset_bytes == 0 ?
6098 plaintext_pad_len : tdata->digest.offset_bytes),
6099 tdata->digest.len, digest_buffer);
6101 digest = rte_pktmbuf_read(ut_params->ibuf,
6102 (tdata->digest.offset_bytes == 0 ?
6103 plaintext_pad_len : tdata->digest.offset_bytes),
6104 tdata->digest.len, digest_buffer);
6106 debug_hexdump(stdout, "digest:", digest,
6108 debug_hexdump(stdout, "digest expected:",
6109 tdata->digest.data, tdata->digest.len);
6114 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6116 tdata->plaintext.data,
6117 tdata->plaintext.len >> 3,
6118 "ZUC Plaintext data not as expected");
6120 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6122 tdata->ciphertext.data,
6123 tdata->validDataLenInBits.len,
6124 "ZUC Ciphertext data not as expected");
6126 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6129 DIGEST_BYTE_LENGTH_KASUMI_F9,
6130 "ZUC Generated auth tag not as expected");
6136 test_kasumi_encryption_test_case_1(void)
6138 return test_kasumi_encryption(&kasumi_test_case_1);
6142 test_kasumi_encryption_test_case_1_sgl(void)
6144 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6148 test_kasumi_encryption_test_case_1_oop(void)
6150 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6154 test_kasumi_encryption_test_case_1_oop_sgl(void)
6156 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6160 test_kasumi_encryption_test_case_2(void)
6162 return test_kasumi_encryption(&kasumi_test_case_2);
6166 test_kasumi_encryption_test_case_3(void)
6168 return test_kasumi_encryption(&kasumi_test_case_3);
6172 test_kasumi_encryption_test_case_4(void)
6174 return test_kasumi_encryption(&kasumi_test_case_4);
6178 test_kasumi_encryption_test_case_5(void)
6180 return test_kasumi_encryption(&kasumi_test_case_5);
6184 test_kasumi_decryption_test_case_1(void)
6186 return test_kasumi_decryption(&kasumi_test_case_1);
6190 test_kasumi_decryption_test_case_1_oop(void)
6192 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6196 test_kasumi_decryption_test_case_2(void)
6198 return test_kasumi_decryption(&kasumi_test_case_2);
6202 test_kasumi_decryption_test_case_3(void)
6204 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6205 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6207 return test_kasumi_decryption(&kasumi_test_case_3);
6211 test_kasumi_decryption_test_case_4(void)
6213 return test_kasumi_decryption(&kasumi_test_case_4);
6217 test_kasumi_decryption_test_case_5(void)
6219 return test_kasumi_decryption(&kasumi_test_case_5);
6222 test_snow3g_encryption_test_case_1(void)
6224 return test_snow3g_encryption(&snow3g_test_case_1);
6228 test_snow3g_encryption_test_case_1_oop(void)
6230 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6234 test_snow3g_encryption_test_case_1_oop_sgl(void)
6236 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6241 test_snow3g_encryption_test_case_1_offset_oop(void)
6243 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6247 test_snow3g_encryption_test_case_2(void)
6249 return test_snow3g_encryption(&snow3g_test_case_2);
6253 test_snow3g_encryption_test_case_3(void)
6255 return test_snow3g_encryption(&snow3g_test_case_3);
6259 test_snow3g_encryption_test_case_4(void)
6261 return test_snow3g_encryption(&snow3g_test_case_4);
6265 test_snow3g_encryption_test_case_5(void)
6267 return test_snow3g_encryption(&snow3g_test_case_5);
6271 test_snow3g_decryption_test_case_1(void)
6273 return test_snow3g_decryption(&snow3g_test_case_1);
6277 test_snow3g_decryption_test_case_1_oop(void)
6279 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6283 test_snow3g_decryption_test_case_2(void)
6285 return test_snow3g_decryption(&snow3g_test_case_2);
6289 test_snow3g_decryption_test_case_3(void)
6291 return test_snow3g_decryption(&snow3g_test_case_3);
6295 test_snow3g_decryption_test_case_4(void)
6297 return test_snow3g_decryption(&snow3g_test_case_4);
6301 test_snow3g_decryption_test_case_5(void)
6303 return test_snow3g_decryption(&snow3g_test_case_5);
6307 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6308 * Pattern digest from snow3g_test_data must be allocated as
6309 * 4 last bytes in plaintext.
6312 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6313 struct snow3g_hash_test_data *output)
6315 if ((pattern != NULL) && (output != NULL)) {
6316 output->key.len = pattern->key.len;
6318 memcpy(output->key.data,
6319 pattern->key.data, pattern->key.len);
6321 output->auth_iv.len = pattern->auth_iv.len;
6323 memcpy(output->auth_iv.data,
6324 pattern->auth_iv.data, pattern->auth_iv.len);
6326 output->plaintext.len = pattern->plaintext.len;
6328 memcpy(output->plaintext.data,
6329 pattern->plaintext.data, pattern->plaintext.len >> 3);
6331 output->digest.len = pattern->digest.len;
6333 memcpy(output->digest.data,
6334 &pattern->plaintext.data[pattern->digest.offset_bytes],
6335 pattern->digest.len);
6337 output->validAuthLenInBits.len =
6338 pattern->validAuthLenInBits.len;
6343 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6346 test_snow3g_decryption_with_digest_test_case_1(void)
6348 struct snow3g_hash_test_data snow3g_hash_data;
6349 struct rte_cryptodev_info dev_info;
6350 struct crypto_testsuite_params *ts_params = &testsuite_params;
6352 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6353 uint64_t feat_flags = dev_info.feature_flags;
6355 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6356 printf("Device doesn't support encrypted digest operations.\n");
6361 * Function prepare data for hash veryfication test case.
6362 * Digest is allocated in 4 last bytes in plaintext, pattern.
6364 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6366 return test_snow3g_decryption(&snow3g_test_case_7) &
6367 test_snow3g_authentication_verify(&snow3g_hash_data);
6371 test_snow3g_cipher_auth_test_case_1(void)
6373 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6377 test_snow3g_auth_cipher_test_case_1(void)
6379 return test_snow3g_auth_cipher(
6380 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6384 test_snow3g_auth_cipher_test_case_2(void)
6386 return test_snow3g_auth_cipher(
6387 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6391 test_snow3g_auth_cipher_test_case_2_oop(void)
6393 return test_snow3g_auth_cipher(
6394 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6398 test_snow3g_auth_cipher_part_digest_enc(void)
6400 return test_snow3g_auth_cipher(
6401 &snow3g_auth_cipher_partial_digest_encryption,
6406 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6408 return test_snow3g_auth_cipher(
6409 &snow3g_auth_cipher_partial_digest_encryption,
6414 test_snow3g_auth_cipher_test_case_3_sgl(void)
6416 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6417 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6419 return test_snow3g_auth_cipher_sgl(
6420 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6424 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6426 return test_snow3g_auth_cipher_sgl(
6427 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6431 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6433 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6434 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6436 return test_snow3g_auth_cipher_sgl(
6437 &snow3g_auth_cipher_partial_digest_encryption,
6442 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6444 return test_snow3g_auth_cipher_sgl(
6445 &snow3g_auth_cipher_partial_digest_encryption,
6450 test_snow3g_auth_cipher_verify_test_case_1(void)
6452 return test_snow3g_auth_cipher(
6453 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6457 test_snow3g_auth_cipher_verify_test_case_2(void)
6459 return test_snow3g_auth_cipher(
6460 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6464 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6466 return test_snow3g_auth_cipher(
6467 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6471 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6473 return test_snow3g_auth_cipher(
6474 &snow3g_auth_cipher_partial_digest_encryption,
6479 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6481 return test_snow3g_auth_cipher(
6482 &snow3g_auth_cipher_partial_digest_encryption,
6487 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6489 return test_snow3g_auth_cipher_sgl(
6490 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6494 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6496 return test_snow3g_auth_cipher_sgl(
6497 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6501 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6503 return test_snow3g_auth_cipher_sgl(
6504 &snow3g_auth_cipher_partial_digest_encryption,
6509 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6511 return test_snow3g_auth_cipher_sgl(
6512 &snow3g_auth_cipher_partial_digest_encryption,
6517 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6519 return test_snow3g_auth_cipher(
6520 &snow3g_test_case_7, IN_PLACE, 0);
6524 test_kasumi_auth_cipher_test_case_1(void)
6526 return test_kasumi_auth_cipher(
6527 &kasumi_test_case_3, IN_PLACE, 0);
6531 test_kasumi_auth_cipher_test_case_2(void)
6533 return test_kasumi_auth_cipher(
6534 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6538 test_kasumi_auth_cipher_test_case_2_oop(void)
6540 return test_kasumi_auth_cipher(
6541 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6545 test_kasumi_auth_cipher_test_case_2_sgl(void)
6547 return test_kasumi_auth_cipher_sgl(
6548 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6552 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6554 return test_kasumi_auth_cipher_sgl(
6555 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6559 test_kasumi_auth_cipher_verify_test_case_1(void)
6561 return test_kasumi_auth_cipher(
6562 &kasumi_test_case_3, IN_PLACE, 1);
6566 test_kasumi_auth_cipher_verify_test_case_2(void)
6568 return test_kasumi_auth_cipher(
6569 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6573 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6575 return test_kasumi_auth_cipher(
6576 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6580 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6582 return test_kasumi_auth_cipher_sgl(
6583 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6587 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6589 return test_kasumi_auth_cipher_sgl(
6590 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6594 test_kasumi_cipher_auth_test_case_1(void)
6596 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6600 test_zuc_encryption_test_case_1(void)
6602 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6606 test_zuc_encryption_test_case_2(void)
6608 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6612 test_zuc_encryption_test_case_3(void)
6614 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6618 test_zuc_encryption_test_case_4(void)
6620 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6624 test_zuc_encryption_test_case_5(void)
6626 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6630 test_zuc_encryption_test_case_6_sgl(void)
6632 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6636 test_zuc_hash_generate_test_case_1(void)
6638 return test_zuc_authentication(&zuc_test_case_auth_1b);
6642 test_zuc_hash_generate_test_case_2(void)
6644 return test_zuc_authentication(&zuc_test_case_auth_90b);
6648 test_zuc_hash_generate_test_case_3(void)
6650 return test_zuc_authentication(&zuc_test_case_auth_577b);
6654 test_zuc_hash_generate_test_case_4(void)
6656 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6660 test_zuc_hash_generate_test_case_5(void)
6662 return test_zuc_authentication(&zuc_test_auth_5670b);
6666 test_zuc_hash_generate_test_case_6(void)
6668 return test_zuc_authentication(&zuc_test_case_auth_128b);
6672 test_zuc_hash_generate_test_case_7(void)
6674 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6678 test_zuc_hash_generate_test_case_8(void)
6680 return test_zuc_authentication(&zuc_test_case_auth_584b);
6684 test_zuc_cipher_auth_test_case_1(void)
6686 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6690 test_zuc_cipher_auth_test_case_2(void)
6692 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6696 test_zuc_auth_cipher_test_case_1(void)
6698 return test_zuc_auth_cipher(
6699 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6703 test_zuc_auth_cipher_test_case_1_oop(void)
6705 return test_zuc_auth_cipher(
6706 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6710 test_zuc_auth_cipher_test_case_1_sgl(void)
6712 return test_zuc_auth_cipher_sgl(
6713 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6717 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6719 return test_zuc_auth_cipher_sgl(
6720 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6724 test_zuc_auth_cipher_verify_test_case_1(void)
6726 return test_zuc_auth_cipher(
6727 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6731 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6733 return test_zuc_auth_cipher(
6734 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6738 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6740 return test_zuc_auth_cipher_sgl(
6741 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6745 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6747 return test_zuc_auth_cipher_sgl(
6748 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6752 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6754 uint8_t dev_id = testsuite_params.valid_devs[0];
6756 struct rte_cryptodev_sym_capability_idx cap_idx;
6758 /* Check if device supports particular cipher algorithm */
6759 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6760 cap_idx.algo.cipher = tdata->cipher_algo;
6761 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6764 /* Check if device supports particular hash algorithm */
6765 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6766 cap_idx.algo.auth = tdata->auth_algo;
6767 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6774 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6775 uint8_t op_mode, uint8_t verify)
6777 struct crypto_testsuite_params *ts_params = &testsuite_params;
6778 struct crypto_unittest_params *ut_params = &unittest_params;
6782 uint8_t *plaintext = NULL, *ciphertext = NULL;
6783 unsigned int plaintext_pad_len;
6784 unsigned int plaintext_len;
6785 unsigned int ciphertext_pad_len;
6786 unsigned int ciphertext_len;
6788 struct rte_cryptodev_info dev_info;
6789 struct rte_crypto_op *op;
6791 /* Check if device supports particular algorithms separately */
6792 if (test_mixed_check_if_unsupported(tdata))
6794 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6797 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6799 uint64_t feat_flags = dev_info.feature_flags;
6801 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6802 printf("Device doesn't support digest encrypted.\n");
6806 /* Create the session */
6808 retval = create_wireless_algo_cipher_auth_session(
6809 ts_params->valid_devs[0],
6810 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6811 RTE_CRYPTO_AUTH_OP_VERIFY,
6814 tdata->auth_key.data, tdata->auth_key.len,
6815 tdata->auth_iv.len, tdata->digest_enc.len,
6816 tdata->cipher_iv.len);
6818 retval = create_wireless_algo_auth_cipher_session(
6819 ts_params->valid_devs[0],
6820 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6821 RTE_CRYPTO_AUTH_OP_GENERATE,
6824 tdata->auth_key.data, tdata->auth_key.len,
6825 tdata->auth_iv.len, tdata->digest_enc.len,
6826 tdata->cipher_iv.len);
6830 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6831 if (op_mode == OUT_OF_PLACE)
6832 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6834 /* clear mbuf payload */
6835 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6836 rte_pktmbuf_tailroom(ut_params->ibuf));
6837 if (op_mode == OUT_OF_PLACE) {
6839 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6840 rte_pktmbuf_tailroom(ut_params->obuf));
6843 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6844 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6845 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6846 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6849 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6850 ciphertext_pad_len);
6851 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6852 if (op_mode == OUT_OF_PLACE)
6853 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6854 debug_hexdump(stdout, "ciphertext:", ciphertext,
6857 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6859 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6860 if (op_mode == OUT_OF_PLACE)
6861 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6862 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6865 /* Create the operation */
6866 retval = create_wireless_algo_auth_cipher_operation(
6867 tdata->digest_enc.data, tdata->digest_enc.len,
6868 tdata->cipher_iv.data, tdata->cipher_iv.len,
6869 tdata->auth_iv.data, tdata->auth_iv.len,
6870 (tdata->digest_enc.offset == 0 ?
6872 : tdata->digest_enc.offset),
6873 tdata->validCipherLen.len_bits,
6874 tdata->cipher.offset_bits,
6875 tdata->validAuthLen.len_bits,
6876 tdata->auth.offset_bits,
6877 op_mode, 0, verify);
6882 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
6884 /* Check if the op failed because the device doesn't */
6885 /* support this particular combination of algorithms */
6886 if (op == NULL && ut_params->op->status ==
6887 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6888 printf("Device doesn't support this mixed combination. "
6894 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6896 ut_params->obuf = (op_mode == IN_PLACE ?
6897 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6900 if (ut_params->obuf)
6901 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6904 plaintext = ciphertext +
6905 (tdata->cipher.offset_bits >> 3);
6907 debug_hexdump(stdout, "plaintext:", plaintext,
6908 tdata->plaintext.len_bits >> 3);
6909 debug_hexdump(stdout, "plaintext expected:",
6910 tdata->plaintext.data,
6911 tdata->plaintext.len_bits >> 3);
6913 if (ut_params->obuf)
6914 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6917 ciphertext = plaintext;
6919 debug_hexdump(stdout, "ciphertext:", ciphertext,
6921 debug_hexdump(stdout, "ciphertext expected:",
6922 tdata->ciphertext.data,
6923 tdata->ciphertext.len_bits >> 3);
6925 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6926 + (tdata->digest_enc.offset == 0 ?
6927 plaintext_pad_len : tdata->digest_enc.offset);
6929 debug_hexdump(stdout, "digest:", ut_params->digest,
6930 tdata->digest_enc.len);
6931 debug_hexdump(stdout, "digest expected:",
6932 tdata->digest_enc.data,
6933 tdata->digest_enc.len);
6938 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6940 tdata->plaintext.data,
6941 tdata->plaintext.len_bits >> 3,
6942 "Plaintext data not as expected");
6944 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6946 tdata->ciphertext.data,
6947 tdata->validDataLen.len_bits,
6948 "Ciphertext data not as expected");
6950 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6952 tdata->digest_enc.data,
6953 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6954 "Generated auth tag not as expected");
6957 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6958 "crypto op processing failed");
6964 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6965 uint8_t op_mode, uint8_t verify)
6967 struct crypto_testsuite_params *ts_params = &testsuite_params;
6968 struct crypto_unittest_params *ut_params = &unittest_params;
6972 const uint8_t *plaintext = NULL;
6973 const uint8_t *ciphertext = NULL;
6974 const uint8_t *digest = NULL;
6975 unsigned int plaintext_pad_len;
6976 unsigned int plaintext_len;
6977 unsigned int ciphertext_pad_len;
6978 unsigned int ciphertext_len;
6979 uint8_t buffer[10000];
6980 uint8_t digest_buffer[10000];
6982 struct rte_cryptodev_info dev_info;
6983 struct rte_crypto_op *op;
6985 /* Check if device supports particular algorithms */
6986 if (test_mixed_check_if_unsupported(tdata))
6988 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6991 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6993 uint64_t feat_flags = dev_info.feature_flags;
6995 if (op_mode == IN_PLACE) {
6996 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6997 printf("Device doesn't support in-place scatter-gather "
6998 "in both input and output mbufs.\n");
7002 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7003 printf("Device doesn't support out-of-place scatter-gather "
7004 "in both input and output mbufs.\n");
7007 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7008 printf("Device doesn't support digest encrypted.\n");
7013 /* Create the session */
7015 retval = create_wireless_algo_cipher_auth_session(
7016 ts_params->valid_devs[0],
7017 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7018 RTE_CRYPTO_AUTH_OP_VERIFY,
7021 tdata->auth_key.data, tdata->auth_key.len,
7022 tdata->auth_iv.len, tdata->digest_enc.len,
7023 tdata->cipher_iv.len);
7025 retval = create_wireless_algo_auth_cipher_session(
7026 ts_params->valid_devs[0],
7027 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7028 RTE_CRYPTO_AUTH_OP_GENERATE,
7031 tdata->auth_key.data, tdata->auth_key.len,
7032 tdata->auth_iv.len, tdata->digest_enc.len,
7033 tdata->cipher_iv.len);
7037 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7038 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7039 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7040 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7042 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7043 ciphertext_pad_len, 15, 0);
7044 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7045 "Failed to allocate input buffer in mempool");
7047 if (op_mode == OUT_OF_PLACE) {
7048 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7049 plaintext_pad_len, 15, 0);
7050 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7051 "Failed to allocate output buffer in mempool");
7055 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7056 tdata->ciphertext.data);
7057 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7058 ciphertext_len, buffer);
7059 debug_hexdump(stdout, "ciphertext:", ciphertext,
7062 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7063 tdata->plaintext.data);
7064 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7065 plaintext_len, buffer);
7066 debug_hexdump(stdout, "plaintext:", plaintext,
7069 memset(buffer, 0, sizeof(buffer));
7071 /* Create the operation */
7072 retval = create_wireless_algo_auth_cipher_operation(
7073 tdata->digest_enc.data, tdata->digest_enc.len,
7074 tdata->cipher_iv.data, tdata->cipher_iv.len,
7075 tdata->auth_iv.data, tdata->auth_iv.len,
7076 (tdata->digest_enc.offset == 0 ?
7078 : tdata->digest_enc.offset),
7079 tdata->validCipherLen.len_bits,
7080 tdata->cipher.offset_bits,
7081 tdata->validAuthLen.len_bits,
7082 tdata->auth.offset_bits,
7083 op_mode, 1, verify);
7088 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7090 /* Check if the op failed because the device doesn't */
7091 /* support this particular combination of algorithms */
7092 if (op == NULL && ut_params->op->status ==
7093 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7094 printf("Device doesn't support this mixed combination. "
7100 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7102 ut_params->obuf = (op_mode == IN_PLACE ?
7103 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7106 if (ut_params->obuf)
7107 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7108 plaintext_len, buffer);
7110 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7111 plaintext_len, buffer);
7113 debug_hexdump(stdout, "plaintext:", plaintext,
7114 (tdata->plaintext.len_bits >> 3) -
7115 tdata->digest_enc.len);
7116 debug_hexdump(stdout, "plaintext expected:",
7117 tdata->plaintext.data,
7118 (tdata->plaintext.len_bits >> 3) -
7119 tdata->digest_enc.len);
7121 if (ut_params->obuf)
7122 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7123 ciphertext_len, buffer);
7125 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7126 ciphertext_len, buffer);
7128 debug_hexdump(stdout, "ciphertext:", ciphertext,
7130 debug_hexdump(stdout, "ciphertext expected:",
7131 tdata->ciphertext.data,
7132 tdata->ciphertext.len_bits >> 3);
7134 if (ut_params->obuf)
7135 digest = rte_pktmbuf_read(ut_params->obuf,
7136 (tdata->digest_enc.offset == 0 ?
7138 tdata->digest_enc.offset),
7139 tdata->digest_enc.len, digest_buffer);
7141 digest = rte_pktmbuf_read(ut_params->ibuf,
7142 (tdata->digest_enc.offset == 0 ?
7144 tdata->digest_enc.offset),
7145 tdata->digest_enc.len, digest_buffer);
7147 debug_hexdump(stdout, "digest:", digest,
7148 tdata->digest_enc.len);
7149 debug_hexdump(stdout, "digest expected:",
7150 tdata->digest_enc.data, tdata->digest_enc.len);
7155 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7157 tdata->plaintext.data,
7158 tdata->plaintext.len_bits >> 3,
7159 "Plaintext data not as expected");
7161 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7163 tdata->ciphertext.data,
7164 tdata->validDataLen.len_bits,
7165 "Ciphertext data not as expected");
7166 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7168 tdata->digest_enc.data,
7169 tdata->digest_enc.len,
7170 "Generated auth tag not as expected");
7173 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7174 "crypto op processing failed");
7179 /** AUTH AES CMAC + CIPHER AES CTR */
7182 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7184 return test_mixed_auth_cipher(
7185 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7189 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7191 return test_mixed_auth_cipher(
7192 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7196 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7198 return test_mixed_auth_cipher_sgl(
7199 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7203 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7205 return test_mixed_auth_cipher_sgl(
7206 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7210 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7212 return test_mixed_auth_cipher(
7213 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7217 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7219 return test_mixed_auth_cipher(
7220 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7224 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7226 return test_mixed_auth_cipher_sgl(
7227 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7231 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7233 return test_mixed_auth_cipher_sgl(
7234 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7237 /** MIXED AUTH + CIPHER */
7240 test_auth_zuc_cipher_snow_test_case_1(void)
7242 return test_mixed_auth_cipher(
7243 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7247 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7249 return test_mixed_auth_cipher(
7250 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7254 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7256 return test_mixed_auth_cipher(
7257 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7261 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7263 return test_mixed_auth_cipher(
7264 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7268 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7270 return test_mixed_auth_cipher(
7271 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7275 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7277 return test_mixed_auth_cipher(
7278 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7282 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7284 return test_mixed_auth_cipher(
7285 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7289 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7291 return test_mixed_auth_cipher(
7292 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7296 test_auth_snow_cipher_zuc_test_case_1(void)
7298 return test_mixed_auth_cipher(
7299 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7303 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7305 return test_mixed_auth_cipher(
7306 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7310 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7312 return test_mixed_auth_cipher(
7313 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7317 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7319 return test_mixed_auth_cipher(
7320 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7324 test_auth_null_cipher_snow_test_case_1(void)
7326 return test_mixed_auth_cipher(
7327 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7331 test_verify_auth_null_cipher_snow_test_case_1(void)
7333 return test_mixed_auth_cipher(
7334 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7338 test_auth_null_cipher_zuc_test_case_1(void)
7340 return test_mixed_auth_cipher(
7341 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7345 test_verify_auth_null_cipher_zuc_test_case_1(void)
7347 return test_mixed_auth_cipher(
7348 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7352 test_auth_snow_cipher_null_test_case_1(void)
7354 return test_mixed_auth_cipher(
7355 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7359 test_verify_auth_snow_cipher_null_test_case_1(void)
7361 return test_mixed_auth_cipher(
7362 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7366 test_auth_zuc_cipher_null_test_case_1(void)
7368 return test_mixed_auth_cipher(
7369 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7373 test_verify_auth_zuc_cipher_null_test_case_1(void)
7375 return test_mixed_auth_cipher(
7376 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7380 test_auth_null_cipher_aes_ctr_test_case_1(void)
7382 return test_mixed_auth_cipher(
7383 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7387 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7389 return test_mixed_auth_cipher(
7390 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7394 test_auth_aes_cmac_cipher_null_test_case_1(void)
7396 return test_mixed_auth_cipher(
7397 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7401 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7403 return test_mixed_auth_cipher(
7404 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7407 /* ***** AEAD algorithm Tests ***** */
7410 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7411 enum rte_crypto_aead_operation op,
7412 const uint8_t *key, const uint8_t key_len,
7413 const uint16_t aad_len, const uint8_t auth_len,
7416 uint8_t aead_key[key_len];
7418 struct crypto_testsuite_params *ts_params = &testsuite_params;
7419 struct crypto_unittest_params *ut_params = &unittest_params;
7421 memcpy(aead_key, key, key_len);
7423 /* Setup AEAD Parameters */
7424 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7425 ut_params->aead_xform.next = NULL;
7426 ut_params->aead_xform.aead.algo = algo;
7427 ut_params->aead_xform.aead.op = op;
7428 ut_params->aead_xform.aead.key.data = aead_key;
7429 ut_params->aead_xform.aead.key.length = key_len;
7430 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7431 ut_params->aead_xform.aead.iv.length = iv_len;
7432 ut_params->aead_xform.aead.digest_length = auth_len;
7433 ut_params->aead_xform.aead.aad_length = aad_len;
7435 debug_hexdump(stdout, "key:", key, key_len);
7437 /* Create Crypto session*/
7438 ut_params->sess = rte_cryptodev_sym_session_create(
7439 ts_params->session_mpool);
7441 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7442 &ut_params->aead_xform,
7443 ts_params->session_priv_mpool);
7445 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7451 create_aead_xform(struct rte_crypto_op *op,
7452 enum rte_crypto_aead_algorithm algo,
7453 enum rte_crypto_aead_operation aead_op,
7454 uint8_t *key, const uint8_t key_len,
7455 const uint8_t aad_len, const uint8_t auth_len,
7458 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7459 "failed to allocate space for crypto transform");
7461 struct rte_crypto_sym_op *sym_op = op->sym;
7463 /* Setup AEAD Parameters */
7464 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7465 sym_op->xform->next = NULL;
7466 sym_op->xform->aead.algo = algo;
7467 sym_op->xform->aead.op = aead_op;
7468 sym_op->xform->aead.key.data = key;
7469 sym_op->xform->aead.key.length = key_len;
7470 sym_op->xform->aead.iv.offset = IV_OFFSET;
7471 sym_op->xform->aead.iv.length = iv_len;
7472 sym_op->xform->aead.digest_length = auth_len;
7473 sym_op->xform->aead.aad_length = aad_len;
7475 debug_hexdump(stdout, "key:", key, key_len);
7481 create_aead_operation(enum rte_crypto_aead_operation op,
7482 const struct aead_test_data *tdata)
7484 struct crypto_testsuite_params *ts_params = &testsuite_params;
7485 struct crypto_unittest_params *ut_params = &unittest_params;
7487 uint8_t *plaintext, *ciphertext;
7488 unsigned int aad_pad_len, plaintext_pad_len;
7490 /* Generate Crypto op data structure */
7491 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7492 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7493 TEST_ASSERT_NOT_NULL(ut_params->op,
7494 "Failed to allocate symmetric crypto operation struct");
7496 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7498 /* Append aad data */
7499 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7500 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7501 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7503 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7504 "no room to append aad");
7506 sym_op->aead.aad.phys_addr =
7507 rte_pktmbuf_iova(ut_params->ibuf);
7508 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7509 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7510 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7513 /* Append IV at the end of the crypto operation*/
7514 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7515 uint8_t *, IV_OFFSET);
7517 /* Copy IV 1 byte after the IV pointer, according to the API */
7518 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7519 debug_hexdump(stdout, "iv:", iv_ptr,
7522 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7523 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7525 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7526 "no room to append aad");
7528 sym_op->aead.aad.phys_addr =
7529 rte_pktmbuf_iova(ut_params->ibuf);
7530 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7531 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7534 /* Append IV at the end of the crypto operation*/
7535 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7536 uint8_t *, IV_OFFSET);
7538 if (tdata->iv.len == 0) {
7539 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7540 debug_hexdump(stdout, "iv:", iv_ptr,
7543 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7544 debug_hexdump(stdout, "iv:", iv_ptr,
7549 /* Append plaintext/ciphertext */
7550 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7551 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7552 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7554 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7556 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7557 debug_hexdump(stdout, "plaintext:", plaintext,
7558 tdata->plaintext.len);
7560 if (ut_params->obuf) {
7561 ciphertext = (uint8_t *)rte_pktmbuf_append(
7563 plaintext_pad_len + aad_pad_len);
7564 TEST_ASSERT_NOT_NULL(ciphertext,
7565 "no room to append ciphertext");
7567 memset(ciphertext + aad_pad_len, 0,
7568 tdata->ciphertext.len);
7571 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7572 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7574 TEST_ASSERT_NOT_NULL(ciphertext,
7575 "no room to append ciphertext");
7577 memcpy(ciphertext, tdata->ciphertext.data,
7578 tdata->ciphertext.len);
7579 debug_hexdump(stdout, "ciphertext:", ciphertext,
7580 tdata->ciphertext.len);
7582 if (ut_params->obuf) {
7583 plaintext = (uint8_t *)rte_pktmbuf_append(
7585 plaintext_pad_len + aad_pad_len);
7586 TEST_ASSERT_NOT_NULL(plaintext,
7587 "no room to append plaintext");
7589 memset(plaintext + aad_pad_len, 0,
7590 tdata->plaintext.len);
7594 /* Append digest data */
7595 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7596 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7597 ut_params->obuf ? ut_params->obuf :
7599 tdata->auth_tag.len);
7600 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7601 "no room to append digest");
7602 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7603 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7604 ut_params->obuf ? ut_params->obuf :
7609 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7610 ut_params->ibuf, tdata->auth_tag.len);
7611 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7612 "no room to append digest");
7613 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7615 plaintext_pad_len + aad_pad_len);
7617 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7618 tdata->auth_tag.len);
7619 debug_hexdump(stdout, "digest:",
7620 sym_op->aead.digest.data,
7621 tdata->auth_tag.len);
7624 sym_op->aead.data.length = tdata->plaintext.len;
7625 sym_op->aead.data.offset = aad_pad_len;
7631 test_authenticated_encryption(const struct aead_test_data *tdata)
7633 struct crypto_testsuite_params *ts_params = &testsuite_params;
7634 struct crypto_unittest_params *ut_params = &unittest_params;
7637 uint8_t *ciphertext, *auth_tag;
7638 uint16_t plaintext_pad_len;
7640 struct rte_cryptodev_info dev_info;
7642 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7643 uint64_t feat_flags = dev_info.feature_flags;
7645 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7646 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7647 printf("Device doesn't support RAW data-path APIs.\n");
7651 /* Verify the capabilities */
7652 struct rte_cryptodev_sym_capability_idx cap_idx;
7653 const struct rte_cryptodev_symmetric_capability *capability;
7654 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7655 cap_idx.algo.aead = tdata->algo;
7656 capability = rte_cryptodev_sym_capability_get(
7657 ts_params->valid_devs[0], &cap_idx);
7658 if (capability == NULL)
7660 if (rte_cryptodev_sym_capability_check_aead(
7661 capability, tdata->key.len, tdata->auth_tag.len,
7662 tdata->aad.len, tdata->iv.len))
7665 /* Create AEAD session */
7666 retval = create_aead_session(ts_params->valid_devs[0],
7668 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7669 tdata->key.data, tdata->key.len,
7670 tdata->aad.len, tdata->auth_tag.len,
7675 if (tdata->aad.len > MBUF_SIZE) {
7676 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7677 /* Populate full size of add data */
7678 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7679 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7681 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7683 /* clear mbuf payload */
7684 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7685 rte_pktmbuf_tailroom(ut_params->ibuf));
7687 /* Create AEAD operation */
7688 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7692 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7694 ut_params->op->sym->m_src = ut_params->ibuf;
7696 /* Process crypto operation */
7697 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7698 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7699 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7700 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
7701 ut_params->op, 0, 0, 0, 0);
7703 TEST_ASSERT_NOT_NULL(
7704 process_crypto_request(ts_params->valid_devs[0],
7705 ut_params->op), "failed to process sym crypto op");
7707 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7708 "crypto op processing failed");
7710 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7712 if (ut_params->op->sym->m_dst) {
7713 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7715 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7716 uint8_t *, plaintext_pad_len);
7718 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7720 ut_params->op->sym->cipher.data.offset);
7721 auth_tag = ciphertext + plaintext_pad_len;
7724 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7725 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7730 tdata->ciphertext.data,
7731 tdata->ciphertext.len,
7732 "Ciphertext data not as expected");
7734 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7736 tdata->auth_tag.data,
7737 tdata->auth_tag.len,
7738 "Generated auth tag not as expected");
7744 #ifdef RTE_LIB_SECURITY
7746 security_proto_supported(enum rte_security_session_action_type action,
7747 enum rte_security_session_protocol proto)
7749 struct crypto_testsuite_params *ts_params = &testsuite_params;
7751 const struct rte_security_capability *capabilities;
7752 const struct rte_security_capability *capability;
7755 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7756 rte_cryptodev_get_sec_ctx(
7757 ts_params->valid_devs[0]);
7760 capabilities = rte_security_capabilities_get(ctx);
7762 if (capabilities == NULL)
7765 while ((capability = &capabilities[i++])->action !=
7766 RTE_SECURITY_ACTION_TYPE_NONE) {
7767 if (capability->action == action &&
7768 capability->protocol == proto)
7775 /* Basic algorithm run function for async inplace mode.
7776 * Creates a session from input parameters and runs one operation
7777 * on input_vec. Checks the output of the crypto operation against
7780 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
7781 enum rte_crypto_auth_operation opa,
7782 const uint8_t *input_vec, unsigned int input_vec_len,
7783 const uint8_t *output_vec,
7784 unsigned int output_vec_len,
7785 enum rte_crypto_cipher_algorithm cipher_alg,
7786 const uint8_t *cipher_key, uint32_t cipher_key_len,
7787 enum rte_crypto_auth_algorithm auth_alg,
7788 const uint8_t *auth_key, uint32_t auth_key_len,
7789 uint8_t bearer, enum rte_security_pdcp_domain domain,
7790 uint8_t packet_direction, uint8_t sn_size,
7791 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
7793 struct crypto_testsuite_params *ts_params = &testsuite_params;
7794 struct crypto_unittest_params *ut_params = &unittest_params;
7796 int ret = TEST_SUCCESS;
7797 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7798 rte_cryptodev_get_sec_ctx(
7799 ts_params->valid_devs[0]);
7801 /* Verify the capabilities */
7802 struct rte_security_capability_idx sec_cap_idx;
7804 sec_cap_idx.action = ut_params->type;
7805 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7806 sec_cap_idx.pdcp.domain = domain;
7807 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7810 /* Generate test mbuf data */
7811 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7813 /* clear mbuf payload */
7814 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7815 rte_pktmbuf_tailroom(ut_params->ibuf));
7817 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7819 memcpy(plaintext, input_vec, input_vec_len);
7821 /* Out of place support */
7824 * For out-op-place we need to alloc another mbuf
7826 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7827 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7830 /* Setup Cipher Parameters */
7831 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7832 ut_params->cipher_xform.cipher.algo = cipher_alg;
7833 ut_params->cipher_xform.cipher.op = opc;
7834 ut_params->cipher_xform.cipher.key.data = cipher_key;
7835 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
7836 ut_params->cipher_xform.cipher.iv.length =
7837 packet_direction ? 4 : 0;
7838 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7840 /* Setup HMAC Parameters if ICV header is required */
7841 if (auth_alg != 0) {
7842 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7843 ut_params->auth_xform.next = NULL;
7844 ut_params->auth_xform.auth.algo = auth_alg;
7845 ut_params->auth_xform.auth.op = opa;
7846 ut_params->auth_xform.auth.key.data = auth_key;
7847 ut_params->auth_xform.auth.key.length = auth_key_len;
7849 ut_params->cipher_xform.next = &ut_params->auth_xform;
7851 ut_params->cipher_xform.next = NULL;
7854 struct rte_security_session_conf sess_conf = {
7855 .action_type = ut_params->type,
7856 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7860 .pkt_dir = packet_direction,
7862 .hfn = packet_direction ? 0 : hfn,
7864 * hfn can be set as pdcp_test_hfn[i]
7865 * if hfn_ovrd is not set. Here, PDCP
7866 * packet direction is just used to
7867 * run half of the cases with session
7868 * HFN and other half with per packet
7871 .hfn_threshold = hfn_threshold,
7872 .hfn_ovrd = packet_direction ? 1 : 0,
7873 .sdap_enabled = sdap,
7875 .crypto_xform = &ut_params->cipher_xform
7878 /* Create security session */
7879 ut_params->sec_session = rte_security_session_create(ctx,
7880 &sess_conf, ts_params->session_mpool,
7881 ts_params->session_priv_mpool);
7883 if (!ut_params->sec_session) {
7884 printf("TestCase %s()-%d line %d failed %s: ",
7885 __func__, i, __LINE__, "Failed to allocate session");
7890 /* Generate crypto op data structure */
7891 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7892 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7893 if (!ut_params->op) {
7894 printf("TestCase %s()-%d line %d failed %s: ",
7895 __func__, i, __LINE__,
7896 "Failed to allocate symmetric crypto operation struct");
7901 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7902 uint32_t *, IV_OFFSET);
7903 *per_pkt_hfn = packet_direction ? hfn : 0;
7905 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7907 /* set crypto operation source mbuf */
7908 ut_params->op->sym->m_src = ut_params->ibuf;
7910 ut_params->op->sym->m_dst = ut_params->obuf;
7912 /* Process crypto operation */
7913 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7915 printf("TestCase %s()-%d line %d failed %s: ",
7916 __func__, i, __LINE__,
7917 "failed to process sym crypto op");
7922 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7923 printf("TestCase %s()-%d line %d failed %s: ",
7924 __func__, i, __LINE__, "crypto op processing failed");
7930 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7933 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7937 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7938 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7939 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7940 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7946 rte_crypto_op_free(ut_params->op);
7947 ut_params->op = NULL;
7949 if (ut_params->sec_session)
7950 rte_security_session_destroy(ctx, ut_params->sec_session);
7951 ut_params->sec_session = NULL;
7953 rte_pktmbuf_free(ut_params->ibuf);
7954 ut_params->ibuf = NULL;
7956 rte_pktmbuf_free(ut_params->obuf);
7957 ut_params->obuf = NULL;
7964 test_pdcp_proto_SGL(int i, int oop,
7965 enum rte_crypto_cipher_operation opc,
7966 enum rte_crypto_auth_operation opa,
7968 unsigned int input_vec_len,
7969 uint8_t *output_vec,
7970 unsigned int output_vec_len,
7972 uint32_t fragsz_oop)
7974 struct crypto_testsuite_params *ts_params = &testsuite_params;
7975 struct crypto_unittest_params *ut_params = &unittest_params;
7977 struct rte_mbuf *buf, *buf_oop = NULL;
7978 int ret = TEST_SUCCESS;
7982 unsigned int trn_data = 0;
7983 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7984 rte_cryptodev_get_sec_ctx(
7985 ts_params->valid_devs[0]);
7987 /* Verify the capabilities */
7988 struct rte_security_capability_idx sec_cap_idx;
7990 sec_cap_idx.action = ut_params->type;
7991 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7992 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7993 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7996 if (fragsz > input_vec_len)
7997 fragsz = input_vec_len;
7999 uint16_t plaintext_len = fragsz;
8000 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8002 if (fragsz_oop > output_vec_len)
8003 frag_size_oop = output_vec_len;
8006 if (input_vec_len % fragsz != 0) {
8007 if (input_vec_len / fragsz + 1 > 16)
8009 } else if (input_vec_len / fragsz > 16)
8012 /* Out of place support */
8015 * For out-op-place we need to alloc another mbuf
8017 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8018 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8019 buf_oop = ut_params->obuf;
8022 /* Generate test mbuf data */
8023 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8025 /* clear mbuf payload */
8026 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8027 rte_pktmbuf_tailroom(ut_params->ibuf));
8029 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8031 memcpy(plaintext, input_vec, plaintext_len);
8032 trn_data += plaintext_len;
8034 buf = ut_params->ibuf;
8037 * Loop until no more fragments
8040 while (trn_data < input_vec_len) {
8042 to_trn = (input_vec_len - trn_data < fragsz) ?
8043 (input_vec_len - trn_data) : fragsz;
8045 to_trn_tbl[ecx++] = to_trn;
8047 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8050 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8051 rte_pktmbuf_tailroom(buf));
8054 if (oop && !fragsz_oop) {
8056 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8057 buf_oop = buf_oop->next;
8058 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8059 0, rte_pktmbuf_tailroom(buf_oop));
8060 rte_pktmbuf_append(buf_oop, to_trn);
8063 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8066 memcpy(plaintext, input_vec + trn_data, to_trn);
8070 ut_params->ibuf->nb_segs = segs;
8073 if (fragsz_oop && oop) {
8077 trn_data = frag_size_oop;
8078 while (trn_data < output_vec_len) {
8081 (output_vec_len - trn_data <
8083 (output_vec_len - trn_data) :
8086 to_trn_tbl[ecx++] = to_trn;
8089 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8090 buf_oop = buf_oop->next;
8091 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8092 0, rte_pktmbuf_tailroom(buf_oop));
8093 rte_pktmbuf_append(buf_oop, to_trn);
8097 ut_params->obuf->nb_segs = segs;
8100 /* Setup Cipher Parameters */
8101 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8102 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8103 ut_params->cipher_xform.cipher.op = opc;
8104 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8105 ut_params->cipher_xform.cipher.key.length =
8106 pdcp_test_params[i].cipher_key_len;
8107 ut_params->cipher_xform.cipher.iv.length = 0;
8109 /* Setup HMAC Parameters if ICV header is required */
8110 if (pdcp_test_params[i].auth_alg != 0) {
8111 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8112 ut_params->auth_xform.next = NULL;
8113 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8114 ut_params->auth_xform.auth.op = opa;
8115 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8116 ut_params->auth_xform.auth.key.length =
8117 pdcp_test_params[i].auth_key_len;
8119 ut_params->cipher_xform.next = &ut_params->auth_xform;
8121 ut_params->cipher_xform.next = NULL;
8124 struct rte_security_session_conf sess_conf = {
8125 .action_type = ut_params->type,
8126 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8128 .bearer = pdcp_test_bearer[i],
8129 .domain = pdcp_test_params[i].domain,
8130 .pkt_dir = pdcp_test_packet_direction[i],
8131 .sn_size = pdcp_test_data_sn_size[i],
8132 .hfn = pdcp_test_hfn[i],
8133 .hfn_threshold = pdcp_test_hfn_threshold[i],
8136 .crypto_xform = &ut_params->cipher_xform
8139 /* Create security session */
8140 ut_params->sec_session = rte_security_session_create(ctx,
8141 &sess_conf, ts_params->session_mpool,
8142 ts_params->session_priv_mpool);
8144 if (!ut_params->sec_session) {
8145 printf("TestCase %s()-%d line %d failed %s: ",
8146 __func__, i, __LINE__, "Failed to allocate session");
8151 /* Generate crypto op data structure */
8152 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8153 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8154 if (!ut_params->op) {
8155 printf("TestCase %s()-%d line %d failed %s: ",
8156 __func__, i, __LINE__,
8157 "Failed to allocate symmetric crypto operation struct");
8162 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8164 /* set crypto operation source mbuf */
8165 ut_params->op->sym->m_src = ut_params->ibuf;
8167 ut_params->op->sym->m_dst = ut_params->obuf;
8169 /* Process crypto operation */
8170 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8172 printf("TestCase %s()-%d line %d failed %s: ",
8173 __func__, i, __LINE__,
8174 "failed to process sym crypto op");
8179 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8180 printf("TestCase %s()-%d line %d failed %s: ",
8181 __func__, i, __LINE__, "crypto op processing failed");
8187 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8190 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8194 fragsz = frag_size_oop;
8195 if (memcmp(ciphertext, output_vec, fragsz)) {
8196 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8197 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8198 rte_hexdump(stdout, "reference", output_vec, fragsz);
8203 buf = ut_params->op->sym->m_src->next;
8205 buf = ut_params->op->sym->m_dst->next;
8207 unsigned int off = fragsz;
8211 ciphertext = rte_pktmbuf_mtod(buf,
8213 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8214 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8215 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8216 rte_hexdump(stdout, "reference", output_vec + off,
8221 off += to_trn_tbl[ecx++];
8225 rte_crypto_op_free(ut_params->op);
8226 ut_params->op = NULL;
8228 if (ut_params->sec_session)
8229 rte_security_session_destroy(ctx, ut_params->sec_session);
8230 ut_params->sec_session = NULL;
8232 rte_pktmbuf_free(ut_params->ibuf);
8233 ut_params->ibuf = NULL;
8235 rte_pktmbuf_free(ut_params->obuf);
8236 ut_params->obuf = NULL;
8243 test_pdcp_proto_cplane_encap(int i)
8245 return test_pdcp_proto(
8246 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8247 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8248 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8249 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8250 pdcp_test_params[i].cipher_key_len,
8251 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8252 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8253 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8254 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8255 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8259 test_pdcp_proto_uplane_encap(int i)
8261 return test_pdcp_proto(
8262 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8263 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8264 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8265 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8266 pdcp_test_params[i].cipher_key_len,
8267 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8268 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8269 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8270 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8271 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8275 test_pdcp_proto_uplane_encap_with_int(int i)
8277 return test_pdcp_proto(
8278 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8279 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8280 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8281 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8282 pdcp_test_params[i].cipher_key_len,
8283 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8284 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8285 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8286 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8287 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8291 test_pdcp_proto_cplane_decap(int i)
8293 return test_pdcp_proto(
8294 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8295 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8296 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8297 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8298 pdcp_test_params[i].cipher_key_len,
8299 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8300 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8301 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8302 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8303 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8307 test_pdcp_proto_uplane_decap(int i)
8309 return test_pdcp_proto(
8310 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8311 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8312 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8313 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8314 pdcp_test_params[i].cipher_key_len,
8315 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8316 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8317 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8318 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8319 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8323 test_pdcp_proto_uplane_decap_with_int(int i)
8325 return test_pdcp_proto(
8326 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8327 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8328 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8329 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8330 pdcp_test_params[i].cipher_key_len,
8331 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8332 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8333 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8334 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8335 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8339 test_PDCP_PROTO_SGL_in_place_32B(void)
8341 /* i can be used for running any PDCP case
8342 * In this case it is uplane 12-bit AES-SNOW DL encap
8344 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8345 return test_pdcp_proto_SGL(i, IN_PLACE,
8346 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8347 RTE_CRYPTO_AUTH_OP_GENERATE,
8348 pdcp_test_data_in[i],
8349 pdcp_test_data_in_len[i],
8350 pdcp_test_data_out[i],
8351 pdcp_test_data_in_len[i]+4,
8355 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8357 /* i can be used for running any PDCP case
8358 * In this case it is uplane 18-bit NULL-NULL DL encap
8360 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8361 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8362 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8363 RTE_CRYPTO_AUTH_OP_GENERATE,
8364 pdcp_test_data_in[i],
8365 pdcp_test_data_in_len[i],
8366 pdcp_test_data_out[i],
8367 pdcp_test_data_in_len[i]+4,
8371 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8373 /* i can be used for running any PDCP case
8374 * In this case it is uplane 18-bit AES DL encap
8376 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8378 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8379 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8380 RTE_CRYPTO_AUTH_OP_GENERATE,
8381 pdcp_test_data_in[i],
8382 pdcp_test_data_in_len[i],
8383 pdcp_test_data_out[i],
8384 pdcp_test_data_in_len[i],
8388 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8390 /* i can be used for running any PDCP case
8391 * In this case it is cplane 12-bit AES-ZUC DL encap
8393 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8394 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8395 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8396 RTE_CRYPTO_AUTH_OP_GENERATE,
8397 pdcp_test_data_in[i],
8398 pdcp_test_data_in_len[i],
8399 pdcp_test_data_out[i],
8400 pdcp_test_data_in_len[i]+4,
8405 test_PDCP_SDAP_PROTO_encap_all(void)
8407 int i = 0, size = 0;
8408 int err, all_err = TEST_SUCCESS;
8409 const struct pdcp_sdap_test *cur_test;
8411 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8413 for (i = 0; i < size; i++) {
8414 cur_test = &list_pdcp_sdap_tests[i];
8415 err = test_pdcp_proto(
8416 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8417 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8418 cur_test->in_len, cur_test->data_out,
8419 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8420 cur_test->param.cipher_alg, cur_test->cipher_key,
8421 cur_test->param.cipher_key_len,
8422 cur_test->param.auth_alg,
8423 cur_test->auth_key, cur_test->param.auth_key_len,
8424 cur_test->bearer, cur_test->param.domain,
8425 cur_test->packet_direction, cur_test->sn_size,
8427 cur_test->hfn_threshold, SDAP_ENABLED);
8429 printf("\t%d) %s: Encapsulation failed\n",
8431 cur_test->param.name);
8434 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8435 cur_test->param.name);
8441 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8443 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8447 test_PDCP_SDAP_PROTO_decap_all(void)
8449 int i = 0, size = 0;
8450 int err, all_err = TEST_SUCCESS;
8451 const struct pdcp_sdap_test *cur_test;
8453 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8455 for (i = 0; i < size; i++) {
8456 cur_test = &list_pdcp_sdap_tests[i];
8457 err = test_pdcp_proto(
8458 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8459 RTE_CRYPTO_AUTH_OP_VERIFY,
8461 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8462 cur_test->data_in, cur_test->in_len,
8463 cur_test->param.cipher_alg,
8464 cur_test->cipher_key, cur_test->param.cipher_key_len,
8465 cur_test->param.auth_alg, cur_test->auth_key,
8466 cur_test->param.auth_key_len, cur_test->bearer,
8467 cur_test->param.domain, cur_test->packet_direction,
8468 cur_test->sn_size, cur_test->hfn,
8469 cur_test->hfn_threshold, SDAP_ENABLED);
8471 printf("\t%d) %s: Decapsulation failed\n",
8473 cur_test->param.name);
8476 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8477 cur_test->param.name);
8483 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8485 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8489 test_PDCP_PROTO_all(void)
8491 struct crypto_testsuite_params *ts_params = &testsuite_params;
8492 struct crypto_unittest_params *ut_params = &unittest_params;
8493 struct rte_cryptodev_info dev_info;
8496 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8497 uint64_t feat_flags = dev_info.feature_flags;
8499 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8502 /* Set action type */
8503 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8504 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8507 if (security_proto_supported(ut_params->type,
8508 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8511 status = test_PDCP_PROTO_cplane_encap_all();
8512 status += test_PDCP_PROTO_cplane_decap_all();
8513 status += test_PDCP_PROTO_uplane_encap_all();
8514 status += test_PDCP_PROTO_uplane_decap_all();
8515 status += test_PDCP_PROTO_SGL_in_place_32B();
8516 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8517 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8518 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8519 status += test_PDCP_SDAP_PROTO_encap_all();
8520 status += test_PDCP_SDAP_PROTO_decap_all();
8525 return TEST_SUCCESS;
8529 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8531 struct crypto_testsuite_params *ts_params = &testsuite_params;
8532 struct crypto_unittest_params *ut_params = &unittest_params;
8533 uint8_t *plaintext, *ciphertext;
8535 int32_t cipher_len, crc_len;
8536 uint32_t crc_data_len;
8537 int ret = TEST_SUCCESS;
8539 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8540 rte_cryptodev_get_sec_ctx(
8541 ts_params->valid_devs[0]);
8543 /* Verify the capabilities */
8544 struct rte_security_capability_idx sec_cap_idx;
8545 const struct rte_security_capability *sec_cap;
8546 const struct rte_cryptodev_capabilities *crypto_cap;
8547 const struct rte_cryptodev_symmetric_capability *sym_cap;
8550 sec_cap_idx.action = ut_params->type;
8551 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8552 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8554 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8555 if (sec_cap == NULL)
8558 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8559 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8560 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8561 crypto_cap->sym.xform_type ==
8562 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8563 crypto_cap->sym.cipher.algo ==
8564 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8565 sym_cap = &crypto_cap->sym;
8566 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8573 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8576 /* Setup source mbuf payload */
8577 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8578 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8579 rte_pktmbuf_tailroom(ut_params->ibuf));
8581 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8582 d_td->ciphertext.len);
8584 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8586 /* Setup cipher session parameters */
8587 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8588 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8589 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8590 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8591 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8592 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8593 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8594 ut_params->cipher_xform.next = NULL;
8596 /* Setup DOCSIS session parameters */
8597 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8599 struct rte_security_session_conf sess_conf = {
8600 .action_type = ut_params->type,
8601 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8602 .docsis = ut_params->docsis_xform,
8603 .crypto_xform = &ut_params->cipher_xform,
8606 /* Create security session */
8607 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8608 ts_params->session_mpool,
8609 ts_params->session_priv_mpool);
8611 if (!ut_params->sec_session) {
8612 printf("TestCase %s(%d) line %d: %s\n",
8613 __func__, i, __LINE__, "failed to allocate session");
8618 /* Generate crypto op data structure */
8619 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8620 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8621 if (!ut_params->op) {
8622 printf("TestCase %s(%d) line %d: %s\n",
8623 __func__, i, __LINE__,
8624 "failed to allocate symmetric crypto operation");
8629 /* Setup CRC operation parameters */
8630 crc_len = d_td->ciphertext.no_crc == false ?
8631 (d_td->ciphertext.len -
8632 d_td->ciphertext.crc_offset -
8633 RTE_ETHER_CRC_LEN) :
8635 crc_len = crc_len > 0 ? crc_len : 0;
8636 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8637 ut_params->op->sym->auth.data.length = crc_len;
8638 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8640 /* Setup cipher operation parameters */
8641 cipher_len = d_td->ciphertext.no_cipher == false ?
8642 (d_td->ciphertext.len -
8643 d_td->ciphertext.cipher_offset) :
8645 cipher_len = cipher_len > 0 ? cipher_len : 0;
8646 ut_params->op->sym->cipher.data.length = cipher_len;
8647 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8649 /* Setup cipher IV */
8650 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8651 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8653 /* Attach session to operation */
8654 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8656 /* Set crypto operation mbufs */
8657 ut_params->op->sym->m_src = ut_params->ibuf;
8658 ut_params->op->sym->m_dst = NULL;
8660 /* Process crypto operation */
8661 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8663 printf("TestCase %s(%d) line %d: %s\n",
8664 __func__, i, __LINE__,
8665 "failed to process security crypto op");
8670 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8671 printf("TestCase %s(%d) line %d: %s\n",
8672 __func__, i, __LINE__, "crypto op processing failed");
8677 /* Validate plaintext */
8678 plaintext = ciphertext;
8680 if (memcmp(plaintext, d_td->plaintext.data,
8681 d_td->plaintext.len - crc_data_len)) {
8682 printf("TestCase %s(%d) line %d: %s\n",
8683 __func__, i, __LINE__, "plaintext not as expected\n");
8684 rte_hexdump(stdout, "expected", d_td->plaintext.data,
8685 d_td->plaintext.len);
8686 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
8692 rte_crypto_op_free(ut_params->op);
8693 ut_params->op = NULL;
8695 if (ut_params->sec_session)
8696 rte_security_session_destroy(ctx, ut_params->sec_session);
8697 ut_params->sec_session = NULL;
8699 rte_pktmbuf_free(ut_params->ibuf);
8700 ut_params->ibuf = NULL;
8706 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
8708 struct crypto_testsuite_params *ts_params = &testsuite_params;
8709 struct crypto_unittest_params *ut_params = &unittest_params;
8710 uint8_t *plaintext, *ciphertext;
8712 int32_t cipher_len, crc_len;
8713 int ret = TEST_SUCCESS;
8715 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8716 rte_cryptodev_get_sec_ctx(
8717 ts_params->valid_devs[0]);
8719 /* Verify the capabilities */
8720 struct rte_security_capability_idx sec_cap_idx;
8721 const struct rte_security_capability *sec_cap;
8722 const struct rte_cryptodev_capabilities *crypto_cap;
8723 const struct rte_cryptodev_symmetric_capability *sym_cap;
8726 sec_cap_idx.action = ut_params->type;
8727 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8728 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8730 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8731 if (sec_cap == NULL)
8734 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8735 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8736 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8737 crypto_cap->sym.xform_type ==
8738 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8739 crypto_cap->sym.cipher.algo ==
8740 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8741 sym_cap = &crypto_cap->sym;
8742 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8749 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8752 /* Setup source mbuf payload */
8753 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8754 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8755 rte_pktmbuf_tailroom(ut_params->ibuf));
8757 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8758 d_td->plaintext.len);
8760 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
8762 /* Setup cipher session parameters */
8763 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8764 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8765 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8766 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8767 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8768 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8769 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8770 ut_params->cipher_xform.next = NULL;
8772 /* Setup DOCSIS session parameters */
8773 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8775 struct rte_security_session_conf sess_conf = {
8776 .action_type = ut_params->type,
8777 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8778 .docsis = ut_params->docsis_xform,
8779 .crypto_xform = &ut_params->cipher_xform,
8782 /* Create security session */
8783 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8784 ts_params->session_mpool,
8785 ts_params->session_priv_mpool);
8787 if (!ut_params->sec_session) {
8788 printf("TestCase %s(%d) line %d: %s\n",
8789 __func__, i, __LINE__, "failed to allocate session");
8794 /* Generate crypto op data structure */
8795 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8796 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8797 if (!ut_params->op) {
8798 printf("TestCase %s(%d) line %d: %s\n",
8799 __func__, i, __LINE__,
8800 "failed to allocate security crypto operation");
8805 /* Setup CRC operation parameters */
8806 crc_len = d_td->plaintext.no_crc == false ?
8807 (d_td->plaintext.len -
8808 d_td->plaintext.crc_offset -
8809 RTE_ETHER_CRC_LEN) :
8811 crc_len = crc_len > 0 ? crc_len : 0;
8812 ut_params->op->sym->auth.data.length = crc_len;
8813 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8815 /* Setup cipher operation parameters */
8816 cipher_len = d_td->plaintext.no_cipher == false ?
8817 (d_td->plaintext.len -
8818 d_td->plaintext.cipher_offset) :
8820 cipher_len = cipher_len > 0 ? cipher_len : 0;
8821 ut_params->op->sym->cipher.data.length = cipher_len;
8822 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8824 /* Setup cipher IV */
8825 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8826 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8828 /* Attach session to operation */
8829 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8831 /* Set crypto operation mbufs */
8832 ut_params->op->sym->m_src = ut_params->ibuf;
8833 ut_params->op->sym->m_dst = NULL;
8835 /* Process crypto operation */
8836 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8838 printf("TestCase %s(%d) line %d: %s\n",
8839 __func__, i, __LINE__,
8840 "failed to process security crypto op");
8845 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8846 printf("TestCase %s(%d) line %d: %s\n",
8847 __func__, i, __LINE__, "crypto op processing failed");
8852 /* Validate ciphertext */
8853 ciphertext = plaintext;
8855 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8856 printf("TestCase %s(%d) line %d: %s\n",
8857 __func__, i, __LINE__, "ciphertext not as expected\n");
8858 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8859 d_td->ciphertext.len);
8860 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8866 rte_crypto_op_free(ut_params->op);
8867 ut_params->op = NULL;
8869 if (ut_params->sec_session)
8870 rte_security_session_destroy(ctx, ut_params->sec_session);
8871 ut_params->sec_session = NULL;
8873 rte_pktmbuf_free(ut_params->ibuf);
8874 ut_params->ibuf = NULL;
8879 #define TEST_DOCSIS_COUNT(func) do { \
8881 if (ret == TEST_SUCCESS) { \
8882 printf("\t%2d)", n++); \
8883 printf("+++++ PASSED:" #func"\n"); \
8885 } else if (ret == -ENOTSUP) { \
8886 printf("\t%2d)", n++); \
8887 printf("~~~~~ UNSUPP:" #func"\n"); \
8890 printf("\t%2d)", n++); \
8891 printf("----- FAILED:" #func"\n"); \
8897 test_DOCSIS_PROTO_uplink_all(void)
8899 int p = 0, u = 0, f = 0, n = 0;
8901 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8902 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8903 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8904 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8905 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8906 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8907 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8908 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8909 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8910 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8911 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8912 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8913 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8914 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8915 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8916 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8917 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8918 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8919 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8920 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8921 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8922 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8923 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8924 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8925 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8926 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8929 printf("## %s: %d passed out of %d (%d unsupported)\n",
8936 test_DOCSIS_PROTO_downlink_all(void)
8938 int p = 0, u = 0, f = 0, n = 0;
8940 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8941 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8942 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8943 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8944 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8945 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8946 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8947 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8948 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8949 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8950 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8951 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8952 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8953 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8954 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8955 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8956 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8957 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8958 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8959 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8960 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8961 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8962 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8963 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8964 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8965 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8968 printf("## %s: %d passed out of %d (%d unsupported)\n",
8975 test_DOCSIS_PROTO_all(void)
8977 struct crypto_testsuite_params *ts_params = &testsuite_params;
8978 struct crypto_unittest_params *ut_params = &unittest_params;
8979 struct rte_cryptodev_info dev_info;
8982 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8983 uint64_t feat_flags = dev_info.feature_flags;
8985 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8988 /* Set action type */
8989 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8990 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8993 if (security_proto_supported(ut_params->type,
8994 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8997 status = test_DOCSIS_PROTO_uplink_all();
8998 status += test_DOCSIS_PROTO_downlink_all();
9003 return TEST_SUCCESS;
9008 test_AES_GCM_authenticated_encryption_test_case_1(void)
9010 return test_authenticated_encryption(&gcm_test_case_1);
9014 test_AES_GCM_authenticated_encryption_test_case_2(void)
9016 return test_authenticated_encryption(&gcm_test_case_2);
9020 test_AES_GCM_authenticated_encryption_test_case_3(void)
9022 return test_authenticated_encryption(&gcm_test_case_3);
9026 test_AES_GCM_authenticated_encryption_test_case_4(void)
9028 return test_authenticated_encryption(&gcm_test_case_4);
9032 test_AES_GCM_authenticated_encryption_test_case_5(void)
9034 return test_authenticated_encryption(&gcm_test_case_5);
9038 test_AES_GCM_authenticated_encryption_test_case_6(void)
9040 return test_authenticated_encryption(&gcm_test_case_6);
9044 test_AES_GCM_authenticated_encryption_test_case_7(void)
9046 return test_authenticated_encryption(&gcm_test_case_7);
9050 test_AES_GCM_authenticated_encryption_test_case_8(void)
9052 return test_authenticated_encryption(&gcm_test_case_8);
9056 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9058 return test_authenticated_encryption(&gcm_J0_test_case_1);
9062 test_AES_GCM_auth_encryption_test_case_192_1(void)
9064 return test_authenticated_encryption(&gcm_test_case_192_1);
9068 test_AES_GCM_auth_encryption_test_case_192_2(void)
9070 return test_authenticated_encryption(&gcm_test_case_192_2);
9074 test_AES_GCM_auth_encryption_test_case_192_3(void)
9076 return test_authenticated_encryption(&gcm_test_case_192_3);
9080 test_AES_GCM_auth_encryption_test_case_192_4(void)
9082 return test_authenticated_encryption(&gcm_test_case_192_4);
9086 test_AES_GCM_auth_encryption_test_case_192_5(void)
9088 return test_authenticated_encryption(&gcm_test_case_192_5);
9092 test_AES_GCM_auth_encryption_test_case_192_6(void)
9094 return test_authenticated_encryption(&gcm_test_case_192_6);
9098 test_AES_GCM_auth_encryption_test_case_192_7(void)
9100 return test_authenticated_encryption(&gcm_test_case_192_7);
9104 test_AES_GCM_auth_encryption_test_case_256_1(void)
9106 return test_authenticated_encryption(&gcm_test_case_256_1);
9110 test_AES_GCM_auth_encryption_test_case_256_2(void)
9112 return test_authenticated_encryption(&gcm_test_case_256_2);
9116 test_AES_GCM_auth_encryption_test_case_256_3(void)
9118 return test_authenticated_encryption(&gcm_test_case_256_3);
9122 test_AES_GCM_auth_encryption_test_case_256_4(void)
9124 return test_authenticated_encryption(&gcm_test_case_256_4);
9128 test_AES_GCM_auth_encryption_test_case_256_5(void)
9130 return test_authenticated_encryption(&gcm_test_case_256_5);
9134 test_AES_GCM_auth_encryption_test_case_256_6(void)
9136 return test_authenticated_encryption(&gcm_test_case_256_6);
9140 test_AES_GCM_auth_encryption_test_case_256_7(void)
9142 return test_authenticated_encryption(&gcm_test_case_256_7);
9146 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9148 return test_authenticated_encryption(&gcm_test_case_aad_1);
9152 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9154 return test_authenticated_encryption(&gcm_test_case_aad_2);
9158 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9160 struct aead_test_data tdata;
9163 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9164 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9165 tdata.iv.data[0] += 1;
9166 res = test_authenticated_encryption(&tdata);
9167 if (res == -ENOTSUP)
9169 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9170 return TEST_SUCCESS;
9174 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9176 struct aead_test_data tdata;
9179 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9180 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9181 tdata.plaintext.data[0] += 1;
9182 res = test_authenticated_encryption(&tdata);
9183 if (res == -ENOTSUP)
9185 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9186 return TEST_SUCCESS;
9190 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9192 struct aead_test_data tdata;
9195 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9196 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9197 tdata.ciphertext.data[0] += 1;
9198 res = test_authenticated_encryption(&tdata);
9199 if (res == -ENOTSUP)
9201 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9202 return TEST_SUCCESS;
9206 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9208 struct aead_test_data tdata;
9211 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9212 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9214 res = test_authenticated_encryption(&tdata);
9215 if (res == -ENOTSUP)
9217 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9218 return TEST_SUCCESS;
9222 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9224 struct aead_test_data tdata;
9225 uint8_t aad[gcm_test_case_7.aad.len];
9228 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9229 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9230 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9232 tdata.aad.data = aad;
9233 res = test_authenticated_encryption(&tdata);
9234 if (res == -ENOTSUP)
9236 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9237 return TEST_SUCCESS;
9241 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9243 struct aead_test_data tdata;
9246 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9247 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9248 tdata.auth_tag.data[0] += 1;
9249 res = test_authenticated_encryption(&tdata);
9250 if (res == -ENOTSUP)
9252 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9253 return TEST_SUCCESS;
9257 test_authenticated_decryption(const struct aead_test_data *tdata)
9259 struct crypto_testsuite_params *ts_params = &testsuite_params;
9260 struct crypto_unittest_params *ut_params = &unittest_params;
9265 struct rte_cryptodev_info dev_info;
9267 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9268 uint64_t feat_flags = dev_info.feature_flags;
9270 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9271 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9272 printf("Device doesn't support RAW data-path APIs.\n");
9276 /* Verify the capabilities */
9277 struct rte_cryptodev_sym_capability_idx cap_idx;
9278 const struct rte_cryptodev_symmetric_capability *capability;
9279 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9280 cap_idx.algo.aead = tdata->algo;
9281 capability = rte_cryptodev_sym_capability_get(
9282 ts_params->valid_devs[0], &cap_idx);
9283 if (capability == NULL)
9285 if (rte_cryptodev_sym_capability_check_aead(
9286 capability, tdata->key.len, tdata->auth_tag.len,
9287 tdata->aad.len, tdata->iv.len))
9290 /* Create AEAD session */
9291 retval = create_aead_session(ts_params->valid_devs[0],
9293 RTE_CRYPTO_AEAD_OP_DECRYPT,
9294 tdata->key.data, tdata->key.len,
9295 tdata->aad.len, tdata->auth_tag.len,
9300 /* alloc mbuf and set payload */
9301 if (tdata->aad.len > MBUF_SIZE) {
9302 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9303 /* Populate full size of add data */
9304 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9305 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9307 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9309 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9310 rte_pktmbuf_tailroom(ut_params->ibuf));
9312 /* Create AEAD operation */
9313 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9317 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9319 ut_params->op->sym->m_src = ut_params->ibuf;
9321 /* Process crypto operation */
9322 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9323 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9324 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9325 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9326 ut_params->op, 0, 0, 0, 0);
9328 TEST_ASSERT_NOT_NULL(
9329 process_crypto_request(ts_params->valid_devs[0],
9330 ut_params->op), "failed to process sym crypto op");
9332 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9333 "crypto op processing failed");
9335 if (ut_params->op->sym->m_dst)
9336 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9339 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9341 ut_params->op->sym->cipher.data.offset);
9343 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9346 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9348 tdata->plaintext.data,
9349 tdata->plaintext.len,
9350 "Plaintext data not as expected");
9352 TEST_ASSERT_EQUAL(ut_params->op->status,
9353 RTE_CRYPTO_OP_STATUS_SUCCESS,
9354 "Authentication failed");
9360 test_AES_GCM_authenticated_decryption_test_case_1(void)
9362 return test_authenticated_decryption(&gcm_test_case_1);
9366 test_AES_GCM_authenticated_decryption_test_case_2(void)
9368 return test_authenticated_decryption(&gcm_test_case_2);
9372 test_AES_GCM_authenticated_decryption_test_case_3(void)
9374 return test_authenticated_decryption(&gcm_test_case_3);
9378 test_AES_GCM_authenticated_decryption_test_case_4(void)
9380 return test_authenticated_decryption(&gcm_test_case_4);
9384 test_AES_GCM_authenticated_decryption_test_case_5(void)
9386 return test_authenticated_decryption(&gcm_test_case_5);
9390 test_AES_GCM_authenticated_decryption_test_case_6(void)
9392 return test_authenticated_decryption(&gcm_test_case_6);
9396 test_AES_GCM_authenticated_decryption_test_case_7(void)
9398 return test_authenticated_decryption(&gcm_test_case_7);
9402 test_AES_GCM_authenticated_decryption_test_case_8(void)
9404 return test_authenticated_decryption(&gcm_test_case_8);
9408 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9410 return test_authenticated_decryption(&gcm_J0_test_case_1);
9414 test_AES_GCM_auth_decryption_test_case_192_1(void)
9416 return test_authenticated_decryption(&gcm_test_case_192_1);
9420 test_AES_GCM_auth_decryption_test_case_192_2(void)
9422 return test_authenticated_decryption(&gcm_test_case_192_2);
9426 test_AES_GCM_auth_decryption_test_case_192_3(void)
9428 return test_authenticated_decryption(&gcm_test_case_192_3);
9432 test_AES_GCM_auth_decryption_test_case_192_4(void)
9434 return test_authenticated_decryption(&gcm_test_case_192_4);
9438 test_AES_GCM_auth_decryption_test_case_192_5(void)
9440 return test_authenticated_decryption(&gcm_test_case_192_5);
9444 test_AES_GCM_auth_decryption_test_case_192_6(void)
9446 return test_authenticated_decryption(&gcm_test_case_192_6);
9450 test_AES_GCM_auth_decryption_test_case_192_7(void)
9452 return test_authenticated_decryption(&gcm_test_case_192_7);
9456 test_AES_GCM_auth_decryption_test_case_256_1(void)
9458 return test_authenticated_decryption(&gcm_test_case_256_1);
9462 test_AES_GCM_auth_decryption_test_case_256_2(void)
9464 return test_authenticated_decryption(&gcm_test_case_256_2);
9468 test_AES_GCM_auth_decryption_test_case_256_3(void)
9470 return test_authenticated_decryption(&gcm_test_case_256_3);
9474 test_AES_GCM_auth_decryption_test_case_256_4(void)
9476 return test_authenticated_decryption(&gcm_test_case_256_4);
9480 test_AES_GCM_auth_decryption_test_case_256_5(void)
9482 return test_authenticated_decryption(&gcm_test_case_256_5);
9486 test_AES_GCM_auth_decryption_test_case_256_6(void)
9488 return test_authenticated_decryption(&gcm_test_case_256_6);
9492 test_AES_GCM_auth_decryption_test_case_256_7(void)
9494 return test_authenticated_decryption(&gcm_test_case_256_7);
9498 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9500 return test_authenticated_decryption(&gcm_test_case_aad_1);
9504 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9506 return test_authenticated_decryption(&gcm_test_case_aad_2);
9510 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9512 struct aead_test_data tdata;
9515 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9516 tdata.iv.data[0] += 1;
9517 res = test_authenticated_decryption(&tdata);
9518 if (res == -ENOTSUP)
9520 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9521 return TEST_SUCCESS;
9525 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9527 struct aead_test_data tdata;
9530 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9531 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9532 tdata.plaintext.data[0] += 1;
9533 res = test_authenticated_decryption(&tdata);
9534 if (res == -ENOTSUP)
9536 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9537 return TEST_SUCCESS;
9541 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9543 struct aead_test_data tdata;
9546 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9547 tdata.ciphertext.data[0] += 1;
9548 res = test_authenticated_decryption(&tdata);
9549 if (res == -ENOTSUP)
9551 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9552 return TEST_SUCCESS;
9556 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9558 struct aead_test_data tdata;
9561 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9563 res = test_authenticated_decryption(&tdata);
9564 if (res == -ENOTSUP)
9566 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9567 return TEST_SUCCESS;
9571 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9573 struct aead_test_data tdata;
9574 uint8_t aad[gcm_test_case_7.aad.len];
9577 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9578 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9580 tdata.aad.data = aad;
9581 res = test_authenticated_decryption(&tdata);
9582 if (res == -ENOTSUP)
9584 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9585 return TEST_SUCCESS;
9589 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9591 struct aead_test_data tdata;
9594 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9595 tdata.auth_tag.data[0] += 1;
9596 res = test_authenticated_decryption(&tdata);
9597 if (res == -ENOTSUP)
9599 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9600 return TEST_SUCCESS;
9604 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9606 struct crypto_testsuite_params *ts_params = &testsuite_params;
9607 struct crypto_unittest_params *ut_params = &unittest_params;
9610 uint8_t *ciphertext, *auth_tag;
9611 uint16_t plaintext_pad_len;
9613 /* Verify the capabilities */
9614 struct rte_cryptodev_sym_capability_idx cap_idx;
9615 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9616 cap_idx.algo.aead = tdata->algo;
9617 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9621 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9624 /* not supported with CPU crypto */
9625 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9628 /* Create AEAD session */
9629 retval = create_aead_session(ts_params->valid_devs[0],
9631 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9632 tdata->key.data, tdata->key.len,
9633 tdata->aad.len, tdata->auth_tag.len,
9638 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9639 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9641 /* clear mbuf payload */
9642 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9643 rte_pktmbuf_tailroom(ut_params->ibuf));
9644 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9645 rte_pktmbuf_tailroom(ut_params->obuf));
9647 /* Create AEAD operation */
9648 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9652 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9654 ut_params->op->sym->m_src = ut_params->ibuf;
9655 ut_params->op->sym->m_dst = ut_params->obuf;
9657 /* Process crypto operation */
9658 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9659 ut_params->op), "failed to process sym crypto op");
9661 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9662 "crypto op processing failed");
9664 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9666 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9667 ut_params->op->sym->cipher.data.offset);
9668 auth_tag = ciphertext + plaintext_pad_len;
9670 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9671 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9674 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9676 tdata->ciphertext.data,
9677 tdata->ciphertext.len,
9678 "Ciphertext data not as expected");
9680 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9682 tdata->auth_tag.data,
9683 tdata->auth_tag.len,
9684 "Generated auth tag not as expected");
9691 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9693 return test_authenticated_encryption_oop(&gcm_test_case_5);
9697 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9699 struct crypto_testsuite_params *ts_params = &testsuite_params;
9700 struct crypto_unittest_params *ut_params = &unittest_params;
9705 /* Verify the capabilities */
9706 struct rte_cryptodev_sym_capability_idx cap_idx;
9707 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9708 cap_idx.algo.aead = tdata->algo;
9709 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9713 /* not supported with CPU crypto and raw data-path APIs*/
9714 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
9715 global_api_test_type == CRYPTODEV_RAW_API_TEST)
9718 /* Create AEAD session */
9719 retval = create_aead_session(ts_params->valid_devs[0],
9721 RTE_CRYPTO_AEAD_OP_DECRYPT,
9722 tdata->key.data, tdata->key.len,
9723 tdata->aad.len, tdata->auth_tag.len,
9728 /* alloc mbuf and set payload */
9729 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9730 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9732 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9733 rte_pktmbuf_tailroom(ut_params->ibuf));
9734 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9735 rte_pktmbuf_tailroom(ut_params->obuf));
9737 /* Create AEAD operation */
9738 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9742 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9744 ut_params->op->sym->m_src = ut_params->ibuf;
9745 ut_params->op->sym->m_dst = ut_params->obuf;
9747 /* Process crypto operation */
9748 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9749 ut_params->op), "failed to process sym crypto op");
9751 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9752 "crypto op processing failed");
9754 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9755 ut_params->op->sym->cipher.data.offset);
9757 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9760 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9762 tdata->plaintext.data,
9763 tdata->plaintext.len,
9764 "Plaintext data not as expected");
9766 TEST_ASSERT_EQUAL(ut_params->op->status,
9767 RTE_CRYPTO_OP_STATUS_SUCCESS,
9768 "Authentication failed");
9773 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9775 return test_authenticated_decryption_oop(&gcm_test_case_5);
9779 test_authenticated_encryption_sessionless(
9780 const struct aead_test_data *tdata)
9782 struct crypto_testsuite_params *ts_params = &testsuite_params;
9783 struct crypto_unittest_params *ut_params = &unittest_params;
9786 uint8_t *ciphertext, *auth_tag;
9787 uint16_t plaintext_pad_len;
9788 uint8_t key[tdata->key.len + 1];
9789 struct rte_cryptodev_info dev_info;
9791 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9792 uint64_t feat_flags = dev_info.feature_flags;
9794 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9795 printf("Device doesn't support Sessionless ops.\n");
9799 /* not supported with CPU crypto */
9800 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9803 /* Verify the capabilities */
9804 struct rte_cryptodev_sym_capability_idx cap_idx;
9805 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9806 cap_idx.algo.aead = tdata->algo;
9807 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9811 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9813 /* clear mbuf payload */
9814 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9815 rte_pktmbuf_tailroom(ut_params->ibuf));
9817 /* Create AEAD operation */
9818 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9822 /* Create GCM xform */
9823 memcpy(key, tdata->key.data, tdata->key.len);
9824 retval = create_aead_xform(ut_params->op,
9826 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9827 key, tdata->key.len,
9828 tdata->aad.len, tdata->auth_tag.len,
9833 ut_params->op->sym->m_src = ut_params->ibuf;
9835 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9836 RTE_CRYPTO_OP_SESSIONLESS,
9837 "crypto op session type not sessionless");
9839 /* Process crypto operation */
9840 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9841 ut_params->op), "failed to process sym crypto op");
9843 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9845 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9846 "crypto op status not success");
9848 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9850 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9851 ut_params->op->sym->cipher.data.offset);
9852 auth_tag = ciphertext + plaintext_pad_len;
9854 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9855 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9858 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9860 tdata->ciphertext.data,
9861 tdata->ciphertext.len,
9862 "Ciphertext data not as expected");
9864 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9866 tdata->auth_tag.data,
9867 tdata->auth_tag.len,
9868 "Generated auth tag not as expected");
9875 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9877 return test_authenticated_encryption_sessionless(
9882 test_authenticated_decryption_sessionless(
9883 const struct aead_test_data *tdata)
9885 struct crypto_testsuite_params *ts_params = &testsuite_params;
9886 struct crypto_unittest_params *ut_params = &unittest_params;
9890 uint8_t key[tdata->key.len + 1];
9891 struct rte_cryptodev_info dev_info;
9893 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9894 uint64_t feat_flags = dev_info.feature_flags;
9896 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9897 printf("Device doesn't support Sessionless ops.\n");
9901 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9902 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9903 printf("Device doesn't support RAW data-path APIs.\n");
9907 /* not supported with CPU crypto */
9908 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9911 /* Verify the capabilities */
9912 struct rte_cryptodev_sym_capability_idx cap_idx;
9913 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9914 cap_idx.algo.aead = tdata->algo;
9915 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9919 /* alloc mbuf and set payload */
9920 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9922 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9923 rte_pktmbuf_tailroom(ut_params->ibuf));
9925 /* Create AEAD operation */
9926 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9930 /* Create AEAD xform */
9931 memcpy(key, tdata->key.data, tdata->key.len);
9932 retval = create_aead_xform(ut_params->op,
9934 RTE_CRYPTO_AEAD_OP_DECRYPT,
9935 key, tdata->key.len,
9936 tdata->aad.len, tdata->auth_tag.len,
9941 ut_params->op->sym->m_src = ut_params->ibuf;
9943 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9944 RTE_CRYPTO_OP_SESSIONLESS,
9945 "crypto op session type not sessionless");
9947 /* Process crypto operation */
9948 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9949 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9950 ut_params->op, 0, 0, 0, 0);
9952 TEST_ASSERT_NOT_NULL(process_crypto_request(
9953 ts_params->valid_devs[0], ut_params->op),
9954 "failed to process sym crypto op");
9956 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9958 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9959 "crypto op status not success");
9961 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9962 ut_params->op->sym->cipher.data.offset);
9964 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9967 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9969 tdata->plaintext.data,
9970 tdata->plaintext.len,
9971 "Plaintext data not as expected");
9973 TEST_ASSERT_EQUAL(ut_params->op->status,
9974 RTE_CRYPTO_OP_STATUS_SUCCESS,
9975 "Authentication failed");
9980 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9982 return test_authenticated_decryption_sessionless(
9987 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9989 return test_authenticated_encryption(&ccm_test_case_128_1);
9993 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9995 return test_authenticated_encryption(&ccm_test_case_128_2);
9999 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10001 return test_authenticated_encryption(&ccm_test_case_128_3);
10005 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10007 return test_authenticated_decryption(&ccm_test_case_128_1);
10011 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10013 return test_authenticated_decryption(&ccm_test_case_128_2);
10017 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10019 return test_authenticated_decryption(&ccm_test_case_128_3);
10023 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10025 return test_authenticated_encryption(&ccm_test_case_192_1);
10029 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10031 return test_authenticated_encryption(&ccm_test_case_192_2);
10035 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10037 return test_authenticated_encryption(&ccm_test_case_192_3);
10041 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10043 return test_authenticated_decryption(&ccm_test_case_192_1);
10047 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10049 return test_authenticated_decryption(&ccm_test_case_192_2);
10053 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10055 return test_authenticated_decryption(&ccm_test_case_192_3);
10059 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10061 return test_authenticated_encryption(&ccm_test_case_256_1);
10065 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10067 return test_authenticated_encryption(&ccm_test_case_256_2);
10071 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10073 return test_authenticated_encryption(&ccm_test_case_256_3);
10077 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10079 return test_authenticated_decryption(&ccm_test_case_256_1);
10083 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10085 return test_authenticated_decryption(&ccm_test_case_256_2);
10089 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10091 return test_authenticated_decryption(&ccm_test_case_256_3);
10097 struct crypto_testsuite_params *ts_params = &testsuite_params;
10098 struct rte_cryptodev_stats stats;
10100 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10103 /* Verify the capabilities */
10104 struct rte_cryptodev_sym_capability_idx cap_idx;
10105 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10106 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10107 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10110 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10111 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10112 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10116 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10120 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10121 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10122 &stats) == -ENODEV),
10123 "rte_cryptodev_stats_get invalid dev failed");
10124 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10125 "rte_cryptodev_stats_get invalid Param failed");
10127 /* Test expected values */
10128 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10129 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10131 "rte_cryptodev_stats_get failed");
10132 TEST_ASSERT((stats.enqueued_count == 1),
10133 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10134 TEST_ASSERT((stats.dequeued_count == 1),
10135 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10136 TEST_ASSERT((stats.enqueue_err_count == 0),
10137 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10138 TEST_ASSERT((stats.dequeue_err_count == 0),
10139 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10141 /* invalid device but should ignore and not reset device stats*/
10142 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10143 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10145 "rte_cryptodev_stats_get failed");
10146 TEST_ASSERT((stats.enqueued_count == 1),
10147 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10149 /* check that a valid reset clears stats */
10150 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10151 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10153 "rte_cryptodev_stats_get failed");
10154 TEST_ASSERT((stats.enqueued_count == 0),
10155 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10156 TEST_ASSERT((stats.dequeued_count == 0),
10157 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10159 return TEST_SUCCESS;
10162 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10163 struct crypto_unittest_params *ut_params,
10164 enum rte_crypto_auth_operation op,
10165 const struct HMAC_MD5_vector *test_case)
10169 memcpy(key, test_case->key.data, test_case->key.len);
10171 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10172 ut_params->auth_xform.next = NULL;
10173 ut_params->auth_xform.auth.op = op;
10175 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10177 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10178 ut_params->auth_xform.auth.key.length = test_case->key.len;
10179 ut_params->auth_xform.auth.key.data = key;
10181 ut_params->sess = rte_cryptodev_sym_session_create(
10182 ts_params->session_mpool);
10184 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10185 ut_params->sess, &ut_params->auth_xform,
10186 ts_params->session_priv_mpool);
10188 if (ut_params->sess == NULL)
10189 return TEST_FAILED;
10191 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10193 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10194 rte_pktmbuf_tailroom(ut_params->ibuf));
10199 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10200 const struct HMAC_MD5_vector *test_case,
10201 uint8_t **plaintext)
10203 uint16_t plaintext_pad_len;
10205 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10207 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10210 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10211 plaintext_pad_len);
10212 memcpy(*plaintext, test_case->plaintext.data,
10213 test_case->plaintext.len);
10215 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10216 ut_params->ibuf, MD5_DIGEST_LEN);
10217 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10218 "no room to append digest");
10219 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10220 ut_params->ibuf, plaintext_pad_len);
10222 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10223 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10224 test_case->auth_tag.len);
10227 sym_op->auth.data.offset = 0;
10228 sym_op->auth.data.length = test_case->plaintext.len;
10230 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10231 ut_params->op->sym->m_src = ut_params->ibuf;
10237 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10239 uint16_t plaintext_pad_len;
10240 uint8_t *plaintext, *auth_tag;
10242 struct crypto_testsuite_params *ts_params = &testsuite_params;
10243 struct crypto_unittest_params *ut_params = &unittest_params;
10244 struct rte_cryptodev_info dev_info;
10246 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10247 uint64_t feat_flags = dev_info.feature_flags;
10249 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10250 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10251 printf("Device doesn't support RAW data-path APIs.\n");
10255 /* Verify the capabilities */
10256 struct rte_cryptodev_sym_capability_idx cap_idx;
10257 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10258 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10259 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10263 if (MD5_HMAC_create_session(ts_params, ut_params,
10264 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10265 return TEST_FAILED;
10267 /* Generate Crypto op data structure */
10268 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10269 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10270 TEST_ASSERT_NOT_NULL(ut_params->op,
10271 "Failed to allocate symmetric crypto operation struct");
10273 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10276 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10277 return TEST_FAILED;
10279 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10280 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10282 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10283 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10284 ut_params->op, 0, 1, 0, 0);
10286 TEST_ASSERT_NOT_NULL(
10287 process_crypto_request(ts_params->valid_devs[0],
10289 "failed to process sym crypto op");
10291 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10292 "crypto op processing failed");
10294 if (ut_params->op->sym->m_dst) {
10295 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10296 uint8_t *, plaintext_pad_len);
10298 auth_tag = plaintext + plaintext_pad_len;
10301 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10303 test_case->auth_tag.data,
10304 test_case->auth_tag.len,
10305 "HMAC_MD5 generated tag not as expected");
10307 return TEST_SUCCESS;
10311 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10313 uint8_t *plaintext;
10315 struct crypto_testsuite_params *ts_params = &testsuite_params;
10316 struct crypto_unittest_params *ut_params = &unittest_params;
10317 struct rte_cryptodev_info dev_info;
10319 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10320 uint64_t feat_flags = dev_info.feature_flags;
10322 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10323 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10324 printf("Device doesn't support RAW data-path APIs.\n");
10328 /* Verify the capabilities */
10329 struct rte_cryptodev_sym_capability_idx cap_idx;
10330 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10331 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10332 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10336 if (MD5_HMAC_create_session(ts_params, ut_params,
10337 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10338 return TEST_FAILED;
10341 /* Generate Crypto op data structure */
10342 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10343 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10344 TEST_ASSERT_NOT_NULL(ut_params->op,
10345 "Failed to allocate symmetric crypto operation struct");
10347 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10348 return TEST_FAILED;
10350 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10351 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10353 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10354 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10355 ut_params->op, 0, 1, 0, 0);
10357 TEST_ASSERT_NOT_NULL(
10358 process_crypto_request(ts_params->valid_devs[0],
10360 "failed to process sym crypto op");
10362 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10363 "HMAC_MD5 crypto op processing failed");
10365 return TEST_SUCCESS;
10369 test_MD5_HMAC_generate_case_1(void)
10371 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10375 test_MD5_HMAC_verify_case_1(void)
10377 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10381 test_MD5_HMAC_generate_case_2(void)
10383 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10387 test_MD5_HMAC_verify_case_2(void)
10389 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10393 test_multi_session(void)
10395 struct crypto_testsuite_params *ts_params = &testsuite_params;
10396 struct crypto_unittest_params *ut_params = &unittest_params;
10398 struct rte_cryptodev_info dev_info;
10399 struct rte_cryptodev_sym_session **sessions;
10403 /* Verify the capabilities */
10404 struct rte_cryptodev_sym_capability_idx cap_idx;
10405 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10406 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10407 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10410 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10411 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10412 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10416 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10417 aes_cbc_key, hmac_sha512_key);
10420 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10422 sessions = rte_malloc(NULL,
10423 (sizeof(struct rte_cryptodev_sym_session *) *
10424 MAX_NB_SESSIONS) + 1, 0);
10426 /* Create multiple crypto sessions*/
10427 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10429 sessions[i] = rte_cryptodev_sym_session_create(
10430 ts_params->session_mpool);
10432 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10433 sessions[i], &ut_params->auth_xform,
10434 ts_params->session_priv_mpool);
10435 TEST_ASSERT_NOT_NULL(sessions[i],
10436 "Session creation failed at session number %u",
10439 /* Attempt to send a request on each session */
10440 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10444 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10445 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10447 "Failed to perform decrypt on request number %u.", i);
10448 /* free crypto operation structure */
10450 rte_crypto_op_free(ut_params->op);
10453 * free mbuf - both obuf and ibuf are usually the same,
10454 * so check if they point at the same address is necessary,
10455 * to avoid freeing the mbuf twice.
10457 if (ut_params->obuf) {
10458 rte_pktmbuf_free(ut_params->obuf);
10459 if (ut_params->ibuf == ut_params->obuf)
10460 ut_params->ibuf = 0;
10461 ut_params->obuf = 0;
10463 if (ut_params->ibuf) {
10464 rte_pktmbuf_free(ut_params->ibuf);
10465 ut_params->ibuf = 0;
10469 /* Next session create should fail */
10470 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10471 sessions[i], &ut_params->auth_xform,
10472 ts_params->session_priv_mpool);
10473 TEST_ASSERT_NULL(sessions[i],
10474 "Session creation succeeded unexpectedly!");
10476 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10477 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10479 rte_cryptodev_sym_session_free(sessions[i]);
10482 rte_free(sessions);
10484 return TEST_SUCCESS;
10487 struct multi_session_params {
10488 struct crypto_unittest_params ut_params;
10489 uint8_t *cipher_key;
10491 const uint8_t *cipher;
10492 const uint8_t *digest;
10496 #define MB_SESSION_NUMBER 3
10499 test_multi_session_random_usage(void)
10501 struct crypto_testsuite_params *ts_params = &testsuite_params;
10502 struct rte_cryptodev_info dev_info;
10503 struct rte_cryptodev_sym_session **sessions;
10505 struct multi_session_params ut_paramz[] = {
10508 .cipher_key = ms_aes_cbc_key0,
10509 .hmac_key = ms_hmac_key0,
10510 .cipher = ms_aes_cbc_cipher0,
10511 .digest = ms_hmac_digest0,
10512 .iv = ms_aes_cbc_iv0
10515 .cipher_key = ms_aes_cbc_key1,
10516 .hmac_key = ms_hmac_key1,
10517 .cipher = ms_aes_cbc_cipher1,
10518 .digest = ms_hmac_digest1,
10519 .iv = ms_aes_cbc_iv1
10522 .cipher_key = ms_aes_cbc_key2,
10523 .hmac_key = ms_hmac_key2,
10524 .cipher = ms_aes_cbc_cipher2,
10525 .digest = ms_hmac_digest2,
10526 .iv = ms_aes_cbc_iv2
10531 /* Verify the capabilities */
10532 struct rte_cryptodev_sym_capability_idx cap_idx;
10533 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10534 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10535 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10538 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10539 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10540 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10544 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10546 sessions = rte_malloc(NULL,
10547 (sizeof(struct rte_cryptodev_sym_session *)
10548 * MAX_NB_SESSIONS) + 1, 0);
10550 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10551 sessions[i] = rte_cryptodev_sym_session_create(
10552 ts_params->session_mpool);
10554 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10555 sizeof(struct crypto_unittest_params));
10557 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10558 &ut_paramz[i].ut_params,
10559 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10561 /* Create multiple crypto sessions*/
10562 rte_cryptodev_sym_session_init(
10563 ts_params->valid_devs[0],
10565 &ut_paramz[i].ut_params.auth_xform,
10566 ts_params->session_priv_mpool);
10568 TEST_ASSERT_NOT_NULL(sessions[i],
10569 "Session creation failed at session number %u",
10575 for (i = 0; i < 40000; i++) {
10577 j = rand() % MB_SESSION_NUMBER;
10579 TEST_ASSERT_SUCCESS(
10580 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10582 &ut_paramz[j].ut_params,
10583 ts_params, ut_paramz[j].cipher,
10584 ut_paramz[j].digest,
10586 "Failed to perform decrypt on request number %u.", i);
10588 if (ut_paramz[j].ut_params.op)
10589 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10592 * free mbuf - both obuf and ibuf are usually the same,
10593 * so check if they point at the same address is necessary,
10594 * to avoid freeing the mbuf twice.
10596 if (ut_paramz[j].ut_params.obuf) {
10597 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10598 if (ut_paramz[j].ut_params.ibuf
10599 == ut_paramz[j].ut_params.obuf)
10600 ut_paramz[j].ut_params.ibuf = 0;
10601 ut_paramz[j].ut_params.obuf = 0;
10603 if (ut_paramz[j].ut_params.ibuf) {
10604 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10605 ut_paramz[j].ut_params.ibuf = 0;
10609 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10610 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10612 rte_cryptodev_sym_session_free(sessions[i]);
10615 rte_free(sessions);
10617 return TEST_SUCCESS;
10620 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10621 0xab, 0xab, 0xab, 0xab,
10622 0xab, 0xab, 0xab, 0xab,
10623 0xab, 0xab, 0xab, 0xab};
10626 test_null_invalid_operation(void)
10628 struct crypto_testsuite_params *ts_params = &testsuite_params;
10629 struct crypto_unittest_params *ut_params = &unittest_params;
10632 /* This test is for NULL PMD only */
10633 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10634 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10637 /* Setup Cipher Parameters */
10638 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10639 ut_params->cipher_xform.next = NULL;
10641 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10642 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10644 ut_params->sess = rte_cryptodev_sym_session_create(
10645 ts_params->session_mpool);
10647 /* Create Crypto session*/
10648 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10649 ut_params->sess, &ut_params->cipher_xform,
10650 ts_params->session_priv_mpool);
10651 TEST_ASSERT(ret < 0,
10652 "Session creation succeeded unexpectedly");
10655 /* Setup HMAC Parameters */
10656 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10657 ut_params->auth_xform.next = NULL;
10659 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10660 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10662 ut_params->sess = rte_cryptodev_sym_session_create(
10663 ts_params->session_mpool);
10665 /* Create Crypto session*/
10666 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10667 ut_params->sess, &ut_params->auth_xform,
10668 ts_params->session_priv_mpool);
10669 TEST_ASSERT(ret < 0,
10670 "Session creation succeeded unexpectedly");
10672 return TEST_SUCCESS;
10676 #define NULL_BURST_LENGTH (32)
10679 test_null_burst_operation(void)
10681 struct crypto_testsuite_params *ts_params = &testsuite_params;
10682 struct crypto_unittest_params *ut_params = &unittest_params;
10684 unsigned i, burst_len = NULL_BURST_LENGTH;
10686 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10687 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10689 /* This test is for NULL PMD only */
10690 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10691 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10694 /* Setup Cipher Parameters */
10695 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10696 ut_params->cipher_xform.next = &ut_params->auth_xform;
10698 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10699 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10701 /* Setup HMAC Parameters */
10702 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10703 ut_params->auth_xform.next = NULL;
10705 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10706 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10708 ut_params->sess = rte_cryptodev_sym_session_create(
10709 ts_params->session_mpool);
10711 /* Create Crypto session*/
10712 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10713 ut_params->sess, &ut_params->cipher_xform,
10714 ts_params->session_priv_mpool);
10715 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10717 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10718 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10719 burst_len, "failed to generate burst of crypto ops");
10721 /* Generate an operation for each mbuf in burst */
10722 for (i = 0; i < burst_len; i++) {
10723 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10725 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10727 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10731 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10733 burst[i]->sym->m_src = m;
10736 /* Process crypto operation */
10737 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10738 0, burst, burst_len),
10740 "Error enqueuing burst");
10742 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10743 0, burst_dequeued, burst_len),
10745 "Error dequeuing burst");
10748 for (i = 0; i < burst_len; i++) {
10750 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10751 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10753 "data not as expected");
10755 rte_pktmbuf_free(burst[i]->sym->m_src);
10756 rte_crypto_op_free(burst[i]);
10759 return TEST_SUCCESS;
10763 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10764 uint16_t nb_ops, void *user_param)
10766 RTE_SET_USED(dev_id);
10767 RTE_SET_USED(qp_id);
10769 RTE_SET_USED(user_param);
10771 printf("crypto enqueue callback called\n");
10776 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10777 uint16_t nb_ops, void *user_param)
10779 RTE_SET_USED(dev_id);
10780 RTE_SET_USED(qp_id);
10782 RTE_SET_USED(user_param);
10784 printf("crypto dequeue callback called\n");
10789 * Thread using enqueue/dequeue callback with RCU.
10792 test_enqdeq_callback_thread(void *arg)
10795 /* DP thread calls rte_cryptodev_enqueue_burst()/
10796 * rte_cryptodev_dequeue_burst() and invokes callback.
10798 test_null_burst_operation();
10803 test_enq_callback_setup(void)
10805 struct crypto_testsuite_params *ts_params = &testsuite_params;
10806 struct rte_cryptodev_info dev_info;
10807 struct rte_cryptodev_qp_conf qp_conf = {
10808 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10811 struct rte_cryptodev_cb *cb;
10812 uint16_t qp_id = 0;
10814 /* Stop the device in case it's started so it can be configured */
10815 rte_cryptodev_stop(ts_params->valid_devs[0]);
10817 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10819 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10821 "Failed to configure cryptodev %u",
10822 ts_params->valid_devs[0]);
10824 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10825 qp_conf.mp_session = ts_params->session_mpool;
10826 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10828 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10829 ts_params->valid_devs[0], qp_id, &qp_conf,
10830 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10832 "rte_cryptodev_queue_pair_setup: num_inflights "
10833 "%u on qp %u on cryptodev %u",
10834 qp_conf.nb_descriptors, qp_id,
10835 ts_params->valid_devs[0]);
10837 /* Test with invalid crypto device */
10838 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
10839 qp_id, test_enq_callback, NULL);
10840 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10841 "cryptodev %u did not fail",
10842 qp_id, RTE_CRYPTO_MAX_DEVS);
10844 /* Test with invalid queue pair */
10845 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10846 dev_info.max_nb_queue_pairs + 1,
10847 test_enq_callback, NULL);
10848 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10849 "cryptodev %u did not fail",
10850 dev_info.max_nb_queue_pairs + 1,
10851 ts_params->valid_devs[0]);
10853 /* Test with NULL callback */
10854 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10855 qp_id, NULL, NULL);
10856 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10857 "cryptodev %u did not fail",
10858 qp_id, ts_params->valid_devs[0]);
10860 /* Test with valid configuration */
10861 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10862 qp_id, test_enq_callback, NULL);
10863 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10864 "qp %u on cryptodev %u",
10865 qp_id, ts_params->valid_devs[0]);
10867 rte_cryptodev_start(ts_params->valid_devs[0]);
10869 /* Launch a thread */
10870 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10871 rte_get_next_lcore(-1, 1, 0));
10873 /* Wait until reader exited. */
10874 rte_eal_mp_wait_lcore();
10876 /* Test with invalid crypto device */
10877 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10878 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10879 "Expected call to fail as crypto device is invalid");
10881 /* Test with invalid queue pair */
10882 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10883 ts_params->valid_devs[0],
10884 dev_info.max_nb_queue_pairs + 1, cb),
10885 "Expected call to fail as queue pair is invalid");
10887 /* Test with NULL callback */
10888 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10889 ts_params->valid_devs[0], qp_id, NULL),
10890 "Expected call to fail as callback is NULL");
10892 /* Test with valid configuration */
10893 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
10894 ts_params->valid_devs[0], qp_id, cb),
10895 "Failed test to remove callback on "
10896 "qp %u on cryptodev %u",
10897 qp_id, ts_params->valid_devs[0]);
10899 return TEST_SUCCESS;
10903 test_deq_callback_setup(void)
10905 struct crypto_testsuite_params *ts_params = &testsuite_params;
10906 struct rte_cryptodev_info dev_info;
10907 struct rte_cryptodev_qp_conf qp_conf = {
10908 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10911 struct rte_cryptodev_cb *cb;
10912 uint16_t qp_id = 0;
10914 /* Stop the device in case it's started so it can be configured */
10915 rte_cryptodev_stop(ts_params->valid_devs[0]);
10917 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10919 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10921 "Failed to configure cryptodev %u",
10922 ts_params->valid_devs[0]);
10924 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10925 qp_conf.mp_session = ts_params->session_mpool;
10926 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10928 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10929 ts_params->valid_devs[0], qp_id, &qp_conf,
10930 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10932 "rte_cryptodev_queue_pair_setup: num_inflights "
10933 "%u on qp %u on cryptodev %u",
10934 qp_conf.nb_descriptors, qp_id,
10935 ts_params->valid_devs[0]);
10937 /* Test with invalid crypto device */
10938 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
10939 qp_id, test_deq_callback, NULL);
10940 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10941 "cryptodev %u did not fail",
10942 qp_id, RTE_CRYPTO_MAX_DEVS);
10944 /* Test with invalid queue pair */
10945 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10946 dev_info.max_nb_queue_pairs + 1,
10947 test_deq_callback, NULL);
10948 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10949 "cryptodev %u did not fail",
10950 dev_info.max_nb_queue_pairs + 1,
10951 ts_params->valid_devs[0]);
10953 /* Test with NULL callback */
10954 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10955 qp_id, NULL, NULL);
10956 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10957 "cryptodev %u did not fail",
10958 qp_id, ts_params->valid_devs[0]);
10960 /* Test with valid configuration */
10961 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10962 qp_id, test_deq_callback, NULL);
10963 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10964 "qp %u on cryptodev %u",
10965 qp_id, ts_params->valid_devs[0]);
10967 rte_cryptodev_start(ts_params->valid_devs[0]);
10969 /* Launch a thread */
10970 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10971 rte_get_next_lcore(-1, 1, 0));
10973 /* Wait until reader exited. */
10974 rte_eal_mp_wait_lcore();
10976 /* Test with invalid crypto device */
10977 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10978 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10979 "Expected call to fail as crypto device is invalid");
10981 /* Test with invalid queue pair */
10982 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10983 ts_params->valid_devs[0],
10984 dev_info.max_nb_queue_pairs + 1, cb),
10985 "Expected call to fail as queue pair is invalid");
10987 /* Test with NULL callback */
10988 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10989 ts_params->valid_devs[0], qp_id, NULL),
10990 "Expected call to fail as callback is NULL");
10992 /* Test with valid configuration */
10993 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
10994 ts_params->valid_devs[0], qp_id, cb),
10995 "Failed test to remove callback on "
10996 "qp %u on cryptodev %u",
10997 qp_id, ts_params->valid_devs[0]);
10999 return TEST_SUCCESS;
11003 generate_gmac_large_plaintext(uint8_t *data)
11007 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11008 memcpy(&data[i], &data[0], 32);
11012 create_gmac_operation(enum rte_crypto_auth_operation op,
11013 const struct gmac_test_data *tdata)
11015 struct crypto_testsuite_params *ts_params = &testsuite_params;
11016 struct crypto_unittest_params *ut_params = &unittest_params;
11017 struct rte_crypto_sym_op *sym_op;
11019 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11021 /* Generate Crypto op data structure */
11022 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11023 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11024 TEST_ASSERT_NOT_NULL(ut_params->op,
11025 "Failed to allocate symmetric crypto operation struct");
11027 sym_op = ut_params->op->sym;
11029 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11030 ut_params->ibuf, tdata->gmac_tag.len);
11031 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11032 "no room to append digest");
11034 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11035 ut_params->ibuf, plaintext_pad_len);
11037 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11038 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11039 tdata->gmac_tag.len);
11040 debug_hexdump(stdout, "digest:",
11041 sym_op->auth.digest.data,
11042 tdata->gmac_tag.len);
11045 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11046 uint8_t *, IV_OFFSET);
11048 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11050 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11052 sym_op->cipher.data.length = 0;
11053 sym_op->cipher.data.offset = 0;
11055 sym_op->auth.data.offset = 0;
11056 sym_op->auth.data.length = tdata->plaintext.len;
11062 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11063 const struct gmac_test_data *tdata,
11064 void *digest_mem, uint64_t digest_phys)
11066 struct crypto_testsuite_params *ts_params = &testsuite_params;
11067 struct crypto_unittest_params *ut_params = &unittest_params;
11068 struct rte_crypto_sym_op *sym_op;
11070 /* Generate Crypto op data structure */
11071 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11072 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11073 TEST_ASSERT_NOT_NULL(ut_params->op,
11074 "Failed to allocate symmetric crypto operation struct");
11076 sym_op = ut_params->op->sym;
11078 sym_op->auth.digest.data = digest_mem;
11079 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11080 "no room to append digest");
11082 sym_op->auth.digest.phys_addr = digest_phys;
11084 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11085 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11086 tdata->gmac_tag.len);
11087 debug_hexdump(stdout, "digest:",
11088 sym_op->auth.digest.data,
11089 tdata->gmac_tag.len);
11092 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11093 uint8_t *, IV_OFFSET);
11095 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11097 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11099 sym_op->cipher.data.length = 0;
11100 sym_op->cipher.data.offset = 0;
11102 sym_op->auth.data.offset = 0;
11103 sym_op->auth.data.length = tdata->plaintext.len;
11108 static int create_gmac_session(uint8_t dev_id,
11109 const struct gmac_test_data *tdata,
11110 enum rte_crypto_auth_operation auth_op)
11112 uint8_t auth_key[tdata->key.len];
11114 struct crypto_testsuite_params *ts_params = &testsuite_params;
11115 struct crypto_unittest_params *ut_params = &unittest_params;
11117 memcpy(auth_key, tdata->key.data, tdata->key.len);
11119 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11120 ut_params->auth_xform.next = NULL;
11122 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11123 ut_params->auth_xform.auth.op = auth_op;
11124 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11125 ut_params->auth_xform.auth.key.length = tdata->key.len;
11126 ut_params->auth_xform.auth.key.data = auth_key;
11127 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11128 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11131 ut_params->sess = rte_cryptodev_sym_session_create(
11132 ts_params->session_mpool);
11134 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11135 &ut_params->auth_xform,
11136 ts_params->session_priv_mpool);
11138 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11144 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11146 struct crypto_testsuite_params *ts_params = &testsuite_params;
11147 struct crypto_unittest_params *ut_params = &unittest_params;
11148 struct rte_cryptodev_info dev_info;
11150 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11151 uint64_t feat_flags = dev_info.feature_flags;
11153 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11154 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11155 printf("Device doesn't support RAW data-path APIs.\n");
11161 uint8_t *auth_tag, *plaintext;
11162 uint16_t plaintext_pad_len;
11164 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11165 "No GMAC length in the source data");
11167 /* Verify the capabilities */
11168 struct rte_cryptodev_sym_capability_idx cap_idx;
11169 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11170 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11171 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11175 retval = create_gmac_session(ts_params->valid_devs[0],
11176 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11181 if (tdata->plaintext.len > MBUF_SIZE)
11182 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11184 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11185 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11186 "Failed to allocate input buffer in mempool");
11188 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11189 rte_pktmbuf_tailroom(ut_params->ibuf));
11191 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11193 * Runtime generate the large plain text instead of use hard code
11194 * plain text vector. It is done to avoid create huge source file
11195 * with the test vector.
11197 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11198 generate_gmac_large_plaintext(tdata->plaintext.data);
11200 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11201 plaintext_pad_len);
11202 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11204 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11205 debug_hexdump(stdout, "plaintext:", plaintext,
11206 tdata->plaintext.len);
11208 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11214 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11216 ut_params->op->sym->m_src = ut_params->ibuf;
11218 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11219 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11221 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11222 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11223 ut_params->op, 0, 1, 0, 0);
11225 TEST_ASSERT_NOT_NULL(
11226 process_crypto_request(ts_params->valid_devs[0],
11227 ut_params->op), "failed to process sym crypto op");
11229 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11230 "crypto op processing failed");
11232 if (ut_params->op->sym->m_dst) {
11233 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11234 uint8_t *, plaintext_pad_len);
11236 auth_tag = plaintext + plaintext_pad_len;
11239 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11241 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11243 tdata->gmac_tag.data,
11244 tdata->gmac_tag.len,
11245 "GMAC Generated auth tag not as expected");
11251 test_AES_GMAC_authentication_test_case_1(void)
11253 return test_AES_GMAC_authentication(&gmac_test_case_1);
11257 test_AES_GMAC_authentication_test_case_2(void)
11259 return test_AES_GMAC_authentication(&gmac_test_case_2);
11263 test_AES_GMAC_authentication_test_case_3(void)
11265 return test_AES_GMAC_authentication(&gmac_test_case_3);
11269 test_AES_GMAC_authentication_test_case_4(void)
11271 return test_AES_GMAC_authentication(&gmac_test_case_4);
11275 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11277 struct crypto_testsuite_params *ts_params = &testsuite_params;
11278 struct crypto_unittest_params *ut_params = &unittest_params;
11280 uint32_t plaintext_pad_len;
11281 uint8_t *plaintext;
11282 struct rte_cryptodev_info dev_info;
11284 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11285 uint64_t feat_flags = dev_info.feature_flags;
11287 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11288 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11289 printf("Device doesn't support RAW data-path APIs.\n");
11293 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11294 "No GMAC length in the source data");
11296 /* Verify the capabilities */
11297 struct rte_cryptodev_sym_capability_idx cap_idx;
11298 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11299 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11300 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11304 retval = create_gmac_session(ts_params->valid_devs[0],
11305 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11310 if (tdata->plaintext.len > MBUF_SIZE)
11311 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11313 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11314 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11315 "Failed to allocate input buffer in mempool");
11317 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11318 rte_pktmbuf_tailroom(ut_params->ibuf));
11320 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11323 * Runtime generate the large plain text instead of use hard code
11324 * plain text vector. It is done to avoid create huge source file
11325 * with the test vector.
11327 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11328 generate_gmac_large_plaintext(tdata->plaintext.data);
11330 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11331 plaintext_pad_len);
11332 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11334 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11335 debug_hexdump(stdout, "plaintext:", plaintext,
11336 tdata->plaintext.len);
11338 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11344 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11346 ut_params->op->sym->m_src = ut_params->ibuf;
11348 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11349 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11351 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11352 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11353 ut_params->op, 0, 1, 0, 0);
11355 TEST_ASSERT_NOT_NULL(
11356 process_crypto_request(ts_params->valid_devs[0],
11357 ut_params->op), "failed to process sym crypto op");
11359 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11360 "crypto op processing failed");
11367 test_AES_GMAC_authentication_verify_test_case_1(void)
11369 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11373 test_AES_GMAC_authentication_verify_test_case_2(void)
11375 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11379 test_AES_GMAC_authentication_verify_test_case_3(void)
11381 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11385 test_AES_GMAC_authentication_verify_test_case_4(void)
11387 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11391 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11394 struct crypto_testsuite_params *ts_params = &testsuite_params;
11395 struct crypto_unittest_params *ut_params = &unittest_params;
11396 struct rte_cryptodev_info dev_info;
11397 uint64_t feature_flags;
11398 unsigned int trn_data = 0;
11399 void *digest_mem = NULL;
11401 unsigned int to_trn = 0;
11402 struct rte_mbuf *buf = NULL;
11403 uint8_t *auth_tag, *plaintext;
11406 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11407 "No GMAC length in the source data");
11409 /* Verify the capabilities */
11410 struct rte_cryptodev_sym_capability_idx cap_idx;
11411 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11412 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11413 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11417 /* Check for any input SGL support */
11418 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11419 feature_flags = dev_info.feature_flags;
11421 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11422 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11423 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11426 if (fragsz > tdata->plaintext.len)
11427 fragsz = tdata->plaintext.len;
11429 uint16_t plaintext_len = fragsz;
11431 retval = create_gmac_session(ts_params->valid_devs[0],
11432 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11437 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11438 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11439 "Failed to allocate input buffer in mempool");
11441 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11442 rte_pktmbuf_tailroom(ut_params->ibuf));
11444 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11446 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11448 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11450 trn_data += plaintext_len;
11452 buf = ut_params->ibuf;
11455 * Loop until no more fragments
11458 while (trn_data < tdata->plaintext.len) {
11460 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11461 (tdata->plaintext.len - trn_data) : fragsz;
11463 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11466 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11467 rte_pktmbuf_tailroom(buf));
11469 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11472 memcpy(plaintext, tdata->plaintext.data + trn_data,
11474 trn_data += to_trn;
11475 if (trn_data == tdata->plaintext.len)
11476 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11477 tdata->gmac_tag.len);
11479 ut_params->ibuf->nb_segs = segs;
11482 * Place digest at the end of the last buffer
11484 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11487 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11488 + tdata->gmac_tag.len);
11489 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11490 tdata->plaintext.len);
11493 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11494 tdata, digest_mem, digest_phys);
11499 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11501 ut_params->op->sym->m_src = ut_params->ibuf;
11503 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11506 TEST_ASSERT_NOT_NULL(
11507 process_crypto_request(ts_params->valid_devs[0],
11508 ut_params->op), "failed to process sym crypto op");
11510 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11511 "crypto op processing failed");
11513 auth_tag = digest_mem;
11514 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11515 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11517 tdata->gmac_tag.data,
11518 tdata->gmac_tag.len,
11519 "GMAC Generated auth tag not as expected");
11524 /* Segment size not multiple of block size (16B) */
11526 test_AES_GMAC_authentication_SGL_40B(void)
11528 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11532 test_AES_GMAC_authentication_SGL_80B(void)
11534 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11538 test_AES_GMAC_authentication_SGL_2048B(void)
11540 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11543 /* Segment size not multiple of block size (16B) */
11545 test_AES_GMAC_authentication_SGL_2047B(void)
11547 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11550 struct test_crypto_vector {
11551 enum rte_crypto_cipher_algorithm crypto_algo;
11552 unsigned int cipher_offset;
11553 unsigned int cipher_len;
11566 const uint8_t *data;
11571 const uint8_t *data;
11575 enum rte_crypto_auth_algorithm auth_algo;
11576 unsigned int auth_offset;
11584 const uint8_t *data;
11594 static const struct test_crypto_vector
11595 hmac_sha1_test_crypto_vector = {
11596 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11598 .data = plaintext_hash,
11603 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11604 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11605 0xDE, 0xF4, 0xDE, 0xAD
11611 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11612 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11613 0x3F, 0x91, 0x64, 0x59
11619 static const struct test_crypto_vector
11620 aes128_gmac_test_vector = {
11621 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11623 .data = plaintext_hash,
11628 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11629 0x08, 0x09, 0x0A, 0x0B
11635 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11636 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11642 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11643 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11649 static const struct test_crypto_vector
11650 aes128cbc_hmac_sha1_test_vector = {
11651 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11652 .cipher_offset = 0,
11656 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11657 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11663 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11664 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11669 .data = plaintext_hash,
11673 .data = ciphertext512_aes128cbc,
11676 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11680 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11681 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11682 0xDE, 0xF4, 0xDE, 0xAD
11688 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
11689 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11690 0x18, 0x8C, 0x1D, 0x32
11696 static const struct test_crypto_vector
11697 aes128cbc_hmac_sha1_aad_test_vector = {
11698 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11699 .cipher_offset = 8,
11703 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11704 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11710 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11711 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11716 .data = plaintext_hash,
11720 .data = ciphertext512_aes128cbc_aad,
11723 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11727 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11728 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11729 0xDE, 0xF4, 0xDE, 0xAD
11735 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
11736 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
11737 0x62, 0x0F, 0xFB, 0x10
11744 data_corruption(uint8_t *data)
11750 tag_corruption(uint8_t *data, unsigned int tag_offset)
11752 data[tag_offset] += 1;
11756 create_auth_session(struct crypto_unittest_params *ut_params,
11758 const struct test_crypto_vector *reference,
11759 enum rte_crypto_auth_operation auth_op)
11761 struct crypto_testsuite_params *ts_params = &testsuite_params;
11762 uint8_t auth_key[reference->auth_key.len + 1];
11764 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11766 /* Setup Authentication Parameters */
11767 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11768 ut_params->auth_xform.auth.op = auth_op;
11769 ut_params->auth_xform.next = NULL;
11770 ut_params->auth_xform.auth.algo = reference->auth_algo;
11771 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11772 ut_params->auth_xform.auth.key.data = auth_key;
11773 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11775 /* Create Crypto session*/
11776 ut_params->sess = rte_cryptodev_sym_session_create(
11777 ts_params->session_mpool);
11779 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11780 &ut_params->auth_xform,
11781 ts_params->session_priv_mpool);
11783 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11789 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
11791 const struct test_crypto_vector *reference,
11792 enum rte_crypto_auth_operation auth_op,
11793 enum rte_crypto_cipher_operation cipher_op)
11795 struct crypto_testsuite_params *ts_params = &testsuite_params;
11796 uint8_t cipher_key[reference->cipher_key.len + 1];
11797 uint8_t auth_key[reference->auth_key.len + 1];
11799 memcpy(cipher_key, reference->cipher_key.data,
11800 reference->cipher_key.len);
11801 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11803 /* Setup Authentication Parameters */
11804 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11805 ut_params->auth_xform.auth.op = auth_op;
11806 ut_params->auth_xform.auth.algo = reference->auth_algo;
11807 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11808 ut_params->auth_xform.auth.key.data = auth_key;
11809 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11811 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
11812 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11813 ut_params->auth_xform.auth.iv.length = reference->iv.len;
11815 ut_params->auth_xform.next = &ut_params->cipher_xform;
11817 /* Setup Cipher Parameters */
11818 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11819 ut_params->cipher_xform.next = NULL;
11820 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11821 ut_params->cipher_xform.cipher.op = cipher_op;
11822 ut_params->cipher_xform.cipher.key.data = cipher_key;
11823 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11824 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11825 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11828 /* Create Crypto session*/
11829 ut_params->sess = rte_cryptodev_sym_session_create(
11830 ts_params->session_mpool);
11832 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11833 &ut_params->auth_xform,
11834 ts_params->session_priv_mpool);
11836 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11842 create_auth_operation(struct crypto_testsuite_params *ts_params,
11843 struct crypto_unittest_params *ut_params,
11844 const struct test_crypto_vector *reference,
11845 unsigned int auth_generate)
11847 /* Generate Crypto op data structure */
11848 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11849 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11850 TEST_ASSERT_NOT_NULL(ut_params->op,
11851 "Failed to allocate pktmbuf offload");
11853 /* Set crypto operation data parameters */
11854 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11856 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11858 /* set crypto operation source mbuf */
11859 sym_op->m_src = ut_params->ibuf;
11862 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11863 ut_params->ibuf, reference->digest.len);
11865 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11866 "no room to append auth tag");
11868 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11869 ut_params->ibuf, reference->plaintext.len);
11872 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11874 memcpy(sym_op->auth.digest.data,
11875 reference->digest.data,
11876 reference->digest.len);
11878 debug_hexdump(stdout, "digest:",
11879 sym_op->auth.digest.data,
11880 reference->digest.len);
11882 sym_op->auth.data.length = reference->plaintext.len;
11883 sym_op->auth.data.offset = 0;
11889 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
11890 struct crypto_unittest_params *ut_params,
11891 const struct test_crypto_vector *reference,
11892 unsigned int auth_generate)
11894 /* Generate Crypto op data structure */
11895 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11896 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11897 TEST_ASSERT_NOT_NULL(ut_params->op,
11898 "Failed to allocate pktmbuf offload");
11900 /* Set crypto operation data parameters */
11901 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11903 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11905 /* set crypto operation source mbuf */
11906 sym_op->m_src = ut_params->ibuf;
11909 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11910 ut_params->ibuf, reference->digest.len);
11912 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11913 "no room to append auth tag");
11915 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11916 ut_params->ibuf, reference->ciphertext.len);
11919 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11921 memcpy(sym_op->auth.digest.data,
11922 reference->digest.data,
11923 reference->digest.len);
11925 debug_hexdump(stdout, "digest:",
11926 sym_op->auth.digest.data,
11927 reference->digest.len);
11929 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11930 reference->iv.data, reference->iv.len);
11932 sym_op->cipher.data.length = 0;
11933 sym_op->cipher.data.offset = 0;
11935 sym_op->auth.data.length = reference->plaintext.len;
11936 sym_op->auth.data.offset = 0;
11942 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11943 struct crypto_unittest_params *ut_params,
11944 const struct test_crypto_vector *reference,
11945 unsigned int auth_generate)
11947 /* Generate Crypto op data structure */
11948 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11949 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11950 TEST_ASSERT_NOT_NULL(ut_params->op,
11951 "Failed to allocate pktmbuf offload");
11953 /* Set crypto operation data parameters */
11954 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11956 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11958 /* set crypto operation source mbuf */
11959 sym_op->m_src = ut_params->ibuf;
11962 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11963 ut_params->ibuf, reference->digest.len);
11965 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11966 "no room to append auth tag");
11968 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11969 ut_params->ibuf, reference->ciphertext.len);
11972 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11974 memcpy(sym_op->auth.digest.data,
11975 reference->digest.data,
11976 reference->digest.len);
11978 debug_hexdump(stdout, "digest:",
11979 sym_op->auth.digest.data,
11980 reference->digest.len);
11982 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11983 reference->iv.data, reference->iv.len);
11985 sym_op->cipher.data.length = reference->cipher_len;
11986 sym_op->cipher.data.offset = reference->cipher_offset;
11988 sym_op->auth.data.length = reference->plaintext.len;
11989 sym_op->auth.data.offset = reference->auth_offset;
11995 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11996 struct crypto_unittest_params *ut_params,
11997 const struct test_crypto_vector *reference)
11999 return create_auth_operation(ts_params, ut_params, reference, 0);
12003 create_auth_verify_GMAC_operation(
12004 struct crypto_testsuite_params *ts_params,
12005 struct crypto_unittest_params *ut_params,
12006 const struct test_crypto_vector *reference)
12008 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12012 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12013 struct crypto_unittest_params *ut_params,
12014 const struct test_crypto_vector *reference)
12016 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12020 test_authentication_verify_fail_when_data_corruption(
12021 struct crypto_testsuite_params *ts_params,
12022 struct crypto_unittest_params *ut_params,
12023 const struct test_crypto_vector *reference,
12024 unsigned int data_corrupted)
12028 uint8_t *plaintext;
12029 struct rte_cryptodev_info dev_info;
12031 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12032 uint64_t feat_flags = dev_info.feature_flags;
12034 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12035 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12036 printf("Device doesn't support RAW data-path APIs.\n");
12040 /* Verify the capabilities */
12041 struct rte_cryptodev_sym_capability_idx cap_idx;
12042 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12043 cap_idx.algo.auth = reference->auth_algo;
12044 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12049 /* Create session */
12050 retval = create_auth_session(ut_params,
12051 ts_params->valid_devs[0],
12053 RTE_CRYPTO_AUTH_OP_VERIFY);
12057 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12058 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12059 "Failed to allocate input buffer in mempool");
12061 /* clear mbuf payload */
12062 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12063 rte_pktmbuf_tailroom(ut_params->ibuf));
12065 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12066 reference->plaintext.len);
12067 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12068 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12070 debug_hexdump(stdout, "plaintext:", plaintext,
12071 reference->plaintext.len);
12073 /* Create operation */
12074 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12079 if (data_corrupted)
12080 data_corruption(plaintext);
12082 tag_corruption(plaintext, reference->plaintext.len);
12084 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12085 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12087 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12088 RTE_CRYPTO_OP_STATUS_SUCCESS,
12089 "authentication not failed");
12090 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12091 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12092 ut_params->op, 0, 1, 0, 0);
12094 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12096 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12103 test_authentication_verify_GMAC_fail_when_corruption(
12104 struct crypto_testsuite_params *ts_params,
12105 struct crypto_unittest_params *ut_params,
12106 const struct test_crypto_vector *reference,
12107 unsigned int data_corrupted)
12110 uint8_t *plaintext;
12111 struct rte_cryptodev_info dev_info;
12113 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12114 uint64_t feat_flags = dev_info.feature_flags;
12116 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12117 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12118 printf("Device doesn't support RAW data-path APIs.\n");
12122 /* Verify the capabilities */
12123 struct rte_cryptodev_sym_capability_idx cap_idx;
12124 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12125 cap_idx.algo.auth = reference->auth_algo;
12126 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12130 /* Create session */
12131 retval = create_auth_cipher_session(ut_params,
12132 ts_params->valid_devs[0],
12134 RTE_CRYPTO_AUTH_OP_VERIFY,
12135 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12139 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12140 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12141 "Failed to allocate input buffer in mempool");
12143 /* clear mbuf payload */
12144 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12145 rte_pktmbuf_tailroom(ut_params->ibuf));
12147 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12148 reference->plaintext.len);
12149 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12150 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12152 debug_hexdump(stdout, "plaintext:", plaintext,
12153 reference->plaintext.len);
12155 /* Create operation */
12156 retval = create_auth_verify_GMAC_operation(ts_params,
12163 if (data_corrupted)
12164 data_corruption(plaintext);
12166 tag_corruption(plaintext, reference->aad.len);
12168 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12169 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12171 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12172 RTE_CRYPTO_OP_STATUS_SUCCESS,
12173 "authentication not failed");
12174 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12175 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12176 ut_params->op, 0, 1, 0, 0);
12178 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12180 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12187 test_authenticated_decryption_fail_when_corruption(
12188 struct crypto_testsuite_params *ts_params,
12189 struct crypto_unittest_params *ut_params,
12190 const struct test_crypto_vector *reference,
12191 unsigned int data_corrupted)
12195 uint8_t *ciphertext;
12196 struct rte_cryptodev_info dev_info;
12198 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12199 uint64_t feat_flags = dev_info.feature_flags;
12201 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12202 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12203 printf("Device doesn't support RAW data-path APIs.\n");
12207 /* Verify the capabilities */
12208 struct rte_cryptodev_sym_capability_idx cap_idx;
12209 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12210 cap_idx.algo.auth = reference->auth_algo;
12211 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12214 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12215 cap_idx.algo.cipher = reference->crypto_algo;
12216 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12220 /* Create session */
12221 retval = create_auth_cipher_session(ut_params,
12222 ts_params->valid_devs[0],
12224 RTE_CRYPTO_AUTH_OP_VERIFY,
12225 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12229 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12230 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12231 "Failed to allocate input buffer in mempool");
12233 /* clear mbuf payload */
12234 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12235 rte_pktmbuf_tailroom(ut_params->ibuf));
12237 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12238 reference->ciphertext.len);
12239 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12240 memcpy(ciphertext, reference->ciphertext.data,
12241 reference->ciphertext.len);
12243 /* Create operation */
12244 retval = create_cipher_auth_verify_operation(ts_params,
12251 if (data_corrupted)
12252 data_corruption(ciphertext);
12254 tag_corruption(ciphertext, reference->ciphertext.len);
12256 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12257 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12259 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12260 RTE_CRYPTO_OP_STATUS_SUCCESS,
12261 "authentication not failed");
12262 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12263 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12264 ut_params->op, 1, 1, 0, 0);
12266 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12268 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12275 test_authenticated_encryt_with_esn(
12276 struct crypto_testsuite_params *ts_params,
12277 struct crypto_unittest_params *ut_params,
12278 const struct test_crypto_vector *reference)
12282 uint8_t *authciphertext, *plaintext, *auth_tag;
12283 uint16_t plaintext_pad_len;
12284 uint8_t cipher_key[reference->cipher_key.len + 1];
12285 uint8_t auth_key[reference->auth_key.len + 1];
12286 struct rte_cryptodev_info dev_info;
12288 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12289 uint64_t feat_flags = dev_info.feature_flags;
12291 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12292 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12293 printf("Device doesn't support RAW data-path APIs.\n");
12297 /* Verify the capabilities */
12298 struct rte_cryptodev_sym_capability_idx cap_idx;
12299 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12300 cap_idx.algo.auth = reference->auth_algo;
12301 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12304 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12305 cap_idx.algo.cipher = reference->crypto_algo;
12306 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12310 /* Create session */
12311 memcpy(cipher_key, reference->cipher_key.data,
12312 reference->cipher_key.len);
12313 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12315 /* Setup Cipher Parameters */
12316 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12317 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12318 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12319 ut_params->cipher_xform.cipher.key.data = cipher_key;
12320 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12321 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12322 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12324 ut_params->cipher_xform.next = &ut_params->auth_xform;
12326 /* Setup Authentication Parameters */
12327 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12328 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12329 ut_params->auth_xform.auth.algo = reference->auth_algo;
12330 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12331 ut_params->auth_xform.auth.key.data = auth_key;
12332 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12333 ut_params->auth_xform.next = NULL;
12335 /* Create Crypto session*/
12336 ut_params->sess = rte_cryptodev_sym_session_create(
12337 ts_params->session_mpool);
12339 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12341 &ut_params->cipher_xform,
12342 ts_params->session_priv_mpool);
12344 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12346 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12347 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12348 "Failed to allocate input buffer in mempool");
12350 /* clear mbuf payload */
12351 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12352 rte_pktmbuf_tailroom(ut_params->ibuf));
12354 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12355 reference->plaintext.len);
12356 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12357 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12359 /* Create operation */
12360 retval = create_cipher_auth_operation(ts_params,
12367 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12368 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12370 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12371 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12372 ut_params->op, 1, 1, 0, 0);
12374 ut_params->op = process_crypto_request(
12375 ts_params->valid_devs[0], ut_params->op);
12377 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12379 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12380 "crypto op processing failed");
12382 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12384 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12385 ut_params->op->sym->auth.data.offset);
12386 auth_tag = authciphertext + plaintext_pad_len;
12387 debug_hexdump(stdout, "ciphertext:", authciphertext,
12388 reference->ciphertext.len);
12389 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12391 /* Validate obuf */
12392 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12394 reference->ciphertext.data,
12395 reference->ciphertext.len,
12396 "Ciphertext data not as expected");
12398 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12400 reference->digest.data,
12401 reference->digest.len,
12402 "Generated digest not as expected");
12404 return TEST_SUCCESS;
12409 test_authenticated_decrypt_with_esn(
12410 struct crypto_testsuite_params *ts_params,
12411 struct crypto_unittest_params *ut_params,
12412 const struct test_crypto_vector *reference)
12416 uint8_t *ciphertext;
12417 uint8_t cipher_key[reference->cipher_key.len + 1];
12418 uint8_t auth_key[reference->auth_key.len + 1];
12419 struct rte_cryptodev_info dev_info;
12421 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12422 uint64_t feat_flags = dev_info.feature_flags;
12424 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12425 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12426 printf("Device doesn't support RAW data-path APIs.\n");
12430 /* Verify the capabilities */
12431 struct rte_cryptodev_sym_capability_idx cap_idx;
12432 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12433 cap_idx.algo.auth = reference->auth_algo;
12434 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12437 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12438 cap_idx.algo.cipher = reference->crypto_algo;
12439 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12443 /* Create session */
12444 memcpy(cipher_key, reference->cipher_key.data,
12445 reference->cipher_key.len);
12446 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12448 /* Setup Authentication Parameters */
12449 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12450 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12451 ut_params->auth_xform.auth.algo = reference->auth_algo;
12452 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12453 ut_params->auth_xform.auth.key.data = auth_key;
12454 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12455 ut_params->auth_xform.next = &ut_params->cipher_xform;
12457 /* Setup Cipher Parameters */
12458 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12459 ut_params->cipher_xform.next = NULL;
12460 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12461 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12462 ut_params->cipher_xform.cipher.key.data = cipher_key;
12463 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12464 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12465 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12467 /* Create Crypto session*/
12468 ut_params->sess = rte_cryptodev_sym_session_create(
12469 ts_params->session_mpool);
12471 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12473 &ut_params->auth_xform,
12474 ts_params->session_priv_mpool);
12476 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12478 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12479 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12480 "Failed to allocate input buffer in mempool");
12482 /* clear mbuf payload */
12483 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12484 rte_pktmbuf_tailroom(ut_params->ibuf));
12486 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12487 reference->ciphertext.len);
12488 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12489 memcpy(ciphertext, reference->ciphertext.data,
12490 reference->ciphertext.len);
12492 /* Create operation */
12493 retval = create_cipher_auth_verify_operation(ts_params,
12500 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12501 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12503 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12504 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12505 ut_params->op, 1, 1, 0, 0);
12507 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12510 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12511 TEST_ASSERT_EQUAL(ut_params->op->status,
12512 RTE_CRYPTO_OP_STATUS_SUCCESS,
12513 "crypto op processing passed");
12515 ut_params->obuf = ut_params->op->sym->m_src;
12516 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12522 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12523 const struct aead_test_data *tdata,
12524 void *digest_mem, uint64_t digest_phys)
12526 struct crypto_testsuite_params *ts_params = &testsuite_params;
12527 struct crypto_unittest_params *ut_params = &unittest_params;
12529 const unsigned int auth_tag_len = tdata->auth_tag.len;
12530 const unsigned int iv_len = tdata->iv.len;
12531 unsigned int aad_len = tdata->aad.len;
12532 unsigned int aad_len_pad = 0;
12534 /* Generate Crypto op data structure */
12535 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12536 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12537 TEST_ASSERT_NOT_NULL(ut_params->op,
12538 "Failed to allocate symmetric crypto operation struct");
12540 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12542 sym_op->aead.digest.data = digest_mem;
12544 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12545 "no room to append digest");
12547 sym_op->aead.digest.phys_addr = digest_phys;
12549 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12550 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12552 debug_hexdump(stdout, "digest:",
12553 sym_op->aead.digest.data,
12557 /* Append aad data */
12558 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12559 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12560 uint8_t *, IV_OFFSET);
12562 /* Copy IV 1 byte after the IV pointer, according to the API */
12563 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12565 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12567 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12568 ut_params->ibuf, aad_len);
12569 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12570 "no room to prepend aad");
12571 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12574 memset(sym_op->aead.aad.data, 0, aad_len);
12575 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12576 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12578 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12579 debug_hexdump(stdout, "aad:",
12580 sym_op->aead.aad.data, aad_len);
12582 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12583 uint8_t *, IV_OFFSET);
12585 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12587 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12589 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12590 ut_params->ibuf, aad_len_pad);
12591 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12592 "no room to prepend aad");
12593 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12596 memset(sym_op->aead.aad.data, 0, aad_len);
12597 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12599 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12600 debug_hexdump(stdout, "aad:",
12601 sym_op->aead.aad.data, aad_len);
12604 sym_op->aead.data.length = tdata->plaintext.len;
12605 sym_op->aead.data.offset = aad_len_pad;
12610 #define SGL_MAX_NO 16
12613 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12614 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12616 struct crypto_testsuite_params *ts_params = &testsuite_params;
12617 struct crypto_unittest_params *ut_params = &unittest_params;
12618 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12621 int to_trn_tbl[SGL_MAX_NO];
12623 unsigned int trn_data = 0;
12624 uint8_t *plaintext, *ciphertext, *auth_tag;
12625 struct rte_cryptodev_info dev_info;
12627 /* Verify the capabilities */
12628 struct rte_cryptodev_sym_capability_idx cap_idx;
12629 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12630 cap_idx.algo.aead = tdata->algo;
12631 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12635 /* OOP not supported with CPU crypto */
12636 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12639 /* Detailed check for the particular SGL support flag */
12640 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12642 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12643 if (sgl_in && (!(dev_info.feature_flags &
12644 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12647 uint64_t feat_flags = dev_info.feature_flags;
12649 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12650 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12651 printf("Device doesn't support RAW data-path APIs.\n");
12655 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12656 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12657 tdata->plaintext.len;
12658 /* Raw data path API does not support OOP */
12659 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12661 if (sgl_in && !sgl_out) {
12662 if (!(dev_info.feature_flags &
12663 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12665 } else if (!sgl_in && sgl_out) {
12666 if (!(dev_info.feature_flags &
12667 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12669 } else if (sgl_in && sgl_out) {
12670 if (!(dev_info.feature_flags &
12671 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12676 if (fragsz > tdata->plaintext.len)
12677 fragsz = tdata->plaintext.len;
12679 uint16_t plaintext_len = fragsz;
12680 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
12682 if (fragsz_oop > tdata->plaintext.len)
12683 frag_size_oop = tdata->plaintext.len;
12686 void *digest_mem = NULL;
12688 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
12690 if (tdata->plaintext.len % fragsz != 0) {
12691 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
12694 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
12699 * For out-op-place we need to alloc another mbuf
12702 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12703 rte_pktmbuf_append(ut_params->obuf,
12704 frag_size_oop + prepend_len);
12705 buf_oop = ut_params->obuf;
12708 /* Create AEAD session */
12709 retval = create_aead_session(ts_params->valid_devs[0],
12711 RTE_CRYPTO_AEAD_OP_ENCRYPT,
12712 tdata->key.data, tdata->key.len,
12713 tdata->aad.len, tdata->auth_tag.len,
12718 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12720 /* clear mbuf payload */
12721 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12722 rte_pktmbuf_tailroom(ut_params->ibuf));
12724 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12727 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12729 trn_data += plaintext_len;
12731 buf = ut_params->ibuf;
12734 * Loop until no more fragments
12737 while (trn_data < tdata->plaintext.len) {
12739 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12740 (tdata->plaintext.len - trn_data) : fragsz;
12742 to_trn_tbl[ecx++] = to_trn;
12744 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12747 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12748 rte_pktmbuf_tailroom(buf));
12751 if (oop && !fragsz_oop) {
12752 buf_last_oop = buf_oop->next =
12753 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12754 buf_oop = buf_oop->next;
12755 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12756 0, rte_pktmbuf_tailroom(buf_oop));
12757 rte_pktmbuf_append(buf_oop, to_trn);
12760 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12763 memcpy(plaintext, tdata->plaintext.data + trn_data,
12765 trn_data += to_trn;
12766 if (trn_data == tdata->plaintext.len) {
12769 digest_mem = rte_pktmbuf_append(buf_oop,
12770 tdata->auth_tag.len);
12772 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12773 tdata->auth_tag.len);
12777 uint64_t digest_phys = 0;
12779 ut_params->ibuf->nb_segs = segs;
12782 if (fragsz_oop && oop) {
12786 if (frag_size_oop == tdata->plaintext.len) {
12787 digest_mem = rte_pktmbuf_append(ut_params->obuf,
12788 tdata->auth_tag.len);
12790 digest_phys = rte_pktmbuf_iova_offset(
12792 tdata->plaintext.len + prepend_len);
12795 trn_data = frag_size_oop;
12796 while (trn_data < tdata->plaintext.len) {
12799 (tdata->plaintext.len - trn_data <
12801 (tdata->plaintext.len - trn_data) :
12804 to_trn_tbl[ecx++] = to_trn;
12806 buf_last_oop = buf_oop->next =
12807 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12808 buf_oop = buf_oop->next;
12809 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12810 0, rte_pktmbuf_tailroom(buf_oop));
12811 rte_pktmbuf_append(buf_oop, to_trn);
12813 trn_data += to_trn;
12815 if (trn_data == tdata->plaintext.len) {
12816 digest_mem = rte_pktmbuf_append(buf_oop,
12817 tdata->auth_tag.len);
12821 ut_params->obuf->nb_segs = segs;
12825 * Place digest at the end of the last buffer
12828 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12829 if (oop && buf_last_oop)
12830 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
12832 if (!digest_mem && !oop) {
12833 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12834 + tdata->auth_tag.len);
12835 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12836 tdata->plaintext.len);
12839 /* Create AEAD operation */
12840 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
12841 tdata, digest_mem, digest_phys);
12846 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12848 ut_params->op->sym->m_src = ut_params->ibuf;
12850 ut_params->op->sym->m_dst = ut_params->obuf;
12852 /* Process crypto operation */
12853 if (oop == IN_PLACE &&
12854 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12855 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12856 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12857 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12858 ut_params->op, 0, 0, 0, 0);
12860 TEST_ASSERT_NOT_NULL(
12861 process_crypto_request(ts_params->valid_devs[0],
12862 ut_params->op), "failed to process sym crypto op");
12864 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12865 "crypto op processing failed");
12868 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12869 uint8_t *, prepend_len);
12871 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12872 uint8_t *, prepend_len);
12876 fragsz = fragsz_oop;
12878 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12880 tdata->ciphertext.data,
12882 "Ciphertext data not as expected");
12884 buf = ut_params->op->sym->m_src->next;
12886 buf = ut_params->op->sym->m_dst->next;
12888 unsigned int off = fragsz;
12892 ciphertext = rte_pktmbuf_mtod(buf,
12895 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12897 tdata->ciphertext.data + off,
12899 "Ciphertext data not as expected");
12901 off += to_trn_tbl[ecx++];
12905 auth_tag = digest_mem;
12906 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12908 tdata->auth_tag.data,
12909 tdata->auth_tag.len,
12910 "Generated auth tag not as expected");
12916 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
12918 return test_authenticated_encryption_SGL(
12919 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
12923 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
12925 return test_authenticated_encryption_SGL(
12926 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
12930 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
12932 return test_authenticated_encryption_SGL(
12933 &gcm_test_case_8, OUT_OF_PLACE, 400,
12934 gcm_test_case_8.plaintext.len);
12938 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
12940 /* This test is not for OPENSSL PMD */
12941 if (gbl_driver_id == rte_cryptodev_driver_id_get(
12942 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
12945 return test_authenticated_encryption_SGL(
12946 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
12950 test_authentication_verify_fail_when_data_corrupted(
12951 struct crypto_testsuite_params *ts_params,
12952 struct crypto_unittest_params *ut_params,
12953 const struct test_crypto_vector *reference)
12955 return test_authentication_verify_fail_when_data_corruption(
12956 ts_params, ut_params, reference, 1);
12960 test_authentication_verify_fail_when_tag_corrupted(
12961 struct crypto_testsuite_params *ts_params,
12962 struct crypto_unittest_params *ut_params,
12963 const struct test_crypto_vector *reference)
12965 return test_authentication_verify_fail_when_data_corruption(
12966 ts_params, ut_params, reference, 0);
12970 test_authentication_verify_GMAC_fail_when_data_corrupted(
12971 struct crypto_testsuite_params *ts_params,
12972 struct crypto_unittest_params *ut_params,
12973 const struct test_crypto_vector *reference)
12975 return test_authentication_verify_GMAC_fail_when_corruption(
12976 ts_params, ut_params, reference, 1);
12980 test_authentication_verify_GMAC_fail_when_tag_corrupted(
12981 struct crypto_testsuite_params *ts_params,
12982 struct crypto_unittest_params *ut_params,
12983 const struct test_crypto_vector *reference)
12985 return test_authentication_verify_GMAC_fail_when_corruption(
12986 ts_params, ut_params, reference, 0);
12990 test_authenticated_decryption_fail_when_data_corrupted(
12991 struct crypto_testsuite_params *ts_params,
12992 struct crypto_unittest_params *ut_params,
12993 const struct test_crypto_vector *reference)
12995 return test_authenticated_decryption_fail_when_corruption(
12996 ts_params, ut_params, reference, 1);
13000 test_authenticated_decryption_fail_when_tag_corrupted(
13001 struct crypto_testsuite_params *ts_params,
13002 struct crypto_unittest_params *ut_params,
13003 const struct test_crypto_vector *reference)
13005 return test_authenticated_decryption_fail_when_corruption(
13006 ts_params, ut_params, reference, 0);
13010 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13012 return test_authentication_verify_fail_when_data_corrupted(
13013 &testsuite_params, &unittest_params,
13014 &hmac_sha1_test_crypto_vector);
13018 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13020 return test_authentication_verify_fail_when_tag_corrupted(
13021 &testsuite_params, &unittest_params,
13022 &hmac_sha1_test_crypto_vector);
13026 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13028 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13029 &testsuite_params, &unittest_params,
13030 &aes128_gmac_test_vector);
13034 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13036 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13037 &testsuite_params, &unittest_params,
13038 &aes128_gmac_test_vector);
13042 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13044 return test_authenticated_decryption_fail_when_data_corrupted(
13047 &aes128cbc_hmac_sha1_test_vector);
13051 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13053 return test_authenticated_decryption_fail_when_tag_corrupted(
13056 &aes128cbc_hmac_sha1_test_vector);
13060 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13062 return test_authenticated_encryt_with_esn(
13065 &aes128cbc_hmac_sha1_aad_test_vector);
13069 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13071 return test_authenticated_decrypt_with_esn(
13074 &aes128cbc_hmac_sha1_aad_test_vector);
13078 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13080 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13084 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13086 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13089 #ifdef RTE_CRYPTO_SCHEDULER
13091 /* global AESNI worker IDs for the scheduler test */
13092 uint8_t aesni_ids[2];
13095 test_scheduler_attach_slave_op(void)
13097 struct crypto_testsuite_params *ts_params = &testsuite_params;
13098 uint8_t sched_id = ts_params->valid_devs[0];
13099 uint32_t nb_devs, i, nb_devs_attached = 0;
13101 char vdev_name[32];
13103 /* create 2 AESNI_MB if necessary */
13104 nb_devs = rte_cryptodev_device_count_by_driver(
13105 rte_cryptodev_driver_id_get(
13106 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13108 for (i = nb_devs; i < 2; i++) {
13109 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13110 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13112 ret = rte_vdev_init(vdev_name, NULL);
13114 TEST_ASSERT(ret == 0,
13115 "Failed to create instance %u of"
13117 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13121 /* attach 2 AESNI_MB cdevs */
13122 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13124 struct rte_cryptodev_info info;
13125 unsigned int session_size;
13127 rte_cryptodev_info_get(i, &info);
13128 if (info.driver_id != rte_cryptodev_driver_id_get(
13129 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13132 session_size = rte_cryptodev_sym_get_private_session_size(i);
13134 * Create the session mempool again, since now there are new devices
13135 * to use the mempool.
13137 if (ts_params->session_mpool) {
13138 rte_mempool_free(ts_params->session_mpool);
13139 ts_params->session_mpool = NULL;
13141 if (ts_params->session_priv_mpool) {
13142 rte_mempool_free(ts_params->session_priv_mpool);
13143 ts_params->session_priv_mpool = NULL;
13146 if (info.sym.max_nb_sessions != 0 &&
13147 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13148 RTE_LOG(ERR, USER1,
13149 "Device does not support "
13150 "at least %u sessions\n",
13152 return TEST_FAILED;
13155 * Create mempool with maximum number of sessions,
13156 * to include the session headers
13158 if (ts_params->session_mpool == NULL) {
13159 ts_params->session_mpool =
13160 rte_cryptodev_sym_session_pool_create(
13162 MAX_NB_SESSIONS, 0, 0, 0,
13164 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13165 "session mempool allocation failed");
13169 * Create mempool with maximum number of sessions,
13170 * to include device specific session private data
13172 if (ts_params->session_priv_mpool == NULL) {
13173 ts_params->session_priv_mpool = rte_mempool_create(
13174 "test_sess_mp_priv",
13177 0, 0, NULL, NULL, NULL,
13178 NULL, SOCKET_ID_ANY,
13181 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13182 "session mempool allocation failed");
13185 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13186 ts_params->qp_conf.mp_session_private =
13187 ts_params->session_priv_mpool;
13189 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13192 TEST_ASSERT(ret == 0,
13193 "Failed to attach device %u of pmd : %s", i,
13194 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13196 aesni_ids[nb_devs_attached] = (uint8_t)i;
13198 nb_devs_attached++;
13205 test_scheduler_detach_slave_op(void)
13207 struct crypto_testsuite_params *ts_params = &testsuite_params;
13208 uint8_t sched_id = ts_params->valid_devs[0];
13212 for (i = 0; i < 2; i++) {
13213 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13215 TEST_ASSERT(ret == 0,
13216 "Failed to detach device %u", aesni_ids[i]);
13223 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13225 struct crypto_testsuite_params *ts_params = &testsuite_params;
13226 uint8_t sched_id = ts_params->valid_devs[0];
13228 return rte_cryptodev_scheduler_mode_set(sched_id,
13233 test_scheduler_mode_roundrobin_op(void)
13235 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13236 0, "Failed to set roundrobin mode");
13242 test_scheduler_mode_multicore_op(void)
13244 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13245 0, "Failed to set multicore mode");
13251 test_scheduler_mode_failover_op(void)
13253 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13254 0, "Failed to set failover mode");
13260 test_scheduler_mode_pkt_size_distr_op(void)
13262 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13263 0, "Failed to set pktsize mode");
13268 static struct unit_test_suite cryptodev_scheduler_testsuite = {
13269 .suite_name = "Crypto Device Scheduler Unit Test Suite",
13270 .setup = testsuite_setup,
13271 .teardown = testsuite_teardown,
13272 .unit_test_cases = {
13274 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13275 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
13276 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13277 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13278 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13279 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13282 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13283 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
13284 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13285 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13286 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13287 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13290 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13291 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
13292 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13293 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13294 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13295 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13298 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13299 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
13300 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13301 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13302 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13303 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13305 TEST_CASES_END() /**< NULL terminate unit test array */
13309 #endif /* RTE_CRYPTO_SCHEDULER */
13311 static struct unit_test_suite cryptodev_testsuite = {
13312 .suite_name = "Crypto Unit Test Suite",
13313 .setup = testsuite_setup,
13314 .teardown = testsuite_teardown,
13315 .unit_test_cases = {
13316 TEST_CASE_ST(ut_setup, ut_teardown,
13317 test_device_configure_invalid_dev_id),
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_queue_pair_descriptor_setup),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_device_configure_invalid_queue_pair_ids),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 test_multi_session),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_multi_session_random_usage),
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_null_invalid_operation),
13329 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13330 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13331 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13332 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13333 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13334 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
13335 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
13336 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
13337 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13338 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13340 /** AES CCM Authenticated Encryption 128 bits key */
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_AES_CCM_authenticated_encryption_test_case_128_1),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_AES_CCM_authenticated_encryption_test_case_128_2),
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 test_AES_CCM_authenticated_encryption_test_case_128_3),
13348 /** AES CCM Authenticated Decryption 128 bits key*/
13349 TEST_CASE_ST(ut_setup, ut_teardown,
13350 test_AES_CCM_authenticated_decryption_test_case_128_1),
13351 TEST_CASE_ST(ut_setup, ut_teardown,
13352 test_AES_CCM_authenticated_decryption_test_case_128_2),
13353 TEST_CASE_ST(ut_setup, ut_teardown,
13354 test_AES_CCM_authenticated_decryption_test_case_128_3),
13356 /** AES CCM Authenticated Encryption 192 bits key */
13357 TEST_CASE_ST(ut_setup, ut_teardown,
13358 test_AES_CCM_authenticated_encryption_test_case_192_1),
13359 TEST_CASE_ST(ut_setup, ut_teardown,
13360 test_AES_CCM_authenticated_encryption_test_case_192_2),
13361 TEST_CASE_ST(ut_setup, ut_teardown,
13362 test_AES_CCM_authenticated_encryption_test_case_192_3),
13364 /** AES CCM Authenticated Decryption 192 bits key*/
13365 TEST_CASE_ST(ut_setup, ut_teardown,
13366 test_AES_CCM_authenticated_decryption_test_case_192_1),
13367 TEST_CASE_ST(ut_setup, ut_teardown,
13368 test_AES_CCM_authenticated_decryption_test_case_192_2),
13369 TEST_CASE_ST(ut_setup, ut_teardown,
13370 test_AES_CCM_authenticated_decryption_test_case_192_3),
13372 /** AES CCM Authenticated Encryption 256 bits key */
13373 TEST_CASE_ST(ut_setup, ut_teardown,
13374 test_AES_CCM_authenticated_encryption_test_case_256_1),
13375 TEST_CASE_ST(ut_setup, ut_teardown,
13376 test_AES_CCM_authenticated_encryption_test_case_256_2),
13377 TEST_CASE_ST(ut_setup, ut_teardown,
13378 test_AES_CCM_authenticated_encryption_test_case_256_3),
13380 /** AES CCM Authenticated Decryption 256 bits key*/
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_AES_CCM_authenticated_decryption_test_case_256_1),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_AES_CCM_authenticated_decryption_test_case_256_2),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_AES_CCM_authenticated_decryption_test_case_256_3),
13388 /** AES GCM Authenticated Encryption */
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13393 TEST_CASE_ST(ut_setup, ut_teardown,
13394 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13395 TEST_CASE_ST(ut_setup, ut_teardown,
13396 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13397 TEST_CASE_ST(ut_setup, ut_teardown,
13398 test_AES_GCM_authenticated_encryption_test_case_1),
13399 TEST_CASE_ST(ut_setup, ut_teardown,
13400 test_AES_GCM_authenticated_encryption_test_case_2),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_AES_GCM_authenticated_encryption_test_case_3),
13403 TEST_CASE_ST(ut_setup, ut_teardown,
13404 test_AES_GCM_authenticated_encryption_test_case_4),
13405 TEST_CASE_ST(ut_setup, ut_teardown,
13406 test_AES_GCM_authenticated_encryption_test_case_5),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_AES_GCM_authenticated_encryption_test_case_6),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_AES_GCM_authenticated_encryption_test_case_7),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_AES_GCM_authenticated_encryption_test_case_8),
13413 TEST_CASE_ST(ut_setup, ut_teardown,
13414 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13416 /** AES GCM Authenticated Decryption */
13417 TEST_CASE_ST(ut_setup, ut_teardown,
13418 test_AES_GCM_authenticated_decryption_test_case_1),
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 test_AES_GCM_authenticated_decryption_test_case_2),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 test_AES_GCM_authenticated_decryption_test_case_3),
13423 TEST_CASE_ST(ut_setup, ut_teardown,
13424 test_AES_GCM_authenticated_decryption_test_case_4),
13425 TEST_CASE_ST(ut_setup, ut_teardown,
13426 test_AES_GCM_authenticated_decryption_test_case_5),
13427 TEST_CASE_ST(ut_setup, ut_teardown,
13428 test_AES_GCM_authenticated_decryption_test_case_6),
13429 TEST_CASE_ST(ut_setup, ut_teardown,
13430 test_AES_GCM_authenticated_decryption_test_case_7),
13431 TEST_CASE_ST(ut_setup, ut_teardown,
13432 test_AES_GCM_authenticated_decryption_test_case_8),
13433 TEST_CASE_ST(ut_setup, ut_teardown,
13434 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13436 /** AES GCM Authenticated Encryption 192 bits key */
13437 TEST_CASE_ST(ut_setup, ut_teardown,
13438 test_AES_GCM_auth_encryption_test_case_192_1),
13439 TEST_CASE_ST(ut_setup, ut_teardown,
13440 test_AES_GCM_auth_encryption_test_case_192_2),
13441 TEST_CASE_ST(ut_setup, ut_teardown,
13442 test_AES_GCM_auth_encryption_test_case_192_3),
13443 TEST_CASE_ST(ut_setup, ut_teardown,
13444 test_AES_GCM_auth_encryption_test_case_192_4),
13445 TEST_CASE_ST(ut_setup, ut_teardown,
13446 test_AES_GCM_auth_encryption_test_case_192_5),
13447 TEST_CASE_ST(ut_setup, ut_teardown,
13448 test_AES_GCM_auth_encryption_test_case_192_6),
13449 TEST_CASE_ST(ut_setup, ut_teardown,
13450 test_AES_GCM_auth_encryption_test_case_192_7),
13452 /** AES GCM Authenticated Decryption 192 bits key */
13453 TEST_CASE_ST(ut_setup, ut_teardown,
13454 test_AES_GCM_auth_decryption_test_case_192_1),
13455 TEST_CASE_ST(ut_setup, ut_teardown,
13456 test_AES_GCM_auth_decryption_test_case_192_2),
13457 TEST_CASE_ST(ut_setup, ut_teardown,
13458 test_AES_GCM_auth_decryption_test_case_192_3),
13459 TEST_CASE_ST(ut_setup, ut_teardown,
13460 test_AES_GCM_auth_decryption_test_case_192_4),
13461 TEST_CASE_ST(ut_setup, ut_teardown,
13462 test_AES_GCM_auth_decryption_test_case_192_5),
13463 TEST_CASE_ST(ut_setup, ut_teardown,
13464 test_AES_GCM_auth_decryption_test_case_192_6),
13465 TEST_CASE_ST(ut_setup, ut_teardown,
13466 test_AES_GCM_auth_decryption_test_case_192_7),
13468 /** AES GCM Authenticated Encryption 256 bits key */
13469 TEST_CASE_ST(ut_setup, ut_teardown,
13470 test_AES_GCM_auth_encryption_test_case_256_1),
13471 TEST_CASE_ST(ut_setup, ut_teardown,
13472 test_AES_GCM_auth_encryption_test_case_256_2),
13473 TEST_CASE_ST(ut_setup, ut_teardown,
13474 test_AES_GCM_auth_encryption_test_case_256_3),
13475 TEST_CASE_ST(ut_setup, ut_teardown,
13476 test_AES_GCM_auth_encryption_test_case_256_4),
13477 TEST_CASE_ST(ut_setup, ut_teardown,
13478 test_AES_GCM_auth_encryption_test_case_256_5),
13479 TEST_CASE_ST(ut_setup, ut_teardown,
13480 test_AES_GCM_auth_encryption_test_case_256_6),
13481 TEST_CASE_ST(ut_setup, ut_teardown,
13482 test_AES_GCM_auth_encryption_test_case_256_7),
13484 /** AES GCM Authenticated Decryption 256 bits key */
13485 TEST_CASE_ST(ut_setup, ut_teardown,
13486 test_AES_GCM_auth_decryption_test_case_256_1),
13487 TEST_CASE_ST(ut_setup, ut_teardown,
13488 test_AES_GCM_auth_decryption_test_case_256_2),
13489 TEST_CASE_ST(ut_setup, ut_teardown,
13490 test_AES_GCM_auth_decryption_test_case_256_3),
13491 TEST_CASE_ST(ut_setup, ut_teardown,
13492 test_AES_GCM_auth_decryption_test_case_256_4),
13493 TEST_CASE_ST(ut_setup, ut_teardown,
13494 test_AES_GCM_auth_decryption_test_case_256_5),
13495 TEST_CASE_ST(ut_setup, ut_teardown,
13496 test_AES_GCM_auth_decryption_test_case_256_6),
13497 TEST_CASE_ST(ut_setup, ut_teardown,
13498 test_AES_GCM_auth_decryption_test_case_256_7),
13500 /** AES GCM Authenticated Encryption big aad size */
13501 TEST_CASE_ST(ut_setup, ut_teardown,
13502 test_AES_GCM_auth_encryption_test_case_aad_1),
13503 TEST_CASE_ST(ut_setup, ut_teardown,
13504 test_AES_GCM_auth_encryption_test_case_aad_2),
13506 /** AES GCM Authenticated Decryption big aad size */
13507 TEST_CASE_ST(ut_setup, ut_teardown,
13508 test_AES_GCM_auth_decryption_test_case_aad_1),
13509 TEST_CASE_ST(ut_setup, ut_teardown,
13510 test_AES_GCM_auth_decryption_test_case_aad_2),
13512 /** Out of place tests */
13513 TEST_CASE_ST(ut_setup, ut_teardown,
13514 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13515 TEST_CASE_ST(ut_setup, ut_teardown,
13516 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13518 /** Session-less tests */
13519 TEST_CASE_ST(ut_setup, ut_teardown,
13520 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13524 /** AES GMAC Authentication */
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_AES_GMAC_authentication_test_case_1),
13527 TEST_CASE_ST(ut_setup, ut_teardown,
13528 test_AES_GMAC_authentication_verify_test_case_1),
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_AES_GMAC_authentication_test_case_2),
13531 TEST_CASE_ST(ut_setup, ut_teardown,
13532 test_AES_GMAC_authentication_verify_test_case_2),
13533 TEST_CASE_ST(ut_setup, ut_teardown,
13534 test_AES_GMAC_authentication_test_case_3),
13535 TEST_CASE_ST(ut_setup, ut_teardown,
13536 test_AES_GMAC_authentication_verify_test_case_3),
13537 TEST_CASE_ST(ut_setup, ut_teardown,
13538 test_AES_GMAC_authentication_test_case_4),
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_AES_GMAC_authentication_verify_test_case_4),
13541 TEST_CASE_ST(ut_setup, ut_teardown,
13542 test_AES_GMAC_authentication_SGL_40B),
13543 TEST_CASE_ST(ut_setup, ut_teardown,
13544 test_AES_GMAC_authentication_SGL_80B),
13545 TEST_CASE_ST(ut_setup, ut_teardown,
13546 test_AES_GMAC_authentication_SGL_2048B),
13547 TEST_CASE_ST(ut_setup, ut_teardown,
13548 test_AES_GMAC_authentication_SGL_2047B),
13550 /** Chacha20-Poly1305 */
13551 TEST_CASE_ST(ut_setup, ut_teardown,
13552 test_chacha20_poly1305_encrypt_test_case_rfc8439),
13553 TEST_CASE_ST(ut_setup, ut_teardown,
13554 test_chacha20_poly1305_decrypt_test_case_rfc8439),
13555 /** SNOW 3G encrypt only (UEA2) */
13556 TEST_CASE_ST(ut_setup, ut_teardown,
13557 test_snow3g_encryption_test_case_1),
13558 TEST_CASE_ST(ut_setup, ut_teardown,
13559 test_snow3g_encryption_test_case_2),
13560 TEST_CASE_ST(ut_setup, ut_teardown,
13561 test_snow3g_encryption_test_case_3),
13562 TEST_CASE_ST(ut_setup, ut_teardown,
13563 test_snow3g_encryption_test_case_4),
13564 TEST_CASE_ST(ut_setup, ut_teardown,
13565 test_snow3g_encryption_test_case_5),
13567 TEST_CASE_ST(ut_setup, ut_teardown,
13568 test_snow3g_encryption_test_case_1_oop),
13569 TEST_CASE_ST(ut_setup, ut_teardown,
13570 test_snow3g_encryption_test_case_1_oop_sgl),
13571 TEST_CASE_ST(ut_setup, ut_teardown,
13572 test_snow3g_encryption_test_case_1_offset_oop),
13573 TEST_CASE_ST(ut_setup, ut_teardown,
13574 test_snow3g_decryption_test_case_1_oop),
13576 /** SNOW 3G generate auth, then encrypt (UEA2) */
13577 TEST_CASE_ST(ut_setup, ut_teardown,
13578 test_snow3g_auth_cipher_test_case_1),
13579 TEST_CASE_ST(ut_setup, ut_teardown,
13580 test_snow3g_auth_cipher_test_case_2),
13581 TEST_CASE_ST(ut_setup, ut_teardown,
13582 test_snow3g_auth_cipher_test_case_2_oop),
13583 TEST_CASE_ST(ut_setup, ut_teardown,
13584 test_snow3g_auth_cipher_part_digest_enc),
13585 TEST_CASE_ST(ut_setup, ut_teardown,
13586 test_snow3g_auth_cipher_part_digest_enc_oop),
13587 TEST_CASE_ST(ut_setup, ut_teardown,
13588 test_snow3g_auth_cipher_test_case_3_sgl),
13589 TEST_CASE_ST(ut_setup, ut_teardown,
13590 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13591 TEST_CASE_ST(ut_setup, ut_teardown,
13592 test_snow3g_auth_cipher_part_digest_enc_sgl),
13593 TEST_CASE_ST(ut_setup, ut_teardown,
13594 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13596 /** SNOW 3G decrypt (UEA2), then verify auth */
13597 TEST_CASE_ST(ut_setup, ut_teardown,
13598 test_snow3g_auth_cipher_verify_test_case_1),
13599 TEST_CASE_ST(ut_setup, ut_teardown,
13600 test_snow3g_auth_cipher_verify_test_case_2),
13601 TEST_CASE_ST(ut_setup, ut_teardown,
13602 test_snow3g_auth_cipher_verify_test_case_2_oop),
13603 TEST_CASE_ST(ut_setup, ut_teardown,
13604 test_snow3g_auth_cipher_verify_part_digest_enc),
13605 TEST_CASE_ST(ut_setup, ut_teardown,
13606 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13607 TEST_CASE_ST(ut_setup, ut_teardown,
13608 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13609 TEST_CASE_ST(ut_setup, ut_teardown,
13610 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13611 TEST_CASE_ST(ut_setup, ut_teardown,
13612 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13613 TEST_CASE_ST(ut_setup, ut_teardown,
13614 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13616 /** SNOW 3G decrypt only (UEA2) */
13617 TEST_CASE_ST(ut_setup, ut_teardown,
13618 test_snow3g_decryption_test_case_1),
13619 TEST_CASE_ST(ut_setup, ut_teardown,
13620 test_snow3g_decryption_test_case_2),
13621 TEST_CASE_ST(ut_setup, ut_teardown,
13622 test_snow3g_decryption_test_case_3),
13623 TEST_CASE_ST(ut_setup, ut_teardown,
13624 test_snow3g_decryption_test_case_4),
13625 TEST_CASE_ST(ut_setup, ut_teardown,
13626 test_snow3g_decryption_test_case_5),
13627 TEST_CASE_ST(ut_setup, ut_teardown,
13628 test_snow3g_decryption_with_digest_test_case_1),
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 test_snow3g_hash_generate_test_case_1),
13631 TEST_CASE_ST(ut_setup, ut_teardown,
13632 test_snow3g_hash_generate_test_case_2),
13633 TEST_CASE_ST(ut_setup, ut_teardown,
13634 test_snow3g_hash_generate_test_case_3),
13635 /* Tests with buffers which length is not byte-aligned */
13636 TEST_CASE_ST(ut_setup, ut_teardown,
13637 test_snow3g_hash_generate_test_case_4),
13638 TEST_CASE_ST(ut_setup, ut_teardown,
13639 test_snow3g_hash_generate_test_case_5),
13640 TEST_CASE_ST(ut_setup, ut_teardown,
13641 test_snow3g_hash_generate_test_case_6),
13642 TEST_CASE_ST(ut_setup, ut_teardown,
13643 test_snow3g_hash_verify_test_case_1),
13644 TEST_CASE_ST(ut_setup, ut_teardown,
13645 test_snow3g_hash_verify_test_case_2),
13646 TEST_CASE_ST(ut_setup, ut_teardown,
13647 test_snow3g_hash_verify_test_case_3),
13648 /* Tests with buffers which length is not byte-aligned */
13649 TEST_CASE_ST(ut_setup, ut_teardown,
13650 test_snow3g_hash_verify_test_case_4),
13651 TEST_CASE_ST(ut_setup, ut_teardown,
13652 test_snow3g_hash_verify_test_case_5),
13653 TEST_CASE_ST(ut_setup, ut_teardown,
13654 test_snow3g_hash_verify_test_case_6),
13655 TEST_CASE_ST(ut_setup, ut_teardown,
13656 test_snow3g_cipher_auth_test_case_1),
13657 TEST_CASE_ST(ut_setup, ut_teardown,
13658 test_snow3g_auth_cipher_with_digest_test_case_1),
13660 /** ZUC encrypt only (EEA3) */
13661 TEST_CASE_ST(ut_setup, ut_teardown,
13662 test_zuc_encryption_test_case_1),
13663 TEST_CASE_ST(ut_setup, ut_teardown,
13664 test_zuc_encryption_test_case_2),
13665 TEST_CASE_ST(ut_setup, ut_teardown,
13666 test_zuc_encryption_test_case_3),
13667 TEST_CASE_ST(ut_setup, ut_teardown,
13668 test_zuc_encryption_test_case_4),
13669 TEST_CASE_ST(ut_setup, ut_teardown,
13670 test_zuc_encryption_test_case_5),
13671 TEST_CASE_ST(ut_setup, ut_teardown,
13672 test_zuc_encryption_test_case_6_sgl),
13674 /** ZUC authenticate (EIA3) */
13675 TEST_CASE_ST(ut_setup, ut_teardown,
13676 test_zuc_hash_generate_test_case_1),
13677 TEST_CASE_ST(ut_setup, ut_teardown,
13678 test_zuc_hash_generate_test_case_2),
13679 TEST_CASE_ST(ut_setup, ut_teardown,
13680 test_zuc_hash_generate_test_case_3),
13681 TEST_CASE_ST(ut_setup, ut_teardown,
13682 test_zuc_hash_generate_test_case_4),
13683 TEST_CASE_ST(ut_setup, ut_teardown,
13684 test_zuc_hash_generate_test_case_5),
13685 TEST_CASE_ST(ut_setup, ut_teardown,
13686 test_zuc_hash_generate_test_case_6),
13687 TEST_CASE_ST(ut_setup, ut_teardown,
13688 test_zuc_hash_generate_test_case_7),
13689 TEST_CASE_ST(ut_setup, ut_teardown,
13690 test_zuc_hash_generate_test_case_8),
13692 /** ZUC alg-chain (EEA3/EIA3) */
13693 TEST_CASE_ST(ut_setup, ut_teardown,
13694 test_zuc_cipher_auth_test_case_1),
13695 TEST_CASE_ST(ut_setup, ut_teardown,
13696 test_zuc_cipher_auth_test_case_2),
13698 /** ZUC generate auth, then encrypt (EEA3) */
13699 TEST_CASE_ST(ut_setup, ut_teardown,
13700 test_zuc_auth_cipher_test_case_1),
13701 TEST_CASE_ST(ut_setup, ut_teardown,
13702 test_zuc_auth_cipher_test_case_1_oop),
13703 TEST_CASE_ST(ut_setup, ut_teardown,
13704 test_zuc_auth_cipher_test_case_1_sgl),
13705 TEST_CASE_ST(ut_setup, ut_teardown,
13706 test_zuc_auth_cipher_test_case_1_oop_sgl),
13708 /** ZUC decrypt (EEA3), then verify auth */
13709 TEST_CASE_ST(ut_setup, ut_teardown,
13710 test_zuc_auth_cipher_verify_test_case_1),
13711 TEST_CASE_ST(ut_setup, ut_teardown,
13712 test_zuc_auth_cipher_verify_test_case_1_oop),
13713 TEST_CASE_ST(ut_setup, ut_teardown,
13714 test_zuc_auth_cipher_verify_test_case_1_sgl),
13715 TEST_CASE_ST(ut_setup, ut_teardown,
13716 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
13718 /** HMAC_MD5 Authentication */
13719 TEST_CASE_ST(ut_setup, ut_teardown,
13720 test_MD5_HMAC_generate_case_1),
13721 TEST_CASE_ST(ut_setup, ut_teardown,
13722 test_MD5_HMAC_verify_case_1),
13723 TEST_CASE_ST(ut_setup, ut_teardown,
13724 test_MD5_HMAC_generate_case_2),
13725 TEST_CASE_ST(ut_setup, ut_teardown,
13726 test_MD5_HMAC_verify_case_2),
13728 /** KASUMI hash only (UIA1) */
13729 TEST_CASE_ST(ut_setup, ut_teardown,
13730 test_kasumi_hash_generate_test_case_1),
13731 TEST_CASE_ST(ut_setup, ut_teardown,
13732 test_kasumi_hash_generate_test_case_2),
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 test_kasumi_hash_generate_test_case_3),
13735 TEST_CASE_ST(ut_setup, ut_teardown,
13736 test_kasumi_hash_generate_test_case_4),
13737 TEST_CASE_ST(ut_setup, ut_teardown,
13738 test_kasumi_hash_generate_test_case_5),
13739 TEST_CASE_ST(ut_setup, ut_teardown,
13740 test_kasumi_hash_generate_test_case_6),
13742 TEST_CASE_ST(ut_setup, ut_teardown,
13743 test_kasumi_hash_verify_test_case_1),
13744 TEST_CASE_ST(ut_setup, ut_teardown,
13745 test_kasumi_hash_verify_test_case_2),
13746 TEST_CASE_ST(ut_setup, ut_teardown,
13747 test_kasumi_hash_verify_test_case_3),
13748 TEST_CASE_ST(ut_setup, ut_teardown,
13749 test_kasumi_hash_verify_test_case_4),
13750 TEST_CASE_ST(ut_setup, ut_teardown,
13751 test_kasumi_hash_verify_test_case_5),
13753 /** KASUMI encrypt only (UEA1) */
13754 TEST_CASE_ST(ut_setup, ut_teardown,
13755 test_kasumi_encryption_test_case_1),
13756 TEST_CASE_ST(ut_setup, ut_teardown,
13757 test_kasumi_encryption_test_case_1_sgl),
13758 TEST_CASE_ST(ut_setup, ut_teardown,
13759 test_kasumi_encryption_test_case_1_oop),
13760 TEST_CASE_ST(ut_setup, ut_teardown,
13761 test_kasumi_encryption_test_case_1_oop_sgl),
13762 TEST_CASE_ST(ut_setup, ut_teardown,
13763 test_kasumi_encryption_test_case_2),
13764 TEST_CASE_ST(ut_setup, ut_teardown,
13765 test_kasumi_encryption_test_case_3),
13766 TEST_CASE_ST(ut_setup, ut_teardown,
13767 test_kasumi_encryption_test_case_4),
13768 TEST_CASE_ST(ut_setup, ut_teardown,
13769 test_kasumi_encryption_test_case_5),
13771 /** KASUMI decrypt only (UEA1) */
13772 TEST_CASE_ST(ut_setup, ut_teardown,
13773 test_kasumi_decryption_test_case_1),
13774 TEST_CASE_ST(ut_setup, ut_teardown,
13775 test_kasumi_decryption_test_case_2),
13776 TEST_CASE_ST(ut_setup, ut_teardown,
13777 test_kasumi_decryption_test_case_3),
13778 TEST_CASE_ST(ut_setup, ut_teardown,
13779 test_kasumi_decryption_test_case_4),
13780 TEST_CASE_ST(ut_setup, ut_teardown,
13781 test_kasumi_decryption_test_case_5),
13782 TEST_CASE_ST(ut_setup, ut_teardown,
13783 test_kasumi_decryption_test_case_1_oop),
13785 TEST_CASE_ST(ut_setup, ut_teardown,
13786 test_kasumi_cipher_auth_test_case_1),
13788 /** KASUMI generate auth, then encrypt (F8) */
13789 TEST_CASE_ST(ut_setup, ut_teardown,
13790 test_kasumi_auth_cipher_test_case_1),
13791 TEST_CASE_ST(ut_setup, ut_teardown,
13792 test_kasumi_auth_cipher_test_case_2),
13793 TEST_CASE_ST(ut_setup, ut_teardown,
13794 test_kasumi_auth_cipher_test_case_2_oop),
13795 TEST_CASE_ST(ut_setup, ut_teardown,
13796 test_kasumi_auth_cipher_test_case_2_sgl),
13797 TEST_CASE_ST(ut_setup, ut_teardown,
13798 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13800 /** KASUMI decrypt (F8), then verify auth */
13801 TEST_CASE_ST(ut_setup, ut_teardown,
13802 test_kasumi_auth_cipher_verify_test_case_1),
13803 TEST_CASE_ST(ut_setup, ut_teardown,
13804 test_kasumi_auth_cipher_verify_test_case_2),
13805 TEST_CASE_ST(ut_setup, ut_teardown,
13806 test_kasumi_auth_cipher_verify_test_case_2_oop),
13807 TEST_CASE_ST(ut_setup, ut_teardown,
13808 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13809 TEST_CASE_ST(ut_setup, ut_teardown,
13810 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13812 /** ESN Testcase */
13813 TEST_CASE_ST(ut_setup, ut_teardown,
13814 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13815 TEST_CASE_ST(ut_setup, ut_teardown,
13816 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13818 /** Negative tests */
13819 TEST_CASE_ST(ut_setup, ut_teardown,
13820 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13821 TEST_CASE_ST(ut_setup, ut_teardown,
13822 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13823 TEST_CASE_ST(ut_setup, ut_teardown,
13824 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13825 TEST_CASE_ST(ut_setup, ut_teardown,
13826 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13829 TEST_CASE_ST(ut_setup, ut_teardown,
13830 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13833 TEST_CASE_ST(ut_setup, ut_teardown,
13834 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13837 TEST_CASE_ST(ut_setup, ut_teardown,
13838 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13839 TEST_CASE_ST(ut_setup, ut_teardown,
13840 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13841 TEST_CASE_ST(ut_setup, ut_teardown,
13842 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13843 TEST_CASE_ST(ut_setup, ut_teardown,
13844 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13845 TEST_CASE_ST(ut_setup, ut_teardown,
13846 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13847 TEST_CASE_ST(ut_setup, ut_teardown,
13848 authentication_verify_AES128_GMAC_fail_data_corrupt),
13849 TEST_CASE_ST(ut_setup, ut_teardown,
13850 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13851 TEST_CASE_ST(ut_setup, ut_teardown,
13852 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13853 TEST_CASE_ST(ut_setup, ut_teardown,
13854 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13856 /** Mixed CIPHER + HASH algorithms */
13857 /** AUTH AES CMAC + CIPHER AES CTR */
13858 TEST_CASE_ST(ut_setup, ut_teardown,
13859 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
13860 TEST_CASE_ST(ut_setup, ut_teardown,
13861 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
13868 TEST_CASE_ST(ut_setup, ut_teardown,
13869 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13870 TEST_CASE_ST(ut_setup, ut_teardown,
13871 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13872 TEST_CASE_ST(ut_setup, ut_teardown,
13873 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13875 /** AUTH ZUC + CIPHER SNOW3G */
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_auth_zuc_cipher_snow_test_case_1),
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_verify_auth_zuc_cipher_snow_test_case_1),
13880 /** AUTH AES CMAC + CIPHER SNOW3G */
13881 TEST_CASE_ST(ut_setup, ut_teardown,
13882 test_auth_aes_cmac_cipher_snow_test_case_1),
13883 TEST_CASE_ST(ut_setup, ut_teardown,
13884 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
13885 /** AUTH ZUC + CIPHER AES CTR */
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_auth_zuc_cipher_aes_ctr_test_case_1),
13888 TEST_CASE_ST(ut_setup, ut_teardown,
13889 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
13890 /** AUTH SNOW3G + CIPHER AES CTR */
13891 TEST_CASE_ST(ut_setup, ut_teardown,
13892 test_auth_snow_cipher_aes_ctr_test_case_1),
13893 TEST_CASE_ST(ut_setup, ut_teardown,
13894 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
13895 /** AUTH SNOW3G + CIPHER ZUC */
13896 TEST_CASE_ST(ut_setup, ut_teardown,
13897 test_auth_snow_cipher_zuc_test_case_1),
13898 TEST_CASE_ST(ut_setup, ut_teardown,
13899 test_verify_auth_snow_cipher_zuc_test_case_1),
13900 /** AUTH AES CMAC + CIPHER ZUC */
13901 TEST_CASE_ST(ut_setup, ut_teardown,
13902 test_auth_aes_cmac_cipher_zuc_test_case_1),
13903 TEST_CASE_ST(ut_setup, ut_teardown,
13904 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
13906 /** AUTH NULL + CIPHER SNOW3G */
13907 TEST_CASE_ST(ut_setup, ut_teardown,
13908 test_auth_null_cipher_snow_test_case_1),
13909 TEST_CASE_ST(ut_setup, ut_teardown,
13910 test_verify_auth_null_cipher_snow_test_case_1),
13911 /** AUTH NULL + CIPHER ZUC */
13912 TEST_CASE_ST(ut_setup, ut_teardown,
13913 test_auth_null_cipher_zuc_test_case_1),
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_verify_auth_null_cipher_zuc_test_case_1),
13916 /** AUTH SNOW3G + CIPHER NULL */
13917 TEST_CASE_ST(ut_setup, ut_teardown,
13918 test_auth_snow_cipher_null_test_case_1),
13919 TEST_CASE_ST(ut_setup, ut_teardown,
13920 test_verify_auth_snow_cipher_null_test_case_1),
13921 /** AUTH ZUC + CIPHER NULL */
13922 TEST_CASE_ST(ut_setup, ut_teardown,
13923 test_auth_zuc_cipher_null_test_case_1),
13924 TEST_CASE_ST(ut_setup, ut_teardown,
13925 test_verify_auth_zuc_cipher_null_test_case_1),
13926 /** AUTH NULL + CIPHER AES CTR */
13927 TEST_CASE_ST(ut_setup, ut_teardown,
13928 test_auth_null_cipher_aes_ctr_test_case_1),
13929 TEST_CASE_ST(ut_setup, ut_teardown,
13930 test_verify_auth_null_cipher_aes_ctr_test_case_1),
13931 /** AUTH AES CMAC + CIPHER NULL */
13932 TEST_CASE_ST(ut_setup, ut_teardown,
13933 test_auth_aes_cmac_cipher_null_test_case_1),
13934 TEST_CASE_ST(ut_setup, ut_teardown,
13935 test_verify_auth_aes_cmac_cipher_null_test_case_1),
13937 #ifdef RTE_LIB_SECURITY
13938 TEST_CASE_ST(ut_setup_security, ut_teardown,
13939 test_PDCP_PROTO_all),
13940 TEST_CASE_ST(ut_setup_security, ut_teardown,
13941 test_DOCSIS_PROTO_all),
13943 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13944 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13945 TEST_CASES_END() /**< NULL terminate unit test array */
13949 static struct unit_test_suite cryptodev_virtio_testsuite = {
13950 .suite_name = "Crypto VIRTIO Unit Test Suite",
13951 .setup = testsuite_setup,
13952 .teardown = testsuite_teardown,
13953 .unit_test_cases = {
13954 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13956 TEST_CASES_END() /**< NULL terminate unit test array */
13960 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13961 .suite_name = "Crypto CAAM JR Unit Test Suite",
13962 .setup = testsuite_setup,
13963 .teardown = testsuite_teardown,
13964 .unit_test_cases = {
13965 TEST_CASE_ST(ut_setup, ut_teardown,
13966 test_device_configure_invalid_dev_id),
13967 TEST_CASE_ST(ut_setup, ut_teardown,
13968 test_multi_session),
13970 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13971 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13972 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13973 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13974 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13976 TEST_CASES_END() /**< NULL terminate unit test array */
13980 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13981 .suite_name = "Crypto Device Marvell Component Test Suite",
13982 .setup = testsuite_setup,
13983 .teardown = testsuite_teardown,
13984 .unit_test_cases = {
13985 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13986 TEST_CASE_ST(ut_setup, ut_teardown,
13987 test_multi_session_random_usage),
13988 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13989 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13990 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13991 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13992 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13994 /** Negative tests */
13995 TEST_CASE_ST(ut_setup, ut_teardown,
13996 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13997 TEST_CASE_ST(ut_setup, ut_teardown,
13998 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13999 TEST_CASE_ST(ut_setup, ut_teardown,
14000 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14001 TEST_CASE_ST(ut_setup, ut_teardown,
14002 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14004 TEST_CASES_END() /**< NULL terminate unit test array */
14008 static struct unit_test_suite cryptodev_ccp_testsuite = {
14009 .suite_name = "Crypto Device CCP Unit Test Suite",
14010 .setup = testsuite_setup,
14011 .teardown = testsuite_teardown,
14012 .unit_test_cases = {
14013 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14014 TEST_CASE_ST(ut_setup, ut_teardown,
14015 test_multi_session_random_usage),
14016 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14017 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
14018 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
14019 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
14020 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14022 /** Negative tests */
14023 TEST_CASE_ST(ut_setup, ut_teardown,
14024 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14025 TEST_CASE_ST(ut_setup, ut_teardown,
14026 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14027 TEST_CASE_ST(ut_setup, ut_teardown,
14028 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14029 TEST_CASE_ST(ut_setup, ut_teardown,
14030 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14032 TEST_CASES_END() /**< NULL terminate unit test array */
14037 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14039 gbl_driver_id = rte_cryptodev_driver_id_get(
14040 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14042 if (gbl_driver_id == -1) {
14043 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14044 return TEST_SKIPPED;
14047 return unit_test_suite_runner(&cryptodev_testsuite);
14051 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14053 gbl_driver_id = rte_cryptodev_driver_id_get(
14054 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14056 if (gbl_driver_id == -1) {
14057 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
14058 return TEST_FAILED;
14061 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14065 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14067 gbl_driver_id = rte_cryptodev_driver_id_get(
14068 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14070 if (gbl_driver_id == -1) {
14071 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14072 return TEST_SKIPPED;
14075 return unit_test_suite_runner(&cryptodev_testsuite);
14079 test_cryptodev_cpu_aesni_mb(void)
14082 enum rte_security_session_action_type at;
14084 gbl_driver_id = rte_cryptodev_driver_id_get(
14085 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14087 if (gbl_driver_id == -1) {
14088 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14089 return TEST_SKIPPED;
14092 at = gbl_action_type;
14093 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14094 rc = unit_test_suite_runner(&cryptodev_testsuite);
14095 gbl_action_type = at;
14100 test_cryptodev_openssl(void)
14102 gbl_driver_id = rte_cryptodev_driver_id_get(
14103 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14105 if (gbl_driver_id == -1) {
14106 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
14107 return TEST_SKIPPED;
14110 return unit_test_suite_runner(&cryptodev_testsuite);
14114 test_cryptodev_aesni_gcm(void)
14116 gbl_driver_id = rte_cryptodev_driver_id_get(
14117 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14119 if (gbl_driver_id == -1) {
14120 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14121 return TEST_SKIPPED;
14124 return unit_test_suite_runner(&cryptodev_testsuite);
14128 test_cryptodev_cpu_aesni_gcm(void)
14131 enum rte_security_session_action_type at;
14133 gbl_driver_id = rte_cryptodev_driver_id_get(
14134 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14136 if (gbl_driver_id == -1) {
14137 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14138 return TEST_SKIPPED;
14141 at = gbl_action_type;
14142 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14143 rc = unit_test_suite_runner(&cryptodev_testsuite);
14144 gbl_action_type = at;
14149 test_cryptodev_null(void)
14151 gbl_driver_id = rte_cryptodev_driver_id_get(
14152 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14154 if (gbl_driver_id == -1) {
14155 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
14156 return TEST_SKIPPED;
14159 return unit_test_suite_runner(&cryptodev_testsuite);
14163 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14165 gbl_driver_id = rte_cryptodev_driver_id_get(
14166 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14168 if (gbl_driver_id == -1) {
14169 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
14170 return TEST_SKIPPED;
14173 return unit_test_suite_runner(&cryptodev_testsuite);
14177 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14179 gbl_driver_id = rte_cryptodev_driver_id_get(
14180 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14182 if (gbl_driver_id == -1) {
14183 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14184 return TEST_SKIPPED;
14187 return unit_test_suite_runner(&cryptodev_testsuite);
14191 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14193 gbl_driver_id = rte_cryptodev_driver_id_get(
14194 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14196 if (gbl_driver_id == -1) {
14197 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14198 return TEST_SKIPPED;
14201 return unit_test_suite_runner(&cryptodev_testsuite);
14205 test_cryptodev_armv8(void)
14207 gbl_driver_id = rte_cryptodev_driver_id_get(
14208 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14210 if (gbl_driver_id == -1) {
14211 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
14212 return TEST_SKIPPED;
14215 return unit_test_suite_runner(&cryptodev_testsuite);
14219 test_cryptodev_mrvl(void)
14221 gbl_driver_id = rte_cryptodev_driver_id_get(
14222 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14224 if (gbl_driver_id == -1) {
14225 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
14226 return TEST_SKIPPED;
14229 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14232 #ifdef RTE_CRYPTO_SCHEDULER
14235 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14237 gbl_driver_id = rte_cryptodev_driver_id_get(
14238 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14240 if (gbl_driver_id == -1) {
14241 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14242 return TEST_SKIPPED;
14245 if (rte_cryptodev_driver_id_get(
14246 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14247 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14248 return TEST_SKIPPED;
14250 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14253 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14258 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14260 gbl_driver_id = rte_cryptodev_driver_id_get(
14261 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14263 if (gbl_driver_id == -1) {
14264 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
14265 return TEST_SKIPPED;
14268 return unit_test_suite_runner(&cryptodev_testsuite);
14272 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14274 gbl_driver_id = rte_cryptodev_driver_id_get(
14275 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14277 if (gbl_driver_id == -1) {
14278 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
14279 return TEST_SKIPPED;
14282 return unit_test_suite_runner(&cryptodev_testsuite);
14286 test_cryptodev_ccp(void)
14288 gbl_driver_id = rte_cryptodev_driver_id_get(
14289 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14291 if (gbl_driver_id == -1) {
14292 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
14293 return TEST_FAILED;
14296 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14300 test_cryptodev_octeontx(void)
14302 gbl_driver_id = rte_cryptodev_driver_id_get(
14303 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14304 if (gbl_driver_id == -1) {
14305 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
14306 return TEST_FAILED;
14308 return unit_test_suite_runner(&cryptodev_testsuite);
14312 test_cryptodev_octeontx2(void)
14314 gbl_driver_id = rte_cryptodev_driver_id_get(
14315 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14316 if (gbl_driver_id == -1) {
14317 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
14318 return TEST_FAILED;
14320 return unit_test_suite_runner(&cryptodev_testsuite);
14324 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14326 gbl_driver_id = rte_cryptodev_driver_id_get(
14327 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14329 if (gbl_driver_id == -1) {
14330 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
14331 return TEST_FAILED;
14334 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14338 test_cryptodev_nitrox(void)
14340 gbl_driver_id = rte_cryptodev_driver_id_get(
14341 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14343 if (gbl_driver_id == -1) {
14344 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
14345 return TEST_FAILED;
14348 return unit_test_suite_runner(&cryptodev_testsuite);
14352 test_cryptodev_bcmfs(void)
14354 gbl_driver_id = rte_cryptodev_driver_id_get(
14355 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14357 if (gbl_driver_id == -1) {
14358 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
14359 return TEST_FAILED;
14362 return unit_test_suite_runner(&cryptodev_testsuite);
14366 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14370 gbl_driver_id = rte_cryptodev_driver_id_get(
14371 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14373 if (gbl_driver_id == -1) {
14374 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14375 return TEST_SKIPPED;
14378 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14379 ret = unit_test_suite_runner(&cryptodev_testsuite);
14380 global_api_test_type = CRYPTODEV_API_TEST;
14385 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14386 test_cryptodev_qat_raw_api);
14387 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14388 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14389 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14390 test_cryptodev_cpu_aesni_mb);
14391 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14392 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14393 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14394 test_cryptodev_cpu_aesni_gcm);
14395 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14396 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14397 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14398 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14399 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14400 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14401 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14402 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14403 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14404 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14405 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14406 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14407 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14408 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14409 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);