1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
14 #include <rte_ether.h>
16 #include <rte_crypto.h>
17 #include <rte_cryptodev.h>
18 #include <rte_cryptodev_pmd.h>
19 #include <rte_string_fns.h>
21 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
22 #include <rte_cryptodev_scheduler.h>
23 #include <rte_cryptodev_scheduler_operations.h>
26 #include <rte_lcore.h>
29 #include "test_cryptodev.h"
31 #include "test_cryptodev_blockcipher.h"
32 #include "test_cryptodev_aes_test_vectors.h"
33 #include "test_cryptodev_des_test_vectors.h"
34 #include "test_cryptodev_hash_test_vectors.h"
35 #include "test_cryptodev_kasumi_test_vectors.h"
36 #include "test_cryptodev_kasumi_hash_test_vectors.h"
37 #include "test_cryptodev_snow3g_test_vectors.h"
38 #include "test_cryptodev_snow3g_hash_test_vectors.h"
39 #include "test_cryptodev_zuc_test_vectors.h"
40 #include "test_cryptodev_aead_test_vectors.h"
41 #include "test_cryptodev_hmac_test_vectors.h"
42 #include "test_cryptodev_mixed_test_vectors.h"
43 #ifdef RTE_LIBRTE_SECURITY
44 #include "test_cryptodev_security_pdcp_test_vectors.h"
45 #include "test_cryptodev_security_pdcp_test_func.h"
46 #include "test_cryptodev_security_docsis_test_vectors.h"
49 #define VDEV_ARGS_SIZE 100
50 #define MAX_NB_SESSIONS 4
52 #define MAX_DRV_SERVICE_CTX_SIZE 256
54 #define MAX_RAW_DEQUEUE_COUNT 65535
57 #define OUT_OF_PLACE 1
59 static int gbl_driver_id;
61 static enum rte_security_session_action_type gbl_action_type =
62 RTE_SECURITY_ACTION_TYPE_NONE;
64 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
66 struct crypto_testsuite_params {
67 struct rte_mempool *mbuf_pool;
68 struct rte_mempool *large_mbuf_pool;
69 struct rte_mempool *op_mpool;
70 struct rte_mempool *session_mpool;
71 struct rte_mempool *session_priv_mpool;
72 struct rte_cryptodev_config conf;
73 struct rte_cryptodev_qp_conf qp_conf;
75 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
76 uint8_t valid_dev_count;
79 struct crypto_unittest_params {
80 struct rte_crypto_sym_xform cipher_xform;
81 struct rte_crypto_sym_xform auth_xform;
82 struct rte_crypto_sym_xform aead_xform;
83 #ifdef RTE_LIBRTE_SECURITY
84 struct rte_security_docsis_xform docsis_xform;
88 struct rte_cryptodev_sym_session *sess;
89 #ifdef RTE_LIBRTE_SECURITY
90 struct rte_security_session *sec_session;
93 #ifdef RTE_LIBRTE_SECURITY
94 enum rte_security_session_action_type type;
96 struct rte_crypto_op *op;
98 struct rte_mbuf *obuf, *ibuf;
103 #define ALIGN_POW2_ROUNDUP(num, align) \
104 (((num) + (align) - 1) & ~((align) - 1))
107 * Forward declarations.
110 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
111 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
115 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
116 struct crypto_unittest_params *ut_params,
117 struct crypto_testsuite_params *ts_param,
118 const uint8_t *cipher,
119 const uint8_t *digest,
122 static struct rte_mbuf *
123 setup_test_string(struct rte_mempool *mpool,
124 const char *string, size_t len, uint8_t blocksize)
126 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
127 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
129 memset(m->buf_addr, 0, m->buf_len);
131 char *dst = rte_pktmbuf_append(m, t_len);
138 rte_memcpy(dst, string, t_len);
140 memset(dst, 0, t_len);
146 /* Get number of bytes in X bits (rounding up) */
148 ceil_byte_length(uint32_t num_bits)
151 return ((num_bits >> 3) + 1);
153 return (num_bits >> 3);
157 get_raw_dp_dequeue_count(void *user_data __rte_unused)
163 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
164 uint8_t is_op_success)
166 struct rte_crypto_op *op = user_data;
167 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
168 RTE_CRYPTO_OP_STATUS_ERROR;
172 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
173 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
174 uint8_t len_in_bits, uint8_t cipher_iv_len)
176 struct rte_crypto_sym_op *sop = op->sym;
177 struct rte_crypto_op *ret_op = NULL;
178 struct rte_crypto_vec data_vec[UINT8_MAX];
179 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
180 union rte_crypto_sym_ofs ofs;
181 struct rte_crypto_sym_vec vec;
182 struct rte_crypto_sgl sgl;
184 union rte_cryptodev_session_ctx sess;
186 struct rte_crypto_raw_dp_ctx *ctx;
187 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
191 int ctx_service_size;
193 int enqueue_status, dequeue_status;
195 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
196 if (ctx_service_size < 0) {
197 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
201 ctx = malloc(ctx_service_size);
203 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
207 /* Both are enums, setting crypto_sess will suit any session type */
208 sess.crypto_sess = op->sym->session;
210 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
211 op->sess_type, sess, 0) < 0) {
212 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
218 aad_auth_iv.iova = 0;
219 aad_auth_iv.va = NULL;
226 vec.digest = &digest;
227 vec.aad = &aad_auth_iv;
228 vec.status = &status;
232 if (is_cipher && is_auth) {
233 cipher_offset = sop->cipher.data.offset;
234 cipher_len = sop->cipher.data.length;
235 auth_offset = sop->auth.data.offset;
236 auth_len = sop->auth.data.length;
237 max_len = RTE_MAX(cipher_offset + cipher_len,
238 auth_offset + auth_len);
240 max_len = max_len >> 3;
241 cipher_offset = cipher_offset >> 3;
242 auth_offset = auth_offset >> 3;
243 cipher_len = cipher_len >> 3;
244 auth_len = auth_len >> 3;
246 ofs.ofs.cipher.head = cipher_offset;
247 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
248 ofs.ofs.auth.head = auth_offset;
249 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
250 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
251 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
252 aad_auth_iv.va = rte_crypto_op_ctod_offset(
253 op, void *, IV_OFFSET + cipher_iv_len);
254 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
256 digest.va = (void *)sop->auth.digest.data;
257 digest.iova = sop->auth.digest.phys_addr;
259 } else if (is_cipher) {
260 cipher_offset = sop->cipher.data.offset;
261 cipher_len = sop->cipher.data.length;
262 max_len = cipher_len + cipher_offset;
264 max_len = max_len >> 3;
265 cipher_offset = cipher_offset >> 3;
266 cipher_len = cipher_len >> 3;
268 ofs.ofs.cipher.head = cipher_offset;
269 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
270 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
271 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
273 } else if (is_auth) {
274 auth_offset = sop->auth.data.offset;
275 auth_len = sop->auth.data.length;
276 max_len = auth_len + auth_offset;
278 max_len = max_len >> 3;
279 auth_offset = auth_offset >> 3;
280 auth_len = auth_len >> 3;
282 ofs.ofs.auth.head = auth_offset;
283 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
284 aad_auth_iv.va = rte_crypto_op_ctod_offset(
285 op, void *, IV_OFFSET + cipher_iv_len);
286 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
288 digest.va = (void *)sop->auth.digest.data;
289 digest.iova = sop->auth.digest.phys_addr;
292 cipher_offset = sop->aead.data.offset;
293 cipher_len = sop->aead.data.length;
294 max_len = cipher_len + cipher_offset;
296 max_len = max_len >> 3;
297 cipher_offset = cipher_offset >> 3;
298 cipher_len = cipher_len >> 3;
300 ofs.ofs.cipher.head = cipher_offset;
301 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
302 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
303 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
304 aad_auth_iv.va = (void *)sop->aead.aad.data;
305 aad_auth_iv.iova = sop->aead.aad.phys_addr;
306 digest.va = (void *)sop->aead.digest.data;
307 digest.iova = sop->aead.digest.phys_addr;
310 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
311 data_vec, RTE_DIM(data_vec));
312 if (n < 0 || n > sop->m_src->nb_segs) {
313 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
319 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
320 &enqueue_status) < 1) {
321 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
325 if (enqueue_status == 0) {
326 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
328 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
331 } else if (enqueue_status < 0) {
332 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
337 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
338 n = rte_cryptodev_raw_dequeue_burst(ctx,
339 get_raw_dp_dequeue_count, post_process_raw_dp_op,
340 (void **)&ret_op, 0, &n_success,
342 if (dequeue_status < 0) {
343 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
350 if (n == 1 && dequeue_status == 0) {
351 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
352 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
357 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
358 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
359 RTE_CRYPTO_OP_STATUS_SUCCESS;
366 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
369 struct rte_crypto_sym_op *sop;
370 union rte_crypto_sym_ofs ofs;
371 struct rte_crypto_sgl sgl;
372 struct rte_crypto_sym_vec symvec;
373 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
374 struct rte_crypto_vec vec[UINT8_MAX];
378 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
379 sop->aead.data.length, vec, RTE_DIM(vec));
381 if (n < 0 || n != sop->m_src->nb_segs) {
382 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
390 symvec.digest = &digest_ptr;
391 symvec.aad = &aad_ptr;
395 /* for CPU crypto the IOVA address is not required */
396 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
397 digest_ptr.va = (void *)sop->aead.digest.data;
398 aad_ptr.va = (void *)sop->aead.aad.data;
402 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
406 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
408 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
412 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
415 struct rte_crypto_sym_op *sop;
416 union rte_crypto_sym_ofs ofs;
417 struct rte_crypto_sgl sgl;
418 struct rte_crypto_sym_vec symvec;
419 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
420 struct rte_crypto_vec vec[UINT8_MAX];
424 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
425 sop->auth.data.length, vec, RTE_DIM(vec));
427 if (n < 0 || n != sop->m_src->nb_segs) {
428 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
436 symvec.digest = &digest_ptr;
440 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
441 digest_ptr.va = (void *)sop->auth.digest.data;
444 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
445 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
446 (sop->cipher.data.offset + sop->cipher.data.length);
448 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
452 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
454 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
457 static struct rte_crypto_op *
458 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
461 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
463 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
464 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
470 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
473 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
474 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
481 static struct crypto_testsuite_params testsuite_params = { NULL };
482 static struct crypto_unittest_params unittest_params;
485 testsuite_setup(void)
487 struct crypto_testsuite_params *ts_params = &testsuite_params;
488 struct rte_cryptodev_info info;
489 uint32_t i = 0, nb_devs, dev_id;
493 memset(ts_params, 0, sizeof(*ts_params));
495 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
496 if (ts_params->mbuf_pool == NULL) {
497 /* Not already created so create */
498 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
500 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
502 if (ts_params->mbuf_pool == NULL) {
503 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
508 ts_params->large_mbuf_pool = rte_mempool_lookup(
509 "CRYPTO_LARGE_MBUFPOOL");
510 if (ts_params->large_mbuf_pool == NULL) {
511 /* Not already created so create */
512 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
513 "CRYPTO_LARGE_MBUFPOOL",
516 if (ts_params->large_mbuf_pool == NULL) {
518 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
523 ts_params->op_mpool = rte_crypto_op_pool_create(
524 "MBUF_CRYPTO_SYM_OP_POOL",
525 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
526 NUM_MBUFS, MBUF_CACHE_SIZE,
528 sizeof(struct rte_crypto_sym_xform) +
531 if (ts_params->op_mpool == NULL) {
532 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
536 /* Create an AESNI MB device if required */
537 if (gbl_driver_id == rte_cryptodev_driver_id_get(
538 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
539 nb_devs = rte_cryptodev_device_count_by_driver(
540 rte_cryptodev_driver_id_get(
541 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
544 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
546 TEST_ASSERT(ret == 0,
547 "Failed to create instance of"
549 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
553 /* Create an AESNI GCM device if required */
554 if (gbl_driver_id == rte_cryptodev_driver_id_get(
555 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
556 nb_devs = rte_cryptodev_device_count_by_driver(
557 rte_cryptodev_driver_id_get(
558 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
560 TEST_ASSERT_SUCCESS(rte_vdev_init(
561 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
562 "Failed to create instance of"
564 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
568 /* Create a SNOW 3G device if required */
569 if (gbl_driver_id == rte_cryptodev_driver_id_get(
570 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
571 nb_devs = rte_cryptodev_device_count_by_driver(
572 rte_cryptodev_driver_id_get(
573 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
575 TEST_ASSERT_SUCCESS(rte_vdev_init(
576 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
577 "Failed to create instance of"
579 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
583 /* Create a KASUMI device if required */
584 if (gbl_driver_id == rte_cryptodev_driver_id_get(
585 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
586 nb_devs = rte_cryptodev_device_count_by_driver(
587 rte_cryptodev_driver_id_get(
588 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
590 TEST_ASSERT_SUCCESS(rte_vdev_init(
591 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
592 "Failed to create instance of"
594 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
598 /* Create a ZUC device if required */
599 if (gbl_driver_id == rte_cryptodev_driver_id_get(
600 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
601 nb_devs = rte_cryptodev_device_count_by_driver(
602 rte_cryptodev_driver_id_get(
603 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
605 TEST_ASSERT_SUCCESS(rte_vdev_init(
606 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
607 "Failed to create instance of"
609 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
613 /* Create a NULL device if required */
614 if (gbl_driver_id == rte_cryptodev_driver_id_get(
615 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
616 nb_devs = rte_cryptodev_device_count_by_driver(
617 rte_cryptodev_driver_id_get(
618 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
621 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
623 TEST_ASSERT(ret == 0,
624 "Failed to create instance of"
626 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
630 /* Create an OPENSSL device if required */
631 if (gbl_driver_id == rte_cryptodev_driver_id_get(
632 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
633 nb_devs = rte_cryptodev_device_count_by_driver(
634 rte_cryptodev_driver_id_get(
635 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
638 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
641 TEST_ASSERT(ret == 0, "Failed to create "
642 "instance of pmd : %s",
643 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
647 /* Create a ARMv8 device if required */
648 if (gbl_driver_id == rte_cryptodev_driver_id_get(
649 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
650 nb_devs = rte_cryptodev_device_count_by_driver(
651 rte_cryptodev_driver_id_get(
652 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
655 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
658 TEST_ASSERT(ret == 0, "Failed to create "
659 "instance of pmd : %s",
660 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
664 /* Create a MVSAM device if required */
665 if (gbl_driver_id == rte_cryptodev_driver_id_get(
666 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
667 nb_devs = rte_cryptodev_device_count_by_driver(
668 rte_cryptodev_driver_id_get(
669 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
672 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
675 TEST_ASSERT(ret == 0, "Failed to create "
676 "instance of pmd : %s",
677 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
681 /* Create an CCP device if required */
682 if (gbl_driver_id == rte_cryptodev_driver_id_get(
683 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
684 nb_devs = rte_cryptodev_device_count_by_driver(
685 rte_cryptodev_driver_id_get(
686 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
689 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
692 TEST_ASSERT(ret == 0, "Failed to create "
693 "instance of pmd : %s",
694 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
698 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
699 char vdev_args[VDEV_ARGS_SIZE] = {""};
700 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
701 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
702 uint16_t worker_core_count = 0;
703 uint16_t socket_id = 0;
705 if (gbl_driver_id == rte_cryptodev_driver_id_get(
706 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
708 /* Identify the Worker Cores
709 * Use 2 worker cores for the device args
711 RTE_LCORE_FOREACH_SLAVE(i) {
712 if (worker_core_count > 1)
714 snprintf(vdev_args, sizeof(vdev_args),
715 "%s%d", temp_str, i);
716 strcpy(temp_str, vdev_args);
717 strlcat(temp_str, ";", sizeof(temp_str));
719 socket_id = rte_lcore_to_socket_id(i);
721 if (worker_core_count != 2) {
723 "Cryptodev scheduler test require at least "
724 "two worker cores to run. "
725 "Please use the correct coremask.\n");
728 strcpy(temp_str, vdev_args);
729 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
730 temp_str, socket_id);
731 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
732 nb_devs = rte_cryptodev_device_count_by_driver(
733 rte_cryptodev_driver_id_get(
734 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
737 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
739 TEST_ASSERT(ret == 0,
740 "Failed to create instance %u of"
742 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
745 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
747 nb_devs = rte_cryptodev_count();
749 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
753 /* Create list of valid crypto devs */
754 for (i = 0; i < nb_devs; i++) {
755 rte_cryptodev_info_get(i, &info);
756 if (info.driver_id == gbl_driver_id)
757 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
760 if (ts_params->valid_dev_count < 1)
763 /* Set up all the qps on the first of the valid devices found */
765 dev_id = ts_params->valid_devs[0];
767 rte_cryptodev_info_get(dev_id, &info);
769 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
770 ts_params->conf.socket_id = SOCKET_ID_ANY;
771 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
773 unsigned int session_size =
774 rte_cryptodev_sym_get_private_session_size(dev_id);
777 * Create mempool with maximum number of sessions * 2,
778 * to include the session headers
780 if (info.sym.max_nb_sessions != 0 &&
781 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
782 RTE_LOG(ERR, USER1, "Device does not support "
783 "at least %u sessions\n",
788 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
789 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
791 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
792 "session mempool allocation failed");
794 ts_params->session_priv_mpool = rte_mempool_create(
798 0, 0, NULL, NULL, NULL,
801 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
802 "session mempool allocation failed");
806 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
808 "Failed to configure cryptodev %u with %u qps",
809 dev_id, ts_params->conf.nb_queue_pairs);
811 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
812 ts_params->qp_conf.mp_session = ts_params->session_mpool;
813 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
815 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
816 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
817 dev_id, qp_id, &ts_params->qp_conf,
818 rte_cryptodev_socket_id(dev_id)),
819 "Failed to setup queue pair %u on cryptodev %u",
827 testsuite_teardown(void)
829 struct crypto_testsuite_params *ts_params = &testsuite_params;
831 if (ts_params->mbuf_pool != NULL) {
832 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
833 rte_mempool_avail_count(ts_params->mbuf_pool));
836 if (ts_params->op_mpool != NULL) {
837 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
838 rte_mempool_avail_count(ts_params->op_mpool));
841 /* Free session mempools */
842 if (ts_params->session_priv_mpool != NULL) {
843 rte_mempool_free(ts_params->session_priv_mpool);
844 ts_params->session_priv_mpool = NULL;
847 if (ts_params->session_mpool != NULL) {
848 rte_mempool_free(ts_params->session_mpool);
849 ts_params->session_mpool = NULL;
854 dev_configure_and_start(uint64_t ff_disable)
856 struct crypto_testsuite_params *ts_params = &testsuite_params;
857 struct crypto_unittest_params *ut_params = &unittest_params;
861 /* Clear unit test parameters before running test */
862 memset(ut_params, 0, sizeof(*ut_params));
864 /* Reconfigure device to default parameters */
865 ts_params->conf.socket_id = SOCKET_ID_ANY;
866 ts_params->conf.ff_disable = ff_disable;
867 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
868 ts_params->qp_conf.mp_session = ts_params->session_mpool;
869 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
871 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
873 "Failed to configure cryptodev %u",
874 ts_params->valid_devs[0]);
876 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
877 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
878 ts_params->valid_devs[0], qp_id,
880 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
881 "Failed to setup queue pair %u on cryptodev %u",
882 qp_id, ts_params->valid_devs[0]);
886 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
888 /* Start the device */
889 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
890 "Failed to start cryptodev %u",
891 ts_params->valid_devs[0]);
899 /* Configure and start the device with security feature disabled */
900 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
904 ut_setup_security(void)
906 /* Configure and start the device with no features disabled */
907 return dev_configure_and_start(0);
913 struct crypto_testsuite_params *ts_params = &testsuite_params;
914 struct crypto_unittest_params *ut_params = &unittest_params;
915 struct rte_cryptodev_stats stats;
917 /* free crypto session structure */
918 #ifdef RTE_LIBRTE_SECURITY
919 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
920 if (ut_params->sec_session) {
921 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
922 (ts_params->valid_devs[0]),
923 ut_params->sec_session);
924 ut_params->sec_session = NULL;
929 if (ut_params->sess) {
930 rte_cryptodev_sym_session_clear(
931 ts_params->valid_devs[0],
933 rte_cryptodev_sym_session_free(ut_params->sess);
934 ut_params->sess = NULL;
938 /* free crypto operation structure */
940 rte_crypto_op_free(ut_params->op);
943 * free mbuf - both obuf and ibuf are usually the same,
944 * so check if they point at the same address is necessary,
945 * to avoid freeing the mbuf twice.
947 if (ut_params->obuf) {
948 rte_pktmbuf_free(ut_params->obuf);
949 if (ut_params->ibuf == ut_params->obuf)
953 if (ut_params->ibuf) {
954 rte_pktmbuf_free(ut_params->ibuf);
958 if (ts_params->mbuf_pool != NULL)
959 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
960 rte_mempool_avail_count(ts_params->mbuf_pool));
962 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
964 /* Stop the device */
965 rte_cryptodev_stop(ts_params->valid_devs[0]);
969 test_device_configure_invalid_dev_id(void)
971 struct crypto_testsuite_params *ts_params = &testsuite_params;
972 uint16_t dev_id, num_devs = 0;
974 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
975 "Need at least %d devices for test", 1);
977 /* valid dev_id values */
978 dev_id = ts_params->valid_devs[0];
980 /* Stop the device in case it's started so it can be configured */
981 rte_cryptodev_stop(dev_id);
983 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
984 "Failed test for rte_cryptodev_configure: "
985 "invalid dev_num %u", dev_id);
987 /* invalid dev_id values */
990 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
991 "Failed test for rte_cryptodev_configure: "
992 "invalid dev_num %u", dev_id);
996 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
997 "Failed test for rte_cryptodev_configure:"
998 "invalid dev_num %u", dev_id);
1000 return TEST_SUCCESS;
1004 test_device_configure_invalid_queue_pair_ids(void)
1006 struct crypto_testsuite_params *ts_params = &testsuite_params;
1007 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1009 /* Stop the device in case it's started so it can be configured */
1010 rte_cryptodev_stop(ts_params->valid_devs[0]);
1012 /* valid - max value queue pairs */
1013 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1015 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1017 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1018 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1020 /* valid - one queue pairs */
1021 ts_params->conf.nb_queue_pairs = 1;
1023 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1025 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1026 ts_params->valid_devs[0],
1027 ts_params->conf.nb_queue_pairs);
1030 /* invalid - zero queue pairs */
1031 ts_params->conf.nb_queue_pairs = 0;
1033 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1035 "Failed test for rte_cryptodev_configure, dev_id %u,"
1037 ts_params->valid_devs[0],
1038 ts_params->conf.nb_queue_pairs);
1041 /* invalid - max value supported by field queue pairs */
1042 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1044 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1046 "Failed test for rte_cryptodev_configure, dev_id %u,"
1048 ts_params->valid_devs[0],
1049 ts_params->conf.nb_queue_pairs);
1052 /* invalid - max value + 1 queue pairs */
1053 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1055 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1057 "Failed test for rte_cryptodev_configure, dev_id %u,"
1059 ts_params->valid_devs[0],
1060 ts_params->conf.nb_queue_pairs);
1062 /* revert to original testsuite value */
1063 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1065 return TEST_SUCCESS;
1069 test_queue_pair_descriptor_setup(void)
1071 struct crypto_testsuite_params *ts_params = &testsuite_params;
1072 struct rte_cryptodev_qp_conf qp_conf = {
1073 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1077 /* Stop the device in case it's started so it can be configured */
1078 rte_cryptodev_stop(ts_params->valid_devs[0]);
1080 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1082 "Failed to configure cryptodev %u",
1083 ts_params->valid_devs[0]);
1086 * Test various ring sizes on this device. memzones can't be
1087 * freed so are re-used if ring is released and re-created.
1089 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1090 qp_conf.mp_session = ts_params->session_mpool;
1091 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1093 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1094 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1095 ts_params->valid_devs[0], qp_id, &qp_conf,
1096 rte_cryptodev_socket_id(
1097 ts_params->valid_devs[0])),
1099 "rte_cryptodev_queue_pair_setup: num_inflights "
1100 "%u on qp %u on cryptodev %u",
1101 qp_conf.nb_descriptors, qp_id,
1102 ts_params->valid_devs[0]);
1105 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
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 = MAX_NUM_OPS_INFLIGHT; /* valid */
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 = DEFAULT_NUM_OPS_INFLIGHT;
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:"
1142 "num_inflights %u on qp %u on cryptodev %u",
1143 qp_conf.nb_descriptors, qp_id,
1144 ts_params->valid_devs[0]);
1147 /* test invalid queue pair id */
1148 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1150 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1152 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1153 ts_params->valid_devs[0],
1155 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1156 "Failed test for rte_cryptodev_queue_pair_setup:"
1157 "invalid qp %u on cryptodev %u",
1158 qp_id, ts_params->valid_devs[0]);
1160 qp_id = 0xffff; /*invalid*/
1162 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1163 ts_params->valid_devs[0],
1165 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1166 "Failed test for rte_cryptodev_queue_pair_setup:"
1167 "invalid qp %u on cryptodev %u",
1168 qp_id, ts_params->valid_devs[0]);
1170 return TEST_SUCCESS;
1173 /* ***** Plaintext data for tests ***** */
1175 const char catch_22_quote_1[] =
1176 "There was only one catch and that was Catch-22, which "
1177 "specified that a concern for one's safety in the face of "
1178 "dangers that were real and immediate was the process of a "
1179 "rational mind. Orr was crazy and could be grounded. All he "
1180 "had to do was ask; and as soon as he did, he would no longer "
1181 "be crazy and would have to fly more missions. Orr would be "
1182 "crazy to fly more missions and sane if he didn't, but if he "
1183 "was sane he had to fly them. If he flew them he was crazy "
1184 "and didn't have to; but if he didn't want to he was sane and "
1185 "had to. Yossarian was moved very deeply by the absolute "
1186 "simplicity of this clause of Catch-22 and let out a "
1187 "respectful whistle. \"That's some catch, that Catch-22\", he "
1188 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1190 const char catch_22_quote[] =
1191 "What a lousy earth! He wondered how many people were "
1192 "destitute that same night even in his own prosperous country, "
1193 "how many homes were shanties, how many husbands were drunk "
1194 "and wives socked, and how many children were bullied, abused, "
1195 "or abandoned. How many families hungered for food they could "
1196 "not afford to buy? How many hearts were broken? How many "
1197 "suicides would take place that same night, how many people "
1198 "would go insane? How many cockroaches and landlords would "
1199 "triumph? How many winners were losers, successes failures, "
1200 "and rich men poor men? How many wise guys were stupid? How "
1201 "many happy endings were unhappy endings? How many honest men "
1202 "were liars, brave men cowards, loyal men traitors, how many "
1203 "sainted men were corrupt, how many people in positions of "
1204 "trust had sold their souls to bodyguards, how many had never "
1205 "had souls? How many straight-and-narrow paths were crooked "
1206 "paths? How many best families were worst families and how "
1207 "many good people were bad people? When you added them all up "
1208 "and then subtracted, you might be left with only the children, "
1209 "and perhaps with Albert Einstein and an old violinist or "
1210 "sculptor somewhere.";
1212 #define QUOTE_480_BYTES (480)
1213 #define QUOTE_512_BYTES (512)
1214 #define QUOTE_768_BYTES (768)
1215 #define QUOTE_1024_BYTES (1024)
1219 /* ***** SHA1 Hash Tests ***** */
1221 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1223 static uint8_t hmac_sha1_key[] = {
1224 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1225 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1226 0xDE, 0xF4, 0xDE, 0xAD };
1228 /* ***** SHA224 Hash Tests ***** */
1230 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1233 /* ***** AES-CBC Cipher Tests ***** */
1235 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1236 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1238 static uint8_t aes_cbc_key[] = {
1239 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1240 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1242 static uint8_t aes_cbc_iv[] = {
1243 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1244 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1247 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1249 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1250 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1251 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1252 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1253 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1254 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1255 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1256 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1257 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1258 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1259 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1260 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1261 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1262 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1263 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1264 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1265 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1266 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1267 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1268 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1269 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1270 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1271 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1272 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1273 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1274 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1275 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1276 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1277 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1278 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1279 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1280 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1281 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1282 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1283 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1284 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1285 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1286 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1287 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1288 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1289 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1290 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1291 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1292 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1293 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1294 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1295 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1296 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1297 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1298 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1299 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1300 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1301 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1302 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1303 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1304 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1305 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1306 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1307 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1308 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1309 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1310 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1311 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1312 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1313 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1316 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1317 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1318 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1319 0x18, 0x8c, 0x1d, 0x32
1323 /* Multisession Vector context Test */
1324 /*Begin Session 0 */
1325 static uint8_t ms_aes_cbc_key0[] = {
1326 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1327 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1330 static uint8_t ms_aes_cbc_iv0[] = {
1331 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1332 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1335 static const uint8_t ms_aes_cbc_cipher0[] = {
1336 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1337 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1338 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1339 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1340 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1341 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1342 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1343 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1344 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1345 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1346 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1347 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1348 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1349 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1350 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1351 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1352 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1353 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1354 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1355 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1356 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1357 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1358 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1359 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1360 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1361 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1362 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1363 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1364 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1365 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1366 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1367 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1368 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1369 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1370 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1371 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1372 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1373 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1374 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1375 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1376 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1377 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1378 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1379 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1380 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1381 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1382 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1383 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1384 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1385 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1386 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1387 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1388 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1389 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1390 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1391 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1392 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1393 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1394 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1395 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1396 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1397 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1398 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1399 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1403 static uint8_t ms_hmac_key0[] = {
1404 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1405 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1406 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1407 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1408 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1409 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1410 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1411 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1414 static const uint8_t ms_hmac_digest0[] = {
1415 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1416 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1417 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1418 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1419 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1420 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1421 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1422 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1426 /* Begin session 1 */
1428 static uint8_t ms_aes_cbc_key1[] = {
1429 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1430 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1433 static uint8_t ms_aes_cbc_iv1[] = {
1434 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1435 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1438 static const uint8_t ms_aes_cbc_cipher1[] = {
1439 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1440 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1441 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1442 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1443 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1444 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1445 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1446 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1447 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1448 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1449 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1450 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1451 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1452 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1453 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1454 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1455 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1456 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1457 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1458 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1459 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1460 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1461 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1462 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1463 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1464 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1465 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1466 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1467 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1468 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1469 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1470 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1471 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1472 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1473 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1474 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1475 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1476 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1477 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1478 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1479 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1480 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1481 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1482 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1483 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1484 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1485 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1486 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1487 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1488 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1489 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1490 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1491 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1492 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1493 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1494 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1495 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1496 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1497 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1498 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1499 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1500 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1501 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1502 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1506 static uint8_t ms_hmac_key1[] = {
1507 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1508 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1509 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1510 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1511 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1512 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1513 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1514 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1517 static const uint8_t ms_hmac_digest1[] = {
1518 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1519 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1520 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1521 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1522 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1523 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1524 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1525 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1528 /* Begin Session 2 */
1529 static uint8_t ms_aes_cbc_key2[] = {
1530 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1531 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1534 static uint8_t ms_aes_cbc_iv2[] = {
1535 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1536 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1539 static const uint8_t ms_aes_cbc_cipher2[] = {
1540 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1541 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1542 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1543 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1544 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1545 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1546 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1547 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1548 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1549 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1550 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1551 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1552 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1553 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1554 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1555 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1556 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1557 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1558 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1559 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1560 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1561 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1562 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1563 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1564 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1565 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1566 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1567 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1568 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1569 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1570 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1571 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1572 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1573 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1574 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1575 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1576 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1577 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1578 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1579 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1580 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1581 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1582 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1583 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1584 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1585 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1586 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1587 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1588 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1589 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1590 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1591 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1592 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1593 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1594 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1595 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1596 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1597 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1598 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1599 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1600 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1601 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1602 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1603 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1606 static uint8_t ms_hmac_key2[] = {
1607 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1608 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1609 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1610 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1611 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1612 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1613 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1614 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1617 static const uint8_t ms_hmac_digest2[] = {
1618 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1619 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1620 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1621 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1622 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1623 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1624 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1625 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1632 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1634 struct crypto_testsuite_params *ts_params = &testsuite_params;
1635 struct crypto_unittest_params *ut_params = &unittest_params;
1637 /* Verify the capabilities */
1638 struct rte_cryptodev_sym_capability_idx cap_idx;
1639 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1640 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
1641 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1644 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1645 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
1646 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
1650 /* Generate test mbuf data and space for digest */
1651 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1652 catch_22_quote, QUOTE_512_BYTES, 0);
1654 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1655 DIGEST_BYTE_LENGTH_SHA1);
1656 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1658 /* Setup Cipher Parameters */
1659 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1660 ut_params->cipher_xform.next = &ut_params->auth_xform;
1662 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1663 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1664 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1665 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1666 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1667 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1669 /* Setup HMAC Parameters */
1670 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1672 ut_params->auth_xform.next = NULL;
1674 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1675 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1676 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1677 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1678 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1680 ut_params->sess = rte_cryptodev_sym_session_create(
1681 ts_params->session_mpool);
1683 /* Create crypto session*/
1684 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1685 ut_params->sess, &ut_params->cipher_xform,
1686 ts_params->session_priv_mpool);
1687 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1689 /* Generate crypto op data structure */
1690 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1691 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1692 TEST_ASSERT_NOT_NULL(ut_params->op,
1693 "Failed to allocate symmetric crypto operation struct");
1695 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1697 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1699 /* set crypto operation source mbuf */
1700 sym_op->m_src = ut_params->ibuf;
1702 /* Set crypto operation authentication parameters */
1703 sym_op->auth.digest.data = ut_params->digest;
1704 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1705 ut_params->ibuf, QUOTE_512_BYTES);
1707 sym_op->auth.data.offset = 0;
1708 sym_op->auth.data.length = QUOTE_512_BYTES;
1710 /* Copy IV at the end of the crypto operation */
1711 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1712 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1714 /* Set crypto operation cipher parameters */
1715 sym_op->cipher.data.offset = 0;
1716 sym_op->cipher.data.length = QUOTE_512_BYTES;
1718 /* Process crypto operation */
1719 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1720 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1723 TEST_ASSERT_NOT_NULL(
1724 process_crypto_request(ts_params->valid_devs[0],
1726 "failed to process sym crypto op");
1728 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1729 "crypto op processing failed");
1732 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1735 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1736 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1738 "ciphertext data not as expected");
1740 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1742 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1743 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1744 gbl_driver_id == rte_cryptodev_driver_id_get(
1745 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1746 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1747 DIGEST_BYTE_LENGTH_SHA1,
1748 "Generated digest data not as expected");
1750 return TEST_SUCCESS;
1753 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1755 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1757 static uint8_t hmac_sha512_key[] = {
1758 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1759 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1760 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1761 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1762 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1763 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1764 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1765 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1767 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1768 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1769 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1770 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1771 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1772 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1773 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1774 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1775 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1780 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1781 struct crypto_unittest_params *ut_params,
1782 uint8_t *cipher_key,
1786 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1787 struct crypto_unittest_params *ut_params,
1788 struct crypto_testsuite_params *ts_params,
1789 const uint8_t *cipher,
1790 const uint8_t *digest,
1795 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1796 struct crypto_unittest_params *ut_params,
1797 uint8_t *cipher_key,
1801 /* Setup Cipher Parameters */
1802 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1803 ut_params->cipher_xform.next = NULL;
1805 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1806 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1807 ut_params->cipher_xform.cipher.key.data = cipher_key;
1808 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1809 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1810 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1812 /* Setup HMAC Parameters */
1813 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1814 ut_params->auth_xform.next = &ut_params->cipher_xform;
1816 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1817 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1818 ut_params->auth_xform.auth.key.data = hmac_key;
1819 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1820 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1822 return TEST_SUCCESS;
1827 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1828 struct crypto_unittest_params *ut_params,
1829 struct crypto_testsuite_params *ts_params,
1830 const uint8_t *cipher,
1831 const uint8_t *digest,
1834 /* Generate test mbuf data and digest */
1835 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1838 QUOTE_512_BYTES, 0);
1840 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1841 DIGEST_BYTE_LENGTH_SHA512);
1842 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1844 rte_memcpy(ut_params->digest,
1846 DIGEST_BYTE_LENGTH_SHA512);
1848 /* Generate Crypto op data structure */
1849 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1850 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1851 TEST_ASSERT_NOT_NULL(ut_params->op,
1852 "Failed to allocate symmetric crypto operation struct");
1854 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1856 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1858 /* set crypto operation source mbuf */
1859 sym_op->m_src = ut_params->ibuf;
1861 sym_op->auth.digest.data = ut_params->digest;
1862 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1863 ut_params->ibuf, QUOTE_512_BYTES);
1865 sym_op->auth.data.offset = 0;
1866 sym_op->auth.data.length = QUOTE_512_BYTES;
1868 /* Copy IV at the end of the crypto operation */
1869 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1870 iv, CIPHER_IV_LENGTH_AES_CBC);
1872 sym_op->cipher.data.offset = 0;
1873 sym_op->cipher.data.length = QUOTE_512_BYTES;
1875 /* Process crypto operation */
1876 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
1877 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
1879 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1880 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
1881 ut_params->op, 1, 1, 0, 0);
1883 TEST_ASSERT_NOT_NULL(
1884 process_crypto_request(ts_params->valid_devs[0],
1886 "failed to process sym crypto op");
1888 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1889 "crypto op processing failed");
1891 ut_params->obuf = ut_params->op->sym->m_src;
1894 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1895 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1898 "Plaintext data not as expected");
1901 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1902 "Digest verification failed");
1904 return TEST_SUCCESS;
1908 test_blockcipher(enum blockcipher_test_type test_type)
1910 struct crypto_testsuite_params *ts_params = &testsuite_params;
1913 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1914 ts_params->op_mpool,
1915 ts_params->session_mpool, ts_params->session_priv_mpool,
1916 ts_params->valid_devs[0],
1919 if (status == -ENOTSUP)
1922 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1924 return TEST_SUCCESS;
1928 test_AES_cipheronly_all(void)
1930 return test_blockcipher(BLKCIPHER_AES_CIPHERONLY_TYPE);
1934 test_AES_docsis_all(void)
1936 /* Data-path service does not support DOCSIS yet */
1937 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1939 return test_blockcipher(BLKCIPHER_AES_DOCSIS_TYPE);
1943 test_DES_docsis_all(void)
1945 /* Data-path service does not support DOCSIS yet */
1946 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
1948 return test_blockcipher(BLKCIPHER_DES_DOCSIS_TYPE);
1952 test_DES_cipheronly_all(void)
1954 return test_blockcipher(BLKCIPHER_DES_CIPHERONLY_TYPE);
1958 test_authonly_all(void)
1960 return test_blockcipher(BLKCIPHER_AUTHONLY_TYPE);
1964 test_AES_chain_all(void)
1966 return test_blockcipher(BLKCIPHER_AES_CHAIN_TYPE);
1970 test_3DES_chain_all(void)
1972 return test_blockcipher(BLKCIPHER_3DES_CHAIN_TYPE);
1976 test_3DES_cipheronly_all(void)
1978 return test_blockcipher(BLKCIPHER_3DES_CIPHERONLY_TYPE);
1981 /* ***** SNOW 3G Tests ***** */
1983 create_wireless_algo_hash_session(uint8_t dev_id,
1984 const uint8_t *key, const uint8_t key_len,
1985 const uint8_t iv_len, const uint8_t auth_len,
1986 enum rte_crypto_auth_operation op,
1987 enum rte_crypto_auth_algorithm algo)
1989 uint8_t hash_key[key_len];
1992 struct crypto_testsuite_params *ts_params = &testsuite_params;
1993 struct crypto_unittest_params *ut_params = &unittest_params;
1995 memcpy(hash_key, key, key_len);
1997 debug_hexdump(stdout, "key:", key, key_len);
1999 /* Setup Authentication Parameters */
2000 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2001 ut_params->auth_xform.next = NULL;
2003 ut_params->auth_xform.auth.op = op;
2004 ut_params->auth_xform.auth.algo = algo;
2005 ut_params->auth_xform.auth.key.length = key_len;
2006 ut_params->auth_xform.auth.key.data = hash_key;
2007 ut_params->auth_xform.auth.digest_length = auth_len;
2008 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2009 ut_params->auth_xform.auth.iv.length = iv_len;
2010 ut_params->sess = rte_cryptodev_sym_session_create(
2011 ts_params->session_mpool);
2013 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2014 &ut_params->auth_xform,
2015 ts_params->session_priv_mpool);
2016 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2017 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2022 create_wireless_algo_cipher_session(uint8_t dev_id,
2023 enum rte_crypto_cipher_operation op,
2024 enum rte_crypto_cipher_algorithm algo,
2025 const uint8_t *key, const uint8_t key_len,
2028 uint8_t cipher_key[key_len];
2030 struct crypto_testsuite_params *ts_params = &testsuite_params;
2031 struct crypto_unittest_params *ut_params = &unittest_params;
2033 memcpy(cipher_key, key, key_len);
2035 /* Setup Cipher Parameters */
2036 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2037 ut_params->cipher_xform.next = NULL;
2039 ut_params->cipher_xform.cipher.algo = algo;
2040 ut_params->cipher_xform.cipher.op = op;
2041 ut_params->cipher_xform.cipher.key.data = cipher_key;
2042 ut_params->cipher_xform.cipher.key.length = key_len;
2043 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2044 ut_params->cipher_xform.cipher.iv.length = iv_len;
2046 debug_hexdump(stdout, "key:", key, key_len);
2048 /* Create Crypto session */
2049 ut_params->sess = rte_cryptodev_sym_session_create(
2050 ts_params->session_mpool);
2052 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2053 &ut_params->cipher_xform,
2054 ts_params->session_priv_mpool);
2055 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2056 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2061 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2062 unsigned int cipher_len,
2063 unsigned int cipher_offset)
2065 struct crypto_testsuite_params *ts_params = &testsuite_params;
2066 struct crypto_unittest_params *ut_params = &unittest_params;
2068 /* Generate Crypto op data structure */
2069 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2070 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2071 TEST_ASSERT_NOT_NULL(ut_params->op,
2072 "Failed to allocate pktmbuf offload");
2074 /* Set crypto operation data parameters */
2075 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2077 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2079 /* set crypto operation source mbuf */
2080 sym_op->m_src = ut_params->ibuf;
2083 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2085 sym_op->cipher.data.length = cipher_len;
2086 sym_op->cipher.data.offset = cipher_offset;
2091 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2092 unsigned int cipher_len,
2093 unsigned int cipher_offset)
2095 struct crypto_testsuite_params *ts_params = &testsuite_params;
2096 struct crypto_unittest_params *ut_params = &unittest_params;
2098 /* Generate Crypto op data structure */
2099 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2100 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2101 TEST_ASSERT_NOT_NULL(ut_params->op,
2102 "Failed to allocate pktmbuf offload");
2104 /* Set crypto operation data parameters */
2105 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2107 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2109 /* set crypto operation source mbuf */
2110 sym_op->m_src = ut_params->ibuf;
2111 sym_op->m_dst = ut_params->obuf;
2114 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2116 sym_op->cipher.data.length = cipher_len;
2117 sym_op->cipher.data.offset = cipher_offset;
2122 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2123 enum rte_crypto_cipher_operation cipher_op,
2124 enum rte_crypto_auth_operation auth_op,
2125 enum rte_crypto_auth_algorithm auth_algo,
2126 enum rte_crypto_cipher_algorithm cipher_algo,
2127 const uint8_t *key, uint8_t key_len,
2128 uint8_t auth_iv_len, uint8_t auth_len,
2129 uint8_t cipher_iv_len)
2132 uint8_t cipher_auth_key[key_len];
2135 struct crypto_testsuite_params *ts_params = &testsuite_params;
2136 struct crypto_unittest_params *ut_params = &unittest_params;
2138 memcpy(cipher_auth_key, key, key_len);
2140 /* Setup Authentication Parameters */
2141 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2142 ut_params->auth_xform.next = NULL;
2144 ut_params->auth_xform.auth.op = auth_op;
2145 ut_params->auth_xform.auth.algo = auth_algo;
2146 ut_params->auth_xform.auth.key.length = key_len;
2147 /* Hash key = cipher key */
2148 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2149 ut_params->auth_xform.auth.digest_length = auth_len;
2150 /* Auth IV will be after cipher IV */
2151 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2152 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2154 /* Setup Cipher Parameters */
2155 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2156 ut_params->cipher_xform.next = &ut_params->auth_xform;
2158 ut_params->cipher_xform.cipher.algo = cipher_algo;
2159 ut_params->cipher_xform.cipher.op = cipher_op;
2160 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2161 ut_params->cipher_xform.cipher.key.length = key_len;
2162 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2163 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2165 debug_hexdump(stdout, "key:", key, key_len);
2167 /* Create Crypto session*/
2168 ut_params->sess = rte_cryptodev_sym_session_create(
2169 ts_params->session_mpool);
2170 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2172 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2173 &ut_params->cipher_xform,
2174 ts_params->session_priv_mpool);
2175 if (status == -ENOTSUP)
2178 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2183 create_wireless_cipher_auth_session(uint8_t dev_id,
2184 enum rte_crypto_cipher_operation cipher_op,
2185 enum rte_crypto_auth_operation auth_op,
2186 enum rte_crypto_auth_algorithm auth_algo,
2187 enum rte_crypto_cipher_algorithm cipher_algo,
2188 const struct wireless_test_data *tdata)
2190 const uint8_t key_len = tdata->key.len;
2191 uint8_t cipher_auth_key[key_len];
2194 struct crypto_testsuite_params *ts_params = &testsuite_params;
2195 struct crypto_unittest_params *ut_params = &unittest_params;
2196 const uint8_t *key = tdata->key.data;
2197 const uint8_t auth_len = tdata->digest.len;
2198 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2199 uint8_t auth_iv_len = tdata->auth_iv.len;
2201 memcpy(cipher_auth_key, key, key_len);
2203 /* Setup Authentication Parameters */
2204 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2205 ut_params->auth_xform.next = NULL;
2207 ut_params->auth_xform.auth.op = auth_op;
2208 ut_params->auth_xform.auth.algo = auth_algo;
2209 ut_params->auth_xform.auth.key.length = key_len;
2210 /* Hash key = cipher key */
2211 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2212 ut_params->auth_xform.auth.digest_length = auth_len;
2213 /* Auth IV will be after cipher IV */
2214 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2215 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2217 /* Setup Cipher Parameters */
2218 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2219 ut_params->cipher_xform.next = &ut_params->auth_xform;
2221 ut_params->cipher_xform.cipher.algo = cipher_algo;
2222 ut_params->cipher_xform.cipher.op = cipher_op;
2223 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2224 ut_params->cipher_xform.cipher.key.length = key_len;
2225 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2226 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2229 debug_hexdump(stdout, "key:", key, key_len);
2231 /* Create Crypto session*/
2232 ut_params->sess = rte_cryptodev_sym_session_create(
2233 ts_params->session_mpool);
2235 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2236 &ut_params->cipher_xform,
2237 ts_params->session_priv_mpool);
2238 if (status == -ENOTSUP)
2241 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2242 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2247 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2248 const struct wireless_test_data *tdata)
2250 return create_wireless_cipher_auth_session(dev_id,
2251 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2252 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2253 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2257 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2258 enum rte_crypto_cipher_operation cipher_op,
2259 enum rte_crypto_auth_operation auth_op,
2260 enum rte_crypto_auth_algorithm auth_algo,
2261 enum rte_crypto_cipher_algorithm cipher_algo,
2262 const uint8_t *key, const uint8_t key_len,
2263 uint8_t auth_iv_len, uint8_t auth_len,
2264 uint8_t cipher_iv_len)
2266 uint8_t auth_cipher_key[key_len];
2268 struct crypto_testsuite_params *ts_params = &testsuite_params;
2269 struct crypto_unittest_params *ut_params = &unittest_params;
2271 memcpy(auth_cipher_key, key, key_len);
2273 /* Setup Authentication Parameters */
2274 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2275 ut_params->auth_xform.auth.op = auth_op;
2276 ut_params->auth_xform.next = &ut_params->cipher_xform;
2277 ut_params->auth_xform.auth.algo = auth_algo;
2278 ut_params->auth_xform.auth.key.length = key_len;
2279 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2280 ut_params->auth_xform.auth.digest_length = auth_len;
2281 /* Auth IV will be after cipher IV */
2282 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2283 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2285 /* Setup Cipher Parameters */
2286 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2287 ut_params->cipher_xform.next = NULL;
2288 ut_params->cipher_xform.cipher.algo = cipher_algo;
2289 ut_params->cipher_xform.cipher.op = cipher_op;
2290 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2291 ut_params->cipher_xform.cipher.key.length = key_len;
2292 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2293 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2295 debug_hexdump(stdout, "key:", key, key_len);
2297 /* Create Crypto session*/
2298 ut_params->sess = rte_cryptodev_sym_session_create(
2299 ts_params->session_mpool);
2300 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2302 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2303 ut_params->auth_xform.next = NULL;
2304 ut_params->cipher_xform.next = &ut_params->auth_xform;
2305 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2306 &ut_params->cipher_xform,
2307 ts_params->session_priv_mpool);
2310 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2311 &ut_params->auth_xform,
2312 ts_params->session_priv_mpool);
2314 if (status == -ENOTSUP)
2317 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2323 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2324 unsigned int auth_tag_len,
2325 const uint8_t *iv, unsigned int iv_len,
2326 unsigned int data_pad_len,
2327 enum rte_crypto_auth_operation op,
2328 unsigned int auth_len, unsigned int auth_offset)
2330 struct crypto_testsuite_params *ts_params = &testsuite_params;
2332 struct crypto_unittest_params *ut_params = &unittest_params;
2334 /* Generate Crypto op data structure */
2335 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2336 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2337 TEST_ASSERT_NOT_NULL(ut_params->op,
2338 "Failed to allocate pktmbuf offload");
2340 /* Set crypto operation data parameters */
2341 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2343 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2345 /* set crypto operation source mbuf */
2346 sym_op->m_src = ut_params->ibuf;
2349 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2352 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2353 ut_params->ibuf, auth_tag_len);
2355 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2356 "no room to append auth tag");
2357 ut_params->digest = sym_op->auth.digest.data;
2358 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2359 ut_params->ibuf, data_pad_len);
2360 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2361 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2363 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2365 debug_hexdump(stdout, "digest:",
2366 sym_op->auth.digest.data,
2369 sym_op->auth.data.length = auth_len;
2370 sym_op->auth.data.offset = auth_offset;
2376 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2377 enum rte_crypto_auth_operation op)
2379 struct crypto_testsuite_params *ts_params = &testsuite_params;
2380 struct crypto_unittest_params *ut_params = &unittest_params;
2382 const uint8_t *auth_tag = tdata->digest.data;
2383 const unsigned int auth_tag_len = tdata->digest.len;
2384 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2385 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2387 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2388 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2389 const uint8_t *auth_iv = tdata->auth_iv.data;
2390 const uint8_t auth_iv_len = tdata->auth_iv.len;
2391 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2392 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2394 /* Generate Crypto op data structure */
2395 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2396 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2397 TEST_ASSERT_NOT_NULL(ut_params->op,
2398 "Failed to allocate pktmbuf offload");
2399 /* Set crypto operation data parameters */
2400 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2402 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2404 /* set crypto operation source mbuf */
2405 sym_op->m_src = ut_params->ibuf;
2408 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2409 ut_params->ibuf, auth_tag_len);
2411 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2412 "no room to append auth tag");
2413 ut_params->digest = sym_op->auth.digest.data;
2414 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2415 ut_params->ibuf, data_pad_len);
2416 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2417 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2419 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2421 debug_hexdump(stdout, "digest:",
2422 sym_op->auth.digest.data,
2425 /* Copy cipher and auth IVs at the end of the crypto operation */
2426 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2428 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2429 iv_ptr += cipher_iv_len;
2430 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2432 sym_op->cipher.data.length = cipher_len;
2433 sym_op->cipher.data.offset = 0;
2434 sym_op->auth.data.length = auth_len;
2435 sym_op->auth.data.offset = 0;
2441 create_zuc_cipher_hash_generate_operation(
2442 const struct wireless_test_data *tdata)
2444 return create_wireless_cipher_hash_operation(tdata,
2445 RTE_CRYPTO_AUTH_OP_GENERATE);
2449 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2450 const unsigned auth_tag_len,
2451 const uint8_t *auth_iv, uint8_t auth_iv_len,
2452 unsigned data_pad_len,
2453 enum rte_crypto_auth_operation op,
2454 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2455 const unsigned cipher_len, const unsigned cipher_offset,
2456 const unsigned auth_len, const unsigned auth_offset)
2458 struct crypto_testsuite_params *ts_params = &testsuite_params;
2459 struct crypto_unittest_params *ut_params = &unittest_params;
2461 enum rte_crypto_cipher_algorithm cipher_algo =
2462 ut_params->cipher_xform.cipher.algo;
2463 enum rte_crypto_auth_algorithm auth_algo =
2464 ut_params->auth_xform.auth.algo;
2466 /* Generate Crypto op data structure */
2467 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2468 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2469 TEST_ASSERT_NOT_NULL(ut_params->op,
2470 "Failed to allocate pktmbuf offload");
2471 /* Set crypto operation data parameters */
2472 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2474 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2476 /* set crypto operation source mbuf */
2477 sym_op->m_src = ut_params->ibuf;
2480 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2481 ut_params->ibuf, auth_tag_len);
2483 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2484 "no room to append auth tag");
2485 ut_params->digest = sym_op->auth.digest.data;
2487 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2488 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2489 ut_params->ibuf, data_pad_len);
2491 struct rte_mbuf *m = ut_params->ibuf;
2492 unsigned int offset = data_pad_len;
2494 while (offset > m->data_len && m->next != NULL) {
2495 offset -= m->data_len;
2498 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2502 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2503 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2505 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2507 debug_hexdump(stdout, "digest:",
2508 sym_op->auth.digest.data,
2511 /* Copy cipher and auth IVs at the end of the crypto operation */
2512 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2514 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2515 iv_ptr += cipher_iv_len;
2516 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2518 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2519 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2520 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2521 sym_op->cipher.data.length = cipher_len;
2522 sym_op->cipher.data.offset = cipher_offset;
2524 sym_op->cipher.data.length = cipher_len >> 3;
2525 sym_op->cipher.data.offset = cipher_offset >> 3;
2528 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2529 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2530 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2531 sym_op->auth.data.length = auth_len;
2532 sym_op->auth.data.offset = auth_offset;
2534 sym_op->auth.data.length = auth_len >> 3;
2535 sym_op->auth.data.offset = auth_offset >> 3;
2542 create_wireless_algo_auth_cipher_operation(
2543 const uint8_t *auth_tag, unsigned int auth_tag_len,
2544 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2545 const uint8_t *auth_iv, uint8_t auth_iv_len,
2546 unsigned int data_pad_len,
2547 unsigned int cipher_len, unsigned int cipher_offset,
2548 unsigned int auth_len, unsigned int auth_offset,
2549 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2551 struct crypto_testsuite_params *ts_params = &testsuite_params;
2552 struct crypto_unittest_params *ut_params = &unittest_params;
2554 enum rte_crypto_cipher_algorithm cipher_algo =
2555 ut_params->cipher_xform.cipher.algo;
2556 enum rte_crypto_auth_algorithm auth_algo =
2557 ut_params->auth_xform.auth.algo;
2559 /* Generate Crypto op data structure */
2560 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2561 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2562 TEST_ASSERT_NOT_NULL(ut_params->op,
2563 "Failed to allocate pktmbuf offload");
2565 /* Set crypto operation data parameters */
2566 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2568 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2570 /* set crypto operation mbufs */
2571 sym_op->m_src = ut_params->ibuf;
2572 if (op_mode == OUT_OF_PLACE)
2573 sym_op->m_dst = ut_params->obuf;
2577 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2578 (op_mode == IN_PLACE ?
2579 ut_params->ibuf : ut_params->obuf),
2580 uint8_t *, data_pad_len);
2581 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2582 (op_mode == IN_PLACE ?
2583 ut_params->ibuf : ut_params->obuf),
2585 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2587 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2588 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2589 sym_op->m_src : sym_op->m_dst);
2590 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2591 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2592 sgl_buf = sgl_buf->next;
2594 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2595 uint8_t *, remaining_off);
2596 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2598 memset(sym_op->auth.digest.data, 0, remaining_off);
2599 while (sgl_buf->next != NULL) {
2600 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2601 0, rte_pktmbuf_data_len(sgl_buf));
2602 sgl_buf = sgl_buf->next;
2606 /* Copy digest for the verification */
2608 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2610 /* Copy cipher and auth IVs at the end of the crypto operation */
2611 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2612 ut_params->op, uint8_t *, IV_OFFSET);
2614 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2615 iv_ptr += cipher_iv_len;
2616 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2618 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2619 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2620 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2621 sym_op->cipher.data.length = cipher_len;
2622 sym_op->cipher.data.offset = cipher_offset;
2624 sym_op->cipher.data.length = cipher_len >> 3;
2625 sym_op->cipher.data.offset = cipher_offset >> 3;
2628 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2629 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2630 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2631 sym_op->auth.data.length = auth_len;
2632 sym_op->auth.data.offset = auth_offset;
2634 sym_op->auth.data.length = auth_len >> 3;
2635 sym_op->auth.data.offset = auth_offset >> 3;
2642 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2644 struct crypto_testsuite_params *ts_params = &testsuite_params;
2645 struct crypto_unittest_params *ut_params = &unittest_params;
2648 unsigned plaintext_pad_len;
2649 unsigned plaintext_len;
2651 struct rte_cryptodev_info dev_info;
2653 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2654 uint64_t feat_flags = dev_info.feature_flags;
2656 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2657 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2658 printf("Device doesn't support NON-Byte Aligned Data.\n");
2662 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2663 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2664 printf("Device doesn't support RAW data-path APIs.\n");
2668 /* Verify the capabilities */
2669 struct rte_cryptodev_sym_capability_idx cap_idx;
2670 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2671 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2672 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2676 /* Create SNOW 3G session */
2677 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2678 tdata->key.data, tdata->key.len,
2679 tdata->auth_iv.len, tdata->digest.len,
2680 RTE_CRYPTO_AUTH_OP_GENERATE,
2681 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2685 /* alloc mbuf and set payload */
2686 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2688 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2689 rte_pktmbuf_tailroom(ut_params->ibuf));
2691 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2692 /* Append data which is padded to a multiple of */
2693 /* the algorithms block size */
2694 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2695 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2697 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2699 /* Create SNOW 3G operation */
2700 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2701 tdata->auth_iv.data, tdata->auth_iv.len,
2702 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2703 tdata->validAuthLenInBits.len,
2708 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2709 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2710 ut_params->op, 0, 1, 1, 0);
2712 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2714 ut_params->obuf = ut_params->op->sym->m_src;
2715 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2716 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2717 + plaintext_pad_len;
2720 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2723 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2724 "SNOW 3G Generated auth tag not as expected");
2730 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2732 struct crypto_testsuite_params *ts_params = &testsuite_params;
2733 struct crypto_unittest_params *ut_params = &unittest_params;
2736 unsigned plaintext_pad_len;
2737 unsigned plaintext_len;
2739 struct rte_cryptodev_info dev_info;
2741 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2742 uint64_t feat_flags = dev_info.feature_flags;
2744 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
2745 ((tdata->validAuthLenInBits.len % 8) != 0)) {
2746 printf("Device doesn't support NON-Byte Aligned Data.\n");
2750 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2751 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2752 printf("Device doesn't support RAW data-path APIs.\n");
2756 /* Verify the capabilities */
2757 struct rte_cryptodev_sym_capability_idx cap_idx;
2758 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2759 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
2760 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2764 /* Create SNOW 3G session */
2765 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2766 tdata->key.data, tdata->key.len,
2767 tdata->auth_iv.len, tdata->digest.len,
2768 RTE_CRYPTO_AUTH_OP_VERIFY,
2769 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2772 /* alloc mbuf and set payload */
2773 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2775 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2776 rte_pktmbuf_tailroom(ut_params->ibuf));
2778 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2779 /* Append data which is padded to a multiple of */
2780 /* the algorithms block size */
2781 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2782 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2784 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2786 /* Create SNOW 3G operation */
2787 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2789 tdata->auth_iv.data, tdata->auth_iv.len,
2791 RTE_CRYPTO_AUTH_OP_VERIFY,
2792 tdata->validAuthLenInBits.len,
2797 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2798 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2799 ut_params->op, 0, 1, 1, 0);
2801 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2803 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2804 ut_params->obuf = ut_params->op->sym->m_src;
2805 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2806 + plaintext_pad_len;
2809 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2818 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2820 struct crypto_testsuite_params *ts_params = &testsuite_params;
2821 struct crypto_unittest_params *ut_params = &unittest_params;
2824 unsigned plaintext_pad_len;
2825 unsigned plaintext_len;
2827 struct rte_cryptodev_info dev_info;
2829 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2830 uint64_t feat_flags = dev_info.feature_flags;
2832 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2833 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2834 printf("Device doesn't support RAW data-path APIs.\n");
2838 /* Verify the capabilities */
2839 struct rte_cryptodev_sym_capability_idx cap_idx;
2840 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2841 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2842 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2846 /* Create KASUMI session */
2847 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2848 tdata->key.data, tdata->key.len,
2849 0, tdata->digest.len,
2850 RTE_CRYPTO_AUTH_OP_GENERATE,
2851 RTE_CRYPTO_AUTH_KASUMI_F9);
2855 /* alloc mbuf and set payload */
2856 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2858 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2859 rte_pktmbuf_tailroom(ut_params->ibuf));
2861 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2862 /* Append data which is padded to a multiple of */
2863 /* the algorithms block size */
2864 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2865 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2867 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2869 /* Create KASUMI operation */
2870 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2872 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2873 tdata->plaintext.len,
2878 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2879 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2881 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2882 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2883 ut_params->op, 0, 1, 1, 0);
2885 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2888 ut_params->obuf = ut_params->op->sym->m_src;
2889 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2890 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2891 + plaintext_pad_len;
2894 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2897 DIGEST_BYTE_LENGTH_KASUMI_F9,
2898 "KASUMI Generated auth tag not as expected");
2904 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2906 struct crypto_testsuite_params *ts_params = &testsuite_params;
2907 struct crypto_unittest_params *ut_params = &unittest_params;
2910 unsigned plaintext_pad_len;
2911 unsigned plaintext_len;
2913 struct rte_cryptodev_info dev_info;
2915 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2916 uint64_t feat_flags = dev_info.feature_flags;
2918 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
2919 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
2920 printf("Device doesn't support RAW data-path APIs.\n");
2924 /* Verify the capabilities */
2925 struct rte_cryptodev_sym_capability_idx cap_idx;
2926 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2927 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
2928 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2932 /* Create KASUMI session */
2933 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2934 tdata->key.data, tdata->key.len,
2935 0, tdata->digest.len,
2936 RTE_CRYPTO_AUTH_OP_VERIFY,
2937 RTE_CRYPTO_AUTH_KASUMI_F9);
2940 /* alloc mbuf and set payload */
2941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2943 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2944 rte_pktmbuf_tailroom(ut_params->ibuf));
2946 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2947 /* Append data which is padded to a multiple */
2948 /* of the algorithms block size */
2949 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2950 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2952 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2954 /* Create KASUMI operation */
2955 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2959 RTE_CRYPTO_AUTH_OP_VERIFY,
2960 tdata->plaintext.len,
2965 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2966 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2967 ut_params->op, 0, 1, 1, 0);
2969 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2971 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2972 ut_params->obuf = ut_params->op->sym->m_src;
2973 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2974 + plaintext_pad_len;
2977 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2986 test_snow3g_hash_generate_test_case_1(void)
2988 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2992 test_snow3g_hash_generate_test_case_2(void)
2994 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2998 test_snow3g_hash_generate_test_case_3(void)
3000 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3004 test_snow3g_hash_generate_test_case_4(void)
3006 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3010 test_snow3g_hash_generate_test_case_5(void)
3012 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3016 test_snow3g_hash_generate_test_case_6(void)
3018 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3022 test_snow3g_hash_verify_test_case_1(void)
3024 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3029 test_snow3g_hash_verify_test_case_2(void)
3031 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3035 test_snow3g_hash_verify_test_case_3(void)
3037 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3041 test_snow3g_hash_verify_test_case_4(void)
3043 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3047 test_snow3g_hash_verify_test_case_5(void)
3049 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3053 test_snow3g_hash_verify_test_case_6(void)
3055 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3059 test_kasumi_hash_generate_test_case_1(void)
3061 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3065 test_kasumi_hash_generate_test_case_2(void)
3067 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3071 test_kasumi_hash_generate_test_case_3(void)
3073 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3077 test_kasumi_hash_generate_test_case_4(void)
3079 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3083 test_kasumi_hash_generate_test_case_5(void)
3085 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3089 test_kasumi_hash_generate_test_case_6(void)
3091 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3095 test_kasumi_hash_verify_test_case_1(void)
3097 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3101 test_kasumi_hash_verify_test_case_2(void)
3103 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3107 test_kasumi_hash_verify_test_case_3(void)
3109 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3113 test_kasumi_hash_verify_test_case_4(void)
3115 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3119 test_kasumi_hash_verify_test_case_5(void)
3121 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3125 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3127 struct crypto_testsuite_params *ts_params = &testsuite_params;
3128 struct crypto_unittest_params *ut_params = &unittest_params;
3131 uint8_t *plaintext, *ciphertext;
3132 unsigned plaintext_pad_len;
3133 unsigned plaintext_len;
3134 struct rte_cryptodev_info dev_info;
3136 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3137 uint64_t feat_flags = dev_info.feature_flags;
3139 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3140 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3141 printf("Device doesn't support RAW data-path APIs.\n");
3145 /* Verify the capabilities */
3146 struct rte_cryptodev_sym_capability_idx cap_idx;
3147 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3148 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3149 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3153 /* Create KASUMI session */
3154 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3155 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3156 RTE_CRYPTO_CIPHER_KASUMI_F8,
3157 tdata->key.data, tdata->key.len,
3158 tdata->cipher_iv.len);
3162 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3164 /* Clear mbuf payload */
3165 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3166 rte_pktmbuf_tailroom(ut_params->ibuf));
3168 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3169 /* Append data which is padded to a multiple */
3170 /* of the algorithms block size */
3171 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3172 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3174 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3176 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3178 /* Create KASUMI operation */
3179 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3180 tdata->cipher_iv.len,
3181 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3182 tdata->validCipherOffsetInBits.len);
3186 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3187 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3188 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3190 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3192 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3194 ut_params->obuf = ut_params->op->sym->m_dst;
3195 if (ut_params->obuf)
3196 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3198 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3200 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3202 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3203 (tdata->validCipherOffsetInBits.len >> 3);
3205 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3207 reference_ciphertext,
3208 tdata->validCipherLenInBits.len,
3209 "KASUMI Ciphertext data not as expected");
3214 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3216 struct crypto_testsuite_params *ts_params = &testsuite_params;
3217 struct crypto_unittest_params *ut_params = &unittest_params;
3221 unsigned int plaintext_pad_len;
3222 unsigned int plaintext_len;
3224 uint8_t buffer[10000];
3225 const uint8_t *ciphertext;
3227 struct rte_cryptodev_info dev_info;
3229 /* Verify the capabilities */
3230 struct rte_cryptodev_sym_capability_idx cap_idx;
3231 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3232 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3233 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3237 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3239 uint64_t feat_flags = dev_info.feature_flags;
3241 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3242 printf("Device doesn't support in-place scatter-gather. "
3247 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3248 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3249 printf("Device doesn't support RAW data-path APIs.\n");
3253 /* Create KASUMI session */
3254 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3255 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3256 RTE_CRYPTO_CIPHER_KASUMI_F8,
3257 tdata->key.data, tdata->key.len,
3258 tdata->cipher_iv.len);
3262 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3265 /* Append data which is padded to a multiple */
3266 /* of the algorithms block size */
3267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3269 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3270 plaintext_pad_len, 10, 0);
3272 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3274 /* Create KASUMI operation */
3275 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3276 tdata->cipher_iv.len,
3277 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3278 tdata->validCipherOffsetInBits.len);
3282 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3283 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3284 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3286 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3288 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3290 ut_params->obuf = ut_params->op->sym->m_dst;
3292 if (ut_params->obuf)
3293 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3294 plaintext_len, buffer);
3296 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3297 tdata->validCipherOffsetInBits.len >> 3,
3298 plaintext_len, buffer);
3301 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3303 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3304 (tdata->validCipherOffsetInBits.len >> 3);
3306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3308 reference_ciphertext,
3309 tdata->validCipherLenInBits.len,
3310 "KASUMI Ciphertext data not as expected");
3315 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3317 struct crypto_testsuite_params *ts_params = &testsuite_params;
3318 struct crypto_unittest_params *ut_params = &unittest_params;
3321 uint8_t *plaintext, *ciphertext;
3322 unsigned plaintext_pad_len;
3323 unsigned plaintext_len;
3325 /* Verify the capabilities */
3326 struct rte_cryptodev_sym_capability_idx cap_idx;
3327 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3328 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3329 /* Data-path service does not support OOP */
3330 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3334 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3337 /* Create KASUMI session */
3338 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3339 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3340 RTE_CRYPTO_CIPHER_KASUMI_F8,
3341 tdata->key.data, tdata->key.len,
3342 tdata->cipher_iv.len);
3346 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3347 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3349 /* Clear mbuf payload */
3350 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3351 rte_pktmbuf_tailroom(ut_params->ibuf));
3353 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3354 /* Append data which is padded to a multiple */
3355 /* of the algorithms block size */
3356 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3357 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3359 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3360 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3362 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3364 /* Create KASUMI operation */
3365 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3366 tdata->cipher_iv.len,
3367 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3368 tdata->validCipherOffsetInBits.len);
3372 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3374 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3376 ut_params->obuf = ut_params->op->sym->m_dst;
3377 if (ut_params->obuf)
3378 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3380 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3382 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3384 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3385 (tdata->validCipherOffsetInBits.len >> 3);
3387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3389 reference_ciphertext,
3390 tdata->validCipherLenInBits.len,
3391 "KASUMI Ciphertext data not as expected");
3396 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3398 struct crypto_testsuite_params *ts_params = &testsuite_params;
3399 struct crypto_unittest_params *ut_params = &unittest_params;
3402 unsigned int plaintext_pad_len;
3403 unsigned int plaintext_len;
3405 const uint8_t *ciphertext;
3406 uint8_t buffer[2048];
3408 struct rte_cryptodev_info dev_info;
3410 /* Verify the capabilities */
3411 struct rte_cryptodev_sym_capability_idx cap_idx;
3412 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3413 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3414 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3418 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3421 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3423 uint64_t feat_flags = dev_info.feature_flags;
3424 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3425 printf("Device doesn't support out-of-place scatter-gather "
3426 "in both input and output mbufs. "
3431 /* Create KASUMI session */
3432 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3433 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3434 RTE_CRYPTO_CIPHER_KASUMI_F8,
3435 tdata->key.data, tdata->key.len,
3436 tdata->cipher_iv.len);
3440 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3441 /* Append data which is padded to a multiple */
3442 /* of the algorithms block size */
3443 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3445 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3446 plaintext_pad_len, 10, 0);
3447 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3448 plaintext_pad_len, 3, 0);
3450 /* Append data which is padded to a multiple */
3451 /* of the algorithms block size */
3452 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3454 /* Create KASUMI operation */
3455 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3456 tdata->cipher_iv.len,
3457 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3458 tdata->validCipherOffsetInBits.len);
3462 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3464 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3466 ut_params->obuf = ut_params->op->sym->m_dst;
3467 if (ut_params->obuf)
3468 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3469 plaintext_pad_len, buffer);
3471 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3472 tdata->validCipherOffsetInBits.len >> 3,
3473 plaintext_pad_len, buffer);
3475 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3476 (tdata->validCipherOffsetInBits.len >> 3);
3478 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3480 reference_ciphertext,
3481 tdata->validCipherLenInBits.len,
3482 "KASUMI Ciphertext data not as expected");
3488 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3490 struct crypto_testsuite_params *ts_params = &testsuite_params;
3491 struct crypto_unittest_params *ut_params = &unittest_params;
3494 uint8_t *ciphertext, *plaintext;
3495 unsigned ciphertext_pad_len;
3496 unsigned ciphertext_len;
3498 /* Verify the capabilities */
3499 struct rte_cryptodev_sym_capability_idx cap_idx;
3500 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3501 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3502 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3506 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3509 /* Create KASUMI session */
3510 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3511 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3512 RTE_CRYPTO_CIPHER_KASUMI_F8,
3513 tdata->key.data, tdata->key.len,
3514 tdata->cipher_iv.len);
3518 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3519 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3521 /* Clear mbuf payload */
3522 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3523 rte_pktmbuf_tailroom(ut_params->ibuf));
3525 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3526 /* Append data which is padded to a multiple */
3527 /* of the algorithms block size */
3528 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3529 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3530 ciphertext_pad_len);
3531 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3532 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3534 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3536 /* Create KASUMI operation */
3537 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3538 tdata->cipher_iv.len,
3539 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3540 tdata->validCipherOffsetInBits.len);
3544 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3546 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3548 ut_params->obuf = ut_params->op->sym->m_dst;
3549 if (ut_params->obuf)
3550 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3552 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3554 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3556 const uint8_t *reference_plaintext = tdata->plaintext.data +
3557 (tdata->validCipherOffsetInBits.len >> 3);
3559 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3561 reference_plaintext,
3562 tdata->validCipherLenInBits.len,
3563 "KASUMI Plaintext data not as expected");
3568 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3570 struct crypto_testsuite_params *ts_params = &testsuite_params;
3571 struct crypto_unittest_params *ut_params = &unittest_params;
3574 uint8_t *ciphertext, *plaintext;
3575 unsigned ciphertext_pad_len;
3576 unsigned ciphertext_len;
3577 struct rte_cryptodev_info dev_info;
3579 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3580 uint64_t feat_flags = dev_info.feature_flags;
3582 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3583 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3584 printf("Device doesn't support RAW data-path APIs.\n");
3588 /* Verify the capabilities */
3589 struct rte_cryptodev_sym_capability_idx cap_idx;
3590 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3591 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3592 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3596 /* Create KASUMI session */
3597 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3598 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3599 RTE_CRYPTO_CIPHER_KASUMI_F8,
3600 tdata->key.data, tdata->key.len,
3601 tdata->cipher_iv.len);
3605 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3607 /* Clear mbuf payload */
3608 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3609 rte_pktmbuf_tailroom(ut_params->ibuf));
3611 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3612 /* Append data which is padded to a multiple */
3613 /* of the algorithms block size */
3614 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3615 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3616 ciphertext_pad_len);
3617 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3619 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3621 /* Create KASUMI operation */
3622 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3623 tdata->cipher_iv.len,
3624 tdata->ciphertext.len,
3625 tdata->validCipherOffsetInBits.len);
3629 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3630 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3631 ut_params->op, 1, 0, 1, 0);
3633 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3635 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3637 ut_params->obuf = ut_params->op->sym->m_dst;
3638 if (ut_params->obuf)
3639 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3641 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3643 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3645 const uint8_t *reference_plaintext = tdata->plaintext.data +
3646 (tdata->validCipherOffsetInBits.len >> 3);
3648 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3650 reference_plaintext,
3651 tdata->validCipherLenInBits.len,
3652 "KASUMI Plaintext data not as expected");
3657 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3659 struct crypto_testsuite_params *ts_params = &testsuite_params;
3660 struct crypto_unittest_params *ut_params = &unittest_params;
3663 uint8_t *plaintext, *ciphertext;
3664 unsigned plaintext_pad_len;
3665 unsigned plaintext_len;
3666 struct rte_cryptodev_info dev_info;
3668 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3669 uint64_t feat_flags = dev_info.feature_flags;
3671 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3672 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3673 printf("Device doesn't support RAW data-path APIs.\n");
3677 /* Verify the capabilities */
3678 struct rte_cryptodev_sym_capability_idx cap_idx;
3679 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3680 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3681 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3685 /* Create SNOW 3G session */
3686 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3687 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3688 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3689 tdata->key.data, tdata->key.len,
3690 tdata->cipher_iv.len);
3694 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3696 /* Clear mbuf payload */
3697 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3698 rte_pktmbuf_tailroom(ut_params->ibuf));
3700 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3701 /* Append data which is padded to a multiple of */
3702 /* the algorithms block size */
3703 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3704 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3706 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3708 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3710 /* Create SNOW 3G operation */
3711 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3712 tdata->cipher_iv.len,
3713 tdata->validCipherLenInBits.len,
3718 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3719 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3720 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3722 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3724 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3726 ut_params->obuf = ut_params->op->sym->m_dst;
3727 if (ut_params->obuf)
3728 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3730 ciphertext = plaintext;
3732 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3735 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3737 tdata->ciphertext.data,
3738 tdata->validDataLenInBits.len,
3739 "SNOW 3G Ciphertext data not as expected");
3745 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3747 struct crypto_testsuite_params *ts_params = &testsuite_params;
3748 struct crypto_unittest_params *ut_params = &unittest_params;
3749 uint8_t *plaintext, *ciphertext;
3752 unsigned plaintext_pad_len;
3753 unsigned plaintext_len;
3755 /* Verify the capabilities */
3756 struct rte_cryptodev_sym_capability_idx cap_idx;
3757 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3758 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3759 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3763 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3766 /* Create SNOW 3G session */
3767 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3768 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3769 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3770 tdata->key.data, tdata->key.len,
3771 tdata->cipher_iv.len);
3775 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3776 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3778 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3779 "Failed to allocate input buffer in mempool");
3780 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3781 "Failed to allocate output buffer in mempool");
3783 /* Clear mbuf payload */
3784 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3785 rte_pktmbuf_tailroom(ut_params->ibuf));
3787 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3788 /* Append data which is padded to a multiple of */
3789 /* the algorithms block size */
3790 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3791 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3793 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3794 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3796 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3798 /* Create SNOW 3G operation */
3799 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3800 tdata->cipher_iv.len,
3801 tdata->validCipherLenInBits.len,
3806 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3808 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3810 ut_params->obuf = ut_params->op->sym->m_dst;
3811 if (ut_params->obuf)
3812 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3814 ciphertext = plaintext;
3816 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3819 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3821 tdata->ciphertext.data,
3822 tdata->validDataLenInBits.len,
3823 "SNOW 3G Ciphertext data not as expected");
3828 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3830 struct crypto_testsuite_params *ts_params = &testsuite_params;
3831 struct crypto_unittest_params *ut_params = &unittest_params;
3834 unsigned int plaintext_pad_len;
3835 unsigned int plaintext_len;
3836 uint8_t buffer[10000];
3837 const uint8_t *ciphertext;
3839 struct rte_cryptodev_info dev_info;
3841 /* Verify the capabilities */
3842 struct rte_cryptodev_sym_capability_idx cap_idx;
3843 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3844 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3845 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3849 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3852 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3854 uint64_t feat_flags = dev_info.feature_flags;
3856 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3857 printf("Device doesn't support out-of-place scatter-gather "
3858 "in both input and output mbufs. "
3863 /* Create SNOW 3G session */
3864 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3865 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3866 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3867 tdata->key.data, tdata->key.len,
3868 tdata->cipher_iv.len);
3872 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3873 /* Append data which is padded to a multiple of */
3874 /* the algorithms block size */
3875 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3877 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3878 plaintext_pad_len, 10, 0);
3879 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3880 plaintext_pad_len, 3, 0);
3882 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3883 "Failed to allocate input buffer in mempool");
3884 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3885 "Failed to allocate output buffer in mempool");
3887 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3889 /* Create SNOW 3G operation */
3890 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3891 tdata->cipher_iv.len,
3892 tdata->validCipherLenInBits.len,
3897 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3899 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3901 ut_params->obuf = ut_params->op->sym->m_dst;
3902 if (ut_params->obuf)
3903 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3904 plaintext_len, buffer);
3906 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3907 plaintext_len, buffer);
3909 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3912 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3914 tdata->ciphertext.data,
3915 tdata->validDataLenInBits.len,
3916 "SNOW 3G Ciphertext data not as expected");
3921 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3923 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3925 uint8_t curr_byte, prev_byte;
3926 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3927 uint8_t lower_byte_mask = (1 << offset) - 1;
3930 prev_byte = buffer[0];
3931 buffer[0] >>= offset;
3933 for (i = 1; i < length_in_bytes; i++) {
3934 curr_byte = buffer[i];
3935 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3936 (curr_byte >> offset);
3937 prev_byte = curr_byte;
3942 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3944 struct crypto_testsuite_params *ts_params = &testsuite_params;
3945 struct crypto_unittest_params *ut_params = &unittest_params;
3946 uint8_t *plaintext, *ciphertext;
3948 uint32_t plaintext_len;
3949 uint32_t plaintext_pad_len;
3950 uint8_t extra_offset = 4;
3951 uint8_t *expected_ciphertext_shifted;
3952 struct rte_cryptodev_info dev_info;
3954 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3955 uint64_t feat_flags = dev_info.feature_flags;
3957 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3958 ((tdata->validDataLenInBits.len % 8) != 0)) {
3959 printf("Device doesn't support NON-Byte Aligned Data.\n");
3963 /* Verify the capabilities */
3964 struct rte_cryptodev_sym_capability_idx cap_idx;
3965 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3966 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
3967 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3971 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3974 /* Create SNOW 3G session */
3975 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3976 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3977 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3978 tdata->key.data, tdata->key.len,
3979 tdata->cipher_iv.len);
3983 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3984 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3986 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3987 "Failed to allocate input buffer in mempool");
3988 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3989 "Failed to allocate output buffer in mempool");
3991 /* Clear mbuf payload */
3992 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3993 rte_pktmbuf_tailroom(ut_params->ibuf));
3995 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3997 * Append data which is padded to a
3998 * multiple of the algorithms block size
4000 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4002 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4005 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4007 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4008 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4010 #ifdef RTE_APP_TEST_DEBUG
4011 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4013 /* Create SNOW 3G operation */
4014 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4015 tdata->cipher_iv.len,
4016 tdata->validCipherLenInBits.len,
4021 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4023 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4025 ut_params->obuf = ut_params->op->sym->m_dst;
4026 if (ut_params->obuf)
4027 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4029 ciphertext = plaintext;
4031 #ifdef RTE_APP_TEST_DEBUG
4032 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4035 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4037 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4038 "failed to reserve memory for ciphertext shifted\n");
4040 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4041 ceil_byte_length(tdata->ciphertext.len));
4042 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4045 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4047 expected_ciphertext_shifted,
4048 tdata->validDataLenInBits.len,
4050 "SNOW 3G Ciphertext data not as expected");
4054 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4056 struct crypto_testsuite_params *ts_params = &testsuite_params;
4057 struct crypto_unittest_params *ut_params = &unittest_params;
4061 uint8_t *plaintext, *ciphertext;
4062 unsigned ciphertext_pad_len;
4063 unsigned ciphertext_len;
4064 struct rte_cryptodev_info dev_info;
4066 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4067 uint64_t feat_flags = dev_info.feature_flags;
4069 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4070 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4071 printf("Device doesn't support RAW data-path APIs.\n");
4075 /* Verify the capabilities */
4076 struct rte_cryptodev_sym_capability_idx cap_idx;
4077 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4078 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4079 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4083 /* Create SNOW 3G session */
4084 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4085 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4086 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4087 tdata->key.data, tdata->key.len,
4088 tdata->cipher_iv.len);
4092 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4094 /* Clear mbuf payload */
4095 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4096 rte_pktmbuf_tailroom(ut_params->ibuf));
4098 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4099 /* Append data which is padded to a multiple of */
4100 /* the algorithms block size */
4101 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4102 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4103 ciphertext_pad_len);
4104 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4106 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4108 /* Create SNOW 3G operation */
4109 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4110 tdata->cipher_iv.len,
4111 tdata->validCipherLenInBits.len,
4112 tdata->cipher.offset_bits);
4116 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4117 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4118 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4122 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4123 ut_params->obuf = ut_params->op->sym->m_dst;
4124 if (ut_params->obuf)
4125 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4127 plaintext = ciphertext;
4129 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4132 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4133 tdata->plaintext.data,
4134 tdata->validDataLenInBits.len,
4135 "SNOW 3G Plaintext data not as expected");
4139 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4141 struct crypto_testsuite_params *ts_params = &testsuite_params;
4142 struct crypto_unittest_params *ut_params = &unittest_params;
4146 uint8_t *plaintext, *ciphertext;
4147 unsigned ciphertext_pad_len;
4148 unsigned ciphertext_len;
4150 /* Verify the capabilities */
4151 struct rte_cryptodev_sym_capability_idx cap_idx;
4152 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4153 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4154 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4158 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4161 /* Create SNOW 3G session */
4162 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4163 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4164 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4165 tdata->key.data, tdata->key.len,
4166 tdata->cipher_iv.len);
4170 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4171 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4173 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4174 "Failed to allocate input buffer");
4175 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4176 "Failed to allocate output buffer");
4178 /* Clear mbuf payload */
4179 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4180 rte_pktmbuf_tailroom(ut_params->ibuf));
4182 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4183 rte_pktmbuf_tailroom(ut_params->obuf));
4185 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4186 /* Append data which is padded to a multiple of */
4187 /* the algorithms block size */
4188 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4189 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4190 ciphertext_pad_len);
4191 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4192 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4194 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4196 /* Create SNOW 3G operation */
4197 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4198 tdata->cipher_iv.len,
4199 tdata->validCipherLenInBits.len,
4204 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4206 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4207 ut_params->obuf = ut_params->op->sym->m_dst;
4208 if (ut_params->obuf)
4209 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4211 plaintext = ciphertext;
4213 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4216 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4217 tdata->plaintext.data,
4218 tdata->validDataLenInBits.len,
4219 "SNOW 3G Plaintext data not as expected");
4224 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4226 struct crypto_testsuite_params *ts_params = &testsuite_params;
4227 struct crypto_unittest_params *ut_params = &unittest_params;
4231 uint8_t *plaintext, *ciphertext;
4232 unsigned int plaintext_pad_len;
4233 unsigned int plaintext_len;
4235 struct rte_cryptodev_info dev_info;
4236 struct rte_cryptodev_sym_capability_idx cap_idx;
4238 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4239 uint64_t feat_flags = dev_info.feature_flags;
4241 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4242 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4243 (tdata->validDataLenInBits.len % 8 != 0))) {
4244 printf("Device doesn't support NON-Byte Aligned Data.\n");
4248 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4249 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4250 printf("Device doesn't support RAW data-path APIs.\n");
4254 /* Check if device supports ZUC EEA3 */
4255 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4256 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4258 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4262 /* Check if device supports ZUC EIA3 */
4263 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4264 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4266 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4270 /* Create ZUC session */
4271 retval = create_zuc_cipher_auth_encrypt_generate_session(
4272 ts_params->valid_devs[0],
4276 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4278 /* clear mbuf payload */
4279 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4280 rte_pktmbuf_tailroom(ut_params->ibuf));
4282 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4283 /* Append data which is padded to a multiple of */
4284 /* the algorithms block size */
4285 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4286 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4288 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4290 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4292 /* Create ZUC operation */
4293 retval = create_zuc_cipher_hash_generate_operation(tdata);
4297 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4298 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4299 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4301 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4303 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4304 ut_params->obuf = ut_params->op->sym->m_src;
4305 if (ut_params->obuf)
4306 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4308 ciphertext = plaintext;
4310 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4312 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4314 tdata->ciphertext.data,
4315 tdata->validDataLenInBits.len,
4316 "ZUC Ciphertext data not as expected");
4318 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4319 + plaintext_pad_len;
4322 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4326 "ZUC Generated auth tag not as expected");
4331 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4333 struct crypto_testsuite_params *ts_params = &testsuite_params;
4334 struct crypto_unittest_params *ut_params = &unittest_params;
4338 uint8_t *plaintext, *ciphertext;
4339 unsigned plaintext_pad_len;
4340 unsigned plaintext_len;
4341 struct rte_cryptodev_info dev_info;
4343 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4344 uint64_t feat_flags = dev_info.feature_flags;
4346 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4347 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4348 printf("Device doesn't support RAW data-path APIs.\n");
4352 /* Verify the capabilities */
4353 struct rte_cryptodev_sym_capability_idx cap_idx;
4354 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4355 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4356 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4359 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4360 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4361 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4365 /* Create SNOW 3G session */
4366 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4367 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4368 RTE_CRYPTO_AUTH_OP_GENERATE,
4369 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4370 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4371 tdata->key.data, tdata->key.len,
4372 tdata->auth_iv.len, tdata->digest.len,
4373 tdata->cipher_iv.len);
4376 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4378 /* clear mbuf payload */
4379 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4380 rte_pktmbuf_tailroom(ut_params->ibuf));
4382 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4383 /* Append data which is padded to a multiple of */
4384 /* the algorithms block size */
4385 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4386 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4388 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4390 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4392 /* Create SNOW 3G operation */
4393 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4394 tdata->digest.len, tdata->auth_iv.data,
4396 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4397 tdata->cipher_iv.data, tdata->cipher_iv.len,
4398 tdata->validCipherLenInBits.len,
4400 tdata->validAuthLenInBits.len,
4406 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4407 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4408 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4410 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4412 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4413 ut_params->obuf = ut_params->op->sym->m_src;
4414 if (ut_params->obuf)
4415 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4417 ciphertext = plaintext;
4419 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4421 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4423 tdata->ciphertext.data,
4424 tdata->validDataLenInBits.len,
4425 "SNOW 3G Ciphertext data not as expected");
4427 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4428 + plaintext_pad_len;
4431 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4434 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4435 "SNOW 3G Generated auth tag not as expected");
4440 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4441 uint8_t op_mode, uint8_t verify)
4443 struct crypto_testsuite_params *ts_params = &testsuite_params;
4444 struct crypto_unittest_params *ut_params = &unittest_params;
4448 uint8_t *plaintext = NULL, *ciphertext = NULL;
4449 unsigned int plaintext_pad_len;
4450 unsigned int plaintext_len;
4451 unsigned int ciphertext_pad_len;
4452 unsigned int ciphertext_len;
4454 struct rte_cryptodev_info dev_info;
4456 /* Verify the capabilities */
4457 struct rte_cryptodev_sym_capability_idx cap_idx;
4458 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4459 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4460 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4463 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4464 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4465 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4469 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4471 uint64_t feat_flags = dev_info.feature_flags;
4473 if (op_mode == OUT_OF_PLACE) {
4474 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4475 printf("Device doesn't support digest encrypted.\n");
4478 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4482 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4483 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4484 printf("Device doesn't support RAW data-path APIs.\n");
4488 /* Create SNOW 3G session */
4489 retval = create_wireless_algo_auth_cipher_session(
4490 ts_params->valid_devs[0],
4491 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4492 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4493 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4494 : RTE_CRYPTO_AUTH_OP_GENERATE),
4495 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4496 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4497 tdata->key.data, tdata->key.len,
4498 tdata->auth_iv.len, tdata->digest.len,
4499 tdata->cipher_iv.len);
4504 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4505 if (op_mode == OUT_OF_PLACE)
4506 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4508 /* clear mbuf payload */
4509 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4510 rte_pktmbuf_tailroom(ut_params->ibuf));
4511 if (op_mode == OUT_OF_PLACE)
4512 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4513 rte_pktmbuf_tailroom(ut_params->obuf));
4515 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4516 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4517 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4518 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4521 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4522 ciphertext_pad_len);
4523 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4524 if (op_mode == OUT_OF_PLACE)
4525 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4526 debug_hexdump(stdout, "ciphertext:", ciphertext,
4529 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4531 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4532 if (op_mode == OUT_OF_PLACE)
4533 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4534 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4537 /* Create SNOW 3G operation */
4538 retval = create_wireless_algo_auth_cipher_operation(
4539 tdata->digest.data, tdata->digest.len,
4540 tdata->cipher_iv.data, tdata->cipher_iv.len,
4541 tdata->auth_iv.data, tdata->auth_iv.len,
4542 (tdata->digest.offset_bytes == 0 ?
4543 (verify ? ciphertext_pad_len : plaintext_pad_len)
4544 : tdata->digest.offset_bytes),
4545 tdata->validCipherLenInBits.len,
4546 tdata->cipher.offset_bits,
4547 tdata->validAuthLenInBits.len,
4548 tdata->auth.offset_bits,
4549 op_mode, 0, verify);
4554 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4555 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4556 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4558 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4561 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4563 ut_params->obuf = (op_mode == IN_PLACE ?
4564 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4567 if (ut_params->obuf)
4568 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4571 plaintext = ciphertext +
4572 (tdata->cipher.offset_bits >> 3);
4574 debug_hexdump(stdout, "plaintext:", plaintext,
4575 (tdata->plaintext.len >> 3) - tdata->digest.len);
4576 debug_hexdump(stdout, "plaintext expected:",
4577 tdata->plaintext.data,
4578 (tdata->plaintext.len >> 3) - tdata->digest.len);
4580 if (ut_params->obuf)
4581 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4584 ciphertext = plaintext;
4586 debug_hexdump(stdout, "ciphertext:", ciphertext,
4588 debug_hexdump(stdout, "ciphertext expected:",
4589 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4591 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4592 + (tdata->digest.offset_bytes == 0 ?
4593 plaintext_pad_len : tdata->digest.offset_bytes);
4595 debug_hexdump(stdout, "digest:", ut_params->digest,
4597 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4603 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4605 tdata->plaintext.data,
4606 tdata->plaintext.len >> 3,
4607 "SNOW 3G Plaintext data not as expected");
4609 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4611 tdata->ciphertext.data,
4612 tdata->validDataLenInBits.len,
4613 "SNOW 3G Ciphertext data not as expected");
4615 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4618 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4619 "SNOW 3G Generated auth tag not as expected");
4625 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4626 uint8_t op_mode, uint8_t verify)
4628 struct crypto_testsuite_params *ts_params = &testsuite_params;
4629 struct crypto_unittest_params *ut_params = &unittest_params;
4633 const uint8_t *plaintext = NULL;
4634 const uint8_t *ciphertext = NULL;
4635 const uint8_t *digest = NULL;
4636 unsigned int plaintext_pad_len;
4637 unsigned int plaintext_len;
4638 unsigned int ciphertext_pad_len;
4639 unsigned int ciphertext_len;
4640 uint8_t buffer[10000];
4641 uint8_t digest_buffer[10000];
4643 struct rte_cryptodev_info dev_info;
4645 /* Verify the capabilities */
4646 struct rte_cryptodev_sym_capability_idx cap_idx;
4647 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4648 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4649 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4652 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4653 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4654 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4658 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4660 uint64_t feat_flags = dev_info.feature_flags;
4662 if (op_mode == IN_PLACE) {
4663 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4664 printf("Device doesn't support in-place scatter-gather "
4665 "in both input and output mbufs.\n");
4668 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4669 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4670 printf("Device doesn't support RAW data-path APIs.\n");
4674 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4676 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4677 printf("Device doesn't support out-of-place scatter-gather "
4678 "in both input and output mbufs.\n");
4681 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4682 printf("Device doesn't support digest encrypted.\n");
4687 /* Create SNOW 3G session */
4688 retval = create_wireless_algo_auth_cipher_session(
4689 ts_params->valid_devs[0],
4690 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4691 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4692 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4693 : RTE_CRYPTO_AUTH_OP_GENERATE),
4694 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4695 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4696 tdata->key.data, tdata->key.len,
4697 tdata->auth_iv.len, tdata->digest.len,
4698 tdata->cipher_iv.len);
4703 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4704 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4705 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4706 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4708 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4709 plaintext_pad_len, 15, 0);
4710 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4711 "Failed to allocate input buffer in mempool");
4713 if (op_mode == OUT_OF_PLACE) {
4714 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4715 plaintext_pad_len, 15, 0);
4716 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4717 "Failed to allocate output buffer in mempool");
4721 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4722 tdata->ciphertext.data);
4723 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4724 ciphertext_len, buffer);
4725 debug_hexdump(stdout, "ciphertext:", ciphertext,
4728 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4729 tdata->plaintext.data);
4730 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4731 plaintext_len, buffer);
4732 debug_hexdump(stdout, "plaintext:", plaintext,
4735 memset(buffer, 0, sizeof(buffer));
4737 /* Create SNOW 3G operation */
4738 retval = create_wireless_algo_auth_cipher_operation(
4739 tdata->digest.data, tdata->digest.len,
4740 tdata->cipher_iv.data, tdata->cipher_iv.len,
4741 tdata->auth_iv.data, tdata->auth_iv.len,
4742 (tdata->digest.offset_bytes == 0 ?
4743 (verify ? ciphertext_pad_len : plaintext_pad_len)
4744 : tdata->digest.offset_bytes),
4745 tdata->validCipherLenInBits.len,
4746 tdata->cipher.offset_bits,
4747 tdata->validAuthLenInBits.len,
4748 tdata->auth.offset_bits,
4749 op_mode, 1, verify);
4754 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4755 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4756 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4758 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4761 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4763 ut_params->obuf = (op_mode == IN_PLACE ?
4764 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4767 if (ut_params->obuf)
4768 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4769 plaintext_len, buffer);
4771 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4772 plaintext_len, buffer);
4774 debug_hexdump(stdout, "plaintext:", plaintext,
4775 (tdata->plaintext.len >> 3) - tdata->digest.len);
4776 debug_hexdump(stdout, "plaintext expected:",
4777 tdata->plaintext.data,
4778 (tdata->plaintext.len >> 3) - tdata->digest.len);
4780 if (ut_params->obuf)
4781 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4782 ciphertext_len, buffer);
4784 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4785 ciphertext_len, buffer);
4787 debug_hexdump(stdout, "ciphertext:", ciphertext,
4789 debug_hexdump(stdout, "ciphertext expected:",
4790 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4792 if (ut_params->obuf)
4793 digest = rte_pktmbuf_read(ut_params->obuf,
4794 (tdata->digest.offset_bytes == 0 ?
4795 plaintext_pad_len : tdata->digest.offset_bytes),
4796 tdata->digest.len, digest_buffer);
4798 digest = rte_pktmbuf_read(ut_params->ibuf,
4799 (tdata->digest.offset_bytes == 0 ?
4800 plaintext_pad_len : tdata->digest.offset_bytes),
4801 tdata->digest.len, digest_buffer);
4803 debug_hexdump(stdout, "digest:", digest,
4805 debug_hexdump(stdout, "digest expected:",
4806 tdata->digest.data, tdata->digest.len);
4811 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4813 tdata->plaintext.data,
4814 tdata->plaintext.len >> 3,
4815 "SNOW 3G Plaintext data not as expected");
4817 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4819 tdata->ciphertext.data,
4820 tdata->validDataLenInBits.len,
4821 "SNOW 3G Ciphertext data not as expected");
4823 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4826 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4827 "SNOW 3G Generated auth tag not as expected");
4833 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4834 uint8_t op_mode, uint8_t verify)
4836 struct crypto_testsuite_params *ts_params = &testsuite_params;
4837 struct crypto_unittest_params *ut_params = &unittest_params;
4841 uint8_t *plaintext = NULL, *ciphertext = NULL;
4842 unsigned int plaintext_pad_len;
4843 unsigned int plaintext_len;
4844 unsigned int ciphertext_pad_len;
4845 unsigned int ciphertext_len;
4847 struct rte_cryptodev_info dev_info;
4849 /* Verify the capabilities */
4850 struct rte_cryptodev_sym_capability_idx cap_idx;
4851 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4852 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
4853 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4856 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4857 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4858 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4862 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4864 uint64_t feat_flags = dev_info.feature_flags;
4866 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4867 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4868 printf("Device doesn't support RAW data-path APIs.\n");
4872 if (op_mode == OUT_OF_PLACE) {
4873 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4875 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4876 printf("Device doesn't support digest encrypted.\n");
4881 /* Create KASUMI session */
4882 retval = create_wireless_algo_auth_cipher_session(
4883 ts_params->valid_devs[0],
4884 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4885 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4886 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4887 : RTE_CRYPTO_AUTH_OP_GENERATE),
4888 RTE_CRYPTO_AUTH_KASUMI_F9,
4889 RTE_CRYPTO_CIPHER_KASUMI_F8,
4890 tdata->key.data, tdata->key.len,
4891 0, tdata->digest.len,
4892 tdata->cipher_iv.len);
4897 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4898 if (op_mode == OUT_OF_PLACE)
4899 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4901 /* clear mbuf payload */
4902 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4903 rte_pktmbuf_tailroom(ut_params->ibuf));
4904 if (op_mode == OUT_OF_PLACE)
4905 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4906 rte_pktmbuf_tailroom(ut_params->obuf));
4908 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4909 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4910 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4911 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4914 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4915 ciphertext_pad_len);
4916 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4917 if (op_mode == OUT_OF_PLACE)
4918 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4919 debug_hexdump(stdout, "ciphertext:", ciphertext,
4922 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4924 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4925 if (op_mode == OUT_OF_PLACE)
4926 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4927 debug_hexdump(stdout, "plaintext:", plaintext,
4931 /* Create KASUMI operation */
4932 retval = create_wireless_algo_auth_cipher_operation(
4933 tdata->digest.data, tdata->digest.len,
4934 tdata->cipher_iv.data, tdata->cipher_iv.len,
4936 (tdata->digest.offset_bytes == 0 ?
4937 (verify ? ciphertext_pad_len : plaintext_pad_len)
4938 : tdata->digest.offset_bytes),
4939 tdata->validCipherLenInBits.len,
4940 tdata->validCipherOffsetInBits.len,
4941 tdata->validAuthLenInBits.len,
4943 op_mode, 0, verify);
4948 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4949 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4950 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4952 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4955 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4957 ut_params->obuf = (op_mode == IN_PLACE ?
4958 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4962 if (ut_params->obuf)
4963 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4966 plaintext = ciphertext;
4968 debug_hexdump(stdout, "plaintext:", plaintext,
4969 (tdata->plaintext.len >> 3) - tdata->digest.len);
4970 debug_hexdump(stdout, "plaintext expected:",
4971 tdata->plaintext.data,
4972 (tdata->plaintext.len >> 3) - tdata->digest.len);
4974 if (ut_params->obuf)
4975 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4978 ciphertext = plaintext;
4980 debug_hexdump(stdout, "ciphertext:", ciphertext,
4982 debug_hexdump(stdout, "ciphertext expected:",
4983 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4985 ut_params->digest = rte_pktmbuf_mtod(
4986 ut_params->obuf, uint8_t *) +
4987 (tdata->digest.offset_bytes == 0 ?
4988 plaintext_pad_len : tdata->digest.offset_bytes);
4990 debug_hexdump(stdout, "digest:", ut_params->digest,
4992 debug_hexdump(stdout, "digest expected:",
4993 tdata->digest.data, tdata->digest.len);
4998 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5000 tdata->plaintext.data,
5001 tdata->plaintext.len >> 3,
5002 "KASUMI Plaintext data not as expected");
5004 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5006 tdata->ciphertext.data,
5007 tdata->ciphertext.len >> 3,
5008 "KASUMI Ciphertext data not as expected");
5010 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5013 DIGEST_BYTE_LENGTH_KASUMI_F9,
5014 "KASUMI Generated auth tag not as expected");
5020 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5021 uint8_t op_mode, uint8_t verify)
5023 struct crypto_testsuite_params *ts_params = &testsuite_params;
5024 struct crypto_unittest_params *ut_params = &unittest_params;
5028 const uint8_t *plaintext = NULL;
5029 const uint8_t *ciphertext = NULL;
5030 const uint8_t *digest = NULL;
5031 unsigned int plaintext_pad_len;
5032 unsigned int plaintext_len;
5033 unsigned int ciphertext_pad_len;
5034 unsigned int ciphertext_len;
5035 uint8_t buffer[10000];
5036 uint8_t digest_buffer[10000];
5038 struct rte_cryptodev_info dev_info;
5040 /* Verify the capabilities */
5041 struct rte_cryptodev_sym_capability_idx cap_idx;
5042 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5043 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5044 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5047 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5048 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5049 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5053 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5055 uint64_t feat_flags = dev_info.feature_flags;
5057 if (op_mode == IN_PLACE) {
5058 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5059 printf("Device doesn't support in-place scatter-gather "
5060 "in both input and output mbufs.\n");
5063 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5064 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5065 printf("Device doesn't support RAW data-path APIs.\n");
5069 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5071 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5072 printf("Device doesn't support out-of-place scatter-gather "
5073 "in both input and output mbufs.\n");
5076 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5077 printf("Device doesn't support digest encrypted.\n");
5082 /* Create KASUMI session */
5083 retval = create_wireless_algo_auth_cipher_session(
5084 ts_params->valid_devs[0],
5085 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5086 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5087 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5088 : RTE_CRYPTO_AUTH_OP_GENERATE),
5089 RTE_CRYPTO_AUTH_KASUMI_F9,
5090 RTE_CRYPTO_CIPHER_KASUMI_F8,
5091 tdata->key.data, tdata->key.len,
5092 0, tdata->digest.len,
5093 tdata->cipher_iv.len);
5098 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5099 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5100 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5101 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5103 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5104 plaintext_pad_len, 15, 0);
5105 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5106 "Failed to allocate input buffer in mempool");
5108 if (op_mode == OUT_OF_PLACE) {
5109 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5110 plaintext_pad_len, 15, 0);
5111 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5112 "Failed to allocate output buffer in mempool");
5116 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5117 tdata->ciphertext.data);
5118 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5119 ciphertext_len, buffer);
5120 debug_hexdump(stdout, "ciphertext:", ciphertext,
5123 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5124 tdata->plaintext.data);
5125 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5126 plaintext_len, buffer);
5127 debug_hexdump(stdout, "plaintext:", plaintext,
5130 memset(buffer, 0, sizeof(buffer));
5132 /* Create KASUMI operation */
5133 retval = create_wireless_algo_auth_cipher_operation(
5134 tdata->digest.data, tdata->digest.len,
5135 tdata->cipher_iv.data, tdata->cipher_iv.len,
5137 (tdata->digest.offset_bytes == 0 ?
5138 (verify ? ciphertext_pad_len : plaintext_pad_len)
5139 : tdata->digest.offset_bytes),
5140 tdata->validCipherLenInBits.len,
5141 tdata->validCipherOffsetInBits.len,
5142 tdata->validAuthLenInBits.len,
5144 op_mode, 1, verify);
5149 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5150 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5151 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5153 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5156 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5158 ut_params->obuf = (op_mode == IN_PLACE ?
5159 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5162 if (ut_params->obuf)
5163 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5164 plaintext_len, buffer);
5166 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5167 plaintext_len, buffer);
5169 debug_hexdump(stdout, "plaintext:", plaintext,
5170 (tdata->plaintext.len >> 3) - tdata->digest.len);
5171 debug_hexdump(stdout, "plaintext expected:",
5172 tdata->plaintext.data,
5173 (tdata->plaintext.len >> 3) - tdata->digest.len);
5175 if (ut_params->obuf)
5176 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5177 ciphertext_len, buffer);
5179 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5180 ciphertext_len, buffer);
5182 debug_hexdump(stdout, "ciphertext:", ciphertext,
5184 debug_hexdump(stdout, "ciphertext expected:",
5185 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5187 if (ut_params->obuf)
5188 digest = rte_pktmbuf_read(ut_params->obuf,
5189 (tdata->digest.offset_bytes == 0 ?
5190 plaintext_pad_len : tdata->digest.offset_bytes),
5191 tdata->digest.len, digest_buffer);
5193 digest = rte_pktmbuf_read(ut_params->ibuf,
5194 (tdata->digest.offset_bytes == 0 ?
5195 plaintext_pad_len : tdata->digest.offset_bytes),
5196 tdata->digest.len, digest_buffer);
5198 debug_hexdump(stdout, "digest:", digest,
5200 debug_hexdump(stdout, "digest expected:",
5201 tdata->digest.data, tdata->digest.len);
5206 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5208 tdata->plaintext.data,
5209 tdata->plaintext.len >> 3,
5210 "KASUMI Plaintext data not as expected");
5212 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5214 tdata->ciphertext.data,
5215 tdata->validDataLenInBits.len,
5216 "KASUMI Ciphertext data not as expected");
5218 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5221 DIGEST_BYTE_LENGTH_KASUMI_F9,
5222 "KASUMI Generated auth tag not as expected");
5228 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5230 struct crypto_testsuite_params *ts_params = &testsuite_params;
5231 struct crypto_unittest_params *ut_params = &unittest_params;
5235 uint8_t *plaintext, *ciphertext;
5236 unsigned plaintext_pad_len;
5237 unsigned plaintext_len;
5238 struct rte_cryptodev_info dev_info;
5240 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5241 uint64_t feat_flags = dev_info.feature_flags;
5243 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5244 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5245 printf("Device doesn't support RAW data-path APIs.\n");
5249 /* Verify the capabilities */
5250 struct rte_cryptodev_sym_capability_idx cap_idx;
5251 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5252 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5253 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5256 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5257 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5258 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5262 /* Create KASUMI session */
5263 retval = create_wireless_algo_cipher_auth_session(
5264 ts_params->valid_devs[0],
5265 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5266 RTE_CRYPTO_AUTH_OP_GENERATE,
5267 RTE_CRYPTO_AUTH_KASUMI_F9,
5268 RTE_CRYPTO_CIPHER_KASUMI_F8,
5269 tdata->key.data, tdata->key.len,
5270 0, tdata->digest.len,
5271 tdata->cipher_iv.len);
5275 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5277 /* clear mbuf payload */
5278 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5279 rte_pktmbuf_tailroom(ut_params->ibuf));
5281 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5282 /* Append data which is padded to a multiple of */
5283 /* the algorithms block size */
5284 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5285 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5287 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5289 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5291 /* Create KASUMI operation */
5292 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5293 tdata->digest.len, NULL, 0,
5294 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5295 tdata->cipher_iv.data, tdata->cipher_iv.len,
5296 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5297 tdata->validCipherOffsetInBits.len,
5298 tdata->validAuthLenInBits.len,
5304 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5305 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5306 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5308 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5310 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5312 if (ut_params->op->sym->m_dst)
5313 ut_params->obuf = ut_params->op->sym->m_dst;
5315 ut_params->obuf = ut_params->op->sym->m_src;
5317 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5318 tdata->validCipherOffsetInBits.len >> 3);
5320 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5321 + plaintext_pad_len;
5323 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5324 (tdata->validCipherOffsetInBits.len >> 3);
5326 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5328 reference_ciphertext,
5329 tdata->validCipherLenInBits.len,
5330 "KASUMI Ciphertext data not as expected");
5333 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5336 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5337 "KASUMI Generated auth tag not as expected");
5342 test_zuc_encryption(const struct wireless_test_data *tdata)
5344 struct crypto_testsuite_params *ts_params = &testsuite_params;
5345 struct crypto_unittest_params *ut_params = &unittest_params;
5348 uint8_t *plaintext, *ciphertext;
5349 unsigned plaintext_pad_len;
5350 unsigned plaintext_len;
5351 struct rte_cryptodev_info dev_info;
5353 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5354 uint64_t feat_flags = dev_info.feature_flags;
5356 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5357 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5358 printf("Device doesn't support RAW data-path APIs.\n");
5362 struct rte_cryptodev_sym_capability_idx cap_idx;
5364 /* Check if device supports ZUC EEA3 */
5365 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5366 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5368 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5372 /* Create ZUC session */
5373 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5374 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5375 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5376 tdata->key.data, tdata->key.len,
5377 tdata->cipher_iv.len);
5381 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5383 /* Clear mbuf payload */
5384 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5385 rte_pktmbuf_tailroom(ut_params->ibuf));
5387 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5388 /* Append data which is padded to a multiple */
5389 /* of the algorithms block size */
5390 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5391 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5393 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5395 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5397 /* Create ZUC operation */
5398 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5399 tdata->cipher_iv.len,
5400 tdata->plaintext.len,
5405 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5406 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5407 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5409 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5411 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5413 ut_params->obuf = ut_params->op->sym->m_dst;
5414 if (ut_params->obuf)
5415 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5417 ciphertext = plaintext;
5419 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5422 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5424 tdata->ciphertext.data,
5425 tdata->validCipherLenInBits.len,
5426 "ZUC Ciphertext data not as expected");
5431 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5433 struct crypto_testsuite_params *ts_params = &testsuite_params;
5434 struct crypto_unittest_params *ut_params = &unittest_params;
5438 unsigned int plaintext_pad_len;
5439 unsigned int plaintext_len;
5440 const uint8_t *ciphertext;
5441 uint8_t ciphertext_buffer[2048];
5442 struct rte_cryptodev_info dev_info;
5444 struct rte_cryptodev_sym_capability_idx cap_idx;
5446 /* Check if device supports ZUC EEA3 */
5447 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5448 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5450 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5454 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5456 uint64_t feat_flags = dev_info.feature_flags;
5458 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5459 printf("Device doesn't support in-place scatter-gather. "
5464 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5465 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5466 printf("Device doesn't support RAW data-path APIs.\n");
5470 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5472 /* Append data which is padded to a multiple */
5473 /* of the algorithms block size */
5474 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5476 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5477 plaintext_pad_len, 10, 0);
5479 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5480 tdata->plaintext.data);
5482 /* Create ZUC session */
5483 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5484 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5485 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5486 tdata->key.data, tdata->key.len,
5487 tdata->cipher_iv.len);
5491 /* Clear mbuf payload */
5493 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5495 /* Create ZUC operation */
5496 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5497 tdata->cipher_iv.len, tdata->plaintext.len,
5502 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5503 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5504 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5506 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5508 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5510 ut_params->obuf = ut_params->op->sym->m_dst;
5511 if (ut_params->obuf)
5512 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5513 0, plaintext_len, ciphertext_buffer);
5515 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5516 0, plaintext_len, ciphertext_buffer);
5519 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5522 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5524 tdata->ciphertext.data,
5525 tdata->validCipherLenInBits.len,
5526 "ZUC Ciphertext data not as expected");
5532 test_zuc_authentication(const struct wireless_test_data *tdata)
5534 struct crypto_testsuite_params *ts_params = &testsuite_params;
5535 struct crypto_unittest_params *ut_params = &unittest_params;
5538 unsigned plaintext_pad_len;
5539 unsigned plaintext_len;
5542 struct rte_cryptodev_sym_capability_idx cap_idx;
5543 struct rte_cryptodev_info dev_info;
5545 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5546 uint64_t feat_flags = dev_info.feature_flags;
5548 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5549 (tdata->validAuthLenInBits.len % 8 != 0)) {
5550 printf("Device doesn't support NON-Byte Aligned Data.\n");
5554 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5555 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5556 printf("Device doesn't support RAW data-path APIs.\n");
5560 /* Check if device supports ZUC EIA3 */
5561 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5562 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5564 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5568 /* Create ZUC session */
5569 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5570 tdata->key.data, tdata->key.len,
5571 tdata->auth_iv.len, tdata->digest.len,
5572 RTE_CRYPTO_AUTH_OP_GENERATE,
5573 RTE_CRYPTO_AUTH_ZUC_EIA3);
5577 /* alloc mbuf and set payload */
5578 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5580 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5581 rte_pktmbuf_tailroom(ut_params->ibuf));
5583 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5584 /* Append data which is padded to a multiple of */
5585 /* the algorithms block size */
5586 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5587 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5589 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5591 /* Create ZUC operation */
5592 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5593 tdata->auth_iv.data, tdata->auth_iv.len,
5594 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5595 tdata->validAuthLenInBits.len,
5600 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5601 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5602 ut_params->op, 0, 1, 1, 0);
5604 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5606 ut_params->obuf = ut_params->op->sym->m_src;
5607 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5608 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5609 + plaintext_pad_len;
5612 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5616 "ZUC Generated auth tag not as expected");
5622 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5623 uint8_t op_mode, uint8_t verify)
5625 struct crypto_testsuite_params *ts_params = &testsuite_params;
5626 struct crypto_unittest_params *ut_params = &unittest_params;
5630 uint8_t *plaintext = NULL, *ciphertext = NULL;
5631 unsigned int plaintext_pad_len;
5632 unsigned int plaintext_len;
5633 unsigned int ciphertext_pad_len;
5634 unsigned int ciphertext_len;
5636 struct rte_cryptodev_info dev_info;
5637 struct rte_cryptodev_sym_capability_idx cap_idx;
5639 /* Check if device supports ZUC EIA3 */
5640 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5641 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5643 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5647 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5649 uint64_t feat_flags = dev_info.feature_flags;
5651 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5652 printf("Device doesn't support digest encrypted.\n");
5655 if (op_mode == IN_PLACE) {
5656 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5657 printf("Device doesn't support in-place scatter-gather "
5658 "in both input and output mbufs.\n");
5662 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5663 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5664 printf("Device doesn't support RAW data-path APIs.\n");
5668 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5670 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5671 printf("Device doesn't support out-of-place scatter-gather "
5672 "in both input and output mbufs.\n");
5677 /* Create ZUC session */
5678 retval = create_wireless_algo_auth_cipher_session(
5679 ts_params->valid_devs[0],
5680 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5681 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5682 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5683 : RTE_CRYPTO_AUTH_OP_GENERATE),
5684 RTE_CRYPTO_AUTH_ZUC_EIA3,
5685 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5686 tdata->key.data, tdata->key.len,
5687 tdata->auth_iv.len, tdata->digest.len,
5688 tdata->cipher_iv.len);
5693 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5694 if (op_mode == OUT_OF_PLACE)
5695 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5697 /* clear mbuf payload */
5698 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5699 rte_pktmbuf_tailroom(ut_params->ibuf));
5700 if (op_mode == OUT_OF_PLACE)
5701 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5702 rte_pktmbuf_tailroom(ut_params->obuf));
5704 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5705 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5706 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5707 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5710 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5711 ciphertext_pad_len);
5712 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5713 if (op_mode == OUT_OF_PLACE)
5714 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5715 debug_hexdump(stdout, "ciphertext:", ciphertext,
5718 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5720 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5721 if (op_mode == OUT_OF_PLACE)
5722 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5723 debug_hexdump(stdout, "plaintext:", plaintext,
5727 /* Create ZUC operation */
5728 retval = create_wireless_algo_auth_cipher_operation(
5729 tdata->digest.data, tdata->digest.len,
5730 tdata->cipher_iv.data, tdata->cipher_iv.len,
5731 tdata->auth_iv.data, tdata->auth_iv.len,
5732 (tdata->digest.offset_bytes == 0 ?
5733 (verify ? ciphertext_pad_len : plaintext_pad_len)
5734 : tdata->digest.offset_bytes),
5735 tdata->validCipherLenInBits.len,
5736 tdata->validCipherOffsetInBits.len,
5737 tdata->validAuthLenInBits.len,
5739 op_mode, 0, verify);
5744 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5745 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5746 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5751 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5753 ut_params->obuf = (op_mode == IN_PLACE ?
5754 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5758 if (ut_params->obuf)
5759 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5762 plaintext = ciphertext;
5764 debug_hexdump(stdout, "plaintext:", plaintext,
5765 (tdata->plaintext.len >> 3) - tdata->digest.len);
5766 debug_hexdump(stdout, "plaintext expected:",
5767 tdata->plaintext.data,
5768 (tdata->plaintext.len >> 3) - tdata->digest.len);
5770 if (ut_params->obuf)
5771 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5774 ciphertext = plaintext;
5776 debug_hexdump(stdout, "ciphertext:", ciphertext,
5778 debug_hexdump(stdout, "ciphertext expected:",
5779 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5781 ut_params->digest = rte_pktmbuf_mtod(
5782 ut_params->obuf, uint8_t *) +
5783 (tdata->digest.offset_bytes == 0 ?
5784 plaintext_pad_len : tdata->digest.offset_bytes);
5786 debug_hexdump(stdout, "digest:", ut_params->digest,
5788 debug_hexdump(stdout, "digest expected:",
5789 tdata->digest.data, tdata->digest.len);
5794 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5796 tdata->plaintext.data,
5797 tdata->plaintext.len >> 3,
5798 "ZUC Plaintext data not as expected");
5800 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5802 tdata->ciphertext.data,
5803 tdata->ciphertext.len >> 3,
5804 "ZUC Ciphertext data not as expected");
5806 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5809 DIGEST_BYTE_LENGTH_KASUMI_F9,
5810 "ZUC Generated auth tag not as expected");
5816 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5817 uint8_t op_mode, uint8_t verify)
5819 struct crypto_testsuite_params *ts_params = &testsuite_params;
5820 struct crypto_unittest_params *ut_params = &unittest_params;
5824 const uint8_t *plaintext = NULL;
5825 const uint8_t *ciphertext = NULL;
5826 const uint8_t *digest = NULL;
5827 unsigned int plaintext_pad_len;
5828 unsigned int plaintext_len;
5829 unsigned int ciphertext_pad_len;
5830 unsigned int ciphertext_len;
5831 uint8_t buffer[10000];
5832 uint8_t digest_buffer[10000];
5834 struct rte_cryptodev_info dev_info;
5835 struct rte_cryptodev_sym_capability_idx cap_idx;
5837 /* Check if device supports ZUC EIA3 */
5838 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5839 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5841 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5845 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5847 uint64_t feat_flags = dev_info.feature_flags;
5849 if (op_mode == IN_PLACE) {
5850 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5851 printf("Device doesn't support in-place scatter-gather "
5852 "in both input and output mbufs.\n");
5856 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5857 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5858 printf("Device doesn't support RAW data-path APIs.\n");
5862 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5864 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5865 printf("Device doesn't support out-of-place scatter-gather "
5866 "in both input and output mbufs.\n");
5869 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5870 printf("Device doesn't support digest encrypted.\n");
5875 /* Create ZUC session */
5876 retval = create_wireless_algo_auth_cipher_session(
5877 ts_params->valid_devs[0],
5878 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5879 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5880 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5881 : RTE_CRYPTO_AUTH_OP_GENERATE),
5882 RTE_CRYPTO_AUTH_ZUC_EIA3,
5883 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5884 tdata->key.data, tdata->key.len,
5885 tdata->auth_iv.len, tdata->digest.len,
5886 tdata->cipher_iv.len);
5891 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5892 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5893 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5894 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5896 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5897 plaintext_pad_len, 15, 0);
5898 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5899 "Failed to allocate input buffer in mempool");
5901 if (op_mode == OUT_OF_PLACE) {
5902 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5903 plaintext_pad_len, 15, 0);
5904 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5905 "Failed to allocate output buffer in mempool");
5909 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5910 tdata->ciphertext.data);
5911 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5912 ciphertext_len, buffer);
5913 debug_hexdump(stdout, "ciphertext:", ciphertext,
5916 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5917 tdata->plaintext.data);
5918 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5919 plaintext_len, buffer);
5920 debug_hexdump(stdout, "plaintext:", plaintext,
5923 memset(buffer, 0, sizeof(buffer));
5925 /* Create ZUC operation */
5926 retval = create_wireless_algo_auth_cipher_operation(
5927 tdata->digest.data, tdata->digest.len,
5928 tdata->cipher_iv.data, tdata->cipher_iv.len,
5930 (tdata->digest.offset_bytes == 0 ?
5931 (verify ? ciphertext_pad_len : plaintext_pad_len)
5932 : tdata->digest.offset_bytes),
5933 tdata->validCipherLenInBits.len,
5934 tdata->validCipherOffsetInBits.len,
5935 tdata->validAuthLenInBits.len,
5937 op_mode, 1, verify);
5942 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5943 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5944 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5946 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5951 ut_params->obuf = (op_mode == IN_PLACE ?
5952 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5955 if (ut_params->obuf)
5956 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5957 plaintext_len, buffer);
5959 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5960 plaintext_len, buffer);
5962 debug_hexdump(stdout, "plaintext:", plaintext,
5963 (tdata->plaintext.len >> 3) - tdata->digest.len);
5964 debug_hexdump(stdout, "plaintext expected:",
5965 tdata->plaintext.data,
5966 (tdata->plaintext.len >> 3) - tdata->digest.len);
5968 if (ut_params->obuf)
5969 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5970 ciphertext_len, buffer);
5972 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5973 ciphertext_len, buffer);
5975 debug_hexdump(stdout, "ciphertext:", ciphertext,
5977 debug_hexdump(stdout, "ciphertext expected:",
5978 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5980 if (ut_params->obuf)
5981 digest = rte_pktmbuf_read(ut_params->obuf,
5982 (tdata->digest.offset_bytes == 0 ?
5983 plaintext_pad_len : tdata->digest.offset_bytes),
5984 tdata->digest.len, digest_buffer);
5986 digest = rte_pktmbuf_read(ut_params->ibuf,
5987 (tdata->digest.offset_bytes == 0 ?
5988 plaintext_pad_len : tdata->digest.offset_bytes),
5989 tdata->digest.len, digest_buffer);
5991 debug_hexdump(stdout, "digest:", digest,
5993 debug_hexdump(stdout, "digest expected:",
5994 tdata->digest.data, tdata->digest.len);
5999 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6001 tdata->plaintext.data,
6002 tdata->plaintext.len >> 3,
6003 "ZUC Plaintext data not as expected");
6005 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6007 tdata->ciphertext.data,
6008 tdata->validDataLenInBits.len,
6009 "ZUC Ciphertext data not as expected");
6011 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6014 DIGEST_BYTE_LENGTH_KASUMI_F9,
6015 "ZUC Generated auth tag not as expected");
6021 test_kasumi_encryption_test_case_1(void)
6023 return test_kasumi_encryption(&kasumi_test_case_1);
6027 test_kasumi_encryption_test_case_1_sgl(void)
6029 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6033 test_kasumi_encryption_test_case_1_oop(void)
6035 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6039 test_kasumi_encryption_test_case_1_oop_sgl(void)
6041 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6045 test_kasumi_encryption_test_case_2(void)
6047 return test_kasumi_encryption(&kasumi_test_case_2);
6051 test_kasumi_encryption_test_case_3(void)
6053 return test_kasumi_encryption(&kasumi_test_case_3);
6057 test_kasumi_encryption_test_case_4(void)
6059 return test_kasumi_encryption(&kasumi_test_case_4);
6063 test_kasumi_encryption_test_case_5(void)
6065 return test_kasumi_encryption(&kasumi_test_case_5);
6069 test_kasumi_decryption_test_case_1(void)
6071 return test_kasumi_decryption(&kasumi_test_case_1);
6075 test_kasumi_decryption_test_case_1_oop(void)
6077 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6081 test_kasumi_decryption_test_case_2(void)
6083 return test_kasumi_decryption(&kasumi_test_case_2);
6087 test_kasumi_decryption_test_case_3(void)
6089 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6090 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6092 return test_kasumi_decryption(&kasumi_test_case_3);
6096 test_kasumi_decryption_test_case_4(void)
6098 return test_kasumi_decryption(&kasumi_test_case_4);
6102 test_kasumi_decryption_test_case_5(void)
6104 return test_kasumi_decryption(&kasumi_test_case_5);
6107 test_snow3g_encryption_test_case_1(void)
6109 return test_snow3g_encryption(&snow3g_test_case_1);
6113 test_snow3g_encryption_test_case_1_oop(void)
6115 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6119 test_snow3g_encryption_test_case_1_oop_sgl(void)
6121 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6126 test_snow3g_encryption_test_case_1_offset_oop(void)
6128 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6132 test_snow3g_encryption_test_case_2(void)
6134 return test_snow3g_encryption(&snow3g_test_case_2);
6138 test_snow3g_encryption_test_case_3(void)
6140 return test_snow3g_encryption(&snow3g_test_case_3);
6144 test_snow3g_encryption_test_case_4(void)
6146 return test_snow3g_encryption(&snow3g_test_case_4);
6150 test_snow3g_encryption_test_case_5(void)
6152 return test_snow3g_encryption(&snow3g_test_case_5);
6156 test_snow3g_decryption_test_case_1(void)
6158 return test_snow3g_decryption(&snow3g_test_case_1);
6162 test_snow3g_decryption_test_case_1_oop(void)
6164 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6168 test_snow3g_decryption_test_case_2(void)
6170 return test_snow3g_decryption(&snow3g_test_case_2);
6174 test_snow3g_decryption_test_case_3(void)
6176 return test_snow3g_decryption(&snow3g_test_case_3);
6180 test_snow3g_decryption_test_case_4(void)
6182 return test_snow3g_decryption(&snow3g_test_case_4);
6186 test_snow3g_decryption_test_case_5(void)
6188 return test_snow3g_decryption(&snow3g_test_case_5);
6192 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6193 * Pattern digest from snow3g_test_data must be allocated as
6194 * 4 last bytes in plaintext.
6197 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6198 struct snow3g_hash_test_data *output)
6200 if ((pattern != NULL) && (output != NULL)) {
6201 output->key.len = pattern->key.len;
6203 memcpy(output->key.data,
6204 pattern->key.data, pattern->key.len);
6206 output->auth_iv.len = pattern->auth_iv.len;
6208 memcpy(output->auth_iv.data,
6209 pattern->auth_iv.data, pattern->auth_iv.len);
6211 output->plaintext.len = pattern->plaintext.len;
6213 memcpy(output->plaintext.data,
6214 pattern->plaintext.data, pattern->plaintext.len >> 3);
6216 output->digest.len = pattern->digest.len;
6218 memcpy(output->digest.data,
6219 &pattern->plaintext.data[pattern->digest.offset_bytes],
6220 pattern->digest.len);
6222 output->validAuthLenInBits.len =
6223 pattern->validAuthLenInBits.len;
6228 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6231 test_snow3g_decryption_with_digest_test_case_1(void)
6233 struct snow3g_hash_test_data snow3g_hash_data;
6236 * Function prepare data for hash veryfication test case.
6237 * Digest is allocated in 4 last bytes in plaintext, pattern.
6239 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6241 return test_snow3g_decryption(&snow3g_test_case_7) &
6242 test_snow3g_authentication_verify(&snow3g_hash_data);
6246 test_snow3g_cipher_auth_test_case_1(void)
6248 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6252 test_snow3g_auth_cipher_test_case_1(void)
6254 return test_snow3g_auth_cipher(
6255 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6259 test_snow3g_auth_cipher_test_case_2(void)
6261 return test_snow3g_auth_cipher(
6262 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6266 test_snow3g_auth_cipher_test_case_2_oop(void)
6268 return test_snow3g_auth_cipher(
6269 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6273 test_snow3g_auth_cipher_part_digest_enc(void)
6275 return test_snow3g_auth_cipher(
6276 &snow3g_auth_cipher_partial_digest_encryption,
6281 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6283 return test_snow3g_auth_cipher(
6284 &snow3g_auth_cipher_partial_digest_encryption,
6289 test_snow3g_auth_cipher_test_case_3_sgl(void)
6291 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6292 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6294 return test_snow3g_auth_cipher_sgl(
6295 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6299 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6301 return test_snow3g_auth_cipher_sgl(
6302 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6306 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6308 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6309 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6311 return test_snow3g_auth_cipher_sgl(
6312 &snow3g_auth_cipher_partial_digest_encryption,
6317 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6319 return test_snow3g_auth_cipher_sgl(
6320 &snow3g_auth_cipher_partial_digest_encryption,
6325 test_snow3g_auth_cipher_verify_test_case_1(void)
6327 return test_snow3g_auth_cipher(
6328 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6332 test_snow3g_auth_cipher_verify_test_case_2(void)
6334 return test_snow3g_auth_cipher(
6335 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6339 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6341 return test_snow3g_auth_cipher(
6342 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6346 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6348 return test_snow3g_auth_cipher(
6349 &snow3g_auth_cipher_partial_digest_encryption,
6354 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6356 return test_snow3g_auth_cipher(
6357 &snow3g_auth_cipher_partial_digest_encryption,
6362 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6364 return test_snow3g_auth_cipher_sgl(
6365 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6369 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6371 return test_snow3g_auth_cipher_sgl(
6372 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6376 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6378 return test_snow3g_auth_cipher_sgl(
6379 &snow3g_auth_cipher_partial_digest_encryption,
6384 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6386 return test_snow3g_auth_cipher_sgl(
6387 &snow3g_auth_cipher_partial_digest_encryption,
6392 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6394 return test_snow3g_auth_cipher(
6395 &snow3g_test_case_7, IN_PLACE, 0);
6399 test_kasumi_auth_cipher_test_case_1(void)
6401 return test_kasumi_auth_cipher(
6402 &kasumi_test_case_3, IN_PLACE, 0);
6406 test_kasumi_auth_cipher_test_case_2(void)
6408 return test_kasumi_auth_cipher(
6409 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6413 test_kasumi_auth_cipher_test_case_2_oop(void)
6415 return test_kasumi_auth_cipher(
6416 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6420 test_kasumi_auth_cipher_test_case_2_sgl(void)
6422 return test_kasumi_auth_cipher_sgl(
6423 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6427 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6429 return test_kasumi_auth_cipher_sgl(
6430 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6434 test_kasumi_auth_cipher_verify_test_case_1(void)
6436 return test_kasumi_auth_cipher(
6437 &kasumi_test_case_3, IN_PLACE, 1);
6441 test_kasumi_auth_cipher_verify_test_case_2(void)
6443 return test_kasumi_auth_cipher(
6444 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6448 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6450 return test_kasumi_auth_cipher(
6451 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6455 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6457 return test_kasumi_auth_cipher_sgl(
6458 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6462 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6464 return test_kasumi_auth_cipher_sgl(
6465 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6469 test_kasumi_cipher_auth_test_case_1(void)
6471 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6475 test_zuc_encryption_test_case_1(void)
6477 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6481 test_zuc_encryption_test_case_2(void)
6483 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6487 test_zuc_encryption_test_case_3(void)
6489 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6493 test_zuc_encryption_test_case_4(void)
6495 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6499 test_zuc_encryption_test_case_5(void)
6501 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6505 test_zuc_encryption_test_case_6_sgl(void)
6507 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6511 test_zuc_hash_generate_test_case_1(void)
6513 return test_zuc_authentication(&zuc_test_case_auth_1b);
6517 test_zuc_hash_generate_test_case_2(void)
6519 return test_zuc_authentication(&zuc_test_case_auth_90b);
6523 test_zuc_hash_generate_test_case_3(void)
6525 return test_zuc_authentication(&zuc_test_case_auth_577b);
6529 test_zuc_hash_generate_test_case_4(void)
6531 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6535 test_zuc_hash_generate_test_case_5(void)
6537 return test_zuc_authentication(&zuc_test_auth_5670b);
6541 test_zuc_hash_generate_test_case_6(void)
6543 return test_zuc_authentication(&zuc_test_case_auth_128b);
6547 test_zuc_hash_generate_test_case_7(void)
6549 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6553 test_zuc_hash_generate_test_case_8(void)
6555 return test_zuc_authentication(&zuc_test_case_auth_584b);
6559 test_zuc_cipher_auth_test_case_1(void)
6561 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6565 test_zuc_cipher_auth_test_case_2(void)
6567 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6571 test_zuc_auth_cipher_test_case_1(void)
6573 return test_zuc_auth_cipher(
6574 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6578 test_zuc_auth_cipher_test_case_1_oop(void)
6580 return test_zuc_auth_cipher(
6581 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6585 test_zuc_auth_cipher_test_case_1_sgl(void)
6587 return test_zuc_auth_cipher_sgl(
6588 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6592 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6594 return test_zuc_auth_cipher_sgl(
6595 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6599 test_zuc_auth_cipher_verify_test_case_1(void)
6601 return test_zuc_auth_cipher(
6602 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6606 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6608 return test_zuc_auth_cipher(
6609 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6613 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6615 return test_zuc_auth_cipher_sgl(
6616 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6620 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6622 return test_zuc_auth_cipher_sgl(
6623 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6627 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6629 uint8_t dev_id = testsuite_params.valid_devs[0];
6631 struct rte_cryptodev_sym_capability_idx cap_idx;
6633 /* Check if device supports particular cipher algorithm */
6634 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6635 cap_idx.algo.cipher = tdata->cipher_algo;
6636 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6639 /* Check if device supports particular hash algorithm */
6640 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6641 cap_idx.algo.auth = tdata->auth_algo;
6642 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6649 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6650 uint8_t op_mode, uint8_t verify)
6652 struct crypto_testsuite_params *ts_params = &testsuite_params;
6653 struct crypto_unittest_params *ut_params = &unittest_params;
6657 uint8_t *plaintext = NULL, *ciphertext = NULL;
6658 unsigned int plaintext_pad_len;
6659 unsigned int plaintext_len;
6660 unsigned int ciphertext_pad_len;
6661 unsigned int ciphertext_len;
6663 struct rte_cryptodev_info dev_info;
6665 /* Check if device supports particular algorithms separately */
6666 if (test_mixed_check_if_unsupported(tdata))
6668 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6671 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6673 uint64_t feat_flags = dev_info.feature_flags;
6675 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6676 printf("Device doesn't support digest encrypted.\n");
6680 if (op_mode == OUT_OF_PLACE)
6683 /* Create the session */
6685 retval = create_wireless_algo_cipher_auth_session(
6686 ts_params->valid_devs[0],
6687 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6688 RTE_CRYPTO_AUTH_OP_VERIFY,
6691 tdata->auth_key.data, tdata->auth_key.len,
6692 tdata->auth_iv.len, tdata->digest_enc.len,
6693 tdata->cipher_iv.len);
6695 retval = create_wireless_algo_auth_cipher_session(
6696 ts_params->valid_devs[0],
6697 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6698 RTE_CRYPTO_AUTH_OP_GENERATE,
6701 tdata->auth_key.data, tdata->auth_key.len,
6702 tdata->auth_iv.len, tdata->digest_enc.len,
6703 tdata->cipher_iv.len);
6707 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6708 if (op_mode == OUT_OF_PLACE)
6709 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6711 /* clear mbuf payload */
6712 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6713 rte_pktmbuf_tailroom(ut_params->ibuf));
6714 if (op_mode == OUT_OF_PLACE) {
6716 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6717 rte_pktmbuf_tailroom(ut_params->obuf));
6720 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6721 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6722 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6723 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6726 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6727 ciphertext_pad_len);
6728 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6729 if (op_mode == OUT_OF_PLACE)
6730 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6731 debug_hexdump(stdout, "ciphertext:", ciphertext,
6734 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6736 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6737 if (op_mode == OUT_OF_PLACE)
6738 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6739 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6742 /* Create the operation */
6743 retval = create_wireless_algo_auth_cipher_operation(
6744 tdata->digest_enc.data, tdata->digest_enc.len,
6745 tdata->cipher_iv.data, tdata->cipher_iv.len,
6746 tdata->auth_iv.data, tdata->auth_iv.len,
6747 (tdata->digest_enc.offset == 0 ?
6749 : tdata->digest_enc.offset),
6750 tdata->validCipherLen.len_bits,
6751 tdata->cipher.offset_bits,
6752 tdata->validAuthLen.len_bits,
6753 tdata->auth.offset_bits,
6754 op_mode, 0, verify);
6759 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6762 /* Check if the op failed because the device doesn't */
6763 /* support this particular combination of algorithms */
6764 if (ut_params->op == NULL && ut_params->op->status ==
6765 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6766 printf("Device doesn't support this mixed combination. "
6771 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6773 ut_params->obuf = (op_mode == IN_PLACE ?
6774 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6777 if (ut_params->obuf)
6778 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6781 plaintext = ciphertext +
6782 (tdata->cipher.offset_bits >> 3);
6784 debug_hexdump(stdout, "plaintext:", plaintext,
6785 tdata->plaintext.len_bits >> 3);
6786 debug_hexdump(stdout, "plaintext expected:",
6787 tdata->plaintext.data,
6788 tdata->plaintext.len_bits >> 3);
6790 if (ut_params->obuf)
6791 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6794 ciphertext = plaintext;
6796 debug_hexdump(stdout, "ciphertext:", ciphertext,
6798 debug_hexdump(stdout, "ciphertext expected:",
6799 tdata->ciphertext.data,
6800 tdata->ciphertext.len_bits >> 3);
6802 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6803 + (tdata->digest_enc.offset == 0 ?
6804 plaintext_pad_len : tdata->digest_enc.offset);
6806 debug_hexdump(stdout, "digest:", ut_params->digest,
6807 tdata->digest_enc.len);
6808 debug_hexdump(stdout, "digest expected:",
6809 tdata->digest_enc.data,
6810 tdata->digest_enc.len);
6815 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6817 tdata->plaintext.data,
6818 tdata->plaintext.len_bits >> 3,
6819 "Plaintext data not as expected");
6821 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6823 tdata->ciphertext.data,
6824 tdata->validDataLen.len_bits,
6825 "Ciphertext data not as expected");
6827 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6829 tdata->digest_enc.data,
6830 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6831 "Generated auth tag not as expected");
6834 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6835 "crypto op processing failed");
6841 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6842 uint8_t op_mode, uint8_t verify)
6844 struct crypto_testsuite_params *ts_params = &testsuite_params;
6845 struct crypto_unittest_params *ut_params = &unittest_params;
6849 const uint8_t *plaintext = NULL;
6850 const uint8_t *ciphertext = NULL;
6851 const uint8_t *digest = NULL;
6852 unsigned int plaintext_pad_len;
6853 unsigned int plaintext_len;
6854 unsigned int ciphertext_pad_len;
6855 unsigned int ciphertext_len;
6856 uint8_t buffer[10000];
6857 uint8_t digest_buffer[10000];
6859 struct rte_cryptodev_info dev_info;
6861 /* Check if device supports particular algorithms */
6862 if (test_mixed_check_if_unsupported(tdata))
6864 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6867 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6869 uint64_t feat_flags = dev_info.feature_flags;
6871 if (op_mode == IN_PLACE) {
6872 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6873 printf("Device doesn't support in-place scatter-gather "
6874 "in both input and output mbufs.\n");
6878 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6879 printf("Device doesn't support out-of-place scatter-gather "
6880 "in both input and output mbufs.\n");
6883 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6884 printf("Device doesn't support digest encrypted.\n");
6889 /* Create the session */
6891 retval = create_wireless_algo_cipher_auth_session(
6892 ts_params->valid_devs[0],
6893 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6894 RTE_CRYPTO_AUTH_OP_VERIFY,
6897 tdata->auth_key.data, tdata->auth_key.len,
6898 tdata->auth_iv.len, tdata->digest_enc.len,
6899 tdata->cipher_iv.len);
6901 retval = create_wireless_algo_auth_cipher_session(
6902 ts_params->valid_devs[0],
6903 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6904 RTE_CRYPTO_AUTH_OP_GENERATE,
6907 tdata->auth_key.data, tdata->auth_key.len,
6908 tdata->auth_iv.len, tdata->digest_enc.len,
6909 tdata->cipher_iv.len);
6913 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6914 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6915 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6916 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6918 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6919 ciphertext_pad_len, 15, 0);
6920 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6921 "Failed to allocate input buffer in mempool");
6923 if (op_mode == OUT_OF_PLACE) {
6924 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6925 plaintext_pad_len, 15, 0);
6926 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6927 "Failed to allocate output buffer in mempool");
6931 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6932 tdata->ciphertext.data);
6933 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6934 ciphertext_len, buffer);
6935 debug_hexdump(stdout, "ciphertext:", ciphertext,
6938 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6939 tdata->plaintext.data);
6940 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6941 plaintext_len, buffer);
6942 debug_hexdump(stdout, "plaintext:", plaintext,
6945 memset(buffer, 0, sizeof(buffer));
6947 /* Create the operation */
6948 retval = create_wireless_algo_auth_cipher_operation(
6949 tdata->digest_enc.data, tdata->digest_enc.len,
6950 tdata->cipher_iv.data, tdata->cipher_iv.len,
6951 tdata->auth_iv.data, tdata->auth_iv.len,
6952 (tdata->digest_enc.offset == 0 ?
6954 : tdata->digest_enc.offset),
6955 tdata->validCipherLen.len_bits,
6956 tdata->cipher.offset_bits,
6957 tdata->validAuthLen.len_bits,
6958 tdata->auth.offset_bits,
6959 op_mode, 1, verify);
6964 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6967 /* Check if the op failed because the device doesn't */
6968 /* support this particular combination of algorithms */
6969 if (ut_params->op == NULL && ut_params->op->status ==
6970 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6971 printf("Device doesn't support this mixed combination. "
6976 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6978 ut_params->obuf = (op_mode == IN_PLACE ?
6979 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6982 if (ut_params->obuf)
6983 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6984 plaintext_len, buffer);
6986 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6987 plaintext_len, buffer);
6989 debug_hexdump(stdout, "plaintext:", plaintext,
6990 (tdata->plaintext.len_bits >> 3) -
6991 tdata->digest_enc.len);
6992 debug_hexdump(stdout, "plaintext expected:",
6993 tdata->plaintext.data,
6994 (tdata->plaintext.len_bits >> 3) -
6995 tdata->digest_enc.len);
6997 if (ut_params->obuf)
6998 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6999 ciphertext_len, buffer);
7001 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7002 ciphertext_len, buffer);
7004 debug_hexdump(stdout, "ciphertext:", ciphertext,
7006 debug_hexdump(stdout, "ciphertext expected:",
7007 tdata->ciphertext.data,
7008 tdata->ciphertext.len_bits >> 3);
7010 if (ut_params->obuf)
7011 digest = rte_pktmbuf_read(ut_params->obuf,
7012 (tdata->digest_enc.offset == 0 ?
7014 tdata->digest_enc.offset),
7015 tdata->digest_enc.len, digest_buffer);
7017 digest = rte_pktmbuf_read(ut_params->ibuf,
7018 (tdata->digest_enc.offset == 0 ?
7020 tdata->digest_enc.offset),
7021 tdata->digest_enc.len, digest_buffer);
7023 debug_hexdump(stdout, "digest:", digest,
7024 tdata->digest_enc.len);
7025 debug_hexdump(stdout, "digest expected:",
7026 tdata->digest_enc.data, tdata->digest_enc.len);
7031 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7033 tdata->plaintext.data,
7034 tdata->plaintext.len_bits >> 3,
7035 "Plaintext data not as expected");
7037 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7039 tdata->ciphertext.data,
7040 tdata->validDataLen.len_bits,
7041 "Ciphertext data not as expected");
7042 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7044 tdata->digest_enc.data,
7045 tdata->digest_enc.len,
7046 "Generated auth tag not as expected");
7049 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7050 "crypto op processing failed");
7055 /** AUTH AES CMAC + CIPHER AES CTR */
7058 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7060 return test_mixed_auth_cipher(
7061 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7065 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7067 return test_mixed_auth_cipher(
7068 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7072 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7074 return test_mixed_auth_cipher_sgl(
7075 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7079 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7081 return test_mixed_auth_cipher_sgl(
7082 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7086 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7088 return test_mixed_auth_cipher(
7089 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7093 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7095 return test_mixed_auth_cipher(
7096 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7100 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7102 return test_mixed_auth_cipher_sgl(
7103 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7107 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7109 return test_mixed_auth_cipher_sgl(
7110 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7113 /** MIXED AUTH + CIPHER */
7116 test_auth_zuc_cipher_snow_test_case_1(void)
7118 return test_mixed_auth_cipher(
7119 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7123 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7125 return test_mixed_auth_cipher(
7126 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7130 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7132 return test_mixed_auth_cipher(
7133 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7137 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7139 return test_mixed_auth_cipher(
7140 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7144 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7146 return test_mixed_auth_cipher(
7147 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7151 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7153 return test_mixed_auth_cipher(
7154 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7158 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7160 return test_mixed_auth_cipher(
7161 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7165 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7167 return test_mixed_auth_cipher(
7168 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7172 test_auth_snow_cipher_zuc_test_case_1(void)
7174 return test_mixed_auth_cipher(
7175 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7179 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7181 return test_mixed_auth_cipher(
7182 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7186 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7188 return test_mixed_auth_cipher(
7189 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7193 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7195 return test_mixed_auth_cipher(
7196 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7200 test_auth_null_cipher_snow_test_case_1(void)
7202 return test_mixed_auth_cipher(
7203 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7207 test_verify_auth_null_cipher_snow_test_case_1(void)
7209 return test_mixed_auth_cipher(
7210 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7214 test_auth_null_cipher_zuc_test_case_1(void)
7216 return test_mixed_auth_cipher(
7217 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7221 test_verify_auth_null_cipher_zuc_test_case_1(void)
7223 return test_mixed_auth_cipher(
7224 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7228 test_auth_snow_cipher_null_test_case_1(void)
7230 return test_mixed_auth_cipher(
7231 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7235 test_verify_auth_snow_cipher_null_test_case_1(void)
7237 return test_mixed_auth_cipher(
7238 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7242 test_auth_zuc_cipher_null_test_case_1(void)
7244 return test_mixed_auth_cipher(
7245 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7249 test_verify_auth_zuc_cipher_null_test_case_1(void)
7251 return test_mixed_auth_cipher(
7252 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7256 test_auth_null_cipher_aes_ctr_test_case_1(void)
7258 return test_mixed_auth_cipher(
7259 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7263 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7265 return test_mixed_auth_cipher(
7266 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7270 test_auth_aes_cmac_cipher_null_test_case_1(void)
7272 return test_mixed_auth_cipher(
7273 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7277 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7279 return test_mixed_auth_cipher(
7280 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7283 /* ***** AEAD algorithm Tests ***** */
7286 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7287 enum rte_crypto_aead_operation op,
7288 const uint8_t *key, const uint8_t key_len,
7289 const uint16_t aad_len, const uint8_t auth_len,
7292 uint8_t aead_key[key_len];
7294 struct crypto_testsuite_params *ts_params = &testsuite_params;
7295 struct crypto_unittest_params *ut_params = &unittest_params;
7297 memcpy(aead_key, key, key_len);
7299 /* Setup AEAD Parameters */
7300 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7301 ut_params->aead_xform.next = NULL;
7302 ut_params->aead_xform.aead.algo = algo;
7303 ut_params->aead_xform.aead.op = op;
7304 ut_params->aead_xform.aead.key.data = aead_key;
7305 ut_params->aead_xform.aead.key.length = key_len;
7306 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7307 ut_params->aead_xform.aead.iv.length = iv_len;
7308 ut_params->aead_xform.aead.digest_length = auth_len;
7309 ut_params->aead_xform.aead.aad_length = aad_len;
7311 debug_hexdump(stdout, "key:", key, key_len);
7313 /* Create Crypto session*/
7314 ut_params->sess = rte_cryptodev_sym_session_create(
7315 ts_params->session_mpool);
7317 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7318 &ut_params->aead_xform,
7319 ts_params->session_priv_mpool);
7321 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7327 create_aead_xform(struct rte_crypto_op *op,
7328 enum rte_crypto_aead_algorithm algo,
7329 enum rte_crypto_aead_operation aead_op,
7330 uint8_t *key, const uint8_t key_len,
7331 const uint8_t aad_len, const uint8_t auth_len,
7334 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7335 "failed to allocate space for crypto transform");
7337 struct rte_crypto_sym_op *sym_op = op->sym;
7339 /* Setup AEAD Parameters */
7340 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7341 sym_op->xform->next = NULL;
7342 sym_op->xform->aead.algo = algo;
7343 sym_op->xform->aead.op = aead_op;
7344 sym_op->xform->aead.key.data = key;
7345 sym_op->xform->aead.key.length = key_len;
7346 sym_op->xform->aead.iv.offset = IV_OFFSET;
7347 sym_op->xform->aead.iv.length = iv_len;
7348 sym_op->xform->aead.digest_length = auth_len;
7349 sym_op->xform->aead.aad_length = aad_len;
7351 debug_hexdump(stdout, "key:", key, key_len);
7357 create_aead_operation(enum rte_crypto_aead_operation op,
7358 const struct aead_test_data *tdata)
7360 struct crypto_testsuite_params *ts_params = &testsuite_params;
7361 struct crypto_unittest_params *ut_params = &unittest_params;
7363 uint8_t *plaintext, *ciphertext;
7364 unsigned int aad_pad_len, plaintext_pad_len;
7366 /* Generate Crypto op data structure */
7367 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7368 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7369 TEST_ASSERT_NOT_NULL(ut_params->op,
7370 "Failed to allocate symmetric crypto operation struct");
7372 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7374 /* Append aad data */
7375 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7376 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7377 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7379 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7380 "no room to append aad");
7382 sym_op->aead.aad.phys_addr =
7383 rte_pktmbuf_iova(ut_params->ibuf);
7384 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7385 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7386 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7389 /* Append IV at the end of the crypto operation*/
7390 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7391 uint8_t *, IV_OFFSET);
7393 /* Copy IV 1 byte after the IV pointer, according to the API */
7394 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7395 debug_hexdump(stdout, "iv:", iv_ptr,
7398 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7399 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7401 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7402 "no room to append aad");
7404 sym_op->aead.aad.phys_addr =
7405 rte_pktmbuf_iova(ut_params->ibuf);
7406 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7407 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7410 /* Append IV at the end of the crypto operation*/
7411 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7412 uint8_t *, IV_OFFSET);
7414 if (tdata->iv.len == 0) {
7415 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7416 debug_hexdump(stdout, "iv:", iv_ptr,
7419 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7420 debug_hexdump(stdout, "iv:", iv_ptr,
7425 /* Append plaintext/ciphertext */
7426 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7427 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7428 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7430 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7432 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7433 debug_hexdump(stdout, "plaintext:", plaintext,
7434 tdata->plaintext.len);
7436 if (ut_params->obuf) {
7437 ciphertext = (uint8_t *)rte_pktmbuf_append(
7439 plaintext_pad_len + aad_pad_len);
7440 TEST_ASSERT_NOT_NULL(ciphertext,
7441 "no room to append ciphertext");
7443 memset(ciphertext + aad_pad_len, 0,
7444 tdata->ciphertext.len);
7447 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7448 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7450 TEST_ASSERT_NOT_NULL(ciphertext,
7451 "no room to append ciphertext");
7453 memcpy(ciphertext, tdata->ciphertext.data,
7454 tdata->ciphertext.len);
7455 debug_hexdump(stdout, "ciphertext:", ciphertext,
7456 tdata->ciphertext.len);
7458 if (ut_params->obuf) {
7459 plaintext = (uint8_t *)rte_pktmbuf_append(
7461 plaintext_pad_len + aad_pad_len);
7462 TEST_ASSERT_NOT_NULL(plaintext,
7463 "no room to append plaintext");
7465 memset(plaintext + aad_pad_len, 0,
7466 tdata->plaintext.len);
7470 /* Append digest data */
7471 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7472 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7473 ut_params->obuf ? ut_params->obuf :
7475 tdata->auth_tag.len);
7476 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7477 "no room to append digest");
7478 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7479 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7480 ut_params->obuf ? ut_params->obuf :
7485 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7486 ut_params->ibuf, tdata->auth_tag.len);
7487 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7488 "no room to append digest");
7489 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7491 plaintext_pad_len + aad_pad_len);
7493 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7494 tdata->auth_tag.len);
7495 debug_hexdump(stdout, "digest:",
7496 sym_op->aead.digest.data,
7497 tdata->auth_tag.len);
7500 sym_op->aead.data.length = tdata->plaintext.len;
7501 sym_op->aead.data.offset = aad_pad_len;
7507 test_authenticated_encryption(const struct aead_test_data *tdata)
7509 struct crypto_testsuite_params *ts_params = &testsuite_params;
7510 struct crypto_unittest_params *ut_params = &unittest_params;
7513 uint8_t *ciphertext, *auth_tag;
7514 uint16_t plaintext_pad_len;
7516 struct rte_cryptodev_info dev_info;
7518 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7519 uint64_t feat_flags = dev_info.feature_flags;
7521 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7522 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7523 printf("Device doesn't support RAW data-path APIs.\n");
7527 /* Verify the capabilities */
7528 struct rte_cryptodev_sym_capability_idx cap_idx;
7529 const struct rte_cryptodev_symmetric_capability *capability;
7530 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7531 cap_idx.algo.aead = tdata->algo;
7532 capability = rte_cryptodev_sym_capability_get(
7533 ts_params->valid_devs[0], &cap_idx);
7534 if (capability == NULL)
7536 if (rte_cryptodev_sym_capability_check_aead(
7537 capability, tdata->key.len, tdata->auth_tag.len,
7538 tdata->aad.len, tdata->iv.len))
7541 /* Create AEAD session */
7542 retval = create_aead_session(ts_params->valid_devs[0],
7544 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7545 tdata->key.data, tdata->key.len,
7546 tdata->aad.len, tdata->auth_tag.len,
7551 if (tdata->aad.len > MBUF_SIZE) {
7552 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7553 /* Populate full size of add data */
7554 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7555 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7557 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7559 /* clear mbuf payload */
7560 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7561 rte_pktmbuf_tailroom(ut_params->ibuf));
7563 /* Create AEAD operation */
7564 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7568 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7570 ut_params->op->sym->m_src = ut_params->ibuf;
7572 /* Process crypto operation */
7573 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
7574 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
7575 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7576 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
7577 ut_params->op, 0, 0, 0, 0);
7579 TEST_ASSERT_NOT_NULL(
7580 process_crypto_request(ts_params->valid_devs[0],
7581 ut_params->op), "failed to process sym crypto op");
7583 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7584 "crypto op processing failed");
7586 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7588 if (ut_params->op->sym->m_dst) {
7589 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7591 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7592 uint8_t *, plaintext_pad_len);
7594 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7596 ut_params->op->sym->cipher.data.offset);
7597 auth_tag = ciphertext + plaintext_pad_len;
7600 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7601 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7604 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7606 tdata->ciphertext.data,
7607 tdata->ciphertext.len,
7608 "Ciphertext data not as expected");
7610 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7612 tdata->auth_tag.data,
7613 tdata->auth_tag.len,
7614 "Generated auth tag not as expected");
7620 #ifdef RTE_LIBRTE_SECURITY
7622 security_proto_supported(enum rte_security_session_action_type action,
7623 enum rte_security_session_protocol proto)
7625 struct crypto_testsuite_params *ts_params = &testsuite_params;
7627 const struct rte_security_capability *capabilities;
7628 const struct rte_security_capability *capability;
7631 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7632 rte_cryptodev_get_sec_ctx(
7633 ts_params->valid_devs[0]);
7636 capabilities = rte_security_capabilities_get(ctx);
7638 if (capabilities == NULL)
7641 while ((capability = &capabilities[i++])->action !=
7642 RTE_SECURITY_ACTION_TYPE_NONE) {
7643 if (capability->action == action &&
7644 capability->protocol == proto)
7651 /* Basic algorithm run function for async inplace mode.
7652 * Creates a session from input parameters and runs one operation
7653 * on input_vec. Checks the output of the crypto operation against
7657 test_pdcp_proto(int i, int oop,
7658 enum rte_crypto_cipher_operation opc,
7659 enum rte_crypto_auth_operation opa,
7661 unsigned int input_vec_len,
7662 uint8_t *output_vec,
7663 unsigned int output_vec_len)
7665 struct crypto_testsuite_params *ts_params = &testsuite_params;
7666 struct crypto_unittest_params *ut_params = &unittest_params;
7668 int ret = TEST_SUCCESS;
7669 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7670 rte_cryptodev_get_sec_ctx(
7671 ts_params->valid_devs[0]);
7673 /* Verify the capabilities */
7674 struct rte_security_capability_idx sec_cap_idx;
7676 sec_cap_idx.action = ut_params->type;
7677 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7678 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7679 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7682 /* Generate test mbuf data */
7683 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7685 /* clear mbuf payload */
7686 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7687 rte_pktmbuf_tailroom(ut_params->ibuf));
7689 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7691 memcpy(plaintext, input_vec, input_vec_len);
7693 /* Out of place support */
7696 * For out-op-place we need to alloc another mbuf
7698 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7699 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7702 /* Setup Cipher Parameters */
7703 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7704 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7705 ut_params->cipher_xform.cipher.op = opc;
7706 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7707 ut_params->cipher_xform.cipher.key.length =
7708 pdcp_test_params[i].cipher_key_len;
7709 ut_params->cipher_xform.cipher.iv.length =
7710 pdcp_test_packet_direction[i] ? 4 : 0;
7711 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7713 /* Setup HMAC Parameters if ICV header is required */
7714 if (pdcp_test_params[i].auth_alg != 0) {
7715 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7716 ut_params->auth_xform.next = NULL;
7717 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7718 ut_params->auth_xform.auth.op = opa;
7719 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7720 ut_params->auth_xform.auth.key.length =
7721 pdcp_test_params[i].auth_key_len;
7723 ut_params->cipher_xform.next = &ut_params->auth_xform;
7725 ut_params->cipher_xform.next = NULL;
7728 struct rte_security_session_conf sess_conf = {
7729 .action_type = ut_params->type,
7730 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7732 .bearer = pdcp_test_bearer[i],
7733 .domain = pdcp_test_params[i].domain,
7734 .pkt_dir = pdcp_test_packet_direction[i],
7735 .sn_size = pdcp_test_data_sn_size[i],
7736 .hfn = pdcp_test_packet_direction[i] ?
7737 0 : pdcp_test_hfn[i],
7739 * hfn can be set as pdcp_test_hfn[i]
7740 * if hfn_ovrd is not set. Here, PDCP
7741 * packet direction is just used to
7742 * run half of the cases with session
7743 * HFN and other half with per packet
7746 .hfn_threshold = pdcp_test_hfn_threshold[i],
7747 .hfn_ovrd = pdcp_test_packet_direction[i] ? 1 : 0,
7749 .crypto_xform = &ut_params->cipher_xform
7752 /* Create security session */
7753 ut_params->sec_session = rte_security_session_create(ctx,
7754 &sess_conf, ts_params->session_priv_mpool);
7756 if (!ut_params->sec_session) {
7757 printf("TestCase %s()-%d line %d failed %s: ",
7758 __func__, i, __LINE__, "Failed to allocate session");
7763 /* Generate crypto op data structure */
7764 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7765 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7766 if (!ut_params->op) {
7767 printf("TestCase %s()-%d line %d failed %s: ",
7768 __func__, i, __LINE__,
7769 "Failed to allocate symmetric crypto operation struct");
7774 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
7775 uint32_t *, IV_OFFSET);
7776 *per_pkt_hfn = pdcp_test_packet_direction[i] ? pdcp_test_hfn[i] : 0;
7778 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7780 /* set crypto operation source mbuf */
7781 ut_params->op->sym->m_src = ut_params->ibuf;
7783 ut_params->op->sym->m_dst = ut_params->obuf;
7785 /* Process crypto operation */
7786 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7788 printf("TestCase %s()-%d line %d failed %s: ",
7789 __func__, i, __LINE__,
7790 "failed to process sym crypto op");
7795 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7796 printf("TestCase %s()-%d line %d failed %s: ",
7797 __func__, i, __LINE__, "crypto op processing failed");
7803 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7806 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7810 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7811 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7812 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7813 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7819 rte_crypto_op_free(ut_params->op);
7820 ut_params->op = NULL;
7822 if (ut_params->sec_session)
7823 rte_security_session_destroy(ctx, ut_params->sec_session);
7824 ut_params->sec_session = NULL;
7826 rte_pktmbuf_free(ut_params->ibuf);
7827 ut_params->ibuf = NULL;
7829 rte_pktmbuf_free(ut_params->obuf);
7830 ut_params->obuf = NULL;
7837 test_pdcp_proto_SGL(int i, int oop,
7838 enum rte_crypto_cipher_operation opc,
7839 enum rte_crypto_auth_operation opa,
7841 unsigned int input_vec_len,
7842 uint8_t *output_vec,
7843 unsigned int output_vec_len,
7845 uint32_t fragsz_oop)
7847 struct crypto_testsuite_params *ts_params = &testsuite_params;
7848 struct crypto_unittest_params *ut_params = &unittest_params;
7850 struct rte_mbuf *buf, *buf_oop = NULL;
7851 int ret = TEST_SUCCESS;
7855 unsigned int trn_data = 0;
7856 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7857 rte_cryptodev_get_sec_ctx(
7858 ts_params->valid_devs[0]);
7860 /* Verify the capabilities */
7861 struct rte_security_capability_idx sec_cap_idx;
7863 sec_cap_idx.action = ut_params->type;
7864 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
7865 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
7866 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
7869 if (fragsz > input_vec_len)
7870 fragsz = input_vec_len;
7872 uint16_t plaintext_len = fragsz;
7873 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7875 if (fragsz_oop > output_vec_len)
7876 frag_size_oop = output_vec_len;
7879 if (input_vec_len % fragsz != 0) {
7880 if (input_vec_len / fragsz + 1 > 16)
7882 } else if (input_vec_len / fragsz > 16)
7885 /* Out of place support */
7888 * For out-op-place we need to alloc another mbuf
7890 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7891 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7892 buf_oop = ut_params->obuf;
7895 /* Generate test mbuf data */
7896 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7898 /* clear mbuf payload */
7899 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7900 rte_pktmbuf_tailroom(ut_params->ibuf));
7902 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7904 memcpy(plaintext, input_vec, plaintext_len);
7905 trn_data += plaintext_len;
7907 buf = ut_params->ibuf;
7910 * Loop until no more fragments
7913 while (trn_data < input_vec_len) {
7915 to_trn = (input_vec_len - trn_data < fragsz) ?
7916 (input_vec_len - trn_data) : fragsz;
7918 to_trn_tbl[ecx++] = to_trn;
7920 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7923 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7924 rte_pktmbuf_tailroom(buf));
7927 if (oop && !fragsz_oop) {
7929 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7930 buf_oop = buf_oop->next;
7931 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7932 0, rte_pktmbuf_tailroom(buf_oop));
7933 rte_pktmbuf_append(buf_oop, to_trn);
7936 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7939 memcpy(plaintext, input_vec + trn_data, to_trn);
7943 ut_params->ibuf->nb_segs = segs;
7946 if (fragsz_oop && oop) {
7950 trn_data = frag_size_oop;
7951 while (trn_data < output_vec_len) {
7954 (output_vec_len - trn_data <
7956 (output_vec_len - trn_data) :
7959 to_trn_tbl[ecx++] = to_trn;
7962 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7963 buf_oop = buf_oop->next;
7964 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7965 0, rte_pktmbuf_tailroom(buf_oop));
7966 rte_pktmbuf_append(buf_oop, to_trn);
7970 ut_params->obuf->nb_segs = segs;
7973 /* Setup Cipher Parameters */
7974 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7975 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7976 ut_params->cipher_xform.cipher.op = opc;
7977 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7978 ut_params->cipher_xform.cipher.key.length =
7979 pdcp_test_params[i].cipher_key_len;
7980 ut_params->cipher_xform.cipher.iv.length = 0;
7982 /* Setup HMAC Parameters if ICV header is required */
7983 if (pdcp_test_params[i].auth_alg != 0) {
7984 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7985 ut_params->auth_xform.next = NULL;
7986 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7987 ut_params->auth_xform.auth.op = opa;
7988 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7989 ut_params->auth_xform.auth.key.length =
7990 pdcp_test_params[i].auth_key_len;
7992 ut_params->cipher_xform.next = &ut_params->auth_xform;
7994 ut_params->cipher_xform.next = NULL;
7997 struct rte_security_session_conf sess_conf = {
7998 .action_type = ut_params->type,
7999 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8001 .bearer = pdcp_test_bearer[i],
8002 .domain = pdcp_test_params[i].domain,
8003 .pkt_dir = pdcp_test_packet_direction[i],
8004 .sn_size = pdcp_test_data_sn_size[i],
8005 .hfn = pdcp_test_hfn[i],
8006 .hfn_threshold = pdcp_test_hfn_threshold[i],
8009 .crypto_xform = &ut_params->cipher_xform
8012 /* Create security session */
8013 ut_params->sec_session = rte_security_session_create(ctx,
8014 &sess_conf, ts_params->session_priv_mpool);
8016 if (!ut_params->sec_session) {
8017 printf("TestCase %s()-%d line %d failed %s: ",
8018 __func__, i, __LINE__, "Failed to allocate session");
8023 /* Generate crypto op data structure */
8024 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8025 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8026 if (!ut_params->op) {
8027 printf("TestCase %s()-%d line %d failed %s: ",
8028 __func__, i, __LINE__,
8029 "Failed to allocate symmetric crypto operation struct");
8034 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8036 /* set crypto operation source mbuf */
8037 ut_params->op->sym->m_src = ut_params->ibuf;
8039 ut_params->op->sym->m_dst = ut_params->obuf;
8041 /* Process crypto operation */
8042 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8044 printf("TestCase %s()-%d line %d failed %s: ",
8045 __func__, i, __LINE__,
8046 "failed to process sym crypto op");
8051 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8052 printf("TestCase %s()-%d line %d failed %s: ",
8053 __func__, i, __LINE__, "crypto op processing failed");
8059 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8062 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8066 fragsz = frag_size_oop;
8067 if (memcmp(ciphertext, output_vec, fragsz)) {
8068 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8069 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8070 rte_hexdump(stdout, "reference", output_vec, fragsz);
8075 buf = ut_params->op->sym->m_src->next;
8077 buf = ut_params->op->sym->m_dst->next;
8079 unsigned int off = fragsz;
8083 ciphertext = rte_pktmbuf_mtod(buf,
8085 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8086 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8087 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8088 rte_hexdump(stdout, "reference", output_vec + off,
8093 off += to_trn_tbl[ecx++];
8097 rte_crypto_op_free(ut_params->op);
8098 ut_params->op = NULL;
8100 if (ut_params->sec_session)
8101 rte_security_session_destroy(ctx, ut_params->sec_session);
8102 ut_params->sec_session = NULL;
8104 rte_pktmbuf_free(ut_params->ibuf);
8105 ut_params->ibuf = NULL;
8107 rte_pktmbuf_free(ut_params->obuf);
8108 ut_params->obuf = NULL;
8115 test_pdcp_proto_cplane_encap(int i)
8117 return test_pdcp_proto(i, 0,
8118 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8119 RTE_CRYPTO_AUTH_OP_GENERATE,
8120 pdcp_test_data_in[i],
8121 pdcp_test_data_in_len[i],
8122 pdcp_test_data_out[i],
8123 pdcp_test_data_in_len[i]+4);
8127 test_pdcp_proto_uplane_encap(int i)
8129 return test_pdcp_proto(i, 0,
8130 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8131 RTE_CRYPTO_AUTH_OP_GENERATE,
8132 pdcp_test_data_in[i],
8133 pdcp_test_data_in_len[i],
8134 pdcp_test_data_out[i],
8135 pdcp_test_data_in_len[i]);
8140 test_pdcp_proto_uplane_encap_with_int(int i)
8142 return test_pdcp_proto(i, 0,
8143 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8144 RTE_CRYPTO_AUTH_OP_GENERATE,
8145 pdcp_test_data_in[i],
8146 pdcp_test_data_in_len[i],
8147 pdcp_test_data_out[i],
8148 pdcp_test_data_in_len[i] + 4);
8152 test_pdcp_proto_cplane_decap(int i)
8154 return test_pdcp_proto(i, 0,
8155 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8156 RTE_CRYPTO_AUTH_OP_VERIFY,
8157 pdcp_test_data_out[i],
8158 pdcp_test_data_in_len[i] + 4,
8159 pdcp_test_data_in[i],
8160 pdcp_test_data_in_len[i]);
8164 test_pdcp_proto_uplane_decap(int i)
8166 return test_pdcp_proto(i, 0,
8167 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8168 RTE_CRYPTO_AUTH_OP_VERIFY,
8169 pdcp_test_data_out[i],
8170 pdcp_test_data_in_len[i],
8171 pdcp_test_data_in[i],
8172 pdcp_test_data_in_len[i]);
8176 test_pdcp_proto_uplane_decap_with_int(int i)
8178 return test_pdcp_proto(i, 0,
8179 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8180 RTE_CRYPTO_AUTH_OP_VERIFY,
8181 pdcp_test_data_out[i],
8182 pdcp_test_data_in_len[i] + 4,
8183 pdcp_test_data_in[i],
8184 pdcp_test_data_in_len[i]);
8188 test_PDCP_PROTO_SGL_in_place_32B(void)
8190 /* i can be used for running any PDCP case
8191 * In this case it is uplane 12-bit AES-SNOW DL encap
8193 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8194 return test_pdcp_proto_SGL(i, IN_PLACE,
8195 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8196 RTE_CRYPTO_AUTH_OP_GENERATE,
8197 pdcp_test_data_in[i],
8198 pdcp_test_data_in_len[i],
8199 pdcp_test_data_out[i],
8200 pdcp_test_data_in_len[i]+4,
8204 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8206 /* i can be used for running any PDCP case
8207 * In this case it is uplane 18-bit NULL-NULL DL encap
8209 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8210 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8211 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8212 RTE_CRYPTO_AUTH_OP_GENERATE,
8213 pdcp_test_data_in[i],
8214 pdcp_test_data_in_len[i],
8215 pdcp_test_data_out[i],
8216 pdcp_test_data_in_len[i]+4,
8220 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8222 /* i can be used for running any PDCP case
8223 * In this case it is uplane 18-bit AES DL encap
8225 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8227 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8228 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8229 RTE_CRYPTO_AUTH_OP_GENERATE,
8230 pdcp_test_data_in[i],
8231 pdcp_test_data_in_len[i],
8232 pdcp_test_data_out[i],
8233 pdcp_test_data_in_len[i],
8237 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8239 /* i can be used for running any PDCP case
8240 * In this case it is cplane 12-bit AES-ZUC DL encap
8242 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8243 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8244 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8245 RTE_CRYPTO_AUTH_OP_GENERATE,
8246 pdcp_test_data_in[i],
8247 pdcp_test_data_in_len[i],
8248 pdcp_test_data_out[i],
8249 pdcp_test_data_in_len[i]+4,
8254 test_PDCP_PROTO_all(void)
8256 struct crypto_testsuite_params *ts_params = &testsuite_params;
8257 struct crypto_unittest_params *ut_params = &unittest_params;
8258 struct rte_cryptodev_info dev_info;
8261 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8262 uint64_t feat_flags = dev_info.feature_flags;
8264 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8267 /* Set action type */
8268 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8269 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8272 if (security_proto_supported(ut_params->type,
8273 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8276 status = test_PDCP_PROTO_cplane_encap_all();
8277 status += test_PDCP_PROTO_cplane_decap_all();
8278 status += test_PDCP_PROTO_uplane_encap_all();
8279 status += test_PDCP_PROTO_uplane_decap_all();
8280 status += test_PDCP_PROTO_SGL_in_place_32B();
8281 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8282 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8283 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8288 return TEST_SUCCESS;
8292 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8294 struct crypto_testsuite_params *ts_params = &testsuite_params;
8295 struct crypto_unittest_params *ut_params = &unittest_params;
8296 uint8_t *plaintext, *ciphertext;
8298 int32_t cipher_len, crc_len;
8299 uint32_t crc_data_len;
8300 int ret = TEST_SUCCESS;
8302 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8303 rte_cryptodev_get_sec_ctx(
8304 ts_params->valid_devs[0]);
8306 /* Verify the capabilities */
8307 struct rte_security_capability_idx sec_cap_idx;
8308 const struct rte_security_capability *sec_cap;
8309 const struct rte_cryptodev_capabilities *crypto_cap;
8310 const struct rte_cryptodev_symmetric_capability *sym_cap;
8313 sec_cap_idx.action = ut_params->type;
8314 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8315 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8317 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8318 if (sec_cap == NULL)
8321 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8322 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8323 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8324 crypto_cap->sym.xform_type ==
8325 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8326 crypto_cap->sym.cipher.algo ==
8327 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8328 sym_cap = &crypto_cap->sym;
8329 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8336 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8339 /* Setup source mbuf payload */
8340 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8341 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8342 rte_pktmbuf_tailroom(ut_params->ibuf));
8344 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8345 d_td->ciphertext.len);
8347 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8349 /* Setup cipher session parameters */
8350 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8351 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8352 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8353 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8354 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8355 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8356 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8357 ut_params->cipher_xform.next = NULL;
8359 /* Setup DOCSIS session parameters */
8360 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8362 struct rte_security_session_conf sess_conf = {
8363 .action_type = ut_params->type,
8364 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8365 .docsis = ut_params->docsis_xform,
8366 .crypto_xform = &ut_params->cipher_xform,
8369 /* Create security session */
8370 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8371 ts_params->session_priv_mpool);
8373 if (!ut_params->sec_session) {
8374 printf("TestCase %s(%d) line %d: %s\n",
8375 __func__, i, __LINE__, "failed to allocate session");
8380 /* Generate crypto op data structure */
8381 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8382 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8383 if (!ut_params->op) {
8384 printf("TestCase %s(%d) line %d: %s\n",
8385 __func__, i, __LINE__,
8386 "failed to allocate symmetric crypto operation");
8391 /* Setup CRC operation parameters */
8392 crc_len = d_td->ciphertext.no_crc == false ?
8393 (d_td->ciphertext.len -
8394 d_td->ciphertext.crc_offset -
8395 RTE_ETHER_CRC_LEN) :
8397 crc_len = crc_len > 0 ? crc_len : 0;
8398 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8399 ut_params->op->sym->auth.data.length = crc_len;
8400 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8402 /* Setup cipher operation parameters */
8403 cipher_len = d_td->ciphertext.no_cipher == false ?
8404 (d_td->ciphertext.len -
8405 d_td->ciphertext.cipher_offset) :
8407 cipher_len = cipher_len > 0 ? cipher_len : 0;
8408 ut_params->op->sym->cipher.data.length = cipher_len;
8409 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8411 /* Setup cipher IV */
8412 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8413 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8415 /* Attach session to operation */
8416 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8418 /* Set crypto operation mbufs */
8419 ut_params->op->sym->m_src = ut_params->ibuf;
8420 ut_params->op->sym->m_dst = NULL;
8422 /* Process crypto operation */
8423 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8425 printf("TestCase %s(%d) line %d: %s\n",
8426 __func__, i, __LINE__,
8427 "failed to process security crypto op");
8432 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8433 printf("TestCase %s(%d) line %d: %s\n",
8434 __func__, i, __LINE__, "crypto op processing failed");
8439 /* Validate plaintext */
8440 plaintext = ciphertext;
8442 if (memcmp(plaintext, d_td->plaintext.data,
8443 d_td->plaintext.len - crc_data_len)) {
8444 printf("TestCase %s(%d) line %d: %s\n",
8445 __func__, i, __LINE__, "plaintext not as expected\n");
8446 rte_hexdump(stdout, "expected", d_td->plaintext.data,
8447 d_td->plaintext.len);
8448 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
8454 rte_crypto_op_free(ut_params->op);
8455 ut_params->op = NULL;
8457 if (ut_params->sec_session)
8458 rte_security_session_destroy(ctx, ut_params->sec_session);
8459 ut_params->sec_session = NULL;
8461 rte_pktmbuf_free(ut_params->ibuf);
8462 ut_params->ibuf = NULL;
8468 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
8470 struct crypto_testsuite_params *ts_params = &testsuite_params;
8471 struct crypto_unittest_params *ut_params = &unittest_params;
8472 uint8_t *plaintext, *ciphertext;
8474 int32_t cipher_len, crc_len;
8475 int ret = TEST_SUCCESS;
8477 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8478 rte_cryptodev_get_sec_ctx(
8479 ts_params->valid_devs[0]);
8481 /* Verify the capabilities */
8482 struct rte_security_capability_idx sec_cap_idx;
8483 const struct rte_security_capability *sec_cap;
8484 const struct rte_cryptodev_capabilities *crypto_cap;
8485 const struct rte_cryptodev_symmetric_capability *sym_cap;
8488 sec_cap_idx.action = ut_params->type;
8489 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8490 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8492 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8493 if (sec_cap == NULL)
8496 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8497 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8498 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8499 crypto_cap->sym.xform_type ==
8500 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8501 crypto_cap->sym.cipher.algo ==
8502 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8503 sym_cap = &crypto_cap->sym;
8504 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8511 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8514 /* Setup source mbuf payload */
8515 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8516 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8517 rte_pktmbuf_tailroom(ut_params->ibuf));
8519 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8520 d_td->plaintext.len);
8522 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
8524 /* Setup cipher session parameters */
8525 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8526 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8527 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8528 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8529 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8530 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8531 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8532 ut_params->cipher_xform.next = NULL;
8534 /* Setup DOCSIS session parameters */
8535 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
8537 struct rte_security_session_conf sess_conf = {
8538 .action_type = ut_params->type,
8539 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8540 .docsis = ut_params->docsis_xform,
8541 .crypto_xform = &ut_params->cipher_xform,
8544 /* Create security session */
8545 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8546 ts_params->session_priv_mpool);
8548 if (!ut_params->sec_session) {
8549 printf("TestCase %s(%d) line %d: %s\n",
8550 __func__, i, __LINE__, "failed to allocate session");
8555 /* Generate crypto op data structure */
8556 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8557 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8558 if (!ut_params->op) {
8559 printf("TestCase %s(%d) line %d: %s\n",
8560 __func__, i, __LINE__,
8561 "failed to allocate security crypto operation");
8566 /* Setup CRC operation parameters */
8567 crc_len = d_td->plaintext.no_crc == false ?
8568 (d_td->plaintext.len -
8569 d_td->plaintext.crc_offset -
8570 RTE_ETHER_CRC_LEN) :
8572 crc_len = crc_len > 0 ? crc_len : 0;
8573 ut_params->op->sym->auth.data.length = crc_len;
8574 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
8576 /* Setup cipher operation parameters */
8577 cipher_len = d_td->plaintext.no_cipher == false ?
8578 (d_td->plaintext.len -
8579 d_td->plaintext.cipher_offset) :
8581 cipher_len = cipher_len > 0 ? cipher_len : 0;
8582 ut_params->op->sym->cipher.data.length = cipher_len;
8583 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
8585 /* Setup cipher IV */
8586 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8587 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8589 /* Attach session to operation */
8590 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8592 /* Set crypto operation mbufs */
8593 ut_params->op->sym->m_src = ut_params->ibuf;
8594 ut_params->op->sym->m_dst = NULL;
8596 /* Process crypto operation */
8597 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8599 printf("TestCase %s(%d) line %d: %s\n",
8600 __func__, i, __LINE__,
8601 "failed to process security crypto op");
8606 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8607 printf("TestCase %s(%d) line %d: %s\n",
8608 __func__, i, __LINE__, "crypto op processing failed");
8613 /* Validate ciphertext */
8614 ciphertext = plaintext;
8616 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
8617 printf("TestCase %s(%d) line %d: %s\n",
8618 __func__, i, __LINE__, "ciphertext not as expected\n");
8619 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
8620 d_td->ciphertext.len);
8621 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
8627 rte_crypto_op_free(ut_params->op);
8628 ut_params->op = NULL;
8630 if (ut_params->sec_session)
8631 rte_security_session_destroy(ctx, ut_params->sec_session);
8632 ut_params->sec_session = NULL;
8634 rte_pktmbuf_free(ut_params->ibuf);
8635 ut_params->ibuf = NULL;
8640 #define TEST_DOCSIS_COUNT(func) do { \
8642 if (ret == TEST_SUCCESS) { \
8643 printf("\t%2d)", n++); \
8644 printf("+++++ PASSED:" #func"\n"); \
8646 } else if (ret == -ENOTSUP) { \
8647 printf("\t%2d)", n++); \
8648 printf("~~~~~ UNSUPP:" #func"\n"); \
8651 printf("\t%2d)", n++); \
8652 printf("----- FAILED:" #func"\n"); \
8658 test_DOCSIS_PROTO_uplink_all(void)
8660 int p = 0, u = 0, f = 0, n = 0;
8662 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
8663 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
8664 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
8665 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
8666 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
8667 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
8668 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
8669 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
8670 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
8671 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
8672 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
8673 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
8674 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
8675 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
8676 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
8677 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
8678 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
8679 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
8680 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
8681 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
8682 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
8683 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
8684 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
8685 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
8686 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
8687 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
8690 printf("## %s: %d passed out of %d (%d unsupported)\n",
8697 test_DOCSIS_PROTO_downlink_all(void)
8699 int p = 0, u = 0, f = 0, n = 0;
8701 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
8702 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
8703 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
8704 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
8705 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
8706 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
8707 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
8708 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
8709 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
8710 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
8711 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
8712 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
8713 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
8714 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
8715 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
8716 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
8717 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
8718 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
8719 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
8720 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
8721 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
8722 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
8723 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
8724 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
8725 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
8726 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
8729 printf("## %s: %d passed out of %d (%d unsupported)\n",
8736 test_DOCSIS_PROTO_all(void)
8738 struct crypto_testsuite_params *ts_params = &testsuite_params;
8739 struct crypto_unittest_params *ut_params = &unittest_params;
8740 struct rte_cryptodev_info dev_info;
8743 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8744 uint64_t feat_flags = dev_info.feature_flags;
8746 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8749 /* Set action type */
8750 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8751 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8754 if (security_proto_supported(ut_params->type,
8755 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
8758 status = test_DOCSIS_PROTO_uplink_all();
8759 status += test_DOCSIS_PROTO_downlink_all();
8764 return TEST_SUCCESS;
8769 test_AES_GCM_authenticated_encryption_test_case_1(void)
8771 return test_authenticated_encryption(&gcm_test_case_1);
8775 test_AES_GCM_authenticated_encryption_test_case_2(void)
8777 return test_authenticated_encryption(&gcm_test_case_2);
8781 test_AES_GCM_authenticated_encryption_test_case_3(void)
8783 return test_authenticated_encryption(&gcm_test_case_3);
8787 test_AES_GCM_authenticated_encryption_test_case_4(void)
8789 return test_authenticated_encryption(&gcm_test_case_4);
8793 test_AES_GCM_authenticated_encryption_test_case_5(void)
8795 return test_authenticated_encryption(&gcm_test_case_5);
8799 test_AES_GCM_authenticated_encryption_test_case_6(void)
8801 return test_authenticated_encryption(&gcm_test_case_6);
8805 test_AES_GCM_authenticated_encryption_test_case_7(void)
8807 return test_authenticated_encryption(&gcm_test_case_7);
8811 test_AES_GCM_authenticated_encryption_test_case_8(void)
8813 return test_authenticated_encryption(&gcm_test_case_8);
8817 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
8819 return test_authenticated_encryption(&gcm_J0_test_case_1);
8823 test_AES_GCM_auth_encryption_test_case_192_1(void)
8825 return test_authenticated_encryption(&gcm_test_case_192_1);
8829 test_AES_GCM_auth_encryption_test_case_192_2(void)
8831 return test_authenticated_encryption(&gcm_test_case_192_2);
8835 test_AES_GCM_auth_encryption_test_case_192_3(void)
8837 return test_authenticated_encryption(&gcm_test_case_192_3);
8841 test_AES_GCM_auth_encryption_test_case_192_4(void)
8843 return test_authenticated_encryption(&gcm_test_case_192_4);
8847 test_AES_GCM_auth_encryption_test_case_192_5(void)
8849 return test_authenticated_encryption(&gcm_test_case_192_5);
8853 test_AES_GCM_auth_encryption_test_case_192_6(void)
8855 return test_authenticated_encryption(&gcm_test_case_192_6);
8859 test_AES_GCM_auth_encryption_test_case_192_7(void)
8861 return test_authenticated_encryption(&gcm_test_case_192_7);
8865 test_AES_GCM_auth_encryption_test_case_256_1(void)
8867 return test_authenticated_encryption(&gcm_test_case_256_1);
8871 test_AES_GCM_auth_encryption_test_case_256_2(void)
8873 return test_authenticated_encryption(&gcm_test_case_256_2);
8877 test_AES_GCM_auth_encryption_test_case_256_3(void)
8879 return test_authenticated_encryption(&gcm_test_case_256_3);
8883 test_AES_GCM_auth_encryption_test_case_256_4(void)
8885 return test_authenticated_encryption(&gcm_test_case_256_4);
8889 test_AES_GCM_auth_encryption_test_case_256_5(void)
8891 return test_authenticated_encryption(&gcm_test_case_256_5);
8895 test_AES_GCM_auth_encryption_test_case_256_6(void)
8897 return test_authenticated_encryption(&gcm_test_case_256_6);
8901 test_AES_GCM_auth_encryption_test_case_256_7(void)
8903 return test_authenticated_encryption(&gcm_test_case_256_7);
8907 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8909 return test_authenticated_encryption(&gcm_test_case_aad_1);
8913 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8915 return test_authenticated_encryption(&gcm_test_case_aad_2);
8919 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8921 struct aead_test_data tdata;
8924 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8925 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8926 tdata.iv.data[0] += 1;
8927 res = test_authenticated_encryption(&tdata);
8928 if (res == -ENOTSUP)
8930 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8931 return TEST_SUCCESS;
8935 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8937 struct aead_test_data tdata;
8940 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8941 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8942 tdata.plaintext.data[0] += 1;
8943 res = test_authenticated_encryption(&tdata);
8944 if (res == -ENOTSUP)
8946 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8947 return TEST_SUCCESS;
8951 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8953 struct aead_test_data tdata;
8956 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8957 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8958 tdata.ciphertext.data[0] += 1;
8959 res = test_authenticated_encryption(&tdata);
8960 if (res == -ENOTSUP)
8962 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8963 return TEST_SUCCESS;
8967 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8969 struct aead_test_data tdata;
8972 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8973 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8975 res = test_authenticated_encryption(&tdata);
8976 if (res == -ENOTSUP)
8978 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8979 return TEST_SUCCESS;
8983 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8985 struct aead_test_data tdata;
8986 uint8_t aad[gcm_test_case_7.aad.len];
8989 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8990 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8991 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8993 tdata.aad.data = aad;
8994 res = test_authenticated_encryption(&tdata);
8995 if (res == -ENOTSUP)
8997 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8998 return TEST_SUCCESS;
9002 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9004 struct aead_test_data tdata;
9007 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9008 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9009 tdata.auth_tag.data[0] += 1;
9010 res = test_authenticated_encryption(&tdata);
9011 if (res == -ENOTSUP)
9013 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9014 return TEST_SUCCESS;
9018 test_authenticated_decryption(const struct aead_test_data *tdata)
9020 struct crypto_testsuite_params *ts_params = &testsuite_params;
9021 struct crypto_unittest_params *ut_params = &unittest_params;
9026 struct rte_cryptodev_info dev_info;
9028 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9029 uint64_t feat_flags = dev_info.feature_flags;
9031 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9032 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9033 printf("Device doesn't support RAW data-path APIs.\n");
9037 /* Verify the capabilities */
9038 struct rte_cryptodev_sym_capability_idx cap_idx;
9039 const struct rte_cryptodev_symmetric_capability *capability;
9040 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9041 cap_idx.algo.aead = tdata->algo;
9042 capability = rte_cryptodev_sym_capability_get(
9043 ts_params->valid_devs[0], &cap_idx);
9044 if (capability == NULL)
9046 if (rte_cryptodev_sym_capability_check_aead(
9047 capability, tdata->key.len, tdata->auth_tag.len,
9048 tdata->aad.len, tdata->iv.len))
9051 /* Create AEAD session */
9052 retval = create_aead_session(ts_params->valid_devs[0],
9054 RTE_CRYPTO_AEAD_OP_DECRYPT,
9055 tdata->key.data, tdata->key.len,
9056 tdata->aad.len, tdata->auth_tag.len,
9061 /* alloc mbuf and set payload */
9062 if (tdata->aad.len > MBUF_SIZE) {
9063 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9064 /* Populate full size of add data */
9065 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9066 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9068 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9070 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9071 rte_pktmbuf_tailroom(ut_params->ibuf));
9073 /* Create AEAD operation */
9074 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9078 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9080 ut_params->op->sym->m_src = ut_params->ibuf;
9082 /* Process crypto operation */
9083 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9084 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9085 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9086 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9087 ut_params->op, 0, 0, 0, 0);
9089 TEST_ASSERT_NOT_NULL(
9090 process_crypto_request(ts_params->valid_devs[0],
9091 ut_params->op), "failed to process sym crypto op");
9093 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9094 "crypto op processing failed");
9096 if (ut_params->op->sym->m_dst)
9097 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9100 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9102 ut_params->op->sym->cipher.data.offset);
9104 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9107 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9109 tdata->plaintext.data,
9110 tdata->plaintext.len,
9111 "Plaintext data not as expected");
9113 TEST_ASSERT_EQUAL(ut_params->op->status,
9114 RTE_CRYPTO_OP_STATUS_SUCCESS,
9115 "Authentication failed");
9121 test_AES_GCM_authenticated_decryption_test_case_1(void)
9123 return test_authenticated_decryption(&gcm_test_case_1);
9127 test_AES_GCM_authenticated_decryption_test_case_2(void)
9129 return test_authenticated_decryption(&gcm_test_case_2);
9133 test_AES_GCM_authenticated_decryption_test_case_3(void)
9135 return test_authenticated_decryption(&gcm_test_case_3);
9139 test_AES_GCM_authenticated_decryption_test_case_4(void)
9141 return test_authenticated_decryption(&gcm_test_case_4);
9145 test_AES_GCM_authenticated_decryption_test_case_5(void)
9147 return test_authenticated_decryption(&gcm_test_case_5);
9151 test_AES_GCM_authenticated_decryption_test_case_6(void)
9153 return test_authenticated_decryption(&gcm_test_case_6);
9157 test_AES_GCM_authenticated_decryption_test_case_7(void)
9159 return test_authenticated_decryption(&gcm_test_case_7);
9163 test_AES_GCM_authenticated_decryption_test_case_8(void)
9165 return test_authenticated_decryption(&gcm_test_case_8);
9169 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9171 return test_authenticated_decryption(&gcm_J0_test_case_1);
9175 test_AES_GCM_auth_decryption_test_case_192_1(void)
9177 return test_authenticated_decryption(&gcm_test_case_192_1);
9181 test_AES_GCM_auth_decryption_test_case_192_2(void)
9183 return test_authenticated_decryption(&gcm_test_case_192_2);
9187 test_AES_GCM_auth_decryption_test_case_192_3(void)
9189 return test_authenticated_decryption(&gcm_test_case_192_3);
9193 test_AES_GCM_auth_decryption_test_case_192_4(void)
9195 return test_authenticated_decryption(&gcm_test_case_192_4);
9199 test_AES_GCM_auth_decryption_test_case_192_5(void)
9201 return test_authenticated_decryption(&gcm_test_case_192_5);
9205 test_AES_GCM_auth_decryption_test_case_192_6(void)
9207 return test_authenticated_decryption(&gcm_test_case_192_6);
9211 test_AES_GCM_auth_decryption_test_case_192_7(void)
9213 return test_authenticated_decryption(&gcm_test_case_192_7);
9217 test_AES_GCM_auth_decryption_test_case_256_1(void)
9219 return test_authenticated_decryption(&gcm_test_case_256_1);
9223 test_AES_GCM_auth_decryption_test_case_256_2(void)
9225 return test_authenticated_decryption(&gcm_test_case_256_2);
9229 test_AES_GCM_auth_decryption_test_case_256_3(void)
9231 return test_authenticated_decryption(&gcm_test_case_256_3);
9235 test_AES_GCM_auth_decryption_test_case_256_4(void)
9237 return test_authenticated_decryption(&gcm_test_case_256_4);
9241 test_AES_GCM_auth_decryption_test_case_256_5(void)
9243 return test_authenticated_decryption(&gcm_test_case_256_5);
9247 test_AES_GCM_auth_decryption_test_case_256_6(void)
9249 return test_authenticated_decryption(&gcm_test_case_256_6);
9253 test_AES_GCM_auth_decryption_test_case_256_7(void)
9255 return test_authenticated_decryption(&gcm_test_case_256_7);
9259 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9261 return test_authenticated_decryption(&gcm_test_case_aad_1);
9265 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9267 return test_authenticated_decryption(&gcm_test_case_aad_2);
9271 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9273 struct aead_test_data tdata;
9276 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9277 tdata.iv.data[0] += 1;
9278 res = test_authenticated_decryption(&tdata);
9279 if (res == -ENOTSUP)
9281 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9282 return TEST_SUCCESS;
9286 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9288 struct aead_test_data tdata;
9291 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9292 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9293 tdata.plaintext.data[0] += 1;
9294 res = test_authenticated_decryption(&tdata);
9295 if (res == -ENOTSUP)
9297 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9298 return TEST_SUCCESS;
9302 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9304 struct aead_test_data tdata;
9307 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9308 tdata.ciphertext.data[0] += 1;
9309 res = test_authenticated_decryption(&tdata);
9310 if (res == -ENOTSUP)
9312 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9313 return TEST_SUCCESS;
9317 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9319 struct aead_test_data tdata;
9322 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9324 res = test_authenticated_decryption(&tdata);
9325 if (res == -ENOTSUP)
9327 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9328 return TEST_SUCCESS;
9332 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9334 struct aead_test_data tdata;
9335 uint8_t aad[gcm_test_case_7.aad.len];
9338 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9339 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9341 tdata.aad.data = aad;
9342 res = test_authenticated_decryption(&tdata);
9343 if (res == -ENOTSUP)
9345 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9346 return TEST_SUCCESS;
9350 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9352 struct aead_test_data tdata;
9355 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9356 tdata.auth_tag.data[0] += 1;
9357 res = test_authenticated_decryption(&tdata);
9358 if (res == -ENOTSUP)
9360 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9361 return TEST_SUCCESS;
9365 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9367 struct crypto_testsuite_params *ts_params = &testsuite_params;
9368 struct crypto_unittest_params *ut_params = &unittest_params;
9371 uint8_t *ciphertext, *auth_tag;
9372 uint16_t plaintext_pad_len;
9374 /* Verify the capabilities */
9375 struct rte_cryptodev_sym_capability_idx cap_idx;
9376 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9377 cap_idx.algo.aead = tdata->algo;
9378 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9382 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9385 /* not supported with CPU crypto */
9386 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9389 /* Create AEAD session */
9390 retval = create_aead_session(ts_params->valid_devs[0],
9392 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9393 tdata->key.data, tdata->key.len,
9394 tdata->aad.len, tdata->auth_tag.len,
9399 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9400 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9402 /* clear mbuf payload */
9403 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9404 rte_pktmbuf_tailroom(ut_params->ibuf));
9405 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9406 rte_pktmbuf_tailroom(ut_params->obuf));
9408 /* Create AEAD operation */
9409 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9413 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9415 ut_params->op->sym->m_src = ut_params->ibuf;
9416 ut_params->op->sym->m_dst = ut_params->obuf;
9418 /* Process crypto operation */
9419 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9420 ut_params->op), "failed to process sym crypto op");
9422 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9423 "crypto op processing failed");
9425 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9427 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9428 ut_params->op->sym->cipher.data.offset);
9429 auth_tag = ciphertext + plaintext_pad_len;
9431 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9432 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9435 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9437 tdata->ciphertext.data,
9438 tdata->ciphertext.len,
9439 "Ciphertext data not as expected");
9441 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9443 tdata->auth_tag.data,
9444 tdata->auth_tag.len,
9445 "Generated auth tag not as expected");
9452 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9454 return test_authenticated_encryption_oop(&gcm_test_case_5);
9458 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9460 struct crypto_testsuite_params *ts_params = &testsuite_params;
9461 struct crypto_unittest_params *ut_params = &unittest_params;
9466 /* Verify the capabilities */
9467 struct rte_cryptodev_sym_capability_idx cap_idx;
9468 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9469 cap_idx.algo.aead = tdata->algo;
9470 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9474 /* not supported with CPU crypto and raw data-path APIs*/
9475 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
9476 global_api_test_type == CRYPTODEV_RAW_API_TEST)
9479 /* Create AEAD session */
9480 retval = create_aead_session(ts_params->valid_devs[0],
9482 RTE_CRYPTO_AEAD_OP_DECRYPT,
9483 tdata->key.data, tdata->key.len,
9484 tdata->aad.len, tdata->auth_tag.len,
9489 /* alloc mbuf and set payload */
9490 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9491 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9493 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9494 rte_pktmbuf_tailroom(ut_params->ibuf));
9495 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9496 rte_pktmbuf_tailroom(ut_params->obuf));
9498 /* Create AEAD operation */
9499 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9503 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9505 ut_params->op->sym->m_src = ut_params->ibuf;
9506 ut_params->op->sym->m_dst = ut_params->obuf;
9508 /* Process crypto operation */
9509 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9510 ut_params->op), "failed to process sym crypto op");
9512 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9513 "crypto op processing failed");
9515 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9516 ut_params->op->sym->cipher.data.offset);
9518 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9521 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9523 tdata->plaintext.data,
9524 tdata->plaintext.len,
9525 "Plaintext data not as expected");
9527 TEST_ASSERT_EQUAL(ut_params->op->status,
9528 RTE_CRYPTO_OP_STATUS_SUCCESS,
9529 "Authentication failed");
9534 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9536 return test_authenticated_decryption_oop(&gcm_test_case_5);
9540 test_authenticated_encryption_sessionless(
9541 const struct aead_test_data *tdata)
9543 struct crypto_testsuite_params *ts_params = &testsuite_params;
9544 struct crypto_unittest_params *ut_params = &unittest_params;
9547 uint8_t *ciphertext, *auth_tag;
9548 uint16_t plaintext_pad_len;
9549 uint8_t key[tdata->key.len + 1];
9550 struct rte_cryptodev_info dev_info;
9552 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9553 uint64_t feat_flags = dev_info.feature_flags;
9555 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9556 printf("Device doesn't support Sessionless ops.\n");
9560 /* not supported with CPU crypto */
9561 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9564 /* Verify the capabilities */
9565 struct rte_cryptodev_sym_capability_idx cap_idx;
9566 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9567 cap_idx.algo.aead = tdata->algo;
9568 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9574 /* clear mbuf payload */
9575 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9576 rte_pktmbuf_tailroom(ut_params->ibuf));
9578 /* Create AEAD operation */
9579 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9583 /* Create GCM xform */
9584 memcpy(key, tdata->key.data, tdata->key.len);
9585 retval = create_aead_xform(ut_params->op,
9587 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9588 key, tdata->key.len,
9589 tdata->aad.len, tdata->auth_tag.len,
9594 ut_params->op->sym->m_src = ut_params->ibuf;
9596 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9597 RTE_CRYPTO_OP_SESSIONLESS,
9598 "crypto op session type not sessionless");
9600 /* Process crypto operation */
9601 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9602 ut_params->op), "failed to process sym crypto op");
9604 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9606 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9607 "crypto op status not success");
9609 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9611 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9612 ut_params->op->sym->cipher.data.offset);
9613 auth_tag = ciphertext + plaintext_pad_len;
9615 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9616 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9619 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9621 tdata->ciphertext.data,
9622 tdata->ciphertext.len,
9623 "Ciphertext data not as expected");
9625 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9627 tdata->auth_tag.data,
9628 tdata->auth_tag.len,
9629 "Generated auth tag not as expected");
9636 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9638 return test_authenticated_encryption_sessionless(
9643 test_authenticated_decryption_sessionless(
9644 const struct aead_test_data *tdata)
9646 struct crypto_testsuite_params *ts_params = &testsuite_params;
9647 struct crypto_unittest_params *ut_params = &unittest_params;
9651 uint8_t key[tdata->key.len + 1];
9652 struct rte_cryptodev_info dev_info;
9654 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9655 uint64_t feat_flags = dev_info.feature_flags;
9657 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
9658 printf("Device doesn't support Sessionless ops.\n");
9662 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9663 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9664 printf("Device doesn't support RAW data-path APIs.\n");
9668 /* not supported with CPU crypto */
9669 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9672 /* Verify the capabilities */
9673 struct rte_cryptodev_sym_capability_idx cap_idx;
9674 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9675 cap_idx.algo.aead = tdata->algo;
9676 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9680 /* alloc mbuf and set payload */
9681 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9683 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9684 rte_pktmbuf_tailroom(ut_params->ibuf));
9686 /* Create AEAD operation */
9687 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9691 /* Create AEAD xform */
9692 memcpy(key, tdata->key.data, tdata->key.len);
9693 retval = create_aead_xform(ut_params->op,
9695 RTE_CRYPTO_AEAD_OP_DECRYPT,
9696 key, tdata->key.len,
9697 tdata->aad.len, tdata->auth_tag.len,
9702 ut_params->op->sym->m_src = ut_params->ibuf;
9704 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9705 RTE_CRYPTO_OP_SESSIONLESS,
9706 "crypto op session type not sessionless");
9708 /* Process crypto operation */
9709 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9710 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9711 ut_params->op, 0, 0, 0, 0);
9713 TEST_ASSERT_NOT_NULL(process_crypto_request(
9714 ts_params->valid_devs[0], ut_params->op),
9715 "failed to process sym crypto op");
9717 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9719 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9720 "crypto op status not success");
9722 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9723 ut_params->op->sym->cipher.data.offset);
9725 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9730 tdata->plaintext.data,
9731 tdata->plaintext.len,
9732 "Plaintext data not as expected");
9734 TEST_ASSERT_EQUAL(ut_params->op->status,
9735 RTE_CRYPTO_OP_STATUS_SUCCESS,
9736 "Authentication failed");
9741 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9743 return test_authenticated_decryption_sessionless(
9748 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9750 return test_authenticated_encryption(&ccm_test_case_128_1);
9754 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9756 return test_authenticated_encryption(&ccm_test_case_128_2);
9760 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9762 return test_authenticated_encryption(&ccm_test_case_128_3);
9766 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9768 return test_authenticated_decryption(&ccm_test_case_128_1);
9772 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9774 return test_authenticated_decryption(&ccm_test_case_128_2);
9778 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9780 return test_authenticated_decryption(&ccm_test_case_128_3);
9784 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9786 return test_authenticated_encryption(&ccm_test_case_192_1);
9790 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9792 return test_authenticated_encryption(&ccm_test_case_192_2);
9796 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9798 return test_authenticated_encryption(&ccm_test_case_192_3);
9802 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9804 return test_authenticated_decryption(&ccm_test_case_192_1);
9808 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9810 return test_authenticated_decryption(&ccm_test_case_192_2);
9814 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9816 return test_authenticated_decryption(&ccm_test_case_192_3);
9820 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9822 return test_authenticated_encryption(&ccm_test_case_256_1);
9826 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9828 return test_authenticated_encryption(&ccm_test_case_256_2);
9832 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9834 return test_authenticated_encryption(&ccm_test_case_256_3);
9838 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9840 return test_authenticated_decryption(&ccm_test_case_256_1);
9844 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9846 return test_authenticated_decryption(&ccm_test_case_256_2);
9850 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9852 return test_authenticated_decryption(&ccm_test_case_256_3);
9858 struct crypto_testsuite_params *ts_params = &testsuite_params;
9859 struct rte_cryptodev_stats stats;
9861 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9864 /* Verify the capabilities */
9865 struct rte_cryptodev_sym_capability_idx cap_idx;
9866 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9867 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
9868 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9871 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9872 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
9873 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9877 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9881 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9882 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9883 &stats) == -ENODEV),
9884 "rte_cryptodev_stats_get invalid dev failed");
9885 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9886 "rte_cryptodev_stats_get invalid Param failed");
9888 /* Test expected values */
9889 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9890 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9892 "rte_cryptodev_stats_get failed");
9893 TEST_ASSERT((stats.enqueued_count == 1),
9894 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9895 TEST_ASSERT((stats.dequeued_count == 1),
9896 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9897 TEST_ASSERT((stats.enqueue_err_count == 0),
9898 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9899 TEST_ASSERT((stats.dequeue_err_count == 0),
9900 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9902 /* invalid device but should ignore and not reset device stats*/
9903 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9904 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9906 "rte_cryptodev_stats_get failed");
9907 TEST_ASSERT((stats.enqueued_count == 1),
9908 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9910 /* check that a valid reset clears stats */
9911 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9912 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9914 "rte_cryptodev_stats_get failed");
9915 TEST_ASSERT((stats.enqueued_count == 0),
9916 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9917 TEST_ASSERT((stats.dequeued_count == 0),
9918 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9920 return TEST_SUCCESS;
9923 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9924 struct crypto_unittest_params *ut_params,
9925 enum rte_crypto_auth_operation op,
9926 const struct HMAC_MD5_vector *test_case)
9930 memcpy(key, test_case->key.data, test_case->key.len);
9932 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9933 ut_params->auth_xform.next = NULL;
9934 ut_params->auth_xform.auth.op = op;
9936 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9938 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9939 ut_params->auth_xform.auth.key.length = test_case->key.len;
9940 ut_params->auth_xform.auth.key.data = key;
9942 ut_params->sess = rte_cryptodev_sym_session_create(
9943 ts_params->session_mpool);
9945 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9946 ut_params->sess, &ut_params->auth_xform,
9947 ts_params->session_priv_mpool);
9949 if (ut_params->sess == NULL)
9952 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9954 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9955 rte_pktmbuf_tailroom(ut_params->ibuf));
9960 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9961 const struct HMAC_MD5_vector *test_case,
9962 uint8_t **plaintext)
9964 uint16_t plaintext_pad_len;
9966 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9968 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9971 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9973 memcpy(*plaintext, test_case->plaintext.data,
9974 test_case->plaintext.len);
9976 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9977 ut_params->ibuf, MD5_DIGEST_LEN);
9978 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9979 "no room to append digest");
9980 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9981 ut_params->ibuf, plaintext_pad_len);
9983 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9984 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9985 test_case->auth_tag.len);
9988 sym_op->auth.data.offset = 0;
9989 sym_op->auth.data.length = test_case->plaintext.len;
9991 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9992 ut_params->op->sym->m_src = ut_params->ibuf;
9998 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10000 uint16_t plaintext_pad_len;
10001 uint8_t *plaintext, *auth_tag;
10003 struct crypto_testsuite_params *ts_params = &testsuite_params;
10004 struct crypto_unittest_params *ut_params = &unittest_params;
10005 struct rte_cryptodev_info dev_info;
10007 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10008 uint64_t feat_flags = dev_info.feature_flags;
10010 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10011 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10012 printf("Device doesn't support RAW data-path APIs.\n");
10016 /* Verify the capabilities */
10017 struct rte_cryptodev_sym_capability_idx cap_idx;
10018 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10019 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10020 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10024 if (MD5_HMAC_create_session(ts_params, ut_params,
10025 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10026 return TEST_FAILED;
10028 /* Generate Crypto op data structure */
10029 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10030 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10031 TEST_ASSERT_NOT_NULL(ut_params->op,
10032 "Failed to allocate symmetric crypto operation struct");
10034 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10037 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10038 return TEST_FAILED;
10040 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10041 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10043 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10044 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10045 ut_params->op, 0, 1, 0, 0);
10047 TEST_ASSERT_NOT_NULL(
10048 process_crypto_request(ts_params->valid_devs[0],
10050 "failed to process sym crypto op");
10052 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10053 "crypto op processing failed");
10055 if (ut_params->op->sym->m_dst) {
10056 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10057 uint8_t *, plaintext_pad_len);
10059 auth_tag = plaintext + plaintext_pad_len;
10062 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10064 test_case->auth_tag.data,
10065 test_case->auth_tag.len,
10066 "HMAC_MD5 generated tag not as expected");
10068 return TEST_SUCCESS;
10072 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10074 uint8_t *plaintext;
10076 struct crypto_testsuite_params *ts_params = &testsuite_params;
10077 struct crypto_unittest_params *ut_params = &unittest_params;
10078 struct rte_cryptodev_info dev_info;
10080 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10081 uint64_t feat_flags = dev_info.feature_flags;
10083 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10084 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10085 printf("Device doesn't support RAW data-path APIs.\n");
10089 /* Verify the capabilities */
10090 struct rte_cryptodev_sym_capability_idx cap_idx;
10091 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10092 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10093 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10097 if (MD5_HMAC_create_session(ts_params, ut_params,
10098 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10099 return TEST_FAILED;
10102 /* Generate Crypto op data structure */
10103 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10104 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10105 TEST_ASSERT_NOT_NULL(ut_params->op,
10106 "Failed to allocate symmetric crypto operation struct");
10108 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10109 return TEST_FAILED;
10111 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10112 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10114 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10115 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10116 ut_params->op, 0, 1, 0, 0);
10118 TEST_ASSERT_NOT_NULL(
10119 process_crypto_request(ts_params->valid_devs[0],
10121 "failed to process sym crypto op");
10123 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10124 "HMAC_MD5 crypto op processing failed");
10126 return TEST_SUCCESS;
10130 test_MD5_HMAC_generate_case_1(void)
10132 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10136 test_MD5_HMAC_verify_case_1(void)
10138 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10142 test_MD5_HMAC_generate_case_2(void)
10144 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10148 test_MD5_HMAC_verify_case_2(void)
10150 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10154 test_multi_session(void)
10156 struct crypto_testsuite_params *ts_params = &testsuite_params;
10157 struct crypto_unittest_params *ut_params = &unittest_params;
10159 struct rte_cryptodev_info dev_info;
10160 struct rte_cryptodev_sym_session **sessions;
10164 /* Verify the capabilities */
10165 struct rte_cryptodev_sym_capability_idx cap_idx;
10166 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10167 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10168 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10171 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10172 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10173 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10177 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10178 aes_cbc_key, hmac_sha512_key);
10181 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10183 sessions = rte_malloc(NULL,
10184 (sizeof(struct rte_cryptodev_sym_session *) *
10185 MAX_NB_SESSIONS) + 1, 0);
10187 /* Create multiple crypto sessions*/
10188 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10190 sessions[i] = rte_cryptodev_sym_session_create(
10191 ts_params->session_mpool);
10193 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10194 sessions[i], &ut_params->auth_xform,
10195 ts_params->session_priv_mpool);
10196 TEST_ASSERT_NOT_NULL(sessions[i],
10197 "Session creation failed at session number %u",
10200 /* Attempt to send a request on each session */
10201 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10205 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10206 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10208 "Failed to perform decrypt on request number %u.", i);
10209 /* free crypto operation structure */
10211 rte_crypto_op_free(ut_params->op);
10214 * free mbuf - both obuf and ibuf are usually the same,
10215 * so check if they point at the same address is necessary,
10216 * to avoid freeing the mbuf twice.
10218 if (ut_params->obuf) {
10219 rte_pktmbuf_free(ut_params->obuf);
10220 if (ut_params->ibuf == ut_params->obuf)
10221 ut_params->ibuf = 0;
10222 ut_params->obuf = 0;
10224 if (ut_params->ibuf) {
10225 rte_pktmbuf_free(ut_params->ibuf);
10226 ut_params->ibuf = 0;
10230 /* Next session create should fail */
10231 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10232 sessions[i], &ut_params->auth_xform,
10233 ts_params->session_priv_mpool);
10234 TEST_ASSERT_NULL(sessions[i],
10235 "Session creation succeeded unexpectedly!");
10237 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10238 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10240 rte_cryptodev_sym_session_free(sessions[i]);
10243 rte_free(sessions);
10245 return TEST_SUCCESS;
10248 struct multi_session_params {
10249 struct crypto_unittest_params ut_params;
10250 uint8_t *cipher_key;
10252 const uint8_t *cipher;
10253 const uint8_t *digest;
10257 #define MB_SESSION_NUMBER 3
10260 test_multi_session_random_usage(void)
10262 struct crypto_testsuite_params *ts_params = &testsuite_params;
10263 struct rte_cryptodev_info dev_info;
10264 struct rte_cryptodev_sym_session **sessions;
10266 struct multi_session_params ut_paramz[] = {
10269 .cipher_key = ms_aes_cbc_key0,
10270 .hmac_key = ms_hmac_key0,
10271 .cipher = ms_aes_cbc_cipher0,
10272 .digest = ms_hmac_digest0,
10273 .iv = ms_aes_cbc_iv0
10276 .cipher_key = ms_aes_cbc_key1,
10277 .hmac_key = ms_hmac_key1,
10278 .cipher = ms_aes_cbc_cipher1,
10279 .digest = ms_hmac_digest1,
10280 .iv = ms_aes_cbc_iv1
10283 .cipher_key = ms_aes_cbc_key2,
10284 .hmac_key = ms_hmac_key2,
10285 .cipher = ms_aes_cbc_cipher2,
10286 .digest = ms_hmac_digest2,
10287 .iv = ms_aes_cbc_iv2
10292 /* Verify the capabilities */
10293 struct rte_cryptodev_sym_capability_idx cap_idx;
10294 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10295 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10296 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10299 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10300 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10301 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10305 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10307 sessions = rte_malloc(NULL,
10308 (sizeof(struct rte_cryptodev_sym_session *)
10309 * MAX_NB_SESSIONS) + 1, 0);
10311 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10312 sessions[i] = rte_cryptodev_sym_session_create(
10313 ts_params->session_mpool);
10315 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10316 sizeof(struct crypto_unittest_params));
10318 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10319 &ut_paramz[i].ut_params,
10320 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10322 /* Create multiple crypto sessions*/
10323 rte_cryptodev_sym_session_init(
10324 ts_params->valid_devs[0],
10326 &ut_paramz[i].ut_params.auth_xform,
10327 ts_params->session_priv_mpool);
10329 TEST_ASSERT_NOT_NULL(sessions[i],
10330 "Session creation failed at session number %u",
10336 for (i = 0; i < 40000; i++) {
10338 j = rand() % MB_SESSION_NUMBER;
10340 TEST_ASSERT_SUCCESS(
10341 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10343 &ut_paramz[j].ut_params,
10344 ts_params, ut_paramz[j].cipher,
10345 ut_paramz[j].digest,
10347 "Failed to perform decrypt on request number %u.", i);
10349 if (ut_paramz[j].ut_params.op)
10350 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10353 * free mbuf - both obuf and ibuf are usually the same,
10354 * so check if they point at the same address is necessary,
10355 * to avoid freeing the mbuf twice.
10357 if (ut_paramz[j].ut_params.obuf) {
10358 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10359 if (ut_paramz[j].ut_params.ibuf
10360 == ut_paramz[j].ut_params.obuf)
10361 ut_paramz[j].ut_params.ibuf = 0;
10362 ut_paramz[j].ut_params.obuf = 0;
10364 if (ut_paramz[j].ut_params.ibuf) {
10365 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10366 ut_paramz[j].ut_params.ibuf = 0;
10370 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10371 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10373 rte_cryptodev_sym_session_free(sessions[i]);
10376 rte_free(sessions);
10378 return TEST_SUCCESS;
10381 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10382 0xab, 0xab, 0xab, 0xab,
10383 0xab, 0xab, 0xab, 0xab,
10384 0xab, 0xab, 0xab, 0xab};
10387 test_null_invalid_operation(void)
10389 struct crypto_testsuite_params *ts_params = &testsuite_params;
10390 struct crypto_unittest_params *ut_params = &unittest_params;
10393 /* This test is for NULL PMD only */
10394 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10395 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10398 /* Setup Cipher Parameters */
10399 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10400 ut_params->cipher_xform.next = NULL;
10402 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10403 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10405 ut_params->sess = rte_cryptodev_sym_session_create(
10406 ts_params->session_mpool);
10408 /* Create Crypto session*/
10409 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10410 ut_params->sess, &ut_params->cipher_xform,
10411 ts_params->session_priv_mpool);
10412 TEST_ASSERT(ret < 0,
10413 "Session creation succeeded unexpectedly");
10416 /* Setup HMAC Parameters */
10417 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10418 ut_params->auth_xform.next = NULL;
10420 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10421 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10423 ut_params->sess = rte_cryptodev_sym_session_create(
10424 ts_params->session_mpool);
10426 /* Create Crypto session*/
10427 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10428 ut_params->sess, &ut_params->auth_xform,
10429 ts_params->session_priv_mpool);
10430 TEST_ASSERT(ret < 0,
10431 "Session creation succeeded unexpectedly");
10433 return TEST_SUCCESS;
10437 #define NULL_BURST_LENGTH (32)
10440 test_null_burst_operation(void)
10442 struct crypto_testsuite_params *ts_params = &testsuite_params;
10443 struct crypto_unittest_params *ut_params = &unittest_params;
10445 unsigned i, burst_len = NULL_BURST_LENGTH;
10447 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10448 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10450 /* This test is for NULL PMD only */
10451 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10452 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10455 /* Setup Cipher Parameters */
10456 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10457 ut_params->cipher_xform.next = &ut_params->auth_xform;
10459 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10460 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10462 /* Setup HMAC Parameters */
10463 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10464 ut_params->auth_xform.next = NULL;
10466 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10467 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10469 ut_params->sess = rte_cryptodev_sym_session_create(
10470 ts_params->session_mpool);
10472 /* Create Crypto session*/
10473 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10474 ut_params->sess, &ut_params->cipher_xform,
10475 ts_params->session_priv_mpool);
10476 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10478 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10479 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10480 burst_len, "failed to generate burst of crypto ops");
10482 /* Generate an operation for each mbuf in burst */
10483 for (i = 0; i < burst_len; i++) {
10484 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10486 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10488 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10492 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10494 burst[i]->sym->m_src = m;
10497 /* Process crypto operation */
10498 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10499 0, burst, burst_len),
10501 "Error enqueuing burst");
10503 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10504 0, burst_dequeued, burst_len),
10506 "Error dequeuing burst");
10509 for (i = 0; i < burst_len; i++) {
10511 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10512 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10514 "data not as expected");
10516 rte_pktmbuf_free(burst[i]->sym->m_src);
10517 rte_crypto_op_free(burst[i]);
10520 return TEST_SUCCESS;
10524 generate_gmac_large_plaintext(uint8_t *data)
10528 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10529 memcpy(&data[i], &data[0], 32);
10533 create_gmac_operation(enum rte_crypto_auth_operation op,
10534 const struct gmac_test_data *tdata)
10536 struct crypto_testsuite_params *ts_params = &testsuite_params;
10537 struct crypto_unittest_params *ut_params = &unittest_params;
10538 struct rte_crypto_sym_op *sym_op;
10540 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10542 /* Generate Crypto op data structure */
10543 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10544 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10545 TEST_ASSERT_NOT_NULL(ut_params->op,
10546 "Failed to allocate symmetric crypto operation struct");
10548 sym_op = ut_params->op->sym;
10550 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10551 ut_params->ibuf, tdata->gmac_tag.len);
10552 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10553 "no room to append digest");
10555 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10556 ut_params->ibuf, plaintext_pad_len);
10558 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10559 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10560 tdata->gmac_tag.len);
10561 debug_hexdump(stdout, "digest:",
10562 sym_op->auth.digest.data,
10563 tdata->gmac_tag.len);
10566 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10567 uint8_t *, IV_OFFSET);
10569 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10571 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10573 sym_op->cipher.data.length = 0;
10574 sym_op->cipher.data.offset = 0;
10576 sym_op->auth.data.offset = 0;
10577 sym_op->auth.data.length = tdata->plaintext.len;
10583 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
10584 const struct gmac_test_data *tdata,
10585 void *digest_mem, uint64_t digest_phys)
10587 struct crypto_testsuite_params *ts_params = &testsuite_params;
10588 struct crypto_unittest_params *ut_params = &unittest_params;
10589 struct rte_crypto_sym_op *sym_op;
10591 /* Generate Crypto op data structure */
10592 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10593 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10594 TEST_ASSERT_NOT_NULL(ut_params->op,
10595 "Failed to allocate symmetric crypto operation struct");
10597 sym_op = ut_params->op->sym;
10599 sym_op->auth.digest.data = digest_mem;
10600 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10601 "no room to append digest");
10603 sym_op->auth.digest.phys_addr = digest_phys;
10605 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10606 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10607 tdata->gmac_tag.len);
10608 debug_hexdump(stdout, "digest:",
10609 sym_op->auth.digest.data,
10610 tdata->gmac_tag.len);
10613 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10614 uint8_t *, IV_OFFSET);
10616 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10618 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10620 sym_op->cipher.data.length = 0;
10621 sym_op->cipher.data.offset = 0;
10623 sym_op->auth.data.offset = 0;
10624 sym_op->auth.data.length = tdata->plaintext.len;
10629 static int create_gmac_session(uint8_t dev_id,
10630 const struct gmac_test_data *tdata,
10631 enum rte_crypto_auth_operation auth_op)
10633 uint8_t auth_key[tdata->key.len];
10635 struct crypto_testsuite_params *ts_params = &testsuite_params;
10636 struct crypto_unittest_params *ut_params = &unittest_params;
10638 memcpy(auth_key, tdata->key.data, tdata->key.len);
10640 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10641 ut_params->auth_xform.next = NULL;
10643 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10644 ut_params->auth_xform.auth.op = auth_op;
10645 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10646 ut_params->auth_xform.auth.key.length = tdata->key.len;
10647 ut_params->auth_xform.auth.key.data = auth_key;
10648 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10649 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10652 ut_params->sess = rte_cryptodev_sym_session_create(
10653 ts_params->session_mpool);
10655 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10656 &ut_params->auth_xform,
10657 ts_params->session_priv_mpool);
10659 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10665 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10667 struct crypto_testsuite_params *ts_params = &testsuite_params;
10668 struct crypto_unittest_params *ut_params = &unittest_params;
10669 struct rte_cryptodev_info dev_info;
10671 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10672 uint64_t feat_flags = dev_info.feature_flags;
10674 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10675 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10676 printf("Device doesn't support RAW data-path APIs.\n");
10682 uint8_t *auth_tag, *plaintext;
10683 uint16_t plaintext_pad_len;
10685 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10686 "No GMAC length in the source data");
10688 /* Verify the capabilities */
10689 struct rte_cryptodev_sym_capability_idx cap_idx;
10690 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10691 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10692 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10696 retval = create_gmac_session(ts_params->valid_devs[0],
10697 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10702 if (tdata->plaintext.len > MBUF_SIZE)
10703 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10705 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10706 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10707 "Failed to allocate input buffer in mempool");
10709 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10710 rte_pktmbuf_tailroom(ut_params->ibuf));
10712 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10714 * Runtime generate the large plain text instead of use hard code
10715 * plain text vector. It is done to avoid create huge source file
10716 * with the test vector.
10718 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10719 generate_gmac_large_plaintext(tdata->plaintext.data);
10721 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10722 plaintext_pad_len);
10723 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10725 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10726 debug_hexdump(stdout, "plaintext:", plaintext,
10727 tdata->plaintext.len);
10729 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10735 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10737 ut_params->op->sym->m_src = ut_params->ibuf;
10739 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10740 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10742 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10743 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10744 ut_params->op, 0, 1, 0, 0);
10746 TEST_ASSERT_NOT_NULL(
10747 process_crypto_request(ts_params->valid_devs[0],
10748 ut_params->op), "failed to process sym crypto op");
10750 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10751 "crypto op processing failed");
10753 if (ut_params->op->sym->m_dst) {
10754 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10755 uint8_t *, plaintext_pad_len);
10757 auth_tag = plaintext + plaintext_pad_len;
10760 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10762 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10764 tdata->gmac_tag.data,
10765 tdata->gmac_tag.len,
10766 "GMAC Generated auth tag not as expected");
10772 test_AES_GMAC_authentication_test_case_1(void)
10774 return test_AES_GMAC_authentication(&gmac_test_case_1);
10778 test_AES_GMAC_authentication_test_case_2(void)
10780 return test_AES_GMAC_authentication(&gmac_test_case_2);
10784 test_AES_GMAC_authentication_test_case_3(void)
10786 return test_AES_GMAC_authentication(&gmac_test_case_3);
10790 test_AES_GMAC_authentication_test_case_4(void)
10792 return test_AES_GMAC_authentication(&gmac_test_case_4);
10796 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10798 struct crypto_testsuite_params *ts_params = &testsuite_params;
10799 struct crypto_unittest_params *ut_params = &unittest_params;
10801 uint32_t plaintext_pad_len;
10802 uint8_t *plaintext;
10803 struct rte_cryptodev_info dev_info;
10805 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10806 uint64_t feat_flags = dev_info.feature_flags;
10808 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10809 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10810 printf("Device doesn't support RAW data-path APIs.\n");
10814 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10815 "No GMAC length in the source data");
10817 /* Verify the capabilities */
10818 struct rte_cryptodev_sym_capability_idx cap_idx;
10819 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10820 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10821 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10825 retval = create_gmac_session(ts_params->valid_devs[0],
10826 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10831 if (tdata->plaintext.len > MBUF_SIZE)
10832 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10834 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10835 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10836 "Failed to allocate input buffer in mempool");
10838 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10839 rte_pktmbuf_tailroom(ut_params->ibuf));
10841 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10844 * Runtime generate the large plain text instead of use hard code
10845 * plain text vector. It is done to avoid create huge source file
10846 * with the test vector.
10848 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10849 generate_gmac_large_plaintext(tdata->plaintext.data);
10851 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10852 plaintext_pad_len);
10853 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10855 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10856 debug_hexdump(stdout, "plaintext:", plaintext,
10857 tdata->plaintext.len);
10859 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10865 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10867 ut_params->op->sym->m_src = ut_params->ibuf;
10869 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10870 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10872 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10873 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10874 ut_params->op, 0, 1, 0, 0);
10876 TEST_ASSERT_NOT_NULL(
10877 process_crypto_request(ts_params->valid_devs[0],
10878 ut_params->op), "failed to process sym crypto op");
10880 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10881 "crypto op processing failed");
10888 test_AES_GMAC_authentication_verify_test_case_1(void)
10890 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10894 test_AES_GMAC_authentication_verify_test_case_2(void)
10896 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10900 test_AES_GMAC_authentication_verify_test_case_3(void)
10902 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10906 test_AES_GMAC_authentication_verify_test_case_4(void)
10908 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10912 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
10915 struct crypto_testsuite_params *ts_params = &testsuite_params;
10916 struct crypto_unittest_params *ut_params = &unittest_params;
10917 struct rte_cryptodev_info dev_info;
10918 uint64_t feature_flags;
10919 unsigned int trn_data = 0;
10920 void *digest_mem = NULL;
10922 unsigned int to_trn = 0;
10923 struct rte_mbuf *buf = NULL;
10924 uint8_t *auth_tag, *plaintext;
10927 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10928 "No GMAC length in the source data");
10930 /* Verify the capabilities */
10931 struct rte_cryptodev_sym_capability_idx cap_idx;
10932 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10933 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
10934 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10938 /* Check for any input SGL support */
10939 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10940 feature_flags = dev_info.feature_flags;
10942 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) &&
10943 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) &&
10944 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
10947 if (fragsz > tdata->plaintext.len)
10948 fragsz = tdata->plaintext.len;
10950 uint16_t plaintext_len = fragsz;
10952 retval = create_gmac_session(ts_params->valid_devs[0],
10953 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10958 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10959 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10960 "Failed to allocate input buffer in mempool");
10962 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10963 rte_pktmbuf_tailroom(ut_params->ibuf));
10965 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10967 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10969 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
10971 trn_data += plaintext_len;
10973 buf = ut_params->ibuf;
10976 * Loop until no more fragments
10979 while (trn_data < tdata->plaintext.len) {
10981 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
10982 (tdata->plaintext.len - trn_data) : fragsz;
10984 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10987 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
10988 rte_pktmbuf_tailroom(buf));
10990 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
10993 memcpy(plaintext, tdata->plaintext.data + trn_data,
10995 trn_data += to_trn;
10996 if (trn_data == tdata->plaintext.len)
10997 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
10998 tdata->gmac_tag.len);
11000 ut_params->ibuf->nb_segs = segs;
11003 * Place digest at the end of the last buffer
11005 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11008 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11009 + tdata->gmac_tag.len);
11010 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11011 tdata->plaintext.len);
11014 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11015 tdata, digest_mem, digest_phys);
11020 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11022 ut_params->op->sym->m_src = ut_params->ibuf;
11024 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11027 TEST_ASSERT_NOT_NULL(
11028 process_crypto_request(ts_params->valid_devs[0],
11029 ut_params->op), "failed to process sym crypto op");
11031 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11032 "crypto op processing failed");
11034 auth_tag = digest_mem;
11035 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11036 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11038 tdata->gmac_tag.data,
11039 tdata->gmac_tag.len,
11040 "GMAC Generated auth tag not as expected");
11045 /* Segment size not multiple of block size (16B) */
11047 test_AES_GMAC_authentication_SGL_40B(void)
11049 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11053 test_AES_GMAC_authentication_SGL_80B(void)
11055 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11059 test_AES_GMAC_authentication_SGL_2048B(void)
11061 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11064 /* Segment size not multiple of block size (16B) */
11066 test_AES_GMAC_authentication_SGL_2047B(void)
11068 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11071 struct test_crypto_vector {
11072 enum rte_crypto_cipher_algorithm crypto_algo;
11073 unsigned int cipher_offset;
11074 unsigned int cipher_len;
11087 const uint8_t *data;
11092 const uint8_t *data;
11096 enum rte_crypto_auth_algorithm auth_algo;
11097 unsigned int auth_offset;
11105 const uint8_t *data;
11115 static const struct test_crypto_vector
11116 hmac_sha1_test_crypto_vector = {
11117 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11119 .data = plaintext_hash,
11124 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11125 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11126 0xDE, 0xF4, 0xDE, 0xAD
11132 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11133 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11134 0x3F, 0x91, 0x64, 0x59
11140 static const struct test_crypto_vector
11141 aes128_gmac_test_vector = {
11142 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11144 .data = plaintext_hash,
11149 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11150 0x08, 0x09, 0x0A, 0x0B
11156 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11157 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11163 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11164 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11170 static const struct test_crypto_vector
11171 aes128cbc_hmac_sha1_test_vector = {
11172 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11173 .cipher_offset = 0,
11177 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11178 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11184 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11185 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11190 .data = plaintext_hash,
11194 .data = ciphertext512_aes128cbc,
11197 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11201 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11202 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11203 0xDE, 0xF4, 0xDE, 0xAD
11209 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
11210 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11211 0x18, 0x8C, 0x1D, 0x32
11217 static const struct test_crypto_vector
11218 aes128cbc_hmac_sha1_aad_test_vector = {
11219 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11220 .cipher_offset = 8,
11224 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11225 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11231 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11232 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11237 .data = plaintext_hash,
11241 .data = ciphertext512_aes128cbc_aad,
11244 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11248 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11249 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11250 0xDE, 0xF4, 0xDE, 0xAD
11256 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
11257 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
11258 0x62, 0x0F, 0xFB, 0x10
11265 data_corruption(uint8_t *data)
11271 tag_corruption(uint8_t *data, unsigned int tag_offset)
11273 data[tag_offset] += 1;
11277 create_auth_session(struct crypto_unittest_params *ut_params,
11279 const struct test_crypto_vector *reference,
11280 enum rte_crypto_auth_operation auth_op)
11282 struct crypto_testsuite_params *ts_params = &testsuite_params;
11283 uint8_t auth_key[reference->auth_key.len + 1];
11285 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11287 /* Setup Authentication Parameters */
11288 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11289 ut_params->auth_xform.auth.op = auth_op;
11290 ut_params->auth_xform.next = NULL;
11291 ut_params->auth_xform.auth.algo = reference->auth_algo;
11292 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11293 ut_params->auth_xform.auth.key.data = auth_key;
11294 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11296 /* Create Crypto session*/
11297 ut_params->sess = rte_cryptodev_sym_session_create(
11298 ts_params->session_mpool);
11300 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11301 &ut_params->auth_xform,
11302 ts_params->session_priv_mpool);
11304 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11310 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
11312 const struct test_crypto_vector *reference,
11313 enum rte_crypto_auth_operation auth_op,
11314 enum rte_crypto_cipher_operation cipher_op)
11316 struct crypto_testsuite_params *ts_params = &testsuite_params;
11317 uint8_t cipher_key[reference->cipher_key.len + 1];
11318 uint8_t auth_key[reference->auth_key.len + 1];
11320 memcpy(cipher_key, reference->cipher_key.data,
11321 reference->cipher_key.len);
11322 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11324 /* Setup Authentication Parameters */
11325 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11326 ut_params->auth_xform.auth.op = auth_op;
11327 ut_params->auth_xform.auth.algo = reference->auth_algo;
11328 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11329 ut_params->auth_xform.auth.key.data = auth_key;
11330 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11332 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
11333 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11334 ut_params->auth_xform.auth.iv.length = reference->iv.len;
11336 ut_params->auth_xform.next = &ut_params->cipher_xform;
11338 /* Setup Cipher Parameters */
11339 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11340 ut_params->cipher_xform.next = NULL;
11341 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11342 ut_params->cipher_xform.cipher.op = cipher_op;
11343 ut_params->cipher_xform.cipher.key.data = cipher_key;
11344 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11345 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11346 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11349 /* Create Crypto session*/
11350 ut_params->sess = rte_cryptodev_sym_session_create(
11351 ts_params->session_mpool);
11353 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11354 &ut_params->auth_xform,
11355 ts_params->session_priv_mpool);
11357 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11363 create_auth_operation(struct crypto_testsuite_params *ts_params,
11364 struct crypto_unittest_params *ut_params,
11365 const struct test_crypto_vector *reference,
11366 unsigned int auth_generate)
11368 /* Generate Crypto op data structure */
11369 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11370 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11371 TEST_ASSERT_NOT_NULL(ut_params->op,
11372 "Failed to allocate pktmbuf offload");
11374 /* Set crypto operation data parameters */
11375 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11377 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11379 /* set crypto operation source mbuf */
11380 sym_op->m_src = ut_params->ibuf;
11383 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11384 ut_params->ibuf, reference->digest.len);
11386 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11387 "no room to append auth tag");
11389 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11390 ut_params->ibuf, reference->plaintext.len);
11393 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11395 memcpy(sym_op->auth.digest.data,
11396 reference->digest.data,
11397 reference->digest.len);
11399 debug_hexdump(stdout, "digest:",
11400 sym_op->auth.digest.data,
11401 reference->digest.len);
11403 sym_op->auth.data.length = reference->plaintext.len;
11404 sym_op->auth.data.offset = 0;
11410 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
11411 struct crypto_unittest_params *ut_params,
11412 const struct test_crypto_vector *reference,
11413 unsigned int auth_generate)
11415 /* Generate Crypto op data structure */
11416 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11417 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11418 TEST_ASSERT_NOT_NULL(ut_params->op,
11419 "Failed to allocate pktmbuf offload");
11421 /* Set crypto operation data parameters */
11422 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11424 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11426 /* set crypto operation source mbuf */
11427 sym_op->m_src = ut_params->ibuf;
11430 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11431 ut_params->ibuf, reference->digest.len);
11433 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11434 "no room to append auth tag");
11436 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11437 ut_params->ibuf, reference->ciphertext.len);
11440 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11442 memcpy(sym_op->auth.digest.data,
11443 reference->digest.data,
11444 reference->digest.len);
11446 debug_hexdump(stdout, "digest:",
11447 sym_op->auth.digest.data,
11448 reference->digest.len);
11450 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11451 reference->iv.data, reference->iv.len);
11453 sym_op->cipher.data.length = 0;
11454 sym_op->cipher.data.offset = 0;
11456 sym_op->auth.data.length = reference->plaintext.len;
11457 sym_op->auth.data.offset = 0;
11463 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11464 struct crypto_unittest_params *ut_params,
11465 const struct test_crypto_vector *reference,
11466 unsigned int auth_generate)
11468 /* Generate Crypto op data structure */
11469 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11470 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11471 TEST_ASSERT_NOT_NULL(ut_params->op,
11472 "Failed to allocate pktmbuf offload");
11474 /* Set crypto operation data parameters */
11475 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11477 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11479 /* set crypto operation source mbuf */
11480 sym_op->m_src = ut_params->ibuf;
11483 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11484 ut_params->ibuf, reference->digest.len);
11486 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11487 "no room to append auth tag");
11489 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11490 ut_params->ibuf, reference->ciphertext.len);
11493 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11495 memcpy(sym_op->auth.digest.data,
11496 reference->digest.data,
11497 reference->digest.len);
11499 debug_hexdump(stdout, "digest:",
11500 sym_op->auth.digest.data,
11501 reference->digest.len);
11503 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11504 reference->iv.data, reference->iv.len);
11506 sym_op->cipher.data.length = reference->cipher_len;
11507 sym_op->cipher.data.offset = reference->cipher_offset;
11509 sym_op->auth.data.length = reference->plaintext.len;
11510 sym_op->auth.data.offset = reference->auth_offset;
11516 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11517 struct crypto_unittest_params *ut_params,
11518 const struct test_crypto_vector *reference)
11520 return create_auth_operation(ts_params, ut_params, reference, 0);
11524 create_auth_verify_GMAC_operation(
11525 struct crypto_testsuite_params *ts_params,
11526 struct crypto_unittest_params *ut_params,
11527 const struct test_crypto_vector *reference)
11529 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11533 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11534 struct crypto_unittest_params *ut_params,
11535 const struct test_crypto_vector *reference)
11537 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11541 test_authentication_verify_fail_when_data_corruption(
11542 struct crypto_testsuite_params *ts_params,
11543 struct crypto_unittest_params *ut_params,
11544 const struct test_crypto_vector *reference,
11545 unsigned int data_corrupted)
11549 uint8_t *plaintext;
11550 struct rte_cryptodev_info dev_info;
11552 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11553 uint64_t feat_flags = dev_info.feature_flags;
11555 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11556 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11557 printf("Device doesn't support RAW data-path APIs.\n");
11561 /* Verify the capabilities */
11562 struct rte_cryptodev_sym_capability_idx cap_idx;
11563 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11564 cap_idx.algo.auth = reference->auth_algo;
11565 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11570 /* Create session */
11571 retval = create_auth_session(ut_params,
11572 ts_params->valid_devs[0],
11574 RTE_CRYPTO_AUTH_OP_VERIFY);
11578 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11579 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11580 "Failed to allocate input buffer in mempool");
11582 /* clear mbuf payload */
11583 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11584 rte_pktmbuf_tailroom(ut_params->ibuf));
11586 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11587 reference->plaintext.len);
11588 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11589 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11591 debug_hexdump(stdout, "plaintext:", plaintext,
11592 reference->plaintext.len);
11594 /* Create operation */
11595 retval = create_auth_verify_operation(ts_params, ut_params, reference);
11600 if (data_corrupted)
11601 data_corruption(plaintext);
11603 tag_corruption(plaintext, reference->plaintext.len);
11605 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11606 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11608 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11609 RTE_CRYPTO_OP_STATUS_SUCCESS,
11610 "authentication not failed");
11611 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11612 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11613 ut_params->op, 0, 1, 0, 0);
11615 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11617 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11624 test_authentication_verify_GMAC_fail_when_corruption(
11625 struct crypto_testsuite_params *ts_params,
11626 struct crypto_unittest_params *ut_params,
11627 const struct test_crypto_vector *reference,
11628 unsigned int data_corrupted)
11631 uint8_t *plaintext;
11632 struct rte_cryptodev_info dev_info;
11634 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11635 uint64_t feat_flags = dev_info.feature_flags;
11637 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11638 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11639 printf("Device doesn't support RAW data-path APIs.\n");
11643 /* Verify the capabilities */
11644 struct rte_cryptodev_sym_capability_idx cap_idx;
11645 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11646 cap_idx.algo.auth = reference->auth_algo;
11647 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11651 /* Create session */
11652 retval = create_auth_cipher_session(ut_params,
11653 ts_params->valid_devs[0],
11655 RTE_CRYPTO_AUTH_OP_VERIFY,
11656 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11660 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11661 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11662 "Failed to allocate input buffer in mempool");
11664 /* clear mbuf payload */
11665 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11666 rte_pktmbuf_tailroom(ut_params->ibuf));
11668 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11669 reference->plaintext.len);
11670 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11671 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11673 debug_hexdump(stdout, "plaintext:", plaintext,
11674 reference->plaintext.len);
11676 /* Create operation */
11677 retval = create_auth_verify_GMAC_operation(ts_params,
11684 if (data_corrupted)
11685 data_corruption(plaintext);
11687 tag_corruption(plaintext, reference->aad.len);
11689 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11690 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11692 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11693 RTE_CRYPTO_OP_STATUS_SUCCESS,
11694 "authentication not failed");
11695 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11696 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11697 ut_params->op, 0, 1, 0, 0);
11699 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11701 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11708 test_authenticated_decryption_fail_when_corruption(
11709 struct crypto_testsuite_params *ts_params,
11710 struct crypto_unittest_params *ut_params,
11711 const struct test_crypto_vector *reference,
11712 unsigned int data_corrupted)
11716 uint8_t *ciphertext;
11717 struct rte_cryptodev_info dev_info;
11719 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11720 uint64_t feat_flags = dev_info.feature_flags;
11722 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11723 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11724 printf("Device doesn't support RAW data-path APIs.\n");
11728 /* Verify the capabilities */
11729 struct rte_cryptodev_sym_capability_idx cap_idx;
11730 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11731 cap_idx.algo.auth = reference->auth_algo;
11732 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11735 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11736 cap_idx.algo.cipher = reference->crypto_algo;
11737 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11741 /* Create session */
11742 retval = create_auth_cipher_session(ut_params,
11743 ts_params->valid_devs[0],
11745 RTE_CRYPTO_AUTH_OP_VERIFY,
11746 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11750 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11751 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11752 "Failed to allocate input buffer in mempool");
11754 /* clear mbuf payload */
11755 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11756 rte_pktmbuf_tailroom(ut_params->ibuf));
11758 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11759 reference->ciphertext.len);
11760 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11761 memcpy(ciphertext, reference->ciphertext.data,
11762 reference->ciphertext.len);
11764 /* Create operation */
11765 retval = create_cipher_auth_verify_operation(ts_params,
11772 if (data_corrupted)
11773 data_corruption(ciphertext);
11775 tag_corruption(ciphertext, reference->ciphertext.len);
11777 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
11778 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11780 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
11781 RTE_CRYPTO_OP_STATUS_SUCCESS,
11782 "authentication not failed");
11783 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11784 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11785 ut_params->op, 1, 1, 0, 0);
11787 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11789 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11796 test_authenticated_encryt_with_esn(
11797 struct crypto_testsuite_params *ts_params,
11798 struct crypto_unittest_params *ut_params,
11799 const struct test_crypto_vector *reference)
11803 uint8_t *authciphertext, *plaintext, *auth_tag;
11804 uint16_t plaintext_pad_len;
11805 uint8_t cipher_key[reference->cipher_key.len + 1];
11806 uint8_t auth_key[reference->auth_key.len + 1];
11807 struct rte_cryptodev_info dev_info;
11809 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11810 uint64_t feat_flags = dev_info.feature_flags;
11812 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11813 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11814 printf("Device doesn't support RAW data-path APIs.\n");
11818 /* Verify the capabilities */
11819 struct rte_cryptodev_sym_capability_idx cap_idx;
11820 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11821 cap_idx.algo.auth = reference->auth_algo;
11822 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11825 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11826 cap_idx.algo.cipher = reference->crypto_algo;
11827 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11831 /* Create session */
11832 memcpy(cipher_key, reference->cipher_key.data,
11833 reference->cipher_key.len);
11834 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11836 /* Setup Cipher Parameters */
11837 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11838 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11839 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11840 ut_params->cipher_xform.cipher.key.data = cipher_key;
11841 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11842 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11843 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11845 ut_params->cipher_xform.next = &ut_params->auth_xform;
11847 /* Setup Authentication Parameters */
11848 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11849 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11850 ut_params->auth_xform.auth.algo = reference->auth_algo;
11851 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11852 ut_params->auth_xform.auth.key.data = auth_key;
11853 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11854 ut_params->auth_xform.next = NULL;
11856 /* Create Crypto session*/
11857 ut_params->sess = rte_cryptodev_sym_session_create(
11858 ts_params->session_mpool);
11860 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11862 &ut_params->cipher_xform,
11863 ts_params->session_priv_mpool);
11865 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11867 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11868 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11869 "Failed to allocate input buffer in mempool");
11871 /* clear mbuf payload */
11872 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11873 rte_pktmbuf_tailroom(ut_params->ibuf));
11875 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11876 reference->plaintext.len);
11877 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11878 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11880 /* Create operation */
11881 retval = create_cipher_auth_operation(ts_params,
11888 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11889 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11891 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11892 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11893 ut_params->op, 1, 1, 0, 0);
11895 ut_params->op = process_crypto_request(
11896 ts_params->valid_devs[0], ut_params->op);
11898 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11900 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11901 "crypto op processing failed");
11903 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11905 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11906 ut_params->op->sym->auth.data.offset);
11907 auth_tag = authciphertext + plaintext_pad_len;
11908 debug_hexdump(stdout, "ciphertext:", authciphertext,
11909 reference->ciphertext.len);
11910 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11912 /* Validate obuf */
11913 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11915 reference->ciphertext.data,
11916 reference->ciphertext.len,
11917 "Ciphertext data not as expected");
11919 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11921 reference->digest.data,
11922 reference->digest.len,
11923 "Generated digest not as expected");
11925 return TEST_SUCCESS;
11930 test_authenticated_decrypt_with_esn(
11931 struct crypto_testsuite_params *ts_params,
11932 struct crypto_unittest_params *ut_params,
11933 const struct test_crypto_vector *reference)
11937 uint8_t *ciphertext;
11938 uint8_t cipher_key[reference->cipher_key.len + 1];
11939 uint8_t auth_key[reference->auth_key.len + 1];
11940 struct rte_cryptodev_info dev_info;
11942 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11943 uint64_t feat_flags = dev_info.feature_flags;
11945 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11946 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11947 printf("Device doesn't support RAW data-path APIs.\n");
11951 /* Verify the capabilities */
11952 struct rte_cryptodev_sym_capability_idx cap_idx;
11953 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11954 cap_idx.algo.auth = reference->auth_algo;
11955 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11958 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11959 cap_idx.algo.cipher = reference->crypto_algo;
11960 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11964 /* Create session */
11965 memcpy(cipher_key, reference->cipher_key.data,
11966 reference->cipher_key.len);
11967 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11969 /* Setup Authentication Parameters */
11970 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11971 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11972 ut_params->auth_xform.auth.algo = reference->auth_algo;
11973 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11974 ut_params->auth_xform.auth.key.data = auth_key;
11975 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11976 ut_params->auth_xform.next = &ut_params->cipher_xform;
11978 /* Setup Cipher Parameters */
11979 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11980 ut_params->cipher_xform.next = NULL;
11981 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11982 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11983 ut_params->cipher_xform.cipher.key.data = cipher_key;
11984 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11985 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11986 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11988 /* Create Crypto session*/
11989 ut_params->sess = rte_cryptodev_sym_session_create(
11990 ts_params->session_mpool);
11992 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11994 &ut_params->auth_xform,
11995 ts_params->session_priv_mpool);
11997 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11999 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12000 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12001 "Failed to allocate input buffer in mempool");
12003 /* clear mbuf payload */
12004 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12005 rte_pktmbuf_tailroom(ut_params->ibuf));
12007 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12008 reference->ciphertext.len);
12009 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12010 memcpy(ciphertext, reference->ciphertext.data,
12011 reference->ciphertext.len);
12013 /* Create operation */
12014 retval = create_cipher_auth_verify_operation(ts_params,
12021 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12022 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12024 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12025 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12026 ut_params->op, 1, 1, 0, 0);
12028 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12031 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12032 TEST_ASSERT_EQUAL(ut_params->op->status,
12033 RTE_CRYPTO_OP_STATUS_SUCCESS,
12034 "crypto op processing passed");
12036 ut_params->obuf = ut_params->op->sym->m_src;
12037 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12043 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12044 const struct aead_test_data *tdata,
12045 void *digest_mem, uint64_t digest_phys)
12047 struct crypto_testsuite_params *ts_params = &testsuite_params;
12048 struct crypto_unittest_params *ut_params = &unittest_params;
12050 const unsigned int auth_tag_len = tdata->auth_tag.len;
12051 const unsigned int iv_len = tdata->iv.len;
12052 unsigned int aad_len = tdata->aad.len;
12053 unsigned int aad_len_pad = 0;
12055 /* Generate Crypto op data structure */
12056 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12057 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12058 TEST_ASSERT_NOT_NULL(ut_params->op,
12059 "Failed to allocate symmetric crypto operation struct");
12061 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12063 sym_op->aead.digest.data = digest_mem;
12065 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12066 "no room to append digest");
12068 sym_op->aead.digest.phys_addr = digest_phys;
12070 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12071 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12073 debug_hexdump(stdout, "digest:",
12074 sym_op->aead.digest.data,
12078 /* Append aad data */
12079 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12080 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12081 uint8_t *, IV_OFFSET);
12083 /* Copy IV 1 byte after the IV pointer, according to the API */
12084 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12086 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12088 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12089 ut_params->ibuf, aad_len);
12090 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12091 "no room to prepend aad");
12092 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12095 memset(sym_op->aead.aad.data, 0, aad_len);
12096 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12097 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12099 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12100 debug_hexdump(stdout, "aad:",
12101 sym_op->aead.aad.data, aad_len);
12103 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12104 uint8_t *, IV_OFFSET);
12106 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12108 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12110 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12111 ut_params->ibuf, aad_len_pad);
12112 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12113 "no room to prepend aad");
12114 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12117 memset(sym_op->aead.aad.data, 0, aad_len);
12118 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12120 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12121 debug_hexdump(stdout, "aad:",
12122 sym_op->aead.aad.data, aad_len);
12125 sym_op->aead.data.length = tdata->plaintext.len;
12126 sym_op->aead.data.offset = aad_len_pad;
12131 #define SGL_MAX_NO 16
12134 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12135 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12137 struct crypto_testsuite_params *ts_params = &testsuite_params;
12138 struct crypto_unittest_params *ut_params = &unittest_params;
12139 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12142 int to_trn_tbl[SGL_MAX_NO];
12144 unsigned int trn_data = 0;
12145 uint8_t *plaintext, *ciphertext, *auth_tag;
12146 struct rte_cryptodev_info dev_info;
12148 /* Verify the capabilities */
12149 struct rte_cryptodev_sym_capability_idx cap_idx;
12150 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12151 cap_idx.algo.aead = tdata->algo;
12152 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12156 /* OOP not supported with CPU crypto */
12157 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12160 /* Detailed check for the particular SGL support flag */
12161 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12163 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12164 if (sgl_in && (!(dev_info.feature_flags &
12165 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12168 uint64_t feat_flags = dev_info.feature_flags;
12170 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12171 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12172 printf("Device doesn't support RAW data-path APIs.\n");
12176 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12177 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12178 tdata->plaintext.len;
12179 /* Raw data path API does not support OOP */
12180 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12182 if (sgl_in && !sgl_out) {
12183 if (!(dev_info.feature_flags &
12184 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12186 } else if (!sgl_in && sgl_out) {
12187 if (!(dev_info.feature_flags &
12188 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12190 } else if (sgl_in && sgl_out) {
12191 if (!(dev_info.feature_flags &
12192 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12197 if (fragsz > tdata->plaintext.len)
12198 fragsz = tdata->plaintext.len;
12200 uint16_t plaintext_len = fragsz;
12201 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
12203 if (fragsz_oop > tdata->plaintext.len)
12204 frag_size_oop = tdata->plaintext.len;
12207 void *digest_mem = NULL;
12209 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
12211 if (tdata->plaintext.len % fragsz != 0) {
12212 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
12215 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
12220 * For out-op-place we need to alloc another mbuf
12223 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12224 rte_pktmbuf_append(ut_params->obuf,
12225 frag_size_oop + prepend_len);
12226 buf_oop = ut_params->obuf;
12229 /* Create AEAD session */
12230 retval = create_aead_session(ts_params->valid_devs[0],
12232 RTE_CRYPTO_AEAD_OP_ENCRYPT,
12233 tdata->key.data, tdata->key.len,
12234 tdata->aad.len, tdata->auth_tag.len,
12239 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12241 /* clear mbuf payload */
12242 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12243 rte_pktmbuf_tailroom(ut_params->ibuf));
12245 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12248 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12250 trn_data += plaintext_len;
12252 buf = ut_params->ibuf;
12255 * Loop until no more fragments
12258 while (trn_data < tdata->plaintext.len) {
12260 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12261 (tdata->plaintext.len - trn_data) : fragsz;
12263 to_trn_tbl[ecx++] = to_trn;
12265 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12268 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12269 rte_pktmbuf_tailroom(buf));
12272 if (oop && !fragsz_oop) {
12273 buf_last_oop = buf_oop->next =
12274 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12275 buf_oop = buf_oop->next;
12276 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12277 0, rte_pktmbuf_tailroom(buf_oop));
12278 rte_pktmbuf_append(buf_oop, to_trn);
12281 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12284 memcpy(plaintext, tdata->plaintext.data + trn_data,
12286 trn_data += to_trn;
12287 if (trn_data == tdata->plaintext.len) {
12290 digest_mem = rte_pktmbuf_append(buf_oop,
12291 tdata->auth_tag.len);
12293 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12294 tdata->auth_tag.len);
12298 uint64_t digest_phys = 0;
12300 ut_params->ibuf->nb_segs = segs;
12303 if (fragsz_oop && oop) {
12307 if (frag_size_oop == tdata->plaintext.len) {
12308 digest_mem = rte_pktmbuf_append(ut_params->obuf,
12309 tdata->auth_tag.len);
12311 digest_phys = rte_pktmbuf_iova_offset(
12313 tdata->plaintext.len + prepend_len);
12316 trn_data = frag_size_oop;
12317 while (trn_data < tdata->plaintext.len) {
12320 (tdata->plaintext.len - trn_data <
12322 (tdata->plaintext.len - trn_data) :
12325 to_trn_tbl[ecx++] = to_trn;
12327 buf_last_oop = buf_oop->next =
12328 rte_pktmbuf_alloc(ts_params->mbuf_pool);
12329 buf_oop = buf_oop->next;
12330 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
12331 0, rte_pktmbuf_tailroom(buf_oop));
12332 rte_pktmbuf_append(buf_oop, to_trn);
12334 trn_data += to_trn;
12336 if (trn_data == tdata->plaintext.len) {
12337 digest_mem = rte_pktmbuf_append(buf_oop,
12338 tdata->auth_tag.len);
12342 ut_params->obuf->nb_segs = segs;
12346 * Place digest at the end of the last buffer
12349 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12350 if (oop && buf_last_oop)
12351 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
12353 if (!digest_mem && !oop) {
12354 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12355 + tdata->auth_tag.len);
12356 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12357 tdata->plaintext.len);
12360 /* Create AEAD operation */
12361 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
12362 tdata, digest_mem, digest_phys);
12367 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12369 ut_params->op->sym->m_src = ut_params->ibuf;
12371 ut_params->op->sym->m_dst = ut_params->obuf;
12373 /* Process crypto operation */
12374 if (oop == IN_PLACE &&
12375 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12376 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12377 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12378 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12379 ut_params->op, 0, 0, 0, 0);
12381 TEST_ASSERT_NOT_NULL(
12382 process_crypto_request(ts_params->valid_devs[0],
12383 ut_params->op), "failed to process sym crypto op");
12385 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12386 "crypto op processing failed");
12389 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12390 uint8_t *, prepend_len);
12392 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12393 uint8_t *, prepend_len);
12397 fragsz = fragsz_oop;
12399 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12401 tdata->ciphertext.data,
12403 "Ciphertext data not as expected");
12405 buf = ut_params->op->sym->m_src->next;
12407 buf = ut_params->op->sym->m_dst->next;
12409 unsigned int off = fragsz;
12413 ciphertext = rte_pktmbuf_mtod(buf,
12416 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12418 tdata->ciphertext.data + off,
12420 "Ciphertext data not as expected");
12422 off += to_trn_tbl[ecx++];
12426 auth_tag = digest_mem;
12427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12429 tdata->auth_tag.data,
12430 tdata->auth_tag.len,
12431 "Generated auth tag not as expected");
12437 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
12439 return test_authenticated_encryption_SGL(
12440 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
12444 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
12446 return test_authenticated_encryption_SGL(
12447 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
12451 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
12453 return test_authenticated_encryption_SGL(
12454 &gcm_test_case_8, OUT_OF_PLACE, 400,
12455 gcm_test_case_8.plaintext.len);
12459 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
12461 /* This test is not for OPENSSL PMD */
12462 if (gbl_driver_id == rte_cryptodev_driver_id_get(
12463 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
12466 return test_authenticated_encryption_SGL(
12467 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
12471 test_authentication_verify_fail_when_data_corrupted(
12472 struct crypto_testsuite_params *ts_params,
12473 struct crypto_unittest_params *ut_params,
12474 const struct test_crypto_vector *reference)
12476 return test_authentication_verify_fail_when_data_corruption(
12477 ts_params, ut_params, reference, 1);
12481 test_authentication_verify_fail_when_tag_corrupted(
12482 struct crypto_testsuite_params *ts_params,
12483 struct crypto_unittest_params *ut_params,
12484 const struct test_crypto_vector *reference)
12486 return test_authentication_verify_fail_when_data_corruption(
12487 ts_params, ut_params, reference, 0);
12491 test_authentication_verify_GMAC_fail_when_data_corrupted(
12492 struct crypto_testsuite_params *ts_params,
12493 struct crypto_unittest_params *ut_params,
12494 const struct test_crypto_vector *reference)
12496 return test_authentication_verify_GMAC_fail_when_corruption(
12497 ts_params, ut_params, reference, 1);
12501 test_authentication_verify_GMAC_fail_when_tag_corrupted(
12502 struct crypto_testsuite_params *ts_params,
12503 struct crypto_unittest_params *ut_params,
12504 const struct test_crypto_vector *reference)
12506 return test_authentication_verify_GMAC_fail_when_corruption(
12507 ts_params, ut_params, reference, 0);
12511 test_authenticated_decryption_fail_when_data_corrupted(
12512 struct crypto_testsuite_params *ts_params,
12513 struct crypto_unittest_params *ut_params,
12514 const struct test_crypto_vector *reference)
12516 return test_authenticated_decryption_fail_when_corruption(
12517 ts_params, ut_params, reference, 1);
12521 test_authenticated_decryption_fail_when_tag_corrupted(
12522 struct crypto_testsuite_params *ts_params,
12523 struct crypto_unittest_params *ut_params,
12524 const struct test_crypto_vector *reference)
12526 return test_authenticated_decryption_fail_when_corruption(
12527 ts_params, ut_params, reference, 0);
12531 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
12533 return test_authentication_verify_fail_when_data_corrupted(
12534 &testsuite_params, &unittest_params,
12535 &hmac_sha1_test_crypto_vector);
12539 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
12541 return test_authentication_verify_fail_when_tag_corrupted(
12542 &testsuite_params, &unittest_params,
12543 &hmac_sha1_test_crypto_vector);
12547 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
12549 return test_authentication_verify_GMAC_fail_when_data_corrupted(
12550 &testsuite_params, &unittest_params,
12551 &aes128_gmac_test_vector);
12555 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
12557 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
12558 &testsuite_params, &unittest_params,
12559 &aes128_gmac_test_vector);
12563 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
12565 return test_authenticated_decryption_fail_when_data_corrupted(
12568 &aes128cbc_hmac_sha1_test_vector);
12572 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
12574 return test_authenticated_decryption_fail_when_tag_corrupted(
12577 &aes128cbc_hmac_sha1_test_vector);
12581 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
12583 return test_authenticated_encryt_with_esn(
12586 &aes128cbc_hmac_sha1_aad_test_vector);
12590 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
12592 return test_authenticated_decrypt_with_esn(
12595 &aes128cbc_hmac_sha1_aad_test_vector);
12599 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
12601 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
12605 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
12607 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
12610 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12612 /* global AESNI worker IDs for the scheduler test */
12613 uint8_t aesni_ids[2];
12616 test_scheduler_attach_slave_op(void)
12618 struct crypto_testsuite_params *ts_params = &testsuite_params;
12619 uint8_t sched_id = ts_params->valid_devs[0];
12620 uint32_t nb_devs, i, nb_devs_attached = 0;
12622 char vdev_name[32];
12624 /* create 2 AESNI_MB if necessary */
12625 nb_devs = rte_cryptodev_device_count_by_driver(
12626 rte_cryptodev_driver_id_get(
12627 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
12629 for (i = nb_devs; i < 2; i++) {
12630 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
12631 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
12633 ret = rte_vdev_init(vdev_name, NULL);
12635 TEST_ASSERT(ret == 0,
12636 "Failed to create instance %u of"
12638 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12642 /* attach 2 AESNI_MB cdevs */
12643 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
12645 struct rte_cryptodev_info info;
12646 unsigned int session_size;
12648 rte_cryptodev_info_get(i, &info);
12649 if (info.driver_id != rte_cryptodev_driver_id_get(
12650 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
12653 session_size = rte_cryptodev_sym_get_private_session_size(i);
12655 * Create the session mempool again, since now there are new devices
12656 * to use the mempool.
12658 if (ts_params->session_mpool) {
12659 rte_mempool_free(ts_params->session_mpool);
12660 ts_params->session_mpool = NULL;
12662 if (ts_params->session_priv_mpool) {
12663 rte_mempool_free(ts_params->session_priv_mpool);
12664 ts_params->session_priv_mpool = NULL;
12667 if (info.sym.max_nb_sessions != 0 &&
12668 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
12669 RTE_LOG(ERR, USER1,
12670 "Device does not support "
12671 "at least %u sessions\n",
12673 return TEST_FAILED;
12676 * Create mempool with maximum number of sessions,
12677 * to include the session headers
12679 if (ts_params->session_mpool == NULL) {
12680 ts_params->session_mpool =
12681 rte_cryptodev_sym_session_pool_create(
12683 MAX_NB_SESSIONS, 0, 0, 0,
12685 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
12686 "session mempool allocation failed");
12690 * Create mempool with maximum number of sessions,
12691 * to include device specific session private data
12693 if (ts_params->session_priv_mpool == NULL) {
12694 ts_params->session_priv_mpool = rte_mempool_create(
12695 "test_sess_mp_priv",
12698 0, 0, NULL, NULL, NULL,
12699 NULL, SOCKET_ID_ANY,
12702 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
12703 "session mempool allocation failed");
12706 ts_params->qp_conf.mp_session = ts_params->session_mpool;
12707 ts_params->qp_conf.mp_session_private =
12708 ts_params->session_priv_mpool;
12710 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
12713 TEST_ASSERT(ret == 0,
12714 "Failed to attach device %u of pmd : %s", i,
12715 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12717 aesni_ids[nb_devs_attached] = (uint8_t)i;
12719 nb_devs_attached++;
12726 test_scheduler_detach_slave_op(void)
12728 struct crypto_testsuite_params *ts_params = &testsuite_params;
12729 uint8_t sched_id = ts_params->valid_devs[0];
12733 for (i = 0; i < 2; i++) {
12734 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
12736 TEST_ASSERT(ret == 0,
12737 "Failed to detach device %u", aesni_ids[i]);
12744 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
12746 struct crypto_testsuite_params *ts_params = &testsuite_params;
12747 uint8_t sched_id = ts_params->valid_devs[0];
12749 return rte_cryptodev_scheduler_mode_set(sched_id,
12754 test_scheduler_mode_roundrobin_op(void)
12756 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
12757 0, "Failed to set roundrobin mode");
12763 test_scheduler_mode_multicore_op(void)
12765 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
12766 0, "Failed to set multicore mode");
12772 test_scheduler_mode_failover_op(void)
12774 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
12775 0, "Failed to set failover mode");
12781 test_scheduler_mode_pkt_size_distr_op(void)
12783 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
12784 0, "Failed to set pktsize mode");
12789 static struct unit_test_suite cryptodev_scheduler_testsuite = {
12790 .suite_name = "Crypto Device Scheduler Unit Test Suite",
12791 .setup = testsuite_setup,
12792 .teardown = testsuite_teardown,
12793 .unit_test_cases = {
12795 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12796 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
12797 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12798 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12799 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12800 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12803 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12804 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
12805 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12806 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12807 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12808 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12811 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12812 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
12813 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12814 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12815 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12816 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12819 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12820 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
12821 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12822 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12823 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12824 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12826 TEST_CASES_END() /**< NULL terminate unit test array */
12830 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
12832 static struct unit_test_suite cryptodev_testsuite = {
12833 .suite_name = "Crypto Unit Test Suite",
12834 .setup = testsuite_setup,
12835 .teardown = testsuite_teardown,
12836 .unit_test_cases = {
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_device_configure_invalid_dev_id),
12839 TEST_CASE_ST(ut_setup, ut_teardown,
12840 test_queue_pair_descriptor_setup),
12841 TEST_CASE_ST(ut_setup, ut_teardown,
12842 test_device_configure_invalid_queue_pair_ids),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_multi_session),
12846 TEST_CASE_ST(ut_setup, ut_teardown,
12847 test_multi_session_random_usage),
12849 TEST_CASE_ST(ut_setup, ut_teardown,
12850 test_null_invalid_operation),
12851 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
12853 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
12854 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
12855 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
12856 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
12857 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_cipheronly_all),
12858 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_all),
12859 TEST_CASE_ST(ut_setup, ut_teardown, test_DES_docsis_all),
12860 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
12861 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
12863 /** AES CCM Authenticated Encryption 128 bits key */
12864 TEST_CASE_ST(ut_setup, ut_teardown,
12865 test_AES_CCM_authenticated_encryption_test_case_128_1),
12866 TEST_CASE_ST(ut_setup, ut_teardown,
12867 test_AES_CCM_authenticated_encryption_test_case_128_2),
12868 TEST_CASE_ST(ut_setup, ut_teardown,
12869 test_AES_CCM_authenticated_encryption_test_case_128_3),
12871 /** AES CCM Authenticated Decryption 128 bits key*/
12872 TEST_CASE_ST(ut_setup, ut_teardown,
12873 test_AES_CCM_authenticated_decryption_test_case_128_1),
12874 TEST_CASE_ST(ut_setup, ut_teardown,
12875 test_AES_CCM_authenticated_decryption_test_case_128_2),
12876 TEST_CASE_ST(ut_setup, ut_teardown,
12877 test_AES_CCM_authenticated_decryption_test_case_128_3),
12879 /** AES CCM Authenticated Encryption 192 bits key */
12880 TEST_CASE_ST(ut_setup, ut_teardown,
12881 test_AES_CCM_authenticated_encryption_test_case_192_1),
12882 TEST_CASE_ST(ut_setup, ut_teardown,
12883 test_AES_CCM_authenticated_encryption_test_case_192_2),
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 test_AES_CCM_authenticated_encryption_test_case_192_3),
12887 /** AES CCM Authenticated Decryption 192 bits key*/
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_AES_CCM_authenticated_decryption_test_case_192_1),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_AES_CCM_authenticated_decryption_test_case_192_2),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_AES_CCM_authenticated_decryption_test_case_192_3),
12895 /** AES CCM Authenticated Encryption 256 bits key */
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_AES_CCM_authenticated_encryption_test_case_256_1),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_AES_CCM_authenticated_encryption_test_case_256_2),
12900 TEST_CASE_ST(ut_setup, ut_teardown,
12901 test_AES_CCM_authenticated_encryption_test_case_256_3),
12903 /** AES CCM Authenticated Decryption 256 bits key*/
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_AES_CCM_authenticated_decryption_test_case_256_1),
12906 TEST_CASE_ST(ut_setup, ut_teardown,
12907 test_AES_CCM_authenticated_decryption_test_case_256_2),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_AES_CCM_authenticated_decryption_test_case_256_3),
12911 /** AES GCM Authenticated Encryption */
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12916 TEST_CASE_ST(ut_setup, ut_teardown,
12917 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12920 TEST_CASE_ST(ut_setup, ut_teardown,
12921 test_AES_GCM_authenticated_encryption_test_case_1),
12922 TEST_CASE_ST(ut_setup, ut_teardown,
12923 test_AES_GCM_authenticated_encryption_test_case_2),
12924 TEST_CASE_ST(ut_setup, ut_teardown,
12925 test_AES_GCM_authenticated_encryption_test_case_3),
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 test_AES_GCM_authenticated_encryption_test_case_4),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 test_AES_GCM_authenticated_encryption_test_case_5),
12930 TEST_CASE_ST(ut_setup, ut_teardown,
12931 test_AES_GCM_authenticated_encryption_test_case_6),
12932 TEST_CASE_ST(ut_setup, ut_teardown,
12933 test_AES_GCM_authenticated_encryption_test_case_7),
12934 TEST_CASE_ST(ut_setup, ut_teardown,
12935 test_AES_GCM_authenticated_encryption_test_case_8),
12936 TEST_CASE_ST(ut_setup, ut_teardown,
12937 test_AES_GCM_J0_authenticated_encryption_test_case_1),
12939 /** AES GCM Authenticated Decryption */
12940 TEST_CASE_ST(ut_setup, ut_teardown,
12941 test_AES_GCM_authenticated_decryption_test_case_1),
12942 TEST_CASE_ST(ut_setup, ut_teardown,
12943 test_AES_GCM_authenticated_decryption_test_case_2),
12944 TEST_CASE_ST(ut_setup, ut_teardown,
12945 test_AES_GCM_authenticated_decryption_test_case_3),
12946 TEST_CASE_ST(ut_setup, ut_teardown,
12947 test_AES_GCM_authenticated_decryption_test_case_4),
12948 TEST_CASE_ST(ut_setup, ut_teardown,
12949 test_AES_GCM_authenticated_decryption_test_case_5),
12950 TEST_CASE_ST(ut_setup, ut_teardown,
12951 test_AES_GCM_authenticated_decryption_test_case_6),
12952 TEST_CASE_ST(ut_setup, ut_teardown,
12953 test_AES_GCM_authenticated_decryption_test_case_7),
12954 TEST_CASE_ST(ut_setup, ut_teardown,
12955 test_AES_GCM_authenticated_decryption_test_case_8),
12956 TEST_CASE_ST(ut_setup, ut_teardown,
12957 test_AES_GCM_J0_authenticated_decryption_test_case_1),
12959 /** AES GCM Authenticated Encryption 192 bits key */
12960 TEST_CASE_ST(ut_setup, ut_teardown,
12961 test_AES_GCM_auth_encryption_test_case_192_1),
12962 TEST_CASE_ST(ut_setup, ut_teardown,
12963 test_AES_GCM_auth_encryption_test_case_192_2),
12964 TEST_CASE_ST(ut_setup, ut_teardown,
12965 test_AES_GCM_auth_encryption_test_case_192_3),
12966 TEST_CASE_ST(ut_setup, ut_teardown,
12967 test_AES_GCM_auth_encryption_test_case_192_4),
12968 TEST_CASE_ST(ut_setup, ut_teardown,
12969 test_AES_GCM_auth_encryption_test_case_192_5),
12970 TEST_CASE_ST(ut_setup, ut_teardown,
12971 test_AES_GCM_auth_encryption_test_case_192_6),
12972 TEST_CASE_ST(ut_setup, ut_teardown,
12973 test_AES_GCM_auth_encryption_test_case_192_7),
12975 /** AES GCM Authenticated Decryption 192 bits key */
12976 TEST_CASE_ST(ut_setup, ut_teardown,
12977 test_AES_GCM_auth_decryption_test_case_192_1),
12978 TEST_CASE_ST(ut_setup, ut_teardown,
12979 test_AES_GCM_auth_decryption_test_case_192_2),
12980 TEST_CASE_ST(ut_setup, ut_teardown,
12981 test_AES_GCM_auth_decryption_test_case_192_3),
12982 TEST_CASE_ST(ut_setup, ut_teardown,
12983 test_AES_GCM_auth_decryption_test_case_192_4),
12984 TEST_CASE_ST(ut_setup, ut_teardown,
12985 test_AES_GCM_auth_decryption_test_case_192_5),
12986 TEST_CASE_ST(ut_setup, ut_teardown,
12987 test_AES_GCM_auth_decryption_test_case_192_6),
12988 TEST_CASE_ST(ut_setup, ut_teardown,
12989 test_AES_GCM_auth_decryption_test_case_192_7),
12991 /** AES GCM Authenticated Encryption 256 bits key */
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 test_AES_GCM_auth_encryption_test_case_256_1),
12994 TEST_CASE_ST(ut_setup, ut_teardown,
12995 test_AES_GCM_auth_encryption_test_case_256_2),
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_AES_GCM_auth_encryption_test_case_256_3),
12998 TEST_CASE_ST(ut_setup, ut_teardown,
12999 test_AES_GCM_auth_encryption_test_case_256_4),
13000 TEST_CASE_ST(ut_setup, ut_teardown,
13001 test_AES_GCM_auth_encryption_test_case_256_5),
13002 TEST_CASE_ST(ut_setup, ut_teardown,
13003 test_AES_GCM_auth_encryption_test_case_256_6),
13004 TEST_CASE_ST(ut_setup, ut_teardown,
13005 test_AES_GCM_auth_encryption_test_case_256_7),
13007 /** AES GCM Authenticated Decryption 256 bits key */
13008 TEST_CASE_ST(ut_setup, ut_teardown,
13009 test_AES_GCM_auth_decryption_test_case_256_1),
13010 TEST_CASE_ST(ut_setup, ut_teardown,
13011 test_AES_GCM_auth_decryption_test_case_256_2),
13012 TEST_CASE_ST(ut_setup, ut_teardown,
13013 test_AES_GCM_auth_decryption_test_case_256_3),
13014 TEST_CASE_ST(ut_setup, ut_teardown,
13015 test_AES_GCM_auth_decryption_test_case_256_4),
13016 TEST_CASE_ST(ut_setup, ut_teardown,
13017 test_AES_GCM_auth_decryption_test_case_256_5),
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 test_AES_GCM_auth_decryption_test_case_256_6),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 test_AES_GCM_auth_decryption_test_case_256_7),
13023 /** AES GCM Authenticated Encryption big aad size */
13024 TEST_CASE_ST(ut_setup, ut_teardown,
13025 test_AES_GCM_auth_encryption_test_case_aad_1),
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 test_AES_GCM_auth_encryption_test_case_aad_2),
13029 /** AES GCM Authenticated Decryption big aad size */
13030 TEST_CASE_ST(ut_setup, ut_teardown,
13031 test_AES_GCM_auth_decryption_test_case_aad_1),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 test_AES_GCM_auth_decryption_test_case_aad_2),
13035 /** Out of place tests */
13036 TEST_CASE_ST(ut_setup, ut_teardown,
13037 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13038 TEST_CASE_ST(ut_setup, ut_teardown,
13039 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13041 /** Session-less tests */
13042 TEST_CASE_ST(ut_setup, ut_teardown,
13043 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13044 TEST_CASE_ST(ut_setup, ut_teardown,
13045 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13047 /** AES GMAC Authentication */
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_AES_GMAC_authentication_test_case_1),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_AES_GMAC_authentication_verify_test_case_1),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_AES_GMAC_authentication_test_case_2),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_AES_GMAC_authentication_verify_test_case_2),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_AES_GMAC_authentication_test_case_3),
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_AES_GMAC_authentication_verify_test_case_3),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_AES_GMAC_authentication_test_case_4),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_AES_GMAC_authentication_verify_test_case_4),
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_AES_GMAC_authentication_SGL_40B),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_AES_GMAC_authentication_SGL_80B),
13068 TEST_CASE_ST(ut_setup, ut_teardown,
13069 test_AES_GMAC_authentication_SGL_2048B),
13070 TEST_CASE_ST(ut_setup, ut_teardown,
13071 test_AES_GMAC_authentication_SGL_2047B),
13073 /** Chacha20-Poly1305 */
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_chacha20_poly1305_encrypt_test_case_rfc8439),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_chacha20_poly1305_decrypt_test_case_rfc8439),
13078 /** SNOW 3G encrypt only (UEA2) */
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_snow3g_encryption_test_case_1),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_snow3g_encryption_test_case_2),
13083 TEST_CASE_ST(ut_setup, ut_teardown,
13084 test_snow3g_encryption_test_case_3),
13085 TEST_CASE_ST(ut_setup, ut_teardown,
13086 test_snow3g_encryption_test_case_4),
13087 TEST_CASE_ST(ut_setup, ut_teardown,
13088 test_snow3g_encryption_test_case_5),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_snow3g_encryption_test_case_1_oop),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_snow3g_encryption_test_case_1_oop_sgl),
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_snow3g_encryption_test_case_1_offset_oop),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_snow3g_decryption_test_case_1_oop),
13099 /** SNOW 3G generate auth, then encrypt (UEA2) */
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_snow3g_auth_cipher_test_case_1),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_snow3g_auth_cipher_test_case_2),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_snow3g_auth_cipher_test_case_2_oop),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_snow3g_auth_cipher_part_digest_enc),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_snow3g_auth_cipher_part_digest_enc_oop),
13110 TEST_CASE_ST(ut_setup, ut_teardown,
13111 test_snow3g_auth_cipher_test_case_3_sgl),
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_snow3g_auth_cipher_part_digest_enc_sgl),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13119 /** SNOW 3G decrypt (UEA2), then verify auth */
13120 TEST_CASE_ST(ut_setup, ut_teardown,
13121 test_snow3g_auth_cipher_verify_test_case_1),
13122 TEST_CASE_ST(ut_setup, ut_teardown,
13123 test_snow3g_auth_cipher_verify_test_case_2),
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 test_snow3g_auth_cipher_verify_test_case_2_oop),
13126 TEST_CASE_ST(ut_setup, ut_teardown,
13127 test_snow3g_auth_cipher_verify_part_digest_enc),
13128 TEST_CASE_ST(ut_setup, ut_teardown,
13129 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13132 TEST_CASE_ST(ut_setup, ut_teardown,
13133 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13136 TEST_CASE_ST(ut_setup, ut_teardown,
13137 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13139 /** SNOW 3G decrypt only (UEA2) */
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_snow3g_decryption_test_case_1),
13142 TEST_CASE_ST(ut_setup, ut_teardown,
13143 test_snow3g_decryption_test_case_2),
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_snow3g_decryption_test_case_3),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 test_snow3g_decryption_test_case_4),
13148 TEST_CASE_ST(ut_setup, ut_teardown,
13149 test_snow3g_decryption_test_case_5),
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 test_snow3g_decryption_with_digest_test_case_1),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 test_snow3g_hash_generate_test_case_1),
13154 TEST_CASE_ST(ut_setup, ut_teardown,
13155 test_snow3g_hash_generate_test_case_2),
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_snow3g_hash_generate_test_case_3),
13158 /* Tests with buffers which length is not byte-aligned */
13159 TEST_CASE_ST(ut_setup, ut_teardown,
13160 test_snow3g_hash_generate_test_case_4),
13161 TEST_CASE_ST(ut_setup, ut_teardown,
13162 test_snow3g_hash_generate_test_case_5),
13163 TEST_CASE_ST(ut_setup, ut_teardown,
13164 test_snow3g_hash_generate_test_case_6),
13165 TEST_CASE_ST(ut_setup, ut_teardown,
13166 test_snow3g_hash_verify_test_case_1),
13167 TEST_CASE_ST(ut_setup, ut_teardown,
13168 test_snow3g_hash_verify_test_case_2),
13169 TEST_CASE_ST(ut_setup, ut_teardown,
13170 test_snow3g_hash_verify_test_case_3),
13171 /* Tests with buffers which length is not byte-aligned */
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_snow3g_hash_verify_test_case_4),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_snow3g_hash_verify_test_case_5),
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_snow3g_hash_verify_test_case_6),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_snow3g_cipher_auth_test_case_1),
13180 TEST_CASE_ST(ut_setup, ut_teardown,
13181 test_snow3g_auth_cipher_with_digest_test_case_1),
13183 /** ZUC encrypt only (EEA3) */
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_zuc_encryption_test_case_1),
13186 TEST_CASE_ST(ut_setup, ut_teardown,
13187 test_zuc_encryption_test_case_2),
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_zuc_encryption_test_case_3),
13190 TEST_CASE_ST(ut_setup, ut_teardown,
13191 test_zuc_encryption_test_case_4),
13192 TEST_CASE_ST(ut_setup, ut_teardown,
13193 test_zuc_encryption_test_case_5),
13194 TEST_CASE_ST(ut_setup, ut_teardown,
13195 test_zuc_encryption_test_case_6_sgl),
13197 /** ZUC authenticate (EIA3) */
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 test_zuc_hash_generate_test_case_1),
13200 TEST_CASE_ST(ut_setup, ut_teardown,
13201 test_zuc_hash_generate_test_case_2),
13202 TEST_CASE_ST(ut_setup, ut_teardown,
13203 test_zuc_hash_generate_test_case_3),
13204 TEST_CASE_ST(ut_setup, ut_teardown,
13205 test_zuc_hash_generate_test_case_4),
13206 TEST_CASE_ST(ut_setup, ut_teardown,
13207 test_zuc_hash_generate_test_case_5),
13208 TEST_CASE_ST(ut_setup, ut_teardown,
13209 test_zuc_hash_generate_test_case_6),
13210 TEST_CASE_ST(ut_setup, ut_teardown,
13211 test_zuc_hash_generate_test_case_7),
13212 TEST_CASE_ST(ut_setup, ut_teardown,
13213 test_zuc_hash_generate_test_case_8),
13215 /** ZUC alg-chain (EEA3/EIA3) */
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 test_zuc_cipher_auth_test_case_1),
13218 TEST_CASE_ST(ut_setup, ut_teardown,
13219 test_zuc_cipher_auth_test_case_2),
13221 /** ZUC generate auth, then encrypt (EEA3) */
13222 TEST_CASE_ST(ut_setup, ut_teardown,
13223 test_zuc_auth_cipher_test_case_1),
13224 TEST_CASE_ST(ut_setup, ut_teardown,
13225 test_zuc_auth_cipher_test_case_1_oop),
13226 TEST_CASE_ST(ut_setup, ut_teardown,
13227 test_zuc_auth_cipher_test_case_1_sgl),
13228 TEST_CASE_ST(ut_setup, ut_teardown,
13229 test_zuc_auth_cipher_test_case_1_oop_sgl),
13231 /** ZUC decrypt (EEA3), then verify auth */
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_zuc_auth_cipher_verify_test_case_1),
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_zuc_auth_cipher_verify_test_case_1_oop),
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_zuc_auth_cipher_verify_test_case_1_sgl),
13238 TEST_CASE_ST(ut_setup, ut_teardown,
13239 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
13241 /** HMAC_MD5 Authentication */
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_MD5_HMAC_generate_case_1),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_MD5_HMAC_verify_case_1),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_MD5_HMAC_generate_case_2),
13248 TEST_CASE_ST(ut_setup, ut_teardown,
13249 test_MD5_HMAC_verify_case_2),
13251 /** KASUMI hash only (UIA1) */
13252 TEST_CASE_ST(ut_setup, ut_teardown,
13253 test_kasumi_hash_generate_test_case_1),
13254 TEST_CASE_ST(ut_setup, ut_teardown,
13255 test_kasumi_hash_generate_test_case_2),
13256 TEST_CASE_ST(ut_setup, ut_teardown,
13257 test_kasumi_hash_generate_test_case_3),
13258 TEST_CASE_ST(ut_setup, ut_teardown,
13259 test_kasumi_hash_generate_test_case_4),
13260 TEST_CASE_ST(ut_setup, ut_teardown,
13261 test_kasumi_hash_generate_test_case_5),
13262 TEST_CASE_ST(ut_setup, ut_teardown,
13263 test_kasumi_hash_generate_test_case_6),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_kasumi_hash_verify_test_case_1),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_kasumi_hash_verify_test_case_2),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_kasumi_hash_verify_test_case_3),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_kasumi_hash_verify_test_case_4),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_kasumi_hash_verify_test_case_5),
13276 /** KASUMI encrypt only (UEA1) */
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_kasumi_encryption_test_case_1),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_kasumi_encryption_test_case_1_sgl),
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_kasumi_encryption_test_case_1_oop),
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_kasumi_encryption_test_case_1_oop_sgl),
13285 TEST_CASE_ST(ut_setup, ut_teardown,
13286 test_kasumi_encryption_test_case_2),
13287 TEST_CASE_ST(ut_setup, ut_teardown,
13288 test_kasumi_encryption_test_case_3),
13289 TEST_CASE_ST(ut_setup, ut_teardown,
13290 test_kasumi_encryption_test_case_4),
13291 TEST_CASE_ST(ut_setup, ut_teardown,
13292 test_kasumi_encryption_test_case_5),
13294 /** KASUMI decrypt only (UEA1) */
13295 TEST_CASE_ST(ut_setup, ut_teardown,
13296 test_kasumi_decryption_test_case_1),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_kasumi_decryption_test_case_2),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_kasumi_decryption_test_case_3),
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_kasumi_decryption_test_case_4),
13303 TEST_CASE_ST(ut_setup, ut_teardown,
13304 test_kasumi_decryption_test_case_5),
13305 TEST_CASE_ST(ut_setup, ut_teardown,
13306 test_kasumi_decryption_test_case_1_oop),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_kasumi_cipher_auth_test_case_1),
13311 /** KASUMI generate auth, then encrypt (F8) */
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 test_kasumi_auth_cipher_test_case_1),
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 test_kasumi_auth_cipher_test_case_2),
13316 TEST_CASE_ST(ut_setup, ut_teardown,
13317 test_kasumi_auth_cipher_test_case_2_oop),
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_kasumi_auth_cipher_test_case_2_sgl),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13323 /** KASUMI decrypt (F8), then verify auth */
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_kasumi_auth_cipher_verify_test_case_1),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_kasumi_auth_cipher_verify_test_case_2),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_kasumi_auth_cipher_verify_test_case_2_oop),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13335 /** ESN Testcase */
13336 TEST_CASE_ST(ut_setup, ut_teardown,
13337 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13338 TEST_CASE_ST(ut_setup, ut_teardown,
13339 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13341 /** Negative tests */
13342 TEST_CASE_ST(ut_setup, ut_teardown,
13343 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13344 TEST_CASE_ST(ut_setup, ut_teardown,
13345 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13346 TEST_CASE_ST(ut_setup, ut_teardown,
13347 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13348 TEST_CASE_ST(ut_setup, ut_teardown,
13349 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13358 TEST_CASE_ST(ut_setup, ut_teardown,
13359 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13360 TEST_CASE_ST(ut_setup, ut_teardown,
13361 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 authentication_verify_AES128_GMAC_fail_data_corrupt),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13379 /** Mixed CIPHER + HASH algorithms */
13380 /** AUTH AES CMAC + CIPHER AES CTR */
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
13393 TEST_CASE_ST(ut_setup, ut_teardown,
13394 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
13395 TEST_CASE_ST(ut_setup, ut_teardown,
13396 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
13398 /** AUTH ZUC + CIPHER SNOW3G */
13399 TEST_CASE_ST(ut_setup, ut_teardown,
13400 test_auth_zuc_cipher_snow_test_case_1),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_verify_auth_zuc_cipher_snow_test_case_1),
13403 /** AUTH AES CMAC + CIPHER SNOW3G */
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_auth_aes_cmac_cipher_snow_test_case_1),
13406 TEST_CASE_ST(ut_setup, ut_teardown,
13407 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
13408 /** AUTH ZUC + CIPHER AES CTR */
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_auth_zuc_cipher_aes_ctr_test_case_1),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
13413 /** AUTH SNOW3G + CIPHER AES CTR */
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_auth_snow_cipher_aes_ctr_test_case_1),
13416 TEST_CASE_ST(ut_setup, ut_teardown,
13417 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
13418 /** AUTH SNOW3G + CIPHER ZUC */
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 test_auth_snow_cipher_zuc_test_case_1),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 test_verify_auth_snow_cipher_zuc_test_case_1),
13423 /** AUTH AES CMAC + CIPHER ZUC */
13424 TEST_CASE_ST(ut_setup, ut_teardown,
13425 test_auth_aes_cmac_cipher_zuc_test_case_1),
13426 TEST_CASE_ST(ut_setup, ut_teardown,
13427 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
13429 /** AUTH NULL + CIPHER SNOW3G */
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_auth_null_cipher_snow_test_case_1),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_verify_auth_null_cipher_snow_test_case_1),
13434 /** AUTH NULL + CIPHER ZUC */
13435 TEST_CASE_ST(ut_setup, ut_teardown,
13436 test_auth_null_cipher_zuc_test_case_1),
13437 TEST_CASE_ST(ut_setup, ut_teardown,
13438 test_verify_auth_null_cipher_zuc_test_case_1),
13439 /** AUTH SNOW3G + CIPHER NULL */
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 test_auth_snow_cipher_null_test_case_1),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 test_verify_auth_snow_cipher_null_test_case_1),
13444 /** AUTH ZUC + CIPHER NULL */
13445 TEST_CASE_ST(ut_setup, ut_teardown,
13446 test_auth_zuc_cipher_null_test_case_1),
13447 TEST_CASE_ST(ut_setup, ut_teardown,
13448 test_verify_auth_zuc_cipher_null_test_case_1),
13449 /** AUTH NULL + CIPHER AES CTR */
13450 TEST_CASE_ST(ut_setup, ut_teardown,
13451 test_auth_null_cipher_aes_ctr_test_case_1),
13452 TEST_CASE_ST(ut_setup, ut_teardown,
13453 test_verify_auth_null_cipher_aes_ctr_test_case_1),
13454 /** AUTH AES CMAC + CIPHER NULL */
13455 TEST_CASE_ST(ut_setup, ut_teardown,
13456 test_auth_aes_cmac_cipher_null_test_case_1),
13457 TEST_CASE_ST(ut_setup, ut_teardown,
13458 test_verify_auth_aes_cmac_cipher_null_test_case_1),
13460 #ifdef RTE_LIBRTE_SECURITY
13461 TEST_CASE_ST(ut_setup_security, ut_teardown,
13462 test_PDCP_PROTO_all),
13463 TEST_CASE_ST(ut_setup_security, ut_teardown,
13464 test_DOCSIS_PROTO_all),
13466 TEST_CASES_END() /**< NULL terminate unit test array */
13470 static struct unit_test_suite cryptodev_virtio_testsuite = {
13471 .suite_name = "Crypto VIRTIO Unit Test Suite",
13472 .setup = testsuite_setup,
13473 .teardown = testsuite_teardown,
13474 .unit_test_cases = {
13475 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13477 TEST_CASES_END() /**< NULL terminate unit test array */
13481 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13482 .suite_name = "Crypto CAAM JR Unit Test Suite",
13483 .setup = testsuite_setup,
13484 .teardown = testsuite_teardown,
13485 .unit_test_cases = {
13486 TEST_CASE_ST(ut_setup, ut_teardown,
13487 test_device_configure_invalid_dev_id),
13488 TEST_CASE_ST(ut_setup, ut_teardown,
13489 test_multi_session),
13491 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13492 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13493 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13494 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13495 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13497 TEST_CASES_END() /**< NULL terminate unit test array */
13501 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13502 .suite_name = "Crypto Device Marvell Component Test Suite",
13503 .setup = testsuite_setup,
13504 .teardown = testsuite_teardown,
13505 .unit_test_cases = {
13506 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13507 TEST_CASE_ST(ut_setup, ut_teardown,
13508 test_multi_session_random_usage),
13509 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13510 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13511 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13512 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13513 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13515 /** Negative tests */
13516 TEST_CASE_ST(ut_setup, ut_teardown,
13517 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13518 TEST_CASE_ST(ut_setup, ut_teardown,
13519 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13520 TEST_CASE_ST(ut_setup, ut_teardown,
13521 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13522 TEST_CASE_ST(ut_setup, ut_teardown,
13523 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13525 TEST_CASES_END() /**< NULL terminate unit test array */
13529 static struct unit_test_suite cryptodev_ccp_testsuite = {
13530 .suite_name = "Crypto Device CCP Unit Test Suite",
13531 .setup = testsuite_setup,
13532 .teardown = testsuite_teardown,
13533 .unit_test_cases = {
13534 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13535 TEST_CASE_ST(ut_setup, ut_teardown,
13536 test_multi_session_random_usage),
13537 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_all),
13538 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_all),
13539 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_all),
13540 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_cipheronly_all),
13541 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_all),
13543 /** Negative tests */
13544 TEST_CASE_ST(ut_setup, ut_teardown,
13545 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13546 TEST_CASE_ST(ut_setup, ut_teardown,
13547 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13548 TEST_CASE_ST(ut_setup, ut_teardown,
13549 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13550 TEST_CASE_ST(ut_setup, ut_teardown,
13551 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13553 TEST_CASES_END() /**< NULL terminate unit test array */
13558 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
13560 gbl_driver_id = rte_cryptodev_driver_id_get(
13561 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13563 if (gbl_driver_id == -1) {
13564 RTE_LOG(ERR, USER1, "QAT PMD must be loaded.\n");
13565 return TEST_SKIPPED;
13568 return unit_test_suite_runner(&cryptodev_testsuite);
13572 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
13574 gbl_driver_id = rte_cryptodev_driver_id_get(
13575 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
13577 if (gbl_driver_id == -1) {
13578 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded.\n");
13579 return TEST_FAILED;
13582 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
13586 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
13588 gbl_driver_id = rte_cryptodev_driver_id_get(
13589 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13591 if (gbl_driver_id == -1) {
13592 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13593 return TEST_SKIPPED;
13596 return unit_test_suite_runner(&cryptodev_testsuite);
13600 test_cryptodev_cpu_aesni_mb(void)
13603 enum rte_security_session_action_type at;
13605 gbl_driver_id = rte_cryptodev_driver_id_get(
13606 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13608 if (gbl_driver_id == -1) {
13609 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13610 return TEST_SKIPPED;
13613 at = gbl_action_type;
13614 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13615 rc = unit_test_suite_runner(&cryptodev_testsuite);
13616 gbl_action_type = at;
13621 test_cryptodev_openssl(void)
13623 gbl_driver_id = rte_cryptodev_driver_id_get(
13624 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
13626 if (gbl_driver_id == -1) {
13627 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded.\n");
13628 return TEST_SKIPPED;
13631 return unit_test_suite_runner(&cryptodev_testsuite);
13635 test_cryptodev_aesni_gcm(void)
13637 gbl_driver_id = rte_cryptodev_driver_id_get(
13638 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13640 if (gbl_driver_id == -1) {
13641 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
13642 return TEST_SKIPPED;
13645 return unit_test_suite_runner(&cryptodev_testsuite);
13649 test_cryptodev_cpu_aesni_gcm(void)
13652 enum rte_security_session_action_type at;
13654 gbl_driver_id = rte_cryptodev_driver_id_get(
13655 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
13657 if (gbl_driver_id == -1) {
13658 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded.\n");
13659 return TEST_SKIPPED;
13662 at = gbl_action_type;
13663 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
13664 rc = unit_test_suite_runner(&cryptodev_testsuite);
13665 gbl_action_type = at;
13670 test_cryptodev_null(void)
13672 gbl_driver_id = rte_cryptodev_driver_id_get(
13673 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
13675 if (gbl_driver_id == -1) {
13676 RTE_LOG(ERR, USER1, "NULL PMD must be loaded.\n");
13677 return TEST_SKIPPED;
13680 return unit_test_suite_runner(&cryptodev_testsuite);
13684 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
13686 gbl_driver_id = rte_cryptodev_driver_id_get(
13687 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
13689 if (gbl_driver_id == -1) {
13690 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded.\n");
13691 return TEST_SKIPPED;
13694 return unit_test_suite_runner(&cryptodev_testsuite);
13698 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
13700 gbl_driver_id = rte_cryptodev_driver_id_get(
13701 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
13703 if (gbl_driver_id == -1) {
13704 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
13705 return TEST_SKIPPED;
13708 return unit_test_suite_runner(&cryptodev_testsuite);
13712 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
13714 gbl_driver_id = rte_cryptodev_driver_id_get(
13715 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
13717 if (gbl_driver_id == -1) {
13718 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded.\n");
13719 return TEST_SKIPPED;
13722 return unit_test_suite_runner(&cryptodev_testsuite);
13726 test_cryptodev_armv8(void)
13728 gbl_driver_id = rte_cryptodev_driver_id_get(
13729 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
13731 if (gbl_driver_id == -1) {
13732 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded.\n");
13733 return TEST_SKIPPED;
13736 return unit_test_suite_runner(&cryptodev_testsuite);
13740 test_cryptodev_mrvl(void)
13742 gbl_driver_id = rte_cryptodev_driver_id_get(
13743 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
13745 if (gbl_driver_id == -1) {
13746 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded.\n");
13747 return TEST_SKIPPED;
13750 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
13753 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
13756 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
13758 gbl_driver_id = rte_cryptodev_driver_id_get(
13759 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13761 if (gbl_driver_id == -1) {
13762 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
13763 return TEST_SKIPPED;
13766 if (rte_cryptodev_driver_id_get(
13767 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
13768 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
13769 return TEST_SKIPPED;
13771 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
13774 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
13779 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13781 gbl_driver_id = rte_cryptodev_driver_id_get(
13782 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
13784 if (gbl_driver_id == -1) {
13785 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded.\n");
13786 return TEST_SKIPPED;
13789 return unit_test_suite_runner(&cryptodev_testsuite);
13793 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
13795 gbl_driver_id = rte_cryptodev_driver_id_get(
13796 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
13798 if (gbl_driver_id == -1) {
13799 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded.\n");
13800 return TEST_SKIPPED;
13803 return unit_test_suite_runner(&cryptodev_testsuite);
13807 test_cryptodev_ccp(void)
13809 gbl_driver_id = rte_cryptodev_driver_id_get(
13810 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
13812 if (gbl_driver_id == -1) {
13813 RTE_LOG(ERR, USER1, "CCP PMD must be loaded.\n");
13814 return TEST_FAILED;
13817 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
13821 test_cryptodev_octeontx(void)
13823 gbl_driver_id = rte_cryptodev_driver_id_get(
13824 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
13825 if (gbl_driver_id == -1) {
13826 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded.\n");
13827 return TEST_FAILED;
13829 return unit_test_suite_runner(&cryptodev_testsuite);
13833 test_cryptodev_octeontx2(void)
13835 gbl_driver_id = rte_cryptodev_driver_id_get(
13836 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
13837 if (gbl_driver_id == -1) {
13838 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded.\n");
13839 return TEST_FAILED;
13841 return unit_test_suite_runner(&cryptodev_testsuite);
13845 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
13847 gbl_driver_id = rte_cryptodev_driver_id_get(
13848 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13850 if (gbl_driver_id == -1) {
13851 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded.\n");
13852 return TEST_FAILED;
13855 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13859 test_cryptodev_nitrox(void)
13861 gbl_driver_id = rte_cryptodev_driver_id_get(
13862 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13864 if (gbl_driver_id == -1) {
13865 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded.\n");
13866 return TEST_FAILED;
13869 return unit_test_suite_runner(&cryptodev_testsuite);
13873 test_cryptodev_bcmfs(void)
13875 gbl_driver_id = rte_cryptodev_driver_id_get(
13876 RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
13878 if (gbl_driver_id == -1) {
13879 RTE_LOG(ERR, USER1, "BCMFS PMD must be loaded.\n");
13880 return TEST_FAILED;
13883 return unit_test_suite_runner(&cryptodev_testsuite);
13887 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
13891 gbl_driver_id = rte_cryptodev_driver_id_get(
13892 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
13894 if (gbl_driver_id == -1) {
13895 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
13896 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
13897 "are enabled in config file to run this testsuite.\n");
13898 return TEST_SKIPPED;
13901 global_api_test_type = CRYPTODEV_RAW_API_TEST;
13902 ret = unit_test_suite_runner(&cryptodev_testsuite);
13903 global_api_test_type = CRYPTODEV_API_TEST;
13908 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
13909 test_cryptodev_qat_raw_api);
13910 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13911 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13912 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
13913 test_cryptodev_cpu_aesni_mb);
13914 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13915 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13916 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
13917 test_cryptodev_cpu_aesni_gcm);
13918 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13919 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13920 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13921 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13922 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13923 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13924 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13925 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13926 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13927 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13928 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13929 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
13930 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13931 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
13932 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);