1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
19 #include <rte_cryptodev_pmd.h>
20 #include <rte_string_fns.h>
22 #ifdef RTE_CRYPTO_SCHEDULER
23 #include <rte_cryptodev_scheduler.h>
24 #include <rte_cryptodev_scheduler_operations.h>
27 #include <rte_lcore.h>
30 #include "test_cryptodev.h"
32 #include "test_cryptodev_blockcipher.h"
33 #include "test_cryptodev_aes_test_vectors.h"
34 #include "test_cryptodev_des_test_vectors.h"
35 #include "test_cryptodev_hash_test_vectors.h"
36 #include "test_cryptodev_kasumi_test_vectors.h"
37 #include "test_cryptodev_kasumi_hash_test_vectors.h"
38 #include "test_cryptodev_snow3g_test_vectors.h"
39 #include "test_cryptodev_snow3g_hash_test_vectors.h"
40 #include "test_cryptodev_zuc_test_vectors.h"
41 #include "test_cryptodev_aead_test_vectors.h"
42 #include "test_cryptodev_hmac_test_vectors.h"
43 #include "test_cryptodev_mixed_test_vectors.h"
44 #ifdef RTE_LIB_SECURITY
45 #include "test_cryptodev_security_pdcp_test_vectors.h"
46 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
47 #include "test_cryptodev_security_pdcp_test_func.h"
48 #include "test_cryptodev_security_docsis_test_vectors.h"
50 #define SDAP_DISABLED 0
51 #define SDAP_ENABLED 1
54 #define VDEV_ARGS_SIZE 100
55 #define MAX_NB_SESSIONS 4
57 #define MAX_DRV_SERVICE_CTX_SIZE 256
59 #define MAX_RAW_DEQUEUE_COUNT 65535
62 #define OUT_OF_PLACE 1
65 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_testsuite_params {
76 struct rte_mempool *mbuf_pool;
77 struct rte_mempool *large_mbuf_pool;
78 struct rte_mempool *op_mpool;
79 struct rte_mempool *session_mpool;
80 struct rte_mempool *session_priv_mpool;
81 struct rte_cryptodev_config conf;
82 struct rte_cryptodev_qp_conf qp_conf;
84 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
85 uint8_t valid_dev_count;
88 struct crypto_unittest_params {
89 struct rte_crypto_sym_xform cipher_xform;
90 struct rte_crypto_sym_xform auth_xform;
91 struct rte_crypto_sym_xform aead_xform;
92 #ifdef RTE_LIB_SECURITY
93 struct rte_security_docsis_xform docsis_xform;
97 struct rte_cryptodev_sym_session *sess;
98 #ifdef RTE_LIB_SECURITY
99 struct rte_security_session *sec_session;
102 #ifdef RTE_LIB_SECURITY
103 enum rte_security_session_action_type type;
105 struct rte_crypto_op *op;
107 struct rte_mbuf *obuf, *ibuf;
112 #define ALIGN_POW2_ROUNDUP(num, align) \
113 (((num) + (align) - 1) & ~((align) - 1))
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
131 static struct rte_mbuf *
132 setup_test_string(struct rte_mempool *mpool,
133 const char *string, size_t len, uint8_t blocksize)
135 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
136 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
138 memset(m->buf_addr, 0, m->buf_len);
140 char *dst = rte_pktmbuf_append(m, t_len);
147 rte_memcpy(dst, string, t_len);
149 memset(dst, 0, t_len);
155 /* Get number of bytes in X bits (rounding up) */
157 ceil_byte_length(uint32_t num_bits)
160 return ((num_bits >> 3) + 1);
162 return (num_bits >> 3);
166 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
167 uint8_t is_op_success)
169 struct rte_crypto_op *op = user_data;
170 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
171 RTE_CRYPTO_OP_STATUS_ERROR;
175 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
176 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
177 uint8_t len_in_bits, uint8_t cipher_iv_len)
179 struct rte_crypto_sym_op *sop = op->sym;
180 struct rte_crypto_op *ret_op = NULL;
181 struct rte_crypto_vec data_vec[UINT8_MAX];
182 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
183 union rte_crypto_sym_ofs ofs;
184 struct rte_crypto_sym_vec vec;
185 struct rte_crypto_sgl sgl;
187 union rte_cryptodev_session_ctx sess;
189 struct rte_crypto_raw_dp_ctx *ctx;
190 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
194 int ctx_service_size;
196 int enqueue_status, dequeue_status;
198 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
199 if (ctx_service_size < 0) {
200 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
204 ctx = malloc(ctx_service_size);
206 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
210 /* Both are enums, setting crypto_sess will suit any session type */
211 sess.crypto_sess = op->sym->session;
213 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
214 op->sess_type, sess, 0) < 0) {
215 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
221 aad_auth_iv.iova = 0;
222 aad_auth_iv.va = NULL;
229 vec.digest = &digest;
230 vec.aad = &aad_auth_iv;
231 vec.status = &status;
235 if (is_cipher && is_auth) {
236 cipher_offset = sop->cipher.data.offset;
237 cipher_len = sop->cipher.data.length;
238 auth_offset = sop->auth.data.offset;
239 auth_len = sop->auth.data.length;
240 max_len = RTE_MAX(cipher_offset + cipher_len,
241 auth_offset + auth_len);
243 max_len = max_len >> 3;
244 cipher_offset = cipher_offset >> 3;
245 auth_offset = auth_offset >> 3;
246 cipher_len = cipher_len >> 3;
247 auth_len = auth_len >> 3;
249 ofs.ofs.cipher.head = cipher_offset;
250 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
251 ofs.ofs.auth.head = auth_offset;
252 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
253 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
254 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
255 aad_auth_iv.va = rte_crypto_op_ctod_offset(
256 op, void *, IV_OFFSET + cipher_iv_len);
257 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
259 digest.va = (void *)sop->auth.digest.data;
260 digest.iova = sop->auth.digest.phys_addr;
262 } else if (is_cipher) {
263 cipher_offset = sop->cipher.data.offset;
264 cipher_len = sop->cipher.data.length;
265 max_len = cipher_len + cipher_offset;
267 max_len = max_len >> 3;
268 cipher_offset = cipher_offset >> 3;
269 cipher_len = cipher_len >> 3;
271 ofs.ofs.cipher.head = cipher_offset;
272 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
273 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
274 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
276 } else if (is_auth) {
277 auth_offset = sop->auth.data.offset;
278 auth_len = sop->auth.data.length;
279 max_len = auth_len + auth_offset;
281 max_len = max_len >> 3;
282 auth_offset = auth_offset >> 3;
283 auth_len = auth_len >> 3;
285 ofs.ofs.auth.head = auth_offset;
286 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
287 aad_auth_iv.va = rte_crypto_op_ctod_offset(
288 op, void *, IV_OFFSET + cipher_iv_len);
289 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
291 digest.va = (void *)sop->auth.digest.data;
292 digest.iova = sop->auth.digest.phys_addr;
295 cipher_offset = sop->aead.data.offset;
296 cipher_len = sop->aead.data.length;
297 max_len = cipher_len + cipher_offset;
299 max_len = max_len >> 3;
300 cipher_offset = cipher_offset >> 3;
301 cipher_len = cipher_len >> 3;
303 ofs.ofs.cipher.head = cipher_offset;
304 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
305 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
306 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
307 aad_auth_iv.va = (void *)sop->aead.aad.data;
308 aad_auth_iv.iova = sop->aead.aad.phys_addr;
309 digest.va = (void *)sop->aead.digest.data;
310 digest.iova = sop->aead.digest.phys_addr;
313 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
314 data_vec, RTE_DIM(data_vec));
315 if (n < 0 || n > sop->m_src->nb_segs) {
316 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
322 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
323 &enqueue_status) < 1) {
324 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
328 if (enqueue_status == 0) {
329 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
331 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
334 } else if (enqueue_status < 0) {
335 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
340 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
341 n = rte_cryptodev_raw_dequeue_burst(ctx,
342 NULL, 1, post_process_raw_dp_op,
343 (void **)&ret_op, 0, &n_success,
345 if (dequeue_status < 0) {
346 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
353 if (n == 1 && dequeue_status == 0) {
354 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
355 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
360 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
361 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
362 RTE_CRYPTO_OP_STATUS_SUCCESS;
369 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
372 struct rte_crypto_sym_op *sop;
373 union rte_crypto_sym_ofs ofs;
374 struct rte_crypto_sgl sgl;
375 struct rte_crypto_sym_vec symvec;
376 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
377 struct rte_crypto_vec vec[UINT8_MAX];
381 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
382 sop->aead.data.length, vec, RTE_DIM(vec));
384 if (n < 0 || n != sop->m_src->nb_segs) {
385 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
393 symvec.digest = &digest_ptr;
394 symvec.aad = &aad_ptr;
398 /* for CPU crypto the IOVA address is not required */
399 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
400 digest_ptr.va = (void *)sop->aead.digest.data;
401 aad_ptr.va = (void *)sop->aead.aad.data;
405 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
409 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
411 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
415 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
418 struct rte_crypto_sym_op *sop;
419 union rte_crypto_sym_ofs ofs;
420 struct rte_crypto_sgl sgl;
421 struct rte_crypto_sym_vec symvec;
422 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
423 struct rte_crypto_vec vec[UINT8_MAX];
427 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
428 sop->auth.data.length, vec, RTE_DIM(vec));
430 if (n < 0 || n != sop->m_src->nb_segs) {
431 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
439 symvec.digest = &digest_ptr;
443 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
444 digest_ptr.va = (void *)sop->auth.digest.data;
447 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
448 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
449 (sop->cipher.data.offset + sop->cipher.data.length);
451 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
455 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
457 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
460 static struct rte_crypto_op *
461 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
464 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
466 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
467 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
473 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
476 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
477 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
484 static struct crypto_testsuite_params testsuite_params = { NULL };
485 static struct crypto_unittest_params unittest_params;
488 testsuite_setup(void)
490 struct crypto_testsuite_params *ts_params = &testsuite_params;
491 struct rte_cryptodev_info info;
492 uint32_t i = 0, nb_devs, dev_id;
496 memset(ts_params, 0, sizeof(*ts_params));
498 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
499 if (ts_params->mbuf_pool == NULL) {
500 /* Not already created so create */
501 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
503 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
505 if (ts_params->mbuf_pool == NULL) {
506 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
511 ts_params->large_mbuf_pool = rte_mempool_lookup(
512 "CRYPTO_LARGE_MBUFPOOL");
513 if (ts_params->large_mbuf_pool == NULL) {
514 /* Not already created so create */
515 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
516 "CRYPTO_LARGE_MBUFPOOL",
519 if (ts_params->large_mbuf_pool == NULL) {
521 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
526 ts_params->op_mpool = rte_crypto_op_pool_create(
527 "MBUF_CRYPTO_SYM_OP_POOL",
528 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
529 NUM_MBUFS, MBUF_CACHE_SIZE,
531 sizeof(struct rte_crypto_sym_xform) +
534 if (ts_params->op_mpool == NULL) {
535 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
539 /* Create an AESNI MB device if required */
540 if (gbl_driver_id == rte_cryptodev_driver_id_get(
541 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
542 nb_devs = rte_cryptodev_device_count_by_driver(
543 rte_cryptodev_driver_id_get(
544 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
547 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
549 TEST_ASSERT(ret == 0,
550 "Failed to create instance of"
552 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
556 /* Create an AESNI GCM device if required */
557 if (gbl_driver_id == rte_cryptodev_driver_id_get(
558 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
559 nb_devs = rte_cryptodev_device_count_by_driver(
560 rte_cryptodev_driver_id_get(
561 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
563 TEST_ASSERT_SUCCESS(rte_vdev_init(
564 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
565 "Failed to create instance of"
567 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
571 /* Create a SNOW 3G device if required */
572 if (gbl_driver_id == rte_cryptodev_driver_id_get(
573 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
574 nb_devs = rte_cryptodev_device_count_by_driver(
575 rte_cryptodev_driver_id_get(
576 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
578 TEST_ASSERT_SUCCESS(rte_vdev_init(
579 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
580 "Failed to create instance of"
582 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
586 /* Create a KASUMI device if required */
587 if (gbl_driver_id == rte_cryptodev_driver_id_get(
588 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
589 nb_devs = rte_cryptodev_device_count_by_driver(
590 rte_cryptodev_driver_id_get(
591 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
593 TEST_ASSERT_SUCCESS(rte_vdev_init(
594 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
595 "Failed to create instance of"
597 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
601 /* Create a ZUC device if required */
602 if (gbl_driver_id == rte_cryptodev_driver_id_get(
603 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
604 nb_devs = rte_cryptodev_device_count_by_driver(
605 rte_cryptodev_driver_id_get(
606 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
608 TEST_ASSERT_SUCCESS(rte_vdev_init(
609 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
610 "Failed to create instance of"
612 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
616 /* Create a NULL device if required */
617 if (gbl_driver_id == rte_cryptodev_driver_id_get(
618 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
619 nb_devs = rte_cryptodev_device_count_by_driver(
620 rte_cryptodev_driver_id_get(
621 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
624 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
626 TEST_ASSERT(ret == 0,
627 "Failed to create instance of"
629 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
633 /* Create an OPENSSL device if required */
634 if (gbl_driver_id == rte_cryptodev_driver_id_get(
635 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
636 nb_devs = rte_cryptodev_device_count_by_driver(
637 rte_cryptodev_driver_id_get(
638 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
641 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
644 TEST_ASSERT(ret == 0, "Failed to create "
645 "instance of pmd : %s",
646 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
650 /* Create a ARMv8 device if required */
651 if (gbl_driver_id == rte_cryptodev_driver_id_get(
652 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
653 nb_devs = rte_cryptodev_device_count_by_driver(
654 rte_cryptodev_driver_id_get(
655 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
658 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
661 TEST_ASSERT(ret == 0, "Failed to create "
662 "instance of pmd : %s",
663 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
667 /* Create a MVSAM device if required */
668 if (gbl_driver_id == rte_cryptodev_driver_id_get(
669 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
670 nb_devs = rte_cryptodev_device_count_by_driver(
671 rte_cryptodev_driver_id_get(
672 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
675 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
678 TEST_ASSERT(ret == 0, "Failed to create "
679 "instance of pmd : %s",
680 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
684 /* Create an CCP device if required */
685 if (gbl_driver_id == rte_cryptodev_driver_id_get(
686 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
687 nb_devs = rte_cryptodev_device_count_by_driver(
688 rte_cryptodev_driver_id_get(
689 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
692 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
695 TEST_ASSERT(ret == 0, "Failed to create "
696 "instance of pmd : %s",
697 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
701 #ifdef RTE_CRYPTO_SCHEDULER
702 char vdev_args[VDEV_ARGS_SIZE] = {""};
703 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
704 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
705 uint16_t worker_core_count = 0;
706 uint16_t socket_id = 0;
708 if (gbl_driver_id == rte_cryptodev_driver_id_get(
709 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
711 /* Identify the Worker Cores
712 * Use 2 worker cores for the device args
714 RTE_LCORE_FOREACH_WORKER(i) {
715 if (worker_core_count > 1)
717 snprintf(vdev_args, sizeof(vdev_args),
718 "%s%d", temp_str, i);
719 strcpy(temp_str, vdev_args);
720 strlcat(temp_str, ";", sizeof(temp_str));
722 socket_id = rte_lcore_to_socket_id(i);
724 if (worker_core_count != 2) {
726 "Cryptodev scheduler test require at least "
727 "two worker cores to run. "
728 "Please use the correct coremask.\n");
731 strcpy(temp_str, vdev_args);
732 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
733 temp_str, socket_id);
734 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
735 nb_devs = rte_cryptodev_device_count_by_driver(
736 rte_cryptodev_driver_id_get(
737 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
740 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
742 TEST_ASSERT(ret == 0,
743 "Failed to create instance %u of"
745 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
748 #endif /* RTE_CRYPTO_SCHEDULER */
750 nb_devs = rte_cryptodev_count();
752 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
756 /* Create list of valid crypto devs */
757 for (i = 0; i < nb_devs; i++) {
758 rte_cryptodev_info_get(i, &info);
759 if (info.driver_id == gbl_driver_id)
760 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
763 if (ts_params->valid_dev_count < 1)
766 /* Set up all the qps on the first of the valid devices found */
768 dev_id = ts_params->valid_devs[0];
770 rte_cryptodev_info_get(dev_id, &info);
772 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
773 ts_params->conf.socket_id = SOCKET_ID_ANY;
774 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
776 unsigned int session_size =
777 rte_cryptodev_sym_get_private_session_size(dev_id);
779 #ifdef RTE_LIB_SECURITY
780 unsigned int security_session_size = rte_security_session_get_size(
781 rte_cryptodev_get_sec_ctx(dev_id));
783 if (session_size < security_session_size)
784 session_size = security_session_size;
787 * Create mempool with maximum number of sessions.
789 if (info.sym.max_nb_sessions != 0 &&
790 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
791 RTE_LOG(ERR, USER1, "Device does not support "
792 "at least %u sessions\n",
797 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
798 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
800 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
801 "session mempool allocation failed");
803 ts_params->session_priv_mpool = rte_mempool_create(
807 0, 0, NULL, NULL, NULL,
810 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
811 "session mempool allocation failed");
815 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
817 "Failed to configure cryptodev %u with %u qps",
818 dev_id, ts_params->conf.nb_queue_pairs);
820 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
821 ts_params->qp_conf.mp_session = ts_params->session_mpool;
822 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
824 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
825 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
826 dev_id, qp_id, &ts_params->qp_conf,
827 rte_cryptodev_socket_id(dev_id)),
828 "Failed to setup queue pair %u on cryptodev %u",
836 testsuite_teardown(void)
838 struct crypto_testsuite_params *ts_params = &testsuite_params;
841 if (ts_params->mbuf_pool != NULL) {
842 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
843 rte_mempool_avail_count(ts_params->mbuf_pool));
846 if (ts_params->op_mpool != NULL) {
847 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
848 rte_mempool_avail_count(ts_params->op_mpool));
851 /* Free session mempools */
852 if (ts_params->session_priv_mpool != NULL) {
853 rte_mempool_free(ts_params->session_priv_mpool);
854 ts_params->session_priv_mpool = NULL;
857 if (ts_params->session_mpool != NULL) {
858 rte_mempool_free(ts_params->session_mpool);
859 ts_params->session_mpool = NULL;
862 res = rte_cryptodev_close(ts_params->valid_devs[0]);
864 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
868 dev_configure_and_start(uint64_t ff_disable)
870 struct crypto_testsuite_params *ts_params = &testsuite_params;
871 struct crypto_unittest_params *ut_params = &unittest_params;
875 /* Clear unit test parameters before running test */
876 memset(ut_params, 0, sizeof(*ut_params));
878 /* Reconfigure device to default parameters */
879 ts_params->conf.socket_id = SOCKET_ID_ANY;
880 ts_params->conf.ff_disable = ff_disable;
881 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
882 ts_params->qp_conf.mp_session = ts_params->session_mpool;
883 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
885 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
887 "Failed to configure cryptodev %u",
888 ts_params->valid_devs[0]);
890 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
891 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
892 ts_params->valid_devs[0], qp_id,
894 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
895 "Failed to setup queue pair %u on cryptodev %u",
896 qp_id, ts_params->valid_devs[0]);
900 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
902 /* Start the device */
903 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
904 "Failed to start cryptodev %u",
905 ts_params->valid_devs[0]);
913 /* Configure and start the device with security feature disabled */
914 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
918 ut_setup_security(void)
920 /* Configure and start the device with no features disabled */
921 return dev_configure_and_start(0);
927 struct crypto_testsuite_params *ts_params = &testsuite_params;
928 struct crypto_unittest_params *ut_params = &unittest_params;
929 struct rte_cryptodev_stats stats;
931 /* free crypto session structure */
932 #ifdef RTE_LIB_SECURITY
933 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
934 if (ut_params->sec_session) {
935 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
936 (ts_params->valid_devs[0]),
937 ut_params->sec_session);
938 ut_params->sec_session = NULL;
943 if (ut_params->sess) {
944 rte_cryptodev_sym_session_clear(
945 ts_params->valid_devs[0],
947 rte_cryptodev_sym_session_free(ut_params->sess);
948 ut_params->sess = NULL;
952 /* free crypto operation structure */
954 rte_crypto_op_free(ut_params->op);
957 * free mbuf - both obuf and ibuf are usually the same,
958 * so check if they point at the same address is necessary,
959 * to avoid freeing the mbuf twice.
961 if (ut_params->obuf) {
962 rte_pktmbuf_free(ut_params->obuf);
963 if (ut_params->ibuf == ut_params->obuf)
967 if (ut_params->ibuf) {
968 rte_pktmbuf_free(ut_params->ibuf);
972 if (ts_params->mbuf_pool != NULL)
973 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
974 rte_mempool_avail_count(ts_params->mbuf_pool));
976 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
978 /* Stop the device */
979 rte_cryptodev_stop(ts_params->valid_devs[0]);
983 test_device_configure_invalid_dev_id(void)
985 struct crypto_testsuite_params *ts_params = &testsuite_params;
986 uint16_t dev_id, num_devs = 0;
988 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
989 "Need at least %d devices for test", 1);
991 /* valid dev_id values */
992 dev_id = ts_params->valid_devs[0];
994 /* Stop the device in case it's started so it can be configured */
995 rte_cryptodev_stop(dev_id);
997 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
998 "Failed test for rte_cryptodev_configure: "
999 "invalid dev_num %u", dev_id);
1001 /* invalid dev_id values */
1004 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1005 "Failed test for rte_cryptodev_configure: "
1006 "invalid dev_num %u", dev_id);
1010 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1011 "Failed test for rte_cryptodev_configure:"
1012 "invalid dev_num %u", dev_id);
1014 return TEST_SUCCESS;
1018 test_device_configure_invalid_queue_pair_ids(void)
1020 struct crypto_testsuite_params *ts_params = &testsuite_params;
1021 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1023 /* Stop the device in case it's started so it can be configured */
1024 rte_cryptodev_stop(ts_params->valid_devs[0]);
1026 /* valid - max value queue pairs */
1027 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1029 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1031 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1032 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1034 /* valid - one queue pairs */
1035 ts_params->conf.nb_queue_pairs = 1;
1037 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1039 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1040 ts_params->valid_devs[0],
1041 ts_params->conf.nb_queue_pairs);
1044 /* invalid - zero queue pairs */
1045 ts_params->conf.nb_queue_pairs = 0;
1047 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1049 "Failed test for rte_cryptodev_configure, dev_id %u,"
1051 ts_params->valid_devs[0],
1052 ts_params->conf.nb_queue_pairs);
1055 /* invalid - max value supported by field queue pairs */
1056 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1058 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1060 "Failed test for rte_cryptodev_configure, dev_id %u,"
1062 ts_params->valid_devs[0],
1063 ts_params->conf.nb_queue_pairs);
1066 /* invalid - max value + 1 queue pairs */
1067 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1069 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1071 "Failed test for rte_cryptodev_configure, dev_id %u,"
1073 ts_params->valid_devs[0],
1074 ts_params->conf.nb_queue_pairs);
1076 /* revert to original testsuite value */
1077 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1079 return TEST_SUCCESS;
1083 test_queue_pair_descriptor_setup(void)
1085 struct crypto_testsuite_params *ts_params = &testsuite_params;
1086 struct rte_cryptodev_qp_conf qp_conf = {
1087 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1091 /* Stop the device in case it's started so it can be configured */
1092 rte_cryptodev_stop(ts_params->valid_devs[0]);
1094 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1096 "Failed to configure cryptodev %u",
1097 ts_params->valid_devs[0]);
1100 * Test various ring sizes on this device. memzones can't be
1101 * freed so are re-used if ring is released and re-created.
1103 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1104 qp_conf.mp_session = ts_params->session_mpool;
1105 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1107 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1108 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1109 ts_params->valid_devs[0], qp_id, &qp_conf,
1110 rte_cryptodev_socket_id(
1111 ts_params->valid_devs[0])),
1113 "rte_cryptodev_queue_pair_setup: num_inflights "
1114 "%u on qp %u on cryptodev %u",
1115 qp_conf.nb_descriptors, qp_id,
1116 ts_params->valid_devs[0]);
1119 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1121 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1122 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1123 ts_params->valid_devs[0], qp_id, &qp_conf,
1124 rte_cryptodev_socket_id(
1125 ts_params->valid_devs[0])),
1127 " rte_cryptodev_queue_pair_setup: num_inflights"
1128 " %u on qp %u on cryptodev %u",
1129 qp_conf.nb_descriptors, qp_id,
1130 ts_params->valid_devs[0]);
1133 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1135 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1136 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1137 ts_params->valid_devs[0], qp_id, &qp_conf,
1138 rte_cryptodev_socket_id(
1139 ts_params->valid_devs[0])),
1141 "rte_cryptodev_queue_pair_setup: num_inflights"
1142 " %u on qp %u on cryptodev %u",
1143 qp_conf.nb_descriptors, qp_id,
1144 ts_params->valid_devs[0]);
1147 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1149 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1150 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1151 ts_params->valid_devs[0], qp_id, &qp_conf,
1152 rte_cryptodev_socket_id(
1153 ts_params->valid_devs[0])),
1155 " rte_cryptodev_queue_pair_setup:"
1156 "num_inflights %u on qp %u on cryptodev %u",
1157 qp_conf.nb_descriptors, qp_id,
1158 ts_params->valid_devs[0]);
1161 /* test invalid queue pair id */
1162 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1164 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1166 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1167 ts_params->valid_devs[0],
1169 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1170 "Failed test for rte_cryptodev_queue_pair_setup:"
1171 "invalid qp %u on cryptodev %u",
1172 qp_id, ts_params->valid_devs[0]);
1174 qp_id = 0xffff; /*invalid*/
1176 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1177 ts_params->valid_devs[0],
1179 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1180 "Failed test for rte_cryptodev_queue_pair_setup:"
1181 "invalid qp %u on cryptodev %u",
1182 qp_id, ts_params->valid_devs[0]);
1184 return TEST_SUCCESS;
1187 /* ***** Plaintext data for tests ***** */
1189 const char catch_22_quote_1[] =
1190 "There was only one catch and that was Catch-22, which "
1191 "specified that a concern for one's safety in the face of "
1192 "dangers that were real and immediate was the process of a "
1193 "rational mind. Orr was crazy and could be grounded. All he "
1194 "had to do was ask; and as soon as he did, he would no longer "
1195 "be crazy and would have to fly more missions. Orr would be "
1196 "crazy to fly more missions and sane if he didn't, but if he "
1197 "was sane he had to fly them. If he flew them he was crazy "
1198 "and didn't have to; but if he didn't want to he was sane and "
1199 "had to. Yossarian was moved very deeply by the absolute "
1200 "simplicity of this clause of Catch-22 and let out a "
1201 "respectful whistle. \"That's some catch, that Catch-22\", he "
1202 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1204 const char catch_22_quote[] =
1205 "What a lousy earth! He wondered how many people were "
1206 "destitute that same night even in his own prosperous country, "
1207 "how many homes were shanties, how many husbands were drunk "
1208 "and wives socked, and how many children were bullied, abused, "
1209 "or abandoned. How many families hungered for food they could "
1210 "not afford to buy? How many hearts were broken? How many "
1211 "suicides would take place that same night, how many people "
1212 "would go insane? How many cockroaches and landlords would "
1213 "triumph? How many winners were losers, successes failures, "
1214 "and rich men poor men? How many wise guys were stupid? How "
1215 "many happy endings were unhappy endings? How many honest men "
1216 "were liars, brave men cowards, loyal men traitors, how many "
1217 "sainted men were corrupt, how many people in positions of "
1218 "trust had sold their souls to bodyguards, how many had never "
1219 "had souls? How many straight-and-narrow paths were crooked "
1220 "paths? How many best families were worst families and how "
1221 "many good people were bad people? When you added them all up "
1222 "and then subtracted, you might be left with only the children, "
1223 "and perhaps with Albert Einstein and an old violinist or "
1224 "sculptor somewhere.";
1226 #define QUOTE_480_BYTES (480)
1227 #define QUOTE_512_BYTES (512)
1228 #define QUOTE_768_BYTES (768)
1229 #define QUOTE_1024_BYTES (1024)
1233 /* ***** SHA1 Hash Tests ***** */
1235 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1237 static uint8_t hmac_sha1_key[] = {
1238 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1239 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1240 0xDE, 0xF4, 0xDE, 0xAD };
1242 /* ***** SHA224 Hash Tests ***** */
1244 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1247 /* ***** AES-CBC Cipher Tests ***** */
1249 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1250 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1252 static uint8_t aes_cbc_key[] = {
1253 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1254 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1256 static uint8_t aes_cbc_iv[] = {
1257 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1258 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1261 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1263 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1264 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1265 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1266 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1267 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1268 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1269 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1270 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1271 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1272 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1273 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1274 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1275 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1276 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1277 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1278 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1279 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1280 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1281 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1282 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1283 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1284 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1285 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1286 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1287 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1288 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1289 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1290 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1291 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1292 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1293 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1294 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1295 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1296 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1297 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1298 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1299 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1300 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1301 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1302 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1303 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1304 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1305 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1306 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1307 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1308 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1309 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1310 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1311 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1312 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1313 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1314 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1315 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1316 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1317 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1318 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1319 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1320 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1321 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1322 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1323 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1324 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1325 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1326 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1327 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1330 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1331 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1332 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1333 0x18, 0x8c, 0x1d, 0x32
1337 /* Multisession Vector context Test */
1338 /*Begin Session 0 */
1339 static uint8_t ms_aes_cbc_key0[] = {
1340 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1341 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1344 static uint8_t ms_aes_cbc_iv0[] = {
1345 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1346 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1349 static const uint8_t ms_aes_cbc_cipher0[] = {
1350 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1351 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1352 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1353 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1354 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1355 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1356 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1357 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1358 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1359 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1360 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1361 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1362 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1363 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1364 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1365 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1366 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1367 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1368 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1369 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1370 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1371 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1372 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1373 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1374 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1375 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1376 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1377 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1378 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1379 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1380 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1381 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1382 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1383 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1384 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1385 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1386 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1387 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1388 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1389 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1390 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1391 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1392 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1393 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1394 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1395 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1396 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1397 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1398 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1399 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1400 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1401 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1402 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1403 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1404 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1405 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1406 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1407 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1408 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1409 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1410 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1411 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1412 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1413 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1417 static uint8_t ms_hmac_key0[] = {
1418 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1419 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1420 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1421 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1422 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1423 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1424 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1425 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1428 static const uint8_t ms_hmac_digest0[] = {
1429 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1430 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1431 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1432 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1433 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1434 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1435 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1436 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1440 /* Begin session 1 */
1442 static uint8_t ms_aes_cbc_key1[] = {
1443 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1444 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1447 static uint8_t ms_aes_cbc_iv1[] = {
1448 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1449 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1452 static const uint8_t ms_aes_cbc_cipher1[] = {
1453 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1454 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1455 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1456 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1457 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1458 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1459 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1460 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1461 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1462 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1463 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1464 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1465 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1466 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1467 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1468 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1469 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1470 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1471 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1472 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1473 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1474 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1475 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1476 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1477 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1478 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1479 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1480 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1481 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1482 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1483 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1484 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1485 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1486 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1487 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1488 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1489 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1490 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1491 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1492 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1493 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1494 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1495 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1496 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1497 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1498 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1499 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1500 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1501 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1502 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1503 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1504 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1505 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1506 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1507 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1508 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1509 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1510 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1511 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1512 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1513 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1514 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1515 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1516 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1520 static uint8_t ms_hmac_key1[] = {
1521 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1522 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1523 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1524 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1525 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1526 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1527 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1528 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1531 static const uint8_t ms_hmac_digest1[] = {
1532 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1533 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1534 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1535 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1536 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1537 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1538 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1539 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1542 /* Begin Session 2 */
1543 static uint8_t ms_aes_cbc_key2[] = {
1544 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1545 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1548 static uint8_t ms_aes_cbc_iv2[] = {
1549 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1550 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1553 static const uint8_t ms_aes_cbc_cipher2[] = {
1554 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1555 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1556 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1557 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1558 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1559 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1560 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1561 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1562 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1563 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1564 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1565 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1566 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1567 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1568 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1569 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1570 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1571 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1572 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1573 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1574 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1575 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1576 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1577 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1578 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1579 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1580 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1581 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1582 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1583 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1584 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1585 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1586 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1587 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1588 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1589 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1590 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1591 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1592 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1593 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1594 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1595 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1596 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1597 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1598 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1599 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1600 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1601 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1602 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1603 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1604 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1605 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1606 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1607 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1608 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1609 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1610 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1611 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1612 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1613 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1614 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1615 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1616 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1617 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1620 static uint8_t ms_hmac_key2[] = {
1621 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1622 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1623 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1624 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1625 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1626 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1627 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1628 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1631 static const uint8_t ms_hmac_digest2[] = {
1632 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1633 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1634 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1635 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1636 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1637 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1638 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1639 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1646 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1648 struct crypto_testsuite_params *ts_params = &testsuite_params;
1649 struct crypto_unittest_params *ut_params = &unittest_params;
1651 /* Verify the capabilities */
1652 struct rte_cryptodev_sym_capability_idx cap_idx;
1653 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1654 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1655 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1658 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1659 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1660 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1664 /* Generate test mbuf data and space for digest */
1665 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1666 catch_22_quote, QUOTE_512_BYTES, 0);
1668 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1669 DIGEST_BYTE_LENGTH_SHA1);
1670 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1672 /* Setup Cipher Parameters */
1673 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1674 ut_params->cipher_xform.next = &ut_params->auth_xform;
1676 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1677 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1678 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1679 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1680 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1681 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1683 /* Setup HMAC Parameters */
1684 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1686 ut_params->auth_xform.next = NULL;
1688 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1689 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1690 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1691 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1692 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1694 ut_params->sess = rte_cryptodev_sym_session_create(
1695 ts_params->session_mpool);
1697 /* Create crypto session*/
1698 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1699 ut_params->sess, &ut_params->cipher_xform,
1700 ts_params->session_priv_mpool);
1701 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1703 /* Generate crypto op data structure */
1704 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1705 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1706 TEST_ASSERT_NOT_NULL(ut_params->op,
1707 "Failed to allocate symmetric crypto operation struct");
1709 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1711 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1713 /* set crypto operation source mbuf */
1714 sym_op->m_src = ut_params->ibuf;
1716 /* Set crypto operation authentication parameters */
1717 sym_op->auth.digest.data = ut_params->digest;
1718 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1719 ut_params->ibuf, QUOTE_512_BYTES);
1721 sym_op->auth.data.offset = 0;
1722 sym_op->auth.data.length = QUOTE_512_BYTES;
1724 /* Copy IV at the end of the crypto operation */
1725 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1726 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1728 /* Set crypto operation cipher parameters */
1729 sym_op->cipher.data.offset = 0;
1730 sym_op->cipher.data.length = QUOTE_512_BYTES;
1732 /* Process crypto operation */
1733 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1734 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1737 TEST_ASSERT_NOT_NULL(
1738 process_crypto_request(ts_params->valid_devs[0],
1740 "failed to process sym crypto op");
1742 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1743 "crypto op processing failed");
1746 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1749 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1750 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1752 "ciphertext data not as expected");
1754 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1756 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1757 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1758 gbl_driver_id == rte_cryptodev_driver_id_get(
1759 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1760 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1761 DIGEST_BYTE_LENGTH_SHA1,
1762 "Generated digest data not as expected");
1764 return TEST_SUCCESS;
1767 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1769 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1771 static uint8_t hmac_sha512_key[] = {
1772 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1773 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1774 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1775 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1776 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1777 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1778 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1779 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1781 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1782 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1783 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1784 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1785 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1786 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1787 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1788 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1789 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1794 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1795 struct crypto_unittest_params *ut_params,
1796 uint8_t *cipher_key,
1800 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1801 struct crypto_unittest_params *ut_params,
1802 struct crypto_testsuite_params *ts_params,
1803 const uint8_t *cipher,
1804 const uint8_t *digest,
1809 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1810 struct crypto_unittest_params *ut_params,
1811 uint8_t *cipher_key,
1815 /* Setup Cipher Parameters */
1816 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1817 ut_params->cipher_xform.next = NULL;
1819 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1820 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1821 ut_params->cipher_xform.cipher.key.data = cipher_key;
1822 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1823 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1824 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1826 /* Setup HMAC Parameters */
1827 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1828 ut_params->auth_xform.next = &ut_params->cipher_xform;
1830 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1831 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1832 ut_params->auth_xform.auth.key.data = hmac_key;
1833 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1834 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1836 return TEST_SUCCESS;
1841 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1842 struct crypto_unittest_params *ut_params,
1843 struct crypto_testsuite_params *ts_params,
1844 const uint8_t *cipher,
1845 const uint8_t *digest,
1848 /* Generate test mbuf data and digest */
1849 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1852 QUOTE_512_BYTES, 0);
1854 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1855 DIGEST_BYTE_LENGTH_SHA512);
1856 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1858 rte_memcpy(ut_params->digest,
1860 DIGEST_BYTE_LENGTH_SHA512);
1862 /* Generate Crypto op data structure */
1863 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1864 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1865 TEST_ASSERT_NOT_NULL(ut_params->op,
1866 "Failed to allocate symmetric crypto operation struct");
1868 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1870 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1872 /* set crypto operation source mbuf */
1873 sym_op->m_src = ut_params->ibuf;
1875 sym_op->auth.digest.data = ut_params->digest;
1876 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1877 ut_params->ibuf, QUOTE_512_BYTES);
1879 sym_op->auth.data.offset = 0;
1880 sym_op->auth.data.length = QUOTE_512_BYTES;
1882 /* Copy IV at the end of the crypto operation */
1883 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1884 iv, CIPHER_IV_LENGTH_AES_CBC);
1886 sym_op->cipher.data.offset = 0;
1887 sym_op->cipher.data.length = QUOTE_512_BYTES;
1889 /* Process crypto operation */
1890 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1891 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1893 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1894 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
1895 ut_params->op, 1, 1, 0, 0);
1897 TEST_ASSERT_NOT_NULL(
1898 process_crypto_request(ts_params->valid_devs[0],
1900 "failed to process sym crypto op");
1902 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1903 "crypto op processing failed");
1905 ut_params->obuf = ut_params->op->sym->m_src;
1908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1909 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1912 "Plaintext data not as expected");
1915 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1916 "Digest verification failed");
1918 return TEST_SUCCESS;
1922 test_blockcipher(enum blockcipher_test_type test_type)
1924 struct crypto_testsuite_params *ts_params = &testsuite_params;
1927 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1928 ts_params->op_mpool,
1929 ts_params->session_mpool, ts_params->session_priv_mpool,
1930 ts_params->valid_devs[0],
1933 if (status == -ENOTSUP)
1936 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1938 return TEST_SUCCESS;
1942 test_AES_cipheronly_all(void)
1944 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1948 test_AES_docsis_all(void)
1950 /* Data-path service does not support DOCSIS yet */
1951 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1953 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1957 test_DES_docsis_all(void)
1959 /* Data-path service does not support DOCSIS yet */
1960 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1962 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1966 test_DES_cipheronly_all(void)
1968 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1972 test_authonly_all(void)
1974 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1978 test_AES_chain_all(void)
1980 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1984 test_3DES_chain_all(void)
1986 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1990 test_3DES_cipheronly_all(void)
1992 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1995 /* ***** SNOW 3G Tests ***** */
1997 create_wireless_algo_hash_session(uint8_t dev_id,
1998 const uint8_t *key, const uint8_t key_len,
1999 const uint8_t iv_len, const uint8_t auth_len,
2000 enum rte_crypto_auth_operation op,
2001 enum rte_crypto_auth_algorithm algo)
2003 uint8_t hash_key[key_len];
2006 struct crypto_testsuite_params *ts_params = &testsuite_params;
2007 struct crypto_unittest_params *ut_params = &unittest_params;
2009 memcpy(hash_key, key, key_len);
2011 debug_hexdump(stdout, "key:", key, key_len);
2013 /* Setup Authentication Parameters */
2014 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2015 ut_params->auth_xform.next = NULL;
2017 ut_params->auth_xform.auth.op = op;
2018 ut_params->auth_xform.auth.algo = algo;
2019 ut_params->auth_xform.auth.key.length = key_len;
2020 ut_params->auth_xform.auth.key.data = hash_key;
2021 ut_params->auth_xform.auth.digest_length = auth_len;
2022 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2023 ut_params->auth_xform.auth.iv.length = iv_len;
2024 ut_params->sess = rte_cryptodev_sym_session_create(
2025 ts_params->session_mpool);
2027 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2028 &ut_params->auth_xform,
2029 ts_params->session_priv_mpool);
2030 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2031 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2036 create_wireless_algo_cipher_session(uint8_t dev_id,
2037 enum rte_crypto_cipher_operation op,
2038 enum rte_crypto_cipher_algorithm algo,
2039 const uint8_t *key, const uint8_t key_len,
2042 uint8_t cipher_key[key_len];
2044 struct crypto_testsuite_params *ts_params = &testsuite_params;
2045 struct crypto_unittest_params *ut_params = &unittest_params;
2047 memcpy(cipher_key, key, key_len);
2049 /* Setup Cipher Parameters */
2050 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2051 ut_params->cipher_xform.next = NULL;
2053 ut_params->cipher_xform.cipher.algo = algo;
2054 ut_params->cipher_xform.cipher.op = op;
2055 ut_params->cipher_xform.cipher.key.data = cipher_key;
2056 ut_params->cipher_xform.cipher.key.length = key_len;
2057 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2058 ut_params->cipher_xform.cipher.iv.length = iv_len;
2060 debug_hexdump(stdout, "key:", key, key_len);
2062 /* Create Crypto session */
2063 ut_params->sess = rte_cryptodev_sym_session_create(
2064 ts_params->session_mpool);
2066 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2067 &ut_params->cipher_xform,
2068 ts_params->session_priv_mpool);
2069 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2070 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2075 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2076 unsigned int cipher_len,
2077 unsigned int cipher_offset)
2079 struct crypto_testsuite_params *ts_params = &testsuite_params;
2080 struct crypto_unittest_params *ut_params = &unittest_params;
2082 /* Generate Crypto op data structure */
2083 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2084 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2085 TEST_ASSERT_NOT_NULL(ut_params->op,
2086 "Failed to allocate pktmbuf offload");
2088 /* Set crypto operation data parameters */
2089 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2091 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2093 /* set crypto operation source mbuf */
2094 sym_op->m_src = ut_params->ibuf;
2097 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2099 sym_op->cipher.data.length = cipher_len;
2100 sym_op->cipher.data.offset = cipher_offset;
2105 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2106 unsigned int cipher_len,
2107 unsigned int cipher_offset)
2109 struct crypto_testsuite_params *ts_params = &testsuite_params;
2110 struct crypto_unittest_params *ut_params = &unittest_params;
2112 /* Generate Crypto op data structure */
2113 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2114 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2115 TEST_ASSERT_NOT_NULL(ut_params->op,
2116 "Failed to allocate pktmbuf offload");
2118 /* Set crypto operation data parameters */
2119 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2121 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2123 /* set crypto operation source mbuf */
2124 sym_op->m_src = ut_params->ibuf;
2125 sym_op->m_dst = ut_params->obuf;
2128 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2130 sym_op->cipher.data.length = cipher_len;
2131 sym_op->cipher.data.offset = cipher_offset;
2136 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2137 enum rte_crypto_cipher_operation cipher_op,
2138 enum rte_crypto_auth_operation auth_op,
2139 enum rte_crypto_auth_algorithm auth_algo,
2140 enum rte_crypto_cipher_algorithm cipher_algo,
2141 const uint8_t *key, uint8_t key_len,
2142 uint8_t auth_iv_len, uint8_t auth_len,
2143 uint8_t cipher_iv_len)
2146 uint8_t cipher_auth_key[key_len];
2149 struct crypto_testsuite_params *ts_params = &testsuite_params;
2150 struct crypto_unittest_params *ut_params = &unittest_params;
2152 memcpy(cipher_auth_key, key, key_len);
2154 /* Setup Authentication Parameters */
2155 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2156 ut_params->auth_xform.next = NULL;
2158 ut_params->auth_xform.auth.op = auth_op;
2159 ut_params->auth_xform.auth.algo = auth_algo;
2160 ut_params->auth_xform.auth.key.length = key_len;
2161 /* Hash key = cipher key */
2162 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2163 ut_params->auth_xform.auth.digest_length = auth_len;
2164 /* Auth IV will be after cipher IV */
2165 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2166 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2168 /* Setup Cipher Parameters */
2169 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2170 ut_params->cipher_xform.next = &ut_params->auth_xform;
2172 ut_params->cipher_xform.cipher.algo = cipher_algo;
2173 ut_params->cipher_xform.cipher.op = cipher_op;
2174 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2175 ut_params->cipher_xform.cipher.key.length = key_len;
2176 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2177 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2179 debug_hexdump(stdout, "key:", key, key_len);
2181 /* Create Crypto session*/
2182 ut_params->sess = rte_cryptodev_sym_session_create(
2183 ts_params->session_mpool);
2184 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2186 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2187 &ut_params->cipher_xform,
2188 ts_params->session_priv_mpool);
2189 if (status == -ENOTSUP)
2192 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2197 create_wireless_cipher_auth_session(uint8_t dev_id,
2198 enum rte_crypto_cipher_operation cipher_op,
2199 enum rte_crypto_auth_operation auth_op,
2200 enum rte_crypto_auth_algorithm auth_algo,
2201 enum rte_crypto_cipher_algorithm cipher_algo,
2202 const struct wireless_test_data *tdata)
2204 const uint8_t key_len = tdata->key.len;
2205 uint8_t cipher_auth_key[key_len];
2208 struct crypto_testsuite_params *ts_params = &testsuite_params;
2209 struct crypto_unittest_params *ut_params = &unittest_params;
2210 const uint8_t *key = tdata->key.data;
2211 const uint8_t auth_len = tdata->digest.len;
2212 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2213 uint8_t auth_iv_len = tdata->auth_iv.len;
2215 memcpy(cipher_auth_key, key, key_len);
2217 /* Setup Authentication Parameters */
2218 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2219 ut_params->auth_xform.next = NULL;
2221 ut_params->auth_xform.auth.op = auth_op;
2222 ut_params->auth_xform.auth.algo = auth_algo;
2223 ut_params->auth_xform.auth.key.length = key_len;
2224 /* Hash key = cipher key */
2225 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2226 ut_params->auth_xform.auth.digest_length = auth_len;
2227 /* Auth IV will be after cipher IV */
2228 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2229 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2231 /* Setup Cipher Parameters */
2232 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2233 ut_params->cipher_xform.next = &ut_params->auth_xform;
2235 ut_params->cipher_xform.cipher.algo = cipher_algo;
2236 ut_params->cipher_xform.cipher.op = cipher_op;
2237 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2238 ut_params->cipher_xform.cipher.key.length = key_len;
2239 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2240 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2243 debug_hexdump(stdout, "key:", key, key_len);
2245 /* Create Crypto session*/
2246 ut_params->sess = rte_cryptodev_sym_session_create(
2247 ts_params->session_mpool);
2249 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2250 &ut_params->cipher_xform,
2251 ts_params->session_priv_mpool);
2252 if (status == -ENOTSUP)
2255 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2256 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2261 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2262 const struct wireless_test_data *tdata)
2264 return create_wireless_cipher_auth_session(dev_id,
2265 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2266 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2267 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2271 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2272 enum rte_crypto_cipher_operation cipher_op,
2273 enum rte_crypto_auth_operation auth_op,
2274 enum rte_crypto_auth_algorithm auth_algo,
2275 enum rte_crypto_cipher_algorithm cipher_algo,
2276 const uint8_t *key, const uint8_t key_len,
2277 uint8_t auth_iv_len, uint8_t auth_len,
2278 uint8_t cipher_iv_len)
2280 uint8_t auth_cipher_key[key_len];
2282 struct crypto_testsuite_params *ts_params = &testsuite_params;
2283 struct crypto_unittest_params *ut_params = &unittest_params;
2285 memcpy(auth_cipher_key, key, key_len);
2287 /* Setup Authentication Parameters */
2288 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2289 ut_params->auth_xform.auth.op = auth_op;
2290 ut_params->auth_xform.next = &ut_params->cipher_xform;
2291 ut_params->auth_xform.auth.algo = auth_algo;
2292 ut_params->auth_xform.auth.key.length = key_len;
2293 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2294 ut_params->auth_xform.auth.digest_length = auth_len;
2295 /* Auth IV will be after cipher IV */
2296 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2297 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2299 /* Setup Cipher Parameters */
2300 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2301 ut_params->cipher_xform.next = NULL;
2302 ut_params->cipher_xform.cipher.algo = cipher_algo;
2303 ut_params->cipher_xform.cipher.op = cipher_op;
2304 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2305 ut_params->cipher_xform.cipher.key.length = key_len;
2306 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2307 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2309 debug_hexdump(stdout, "key:", key, key_len);
2311 /* Create Crypto session*/
2312 ut_params->sess = rte_cryptodev_sym_session_create(
2313 ts_params->session_mpool);
2314 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2316 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2317 ut_params->auth_xform.next = NULL;
2318 ut_params->cipher_xform.next = &ut_params->auth_xform;
2319 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2320 &ut_params->cipher_xform,
2321 ts_params->session_priv_mpool);
2324 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2325 &ut_params->auth_xform,
2326 ts_params->session_priv_mpool);
2328 if (status == -ENOTSUP)
2331 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2337 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2338 unsigned int auth_tag_len,
2339 const uint8_t *iv, unsigned int iv_len,
2340 unsigned int data_pad_len,
2341 enum rte_crypto_auth_operation op,
2342 unsigned int auth_len, unsigned int auth_offset)
2344 struct crypto_testsuite_params *ts_params = &testsuite_params;
2346 struct crypto_unittest_params *ut_params = &unittest_params;
2348 /* Generate Crypto op data structure */
2349 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2350 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2351 TEST_ASSERT_NOT_NULL(ut_params->op,
2352 "Failed to allocate pktmbuf offload");
2354 /* Set crypto operation data parameters */
2355 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2357 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2359 /* set crypto operation source mbuf */
2360 sym_op->m_src = ut_params->ibuf;
2363 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2366 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2367 ut_params->ibuf, auth_tag_len);
2369 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2370 "no room to append auth tag");
2371 ut_params->digest = sym_op->auth.digest.data;
2372 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2373 ut_params->ibuf, data_pad_len);
2374 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2375 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2377 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2379 debug_hexdump(stdout, "digest:",
2380 sym_op->auth.digest.data,
2383 sym_op->auth.data.length = auth_len;
2384 sym_op->auth.data.offset = auth_offset;
2390 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2391 enum rte_crypto_auth_operation op)
2393 struct crypto_testsuite_params *ts_params = &testsuite_params;
2394 struct crypto_unittest_params *ut_params = &unittest_params;
2396 const uint8_t *auth_tag = tdata->digest.data;
2397 const unsigned int auth_tag_len = tdata->digest.len;
2398 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2399 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2401 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2402 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2403 const uint8_t *auth_iv = tdata->auth_iv.data;
2404 const uint8_t auth_iv_len = tdata->auth_iv.len;
2405 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2406 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2408 /* Generate Crypto op data structure */
2409 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2410 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2411 TEST_ASSERT_NOT_NULL(ut_params->op,
2412 "Failed to allocate pktmbuf offload");
2413 /* Set crypto operation data parameters */
2414 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2416 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2418 /* set crypto operation source mbuf */
2419 sym_op->m_src = ut_params->ibuf;
2422 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2423 ut_params->ibuf, auth_tag_len);
2425 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2426 "no room to append auth tag");
2427 ut_params->digest = sym_op->auth.digest.data;
2428 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2429 ut_params->ibuf, data_pad_len);
2430 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2431 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2433 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2435 debug_hexdump(stdout, "digest:",
2436 sym_op->auth.digest.data,
2439 /* Copy cipher and auth IVs at the end of the crypto operation */
2440 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2442 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2443 iv_ptr += cipher_iv_len;
2444 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2446 sym_op->cipher.data.length = cipher_len;
2447 sym_op->cipher.data.offset = 0;
2448 sym_op->auth.data.length = auth_len;
2449 sym_op->auth.data.offset = 0;
2455 create_zuc_cipher_hash_generate_operation(
2456 const struct wireless_test_data *tdata)
2458 return create_wireless_cipher_hash_operation(tdata,
2459 RTE_CRYPTO_AUTH_OP_GENERATE);
2463 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2464 const unsigned auth_tag_len,
2465 const uint8_t *auth_iv, uint8_t auth_iv_len,
2466 unsigned data_pad_len,
2467 enum rte_crypto_auth_operation op,
2468 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2469 const unsigned cipher_len, const unsigned cipher_offset,
2470 const unsigned auth_len, const unsigned auth_offset)
2472 struct crypto_testsuite_params *ts_params = &testsuite_params;
2473 struct crypto_unittest_params *ut_params = &unittest_params;
2475 enum rte_crypto_cipher_algorithm cipher_algo =
2476 ut_params->cipher_xform.cipher.algo;
2477 enum rte_crypto_auth_algorithm auth_algo =
2478 ut_params->auth_xform.auth.algo;
2480 /* Generate Crypto op data structure */
2481 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2482 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2483 TEST_ASSERT_NOT_NULL(ut_params->op,
2484 "Failed to allocate pktmbuf offload");
2485 /* Set crypto operation data parameters */
2486 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2488 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2490 /* set crypto operation source mbuf */
2491 sym_op->m_src = ut_params->ibuf;
2494 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2495 ut_params->ibuf, auth_tag_len);
2497 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2498 "no room to append auth tag");
2499 ut_params->digest = sym_op->auth.digest.data;
2501 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2502 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2503 ut_params->ibuf, data_pad_len);
2505 struct rte_mbuf *m = ut_params->ibuf;
2506 unsigned int offset = data_pad_len;
2508 while (offset > m->data_len && m->next != NULL) {
2509 offset -= m->data_len;
2512 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2516 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2517 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2519 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2521 debug_hexdump(stdout, "digest:",
2522 sym_op->auth.digest.data,
2525 /* Copy cipher and auth IVs at the end of the crypto operation */
2526 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2528 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2529 iv_ptr += cipher_iv_len;
2530 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2532 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2533 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2534 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2535 sym_op->cipher.data.length = cipher_len;
2536 sym_op->cipher.data.offset = cipher_offset;
2538 sym_op->cipher.data.length = cipher_len >> 3;
2539 sym_op->cipher.data.offset = cipher_offset >> 3;
2542 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2543 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2544 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2545 sym_op->auth.data.length = auth_len;
2546 sym_op->auth.data.offset = auth_offset;
2548 sym_op->auth.data.length = auth_len >> 3;
2549 sym_op->auth.data.offset = auth_offset >> 3;
2556 create_wireless_algo_auth_cipher_operation(
2557 const uint8_t *auth_tag, unsigned int auth_tag_len,
2558 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2559 const uint8_t *auth_iv, uint8_t auth_iv_len,
2560 unsigned int data_pad_len,
2561 unsigned int cipher_len, unsigned int cipher_offset,
2562 unsigned int auth_len, unsigned int auth_offset,
2563 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2565 struct crypto_testsuite_params *ts_params = &testsuite_params;
2566 struct crypto_unittest_params *ut_params = &unittest_params;
2568 enum rte_crypto_cipher_algorithm cipher_algo =
2569 ut_params->cipher_xform.cipher.algo;
2570 enum rte_crypto_auth_algorithm auth_algo =
2571 ut_params->auth_xform.auth.algo;
2573 /* Generate Crypto op data structure */
2574 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2575 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2576 TEST_ASSERT_NOT_NULL(ut_params->op,
2577 "Failed to allocate pktmbuf offload");
2579 /* Set crypto operation data parameters */
2580 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2582 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2584 /* set crypto operation mbufs */
2585 sym_op->m_src = ut_params->ibuf;
2586 if (op_mode == OUT_OF_PLACE)
2587 sym_op->m_dst = ut_params->obuf;
2591 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2592 (op_mode == IN_PLACE ?
2593 ut_params->ibuf : ut_params->obuf),
2594 uint8_t *, data_pad_len);
2595 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2596 (op_mode == IN_PLACE ?
2597 ut_params->ibuf : ut_params->obuf),
2599 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2601 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2602 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2603 sym_op->m_src : sym_op->m_dst);
2604 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2605 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2606 sgl_buf = sgl_buf->next;
2608 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2609 uint8_t *, remaining_off);
2610 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2612 memset(sym_op->auth.digest.data, 0, remaining_off);
2613 while (sgl_buf->next != NULL) {
2614 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2615 0, rte_pktmbuf_data_len(sgl_buf));
2616 sgl_buf = sgl_buf->next;
2620 /* Copy digest for the verification */
2622 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2624 /* Copy cipher and auth IVs at the end of the crypto operation */
2625 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2626 ut_params->op, uint8_t *, IV_OFFSET);
2628 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2629 iv_ptr += cipher_iv_len;
2630 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2632 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2633 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2634 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2635 sym_op->cipher.data.length = cipher_len;
2636 sym_op->cipher.data.offset = cipher_offset;
2638 sym_op->cipher.data.length = cipher_len >> 3;
2639 sym_op->cipher.data.offset = cipher_offset >> 3;
2642 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2643 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2644 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2645 sym_op->auth.data.length = auth_len;
2646 sym_op->auth.data.offset = auth_offset;
2648 sym_op->auth.data.length = auth_len >> 3;
2649 sym_op->auth.data.offset = auth_offset >> 3;
2656 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2658 struct crypto_testsuite_params *ts_params = &testsuite_params;
2659 struct crypto_unittest_params *ut_params = &unittest_params;
2662 unsigned plaintext_pad_len;
2663 unsigned plaintext_len;
2665 struct rte_cryptodev_info dev_info;
2667 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2668 uint64_t feat_flags = dev_info.feature_flags;
2670 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2671 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2672 printf("Device doesn't support NON-Byte Aligned Data.\n");
2676 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2677 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2678 printf("Device doesn't support RAW data-path APIs.\n");
2682 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2685 /* Verify the capabilities */
2686 struct rte_cryptodev_sym_capability_idx cap_idx;
2687 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2688 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2689 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2693 /* Create SNOW 3G session */
2694 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2695 tdata->key.data, tdata->key.len,
2696 tdata->auth_iv.len, tdata->digest.len,
2697 RTE_CRYPTO_AUTH_OP_GENERATE,
2698 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2702 /* alloc mbuf and set payload */
2703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2705 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2706 rte_pktmbuf_tailroom(ut_params->ibuf));
2708 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2709 /* Append data which is padded to a multiple of */
2710 /* the algorithms block size */
2711 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2712 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2714 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2716 /* Create SNOW 3G operation */
2717 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2718 tdata->auth_iv.data, tdata->auth_iv.len,
2719 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2720 tdata->validAuthLenInBits.len,
2725 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2726 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2727 ut_params->op, 0, 1, 1, 0);
2729 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2731 ut_params->obuf = ut_params->op->sym->m_src;
2732 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2733 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2734 + plaintext_pad_len;
2737 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2740 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2741 "SNOW 3G Generated auth tag not as expected");
2747 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2749 struct crypto_testsuite_params *ts_params = &testsuite_params;
2750 struct crypto_unittest_params *ut_params = &unittest_params;
2753 unsigned plaintext_pad_len;
2754 unsigned plaintext_len;
2756 struct rte_cryptodev_info dev_info;
2758 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2759 uint64_t feat_flags = dev_info.feature_flags;
2761 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2762 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2763 printf("Device doesn't support NON-Byte Aligned Data.\n");
2767 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2768 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2769 printf("Device doesn't support RAW data-path APIs.\n");
2773 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2776 /* Verify the capabilities */
2777 struct rte_cryptodev_sym_capability_idx cap_idx;
2778 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2779 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2780 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2784 /* Create SNOW 3G session */
2785 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2786 tdata->key.data, tdata->key.len,
2787 tdata->auth_iv.len, tdata->digest.len,
2788 RTE_CRYPTO_AUTH_OP_VERIFY,
2789 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2792 /* alloc mbuf and set payload */
2793 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2795 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2796 rte_pktmbuf_tailroom(ut_params->ibuf));
2798 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2799 /* Append data which is padded to a multiple of */
2800 /* the algorithms block size */
2801 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2802 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2804 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2806 /* Create SNOW 3G operation */
2807 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2809 tdata->auth_iv.data, tdata->auth_iv.len,
2811 RTE_CRYPTO_AUTH_OP_VERIFY,
2812 tdata->validAuthLenInBits.len,
2817 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2818 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2819 ut_params->op, 0, 1, 1, 0);
2821 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2824 ut_params->obuf = ut_params->op->sym->m_src;
2825 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2826 + plaintext_pad_len;
2829 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2838 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2840 struct crypto_testsuite_params *ts_params = &testsuite_params;
2841 struct crypto_unittest_params *ut_params = &unittest_params;
2844 unsigned plaintext_pad_len;
2845 unsigned plaintext_len;
2847 struct rte_cryptodev_info dev_info;
2849 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2850 uint64_t feat_flags = dev_info.feature_flags;
2852 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2853 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2854 printf("Device doesn't support RAW data-path APIs.\n");
2858 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2861 /* Verify the capabilities */
2862 struct rte_cryptodev_sym_capability_idx cap_idx;
2863 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2864 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2865 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2869 /* Create KASUMI session */
2870 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2871 tdata->key.data, tdata->key.len,
2872 0, tdata->digest.len,
2873 RTE_CRYPTO_AUTH_OP_GENERATE,
2874 RTE_CRYPTO_AUTH_KASUMI_F9);
2878 /* alloc mbuf and set payload */
2879 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2881 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2882 rte_pktmbuf_tailroom(ut_params->ibuf));
2884 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2885 /* Append data which is padded to a multiple of */
2886 /* the algorithms block size */
2887 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2888 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2890 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2892 /* Create KASUMI operation */
2893 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2895 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2896 tdata->plaintext.len,
2901 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2902 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2904 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2905 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2906 ut_params->op, 0, 1, 1, 0);
2908 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2911 ut_params->obuf = ut_params->op->sym->m_src;
2912 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2913 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2914 + plaintext_pad_len;
2917 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2920 DIGEST_BYTE_LENGTH_KASUMI_F9,
2921 "KASUMI Generated auth tag not as expected");
2927 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2929 struct crypto_testsuite_params *ts_params = &testsuite_params;
2930 struct crypto_unittest_params *ut_params = &unittest_params;
2933 unsigned plaintext_pad_len;
2934 unsigned plaintext_len;
2936 struct rte_cryptodev_info dev_info;
2938 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2939 uint64_t feat_flags = dev_info.feature_flags;
2941 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2942 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2943 printf("Device doesn't support RAW data-path APIs.\n");
2947 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2950 /* Verify the capabilities */
2951 struct rte_cryptodev_sym_capability_idx cap_idx;
2952 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2953 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2954 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2958 /* Create KASUMI session */
2959 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2960 tdata->key.data, tdata->key.len,
2961 0, tdata->digest.len,
2962 RTE_CRYPTO_AUTH_OP_VERIFY,
2963 RTE_CRYPTO_AUTH_KASUMI_F9);
2966 /* alloc mbuf and set payload */
2967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2969 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2970 rte_pktmbuf_tailroom(ut_params->ibuf));
2972 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2973 /* Append data which is padded to a multiple */
2974 /* of the algorithms block size */
2975 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2976 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2978 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2980 /* Create KASUMI operation */
2981 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2985 RTE_CRYPTO_AUTH_OP_VERIFY,
2986 tdata->plaintext.len,
2991 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2992 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2993 ut_params->op, 0, 1, 1, 0);
2995 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2997 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2998 ut_params->obuf = ut_params->op->sym->m_src;
2999 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3000 + plaintext_pad_len;
3003 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3012 test_snow3g_hash_generate_test_case_1(void)
3014 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3018 test_snow3g_hash_generate_test_case_2(void)
3020 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3024 test_snow3g_hash_generate_test_case_3(void)
3026 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3030 test_snow3g_hash_generate_test_case_4(void)
3032 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3036 test_snow3g_hash_generate_test_case_5(void)
3038 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3042 test_snow3g_hash_generate_test_case_6(void)
3044 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3048 test_snow3g_hash_verify_test_case_1(void)
3050 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3055 test_snow3g_hash_verify_test_case_2(void)
3057 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3061 test_snow3g_hash_verify_test_case_3(void)
3063 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3067 test_snow3g_hash_verify_test_case_4(void)
3069 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3073 test_snow3g_hash_verify_test_case_5(void)
3075 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3079 test_snow3g_hash_verify_test_case_6(void)
3081 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3085 test_kasumi_hash_generate_test_case_1(void)
3087 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3091 test_kasumi_hash_generate_test_case_2(void)
3093 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3097 test_kasumi_hash_generate_test_case_3(void)
3099 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3103 test_kasumi_hash_generate_test_case_4(void)
3105 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3109 test_kasumi_hash_generate_test_case_5(void)
3111 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3115 test_kasumi_hash_generate_test_case_6(void)
3117 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3121 test_kasumi_hash_verify_test_case_1(void)
3123 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3127 test_kasumi_hash_verify_test_case_2(void)
3129 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3133 test_kasumi_hash_verify_test_case_3(void)
3135 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3139 test_kasumi_hash_verify_test_case_4(void)
3141 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3145 test_kasumi_hash_verify_test_case_5(void)
3147 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3151 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3153 struct crypto_testsuite_params *ts_params = &testsuite_params;
3154 struct crypto_unittest_params *ut_params = &unittest_params;
3157 uint8_t *plaintext, *ciphertext;
3158 unsigned plaintext_pad_len;
3159 unsigned plaintext_len;
3160 struct rte_cryptodev_info dev_info;
3162 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3163 uint64_t feat_flags = dev_info.feature_flags;
3165 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3166 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3167 printf("Device doesn't support RAW data-path APIs.\n");
3171 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3174 /* Verify the capabilities */
3175 struct rte_cryptodev_sym_capability_idx cap_idx;
3176 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3177 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3178 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3182 /* Create KASUMI session */
3183 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3184 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3185 RTE_CRYPTO_CIPHER_KASUMI_F8,
3186 tdata->key.data, tdata->key.len,
3187 tdata->cipher_iv.len);
3191 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3193 /* Clear mbuf payload */
3194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3195 rte_pktmbuf_tailroom(ut_params->ibuf));
3197 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3198 /* Append data which is padded to a multiple */
3199 /* of the algorithms block size */
3200 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3201 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3203 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3205 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3207 /* Create KASUMI operation */
3208 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3209 tdata->cipher_iv.len,
3210 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3211 tdata->validCipherOffsetInBits.len);
3215 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3216 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3217 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3219 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3221 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3223 ut_params->obuf = ut_params->op->sym->m_dst;
3224 if (ut_params->obuf)
3225 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3227 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3229 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3231 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3232 (tdata->validCipherOffsetInBits.len >> 3);
3234 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3236 reference_ciphertext,
3237 tdata->validCipherLenInBits.len,
3238 "KASUMI Ciphertext data not as expected");
3243 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3245 struct crypto_testsuite_params *ts_params = &testsuite_params;
3246 struct crypto_unittest_params *ut_params = &unittest_params;
3250 unsigned int plaintext_pad_len;
3251 unsigned int plaintext_len;
3253 uint8_t buffer[10000];
3254 const uint8_t *ciphertext;
3256 struct rte_cryptodev_info dev_info;
3258 /* Verify the capabilities */
3259 struct rte_cryptodev_sym_capability_idx cap_idx;
3260 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3261 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3262 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3266 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3268 uint64_t feat_flags = dev_info.feature_flags;
3270 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3271 printf("Device doesn't support in-place scatter-gather. "
3276 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3277 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3278 printf("Device doesn't support RAW data-path APIs.\n");
3282 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3285 /* Create KASUMI session */
3286 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3287 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3288 RTE_CRYPTO_CIPHER_KASUMI_F8,
3289 tdata->key.data, tdata->key.len,
3290 tdata->cipher_iv.len);
3294 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3297 /* Append data which is padded to a multiple */
3298 /* of the algorithms block size */
3299 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3301 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3302 plaintext_pad_len, 10, 0);
3304 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3306 /* Create KASUMI operation */
3307 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3308 tdata->cipher_iv.len,
3309 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3310 tdata->validCipherOffsetInBits.len);
3314 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3315 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3316 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3318 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3320 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3322 ut_params->obuf = ut_params->op->sym->m_dst;
3324 if (ut_params->obuf)
3325 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3326 plaintext_len, buffer);
3328 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3329 tdata->validCipherOffsetInBits.len >> 3,
3330 plaintext_len, buffer);
3333 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3335 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3336 (tdata->validCipherOffsetInBits.len >> 3);
3338 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3340 reference_ciphertext,
3341 tdata->validCipherLenInBits.len,
3342 "KASUMI Ciphertext data not as expected");
3347 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3349 struct crypto_testsuite_params *ts_params = &testsuite_params;
3350 struct crypto_unittest_params *ut_params = &unittest_params;
3353 uint8_t *plaintext, *ciphertext;
3354 unsigned plaintext_pad_len;
3355 unsigned plaintext_len;
3357 /* Verify the capabilities */
3358 struct rte_cryptodev_sym_capability_idx cap_idx;
3359 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3360 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3361 /* Data-path service does not support OOP */
3362 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3366 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3369 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3372 /* Create KASUMI session */
3373 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3374 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3375 RTE_CRYPTO_CIPHER_KASUMI_F8,
3376 tdata->key.data, tdata->key.len,
3377 tdata->cipher_iv.len);
3381 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3382 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3384 /* Clear mbuf payload */
3385 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3386 rte_pktmbuf_tailroom(ut_params->ibuf));
3388 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3389 /* Append data which is padded to a multiple */
3390 /* of the algorithms block size */
3391 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3392 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3394 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3395 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3397 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3399 /* Create KASUMI operation */
3400 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3401 tdata->cipher_iv.len,
3402 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3403 tdata->validCipherOffsetInBits.len);
3407 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3409 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3411 ut_params->obuf = ut_params->op->sym->m_dst;
3412 if (ut_params->obuf)
3413 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3415 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3417 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3419 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3420 (tdata->validCipherOffsetInBits.len >> 3);
3422 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3424 reference_ciphertext,
3425 tdata->validCipherLenInBits.len,
3426 "KASUMI Ciphertext data not as expected");
3431 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3433 struct crypto_testsuite_params *ts_params = &testsuite_params;
3434 struct crypto_unittest_params *ut_params = &unittest_params;
3437 unsigned int plaintext_pad_len;
3438 unsigned int plaintext_len;
3440 const uint8_t *ciphertext;
3441 uint8_t buffer[2048];
3443 struct rte_cryptodev_info dev_info;
3445 /* Verify the capabilities */
3446 struct rte_cryptodev_sym_capability_idx cap_idx;
3447 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3448 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3449 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3453 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3456 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3459 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3461 uint64_t feat_flags = dev_info.feature_flags;
3462 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3463 printf("Device doesn't support out-of-place scatter-gather "
3464 "in both input and output mbufs. "
3469 /* Create KASUMI session */
3470 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3471 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3472 RTE_CRYPTO_CIPHER_KASUMI_F8,
3473 tdata->key.data, tdata->key.len,
3474 tdata->cipher_iv.len);
3478 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3479 /* Append data which is padded to a multiple */
3480 /* of the algorithms block size */
3481 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3483 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3484 plaintext_pad_len, 10, 0);
3485 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3486 plaintext_pad_len, 3, 0);
3488 /* Append data which is padded to a multiple */
3489 /* of the algorithms block size */
3490 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3492 /* Create KASUMI operation */
3493 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3494 tdata->cipher_iv.len,
3495 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3496 tdata->validCipherOffsetInBits.len);
3500 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3502 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3504 ut_params->obuf = ut_params->op->sym->m_dst;
3505 if (ut_params->obuf)
3506 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3507 plaintext_pad_len, buffer);
3509 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3510 tdata->validCipherOffsetInBits.len >> 3,
3511 plaintext_pad_len, buffer);
3513 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3514 (tdata->validCipherOffsetInBits.len >> 3);
3516 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3518 reference_ciphertext,
3519 tdata->validCipherLenInBits.len,
3520 "KASUMI Ciphertext data not as expected");
3526 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3528 struct crypto_testsuite_params *ts_params = &testsuite_params;
3529 struct crypto_unittest_params *ut_params = &unittest_params;
3532 uint8_t *ciphertext, *plaintext;
3533 unsigned ciphertext_pad_len;
3534 unsigned ciphertext_len;
3536 /* Verify the capabilities */
3537 struct rte_cryptodev_sym_capability_idx cap_idx;
3538 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3539 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3540 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3544 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3547 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3550 /* Create KASUMI session */
3551 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3552 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3553 RTE_CRYPTO_CIPHER_KASUMI_F8,
3554 tdata->key.data, tdata->key.len,
3555 tdata->cipher_iv.len);
3559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3560 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3562 /* Clear mbuf payload */
3563 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3564 rte_pktmbuf_tailroom(ut_params->ibuf));
3566 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3567 /* Append data which is padded to a multiple */
3568 /* of the algorithms block size */
3569 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3570 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3571 ciphertext_pad_len);
3572 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3573 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3575 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3577 /* Create KASUMI operation */
3578 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3579 tdata->cipher_iv.len,
3580 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3581 tdata->validCipherOffsetInBits.len);
3585 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3587 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3589 ut_params->obuf = ut_params->op->sym->m_dst;
3590 if (ut_params->obuf)
3591 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3593 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3595 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3597 const uint8_t *reference_plaintext = tdata->plaintext.data +
3598 (tdata->validCipherOffsetInBits.len >> 3);
3600 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3602 reference_plaintext,
3603 tdata->validCipherLenInBits.len,
3604 "KASUMI Plaintext data not as expected");
3609 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3611 struct crypto_testsuite_params *ts_params = &testsuite_params;
3612 struct crypto_unittest_params *ut_params = &unittest_params;
3615 uint8_t *ciphertext, *plaintext;
3616 unsigned ciphertext_pad_len;
3617 unsigned ciphertext_len;
3618 struct rte_cryptodev_info dev_info;
3620 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3621 uint64_t feat_flags = dev_info.feature_flags;
3623 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3624 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3625 printf("Device doesn't support RAW data-path APIs.\n");
3629 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3632 /* Verify the capabilities */
3633 struct rte_cryptodev_sym_capability_idx cap_idx;
3634 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3635 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3636 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3640 /* Create KASUMI session */
3641 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3642 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3643 RTE_CRYPTO_CIPHER_KASUMI_F8,
3644 tdata->key.data, tdata->key.len,
3645 tdata->cipher_iv.len);
3649 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3651 /* Clear mbuf payload */
3652 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3653 rte_pktmbuf_tailroom(ut_params->ibuf));
3655 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3656 /* Append data which is padded to a multiple */
3657 /* of the algorithms block size */
3658 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3659 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3660 ciphertext_pad_len);
3661 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3663 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3665 /* Create KASUMI operation */
3666 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3667 tdata->cipher_iv.len,
3668 tdata->ciphertext.len,
3669 tdata->validCipherOffsetInBits.len);
3673 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3674 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3675 ut_params->op, 1, 0, 1, 0);
3677 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3679 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3681 ut_params->obuf = ut_params->op->sym->m_dst;
3682 if (ut_params->obuf)
3683 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3685 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3687 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3689 const uint8_t *reference_plaintext = tdata->plaintext.data +
3690 (tdata->validCipherOffsetInBits.len >> 3);
3692 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3694 reference_plaintext,
3695 tdata->validCipherLenInBits.len,
3696 "KASUMI Plaintext data not as expected");
3701 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3703 struct crypto_testsuite_params *ts_params = &testsuite_params;
3704 struct crypto_unittest_params *ut_params = &unittest_params;
3707 uint8_t *plaintext, *ciphertext;
3708 unsigned plaintext_pad_len;
3709 unsigned plaintext_len;
3710 struct rte_cryptodev_info dev_info;
3712 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3713 uint64_t feat_flags = dev_info.feature_flags;
3715 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3716 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3717 printf("Device doesn't support RAW data-path APIs.\n");
3721 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3724 /* Verify the capabilities */
3725 struct rte_cryptodev_sym_capability_idx cap_idx;
3726 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3727 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3728 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3732 /* Create SNOW 3G session */
3733 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3734 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3735 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3736 tdata->key.data, tdata->key.len,
3737 tdata->cipher_iv.len);
3741 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3743 /* Clear mbuf payload */
3744 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3745 rte_pktmbuf_tailroom(ut_params->ibuf));
3747 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3748 /* Append data which is padded to a multiple of */
3749 /* the algorithms block size */
3750 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3751 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3753 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3755 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3757 /* Create SNOW 3G operation */
3758 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3759 tdata->cipher_iv.len,
3760 tdata->validCipherLenInBits.len,
3765 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3766 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3767 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3769 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3771 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3773 ut_params->obuf = ut_params->op->sym->m_dst;
3774 if (ut_params->obuf)
3775 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3777 ciphertext = plaintext;
3779 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3782 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3784 tdata->ciphertext.data,
3785 tdata->validDataLenInBits.len,
3786 "SNOW 3G Ciphertext data not as expected");
3792 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3794 struct crypto_testsuite_params *ts_params = &testsuite_params;
3795 struct crypto_unittest_params *ut_params = &unittest_params;
3796 uint8_t *plaintext, *ciphertext;
3799 unsigned plaintext_pad_len;
3800 unsigned plaintext_len;
3802 /* Verify the capabilities */
3803 struct rte_cryptodev_sym_capability_idx cap_idx;
3804 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3805 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3806 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3810 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3813 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3816 /* Create SNOW 3G session */
3817 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3818 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3819 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3820 tdata->key.data, tdata->key.len,
3821 tdata->cipher_iv.len);
3825 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3826 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3828 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3829 "Failed to allocate input buffer in mempool");
3830 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3831 "Failed to allocate output buffer in mempool");
3833 /* Clear mbuf payload */
3834 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3835 rte_pktmbuf_tailroom(ut_params->ibuf));
3837 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3838 /* Append data which is padded to a multiple of */
3839 /* the algorithms block size */
3840 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3841 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3843 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3844 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3846 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3848 /* Create SNOW 3G operation */
3849 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3850 tdata->cipher_iv.len,
3851 tdata->validCipherLenInBits.len,
3856 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3858 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3860 ut_params->obuf = ut_params->op->sym->m_dst;
3861 if (ut_params->obuf)
3862 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3864 ciphertext = plaintext;
3866 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3869 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3871 tdata->ciphertext.data,
3872 tdata->validDataLenInBits.len,
3873 "SNOW 3G Ciphertext data not as expected");
3878 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3880 struct crypto_testsuite_params *ts_params = &testsuite_params;
3881 struct crypto_unittest_params *ut_params = &unittest_params;
3884 unsigned int plaintext_pad_len;
3885 unsigned int plaintext_len;
3886 uint8_t buffer[10000];
3887 const uint8_t *ciphertext;
3889 struct rte_cryptodev_info dev_info;
3891 /* Verify the capabilities */
3892 struct rte_cryptodev_sym_capability_idx cap_idx;
3893 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3894 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3895 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3899 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3902 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3905 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3907 uint64_t feat_flags = dev_info.feature_flags;
3909 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3910 printf("Device doesn't support out-of-place scatter-gather "
3911 "in both input and output mbufs. "
3916 /* Create SNOW 3G session */
3917 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3918 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3919 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3920 tdata->key.data, tdata->key.len,
3921 tdata->cipher_iv.len);
3925 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3926 /* Append data which is padded to a multiple of */
3927 /* the algorithms block size */
3928 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3930 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3931 plaintext_pad_len, 10, 0);
3932 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3933 plaintext_pad_len, 3, 0);
3935 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3936 "Failed to allocate input buffer in mempool");
3937 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3938 "Failed to allocate output buffer in mempool");
3940 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3942 /* Create SNOW 3G operation */
3943 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3944 tdata->cipher_iv.len,
3945 tdata->validCipherLenInBits.len,
3950 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3952 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3954 ut_params->obuf = ut_params->op->sym->m_dst;
3955 if (ut_params->obuf)
3956 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3957 plaintext_len, buffer);
3959 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3960 plaintext_len, buffer);
3962 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3965 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3967 tdata->ciphertext.data,
3968 tdata->validDataLenInBits.len,
3969 "SNOW 3G Ciphertext data not as expected");
3974 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3976 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3978 uint8_t curr_byte, prev_byte;
3979 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3980 uint8_t lower_byte_mask = (1 << offset) - 1;
3983 prev_byte = buffer[0];
3984 buffer[0] >>= offset;
3986 for (i = 1; i < length_in_bytes; i++) {
3987 curr_byte = buffer[i];
3988 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3989 (curr_byte >> offset);
3990 prev_byte = curr_byte;
3995 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3997 struct crypto_testsuite_params *ts_params = &testsuite_params;
3998 struct crypto_unittest_params *ut_params = &unittest_params;
3999 uint8_t *plaintext, *ciphertext;
4001 uint32_t plaintext_len;
4002 uint32_t plaintext_pad_len;
4003 uint8_t extra_offset = 4;
4004 uint8_t *expected_ciphertext_shifted;
4005 struct rte_cryptodev_info dev_info;
4007 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4008 uint64_t feat_flags = dev_info.feature_flags;
4010 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4011 ((tdata->validDataLenInBits.len % 8) != 0)) {
4012 printf("Device doesn't support NON-Byte Aligned Data.\n");
4016 /* Verify the capabilities */
4017 struct rte_cryptodev_sym_capability_idx cap_idx;
4018 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4019 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4020 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4024 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4027 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4030 /* Create SNOW 3G session */
4031 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4032 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4033 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4034 tdata->key.data, tdata->key.len,
4035 tdata->cipher_iv.len);
4039 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4040 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4042 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4043 "Failed to allocate input buffer in mempool");
4044 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4045 "Failed to allocate output buffer in mempool");
4047 /* Clear mbuf payload */
4048 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4049 rte_pktmbuf_tailroom(ut_params->ibuf));
4051 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4053 * Append data which is padded to a
4054 * multiple of the algorithms block size
4056 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4058 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4061 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4063 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4064 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4066 #ifdef RTE_APP_TEST_DEBUG
4067 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4069 /* Create SNOW 3G operation */
4070 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4071 tdata->cipher_iv.len,
4072 tdata->validCipherLenInBits.len,
4077 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4079 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4081 ut_params->obuf = ut_params->op->sym->m_dst;
4082 if (ut_params->obuf)
4083 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4085 ciphertext = plaintext;
4087 #ifdef RTE_APP_TEST_DEBUG
4088 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4091 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4093 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4094 "failed to reserve memory for ciphertext shifted\n");
4096 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4097 ceil_byte_length(tdata->ciphertext.len));
4098 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4101 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4103 expected_ciphertext_shifted,
4104 tdata->validDataLenInBits.len,
4106 "SNOW 3G Ciphertext data not as expected");
4110 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4112 struct crypto_testsuite_params *ts_params = &testsuite_params;
4113 struct crypto_unittest_params *ut_params = &unittest_params;
4117 uint8_t *plaintext, *ciphertext;
4118 unsigned ciphertext_pad_len;
4119 unsigned ciphertext_len;
4120 struct rte_cryptodev_info dev_info;
4122 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4123 uint64_t feat_flags = dev_info.feature_flags;
4125 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4126 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4127 printf("Device doesn't support RAW data-path APIs.\n");
4131 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4134 /* Verify the capabilities */
4135 struct rte_cryptodev_sym_capability_idx cap_idx;
4136 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4137 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4138 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4142 /* Create SNOW 3G session */
4143 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4144 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4145 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4146 tdata->key.data, tdata->key.len,
4147 tdata->cipher_iv.len);
4151 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4153 /* Clear mbuf payload */
4154 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4155 rte_pktmbuf_tailroom(ut_params->ibuf));
4157 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4158 /* Append data which is padded to a multiple of */
4159 /* the algorithms block size */
4160 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4161 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4162 ciphertext_pad_len);
4163 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4165 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4167 /* Create SNOW 3G operation */
4168 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4169 tdata->cipher_iv.len,
4170 tdata->validCipherLenInBits.len,
4171 tdata->cipher.offset_bits);
4175 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4176 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4177 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4179 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4181 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4182 ut_params->obuf = ut_params->op->sym->m_dst;
4183 if (ut_params->obuf)
4184 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4186 plaintext = ciphertext;
4188 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4191 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4192 tdata->plaintext.data,
4193 tdata->validDataLenInBits.len,
4194 "SNOW 3G Plaintext data not as expected");
4198 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4200 struct crypto_testsuite_params *ts_params = &testsuite_params;
4201 struct crypto_unittest_params *ut_params = &unittest_params;
4205 uint8_t *plaintext, *ciphertext;
4206 unsigned ciphertext_pad_len;
4207 unsigned ciphertext_len;
4209 /* Verify the capabilities */
4210 struct rte_cryptodev_sym_capability_idx cap_idx;
4211 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4212 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4213 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4217 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4220 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4223 /* Create SNOW 3G session */
4224 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4225 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4226 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4227 tdata->key.data, tdata->key.len,
4228 tdata->cipher_iv.len);
4232 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4233 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4235 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4236 "Failed to allocate input buffer");
4237 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4238 "Failed to allocate output buffer");
4240 /* Clear mbuf payload */
4241 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4242 rte_pktmbuf_tailroom(ut_params->ibuf));
4244 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4245 rte_pktmbuf_tailroom(ut_params->obuf));
4247 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4248 /* Append data which is padded to a multiple of */
4249 /* the algorithms block size */
4250 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4251 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4252 ciphertext_pad_len);
4253 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4254 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4256 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4258 /* Create SNOW 3G operation */
4259 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4260 tdata->cipher_iv.len,
4261 tdata->validCipherLenInBits.len,
4266 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4268 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4269 ut_params->obuf = ut_params->op->sym->m_dst;
4270 if (ut_params->obuf)
4271 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4273 plaintext = ciphertext;
4275 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4278 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4279 tdata->plaintext.data,
4280 tdata->validDataLenInBits.len,
4281 "SNOW 3G Plaintext data not as expected");
4286 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4288 struct crypto_testsuite_params *ts_params = &testsuite_params;
4289 struct crypto_unittest_params *ut_params = &unittest_params;
4293 uint8_t *plaintext, *ciphertext;
4294 unsigned int plaintext_pad_len;
4295 unsigned int plaintext_len;
4297 struct rte_cryptodev_info dev_info;
4298 struct rte_cryptodev_sym_capability_idx cap_idx;
4300 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4301 uint64_t feat_flags = dev_info.feature_flags;
4303 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4304 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4305 (tdata->validDataLenInBits.len % 8 != 0))) {
4306 printf("Device doesn't support NON-Byte Aligned Data.\n");
4310 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4311 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4312 printf("Device doesn't support RAW data-path APIs.\n");
4316 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4319 /* Check if device supports ZUC EEA3 */
4320 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4321 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4323 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4327 /* Check if device supports ZUC EIA3 */
4328 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4329 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4331 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4335 /* Create ZUC session */
4336 retval = create_zuc_cipher_auth_encrypt_generate_session(
4337 ts_params->valid_devs[0],
4341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4343 /* clear mbuf payload */
4344 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4345 rte_pktmbuf_tailroom(ut_params->ibuf));
4347 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4348 /* Append data which is padded to a multiple of */
4349 /* the algorithms block size */
4350 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4351 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4353 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4355 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4357 /* Create ZUC operation */
4358 retval = create_zuc_cipher_hash_generate_operation(tdata);
4362 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4363 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4364 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4366 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4368 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4369 ut_params->obuf = ut_params->op->sym->m_src;
4370 if (ut_params->obuf)
4371 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4373 ciphertext = plaintext;
4375 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4377 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4379 tdata->ciphertext.data,
4380 tdata->validDataLenInBits.len,
4381 "ZUC Ciphertext data not as expected");
4383 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4384 + plaintext_pad_len;
4387 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4391 "ZUC Generated auth tag not as expected");
4396 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4398 struct crypto_testsuite_params *ts_params = &testsuite_params;
4399 struct crypto_unittest_params *ut_params = &unittest_params;
4403 uint8_t *plaintext, *ciphertext;
4404 unsigned plaintext_pad_len;
4405 unsigned plaintext_len;
4406 struct rte_cryptodev_info dev_info;
4408 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4409 uint64_t feat_flags = dev_info.feature_flags;
4411 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4412 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4413 printf("Device doesn't support RAW data-path APIs.\n");
4417 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4420 /* Verify the capabilities */
4421 struct rte_cryptodev_sym_capability_idx cap_idx;
4422 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4423 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4424 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4427 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4428 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4429 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4433 /* Create SNOW 3G session */
4434 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4435 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4436 RTE_CRYPTO_AUTH_OP_GENERATE,
4437 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4438 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4439 tdata->key.data, tdata->key.len,
4440 tdata->auth_iv.len, tdata->digest.len,
4441 tdata->cipher_iv.len);
4444 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4446 /* clear mbuf payload */
4447 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4448 rte_pktmbuf_tailroom(ut_params->ibuf));
4450 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4451 /* Append data which is padded to a multiple of */
4452 /* the algorithms block size */
4453 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4454 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4456 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4458 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4460 /* Create SNOW 3G operation */
4461 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4462 tdata->digest.len, tdata->auth_iv.data,
4464 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4465 tdata->cipher_iv.data, tdata->cipher_iv.len,
4466 tdata->validCipherLenInBits.len,
4468 tdata->validAuthLenInBits.len,
4474 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4475 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4476 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4478 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4480 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4481 ut_params->obuf = ut_params->op->sym->m_src;
4482 if (ut_params->obuf)
4483 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4485 ciphertext = plaintext;
4487 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4489 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4491 tdata->ciphertext.data,
4492 tdata->validDataLenInBits.len,
4493 "SNOW 3G Ciphertext data not as expected");
4495 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4496 + plaintext_pad_len;
4499 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4502 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4503 "SNOW 3G Generated auth tag not as expected");
4508 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4509 uint8_t op_mode, uint8_t verify)
4511 struct crypto_testsuite_params *ts_params = &testsuite_params;
4512 struct crypto_unittest_params *ut_params = &unittest_params;
4516 uint8_t *plaintext = NULL, *ciphertext = NULL;
4517 unsigned int plaintext_pad_len;
4518 unsigned int plaintext_len;
4519 unsigned int ciphertext_pad_len;
4520 unsigned int ciphertext_len;
4522 struct rte_cryptodev_info dev_info;
4524 /* Verify the capabilities */
4525 struct rte_cryptodev_sym_capability_idx cap_idx;
4526 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4527 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4528 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4531 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4532 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4533 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4537 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4540 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4542 uint64_t feat_flags = dev_info.feature_flags;
4544 if (op_mode == OUT_OF_PLACE) {
4545 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4546 printf("Device doesn't support digest encrypted.\n");
4549 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4553 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4554 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4555 printf("Device doesn't support RAW data-path APIs.\n");
4559 /* Create SNOW 3G session */
4560 retval = create_wireless_algo_auth_cipher_session(
4561 ts_params->valid_devs[0],
4562 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4563 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4564 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4565 : RTE_CRYPTO_AUTH_OP_GENERATE),
4566 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4567 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4568 tdata->key.data, tdata->key.len,
4569 tdata->auth_iv.len, tdata->digest.len,
4570 tdata->cipher_iv.len);
4575 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4576 if (op_mode == OUT_OF_PLACE)
4577 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4579 /* clear mbuf payload */
4580 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4581 rte_pktmbuf_tailroom(ut_params->ibuf));
4582 if (op_mode == OUT_OF_PLACE)
4583 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4584 rte_pktmbuf_tailroom(ut_params->obuf));
4586 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4587 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4588 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4589 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4592 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4593 ciphertext_pad_len);
4594 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4595 if (op_mode == OUT_OF_PLACE)
4596 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4597 debug_hexdump(stdout, "ciphertext:", ciphertext,
4600 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4602 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4603 if (op_mode == OUT_OF_PLACE)
4604 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4605 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4608 /* Create SNOW 3G operation */
4609 retval = create_wireless_algo_auth_cipher_operation(
4610 tdata->digest.data, tdata->digest.len,
4611 tdata->cipher_iv.data, tdata->cipher_iv.len,
4612 tdata->auth_iv.data, tdata->auth_iv.len,
4613 (tdata->digest.offset_bytes == 0 ?
4614 (verify ? ciphertext_pad_len : plaintext_pad_len)
4615 : tdata->digest.offset_bytes),
4616 tdata->validCipherLenInBits.len,
4617 tdata->cipher.offset_bits,
4618 tdata->validAuthLenInBits.len,
4619 tdata->auth.offset_bits,
4620 op_mode, 0, verify);
4625 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4626 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4627 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4629 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4632 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4634 ut_params->obuf = (op_mode == IN_PLACE ?
4635 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4638 if (ut_params->obuf)
4639 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4642 plaintext = ciphertext +
4643 (tdata->cipher.offset_bits >> 3);
4645 debug_hexdump(stdout, "plaintext:", plaintext,
4646 (tdata->plaintext.len >> 3) - tdata->digest.len);
4647 debug_hexdump(stdout, "plaintext expected:",
4648 tdata->plaintext.data,
4649 (tdata->plaintext.len >> 3) - tdata->digest.len);
4651 if (ut_params->obuf)
4652 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4655 ciphertext = plaintext;
4657 debug_hexdump(stdout, "ciphertext:", ciphertext,
4659 debug_hexdump(stdout, "ciphertext expected:",
4660 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4662 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4663 + (tdata->digest.offset_bytes == 0 ?
4664 plaintext_pad_len : tdata->digest.offset_bytes);
4666 debug_hexdump(stdout, "digest:", ut_params->digest,
4668 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4674 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4676 tdata->plaintext.data,
4677 (tdata->plaintext.len - tdata->cipher.offset_bits -
4678 (tdata->digest.len << 3)),
4679 tdata->cipher.offset_bits,
4680 "SNOW 3G Plaintext data not as expected");
4682 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4684 tdata->ciphertext.data,
4685 (tdata->validDataLenInBits.len -
4686 tdata->cipher.offset_bits),
4687 tdata->cipher.offset_bits,
4688 "SNOW 3G Ciphertext data not as expected");
4690 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4693 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4694 "SNOW 3G Generated auth tag not as expected");
4700 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4701 uint8_t op_mode, uint8_t verify)
4703 struct crypto_testsuite_params *ts_params = &testsuite_params;
4704 struct crypto_unittest_params *ut_params = &unittest_params;
4708 const uint8_t *plaintext = NULL;
4709 const uint8_t *ciphertext = NULL;
4710 const uint8_t *digest = NULL;
4711 unsigned int plaintext_pad_len;
4712 unsigned int plaintext_len;
4713 unsigned int ciphertext_pad_len;
4714 unsigned int ciphertext_len;
4715 uint8_t buffer[10000];
4716 uint8_t digest_buffer[10000];
4718 struct rte_cryptodev_info dev_info;
4720 /* Verify the capabilities */
4721 struct rte_cryptodev_sym_capability_idx cap_idx;
4722 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4723 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4724 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4727 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4728 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4729 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4733 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4736 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4738 uint64_t feat_flags = dev_info.feature_flags;
4740 if (op_mode == IN_PLACE) {
4741 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4742 printf("Device doesn't support in-place scatter-gather "
4743 "in both input and output mbufs.\n");
4746 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4747 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4748 printf("Device doesn't support RAW data-path APIs.\n");
4752 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4754 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4755 printf("Device doesn't support out-of-place scatter-gather "
4756 "in both input and output mbufs.\n");
4759 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4760 printf("Device doesn't support digest encrypted.\n");
4765 /* Create SNOW 3G session */
4766 retval = create_wireless_algo_auth_cipher_session(
4767 ts_params->valid_devs[0],
4768 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4769 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4770 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4771 : RTE_CRYPTO_AUTH_OP_GENERATE),
4772 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4773 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4774 tdata->key.data, tdata->key.len,
4775 tdata->auth_iv.len, tdata->digest.len,
4776 tdata->cipher_iv.len);
4781 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4782 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4783 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4784 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4786 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4787 plaintext_pad_len, 15, 0);
4788 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4789 "Failed to allocate input buffer in mempool");
4791 if (op_mode == OUT_OF_PLACE) {
4792 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4793 plaintext_pad_len, 15, 0);
4794 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4795 "Failed to allocate output buffer in mempool");
4799 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4800 tdata->ciphertext.data);
4801 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4802 ciphertext_len, buffer);
4803 debug_hexdump(stdout, "ciphertext:", ciphertext,
4806 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4807 tdata->plaintext.data);
4808 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4809 plaintext_len, buffer);
4810 debug_hexdump(stdout, "plaintext:", plaintext,
4813 memset(buffer, 0, sizeof(buffer));
4815 /* Create SNOW 3G operation */
4816 retval = create_wireless_algo_auth_cipher_operation(
4817 tdata->digest.data, tdata->digest.len,
4818 tdata->cipher_iv.data, tdata->cipher_iv.len,
4819 tdata->auth_iv.data, tdata->auth_iv.len,
4820 (tdata->digest.offset_bytes == 0 ?
4821 (verify ? ciphertext_pad_len : plaintext_pad_len)
4822 : tdata->digest.offset_bytes),
4823 tdata->validCipherLenInBits.len,
4824 tdata->cipher.offset_bits,
4825 tdata->validAuthLenInBits.len,
4826 tdata->auth.offset_bits,
4827 op_mode, 1, verify);
4832 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4833 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4834 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4836 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4839 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4841 ut_params->obuf = (op_mode == IN_PLACE ?
4842 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4845 if (ut_params->obuf)
4846 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4847 plaintext_len, buffer);
4849 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4850 plaintext_len, buffer);
4852 debug_hexdump(stdout, "plaintext:", plaintext,
4853 (tdata->plaintext.len >> 3) - tdata->digest.len);
4854 debug_hexdump(stdout, "plaintext expected:",
4855 tdata->plaintext.data,
4856 (tdata->plaintext.len >> 3) - tdata->digest.len);
4858 if (ut_params->obuf)
4859 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4860 ciphertext_len, buffer);
4862 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4863 ciphertext_len, buffer);
4865 debug_hexdump(stdout, "ciphertext:", ciphertext,
4867 debug_hexdump(stdout, "ciphertext expected:",
4868 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4870 if (ut_params->obuf)
4871 digest = rte_pktmbuf_read(ut_params->obuf,
4872 (tdata->digest.offset_bytes == 0 ?
4873 plaintext_pad_len : tdata->digest.offset_bytes),
4874 tdata->digest.len, digest_buffer);
4876 digest = rte_pktmbuf_read(ut_params->ibuf,
4877 (tdata->digest.offset_bytes == 0 ?
4878 plaintext_pad_len : tdata->digest.offset_bytes),
4879 tdata->digest.len, digest_buffer);
4881 debug_hexdump(stdout, "digest:", digest,
4883 debug_hexdump(stdout, "digest expected:",
4884 tdata->digest.data, tdata->digest.len);
4889 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4891 tdata->plaintext.data,
4892 (tdata->plaintext.len - tdata->cipher.offset_bits -
4893 (tdata->digest.len << 3)),
4894 tdata->cipher.offset_bits,
4895 "SNOW 3G Plaintext data not as expected");
4897 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4899 tdata->ciphertext.data,
4900 (tdata->validDataLenInBits.len -
4901 tdata->cipher.offset_bits),
4902 tdata->cipher.offset_bits,
4903 "SNOW 3G Ciphertext data not as expected");
4905 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4908 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4909 "SNOW 3G Generated auth tag not as expected");
4915 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4916 uint8_t op_mode, uint8_t verify)
4918 struct crypto_testsuite_params *ts_params = &testsuite_params;
4919 struct crypto_unittest_params *ut_params = &unittest_params;
4923 uint8_t *plaintext = NULL, *ciphertext = NULL;
4924 unsigned int plaintext_pad_len;
4925 unsigned int plaintext_len;
4926 unsigned int ciphertext_pad_len;
4927 unsigned int ciphertext_len;
4929 struct rte_cryptodev_info dev_info;
4931 /* Verify the capabilities */
4932 struct rte_cryptodev_sym_capability_idx cap_idx;
4933 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4934 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4935 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4938 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4939 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4940 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4944 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4946 uint64_t feat_flags = dev_info.feature_flags;
4948 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4949 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4950 printf("Device doesn't support RAW data-path APIs.\n");
4954 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4957 if (op_mode == OUT_OF_PLACE) {
4958 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4960 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4961 printf("Device doesn't support digest encrypted.\n");
4966 /* Create KASUMI session */
4967 retval = create_wireless_algo_auth_cipher_session(
4968 ts_params->valid_devs[0],
4969 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4970 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4971 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4972 : RTE_CRYPTO_AUTH_OP_GENERATE),
4973 RTE_CRYPTO_AUTH_KASUMI_F9,
4974 RTE_CRYPTO_CIPHER_KASUMI_F8,
4975 tdata->key.data, tdata->key.len,
4976 0, tdata->digest.len,
4977 tdata->cipher_iv.len);
4982 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4983 if (op_mode == OUT_OF_PLACE)
4984 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4986 /* clear mbuf payload */
4987 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4988 rte_pktmbuf_tailroom(ut_params->ibuf));
4989 if (op_mode == OUT_OF_PLACE)
4990 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4991 rte_pktmbuf_tailroom(ut_params->obuf));
4993 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4994 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4995 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4996 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4999 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5000 ciphertext_pad_len);
5001 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5002 if (op_mode == OUT_OF_PLACE)
5003 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5004 debug_hexdump(stdout, "ciphertext:", ciphertext,
5007 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5009 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5010 if (op_mode == OUT_OF_PLACE)
5011 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5012 debug_hexdump(stdout, "plaintext:", plaintext,
5016 /* Create KASUMI operation */
5017 retval = create_wireless_algo_auth_cipher_operation(
5018 tdata->digest.data, tdata->digest.len,
5019 tdata->cipher_iv.data, tdata->cipher_iv.len,
5021 (tdata->digest.offset_bytes == 0 ?
5022 (verify ? ciphertext_pad_len : plaintext_pad_len)
5023 : tdata->digest.offset_bytes),
5024 tdata->validCipherLenInBits.len,
5025 tdata->validCipherOffsetInBits.len,
5026 tdata->validAuthLenInBits.len,
5028 op_mode, 0, verify);
5033 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5034 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5035 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5037 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5040 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5042 ut_params->obuf = (op_mode == IN_PLACE ?
5043 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5047 if (ut_params->obuf)
5048 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5051 plaintext = ciphertext;
5053 debug_hexdump(stdout, "plaintext:", plaintext,
5054 (tdata->plaintext.len >> 3) - tdata->digest.len);
5055 debug_hexdump(stdout, "plaintext expected:",
5056 tdata->plaintext.data,
5057 (tdata->plaintext.len >> 3) - tdata->digest.len);
5059 if (ut_params->obuf)
5060 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5063 ciphertext = plaintext;
5065 debug_hexdump(stdout, "ciphertext:", ciphertext,
5067 debug_hexdump(stdout, "ciphertext expected:",
5068 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5070 ut_params->digest = rte_pktmbuf_mtod(
5071 ut_params->obuf, uint8_t *) +
5072 (tdata->digest.offset_bytes == 0 ?
5073 plaintext_pad_len : tdata->digest.offset_bytes);
5075 debug_hexdump(stdout, "digest:", ut_params->digest,
5077 debug_hexdump(stdout, "digest expected:",
5078 tdata->digest.data, tdata->digest.len);
5083 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5085 tdata->plaintext.data,
5086 tdata->plaintext.len >> 3,
5087 "KASUMI Plaintext data not as expected");
5089 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5091 tdata->ciphertext.data,
5092 tdata->ciphertext.len >> 3,
5093 "KASUMI Ciphertext data not as expected");
5095 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5098 DIGEST_BYTE_LENGTH_KASUMI_F9,
5099 "KASUMI Generated auth tag not as expected");
5105 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5106 uint8_t op_mode, uint8_t verify)
5108 struct crypto_testsuite_params *ts_params = &testsuite_params;
5109 struct crypto_unittest_params *ut_params = &unittest_params;
5113 const uint8_t *plaintext = NULL;
5114 const uint8_t *ciphertext = NULL;
5115 const uint8_t *digest = NULL;
5116 unsigned int plaintext_pad_len;
5117 unsigned int plaintext_len;
5118 unsigned int ciphertext_pad_len;
5119 unsigned int ciphertext_len;
5120 uint8_t buffer[10000];
5121 uint8_t digest_buffer[10000];
5123 struct rte_cryptodev_info dev_info;
5125 /* Verify the capabilities */
5126 struct rte_cryptodev_sym_capability_idx cap_idx;
5127 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5128 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5129 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5132 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5133 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5134 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5138 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5141 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5143 uint64_t feat_flags = dev_info.feature_flags;
5145 if (op_mode == IN_PLACE) {
5146 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5147 printf("Device doesn't support in-place scatter-gather "
5148 "in both input and output mbufs.\n");
5151 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5152 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5153 printf("Device doesn't support RAW data-path APIs.\n");
5157 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5159 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5160 printf("Device doesn't support out-of-place scatter-gather "
5161 "in both input and output mbufs.\n");
5164 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5165 printf("Device doesn't support digest encrypted.\n");
5170 /* Create KASUMI session */
5171 retval = create_wireless_algo_auth_cipher_session(
5172 ts_params->valid_devs[0],
5173 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5174 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5175 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5176 : RTE_CRYPTO_AUTH_OP_GENERATE),
5177 RTE_CRYPTO_AUTH_KASUMI_F9,
5178 RTE_CRYPTO_CIPHER_KASUMI_F8,
5179 tdata->key.data, tdata->key.len,
5180 0, tdata->digest.len,
5181 tdata->cipher_iv.len);
5186 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5187 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5188 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5189 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5191 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5192 plaintext_pad_len, 15, 0);
5193 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5194 "Failed to allocate input buffer in mempool");
5196 if (op_mode == OUT_OF_PLACE) {
5197 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5198 plaintext_pad_len, 15, 0);
5199 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5200 "Failed to allocate output buffer in mempool");
5204 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5205 tdata->ciphertext.data);
5206 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5207 ciphertext_len, buffer);
5208 debug_hexdump(stdout, "ciphertext:", ciphertext,
5211 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5212 tdata->plaintext.data);
5213 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5214 plaintext_len, buffer);
5215 debug_hexdump(stdout, "plaintext:", plaintext,
5218 memset(buffer, 0, sizeof(buffer));
5220 /* Create KASUMI operation */
5221 retval = create_wireless_algo_auth_cipher_operation(
5222 tdata->digest.data, tdata->digest.len,
5223 tdata->cipher_iv.data, tdata->cipher_iv.len,
5225 (tdata->digest.offset_bytes == 0 ?
5226 (verify ? ciphertext_pad_len : plaintext_pad_len)
5227 : tdata->digest.offset_bytes),
5228 tdata->validCipherLenInBits.len,
5229 tdata->validCipherOffsetInBits.len,
5230 tdata->validAuthLenInBits.len,
5232 op_mode, 1, verify);
5237 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5238 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5239 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5241 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5244 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5246 ut_params->obuf = (op_mode == IN_PLACE ?
5247 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5250 if (ut_params->obuf)
5251 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5252 plaintext_len, buffer);
5254 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5255 plaintext_len, buffer);
5257 debug_hexdump(stdout, "plaintext:", plaintext,
5258 (tdata->plaintext.len >> 3) - tdata->digest.len);
5259 debug_hexdump(stdout, "plaintext expected:",
5260 tdata->plaintext.data,
5261 (tdata->plaintext.len >> 3) - tdata->digest.len);
5263 if (ut_params->obuf)
5264 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5265 ciphertext_len, buffer);
5267 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5268 ciphertext_len, buffer);
5270 debug_hexdump(stdout, "ciphertext:", ciphertext,
5272 debug_hexdump(stdout, "ciphertext expected:",
5273 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5275 if (ut_params->obuf)
5276 digest = rte_pktmbuf_read(ut_params->obuf,
5277 (tdata->digest.offset_bytes == 0 ?
5278 plaintext_pad_len : tdata->digest.offset_bytes),
5279 tdata->digest.len, digest_buffer);
5281 digest = rte_pktmbuf_read(ut_params->ibuf,
5282 (tdata->digest.offset_bytes == 0 ?
5283 plaintext_pad_len : tdata->digest.offset_bytes),
5284 tdata->digest.len, digest_buffer);
5286 debug_hexdump(stdout, "digest:", digest,
5288 debug_hexdump(stdout, "digest expected:",
5289 tdata->digest.data, tdata->digest.len);
5294 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5296 tdata->plaintext.data,
5297 tdata->plaintext.len >> 3,
5298 "KASUMI Plaintext data not as expected");
5300 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5302 tdata->ciphertext.data,
5303 tdata->validDataLenInBits.len,
5304 "KASUMI Ciphertext data not as expected");
5306 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5309 DIGEST_BYTE_LENGTH_KASUMI_F9,
5310 "KASUMI Generated auth tag not as expected");
5316 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5318 struct crypto_testsuite_params *ts_params = &testsuite_params;
5319 struct crypto_unittest_params *ut_params = &unittest_params;
5323 uint8_t *plaintext, *ciphertext;
5324 unsigned plaintext_pad_len;
5325 unsigned plaintext_len;
5326 struct rte_cryptodev_info dev_info;
5328 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5329 uint64_t feat_flags = dev_info.feature_flags;
5331 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5332 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5333 printf("Device doesn't support RAW data-path APIs.\n");
5337 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5340 /* Verify the capabilities */
5341 struct rte_cryptodev_sym_capability_idx cap_idx;
5342 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5343 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5344 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5347 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5348 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5349 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5353 /* Create KASUMI session */
5354 retval = create_wireless_algo_cipher_auth_session(
5355 ts_params->valid_devs[0],
5356 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5357 RTE_CRYPTO_AUTH_OP_GENERATE,
5358 RTE_CRYPTO_AUTH_KASUMI_F9,
5359 RTE_CRYPTO_CIPHER_KASUMI_F8,
5360 tdata->key.data, tdata->key.len,
5361 0, tdata->digest.len,
5362 tdata->cipher_iv.len);
5366 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5368 /* clear mbuf payload */
5369 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5370 rte_pktmbuf_tailroom(ut_params->ibuf));
5372 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5373 /* Append data which is padded to a multiple of */
5374 /* the algorithms block size */
5375 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5376 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5378 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5380 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5382 /* Create KASUMI operation */
5383 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5384 tdata->digest.len, NULL, 0,
5385 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5386 tdata->cipher_iv.data, tdata->cipher_iv.len,
5387 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5388 tdata->validCipherOffsetInBits.len,
5389 tdata->validAuthLenInBits.len,
5395 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5396 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5397 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5399 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5401 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5403 if (ut_params->op->sym->m_dst)
5404 ut_params->obuf = ut_params->op->sym->m_dst;
5406 ut_params->obuf = ut_params->op->sym->m_src;
5408 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5409 tdata->validCipherOffsetInBits.len >> 3);
5411 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5412 + plaintext_pad_len;
5414 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5415 (tdata->validCipherOffsetInBits.len >> 3);
5417 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5419 reference_ciphertext,
5420 tdata->validCipherLenInBits.len,
5421 "KASUMI Ciphertext data not as expected");
5424 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5427 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5428 "KASUMI Generated auth tag not as expected");
5433 test_zuc_encryption(const struct wireless_test_data *tdata)
5435 struct crypto_testsuite_params *ts_params = &testsuite_params;
5436 struct crypto_unittest_params *ut_params = &unittest_params;
5439 uint8_t *plaintext, *ciphertext;
5440 unsigned plaintext_pad_len;
5441 unsigned plaintext_len;
5442 struct rte_cryptodev_info dev_info;
5444 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5445 uint64_t feat_flags = dev_info.feature_flags;
5447 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5448 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5449 printf("Device doesn't support RAW data-path APIs.\n");
5453 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5456 struct rte_cryptodev_sym_capability_idx cap_idx;
5458 /* Check if device supports ZUC EEA3 */
5459 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5460 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5462 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5466 /* Create ZUC session */
5467 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5468 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5469 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5470 tdata->key.data, tdata->key.len,
5471 tdata->cipher_iv.len);
5475 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5477 /* Clear mbuf payload */
5478 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5479 rte_pktmbuf_tailroom(ut_params->ibuf));
5481 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5482 /* Append data which is padded to a multiple */
5483 /* of the algorithms block size */
5484 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5485 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5487 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5489 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5491 /* Create ZUC operation */
5492 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5493 tdata->cipher_iv.len,
5494 tdata->plaintext.len,
5499 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5500 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5501 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5503 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5505 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5507 ut_params->obuf = ut_params->op->sym->m_dst;
5508 if (ut_params->obuf)
5509 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5511 ciphertext = plaintext;
5513 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5516 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5518 tdata->ciphertext.data,
5519 tdata->validCipherLenInBits.len,
5520 "ZUC Ciphertext data not as expected");
5525 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5527 struct crypto_testsuite_params *ts_params = &testsuite_params;
5528 struct crypto_unittest_params *ut_params = &unittest_params;
5532 unsigned int plaintext_pad_len;
5533 unsigned int plaintext_len;
5534 const uint8_t *ciphertext;
5535 uint8_t ciphertext_buffer[2048];
5536 struct rte_cryptodev_info dev_info;
5538 struct rte_cryptodev_sym_capability_idx cap_idx;
5540 /* Check if device supports ZUC EEA3 */
5541 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5542 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5544 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5548 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5551 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5553 uint64_t feat_flags = dev_info.feature_flags;
5555 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5556 printf("Device doesn't support in-place scatter-gather. "
5561 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5562 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5563 printf("Device doesn't support RAW data-path APIs.\n");
5567 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5569 /* Append data which is padded to a multiple */
5570 /* of the algorithms block size */
5571 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5573 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5574 plaintext_pad_len, 10, 0);
5576 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5577 tdata->plaintext.data);
5579 /* Create ZUC session */
5580 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5581 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5582 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5583 tdata->key.data, tdata->key.len,
5584 tdata->cipher_iv.len);
5588 /* Clear mbuf payload */
5590 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5592 /* Create ZUC operation */
5593 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5594 tdata->cipher_iv.len, tdata->plaintext.len,
5599 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5600 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5601 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5603 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5605 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5607 ut_params->obuf = ut_params->op->sym->m_dst;
5608 if (ut_params->obuf)
5609 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5610 0, plaintext_len, ciphertext_buffer);
5612 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5613 0, plaintext_len, ciphertext_buffer);
5616 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5619 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5621 tdata->ciphertext.data,
5622 tdata->validCipherLenInBits.len,
5623 "ZUC Ciphertext data not as expected");
5629 test_zuc_authentication(const struct wireless_test_data *tdata)
5631 struct crypto_testsuite_params *ts_params = &testsuite_params;
5632 struct crypto_unittest_params *ut_params = &unittest_params;
5635 unsigned plaintext_pad_len;
5636 unsigned plaintext_len;
5639 struct rte_cryptodev_sym_capability_idx cap_idx;
5640 struct rte_cryptodev_info dev_info;
5642 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5643 uint64_t feat_flags = dev_info.feature_flags;
5645 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5646 (tdata->validAuthLenInBits.len % 8 != 0)) {
5647 printf("Device doesn't support NON-Byte Aligned Data.\n");
5651 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5652 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5653 printf("Device doesn't support RAW data-path APIs.\n");
5657 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5660 /* Check if device supports ZUC EIA3 */
5661 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5662 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5664 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5668 /* Create ZUC session */
5669 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5670 tdata->key.data, tdata->key.len,
5671 tdata->auth_iv.len, tdata->digest.len,
5672 RTE_CRYPTO_AUTH_OP_GENERATE,
5673 RTE_CRYPTO_AUTH_ZUC_EIA3);
5677 /* alloc mbuf and set payload */
5678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5680 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5681 rte_pktmbuf_tailroom(ut_params->ibuf));
5683 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5684 /* Append data which is padded to a multiple of */
5685 /* the algorithms block size */
5686 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5687 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5689 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5691 /* Create ZUC operation */
5692 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5693 tdata->auth_iv.data, tdata->auth_iv.len,
5694 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5695 tdata->validAuthLenInBits.len,
5700 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5701 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5702 ut_params->op, 0, 1, 1, 0);
5704 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5706 ut_params->obuf = ut_params->op->sym->m_src;
5707 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5708 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5709 + plaintext_pad_len;
5712 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5716 "ZUC Generated auth tag not as expected");
5722 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5723 uint8_t op_mode, uint8_t verify)
5725 struct crypto_testsuite_params *ts_params = &testsuite_params;
5726 struct crypto_unittest_params *ut_params = &unittest_params;
5730 uint8_t *plaintext = NULL, *ciphertext = NULL;
5731 unsigned int plaintext_pad_len;
5732 unsigned int plaintext_len;
5733 unsigned int ciphertext_pad_len;
5734 unsigned int ciphertext_len;
5736 struct rte_cryptodev_info dev_info;
5737 struct rte_cryptodev_sym_capability_idx cap_idx;
5739 /* Check if device supports ZUC EIA3 */
5740 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5741 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5743 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5747 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5749 uint64_t feat_flags = dev_info.feature_flags;
5751 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5752 printf("Device doesn't support digest encrypted.\n");
5755 if (op_mode == IN_PLACE) {
5756 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5757 printf("Device doesn't support in-place scatter-gather "
5758 "in both input and output mbufs.\n");
5762 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5763 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5764 printf("Device doesn't support RAW data-path APIs.\n");
5768 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5770 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5771 printf("Device doesn't support out-of-place scatter-gather "
5772 "in both input and output mbufs.\n");
5777 /* Create ZUC session */
5778 retval = create_wireless_algo_auth_cipher_session(
5779 ts_params->valid_devs[0],
5780 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5781 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5782 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5783 : RTE_CRYPTO_AUTH_OP_GENERATE),
5784 RTE_CRYPTO_AUTH_ZUC_EIA3,
5785 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5786 tdata->key.data, tdata->key.len,
5787 tdata->auth_iv.len, tdata->digest.len,
5788 tdata->cipher_iv.len);
5793 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5794 if (op_mode == OUT_OF_PLACE)
5795 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5797 /* clear mbuf payload */
5798 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5799 rte_pktmbuf_tailroom(ut_params->ibuf));
5800 if (op_mode == OUT_OF_PLACE)
5801 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5802 rte_pktmbuf_tailroom(ut_params->obuf));
5804 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5805 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5806 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5807 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5810 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5811 ciphertext_pad_len);
5812 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5813 if (op_mode == OUT_OF_PLACE)
5814 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5815 debug_hexdump(stdout, "ciphertext:", ciphertext,
5818 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5820 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5821 if (op_mode == OUT_OF_PLACE)
5822 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5823 debug_hexdump(stdout, "plaintext:", plaintext,
5827 /* Create ZUC operation */
5828 retval = create_wireless_algo_auth_cipher_operation(
5829 tdata->digest.data, tdata->digest.len,
5830 tdata->cipher_iv.data, tdata->cipher_iv.len,
5831 tdata->auth_iv.data, tdata->auth_iv.len,
5832 (tdata->digest.offset_bytes == 0 ?
5833 (verify ? ciphertext_pad_len : plaintext_pad_len)
5834 : tdata->digest.offset_bytes),
5835 tdata->validCipherLenInBits.len,
5836 tdata->validCipherOffsetInBits.len,
5837 tdata->validAuthLenInBits.len,
5839 op_mode, 0, verify);
5844 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5845 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5846 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5848 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5851 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5853 ut_params->obuf = (op_mode == IN_PLACE ?
5854 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5858 if (ut_params->obuf)
5859 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5862 plaintext = ciphertext;
5864 debug_hexdump(stdout, "plaintext:", plaintext,
5865 (tdata->plaintext.len >> 3) - tdata->digest.len);
5866 debug_hexdump(stdout, "plaintext expected:",
5867 tdata->plaintext.data,
5868 (tdata->plaintext.len >> 3) - tdata->digest.len);
5870 if (ut_params->obuf)
5871 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5874 ciphertext = plaintext;
5876 debug_hexdump(stdout, "ciphertext:", ciphertext,
5878 debug_hexdump(stdout, "ciphertext expected:",
5879 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5881 ut_params->digest = rte_pktmbuf_mtod(
5882 ut_params->obuf, uint8_t *) +
5883 (tdata->digest.offset_bytes == 0 ?
5884 plaintext_pad_len : tdata->digest.offset_bytes);
5886 debug_hexdump(stdout, "digest:", ut_params->digest,
5888 debug_hexdump(stdout, "digest expected:",
5889 tdata->digest.data, tdata->digest.len);
5894 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5896 tdata->plaintext.data,
5897 tdata->plaintext.len >> 3,
5898 "ZUC Plaintext data not as expected");
5900 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5902 tdata->ciphertext.data,
5903 tdata->ciphertext.len >> 3,
5904 "ZUC Ciphertext data not as expected");
5906 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5909 DIGEST_BYTE_LENGTH_KASUMI_F9,
5910 "ZUC Generated auth tag not as expected");
5916 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5917 uint8_t op_mode, uint8_t verify)
5919 struct crypto_testsuite_params *ts_params = &testsuite_params;
5920 struct crypto_unittest_params *ut_params = &unittest_params;
5924 const uint8_t *plaintext = NULL;
5925 const uint8_t *ciphertext = NULL;
5926 const uint8_t *digest = NULL;
5927 unsigned int plaintext_pad_len;
5928 unsigned int plaintext_len;
5929 unsigned int ciphertext_pad_len;
5930 unsigned int ciphertext_len;
5931 uint8_t buffer[10000];
5932 uint8_t digest_buffer[10000];
5934 struct rte_cryptodev_info dev_info;
5935 struct rte_cryptodev_sym_capability_idx cap_idx;
5937 /* Check if device supports ZUC EIA3 */
5938 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5939 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5941 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5945 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5947 uint64_t feat_flags = dev_info.feature_flags;
5949 if (op_mode == IN_PLACE) {
5950 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5951 printf("Device doesn't support in-place scatter-gather "
5952 "in both input and output mbufs.\n");
5956 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5957 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5958 printf("Device doesn't support RAW data-path APIs.\n");
5962 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5964 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5965 printf("Device doesn't support out-of-place scatter-gather "
5966 "in both input and output mbufs.\n");
5969 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5970 printf("Device doesn't support digest encrypted.\n");
5975 /* Create ZUC session */
5976 retval = create_wireless_algo_auth_cipher_session(
5977 ts_params->valid_devs[0],
5978 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5979 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5980 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5981 : RTE_CRYPTO_AUTH_OP_GENERATE),
5982 RTE_CRYPTO_AUTH_ZUC_EIA3,
5983 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5984 tdata->key.data, tdata->key.len,
5985 tdata->auth_iv.len, tdata->digest.len,
5986 tdata->cipher_iv.len);
5991 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5992 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5993 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5994 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5996 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5997 plaintext_pad_len, 15, 0);
5998 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5999 "Failed to allocate input buffer in mempool");
6001 if (op_mode == OUT_OF_PLACE) {
6002 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6003 plaintext_pad_len, 15, 0);
6004 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6005 "Failed to allocate output buffer in mempool");
6009 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6010 tdata->ciphertext.data);
6011 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6012 ciphertext_len, buffer);
6013 debug_hexdump(stdout, "ciphertext:", ciphertext,
6016 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6017 tdata->plaintext.data);
6018 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6019 plaintext_len, buffer);
6020 debug_hexdump(stdout, "plaintext:", plaintext,
6023 memset(buffer, 0, sizeof(buffer));
6025 /* Create ZUC operation */
6026 retval = create_wireless_algo_auth_cipher_operation(
6027 tdata->digest.data, tdata->digest.len,
6028 tdata->cipher_iv.data, tdata->cipher_iv.len,
6030 (tdata->digest.offset_bytes == 0 ?
6031 (verify ? ciphertext_pad_len : plaintext_pad_len)
6032 : tdata->digest.offset_bytes),
6033 tdata->validCipherLenInBits.len,
6034 tdata->validCipherOffsetInBits.len,
6035 tdata->validAuthLenInBits.len,
6037 op_mode, 1, verify);
6042 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6043 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6044 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6046 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6049 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6051 ut_params->obuf = (op_mode == IN_PLACE ?
6052 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6055 if (ut_params->obuf)
6056 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6057 plaintext_len, buffer);
6059 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6060 plaintext_len, buffer);
6062 debug_hexdump(stdout, "plaintext:", plaintext,
6063 (tdata->plaintext.len >> 3) - tdata->digest.len);
6064 debug_hexdump(stdout, "plaintext expected:",
6065 tdata->plaintext.data,
6066 (tdata->plaintext.len >> 3) - tdata->digest.len);
6068 if (ut_params->obuf)
6069 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6070 ciphertext_len, buffer);
6072 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6073 ciphertext_len, buffer);
6075 debug_hexdump(stdout, "ciphertext:", ciphertext,
6077 debug_hexdump(stdout, "ciphertext expected:",
6078 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6080 if (ut_params->obuf)
6081 digest = rte_pktmbuf_read(ut_params->obuf,
6082 (tdata->digest.offset_bytes == 0 ?
6083 plaintext_pad_len : tdata->digest.offset_bytes),
6084 tdata->digest.len, digest_buffer);
6086 digest = rte_pktmbuf_read(ut_params->ibuf,
6087 (tdata->digest.offset_bytes == 0 ?
6088 plaintext_pad_len : tdata->digest.offset_bytes),
6089 tdata->digest.len, digest_buffer);
6091 debug_hexdump(stdout, "digest:", digest,
6093 debug_hexdump(stdout, "digest expected:",
6094 tdata->digest.data, tdata->digest.len);
6099 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6101 tdata->plaintext.data,
6102 tdata->plaintext.len >> 3,
6103 "ZUC Plaintext data not as expected");
6105 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6107 tdata->ciphertext.data,
6108 tdata->validDataLenInBits.len,
6109 "ZUC Ciphertext data not as expected");
6111 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6114 DIGEST_BYTE_LENGTH_KASUMI_F9,
6115 "ZUC Generated auth tag not as expected");
6121 test_kasumi_encryption_test_case_1(void)
6123 return test_kasumi_encryption(&kasumi_test_case_1);
6127 test_kasumi_encryption_test_case_1_sgl(void)
6129 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6133 test_kasumi_encryption_test_case_1_oop(void)
6135 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6139 test_kasumi_encryption_test_case_1_oop_sgl(void)
6141 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6145 test_kasumi_encryption_test_case_2(void)
6147 return test_kasumi_encryption(&kasumi_test_case_2);
6151 test_kasumi_encryption_test_case_3(void)
6153 return test_kasumi_encryption(&kasumi_test_case_3);
6157 test_kasumi_encryption_test_case_4(void)
6159 return test_kasumi_encryption(&kasumi_test_case_4);
6163 test_kasumi_encryption_test_case_5(void)
6165 return test_kasumi_encryption(&kasumi_test_case_5);
6169 test_kasumi_decryption_test_case_1(void)
6171 return test_kasumi_decryption(&kasumi_test_case_1);
6175 test_kasumi_decryption_test_case_1_oop(void)
6177 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6181 test_kasumi_decryption_test_case_2(void)
6183 return test_kasumi_decryption(&kasumi_test_case_2);
6187 test_kasumi_decryption_test_case_3(void)
6189 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6190 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6192 return test_kasumi_decryption(&kasumi_test_case_3);
6196 test_kasumi_decryption_test_case_4(void)
6198 return test_kasumi_decryption(&kasumi_test_case_4);
6202 test_kasumi_decryption_test_case_5(void)
6204 return test_kasumi_decryption(&kasumi_test_case_5);
6207 test_snow3g_encryption_test_case_1(void)
6209 return test_snow3g_encryption(&snow3g_test_case_1);
6213 test_snow3g_encryption_test_case_1_oop(void)
6215 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6219 test_snow3g_encryption_test_case_1_oop_sgl(void)
6221 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6226 test_snow3g_encryption_test_case_1_offset_oop(void)
6228 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6232 test_snow3g_encryption_test_case_2(void)
6234 return test_snow3g_encryption(&snow3g_test_case_2);
6238 test_snow3g_encryption_test_case_3(void)
6240 return test_snow3g_encryption(&snow3g_test_case_3);
6244 test_snow3g_encryption_test_case_4(void)
6246 return test_snow3g_encryption(&snow3g_test_case_4);
6250 test_snow3g_encryption_test_case_5(void)
6252 return test_snow3g_encryption(&snow3g_test_case_5);
6256 test_snow3g_decryption_test_case_1(void)
6258 return test_snow3g_decryption(&snow3g_test_case_1);
6262 test_snow3g_decryption_test_case_1_oop(void)
6264 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6268 test_snow3g_decryption_test_case_2(void)
6270 return test_snow3g_decryption(&snow3g_test_case_2);
6274 test_snow3g_decryption_test_case_3(void)
6276 return test_snow3g_decryption(&snow3g_test_case_3);
6280 test_snow3g_decryption_test_case_4(void)
6282 return test_snow3g_decryption(&snow3g_test_case_4);
6286 test_snow3g_decryption_test_case_5(void)
6288 return test_snow3g_decryption(&snow3g_test_case_5);
6292 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6293 * Pattern digest from snow3g_test_data must be allocated as
6294 * 4 last bytes in plaintext.
6297 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6298 struct snow3g_hash_test_data *output)
6300 if ((pattern != NULL) && (output != NULL)) {
6301 output->key.len = pattern->key.len;
6303 memcpy(output->key.data,
6304 pattern->key.data, pattern->key.len);
6306 output->auth_iv.len = pattern->auth_iv.len;
6308 memcpy(output->auth_iv.data,
6309 pattern->auth_iv.data, pattern->auth_iv.len);
6311 output->plaintext.len = pattern->plaintext.len;
6313 memcpy(output->plaintext.data,
6314 pattern->plaintext.data, pattern->plaintext.len >> 3);
6316 output->digest.len = pattern->digest.len;
6318 memcpy(output->digest.data,
6319 &pattern->plaintext.data[pattern->digest.offset_bytes],
6320 pattern->digest.len);
6322 output->validAuthLenInBits.len =
6323 pattern->validAuthLenInBits.len;
6328 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6331 test_snow3g_decryption_with_digest_test_case_1(void)
6333 struct snow3g_hash_test_data snow3g_hash_data;
6334 struct rte_cryptodev_info dev_info;
6335 struct crypto_testsuite_params *ts_params = &testsuite_params;
6337 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6338 uint64_t feat_flags = dev_info.feature_flags;
6340 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6341 printf("Device doesn't support encrypted digest operations.\n");
6346 * Function prepare data for hash veryfication test case.
6347 * Digest is allocated in 4 last bytes in plaintext, pattern.
6349 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6351 return test_snow3g_decryption(&snow3g_test_case_7) &
6352 test_snow3g_authentication_verify(&snow3g_hash_data);
6356 test_snow3g_cipher_auth_test_case_1(void)
6358 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6362 test_snow3g_auth_cipher_test_case_1(void)
6364 return test_snow3g_auth_cipher(
6365 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6369 test_snow3g_auth_cipher_test_case_2(void)
6371 return test_snow3g_auth_cipher(
6372 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6376 test_snow3g_auth_cipher_test_case_2_oop(void)
6378 return test_snow3g_auth_cipher(
6379 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6383 test_snow3g_auth_cipher_part_digest_enc(void)
6385 return test_snow3g_auth_cipher(
6386 &snow3g_auth_cipher_partial_digest_encryption,
6391 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6393 return test_snow3g_auth_cipher(
6394 &snow3g_auth_cipher_partial_digest_encryption,
6399 test_snow3g_auth_cipher_test_case_3_sgl(void)
6401 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6402 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6404 return test_snow3g_auth_cipher_sgl(
6405 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6409 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6411 return test_snow3g_auth_cipher_sgl(
6412 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6416 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6418 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6419 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6421 return test_snow3g_auth_cipher_sgl(
6422 &snow3g_auth_cipher_partial_digest_encryption,
6427 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6429 return test_snow3g_auth_cipher_sgl(
6430 &snow3g_auth_cipher_partial_digest_encryption,
6435 test_snow3g_auth_cipher_verify_test_case_1(void)
6437 return test_snow3g_auth_cipher(
6438 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6442 test_snow3g_auth_cipher_verify_test_case_2(void)
6444 return test_snow3g_auth_cipher(
6445 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6449 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6451 return test_snow3g_auth_cipher(
6452 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6456 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6458 return test_snow3g_auth_cipher(
6459 &snow3g_auth_cipher_partial_digest_encryption,
6464 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6466 return test_snow3g_auth_cipher(
6467 &snow3g_auth_cipher_partial_digest_encryption,
6472 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6474 return test_snow3g_auth_cipher_sgl(
6475 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6479 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6481 return test_snow3g_auth_cipher_sgl(
6482 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6486 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6488 return test_snow3g_auth_cipher_sgl(
6489 &snow3g_auth_cipher_partial_digest_encryption,
6494 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6496 return test_snow3g_auth_cipher_sgl(
6497 &snow3g_auth_cipher_partial_digest_encryption,
6502 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6504 return test_snow3g_auth_cipher(
6505 &snow3g_test_case_7, IN_PLACE, 0);
6509 test_kasumi_auth_cipher_test_case_1(void)
6511 return test_kasumi_auth_cipher(
6512 &kasumi_test_case_3, IN_PLACE, 0);
6516 test_kasumi_auth_cipher_test_case_2(void)
6518 return test_kasumi_auth_cipher(
6519 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6523 test_kasumi_auth_cipher_test_case_2_oop(void)
6525 return test_kasumi_auth_cipher(
6526 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6530 test_kasumi_auth_cipher_test_case_2_sgl(void)
6532 return test_kasumi_auth_cipher_sgl(
6533 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6537 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6539 return test_kasumi_auth_cipher_sgl(
6540 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6544 test_kasumi_auth_cipher_verify_test_case_1(void)
6546 return test_kasumi_auth_cipher(
6547 &kasumi_test_case_3, IN_PLACE, 1);
6551 test_kasumi_auth_cipher_verify_test_case_2(void)
6553 return test_kasumi_auth_cipher(
6554 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6558 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6560 return test_kasumi_auth_cipher(
6561 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6565 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6567 return test_kasumi_auth_cipher_sgl(
6568 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6572 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6574 return test_kasumi_auth_cipher_sgl(
6575 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6579 test_kasumi_cipher_auth_test_case_1(void)
6581 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6585 test_zuc_encryption_test_case_1(void)
6587 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6591 test_zuc_encryption_test_case_2(void)
6593 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6597 test_zuc_encryption_test_case_3(void)
6599 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6603 test_zuc_encryption_test_case_4(void)
6605 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6609 test_zuc_encryption_test_case_5(void)
6611 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6615 test_zuc_encryption_test_case_6_sgl(void)
6617 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6621 test_zuc_hash_generate_test_case_1(void)
6623 return test_zuc_authentication(&zuc_test_case_auth_1b);
6627 test_zuc_hash_generate_test_case_2(void)
6629 return test_zuc_authentication(&zuc_test_case_auth_90b);
6633 test_zuc_hash_generate_test_case_3(void)
6635 return test_zuc_authentication(&zuc_test_case_auth_577b);
6639 test_zuc_hash_generate_test_case_4(void)
6641 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6645 test_zuc_hash_generate_test_case_5(void)
6647 return test_zuc_authentication(&zuc_test_auth_5670b);
6651 test_zuc_hash_generate_test_case_6(void)
6653 return test_zuc_authentication(&zuc_test_case_auth_128b);
6657 test_zuc_hash_generate_test_case_7(void)
6659 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6663 test_zuc_hash_generate_test_case_8(void)
6665 return test_zuc_authentication(&zuc_test_case_auth_584b);
6669 test_zuc_cipher_auth_test_case_1(void)
6671 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6675 test_zuc_cipher_auth_test_case_2(void)
6677 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6681 test_zuc_auth_cipher_test_case_1(void)
6683 return test_zuc_auth_cipher(
6684 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6688 test_zuc_auth_cipher_test_case_1_oop(void)
6690 return test_zuc_auth_cipher(
6691 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6695 test_zuc_auth_cipher_test_case_1_sgl(void)
6697 return test_zuc_auth_cipher_sgl(
6698 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6702 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6704 return test_zuc_auth_cipher_sgl(
6705 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6709 test_zuc_auth_cipher_verify_test_case_1(void)
6711 return test_zuc_auth_cipher(
6712 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6716 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6718 return test_zuc_auth_cipher(
6719 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6723 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6725 return test_zuc_auth_cipher_sgl(
6726 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6730 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6732 return test_zuc_auth_cipher_sgl(
6733 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6737 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6739 uint8_t dev_id = testsuite_params.valid_devs[0];
6741 struct rte_cryptodev_sym_capability_idx cap_idx;
6743 /* Check if device supports particular cipher algorithm */
6744 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6745 cap_idx.algo.cipher = tdata->cipher_algo;
6746 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6749 /* Check if device supports particular hash algorithm */
6750 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6751 cap_idx.algo.auth = tdata->auth_algo;
6752 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6759 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6760 uint8_t op_mode, uint8_t verify)
6762 struct crypto_testsuite_params *ts_params = &testsuite_params;
6763 struct crypto_unittest_params *ut_params = &unittest_params;
6767 uint8_t *plaintext = NULL, *ciphertext = NULL;
6768 unsigned int plaintext_pad_len;
6769 unsigned int plaintext_len;
6770 unsigned int ciphertext_pad_len;
6771 unsigned int ciphertext_len;
6773 struct rte_cryptodev_info dev_info;
6774 struct rte_crypto_op *op;
6776 /* Check if device supports particular algorithms separately */
6777 if (test_mixed_check_if_unsupported(tdata))
6779 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6782 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6784 uint64_t feat_flags = dev_info.feature_flags;
6786 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6787 printf("Device doesn't support digest encrypted.\n");
6791 /* Create the session */
6793 retval = create_wireless_algo_cipher_auth_session(
6794 ts_params->valid_devs[0],
6795 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6796 RTE_CRYPTO_AUTH_OP_VERIFY,
6799 tdata->auth_key.data, tdata->auth_key.len,
6800 tdata->auth_iv.len, tdata->digest_enc.len,
6801 tdata->cipher_iv.len);
6803 retval = create_wireless_algo_auth_cipher_session(
6804 ts_params->valid_devs[0],
6805 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6806 RTE_CRYPTO_AUTH_OP_GENERATE,
6809 tdata->auth_key.data, tdata->auth_key.len,
6810 tdata->auth_iv.len, tdata->digest_enc.len,
6811 tdata->cipher_iv.len);
6815 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6816 if (op_mode == OUT_OF_PLACE)
6817 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6819 /* clear mbuf payload */
6820 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6821 rte_pktmbuf_tailroom(ut_params->ibuf));
6822 if (op_mode == OUT_OF_PLACE) {
6824 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6825 rte_pktmbuf_tailroom(ut_params->obuf));
6828 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6829 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6830 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6831 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6834 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6835 ciphertext_pad_len);
6836 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6837 if (op_mode == OUT_OF_PLACE)
6838 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6839 debug_hexdump(stdout, "ciphertext:", ciphertext,
6842 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6844 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6845 if (op_mode == OUT_OF_PLACE)
6846 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6847 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6850 /* Create the operation */
6851 retval = create_wireless_algo_auth_cipher_operation(
6852 tdata->digest_enc.data, tdata->digest_enc.len,
6853 tdata->cipher_iv.data, tdata->cipher_iv.len,
6854 tdata->auth_iv.data, tdata->auth_iv.len,
6855 (tdata->digest_enc.offset == 0 ?
6857 : tdata->digest_enc.offset),
6858 tdata->validCipherLen.len_bits,
6859 tdata->cipher.offset_bits,
6860 tdata->validAuthLen.len_bits,
6861 tdata->auth.offset_bits,
6862 op_mode, 0, verify);
6867 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
6869 /* Check if the op failed because the device doesn't */
6870 /* support this particular combination of algorithms */
6871 if (op == NULL && ut_params->op->status ==
6872 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6873 printf("Device doesn't support this mixed combination. "
6879 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6881 ut_params->obuf = (op_mode == IN_PLACE ?
6882 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6885 if (ut_params->obuf)
6886 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6889 plaintext = ciphertext +
6890 (tdata->cipher.offset_bits >> 3);
6892 debug_hexdump(stdout, "plaintext:", plaintext,
6893 tdata->plaintext.len_bits >> 3);
6894 debug_hexdump(stdout, "plaintext expected:",
6895 tdata->plaintext.data,
6896 tdata->plaintext.len_bits >> 3);
6898 if (ut_params->obuf)
6899 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6902 ciphertext = plaintext;
6904 debug_hexdump(stdout, "ciphertext:", ciphertext,
6906 debug_hexdump(stdout, "ciphertext expected:",
6907 tdata->ciphertext.data,
6908 tdata->ciphertext.len_bits >> 3);
6910 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6911 + (tdata->digest_enc.offset == 0 ?
6912 plaintext_pad_len : tdata->digest_enc.offset);
6914 debug_hexdump(stdout, "digest:", ut_params->digest,
6915 tdata->digest_enc.len);
6916 debug_hexdump(stdout, "digest expected:",
6917 tdata->digest_enc.data,
6918 tdata->digest_enc.len);
6923 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6925 tdata->plaintext.data,
6926 tdata->plaintext.len_bits >> 3,
6927 "Plaintext data not as expected");
6929 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6931 tdata->ciphertext.data,
6932 tdata->validDataLen.len_bits,
6933 "Ciphertext data not as expected");
6935 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6937 tdata->digest_enc.data,
6938 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6939 "Generated auth tag not as expected");
6942 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6943 "crypto op processing failed");
6949 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6950 uint8_t op_mode, uint8_t verify)
6952 struct crypto_testsuite_params *ts_params = &testsuite_params;
6953 struct crypto_unittest_params *ut_params = &unittest_params;
6957 const uint8_t *plaintext = NULL;
6958 const uint8_t *ciphertext = NULL;
6959 const uint8_t *digest = NULL;
6960 unsigned int plaintext_pad_len;
6961 unsigned int plaintext_len;
6962 unsigned int ciphertext_pad_len;
6963 unsigned int ciphertext_len;
6964 uint8_t buffer[10000];
6965 uint8_t digest_buffer[10000];
6967 struct rte_cryptodev_info dev_info;
6968 struct rte_crypto_op *op;
6970 /* Check if device supports particular algorithms */
6971 if (test_mixed_check_if_unsupported(tdata))
6973 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6976 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6978 uint64_t feat_flags = dev_info.feature_flags;
6980 if (op_mode == IN_PLACE) {
6981 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6982 printf("Device doesn't support in-place scatter-gather "
6983 "in both input and output mbufs.\n");
6987 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6988 printf("Device doesn't support out-of-place scatter-gather "
6989 "in both input and output mbufs.\n");
6992 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6993 printf("Device doesn't support digest encrypted.\n");
6998 /* Create the session */
7000 retval = create_wireless_algo_cipher_auth_session(
7001 ts_params->valid_devs[0],
7002 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7003 RTE_CRYPTO_AUTH_OP_VERIFY,
7006 tdata->auth_key.data, tdata->auth_key.len,
7007 tdata->auth_iv.len, tdata->digest_enc.len,
7008 tdata->cipher_iv.len);
7010 retval = create_wireless_algo_auth_cipher_session(
7011 ts_params->valid_devs[0],
7012 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7013 RTE_CRYPTO_AUTH_OP_GENERATE,
7016 tdata->auth_key.data, tdata->auth_key.len,
7017 tdata->auth_iv.len, tdata->digest_enc.len,
7018 tdata->cipher_iv.len);
7022 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7023 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7024 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7025 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7027 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7028 ciphertext_pad_len, 15, 0);
7029 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7030 "Failed to allocate input buffer in mempool");
7032 if (op_mode == OUT_OF_PLACE) {
7033 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7034 plaintext_pad_len, 15, 0);
7035 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7036 "Failed to allocate output buffer in mempool");
7040 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7041 tdata->ciphertext.data);
7042 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7043 ciphertext_len, buffer);
7044 debug_hexdump(stdout, "ciphertext:", ciphertext,
7047 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7048 tdata->plaintext.data);
7049 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7050 plaintext_len, buffer);
7051 debug_hexdump(stdout, "plaintext:", plaintext,
7054 memset(buffer, 0, sizeof(buffer));
7056 /* Create the operation */
7057 retval = create_wireless_algo_auth_cipher_operation(
7058 tdata->digest_enc.data, tdata->digest_enc.len,
7059 tdata->cipher_iv.data, tdata->cipher_iv.len,
7060 tdata->auth_iv.data, tdata->auth_iv.len,
7061 (tdata->digest_enc.offset == 0 ?
7063 : tdata->digest_enc.offset),
7064 tdata->validCipherLen.len_bits,
7065 tdata->cipher.offset_bits,
7066 tdata->validAuthLen.len_bits,
7067 tdata->auth.offset_bits,
7068 op_mode, 1, verify);
7073 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7075 /* Check if the op failed because the device doesn't */
7076 /* support this particular combination of algorithms */
7077 if (op == NULL && ut_params->op->status ==
7078 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7079 printf("Device doesn't support this mixed combination. "
7085 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7087 ut_params->obuf = (op_mode == IN_PLACE ?
7088 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7091 if (ut_params->obuf)
7092 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7093 plaintext_len, buffer);
7095 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7096 plaintext_len, buffer);
7098 debug_hexdump(stdout, "plaintext:", plaintext,
7099 (tdata->plaintext.len_bits >> 3) -
7100 tdata->digest_enc.len);
7101 debug_hexdump(stdout, "plaintext expected:",
7102 tdata->plaintext.data,
7103 (tdata->plaintext.len_bits >> 3) -
7104 tdata->digest_enc.len);
7106 if (ut_params->obuf)
7107 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7108 ciphertext_len, buffer);
7110 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7111 ciphertext_len, buffer);
7113 debug_hexdump(stdout, "ciphertext:", ciphertext,
7115 debug_hexdump(stdout, "ciphertext expected:",
7116 tdata->ciphertext.data,
7117 tdata->ciphertext.len_bits >> 3);
7119 if (ut_params->obuf)
7120 digest = rte_pktmbuf_read(ut_params->obuf,
7121 (tdata->digest_enc.offset == 0 ?
7123 tdata->digest_enc.offset),
7124 tdata->digest_enc.len, digest_buffer);
7126 digest = rte_pktmbuf_read(ut_params->ibuf,
7127 (tdata->digest_enc.offset == 0 ?
7129 tdata->digest_enc.offset),
7130 tdata->digest_enc.len, digest_buffer);
7132 debug_hexdump(stdout, "digest:", digest,
7133 tdata->digest_enc.len);
7134 debug_hexdump(stdout, "digest expected:",
7135 tdata->digest_enc.data, tdata->digest_enc.len);
7140 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7142 tdata->plaintext.data,
7143 tdata->plaintext.len_bits >> 3,
7144 "Plaintext data not as expected");
7146 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7148 tdata->ciphertext.data,
7149 tdata->validDataLen.len_bits,
7150 "Ciphertext data not as expected");
7151 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7153 tdata->digest_enc.data,
7154 tdata->digest_enc.len,
7155 "Generated auth tag not as expected");
7158 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7159 "crypto op processing failed");
7164 /** AUTH AES CMAC + CIPHER AES CTR */
7167 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7169 return test_mixed_auth_cipher(
7170 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7174 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7176 return test_mixed_auth_cipher(
7177 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7181 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7183 return test_mixed_auth_cipher_sgl(
7184 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7188 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7190 return test_mixed_auth_cipher_sgl(
7191 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7195 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7197 return test_mixed_auth_cipher(
7198 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7202 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7204 return test_mixed_auth_cipher(
7205 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7209 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7211 return test_mixed_auth_cipher_sgl(
7212 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7216 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7218 return test_mixed_auth_cipher_sgl(
7219 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7222 /** MIXED AUTH + CIPHER */
7225 test_auth_zuc_cipher_snow_test_case_1(void)
7227 return test_mixed_auth_cipher(
7228 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7232 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7234 return test_mixed_auth_cipher(
7235 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7239 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7241 return test_mixed_auth_cipher(
7242 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7246 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7248 return test_mixed_auth_cipher(
7249 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7253 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7255 return test_mixed_auth_cipher(
7256 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7260 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7262 return test_mixed_auth_cipher(
7263 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7267 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7269 return test_mixed_auth_cipher(
7270 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7274 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7276 return test_mixed_auth_cipher(
7277 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7281 test_auth_snow_cipher_zuc_test_case_1(void)
7283 return test_mixed_auth_cipher(
7284 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7288 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7290 return test_mixed_auth_cipher(
7291 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7295 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7297 return test_mixed_auth_cipher(
7298 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7302 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7304 return test_mixed_auth_cipher(
7305 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7309 test_auth_null_cipher_snow_test_case_1(void)
7311 return test_mixed_auth_cipher(
7312 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7316 test_verify_auth_null_cipher_snow_test_case_1(void)
7318 return test_mixed_auth_cipher(
7319 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7323 test_auth_null_cipher_zuc_test_case_1(void)
7325 return test_mixed_auth_cipher(
7326 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7330 test_verify_auth_null_cipher_zuc_test_case_1(void)
7332 return test_mixed_auth_cipher(
7333 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7337 test_auth_snow_cipher_null_test_case_1(void)
7339 return test_mixed_auth_cipher(
7340 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7344 test_verify_auth_snow_cipher_null_test_case_1(void)
7346 return test_mixed_auth_cipher(
7347 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7351 test_auth_zuc_cipher_null_test_case_1(void)
7353 return test_mixed_auth_cipher(
7354 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7358 test_verify_auth_zuc_cipher_null_test_case_1(void)
7360 return test_mixed_auth_cipher(
7361 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7365 test_auth_null_cipher_aes_ctr_test_case_1(void)
7367 return test_mixed_auth_cipher(
7368 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7372 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7374 return test_mixed_auth_cipher(
7375 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7379 test_auth_aes_cmac_cipher_null_test_case_1(void)
7381 return test_mixed_auth_cipher(
7382 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7386 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7388 return test_mixed_auth_cipher(
7389 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7392 /* ***** AEAD algorithm Tests ***** */
7395 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7396 enum rte_crypto_aead_operation op,
7397 const uint8_t *key, const uint8_t key_len,
7398 const uint16_t aad_len, const uint8_t auth_len,
7401 uint8_t aead_key[key_len];
7403 struct crypto_testsuite_params *ts_params = &testsuite_params;
7404 struct crypto_unittest_params *ut_params = &unittest_params;
7406 memcpy(aead_key, key, key_len);
7408 /* Setup AEAD Parameters */
7409 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7410 ut_params->aead_xform.next = NULL;
7411 ut_params->aead_xform.aead.algo = algo;
7412 ut_params->aead_xform.aead.op = op;
7413 ut_params->aead_xform.aead.key.data = aead_key;
7414 ut_params->aead_xform.aead.key.length = key_len;
7415 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7416 ut_params->aead_xform.aead.iv.length = iv_len;
7417 ut_params->aead_xform.aead.digest_length = auth_len;
7418 ut_params->aead_xform.aead.aad_length = aad_len;
7420 debug_hexdump(stdout, "key:", key, key_len);
7422 /* Create Crypto session*/
7423 ut_params->sess = rte_cryptodev_sym_session_create(
7424 ts_params->session_mpool);
7426 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7427 &ut_params->aead_xform,
7428 ts_params->session_priv_mpool);
7430 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7436 create_aead_xform(struct rte_crypto_op *op,
7437 enum rte_crypto_aead_algorithm algo,
7438 enum rte_crypto_aead_operation aead_op,
7439 uint8_t *key, const uint8_t key_len,
7440 const uint8_t aad_len, const uint8_t auth_len,
7443 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7444 "failed to allocate space for crypto transform");
7446 struct rte_crypto_sym_op *sym_op = op->sym;
7448 /* Setup AEAD Parameters */
7449 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7450 sym_op->xform->next = NULL;
7451 sym_op->xform->aead.algo = algo;
7452 sym_op->xform->aead.op = aead_op;
7453 sym_op->xform->aead.key.data = key;
7454 sym_op->xform->aead.key.length = key_len;
7455 sym_op->xform->aead.iv.offset = IV_OFFSET;
7456 sym_op->xform->aead.iv.length = iv_len;
7457 sym_op->xform->aead.digest_length = auth_len;
7458 sym_op->xform->aead.aad_length = aad_len;
7460 debug_hexdump(stdout, "key:", key, key_len);
7466 create_aead_operation(enum rte_crypto_aead_operation op,
7467 const struct aead_test_data *tdata)
7469 struct crypto_testsuite_params *ts_params = &testsuite_params;
7470 struct crypto_unittest_params *ut_params = &unittest_params;
7472 uint8_t *plaintext, *ciphertext;
7473 unsigned int aad_pad_len, plaintext_pad_len;
7475 /* Generate Crypto op data structure */
7476 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7477 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7478 TEST_ASSERT_NOT_NULL(ut_params->op,
7479 "Failed to allocate symmetric crypto operation struct");
7481 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7483 /* Append aad data */
7484 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7485 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7486 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7488 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7489 "no room to append aad");
7491 sym_op->aead.aad.phys_addr =
7492 rte_pktmbuf_iova(ut_params->ibuf);
7493 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7494 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7495 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7498 /* Append IV at the end of the crypto operation*/
7499 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7500 uint8_t *, IV_OFFSET);
7502 /* Copy IV 1 byte after the IV pointer, according to the API */
7503 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7504 debug_hexdump(stdout, "iv:", iv_ptr,
7507 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7508 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7510 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7511 "no room to append aad");
7513 sym_op->aead.aad.phys_addr =
7514 rte_pktmbuf_iova(ut_params->ibuf);
7515 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7516 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7519 /* Append IV at the end of the crypto operation*/
7520 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7521 uint8_t *, IV_OFFSET);
7523 if (tdata->iv.len == 0) {
7524 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7525 debug_hexdump(stdout, "iv:", iv_ptr,
7528 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7529 debug_hexdump(stdout, "iv:", iv_ptr,
7534 /* Append plaintext/ciphertext */
7535 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7536 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7537 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7539 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7541 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7542 debug_hexdump(stdout, "plaintext:", plaintext,
7543 tdata->plaintext.len);
7545 if (ut_params->obuf) {
7546 ciphertext = (uint8_t *)rte_pktmbuf_append(
7548 plaintext_pad_len + aad_pad_len);
7549 TEST_ASSERT_NOT_NULL(ciphertext,
7550 "no room to append ciphertext");
7552 memset(ciphertext + aad_pad_len, 0,
7553 tdata->ciphertext.len);
7556 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7557 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7559 TEST_ASSERT_NOT_NULL(ciphertext,
7560 "no room to append ciphertext");
7562 memcpy(ciphertext, tdata->ciphertext.data,
7563 tdata->ciphertext.len);
7564 debug_hexdump(stdout, "ciphertext:", ciphertext,
7565 tdata->ciphertext.len);
7567 if (ut_params->obuf) {
7568 plaintext = (uint8_t *)rte_pktmbuf_append(
7570 plaintext_pad_len + aad_pad_len);
7571 TEST_ASSERT_NOT_NULL(plaintext,
7572 "no room to append plaintext");
7574 memset(plaintext + aad_pad_len, 0,
7575 tdata->plaintext.len);
7579 /* Append digest data */
7580 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7581 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7582 ut_params->obuf ? ut_params->obuf :
7584 tdata->auth_tag.len);
7585 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7586 "no room to append digest");
7587 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7588 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7589 ut_params->obuf ? ut_params->obuf :
7594 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7595 ut_params->ibuf, tdata->auth_tag.len);
7596 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7597 "no room to append digest");
7598 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7600 plaintext_pad_len + aad_pad_len);
7602 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7603 tdata->auth_tag.len);
7604 debug_hexdump(stdout, "digest:",
7605 sym_op->aead.digest.data,
7606 tdata->auth_tag.len);
7609 sym_op->aead.data.length = tdata->plaintext.len;
7610 sym_op->aead.data.offset = aad_pad_len;
7616 test_authenticated_encryption(const struct aead_test_data *tdata)
7618 struct crypto_testsuite_params *ts_params = &testsuite_params;
7619 struct crypto_unittest_params *ut_params = &unittest_params;
7622 uint8_t *ciphertext, *auth_tag;
7623 uint16_t plaintext_pad_len;
7625 struct rte_cryptodev_info dev_info;
7627 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7628 uint64_t feat_flags = dev_info.feature_flags;
7630 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7631 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7632 printf("Device doesn't support RAW data-path APIs.\n");
7636 /* Verify the capabilities */
7637 struct rte_cryptodev_sym_capability_idx cap_idx;
7638 const struct rte_cryptodev_symmetric_capability *capability;
7639 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7640 cap_idx.algo.aead = tdata->algo;
7641 capability = rte_cryptodev_sym_capability_get(
7642 ts_params->valid_devs[0], &cap_idx);
7643 if (capability == NULL)
7645 if (rte_cryptodev_sym_capability_check_aead(
7646 capability, tdata->key.len, tdata->auth_tag.len,
7647 tdata->aad.len, tdata->iv.len))
7650 /* Create AEAD session */
7651 retval = create_aead_session(ts_params->valid_devs[0],
7653 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7654 tdata->key.data, tdata->key.len,
7655 tdata->aad.len, tdata->auth_tag.len,
7660 if (tdata->aad.len > MBUF_SIZE) {
7661 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7662 /* Populate full size of add data */
7663 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7664 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7666 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7668 /* clear mbuf payload */
7669 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7670 rte_pktmbuf_tailroom(ut_params->ibuf));
7672 /* Create AEAD operation */
7673 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7677 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7679 ut_params->op->sym->m_src = ut_params->ibuf;
7681 /* Process crypto operation */
7682 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7683 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7684 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7685 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
7686 ut_params->op, 0, 0, 0, 0);
7688 TEST_ASSERT_NOT_NULL(
7689 process_crypto_request(ts_params->valid_devs[0],
7690 ut_params->op), "failed to process sym crypto op");
7692 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7693 "crypto op processing failed");
7695 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7697 if (ut_params->op->sym->m_dst) {
7698 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7700 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7701 uint8_t *, plaintext_pad_len);
7703 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7705 ut_params->op->sym->cipher.data.offset);
7706 auth_tag = ciphertext + plaintext_pad_len;
7709 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7710 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7713 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7715 tdata->ciphertext.data,
7716 tdata->ciphertext.len,
7717 "Ciphertext data not as expected");
7719 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7721 tdata->auth_tag.data,
7722 tdata->auth_tag.len,
7723 "Generated auth tag not as expected");
7729 #ifdef RTE_LIB_SECURITY
7731 security_proto_supported(enum rte_security_session_action_type action,
7732 enum rte_security_session_protocol proto)
7734 struct crypto_testsuite_params *ts_params = &testsuite_params;
7736 const struct rte_security_capability *capabilities;
7737 const struct rte_security_capability *capability;
7740 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7741 rte_cryptodev_get_sec_ctx(
7742 ts_params->valid_devs[0]);
7745 capabilities = rte_security_capabilities_get(ctx);
7747 if (capabilities == NULL)
7750 while ((capability = &capabilities[i++])->action !=
7751 RTE_SECURITY_ACTION_TYPE_NONE) {
7752 if (capability->action == action &&
7753 capability->protocol == proto)
7760 /* Basic algorithm run function for async inplace mode.
7761 * Creates a session from input parameters and runs one operation
7762 * on input_vec. Checks the output of the crypto operation against
7765 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
7766 enum rte_crypto_auth_operation opa,
7767 const uint8_t *input_vec, unsigned int input_vec_len,
7768 const uint8_t *output_vec,
7769 unsigned int output_vec_len,
7770 enum rte_crypto_cipher_algorithm cipher_alg,
7771 const uint8_t *cipher_key, uint32_t cipher_key_len,
7772 enum rte_crypto_auth_algorithm auth_alg,
7773 const uint8_t *auth_key, uint32_t auth_key_len,
7774 uint8_t bearer, enum rte_security_pdcp_domain domain,
7775 uint8_t packet_direction, uint8_t sn_size,
7776 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
7778 struct crypto_testsuite_params *ts_params = &testsuite_params;
7779 struct crypto_unittest_params *ut_params = &unittest_params;
7781 int ret = TEST_SUCCESS;
7782 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7783 rte_cryptodev_get_sec_ctx(
7784 ts_params->valid_devs[0]);
7786 /* Verify the capabilities */
7787 struct rte_security_capability_idx sec_cap_idx;
7789 sec_cap_idx.action = ut_params->type;
7790 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7791 sec_cap_idx.pdcp.domain = domain;
7792 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7795 /* Generate test mbuf data */
7796 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7798 /* clear mbuf payload */
7799 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7800 rte_pktmbuf_tailroom(ut_params->ibuf));
7802 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7804 memcpy(plaintext, input_vec, input_vec_len);
7806 /* Out of place support */
7809 * For out-op-place we need to alloc another mbuf
7811 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7812 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7815 /* Setup Cipher Parameters */
7816 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7817 ut_params->cipher_xform.cipher.algo = cipher_alg;
7818 ut_params->cipher_xform.cipher.op = opc;
7819 ut_params->cipher_xform.cipher.key.data = cipher_key;
7820 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
7821 ut_params->cipher_xform.cipher.iv.length =
7822 packet_direction ? 4 : 0;
7823 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7825 /* Setup HMAC Parameters if ICV header is required */
7826 if (auth_alg != 0) {
7827 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7828 ut_params->auth_xform.next = NULL;
7829 ut_params->auth_xform.auth.algo = auth_alg;
7830 ut_params->auth_xform.auth.op = opa;
7831 ut_params->auth_xform.auth.key.data = auth_key;
7832 ut_params->auth_xform.auth.key.length = auth_key_len;
7834 ut_params->cipher_xform.next = &ut_params->auth_xform;
7836 ut_params->cipher_xform.next = NULL;
7839 struct rte_security_session_conf sess_conf = {
7840 .action_type = ut_params->type,
7841 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7845 .pkt_dir = packet_direction,
7847 .hfn = packet_direction ? 0 : hfn,
7849 * hfn can be set as pdcp_test_hfn[i]
7850 * if hfn_ovrd is not set. Here, PDCP
7851 * packet direction is just used to
7852 * run half of the cases with session
7853 * HFN and other half with per packet
7856 .hfn_threshold = hfn_threshold,
7857 .hfn_ovrd = packet_direction ? 1 : 0,
7858 .sdap_enabled = sdap,
7860 .crypto_xform = &ut_params->cipher_xform
7863 /* Create security session */
7864 ut_params->sec_session = rte_security_session_create(ctx,
7865 &sess_conf, ts_params->session_mpool,
7866 ts_params->session_priv_mpool);
7868 if (!ut_params->sec_session) {
7869 printf("TestCase %s()-%d line %d failed %s: ",
7870 __func__, i, __LINE__, "Failed to allocate session");
7875 /* Generate crypto op data structure */
7876 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7877 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7878 if (!ut_params->op) {
7879 printf("TestCase %s()-%d line %d failed %s: ",
7880 __func__, i, __LINE__,
7881 "Failed to allocate symmetric crypto operation struct");
7886 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7887 uint32_t *, IV_OFFSET);
7888 *per_pkt_hfn = packet_direction ? hfn : 0;
7890 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7892 /* set crypto operation source mbuf */
7893 ut_params->op->sym->m_src = ut_params->ibuf;
7895 ut_params->op->sym->m_dst = ut_params->obuf;
7897 /* Process crypto operation */
7898 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7900 printf("TestCase %s()-%d line %d failed %s: ",
7901 __func__, i, __LINE__,
7902 "failed to process sym crypto op");
7907 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7908 printf("TestCase %s()-%d line %d failed %s: ",
7909 __func__, i, __LINE__, "crypto op processing failed");
7915 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7918 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7922 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7923 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7924 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7925 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7931 rte_crypto_op_free(ut_params->op);
7932 ut_params->op = NULL;
7934 if (ut_params->sec_session)
7935 rte_security_session_destroy(ctx, ut_params->sec_session);
7936 ut_params->sec_session = NULL;
7938 rte_pktmbuf_free(ut_params->ibuf);
7939 ut_params->ibuf = NULL;
7941 rte_pktmbuf_free(ut_params->obuf);
7942 ut_params->obuf = NULL;
7949 test_pdcp_proto_SGL(int i, int oop,
7950 enum rte_crypto_cipher_operation opc,
7951 enum rte_crypto_auth_operation opa,
7953 unsigned int input_vec_len,
7954 uint8_t *output_vec,
7955 unsigned int output_vec_len,
7957 uint32_t fragsz_oop)
7959 struct crypto_testsuite_params *ts_params = &testsuite_params;
7960 struct crypto_unittest_params *ut_params = &unittest_params;
7962 struct rte_mbuf *buf, *buf_oop = NULL;
7963 int ret = TEST_SUCCESS;
7967 unsigned int trn_data = 0;
7968 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7969 rte_cryptodev_get_sec_ctx(
7970 ts_params->valid_devs[0]);
7972 /* Verify the capabilities */
7973 struct rte_security_capability_idx sec_cap_idx;
7975 sec_cap_idx.action = ut_params->type;
7976 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7977 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7978 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7981 if (fragsz > input_vec_len)
7982 fragsz = input_vec_len;
7984 uint16_t plaintext_len = fragsz;
7985 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7987 if (fragsz_oop > output_vec_len)
7988 frag_size_oop = output_vec_len;
7991 if (input_vec_len % fragsz != 0) {
7992 if (input_vec_len / fragsz + 1 > 16)
7994 } else if (input_vec_len / fragsz > 16)
7997 /* Out of place support */
8000 * For out-op-place we need to alloc another mbuf
8002 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8003 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8004 buf_oop = ut_params->obuf;
8007 /* Generate test mbuf data */
8008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8010 /* clear mbuf payload */
8011 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8012 rte_pktmbuf_tailroom(ut_params->ibuf));
8014 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8016 memcpy(plaintext, input_vec, plaintext_len);
8017 trn_data += plaintext_len;
8019 buf = ut_params->ibuf;
8022 * Loop until no more fragments
8025 while (trn_data < input_vec_len) {
8027 to_trn = (input_vec_len - trn_data < fragsz) ?
8028 (input_vec_len - trn_data) : fragsz;
8030 to_trn_tbl[ecx++] = to_trn;
8032 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8035 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8036 rte_pktmbuf_tailroom(buf));
8039 if (oop && !fragsz_oop) {
8041 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8042 buf_oop = buf_oop->next;
8043 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8044 0, rte_pktmbuf_tailroom(buf_oop));
8045 rte_pktmbuf_append(buf_oop, to_trn);
8048 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8051 memcpy(plaintext, input_vec + trn_data, to_trn);
8055 ut_params->ibuf->nb_segs = segs;
8058 if (fragsz_oop && oop) {
8062 trn_data = frag_size_oop;
8063 while (trn_data < output_vec_len) {
8066 (output_vec_len - trn_data <
8068 (output_vec_len - trn_data) :
8071 to_trn_tbl[ecx++] = to_trn;
8074 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8075 buf_oop = buf_oop->next;
8076 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8077 0, rte_pktmbuf_tailroom(buf_oop));
8078 rte_pktmbuf_append(buf_oop, to_trn);
8082 ut_params->obuf->nb_segs = segs;
8085 /* Setup Cipher Parameters */
8086 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8087 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8088 ut_params->cipher_xform.cipher.op = opc;
8089 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8090 ut_params->cipher_xform.cipher.key.length =
8091 pdcp_test_params[i].cipher_key_len;
8092 ut_params->cipher_xform.cipher.iv.length = 0;
8094 /* Setup HMAC Parameters if ICV header is required */
8095 if (pdcp_test_params[i].auth_alg != 0) {
8096 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8097 ut_params->auth_xform.next = NULL;
8098 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8099 ut_params->auth_xform.auth.op = opa;
8100 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8101 ut_params->auth_xform.auth.key.length =
8102 pdcp_test_params[i].auth_key_len;
8104 ut_params->cipher_xform.next = &ut_params->auth_xform;
8106 ut_params->cipher_xform.next = NULL;
8109 struct rte_security_session_conf sess_conf = {
8110 .action_type = ut_params->type,
8111 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8113 .bearer = pdcp_test_bearer[i],
8114 .domain = pdcp_test_params[i].domain,
8115 .pkt_dir = pdcp_test_packet_direction[i],
8116 .sn_size = pdcp_test_data_sn_size[i],
8117 .hfn = pdcp_test_hfn[i],
8118 .hfn_threshold = pdcp_test_hfn_threshold[i],
8121 .crypto_xform = &ut_params->cipher_xform
8124 /* Create security session */
8125 ut_params->sec_session = rte_security_session_create(ctx,
8126 &sess_conf, ts_params->session_mpool,
8127 ts_params->session_priv_mpool);
8129 if (!ut_params->sec_session) {
8130 printf("TestCase %s()-%d line %d failed %s: ",
8131 __func__, i, __LINE__, "Failed to allocate session");
8136 /* Generate crypto op data structure */
8137 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8138 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8139 if (!ut_params->op) {
8140 printf("TestCase %s()-%d line %d failed %s: ",
8141 __func__, i, __LINE__,
8142 "Failed to allocate symmetric crypto operation struct");
8147 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8149 /* set crypto operation source mbuf */
8150 ut_params->op->sym->m_src = ut_params->ibuf;
8152 ut_params->op->sym->m_dst = ut_params->obuf;
8154 /* Process crypto operation */
8155 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8157 printf("TestCase %s()-%d line %d failed %s: ",
8158 __func__, i, __LINE__,
8159 "failed to process sym crypto op");
8164 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8165 printf("TestCase %s()-%d line %d failed %s: ",
8166 __func__, i, __LINE__, "crypto op processing failed");
8172 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8175 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8179 fragsz = frag_size_oop;
8180 if (memcmp(ciphertext, output_vec, fragsz)) {
8181 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8182 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8183 rte_hexdump(stdout, "reference", output_vec, fragsz);
8188 buf = ut_params->op->sym->m_src->next;
8190 buf = ut_params->op->sym->m_dst->next;
8192 unsigned int off = fragsz;
8196 ciphertext = rte_pktmbuf_mtod(buf,
8198 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8199 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8200 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8201 rte_hexdump(stdout, "reference", output_vec + off,
8206 off += to_trn_tbl[ecx++];
8210 rte_crypto_op_free(ut_params->op);
8211 ut_params->op = NULL;
8213 if (ut_params->sec_session)
8214 rte_security_session_destroy(ctx, ut_params->sec_session);
8215 ut_params->sec_session = NULL;
8217 rte_pktmbuf_free(ut_params->ibuf);
8218 ut_params->ibuf = NULL;
8220 rte_pktmbuf_free(ut_params->obuf);
8221 ut_params->obuf = NULL;
8228 test_pdcp_proto_cplane_encap(int i)
8230 return test_pdcp_proto(
8231 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8232 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8233 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8234 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8235 pdcp_test_params[i].cipher_key_len,
8236 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8237 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8238 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8239 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8240 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8244 test_pdcp_proto_uplane_encap(int i)
8246 return test_pdcp_proto(
8247 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8248 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8249 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8250 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8251 pdcp_test_params[i].cipher_key_len,
8252 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8253 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8254 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8255 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8256 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8260 test_pdcp_proto_uplane_encap_with_int(int i)
8262 return test_pdcp_proto(
8263 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8264 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8265 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8266 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8267 pdcp_test_params[i].cipher_key_len,
8268 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8269 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8270 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8271 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8272 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8276 test_pdcp_proto_cplane_decap(int i)
8278 return test_pdcp_proto(
8279 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8280 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8281 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8282 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8283 pdcp_test_params[i].cipher_key_len,
8284 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8285 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8286 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8287 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8288 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8292 test_pdcp_proto_uplane_decap(int i)
8294 return test_pdcp_proto(
8295 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8296 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8297 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8298 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8299 pdcp_test_params[i].cipher_key_len,
8300 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8301 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8302 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8303 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8304 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8308 test_pdcp_proto_uplane_decap_with_int(int i)
8310 return test_pdcp_proto(
8311 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8312 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8313 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8314 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8315 pdcp_test_params[i].cipher_key_len,
8316 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8317 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8318 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8319 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8320 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8324 test_PDCP_PROTO_SGL_in_place_32B(void)
8326 /* i can be used for running any PDCP case
8327 * In this case it is uplane 12-bit AES-SNOW DL encap
8329 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8330 return test_pdcp_proto_SGL(i, IN_PLACE,
8331 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8332 RTE_CRYPTO_AUTH_OP_GENERATE,
8333 pdcp_test_data_in[i],
8334 pdcp_test_data_in_len[i],
8335 pdcp_test_data_out[i],
8336 pdcp_test_data_in_len[i]+4,
8340 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8342 /* i can be used for running any PDCP case
8343 * In this case it is uplane 18-bit NULL-NULL DL encap
8345 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8346 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8347 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8348 RTE_CRYPTO_AUTH_OP_GENERATE,
8349 pdcp_test_data_in[i],
8350 pdcp_test_data_in_len[i],
8351 pdcp_test_data_out[i],
8352 pdcp_test_data_in_len[i]+4,
8356 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8358 /* i can be used for running any PDCP case
8359 * In this case it is uplane 18-bit AES DL encap
8361 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8363 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8364 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8365 RTE_CRYPTO_AUTH_OP_GENERATE,
8366 pdcp_test_data_in[i],
8367 pdcp_test_data_in_len[i],
8368 pdcp_test_data_out[i],
8369 pdcp_test_data_in_len[i],
8373 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8375 /* i can be used for running any PDCP case
8376 * In this case it is cplane 12-bit AES-ZUC DL encap
8378 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8379 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8380 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8381 RTE_CRYPTO_AUTH_OP_GENERATE,
8382 pdcp_test_data_in[i],
8383 pdcp_test_data_in_len[i],
8384 pdcp_test_data_out[i],
8385 pdcp_test_data_in_len[i]+4,
8390 test_PDCP_SDAP_PROTO_encap_all(void)
8392 int i = 0, size = 0;
8393 int err, all_err = TEST_SUCCESS;
8394 const struct pdcp_sdap_test *cur_test;
8396 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8398 for (i = 0; i < size; i++) {
8399 cur_test = &list_pdcp_sdap_tests[i];
8400 err = test_pdcp_proto(
8401 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8402 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8403 cur_test->in_len, cur_test->data_out,
8404 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8405 cur_test->param.cipher_alg, cur_test->cipher_key,
8406 cur_test->param.cipher_key_len,
8407 cur_test->param.auth_alg,
8408 cur_test->auth_key, cur_test->param.auth_key_len,
8409 cur_test->bearer, cur_test->param.domain,
8410 cur_test->packet_direction, cur_test->sn_size,
8412 cur_test->hfn_threshold, SDAP_ENABLED);
8414 printf("\t%d) %s: Encapsulation failed\n",
8416 cur_test->param.name);
8419 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8420 cur_test->param.name);
8426 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8428 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8432 test_PDCP_SDAP_PROTO_decap_all(void)
8434 int i = 0, size = 0;
8435 int err, all_err = TEST_SUCCESS;
8436 const struct pdcp_sdap_test *cur_test;
8438 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8440 for (i = 0; i < size; i++) {
8441 cur_test = &list_pdcp_sdap_tests[i];
8442 err = test_pdcp_proto(
8443 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8444 RTE_CRYPTO_AUTH_OP_VERIFY,
8446 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8447 cur_test->data_in, cur_test->in_len,
8448 cur_test->param.cipher_alg,
8449 cur_test->cipher_key, cur_test->param.cipher_key_len,
8450 cur_test->param.auth_alg, cur_test->auth_key,
8451 cur_test->param.auth_key_len, cur_test->bearer,
8452 cur_test->param.domain, cur_test->packet_direction,
8453 cur_test->sn_size, cur_test->hfn,
8454 cur_test->hfn_threshold, SDAP_ENABLED);
8456 printf("\t%d) %s: Decapsulation failed\n",
8458 cur_test->param.name);
8461 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8462 cur_test->param.name);
8468 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8470 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8474 test_PDCP_PROTO_all(void)
8476 struct crypto_testsuite_params *ts_params = &testsuite_params;
8477 struct crypto_unittest_params *ut_params = &unittest_params;
8478 struct rte_cryptodev_info dev_info;
8481 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8482 uint64_t feat_flags = dev_info.feature_flags;
8484 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8487 /* Set action type */
8488 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8489 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8492 if (security_proto_supported(ut_params->type,
8493 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8496 status = test_PDCP_PROTO_cplane_encap_all();
8497 status += test_PDCP_PROTO_cplane_decap_all();
8498 status += test_PDCP_PROTO_uplane_encap_all();
8499 status += test_PDCP_PROTO_uplane_decap_all();
8500 status += test_PDCP_PROTO_SGL_in_place_32B();
8501 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8502 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8503 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8504 status += test_PDCP_SDAP_PROTO_encap_all();
8505 status += test_PDCP_SDAP_PROTO_decap_all();
8510 return TEST_SUCCESS;
8514 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8516 struct crypto_testsuite_params *ts_params = &testsuite_params;
8517 struct crypto_unittest_params *ut_params = &unittest_params;
8518 uint8_t *plaintext, *ciphertext;
8520 int32_t cipher_len, crc_len;
8521 uint32_t crc_data_len;
8522 int ret = TEST_SUCCESS;
8524 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8525 rte_cryptodev_get_sec_ctx(
8526 ts_params->valid_devs[0]);
8528 /* Verify the capabilities */
8529 struct rte_security_capability_idx sec_cap_idx;
8530 const struct rte_security_capability *sec_cap;
8531 const struct rte_cryptodev_capabilities *crypto_cap;
8532 const struct rte_cryptodev_symmetric_capability *sym_cap;
8535 sec_cap_idx.action = ut_params->type;
8536 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8537 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8539 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8540 if (sec_cap == NULL)
8543 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8544 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8545 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8546 crypto_cap->sym.xform_type ==
8547 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8548 crypto_cap->sym.cipher.algo ==
8549 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8550 sym_cap = &crypto_cap->sym;
8551 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8558 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8561 /* Setup source mbuf payload */
8562 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8563 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8564 rte_pktmbuf_tailroom(ut_params->ibuf));
8566 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8567 d_td->ciphertext.len);
8569 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8571 /* Setup cipher session parameters */
8572 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8573 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8574 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8575 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8576 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8577 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8578 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8579 ut_params->cipher_xform.next = NULL;
8581 /* Setup DOCSIS session parameters */
8582 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8584 struct rte_security_session_conf sess_conf = {
8585 .action_type = ut_params->type,
8586 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8587 .docsis = ut_params->docsis_xform,
8588 .crypto_xform = &ut_params->cipher_xform,
8591 /* Create security session */
8592 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8593 ts_params->session_mpool,
8594 ts_params->session_priv_mpool);
8596 if (!ut_params->sec_session) {
8597 printf("TestCase %s(%d) line %d: %s\n",
8598 __func__, i, __LINE__, "failed to allocate session");
8603 /* Generate crypto op data structure */
8604 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8605 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8606 if (!ut_params->op) {
8607 printf("TestCase %s(%d) line %d: %s\n",
8608 __func__, i, __LINE__,
8609 "failed to allocate symmetric crypto operation");
8614 /* Setup CRC operation parameters */
8615 crc_len = d_td->ciphertext.no_crc == false ?
8616 (d_td->ciphertext.len -
8617 d_td->ciphertext.crc_offset -
8618 RTE_ETHER_CRC_LEN) :
8620 crc_len = crc_len > 0 ? crc_len : 0;
8621 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8622 ut_params->op->sym->auth.data.length = crc_len;
8623 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8625 /* Setup cipher operation parameters */
8626 cipher_len = d_td->ciphertext.no_cipher == false ?
8627 (d_td->ciphertext.len -
8628 d_td->ciphertext.cipher_offset) :
8630 cipher_len = cipher_len > 0 ? cipher_len : 0;
8631 ut_params->op->sym->cipher.data.length = cipher_len;
8632 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8634 /* Setup cipher IV */
8635 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8636 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8638 /* Attach session to operation */
8639 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8641 /* Set crypto operation mbufs */
8642 ut_params->op->sym->m_src = ut_params->ibuf;
8643 ut_params->op->sym->m_dst = NULL;
8645 /* Process crypto operation */
8646 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8648 printf("TestCase %s(%d) line %d: %s\n",
8649 __func__, i, __LINE__,
8650 "failed to process security crypto op");
8655 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8656 printf("TestCase %s(%d) line %d: %s\n",
8657 __func__, i, __LINE__, "crypto op processing failed");
8662 /* Validate plaintext */
8663 plaintext = ciphertext;
8665 if (memcmp(plaintext, d_td->plaintext.data,
8666 d_td->plaintext.len - crc_data_len)) {
8667 printf("TestCase %s(%d) line %d: %s\n",
8668 __func__, i, __LINE__, "plaintext not as expected\n");
8669 rte_hexdump(stdout, "expected", d_td->plaintext.data,
8670 d_td->plaintext.len);
8671 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
8677 rte_crypto_op_free(ut_params->op);
8678 ut_params->op = NULL;
8680 if (ut_params->sec_session)
8681 rte_security_session_destroy(ctx, ut_params->sec_session);
8682 ut_params->sec_session = NULL;
8684 rte_pktmbuf_free(ut_params->ibuf);
8685 ut_params->ibuf = NULL;
8691 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
8693 struct crypto_testsuite_params *ts_params = &testsuite_params;
8694 struct crypto_unittest_params *ut_params = &unittest_params;
8695 uint8_t *plaintext, *ciphertext;
8697 int32_t cipher_len, crc_len;
8698 int ret = TEST_SUCCESS;
8700 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8701 rte_cryptodev_get_sec_ctx(
8702 ts_params->valid_devs[0]);
8704 /* Verify the capabilities */
8705 struct rte_security_capability_idx sec_cap_idx;
8706 const struct rte_security_capability *sec_cap;
8707 const struct rte_cryptodev_capabilities *crypto_cap;
8708 const struct rte_cryptodev_symmetric_capability *sym_cap;
8711 sec_cap_idx.action = ut_params->type;
8712 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8713 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8715 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8716 if (sec_cap == NULL)
8719 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8720 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8721 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8722 crypto_cap->sym.xform_type ==
8723 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8724 crypto_cap->sym.cipher.algo ==
8725 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8726 sym_cap = &crypto_cap->sym;
8727 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8734 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8737 /* Setup source mbuf payload */
8738 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8739 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8740 rte_pktmbuf_tailroom(ut_params->ibuf));
8742 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8743 d_td->plaintext.len);
8745 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
8747 /* Setup cipher session parameters */
8748 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8749 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8750 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8751 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8752 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8753 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8754 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8755 ut_params->cipher_xform.next = NULL;
8757 /* Setup DOCSIS session parameters */
8758 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8760 struct rte_security_session_conf sess_conf = {
8761 .action_type = ut_params->type,
8762 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8763 .docsis = ut_params->docsis_xform,
8764 .crypto_xform = &ut_params->cipher_xform,
8767 /* Create security session */
8768 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8769 ts_params->session_mpool,
8770 ts_params->session_priv_mpool);
8772 if (!ut_params->sec_session) {
8773 printf("TestCase %s(%d) line %d: %s\n",
8774 __func__, i, __LINE__, "failed to allocate session");
8779 /* Generate crypto op data structure */
8780 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8781 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8782 if (!ut_params->op) {
8783 printf("TestCase %s(%d) line %d: %s\n",
8784 __func__, i, __LINE__,
8785 "failed to allocate security crypto operation");
8790 /* Setup CRC operation parameters */
8791 crc_len = d_td->plaintext.no_crc == false ?
8792 (d_td->plaintext.len -
8793 d_td->plaintext.crc_offset -
8794 RTE_ETHER_CRC_LEN) :
8796 crc_len = crc_len > 0 ? crc_len : 0;
8797 ut_params->op->sym->auth.data.length = crc_len;
8798 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8800 /* Setup cipher operation parameters */
8801 cipher_len = d_td->plaintext.no_cipher == false ?
8802 (d_td->plaintext.len -
8803 d_td->plaintext.cipher_offset) :
8805 cipher_len = cipher_len > 0 ? cipher_len : 0;
8806 ut_params->op->sym->cipher.data.length = cipher_len;
8807 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8809 /* Setup cipher IV */
8810 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8811 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8813 /* Attach session to operation */
8814 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8816 /* Set crypto operation mbufs */
8817 ut_params->op->sym->m_src = ut_params->ibuf;
8818 ut_params->op->sym->m_dst = NULL;
8820 /* Process crypto operation */
8821 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8823 printf("TestCase %s(%d) line %d: %s\n",
8824 __func__, i, __LINE__,
8825 "failed to process security crypto op");
8830 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8831 printf("TestCase %s(%d) line %d: %s\n",
8832 __func__, i, __LINE__, "crypto op processing failed");
8837 /* Validate ciphertext */
8838 ciphertext = plaintext;
8840 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8841 printf("TestCase %s(%d) line %d: %s\n",
8842 __func__, i, __LINE__, "ciphertext not as expected\n");
8843 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8844 d_td->ciphertext.len);
8845 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8851 rte_crypto_op_free(ut_params->op);
8852 ut_params->op = NULL;
8854 if (ut_params->sec_session)
8855 rte_security_session_destroy(ctx, ut_params->sec_session);
8856 ut_params->sec_session = NULL;
8858 rte_pktmbuf_free(ut_params->ibuf);
8859 ut_params->ibuf = NULL;
8864 #define TEST_DOCSIS_COUNT(func) do { \
8866 if (ret == TEST_SUCCESS) { \
8867 printf("\t%2d)", n++); \
8868 printf("+++++ PASSED:" #func"\n"); \
8870 } else if (ret == -ENOTSUP) { \
8871 printf("\t%2d)", n++); \
8872 printf("~~~~~ UNSUPP:" #func"\n"); \
8875 printf("\t%2d)", n++); \
8876 printf("----- FAILED:" #func"\n"); \
8882 test_DOCSIS_PROTO_uplink_all(void)
8884 int p = 0, u = 0, f = 0, n = 0;
8886 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8887 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8888 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8889 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8890 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8891 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8892 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8893 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8894 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8895 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8896 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8897 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8898 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8899 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8900 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8901 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8902 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8903 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8904 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8905 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8906 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8907 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8908 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8909 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8910 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8911 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8914 printf("## %s: %d passed out of %d (%d unsupported)\n",
8921 test_DOCSIS_PROTO_downlink_all(void)
8923 int p = 0, u = 0, f = 0, n = 0;
8925 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8926 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8927 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8928 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8929 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8930 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8931 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8932 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8933 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8934 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8935 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8936 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8937 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8938 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8939 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8940 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8941 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8942 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8943 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8944 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8945 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8946 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8947 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8948 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8949 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8950 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8953 printf("## %s: %d passed out of %d (%d unsupported)\n",
8960 test_DOCSIS_PROTO_all(void)
8962 struct crypto_testsuite_params *ts_params = &testsuite_params;
8963 struct crypto_unittest_params *ut_params = &unittest_params;
8964 struct rte_cryptodev_info dev_info;
8967 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8968 uint64_t feat_flags = dev_info.feature_flags;
8970 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8973 /* Set action type */
8974 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8975 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8978 if (security_proto_supported(ut_params->type,
8979 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8982 status = test_DOCSIS_PROTO_uplink_all();
8983 status += test_DOCSIS_PROTO_downlink_all();
8988 return TEST_SUCCESS;
8993 test_AES_GCM_authenticated_encryption_test_case_1(void)
8995 return test_authenticated_encryption(&gcm_test_case_1);
8999 test_AES_GCM_authenticated_encryption_test_case_2(void)
9001 return test_authenticated_encryption(&gcm_test_case_2);
9005 test_AES_GCM_authenticated_encryption_test_case_3(void)
9007 return test_authenticated_encryption(&gcm_test_case_3);
9011 test_AES_GCM_authenticated_encryption_test_case_4(void)
9013 return test_authenticated_encryption(&gcm_test_case_4);
9017 test_AES_GCM_authenticated_encryption_test_case_5(void)
9019 return test_authenticated_encryption(&gcm_test_case_5);
9023 test_AES_GCM_authenticated_encryption_test_case_6(void)
9025 return test_authenticated_encryption(&gcm_test_case_6);
9029 test_AES_GCM_authenticated_encryption_test_case_7(void)
9031 return test_authenticated_encryption(&gcm_test_case_7);
9035 test_AES_GCM_authenticated_encryption_test_case_8(void)
9037 return test_authenticated_encryption(&gcm_test_case_8);
9041 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9043 return test_authenticated_encryption(&gcm_J0_test_case_1);
9047 test_AES_GCM_auth_encryption_test_case_192_1(void)
9049 return test_authenticated_encryption(&gcm_test_case_192_1);
9053 test_AES_GCM_auth_encryption_test_case_192_2(void)
9055 return test_authenticated_encryption(&gcm_test_case_192_2);
9059 test_AES_GCM_auth_encryption_test_case_192_3(void)
9061 return test_authenticated_encryption(&gcm_test_case_192_3);
9065 test_AES_GCM_auth_encryption_test_case_192_4(void)
9067 return test_authenticated_encryption(&gcm_test_case_192_4);
9071 test_AES_GCM_auth_encryption_test_case_192_5(void)
9073 return test_authenticated_encryption(&gcm_test_case_192_5);
9077 test_AES_GCM_auth_encryption_test_case_192_6(void)
9079 return test_authenticated_encryption(&gcm_test_case_192_6);
9083 test_AES_GCM_auth_encryption_test_case_192_7(void)
9085 return test_authenticated_encryption(&gcm_test_case_192_7);
9089 test_AES_GCM_auth_encryption_test_case_256_1(void)
9091 return test_authenticated_encryption(&gcm_test_case_256_1);
9095 test_AES_GCM_auth_encryption_test_case_256_2(void)
9097 return test_authenticated_encryption(&gcm_test_case_256_2);
9101 test_AES_GCM_auth_encryption_test_case_256_3(void)
9103 return test_authenticated_encryption(&gcm_test_case_256_3);
9107 test_AES_GCM_auth_encryption_test_case_256_4(void)
9109 return test_authenticated_encryption(&gcm_test_case_256_4);
9113 test_AES_GCM_auth_encryption_test_case_256_5(void)
9115 return test_authenticated_encryption(&gcm_test_case_256_5);
9119 test_AES_GCM_auth_encryption_test_case_256_6(void)
9121 return test_authenticated_encryption(&gcm_test_case_256_6);
9125 test_AES_GCM_auth_encryption_test_case_256_7(void)
9127 return test_authenticated_encryption(&gcm_test_case_256_7);
9131 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9133 return test_authenticated_encryption(&gcm_test_case_aad_1);
9137 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9139 return test_authenticated_encryption(&gcm_test_case_aad_2);
9143 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9145 struct aead_test_data tdata;
9148 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9149 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9150 tdata.iv.data[0] += 1;
9151 res = test_authenticated_encryption(&tdata);
9152 if (res == -ENOTSUP)
9154 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9155 return TEST_SUCCESS;
9159 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9161 struct aead_test_data tdata;
9164 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9165 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9166 tdata.plaintext.data[0] += 1;
9167 res = test_authenticated_encryption(&tdata);
9168 if (res == -ENOTSUP)
9170 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9171 return TEST_SUCCESS;
9175 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9177 struct aead_test_data tdata;
9180 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9181 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9182 tdata.ciphertext.data[0] += 1;
9183 res = test_authenticated_encryption(&tdata);
9184 if (res == -ENOTSUP)
9186 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9187 return TEST_SUCCESS;
9191 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9193 struct aead_test_data tdata;
9196 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9197 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9199 res = test_authenticated_encryption(&tdata);
9200 if (res == -ENOTSUP)
9202 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9203 return TEST_SUCCESS;
9207 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9209 struct aead_test_data tdata;
9210 uint8_t aad[gcm_test_case_7.aad.len];
9213 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9214 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9215 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9217 tdata.aad.data = aad;
9218 res = test_authenticated_encryption(&tdata);
9219 if (res == -ENOTSUP)
9221 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9222 return TEST_SUCCESS;
9226 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9228 struct aead_test_data tdata;
9231 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9232 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9233 tdata.auth_tag.data[0] += 1;
9234 res = test_authenticated_encryption(&tdata);
9235 if (res == -ENOTSUP)
9237 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9238 return TEST_SUCCESS;
9242 test_authenticated_decryption(const struct aead_test_data *tdata)
9244 struct crypto_testsuite_params *ts_params = &testsuite_params;
9245 struct crypto_unittest_params *ut_params = &unittest_params;
9250 struct rte_cryptodev_info dev_info;
9252 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9253 uint64_t feat_flags = dev_info.feature_flags;
9255 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9256 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9257 printf("Device doesn't support RAW data-path APIs.\n");
9261 /* Verify the capabilities */
9262 struct rte_cryptodev_sym_capability_idx cap_idx;
9263 const struct rte_cryptodev_symmetric_capability *capability;
9264 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9265 cap_idx.algo.aead = tdata->algo;
9266 capability = rte_cryptodev_sym_capability_get(
9267 ts_params->valid_devs[0], &cap_idx);
9268 if (capability == NULL)
9270 if (rte_cryptodev_sym_capability_check_aead(
9271 capability, tdata->key.len, tdata->auth_tag.len,
9272 tdata->aad.len, tdata->iv.len))
9275 /* Create AEAD session */
9276 retval = create_aead_session(ts_params->valid_devs[0],
9278 RTE_CRYPTO_AEAD_OP_DECRYPT,
9279 tdata->key.data, tdata->key.len,
9280 tdata->aad.len, tdata->auth_tag.len,
9285 /* alloc mbuf and set payload */
9286 if (tdata->aad.len > MBUF_SIZE) {
9287 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9288 /* Populate full size of add data */
9289 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9290 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9292 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9295 rte_pktmbuf_tailroom(ut_params->ibuf));
9297 /* Create AEAD operation */
9298 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9302 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9304 ut_params->op->sym->m_src = ut_params->ibuf;
9306 /* Process crypto operation */
9307 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9308 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9309 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9310 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9311 ut_params->op, 0, 0, 0, 0);
9313 TEST_ASSERT_NOT_NULL(
9314 process_crypto_request(ts_params->valid_devs[0],
9315 ut_params->op), "failed to process sym crypto op");
9317 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9318 "crypto op processing failed");
9320 if (ut_params->op->sym->m_dst)
9321 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9324 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9326 ut_params->op->sym->cipher.data.offset);
9328 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9331 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9333 tdata->plaintext.data,
9334 tdata->plaintext.len,
9335 "Plaintext data not as expected");
9337 TEST_ASSERT_EQUAL(ut_params->op->status,
9338 RTE_CRYPTO_OP_STATUS_SUCCESS,
9339 "Authentication failed");
9345 test_AES_GCM_authenticated_decryption_test_case_1(void)
9347 return test_authenticated_decryption(&gcm_test_case_1);
9351 test_AES_GCM_authenticated_decryption_test_case_2(void)
9353 return test_authenticated_decryption(&gcm_test_case_2);
9357 test_AES_GCM_authenticated_decryption_test_case_3(void)
9359 return test_authenticated_decryption(&gcm_test_case_3);
9363 test_AES_GCM_authenticated_decryption_test_case_4(void)
9365 return test_authenticated_decryption(&gcm_test_case_4);
9369 test_AES_GCM_authenticated_decryption_test_case_5(void)
9371 return test_authenticated_decryption(&gcm_test_case_5);
9375 test_AES_GCM_authenticated_decryption_test_case_6(void)
9377 return test_authenticated_decryption(&gcm_test_case_6);
9381 test_AES_GCM_authenticated_decryption_test_case_7(void)
9383 return test_authenticated_decryption(&gcm_test_case_7);
9387 test_AES_GCM_authenticated_decryption_test_case_8(void)
9389 return test_authenticated_decryption(&gcm_test_case_8);
9393 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9395 return test_authenticated_decryption(&gcm_J0_test_case_1);
9399 test_AES_GCM_auth_decryption_test_case_192_1(void)
9401 return test_authenticated_decryption(&gcm_test_case_192_1);
9405 test_AES_GCM_auth_decryption_test_case_192_2(void)
9407 return test_authenticated_decryption(&gcm_test_case_192_2);
9411 test_AES_GCM_auth_decryption_test_case_192_3(void)
9413 return test_authenticated_decryption(&gcm_test_case_192_3);
9417 test_AES_GCM_auth_decryption_test_case_192_4(void)
9419 return test_authenticated_decryption(&gcm_test_case_192_4);
9423 test_AES_GCM_auth_decryption_test_case_192_5(void)
9425 return test_authenticated_decryption(&gcm_test_case_192_5);
9429 test_AES_GCM_auth_decryption_test_case_192_6(void)
9431 return test_authenticated_decryption(&gcm_test_case_192_6);
9435 test_AES_GCM_auth_decryption_test_case_192_7(void)
9437 return test_authenticated_decryption(&gcm_test_case_192_7);
9441 test_AES_GCM_auth_decryption_test_case_256_1(void)
9443 return test_authenticated_decryption(&gcm_test_case_256_1);
9447 test_AES_GCM_auth_decryption_test_case_256_2(void)
9449 return test_authenticated_decryption(&gcm_test_case_256_2);
9453 test_AES_GCM_auth_decryption_test_case_256_3(void)
9455 return test_authenticated_decryption(&gcm_test_case_256_3);
9459 test_AES_GCM_auth_decryption_test_case_256_4(void)
9461 return test_authenticated_decryption(&gcm_test_case_256_4);
9465 test_AES_GCM_auth_decryption_test_case_256_5(void)
9467 return test_authenticated_decryption(&gcm_test_case_256_5);
9471 test_AES_GCM_auth_decryption_test_case_256_6(void)
9473 return test_authenticated_decryption(&gcm_test_case_256_6);
9477 test_AES_GCM_auth_decryption_test_case_256_7(void)
9479 return test_authenticated_decryption(&gcm_test_case_256_7);
9483 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9485 return test_authenticated_decryption(&gcm_test_case_aad_1);
9489 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9491 return test_authenticated_decryption(&gcm_test_case_aad_2);
9495 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9497 struct aead_test_data tdata;
9500 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9501 tdata.iv.data[0] += 1;
9502 res = test_authenticated_decryption(&tdata);
9503 if (res == -ENOTSUP)
9505 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9506 return TEST_SUCCESS;
9510 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9512 struct aead_test_data tdata;
9515 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9516 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9517 tdata.plaintext.data[0] += 1;
9518 res = test_authenticated_decryption(&tdata);
9519 if (res == -ENOTSUP)
9521 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9522 return TEST_SUCCESS;
9526 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9528 struct aead_test_data tdata;
9531 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9532 tdata.ciphertext.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_aad_len_corrupt(void)
9543 struct aead_test_data tdata;
9546 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
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_corrupt(void)
9558 struct aead_test_data tdata;
9559 uint8_t aad[gcm_test_case_7.aad.len];
9562 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9563 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9565 tdata.aad.data = aad;
9566 res = test_authenticated_decryption(&tdata);
9567 if (res == -ENOTSUP)
9569 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9570 return TEST_SUCCESS;
9574 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9576 struct aead_test_data tdata;
9579 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9580 tdata.auth_tag.data[0] += 1;
9581 res = test_authenticated_decryption(&tdata);
9582 if (res == -ENOTSUP)
9584 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9585 return TEST_SUCCESS;
9589 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9591 struct crypto_testsuite_params *ts_params = &testsuite_params;
9592 struct crypto_unittest_params *ut_params = &unittest_params;
9595 uint8_t *ciphertext, *auth_tag;
9596 uint16_t plaintext_pad_len;
9598 /* Verify the capabilities */
9599 struct rte_cryptodev_sym_capability_idx cap_idx;
9600 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9601 cap_idx.algo.aead = tdata->algo;
9602 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9606 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9609 /* not supported with CPU crypto */
9610 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9613 /* Create AEAD session */
9614 retval = create_aead_session(ts_params->valid_devs[0],
9616 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9617 tdata->key.data, tdata->key.len,
9618 tdata->aad.len, tdata->auth_tag.len,
9623 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9624 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9626 /* clear mbuf payload */
9627 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9628 rte_pktmbuf_tailroom(ut_params->ibuf));
9629 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9630 rte_pktmbuf_tailroom(ut_params->obuf));
9632 /* Create AEAD operation */
9633 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9637 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9639 ut_params->op->sym->m_src = ut_params->ibuf;
9640 ut_params->op->sym->m_dst = ut_params->obuf;
9642 /* Process crypto operation */
9643 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9644 ut_params->op), "failed to process sym crypto op");
9646 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9647 "crypto op processing failed");
9649 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9651 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9652 ut_params->op->sym->cipher.data.offset);
9653 auth_tag = ciphertext + plaintext_pad_len;
9655 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9656 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9659 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9661 tdata->ciphertext.data,
9662 tdata->ciphertext.len,
9663 "Ciphertext data not as expected");
9665 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9667 tdata->auth_tag.data,
9668 tdata->auth_tag.len,
9669 "Generated auth tag not as expected");
9676 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9678 return test_authenticated_encryption_oop(&gcm_test_case_5);
9682 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9684 struct crypto_testsuite_params *ts_params = &testsuite_params;
9685 struct crypto_unittest_params *ut_params = &unittest_params;
9690 /* Verify the capabilities */
9691 struct rte_cryptodev_sym_capability_idx cap_idx;
9692 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9693 cap_idx.algo.aead = tdata->algo;
9694 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9698 /* not supported with CPU crypto and raw data-path APIs*/
9699 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
9700 global_api_test_type == CRYPTODEV_RAW_API_TEST)
9703 /* Create AEAD session */
9704 retval = create_aead_session(ts_params->valid_devs[0],
9706 RTE_CRYPTO_AEAD_OP_DECRYPT,
9707 tdata->key.data, tdata->key.len,
9708 tdata->aad.len, tdata->auth_tag.len,
9713 /* alloc mbuf and set payload */
9714 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9715 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9717 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9718 rte_pktmbuf_tailroom(ut_params->ibuf));
9719 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9720 rte_pktmbuf_tailroom(ut_params->obuf));
9722 /* Create AEAD operation */
9723 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9727 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9729 ut_params->op->sym->m_src = ut_params->ibuf;
9730 ut_params->op->sym->m_dst = ut_params->obuf;
9732 /* Process crypto operation */
9733 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9734 ut_params->op), "failed to process sym crypto op");
9736 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9737 "crypto op processing failed");
9739 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9740 ut_params->op->sym->cipher.data.offset);
9742 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9745 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9747 tdata->plaintext.data,
9748 tdata->plaintext.len,
9749 "Plaintext data not as expected");
9751 TEST_ASSERT_EQUAL(ut_params->op->status,
9752 RTE_CRYPTO_OP_STATUS_SUCCESS,
9753 "Authentication failed");
9758 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9760 return test_authenticated_decryption_oop(&gcm_test_case_5);
9764 test_authenticated_encryption_sessionless(
9765 const struct aead_test_data *tdata)
9767 struct crypto_testsuite_params *ts_params = &testsuite_params;
9768 struct crypto_unittest_params *ut_params = &unittest_params;
9771 uint8_t *ciphertext, *auth_tag;
9772 uint16_t plaintext_pad_len;
9773 uint8_t key[tdata->key.len + 1];
9774 struct rte_cryptodev_info dev_info;
9776 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9777 uint64_t feat_flags = dev_info.feature_flags;
9779 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9780 printf("Device doesn't support Sessionless ops.\n");
9784 /* not supported with CPU crypto */
9785 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9788 /* Verify the capabilities */
9789 struct rte_cryptodev_sym_capability_idx cap_idx;
9790 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9791 cap_idx.algo.aead = tdata->algo;
9792 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9796 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9798 /* clear mbuf payload */
9799 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9800 rte_pktmbuf_tailroom(ut_params->ibuf));
9802 /* Create AEAD operation */
9803 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9807 /* Create GCM xform */
9808 memcpy(key, tdata->key.data, tdata->key.len);
9809 retval = create_aead_xform(ut_params->op,
9811 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9812 key, tdata->key.len,
9813 tdata->aad.len, tdata->auth_tag.len,
9818 ut_params->op->sym->m_src = ut_params->ibuf;
9820 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9821 RTE_CRYPTO_OP_SESSIONLESS,
9822 "crypto op session type not sessionless");
9824 /* Process crypto operation */
9825 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9826 ut_params->op), "failed to process sym crypto op");
9828 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9830 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9831 "crypto op status not success");
9833 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9835 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9836 ut_params->op->sym->cipher.data.offset);
9837 auth_tag = ciphertext + plaintext_pad_len;
9839 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9840 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9843 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9845 tdata->ciphertext.data,
9846 tdata->ciphertext.len,
9847 "Ciphertext data not as expected");
9849 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9851 tdata->auth_tag.data,
9852 tdata->auth_tag.len,
9853 "Generated auth tag not as expected");
9860 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9862 return test_authenticated_encryption_sessionless(
9867 test_authenticated_decryption_sessionless(
9868 const struct aead_test_data *tdata)
9870 struct crypto_testsuite_params *ts_params = &testsuite_params;
9871 struct crypto_unittest_params *ut_params = &unittest_params;
9875 uint8_t key[tdata->key.len + 1];
9876 struct rte_cryptodev_info dev_info;
9878 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9879 uint64_t feat_flags = dev_info.feature_flags;
9881 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9882 printf("Device doesn't support Sessionless ops.\n");
9886 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9887 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9888 printf("Device doesn't support RAW data-path APIs.\n");
9892 /* not supported with CPU crypto */
9893 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9896 /* Verify the capabilities */
9897 struct rte_cryptodev_sym_capability_idx cap_idx;
9898 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9899 cap_idx.algo.aead = tdata->algo;
9900 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9904 /* alloc mbuf and set payload */
9905 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9907 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9908 rte_pktmbuf_tailroom(ut_params->ibuf));
9910 /* Create AEAD operation */
9911 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9915 /* Create AEAD xform */
9916 memcpy(key, tdata->key.data, tdata->key.len);
9917 retval = create_aead_xform(ut_params->op,
9919 RTE_CRYPTO_AEAD_OP_DECRYPT,
9920 key, tdata->key.len,
9921 tdata->aad.len, tdata->auth_tag.len,
9926 ut_params->op->sym->m_src = ut_params->ibuf;
9928 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9929 RTE_CRYPTO_OP_SESSIONLESS,
9930 "crypto op session type not sessionless");
9932 /* Process crypto operation */
9933 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9934 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9935 ut_params->op, 0, 0, 0, 0);
9937 TEST_ASSERT_NOT_NULL(process_crypto_request(
9938 ts_params->valid_devs[0], ut_params->op),
9939 "failed to process sym crypto op");
9941 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9943 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9944 "crypto op status not success");
9946 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9947 ut_params->op->sym->cipher.data.offset);
9949 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9952 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9954 tdata->plaintext.data,
9955 tdata->plaintext.len,
9956 "Plaintext data not as expected");
9958 TEST_ASSERT_EQUAL(ut_params->op->status,
9959 RTE_CRYPTO_OP_STATUS_SUCCESS,
9960 "Authentication failed");
9965 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9967 return test_authenticated_decryption_sessionless(
9972 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9974 return test_authenticated_encryption(&ccm_test_case_128_1);
9978 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9980 return test_authenticated_encryption(&ccm_test_case_128_2);
9984 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9986 return test_authenticated_encryption(&ccm_test_case_128_3);
9990 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9992 return test_authenticated_decryption(&ccm_test_case_128_1);
9996 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9998 return test_authenticated_decryption(&ccm_test_case_128_2);
10002 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10004 return test_authenticated_decryption(&ccm_test_case_128_3);
10008 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10010 return test_authenticated_encryption(&ccm_test_case_192_1);
10014 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10016 return test_authenticated_encryption(&ccm_test_case_192_2);
10020 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10022 return test_authenticated_encryption(&ccm_test_case_192_3);
10026 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10028 return test_authenticated_decryption(&ccm_test_case_192_1);
10032 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10034 return test_authenticated_decryption(&ccm_test_case_192_2);
10038 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10040 return test_authenticated_decryption(&ccm_test_case_192_3);
10044 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10046 return test_authenticated_encryption(&ccm_test_case_256_1);
10050 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10052 return test_authenticated_encryption(&ccm_test_case_256_2);
10056 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10058 return test_authenticated_encryption(&ccm_test_case_256_3);
10062 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10064 return test_authenticated_decryption(&ccm_test_case_256_1);
10068 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10070 return test_authenticated_decryption(&ccm_test_case_256_2);
10074 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10076 return test_authenticated_decryption(&ccm_test_case_256_3);
10082 struct crypto_testsuite_params *ts_params = &testsuite_params;
10083 struct rte_cryptodev_stats stats;
10085 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10088 /* Verify the capabilities */
10089 struct rte_cryptodev_sym_capability_idx cap_idx;
10090 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10091 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10092 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10095 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10096 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10097 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10101 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10105 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10106 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10107 &stats) == -ENODEV),
10108 "rte_cryptodev_stats_get invalid dev failed");
10109 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10110 "rte_cryptodev_stats_get invalid Param failed");
10112 /* Test expected values */
10113 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10114 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10116 "rte_cryptodev_stats_get failed");
10117 TEST_ASSERT((stats.enqueued_count == 1),
10118 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10119 TEST_ASSERT((stats.dequeued_count == 1),
10120 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10121 TEST_ASSERT((stats.enqueue_err_count == 0),
10122 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10123 TEST_ASSERT((stats.dequeue_err_count == 0),
10124 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10126 /* invalid device but should ignore and not reset device stats*/
10127 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10128 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10130 "rte_cryptodev_stats_get failed");
10131 TEST_ASSERT((stats.enqueued_count == 1),
10132 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10134 /* check that a valid reset clears stats */
10135 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10136 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10138 "rte_cryptodev_stats_get failed");
10139 TEST_ASSERT((stats.enqueued_count == 0),
10140 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10141 TEST_ASSERT((stats.dequeued_count == 0),
10142 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10144 return TEST_SUCCESS;
10147 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10148 struct crypto_unittest_params *ut_params,
10149 enum rte_crypto_auth_operation op,
10150 const struct HMAC_MD5_vector *test_case)
10154 memcpy(key, test_case->key.data, test_case->key.len);
10156 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10157 ut_params->auth_xform.next = NULL;
10158 ut_params->auth_xform.auth.op = op;
10160 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10162 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10163 ut_params->auth_xform.auth.key.length = test_case->key.len;
10164 ut_params->auth_xform.auth.key.data = key;
10166 ut_params->sess = rte_cryptodev_sym_session_create(
10167 ts_params->session_mpool);
10169 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10170 ut_params->sess, &ut_params->auth_xform,
10171 ts_params->session_priv_mpool);
10173 if (ut_params->sess == NULL)
10174 return TEST_FAILED;
10176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10178 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10179 rte_pktmbuf_tailroom(ut_params->ibuf));
10184 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10185 const struct HMAC_MD5_vector *test_case,
10186 uint8_t **plaintext)
10188 uint16_t plaintext_pad_len;
10190 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10192 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10195 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10196 plaintext_pad_len);
10197 memcpy(*plaintext, test_case->plaintext.data,
10198 test_case->plaintext.len);
10200 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10201 ut_params->ibuf, MD5_DIGEST_LEN);
10202 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10203 "no room to append digest");
10204 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10205 ut_params->ibuf, plaintext_pad_len);
10207 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10208 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10209 test_case->auth_tag.len);
10212 sym_op->auth.data.offset = 0;
10213 sym_op->auth.data.length = test_case->plaintext.len;
10215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10216 ut_params->op->sym->m_src = ut_params->ibuf;
10222 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10224 uint16_t plaintext_pad_len;
10225 uint8_t *plaintext, *auth_tag;
10227 struct crypto_testsuite_params *ts_params = &testsuite_params;
10228 struct crypto_unittest_params *ut_params = &unittest_params;
10229 struct rte_cryptodev_info dev_info;
10231 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10232 uint64_t feat_flags = dev_info.feature_flags;
10234 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10235 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10236 printf("Device doesn't support RAW data-path APIs.\n");
10240 /* Verify the capabilities */
10241 struct rte_cryptodev_sym_capability_idx cap_idx;
10242 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10243 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10244 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10248 if (MD5_HMAC_create_session(ts_params, ut_params,
10249 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10250 return TEST_FAILED;
10252 /* Generate Crypto op data structure */
10253 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10254 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10255 TEST_ASSERT_NOT_NULL(ut_params->op,
10256 "Failed to allocate symmetric crypto operation struct");
10258 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10261 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10262 return TEST_FAILED;
10264 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10265 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10267 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10268 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10269 ut_params->op, 0, 1, 0, 0);
10271 TEST_ASSERT_NOT_NULL(
10272 process_crypto_request(ts_params->valid_devs[0],
10274 "failed to process sym crypto op");
10276 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10277 "crypto op processing failed");
10279 if (ut_params->op->sym->m_dst) {
10280 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10281 uint8_t *, plaintext_pad_len);
10283 auth_tag = plaintext + plaintext_pad_len;
10286 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10288 test_case->auth_tag.data,
10289 test_case->auth_tag.len,
10290 "HMAC_MD5 generated tag not as expected");
10292 return TEST_SUCCESS;
10296 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10298 uint8_t *plaintext;
10300 struct crypto_testsuite_params *ts_params = &testsuite_params;
10301 struct crypto_unittest_params *ut_params = &unittest_params;
10302 struct rte_cryptodev_info dev_info;
10304 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10305 uint64_t feat_flags = dev_info.feature_flags;
10307 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10308 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10309 printf("Device doesn't support RAW data-path APIs.\n");
10313 /* Verify the capabilities */
10314 struct rte_cryptodev_sym_capability_idx cap_idx;
10315 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10316 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10317 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10321 if (MD5_HMAC_create_session(ts_params, ut_params,
10322 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10323 return TEST_FAILED;
10326 /* Generate Crypto op data structure */
10327 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10328 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10329 TEST_ASSERT_NOT_NULL(ut_params->op,
10330 "Failed to allocate symmetric crypto operation struct");
10332 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10333 return TEST_FAILED;
10335 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10336 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10338 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10339 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10340 ut_params->op, 0, 1, 0, 0);
10342 TEST_ASSERT_NOT_NULL(
10343 process_crypto_request(ts_params->valid_devs[0],
10345 "failed to process sym crypto op");
10347 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10348 "HMAC_MD5 crypto op processing failed");
10350 return TEST_SUCCESS;
10354 test_MD5_HMAC_generate_case_1(void)
10356 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10360 test_MD5_HMAC_verify_case_1(void)
10362 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10366 test_MD5_HMAC_generate_case_2(void)
10368 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10372 test_MD5_HMAC_verify_case_2(void)
10374 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10378 test_multi_session(void)
10380 struct crypto_testsuite_params *ts_params = &testsuite_params;
10381 struct crypto_unittest_params *ut_params = &unittest_params;
10383 struct rte_cryptodev_info dev_info;
10384 struct rte_cryptodev_sym_session **sessions;
10388 /* Verify the capabilities */
10389 struct rte_cryptodev_sym_capability_idx cap_idx;
10390 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10391 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10392 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10395 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10396 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10397 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10401 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10402 aes_cbc_key, hmac_sha512_key);
10405 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10407 sessions = rte_malloc(NULL,
10408 (sizeof(struct rte_cryptodev_sym_session *) *
10409 MAX_NB_SESSIONS) + 1, 0);
10411 /* Create multiple crypto sessions*/
10412 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10414 sessions[i] = rte_cryptodev_sym_session_create(
10415 ts_params->session_mpool);
10417 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10418 sessions[i], &ut_params->auth_xform,
10419 ts_params->session_priv_mpool);
10420 TEST_ASSERT_NOT_NULL(sessions[i],
10421 "Session creation failed at session number %u",
10424 /* Attempt to send a request on each session */
10425 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10429 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10430 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10432 "Failed to perform decrypt on request number %u.", i);
10433 /* free crypto operation structure */
10435 rte_crypto_op_free(ut_params->op);
10438 * free mbuf - both obuf and ibuf are usually the same,
10439 * so check if they point at the same address is necessary,
10440 * to avoid freeing the mbuf twice.
10442 if (ut_params->obuf) {
10443 rte_pktmbuf_free(ut_params->obuf);
10444 if (ut_params->ibuf == ut_params->obuf)
10445 ut_params->ibuf = 0;
10446 ut_params->obuf = 0;
10448 if (ut_params->ibuf) {
10449 rte_pktmbuf_free(ut_params->ibuf);
10450 ut_params->ibuf = 0;
10454 /* Next session create should fail */
10455 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10456 sessions[i], &ut_params->auth_xform,
10457 ts_params->session_priv_mpool);
10458 TEST_ASSERT_NULL(sessions[i],
10459 "Session creation succeeded unexpectedly!");
10461 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10462 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10464 rte_cryptodev_sym_session_free(sessions[i]);
10467 rte_free(sessions);
10469 return TEST_SUCCESS;
10472 struct multi_session_params {
10473 struct crypto_unittest_params ut_params;
10474 uint8_t *cipher_key;
10476 const uint8_t *cipher;
10477 const uint8_t *digest;
10481 #define MB_SESSION_NUMBER 3
10484 test_multi_session_random_usage(void)
10486 struct crypto_testsuite_params *ts_params = &testsuite_params;
10487 struct rte_cryptodev_info dev_info;
10488 struct rte_cryptodev_sym_session **sessions;
10490 struct multi_session_params ut_paramz[] = {
10493 .cipher_key = ms_aes_cbc_key0,
10494 .hmac_key = ms_hmac_key0,
10495 .cipher = ms_aes_cbc_cipher0,
10496 .digest = ms_hmac_digest0,
10497 .iv = ms_aes_cbc_iv0
10500 .cipher_key = ms_aes_cbc_key1,
10501 .hmac_key = ms_hmac_key1,
10502 .cipher = ms_aes_cbc_cipher1,
10503 .digest = ms_hmac_digest1,
10504 .iv = ms_aes_cbc_iv1
10507 .cipher_key = ms_aes_cbc_key2,
10508 .hmac_key = ms_hmac_key2,
10509 .cipher = ms_aes_cbc_cipher2,
10510 .digest = ms_hmac_digest2,
10511 .iv = ms_aes_cbc_iv2
10516 /* Verify the capabilities */
10517 struct rte_cryptodev_sym_capability_idx cap_idx;
10518 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10519 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10520 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10523 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10524 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10525 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10529 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10531 sessions = rte_malloc(NULL,
10532 (sizeof(struct rte_cryptodev_sym_session *)
10533 * MAX_NB_SESSIONS) + 1, 0);
10535 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10536 sessions[i] = rte_cryptodev_sym_session_create(
10537 ts_params->session_mpool);
10539 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10540 sizeof(struct crypto_unittest_params));
10542 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10543 &ut_paramz[i].ut_params,
10544 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10546 /* Create multiple crypto sessions*/
10547 rte_cryptodev_sym_session_init(
10548 ts_params->valid_devs[0],
10550 &ut_paramz[i].ut_params.auth_xform,
10551 ts_params->session_priv_mpool);
10553 TEST_ASSERT_NOT_NULL(sessions[i],
10554 "Session creation failed at session number %u",
10560 for (i = 0; i < 40000; i++) {
10562 j = rand() % MB_SESSION_NUMBER;
10564 TEST_ASSERT_SUCCESS(
10565 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10567 &ut_paramz[j].ut_params,
10568 ts_params, ut_paramz[j].cipher,
10569 ut_paramz[j].digest,
10571 "Failed to perform decrypt on request number %u.", i);
10573 if (ut_paramz[j].ut_params.op)
10574 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10577 * free mbuf - both obuf and ibuf are usually the same,
10578 * so check if they point at the same address is necessary,
10579 * to avoid freeing the mbuf twice.
10581 if (ut_paramz[j].ut_params.obuf) {
10582 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10583 if (ut_paramz[j].ut_params.ibuf
10584 == ut_paramz[j].ut_params.obuf)
10585 ut_paramz[j].ut_params.ibuf = 0;
10586 ut_paramz[j].ut_params.obuf = 0;
10588 if (ut_paramz[j].ut_params.ibuf) {
10589 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10590 ut_paramz[j].ut_params.ibuf = 0;
10594 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10595 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10597 rte_cryptodev_sym_session_free(sessions[i]);
10600 rte_free(sessions);
10602 return TEST_SUCCESS;
10605 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10606 0xab, 0xab, 0xab, 0xab,
10607 0xab, 0xab, 0xab, 0xab,
10608 0xab, 0xab, 0xab, 0xab};
10611 test_null_invalid_operation(void)
10613 struct crypto_testsuite_params *ts_params = &testsuite_params;
10614 struct crypto_unittest_params *ut_params = &unittest_params;
10617 /* This test is for NULL PMD only */
10618 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10619 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10622 /* Setup Cipher Parameters */
10623 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10624 ut_params->cipher_xform.next = NULL;
10626 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10627 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10629 ut_params->sess = rte_cryptodev_sym_session_create(
10630 ts_params->session_mpool);
10632 /* Create Crypto session*/
10633 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10634 ut_params->sess, &ut_params->cipher_xform,
10635 ts_params->session_priv_mpool);
10636 TEST_ASSERT(ret < 0,
10637 "Session creation succeeded unexpectedly");
10640 /* Setup HMAC Parameters */
10641 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10642 ut_params->auth_xform.next = NULL;
10644 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10645 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10647 ut_params->sess = rte_cryptodev_sym_session_create(
10648 ts_params->session_mpool);
10650 /* Create Crypto session*/
10651 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10652 ut_params->sess, &ut_params->auth_xform,
10653 ts_params->session_priv_mpool);
10654 TEST_ASSERT(ret < 0,
10655 "Session creation succeeded unexpectedly");
10657 return TEST_SUCCESS;
10661 #define NULL_BURST_LENGTH (32)
10664 test_null_burst_operation(void)
10666 struct crypto_testsuite_params *ts_params = &testsuite_params;
10667 struct crypto_unittest_params *ut_params = &unittest_params;
10669 unsigned i, burst_len = NULL_BURST_LENGTH;
10671 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10672 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10674 /* This test is for NULL PMD only */
10675 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10676 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10679 /* Setup Cipher Parameters */
10680 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10681 ut_params->cipher_xform.next = &ut_params->auth_xform;
10683 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10684 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10686 /* Setup HMAC Parameters */
10687 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10688 ut_params->auth_xform.next = NULL;
10690 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10691 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10693 ut_params->sess = rte_cryptodev_sym_session_create(
10694 ts_params->session_mpool);
10696 /* Create Crypto session*/
10697 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10698 ut_params->sess, &ut_params->cipher_xform,
10699 ts_params->session_priv_mpool);
10700 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10702 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10703 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10704 burst_len, "failed to generate burst of crypto ops");
10706 /* Generate an operation for each mbuf in burst */
10707 for (i = 0; i < burst_len; i++) {
10708 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10710 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10712 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10716 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10718 burst[i]->sym->m_src = m;
10721 /* Process crypto operation */
10722 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10723 0, burst, burst_len),
10725 "Error enqueuing burst");
10727 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10728 0, burst_dequeued, burst_len),
10730 "Error dequeuing burst");
10733 for (i = 0; i < burst_len; i++) {
10735 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10736 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10738 "data not as expected");
10740 rte_pktmbuf_free(burst[i]->sym->m_src);
10741 rte_crypto_op_free(burst[i]);
10744 return TEST_SUCCESS;
10748 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10749 uint16_t nb_ops, void *user_param)
10751 RTE_SET_USED(dev_id);
10752 RTE_SET_USED(qp_id);
10754 RTE_SET_USED(user_param);
10756 printf("crypto enqueue callback called\n");
10761 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
10762 uint16_t nb_ops, void *user_param)
10764 RTE_SET_USED(dev_id);
10765 RTE_SET_USED(qp_id);
10767 RTE_SET_USED(user_param);
10769 printf("crypto dequeue callback called\n");
10774 * Thread using enqueue/dequeue callback with RCU.
10777 test_enqdeq_callback_thread(void *arg)
10780 /* DP thread calls rte_cryptodev_enqueue_burst()/
10781 * rte_cryptodev_dequeue_burst() and invokes callback.
10783 test_null_burst_operation();
10788 test_enq_callback_setup(void)
10790 struct crypto_testsuite_params *ts_params = &testsuite_params;
10791 struct rte_cryptodev_info dev_info;
10792 struct rte_cryptodev_qp_conf qp_conf = {
10793 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10796 struct rte_cryptodev_cb *cb;
10797 uint16_t qp_id = 0;
10799 /* Stop the device in case it's started so it can be configured */
10800 rte_cryptodev_stop(ts_params->valid_devs[0]);
10802 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10804 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10806 "Failed to configure cryptodev %u",
10807 ts_params->valid_devs[0]);
10809 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10810 qp_conf.mp_session = ts_params->session_mpool;
10811 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10813 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10814 ts_params->valid_devs[0], qp_id, &qp_conf,
10815 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10817 "rte_cryptodev_queue_pair_setup: num_inflights "
10818 "%u on qp %u on cryptodev %u",
10819 qp_conf.nb_descriptors, qp_id,
10820 ts_params->valid_devs[0]);
10822 /* Test with invalid crypto device */
10823 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
10824 qp_id, test_enq_callback, NULL);
10825 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10826 "cryptodev %u did not fail",
10827 qp_id, RTE_CRYPTO_MAX_DEVS);
10829 /* Test with invalid queue pair */
10830 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10831 dev_info.max_nb_queue_pairs + 1,
10832 test_enq_callback, NULL);
10833 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10834 "cryptodev %u did not fail",
10835 dev_info.max_nb_queue_pairs + 1,
10836 ts_params->valid_devs[0]);
10838 /* Test with NULL callback */
10839 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10840 qp_id, NULL, NULL);
10841 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10842 "cryptodev %u did not fail",
10843 qp_id, ts_params->valid_devs[0]);
10845 /* Test with valid configuration */
10846 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
10847 qp_id, test_enq_callback, NULL);
10848 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10849 "qp %u on cryptodev %u",
10850 qp_id, ts_params->valid_devs[0]);
10852 rte_cryptodev_start(ts_params->valid_devs[0]);
10854 /* Launch a thread */
10855 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10856 rte_get_next_lcore(-1, 1, 0));
10858 /* Wait until reader exited. */
10859 rte_eal_mp_wait_lcore();
10861 /* Test with invalid crypto device */
10862 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10863 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10864 "Expected call to fail as crypto device is invalid");
10866 /* Test with invalid queue pair */
10867 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10868 ts_params->valid_devs[0],
10869 dev_info.max_nb_queue_pairs + 1, cb),
10870 "Expected call to fail as queue pair is invalid");
10872 /* Test with NULL callback */
10873 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
10874 ts_params->valid_devs[0], qp_id, NULL),
10875 "Expected call to fail as callback is NULL");
10877 /* Test with valid configuration */
10878 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
10879 ts_params->valid_devs[0], qp_id, cb),
10880 "Failed test to remove callback on "
10881 "qp %u on cryptodev %u",
10882 qp_id, ts_params->valid_devs[0]);
10884 return TEST_SUCCESS;
10888 test_deq_callback_setup(void)
10890 struct crypto_testsuite_params *ts_params = &testsuite_params;
10891 struct rte_cryptodev_info dev_info;
10892 struct rte_cryptodev_qp_conf qp_conf = {
10893 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
10896 struct rte_cryptodev_cb *cb;
10897 uint16_t qp_id = 0;
10899 /* Stop the device in case it's started so it can be configured */
10900 rte_cryptodev_stop(ts_params->valid_devs[0]);
10902 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10904 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
10906 "Failed to configure cryptodev %u",
10907 ts_params->valid_devs[0]);
10909 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
10910 qp_conf.mp_session = ts_params->session_mpool;
10911 qp_conf.mp_session_private = ts_params->session_priv_mpool;
10913 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
10914 ts_params->valid_devs[0], qp_id, &qp_conf,
10915 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
10917 "rte_cryptodev_queue_pair_setup: num_inflights "
10918 "%u on qp %u on cryptodev %u",
10919 qp_conf.nb_descriptors, qp_id,
10920 ts_params->valid_devs[0]);
10922 /* Test with invalid crypto device */
10923 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
10924 qp_id, test_deq_callback, NULL);
10925 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10926 "cryptodev %u did not fail",
10927 qp_id, RTE_CRYPTO_MAX_DEVS);
10929 /* Test with invalid queue pair */
10930 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10931 dev_info.max_nb_queue_pairs + 1,
10932 test_deq_callback, NULL);
10933 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10934 "cryptodev %u did not fail",
10935 dev_info.max_nb_queue_pairs + 1,
10936 ts_params->valid_devs[0]);
10938 /* Test with NULL callback */
10939 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10940 qp_id, NULL, NULL);
10941 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
10942 "cryptodev %u did not fail",
10943 qp_id, ts_params->valid_devs[0]);
10945 /* Test with valid configuration */
10946 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
10947 qp_id, test_deq_callback, NULL);
10948 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
10949 "qp %u on cryptodev %u",
10950 qp_id, ts_params->valid_devs[0]);
10952 rte_cryptodev_start(ts_params->valid_devs[0]);
10954 /* Launch a thread */
10955 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
10956 rte_get_next_lcore(-1, 1, 0));
10958 /* Wait until reader exited. */
10959 rte_eal_mp_wait_lcore();
10961 /* Test with invalid crypto device */
10962 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10963 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
10964 "Expected call to fail as crypto device is invalid");
10966 /* Test with invalid queue pair */
10967 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10968 ts_params->valid_devs[0],
10969 dev_info.max_nb_queue_pairs + 1, cb),
10970 "Expected call to fail as queue pair is invalid");
10972 /* Test with NULL callback */
10973 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
10974 ts_params->valid_devs[0], qp_id, NULL),
10975 "Expected call to fail as callback is NULL");
10977 /* Test with valid configuration */
10978 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
10979 ts_params->valid_devs[0], qp_id, cb),
10980 "Failed test to remove callback on "
10981 "qp %u on cryptodev %u",
10982 qp_id, ts_params->valid_devs[0]);
10984 return TEST_SUCCESS;
10988 generate_gmac_large_plaintext(uint8_t *data)
10992 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10993 memcpy(&data[i], &data[0], 32);
10997 create_gmac_operation(enum rte_crypto_auth_operation op,
10998 const struct gmac_test_data *tdata)
11000 struct crypto_testsuite_params *ts_params = &testsuite_params;
11001 struct crypto_unittest_params *ut_params = &unittest_params;
11002 struct rte_crypto_sym_op *sym_op;
11004 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11006 /* Generate Crypto op data structure */
11007 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11008 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11009 TEST_ASSERT_NOT_NULL(ut_params->op,
11010 "Failed to allocate symmetric crypto operation struct");
11012 sym_op = ut_params->op->sym;
11014 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11015 ut_params->ibuf, tdata->gmac_tag.len);
11016 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11017 "no room to append digest");
11019 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11020 ut_params->ibuf, plaintext_pad_len);
11022 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11023 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11024 tdata->gmac_tag.len);
11025 debug_hexdump(stdout, "digest:",
11026 sym_op->auth.digest.data,
11027 tdata->gmac_tag.len);
11030 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11031 uint8_t *, IV_OFFSET);
11033 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11035 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11037 sym_op->cipher.data.length = 0;
11038 sym_op->cipher.data.offset = 0;
11040 sym_op->auth.data.offset = 0;
11041 sym_op->auth.data.length = tdata->plaintext.len;
11047 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11048 const struct gmac_test_data *tdata,
11049 void *digest_mem, uint64_t digest_phys)
11051 struct crypto_testsuite_params *ts_params = &testsuite_params;
11052 struct crypto_unittest_params *ut_params = &unittest_params;
11053 struct rte_crypto_sym_op *sym_op;
11055 /* Generate Crypto op data structure */
11056 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11057 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11058 TEST_ASSERT_NOT_NULL(ut_params->op,
11059 "Failed to allocate symmetric crypto operation struct");
11061 sym_op = ut_params->op->sym;
11063 sym_op->auth.digest.data = digest_mem;
11064 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11065 "no room to append digest");
11067 sym_op->auth.digest.phys_addr = digest_phys;
11069 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11070 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11071 tdata->gmac_tag.len);
11072 debug_hexdump(stdout, "digest:",
11073 sym_op->auth.digest.data,
11074 tdata->gmac_tag.len);
11077 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11078 uint8_t *, IV_OFFSET);
11080 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11082 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11084 sym_op->cipher.data.length = 0;
11085 sym_op->cipher.data.offset = 0;
11087 sym_op->auth.data.offset = 0;
11088 sym_op->auth.data.length = tdata->plaintext.len;
11093 static int create_gmac_session(uint8_t dev_id,
11094 const struct gmac_test_data *tdata,
11095 enum rte_crypto_auth_operation auth_op)
11097 uint8_t auth_key[tdata->key.len];
11099 struct crypto_testsuite_params *ts_params = &testsuite_params;
11100 struct crypto_unittest_params *ut_params = &unittest_params;
11102 memcpy(auth_key, tdata->key.data, tdata->key.len);
11104 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11105 ut_params->auth_xform.next = NULL;
11107 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11108 ut_params->auth_xform.auth.op = auth_op;
11109 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11110 ut_params->auth_xform.auth.key.length = tdata->key.len;
11111 ut_params->auth_xform.auth.key.data = auth_key;
11112 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11113 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11116 ut_params->sess = rte_cryptodev_sym_session_create(
11117 ts_params->session_mpool);
11119 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11120 &ut_params->auth_xform,
11121 ts_params->session_priv_mpool);
11123 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11129 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11131 struct crypto_testsuite_params *ts_params = &testsuite_params;
11132 struct crypto_unittest_params *ut_params = &unittest_params;
11133 struct rte_cryptodev_info dev_info;
11135 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11136 uint64_t feat_flags = dev_info.feature_flags;
11138 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11139 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11140 printf("Device doesn't support RAW data-path APIs.\n");
11146 uint8_t *auth_tag, *plaintext;
11147 uint16_t plaintext_pad_len;
11149 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11150 "No GMAC length in the source data");
11152 /* Verify the capabilities */
11153 struct rte_cryptodev_sym_capability_idx cap_idx;
11154 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11155 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11156 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11160 retval = create_gmac_session(ts_params->valid_devs[0],
11161 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11166 if (tdata->plaintext.len > MBUF_SIZE)
11167 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11169 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11170 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11171 "Failed to allocate input buffer in mempool");
11173 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11174 rte_pktmbuf_tailroom(ut_params->ibuf));
11176 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11178 * Runtime generate the large plain text instead of use hard code
11179 * plain text vector. It is done to avoid create huge source file
11180 * with the test vector.
11182 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11183 generate_gmac_large_plaintext(tdata->plaintext.data);
11185 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11186 plaintext_pad_len);
11187 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11189 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11190 debug_hexdump(stdout, "plaintext:", plaintext,
11191 tdata->plaintext.len);
11193 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11199 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11201 ut_params->op->sym->m_src = ut_params->ibuf;
11203 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11204 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11206 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11207 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11208 ut_params->op, 0, 1, 0, 0);
11210 TEST_ASSERT_NOT_NULL(
11211 process_crypto_request(ts_params->valid_devs[0],
11212 ut_params->op), "failed to process sym crypto op");
11214 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11215 "crypto op processing failed");
11217 if (ut_params->op->sym->m_dst) {
11218 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11219 uint8_t *, plaintext_pad_len);
11221 auth_tag = plaintext + plaintext_pad_len;
11224 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11226 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11228 tdata->gmac_tag.data,
11229 tdata->gmac_tag.len,
11230 "GMAC Generated auth tag not as expected");
11236 test_AES_GMAC_authentication_test_case_1(void)
11238 return test_AES_GMAC_authentication(&gmac_test_case_1);
11242 test_AES_GMAC_authentication_test_case_2(void)
11244 return test_AES_GMAC_authentication(&gmac_test_case_2);
11248 test_AES_GMAC_authentication_test_case_3(void)
11250 return test_AES_GMAC_authentication(&gmac_test_case_3);
11254 test_AES_GMAC_authentication_test_case_4(void)
11256 return test_AES_GMAC_authentication(&gmac_test_case_4);
11260 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11262 struct crypto_testsuite_params *ts_params = &testsuite_params;
11263 struct crypto_unittest_params *ut_params = &unittest_params;
11265 uint32_t plaintext_pad_len;
11266 uint8_t *plaintext;
11267 struct rte_cryptodev_info dev_info;
11269 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11270 uint64_t feat_flags = dev_info.feature_flags;
11272 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11273 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11274 printf("Device doesn't support RAW data-path APIs.\n");
11278 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11279 "No GMAC length in the source data");
11281 /* Verify the capabilities */
11282 struct rte_cryptodev_sym_capability_idx cap_idx;
11283 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11284 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11285 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11289 retval = create_gmac_session(ts_params->valid_devs[0],
11290 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11295 if (tdata->plaintext.len > MBUF_SIZE)
11296 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11298 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11299 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11300 "Failed to allocate input buffer in mempool");
11302 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11303 rte_pktmbuf_tailroom(ut_params->ibuf));
11305 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11308 * Runtime generate the large plain text instead of use hard code
11309 * plain text vector. It is done to avoid create huge source file
11310 * with the test vector.
11312 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11313 generate_gmac_large_plaintext(tdata->plaintext.data);
11315 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11316 plaintext_pad_len);
11317 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11319 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11320 debug_hexdump(stdout, "plaintext:", plaintext,
11321 tdata->plaintext.len);
11323 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11329 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11331 ut_params->op->sym->m_src = ut_params->ibuf;
11333 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11334 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11336 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11337 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11338 ut_params->op, 0, 1, 0, 0);
11340 TEST_ASSERT_NOT_NULL(
11341 process_crypto_request(ts_params->valid_devs[0],
11342 ut_params->op), "failed to process sym crypto op");
11344 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11345 "crypto op processing failed");
11352 test_AES_GMAC_authentication_verify_test_case_1(void)
11354 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11358 test_AES_GMAC_authentication_verify_test_case_2(void)
11360 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11364 test_AES_GMAC_authentication_verify_test_case_3(void)
11366 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11370 test_AES_GMAC_authentication_verify_test_case_4(void)
11372 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11376 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11379 struct crypto_testsuite_params *ts_params = &testsuite_params;
11380 struct crypto_unittest_params *ut_params = &unittest_params;
11381 struct rte_cryptodev_info dev_info;
11382 uint64_t feature_flags;
11383 unsigned int trn_data = 0;
11384 void *digest_mem = NULL;
11386 unsigned int to_trn = 0;
11387 struct rte_mbuf *buf = NULL;
11388 uint8_t *auth_tag, *plaintext;
11391 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11392 "No GMAC length in the source data");
11394 /* Verify the capabilities */
11395 struct rte_cryptodev_sym_capability_idx cap_idx;
11396 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11397 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11398 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11402 /* Check for any input SGL support */
11403 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11404 feature_flags = dev_info.feature_flags;
11406 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11407 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11408 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11411 if (fragsz > tdata->plaintext.len)
11412 fragsz = tdata->plaintext.len;
11414 uint16_t plaintext_len = fragsz;
11416 retval = create_gmac_session(ts_params->valid_devs[0],
11417 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11422 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11423 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11424 "Failed to allocate input buffer in mempool");
11426 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11427 rte_pktmbuf_tailroom(ut_params->ibuf));
11429 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11431 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11433 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11435 trn_data += plaintext_len;
11437 buf = ut_params->ibuf;
11440 * Loop until no more fragments
11443 while (trn_data < tdata->plaintext.len) {
11445 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11446 (tdata->plaintext.len - trn_data) : fragsz;
11448 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11451 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11452 rte_pktmbuf_tailroom(buf));
11454 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11457 memcpy(plaintext, tdata->plaintext.data + trn_data,
11459 trn_data += to_trn;
11460 if (trn_data == tdata->plaintext.len)
11461 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11462 tdata->gmac_tag.len);
11464 ut_params->ibuf->nb_segs = segs;
11467 * Place digest at the end of the last buffer
11469 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11472 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11473 + tdata->gmac_tag.len);
11474 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11475 tdata->plaintext.len);
11478 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11479 tdata, digest_mem, digest_phys);
11484 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11486 ut_params->op->sym->m_src = ut_params->ibuf;
11488 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11491 TEST_ASSERT_NOT_NULL(
11492 process_crypto_request(ts_params->valid_devs[0],
11493 ut_params->op), "failed to process sym crypto op");
11495 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11496 "crypto op processing failed");
11498 auth_tag = digest_mem;
11499 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11500 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11502 tdata->gmac_tag.data,
11503 tdata->gmac_tag.len,
11504 "GMAC Generated auth tag not as expected");
11509 /* Segment size not multiple of block size (16B) */
11511 test_AES_GMAC_authentication_SGL_40B(void)
11513 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11517 test_AES_GMAC_authentication_SGL_80B(void)
11519 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11523 test_AES_GMAC_authentication_SGL_2048B(void)
11525 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11528 /* Segment size not multiple of block size (16B) */
11530 test_AES_GMAC_authentication_SGL_2047B(void)
11532 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11535 struct test_crypto_vector {
11536 enum rte_crypto_cipher_algorithm crypto_algo;
11537 unsigned int cipher_offset;
11538 unsigned int cipher_len;
11551 const uint8_t *data;
11556 const uint8_t *data;
11560 enum rte_crypto_auth_algorithm auth_algo;
11561 unsigned int auth_offset;
11569 const uint8_t *data;
11579 static const struct test_crypto_vector
11580 hmac_sha1_test_crypto_vector = {
11581 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11583 .data = plaintext_hash,
11588 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11589 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11590 0xDE, 0xF4, 0xDE, 0xAD
11596 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11597 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11598 0x3F, 0x91, 0x64, 0x59
11604 static const struct test_crypto_vector
11605 aes128_gmac_test_vector = {
11606 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11608 .data = plaintext_hash,
11613 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11614 0x08, 0x09, 0x0A, 0x0B
11620 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11621 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11627 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11628 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11634 static const struct test_crypto_vector
11635 aes128cbc_hmac_sha1_test_vector = {
11636 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11637 .cipher_offset = 0,
11641 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11642 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11648 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11649 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11654 .data = plaintext_hash,
11658 .data = ciphertext512_aes128cbc,
11661 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11665 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11666 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11667 0xDE, 0xF4, 0xDE, 0xAD
11673 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
11674 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11675 0x18, 0x8C, 0x1D, 0x32
11681 static const struct test_crypto_vector
11682 aes128cbc_hmac_sha1_aad_test_vector = {
11683 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11684 .cipher_offset = 8,
11688 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11689 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11695 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11696 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11701 .data = plaintext_hash,
11705 .data = ciphertext512_aes128cbc_aad,
11708 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11712 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11713 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11714 0xDE, 0xF4, 0xDE, 0xAD
11720 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
11721 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
11722 0x62, 0x0F, 0xFB, 0x10
11729 data_corruption(uint8_t *data)
11735 tag_corruption(uint8_t *data, unsigned int tag_offset)
11737 data[tag_offset] += 1;
11741 create_auth_session(struct crypto_unittest_params *ut_params,
11743 const struct test_crypto_vector *reference,
11744 enum rte_crypto_auth_operation auth_op)
11746 struct crypto_testsuite_params *ts_params = &testsuite_params;
11747 uint8_t auth_key[reference->auth_key.len + 1];
11749 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11751 /* Setup Authentication Parameters */
11752 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11753 ut_params->auth_xform.auth.op = auth_op;
11754 ut_params->auth_xform.next = NULL;
11755 ut_params->auth_xform.auth.algo = reference->auth_algo;
11756 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11757 ut_params->auth_xform.auth.key.data = auth_key;
11758 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11760 /* Create Crypto session*/
11761 ut_params->sess = rte_cryptodev_sym_session_create(
11762 ts_params->session_mpool);
11764 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11765 &ut_params->auth_xform,
11766 ts_params->session_priv_mpool);
11768 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11774 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
11776 const struct test_crypto_vector *reference,
11777 enum rte_crypto_auth_operation auth_op,
11778 enum rte_crypto_cipher_operation cipher_op)
11780 struct crypto_testsuite_params *ts_params = &testsuite_params;
11781 uint8_t cipher_key[reference->cipher_key.len + 1];
11782 uint8_t auth_key[reference->auth_key.len + 1];
11784 memcpy(cipher_key, reference->cipher_key.data,
11785 reference->cipher_key.len);
11786 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11788 /* Setup Authentication Parameters */
11789 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11790 ut_params->auth_xform.auth.op = auth_op;
11791 ut_params->auth_xform.auth.algo = reference->auth_algo;
11792 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11793 ut_params->auth_xform.auth.key.data = auth_key;
11794 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11796 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
11797 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11798 ut_params->auth_xform.auth.iv.length = reference->iv.len;
11800 ut_params->auth_xform.next = &ut_params->cipher_xform;
11802 /* Setup Cipher Parameters */
11803 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11804 ut_params->cipher_xform.next = NULL;
11805 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11806 ut_params->cipher_xform.cipher.op = cipher_op;
11807 ut_params->cipher_xform.cipher.key.data = cipher_key;
11808 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11809 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11810 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11813 /* Create Crypto session*/
11814 ut_params->sess = rte_cryptodev_sym_session_create(
11815 ts_params->session_mpool);
11817 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11818 &ut_params->auth_xform,
11819 ts_params->session_priv_mpool);
11821 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11827 create_auth_operation(struct crypto_testsuite_params *ts_params,
11828 struct crypto_unittest_params *ut_params,
11829 const struct test_crypto_vector *reference,
11830 unsigned int auth_generate)
11832 /* Generate Crypto op data structure */
11833 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11834 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11835 TEST_ASSERT_NOT_NULL(ut_params->op,
11836 "Failed to allocate pktmbuf offload");
11838 /* Set crypto operation data parameters */
11839 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11841 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11843 /* set crypto operation source mbuf */
11844 sym_op->m_src = ut_params->ibuf;
11847 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11848 ut_params->ibuf, reference->digest.len);
11850 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11851 "no room to append auth tag");
11853 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11854 ut_params->ibuf, reference->plaintext.len);
11857 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11859 memcpy(sym_op->auth.digest.data,
11860 reference->digest.data,
11861 reference->digest.len);
11863 debug_hexdump(stdout, "digest:",
11864 sym_op->auth.digest.data,
11865 reference->digest.len);
11867 sym_op->auth.data.length = reference->plaintext.len;
11868 sym_op->auth.data.offset = 0;
11874 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
11875 struct crypto_unittest_params *ut_params,
11876 const struct test_crypto_vector *reference,
11877 unsigned int auth_generate)
11879 /* Generate Crypto op data structure */
11880 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11881 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11882 TEST_ASSERT_NOT_NULL(ut_params->op,
11883 "Failed to allocate pktmbuf offload");
11885 /* Set crypto operation data parameters */
11886 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11888 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11890 /* set crypto operation source mbuf */
11891 sym_op->m_src = ut_params->ibuf;
11894 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11895 ut_params->ibuf, reference->digest.len);
11897 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11898 "no room to append auth tag");
11900 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11901 ut_params->ibuf, reference->ciphertext.len);
11904 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11906 memcpy(sym_op->auth.digest.data,
11907 reference->digest.data,
11908 reference->digest.len);
11910 debug_hexdump(stdout, "digest:",
11911 sym_op->auth.digest.data,
11912 reference->digest.len);
11914 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11915 reference->iv.data, reference->iv.len);
11917 sym_op->cipher.data.length = 0;
11918 sym_op->cipher.data.offset = 0;
11920 sym_op->auth.data.length = reference->plaintext.len;
11921 sym_op->auth.data.offset = 0;
11927 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11928 struct crypto_unittest_params *ut_params,
11929 const struct test_crypto_vector *reference,
11930 unsigned int auth_generate)
11932 /* Generate Crypto op data structure */
11933 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11934 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11935 TEST_ASSERT_NOT_NULL(ut_params->op,
11936 "Failed to allocate pktmbuf offload");
11938 /* Set crypto operation data parameters */
11939 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11941 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11943 /* set crypto operation source mbuf */
11944 sym_op->m_src = ut_params->ibuf;
11947 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11948 ut_params->ibuf, reference->digest.len);
11950 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11951 "no room to append auth tag");
11953 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11954 ut_params->ibuf, reference->ciphertext.len);
11957 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11959 memcpy(sym_op->auth.digest.data,
11960 reference->digest.data,
11961 reference->digest.len);
11963 debug_hexdump(stdout, "digest:",
11964 sym_op->auth.digest.data,
11965 reference->digest.len);
11967 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11968 reference->iv.data, reference->iv.len);
11970 sym_op->cipher.data.length = reference->cipher_len;
11971 sym_op->cipher.data.offset = reference->cipher_offset;
11973 sym_op->auth.data.length = reference->plaintext.len;
11974 sym_op->auth.data.offset = reference->auth_offset;
11980 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11981 struct crypto_unittest_params *ut_params,
11982 const struct test_crypto_vector *reference)
11984 return create_auth_operation(ts_params, ut_params, reference, 0);
11988 create_auth_verify_GMAC_operation(
11989 struct crypto_testsuite_params *ts_params,
11990 struct crypto_unittest_params *ut_params,
11991 const struct test_crypto_vector *reference)
11993 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11997 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11998 struct crypto_unittest_params *ut_params,
11999 const struct test_crypto_vector *reference)
12001 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12005 test_authentication_verify_fail_when_data_corruption(
12006 struct crypto_testsuite_params *ts_params,
12007 struct crypto_unittest_params *ut_params,
12008 const struct test_crypto_vector *reference,
12009 unsigned int data_corrupted)
12013 uint8_t *plaintext;
12014 struct rte_cryptodev_info dev_info;
12016 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12017 uint64_t feat_flags = dev_info.feature_flags;
12019 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12020 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12021 printf("Device doesn't support RAW data-path APIs.\n");
12025 /* Verify the capabilities */
12026 struct rte_cryptodev_sym_capability_idx cap_idx;
12027 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12028 cap_idx.algo.auth = reference->auth_algo;
12029 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12034 /* Create session */
12035 retval = create_auth_session(ut_params,
12036 ts_params->valid_devs[0],
12038 RTE_CRYPTO_AUTH_OP_VERIFY);
12042 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12043 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12044 "Failed to allocate input buffer in mempool");
12046 /* clear mbuf payload */
12047 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12048 rte_pktmbuf_tailroom(ut_params->ibuf));
12050 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12051 reference->plaintext.len);
12052 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12053 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12055 debug_hexdump(stdout, "plaintext:", plaintext,
12056 reference->plaintext.len);
12058 /* Create operation */
12059 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12064 if (data_corrupted)
12065 data_corruption(plaintext);
12067 tag_corruption(plaintext, reference->plaintext.len);
12069 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12070 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12072 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12073 RTE_CRYPTO_OP_STATUS_SUCCESS,
12074 "authentication not failed");
12075 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12076 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12077 ut_params->op, 0, 1, 0, 0);
12079 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12081 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12088 test_authentication_verify_GMAC_fail_when_corruption(
12089 struct crypto_testsuite_params *ts_params,
12090 struct crypto_unittest_params *ut_params,
12091 const struct test_crypto_vector *reference,
12092 unsigned int data_corrupted)
12095 uint8_t *plaintext;
12096 struct rte_cryptodev_info dev_info;
12098 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12099 uint64_t feat_flags = dev_info.feature_flags;
12101 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12102 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12103 printf("Device doesn't support RAW data-path APIs.\n");
12107 /* Verify the capabilities */
12108 struct rte_cryptodev_sym_capability_idx cap_idx;
12109 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12110 cap_idx.algo.auth = reference->auth_algo;
12111 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12115 /* Create session */
12116 retval = create_auth_cipher_session(ut_params,
12117 ts_params->valid_devs[0],
12119 RTE_CRYPTO_AUTH_OP_VERIFY,
12120 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12124 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12125 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12126 "Failed to allocate input buffer in mempool");
12128 /* clear mbuf payload */
12129 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12130 rte_pktmbuf_tailroom(ut_params->ibuf));
12132 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12133 reference->plaintext.len);
12134 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12135 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12137 debug_hexdump(stdout, "plaintext:", plaintext,
12138 reference->plaintext.len);
12140 /* Create operation */
12141 retval = create_auth_verify_GMAC_operation(ts_params,
12148 if (data_corrupted)
12149 data_corruption(plaintext);
12151 tag_corruption(plaintext, reference->aad.len);
12153 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12154 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12156 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12157 RTE_CRYPTO_OP_STATUS_SUCCESS,
12158 "authentication not failed");
12159 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12160 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12161 ut_params->op, 0, 1, 0, 0);
12163 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12165 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12172 test_authenticated_decryption_fail_when_corruption(
12173 struct crypto_testsuite_params *ts_params,
12174 struct crypto_unittest_params *ut_params,
12175 const struct test_crypto_vector *reference,
12176 unsigned int data_corrupted)
12180 uint8_t *ciphertext;
12181 struct rte_cryptodev_info dev_info;
12183 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12184 uint64_t feat_flags = dev_info.feature_flags;
12186 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12187 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12188 printf("Device doesn't support RAW data-path APIs.\n");
12192 /* Verify the capabilities */
12193 struct rte_cryptodev_sym_capability_idx cap_idx;
12194 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12195 cap_idx.algo.auth = reference->auth_algo;
12196 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12199 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12200 cap_idx.algo.cipher = reference->crypto_algo;
12201 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12205 /* Create session */
12206 retval = create_auth_cipher_session(ut_params,
12207 ts_params->valid_devs[0],
12209 RTE_CRYPTO_AUTH_OP_VERIFY,
12210 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12214 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12215 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12216 "Failed to allocate input buffer in mempool");
12218 /* clear mbuf payload */
12219 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12220 rte_pktmbuf_tailroom(ut_params->ibuf));
12222 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12223 reference->ciphertext.len);
12224 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12225 memcpy(ciphertext, reference->ciphertext.data,
12226 reference->ciphertext.len);
12228 /* Create operation */
12229 retval = create_cipher_auth_verify_operation(ts_params,
12236 if (data_corrupted)
12237 data_corruption(ciphertext);
12239 tag_corruption(ciphertext, reference->ciphertext.len);
12241 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12242 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12244 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12245 RTE_CRYPTO_OP_STATUS_SUCCESS,
12246 "authentication not failed");
12247 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12248 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12249 ut_params->op, 1, 1, 0, 0);
12251 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12253 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12260 test_authenticated_encryt_with_esn(
12261 struct crypto_testsuite_params *ts_params,
12262 struct crypto_unittest_params *ut_params,
12263 const struct test_crypto_vector *reference)
12267 uint8_t *authciphertext, *plaintext, *auth_tag;
12268 uint16_t plaintext_pad_len;
12269 uint8_t cipher_key[reference->cipher_key.len + 1];
12270 uint8_t auth_key[reference->auth_key.len + 1];
12271 struct rte_cryptodev_info dev_info;
12273 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12274 uint64_t feat_flags = dev_info.feature_flags;
12276 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12277 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12278 printf("Device doesn't support RAW data-path APIs.\n");
12282 /* Verify the capabilities */
12283 struct rte_cryptodev_sym_capability_idx cap_idx;
12284 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12285 cap_idx.algo.auth = reference->auth_algo;
12286 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12289 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12290 cap_idx.algo.cipher = reference->crypto_algo;
12291 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12295 /* Create session */
12296 memcpy(cipher_key, reference->cipher_key.data,
12297 reference->cipher_key.len);
12298 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12300 /* Setup Cipher Parameters */
12301 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12302 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12303 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12304 ut_params->cipher_xform.cipher.key.data = cipher_key;
12305 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12306 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12307 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12309 ut_params->cipher_xform.next = &ut_params->auth_xform;
12311 /* Setup Authentication Parameters */
12312 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12313 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12314 ut_params->auth_xform.auth.algo = reference->auth_algo;
12315 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12316 ut_params->auth_xform.auth.key.data = auth_key;
12317 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12318 ut_params->auth_xform.next = NULL;
12320 /* Create Crypto session*/
12321 ut_params->sess = rte_cryptodev_sym_session_create(
12322 ts_params->session_mpool);
12324 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12326 &ut_params->cipher_xform,
12327 ts_params->session_priv_mpool);
12329 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12331 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12332 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12333 "Failed to allocate input buffer in mempool");
12335 /* clear mbuf payload */
12336 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12337 rte_pktmbuf_tailroom(ut_params->ibuf));
12339 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12340 reference->plaintext.len);
12341 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12342 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12344 /* Create operation */
12345 retval = create_cipher_auth_operation(ts_params,
12352 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12353 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12355 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12356 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12357 ut_params->op, 1, 1, 0, 0);
12359 ut_params->op = process_crypto_request(
12360 ts_params->valid_devs[0], ut_params->op);
12362 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12364 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12365 "crypto op processing failed");
12367 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12369 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12370 ut_params->op->sym->auth.data.offset);
12371 auth_tag = authciphertext + plaintext_pad_len;
12372 debug_hexdump(stdout, "ciphertext:", authciphertext,
12373 reference->ciphertext.len);
12374 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12376 /* Validate obuf */
12377 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12379 reference->ciphertext.data,
12380 reference->ciphertext.len,
12381 "Ciphertext data not as expected");
12383 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12385 reference->digest.data,
12386 reference->digest.len,
12387 "Generated digest not as expected");
12389 return TEST_SUCCESS;
12394 test_authenticated_decrypt_with_esn(
12395 struct crypto_testsuite_params *ts_params,
12396 struct crypto_unittest_params *ut_params,
12397 const struct test_crypto_vector *reference)
12401 uint8_t *ciphertext;
12402 uint8_t cipher_key[reference->cipher_key.len + 1];
12403 uint8_t auth_key[reference->auth_key.len + 1];
12404 struct rte_cryptodev_info dev_info;
12406 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12407 uint64_t feat_flags = dev_info.feature_flags;
12409 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12410 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12411 printf("Device doesn't support RAW data-path APIs.\n");
12415 /* Verify the capabilities */
12416 struct rte_cryptodev_sym_capability_idx cap_idx;
12417 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12418 cap_idx.algo.auth = reference->auth_algo;
12419 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12422 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12423 cap_idx.algo.cipher = reference->crypto_algo;
12424 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12428 /* Create session */
12429 memcpy(cipher_key, reference->cipher_key.data,
12430 reference->cipher_key.len);
12431 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12433 /* Setup Authentication Parameters */
12434 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12435 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12436 ut_params->auth_xform.auth.algo = reference->auth_algo;
12437 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12438 ut_params->auth_xform.auth.key.data = auth_key;
12439 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12440 ut_params->auth_xform.next = &ut_params->cipher_xform;
12442 /* Setup Cipher Parameters */
12443 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12444 ut_params->cipher_xform.next = NULL;
12445 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12446 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12447 ut_params->cipher_xform.cipher.key.data = cipher_key;
12448 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12449 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12450 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12452 /* Create Crypto session*/
12453 ut_params->sess = rte_cryptodev_sym_session_create(
12454 ts_params->session_mpool);
12456 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12458 &ut_params->auth_xform,
12459 ts_params->session_priv_mpool);
12461 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12463 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12464 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12465 "Failed to allocate input buffer in mempool");
12467 /* clear mbuf payload */
12468 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12469 rte_pktmbuf_tailroom(ut_params->ibuf));
12471 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12472 reference->ciphertext.len);
12473 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12474 memcpy(ciphertext, reference->ciphertext.data,
12475 reference->ciphertext.len);
12477 /* Create operation */
12478 retval = create_cipher_auth_verify_operation(ts_params,
12485 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12486 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12488 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12489 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12490 ut_params->op, 1, 1, 0, 0);
12492 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12495 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12496 TEST_ASSERT_EQUAL(ut_params->op->status,
12497 RTE_CRYPTO_OP_STATUS_SUCCESS,
12498 "crypto op processing passed");
12500 ut_params->obuf = ut_params->op->sym->m_src;
12501 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12507 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12508 const struct aead_test_data *tdata,
12509 void *digest_mem, uint64_t digest_phys)
12511 struct crypto_testsuite_params *ts_params = &testsuite_params;
12512 struct crypto_unittest_params *ut_params = &unittest_params;
12514 const unsigned int auth_tag_len = tdata->auth_tag.len;
12515 const unsigned int iv_len = tdata->iv.len;
12516 unsigned int aad_len = tdata->aad.len;
12517 unsigned int aad_len_pad = 0;
12519 /* Generate Crypto op data structure */
12520 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12521 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12522 TEST_ASSERT_NOT_NULL(ut_params->op,
12523 "Failed to allocate symmetric crypto operation struct");
12525 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12527 sym_op->aead.digest.data = digest_mem;
12529 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12530 "no room to append digest");
12532 sym_op->aead.digest.phys_addr = digest_phys;
12534 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12535 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12537 debug_hexdump(stdout, "digest:",
12538 sym_op->aead.digest.data,
12542 /* Append aad data */
12543 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12544 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12545 uint8_t *, IV_OFFSET);
12547 /* Copy IV 1 byte after the IV pointer, according to the API */
12548 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12550 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12552 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12553 ut_params->ibuf, aad_len);
12554 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12555 "no room to prepend aad");
12556 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12559 memset(sym_op->aead.aad.data, 0, aad_len);
12560 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12561 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12563 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12564 debug_hexdump(stdout, "aad:",
12565 sym_op->aead.aad.data, aad_len);
12567 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12568 uint8_t *, IV_OFFSET);
12570 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12572 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12574 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12575 ut_params->ibuf, aad_len_pad);
12576 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12577 "no room to prepend aad");
12578 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12581 memset(sym_op->aead.aad.data, 0, aad_len);
12582 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12584 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12585 debug_hexdump(stdout, "aad:",
12586 sym_op->aead.aad.data, aad_len);
12589 sym_op->aead.data.length = tdata->plaintext.len;
12590 sym_op->aead.data.offset = aad_len_pad;
12595 #define SGL_MAX_NO 16
12598 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12599 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12601 struct crypto_testsuite_params *ts_params = &testsuite_params;
12602 struct crypto_unittest_params *ut_params = &unittest_params;
12603 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12606 int to_trn_tbl[SGL_MAX_NO];
12608 unsigned int trn_data = 0;
12609 uint8_t *plaintext, *ciphertext, *auth_tag;
12610 struct rte_cryptodev_info dev_info;
12612 /* Verify the capabilities */
12613 struct rte_cryptodev_sym_capability_idx cap_idx;
12614 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12615 cap_idx.algo.aead = tdata->algo;
12616 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12620 /* OOP not supported with CPU crypto */
12621 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12624 /* Detailed check for the particular SGL support flag */
12625 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12627 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12628 if (sgl_in && (!(dev_info.feature_flags &
12629 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12632 uint64_t feat_flags = dev_info.feature_flags;
12634 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12635 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12636 printf("Device doesn't support RAW data-path APIs.\n");
12640 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12641 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12642 tdata->plaintext.len;
12643 /* Raw data path API does not support OOP */
12644 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12646 if (sgl_in && !sgl_out) {
12647 if (!(dev_info.feature_flags &
12648 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12650 } else if (!sgl_in && sgl_out) {
12651 if (!(dev_info.feature_flags &
12652 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12654 } else if (sgl_in && sgl_out) {
12655 if (!(dev_info.feature_flags &
12656 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12661 if (fragsz > tdata->plaintext.len)
12662 fragsz = tdata->plaintext.len;
12664 uint16_t plaintext_len = fragsz;
12665 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
12667 if (fragsz_oop > tdata->plaintext.len)
12668 frag_size_oop = tdata->plaintext.len;
12671 void *digest_mem = NULL;
12673 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
12675 if (tdata->plaintext.len % fragsz != 0) {
12676 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
12679 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
12684 * For out-op-place we need to alloc another mbuf
12687 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12688 rte_pktmbuf_append(ut_params->obuf,
12689 frag_size_oop + prepend_len);
12690 buf_oop = ut_params->obuf;
12693 /* Create AEAD session */
12694 retval = create_aead_session(ts_params->valid_devs[0],
12696 RTE_CRYPTO_AEAD_OP_ENCRYPT,
12697 tdata->key.data, tdata->key.len,
12698 tdata->aad.len, tdata->auth_tag.len,
12703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12705 /* clear mbuf payload */
12706 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12707 rte_pktmbuf_tailroom(ut_params->ibuf));
12709 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12712 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12714 trn_data += plaintext_len;
12716 buf = ut_params->ibuf;
12719 * Loop until no more fragments
12722 while (trn_data < tdata->plaintext.len) {
12724 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12725 (tdata->plaintext.len - trn_data) : fragsz;
12727 to_trn_tbl[ecx++] = to_trn;
12729 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12732 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12733 rte_pktmbuf_tailroom(buf));
12736 if (oop && !fragsz_oop) {
12737 buf_last_oop = buf_oop->next =
12738 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12739 buf_oop = buf_oop->next;
12740 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12741 0, rte_pktmbuf_tailroom(buf_oop));
12742 rte_pktmbuf_append(buf_oop, to_trn);
12745 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12748 memcpy(plaintext, tdata->plaintext.data + trn_data,
12750 trn_data += to_trn;
12751 if (trn_data == tdata->plaintext.len) {
12754 digest_mem = rte_pktmbuf_append(buf_oop,
12755 tdata->auth_tag.len);
12757 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12758 tdata->auth_tag.len);
12762 uint64_t digest_phys = 0;
12764 ut_params->ibuf->nb_segs = segs;
12767 if (fragsz_oop && oop) {
12771 if (frag_size_oop == tdata->plaintext.len) {
12772 digest_mem = rte_pktmbuf_append(ut_params->obuf,
12773 tdata->auth_tag.len);
12775 digest_phys = rte_pktmbuf_iova_offset(
12777 tdata->plaintext.len + prepend_len);
12780 trn_data = frag_size_oop;
12781 while (trn_data < tdata->plaintext.len) {
12784 (tdata->plaintext.len - trn_data <
12786 (tdata->plaintext.len - trn_data) :
12789 to_trn_tbl[ecx++] = to_trn;
12791 buf_last_oop = buf_oop->next =
12792 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12793 buf_oop = buf_oop->next;
12794 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12795 0, rte_pktmbuf_tailroom(buf_oop));
12796 rte_pktmbuf_append(buf_oop, to_trn);
12798 trn_data += to_trn;
12800 if (trn_data == tdata->plaintext.len) {
12801 digest_mem = rte_pktmbuf_append(buf_oop,
12802 tdata->auth_tag.len);
12806 ut_params->obuf->nb_segs = segs;
12810 * Place digest at the end of the last buffer
12813 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12814 if (oop && buf_last_oop)
12815 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
12817 if (!digest_mem && !oop) {
12818 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12819 + tdata->auth_tag.len);
12820 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12821 tdata->plaintext.len);
12824 /* Create AEAD operation */
12825 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
12826 tdata, digest_mem, digest_phys);
12831 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12833 ut_params->op->sym->m_src = ut_params->ibuf;
12835 ut_params->op->sym->m_dst = ut_params->obuf;
12837 /* Process crypto operation */
12838 if (oop == IN_PLACE &&
12839 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12840 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12841 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12842 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12843 ut_params->op, 0, 0, 0, 0);
12845 TEST_ASSERT_NOT_NULL(
12846 process_crypto_request(ts_params->valid_devs[0],
12847 ut_params->op), "failed to process sym crypto op");
12849 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12850 "crypto op processing failed");
12853 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12854 uint8_t *, prepend_len);
12856 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12857 uint8_t *, prepend_len);
12861 fragsz = fragsz_oop;
12863 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12865 tdata->ciphertext.data,
12867 "Ciphertext data not as expected");
12869 buf = ut_params->op->sym->m_src->next;
12871 buf = ut_params->op->sym->m_dst->next;
12873 unsigned int off = fragsz;
12877 ciphertext = rte_pktmbuf_mtod(buf,
12880 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12882 tdata->ciphertext.data + off,
12884 "Ciphertext data not as expected");
12886 off += to_trn_tbl[ecx++];
12890 auth_tag = digest_mem;
12891 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12893 tdata->auth_tag.data,
12894 tdata->auth_tag.len,
12895 "Generated auth tag not as expected");
12901 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
12903 return test_authenticated_encryption_SGL(
12904 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
12908 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
12910 return test_authenticated_encryption_SGL(
12911 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
12915 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
12917 return test_authenticated_encryption_SGL(
12918 &gcm_test_case_8, OUT_OF_PLACE, 400,
12919 gcm_test_case_8.plaintext.len);
12923 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
12925 /* This test is not for OPENSSL PMD */
12926 if (gbl_driver_id == rte_cryptodev_driver_id_get(
12927 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
12930 return test_authenticated_encryption_SGL(
12931 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
12935 test_authentication_verify_fail_when_data_corrupted(
12936 struct crypto_testsuite_params *ts_params,
12937 struct crypto_unittest_params *ut_params,
12938 const struct test_crypto_vector *reference)
12940 return test_authentication_verify_fail_when_data_corruption(
12941 ts_params, ut_params, reference, 1);
12945 test_authentication_verify_fail_when_tag_corrupted(
12946 struct crypto_testsuite_params *ts_params,
12947 struct crypto_unittest_params *ut_params,
12948 const struct test_crypto_vector *reference)
12950 return test_authentication_verify_fail_when_data_corruption(
12951 ts_params, ut_params, reference, 0);
12955 test_authentication_verify_GMAC_fail_when_data_corrupted(
12956 struct crypto_testsuite_params *ts_params,
12957 struct crypto_unittest_params *ut_params,
12958 const struct test_crypto_vector *reference)
12960 return test_authentication_verify_GMAC_fail_when_corruption(
12961 ts_params, ut_params, reference, 1);
12965 test_authentication_verify_GMAC_fail_when_tag_corrupted(
12966 struct crypto_testsuite_params *ts_params,
12967 struct crypto_unittest_params *ut_params,
12968 const struct test_crypto_vector *reference)
12970 return test_authentication_verify_GMAC_fail_when_corruption(
12971 ts_params, ut_params, reference, 0);
12975 test_authenticated_decryption_fail_when_data_corrupted(
12976 struct crypto_testsuite_params *ts_params,
12977 struct crypto_unittest_params *ut_params,
12978 const struct test_crypto_vector *reference)
12980 return test_authenticated_decryption_fail_when_corruption(
12981 ts_params, ut_params, reference, 1);
12985 test_authenticated_decryption_fail_when_tag_corrupted(
12986 struct crypto_testsuite_params *ts_params,
12987 struct crypto_unittest_params *ut_params,
12988 const struct test_crypto_vector *reference)
12990 return test_authenticated_decryption_fail_when_corruption(
12991 ts_params, ut_params, reference, 0);
12995 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
12997 return test_authentication_verify_fail_when_data_corrupted(
12998 &testsuite_params, &unittest_params,
12999 &hmac_sha1_test_crypto_vector);
13003 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13005 return test_authentication_verify_fail_when_tag_corrupted(
13006 &testsuite_params, &unittest_params,
13007 &hmac_sha1_test_crypto_vector);
13011 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13013 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13014 &testsuite_params, &unittest_params,
13015 &aes128_gmac_test_vector);
13019 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13021 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13022 &testsuite_params, &unittest_params,
13023 &aes128_gmac_test_vector);
13027 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13029 return test_authenticated_decryption_fail_when_data_corrupted(
13032 &aes128cbc_hmac_sha1_test_vector);
13036 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13038 return test_authenticated_decryption_fail_when_tag_corrupted(
13041 &aes128cbc_hmac_sha1_test_vector);
13045 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13047 return test_authenticated_encryt_with_esn(
13050 &aes128cbc_hmac_sha1_aad_test_vector);
13054 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13056 return test_authenticated_decrypt_with_esn(
13059 &aes128cbc_hmac_sha1_aad_test_vector);
13063 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13065 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13069 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13071 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13074 #ifdef RTE_CRYPTO_SCHEDULER
13076 /* global AESNI worker IDs for the scheduler test */
13077 uint8_t aesni_ids[2];
13080 test_scheduler_attach_slave_op(void)
13082 struct crypto_testsuite_params *ts_params = &testsuite_params;
13083 uint8_t sched_id = ts_params->valid_devs[0];
13084 uint32_t nb_devs, i, nb_devs_attached = 0;
13086 char vdev_name[32];
13088 /* create 2 AESNI_MB if necessary */
13089 nb_devs = rte_cryptodev_device_count_by_driver(
13090 rte_cryptodev_driver_id_get(
13091 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13093 for (i = nb_devs; i < 2; i++) {
13094 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13095 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13097 ret = rte_vdev_init(vdev_name, NULL);
13099 TEST_ASSERT(ret == 0,
13100 "Failed to create instance %u of"
13102 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13106 /* attach 2 AESNI_MB cdevs */
13107 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13109 struct rte_cryptodev_info info;
13110 unsigned int session_size;
13112 rte_cryptodev_info_get(i, &info);
13113 if (info.driver_id != rte_cryptodev_driver_id_get(
13114 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13117 session_size = rte_cryptodev_sym_get_private_session_size(i);
13119 * Create the session mempool again, since now there are new devices
13120 * to use the mempool.
13122 if (ts_params->session_mpool) {
13123 rte_mempool_free(ts_params->session_mpool);
13124 ts_params->session_mpool = NULL;
13126 if (ts_params->session_priv_mpool) {
13127 rte_mempool_free(ts_params->session_priv_mpool);
13128 ts_params->session_priv_mpool = NULL;
13131 if (info.sym.max_nb_sessions != 0 &&
13132 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13133 RTE_LOG(ERR, USER1,
13134 "Device does not support "
13135 "at least %u sessions\n",
13137 return TEST_FAILED;
13140 * Create mempool with maximum number of sessions,
13141 * to include the session headers
13143 if (ts_params->session_mpool == NULL) {
13144 ts_params->session_mpool =
13145 rte_cryptodev_sym_session_pool_create(
13147 MAX_NB_SESSIONS, 0, 0, 0,
13149 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13150 "session mempool allocation failed");
13154 * Create mempool with maximum number of sessions,
13155 * to include device specific session private data
13157 if (ts_params->session_priv_mpool == NULL) {
13158 ts_params->session_priv_mpool = rte_mempool_create(
13159 "test_sess_mp_priv",
13162 0, 0, NULL, NULL, NULL,
13163 NULL, SOCKET_ID_ANY,
13166 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13167 "session mempool allocation failed");
13170 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13171 ts_params->qp_conf.mp_session_private =
13172 ts_params->session_priv_mpool;
13174 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13177 TEST_ASSERT(ret == 0,
13178 "Failed to attach device %u of pmd : %s", i,
13179 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13181 aesni_ids[nb_devs_attached] = (uint8_t)i;
13183 nb_devs_attached++;
13190 test_scheduler_detach_slave_op(void)
13192 struct crypto_testsuite_params *ts_params = &testsuite_params;
13193 uint8_t sched_id = ts_params->valid_devs[0];
13197 for (i = 0; i < 2; i++) {
13198 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13200 TEST_ASSERT(ret == 0,
13201 "Failed to detach device %u", aesni_ids[i]);
13208 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13210 struct crypto_testsuite_params *ts_params = &testsuite_params;
13211 uint8_t sched_id = ts_params->valid_devs[0];
13213 return rte_cryptodev_scheduler_mode_set(sched_id,
13218 test_scheduler_mode_roundrobin_op(void)
13220 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13221 0, "Failed to set roundrobin mode");
13227 test_scheduler_mode_multicore_op(void)
13229 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13230 0, "Failed to set multicore mode");
13236 test_scheduler_mode_failover_op(void)
13238 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13239 0, "Failed to set failover mode");
13245 test_scheduler_mode_pkt_size_distr_op(void)
13247 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13248 0, "Failed to set pktsize mode");
13253 static struct unit_test_suite cryptodev_scheduler_testsuite = {
13254 .suite_name = "Crypto Device Scheduler Unit Test Suite",
13255 .setup = testsuite_setup,
13256 .teardown = testsuite_teardown,
13257 .unit_test_cases = {
13259 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13260 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
13261 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13262 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13263 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13264 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13267 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13268 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
13269 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13270 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13271 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13272 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13275 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13276 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
13277 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13278 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13279 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13280 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13283 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
13284 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
13285 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13286 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13287 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13288 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
13290 TEST_CASES_END() /**< NULL terminate unit test array */
13294 #endif /* RTE_CRYPTO_SCHEDULER */
13296 static struct unit_test_suite cryptodev_testsuite = {
13297 .suite_name = "Crypto Unit Test Suite",
13298 .setup = testsuite_setup,
13299 .teardown = testsuite_teardown,
13300 .unit_test_cases = {
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_device_configure_invalid_dev_id),
13303 TEST_CASE_ST(ut_setup, ut_teardown,
13304 test_queue_pair_descriptor_setup),
13305 TEST_CASE_ST(ut_setup, ut_teardown,
13306 test_device_configure_invalid_queue_pair_ids),
13307 TEST_CASE_ST(ut_setup, ut_teardown,
13308 test_multi_session),
13309 TEST_CASE_ST(ut_setup, ut_teardown,
13310 test_multi_session_random_usage),
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 test_null_invalid_operation),
13314 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13315 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13316 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13317 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13318 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13319 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
13320 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
13321 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
13322 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13323 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13325 /** AES CCM Authenticated Encryption 128 bits key */
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_AES_CCM_authenticated_encryption_test_case_128_1),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_AES_CCM_authenticated_encryption_test_case_128_2),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_AES_CCM_authenticated_encryption_test_case_128_3),
13333 /** AES CCM Authenticated Decryption 128 bits key*/
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_AES_CCM_authenticated_decryption_test_case_128_1),
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 test_AES_CCM_authenticated_decryption_test_case_128_2),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 test_AES_CCM_authenticated_decryption_test_case_128_3),
13341 /** AES CCM Authenticated Encryption 192 bits key */
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 test_AES_CCM_authenticated_encryption_test_case_192_1),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 test_AES_CCM_authenticated_encryption_test_case_192_2),
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_AES_CCM_authenticated_encryption_test_case_192_3),
13349 /** AES CCM Authenticated Decryption 192 bits key*/
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_AES_CCM_authenticated_decryption_test_case_192_1),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_AES_CCM_authenticated_decryption_test_case_192_2),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_AES_CCM_authenticated_decryption_test_case_192_3),
13357 /** AES CCM Authenticated Encryption 256 bits key */
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_AES_CCM_authenticated_encryption_test_case_256_1),
13360 TEST_CASE_ST(ut_setup, ut_teardown,
13361 test_AES_CCM_authenticated_encryption_test_case_256_2),
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_AES_CCM_authenticated_encryption_test_case_256_3),
13365 /** AES CCM Authenticated Decryption 256 bits key*/
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_AES_CCM_authenticated_decryption_test_case_256_1),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_AES_CCM_authenticated_decryption_test_case_256_2),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_AES_CCM_authenticated_decryption_test_case_256_3),
13373 /** AES GCM Authenticated Encryption */
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_AES_GCM_authenticated_encryption_test_case_1),
13384 TEST_CASE_ST(ut_setup, ut_teardown,
13385 test_AES_GCM_authenticated_encryption_test_case_2),
13386 TEST_CASE_ST(ut_setup, ut_teardown,
13387 test_AES_GCM_authenticated_encryption_test_case_3),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_AES_GCM_authenticated_encryption_test_case_4),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_AES_GCM_authenticated_encryption_test_case_5),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_AES_GCM_authenticated_encryption_test_case_6),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_AES_GCM_authenticated_encryption_test_case_7),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_AES_GCM_authenticated_encryption_test_case_8),
13398 TEST_CASE_ST(ut_setup, ut_teardown,
13399 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13401 /** AES GCM Authenticated Decryption */
13402 TEST_CASE_ST(ut_setup, ut_teardown,
13403 test_AES_GCM_authenticated_decryption_test_case_1),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_AES_GCM_authenticated_decryption_test_case_2),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 test_AES_GCM_authenticated_decryption_test_case_3),
13408 TEST_CASE_ST(ut_setup, ut_teardown,
13409 test_AES_GCM_authenticated_decryption_test_case_4),
13410 TEST_CASE_ST(ut_setup, ut_teardown,
13411 test_AES_GCM_authenticated_decryption_test_case_5),
13412 TEST_CASE_ST(ut_setup, ut_teardown,
13413 test_AES_GCM_authenticated_decryption_test_case_6),
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_AES_GCM_authenticated_decryption_test_case_7),
13416 TEST_CASE_ST(ut_setup, ut_teardown,
13417 test_AES_GCM_authenticated_decryption_test_case_8),
13418 TEST_CASE_ST(ut_setup, ut_teardown,
13419 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13421 /** AES GCM Authenticated Encryption 192 bits key */
13422 TEST_CASE_ST(ut_setup, ut_teardown,
13423 test_AES_GCM_auth_encryption_test_case_192_1),
13424 TEST_CASE_ST(ut_setup, ut_teardown,
13425 test_AES_GCM_auth_encryption_test_case_192_2),
13426 TEST_CASE_ST(ut_setup, ut_teardown,
13427 test_AES_GCM_auth_encryption_test_case_192_3),
13428 TEST_CASE_ST(ut_setup, ut_teardown,
13429 test_AES_GCM_auth_encryption_test_case_192_4),
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_AES_GCM_auth_encryption_test_case_192_5),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_AES_GCM_auth_encryption_test_case_192_6),
13434 TEST_CASE_ST(ut_setup, ut_teardown,
13435 test_AES_GCM_auth_encryption_test_case_192_7),
13437 /** AES GCM Authenticated Decryption 192 bits key */
13438 TEST_CASE_ST(ut_setup, ut_teardown,
13439 test_AES_GCM_auth_decryption_test_case_192_1),
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 test_AES_GCM_auth_decryption_test_case_192_2),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 test_AES_GCM_auth_decryption_test_case_192_3),
13444 TEST_CASE_ST(ut_setup, ut_teardown,
13445 test_AES_GCM_auth_decryption_test_case_192_4),
13446 TEST_CASE_ST(ut_setup, ut_teardown,
13447 test_AES_GCM_auth_decryption_test_case_192_5),
13448 TEST_CASE_ST(ut_setup, ut_teardown,
13449 test_AES_GCM_auth_decryption_test_case_192_6),
13450 TEST_CASE_ST(ut_setup, ut_teardown,
13451 test_AES_GCM_auth_decryption_test_case_192_7),
13453 /** AES GCM Authenticated Encryption 256 bits key */
13454 TEST_CASE_ST(ut_setup, ut_teardown,
13455 test_AES_GCM_auth_encryption_test_case_256_1),
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 test_AES_GCM_auth_encryption_test_case_256_2),
13458 TEST_CASE_ST(ut_setup, ut_teardown,
13459 test_AES_GCM_auth_encryption_test_case_256_3),
13460 TEST_CASE_ST(ut_setup, ut_teardown,
13461 test_AES_GCM_auth_encryption_test_case_256_4),
13462 TEST_CASE_ST(ut_setup, ut_teardown,
13463 test_AES_GCM_auth_encryption_test_case_256_5),
13464 TEST_CASE_ST(ut_setup, ut_teardown,
13465 test_AES_GCM_auth_encryption_test_case_256_6),
13466 TEST_CASE_ST(ut_setup, ut_teardown,
13467 test_AES_GCM_auth_encryption_test_case_256_7),
13469 /** AES GCM Authenticated Decryption 256 bits key */
13470 TEST_CASE_ST(ut_setup, ut_teardown,
13471 test_AES_GCM_auth_decryption_test_case_256_1),
13472 TEST_CASE_ST(ut_setup, ut_teardown,
13473 test_AES_GCM_auth_decryption_test_case_256_2),
13474 TEST_CASE_ST(ut_setup, ut_teardown,
13475 test_AES_GCM_auth_decryption_test_case_256_3),
13476 TEST_CASE_ST(ut_setup, ut_teardown,
13477 test_AES_GCM_auth_decryption_test_case_256_4),
13478 TEST_CASE_ST(ut_setup, ut_teardown,
13479 test_AES_GCM_auth_decryption_test_case_256_5),
13480 TEST_CASE_ST(ut_setup, ut_teardown,
13481 test_AES_GCM_auth_decryption_test_case_256_6),
13482 TEST_CASE_ST(ut_setup, ut_teardown,
13483 test_AES_GCM_auth_decryption_test_case_256_7),
13485 /** AES GCM Authenticated Encryption big aad size */
13486 TEST_CASE_ST(ut_setup, ut_teardown,
13487 test_AES_GCM_auth_encryption_test_case_aad_1),
13488 TEST_CASE_ST(ut_setup, ut_teardown,
13489 test_AES_GCM_auth_encryption_test_case_aad_2),
13491 /** AES GCM Authenticated Decryption big aad size */
13492 TEST_CASE_ST(ut_setup, ut_teardown,
13493 test_AES_GCM_auth_decryption_test_case_aad_1),
13494 TEST_CASE_ST(ut_setup, ut_teardown,
13495 test_AES_GCM_auth_decryption_test_case_aad_2),
13497 /** Out of place tests */
13498 TEST_CASE_ST(ut_setup, ut_teardown,
13499 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13500 TEST_CASE_ST(ut_setup, ut_teardown,
13501 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13503 /** Session-less tests */
13504 TEST_CASE_ST(ut_setup, ut_teardown,
13505 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13506 TEST_CASE_ST(ut_setup, ut_teardown,
13507 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13509 /** AES GMAC Authentication */
13510 TEST_CASE_ST(ut_setup, ut_teardown,
13511 test_AES_GMAC_authentication_test_case_1),
13512 TEST_CASE_ST(ut_setup, ut_teardown,
13513 test_AES_GMAC_authentication_verify_test_case_1),
13514 TEST_CASE_ST(ut_setup, ut_teardown,
13515 test_AES_GMAC_authentication_test_case_2),
13516 TEST_CASE_ST(ut_setup, ut_teardown,
13517 test_AES_GMAC_authentication_verify_test_case_2),
13518 TEST_CASE_ST(ut_setup, ut_teardown,
13519 test_AES_GMAC_authentication_test_case_3),
13520 TEST_CASE_ST(ut_setup, ut_teardown,
13521 test_AES_GMAC_authentication_verify_test_case_3),
13522 TEST_CASE_ST(ut_setup, ut_teardown,
13523 test_AES_GMAC_authentication_test_case_4),
13524 TEST_CASE_ST(ut_setup, ut_teardown,
13525 test_AES_GMAC_authentication_verify_test_case_4),
13526 TEST_CASE_ST(ut_setup, ut_teardown,
13527 test_AES_GMAC_authentication_SGL_40B),
13528 TEST_CASE_ST(ut_setup, ut_teardown,
13529 test_AES_GMAC_authentication_SGL_80B),
13530 TEST_CASE_ST(ut_setup, ut_teardown,
13531 test_AES_GMAC_authentication_SGL_2048B),
13532 TEST_CASE_ST(ut_setup, ut_teardown,
13533 test_AES_GMAC_authentication_SGL_2047B),
13535 /** Chacha20-Poly1305 */
13536 TEST_CASE_ST(ut_setup, ut_teardown,
13537 test_chacha20_poly1305_encrypt_test_case_rfc8439),
13538 TEST_CASE_ST(ut_setup, ut_teardown,
13539 test_chacha20_poly1305_decrypt_test_case_rfc8439),
13540 /** SNOW 3G encrypt only (UEA2) */
13541 TEST_CASE_ST(ut_setup, ut_teardown,
13542 test_snow3g_encryption_test_case_1),
13543 TEST_CASE_ST(ut_setup, ut_teardown,
13544 test_snow3g_encryption_test_case_2),
13545 TEST_CASE_ST(ut_setup, ut_teardown,
13546 test_snow3g_encryption_test_case_3),
13547 TEST_CASE_ST(ut_setup, ut_teardown,
13548 test_snow3g_encryption_test_case_4),
13549 TEST_CASE_ST(ut_setup, ut_teardown,
13550 test_snow3g_encryption_test_case_5),
13552 TEST_CASE_ST(ut_setup, ut_teardown,
13553 test_snow3g_encryption_test_case_1_oop),
13554 TEST_CASE_ST(ut_setup, ut_teardown,
13555 test_snow3g_encryption_test_case_1_oop_sgl),
13556 TEST_CASE_ST(ut_setup, ut_teardown,
13557 test_snow3g_encryption_test_case_1_offset_oop),
13558 TEST_CASE_ST(ut_setup, ut_teardown,
13559 test_snow3g_decryption_test_case_1_oop),
13561 /** SNOW 3G generate auth, then encrypt (UEA2) */
13562 TEST_CASE_ST(ut_setup, ut_teardown,
13563 test_snow3g_auth_cipher_test_case_1),
13564 TEST_CASE_ST(ut_setup, ut_teardown,
13565 test_snow3g_auth_cipher_test_case_2),
13566 TEST_CASE_ST(ut_setup, ut_teardown,
13567 test_snow3g_auth_cipher_test_case_2_oop),
13568 TEST_CASE_ST(ut_setup, ut_teardown,
13569 test_snow3g_auth_cipher_part_digest_enc),
13570 TEST_CASE_ST(ut_setup, ut_teardown,
13571 test_snow3g_auth_cipher_part_digest_enc_oop),
13572 TEST_CASE_ST(ut_setup, ut_teardown,
13573 test_snow3g_auth_cipher_test_case_3_sgl),
13574 TEST_CASE_ST(ut_setup, ut_teardown,
13575 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13576 TEST_CASE_ST(ut_setup, ut_teardown,
13577 test_snow3g_auth_cipher_part_digest_enc_sgl),
13578 TEST_CASE_ST(ut_setup, ut_teardown,
13579 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13581 /** SNOW 3G decrypt (UEA2), then verify auth */
13582 TEST_CASE_ST(ut_setup, ut_teardown,
13583 test_snow3g_auth_cipher_verify_test_case_1),
13584 TEST_CASE_ST(ut_setup, ut_teardown,
13585 test_snow3g_auth_cipher_verify_test_case_2),
13586 TEST_CASE_ST(ut_setup, ut_teardown,
13587 test_snow3g_auth_cipher_verify_test_case_2_oop),
13588 TEST_CASE_ST(ut_setup, ut_teardown,
13589 test_snow3g_auth_cipher_verify_part_digest_enc),
13590 TEST_CASE_ST(ut_setup, ut_teardown,
13591 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13592 TEST_CASE_ST(ut_setup, ut_teardown,
13593 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13594 TEST_CASE_ST(ut_setup, ut_teardown,
13595 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13596 TEST_CASE_ST(ut_setup, ut_teardown,
13597 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13598 TEST_CASE_ST(ut_setup, ut_teardown,
13599 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13601 /** SNOW 3G decrypt only (UEA2) */
13602 TEST_CASE_ST(ut_setup, ut_teardown,
13603 test_snow3g_decryption_test_case_1),
13604 TEST_CASE_ST(ut_setup, ut_teardown,
13605 test_snow3g_decryption_test_case_2),
13606 TEST_CASE_ST(ut_setup, ut_teardown,
13607 test_snow3g_decryption_test_case_3),
13608 TEST_CASE_ST(ut_setup, ut_teardown,
13609 test_snow3g_decryption_test_case_4),
13610 TEST_CASE_ST(ut_setup, ut_teardown,
13611 test_snow3g_decryption_test_case_5),
13612 TEST_CASE_ST(ut_setup, ut_teardown,
13613 test_snow3g_decryption_with_digest_test_case_1),
13614 TEST_CASE_ST(ut_setup, ut_teardown,
13615 test_snow3g_hash_generate_test_case_1),
13616 TEST_CASE_ST(ut_setup, ut_teardown,
13617 test_snow3g_hash_generate_test_case_2),
13618 TEST_CASE_ST(ut_setup, ut_teardown,
13619 test_snow3g_hash_generate_test_case_3),
13620 /* Tests with buffers which length is not byte-aligned */
13621 TEST_CASE_ST(ut_setup, ut_teardown,
13622 test_snow3g_hash_generate_test_case_4),
13623 TEST_CASE_ST(ut_setup, ut_teardown,
13624 test_snow3g_hash_generate_test_case_5),
13625 TEST_CASE_ST(ut_setup, ut_teardown,
13626 test_snow3g_hash_generate_test_case_6),
13627 TEST_CASE_ST(ut_setup, ut_teardown,
13628 test_snow3g_hash_verify_test_case_1),
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 test_snow3g_hash_verify_test_case_2),
13631 TEST_CASE_ST(ut_setup, ut_teardown,
13632 test_snow3g_hash_verify_test_case_3),
13633 /* Tests with buffers which length is not byte-aligned */
13634 TEST_CASE_ST(ut_setup, ut_teardown,
13635 test_snow3g_hash_verify_test_case_4),
13636 TEST_CASE_ST(ut_setup, ut_teardown,
13637 test_snow3g_hash_verify_test_case_5),
13638 TEST_CASE_ST(ut_setup, ut_teardown,
13639 test_snow3g_hash_verify_test_case_6),
13640 TEST_CASE_ST(ut_setup, ut_teardown,
13641 test_snow3g_cipher_auth_test_case_1),
13642 TEST_CASE_ST(ut_setup, ut_teardown,
13643 test_snow3g_auth_cipher_with_digest_test_case_1),
13645 /** ZUC encrypt only (EEA3) */
13646 TEST_CASE_ST(ut_setup, ut_teardown,
13647 test_zuc_encryption_test_case_1),
13648 TEST_CASE_ST(ut_setup, ut_teardown,
13649 test_zuc_encryption_test_case_2),
13650 TEST_CASE_ST(ut_setup, ut_teardown,
13651 test_zuc_encryption_test_case_3),
13652 TEST_CASE_ST(ut_setup, ut_teardown,
13653 test_zuc_encryption_test_case_4),
13654 TEST_CASE_ST(ut_setup, ut_teardown,
13655 test_zuc_encryption_test_case_5),
13656 TEST_CASE_ST(ut_setup, ut_teardown,
13657 test_zuc_encryption_test_case_6_sgl),
13659 /** ZUC authenticate (EIA3) */
13660 TEST_CASE_ST(ut_setup, ut_teardown,
13661 test_zuc_hash_generate_test_case_1),
13662 TEST_CASE_ST(ut_setup, ut_teardown,
13663 test_zuc_hash_generate_test_case_2),
13664 TEST_CASE_ST(ut_setup, ut_teardown,
13665 test_zuc_hash_generate_test_case_3),
13666 TEST_CASE_ST(ut_setup, ut_teardown,
13667 test_zuc_hash_generate_test_case_4),
13668 TEST_CASE_ST(ut_setup, ut_teardown,
13669 test_zuc_hash_generate_test_case_5),
13670 TEST_CASE_ST(ut_setup, ut_teardown,
13671 test_zuc_hash_generate_test_case_6),
13672 TEST_CASE_ST(ut_setup, ut_teardown,
13673 test_zuc_hash_generate_test_case_7),
13674 TEST_CASE_ST(ut_setup, ut_teardown,
13675 test_zuc_hash_generate_test_case_8),
13677 /** ZUC alg-chain (EEA3/EIA3) */
13678 TEST_CASE_ST(ut_setup, ut_teardown,
13679 test_zuc_cipher_auth_test_case_1),
13680 TEST_CASE_ST(ut_setup, ut_teardown,
13681 test_zuc_cipher_auth_test_case_2),
13683 /** ZUC generate auth, then encrypt (EEA3) */
13684 TEST_CASE_ST(ut_setup, ut_teardown,
13685 test_zuc_auth_cipher_test_case_1),
13686 TEST_CASE_ST(ut_setup, ut_teardown,
13687 test_zuc_auth_cipher_test_case_1_oop),
13688 TEST_CASE_ST(ut_setup, ut_teardown,
13689 test_zuc_auth_cipher_test_case_1_sgl),
13690 TEST_CASE_ST(ut_setup, ut_teardown,
13691 test_zuc_auth_cipher_test_case_1_oop_sgl),
13693 /** ZUC decrypt (EEA3), then verify auth */
13694 TEST_CASE_ST(ut_setup, ut_teardown,
13695 test_zuc_auth_cipher_verify_test_case_1),
13696 TEST_CASE_ST(ut_setup, ut_teardown,
13697 test_zuc_auth_cipher_verify_test_case_1_oop),
13698 TEST_CASE_ST(ut_setup, ut_teardown,
13699 test_zuc_auth_cipher_verify_test_case_1_sgl),
13700 TEST_CASE_ST(ut_setup, ut_teardown,
13701 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
13703 /** HMAC_MD5 Authentication */
13704 TEST_CASE_ST(ut_setup, ut_teardown,
13705 test_MD5_HMAC_generate_case_1),
13706 TEST_CASE_ST(ut_setup, ut_teardown,
13707 test_MD5_HMAC_verify_case_1),
13708 TEST_CASE_ST(ut_setup, ut_teardown,
13709 test_MD5_HMAC_generate_case_2),
13710 TEST_CASE_ST(ut_setup, ut_teardown,
13711 test_MD5_HMAC_verify_case_2),
13713 /** KASUMI hash only (UIA1) */
13714 TEST_CASE_ST(ut_setup, ut_teardown,
13715 test_kasumi_hash_generate_test_case_1),
13716 TEST_CASE_ST(ut_setup, ut_teardown,
13717 test_kasumi_hash_generate_test_case_2),
13718 TEST_CASE_ST(ut_setup, ut_teardown,
13719 test_kasumi_hash_generate_test_case_3),
13720 TEST_CASE_ST(ut_setup, ut_teardown,
13721 test_kasumi_hash_generate_test_case_4),
13722 TEST_CASE_ST(ut_setup, ut_teardown,
13723 test_kasumi_hash_generate_test_case_5),
13724 TEST_CASE_ST(ut_setup, ut_teardown,
13725 test_kasumi_hash_generate_test_case_6),
13727 TEST_CASE_ST(ut_setup, ut_teardown,
13728 test_kasumi_hash_verify_test_case_1),
13729 TEST_CASE_ST(ut_setup, ut_teardown,
13730 test_kasumi_hash_verify_test_case_2),
13731 TEST_CASE_ST(ut_setup, ut_teardown,
13732 test_kasumi_hash_verify_test_case_3),
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 test_kasumi_hash_verify_test_case_4),
13735 TEST_CASE_ST(ut_setup, ut_teardown,
13736 test_kasumi_hash_verify_test_case_5),
13738 /** KASUMI encrypt only (UEA1) */
13739 TEST_CASE_ST(ut_setup, ut_teardown,
13740 test_kasumi_encryption_test_case_1),
13741 TEST_CASE_ST(ut_setup, ut_teardown,
13742 test_kasumi_encryption_test_case_1_sgl),
13743 TEST_CASE_ST(ut_setup, ut_teardown,
13744 test_kasumi_encryption_test_case_1_oop),
13745 TEST_CASE_ST(ut_setup, ut_teardown,
13746 test_kasumi_encryption_test_case_1_oop_sgl),
13747 TEST_CASE_ST(ut_setup, ut_teardown,
13748 test_kasumi_encryption_test_case_2),
13749 TEST_CASE_ST(ut_setup, ut_teardown,
13750 test_kasumi_encryption_test_case_3),
13751 TEST_CASE_ST(ut_setup, ut_teardown,
13752 test_kasumi_encryption_test_case_4),
13753 TEST_CASE_ST(ut_setup, ut_teardown,
13754 test_kasumi_encryption_test_case_5),
13756 /** KASUMI decrypt only (UEA1) */
13757 TEST_CASE_ST(ut_setup, ut_teardown,
13758 test_kasumi_decryption_test_case_1),
13759 TEST_CASE_ST(ut_setup, ut_teardown,
13760 test_kasumi_decryption_test_case_2),
13761 TEST_CASE_ST(ut_setup, ut_teardown,
13762 test_kasumi_decryption_test_case_3),
13763 TEST_CASE_ST(ut_setup, ut_teardown,
13764 test_kasumi_decryption_test_case_4),
13765 TEST_CASE_ST(ut_setup, ut_teardown,
13766 test_kasumi_decryption_test_case_5),
13767 TEST_CASE_ST(ut_setup, ut_teardown,
13768 test_kasumi_decryption_test_case_1_oop),
13770 TEST_CASE_ST(ut_setup, ut_teardown,
13771 test_kasumi_cipher_auth_test_case_1),
13773 /** KASUMI generate auth, then encrypt (F8) */
13774 TEST_CASE_ST(ut_setup, ut_teardown,
13775 test_kasumi_auth_cipher_test_case_1),
13776 TEST_CASE_ST(ut_setup, ut_teardown,
13777 test_kasumi_auth_cipher_test_case_2),
13778 TEST_CASE_ST(ut_setup, ut_teardown,
13779 test_kasumi_auth_cipher_test_case_2_oop),
13780 TEST_CASE_ST(ut_setup, ut_teardown,
13781 test_kasumi_auth_cipher_test_case_2_sgl),
13782 TEST_CASE_ST(ut_setup, ut_teardown,
13783 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13785 /** KASUMI decrypt (F8), then verify auth */
13786 TEST_CASE_ST(ut_setup, ut_teardown,
13787 test_kasumi_auth_cipher_verify_test_case_1),
13788 TEST_CASE_ST(ut_setup, ut_teardown,
13789 test_kasumi_auth_cipher_verify_test_case_2),
13790 TEST_CASE_ST(ut_setup, ut_teardown,
13791 test_kasumi_auth_cipher_verify_test_case_2_oop),
13792 TEST_CASE_ST(ut_setup, ut_teardown,
13793 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13794 TEST_CASE_ST(ut_setup, ut_teardown,
13795 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13797 /** ESN Testcase */
13798 TEST_CASE_ST(ut_setup, ut_teardown,
13799 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13800 TEST_CASE_ST(ut_setup, ut_teardown,
13801 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13803 /** Negative tests */
13804 TEST_CASE_ST(ut_setup, ut_teardown,
13805 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13806 TEST_CASE_ST(ut_setup, ut_teardown,
13807 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13810 TEST_CASE_ST(ut_setup, ut_teardown,
13811 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13812 TEST_CASE_ST(ut_setup, ut_teardown,
13813 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13814 TEST_CASE_ST(ut_setup, ut_teardown,
13815 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13816 TEST_CASE_ST(ut_setup, ut_teardown,
13817 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13818 TEST_CASE_ST(ut_setup, ut_teardown,
13819 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13820 TEST_CASE_ST(ut_setup, ut_teardown,
13821 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13822 TEST_CASE_ST(ut_setup, ut_teardown,
13823 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13824 TEST_CASE_ST(ut_setup, ut_teardown,
13825 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13826 TEST_CASE_ST(ut_setup, ut_teardown,
13827 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13828 TEST_CASE_ST(ut_setup, ut_teardown,
13829 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13830 TEST_CASE_ST(ut_setup, ut_teardown,
13831 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13832 TEST_CASE_ST(ut_setup, ut_teardown,
13833 authentication_verify_AES128_GMAC_fail_data_corrupt),
13834 TEST_CASE_ST(ut_setup, ut_teardown,
13835 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13836 TEST_CASE_ST(ut_setup, ut_teardown,
13837 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13838 TEST_CASE_ST(ut_setup, ut_teardown,
13839 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13841 /** Mixed CIPHER + HASH algorithms */
13842 /** AUTH AES CMAC + CIPHER AES CTR */
13843 TEST_CASE_ST(ut_setup, ut_teardown,
13844 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
13845 TEST_CASE_ST(ut_setup, ut_teardown,
13846 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13847 TEST_CASE_ST(ut_setup, ut_teardown,
13848 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13849 TEST_CASE_ST(ut_setup, ut_teardown,
13850 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13851 TEST_CASE_ST(ut_setup, ut_teardown,
13852 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
13853 TEST_CASE_ST(ut_setup, ut_teardown,
13854 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13855 TEST_CASE_ST(ut_setup, ut_teardown,
13856 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13857 TEST_CASE_ST(ut_setup, ut_teardown,
13858 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13860 /** AUTH ZUC + CIPHER SNOW3G */
13861 TEST_CASE_ST(ut_setup, ut_teardown,
13862 test_auth_zuc_cipher_snow_test_case_1),
13863 TEST_CASE_ST(ut_setup, ut_teardown,
13864 test_verify_auth_zuc_cipher_snow_test_case_1),
13865 /** AUTH AES CMAC + CIPHER SNOW3G */
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_auth_aes_cmac_cipher_snow_test_case_1),
13868 TEST_CASE_ST(ut_setup, ut_teardown,
13869 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
13870 /** AUTH ZUC + CIPHER AES CTR */
13871 TEST_CASE_ST(ut_setup, ut_teardown,
13872 test_auth_zuc_cipher_aes_ctr_test_case_1),
13873 TEST_CASE_ST(ut_setup, ut_teardown,
13874 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
13875 /** AUTH SNOW3G + CIPHER AES CTR */
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_auth_snow_cipher_aes_ctr_test_case_1),
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
13880 /** AUTH SNOW3G + CIPHER ZUC */
13881 TEST_CASE_ST(ut_setup, ut_teardown,
13882 test_auth_snow_cipher_zuc_test_case_1),
13883 TEST_CASE_ST(ut_setup, ut_teardown,
13884 test_verify_auth_snow_cipher_zuc_test_case_1),
13885 /** AUTH AES CMAC + CIPHER ZUC */
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_auth_aes_cmac_cipher_zuc_test_case_1),
13888 TEST_CASE_ST(ut_setup, ut_teardown,
13889 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
13891 /** AUTH NULL + CIPHER SNOW3G */
13892 TEST_CASE_ST(ut_setup, ut_teardown,
13893 test_auth_null_cipher_snow_test_case_1),
13894 TEST_CASE_ST(ut_setup, ut_teardown,
13895 test_verify_auth_null_cipher_snow_test_case_1),
13896 /** AUTH NULL + CIPHER ZUC */
13897 TEST_CASE_ST(ut_setup, ut_teardown,
13898 test_auth_null_cipher_zuc_test_case_1),
13899 TEST_CASE_ST(ut_setup, ut_teardown,
13900 test_verify_auth_null_cipher_zuc_test_case_1),
13901 /** AUTH SNOW3G + CIPHER NULL */
13902 TEST_CASE_ST(ut_setup, ut_teardown,
13903 test_auth_snow_cipher_null_test_case_1),
13904 TEST_CASE_ST(ut_setup, ut_teardown,
13905 test_verify_auth_snow_cipher_null_test_case_1),
13906 /** AUTH ZUC + CIPHER NULL */
13907 TEST_CASE_ST(ut_setup, ut_teardown,
13908 test_auth_zuc_cipher_null_test_case_1),
13909 TEST_CASE_ST(ut_setup, ut_teardown,
13910 test_verify_auth_zuc_cipher_null_test_case_1),
13911 /** AUTH NULL + CIPHER AES CTR */
13912 TEST_CASE_ST(ut_setup, ut_teardown,
13913 test_auth_null_cipher_aes_ctr_test_case_1),
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_verify_auth_null_cipher_aes_ctr_test_case_1),
13916 /** AUTH AES CMAC + CIPHER NULL */
13917 TEST_CASE_ST(ut_setup, ut_teardown,
13918 test_auth_aes_cmac_cipher_null_test_case_1),
13919 TEST_CASE_ST(ut_setup, ut_teardown,
13920 test_verify_auth_aes_cmac_cipher_null_test_case_1),
13922 #ifdef RTE_LIB_SECURITY
13923 TEST_CASE_ST(ut_setup_security, ut_teardown,
13924 test_PDCP_PROTO_all),
13925 TEST_CASE_ST(ut_setup_security, ut_teardown,
13926 test_DOCSIS_PROTO_all),
13928 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13929 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13930 TEST_CASES_END() /**< NULL terminate unit test array */
13934 static struct unit_test_suite cryptodev_virtio_testsuite = {
13935 .suite_name = "Crypto VIRTIO Unit Test Suite",
13936 .setup = testsuite_setup,
13937 .teardown = testsuite_teardown,
13938 .unit_test_cases = {
13939 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13941 TEST_CASES_END() /**< NULL terminate unit test array */
13945 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13946 .suite_name = "Crypto CAAM JR Unit Test Suite",
13947 .setup = testsuite_setup,
13948 .teardown = testsuite_teardown,
13949 .unit_test_cases = {
13950 TEST_CASE_ST(ut_setup, ut_teardown,
13951 test_device_configure_invalid_dev_id),
13952 TEST_CASE_ST(ut_setup, ut_teardown,
13953 test_multi_session),
13955 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13956 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13957 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13958 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13959 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13961 TEST_CASES_END() /**< NULL terminate unit test array */
13965 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13966 .suite_name = "Crypto Device Marvell Component Test Suite",
13967 .setup = testsuite_setup,
13968 .teardown = testsuite_teardown,
13969 .unit_test_cases = {
13970 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13971 TEST_CASE_ST(ut_setup, ut_teardown,
13972 test_multi_session_random_usage),
13973 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13974 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13975 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13976 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13977 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13979 /** Negative tests */
13980 TEST_CASE_ST(ut_setup, ut_teardown,
13981 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13982 TEST_CASE_ST(ut_setup, ut_teardown,
13983 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13984 TEST_CASE_ST(ut_setup, ut_teardown,
13985 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13986 TEST_CASE_ST(ut_setup, ut_teardown,
13987 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13989 TEST_CASES_END() /**< NULL terminate unit test array */
13993 static struct unit_test_suite cryptodev_ccp_testsuite = {
13994 .suite_name = "Crypto Device CCP Unit Test Suite",
13995 .setup = testsuite_setup,
13996 .teardown = testsuite_teardown,
13997 .unit_test_cases = {
13998 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13999 TEST_CASE_ST(ut_setup, ut_teardown,
14000 test_multi_session_random_usage),
14001 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
14002 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
14003 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
14004 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
14005 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
14007 /** Negative tests */
14008 TEST_CASE_ST(ut_setup, ut_teardown,
14009 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14010 TEST_CASE_ST(ut_setup, ut_teardown,
14011 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14012 TEST_CASE_ST(ut_setup, ut_teardown,
14013 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14014 TEST_CASE_ST(ut_setup, ut_teardown,
14015 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14017 TEST_CASES_END() /**< NULL terminate unit test array */
14022 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14024 gbl_driver_id = rte_cryptodev_driver_id_get(
14025 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14027 if (gbl_driver_id == -1) {
14028 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14029 return TEST_SKIPPED;
14032 return unit_test_suite_runner(&cryptodev_testsuite);
14036 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14038 gbl_driver_id = rte_cryptodev_driver_id_get(
14039 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14041 if (gbl_driver_id == -1) {
14042 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
14043 return TEST_FAILED;
14046 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14050 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14052 gbl_driver_id = rte_cryptodev_driver_id_get(
14053 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14055 if (gbl_driver_id == -1) {
14056 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14057 return TEST_SKIPPED;
14060 return unit_test_suite_runner(&cryptodev_testsuite);
14064 test_cryptodev_cpu_aesni_mb(void)
14067 enum rte_security_session_action_type at;
14069 gbl_driver_id = rte_cryptodev_driver_id_get(
14070 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14072 if (gbl_driver_id == -1) {
14073 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14074 return TEST_SKIPPED;
14077 at = gbl_action_type;
14078 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14079 rc = unit_test_suite_runner(&cryptodev_testsuite);
14080 gbl_action_type = at;
14085 test_cryptodev_openssl(void)
14087 gbl_driver_id = rte_cryptodev_driver_id_get(
14088 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14090 if (gbl_driver_id == -1) {
14091 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
14092 return TEST_SKIPPED;
14095 return unit_test_suite_runner(&cryptodev_testsuite);
14099 test_cryptodev_aesni_gcm(void)
14101 gbl_driver_id = rte_cryptodev_driver_id_get(
14102 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14104 if (gbl_driver_id == -1) {
14105 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14106 return TEST_SKIPPED;
14109 return unit_test_suite_runner(&cryptodev_testsuite);
14113 test_cryptodev_cpu_aesni_gcm(void)
14116 enum rte_security_session_action_type at;
14118 gbl_driver_id = rte_cryptodev_driver_id_get(
14119 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14121 if (gbl_driver_id == -1) {
14122 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
14123 return TEST_SKIPPED;
14126 at = gbl_action_type;
14127 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14128 rc = unit_test_suite_runner(&cryptodev_testsuite);
14129 gbl_action_type = at;
14134 test_cryptodev_null(void)
14136 gbl_driver_id = rte_cryptodev_driver_id_get(
14137 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14139 if (gbl_driver_id == -1) {
14140 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
14141 return TEST_SKIPPED;
14144 return unit_test_suite_runner(&cryptodev_testsuite);
14148 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14150 gbl_driver_id = rte_cryptodev_driver_id_get(
14151 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14153 if (gbl_driver_id == -1) {
14154 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
14155 return TEST_SKIPPED;
14158 return unit_test_suite_runner(&cryptodev_testsuite);
14162 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14164 gbl_driver_id = rte_cryptodev_driver_id_get(
14165 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14167 if (gbl_driver_id == -1) {
14168 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14169 return TEST_SKIPPED;
14172 return unit_test_suite_runner(&cryptodev_testsuite);
14176 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14178 gbl_driver_id = rte_cryptodev_driver_id_get(
14179 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14181 if (gbl_driver_id == -1) {
14182 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
14183 return TEST_SKIPPED;
14186 return unit_test_suite_runner(&cryptodev_testsuite);
14190 test_cryptodev_armv8(void)
14192 gbl_driver_id = rte_cryptodev_driver_id_get(
14193 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14195 if (gbl_driver_id == -1) {
14196 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
14197 return TEST_SKIPPED;
14200 return unit_test_suite_runner(&cryptodev_testsuite);
14204 test_cryptodev_mrvl(void)
14206 gbl_driver_id = rte_cryptodev_driver_id_get(
14207 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14209 if (gbl_driver_id == -1) {
14210 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
14211 return TEST_SKIPPED;
14214 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14217 #ifdef RTE_CRYPTO_SCHEDULER
14220 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14222 gbl_driver_id = rte_cryptodev_driver_id_get(
14223 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14225 if (gbl_driver_id == -1) {
14226 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14227 return TEST_SKIPPED;
14230 if (rte_cryptodev_driver_id_get(
14231 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14232 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14233 return TEST_SKIPPED;
14235 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14238 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14243 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14245 gbl_driver_id = rte_cryptodev_driver_id_get(
14246 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14248 if (gbl_driver_id == -1) {
14249 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
14250 return TEST_SKIPPED;
14253 return unit_test_suite_runner(&cryptodev_testsuite);
14257 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14259 gbl_driver_id = rte_cryptodev_driver_id_get(
14260 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14262 if (gbl_driver_id == -1) {
14263 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
14264 return TEST_SKIPPED;
14267 return unit_test_suite_runner(&cryptodev_testsuite);
14271 test_cryptodev_ccp(void)
14273 gbl_driver_id = rte_cryptodev_driver_id_get(
14274 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14276 if (gbl_driver_id == -1) {
14277 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
14278 return TEST_FAILED;
14281 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14285 test_cryptodev_octeontx(void)
14287 gbl_driver_id = rte_cryptodev_driver_id_get(
14288 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14289 if (gbl_driver_id == -1) {
14290 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
14291 return TEST_FAILED;
14293 return unit_test_suite_runner(&cryptodev_testsuite);
14297 test_cryptodev_octeontx2(void)
14299 gbl_driver_id = rte_cryptodev_driver_id_get(
14300 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14301 if (gbl_driver_id == -1) {
14302 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
14303 return TEST_FAILED;
14305 return unit_test_suite_runner(&cryptodev_testsuite);
14309 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14311 gbl_driver_id = rte_cryptodev_driver_id_get(
14312 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14314 if (gbl_driver_id == -1) {
14315 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
14316 return TEST_FAILED;
14319 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14323 test_cryptodev_nitrox(void)
14325 gbl_driver_id = rte_cryptodev_driver_id_get(
14326 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14328 if (gbl_driver_id == -1) {
14329 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
14330 return TEST_FAILED;
14333 return unit_test_suite_runner(&cryptodev_testsuite);
14337 test_cryptodev_bcmfs(void)
14339 gbl_driver_id = rte_cryptodev_driver_id_get(
14340 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14342 if (gbl_driver_id == -1) {
14343 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
14344 return TEST_FAILED;
14347 return unit_test_suite_runner(&cryptodev_testsuite);
14351 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14355 gbl_driver_id = rte_cryptodev_driver_id_get(
14356 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14358 if (gbl_driver_id == -1) {
14359 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
14360 return TEST_SKIPPED;
14363 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14364 ret = unit_test_suite_runner(&cryptodev_testsuite);
14365 global_api_test_type = CRYPTODEV_API_TEST;
14370 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14371 test_cryptodev_qat_raw_api);
14372 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14373 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14374 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14375 test_cryptodev_cpu_aesni_mb);
14376 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14377 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14378 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14379 test_cryptodev_cpu_aesni_gcm);
14380 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14381 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14382 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14383 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14384 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14385 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14386 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14387 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14388 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14389 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14390 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14391 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14392 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14393 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14394 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);