1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
20 #include <rte_string_fns.h>
24 #ifdef RTE_CRYPTO_SCHEDULER
25 #include <rte_cryptodev_scheduler.h>
26 #include <rte_cryptodev_scheduler_operations.h>
29 #include <rte_lcore.h>
32 #include "test_cryptodev.h"
34 #include "test_cryptodev_blockcipher.h"
35 #include "test_cryptodev_aes_test_vectors.h"
36 #include "test_cryptodev_des_test_vectors.h"
37 #include "test_cryptodev_hash_test_vectors.h"
38 #include "test_cryptodev_kasumi_test_vectors.h"
39 #include "test_cryptodev_kasumi_hash_test_vectors.h"
40 #include "test_cryptodev_snow3g_test_vectors.h"
41 #include "test_cryptodev_snow3g_hash_test_vectors.h"
42 #include "test_cryptodev_zuc_test_vectors.h"
43 #include "test_cryptodev_aead_test_vectors.h"
44 #include "test_cryptodev_hmac_test_vectors.h"
45 #include "test_cryptodev_mixed_test_vectors.h"
46 #ifdef RTE_LIB_SECURITY
47 #include "test_cryptodev_security_ipsec.h"
48 #include "test_cryptodev_security_ipsec_test_vectors.h"
49 #include "test_cryptodev_security_pdcp_test_vectors.h"
50 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_func.h"
52 #include "test_cryptodev_security_docsis_test_vectors.h"
54 #define SDAP_DISABLED 0
55 #define SDAP_ENABLED 1
58 #define VDEV_ARGS_SIZE 100
59 #define MAX_NB_SESSIONS 4
61 #define MAX_DRV_SERVICE_CTX_SIZE 256
63 #define MAX_RAW_DEQUEUE_COUNT 65535
66 #define OUT_OF_PLACE 1
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_unittest_params {
76 struct rte_crypto_sym_xform cipher_xform;
77 struct rte_crypto_sym_xform auth_xform;
78 struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 struct rte_security_docsis_xform docsis_xform;
84 struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 struct rte_security_session *sec_session;
89 #ifdef RTE_LIB_SECURITY
90 enum rte_security_session_action_type type;
92 struct rte_crypto_op *op;
94 struct rte_mbuf *obuf, *ibuf;
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 (((num) + (align) - 1) & ~((align) - 1))
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
103 for (j = 0; j < num_child_ts; index++, j++) \
104 parent_ts.unit_test_suites[index] = child_ts[j]
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
107 for (j = 0; j < num_blk_types; index++, j++) \
108 parent_ts.unit_test_suites[index] = \
109 build_blockcipher_test_suite(blk_types[j])
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
112 for (j = index; j < index + num_blk_types; j++) \
113 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
132 security_proto_supported(enum rte_security_session_action_type action,
133 enum rte_security_session_protocol proto);
136 dev_configure_and_start(uint64_t ff_disable);
138 static struct rte_mbuf *
139 setup_test_string(struct rte_mempool *mpool,
140 const char *string, size_t len, uint8_t blocksize)
142 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
143 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
148 memset(m->buf_addr, 0, m->buf_len);
149 dst = rte_pktmbuf_append(m, t_len);
155 rte_memcpy(dst, string, t_len);
157 memset(dst, 0, t_len);
163 /* Get number of bytes in X bits (rounding up) */
165 ceil_byte_length(uint32_t num_bits)
168 return ((num_bits >> 3) + 1);
170 return (num_bits >> 3);
174 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
175 uint8_t is_op_success)
177 struct rte_crypto_op *op = user_data;
178 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
179 RTE_CRYPTO_OP_STATUS_ERROR;
182 static struct crypto_testsuite_params testsuite_params = { NULL };
183 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
184 static struct crypto_unittest_params unittest_params;
187 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
188 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
189 uint8_t len_in_bits, uint8_t cipher_iv_len)
191 struct rte_crypto_sym_op *sop = op->sym;
192 struct rte_crypto_op *ret_op = NULL;
193 struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
194 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
195 union rte_crypto_sym_ofs ofs;
196 struct rte_crypto_sym_vec vec;
197 struct rte_crypto_sgl sgl, dest_sgl;
199 union rte_cryptodev_session_ctx sess;
200 uint64_t auth_end_iova;
202 struct rte_crypto_raw_dp_ctx *ctx;
203 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
207 int ctx_service_size;
209 int enqueue_status, dequeue_status;
210 struct crypto_unittest_params *ut_params = &unittest_params;
211 int is_sgl = sop->m_src->nb_segs > 1;
214 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
215 if (ctx_service_size < 0) {
216 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
220 ctx = malloc(ctx_service_size);
222 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
226 /* Both are enums, setting crypto_sess will suit any session type */
227 sess.crypto_sess = op->sym->session;
229 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
230 op->sess_type, sess, 0) < 0) {
231 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
237 aad_auth_iv.iova = 0;
238 aad_auth_iv.va = NULL;
245 vec.digest = &digest;
246 vec.aad = &aad_auth_iv;
247 vec.status = &status;
251 if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
254 if (is_cipher && is_auth) {
255 cipher_offset = sop->cipher.data.offset;
256 cipher_len = sop->cipher.data.length;
257 auth_offset = sop->auth.data.offset;
258 auth_len = sop->auth.data.length;
259 max_len = RTE_MAX(cipher_offset + cipher_len,
260 auth_offset + auth_len);
262 max_len = max_len >> 3;
263 cipher_offset = cipher_offset >> 3;
264 auth_offset = auth_offset >> 3;
265 cipher_len = cipher_len >> 3;
266 auth_len = auth_len >> 3;
268 ofs.ofs.cipher.head = cipher_offset;
269 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
270 ofs.ofs.auth.head = auth_offset;
271 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
272 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
273 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
274 aad_auth_iv.va = rte_crypto_op_ctod_offset(
275 op, void *, IV_OFFSET + cipher_iv_len);
276 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
278 digest.va = (void *)sop->auth.digest.data;
279 digest.iova = sop->auth.digest.phys_addr;
282 uint32_t remaining_off = auth_offset + auth_len;
283 struct rte_mbuf *sgl_buf = sop->m_src;
285 sgl_buf = sop->m_dst;
287 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
288 && sgl_buf->next != NULL) {
289 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
290 sgl_buf = sgl_buf->next;
293 auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
294 sgl_buf, remaining_off);
296 auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
297 auth_offset + auth_len;
299 /* Then check if digest-encrypted conditions are met */
300 if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
301 (digest.iova == auth_end_iova) && is_sgl)
302 max_len = RTE_MAX(max_len,
303 auth_offset + auth_len +
304 ut_params->auth_xform.auth.digest_length);
306 } else if (is_cipher) {
307 cipher_offset = sop->cipher.data.offset;
308 cipher_len = sop->cipher.data.length;
309 max_len = cipher_len + cipher_offset;
311 max_len = max_len >> 3;
312 cipher_offset = cipher_offset >> 3;
313 cipher_len = cipher_len >> 3;
315 ofs.ofs.cipher.head = cipher_offset;
316 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
317 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
318 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
320 } else if (is_auth) {
321 auth_offset = sop->auth.data.offset;
322 auth_len = sop->auth.data.length;
323 max_len = auth_len + auth_offset;
325 max_len = max_len >> 3;
326 auth_offset = auth_offset >> 3;
327 auth_len = auth_len >> 3;
329 ofs.ofs.auth.head = auth_offset;
330 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
331 aad_auth_iv.va = rte_crypto_op_ctod_offset(
332 op, void *, IV_OFFSET + cipher_iv_len);
333 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
335 digest.va = (void *)sop->auth.digest.data;
336 digest.iova = sop->auth.digest.phys_addr;
339 cipher_offset = sop->aead.data.offset;
340 cipher_len = sop->aead.data.length;
341 max_len = cipher_len + cipher_offset;
343 max_len = max_len >> 3;
344 cipher_offset = cipher_offset >> 3;
345 cipher_len = cipher_len >> 3;
347 ofs.ofs.cipher.head = cipher_offset;
348 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
349 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
350 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
351 aad_auth_iv.va = (void *)sop->aead.aad.data;
352 aad_auth_iv.iova = sop->aead.aad.phys_addr;
353 digest.va = (void *)sop->aead.digest.data;
354 digest.iova = sop->aead.digest.phys_addr;
357 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
358 data_vec, RTE_DIM(data_vec));
359 if (n < 0 || n > sop->m_src->nb_segs) {
360 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
367 dest_sgl.vec = dest_data_vec;
368 vec.dest_sgl = &dest_sgl;
369 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
370 dest_data_vec, RTE_DIM(dest_data_vec));
371 if (n < 0 || n > sop->m_dst->nb_segs) {
372 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
379 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
380 &enqueue_status) < 1) {
381 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
385 if (enqueue_status == 0) {
386 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
388 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
391 } else if (enqueue_status < 0) {
392 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
397 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
398 n = rte_cryptodev_raw_dequeue_burst(ctx,
399 NULL, 1, post_process_raw_dp_op,
400 (void **)&ret_op, 0, &n_success,
402 if (dequeue_status < 0) {
403 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
410 if (n == 1 && dequeue_status == 0) {
411 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
412 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
417 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
418 ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
419 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
420 RTE_CRYPTO_OP_STATUS_SUCCESS;
427 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
430 struct rte_crypto_sym_op *sop;
431 union rte_crypto_sym_ofs ofs;
432 struct rte_crypto_sgl sgl;
433 struct rte_crypto_sym_vec symvec;
434 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
435 struct rte_crypto_vec vec[UINT8_MAX];
439 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
440 sop->aead.data.length, vec, RTE_DIM(vec));
442 if (n < 0 || n != sop->m_src->nb_segs) {
443 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
449 symvec.src_sgl = &sgl;
451 symvec.digest = &digest_ptr;
452 symvec.aad = &aad_ptr;
456 /* for CPU crypto the IOVA address is not required */
457 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
458 digest_ptr.va = (void *)sop->aead.digest.data;
459 aad_ptr.va = (void *)sop->aead.aad.data;
463 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
467 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
469 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
473 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
476 struct rte_crypto_sym_op *sop;
477 union rte_crypto_sym_ofs ofs;
478 struct rte_crypto_sgl sgl;
479 struct rte_crypto_sym_vec symvec;
480 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
481 struct rte_crypto_vec vec[UINT8_MAX];
485 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
486 sop->auth.data.length, vec, RTE_DIM(vec));
488 if (n < 0 || n != sop->m_src->nb_segs) {
489 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
495 symvec.src_sgl = &sgl;
497 symvec.digest = &digest_ptr;
501 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
502 digest_ptr.va = (void *)sop->auth.digest.data;
505 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
506 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
507 (sop->cipher.data.offset + sop->cipher.data.length);
509 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
513 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
515 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
518 static struct rte_crypto_op *
519 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
522 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
524 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
525 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
531 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
534 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
535 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
543 testsuite_setup(void)
545 struct crypto_testsuite_params *ts_params = &testsuite_params;
546 struct rte_cryptodev_info info;
547 uint32_t i = 0, nb_devs, dev_id;
550 memset(ts_params, 0, sizeof(*ts_params));
552 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
553 if (ts_params->mbuf_pool == NULL) {
554 /* Not already created so create */
555 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
557 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
559 if (ts_params->mbuf_pool == NULL) {
560 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
565 ts_params->large_mbuf_pool = rte_mempool_lookup(
566 "CRYPTO_LARGE_MBUFPOOL");
567 if (ts_params->large_mbuf_pool == NULL) {
568 /* Not already created so create */
569 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
570 "CRYPTO_LARGE_MBUFPOOL",
573 if (ts_params->large_mbuf_pool == NULL) {
575 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
580 ts_params->op_mpool = rte_crypto_op_pool_create(
581 "MBUF_CRYPTO_SYM_OP_POOL",
582 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
583 NUM_MBUFS, MBUF_CACHE_SIZE,
585 sizeof(struct rte_crypto_sym_xform) +
588 if (ts_params->op_mpool == NULL) {
589 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
593 nb_devs = rte_cryptodev_count();
595 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
599 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
600 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
601 rte_cryptodev_driver_name_get(gbl_driver_id));
605 /* Create list of valid crypto devs */
606 for (i = 0; i < nb_devs; i++) {
607 rte_cryptodev_info_get(i, &info);
608 if (info.driver_id == gbl_driver_id)
609 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
612 if (ts_params->valid_dev_count < 1)
615 /* Set up all the qps on the first of the valid devices found */
617 dev_id = ts_params->valid_devs[0];
619 rte_cryptodev_info_get(dev_id, &info);
621 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
622 ts_params->conf.socket_id = SOCKET_ID_ANY;
623 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
625 unsigned int session_size =
626 rte_cryptodev_sym_get_private_session_size(dev_id);
628 #ifdef RTE_LIB_SECURITY
629 unsigned int security_session_size = rte_security_session_get_size(
630 rte_cryptodev_get_sec_ctx(dev_id));
632 if (session_size < security_session_size)
633 session_size = security_session_size;
636 * Create mempool with maximum number of sessions.
638 if (info.sym.max_nb_sessions != 0 &&
639 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
640 RTE_LOG(ERR, USER1, "Device does not support "
641 "at least %u sessions\n",
646 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
647 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
649 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
650 "session mempool allocation failed");
652 ts_params->session_priv_mpool = rte_mempool_create(
656 0, 0, NULL, NULL, NULL,
659 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
660 "session mempool allocation failed");
664 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
666 "Failed to configure cryptodev %u with %u qps",
667 dev_id, ts_params->conf.nb_queue_pairs);
669 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
670 ts_params->qp_conf.mp_session = ts_params->session_mpool;
671 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
673 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
674 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
675 dev_id, qp_id, &ts_params->qp_conf,
676 rte_cryptodev_socket_id(dev_id)),
677 "Failed to setup queue pair %u on cryptodev %u",
685 testsuite_teardown(void)
687 struct crypto_testsuite_params *ts_params = &testsuite_params;
690 if (ts_params->mbuf_pool != NULL) {
691 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
692 rte_mempool_avail_count(ts_params->mbuf_pool));
695 if (ts_params->op_mpool != NULL) {
696 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
697 rte_mempool_avail_count(ts_params->op_mpool));
700 /* Free session mempools */
701 if (ts_params->session_priv_mpool != NULL) {
702 rte_mempool_free(ts_params->session_priv_mpool);
703 ts_params->session_priv_mpool = NULL;
706 if (ts_params->session_mpool != NULL) {
707 rte_mempool_free(ts_params->session_mpool);
708 ts_params->session_mpool = NULL;
711 res = rte_cryptodev_close(ts_params->valid_devs[0]);
713 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
717 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
718 const int *algs, uint16_t num_algs)
720 uint8_t dev_id = testsuite_params.valid_devs[0];
721 bool some_alg_supported = FALSE;
724 for (i = 0; i < num_algs && !some_alg_supported; i++) {
725 struct rte_cryptodev_sym_capability_idx alg = {
728 if (rte_cryptodev_sym_capability_get(dev_id,
730 some_alg_supported = TRUE;
732 if (!some_alg_supported)
739 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
740 uint16_t num_ciphers)
742 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
743 (const int *) ciphers, num_ciphers);
747 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
750 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
751 (const int *) auths, num_auths);
755 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
758 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
759 (const int *) aeads, num_aeads);
763 null_testsuite_setup(void)
765 struct crypto_testsuite_params *ts_params = &testsuite_params;
766 uint8_t dev_id = ts_params->valid_devs[0];
767 struct rte_cryptodev_info dev_info;
768 const enum rte_crypto_cipher_algorithm ciphers[] = {
769 RTE_CRYPTO_CIPHER_NULL
771 const enum rte_crypto_auth_algorithm auths[] = {
775 rte_cryptodev_info_get(dev_id, &dev_info);
777 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
778 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
779 "testsuite not met\n");
783 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
784 && check_auth_capabilities_supported(auths,
785 RTE_DIM(auths)) != 0) {
786 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
787 "testsuite not met\n");
795 crypto_gen_testsuite_setup(void)
797 struct crypto_testsuite_params *ts_params = &testsuite_params;
798 uint8_t dev_id = ts_params->valid_devs[0];
799 struct rte_cryptodev_info dev_info;
801 rte_cryptodev_info_get(dev_id, &dev_info);
803 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
804 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
805 "testsuite not met\n");
812 #ifdef RTE_LIB_SECURITY
814 ipsec_proto_testsuite_setup(void)
816 struct crypto_testsuite_params *ts_params = &testsuite_params;
817 struct crypto_unittest_params *ut_params = &unittest_params;
818 struct rte_cryptodev_info dev_info;
821 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
823 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
824 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
825 "testsuite not met\n");
829 /* Reconfigure to enable security */
830 ret = dev_configure_and_start(0);
831 if (ret != TEST_SUCCESS)
834 /* Set action type */
835 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
837 if (security_proto_supported(
838 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
839 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
840 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
845 test_ipsec_alg_list_populate();
846 test_ipsec_ah_alg_list_populate();
849 * Stop the device. Device would be started again by individual test
850 * case setup routine.
852 rte_cryptodev_stop(ts_params->valid_devs[0]);
858 pdcp_proto_testsuite_setup(void)
860 struct crypto_testsuite_params *ts_params = &testsuite_params;
861 uint8_t dev_id = ts_params->valid_devs[0];
862 struct rte_cryptodev_info dev_info;
863 const enum rte_crypto_cipher_algorithm ciphers[] = {
864 RTE_CRYPTO_CIPHER_NULL,
865 RTE_CRYPTO_CIPHER_AES_CTR,
866 RTE_CRYPTO_CIPHER_ZUC_EEA3,
867 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
869 const enum rte_crypto_auth_algorithm auths[] = {
870 RTE_CRYPTO_AUTH_NULL,
871 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
872 RTE_CRYPTO_AUTH_AES_CMAC,
873 RTE_CRYPTO_AUTH_ZUC_EIA3
876 rte_cryptodev_info_get(dev_id, &dev_info);
878 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
879 !(dev_info.feature_flags &
880 RTE_CRYPTODEV_FF_SECURITY)) {
881 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
882 "testsuite not met\n");
886 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
887 && check_auth_capabilities_supported(auths,
888 RTE_DIM(auths)) != 0) {
889 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
890 "testsuite not met\n");
898 docsis_proto_testsuite_setup(void)
900 struct crypto_testsuite_params *ts_params = &testsuite_params;
901 uint8_t dev_id = ts_params->valid_devs[0];
902 struct rte_cryptodev_info dev_info;
903 const enum rte_crypto_cipher_algorithm ciphers[] = {
904 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
907 rte_cryptodev_info_get(dev_id, &dev_info);
909 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
910 !(dev_info.feature_flags &
911 RTE_CRYPTODEV_FF_SECURITY)) {
912 RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
913 "Proto testsuite not met\n");
917 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
918 RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
919 "testsuite not met\n");
928 aes_ccm_auth_testsuite_setup(void)
930 struct crypto_testsuite_params *ts_params = &testsuite_params;
931 uint8_t dev_id = ts_params->valid_devs[0];
932 struct rte_cryptodev_info dev_info;
933 const enum rte_crypto_aead_algorithm aeads[] = {
934 RTE_CRYPTO_AEAD_AES_CCM
937 rte_cryptodev_info_get(dev_id, &dev_info);
939 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
940 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
941 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
942 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
943 "testsuite not met\n");
947 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
948 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
949 "testsuite not met\n");
957 aes_gcm_auth_testsuite_setup(void)
959 struct crypto_testsuite_params *ts_params = &testsuite_params;
960 uint8_t dev_id = ts_params->valid_devs[0];
961 struct rte_cryptodev_info dev_info;
962 const enum rte_crypto_aead_algorithm aeads[] = {
963 RTE_CRYPTO_AEAD_AES_GCM
966 rte_cryptodev_info_get(dev_id, &dev_info);
968 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
969 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
970 "testsuite not met\n");
974 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
975 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
976 "testsuite not met\n");
984 aes_gmac_auth_testsuite_setup(void)
986 struct crypto_testsuite_params *ts_params = &testsuite_params;
987 uint8_t dev_id = ts_params->valid_devs[0];
988 struct rte_cryptodev_info dev_info;
989 const enum rte_crypto_auth_algorithm auths[] = {
990 RTE_CRYPTO_AUTH_AES_GMAC
993 rte_cryptodev_info_get(dev_id, &dev_info);
995 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
996 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
997 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
998 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
999 "testsuite not met\n");
1000 return TEST_SKIPPED;
1003 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1004 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1005 "testsuite not met\n");
1006 return TEST_SKIPPED;
1013 chacha20_poly1305_testsuite_setup(void)
1015 struct crypto_testsuite_params *ts_params = &testsuite_params;
1016 uint8_t dev_id = ts_params->valid_devs[0];
1017 struct rte_cryptodev_info dev_info;
1018 const enum rte_crypto_aead_algorithm aeads[] = {
1019 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1022 rte_cryptodev_info_get(dev_id, &dev_info);
1024 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1025 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1026 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1027 RTE_LOG(INFO, USER1, "Feature flag requirements for "
1028 "Chacha20-Poly1305 testsuite not met\n");
1029 return TEST_SKIPPED;
1032 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1033 RTE_LOG(INFO, USER1, "Capability requirements for "
1034 "Chacha20-Poly1305 testsuite not met\n");
1035 return TEST_SKIPPED;
1042 snow3g_testsuite_setup(void)
1044 struct crypto_testsuite_params *ts_params = &testsuite_params;
1045 uint8_t dev_id = ts_params->valid_devs[0];
1046 struct rte_cryptodev_info dev_info;
1047 const enum rte_crypto_cipher_algorithm ciphers[] = {
1048 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1051 const enum rte_crypto_auth_algorithm auths[] = {
1052 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1055 rte_cryptodev_info_get(dev_id, &dev_info);
1057 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1058 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1059 "testsuite not met\n");
1060 return TEST_SKIPPED;
1063 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1064 && check_auth_capabilities_supported(auths,
1065 RTE_DIM(auths)) != 0) {
1066 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1067 "testsuite not met\n");
1068 return TEST_SKIPPED;
1075 zuc_testsuite_setup(void)
1077 struct crypto_testsuite_params *ts_params = &testsuite_params;
1078 uint8_t dev_id = ts_params->valid_devs[0];
1079 struct rte_cryptodev_info dev_info;
1080 const enum rte_crypto_cipher_algorithm ciphers[] = {
1081 RTE_CRYPTO_CIPHER_ZUC_EEA3
1083 const enum rte_crypto_auth_algorithm auths[] = {
1084 RTE_CRYPTO_AUTH_ZUC_EIA3
1087 rte_cryptodev_info_get(dev_id, &dev_info);
1089 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1090 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1091 "testsuite not met\n");
1092 return TEST_SKIPPED;
1095 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1096 && check_auth_capabilities_supported(auths,
1097 RTE_DIM(auths)) != 0) {
1098 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1099 "testsuite not met\n");
1100 return TEST_SKIPPED;
1107 hmac_md5_auth_testsuite_setup(void)
1109 struct crypto_testsuite_params *ts_params = &testsuite_params;
1110 uint8_t dev_id = ts_params->valid_devs[0];
1111 struct rte_cryptodev_info dev_info;
1112 const enum rte_crypto_auth_algorithm auths[] = {
1113 RTE_CRYPTO_AUTH_MD5_HMAC
1116 rte_cryptodev_info_get(dev_id, &dev_info);
1118 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1119 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1120 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1121 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1122 "Auth testsuite not met\n");
1123 return TEST_SKIPPED;
1126 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1127 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1128 "testsuite not met\n");
1129 return TEST_SKIPPED;
1136 kasumi_testsuite_setup(void)
1138 struct crypto_testsuite_params *ts_params = &testsuite_params;
1139 uint8_t dev_id = ts_params->valid_devs[0];
1140 struct rte_cryptodev_info dev_info;
1141 const enum rte_crypto_cipher_algorithm ciphers[] = {
1142 RTE_CRYPTO_CIPHER_KASUMI_F8
1144 const enum rte_crypto_auth_algorithm auths[] = {
1145 RTE_CRYPTO_AUTH_KASUMI_F9
1148 rte_cryptodev_info_get(dev_id, &dev_info);
1150 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1151 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1152 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1153 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1154 "testsuite not met\n");
1155 return TEST_SKIPPED;
1158 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1159 && check_auth_capabilities_supported(auths,
1160 RTE_DIM(auths)) != 0) {
1161 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1162 "testsuite not met\n");
1163 return TEST_SKIPPED;
1170 negative_aes_gcm_testsuite_setup(void)
1172 struct crypto_testsuite_params *ts_params = &testsuite_params;
1173 uint8_t dev_id = ts_params->valid_devs[0];
1174 struct rte_cryptodev_info dev_info;
1175 const enum rte_crypto_aead_algorithm aeads[] = {
1176 RTE_CRYPTO_AEAD_AES_GCM
1179 rte_cryptodev_info_get(dev_id, &dev_info);
1181 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1182 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1183 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1184 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1185 "AES GCM testsuite not met\n");
1186 return TEST_SKIPPED;
1189 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1190 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1191 "AES GCM testsuite not met\n");
1192 return TEST_SKIPPED;
1199 negative_aes_gmac_testsuite_setup(void)
1201 struct crypto_testsuite_params *ts_params = &testsuite_params;
1202 uint8_t dev_id = ts_params->valid_devs[0];
1203 struct rte_cryptodev_info dev_info;
1204 const enum rte_crypto_auth_algorithm auths[] = {
1205 RTE_CRYPTO_AUTH_AES_GMAC
1208 rte_cryptodev_info_get(dev_id, &dev_info);
1210 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1211 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1212 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1213 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1214 "AES GMAC testsuite not met\n");
1215 return TEST_SKIPPED;
1218 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1219 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1220 "AES GMAC testsuite not met\n");
1221 return TEST_SKIPPED;
1228 mixed_cipher_hash_testsuite_setup(void)
1230 struct crypto_testsuite_params *ts_params = &testsuite_params;
1231 uint8_t dev_id = ts_params->valid_devs[0];
1232 struct rte_cryptodev_info dev_info;
1233 uint64_t feat_flags;
1234 const enum rte_crypto_cipher_algorithm ciphers[] = {
1235 RTE_CRYPTO_CIPHER_NULL,
1236 RTE_CRYPTO_CIPHER_AES_CTR,
1237 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1238 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1240 const enum rte_crypto_auth_algorithm auths[] = {
1241 RTE_CRYPTO_AUTH_NULL,
1242 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1243 RTE_CRYPTO_AUTH_AES_CMAC,
1244 RTE_CRYPTO_AUTH_ZUC_EIA3
1247 rte_cryptodev_info_get(dev_id, &dev_info);
1248 feat_flags = dev_info.feature_flags;
1250 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1251 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1252 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1253 "Cipher Hash testsuite not met\n");
1254 return TEST_SKIPPED;
1257 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1258 && check_auth_capabilities_supported(auths,
1259 RTE_DIM(auths)) != 0) {
1260 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1261 "Cipher Hash testsuite not met\n");
1262 return TEST_SKIPPED;
1269 esn_testsuite_setup(void)
1271 struct crypto_testsuite_params *ts_params = &testsuite_params;
1272 uint8_t dev_id = ts_params->valid_devs[0];
1273 struct rte_cryptodev_info dev_info;
1274 const enum rte_crypto_cipher_algorithm ciphers[] = {
1275 RTE_CRYPTO_CIPHER_AES_CBC
1277 const enum rte_crypto_auth_algorithm auths[] = {
1278 RTE_CRYPTO_AUTH_SHA1_HMAC
1281 rte_cryptodev_info_get(dev_id, &dev_info);
1283 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1284 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1285 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1286 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1287 "testsuite not met\n");
1288 return TEST_SKIPPED;
1291 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1292 && check_auth_capabilities_supported(auths,
1293 RTE_DIM(auths)) != 0) {
1294 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1295 "testsuite not met\n");
1296 return TEST_SKIPPED;
1303 multi_session_testsuite_setup(void)
1305 struct crypto_testsuite_params *ts_params = &testsuite_params;
1306 uint8_t dev_id = ts_params->valid_devs[0];
1307 struct rte_cryptodev_info dev_info;
1308 const enum rte_crypto_cipher_algorithm ciphers[] = {
1309 RTE_CRYPTO_CIPHER_AES_CBC
1311 const enum rte_crypto_auth_algorithm auths[] = {
1312 RTE_CRYPTO_AUTH_SHA512_HMAC
1315 rte_cryptodev_info_get(dev_id, &dev_info);
1317 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1318 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1319 "Session testsuite not met\n");
1320 return TEST_SKIPPED;
1323 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1324 && check_auth_capabilities_supported(auths,
1325 RTE_DIM(auths)) != 0) {
1326 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1327 "Session testsuite not met\n");
1328 return TEST_SKIPPED;
1335 negative_hmac_sha1_testsuite_setup(void)
1337 struct crypto_testsuite_params *ts_params = &testsuite_params;
1338 uint8_t dev_id = ts_params->valid_devs[0];
1339 struct rte_cryptodev_info dev_info;
1340 const enum rte_crypto_cipher_algorithm ciphers[] = {
1341 RTE_CRYPTO_CIPHER_AES_CBC
1343 const enum rte_crypto_auth_algorithm auths[] = {
1344 RTE_CRYPTO_AUTH_SHA1_HMAC
1347 rte_cryptodev_info_get(dev_id, &dev_info);
1349 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1350 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1351 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1352 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1353 "HMAC SHA1 testsuite not met\n");
1354 return TEST_SKIPPED;
1357 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1358 && check_auth_capabilities_supported(auths,
1359 RTE_DIM(auths)) != 0) {
1360 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1361 "HMAC SHA1 testsuite not met\n");
1362 return TEST_SKIPPED;
1369 dev_configure_and_start(uint64_t ff_disable)
1371 struct crypto_testsuite_params *ts_params = &testsuite_params;
1372 struct crypto_unittest_params *ut_params = &unittest_params;
1376 /* Clear unit test parameters before running test */
1377 memset(ut_params, 0, sizeof(*ut_params));
1379 /* Reconfigure device to default parameters */
1380 ts_params->conf.socket_id = SOCKET_ID_ANY;
1381 ts_params->conf.ff_disable = ff_disable;
1382 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1383 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1384 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1386 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1388 "Failed to configure cryptodev %u",
1389 ts_params->valid_devs[0]);
1391 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1392 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1393 ts_params->valid_devs[0], qp_id,
1394 &ts_params->qp_conf,
1395 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1396 "Failed to setup queue pair %u on cryptodev %u",
1397 qp_id, ts_params->valid_devs[0]);
1401 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1403 /* Start the device */
1404 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1405 "Failed to start cryptodev %u",
1406 ts_params->valid_devs[0]);
1408 return TEST_SUCCESS;
1414 /* Configure and start the device with security feature disabled */
1415 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1419 ut_setup_security(void)
1421 /* Configure and start the device with no features disabled */
1422 return dev_configure_and_start(0);
1428 struct crypto_testsuite_params *ts_params = &testsuite_params;
1429 struct crypto_unittest_params *ut_params = &unittest_params;
1431 /* free crypto session structure */
1432 #ifdef RTE_LIB_SECURITY
1433 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1434 if (ut_params->sec_session) {
1435 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1436 (ts_params->valid_devs[0]),
1437 ut_params->sec_session);
1438 ut_params->sec_session = NULL;
1443 if (ut_params->sess) {
1444 rte_cryptodev_sym_session_clear(
1445 ts_params->valid_devs[0],
1447 rte_cryptodev_sym_session_free(ut_params->sess);
1448 ut_params->sess = NULL;
1452 /* free crypto operation structure */
1454 rte_crypto_op_free(ut_params->op);
1457 * free mbuf - both obuf and ibuf are usually the same,
1458 * so check if they point at the same address is necessary,
1459 * to avoid freeing the mbuf twice.
1461 if (ut_params->obuf) {
1462 rte_pktmbuf_free(ut_params->obuf);
1463 if (ut_params->ibuf == ut_params->obuf)
1464 ut_params->ibuf = 0;
1465 ut_params->obuf = 0;
1467 if (ut_params->ibuf) {
1468 rte_pktmbuf_free(ut_params->ibuf);
1469 ut_params->ibuf = 0;
1472 if (ts_params->mbuf_pool != NULL)
1473 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1474 rte_mempool_avail_count(ts_params->mbuf_pool));
1476 /* Stop the device */
1477 rte_cryptodev_stop(ts_params->valid_devs[0]);
1481 test_device_configure_invalid_dev_id(void)
1483 struct crypto_testsuite_params *ts_params = &testsuite_params;
1484 uint16_t dev_id, num_devs = 0;
1486 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1487 "Need at least %d devices for test", 1);
1489 /* valid dev_id values */
1490 dev_id = ts_params->valid_devs[0];
1492 /* Stop the device in case it's started so it can be configured */
1493 rte_cryptodev_stop(dev_id);
1495 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1496 "Failed test for rte_cryptodev_configure: "
1497 "invalid dev_num %u", dev_id);
1499 /* invalid dev_id values */
1502 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1503 "Failed test for rte_cryptodev_configure: "
1504 "invalid dev_num %u", dev_id);
1508 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1509 "Failed test for rte_cryptodev_configure:"
1510 "invalid dev_num %u", dev_id);
1512 return TEST_SUCCESS;
1516 test_device_configure_invalid_queue_pair_ids(void)
1518 struct crypto_testsuite_params *ts_params = &testsuite_params;
1519 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1521 /* Stop the device in case it's started so it can be configured */
1522 rte_cryptodev_stop(ts_params->valid_devs[0]);
1524 /* valid - max value queue pairs */
1525 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1527 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1529 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1530 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1532 /* valid - one queue pairs */
1533 ts_params->conf.nb_queue_pairs = 1;
1535 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1537 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1538 ts_params->valid_devs[0],
1539 ts_params->conf.nb_queue_pairs);
1542 /* invalid - zero queue pairs */
1543 ts_params->conf.nb_queue_pairs = 0;
1545 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1547 "Failed test for rte_cryptodev_configure, dev_id %u,"
1549 ts_params->valid_devs[0],
1550 ts_params->conf.nb_queue_pairs);
1553 /* invalid - max value supported by field queue pairs */
1554 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1556 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1558 "Failed test for rte_cryptodev_configure, dev_id %u,"
1560 ts_params->valid_devs[0],
1561 ts_params->conf.nb_queue_pairs);
1564 /* invalid - max value + 1 queue pairs */
1565 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1567 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1569 "Failed test for rte_cryptodev_configure, dev_id %u,"
1571 ts_params->valid_devs[0],
1572 ts_params->conf.nb_queue_pairs);
1574 /* revert to original testsuite value */
1575 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1577 return TEST_SUCCESS;
1581 test_queue_pair_descriptor_setup(void)
1583 struct crypto_testsuite_params *ts_params = &testsuite_params;
1584 struct rte_cryptodev_qp_conf qp_conf = {
1585 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1589 /* Stop the device in case it's started so it can be configured */
1590 rte_cryptodev_stop(ts_params->valid_devs[0]);
1592 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1594 "Failed to configure cryptodev %u",
1595 ts_params->valid_devs[0]);
1598 * Test various ring sizes on this device. memzones can't be
1599 * freed so are re-used if ring is released and re-created.
1601 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1602 qp_conf.mp_session = ts_params->session_mpool;
1603 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1605 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1606 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1607 ts_params->valid_devs[0], qp_id, &qp_conf,
1608 rte_cryptodev_socket_id(
1609 ts_params->valid_devs[0])),
1611 "rte_cryptodev_queue_pair_setup: num_inflights "
1612 "%u on qp %u on cryptodev %u",
1613 qp_conf.nb_descriptors, qp_id,
1614 ts_params->valid_devs[0]);
1617 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1619 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1620 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1621 ts_params->valid_devs[0], qp_id, &qp_conf,
1622 rte_cryptodev_socket_id(
1623 ts_params->valid_devs[0])),
1625 " rte_cryptodev_queue_pair_setup: num_inflights"
1626 " %u on qp %u on cryptodev %u",
1627 qp_conf.nb_descriptors, qp_id,
1628 ts_params->valid_devs[0]);
1631 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1633 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1634 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1635 ts_params->valid_devs[0], qp_id, &qp_conf,
1636 rte_cryptodev_socket_id(
1637 ts_params->valid_devs[0])),
1639 "rte_cryptodev_queue_pair_setup: num_inflights"
1640 " %u on qp %u on cryptodev %u",
1641 qp_conf.nb_descriptors, qp_id,
1642 ts_params->valid_devs[0]);
1645 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1647 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1648 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1649 ts_params->valid_devs[0], qp_id, &qp_conf,
1650 rte_cryptodev_socket_id(
1651 ts_params->valid_devs[0])),
1653 " rte_cryptodev_queue_pair_setup:"
1654 "num_inflights %u on qp %u on cryptodev %u",
1655 qp_conf.nb_descriptors, qp_id,
1656 ts_params->valid_devs[0]);
1659 /* test invalid queue pair id */
1660 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1662 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1664 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1665 ts_params->valid_devs[0],
1667 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1668 "Failed test for rte_cryptodev_queue_pair_setup:"
1669 "invalid qp %u on cryptodev %u",
1670 qp_id, ts_params->valid_devs[0]);
1672 qp_id = 0xffff; /*invalid*/
1674 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1675 ts_params->valid_devs[0],
1677 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1678 "Failed test for rte_cryptodev_queue_pair_setup:"
1679 "invalid qp %u on cryptodev %u",
1680 qp_id, ts_params->valid_devs[0]);
1682 return TEST_SUCCESS;
1685 /* ***** Plaintext data for tests ***** */
1687 const char catch_22_quote_1[] =
1688 "There was only one catch and that was Catch-22, which "
1689 "specified that a concern for one's safety in the face of "
1690 "dangers that were real and immediate was the process of a "
1691 "rational mind. Orr was crazy and could be grounded. All he "
1692 "had to do was ask; and as soon as he did, he would no longer "
1693 "be crazy and would have to fly more missions. Orr would be "
1694 "crazy to fly more missions and sane if he didn't, but if he "
1695 "was sane he had to fly them. If he flew them he was crazy "
1696 "and didn't have to; but if he didn't want to he was sane and "
1697 "had to. Yossarian was moved very deeply by the absolute "
1698 "simplicity of this clause of Catch-22 and let out a "
1699 "respectful whistle. \"That's some catch, that Catch-22\", he "
1700 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1702 const char catch_22_quote[] =
1703 "What a lousy earth! He wondered how many people were "
1704 "destitute that same night even in his own prosperous country, "
1705 "how many homes were shanties, how many husbands were drunk "
1706 "and wives socked, and how many children were bullied, abused, "
1707 "or abandoned. How many families hungered for food they could "
1708 "not afford to buy? How many hearts were broken? How many "
1709 "suicides would take place that same night, how many people "
1710 "would go insane? How many cockroaches and landlords would "
1711 "triumph? How many winners were losers, successes failures, "
1712 "and rich men poor men? How many wise guys were stupid? How "
1713 "many happy endings were unhappy endings? How many honest men "
1714 "were liars, brave men cowards, loyal men traitors, how many "
1715 "sainted men were corrupt, how many people in positions of "
1716 "trust had sold their souls to bodyguards, how many had never "
1717 "had souls? How many straight-and-narrow paths were crooked "
1718 "paths? How many best families were worst families and how "
1719 "many good people were bad people? When you added them all up "
1720 "and then subtracted, you might be left with only the children, "
1721 "and perhaps with Albert Einstein and an old violinist or "
1722 "sculptor somewhere.";
1724 #define QUOTE_480_BYTES (480)
1725 #define QUOTE_512_BYTES (512)
1726 #define QUOTE_768_BYTES (768)
1727 #define QUOTE_1024_BYTES (1024)
1731 /* ***** SHA1 Hash Tests ***** */
1733 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1735 static uint8_t hmac_sha1_key[] = {
1736 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1737 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1738 0xDE, 0xF4, 0xDE, 0xAD };
1740 /* ***** SHA224 Hash Tests ***** */
1742 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1745 /* ***** AES-CBC Cipher Tests ***** */
1747 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1748 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1750 static uint8_t aes_cbc_key[] = {
1751 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1752 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1754 static uint8_t aes_cbc_iv[] = {
1755 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1756 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1759 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1761 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1762 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1763 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1764 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1765 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1766 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1767 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1768 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1769 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1770 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1771 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1772 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1773 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1774 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1775 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1776 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1777 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1778 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1779 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1780 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1781 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1782 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1783 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1784 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1785 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1786 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1787 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1788 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1789 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1790 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1791 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1792 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1793 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1794 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1795 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1796 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1797 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1798 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1799 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1800 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1801 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1802 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1803 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1804 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1805 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1806 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1807 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1808 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1809 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1810 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1811 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1812 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1813 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1814 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1815 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1816 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1817 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1818 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1819 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1820 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1821 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1822 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1823 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1824 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1825 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1828 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1829 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1830 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1831 0x18, 0x8c, 0x1d, 0x32
1835 /* Multisession Vector context Test */
1836 /*Begin Session 0 */
1837 static uint8_t ms_aes_cbc_key0[] = {
1838 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1839 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1842 static uint8_t ms_aes_cbc_iv0[] = {
1843 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1844 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1847 static const uint8_t ms_aes_cbc_cipher0[] = {
1848 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1849 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1850 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1851 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1852 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1853 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1854 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1855 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1856 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1857 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1858 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1859 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1860 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1861 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1862 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1863 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1864 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1865 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1866 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1867 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1868 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1869 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1870 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1871 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1872 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1873 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1874 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1875 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1876 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1877 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1878 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1879 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1880 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1881 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1882 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1883 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1884 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1885 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1886 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1887 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1888 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1889 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1890 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1891 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1892 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1893 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1894 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1895 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1896 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1897 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1898 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1899 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1900 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1901 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1902 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1903 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1904 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1905 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1906 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1907 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1908 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1909 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1910 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1911 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1915 static uint8_t ms_hmac_key0[] = {
1916 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1917 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1918 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1919 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1920 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1921 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1922 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1923 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1926 static const uint8_t ms_hmac_digest0[] = {
1927 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1928 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1929 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1930 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1931 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1932 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1933 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1934 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1938 /* Begin session 1 */
1940 static uint8_t ms_aes_cbc_key1[] = {
1941 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1942 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1945 static uint8_t ms_aes_cbc_iv1[] = {
1946 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1947 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1950 static const uint8_t ms_aes_cbc_cipher1[] = {
1951 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1952 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1953 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1954 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1955 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1956 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1957 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1958 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1959 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1960 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1961 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1962 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1963 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1964 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1965 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1966 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1967 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1968 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1969 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1970 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1971 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1972 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1973 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1974 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1975 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1976 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1977 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1978 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1979 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1980 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1981 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1982 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1983 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1984 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1985 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1986 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1987 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1988 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1989 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1990 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1991 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1992 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1993 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1994 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1995 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1996 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1997 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1998 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1999 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2000 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2001 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2002 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2003 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2004 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2005 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2006 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2007 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2008 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2009 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2010 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2011 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2012 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2013 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2014 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2018 static uint8_t ms_hmac_key1[] = {
2019 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2020 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2021 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2022 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2023 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2024 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2025 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2026 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2029 static const uint8_t ms_hmac_digest1[] = {
2030 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2031 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2032 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2033 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2034 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2035 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2036 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2037 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2040 /* Begin Session 2 */
2041 static uint8_t ms_aes_cbc_key2[] = {
2042 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2043 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2046 static uint8_t ms_aes_cbc_iv2[] = {
2047 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2048 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2051 static const uint8_t ms_aes_cbc_cipher2[] = {
2052 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2053 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2054 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2055 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2056 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2057 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2058 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2059 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2060 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2061 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2062 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2063 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2064 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2065 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2066 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2067 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2068 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2069 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2070 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2071 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2072 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2073 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2074 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2075 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2076 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2077 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2078 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2079 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2080 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2081 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2082 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2083 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2084 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2085 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2086 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2087 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2088 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2089 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2090 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2091 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2092 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2093 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2094 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2095 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2096 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2097 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2098 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2099 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2100 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2101 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2102 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2103 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2104 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2105 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2106 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2107 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2108 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2109 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2110 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2111 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2112 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2113 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2114 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2115 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2118 static uint8_t ms_hmac_key2[] = {
2119 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2120 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2121 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2122 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2123 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2124 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2125 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2126 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2129 static const uint8_t ms_hmac_digest2[] = {
2130 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2131 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2132 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2133 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2134 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2135 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2136 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2137 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2144 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2146 struct crypto_testsuite_params *ts_params = &testsuite_params;
2147 struct crypto_unittest_params *ut_params = &unittest_params;
2150 /* Verify the capabilities */
2151 struct rte_cryptodev_sym_capability_idx cap_idx;
2152 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2153 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2154 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2156 return TEST_SKIPPED;
2157 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2158 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2159 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2161 return TEST_SKIPPED;
2163 /* Generate test mbuf data and space for digest */
2164 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2165 catch_22_quote, QUOTE_512_BYTES, 0);
2167 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2168 DIGEST_BYTE_LENGTH_SHA1);
2169 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2171 /* Setup Cipher Parameters */
2172 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2173 ut_params->cipher_xform.next = &ut_params->auth_xform;
2175 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2176 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2177 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2178 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2179 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2180 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2182 /* Setup HMAC Parameters */
2183 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2185 ut_params->auth_xform.next = NULL;
2187 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2188 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2189 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2190 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2191 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2193 ut_params->sess = rte_cryptodev_sym_session_create(
2194 ts_params->session_mpool);
2195 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2197 /* Create crypto session*/
2198 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2199 ut_params->sess, &ut_params->cipher_xform,
2200 ts_params->session_priv_mpool);
2202 if (status == -ENOTSUP)
2203 return TEST_SKIPPED;
2205 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
2207 /* Generate crypto op data structure */
2208 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2209 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2210 TEST_ASSERT_NOT_NULL(ut_params->op,
2211 "Failed to allocate symmetric crypto operation struct");
2213 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2215 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2217 /* set crypto operation source mbuf */
2218 sym_op->m_src = ut_params->ibuf;
2220 /* Set crypto operation authentication parameters */
2221 sym_op->auth.digest.data = ut_params->digest;
2222 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2223 ut_params->ibuf, QUOTE_512_BYTES);
2225 sym_op->auth.data.offset = 0;
2226 sym_op->auth.data.length = QUOTE_512_BYTES;
2228 /* Copy IV at the end of the crypto operation */
2229 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2230 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2232 /* Set crypto operation cipher parameters */
2233 sym_op->cipher.data.offset = 0;
2234 sym_op->cipher.data.length = QUOTE_512_BYTES;
2236 /* Process crypto operation */
2237 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2238 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2241 TEST_ASSERT_NOT_NULL(
2242 process_crypto_request(ts_params->valid_devs[0],
2244 "failed to process sym crypto op");
2246 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2247 "crypto op processing failed");
2250 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2253 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2254 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2256 "ciphertext data not as expected");
2258 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2260 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2261 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2262 gbl_driver_id == rte_cryptodev_driver_id_get(
2263 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2264 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2265 DIGEST_BYTE_LENGTH_SHA1,
2266 "Generated digest data not as expected");
2268 return TEST_SUCCESS;
2271 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2273 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2275 static uint8_t hmac_sha512_key[] = {
2276 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2277 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2278 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2279 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2280 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2281 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2282 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2283 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2285 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2286 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2287 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2288 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2289 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2290 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2291 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2292 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2293 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2298 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2299 struct crypto_unittest_params *ut_params,
2300 uint8_t *cipher_key,
2304 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2305 struct crypto_unittest_params *ut_params,
2306 struct crypto_testsuite_params *ts_params,
2307 const uint8_t *cipher,
2308 const uint8_t *digest,
2313 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2314 struct crypto_unittest_params *ut_params,
2315 uint8_t *cipher_key,
2319 /* Setup Cipher Parameters */
2320 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2321 ut_params->cipher_xform.next = NULL;
2323 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2324 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2325 ut_params->cipher_xform.cipher.key.data = cipher_key;
2326 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2327 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2328 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2330 /* Setup HMAC Parameters */
2331 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2332 ut_params->auth_xform.next = &ut_params->cipher_xform;
2334 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2335 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2336 ut_params->auth_xform.auth.key.data = hmac_key;
2337 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2338 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2340 return TEST_SUCCESS;
2345 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2346 struct crypto_unittest_params *ut_params,
2347 struct crypto_testsuite_params *ts_params,
2348 const uint8_t *cipher,
2349 const uint8_t *digest,
2352 /* Generate test mbuf data and digest */
2353 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2356 QUOTE_512_BYTES, 0);
2358 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2359 DIGEST_BYTE_LENGTH_SHA512);
2360 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2362 rte_memcpy(ut_params->digest,
2364 DIGEST_BYTE_LENGTH_SHA512);
2366 /* Generate Crypto op data structure */
2367 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2368 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2369 TEST_ASSERT_NOT_NULL(ut_params->op,
2370 "Failed to allocate symmetric crypto operation struct");
2372 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2374 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2376 /* set crypto operation source mbuf */
2377 sym_op->m_src = ut_params->ibuf;
2379 sym_op->auth.digest.data = ut_params->digest;
2380 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2381 ut_params->ibuf, QUOTE_512_BYTES);
2383 sym_op->auth.data.offset = 0;
2384 sym_op->auth.data.length = QUOTE_512_BYTES;
2386 /* Copy IV at the end of the crypto operation */
2387 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2388 iv, CIPHER_IV_LENGTH_AES_CBC);
2390 sym_op->cipher.data.offset = 0;
2391 sym_op->cipher.data.length = QUOTE_512_BYTES;
2393 /* Process crypto operation */
2394 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2395 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2397 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2398 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2399 ut_params->op, 1, 1, 0, 0);
2401 TEST_ASSERT_NOT_NULL(
2402 process_crypto_request(ts_params->valid_devs[0],
2404 "failed to process sym crypto op");
2406 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2407 "crypto op processing failed");
2409 ut_params->obuf = ut_params->op->sym->m_src;
2412 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2413 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2416 "Plaintext data not as expected");
2419 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2420 "Digest verification failed");
2422 return TEST_SUCCESS;
2425 /* ***** SNOW 3G Tests ***** */
2427 create_wireless_algo_hash_session(uint8_t dev_id,
2428 const uint8_t *key, const uint8_t key_len,
2429 const uint8_t iv_len, const uint8_t auth_len,
2430 enum rte_crypto_auth_operation op,
2431 enum rte_crypto_auth_algorithm algo)
2433 uint8_t hash_key[key_len];
2436 struct crypto_testsuite_params *ts_params = &testsuite_params;
2437 struct crypto_unittest_params *ut_params = &unittest_params;
2439 memcpy(hash_key, key, key_len);
2441 debug_hexdump(stdout, "key:", key, key_len);
2443 /* Setup Authentication Parameters */
2444 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2445 ut_params->auth_xform.next = NULL;
2447 ut_params->auth_xform.auth.op = op;
2448 ut_params->auth_xform.auth.algo = algo;
2449 ut_params->auth_xform.auth.key.length = key_len;
2450 ut_params->auth_xform.auth.key.data = hash_key;
2451 ut_params->auth_xform.auth.digest_length = auth_len;
2452 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2453 ut_params->auth_xform.auth.iv.length = iv_len;
2454 ut_params->sess = rte_cryptodev_sym_session_create(
2455 ts_params->session_mpool);
2457 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2458 &ut_params->auth_xform,
2459 ts_params->session_priv_mpool);
2460 if (status == -ENOTSUP)
2461 return TEST_SKIPPED;
2463 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2464 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2469 create_wireless_algo_cipher_session(uint8_t dev_id,
2470 enum rte_crypto_cipher_operation op,
2471 enum rte_crypto_cipher_algorithm algo,
2472 const uint8_t *key, const uint8_t key_len,
2475 uint8_t cipher_key[key_len];
2477 struct crypto_testsuite_params *ts_params = &testsuite_params;
2478 struct crypto_unittest_params *ut_params = &unittest_params;
2480 memcpy(cipher_key, key, key_len);
2482 /* Setup Cipher Parameters */
2483 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2484 ut_params->cipher_xform.next = NULL;
2486 ut_params->cipher_xform.cipher.algo = algo;
2487 ut_params->cipher_xform.cipher.op = op;
2488 ut_params->cipher_xform.cipher.key.data = cipher_key;
2489 ut_params->cipher_xform.cipher.key.length = key_len;
2490 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2491 ut_params->cipher_xform.cipher.iv.length = iv_len;
2493 debug_hexdump(stdout, "key:", key, key_len);
2495 /* Create Crypto session */
2496 ut_params->sess = rte_cryptodev_sym_session_create(
2497 ts_params->session_mpool);
2499 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2500 &ut_params->cipher_xform,
2501 ts_params->session_priv_mpool);
2502 if (status == -ENOTSUP)
2503 return TEST_SKIPPED;
2505 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2506 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2511 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2512 unsigned int cipher_len,
2513 unsigned int cipher_offset)
2515 struct crypto_testsuite_params *ts_params = &testsuite_params;
2516 struct crypto_unittest_params *ut_params = &unittest_params;
2518 /* Generate Crypto op data structure */
2519 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2520 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2521 TEST_ASSERT_NOT_NULL(ut_params->op,
2522 "Failed to allocate pktmbuf offload");
2524 /* Set crypto operation data parameters */
2525 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2527 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2529 /* set crypto operation source mbuf */
2530 sym_op->m_src = ut_params->ibuf;
2533 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2535 sym_op->cipher.data.length = cipher_len;
2536 sym_op->cipher.data.offset = cipher_offset;
2541 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2542 unsigned int cipher_len,
2543 unsigned int cipher_offset)
2545 struct crypto_testsuite_params *ts_params = &testsuite_params;
2546 struct crypto_unittest_params *ut_params = &unittest_params;
2548 /* Generate Crypto op data structure */
2549 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2550 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2551 TEST_ASSERT_NOT_NULL(ut_params->op,
2552 "Failed to allocate pktmbuf offload");
2554 /* Set crypto operation data parameters */
2555 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2557 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2559 /* set crypto operation source mbuf */
2560 sym_op->m_src = ut_params->ibuf;
2561 sym_op->m_dst = ut_params->obuf;
2564 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2566 sym_op->cipher.data.length = cipher_len;
2567 sym_op->cipher.data.offset = cipher_offset;
2572 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2573 enum rte_crypto_cipher_operation cipher_op,
2574 enum rte_crypto_auth_operation auth_op,
2575 enum rte_crypto_auth_algorithm auth_algo,
2576 enum rte_crypto_cipher_algorithm cipher_algo,
2577 const uint8_t *key, uint8_t key_len,
2578 uint8_t auth_iv_len, uint8_t auth_len,
2579 uint8_t cipher_iv_len)
2582 uint8_t cipher_auth_key[key_len];
2585 struct crypto_testsuite_params *ts_params = &testsuite_params;
2586 struct crypto_unittest_params *ut_params = &unittest_params;
2588 memcpy(cipher_auth_key, key, key_len);
2590 /* Setup Authentication Parameters */
2591 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2592 ut_params->auth_xform.next = NULL;
2594 ut_params->auth_xform.auth.op = auth_op;
2595 ut_params->auth_xform.auth.algo = auth_algo;
2596 ut_params->auth_xform.auth.key.length = key_len;
2597 /* Hash key = cipher key */
2598 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2599 ut_params->auth_xform.auth.digest_length = auth_len;
2600 /* Auth IV will be after cipher IV */
2601 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2602 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2604 /* Setup Cipher Parameters */
2605 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2606 ut_params->cipher_xform.next = &ut_params->auth_xform;
2608 ut_params->cipher_xform.cipher.algo = cipher_algo;
2609 ut_params->cipher_xform.cipher.op = cipher_op;
2610 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2611 ut_params->cipher_xform.cipher.key.length = key_len;
2612 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2613 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2615 debug_hexdump(stdout, "key:", key, key_len);
2617 /* Create Crypto session*/
2618 ut_params->sess = rte_cryptodev_sym_session_create(
2619 ts_params->session_mpool);
2620 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2622 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2623 &ut_params->cipher_xform,
2624 ts_params->session_priv_mpool);
2625 if (status == -ENOTSUP)
2626 return TEST_SKIPPED;
2628 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2633 create_wireless_cipher_auth_session(uint8_t dev_id,
2634 enum rte_crypto_cipher_operation cipher_op,
2635 enum rte_crypto_auth_operation auth_op,
2636 enum rte_crypto_auth_algorithm auth_algo,
2637 enum rte_crypto_cipher_algorithm cipher_algo,
2638 const struct wireless_test_data *tdata)
2640 const uint8_t key_len = tdata->key.len;
2641 uint8_t cipher_auth_key[key_len];
2644 struct crypto_testsuite_params *ts_params = &testsuite_params;
2645 struct crypto_unittest_params *ut_params = &unittest_params;
2646 const uint8_t *key = tdata->key.data;
2647 const uint8_t auth_len = tdata->digest.len;
2648 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2649 uint8_t auth_iv_len = tdata->auth_iv.len;
2651 memcpy(cipher_auth_key, key, key_len);
2653 /* Setup Authentication Parameters */
2654 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2655 ut_params->auth_xform.next = NULL;
2657 ut_params->auth_xform.auth.op = auth_op;
2658 ut_params->auth_xform.auth.algo = auth_algo;
2659 ut_params->auth_xform.auth.key.length = key_len;
2660 /* Hash key = cipher key */
2661 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2662 ut_params->auth_xform.auth.digest_length = auth_len;
2663 /* Auth IV will be after cipher IV */
2664 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2665 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2667 /* Setup Cipher Parameters */
2668 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2669 ut_params->cipher_xform.next = &ut_params->auth_xform;
2671 ut_params->cipher_xform.cipher.algo = cipher_algo;
2672 ut_params->cipher_xform.cipher.op = cipher_op;
2673 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2674 ut_params->cipher_xform.cipher.key.length = key_len;
2675 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2676 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2679 debug_hexdump(stdout, "key:", key, key_len);
2681 /* Create Crypto session*/
2682 ut_params->sess = rte_cryptodev_sym_session_create(
2683 ts_params->session_mpool);
2685 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2686 &ut_params->cipher_xform,
2687 ts_params->session_priv_mpool);
2688 if (status == -ENOTSUP)
2689 return TEST_SKIPPED;
2691 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2692 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2697 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2698 const struct wireless_test_data *tdata)
2700 return create_wireless_cipher_auth_session(dev_id,
2701 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2702 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2703 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2707 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2708 enum rte_crypto_cipher_operation cipher_op,
2709 enum rte_crypto_auth_operation auth_op,
2710 enum rte_crypto_auth_algorithm auth_algo,
2711 enum rte_crypto_cipher_algorithm cipher_algo,
2712 const uint8_t *key, const uint8_t key_len,
2713 uint8_t auth_iv_len, uint8_t auth_len,
2714 uint8_t cipher_iv_len)
2716 uint8_t auth_cipher_key[key_len];
2718 struct crypto_testsuite_params *ts_params = &testsuite_params;
2719 struct crypto_unittest_params *ut_params = &unittest_params;
2721 memcpy(auth_cipher_key, key, key_len);
2723 /* Setup Authentication Parameters */
2724 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2725 ut_params->auth_xform.auth.op = auth_op;
2726 ut_params->auth_xform.next = &ut_params->cipher_xform;
2727 ut_params->auth_xform.auth.algo = auth_algo;
2728 ut_params->auth_xform.auth.key.length = key_len;
2729 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2730 ut_params->auth_xform.auth.digest_length = auth_len;
2731 /* Auth IV will be after cipher IV */
2732 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2733 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2735 /* Setup Cipher Parameters */
2736 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2737 ut_params->cipher_xform.next = NULL;
2738 ut_params->cipher_xform.cipher.algo = cipher_algo;
2739 ut_params->cipher_xform.cipher.op = cipher_op;
2740 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2741 ut_params->cipher_xform.cipher.key.length = key_len;
2742 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2743 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2745 debug_hexdump(stdout, "key:", key, key_len);
2747 /* Create Crypto session*/
2748 ut_params->sess = rte_cryptodev_sym_session_create(
2749 ts_params->session_mpool);
2750 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2752 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2753 ut_params->auth_xform.next = NULL;
2754 ut_params->cipher_xform.next = &ut_params->auth_xform;
2755 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2756 &ut_params->cipher_xform,
2757 ts_params->session_priv_mpool);
2760 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2761 &ut_params->auth_xform,
2762 ts_params->session_priv_mpool);
2764 if (status == -ENOTSUP)
2765 return TEST_SKIPPED;
2767 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2773 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2774 unsigned int auth_tag_len,
2775 const uint8_t *iv, unsigned int iv_len,
2776 unsigned int data_pad_len,
2777 enum rte_crypto_auth_operation op,
2778 unsigned int auth_len, unsigned int auth_offset)
2780 struct crypto_testsuite_params *ts_params = &testsuite_params;
2782 struct crypto_unittest_params *ut_params = &unittest_params;
2784 /* Generate Crypto op data structure */
2785 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2786 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2787 TEST_ASSERT_NOT_NULL(ut_params->op,
2788 "Failed to allocate pktmbuf offload");
2790 /* Set crypto operation data parameters */
2791 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2793 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2795 /* set crypto operation source mbuf */
2796 sym_op->m_src = ut_params->ibuf;
2799 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2802 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2803 ut_params->ibuf, auth_tag_len);
2805 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2806 "no room to append auth tag");
2807 ut_params->digest = sym_op->auth.digest.data;
2808 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2809 ut_params->ibuf, data_pad_len);
2810 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2811 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2813 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2815 debug_hexdump(stdout, "digest:",
2816 sym_op->auth.digest.data,
2819 sym_op->auth.data.length = auth_len;
2820 sym_op->auth.data.offset = auth_offset;
2826 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2827 enum rte_crypto_auth_operation op)
2829 struct crypto_testsuite_params *ts_params = &testsuite_params;
2830 struct crypto_unittest_params *ut_params = &unittest_params;
2832 const uint8_t *auth_tag = tdata->digest.data;
2833 const unsigned int auth_tag_len = tdata->digest.len;
2834 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2835 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2837 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2838 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2839 const uint8_t *auth_iv = tdata->auth_iv.data;
2840 const uint8_t auth_iv_len = tdata->auth_iv.len;
2841 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2842 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2844 /* Generate Crypto op data structure */
2845 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2846 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2847 TEST_ASSERT_NOT_NULL(ut_params->op,
2848 "Failed to allocate pktmbuf offload");
2849 /* Set crypto operation data parameters */
2850 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2852 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2854 /* set crypto operation source mbuf */
2855 sym_op->m_src = ut_params->ibuf;
2858 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2859 ut_params->ibuf, auth_tag_len);
2861 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2862 "no room to append auth tag");
2863 ut_params->digest = sym_op->auth.digest.data;
2864 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2865 ut_params->ibuf, data_pad_len);
2866 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2867 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2869 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2871 debug_hexdump(stdout, "digest:",
2872 sym_op->auth.digest.data,
2875 /* Copy cipher and auth IVs at the end of the crypto operation */
2876 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2878 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2879 iv_ptr += cipher_iv_len;
2880 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2882 sym_op->cipher.data.length = cipher_len;
2883 sym_op->cipher.data.offset = 0;
2884 sym_op->auth.data.length = auth_len;
2885 sym_op->auth.data.offset = 0;
2891 create_zuc_cipher_hash_generate_operation(
2892 const struct wireless_test_data *tdata)
2894 return create_wireless_cipher_hash_operation(tdata,
2895 RTE_CRYPTO_AUTH_OP_GENERATE);
2899 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2900 const unsigned auth_tag_len,
2901 const uint8_t *auth_iv, uint8_t auth_iv_len,
2902 unsigned data_pad_len,
2903 enum rte_crypto_auth_operation op,
2904 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2905 const unsigned cipher_len, const unsigned cipher_offset,
2906 const unsigned auth_len, const unsigned auth_offset)
2908 struct crypto_testsuite_params *ts_params = &testsuite_params;
2909 struct crypto_unittest_params *ut_params = &unittest_params;
2911 enum rte_crypto_cipher_algorithm cipher_algo =
2912 ut_params->cipher_xform.cipher.algo;
2913 enum rte_crypto_auth_algorithm auth_algo =
2914 ut_params->auth_xform.auth.algo;
2916 /* Generate Crypto op data structure */
2917 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2918 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2919 TEST_ASSERT_NOT_NULL(ut_params->op,
2920 "Failed to allocate pktmbuf offload");
2921 /* Set crypto operation data parameters */
2922 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2924 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2926 /* set crypto operation source mbuf */
2927 sym_op->m_src = ut_params->ibuf;
2930 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2931 ut_params->ibuf, auth_tag_len);
2933 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2934 "no room to append auth tag");
2935 ut_params->digest = sym_op->auth.digest.data;
2937 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2938 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2939 ut_params->ibuf, data_pad_len);
2941 struct rte_mbuf *m = ut_params->ibuf;
2942 unsigned int offset = data_pad_len;
2944 while (offset > m->data_len && m->next != NULL) {
2945 offset -= m->data_len;
2948 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2952 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2953 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2955 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2957 debug_hexdump(stdout, "digest:",
2958 sym_op->auth.digest.data,
2961 /* Copy cipher and auth IVs at the end of the crypto operation */
2962 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2964 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2965 iv_ptr += cipher_iv_len;
2966 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2968 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2969 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2970 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2971 sym_op->cipher.data.length = cipher_len;
2972 sym_op->cipher.data.offset = cipher_offset;
2974 sym_op->cipher.data.length = cipher_len >> 3;
2975 sym_op->cipher.data.offset = cipher_offset >> 3;
2978 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2979 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2980 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2981 sym_op->auth.data.length = auth_len;
2982 sym_op->auth.data.offset = auth_offset;
2984 sym_op->auth.data.length = auth_len >> 3;
2985 sym_op->auth.data.offset = auth_offset >> 3;
2992 create_wireless_algo_auth_cipher_operation(
2993 const uint8_t *auth_tag, unsigned int auth_tag_len,
2994 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2995 const uint8_t *auth_iv, uint8_t auth_iv_len,
2996 unsigned int data_pad_len,
2997 unsigned int cipher_len, unsigned int cipher_offset,
2998 unsigned int auth_len, unsigned int auth_offset,
2999 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3001 struct crypto_testsuite_params *ts_params = &testsuite_params;
3002 struct crypto_unittest_params *ut_params = &unittest_params;
3004 enum rte_crypto_cipher_algorithm cipher_algo =
3005 ut_params->cipher_xform.cipher.algo;
3006 enum rte_crypto_auth_algorithm auth_algo =
3007 ut_params->auth_xform.auth.algo;
3009 /* Generate Crypto op data structure */
3010 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3011 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3012 TEST_ASSERT_NOT_NULL(ut_params->op,
3013 "Failed to allocate pktmbuf offload");
3015 /* Set crypto operation data parameters */
3016 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3018 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3020 /* set crypto operation mbufs */
3021 sym_op->m_src = ut_params->ibuf;
3022 if (op_mode == OUT_OF_PLACE)
3023 sym_op->m_dst = ut_params->obuf;
3027 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3028 (op_mode == IN_PLACE ?
3029 ut_params->ibuf : ut_params->obuf),
3030 uint8_t *, data_pad_len);
3031 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3032 (op_mode == IN_PLACE ?
3033 ut_params->ibuf : ut_params->obuf),
3035 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3037 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3038 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3039 sym_op->m_src : sym_op->m_dst);
3040 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3041 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3042 sgl_buf = sgl_buf->next;
3044 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3045 uint8_t *, remaining_off);
3046 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3048 memset(sym_op->auth.digest.data, 0, remaining_off);
3049 while (sgl_buf->next != NULL) {
3050 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3051 0, rte_pktmbuf_data_len(sgl_buf));
3052 sgl_buf = sgl_buf->next;
3056 /* Copy digest for the verification */
3058 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3060 /* Copy cipher and auth IVs at the end of the crypto operation */
3061 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3062 ut_params->op, uint8_t *, IV_OFFSET);
3064 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3065 iv_ptr += cipher_iv_len;
3066 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3068 /* Only copy over the offset data needed from src to dst in OOP,
3069 * if the auth and cipher offsets are not aligned
3071 if (op_mode == OUT_OF_PLACE) {
3072 if (cipher_offset > auth_offset)
3074 rte_pktmbuf_mtod_offset(
3076 uint8_t *, auth_offset >> 3),
3077 rte_pktmbuf_mtod_offset(
3079 uint8_t *, auth_offset >> 3),
3080 ((cipher_offset >> 3) - (auth_offset >> 3)));
3083 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3084 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3085 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3086 sym_op->cipher.data.length = cipher_len;
3087 sym_op->cipher.data.offset = cipher_offset;
3089 sym_op->cipher.data.length = cipher_len >> 3;
3090 sym_op->cipher.data.offset = cipher_offset >> 3;
3093 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3094 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3095 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3096 sym_op->auth.data.length = auth_len;
3097 sym_op->auth.data.offset = auth_offset;
3099 sym_op->auth.data.length = auth_len >> 3;
3100 sym_op->auth.data.offset = auth_offset >> 3;
3107 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3109 struct crypto_testsuite_params *ts_params = &testsuite_params;
3110 struct crypto_unittest_params *ut_params = &unittest_params;
3113 unsigned plaintext_pad_len;
3114 unsigned plaintext_len;
3116 struct rte_cryptodev_info dev_info;
3118 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3119 uint64_t feat_flags = dev_info.feature_flags;
3121 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3122 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3123 printf("Device doesn't support NON-Byte Aligned Data.\n");
3124 return TEST_SKIPPED;
3127 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3128 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3129 printf("Device doesn't support RAW data-path APIs.\n");
3130 return TEST_SKIPPED;
3133 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3134 return TEST_SKIPPED;
3136 /* Verify the capabilities */
3137 struct rte_cryptodev_sym_capability_idx cap_idx;
3138 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3139 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3140 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3142 return TEST_SKIPPED;
3144 /* Create SNOW 3G session */
3145 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3146 tdata->key.data, tdata->key.len,
3147 tdata->auth_iv.len, tdata->digest.len,
3148 RTE_CRYPTO_AUTH_OP_GENERATE,
3149 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3153 /* alloc mbuf and set payload */
3154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3156 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3157 rte_pktmbuf_tailroom(ut_params->ibuf));
3159 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3160 /* Append data which is padded to a multiple of */
3161 /* the algorithms block size */
3162 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3163 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3165 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3167 /* Create SNOW 3G operation */
3168 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3169 tdata->auth_iv.data, tdata->auth_iv.len,
3170 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3171 tdata->validAuthLenInBits.len,
3176 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3177 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3178 ut_params->op, 0, 1, 1, 0);
3180 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3182 ut_params->obuf = ut_params->op->sym->m_src;
3183 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3184 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3185 + plaintext_pad_len;
3188 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3191 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3192 "SNOW 3G Generated auth tag not as expected");
3198 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3200 struct crypto_testsuite_params *ts_params = &testsuite_params;
3201 struct crypto_unittest_params *ut_params = &unittest_params;
3204 unsigned plaintext_pad_len;
3205 unsigned plaintext_len;
3207 struct rte_cryptodev_info dev_info;
3209 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3210 uint64_t feat_flags = dev_info.feature_flags;
3212 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3213 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3214 printf("Device doesn't support NON-Byte Aligned Data.\n");
3215 return TEST_SKIPPED;
3218 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3219 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3220 printf("Device doesn't support RAW data-path APIs.\n");
3221 return TEST_SKIPPED;
3224 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3225 return TEST_SKIPPED;
3227 /* Verify the capabilities */
3228 struct rte_cryptodev_sym_capability_idx cap_idx;
3229 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3230 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3231 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3233 return TEST_SKIPPED;
3235 /* Create SNOW 3G session */
3236 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3237 tdata->key.data, tdata->key.len,
3238 tdata->auth_iv.len, tdata->digest.len,
3239 RTE_CRYPTO_AUTH_OP_VERIFY,
3240 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3243 /* alloc mbuf and set payload */
3244 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3246 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3247 rte_pktmbuf_tailroom(ut_params->ibuf));
3249 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3250 /* Append data which is padded to a multiple of */
3251 /* the algorithms block size */
3252 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3253 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3255 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3257 /* Create SNOW 3G operation */
3258 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3260 tdata->auth_iv.data, tdata->auth_iv.len,
3262 RTE_CRYPTO_AUTH_OP_VERIFY,
3263 tdata->validAuthLenInBits.len,
3268 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3269 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3270 ut_params->op, 0, 1, 1, 0);
3272 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3274 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3275 ut_params->obuf = ut_params->op->sym->m_src;
3276 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3277 + plaintext_pad_len;
3280 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3289 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3291 struct crypto_testsuite_params *ts_params = &testsuite_params;
3292 struct crypto_unittest_params *ut_params = &unittest_params;
3295 unsigned plaintext_pad_len;
3296 unsigned plaintext_len;
3298 struct rte_cryptodev_info dev_info;
3300 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3301 uint64_t feat_flags = dev_info.feature_flags;
3303 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3304 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3305 printf("Device doesn't support RAW data-path APIs.\n");
3306 return TEST_SKIPPED;
3309 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3310 return TEST_SKIPPED;
3312 /* Verify the capabilities */
3313 struct rte_cryptodev_sym_capability_idx cap_idx;
3314 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3315 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3316 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3318 return TEST_SKIPPED;
3320 /* Create KASUMI session */
3321 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3322 tdata->key.data, tdata->key.len,
3323 0, tdata->digest.len,
3324 RTE_CRYPTO_AUTH_OP_GENERATE,
3325 RTE_CRYPTO_AUTH_KASUMI_F9);
3329 /* alloc mbuf and set payload */
3330 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3332 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3333 rte_pktmbuf_tailroom(ut_params->ibuf));
3335 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3336 /* Append data which is padded to a multiple of */
3337 /* the algorithms block size */
3338 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3339 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3341 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3343 /* Create KASUMI operation */
3344 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3346 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3347 tdata->plaintext.len,
3352 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3353 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3355 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3356 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3357 ut_params->op, 0, 1, 1, 0);
3359 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3362 ut_params->obuf = ut_params->op->sym->m_src;
3363 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3364 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3365 + plaintext_pad_len;
3368 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3371 DIGEST_BYTE_LENGTH_KASUMI_F9,
3372 "KASUMI Generated auth tag not as expected");
3378 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3380 struct crypto_testsuite_params *ts_params = &testsuite_params;
3381 struct crypto_unittest_params *ut_params = &unittest_params;
3384 unsigned plaintext_pad_len;
3385 unsigned plaintext_len;
3387 struct rte_cryptodev_info dev_info;
3389 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3390 uint64_t feat_flags = dev_info.feature_flags;
3392 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3393 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3394 printf("Device doesn't support RAW data-path APIs.\n");
3395 return TEST_SKIPPED;
3398 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3399 return TEST_SKIPPED;
3401 /* Verify the capabilities */
3402 struct rte_cryptodev_sym_capability_idx cap_idx;
3403 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3404 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3405 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3407 return TEST_SKIPPED;
3409 /* Create KASUMI session */
3410 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3411 tdata->key.data, tdata->key.len,
3412 0, tdata->digest.len,
3413 RTE_CRYPTO_AUTH_OP_VERIFY,
3414 RTE_CRYPTO_AUTH_KASUMI_F9);
3417 /* alloc mbuf and set payload */
3418 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3420 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3421 rte_pktmbuf_tailroom(ut_params->ibuf));
3423 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3424 /* Append data which is padded to a multiple */
3425 /* of the algorithms block size */
3426 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3427 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3429 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3431 /* Create KASUMI operation */
3432 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3436 RTE_CRYPTO_AUTH_OP_VERIFY,
3437 tdata->plaintext.len,
3442 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3443 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3444 ut_params->op, 0, 1, 1, 0);
3446 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3448 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3449 ut_params->obuf = ut_params->op->sym->m_src;
3450 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3451 + plaintext_pad_len;
3454 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3463 test_snow3g_hash_generate_test_case_1(void)
3465 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3469 test_snow3g_hash_generate_test_case_2(void)
3471 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3475 test_snow3g_hash_generate_test_case_3(void)
3477 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3481 test_snow3g_hash_generate_test_case_4(void)
3483 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3487 test_snow3g_hash_generate_test_case_5(void)
3489 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3493 test_snow3g_hash_generate_test_case_6(void)
3495 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3499 test_snow3g_hash_verify_test_case_1(void)
3501 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3506 test_snow3g_hash_verify_test_case_2(void)
3508 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3512 test_snow3g_hash_verify_test_case_3(void)
3514 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3518 test_snow3g_hash_verify_test_case_4(void)
3520 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3524 test_snow3g_hash_verify_test_case_5(void)
3526 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3530 test_snow3g_hash_verify_test_case_6(void)
3532 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3536 test_kasumi_hash_generate_test_case_1(void)
3538 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3542 test_kasumi_hash_generate_test_case_2(void)
3544 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3548 test_kasumi_hash_generate_test_case_3(void)
3550 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3554 test_kasumi_hash_generate_test_case_4(void)
3556 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3560 test_kasumi_hash_generate_test_case_5(void)
3562 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3566 test_kasumi_hash_generate_test_case_6(void)
3568 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3572 test_kasumi_hash_verify_test_case_1(void)
3574 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3578 test_kasumi_hash_verify_test_case_2(void)
3580 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3584 test_kasumi_hash_verify_test_case_3(void)
3586 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3590 test_kasumi_hash_verify_test_case_4(void)
3592 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3596 test_kasumi_hash_verify_test_case_5(void)
3598 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3602 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3604 struct crypto_testsuite_params *ts_params = &testsuite_params;
3605 struct crypto_unittest_params *ut_params = &unittest_params;
3608 uint8_t *plaintext, *ciphertext;
3609 unsigned plaintext_pad_len;
3610 unsigned plaintext_len;
3611 struct rte_cryptodev_info dev_info;
3613 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3614 uint64_t feat_flags = dev_info.feature_flags;
3616 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3617 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3618 printf("Device doesn't support RAW data-path APIs.\n");
3619 return TEST_SKIPPED;
3622 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3623 return TEST_SKIPPED;
3625 /* Verify the capabilities */
3626 struct rte_cryptodev_sym_capability_idx cap_idx;
3627 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3628 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3629 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3631 return TEST_SKIPPED;
3633 /* Create KASUMI session */
3634 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3635 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3636 RTE_CRYPTO_CIPHER_KASUMI_F8,
3637 tdata->key.data, tdata->key.len,
3638 tdata->cipher_iv.len);
3642 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3644 /* Clear mbuf payload */
3645 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3646 rte_pktmbuf_tailroom(ut_params->ibuf));
3648 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3649 /* Append data which is padded to a multiple */
3650 /* of the algorithms block size */
3651 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3652 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3654 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3656 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3658 /* Create KASUMI operation */
3659 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3660 tdata->cipher_iv.len,
3661 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3662 tdata->validCipherOffsetInBits.len);
3666 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3667 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3668 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3670 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3672 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3674 ut_params->obuf = ut_params->op->sym->m_dst;
3675 if (ut_params->obuf)
3676 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3678 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3680 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3682 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3683 (tdata->validCipherOffsetInBits.len >> 3);
3685 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3687 reference_ciphertext,
3688 tdata->validCipherLenInBits.len,
3689 "KASUMI Ciphertext data not as expected");
3694 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3696 struct crypto_testsuite_params *ts_params = &testsuite_params;
3697 struct crypto_unittest_params *ut_params = &unittest_params;
3701 unsigned int plaintext_pad_len;
3702 unsigned int plaintext_len;
3704 uint8_t buffer[10000];
3705 const uint8_t *ciphertext;
3707 struct rte_cryptodev_info dev_info;
3709 /* Verify the capabilities */
3710 struct rte_cryptodev_sym_capability_idx cap_idx;
3711 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3712 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3713 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3715 return TEST_SKIPPED;
3717 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3719 uint64_t feat_flags = dev_info.feature_flags;
3721 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3722 printf("Device doesn't support in-place scatter-gather. "
3724 return TEST_SKIPPED;
3727 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3728 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3729 printf("Device doesn't support RAW data-path APIs.\n");
3730 return TEST_SKIPPED;
3733 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3734 return TEST_SKIPPED;
3736 /* Create KASUMI session */
3737 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3738 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3739 RTE_CRYPTO_CIPHER_KASUMI_F8,
3740 tdata->key.data, tdata->key.len,
3741 tdata->cipher_iv.len);
3745 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3748 /* Append data which is padded to a multiple */
3749 /* of the algorithms block size */
3750 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3752 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3753 plaintext_pad_len, 10, 0);
3755 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3757 /* Create KASUMI operation */
3758 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3759 tdata->cipher_iv.len,
3760 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3761 tdata->validCipherOffsetInBits.len);
3765 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3766 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3767 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3769 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3771 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3773 ut_params->obuf = ut_params->op->sym->m_dst;
3775 if (ut_params->obuf)
3776 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3777 plaintext_len, buffer);
3779 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3780 tdata->validCipherOffsetInBits.len >> 3,
3781 plaintext_len, buffer);
3784 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3786 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3787 (tdata->validCipherOffsetInBits.len >> 3);
3789 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3791 reference_ciphertext,
3792 tdata->validCipherLenInBits.len,
3793 "KASUMI Ciphertext data not as expected");
3798 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3800 struct crypto_testsuite_params *ts_params = &testsuite_params;
3801 struct crypto_unittest_params *ut_params = &unittest_params;
3804 uint8_t *plaintext, *ciphertext;
3805 unsigned plaintext_pad_len;
3806 unsigned plaintext_len;
3808 /* Verify the capabilities */
3809 struct rte_cryptodev_sym_capability_idx cap_idx;
3810 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3811 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3812 /* Data-path service does not support OOP */
3813 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3815 return TEST_SKIPPED;
3817 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3818 return TEST_SKIPPED;
3820 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3821 return TEST_SKIPPED;
3823 /* Create KASUMI session */
3824 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3825 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3826 RTE_CRYPTO_CIPHER_KASUMI_F8,
3827 tdata->key.data, tdata->key.len,
3828 tdata->cipher_iv.len);
3832 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3833 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3835 /* Clear mbuf payload */
3836 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3837 rte_pktmbuf_tailroom(ut_params->ibuf));
3839 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3840 /* Append data which is padded to a multiple */
3841 /* of the algorithms block size */
3842 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3843 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3845 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3846 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3848 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3850 /* Create KASUMI operation */
3851 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3852 tdata->cipher_iv.len,
3853 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3854 tdata->validCipherOffsetInBits.len);
3858 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3860 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3862 ut_params->obuf = ut_params->op->sym->m_dst;
3863 if (ut_params->obuf)
3864 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3866 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3868 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3870 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3871 (tdata->validCipherOffsetInBits.len >> 3);
3873 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3875 reference_ciphertext,
3876 tdata->validCipherLenInBits.len,
3877 "KASUMI Ciphertext data not as expected");
3882 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3884 struct crypto_testsuite_params *ts_params = &testsuite_params;
3885 struct crypto_unittest_params *ut_params = &unittest_params;
3888 unsigned int plaintext_pad_len;
3889 unsigned int plaintext_len;
3891 const uint8_t *ciphertext;
3892 uint8_t buffer[2048];
3894 struct rte_cryptodev_info dev_info;
3896 /* Verify the capabilities */
3897 struct rte_cryptodev_sym_capability_idx cap_idx;
3898 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3899 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3900 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3902 return TEST_SKIPPED;
3904 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3905 return TEST_SKIPPED;
3907 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3908 return TEST_SKIPPED;
3910 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3912 uint64_t feat_flags = dev_info.feature_flags;
3913 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3914 printf("Device doesn't support out-of-place scatter-gather "
3915 "in both input and output mbufs. "
3917 return TEST_SKIPPED;
3920 /* Create KASUMI session */
3921 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3922 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3923 RTE_CRYPTO_CIPHER_KASUMI_F8,
3924 tdata->key.data, tdata->key.len,
3925 tdata->cipher_iv.len);
3929 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3930 /* Append data which is padded to a multiple */
3931 /* of the algorithms block size */
3932 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3934 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3935 plaintext_pad_len, 10, 0);
3936 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3937 plaintext_pad_len, 3, 0);
3939 /* Append data which is padded to a multiple */
3940 /* of the algorithms block size */
3941 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3943 /* Create KASUMI operation */
3944 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3945 tdata->cipher_iv.len,
3946 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3947 tdata->validCipherOffsetInBits.len);
3951 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3953 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3955 ut_params->obuf = ut_params->op->sym->m_dst;
3956 if (ut_params->obuf)
3957 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3958 plaintext_pad_len, buffer);
3960 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3961 tdata->validCipherOffsetInBits.len >> 3,
3962 plaintext_pad_len, buffer);
3964 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3965 (tdata->validCipherOffsetInBits.len >> 3);
3967 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3969 reference_ciphertext,
3970 tdata->validCipherLenInBits.len,
3971 "KASUMI Ciphertext data not as expected");
3977 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3979 struct crypto_testsuite_params *ts_params = &testsuite_params;
3980 struct crypto_unittest_params *ut_params = &unittest_params;
3983 uint8_t *ciphertext, *plaintext;
3984 unsigned ciphertext_pad_len;
3985 unsigned ciphertext_len;
3987 /* Verify the capabilities */
3988 struct rte_cryptodev_sym_capability_idx cap_idx;
3989 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3990 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3991 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3993 return TEST_SKIPPED;
3995 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3996 return TEST_SKIPPED;
3998 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3999 return TEST_SKIPPED;
4001 /* Create KASUMI session */
4002 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4003 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4004 RTE_CRYPTO_CIPHER_KASUMI_F8,
4005 tdata->key.data, tdata->key.len,
4006 tdata->cipher_iv.len);
4010 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4011 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4013 /* Clear mbuf payload */
4014 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4015 rte_pktmbuf_tailroom(ut_params->ibuf));
4017 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4018 /* Append data which is padded to a multiple */
4019 /* of the algorithms block size */
4020 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4021 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4022 ciphertext_pad_len);
4023 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4024 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4026 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4028 /* Create KASUMI operation */
4029 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4030 tdata->cipher_iv.len,
4031 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4032 tdata->validCipherOffsetInBits.len);
4036 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4038 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4040 ut_params->obuf = ut_params->op->sym->m_dst;
4041 if (ut_params->obuf)
4042 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4044 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4046 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4048 const uint8_t *reference_plaintext = tdata->plaintext.data +
4049 (tdata->validCipherOffsetInBits.len >> 3);
4051 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4053 reference_plaintext,
4054 tdata->validCipherLenInBits.len,
4055 "KASUMI Plaintext data not as expected");
4060 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4062 struct crypto_testsuite_params *ts_params = &testsuite_params;
4063 struct crypto_unittest_params *ut_params = &unittest_params;
4066 uint8_t *ciphertext, *plaintext;
4067 unsigned ciphertext_pad_len;
4068 unsigned ciphertext_len;
4069 struct rte_cryptodev_info dev_info;
4071 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4072 uint64_t feat_flags = dev_info.feature_flags;
4074 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4075 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4076 printf("Device doesn't support RAW data-path APIs.\n");
4077 return TEST_SKIPPED;
4080 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4081 return TEST_SKIPPED;
4083 /* Verify the capabilities */
4084 struct rte_cryptodev_sym_capability_idx cap_idx;
4085 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4086 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4087 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4089 return TEST_SKIPPED;
4091 /* Create KASUMI session */
4092 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4093 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4094 RTE_CRYPTO_CIPHER_KASUMI_F8,
4095 tdata->key.data, tdata->key.len,
4096 tdata->cipher_iv.len);
4100 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4102 /* Clear mbuf payload */
4103 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4104 rte_pktmbuf_tailroom(ut_params->ibuf));
4106 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4107 /* Append data which is padded to a multiple */
4108 /* of the algorithms block size */
4109 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4110 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4111 ciphertext_pad_len);
4112 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4114 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4116 /* Create KASUMI operation */
4117 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4118 tdata->cipher_iv.len,
4119 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4120 tdata->validCipherOffsetInBits.len);
4124 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4125 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4126 ut_params->op, 1, 0, 1, 0);
4128 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4130 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4132 ut_params->obuf = ut_params->op->sym->m_dst;
4133 if (ut_params->obuf)
4134 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4136 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4138 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4140 const uint8_t *reference_plaintext = tdata->plaintext.data +
4141 (tdata->validCipherOffsetInBits.len >> 3);
4143 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4145 reference_plaintext,
4146 tdata->validCipherLenInBits.len,
4147 "KASUMI Plaintext data not as expected");
4152 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4154 struct crypto_testsuite_params *ts_params = &testsuite_params;
4155 struct crypto_unittest_params *ut_params = &unittest_params;
4158 uint8_t *plaintext, *ciphertext;
4159 unsigned plaintext_pad_len;
4160 unsigned plaintext_len;
4161 struct rte_cryptodev_info dev_info;
4163 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4164 uint64_t feat_flags = dev_info.feature_flags;
4166 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4167 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4168 printf("Device doesn't support RAW data-path APIs.\n");
4169 return TEST_SKIPPED;
4172 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4173 return TEST_SKIPPED;
4175 /* Verify the capabilities */
4176 struct rte_cryptodev_sym_capability_idx cap_idx;
4177 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4178 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4179 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4181 return TEST_SKIPPED;
4183 /* Create SNOW 3G session */
4184 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4185 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4186 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4187 tdata->key.data, tdata->key.len,
4188 tdata->cipher_iv.len);
4192 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4194 /* Clear mbuf payload */
4195 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4196 rte_pktmbuf_tailroom(ut_params->ibuf));
4198 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4199 /* Append data which is padded to a multiple of */
4200 /* the algorithms block size */
4201 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4202 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4204 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4206 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4208 /* Create SNOW 3G operation */
4209 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4210 tdata->cipher_iv.len,
4211 tdata->validCipherLenInBits.len,
4216 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4217 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4218 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4220 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4222 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4224 ut_params->obuf = ut_params->op->sym->m_dst;
4225 if (ut_params->obuf)
4226 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4228 ciphertext = plaintext;
4230 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4233 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4235 tdata->ciphertext.data,
4236 tdata->validDataLenInBits.len,
4237 "SNOW 3G Ciphertext data not as expected");
4243 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4245 struct crypto_testsuite_params *ts_params = &testsuite_params;
4246 struct crypto_unittest_params *ut_params = &unittest_params;
4247 uint8_t *plaintext, *ciphertext;
4250 unsigned plaintext_pad_len;
4251 unsigned plaintext_len;
4252 struct rte_cryptodev_info dev_info;
4254 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4255 uint64_t feat_flags = dev_info.feature_flags;
4257 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4258 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4259 printf("Device does not support RAW data-path APIs.\n");
4263 /* Verify the capabilities */
4264 struct rte_cryptodev_sym_capability_idx cap_idx;
4265 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4266 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4267 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4269 return TEST_SKIPPED;
4271 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4272 return TEST_SKIPPED;
4274 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4275 return TEST_SKIPPED;
4277 /* Create SNOW 3G session */
4278 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4279 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4280 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4281 tdata->key.data, tdata->key.len,
4282 tdata->cipher_iv.len);
4286 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4287 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4289 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4290 "Failed to allocate input buffer in mempool");
4291 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4292 "Failed to allocate output buffer in mempool");
4294 /* Clear mbuf payload */
4295 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4296 rte_pktmbuf_tailroom(ut_params->ibuf));
4298 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4299 /* Append data which is padded to a multiple of */
4300 /* the algorithms block size */
4301 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4302 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4304 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4305 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4307 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4309 /* Create SNOW 3G operation */
4310 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4311 tdata->cipher_iv.len,
4312 tdata->validCipherLenInBits.len,
4317 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4318 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4319 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4321 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4323 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4325 ut_params->obuf = ut_params->op->sym->m_dst;
4326 if (ut_params->obuf)
4327 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4329 ciphertext = plaintext;
4331 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4334 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4336 tdata->ciphertext.data,
4337 tdata->validDataLenInBits.len,
4338 "SNOW 3G Ciphertext data not as expected");
4343 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4345 struct crypto_testsuite_params *ts_params = &testsuite_params;
4346 struct crypto_unittest_params *ut_params = &unittest_params;
4349 unsigned int plaintext_pad_len;
4350 unsigned int plaintext_len;
4351 uint8_t buffer[10000];
4352 const uint8_t *ciphertext;
4354 struct rte_cryptodev_info dev_info;
4356 /* Verify the capabilities */
4357 struct rte_cryptodev_sym_capability_idx cap_idx;
4358 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4359 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4360 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4362 return TEST_SKIPPED;
4364 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4365 return TEST_SKIPPED;
4367 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4368 return TEST_SKIPPED;
4370 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4372 uint64_t feat_flags = dev_info.feature_flags;
4374 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4375 printf("Device doesn't support out-of-place scatter-gather "
4376 "in both input and output mbufs. "
4378 return TEST_SKIPPED;
4381 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4382 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4383 printf("Device does not support RAW data-path APIs.\n");
4387 /* Create SNOW 3G session */
4388 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4389 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4390 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4391 tdata->key.data, tdata->key.len,
4392 tdata->cipher_iv.len);
4396 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4397 /* Append data which is padded to a multiple of */
4398 /* the algorithms block size */
4399 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4401 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4402 plaintext_pad_len, 10, 0);
4403 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4404 plaintext_pad_len, 3, 0);
4406 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4407 "Failed to allocate input buffer in mempool");
4408 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4409 "Failed to allocate output buffer in mempool");
4411 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4413 /* Create SNOW 3G operation */
4414 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4415 tdata->cipher_iv.len,
4416 tdata->validCipherLenInBits.len,
4421 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4422 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4423 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4425 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4427 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4429 ut_params->obuf = ut_params->op->sym->m_dst;
4430 if (ut_params->obuf)
4431 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4432 plaintext_len, buffer);
4434 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4435 plaintext_len, buffer);
4437 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4440 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4442 tdata->ciphertext.data,
4443 tdata->validDataLenInBits.len,
4444 "SNOW 3G Ciphertext data not as expected");
4449 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4451 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4453 uint8_t curr_byte, prev_byte;
4454 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4455 uint8_t lower_byte_mask = (1 << offset) - 1;
4458 prev_byte = buffer[0];
4459 buffer[0] >>= offset;
4461 for (i = 1; i < length_in_bytes; i++) {
4462 curr_byte = buffer[i];
4463 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4464 (curr_byte >> offset);
4465 prev_byte = curr_byte;
4470 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4472 struct crypto_testsuite_params *ts_params = &testsuite_params;
4473 struct crypto_unittest_params *ut_params = &unittest_params;
4474 uint8_t *plaintext, *ciphertext;
4476 uint32_t plaintext_len;
4477 uint32_t plaintext_pad_len;
4478 uint8_t extra_offset = 4;
4479 uint8_t *expected_ciphertext_shifted;
4480 struct rte_cryptodev_info dev_info;
4482 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4483 uint64_t feat_flags = dev_info.feature_flags;
4485 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4486 ((tdata->validDataLenInBits.len % 8) != 0)) {
4487 printf("Device doesn't support NON-Byte Aligned Data.\n");
4488 return TEST_SKIPPED;
4491 /* Verify the capabilities */
4492 struct rte_cryptodev_sym_capability_idx cap_idx;
4493 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4494 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4495 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4497 return TEST_SKIPPED;
4499 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4500 return TEST_SKIPPED;
4502 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4503 return TEST_SKIPPED;
4505 /* Create SNOW 3G session */
4506 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4507 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4508 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4509 tdata->key.data, tdata->key.len,
4510 tdata->cipher_iv.len);
4514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4515 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4517 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4518 "Failed to allocate input buffer in mempool");
4519 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4520 "Failed to allocate output buffer in mempool");
4522 /* Clear mbuf payload */
4523 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4524 rte_pktmbuf_tailroom(ut_params->ibuf));
4526 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4528 * Append data which is padded to a
4529 * multiple of the algorithms block size
4531 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4533 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4536 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4538 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4539 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4541 #ifdef RTE_APP_TEST_DEBUG
4542 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4544 /* Create SNOW 3G operation */
4545 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4546 tdata->cipher_iv.len,
4547 tdata->validCipherLenInBits.len,
4552 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4553 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4554 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4556 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4558 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4560 ut_params->obuf = ut_params->op->sym->m_dst;
4561 if (ut_params->obuf)
4562 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4564 ciphertext = plaintext;
4566 #ifdef RTE_APP_TEST_DEBUG
4567 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4570 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4572 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4573 "failed to reserve memory for ciphertext shifted\n");
4575 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4576 ceil_byte_length(tdata->ciphertext.len));
4577 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4580 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4582 expected_ciphertext_shifted,
4583 tdata->validDataLenInBits.len,
4585 "SNOW 3G Ciphertext data not as expected");
4589 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4591 struct crypto_testsuite_params *ts_params = &testsuite_params;
4592 struct crypto_unittest_params *ut_params = &unittest_params;
4596 uint8_t *plaintext, *ciphertext;
4597 unsigned ciphertext_pad_len;
4598 unsigned ciphertext_len;
4599 struct rte_cryptodev_info dev_info;
4601 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4602 uint64_t feat_flags = dev_info.feature_flags;
4604 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4605 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4606 printf("Device doesn't support RAW data-path APIs.\n");
4607 return TEST_SKIPPED;
4610 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4611 return TEST_SKIPPED;
4613 /* Verify the capabilities */
4614 struct rte_cryptodev_sym_capability_idx cap_idx;
4615 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4616 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4617 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4619 return TEST_SKIPPED;
4621 /* Create SNOW 3G session */
4622 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4623 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4624 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4625 tdata->key.data, tdata->key.len,
4626 tdata->cipher_iv.len);
4630 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4632 /* Clear mbuf payload */
4633 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4634 rte_pktmbuf_tailroom(ut_params->ibuf));
4636 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4637 /* Append data which is padded to a multiple of */
4638 /* the algorithms block size */
4639 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4640 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4641 ciphertext_pad_len);
4642 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4644 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4646 /* Create SNOW 3G operation */
4647 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4648 tdata->cipher_iv.len,
4649 tdata->validCipherLenInBits.len,
4650 tdata->cipher.offset_bits);
4654 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4655 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4656 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4658 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4660 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4661 ut_params->obuf = ut_params->op->sym->m_dst;
4662 if (ut_params->obuf)
4663 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4665 plaintext = ciphertext;
4667 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4670 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4671 tdata->plaintext.data,
4672 tdata->validDataLenInBits.len,
4673 "SNOW 3G Plaintext data not as expected");
4677 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4679 struct crypto_testsuite_params *ts_params = &testsuite_params;
4680 struct crypto_unittest_params *ut_params = &unittest_params;
4684 uint8_t *plaintext, *ciphertext;
4685 unsigned ciphertext_pad_len;
4686 unsigned ciphertext_len;
4687 struct rte_cryptodev_info dev_info;
4689 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4690 uint64_t feat_flags = dev_info.feature_flags;
4692 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4693 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4694 printf("Device does not support RAW data-path APIs.\n");
4697 /* Verify the capabilities */
4698 struct rte_cryptodev_sym_capability_idx cap_idx;
4699 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4700 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4701 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4703 return TEST_SKIPPED;
4705 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4706 return TEST_SKIPPED;
4708 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4709 return TEST_SKIPPED;
4711 /* Create SNOW 3G session */
4712 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4713 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4714 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4715 tdata->key.data, tdata->key.len,
4716 tdata->cipher_iv.len);
4720 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4721 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4723 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4724 "Failed to allocate input buffer");
4725 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4726 "Failed to allocate output buffer");
4728 /* Clear mbuf payload */
4729 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4730 rte_pktmbuf_tailroom(ut_params->ibuf));
4732 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4733 rte_pktmbuf_tailroom(ut_params->obuf));
4735 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4736 /* Append data which is padded to a multiple of */
4737 /* the algorithms block size */
4738 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4739 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4740 ciphertext_pad_len);
4741 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4742 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4744 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4746 /* Create SNOW 3G operation */
4747 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4748 tdata->cipher_iv.len,
4749 tdata->validCipherLenInBits.len,
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, 0, 1, tdata->cipher_iv.len);
4758 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4760 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4761 ut_params->obuf = ut_params->op->sym->m_dst;
4762 if (ut_params->obuf)
4763 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4765 plaintext = ciphertext;
4767 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4770 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4771 tdata->plaintext.data,
4772 tdata->validDataLenInBits.len,
4773 "SNOW 3G Plaintext data not as expected");
4778 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4780 struct crypto_testsuite_params *ts_params = &testsuite_params;
4781 struct crypto_unittest_params *ut_params = &unittest_params;
4785 uint8_t *plaintext, *ciphertext;
4786 unsigned int plaintext_pad_len;
4787 unsigned int plaintext_len;
4789 struct rte_cryptodev_info dev_info;
4790 struct rte_cryptodev_sym_capability_idx cap_idx;
4792 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4793 uint64_t feat_flags = dev_info.feature_flags;
4795 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4796 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4797 (tdata->validDataLenInBits.len % 8 != 0))) {
4798 printf("Device doesn't support NON-Byte Aligned Data.\n");
4799 return TEST_SKIPPED;
4802 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4803 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4804 printf("Device doesn't support RAW data-path APIs.\n");
4805 return TEST_SKIPPED;
4808 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4809 return TEST_SKIPPED;
4811 /* Check if device supports ZUC EEA3 */
4812 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4813 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4815 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4817 return TEST_SKIPPED;
4819 /* Check if device supports ZUC EIA3 */
4820 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4821 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4823 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4825 return TEST_SKIPPED;
4827 /* Create ZUC session */
4828 retval = create_zuc_cipher_auth_encrypt_generate_session(
4829 ts_params->valid_devs[0],
4833 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4835 /* clear mbuf payload */
4836 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4837 rte_pktmbuf_tailroom(ut_params->ibuf));
4839 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4840 /* Append data which is padded to a multiple of */
4841 /* the algorithms block size */
4842 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4843 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4845 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4847 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4849 /* Create ZUC operation */
4850 retval = create_zuc_cipher_hash_generate_operation(tdata);
4854 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4855 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4856 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4858 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4860 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4861 ut_params->obuf = ut_params->op->sym->m_src;
4862 if (ut_params->obuf)
4863 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4865 ciphertext = plaintext;
4867 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4869 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4871 tdata->ciphertext.data,
4872 tdata->validDataLenInBits.len,
4873 "ZUC Ciphertext data not as expected");
4875 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4876 + plaintext_pad_len;
4879 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4883 "ZUC Generated auth tag not as expected");
4888 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4890 struct crypto_testsuite_params *ts_params = &testsuite_params;
4891 struct crypto_unittest_params *ut_params = &unittest_params;
4895 uint8_t *plaintext, *ciphertext;
4896 unsigned plaintext_pad_len;
4897 unsigned plaintext_len;
4898 struct rte_cryptodev_info dev_info;
4900 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4901 uint64_t feat_flags = dev_info.feature_flags;
4903 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4904 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4905 printf("Device doesn't support RAW data-path APIs.\n");
4906 return TEST_SKIPPED;
4909 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4910 return TEST_SKIPPED;
4912 /* Verify the capabilities */
4913 struct rte_cryptodev_sym_capability_idx cap_idx;
4914 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4915 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4916 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4918 return TEST_SKIPPED;
4919 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4920 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4921 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4923 return TEST_SKIPPED;
4925 /* Create SNOW 3G session */
4926 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4927 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4928 RTE_CRYPTO_AUTH_OP_GENERATE,
4929 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4930 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4931 tdata->key.data, tdata->key.len,
4932 tdata->auth_iv.len, tdata->digest.len,
4933 tdata->cipher_iv.len);
4936 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4938 /* clear mbuf payload */
4939 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4940 rte_pktmbuf_tailroom(ut_params->ibuf));
4942 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4943 /* Append data which is padded to a multiple of */
4944 /* the algorithms block size */
4945 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4946 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4948 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4950 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4952 /* Create SNOW 3G operation */
4953 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4954 tdata->digest.len, tdata->auth_iv.data,
4956 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4957 tdata->cipher_iv.data, tdata->cipher_iv.len,
4958 tdata->validCipherLenInBits.len,
4960 tdata->validAuthLenInBits.len,
4966 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4967 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4968 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4970 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4972 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4973 ut_params->obuf = ut_params->op->sym->m_src;
4974 if (ut_params->obuf)
4975 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4977 ciphertext = plaintext;
4979 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4981 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4983 tdata->ciphertext.data,
4984 tdata->validDataLenInBits.len,
4985 "SNOW 3G Ciphertext data not as expected");
4987 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4988 + plaintext_pad_len;
4991 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4994 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4995 "SNOW 3G Generated auth tag not as expected");
5000 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5001 uint8_t op_mode, uint8_t verify)
5003 struct crypto_testsuite_params *ts_params = &testsuite_params;
5004 struct crypto_unittest_params *ut_params = &unittest_params;
5008 uint8_t *plaintext = NULL, *ciphertext = NULL;
5009 unsigned int plaintext_pad_len;
5010 unsigned int plaintext_len;
5011 unsigned int ciphertext_pad_len;
5012 unsigned int ciphertext_len;
5014 struct rte_cryptodev_info dev_info;
5016 /* Verify the capabilities */
5017 struct rte_cryptodev_sym_capability_idx cap_idx;
5018 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5019 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5020 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5022 return TEST_SKIPPED;
5023 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5024 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5025 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5027 return TEST_SKIPPED;
5029 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5030 return TEST_SKIPPED;
5032 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5034 uint64_t feat_flags = dev_info.feature_flags;
5036 if (op_mode == OUT_OF_PLACE) {
5037 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5038 printf("Device doesn't support digest encrypted.\n");
5039 return TEST_SKIPPED;
5041 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5042 return TEST_SKIPPED;
5045 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5046 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5047 printf("Device doesn't support RAW data-path APIs.\n");
5048 return TEST_SKIPPED;
5051 /* Create SNOW 3G session */
5052 retval = create_wireless_algo_auth_cipher_session(
5053 ts_params->valid_devs[0],
5054 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5055 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5056 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5057 : RTE_CRYPTO_AUTH_OP_GENERATE),
5058 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5059 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5060 tdata->key.data, tdata->key.len,
5061 tdata->auth_iv.len, tdata->digest.len,
5062 tdata->cipher_iv.len);
5066 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5067 if (op_mode == OUT_OF_PLACE)
5068 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5070 /* clear mbuf payload */
5071 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5072 rte_pktmbuf_tailroom(ut_params->ibuf));
5073 if (op_mode == OUT_OF_PLACE)
5074 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5075 rte_pktmbuf_tailroom(ut_params->obuf));
5077 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5078 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5079 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5080 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5083 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5084 ciphertext_pad_len);
5085 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5086 if (op_mode == OUT_OF_PLACE)
5087 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5088 debug_hexdump(stdout, "ciphertext:", ciphertext,
5091 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5093 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5094 if (op_mode == OUT_OF_PLACE)
5095 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5096 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5099 /* Create SNOW 3G operation */
5100 retval = create_wireless_algo_auth_cipher_operation(
5101 tdata->digest.data, tdata->digest.len,
5102 tdata->cipher_iv.data, tdata->cipher_iv.len,
5103 tdata->auth_iv.data, tdata->auth_iv.len,
5104 (tdata->digest.offset_bytes == 0 ?
5105 (verify ? ciphertext_pad_len : plaintext_pad_len)
5106 : tdata->digest.offset_bytes),
5107 tdata->validCipherLenInBits.len,
5108 tdata->cipher.offset_bits,
5109 tdata->validAuthLenInBits.len,
5110 tdata->auth.offset_bits,
5111 op_mode, 0, verify);
5116 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5117 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5118 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5123 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5125 ut_params->obuf = (op_mode == IN_PLACE ?
5126 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5129 if (ut_params->obuf)
5130 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5133 plaintext = ciphertext +
5134 (tdata->cipher.offset_bits >> 3);
5136 debug_hexdump(stdout, "plaintext:", plaintext,
5137 (tdata->plaintext.len >> 3) - tdata->digest.len);
5138 debug_hexdump(stdout, "plaintext expected:",
5139 tdata->plaintext.data,
5140 (tdata->plaintext.len >> 3) - tdata->digest.len);
5142 if (ut_params->obuf)
5143 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5146 ciphertext = plaintext;
5148 debug_hexdump(stdout, "ciphertext:", ciphertext,
5150 debug_hexdump(stdout, "ciphertext expected:",
5151 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5153 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5154 + (tdata->digest.offset_bytes == 0 ?
5155 plaintext_pad_len : tdata->digest.offset_bytes);
5157 debug_hexdump(stdout, "digest:", ut_params->digest,
5159 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5165 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5167 tdata->plaintext.data,
5168 (tdata->plaintext.len - tdata->cipher.offset_bits -
5169 (tdata->digest.len << 3)),
5170 tdata->cipher.offset_bits,
5171 "SNOW 3G Plaintext data not as expected");
5173 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5175 tdata->ciphertext.data,
5176 (tdata->validDataLenInBits.len -
5177 tdata->cipher.offset_bits),
5178 tdata->cipher.offset_bits,
5179 "SNOW 3G Ciphertext data not as expected");
5181 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5184 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5185 "SNOW 3G Generated auth tag not as expected");
5191 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5192 uint8_t op_mode, uint8_t verify)
5194 struct crypto_testsuite_params *ts_params = &testsuite_params;
5195 struct crypto_unittest_params *ut_params = &unittest_params;
5199 const uint8_t *plaintext = NULL;
5200 const uint8_t *ciphertext = NULL;
5201 const uint8_t *digest = NULL;
5202 unsigned int plaintext_pad_len;
5203 unsigned int plaintext_len;
5204 unsigned int ciphertext_pad_len;
5205 unsigned int ciphertext_len;
5206 uint8_t buffer[10000];
5207 uint8_t digest_buffer[10000];
5209 struct rte_cryptodev_info dev_info;
5211 /* Verify the capabilities */
5212 struct rte_cryptodev_sym_capability_idx cap_idx;
5213 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5214 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5215 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5217 return TEST_SKIPPED;
5218 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5219 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5220 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5222 return TEST_SKIPPED;
5224 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5225 return TEST_SKIPPED;
5227 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5229 uint64_t feat_flags = dev_info.feature_flags;
5231 if (op_mode == IN_PLACE) {
5232 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5233 printf("Device doesn't support in-place scatter-gather "
5234 "in both input and output mbufs.\n");
5235 return TEST_SKIPPED;
5237 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5238 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5239 printf("Device doesn't support RAW data-path APIs.\n");
5240 return TEST_SKIPPED;
5243 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5244 return TEST_SKIPPED;
5245 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5246 printf("Device doesn't support out-of-place scatter-gather "
5247 "in both input and output mbufs.\n");
5248 return TEST_SKIPPED;
5250 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5251 printf("Device doesn't support digest encrypted.\n");
5252 return TEST_SKIPPED;
5256 /* Create SNOW 3G session */
5257 retval = create_wireless_algo_auth_cipher_session(
5258 ts_params->valid_devs[0],
5259 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5260 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5261 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5262 : RTE_CRYPTO_AUTH_OP_GENERATE),
5263 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5264 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5265 tdata->key.data, tdata->key.len,
5266 tdata->auth_iv.len, tdata->digest.len,
5267 tdata->cipher_iv.len);
5272 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5273 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5274 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5275 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5277 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5278 plaintext_pad_len, 15, 0);
5279 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5280 "Failed to allocate input buffer in mempool");
5282 if (op_mode == OUT_OF_PLACE) {
5283 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5284 plaintext_pad_len, 15, 0);
5285 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5286 "Failed to allocate output buffer in mempool");
5290 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5291 tdata->ciphertext.data);
5292 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5293 ciphertext_len, buffer);
5294 debug_hexdump(stdout, "ciphertext:", ciphertext,
5297 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5298 tdata->plaintext.data);
5299 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5300 plaintext_len, buffer);
5301 debug_hexdump(stdout, "plaintext:", plaintext,
5304 memset(buffer, 0, sizeof(buffer));
5306 /* Create SNOW 3G operation */
5307 retval = create_wireless_algo_auth_cipher_operation(
5308 tdata->digest.data, tdata->digest.len,
5309 tdata->cipher_iv.data, tdata->cipher_iv.len,
5310 tdata->auth_iv.data, tdata->auth_iv.len,
5311 (tdata->digest.offset_bytes == 0 ?
5312 (verify ? ciphertext_pad_len : plaintext_pad_len)
5313 : tdata->digest.offset_bytes),
5314 tdata->validCipherLenInBits.len,
5315 tdata->cipher.offset_bits,
5316 tdata->validAuthLenInBits.len,
5317 tdata->auth.offset_bits,
5318 op_mode, 1, verify);
5323 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5324 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5325 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5327 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5330 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5332 ut_params->obuf = (op_mode == IN_PLACE ?
5333 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5336 if (ut_params->obuf)
5337 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5338 plaintext_len, buffer);
5340 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5341 plaintext_len, buffer);
5343 debug_hexdump(stdout, "plaintext:", plaintext,
5344 (tdata->plaintext.len >> 3) - tdata->digest.len);
5345 debug_hexdump(stdout, "plaintext expected:",
5346 tdata->plaintext.data,
5347 (tdata->plaintext.len >> 3) - tdata->digest.len);
5349 if (ut_params->obuf)
5350 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5351 ciphertext_len, buffer);
5353 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5354 ciphertext_len, buffer);
5356 debug_hexdump(stdout, "ciphertext:", ciphertext,
5358 debug_hexdump(stdout, "ciphertext expected:",
5359 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5361 if (ut_params->obuf)
5362 digest = rte_pktmbuf_read(ut_params->obuf,
5363 (tdata->digest.offset_bytes == 0 ?
5364 plaintext_pad_len : tdata->digest.offset_bytes),
5365 tdata->digest.len, digest_buffer);
5367 digest = rte_pktmbuf_read(ut_params->ibuf,
5368 (tdata->digest.offset_bytes == 0 ?
5369 plaintext_pad_len : tdata->digest.offset_bytes),
5370 tdata->digest.len, digest_buffer);
5372 debug_hexdump(stdout, "digest:", digest,
5374 debug_hexdump(stdout, "digest expected:",
5375 tdata->digest.data, tdata->digest.len);
5380 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5382 tdata->plaintext.data,
5383 (tdata->plaintext.len - tdata->cipher.offset_bits -
5384 (tdata->digest.len << 3)),
5385 tdata->cipher.offset_bits,
5386 "SNOW 3G Plaintext data not as expected");
5388 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5390 tdata->ciphertext.data,
5391 (tdata->validDataLenInBits.len -
5392 tdata->cipher.offset_bits),
5393 tdata->cipher.offset_bits,
5394 "SNOW 3G Ciphertext data not as expected");
5396 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5399 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5400 "SNOW 3G Generated auth tag not as expected");
5406 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5407 uint8_t op_mode, uint8_t verify)
5409 struct crypto_testsuite_params *ts_params = &testsuite_params;
5410 struct crypto_unittest_params *ut_params = &unittest_params;
5414 uint8_t *plaintext = NULL, *ciphertext = NULL;
5415 unsigned int plaintext_pad_len;
5416 unsigned int plaintext_len;
5417 unsigned int ciphertext_pad_len;
5418 unsigned int ciphertext_len;
5420 struct rte_cryptodev_info dev_info;
5422 /* Verify the capabilities */
5423 struct rte_cryptodev_sym_capability_idx cap_idx;
5424 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5425 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5426 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5428 return TEST_SKIPPED;
5429 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5430 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5431 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5433 return TEST_SKIPPED;
5435 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5437 uint64_t feat_flags = dev_info.feature_flags;
5439 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5440 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5441 printf("Device doesn't support RAW data-path APIs.\n");
5442 return TEST_SKIPPED;
5445 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5446 return TEST_SKIPPED;
5448 if (op_mode == OUT_OF_PLACE) {
5449 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5450 return TEST_SKIPPED;
5451 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5452 printf("Device doesn't support digest encrypted.\n");
5453 return TEST_SKIPPED;
5457 /* Create KASUMI session */
5458 retval = create_wireless_algo_auth_cipher_session(
5459 ts_params->valid_devs[0],
5460 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5461 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5462 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5463 : RTE_CRYPTO_AUTH_OP_GENERATE),
5464 RTE_CRYPTO_AUTH_KASUMI_F9,
5465 RTE_CRYPTO_CIPHER_KASUMI_F8,
5466 tdata->key.data, tdata->key.len,
5467 0, tdata->digest.len,
5468 tdata->cipher_iv.len);
5473 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5474 if (op_mode == OUT_OF_PLACE)
5475 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5477 /* clear mbuf payload */
5478 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5479 rte_pktmbuf_tailroom(ut_params->ibuf));
5480 if (op_mode == OUT_OF_PLACE)
5481 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5482 rte_pktmbuf_tailroom(ut_params->obuf));
5484 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5485 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5486 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5487 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5490 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5491 ciphertext_pad_len);
5492 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5493 if (op_mode == OUT_OF_PLACE)
5494 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5495 debug_hexdump(stdout, "ciphertext:", ciphertext,
5498 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5500 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5501 if (op_mode == OUT_OF_PLACE)
5502 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5503 debug_hexdump(stdout, "plaintext:", plaintext,
5507 /* Create KASUMI operation */
5508 retval = create_wireless_algo_auth_cipher_operation(
5509 tdata->digest.data, tdata->digest.len,
5510 tdata->cipher_iv.data, tdata->cipher_iv.len,
5512 (tdata->digest.offset_bytes == 0 ?
5513 (verify ? ciphertext_pad_len : plaintext_pad_len)
5514 : tdata->digest.offset_bytes),
5515 tdata->validCipherLenInBits.len,
5516 tdata->validCipherOffsetInBits.len,
5517 tdata->validAuthLenInBits.len,
5519 op_mode, 0, verify);
5524 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5525 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5526 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5528 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5531 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5533 ut_params->obuf = (op_mode == IN_PLACE ?
5534 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5538 if (ut_params->obuf)
5539 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5542 plaintext = ciphertext;
5544 debug_hexdump(stdout, "plaintext:", plaintext,
5545 (tdata->plaintext.len >> 3) - tdata->digest.len);
5546 debug_hexdump(stdout, "plaintext expected:",
5547 tdata->plaintext.data,
5548 (tdata->plaintext.len >> 3) - tdata->digest.len);
5550 if (ut_params->obuf)
5551 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5554 ciphertext = plaintext;
5556 debug_hexdump(stdout, "ciphertext:", ciphertext,
5558 debug_hexdump(stdout, "ciphertext expected:",
5559 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5561 ut_params->digest = rte_pktmbuf_mtod(
5562 ut_params->obuf, uint8_t *) +
5563 (tdata->digest.offset_bytes == 0 ?
5564 plaintext_pad_len : tdata->digest.offset_bytes);
5566 debug_hexdump(stdout, "digest:", ut_params->digest,
5568 debug_hexdump(stdout, "digest expected:",
5569 tdata->digest.data, tdata->digest.len);
5574 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5576 tdata->plaintext.data,
5577 tdata->plaintext.len >> 3,
5578 "KASUMI Plaintext data not as expected");
5580 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5582 tdata->ciphertext.data,
5583 tdata->ciphertext.len >> 3,
5584 "KASUMI Ciphertext data not as expected");
5586 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5589 DIGEST_BYTE_LENGTH_KASUMI_F9,
5590 "KASUMI Generated auth tag not as expected");
5596 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5597 uint8_t op_mode, uint8_t verify)
5599 struct crypto_testsuite_params *ts_params = &testsuite_params;
5600 struct crypto_unittest_params *ut_params = &unittest_params;
5604 const uint8_t *plaintext = NULL;
5605 const uint8_t *ciphertext = NULL;
5606 const uint8_t *digest = NULL;
5607 unsigned int plaintext_pad_len;
5608 unsigned int plaintext_len;
5609 unsigned int ciphertext_pad_len;
5610 unsigned int ciphertext_len;
5611 uint8_t buffer[10000];
5612 uint8_t digest_buffer[10000];
5614 struct rte_cryptodev_info dev_info;
5616 /* Verify the capabilities */
5617 struct rte_cryptodev_sym_capability_idx cap_idx;
5618 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5619 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5620 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5622 return TEST_SKIPPED;
5623 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5624 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5625 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5627 return TEST_SKIPPED;
5629 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5630 return TEST_SKIPPED;
5632 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5634 uint64_t feat_flags = dev_info.feature_flags;
5636 if (op_mode == IN_PLACE) {
5637 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5638 printf("Device doesn't support in-place scatter-gather "
5639 "in both input and output mbufs.\n");
5640 return TEST_SKIPPED;
5642 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5643 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5644 printf("Device doesn't support RAW data-path APIs.\n");
5645 return TEST_SKIPPED;
5648 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5649 return TEST_SKIPPED;
5650 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5651 printf("Device doesn't support out-of-place scatter-gather "
5652 "in both input and output mbufs.\n");
5653 return TEST_SKIPPED;
5655 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5656 printf("Device doesn't support digest encrypted.\n");
5657 return TEST_SKIPPED;
5661 /* Create KASUMI session */
5662 retval = create_wireless_algo_auth_cipher_session(
5663 ts_params->valid_devs[0],
5664 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5665 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5666 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5667 : RTE_CRYPTO_AUTH_OP_GENERATE),
5668 RTE_CRYPTO_AUTH_KASUMI_F9,
5669 RTE_CRYPTO_CIPHER_KASUMI_F8,
5670 tdata->key.data, tdata->key.len,
5671 0, tdata->digest.len,
5672 tdata->cipher_iv.len);
5677 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5678 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5679 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5680 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5682 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5683 plaintext_pad_len, 15, 0);
5684 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5685 "Failed to allocate input buffer in mempool");
5687 if (op_mode == OUT_OF_PLACE) {
5688 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5689 plaintext_pad_len, 15, 0);
5690 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5691 "Failed to allocate output buffer in mempool");
5695 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5696 tdata->ciphertext.data);
5697 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5698 ciphertext_len, buffer);
5699 debug_hexdump(stdout, "ciphertext:", ciphertext,
5702 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5703 tdata->plaintext.data);
5704 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5705 plaintext_len, buffer);
5706 debug_hexdump(stdout, "plaintext:", plaintext,
5709 memset(buffer, 0, sizeof(buffer));
5711 /* Create KASUMI operation */
5712 retval = create_wireless_algo_auth_cipher_operation(
5713 tdata->digest.data, tdata->digest.len,
5714 tdata->cipher_iv.data, tdata->cipher_iv.len,
5716 (tdata->digest.offset_bytes == 0 ?
5717 (verify ? ciphertext_pad_len : plaintext_pad_len)
5718 : tdata->digest.offset_bytes),
5719 tdata->validCipherLenInBits.len,
5720 tdata->validCipherOffsetInBits.len,
5721 tdata->validAuthLenInBits.len,
5723 op_mode, 1, verify);
5728 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5729 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5730 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5732 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5735 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5737 ut_params->obuf = (op_mode == IN_PLACE ?
5738 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5741 if (ut_params->obuf)
5742 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5743 plaintext_len, buffer);
5745 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5746 plaintext_len, buffer);
5748 debug_hexdump(stdout, "plaintext:", plaintext,
5749 (tdata->plaintext.len >> 3) - tdata->digest.len);
5750 debug_hexdump(stdout, "plaintext expected:",
5751 tdata->plaintext.data,
5752 (tdata->plaintext.len >> 3) - tdata->digest.len);
5754 if (ut_params->obuf)
5755 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5756 ciphertext_len, buffer);
5758 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5759 ciphertext_len, buffer);
5761 debug_hexdump(stdout, "ciphertext:", ciphertext,
5763 debug_hexdump(stdout, "ciphertext expected:",
5764 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5766 if (ut_params->obuf)
5767 digest = rte_pktmbuf_read(ut_params->obuf,
5768 (tdata->digest.offset_bytes == 0 ?
5769 plaintext_pad_len : tdata->digest.offset_bytes),
5770 tdata->digest.len, digest_buffer);
5772 digest = rte_pktmbuf_read(ut_params->ibuf,
5773 (tdata->digest.offset_bytes == 0 ?
5774 plaintext_pad_len : tdata->digest.offset_bytes),
5775 tdata->digest.len, digest_buffer);
5777 debug_hexdump(stdout, "digest:", digest,
5779 debug_hexdump(stdout, "digest expected:",
5780 tdata->digest.data, tdata->digest.len);
5785 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5787 tdata->plaintext.data,
5788 tdata->plaintext.len >> 3,
5789 "KASUMI Plaintext data not as expected");
5791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5793 tdata->ciphertext.data,
5794 tdata->validDataLenInBits.len,
5795 "KASUMI Ciphertext data not as expected");
5797 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5800 DIGEST_BYTE_LENGTH_KASUMI_F9,
5801 "KASUMI Generated auth tag not as expected");
5807 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5809 struct crypto_testsuite_params *ts_params = &testsuite_params;
5810 struct crypto_unittest_params *ut_params = &unittest_params;
5814 uint8_t *plaintext, *ciphertext;
5815 unsigned plaintext_pad_len;
5816 unsigned plaintext_len;
5817 struct rte_cryptodev_info dev_info;
5819 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5820 uint64_t feat_flags = dev_info.feature_flags;
5822 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5823 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5824 printf("Device doesn't support RAW data-path APIs.\n");
5825 return TEST_SKIPPED;
5828 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5829 return TEST_SKIPPED;
5831 /* Verify the capabilities */
5832 struct rte_cryptodev_sym_capability_idx cap_idx;
5833 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5834 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5837 return TEST_SKIPPED;
5838 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5839 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5840 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5842 return TEST_SKIPPED;
5844 /* Create KASUMI session */
5845 retval = create_wireless_algo_cipher_auth_session(
5846 ts_params->valid_devs[0],
5847 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5848 RTE_CRYPTO_AUTH_OP_GENERATE,
5849 RTE_CRYPTO_AUTH_KASUMI_F9,
5850 RTE_CRYPTO_CIPHER_KASUMI_F8,
5851 tdata->key.data, tdata->key.len,
5852 0, tdata->digest.len,
5853 tdata->cipher_iv.len);
5857 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5859 /* clear mbuf payload */
5860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5861 rte_pktmbuf_tailroom(ut_params->ibuf));
5863 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5864 /* Append data which is padded to a multiple of */
5865 /* the algorithms block size */
5866 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5867 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5869 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5871 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5873 /* Create KASUMI operation */
5874 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5875 tdata->digest.len, NULL, 0,
5876 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5877 tdata->cipher_iv.data, tdata->cipher_iv.len,
5878 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5879 tdata->validCipherOffsetInBits.len,
5880 tdata->validAuthLenInBits.len,
5886 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5887 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5888 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5890 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5892 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5894 if (ut_params->op->sym->m_dst)
5895 ut_params->obuf = ut_params->op->sym->m_dst;
5897 ut_params->obuf = ut_params->op->sym->m_src;
5899 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5900 tdata->validCipherOffsetInBits.len >> 3);
5902 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5903 + plaintext_pad_len;
5905 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5906 (tdata->validCipherOffsetInBits.len >> 3);
5908 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5910 reference_ciphertext,
5911 tdata->validCipherLenInBits.len,
5912 "KASUMI Ciphertext data not as expected");
5915 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5918 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5919 "KASUMI Generated auth tag not as expected");
5924 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5925 const enum rte_crypto_cipher_algorithm cipher_algo,
5926 const uint16_t key_size, const uint16_t iv_size)
5928 struct rte_cryptodev_sym_capability_idx cap_idx;
5929 const struct rte_cryptodev_symmetric_capability *cap;
5931 /* Check if device supports the algorithm */
5932 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5933 cap_idx.algo.cipher = cipher_algo;
5935 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5941 /* Check if device supports key size and IV size */
5942 if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5951 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5952 const enum rte_crypto_auth_algorithm auth_algo,
5953 const uint16_t key_size, const uint16_t iv_size,
5954 const uint16_t tag_size)
5956 struct rte_cryptodev_sym_capability_idx cap_idx;
5957 const struct rte_cryptodev_symmetric_capability *cap;
5959 /* Check if device supports the algorithm */
5960 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5961 cap_idx.algo.auth = auth_algo;
5963 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5969 /* Check if device supports key size and IV size */
5970 if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5971 tag_size, iv_size) < 0) {
5979 test_zuc_encryption(const struct wireless_test_data *tdata)
5981 struct crypto_testsuite_params *ts_params = &testsuite_params;
5982 struct crypto_unittest_params *ut_params = &unittest_params;
5985 uint8_t *plaintext, *ciphertext;
5986 unsigned plaintext_pad_len;
5987 unsigned plaintext_len;
5988 struct rte_cryptodev_info dev_info;
5990 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5991 uint64_t feat_flags = dev_info.feature_flags;
5993 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5994 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5995 printf("Device doesn't support RAW data-path APIs.\n");
5996 return TEST_SKIPPED;
5999 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6000 return TEST_SKIPPED;
6002 /* Check if device supports ZUC EEA3 */
6003 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6004 tdata->key.len, tdata->cipher_iv.len) < 0)
6005 return TEST_SKIPPED;
6007 /* Create ZUC session */
6008 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6009 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6010 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6011 tdata->key.data, tdata->key.len,
6012 tdata->cipher_iv.len);
6016 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6018 /* Clear mbuf payload */
6019 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6020 rte_pktmbuf_tailroom(ut_params->ibuf));
6022 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6023 /* Append data which is padded to a multiple */
6024 /* of the algorithms block size */
6025 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6026 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6028 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6030 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6032 /* Create ZUC operation */
6033 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6034 tdata->cipher_iv.len,
6035 tdata->plaintext.len,
6036 tdata->validCipherOffsetInBits.len);
6040 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6041 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6042 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6044 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6046 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6048 ut_params->obuf = ut_params->op->sym->m_dst;
6049 if (ut_params->obuf)
6050 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6052 ciphertext = plaintext;
6054 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6057 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6059 tdata->ciphertext.data,
6060 tdata->validCipherLenInBits.len,
6061 "ZUC Ciphertext data not as expected");
6066 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6068 struct crypto_testsuite_params *ts_params = &testsuite_params;
6069 struct crypto_unittest_params *ut_params = &unittest_params;
6073 unsigned int plaintext_pad_len;
6074 unsigned int plaintext_len;
6075 const uint8_t *ciphertext;
6076 uint8_t ciphertext_buffer[2048];
6077 struct rte_cryptodev_info dev_info;
6079 /* Check if device supports ZUC EEA3 */
6080 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6081 tdata->key.len, tdata->cipher_iv.len) < 0)
6082 return TEST_SKIPPED;
6084 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6085 return TEST_SKIPPED;
6087 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6089 uint64_t feat_flags = dev_info.feature_flags;
6091 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6092 printf("Device doesn't support in-place scatter-gather. "
6094 return TEST_SKIPPED;
6097 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6098 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6099 printf("Device doesn't support RAW data-path APIs.\n");
6100 return TEST_SKIPPED;
6103 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6105 /* Append data which is padded to a multiple */
6106 /* of the algorithms block size */
6107 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6109 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6110 plaintext_pad_len, 10, 0);
6112 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6113 tdata->plaintext.data);
6115 /* Create ZUC session */
6116 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6117 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6118 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6119 tdata->key.data, tdata->key.len,
6120 tdata->cipher_iv.len);
6124 /* Clear mbuf payload */
6126 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6128 /* Create ZUC operation */
6129 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6130 tdata->cipher_iv.len, tdata->plaintext.len,
6131 tdata->validCipherOffsetInBits.len);
6135 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6136 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6137 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6139 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6141 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6143 ut_params->obuf = ut_params->op->sym->m_dst;
6144 if (ut_params->obuf)
6145 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6146 0, plaintext_len, ciphertext_buffer);
6148 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6149 0, plaintext_len, ciphertext_buffer);
6152 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6155 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6157 tdata->ciphertext.data,
6158 tdata->validCipherLenInBits.len,
6159 "ZUC Ciphertext data not as expected");
6165 test_zuc_authentication(const struct wireless_test_data *tdata)
6167 struct crypto_testsuite_params *ts_params = &testsuite_params;
6168 struct crypto_unittest_params *ut_params = &unittest_params;
6171 unsigned plaintext_pad_len;
6172 unsigned plaintext_len;
6175 struct rte_cryptodev_info dev_info;
6177 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6178 uint64_t feat_flags = dev_info.feature_flags;
6180 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6181 (tdata->validAuthLenInBits.len % 8 != 0)) {
6182 printf("Device doesn't support NON-Byte Aligned Data.\n");
6183 return TEST_SKIPPED;
6186 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6187 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6188 printf("Device doesn't support RAW data-path APIs.\n");
6189 return TEST_SKIPPED;
6192 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6193 return TEST_SKIPPED;
6195 /* Check if device supports ZUC EIA3 */
6196 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6197 tdata->key.len, tdata->auth_iv.len,
6198 tdata->digest.len) < 0)
6199 return TEST_SKIPPED;
6201 /* Create ZUC session */
6202 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6203 tdata->key.data, tdata->key.len,
6204 tdata->auth_iv.len, tdata->digest.len,
6205 RTE_CRYPTO_AUTH_OP_GENERATE,
6206 RTE_CRYPTO_AUTH_ZUC_EIA3);
6210 /* alloc mbuf and set payload */
6211 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6213 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6214 rte_pktmbuf_tailroom(ut_params->ibuf));
6216 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6217 /* Append data which is padded to a multiple of */
6218 /* the algorithms block size */
6219 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6220 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6222 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6224 /* Create ZUC operation */
6225 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6226 tdata->auth_iv.data, tdata->auth_iv.len,
6227 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6228 tdata->validAuthLenInBits.len,
6233 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6234 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6235 ut_params->op, 0, 1, 1, 0);
6237 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6239 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6240 ut_params->obuf = ut_params->op->sym->m_src;
6241 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6242 + plaintext_pad_len;
6245 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6249 "ZUC Generated auth tag not as expected");
6255 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6256 uint8_t op_mode, uint8_t verify)
6258 struct crypto_testsuite_params *ts_params = &testsuite_params;
6259 struct crypto_unittest_params *ut_params = &unittest_params;
6263 uint8_t *plaintext = NULL, *ciphertext = NULL;
6264 unsigned int plaintext_pad_len;
6265 unsigned int plaintext_len;
6266 unsigned int ciphertext_pad_len;
6267 unsigned int ciphertext_len;
6269 struct rte_cryptodev_info dev_info;
6271 /* Check if device supports ZUC EEA3 */
6272 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6273 tdata->key.len, tdata->cipher_iv.len) < 0)
6274 return TEST_SKIPPED;
6276 /* Check if device supports ZUC EIA3 */
6277 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6278 tdata->key.len, tdata->auth_iv.len,
6279 tdata->digest.len) < 0)
6280 return TEST_SKIPPED;
6282 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6284 uint64_t feat_flags = dev_info.feature_flags;
6286 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6287 printf("Device doesn't support digest encrypted.\n");
6288 return TEST_SKIPPED;
6290 if (op_mode == IN_PLACE) {
6291 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6292 printf("Device doesn't support in-place scatter-gather "
6293 "in both input and output mbufs.\n");
6294 return TEST_SKIPPED;
6297 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6298 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6299 printf("Device doesn't support RAW data-path APIs.\n");
6300 return TEST_SKIPPED;
6303 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6304 return TEST_SKIPPED;
6305 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6306 printf("Device doesn't support out-of-place scatter-gather "
6307 "in both input and output mbufs.\n");
6308 return TEST_SKIPPED;
6312 /* Create ZUC session */
6313 retval = create_wireless_algo_auth_cipher_session(
6314 ts_params->valid_devs[0],
6315 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6316 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6317 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6318 : RTE_CRYPTO_AUTH_OP_GENERATE),
6319 RTE_CRYPTO_AUTH_ZUC_EIA3,
6320 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6321 tdata->key.data, tdata->key.len,
6322 tdata->auth_iv.len, tdata->digest.len,
6323 tdata->cipher_iv.len);
6328 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6329 if (op_mode == OUT_OF_PLACE)
6330 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6332 /* clear mbuf payload */
6333 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6334 rte_pktmbuf_tailroom(ut_params->ibuf));
6335 if (op_mode == OUT_OF_PLACE)
6336 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6337 rte_pktmbuf_tailroom(ut_params->obuf));
6339 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6340 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6341 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6342 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6345 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6346 ciphertext_pad_len);
6347 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6348 debug_hexdump(stdout, "ciphertext:", ciphertext,
6351 /* make sure enough space to cover partial digest verify case */
6352 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6353 ciphertext_pad_len);
6354 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6355 debug_hexdump(stdout, "plaintext:", plaintext,
6359 if (op_mode == OUT_OF_PLACE)
6360 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6362 /* Create ZUC operation */
6363 retval = create_wireless_algo_auth_cipher_operation(
6364 tdata->digest.data, tdata->digest.len,
6365 tdata->cipher_iv.data, tdata->cipher_iv.len,
6366 tdata->auth_iv.data, tdata->auth_iv.len,
6367 (tdata->digest.offset_bytes == 0 ?
6368 (verify ? ciphertext_pad_len : plaintext_pad_len)
6369 : tdata->digest.offset_bytes),
6370 tdata->validCipherLenInBits.len,
6371 tdata->validCipherOffsetInBits.len,
6372 tdata->validAuthLenInBits.len,
6374 op_mode, 0, verify);
6379 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6380 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6381 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6383 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6386 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6388 ut_params->obuf = (op_mode == IN_PLACE ?
6389 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6393 if (ut_params->obuf)
6394 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6397 plaintext = ciphertext;
6399 debug_hexdump(stdout, "plaintext:", plaintext,
6400 (tdata->plaintext.len >> 3) - tdata->digest.len);
6401 debug_hexdump(stdout, "plaintext expected:",
6402 tdata->plaintext.data,
6403 (tdata->plaintext.len >> 3) - tdata->digest.len);
6405 if (ut_params->obuf)
6406 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6409 ciphertext = plaintext;
6411 debug_hexdump(stdout, "ciphertext:", ciphertext,
6413 debug_hexdump(stdout, "ciphertext expected:",
6414 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6416 ut_params->digest = rte_pktmbuf_mtod(
6417 ut_params->obuf, uint8_t *) +
6418 (tdata->digest.offset_bytes == 0 ?
6419 plaintext_pad_len : tdata->digest.offset_bytes);
6421 debug_hexdump(stdout, "digest:", ut_params->digest,
6423 debug_hexdump(stdout, "digest expected:",
6424 tdata->digest.data, tdata->digest.len);
6429 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6431 tdata->plaintext.data,
6432 tdata->plaintext.len >> 3,
6433 "ZUC Plaintext data not as expected");
6435 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6437 tdata->ciphertext.data,
6438 tdata->ciphertext.len >> 3,
6439 "ZUC Ciphertext data not as expected");
6441 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6444 DIGEST_BYTE_LENGTH_KASUMI_F9,
6445 "ZUC Generated auth tag not as expected");
6451 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6452 uint8_t op_mode, uint8_t verify)
6454 struct crypto_testsuite_params *ts_params = &testsuite_params;
6455 struct crypto_unittest_params *ut_params = &unittest_params;
6459 const uint8_t *plaintext = NULL;
6460 const uint8_t *ciphertext = NULL;
6461 const uint8_t *digest = NULL;
6462 unsigned int plaintext_pad_len;
6463 unsigned int plaintext_len;
6464 unsigned int ciphertext_pad_len;
6465 unsigned int ciphertext_len;
6466 uint8_t buffer[10000];
6467 uint8_t digest_buffer[10000];
6469 struct rte_cryptodev_info dev_info;
6471 /* Check if device supports ZUC EEA3 */
6472 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6473 tdata->key.len, tdata->cipher_iv.len) < 0)
6474 return TEST_SKIPPED;
6476 /* Check if device supports ZUC EIA3 */
6477 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6478 tdata->key.len, tdata->auth_iv.len,
6479 tdata->digest.len) < 0)
6480 return TEST_SKIPPED;
6482 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6484 uint64_t feat_flags = dev_info.feature_flags;
6486 if (op_mode == IN_PLACE) {
6487 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6488 printf("Device doesn't support in-place scatter-gather "
6489 "in both input and output mbufs.\n");
6490 return TEST_SKIPPED;
6493 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6494 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6495 printf("Device doesn't support RAW data-path APIs.\n");
6496 return TEST_SKIPPED;
6499 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6500 return TEST_SKIPPED;
6501 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6502 printf("Device doesn't support out-of-place scatter-gather "
6503 "in both input and output mbufs.\n");
6504 return TEST_SKIPPED;
6506 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6507 printf("Device doesn't support digest encrypted.\n");
6508 return TEST_SKIPPED;
6512 /* Create ZUC session */
6513 retval = create_wireless_algo_auth_cipher_session(
6514 ts_params->valid_devs[0],
6515 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6516 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6517 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6518 : RTE_CRYPTO_AUTH_OP_GENERATE),
6519 RTE_CRYPTO_AUTH_ZUC_EIA3,
6520 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6521 tdata->key.data, tdata->key.len,
6522 tdata->auth_iv.len, tdata->digest.len,
6523 tdata->cipher_iv.len);
6528 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6529 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6530 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6531 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6533 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6534 plaintext_pad_len, 15, 0);
6535 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6536 "Failed to allocate input buffer in mempool");
6538 if (op_mode == OUT_OF_PLACE) {
6539 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6540 plaintext_pad_len, 15, 0);
6541 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6542 "Failed to allocate output buffer in mempool");
6546 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6547 tdata->ciphertext.data);
6548 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6549 ciphertext_len, buffer);
6550 debug_hexdump(stdout, "ciphertext:", ciphertext,
6553 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6554 tdata->plaintext.data);
6555 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6556 plaintext_len, buffer);
6557 debug_hexdump(stdout, "plaintext:", plaintext,
6560 memset(buffer, 0, sizeof(buffer));
6562 /* Create ZUC operation */
6563 retval = create_wireless_algo_auth_cipher_operation(
6564 tdata->digest.data, tdata->digest.len,
6565 tdata->cipher_iv.data, tdata->cipher_iv.len,
6567 (tdata->digest.offset_bytes == 0 ?
6568 (verify ? ciphertext_pad_len : plaintext_pad_len)
6569 : tdata->digest.offset_bytes),
6570 tdata->validCipherLenInBits.len,
6571 tdata->validCipherOffsetInBits.len,
6572 tdata->validAuthLenInBits.len,
6574 op_mode, 1, verify);
6579 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6580 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6581 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6583 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6586 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6588 ut_params->obuf = (op_mode == IN_PLACE ?
6589 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6592 if (ut_params->obuf)
6593 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6594 plaintext_len, buffer);
6596 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6597 plaintext_len, buffer);
6599 debug_hexdump(stdout, "plaintext:", plaintext,
6600 (tdata->plaintext.len >> 3) - tdata->digest.len);
6601 debug_hexdump(stdout, "plaintext expected:",
6602 tdata->plaintext.data,
6603 (tdata->plaintext.len >> 3) - tdata->digest.len);
6605 if (ut_params->obuf)
6606 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6607 ciphertext_len, buffer);
6609 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6610 ciphertext_len, buffer);
6612 debug_hexdump(stdout, "ciphertext:", ciphertext,
6614 debug_hexdump(stdout, "ciphertext expected:",
6615 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6617 if (ut_params->obuf)
6618 digest = rte_pktmbuf_read(ut_params->obuf,
6619 (tdata->digest.offset_bytes == 0 ?
6620 plaintext_pad_len : tdata->digest.offset_bytes),
6621 tdata->digest.len, digest_buffer);
6623 digest = rte_pktmbuf_read(ut_params->ibuf,
6624 (tdata->digest.offset_bytes == 0 ?
6625 plaintext_pad_len : tdata->digest.offset_bytes),
6626 tdata->digest.len, digest_buffer);
6628 debug_hexdump(stdout, "digest:", digest,
6630 debug_hexdump(stdout, "digest expected:",
6631 tdata->digest.data, tdata->digest.len);
6636 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6638 tdata->plaintext.data,
6639 tdata->plaintext.len >> 3,
6640 "ZUC Plaintext data not as expected");
6642 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6644 tdata->ciphertext.data,
6645 tdata->validDataLenInBits.len,
6646 "ZUC Ciphertext data not as expected");
6648 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6651 DIGEST_BYTE_LENGTH_KASUMI_F9,
6652 "ZUC Generated auth tag not as expected");
6658 test_kasumi_encryption_test_case_1(void)
6660 return test_kasumi_encryption(&kasumi_test_case_1);
6664 test_kasumi_encryption_test_case_1_sgl(void)
6666 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6670 test_kasumi_encryption_test_case_1_oop(void)
6672 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6676 test_kasumi_encryption_test_case_1_oop_sgl(void)
6678 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6682 test_kasumi_encryption_test_case_2(void)
6684 return test_kasumi_encryption(&kasumi_test_case_2);
6688 test_kasumi_encryption_test_case_3(void)
6690 return test_kasumi_encryption(&kasumi_test_case_3);
6694 test_kasumi_encryption_test_case_4(void)
6696 return test_kasumi_encryption(&kasumi_test_case_4);
6700 test_kasumi_encryption_test_case_5(void)
6702 return test_kasumi_encryption(&kasumi_test_case_5);
6706 test_kasumi_decryption_test_case_1(void)
6708 return test_kasumi_decryption(&kasumi_test_case_1);
6712 test_kasumi_decryption_test_case_1_oop(void)
6714 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6718 test_kasumi_decryption_test_case_2(void)
6720 return test_kasumi_decryption(&kasumi_test_case_2);
6724 test_kasumi_decryption_test_case_3(void)
6726 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6727 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6728 return TEST_SKIPPED;
6729 return test_kasumi_decryption(&kasumi_test_case_3);
6733 test_kasumi_decryption_test_case_4(void)
6735 return test_kasumi_decryption(&kasumi_test_case_4);
6739 test_kasumi_decryption_test_case_5(void)
6741 return test_kasumi_decryption(&kasumi_test_case_5);
6744 test_snow3g_encryption_test_case_1(void)
6746 return test_snow3g_encryption(&snow3g_test_case_1);
6750 test_snow3g_encryption_test_case_1_oop(void)
6752 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6756 test_snow3g_encryption_test_case_1_oop_sgl(void)
6758 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6763 test_snow3g_encryption_test_case_1_offset_oop(void)
6765 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6769 test_snow3g_encryption_test_case_2(void)
6771 return test_snow3g_encryption(&snow3g_test_case_2);
6775 test_snow3g_encryption_test_case_3(void)
6777 return test_snow3g_encryption(&snow3g_test_case_3);
6781 test_snow3g_encryption_test_case_4(void)
6783 return test_snow3g_encryption(&snow3g_test_case_4);
6787 test_snow3g_encryption_test_case_5(void)
6789 return test_snow3g_encryption(&snow3g_test_case_5);
6793 test_snow3g_decryption_test_case_1(void)
6795 return test_snow3g_decryption(&snow3g_test_case_1);
6799 test_snow3g_decryption_test_case_1_oop(void)
6801 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6805 test_snow3g_decryption_test_case_2(void)
6807 return test_snow3g_decryption(&snow3g_test_case_2);
6811 test_snow3g_decryption_test_case_3(void)
6813 return test_snow3g_decryption(&snow3g_test_case_3);
6817 test_snow3g_decryption_test_case_4(void)
6819 return test_snow3g_decryption(&snow3g_test_case_4);
6823 test_snow3g_decryption_test_case_5(void)
6825 return test_snow3g_decryption(&snow3g_test_case_5);
6829 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6830 * Pattern digest from snow3g_test_data must be allocated as
6831 * 4 last bytes in plaintext.
6834 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6835 struct snow3g_hash_test_data *output)
6837 if ((pattern != NULL) && (output != NULL)) {
6838 output->key.len = pattern->key.len;
6840 memcpy(output->key.data,
6841 pattern->key.data, pattern->key.len);
6843 output->auth_iv.len = pattern->auth_iv.len;
6845 memcpy(output->auth_iv.data,
6846 pattern->auth_iv.data, pattern->auth_iv.len);
6848 output->plaintext.len = pattern->plaintext.len;
6850 memcpy(output->plaintext.data,
6851 pattern->plaintext.data, pattern->plaintext.len >> 3);
6853 output->digest.len = pattern->digest.len;
6855 memcpy(output->digest.data,
6856 &pattern->plaintext.data[pattern->digest.offset_bytes],
6857 pattern->digest.len);
6859 output->validAuthLenInBits.len =
6860 pattern->validAuthLenInBits.len;
6865 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6868 test_snow3g_decryption_with_digest_test_case_1(void)
6870 struct snow3g_hash_test_data snow3g_hash_data;
6871 struct rte_cryptodev_info dev_info;
6872 struct crypto_testsuite_params *ts_params = &testsuite_params;
6874 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6875 uint64_t feat_flags = dev_info.feature_flags;
6877 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6878 printf("Device doesn't support encrypted digest operations.\n");
6879 return TEST_SKIPPED;
6883 * Function prepare data for hash verification test case.
6884 * Digest is allocated in 4 last bytes in plaintext, pattern.
6886 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6888 return test_snow3g_decryption(&snow3g_test_case_7) &
6889 test_snow3g_authentication_verify(&snow3g_hash_data);
6893 test_snow3g_cipher_auth_test_case_1(void)
6895 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6899 test_snow3g_auth_cipher_test_case_1(void)
6901 return test_snow3g_auth_cipher(
6902 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6906 test_snow3g_auth_cipher_test_case_2(void)
6908 return test_snow3g_auth_cipher(
6909 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6913 test_snow3g_auth_cipher_test_case_2_oop(void)
6915 return test_snow3g_auth_cipher(
6916 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6920 test_snow3g_auth_cipher_part_digest_enc(void)
6922 return test_snow3g_auth_cipher(
6923 &snow3g_auth_cipher_partial_digest_encryption,
6928 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6930 return test_snow3g_auth_cipher(
6931 &snow3g_auth_cipher_partial_digest_encryption,
6936 test_snow3g_auth_cipher_test_case_3_sgl(void)
6938 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6939 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6940 return TEST_SKIPPED;
6941 return test_snow3g_auth_cipher_sgl(
6942 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6946 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6948 return test_snow3g_auth_cipher_sgl(
6949 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6953 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6955 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6956 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6957 return TEST_SKIPPED;
6958 return test_snow3g_auth_cipher_sgl(
6959 &snow3g_auth_cipher_partial_digest_encryption,
6964 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6966 return test_snow3g_auth_cipher_sgl(
6967 &snow3g_auth_cipher_partial_digest_encryption,
6972 test_snow3g_auth_cipher_verify_test_case_1(void)
6974 return test_snow3g_auth_cipher(
6975 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6979 test_snow3g_auth_cipher_verify_test_case_2(void)
6981 return test_snow3g_auth_cipher(
6982 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6986 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6988 return test_snow3g_auth_cipher(
6989 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6993 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6995 return test_snow3g_auth_cipher(
6996 &snow3g_auth_cipher_partial_digest_encryption,
7001 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7003 return test_snow3g_auth_cipher(
7004 &snow3g_auth_cipher_partial_digest_encryption,
7009 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7011 return test_snow3g_auth_cipher_sgl(
7012 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7016 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7018 return test_snow3g_auth_cipher_sgl(
7019 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7023 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7025 return test_snow3g_auth_cipher_sgl(
7026 &snow3g_auth_cipher_partial_digest_encryption,
7031 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7033 return test_snow3g_auth_cipher_sgl(
7034 &snow3g_auth_cipher_partial_digest_encryption,
7039 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7041 return test_snow3g_auth_cipher(
7042 &snow3g_test_case_7, IN_PLACE, 0);
7046 test_kasumi_auth_cipher_test_case_1(void)
7048 return test_kasumi_auth_cipher(
7049 &kasumi_test_case_3, IN_PLACE, 0);
7053 test_kasumi_auth_cipher_test_case_2(void)
7055 return test_kasumi_auth_cipher(
7056 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7060 test_kasumi_auth_cipher_test_case_2_oop(void)
7062 return test_kasumi_auth_cipher(
7063 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7067 test_kasumi_auth_cipher_test_case_2_sgl(void)
7069 return test_kasumi_auth_cipher_sgl(
7070 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7074 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7076 return test_kasumi_auth_cipher_sgl(
7077 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7081 test_kasumi_auth_cipher_verify_test_case_1(void)
7083 return test_kasumi_auth_cipher(
7084 &kasumi_test_case_3, IN_PLACE, 1);
7088 test_kasumi_auth_cipher_verify_test_case_2(void)
7090 return test_kasumi_auth_cipher(
7091 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7095 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7097 return test_kasumi_auth_cipher(
7098 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7102 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7104 return test_kasumi_auth_cipher_sgl(
7105 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7109 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7111 return test_kasumi_auth_cipher_sgl(
7112 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7116 test_kasumi_cipher_auth_test_case_1(void)
7118 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7122 test_zuc_encryption_test_case_1(void)
7124 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7128 test_zuc_encryption_test_case_2(void)
7130 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7134 test_zuc_encryption_test_case_3(void)
7136 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7140 test_zuc_encryption_test_case_4(void)
7142 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7146 test_zuc_encryption_test_case_5(void)
7148 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7152 test_zuc_encryption_test_case_6_sgl(void)
7154 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7158 test_zuc_hash_generate_test_case_1(void)
7160 return test_zuc_authentication(&zuc_test_case_auth_1b);
7164 test_zuc_hash_generate_test_case_2(void)
7166 return test_zuc_authentication(&zuc_test_case_auth_90b);
7170 test_zuc_hash_generate_test_case_3(void)
7172 return test_zuc_authentication(&zuc_test_case_auth_577b);
7176 test_zuc_hash_generate_test_case_4(void)
7178 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7182 test_zuc_hash_generate_test_case_5(void)
7184 return test_zuc_authentication(&zuc_test_auth_5670b);
7188 test_zuc_hash_generate_test_case_6(void)
7190 return test_zuc_authentication(&zuc_test_case_auth_128b);
7194 test_zuc_hash_generate_test_case_7(void)
7196 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7200 test_zuc_hash_generate_test_case_8(void)
7202 return test_zuc_authentication(&zuc_test_case_auth_584b);
7206 test_zuc_hash_generate_test_case_9(void)
7208 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7212 test_zuc_hash_generate_test_case_10(void)
7214 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7218 test_zuc_hash_generate_test_case_11(void)
7220 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7224 test_zuc_cipher_auth_test_case_1(void)
7226 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7230 test_zuc_cipher_auth_test_case_2(void)
7232 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7236 test_zuc_auth_cipher_test_case_1(void)
7238 return test_zuc_auth_cipher(
7239 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7243 test_zuc_auth_cipher_test_case_1_oop(void)
7245 return test_zuc_auth_cipher(
7246 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7250 test_zuc_auth_cipher_test_case_1_sgl(void)
7252 return test_zuc_auth_cipher_sgl(
7253 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7257 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7259 return test_zuc_auth_cipher_sgl(
7260 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7264 test_zuc_auth_cipher_verify_test_case_1(void)
7266 return test_zuc_auth_cipher(
7267 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7271 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7273 return test_zuc_auth_cipher(
7274 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7278 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7280 return test_zuc_auth_cipher_sgl(
7281 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7285 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7287 return test_zuc_auth_cipher_sgl(
7288 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7292 test_zuc256_encryption_test_case_1(void)
7294 return test_zuc_encryption(&zuc256_test_case_cipher_1);
7298 test_zuc256_encryption_test_case_2(void)
7300 return test_zuc_encryption(&zuc256_test_case_cipher_2);
7304 test_zuc256_authentication_test_case_1(void)
7306 return test_zuc_authentication(&zuc256_test_case_auth_1);
7310 test_zuc256_authentication_test_case_2(void)
7312 return test_zuc_authentication(&zuc256_test_case_auth_2);
7316 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7318 uint8_t dev_id = testsuite_params.valid_devs[0];
7320 struct rte_cryptodev_sym_capability_idx cap_idx;
7322 /* Check if device supports particular cipher algorithm */
7323 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7324 cap_idx.algo.cipher = tdata->cipher_algo;
7325 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7326 return TEST_SKIPPED;
7328 /* Check if device supports particular hash algorithm */
7329 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7330 cap_idx.algo.auth = tdata->auth_algo;
7331 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7332 return TEST_SKIPPED;
7338 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7339 uint8_t op_mode, uint8_t verify)
7341 struct crypto_testsuite_params *ts_params = &testsuite_params;
7342 struct crypto_unittest_params *ut_params = &unittest_params;
7346 uint8_t *plaintext = NULL, *ciphertext = NULL;
7347 unsigned int plaintext_pad_len;
7348 unsigned int plaintext_len;
7349 unsigned int ciphertext_pad_len;
7350 unsigned int ciphertext_len;
7352 struct rte_cryptodev_info dev_info;
7353 struct rte_crypto_op *op;
7355 /* Check if device supports particular algorithms separately */
7356 if (test_mixed_check_if_unsupported(tdata))
7357 return TEST_SKIPPED;
7358 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7359 return TEST_SKIPPED;
7361 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7363 uint64_t feat_flags = dev_info.feature_flags;
7365 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7366 printf("Device doesn't support digest encrypted.\n");
7367 return TEST_SKIPPED;
7370 /* Create the session */
7372 retval = create_wireless_algo_cipher_auth_session(
7373 ts_params->valid_devs[0],
7374 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7375 RTE_CRYPTO_AUTH_OP_VERIFY,
7378 tdata->auth_key.data, tdata->auth_key.len,
7379 tdata->auth_iv.len, tdata->digest_enc.len,
7380 tdata->cipher_iv.len);
7382 retval = create_wireless_algo_auth_cipher_session(
7383 ts_params->valid_devs[0],
7384 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7385 RTE_CRYPTO_AUTH_OP_GENERATE,
7388 tdata->auth_key.data, tdata->auth_key.len,
7389 tdata->auth_iv.len, tdata->digest_enc.len,
7390 tdata->cipher_iv.len);
7394 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7395 if (op_mode == OUT_OF_PLACE)
7396 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7398 /* clear mbuf payload */
7399 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7400 rte_pktmbuf_tailroom(ut_params->ibuf));
7401 if (op_mode == OUT_OF_PLACE) {
7403 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7404 rte_pktmbuf_tailroom(ut_params->obuf));
7407 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7408 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7409 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7410 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7413 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7414 ciphertext_pad_len);
7415 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7416 debug_hexdump(stdout, "ciphertext:", ciphertext,
7419 /* make sure enough space to cover partial digest verify case */
7420 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7421 ciphertext_pad_len);
7422 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7423 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7426 if (op_mode == OUT_OF_PLACE)
7427 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7429 /* Create the operation */
7430 retval = create_wireless_algo_auth_cipher_operation(
7431 tdata->digest_enc.data, tdata->digest_enc.len,
7432 tdata->cipher_iv.data, tdata->cipher_iv.len,
7433 tdata->auth_iv.data, tdata->auth_iv.len,
7434 (tdata->digest_enc.offset == 0 ?
7436 : tdata->digest_enc.offset),
7437 tdata->validCipherLen.len_bits,
7438 tdata->cipher.offset_bits,
7439 tdata->validAuthLen.len_bits,
7440 tdata->auth.offset_bits,
7441 op_mode, 0, verify);
7446 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7448 /* Check if the op failed because the device doesn't */
7449 /* support this particular combination of algorithms */
7450 if (op == NULL && ut_params->op->status ==
7451 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7452 printf("Device doesn't support this mixed combination. "
7454 return TEST_SKIPPED;
7458 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7460 ut_params->obuf = (op_mode == IN_PLACE ?
7461 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7464 if (ut_params->obuf)
7465 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7468 plaintext = ciphertext +
7469 (tdata->cipher.offset_bits >> 3);
7471 debug_hexdump(stdout, "plaintext:", plaintext,
7472 tdata->plaintext.len_bits >> 3);
7473 debug_hexdump(stdout, "plaintext expected:",
7474 tdata->plaintext.data,
7475 tdata->plaintext.len_bits >> 3);
7477 if (ut_params->obuf)
7478 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7481 ciphertext = plaintext;
7483 debug_hexdump(stdout, "ciphertext:", ciphertext,
7485 debug_hexdump(stdout, "ciphertext expected:",
7486 tdata->ciphertext.data,
7487 tdata->ciphertext.len_bits >> 3);
7489 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7490 + (tdata->digest_enc.offset == 0 ?
7491 plaintext_pad_len : tdata->digest_enc.offset);
7493 debug_hexdump(stdout, "digest:", ut_params->digest,
7494 tdata->digest_enc.len);
7495 debug_hexdump(stdout, "digest expected:",
7496 tdata->digest_enc.data,
7497 tdata->digest_enc.len);
7501 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7503 tdata->digest_enc.data,
7504 tdata->digest_enc.len,
7505 "Generated auth tag not as expected");
7508 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7510 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7512 tdata->plaintext.data,
7513 tdata->plaintext.len_bits >> 3,
7514 "Plaintext data not as expected");
7516 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7518 tdata->ciphertext.data,
7519 tdata->validDataLen.len_bits,
7520 "Ciphertext data not as expected");
7524 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7525 "crypto op processing failed");
7531 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7532 uint8_t op_mode, uint8_t verify)
7534 struct crypto_testsuite_params *ts_params = &testsuite_params;
7535 struct crypto_unittest_params *ut_params = &unittest_params;
7539 const uint8_t *plaintext = NULL;
7540 const uint8_t *ciphertext = NULL;
7541 const uint8_t *digest = NULL;
7542 unsigned int plaintext_pad_len;
7543 unsigned int plaintext_len;
7544 unsigned int ciphertext_pad_len;
7545 unsigned int ciphertext_len;
7546 uint8_t buffer[10000];
7547 uint8_t digest_buffer[10000];
7549 struct rte_cryptodev_info dev_info;
7550 struct rte_crypto_op *op;
7552 /* Check if device supports particular algorithms */
7553 if (test_mixed_check_if_unsupported(tdata))
7554 return TEST_SKIPPED;
7555 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7556 return TEST_SKIPPED;
7558 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7560 uint64_t feat_flags = dev_info.feature_flags;
7562 if (op_mode == IN_PLACE) {
7563 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7564 printf("Device doesn't support in-place scatter-gather "
7565 "in both input and output mbufs.\n");
7566 return TEST_SKIPPED;
7569 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7570 printf("Device doesn't support out-of-place scatter-gather "
7571 "in both input and output mbufs.\n");
7572 return TEST_SKIPPED;
7574 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7575 printf("Device doesn't support digest encrypted.\n");
7576 return TEST_SKIPPED;
7580 /* Create the session */
7582 retval = create_wireless_algo_cipher_auth_session(
7583 ts_params->valid_devs[0],
7584 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7585 RTE_CRYPTO_AUTH_OP_VERIFY,
7588 tdata->auth_key.data, tdata->auth_key.len,
7589 tdata->auth_iv.len, tdata->digest_enc.len,
7590 tdata->cipher_iv.len);
7592 retval = create_wireless_algo_auth_cipher_session(
7593 ts_params->valid_devs[0],
7594 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7595 RTE_CRYPTO_AUTH_OP_GENERATE,
7598 tdata->auth_key.data, tdata->auth_key.len,
7599 tdata->auth_iv.len, tdata->digest_enc.len,
7600 tdata->cipher_iv.len);
7604 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7605 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7606 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7607 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7609 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7610 ciphertext_pad_len, 15, 0);
7611 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7612 "Failed to allocate input buffer in mempool");
7614 if (op_mode == OUT_OF_PLACE) {
7615 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7616 plaintext_pad_len, 15, 0);
7617 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7618 "Failed to allocate output buffer in mempool");
7622 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7623 tdata->ciphertext.data);
7624 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7625 ciphertext_len, buffer);
7626 debug_hexdump(stdout, "ciphertext:", ciphertext,
7629 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7630 tdata->plaintext.data);
7631 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7632 plaintext_len, buffer);
7633 debug_hexdump(stdout, "plaintext:", plaintext,
7636 memset(buffer, 0, sizeof(buffer));
7638 /* Create the operation */
7639 retval = create_wireless_algo_auth_cipher_operation(
7640 tdata->digest_enc.data, tdata->digest_enc.len,
7641 tdata->cipher_iv.data, tdata->cipher_iv.len,
7642 tdata->auth_iv.data, tdata->auth_iv.len,
7643 (tdata->digest_enc.offset == 0 ?
7645 : tdata->digest_enc.offset),
7646 tdata->validCipherLen.len_bits,
7647 tdata->cipher.offset_bits,
7648 tdata->validAuthLen.len_bits,
7649 tdata->auth.offset_bits,
7650 op_mode, 1, verify);
7655 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7657 /* Check if the op failed because the device doesn't */
7658 /* support this particular combination of algorithms */
7659 if (op == NULL && ut_params->op->status ==
7660 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7661 printf("Device doesn't support this mixed combination. "
7663 return TEST_SKIPPED;
7667 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7669 ut_params->obuf = (op_mode == IN_PLACE ?
7670 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7673 if (ut_params->obuf)
7674 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7675 plaintext_len, buffer);
7677 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7678 plaintext_len, buffer);
7680 debug_hexdump(stdout, "plaintext:", plaintext,
7681 (tdata->plaintext.len_bits >> 3) -
7682 tdata->digest_enc.len);
7683 debug_hexdump(stdout, "plaintext expected:",
7684 tdata->plaintext.data,
7685 (tdata->plaintext.len_bits >> 3) -
7686 tdata->digest_enc.len);
7688 if (ut_params->obuf)
7689 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7690 ciphertext_len, buffer);
7692 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7693 ciphertext_len, buffer);
7695 debug_hexdump(stdout, "ciphertext:", ciphertext,
7697 debug_hexdump(stdout, "ciphertext expected:",
7698 tdata->ciphertext.data,
7699 tdata->ciphertext.len_bits >> 3);
7701 if (ut_params->obuf)
7702 digest = rte_pktmbuf_read(ut_params->obuf,
7703 (tdata->digest_enc.offset == 0 ?
7705 tdata->digest_enc.offset),
7706 tdata->digest_enc.len, digest_buffer);
7708 digest = rte_pktmbuf_read(ut_params->ibuf,
7709 (tdata->digest_enc.offset == 0 ?
7711 tdata->digest_enc.offset),
7712 tdata->digest_enc.len, digest_buffer);
7714 debug_hexdump(stdout, "digest:", digest,
7715 tdata->digest_enc.len);
7716 debug_hexdump(stdout, "digest expected:",
7717 tdata->digest_enc.data, tdata->digest_enc.len);
7721 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7723 tdata->digest_enc.data,
7724 tdata->digest_enc.len,
7725 "Generated auth tag not as expected");
7728 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7730 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7732 tdata->plaintext.data,
7733 tdata->plaintext.len_bits >> 3,
7734 "Plaintext data not as expected");
7736 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7738 tdata->ciphertext.data,
7739 tdata->validDataLen.len_bits,
7740 "Ciphertext data not as expected");
7744 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7745 "crypto op processing failed");
7750 /** AUTH AES CMAC + CIPHER AES CTR */
7753 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7755 return test_mixed_auth_cipher(
7756 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7760 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7762 return test_mixed_auth_cipher(
7763 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7767 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7769 return test_mixed_auth_cipher_sgl(
7770 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7774 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7776 return test_mixed_auth_cipher_sgl(
7777 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7781 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7783 return test_mixed_auth_cipher(
7784 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7788 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7790 return test_mixed_auth_cipher(
7791 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7795 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7797 return test_mixed_auth_cipher_sgl(
7798 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7802 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7804 return test_mixed_auth_cipher_sgl(
7805 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7808 /** MIXED AUTH + CIPHER */
7811 test_auth_zuc_cipher_snow_test_case_1(void)
7813 return test_mixed_auth_cipher(
7814 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7818 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7820 return test_mixed_auth_cipher(
7821 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7825 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7827 return test_mixed_auth_cipher(
7828 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7832 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7834 return test_mixed_auth_cipher(
7835 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7839 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7841 return test_mixed_auth_cipher(
7842 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7846 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7848 return test_mixed_auth_cipher(
7849 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7853 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7855 return test_mixed_auth_cipher(
7856 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7860 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7862 return test_mixed_auth_cipher(
7863 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7867 test_auth_snow_cipher_zuc_test_case_1(void)
7869 return test_mixed_auth_cipher(
7870 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7874 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7876 return test_mixed_auth_cipher(
7877 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7881 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7883 return test_mixed_auth_cipher(
7884 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7888 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7890 return test_mixed_auth_cipher(
7891 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7895 test_auth_null_cipher_snow_test_case_1(void)
7897 return test_mixed_auth_cipher(
7898 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7902 test_verify_auth_null_cipher_snow_test_case_1(void)
7904 return test_mixed_auth_cipher(
7905 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7909 test_auth_null_cipher_zuc_test_case_1(void)
7911 return test_mixed_auth_cipher(
7912 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7916 test_verify_auth_null_cipher_zuc_test_case_1(void)
7918 return test_mixed_auth_cipher(
7919 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7923 test_auth_snow_cipher_null_test_case_1(void)
7925 return test_mixed_auth_cipher(
7926 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7930 test_verify_auth_snow_cipher_null_test_case_1(void)
7932 return test_mixed_auth_cipher(
7933 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7937 test_auth_zuc_cipher_null_test_case_1(void)
7939 return test_mixed_auth_cipher(
7940 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7944 test_verify_auth_zuc_cipher_null_test_case_1(void)
7946 return test_mixed_auth_cipher(
7947 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7951 test_auth_null_cipher_aes_ctr_test_case_1(void)
7953 return test_mixed_auth_cipher(
7954 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7958 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7960 return test_mixed_auth_cipher(
7961 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7965 test_auth_aes_cmac_cipher_null_test_case_1(void)
7967 return test_mixed_auth_cipher(
7968 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7972 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7974 return test_mixed_auth_cipher(
7975 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7978 /* ***** AEAD algorithm Tests ***** */
7981 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7982 enum rte_crypto_aead_operation op,
7983 const uint8_t *key, const uint8_t key_len,
7984 const uint16_t aad_len, const uint8_t auth_len,
7987 uint8_t aead_key[key_len];
7990 struct crypto_testsuite_params *ts_params = &testsuite_params;
7991 struct crypto_unittest_params *ut_params = &unittest_params;
7993 memcpy(aead_key, key, key_len);
7995 /* Setup AEAD Parameters */
7996 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7997 ut_params->aead_xform.next = NULL;
7998 ut_params->aead_xform.aead.algo = algo;
7999 ut_params->aead_xform.aead.op = op;
8000 ut_params->aead_xform.aead.key.data = aead_key;
8001 ut_params->aead_xform.aead.key.length = key_len;
8002 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8003 ut_params->aead_xform.aead.iv.length = iv_len;
8004 ut_params->aead_xform.aead.digest_length = auth_len;
8005 ut_params->aead_xform.aead.aad_length = aad_len;
8007 debug_hexdump(stdout, "key:", key, key_len);
8009 /* Create Crypto session*/
8010 ut_params->sess = rte_cryptodev_sym_session_create(
8011 ts_params->session_mpool);
8012 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8014 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8015 &ut_params->aead_xform,
8016 ts_params->session_priv_mpool);
8022 create_aead_xform(struct rte_crypto_op *op,
8023 enum rte_crypto_aead_algorithm algo,
8024 enum rte_crypto_aead_operation aead_op,
8025 uint8_t *key, const uint8_t key_len,
8026 const uint8_t aad_len, const uint8_t auth_len,
8029 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8030 "failed to allocate space for crypto transform");
8032 struct rte_crypto_sym_op *sym_op = op->sym;
8034 /* Setup AEAD Parameters */
8035 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8036 sym_op->xform->next = NULL;
8037 sym_op->xform->aead.algo = algo;
8038 sym_op->xform->aead.op = aead_op;
8039 sym_op->xform->aead.key.data = key;
8040 sym_op->xform->aead.key.length = key_len;
8041 sym_op->xform->aead.iv.offset = IV_OFFSET;
8042 sym_op->xform->aead.iv.length = iv_len;
8043 sym_op->xform->aead.digest_length = auth_len;
8044 sym_op->xform->aead.aad_length = aad_len;
8046 debug_hexdump(stdout, "key:", key, key_len);
8052 create_aead_operation(enum rte_crypto_aead_operation op,
8053 const struct aead_test_data *tdata)
8055 struct crypto_testsuite_params *ts_params = &testsuite_params;
8056 struct crypto_unittest_params *ut_params = &unittest_params;
8058 uint8_t *plaintext, *ciphertext;
8059 unsigned int aad_pad_len, plaintext_pad_len;
8061 /* Generate Crypto op data structure */
8062 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8063 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8064 TEST_ASSERT_NOT_NULL(ut_params->op,
8065 "Failed to allocate symmetric crypto operation struct");
8067 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8069 /* Append aad data */
8070 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8071 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8072 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8074 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8075 "no room to append aad");
8077 sym_op->aead.aad.phys_addr =
8078 rte_pktmbuf_iova(ut_params->ibuf);
8079 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8080 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8081 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8084 /* Append IV at the end of the crypto operation*/
8085 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8086 uint8_t *, IV_OFFSET);
8088 /* Copy IV 1 byte after the IV pointer, according to the API */
8089 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8090 debug_hexdump(stdout, "iv:", iv_ptr,
8093 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8094 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8096 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8097 "no room to append aad");
8099 sym_op->aead.aad.phys_addr =
8100 rte_pktmbuf_iova(ut_params->ibuf);
8101 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8102 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8105 /* Append IV at the end of the crypto operation*/
8106 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8107 uint8_t *, IV_OFFSET);
8109 if (tdata->iv.len == 0) {
8110 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8111 debug_hexdump(stdout, "iv:", iv_ptr,
8114 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8115 debug_hexdump(stdout, "iv:", iv_ptr,
8120 /* Append plaintext/ciphertext */
8121 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8122 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8123 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8125 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8127 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8128 debug_hexdump(stdout, "plaintext:", plaintext,
8129 tdata->plaintext.len);
8131 if (ut_params->obuf) {
8132 ciphertext = (uint8_t *)rte_pktmbuf_append(
8134 plaintext_pad_len + aad_pad_len);
8135 TEST_ASSERT_NOT_NULL(ciphertext,
8136 "no room to append ciphertext");
8138 memset(ciphertext + aad_pad_len, 0,
8139 tdata->ciphertext.len);
8142 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8143 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8145 TEST_ASSERT_NOT_NULL(ciphertext,
8146 "no room to append ciphertext");
8148 memcpy(ciphertext, tdata->ciphertext.data,
8149 tdata->ciphertext.len);
8150 debug_hexdump(stdout, "ciphertext:", ciphertext,
8151 tdata->ciphertext.len);
8153 if (ut_params->obuf) {
8154 plaintext = (uint8_t *)rte_pktmbuf_append(
8156 plaintext_pad_len + aad_pad_len);
8157 TEST_ASSERT_NOT_NULL(plaintext,
8158 "no room to append plaintext");
8160 memset(plaintext + aad_pad_len, 0,
8161 tdata->plaintext.len);
8165 /* Append digest data */
8166 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8167 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8168 ut_params->obuf ? ut_params->obuf :
8170 tdata->auth_tag.len);
8171 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8172 "no room to append digest");
8173 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8174 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8175 ut_params->obuf ? ut_params->obuf :
8180 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8181 ut_params->ibuf, tdata->auth_tag.len);
8182 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8183 "no room to append digest");
8184 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8186 plaintext_pad_len + aad_pad_len);
8188 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8189 tdata->auth_tag.len);
8190 debug_hexdump(stdout, "digest:",
8191 sym_op->aead.digest.data,
8192 tdata->auth_tag.len);
8195 sym_op->aead.data.length = tdata->plaintext.len;
8196 sym_op->aead.data.offset = aad_pad_len;
8202 test_authenticated_encryption(const struct aead_test_data *tdata)
8204 struct crypto_testsuite_params *ts_params = &testsuite_params;
8205 struct crypto_unittest_params *ut_params = &unittest_params;
8208 uint8_t *ciphertext, *auth_tag;
8209 uint16_t plaintext_pad_len;
8211 struct rte_cryptodev_info dev_info;
8213 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8214 uint64_t feat_flags = dev_info.feature_flags;
8216 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8217 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8218 printf("Device doesn't support RAW data-path APIs.\n");
8219 return TEST_SKIPPED;
8222 /* Verify the capabilities */
8223 struct rte_cryptodev_sym_capability_idx cap_idx;
8224 const struct rte_cryptodev_symmetric_capability *capability;
8225 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8226 cap_idx.algo.aead = tdata->algo;
8227 capability = rte_cryptodev_sym_capability_get(
8228 ts_params->valid_devs[0], &cap_idx);
8229 if (capability == NULL)
8230 return TEST_SKIPPED;
8231 if (rte_cryptodev_sym_capability_check_aead(
8232 capability, tdata->key.len, tdata->auth_tag.len,
8233 tdata->aad.len, tdata->iv.len))
8234 return TEST_SKIPPED;
8236 /* Create AEAD session */
8237 retval = create_aead_session(ts_params->valid_devs[0],
8239 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8240 tdata->key.data, tdata->key.len,
8241 tdata->aad.len, tdata->auth_tag.len,
8246 if (tdata->aad.len > MBUF_SIZE) {
8247 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8248 /* Populate full size of add data */
8249 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8250 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8252 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8254 /* clear mbuf payload */
8255 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8256 rte_pktmbuf_tailroom(ut_params->ibuf));
8258 /* Create AEAD operation */
8259 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8263 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8265 ut_params->op->sym->m_src = ut_params->ibuf;
8267 /* Process crypto operation */
8268 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8269 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8270 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8271 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8272 ut_params->op, 0, 0, 0, 0);
8274 TEST_ASSERT_NOT_NULL(
8275 process_crypto_request(ts_params->valid_devs[0],
8276 ut_params->op), "failed to process sym crypto op");
8278 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8279 "crypto op processing failed");
8281 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8283 if (ut_params->op->sym->m_dst) {
8284 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8286 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8287 uint8_t *, plaintext_pad_len);
8289 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8291 ut_params->op->sym->cipher.data.offset);
8292 auth_tag = ciphertext + plaintext_pad_len;
8295 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8296 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8299 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8301 tdata->ciphertext.data,
8302 tdata->ciphertext.len,
8303 "Ciphertext data not as expected");
8305 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8307 tdata->auth_tag.data,
8308 tdata->auth_tag.len,
8309 "Generated auth tag not as expected");
8315 #ifdef RTE_LIB_SECURITY
8317 security_proto_supported(enum rte_security_session_action_type action,
8318 enum rte_security_session_protocol proto)
8320 struct crypto_testsuite_params *ts_params = &testsuite_params;
8322 const struct rte_security_capability *capabilities;
8323 const struct rte_security_capability *capability;
8326 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8327 rte_cryptodev_get_sec_ctx(
8328 ts_params->valid_devs[0]);
8331 capabilities = rte_security_capabilities_get(ctx);
8333 if (capabilities == NULL)
8336 while ((capability = &capabilities[i++])->action !=
8337 RTE_SECURITY_ACTION_TYPE_NONE) {
8338 if (capability->action == action &&
8339 capability->protocol == proto)
8346 /* Basic algorithm run function for async inplace mode.
8347 * Creates a session from input parameters and runs one operation
8348 * on input_vec. Checks the output of the crypto operation against
8351 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8352 enum rte_crypto_auth_operation opa,
8353 const uint8_t *input_vec, unsigned int input_vec_len,
8354 const uint8_t *output_vec,
8355 unsigned int output_vec_len,
8356 enum rte_crypto_cipher_algorithm cipher_alg,
8357 const uint8_t *cipher_key, uint32_t cipher_key_len,
8358 enum rte_crypto_auth_algorithm auth_alg,
8359 const uint8_t *auth_key, uint32_t auth_key_len,
8360 uint8_t bearer, enum rte_security_pdcp_domain domain,
8361 uint8_t packet_direction, uint8_t sn_size,
8362 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8364 struct crypto_testsuite_params *ts_params = &testsuite_params;
8365 struct crypto_unittest_params *ut_params = &unittest_params;
8367 int ret = TEST_SUCCESS;
8368 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8369 rte_cryptodev_get_sec_ctx(
8370 ts_params->valid_devs[0]);
8371 struct rte_cryptodev_info dev_info;
8372 uint64_t feat_flags;
8374 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8375 feat_flags = dev_info.feature_flags;
8377 /* Verify the capabilities */
8378 struct rte_security_capability_idx sec_cap_idx;
8380 sec_cap_idx.action = ut_params->type;
8381 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8382 sec_cap_idx.pdcp.domain = domain;
8383 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8384 return TEST_SKIPPED;
8386 /* Generate test mbuf data */
8387 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8389 /* clear mbuf payload */
8390 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8391 rte_pktmbuf_tailroom(ut_params->ibuf));
8393 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8395 memcpy(plaintext, input_vec, input_vec_len);
8397 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8398 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8399 printf("Device does not support RAW data-path APIs.\n");
8400 return TEST_SKIPPED;
8402 /* Out of place support */
8405 * For out-op-place we need to alloc another mbuf
8407 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8408 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8411 /* Setup Cipher Parameters */
8412 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8413 ut_params->cipher_xform.cipher.algo = cipher_alg;
8414 ut_params->cipher_xform.cipher.op = opc;
8415 ut_params->cipher_xform.cipher.key.data = cipher_key;
8416 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8417 ut_params->cipher_xform.cipher.iv.length =
8418 packet_direction ? 4 : 0;
8419 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8421 /* Setup HMAC Parameters if ICV header is required */
8422 if (auth_alg != 0) {
8423 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8424 ut_params->auth_xform.next = NULL;
8425 ut_params->auth_xform.auth.algo = auth_alg;
8426 ut_params->auth_xform.auth.op = opa;
8427 ut_params->auth_xform.auth.key.data = auth_key;
8428 ut_params->auth_xform.auth.key.length = auth_key_len;
8430 ut_params->cipher_xform.next = &ut_params->auth_xform;
8432 ut_params->cipher_xform.next = NULL;
8435 struct rte_security_session_conf sess_conf = {
8436 .action_type = ut_params->type,
8437 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8441 .pkt_dir = packet_direction,
8443 .hfn = packet_direction ? 0 : hfn,
8445 * hfn can be set as pdcp_test_hfn[i]
8446 * if hfn_ovrd is not set. Here, PDCP
8447 * packet direction is just used to
8448 * run half of the cases with session
8449 * HFN and other half with per packet
8452 .hfn_threshold = hfn_threshold,
8453 .hfn_ovrd = packet_direction ? 1 : 0,
8454 .sdap_enabled = sdap,
8456 .crypto_xform = &ut_params->cipher_xform
8459 /* Create security session */
8460 ut_params->sec_session = rte_security_session_create(ctx,
8461 &sess_conf, ts_params->session_mpool,
8462 ts_params->session_priv_mpool);
8464 if (!ut_params->sec_session) {
8465 printf("TestCase %s()-%d line %d failed %s: ",
8466 __func__, i, __LINE__, "Failed to allocate session");
8471 /* Generate crypto op data structure */
8472 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8473 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8474 if (!ut_params->op) {
8475 printf("TestCase %s()-%d line %d failed %s: ",
8476 __func__, i, __LINE__,
8477 "Failed to allocate symmetric crypto operation struct");
8482 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8483 uint32_t *, IV_OFFSET);
8484 *per_pkt_hfn = packet_direction ? hfn : 0;
8486 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8488 /* set crypto operation source mbuf */
8489 ut_params->op->sym->m_src = ut_params->ibuf;
8491 ut_params->op->sym->m_dst = ut_params->obuf;
8493 /* Process crypto operation */
8494 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8495 /* filling lengths */
8496 ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
8497 ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
8498 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8499 ut_params->op, 1, 1, 0, 0);
8501 ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8503 if (ut_params->op == NULL) {
8504 printf("TestCase %s()-%d line %d failed %s: ",
8505 __func__, i, __LINE__,
8506 "failed to process sym crypto op");
8511 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8512 printf("TestCase %s()-%d line %d failed %s: ",
8513 __func__, i, __LINE__, "crypto op processing failed");
8519 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8522 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8526 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8527 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8528 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8529 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8535 rte_crypto_op_free(ut_params->op);
8536 ut_params->op = NULL;
8538 if (ut_params->sec_session)
8539 rte_security_session_destroy(ctx, ut_params->sec_session);
8540 ut_params->sec_session = NULL;
8542 rte_pktmbuf_free(ut_params->ibuf);
8543 ut_params->ibuf = NULL;
8545 rte_pktmbuf_free(ut_params->obuf);
8546 ut_params->obuf = NULL;
8553 test_pdcp_proto_SGL(int i, int oop,
8554 enum rte_crypto_cipher_operation opc,
8555 enum rte_crypto_auth_operation opa,
8557 unsigned int input_vec_len,
8558 uint8_t *output_vec,
8559 unsigned int output_vec_len,
8561 uint32_t fragsz_oop)
8563 struct crypto_testsuite_params *ts_params = &testsuite_params;
8564 struct crypto_unittest_params *ut_params = &unittest_params;
8566 struct rte_mbuf *buf, *buf_oop = NULL;
8567 int ret = TEST_SUCCESS;
8571 unsigned int trn_data = 0;
8572 struct rte_cryptodev_info dev_info;
8573 uint64_t feat_flags;
8574 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8575 rte_cryptodev_get_sec_ctx(
8576 ts_params->valid_devs[0]);
8577 struct rte_mbuf *temp_mbuf;
8579 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8580 feat_flags = dev_info.feature_flags;
8582 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8583 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8584 printf("Device does not support RAW data-path APIs.\n");
8587 /* Verify the capabilities */
8588 struct rte_security_capability_idx sec_cap_idx;
8590 sec_cap_idx.action = ut_params->type;
8591 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8592 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8593 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8594 return TEST_SKIPPED;
8596 if (fragsz > input_vec_len)
8597 fragsz = input_vec_len;
8599 uint16_t plaintext_len = fragsz;
8600 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8602 if (fragsz_oop > output_vec_len)
8603 frag_size_oop = output_vec_len;
8606 if (input_vec_len % fragsz != 0) {
8607 if (input_vec_len / fragsz + 1 > 16)
8609 } else if (input_vec_len / fragsz > 16)
8612 /* Out of place support */
8615 * For out-op-place we need to alloc another mbuf
8617 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8618 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8619 buf_oop = ut_params->obuf;
8622 /* Generate test mbuf data */
8623 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8625 /* clear mbuf payload */
8626 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8627 rte_pktmbuf_tailroom(ut_params->ibuf));
8629 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8631 memcpy(plaintext, input_vec, plaintext_len);
8632 trn_data += plaintext_len;
8634 buf = ut_params->ibuf;
8637 * Loop until no more fragments
8640 while (trn_data < input_vec_len) {
8642 to_trn = (input_vec_len - trn_data < fragsz) ?
8643 (input_vec_len - trn_data) : fragsz;
8645 to_trn_tbl[ecx++] = to_trn;
8647 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8650 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8651 rte_pktmbuf_tailroom(buf));
8654 if (oop && !fragsz_oop) {
8656 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8657 buf_oop = buf_oop->next;
8658 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8659 0, rte_pktmbuf_tailroom(buf_oop));
8660 rte_pktmbuf_append(buf_oop, to_trn);
8663 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8666 memcpy(plaintext, input_vec + trn_data, to_trn);
8670 ut_params->ibuf->nb_segs = segs;
8673 if (fragsz_oop && oop) {
8677 trn_data = frag_size_oop;
8678 while (trn_data < output_vec_len) {
8681 (output_vec_len - trn_data <
8683 (output_vec_len - trn_data) :
8686 to_trn_tbl[ecx++] = to_trn;
8689 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8690 buf_oop = buf_oop->next;
8691 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8692 0, rte_pktmbuf_tailroom(buf_oop));
8693 rte_pktmbuf_append(buf_oop, to_trn);
8697 ut_params->obuf->nb_segs = segs;
8700 /* Setup Cipher Parameters */
8701 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8702 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8703 ut_params->cipher_xform.cipher.op = opc;
8704 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8705 ut_params->cipher_xform.cipher.key.length =
8706 pdcp_test_params[i].cipher_key_len;
8707 ut_params->cipher_xform.cipher.iv.length = 0;
8709 /* Setup HMAC Parameters if ICV header is required */
8710 if (pdcp_test_params[i].auth_alg != 0) {
8711 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8712 ut_params->auth_xform.next = NULL;
8713 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8714 ut_params->auth_xform.auth.op = opa;
8715 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8716 ut_params->auth_xform.auth.key.length =
8717 pdcp_test_params[i].auth_key_len;
8719 ut_params->cipher_xform.next = &ut_params->auth_xform;
8721 ut_params->cipher_xform.next = NULL;
8724 struct rte_security_session_conf sess_conf = {
8725 .action_type = ut_params->type,
8726 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8728 .bearer = pdcp_test_bearer[i],
8729 .domain = pdcp_test_params[i].domain,
8730 .pkt_dir = pdcp_test_packet_direction[i],
8731 .sn_size = pdcp_test_data_sn_size[i],
8732 .hfn = pdcp_test_hfn[i],
8733 .hfn_threshold = pdcp_test_hfn_threshold[i],
8736 .crypto_xform = &ut_params->cipher_xform
8739 /* Create security session */
8740 ut_params->sec_session = rte_security_session_create(ctx,
8741 &sess_conf, ts_params->session_mpool,
8742 ts_params->session_priv_mpool);
8744 if (!ut_params->sec_session) {
8745 printf("TestCase %s()-%d line %d failed %s: ",
8746 __func__, i, __LINE__, "Failed to allocate session");
8751 /* Generate crypto op data structure */
8752 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8753 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8754 if (!ut_params->op) {
8755 printf("TestCase %s()-%d line %d failed %s: ",
8756 __func__, i, __LINE__,
8757 "Failed to allocate symmetric crypto operation struct");
8762 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8764 /* set crypto operation source mbuf */
8765 ut_params->op->sym->m_src = ut_params->ibuf;
8767 ut_params->op->sym->m_dst = ut_params->obuf;
8769 /* Process crypto operation */
8770 temp_mbuf = ut_params->op->sym->m_src;
8771 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8772 /* filling lengths */
8774 ut_params->op->sym->cipher.data.length
8775 += temp_mbuf->pkt_len;
8776 ut_params->op->sym->auth.data.length
8777 += temp_mbuf->pkt_len;
8778 temp_mbuf = temp_mbuf->next;
8780 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8781 ut_params->op, 1, 1, 0, 0);
8783 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8786 if (ut_params->op == NULL) {
8787 printf("TestCase %s()-%d line %d failed %s: ",
8788 __func__, i, __LINE__,
8789 "failed to process sym crypto op");
8794 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8795 printf("TestCase %s()-%d line %d failed %s: ",
8796 __func__, i, __LINE__, "crypto op processing failed");
8802 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8805 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8809 fragsz = frag_size_oop;
8810 if (memcmp(ciphertext, output_vec, fragsz)) {
8811 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8812 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8813 rte_hexdump(stdout, "reference", output_vec, fragsz);
8818 buf = ut_params->op->sym->m_src->next;
8820 buf = ut_params->op->sym->m_dst->next;
8822 unsigned int off = fragsz;
8826 ciphertext = rte_pktmbuf_mtod(buf,
8828 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8829 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8830 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8831 rte_hexdump(stdout, "reference", output_vec + off,
8836 off += to_trn_tbl[ecx++];
8840 rte_crypto_op_free(ut_params->op);
8841 ut_params->op = NULL;
8843 if (ut_params->sec_session)
8844 rte_security_session_destroy(ctx, ut_params->sec_session);
8845 ut_params->sec_session = NULL;
8847 rte_pktmbuf_free(ut_params->ibuf);
8848 ut_params->ibuf = NULL;
8850 rte_pktmbuf_free(ut_params->obuf);
8851 ut_params->obuf = NULL;
8858 test_pdcp_proto_cplane_encap(int i)
8860 return test_pdcp_proto(
8861 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8862 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8863 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8864 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8865 pdcp_test_params[i].cipher_key_len,
8866 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8867 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8868 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8869 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8870 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8874 test_pdcp_proto_uplane_encap(int i)
8876 return test_pdcp_proto(
8877 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8878 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8879 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8880 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8881 pdcp_test_params[i].cipher_key_len,
8882 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8883 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8884 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8885 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8886 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8890 test_pdcp_proto_uplane_encap_with_int(int i)
8892 return test_pdcp_proto(
8893 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8894 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8895 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8896 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8897 pdcp_test_params[i].cipher_key_len,
8898 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8899 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8900 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8901 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8902 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8906 test_pdcp_proto_cplane_decap(int i)
8908 return test_pdcp_proto(
8909 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8910 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8911 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8912 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8913 pdcp_test_params[i].cipher_key_len,
8914 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8915 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8916 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8917 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8918 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8922 test_pdcp_proto_uplane_decap(int i)
8924 return test_pdcp_proto(
8925 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8926 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8927 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8928 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8929 pdcp_test_params[i].cipher_key_len,
8930 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8931 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8932 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8933 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8934 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8938 test_pdcp_proto_uplane_decap_with_int(int i)
8940 return test_pdcp_proto(
8941 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8942 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8943 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8944 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8945 pdcp_test_params[i].cipher_key_len,
8946 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8947 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8948 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8949 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8950 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8954 test_PDCP_PROTO_SGL_in_place_32B(void)
8956 /* i can be used for running any PDCP case
8957 * In this case it is uplane 12-bit AES-SNOW DL encap
8959 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8960 return test_pdcp_proto_SGL(i, IN_PLACE,
8961 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8962 RTE_CRYPTO_AUTH_OP_GENERATE,
8963 pdcp_test_data_in[i],
8964 pdcp_test_data_in_len[i],
8965 pdcp_test_data_out[i],
8966 pdcp_test_data_in_len[i]+4,
8970 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8972 /* i can be used for running any PDCP case
8973 * In this case it is uplane 18-bit NULL-NULL DL encap
8975 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8976 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8977 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8978 RTE_CRYPTO_AUTH_OP_GENERATE,
8979 pdcp_test_data_in[i],
8980 pdcp_test_data_in_len[i],
8981 pdcp_test_data_out[i],
8982 pdcp_test_data_in_len[i]+4,
8986 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8988 /* i can be used for running any PDCP case
8989 * In this case it is uplane 18-bit AES DL encap
8991 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8993 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8994 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8995 RTE_CRYPTO_AUTH_OP_GENERATE,
8996 pdcp_test_data_in[i],
8997 pdcp_test_data_in_len[i],
8998 pdcp_test_data_out[i],
8999 pdcp_test_data_in_len[i],
9003 test_PDCP_PROTO_SGL_oop_128B_32B(void)
9005 /* i can be used for running any PDCP case
9006 * In this case it is cplane 12-bit AES-ZUC DL encap
9008 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9009 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9010 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9011 RTE_CRYPTO_AUTH_OP_GENERATE,
9012 pdcp_test_data_in[i],
9013 pdcp_test_data_in_len[i],
9014 pdcp_test_data_out[i],
9015 pdcp_test_data_in_len[i]+4,
9020 test_PDCP_SDAP_PROTO_encap_all(void)
9022 int i = 0, size = 0;
9023 int err, all_err = TEST_SUCCESS;
9024 const struct pdcp_sdap_test *cur_test;
9026 size = RTE_DIM(list_pdcp_sdap_tests);
9028 for (i = 0; i < size; i++) {
9029 cur_test = &list_pdcp_sdap_tests[i];
9030 err = test_pdcp_proto(
9031 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9032 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9033 cur_test->in_len, cur_test->data_out,
9034 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9035 cur_test->param.cipher_alg, cur_test->cipher_key,
9036 cur_test->param.cipher_key_len,
9037 cur_test->param.auth_alg,
9038 cur_test->auth_key, cur_test->param.auth_key_len,
9039 cur_test->bearer, cur_test->param.domain,
9040 cur_test->packet_direction, cur_test->sn_size,
9042 cur_test->hfn_threshold, SDAP_ENABLED);
9044 printf("\t%d) %s: Encapsulation failed\n",
9046 cur_test->param.name);
9049 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9050 cur_test->param.name);
9056 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9058 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9062 test_PDCP_PROTO_short_mac(void)
9064 int i = 0, size = 0;
9065 int err, all_err = TEST_SUCCESS;
9066 const struct pdcp_short_mac_test *cur_test;
9068 size = RTE_DIM(list_pdcp_smac_tests);
9070 for (i = 0; i < size; i++) {
9071 cur_test = &list_pdcp_smac_tests[i];
9072 err = test_pdcp_proto(
9073 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9074 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9075 cur_test->in_len, cur_test->data_out,
9076 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9077 RTE_CRYPTO_CIPHER_NULL, NULL,
9078 0, cur_test->param.auth_alg,
9079 cur_test->auth_key, cur_test->param.auth_key_len,
9080 0, cur_test->param.domain, 0, 0,
9083 printf("\t%d) %s: Short MAC test failed\n",
9085 cur_test->param.name);
9088 printf("\t%d) %s: Short MAC test PASS\n",
9090 cur_test->param.name);
9091 rte_hexdump(stdout, "MAC I",
9092 cur_test->data_out + cur_test->in_len + 2,
9099 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9101 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9106 test_PDCP_SDAP_PROTO_decap_all(void)
9108 int i = 0, size = 0;
9109 int err, all_err = TEST_SUCCESS;
9110 const struct pdcp_sdap_test *cur_test;
9112 size = RTE_DIM(list_pdcp_sdap_tests);
9114 for (i = 0; i < size; i++) {
9115 cur_test = &list_pdcp_sdap_tests[i];
9116 err = test_pdcp_proto(
9117 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9118 RTE_CRYPTO_AUTH_OP_VERIFY,
9120 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9121 cur_test->data_in, cur_test->in_len,
9122 cur_test->param.cipher_alg,
9123 cur_test->cipher_key, cur_test->param.cipher_key_len,
9124 cur_test->param.auth_alg, cur_test->auth_key,
9125 cur_test->param.auth_key_len, cur_test->bearer,
9126 cur_test->param.domain, cur_test->packet_direction,
9127 cur_test->sn_size, cur_test->hfn,
9128 cur_test->hfn_threshold, SDAP_ENABLED);
9130 printf("\t%d) %s: Decapsulation failed\n",
9132 cur_test->param.name);
9135 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9136 cur_test->param.name);
9142 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9144 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9148 test_ipsec_proto_process(const struct ipsec_test_data td[],
9149 struct ipsec_test_data res_d[],
9152 const struct ipsec_test_flags *flags)
9154 uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
9156 uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
9158 const struct rte_ipv4_hdr *ipv4 =
9159 (const struct rte_ipv4_hdr *)td[0].output_text.data;
9160 struct crypto_testsuite_params *ts_params = &testsuite_params;
9161 struct crypto_unittest_params *ut_params = &unittest_params;
9162 struct rte_security_capability_idx sec_cap_idx;
9163 const struct rte_security_capability *sec_cap;
9164 struct rte_security_ipsec_xform ipsec_xform;
9165 uint8_t dev_id = ts_params->valid_devs[0];
9166 enum rte_security_ipsec_sa_direction dir;
9167 struct ipsec_test_data *res_d_tmp = NULL;
9168 int salt_len, i, ret = TEST_SUCCESS;
9169 struct rte_security_ctx *ctx;
9170 uint8_t *input_text;
9174 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9175 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9177 /* Use first test data to create session */
9179 /* Copy IPsec xform */
9180 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9182 dir = ipsec_xform.direction;
9183 verify = flags->tunnel_hdr_verify;
9185 memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
9186 memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
9188 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9189 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9191 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9195 if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
9196 if (td->ipsec_xform.tunnel.type ==
9197 RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
9198 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
9200 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
9203 if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
9204 ipsec_xform.tunnel.ipv4.df = 0;
9206 if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
9207 ipsec_xform.tunnel.ipv4.df = 1;
9209 if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
9210 ipsec_xform.tunnel.ipv4.dscp = 0;
9212 if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
9213 ipsec_xform.tunnel.ipv4.dscp =
9214 TEST_IPSEC_DSCP_VAL;
9217 if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
9218 ipsec_xform.tunnel.ipv6.dscp = 0;
9220 if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
9221 ipsec_xform.tunnel.ipv6.dscp =
9222 TEST_IPSEC_DSCP_VAL;
9224 memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
9226 memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
9231 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9233 sec_cap_idx.action = ut_params->type;
9234 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9235 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9236 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9237 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9239 if (flags->udp_encap)
9240 ipsec_xform.options.udp_encap = 1;
9242 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9243 if (sec_cap == NULL)
9244 return TEST_SKIPPED;
9246 /* Copy cipher session parameters */
9248 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9249 sizeof(ut_params->aead_xform));
9250 ut_params->aead_xform.aead.key.data = td[0].key.data;
9251 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9253 /* Verify crypto capabilities */
9254 if (test_ipsec_crypto_caps_aead_verify(
9256 &ut_params->aead_xform) != 0) {
9258 RTE_LOG(INFO, USER1,
9259 "Crypto capabilities not supported\n");
9260 return TEST_SKIPPED;
9262 } else if (td[0].auth_only) {
9263 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9264 sizeof(ut_params->auth_xform));
9265 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9267 if (test_ipsec_crypto_caps_auth_verify(
9269 &ut_params->auth_xform) != 0) {
9271 RTE_LOG(INFO, USER1,
9272 "Auth crypto capabilities not supported\n");
9273 return TEST_SKIPPED;
9276 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
9277 sizeof(ut_params->cipher_xform));
9278 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9279 sizeof(ut_params->auth_xform));
9280 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
9281 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9282 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9284 /* Verify crypto capabilities */
9286 if (test_ipsec_crypto_caps_cipher_verify(
9288 &ut_params->cipher_xform) != 0) {
9290 RTE_LOG(INFO, USER1,
9291 "Cipher crypto capabilities not supported\n");
9292 return TEST_SKIPPED;
9295 if (test_ipsec_crypto_caps_auth_verify(
9297 &ut_params->auth_xform) != 0) {
9299 RTE_LOG(INFO, USER1,
9300 "Auth crypto capabilities not supported\n");
9301 return TEST_SKIPPED;
9305 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9306 return TEST_SKIPPED;
9308 struct rte_security_session_conf sess_conf = {
9309 .action_type = ut_params->type,
9310 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9313 if (td[0].aead || td[0].aes_gmac) {
9314 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9315 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9319 sess_conf.ipsec = ipsec_xform;
9320 sess_conf.crypto_xform = &ut_params->aead_xform;
9321 } else if (td[0].auth_only) {
9322 sess_conf.ipsec = ipsec_xform;
9323 sess_conf.crypto_xform = &ut_params->auth_xform;
9325 sess_conf.ipsec = ipsec_xform;
9326 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
9327 sess_conf.crypto_xform = &ut_params->cipher_xform;
9328 ut_params->cipher_xform.next = &ut_params->auth_xform;
9330 sess_conf.crypto_xform = &ut_params->auth_xform;
9331 ut_params->auth_xform.next = &ut_params->cipher_xform;
9335 /* Create security session */
9336 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9337 ts_params->session_mpool,
9338 ts_params->session_priv_mpool);
9340 if (ut_params->sec_session == NULL)
9341 return TEST_SKIPPED;
9343 for (i = 0; i < nb_td; i++) {
9344 if (flags->antireplay &&
9345 (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
9346 sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
9347 ret = rte_security_session_update(ctx,
9348 ut_params->sec_session, &sess_conf);
9350 printf("Could not update sequence number in "
9352 return TEST_SKIPPED;
9356 /* Setup source mbuf payload */
9357 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9358 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9359 rte_pktmbuf_tailroom(ut_params->ibuf));
9361 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9362 td[i].input_text.len);
9364 memcpy(input_text, td[i].input_text.data,
9365 td[i].input_text.len);
9367 if (test_ipsec_pkt_update(input_text, flags))
9370 /* Generate crypto op data structure */
9371 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9372 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9373 if (!ut_params->op) {
9374 printf("TestCase %s line %d: %s\n",
9376 "failed to allocate crypto op");
9378 goto crypto_op_free;
9381 /* Attach session to operation */
9382 rte_security_attach_session(ut_params->op,
9383 ut_params->sec_session);
9385 /* Set crypto operation mbufs */
9386 ut_params->op->sym->m_src = ut_params->ibuf;
9387 ut_params->op->sym->m_dst = NULL;
9389 /* Copy IV in crypto operation when IV generation is disabled */
9390 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9391 ipsec_xform.options.iv_gen_disable == 1) {
9392 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9398 len = td[i].xform.aead.aead.iv.length;
9399 else if (td[i].aes_gmac)
9400 len = td[i].xform.chain.auth.auth.iv.length;
9402 len = td[i].xform.chain.cipher.cipher.iv.length;
9404 memcpy(iv, td[i].iv.data, len);
9407 /* Process crypto operation */
9408 process_crypto_request(dev_id, ut_params->op);
9410 ret = test_ipsec_status_check(&td[i], ut_params->op, flags, dir,
9412 if (ret != TEST_SUCCESS)
9413 goto crypto_op_free;
9416 res_d_tmp = &res_d[i];
9418 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9419 res_d_tmp, silent, flags);
9420 if (ret != TEST_SUCCESS)
9421 goto crypto_op_free;
9423 ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
9425 if (ret != TEST_SUCCESS)
9426 goto crypto_op_free;
9428 rte_crypto_op_free(ut_params->op);
9429 ut_params->op = NULL;
9431 rte_pktmbuf_free(ut_params->ibuf);
9432 ut_params->ibuf = NULL;
9436 rte_crypto_op_free(ut_params->op);
9437 ut_params->op = NULL;
9439 rte_pktmbuf_free(ut_params->ibuf);
9440 ut_params->ibuf = NULL;
9442 if (ut_params->sec_session)
9443 rte_security_session_destroy(ctx, ut_params->sec_session);
9444 ut_params->sec_session = NULL;
9450 test_ipsec_proto_known_vec(const void *test_data)
9452 struct ipsec_test_data td_outb;
9453 struct ipsec_test_flags flags;
9455 memset(&flags, 0, sizeof(flags));
9457 memcpy(&td_outb, test_data, sizeof(td_outb));
9459 if (td_outb.aes_gmac || td_outb.aead ||
9460 ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
9461 (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
9462 /* Disable IV gen to be able to test with known vectors */
9463 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9466 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9470 test_ipsec_proto_known_vec_inb(const void *test_data)
9472 const struct ipsec_test_data *td = test_data;
9473 struct ipsec_test_flags flags;
9474 struct ipsec_test_data td_inb;
9476 memset(&flags, 0, sizeof(flags));
9478 if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
9479 test_ipsec_td_in_from_out(td, &td_inb);
9481 memcpy(&td_inb, td, sizeof(td_inb));
9483 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9487 test_ipsec_proto_known_vec_fragmented(const void *test_data)
9489 struct ipsec_test_data td_outb;
9490 struct ipsec_test_flags flags;
9492 memset(&flags, 0, sizeof(flags));
9493 flags.fragment = true;
9495 memcpy(&td_outb, test_data, sizeof(td_outb));
9497 /* Disable IV gen to be able to test with known vectors */
9498 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9500 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9504 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9506 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9507 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9508 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9511 if (flags->iv_gen ||
9512 flags->sa_expiry_pkts_soft ||
9513 flags->sa_expiry_pkts_hard)
9514 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9516 for (i = 0; i < RTE_DIM(alg_list); i++) {
9517 test_ipsec_td_prepare(alg_list[i].param1,
9523 if (!td_outb->aead) {
9524 enum rte_crypto_cipher_algorithm cipher_alg;
9525 enum rte_crypto_auth_algorithm auth_alg;
9527 cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
9528 auth_alg = td_outb->xform.chain.auth.auth.algo;
9530 if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
9533 /* ICV is not applicable for NULL auth */
9534 if (flags->icv_corrupt &&
9535 auth_alg == RTE_CRYPTO_AUTH_NULL)
9538 /* IV is not applicable for NULL cipher */
9539 if (flags->iv_gen &&
9540 cipher_alg == RTE_CRYPTO_CIPHER_NULL)
9544 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9546 if (ret == TEST_SKIPPED)
9549 if (ret == TEST_FAILED)
9552 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9554 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9556 if (ret == TEST_SKIPPED)
9559 if (ret == TEST_FAILED)
9562 if (flags->display_alg)
9563 test_ipsec_display_alg(alg_list[i].param1,
9564 alg_list[i].param2);
9570 return TEST_SUCCESS;
9572 return TEST_SKIPPED;
9576 test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
9578 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9579 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9580 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9583 for (i = 0; i < RTE_DIM(ah_alg_list); i++) {
9584 test_ipsec_td_prepare(ah_alg_list[i].param1,
9585 ah_alg_list[i].param2,
9590 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9592 if (ret == TEST_SKIPPED)
9595 if (ret == TEST_FAILED)
9598 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9600 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9602 if (ret == TEST_SKIPPED)
9605 if (ret == TEST_FAILED)
9608 if (flags->display_alg)
9609 test_ipsec_display_alg(ah_alg_list[i].param1,
9610 ah_alg_list[i].param2);
9616 return TEST_SUCCESS;
9618 return TEST_SKIPPED;
9622 test_ipsec_proto_display_list(const void *data __rte_unused)
9624 struct ipsec_test_flags flags;
9626 memset(&flags, 0, sizeof(flags));
9628 flags.display_alg = true;
9630 return test_ipsec_proto_all(&flags);
9634 test_ipsec_proto_ah_tunnel_ipv4(const void *data __rte_unused)
9636 struct ipsec_test_flags flags;
9638 memset(&flags, 0, sizeof(flags));
9641 flags.display_alg = true;
9643 return test_ipsec_ah_proto_all(&flags);
9647 test_ipsec_proto_ah_transport_ipv4(const void *data __rte_unused)
9649 struct ipsec_test_flags flags;
9651 memset(&flags, 0, sizeof(flags));
9654 flags.transport = true;
9656 return test_ipsec_ah_proto_all(&flags);
9660 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9662 struct ipsec_test_flags flags;
9664 memset(&flags, 0, sizeof(flags));
9666 flags.iv_gen = true;
9668 return test_ipsec_proto_all(&flags);
9672 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9674 struct ipsec_test_flags flags;
9676 memset(&flags, 0, sizeof(flags));
9678 flags.sa_expiry_pkts_soft = true;
9680 return test_ipsec_proto_all(&flags);
9684 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9686 struct ipsec_test_flags flags;
9688 memset(&flags, 0, sizeof(flags));
9690 flags.sa_expiry_pkts_hard = true;
9692 return test_ipsec_proto_all(&flags);
9696 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9698 struct ipsec_test_flags flags;
9700 memset(&flags, 0, sizeof(flags));
9702 flags.icv_corrupt = true;
9704 return test_ipsec_proto_all(&flags);
9708 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9710 struct ipsec_test_flags flags;
9712 memset(&flags, 0, sizeof(flags));
9714 flags.udp_encap = true;
9716 return test_ipsec_proto_all(&flags);
9720 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9722 struct ipsec_test_flags flags;
9724 memset(&flags, 0, sizeof(flags));
9726 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9728 return test_ipsec_proto_all(&flags);
9732 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9734 struct ipsec_test_flags flags;
9736 memset(&flags, 0, sizeof(flags));
9738 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9740 return test_ipsec_proto_all(&flags);
9744 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9746 struct ipsec_test_flags flags;
9748 memset(&flags, 0, sizeof(flags));
9750 flags.udp_encap = true;
9751 flags.udp_ports_verify = true;
9753 return test_ipsec_proto_all(&flags);
9757 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9759 struct ipsec_test_flags flags;
9761 memset(&flags, 0, sizeof(flags));
9763 flags.ip_csum = true;
9765 return test_ipsec_proto_all(&flags);
9769 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9771 struct ipsec_test_flags flags;
9773 memset(&flags, 0, sizeof(flags));
9775 flags.l4_csum = true;
9777 return test_ipsec_proto_all(&flags);
9781 test_ipsec_proto_tunnel_v4_in_v4(const void *data __rte_unused)
9783 struct ipsec_test_flags flags;
9785 memset(&flags, 0, sizeof(flags));
9788 flags.tunnel_ipv6 = false;
9790 return test_ipsec_proto_all(&flags);
9794 test_ipsec_proto_tunnel_v6_in_v6(const void *data __rte_unused)
9796 struct ipsec_test_flags flags;
9798 memset(&flags, 0, sizeof(flags));
9801 flags.tunnel_ipv6 = true;
9803 return test_ipsec_proto_all(&flags);
9807 test_ipsec_proto_tunnel_v4_in_v6(const void *data __rte_unused)
9809 struct ipsec_test_flags flags;
9811 memset(&flags, 0, sizeof(flags));
9814 flags.tunnel_ipv6 = true;
9816 return test_ipsec_proto_all(&flags);
9820 test_ipsec_proto_tunnel_v6_in_v4(const void *data __rte_unused)
9822 struct ipsec_test_flags flags;
9824 memset(&flags, 0, sizeof(flags));
9827 flags.tunnel_ipv6 = false;
9829 return test_ipsec_proto_all(&flags);
9833 test_ipsec_proto_transport_v4(const void *data __rte_unused)
9835 struct ipsec_test_flags flags;
9837 memset(&flags, 0, sizeof(flags));
9840 flags.transport = true;
9842 return test_ipsec_proto_all(&flags);
9846 test_ipsec_proto_transport_l4_csum(const void *data __rte_unused)
9848 struct ipsec_test_flags flags = {
9853 return test_ipsec_proto_all(&flags);
9857 test_ipsec_proto_stats(const void *data __rte_unused)
9859 struct ipsec_test_flags flags;
9861 memset(&flags, 0, sizeof(flags));
9863 flags.stats_success = true;
9865 return test_ipsec_proto_all(&flags);
9869 test_ipsec_proto_pkt_fragment(const void *data __rte_unused)
9871 struct ipsec_test_flags flags;
9873 memset(&flags, 0, sizeof(flags));
9875 flags.fragment = true;
9877 return test_ipsec_proto_all(&flags);
9882 test_ipsec_proto_copy_df_inner_0(const void *data __rte_unused)
9884 struct ipsec_test_flags flags;
9886 memset(&flags, 0, sizeof(flags));
9888 flags.df = TEST_IPSEC_COPY_DF_INNER_0;
9890 return test_ipsec_proto_all(&flags);
9894 test_ipsec_proto_copy_df_inner_1(const void *data __rte_unused)
9896 struct ipsec_test_flags flags;
9898 memset(&flags, 0, sizeof(flags));
9900 flags.df = TEST_IPSEC_COPY_DF_INNER_1;
9902 return test_ipsec_proto_all(&flags);
9906 test_ipsec_proto_set_df_0_inner_1(const void *data __rte_unused)
9908 struct ipsec_test_flags flags;
9910 memset(&flags, 0, sizeof(flags));
9912 flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
9914 return test_ipsec_proto_all(&flags);
9918 test_ipsec_proto_set_df_1_inner_0(const void *data __rte_unused)
9920 struct ipsec_test_flags flags;
9922 memset(&flags, 0, sizeof(flags));
9924 flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
9926 return test_ipsec_proto_all(&flags);
9930 test_ipsec_proto_ipv4_copy_dscp_inner_0(const void *data __rte_unused)
9932 struct ipsec_test_flags flags;
9934 memset(&flags, 0, sizeof(flags));
9936 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
9938 return test_ipsec_proto_all(&flags);
9942 test_ipsec_proto_ipv4_copy_dscp_inner_1(const void *data __rte_unused)
9944 struct ipsec_test_flags flags;
9946 memset(&flags, 0, sizeof(flags));
9948 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
9950 return test_ipsec_proto_all(&flags);
9954 test_ipsec_proto_ipv4_set_dscp_0_inner_1(const void *data __rte_unused)
9956 struct ipsec_test_flags flags;
9958 if (gbl_driver_id == rte_cryptodev_driver_id_get(
9959 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
9960 return TEST_SKIPPED;
9962 memset(&flags, 0, sizeof(flags));
9964 flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
9966 return test_ipsec_proto_all(&flags);
9970 test_ipsec_proto_ipv4_set_dscp_1_inner_0(const void *data __rte_unused)
9972 struct ipsec_test_flags flags;
9974 if (gbl_driver_id == rte_cryptodev_driver_id_get(
9975 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
9976 return TEST_SKIPPED;
9978 memset(&flags, 0, sizeof(flags));
9980 flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
9982 return test_ipsec_proto_all(&flags);
9986 test_ipsec_proto_ipv6_copy_dscp_inner_0(const void *data __rte_unused)
9988 struct ipsec_test_flags flags;
9990 memset(&flags, 0, sizeof(flags));
9993 flags.tunnel_ipv6 = true;
9994 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
9996 return test_ipsec_proto_all(&flags);
10000 test_ipsec_proto_ipv6_copy_dscp_inner_1(const void *data __rte_unused)
10002 struct ipsec_test_flags flags;
10004 memset(&flags, 0, sizeof(flags));
10007 flags.tunnel_ipv6 = true;
10008 flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
10010 return test_ipsec_proto_all(&flags);
10014 test_ipsec_proto_ipv6_set_dscp_0_inner_1(const void *data __rte_unused)
10016 struct ipsec_test_flags flags;
10018 if (gbl_driver_id == rte_cryptodev_driver_id_get(
10019 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10020 return TEST_SKIPPED;
10022 memset(&flags, 0, sizeof(flags));
10025 flags.tunnel_ipv6 = true;
10026 flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
10028 return test_ipsec_proto_all(&flags);
10032 test_ipsec_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused)
10034 struct ipsec_test_flags flags;
10036 if (gbl_driver_id == rte_cryptodev_driver_id_get(
10037 RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
10038 return TEST_SKIPPED;
10040 memset(&flags, 0, sizeof(flags));
10043 flags.tunnel_ipv6 = true;
10044 flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
10046 return test_ipsec_proto_all(&flags);
10050 test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
10051 bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
10054 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
10055 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
10056 struct ipsec_test_flags flags;
10057 uint32_t i = 0, ret = 0;
10060 return TEST_FAILED;
10062 memset(&flags, 0, sizeof(flags));
10063 flags.antireplay = true;
10065 for (i = 0; i < nb_pkts; i++) {
10066 memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
10067 td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
10068 td_outb[i].ipsec_xform.replay_win_sz = winsz;
10069 td_outb[i].ipsec_xform.options.esn = esn_en;
10072 for (i = 0; i < nb_pkts; i++)
10073 td_outb[i].ipsec_xform.esn.value = esn[i];
10075 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10077 if (ret != TEST_SUCCESS)
10080 test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
10082 for (i = 0; i < nb_pkts; i++) {
10083 td_inb[i].ipsec_xform.options.esn = esn_en;
10084 /* Set antireplay flag for packets to be dropped */
10085 td_inb[i].ar_packet = replayed_pkt[i];
10088 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10095 test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
10098 uint32_t nb_pkts = 5;
10099 bool replayed_pkt[5];
10102 /* 1. Advance the TOP of the window to WS * 2 */
10103 esn[0] = winsz * 2;
10104 /* 2. Test sequence number within the new window(WS + 1) */
10105 esn[1] = winsz + 1;
10106 /* 3. Test sequence number less than the window BOTTOM */
10108 /* 4. Test sequence number in the middle of the window */
10109 esn[3] = winsz + (winsz / 2);
10110 /* 5. Test replay of the packet in the middle of the window */
10111 esn[4] = winsz + (winsz / 2);
10113 replayed_pkt[0] = false;
10114 replayed_pkt[1] = false;
10115 replayed_pkt[2] = true;
10116 replayed_pkt[3] = false;
10117 replayed_pkt[4] = true;
10119 return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
10124 test_ipsec_proto_pkt_antireplay1024(const void *test_data)
10126 return test_ipsec_proto_pkt_antireplay(test_data, 1024);
10130 test_ipsec_proto_pkt_antireplay2048(const void *test_data)
10132 return test_ipsec_proto_pkt_antireplay(test_data, 2048);
10136 test_ipsec_proto_pkt_antireplay4096(const void *test_data)
10138 return test_ipsec_proto_pkt_antireplay(test_data, 4096);
10142 test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
10145 uint32_t nb_pkts = 7;
10146 bool replayed_pkt[7];
10149 /* Set the initial sequence number */
10150 esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
10151 /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
10152 esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
10153 /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
10154 esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
10155 /* 3. Test with sequence number within window (1<<32 - 1) */
10156 esn[3] = (uint64_t)((1ULL << 32) - 1);
10157 /* 4. Test with sequence number within window (1<<32 - 1) */
10158 esn[4] = (uint64_t)(1ULL << 32);
10159 /* 5. Test with duplicate sequence number within
10160 * new window (1<<32 - 1)
10162 esn[5] = (uint64_t)((1ULL << 32) - 1);
10163 /* 6. Test with duplicate sequence number within new window (1<<32) */
10164 esn[6] = (uint64_t)(1ULL << 32);
10166 replayed_pkt[0] = false;
10167 replayed_pkt[1] = false;
10168 replayed_pkt[2] = false;
10169 replayed_pkt[3] = false;
10170 replayed_pkt[4] = false;
10171 replayed_pkt[5] = true;
10172 replayed_pkt[6] = true;
10174 return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
10179 test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
10181 return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
10185 test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
10187 return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
10191 test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
10193 return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
10197 test_PDCP_PROTO_all(void)
10199 struct crypto_testsuite_params *ts_params = &testsuite_params;
10200 struct crypto_unittest_params *ut_params = &unittest_params;
10201 struct rte_cryptodev_info dev_info;
10204 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10205 uint64_t feat_flags = dev_info.feature_flags;
10207 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
10208 return TEST_SKIPPED;
10210 /* Set action type */
10211 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10212 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10215 if (security_proto_supported(ut_params->type,
10216 RTE_SECURITY_PROTOCOL_PDCP) < 0)
10217 return TEST_SKIPPED;
10219 status = test_PDCP_PROTO_cplane_encap_all();
10220 status += test_PDCP_PROTO_cplane_decap_all();
10221 status += test_PDCP_PROTO_uplane_encap_all();
10222 status += test_PDCP_PROTO_uplane_decap_all();
10223 status += test_PDCP_PROTO_SGL_in_place_32B();
10224 status += test_PDCP_PROTO_SGL_oop_32B_128B();
10225 status += test_PDCP_PROTO_SGL_oop_32B_40B();
10226 status += test_PDCP_PROTO_SGL_oop_128B_32B();
10227 status += test_PDCP_SDAP_PROTO_encap_all();
10228 status += test_PDCP_SDAP_PROTO_decap_all();
10229 status += test_PDCP_PROTO_short_mac();
10232 return TEST_FAILED;
10234 return TEST_SUCCESS;
10238 test_ipsec_proto_ipv4_ttl_decrement(const void *data __rte_unused)
10240 struct ipsec_test_flags flags = {
10241 .dec_ttl_or_hop_limit = true
10244 return test_ipsec_proto_all(&flags);
10248 test_ipsec_proto_ipv6_hop_limit_decrement(const void *data __rte_unused)
10250 struct ipsec_test_flags flags = {
10252 .dec_ttl_or_hop_limit = true
10255 return test_ipsec_proto_all(&flags);
10259 test_docsis_proto_uplink(const void *data)
10261 const struct docsis_test_data *d_td = data;
10262 struct crypto_testsuite_params *ts_params = &testsuite_params;
10263 struct crypto_unittest_params *ut_params = &unittest_params;
10264 uint8_t *plaintext = NULL;
10265 uint8_t *ciphertext = NULL;
10267 int32_t cipher_len, crc_len;
10268 uint32_t crc_data_len;
10269 int ret = TEST_SUCCESS;
10271 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10272 rte_cryptodev_get_sec_ctx(
10273 ts_params->valid_devs[0]);
10275 /* Verify the capabilities */
10276 struct rte_security_capability_idx sec_cap_idx;
10277 const struct rte_security_capability *sec_cap;
10278 const struct rte_cryptodev_capabilities *crypto_cap;
10279 const struct rte_cryptodev_symmetric_capability *sym_cap;
10282 /* Set action type */
10283 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10284 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10287 if (security_proto_supported(ut_params->type,
10288 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10289 return TEST_SKIPPED;
10291 sec_cap_idx.action = ut_params->type;
10292 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10293 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
10295 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10296 if (sec_cap == NULL)
10297 return TEST_SKIPPED;
10299 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10300 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10301 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10302 crypto_cap->sym.xform_type ==
10303 RTE_CRYPTO_SYM_XFORM_CIPHER &&
10304 crypto_cap->sym.cipher.algo ==
10305 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10306 sym_cap = &crypto_cap->sym;
10307 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10309 d_td->iv.len) == 0)
10314 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10315 return TEST_SKIPPED;
10317 /* Setup source mbuf payload */
10318 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10319 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10320 rte_pktmbuf_tailroom(ut_params->ibuf));
10322 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10323 d_td->ciphertext.len);
10325 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
10327 /* Setup cipher session parameters */
10328 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10329 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10330 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
10331 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10332 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10333 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10334 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10335 ut_params->cipher_xform.next = NULL;
10337 /* Setup DOCSIS session parameters */
10338 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
10340 struct rte_security_session_conf sess_conf = {
10341 .action_type = ut_params->type,
10342 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10343 .docsis = ut_params->docsis_xform,
10344 .crypto_xform = &ut_params->cipher_xform,
10347 /* Create security session */
10348 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10349 ts_params->session_mpool,
10350 ts_params->session_priv_mpool);
10352 if (!ut_params->sec_session) {
10353 printf("Test function %s line %u: failed to allocate session\n",
10354 __func__, __LINE__);
10359 /* Generate crypto op data structure */
10360 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10361 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10362 if (!ut_params->op) {
10363 printf("Test function %s line %u: failed to allocate symmetric "
10364 "crypto operation\n", __func__, __LINE__);
10369 /* Setup CRC operation parameters */
10370 crc_len = d_td->ciphertext.no_crc == false ?
10371 (d_td->ciphertext.len -
10372 d_td->ciphertext.crc_offset -
10373 RTE_ETHER_CRC_LEN) :
10375 crc_len = crc_len > 0 ? crc_len : 0;
10376 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
10377 ut_params->op->sym->auth.data.length = crc_len;
10378 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
10380 /* Setup cipher operation parameters */
10381 cipher_len = d_td->ciphertext.no_cipher == false ?
10382 (d_td->ciphertext.len -
10383 d_td->ciphertext.cipher_offset) :
10385 cipher_len = cipher_len > 0 ? cipher_len : 0;
10386 ut_params->op->sym->cipher.data.length = cipher_len;
10387 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
10389 /* Setup cipher IV */
10390 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10391 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10393 /* Attach session to operation */
10394 rte_security_attach_session(ut_params->op, ut_params->sec_session);
10396 /* Set crypto operation mbufs */
10397 ut_params->op->sym->m_src = ut_params->ibuf;
10398 ut_params->op->sym->m_dst = NULL;
10400 /* Process crypto operation */
10401 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10403 printf("Test function %s line %u: failed to process security "
10404 "crypto op\n", __func__, __LINE__);
10409 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10410 printf("Test function %s line %u: failed to process crypto op\n",
10411 __func__, __LINE__);
10416 /* Validate plaintext */
10417 plaintext = ciphertext;
10419 if (memcmp(plaintext, d_td->plaintext.data,
10420 d_td->plaintext.len - crc_data_len)) {
10421 printf("Test function %s line %u: plaintext not as expected\n",
10422 __func__, __LINE__);
10423 rte_hexdump(stdout, "expected", d_td->plaintext.data,
10424 d_td->plaintext.len);
10425 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
10431 rte_crypto_op_free(ut_params->op);
10432 ut_params->op = NULL;
10434 if (ut_params->sec_session)
10435 rte_security_session_destroy(ctx, ut_params->sec_session);
10436 ut_params->sec_session = NULL;
10438 rte_pktmbuf_free(ut_params->ibuf);
10439 ut_params->ibuf = NULL;
10445 test_docsis_proto_downlink(const void *data)
10447 const struct docsis_test_data *d_td = data;
10448 struct crypto_testsuite_params *ts_params = &testsuite_params;
10449 struct crypto_unittest_params *ut_params = &unittest_params;
10450 uint8_t *plaintext = NULL;
10451 uint8_t *ciphertext = NULL;
10453 int32_t cipher_len, crc_len;
10454 int ret = TEST_SUCCESS;
10456 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10457 rte_cryptodev_get_sec_ctx(
10458 ts_params->valid_devs[0]);
10460 /* Verify the capabilities */
10461 struct rte_security_capability_idx sec_cap_idx;
10462 const struct rte_security_capability *sec_cap;
10463 const struct rte_cryptodev_capabilities *crypto_cap;
10464 const struct rte_cryptodev_symmetric_capability *sym_cap;
10467 /* Set action type */
10468 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10469 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10472 if (security_proto_supported(ut_params->type,
10473 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10474 return TEST_SKIPPED;
10476 sec_cap_idx.action = ut_params->type;
10477 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10478 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10480 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10481 if (sec_cap == NULL)
10482 return TEST_SKIPPED;
10484 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10485 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10486 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10487 crypto_cap->sym.xform_type ==
10488 RTE_CRYPTO_SYM_XFORM_CIPHER &&
10489 crypto_cap->sym.cipher.algo ==
10490 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10491 sym_cap = &crypto_cap->sym;
10492 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10494 d_td->iv.len) == 0)
10499 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10500 return TEST_SKIPPED;
10502 /* Setup source mbuf payload */
10503 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10504 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10505 rte_pktmbuf_tailroom(ut_params->ibuf));
10507 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10508 d_td->plaintext.len);
10510 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
10512 /* Setup cipher session parameters */
10513 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10514 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10515 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10516 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10517 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10518 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10519 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10520 ut_params->cipher_xform.next = NULL;
10522 /* Setup DOCSIS session parameters */
10523 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10525 struct rte_security_session_conf sess_conf = {
10526 .action_type = ut_params->type,
10527 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10528 .docsis = ut_params->docsis_xform,
10529 .crypto_xform = &ut_params->cipher_xform,
10532 /* Create security session */
10533 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10534 ts_params->session_mpool,
10535 ts_params->session_priv_mpool);
10537 if (!ut_params->sec_session) {
10538 printf("Test function %s line %u: failed to allocate session\n",
10539 __func__, __LINE__);
10544 /* Generate crypto op data structure */
10545 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10546 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10547 if (!ut_params->op) {
10548 printf("Test function %s line %u: failed to allocate symmetric "
10549 "crypto operation\n", __func__, __LINE__);
10554 /* Setup CRC operation parameters */
10555 crc_len = d_td->plaintext.no_crc == false ?
10556 (d_td->plaintext.len -
10557 d_td->plaintext.crc_offset -
10558 RTE_ETHER_CRC_LEN) :
10560 crc_len = crc_len > 0 ? crc_len : 0;
10561 ut_params->op->sym->auth.data.length = crc_len;
10562 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
10564 /* Setup cipher operation parameters */
10565 cipher_len = d_td->plaintext.no_cipher == false ?
10566 (d_td->plaintext.len -
10567 d_td->plaintext.cipher_offset) :
10569 cipher_len = cipher_len > 0 ? cipher_len : 0;
10570 ut_params->op->sym->cipher.data.length = cipher_len;
10571 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
10573 /* Setup cipher IV */
10574 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10575 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10577 /* Attach session to operation */
10578 rte_security_attach_session(ut_params->op, ut_params->sec_session);
10580 /* Set crypto operation mbufs */
10581 ut_params->op->sym->m_src = ut_params->ibuf;
10582 ut_params->op->sym->m_dst = NULL;
10584 /* Process crypto operation */
10585 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10587 printf("Test function %s line %u: failed to process crypto op\n",
10588 __func__, __LINE__);
10593 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10594 printf("Test function %s line %u: crypto op processing failed\n",
10595 __func__, __LINE__);
10600 /* Validate ciphertext */
10601 ciphertext = plaintext;
10603 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
10604 printf("Test function %s line %u: plaintext not as expected\n",
10605 __func__, __LINE__);
10606 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
10607 d_td->ciphertext.len);
10608 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
10614 rte_crypto_op_free(ut_params->op);
10615 ut_params->op = NULL;
10617 if (ut_params->sec_session)
10618 rte_security_session_destroy(ctx, ut_params->sec_session);
10619 ut_params->sec_session = NULL;
10621 rte_pktmbuf_free(ut_params->ibuf);
10622 ut_params->ibuf = NULL;
10629 test_AES_GCM_authenticated_encryption_test_case_1(void)
10631 return test_authenticated_encryption(&gcm_test_case_1);
10635 test_AES_GCM_authenticated_encryption_test_case_2(void)
10637 return test_authenticated_encryption(&gcm_test_case_2);
10641 test_AES_GCM_authenticated_encryption_test_case_3(void)
10643 return test_authenticated_encryption(&gcm_test_case_3);
10647 test_AES_GCM_authenticated_encryption_test_case_4(void)
10649 return test_authenticated_encryption(&gcm_test_case_4);
10653 test_AES_GCM_authenticated_encryption_test_case_5(void)
10655 return test_authenticated_encryption(&gcm_test_case_5);
10659 test_AES_GCM_authenticated_encryption_test_case_6(void)
10661 return test_authenticated_encryption(&gcm_test_case_6);
10665 test_AES_GCM_authenticated_encryption_test_case_7(void)
10667 return test_authenticated_encryption(&gcm_test_case_7);
10671 test_AES_GCM_authenticated_encryption_test_case_8(void)
10673 return test_authenticated_encryption(&gcm_test_case_8);
10677 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
10679 return test_authenticated_encryption(&gcm_J0_test_case_1);
10683 test_AES_GCM_auth_encryption_test_case_192_1(void)
10685 return test_authenticated_encryption(&gcm_test_case_192_1);
10689 test_AES_GCM_auth_encryption_test_case_192_2(void)
10691 return test_authenticated_encryption(&gcm_test_case_192_2);
10695 test_AES_GCM_auth_encryption_test_case_192_3(void)
10697 return test_authenticated_encryption(&gcm_test_case_192_3);
10701 test_AES_GCM_auth_encryption_test_case_192_4(void)
10703 return test_authenticated_encryption(&gcm_test_case_192_4);
10707 test_AES_GCM_auth_encryption_test_case_192_5(void)
10709 return test_authenticated_encryption(&gcm_test_case_192_5);
10713 test_AES_GCM_auth_encryption_test_case_192_6(void)
10715 return test_authenticated_encryption(&gcm_test_case_192_6);
10719 test_AES_GCM_auth_encryption_test_case_192_7(void)
10721 return test_authenticated_encryption(&gcm_test_case_192_7);
10725 test_AES_GCM_auth_encryption_test_case_256_1(void)
10727 return test_authenticated_encryption(&gcm_test_case_256_1);
10731 test_AES_GCM_auth_encryption_test_case_256_2(void)
10733 return test_authenticated_encryption(&gcm_test_case_256_2);
10737 test_AES_GCM_auth_encryption_test_case_256_3(void)
10739 return test_authenticated_encryption(&gcm_test_case_256_3);
10743 test_AES_GCM_auth_encryption_test_case_256_4(void)
10745 return test_authenticated_encryption(&gcm_test_case_256_4);
10749 test_AES_GCM_auth_encryption_test_case_256_5(void)
10751 return test_authenticated_encryption(&gcm_test_case_256_5);
10755 test_AES_GCM_auth_encryption_test_case_256_6(void)
10757 return test_authenticated_encryption(&gcm_test_case_256_6);
10761 test_AES_GCM_auth_encryption_test_case_256_7(void)
10763 return test_authenticated_encryption(&gcm_test_case_256_7);
10767 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10769 return test_authenticated_encryption(&gcm_test_case_aad_1);
10773 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10775 return test_authenticated_encryption(&gcm_test_case_aad_2);
10779 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10781 struct aead_test_data tdata;
10784 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10785 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10786 tdata.iv.data[0] += 1;
10787 res = test_authenticated_encryption(&tdata);
10788 if (res == TEST_SKIPPED)
10790 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10791 return TEST_SUCCESS;
10795 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10797 struct aead_test_data tdata;
10800 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10801 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10802 tdata.plaintext.data[0] += 1;
10803 res = test_authenticated_encryption(&tdata);
10804 if (res == TEST_SKIPPED)
10806 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10807 return TEST_SUCCESS;
10811 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10813 struct aead_test_data tdata;
10816 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10817 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10818 tdata.ciphertext.data[0] += 1;
10819 res = test_authenticated_encryption(&tdata);
10820 if (res == TEST_SKIPPED)
10822 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10823 return TEST_SUCCESS;
10827 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10829 struct aead_test_data tdata;
10832 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10833 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10834 tdata.aad.len += 1;
10835 res = test_authenticated_encryption(&tdata);
10836 if (res == TEST_SKIPPED)
10838 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10839 return TEST_SUCCESS;
10843 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10845 struct aead_test_data tdata;
10846 uint8_t aad[gcm_test_case_7.aad.len];
10849 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10850 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10851 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10853 tdata.aad.data = aad;
10854 res = test_authenticated_encryption(&tdata);
10855 if (res == TEST_SKIPPED)
10857 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10858 return TEST_SUCCESS;
10862 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10864 struct aead_test_data tdata;
10867 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10868 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10869 tdata.auth_tag.data[0] += 1;
10870 res = test_authenticated_encryption(&tdata);
10871 if (res == TEST_SKIPPED)
10873 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10874 return TEST_SUCCESS;
10878 test_authenticated_decryption(const struct aead_test_data *tdata)
10880 struct crypto_testsuite_params *ts_params = &testsuite_params;
10881 struct crypto_unittest_params *ut_params = &unittest_params;
10884 uint8_t *plaintext;
10886 struct rte_cryptodev_info dev_info;
10888 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10889 uint64_t feat_flags = dev_info.feature_flags;
10891 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10892 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10893 printf("Device doesn't support RAW data-path APIs.\n");
10894 return TEST_SKIPPED;
10897 /* Verify the capabilities */
10898 struct rte_cryptodev_sym_capability_idx cap_idx;
10899 const struct rte_cryptodev_symmetric_capability *capability;
10900 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10901 cap_idx.algo.aead = tdata->algo;
10902 capability = rte_cryptodev_sym_capability_get(
10903 ts_params->valid_devs[0], &cap_idx);
10904 if (capability == NULL)
10905 return TEST_SKIPPED;
10906 if (rte_cryptodev_sym_capability_check_aead(
10907 capability, tdata->key.len, tdata->auth_tag.len,
10908 tdata->aad.len, tdata->iv.len))
10909 return TEST_SKIPPED;
10911 /* Create AEAD session */
10912 retval = create_aead_session(ts_params->valid_devs[0],
10914 RTE_CRYPTO_AEAD_OP_DECRYPT,
10915 tdata->key.data, tdata->key.len,
10916 tdata->aad.len, tdata->auth_tag.len,
10921 /* alloc mbuf and set payload */
10922 if (tdata->aad.len > MBUF_SIZE) {
10923 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10924 /* Populate full size of add data */
10925 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10926 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10928 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10930 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10931 rte_pktmbuf_tailroom(ut_params->ibuf));
10933 /* Create AEAD operation */
10934 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10938 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10940 ut_params->op->sym->m_src = ut_params->ibuf;
10942 /* Process crypto operation */
10943 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10944 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10945 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10946 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10947 ut_params->op, 0, 0, 0, 0);
10949 TEST_ASSERT_NOT_NULL(
10950 process_crypto_request(ts_params->valid_devs[0],
10951 ut_params->op), "failed to process sym crypto op");
10953 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10954 "crypto op processing failed");
10956 if (ut_params->op->sym->m_dst)
10957 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10960 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10962 ut_params->op->sym->cipher.data.offset);
10964 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10966 /* Validate obuf */
10967 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10969 tdata->plaintext.data,
10970 tdata->plaintext.len,
10971 "Plaintext data not as expected");
10973 TEST_ASSERT_EQUAL(ut_params->op->status,
10974 RTE_CRYPTO_OP_STATUS_SUCCESS,
10975 "Authentication failed");
10981 test_AES_GCM_authenticated_decryption_test_case_1(void)
10983 return test_authenticated_decryption(&gcm_test_case_1);
10987 test_AES_GCM_authenticated_decryption_test_case_2(void)
10989 return test_authenticated_decryption(&gcm_test_case_2);
10993 test_AES_GCM_authenticated_decryption_test_case_3(void)
10995 return test_authenticated_decryption(&gcm_test_case_3);
10999 test_AES_GCM_authenticated_decryption_test_case_4(void)
11001 return test_authenticated_decryption(&gcm_test_case_4);
11005 test_AES_GCM_authenticated_decryption_test_case_5(void)
11007 return test_authenticated_decryption(&gcm_test_case_5);
11011 test_AES_GCM_authenticated_decryption_test_case_6(void)
11013 return test_authenticated_decryption(&gcm_test_case_6);
11017 test_AES_GCM_authenticated_decryption_test_case_7(void)
11019 return test_authenticated_decryption(&gcm_test_case_7);
11023 test_AES_GCM_authenticated_decryption_test_case_8(void)
11025 return test_authenticated_decryption(&gcm_test_case_8);
11029 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
11031 return test_authenticated_decryption(&gcm_J0_test_case_1);
11035 test_AES_GCM_auth_decryption_test_case_192_1(void)
11037 return test_authenticated_decryption(&gcm_test_case_192_1);
11041 test_AES_GCM_auth_decryption_test_case_192_2(void)
11043 return test_authenticated_decryption(&gcm_test_case_192_2);
11047 test_AES_GCM_auth_decryption_test_case_192_3(void)
11049 return test_authenticated_decryption(&gcm_test_case_192_3);
11053 test_AES_GCM_auth_decryption_test_case_192_4(void)
11055 return test_authenticated_decryption(&gcm_test_case_192_4);
11059 test_AES_GCM_auth_decryption_test_case_192_5(void)
11061 return test_authenticated_decryption(&gcm_test_case_192_5);
11065 test_AES_GCM_auth_decryption_test_case_192_6(void)
11067 return test_authenticated_decryption(&gcm_test_case_192_6);
11071 test_AES_GCM_auth_decryption_test_case_192_7(void)
11073 return test_authenticated_decryption(&gcm_test_case_192_7);
11077 test_AES_GCM_auth_decryption_test_case_256_1(void)
11079 return test_authenticated_decryption(&gcm_test_case_256_1);
11083 test_AES_GCM_auth_decryption_test_case_256_2(void)
11085 return test_authenticated_decryption(&gcm_test_case_256_2);
11089 test_AES_GCM_auth_decryption_test_case_256_3(void)
11091 return test_authenticated_decryption(&gcm_test_case_256_3);
11095 test_AES_GCM_auth_decryption_test_case_256_4(void)
11097 return test_authenticated_decryption(&gcm_test_case_256_4);
11101 test_AES_GCM_auth_decryption_test_case_256_5(void)
11103 return test_authenticated_decryption(&gcm_test_case_256_5);
11107 test_AES_GCM_auth_decryption_test_case_256_6(void)
11109 return test_authenticated_decryption(&gcm_test_case_256_6);
11113 test_AES_GCM_auth_decryption_test_case_256_7(void)
11115 return test_authenticated_decryption(&gcm_test_case_256_7);
11119 test_AES_GCM_auth_decryption_test_case_aad_1(void)
11121 return test_authenticated_decryption(&gcm_test_case_aad_1);
11125 test_AES_GCM_auth_decryption_test_case_aad_2(void)
11127 return test_authenticated_decryption(&gcm_test_case_aad_2);
11131 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
11133 struct aead_test_data tdata;
11136 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11137 tdata.iv.data[0] += 1;
11138 res = test_authenticated_decryption(&tdata);
11139 if (res == TEST_SKIPPED)
11141 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11142 return TEST_SUCCESS;
11146 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
11148 struct aead_test_data tdata;
11151 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
11152 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11153 tdata.plaintext.data[0] += 1;
11154 res = test_authenticated_decryption(&tdata);
11155 if (res == TEST_SKIPPED)
11157 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11158 return TEST_SUCCESS;
11162 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
11164 struct aead_test_data tdata;
11167 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11168 tdata.ciphertext.data[0] += 1;
11169 res = test_authenticated_decryption(&tdata);
11170 if (res == TEST_SKIPPED)
11172 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11173 return TEST_SUCCESS;
11177 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
11179 struct aead_test_data tdata;
11182 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11183 tdata.aad.len += 1;
11184 res = test_authenticated_decryption(&tdata);
11185 if (res == TEST_SKIPPED)
11187 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11188 return TEST_SUCCESS;
11192 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
11194 struct aead_test_data tdata;
11195 uint8_t aad[gcm_test_case_7.aad.len];
11198 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11199 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
11201 tdata.aad.data = aad;
11202 res = test_authenticated_decryption(&tdata);
11203 if (res == TEST_SKIPPED)
11205 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
11206 return TEST_SUCCESS;
11210 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
11212 struct aead_test_data tdata;
11215 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
11216 tdata.auth_tag.data[0] += 1;
11217 res = test_authenticated_decryption(&tdata);
11218 if (res == TEST_SKIPPED)
11220 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
11221 return TEST_SUCCESS;
11225 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
11227 struct crypto_testsuite_params *ts_params = &testsuite_params;
11228 struct crypto_unittest_params *ut_params = &unittest_params;
11231 uint8_t *ciphertext, *auth_tag;
11232 uint16_t plaintext_pad_len;
11233 struct rte_cryptodev_info dev_info;
11235 /* Verify the capabilities */
11236 struct rte_cryptodev_sym_capability_idx cap_idx;
11237 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11238 cap_idx.algo.aead = tdata->algo;
11239 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11241 return TEST_SKIPPED;
11243 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11244 uint64_t feat_flags = dev_info.feature_flags;
11246 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11247 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
11248 return TEST_SKIPPED;
11250 /* not supported with CPU crypto */
11251 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11252 return TEST_SKIPPED;
11254 /* Create AEAD session */
11255 retval = create_aead_session(ts_params->valid_devs[0],
11257 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11258 tdata->key.data, tdata->key.len,
11259 tdata->aad.len, tdata->auth_tag.len,
11264 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11265 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11267 /* clear mbuf payload */
11268 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11269 rte_pktmbuf_tailroom(ut_params->ibuf));
11270 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
11271 rte_pktmbuf_tailroom(ut_params->obuf));
11273 /* Create AEAD operation */
11274 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11278 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11280 ut_params->op->sym->m_src = ut_params->ibuf;
11281 ut_params->op->sym->m_dst = ut_params->obuf;
11283 /* Process crypto operation */
11284 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11285 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11286 ut_params->op, 0, 0, 0, 0);
11288 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11289 ut_params->op), "failed to process sym crypto op");
11291 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11292 "crypto op processing failed");
11294 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11296 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
11297 ut_params->op->sym->cipher.data.offset);
11298 auth_tag = ciphertext + plaintext_pad_len;
11300 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11301 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11303 /* Validate obuf */
11304 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11306 tdata->ciphertext.data,
11307 tdata->ciphertext.len,
11308 "Ciphertext data not as expected");
11310 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11312 tdata->auth_tag.data,
11313 tdata->auth_tag.len,
11314 "Generated auth tag not as expected");
11321 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
11323 return test_authenticated_encryption_oop(&gcm_test_case_5);
11327 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
11329 struct crypto_testsuite_params *ts_params = &testsuite_params;
11330 struct crypto_unittest_params *ut_params = &unittest_params;
11333 uint8_t *plaintext;
11334 struct rte_cryptodev_info dev_info;
11336 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11337 uint64_t feat_flags = dev_info.feature_flags;
11339 /* Verify the capabilities */
11340 struct rte_cryptodev_sym_capability_idx cap_idx;
11341 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11342 cap_idx.algo.aead = tdata->algo;
11343 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11345 return TEST_SKIPPED;
11347 /* not supported with CPU crypto and raw data-path APIs*/
11348 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
11349 global_api_test_type == CRYPTODEV_RAW_API_TEST)
11350 return TEST_SKIPPED;
11352 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11353 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11354 printf("Device does not support RAW data-path APIs.\n");
11355 return TEST_SKIPPED;
11358 /* Create AEAD session */
11359 retval = create_aead_session(ts_params->valid_devs[0],
11361 RTE_CRYPTO_AEAD_OP_DECRYPT,
11362 tdata->key.data, tdata->key.len,
11363 tdata->aad.len, tdata->auth_tag.len,
11368 /* alloc mbuf and set payload */
11369 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11370 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11372 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11373 rte_pktmbuf_tailroom(ut_params->ibuf));
11374 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
11375 rte_pktmbuf_tailroom(ut_params->obuf));
11377 /* Create AEAD operation */
11378 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11382 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11384 ut_params->op->sym->m_src = ut_params->ibuf;
11385 ut_params->op->sym->m_dst = ut_params->obuf;
11387 /* Process crypto operation */
11388 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11389 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11390 ut_params->op, 0, 0, 0, 0);
11392 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11393 ut_params->op), "failed to process sym crypto op");
11395 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11396 "crypto op processing failed");
11398 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
11399 ut_params->op->sym->cipher.data.offset);
11401 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11403 /* Validate obuf */
11404 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11406 tdata->plaintext.data,
11407 tdata->plaintext.len,
11408 "Plaintext data not as expected");
11410 TEST_ASSERT_EQUAL(ut_params->op->status,
11411 RTE_CRYPTO_OP_STATUS_SUCCESS,
11412 "Authentication failed");
11417 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
11419 return test_authenticated_decryption_oop(&gcm_test_case_5);
11423 test_authenticated_encryption_sessionless(
11424 const struct aead_test_data *tdata)
11426 struct crypto_testsuite_params *ts_params = &testsuite_params;
11427 struct crypto_unittest_params *ut_params = &unittest_params;
11430 uint8_t *ciphertext, *auth_tag;
11431 uint16_t plaintext_pad_len;
11432 uint8_t key[tdata->key.len + 1];
11433 struct rte_cryptodev_info dev_info;
11435 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11436 uint64_t feat_flags = dev_info.feature_flags;
11438 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11439 printf("Device doesn't support Sessionless ops.\n");
11440 return TEST_SKIPPED;
11443 /* not supported with CPU crypto */
11444 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11445 return TEST_SKIPPED;
11447 /* Verify the capabilities */
11448 struct rte_cryptodev_sym_capability_idx cap_idx;
11449 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11450 cap_idx.algo.aead = tdata->algo;
11451 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11453 return TEST_SKIPPED;
11455 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11457 /* clear mbuf payload */
11458 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11459 rte_pktmbuf_tailroom(ut_params->ibuf));
11461 /* Create AEAD operation */
11462 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11466 /* Create GCM xform */
11467 memcpy(key, tdata->key.data, tdata->key.len);
11468 retval = create_aead_xform(ut_params->op,
11470 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11471 key, tdata->key.len,
11472 tdata->aad.len, tdata->auth_tag.len,
11477 ut_params->op->sym->m_src = ut_params->ibuf;
11479 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11480 RTE_CRYPTO_OP_SESSIONLESS,
11481 "crypto op session type not sessionless");
11483 /* Process crypto operation */
11484 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11485 ut_params->op), "failed to process sym crypto op");
11487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11489 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11490 "crypto op status not success");
11492 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11494 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11495 ut_params->op->sym->cipher.data.offset);
11496 auth_tag = ciphertext + plaintext_pad_len;
11498 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11499 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11501 /* Validate obuf */
11502 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11504 tdata->ciphertext.data,
11505 tdata->ciphertext.len,
11506 "Ciphertext data not as expected");
11508 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11510 tdata->auth_tag.data,
11511 tdata->auth_tag.len,
11512 "Generated auth tag not as expected");
11519 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
11521 return test_authenticated_encryption_sessionless(
11526 test_authenticated_decryption_sessionless(
11527 const struct aead_test_data *tdata)
11529 struct crypto_testsuite_params *ts_params = &testsuite_params;
11530 struct crypto_unittest_params *ut_params = &unittest_params;
11533 uint8_t *plaintext;
11534 uint8_t key[tdata->key.len + 1];
11535 struct rte_cryptodev_info dev_info;
11537 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11538 uint64_t feat_flags = dev_info.feature_flags;
11540 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11541 printf("Device doesn't support Sessionless ops.\n");
11542 return TEST_SKIPPED;
11545 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11546 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11547 printf("Device doesn't support RAW data-path APIs.\n");
11548 return TEST_SKIPPED;
11551 /* not supported with CPU crypto */
11552 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11553 return TEST_SKIPPED;
11555 /* Verify the capabilities */
11556 struct rte_cryptodev_sym_capability_idx cap_idx;
11557 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11558 cap_idx.algo.aead = tdata->algo;
11559 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11561 return TEST_SKIPPED;
11563 /* alloc mbuf and set payload */
11564 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11566 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11567 rte_pktmbuf_tailroom(ut_params->ibuf));
11569 /* Create AEAD operation */
11570 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11574 /* Create AEAD xform */
11575 memcpy(key, tdata->key.data, tdata->key.len);
11576 retval = create_aead_xform(ut_params->op,
11578 RTE_CRYPTO_AEAD_OP_DECRYPT,
11579 key, tdata->key.len,
11580 tdata->aad.len, tdata->auth_tag.len,
11585 ut_params->op->sym->m_src = ut_params->ibuf;
11587 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11588 RTE_CRYPTO_OP_SESSIONLESS,
11589 "crypto op session type not sessionless");
11591 /* Process crypto operation */
11592 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11593 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11594 ut_params->op, 0, 0, 0, 0);
11596 TEST_ASSERT_NOT_NULL(process_crypto_request(
11597 ts_params->valid_devs[0], ut_params->op),
11598 "failed to process sym crypto op");
11600 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11602 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11603 "crypto op status not success");
11605 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11606 ut_params->op->sym->cipher.data.offset);
11608 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11610 /* Validate obuf */
11611 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11613 tdata->plaintext.data,
11614 tdata->plaintext.len,
11615 "Plaintext data not as expected");
11617 TEST_ASSERT_EQUAL(ut_params->op->status,
11618 RTE_CRYPTO_OP_STATUS_SUCCESS,
11619 "Authentication failed");
11624 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
11626 return test_authenticated_decryption_sessionless(
11631 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
11633 return test_authenticated_encryption(&ccm_test_case_128_1);
11637 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
11639 return test_authenticated_encryption(&ccm_test_case_128_2);
11643 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
11645 return test_authenticated_encryption(&ccm_test_case_128_3);
11649 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
11651 return test_authenticated_decryption(&ccm_test_case_128_1);
11655 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
11657 return test_authenticated_decryption(&ccm_test_case_128_2);
11661 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
11663 return test_authenticated_decryption(&ccm_test_case_128_3);
11667 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
11669 return test_authenticated_encryption(&ccm_test_case_192_1);
11673 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
11675 return test_authenticated_encryption(&ccm_test_case_192_2);
11679 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
11681 return test_authenticated_encryption(&ccm_test_case_192_3);
11685 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
11687 return test_authenticated_decryption(&ccm_test_case_192_1);
11691 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
11693 return test_authenticated_decryption(&ccm_test_case_192_2);
11697 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
11699 return test_authenticated_decryption(&ccm_test_case_192_3);
11703 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11705 return test_authenticated_encryption(&ccm_test_case_256_1);
11709 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11711 return test_authenticated_encryption(&ccm_test_case_256_2);
11715 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11717 return test_authenticated_encryption(&ccm_test_case_256_3);
11721 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11723 return test_authenticated_decryption(&ccm_test_case_256_1);
11727 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11729 return test_authenticated_decryption(&ccm_test_case_256_2);
11733 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11735 return test_authenticated_decryption(&ccm_test_case_256_3);
11741 struct crypto_testsuite_params *ts_params = &testsuite_params;
11742 struct rte_cryptodev_stats stats;
11744 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11745 return TEST_SKIPPED;
11747 /* Verify the capabilities */
11748 struct rte_cryptodev_sym_capability_idx cap_idx;
11749 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11750 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11751 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11753 return TEST_SKIPPED;
11754 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11755 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11756 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11758 return TEST_SKIPPED;
11760 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11762 return TEST_SKIPPED;
11764 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11765 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11766 &stats) == -ENODEV),
11767 "rte_cryptodev_stats_get invalid dev failed");
11768 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11769 "rte_cryptodev_stats_get invalid Param failed");
11771 /* Test expected values */
11772 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11773 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11775 "rte_cryptodev_stats_get failed");
11776 TEST_ASSERT((stats.enqueued_count == 1),
11777 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11778 TEST_ASSERT((stats.dequeued_count == 1),
11779 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11780 TEST_ASSERT((stats.enqueue_err_count == 0),
11781 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11782 TEST_ASSERT((stats.dequeue_err_count == 0),
11783 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11785 /* invalid device but should ignore and not reset device stats*/
11786 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11787 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11789 "rte_cryptodev_stats_get failed");
11790 TEST_ASSERT((stats.enqueued_count == 1),
11791 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11793 /* check that a valid reset clears stats */
11794 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11795 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11797 "rte_cryptodev_stats_get failed");
11798 TEST_ASSERT((stats.enqueued_count == 0),
11799 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11800 TEST_ASSERT((stats.dequeued_count == 0),
11801 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11803 return TEST_SUCCESS;
11806 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11807 struct crypto_unittest_params *ut_params,
11808 enum rte_crypto_auth_operation op,
11809 const struct HMAC_MD5_vector *test_case)
11814 memcpy(key, test_case->key.data, test_case->key.len);
11816 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11817 ut_params->auth_xform.next = NULL;
11818 ut_params->auth_xform.auth.op = op;
11820 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11822 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11823 ut_params->auth_xform.auth.key.length = test_case->key.len;
11824 ut_params->auth_xform.auth.key.data = key;
11826 ut_params->sess = rte_cryptodev_sym_session_create(
11827 ts_params->session_mpool);
11828 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11829 if (ut_params->sess == NULL)
11830 return TEST_FAILED;
11832 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11833 ut_params->sess, &ut_params->auth_xform,
11834 ts_params->session_priv_mpool);
11835 if (status == -ENOTSUP)
11836 return TEST_SKIPPED;
11838 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11840 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11841 rte_pktmbuf_tailroom(ut_params->ibuf));
11846 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11847 const struct HMAC_MD5_vector *test_case,
11848 uint8_t **plaintext)
11850 uint16_t plaintext_pad_len;
11852 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11854 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11857 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11858 plaintext_pad_len);
11859 memcpy(*plaintext, test_case->plaintext.data,
11860 test_case->plaintext.len);
11862 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11863 ut_params->ibuf, MD5_DIGEST_LEN);
11864 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11865 "no room to append digest");
11866 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11867 ut_params->ibuf, plaintext_pad_len);
11869 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11870 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11871 test_case->auth_tag.len);
11874 sym_op->auth.data.offset = 0;
11875 sym_op->auth.data.length = test_case->plaintext.len;
11877 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11878 ut_params->op->sym->m_src = ut_params->ibuf;
11884 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11886 uint16_t plaintext_pad_len;
11887 uint8_t *plaintext, *auth_tag;
11889 struct crypto_testsuite_params *ts_params = &testsuite_params;
11890 struct crypto_unittest_params *ut_params = &unittest_params;
11891 struct rte_cryptodev_info dev_info;
11893 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11894 uint64_t feat_flags = dev_info.feature_flags;
11896 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11897 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11898 printf("Device doesn't support RAW data-path APIs.\n");
11899 return TEST_SKIPPED;
11902 /* Verify the capabilities */
11903 struct rte_cryptodev_sym_capability_idx cap_idx;
11904 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11905 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11906 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11908 return TEST_SKIPPED;
11910 if (MD5_HMAC_create_session(ts_params, ut_params,
11911 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11912 return TEST_FAILED;
11914 /* Generate Crypto op data structure */
11915 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11916 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11917 TEST_ASSERT_NOT_NULL(ut_params->op,
11918 "Failed to allocate symmetric crypto operation struct");
11920 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11923 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11924 return TEST_FAILED;
11926 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11927 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11929 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11930 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11931 ut_params->op, 0, 1, 0, 0);
11933 TEST_ASSERT_NOT_NULL(
11934 process_crypto_request(ts_params->valid_devs[0],
11936 "failed to process sym crypto op");
11938 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11939 "crypto op processing failed");
11941 if (ut_params->op->sym->m_dst) {
11942 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11943 uint8_t *, plaintext_pad_len);
11945 auth_tag = plaintext + plaintext_pad_len;
11948 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11950 test_case->auth_tag.data,
11951 test_case->auth_tag.len,
11952 "HMAC_MD5 generated tag not as expected");
11954 return TEST_SUCCESS;
11958 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11960 uint8_t *plaintext;
11962 struct crypto_testsuite_params *ts_params = &testsuite_params;
11963 struct crypto_unittest_params *ut_params = &unittest_params;
11964 struct rte_cryptodev_info dev_info;
11966 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11967 uint64_t feat_flags = dev_info.feature_flags;
11969 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11970 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11971 printf("Device doesn't support RAW data-path APIs.\n");
11972 return TEST_SKIPPED;
11975 /* Verify the capabilities */
11976 struct rte_cryptodev_sym_capability_idx cap_idx;
11977 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11978 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11979 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11981 return TEST_SKIPPED;
11983 if (MD5_HMAC_create_session(ts_params, ut_params,
11984 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11985 return TEST_FAILED;
11988 /* Generate Crypto op data structure */
11989 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11990 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11991 TEST_ASSERT_NOT_NULL(ut_params->op,
11992 "Failed to allocate symmetric crypto operation struct");
11994 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11995 return TEST_FAILED;
11997 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11998 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12000 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12001 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12002 ut_params->op, 0, 1, 0, 0);
12004 TEST_ASSERT_NOT_NULL(
12005 process_crypto_request(ts_params->valid_devs[0],
12007 "failed to process sym crypto op");
12009 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12010 "HMAC_MD5 crypto op processing failed");
12012 return TEST_SUCCESS;
12016 test_MD5_HMAC_generate_case_1(void)
12018 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
12022 test_MD5_HMAC_verify_case_1(void)
12024 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
12028 test_MD5_HMAC_generate_case_2(void)
12030 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
12034 test_MD5_HMAC_verify_case_2(void)
12036 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
12040 test_multi_session(void)
12042 struct crypto_testsuite_params *ts_params = &testsuite_params;
12043 struct crypto_unittest_params *ut_params = &unittest_params;
12045 struct rte_cryptodev_info dev_info;
12046 struct rte_cryptodev_sym_session **sessions;
12051 /* Verify the capabilities */
12052 struct rte_cryptodev_sym_capability_idx cap_idx;
12053 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12054 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
12055 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12057 return TEST_SKIPPED;
12058 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12059 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12060 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12062 return TEST_SKIPPED;
12064 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
12065 aes_cbc_key, hmac_sha512_key);
12068 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12070 sessions = rte_malloc(NULL,
12071 sizeof(struct rte_cryptodev_sym_session *) *
12072 (MAX_NB_SESSIONS + 1), 0);
12074 /* Create multiple crypto sessions*/
12075 for (i = 0; i < MAX_NB_SESSIONS; i++) {
12077 sessions[i] = rte_cryptodev_sym_session_create(
12078 ts_params->session_mpool);
12079 TEST_ASSERT_NOT_NULL(sessions[i],
12080 "Session creation failed at session number %u",
12083 status = rte_cryptodev_sym_session_init(
12084 ts_params->valid_devs[0],
12085 sessions[i], &ut_params->auth_xform,
12086 ts_params->session_priv_mpool);
12087 if (status == -ENOTSUP)
12088 return TEST_SKIPPED;
12090 /* Attempt to send a request on each session */
12091 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
12095 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
12096 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
12098 "Failed to perform decrypt on request number %u.", i);
12099 /* free crypto operation structure */
12101 rte_crypto_op_free(ut_params->op);
12104 * free mbuf - both obuf and ibuf are usually the same,
12105 * so check if they point at the same address is necessary,
12106 * to avoid freeing the mbuf twice.
12108 if (ut_params->obuf) {
12109 rte_pktmbuf_free(ut_params->obuf);
12110 if (ut_params->ibuf == ut_params->obuf)
12111 ut_params->ibuf = 0;
12112 ut_params->obuf = 0;
12114 if (ut_params->ibuf) {
12115 rte_pktmbuf_free(ut_params->ibuf);
12116 ut_params->ibuf = 0;
12120 sessions[i] = NULL;
12121 /* Next session create should fail */
12122 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12123 sessions[i], &ut_params->auth_xform,
12124 ts_params->session_priv_mpool);
12125 TEST_ASSERT_NULL(sessions[i],
12126 "Session creation succeeded unexpectedly!");
12128 for (i = 0; i < MAX_NB_SESSIONS; i++) {
12129 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
12131 rte_cryptodev_sym_session_free(sessions[i]);
12134 rte_free(sessions);
12136 return TEST_SUCCESS;
12139 struct multi_session_params {
12140 struct crypto_unittest_params ut_params;
12141 uint8_t *cipher_key;
12143 const uint8_t *cipher;
12144 const uint8_t *digest;
12148 #define MB_SESSION_NUMBER 3
12151 test_multi_session_random_usage(void)
12153 struct crypto_testsuite_params *ts_params = &testsuite_params;
12154 struct rte_cryptodev_info dev_info;
12155 struct rte_cryptodev_sym_session **sessions;
12157 struct multi_session_params ut_paramz[] = {
12160 .cipher_key = ms_aes_cbc_key0,
12161 .hmac_key = ms_hmac_key0,
12162 .cipher = ms_aes_cbc_cipher0,
12163 .digest = ms_hmac_digest0,
12164 .iv = ms_aes_cbc_iv0
12167 .cipher_key = ms_aes_cbc_key1,
12168 .hmac_key = ms_hmac_key1,
12169 .cipher = ms_aes_cbc_cipher1,
12170 .digest = ms_hmac_digest1,
12171 .iv = ms_aes_cbc_iv1
12174 .cipher_key = ms_aes_cbc_key2,
12175 .hmac_key = ms_hmac_key2,
12176 .cipher = ms_aes_cbc_cipher2,
12177 .digest = ms_hmac_digest2,
12178 .iv = ms_aes_cbc_iv2
12184 /* Verify the capabilities */
12185 struct rte_cryptodev_sym_capability_idx cap_idx;
12186 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12187 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
12188 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12190 return TEST_SKIPPED;
12191 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12192 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
12193 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12195 return TEST_SKIPPED;
12197 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12199 sessions = rte_malloc(NULL,
12200 (sizeof(struct rte_cryptodev_sym_session *)
12201 * MAX_NB_SESSIONS) + 1, 0);
12203 for (i = 0; i < MB_SESSION_NUMBER; i++) {
12204 sessions[i] = rte_cryptodev_sym_session_create(
12205 ts_params->session_mpool);
12206 TEST_ASSERT_NOT_NULL(sessions[i],
12207 "Session creation failed at session number %u",
12210 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
12211 sizeof(struct crypto_unittest_params));
12213 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
12214 &ut_paramz[i].ut_params,
12215 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
12217 /* Create multiple crypto sessions*/
12218 status = rte_cryptodev_sym_session_init(
12219 ts_params->valid_devs[0],
12221 &ut_paramz[i].ut_params.auth_xform,
12222 ts_params->session_priv_mpool);
12224 if (status == -ENOTSUP)
12225 return TEST_SKIPPED;
12227 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
12231 for (i = 0; i < 40000; i++) {
12233 j = rand() % MB_SESSION_NUMBER;
12235 TEST_ASSERT_SUCCESS(
12236 test_AES_CBC_HMAC_SHA512_decrypt_perform(
12238 &ut_paramz[j].ut_params,
12239 ts_params, ut_paramz[j].cipher,
12240 ut_paramz[j].digest,
12242 "Failed to perform decrypt on request number %u.", i);
12244 if (ut_paramz[j].ut_params.op)
12245 rte_crypto_op_free(ut_paramz[j].ut_params.op);
12248 * free mbuf - both obuf and ibuf are usually the same,
12249 * so check if they point at the same address is necessary,
12250 * to avoid freeing the mbuf twice.
12252 if (ut_paramz[j].ut_params.obuf) {
12253 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
12254 if (ut_paramz[j].ut_params.ibuf
12255 == ut_paramz[j].ut_params.obuf)
12256 ut_paramz[j].ut_params.ibuf = 0;
12257 ut_paramz[j].ut_params.obuf = 0;
12259 if (ut_paramz[j].ut_params.ibuf) {
12260 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
12261 ut_paramz[j].ut_params.ibuf = 0;
12265 for (i = 0; i < MB_SESSION_NUMBER; i++) {
12266 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
12268 rte_cryptodev_sym_session_free(sessions[i]);
12271 rte_free(sessions);
12273 return TEST_SUCCESS;
12276 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
12277 0xab, 0xab, 0xab, 0xab,
12278 0xab, 0xab, 0xab, 0xab,
12279 0xab, 0xab, 0xab, 0xab};
12282 test_null_invalid_operation(void)
12284 struct crypto_testsuite_params *ts_params = &testsuite_params;
12285 struct crypto_unittest_params *ut_params = &unittest_params;
12288 /* This test is for NULL PMD only */
12289 if (gbl_driver_id != rte_cryptodev_driver_id_get(
12290 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
12291 return TEST_SKIPPED;
12293 /* Setup Cipher Parameters */
12294 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12295 ut_params->cipher_xform.next = NULL;
12297 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
12298 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12300 ut_params->sess = rte_cryptodev_sym_session_create(
12301 ts_params->session_mpool);
12303 /* Create Crypto session*/
12304 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12305 ut_params->sess, &ut_params->cipher_xform,
12306 ts_params->session_priv_mpool);
12307 TEST_ASSERT(ret < 0,
12308 "Session creation succeeded unexpectedly");
12311 /* Setup HMAC Parameters */
12312 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12313 ut_params->auth_xform.next = NULL;
12315 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
12316 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12318 ut_params->sess = rte_cryptodev_sym_session_create(
12319 ts_params->session_mpool);
12321 /* Create Crypto session*/
12322 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12323 ut_params->sess, &ut_params->auth_xform,
12324 ts_params->session_priv_mpool);
12325 TEST_ASSERT(ret < 0,
12326 "Session creation succeeded unexpectedly");
12328 return TEST_SUCCESS;
12332 #define NULL_BURST_LENGTH (32)
12335 test_null_burst_operation(void)
12337 struct crypto_testsuite_params *ts_params = &testsuite_params;
12338 struct crypto_unittest_params *ut_params = &unittest_params;
12341 unsigned i, burst_len = NULL_BURST_LENGTH;
12343 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
12344 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
12346 /* This test is for NULL PMD only */
12347 if (gbl_driver_id != rte_cryptodev_driver_id_get(
12348 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
12349 return TEST_SKIPPED;
12351 /* Setup Cipher Parameters */
12352 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12353 ut_params->cipher_xform.next = &ut_params->auth_xform;
12355 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
12356 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12358 /* Setup HMAC Parameters */
12359 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12360 ut_params->auth_xform.next = NULL;
12362 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
12363 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12365 ut_params->sess = rte_cryptodev_sym_session_create(
12366 ts_params->session_mpool);
12367 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12369 /* Create Crypto session*/
12370 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12371 ut_params->sess, &ut_params->cipher_xform,
12372 ts_params->session_priv_mpool);
12374 if (status == -ENOTSUP)
12375 return TEST_SKIPPED;
12377 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
12379 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
12380 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
12381 burst_len, "failed to generate burst of crypto ops");
12383 /* Generate an operation for each mbuf in burst */
12384 for (i = 0; i < burst_len; i++) {
12385 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12387 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
12389 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
12393 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
12395 burst[i]->sym->m_src = m;
12398 /* Process crypto operation */
12399 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
12400 0, burst, burst_len),
12402 "Error enqueuing burst");
12404 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
12405 0, burst_dequeued, burst_len),
12407 "Error dequeuing burst");
12410 for (i = 0; i < burst_len; i++) {
12412 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
12413 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
12415 "data not as expected");
12417 rte_pktmbuf_free(burst[i]->sym->m_src);
12418 rte_crypto_op_free(burst[i]);
12421 return TEST_SUCCESS;
12425 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
12426 uint16_t nb_ops, void *user_param)
12428 RTE_SET_USED(dev_id);
12429 RTE_SET_USED(qp_id);
12431 RTE_SET_USED(user_param);
12433 printf("crypto enqueue callback called\n");
12438 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
12439 uint16_t nb_ops, void *user_param)
12441 RTE_SET_USED(dev_id);
12442 RTE_SET_USED(qp_id);
12444 RTE_SET_USED(user_param);
12446 printf("crypto dequeue callback called\n");
12451 * Thread using enqueue/dequeue callback with RCU.
12454 test_enqdeq_callback_thread(void *arg)
12457 /* DP thread calls rte_cryptodev_enqueue_burst()/
12458 * rte_cryptodev_dequeue_burst() and invokes callback.
12460 test_null_burst_operation();
12465 test_enq_callback_setup(void)
12467 struct crypto_testsuite_params *ts_params = &testsuite_params;
12468 struct rte_cryptodev_info dev_info;
12469 struct rte_cryptodev_qp_conf qp_conf = {
12470 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12473 struct rte_cryptodev_cb *cb;
12474 uint16_t qp_id = 0;
12476 /* Stop the device in case it's started so it can be configured */
12477 rte_cryptodev_stop(ts_params->valid_devs[0]);
12479 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12481 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12483 "Failed to configure cryptodev %u",
12484 ts_params->valid_devs[0]);
12486 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12487 qp_conf.mp_session = ts_params->session_mpool;
12488 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12490 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12491 ts_params->valid_devs[0], qp_id, &qp_conf,
12492 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12494 "rte_cryptodev_queue_pair_setup: num_inflights "
12495 "%u on qp %u on cryptodev %u",
12496 qp_conf.nb_descriptors, qp_id,
12497 ts_params->valid_devs[0]);
12499 /* Test with invalid crypto device */
12500 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
12501 qp_id, test_enq_callback, NULL);
12502 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12503 "cryptodev %u did not fail",
12504 qp_id, RTE_CRYPTO_MAX_DEVS);
12506 /* Test with invalid queue pair */
12507 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12508 dev_info.max_nb_queue_pairs + 1,
12509 test_enq_callback, NULL);
12510 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12511 "cryptodev %u did not fail",
12512 dev_info.max_nb_queue_pairs + 1,
12513 ts_params->valid_devs[0]);
12515 /* Test with NULL callback */
12516 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12517 qp_id, NULL, NULL);
12518 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12519 "cryptodev %u did not fail",
12520 qp_id, ts_params->valid_devs[0]);
12522 /* Test with valid configuration */
12523 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12524 qp_id, test_enq_callback, NULL);
12525 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12526 "qp %u on cryptodev %u",
12527 qp_id, ts_params->valid_devs[0]);
12529 rte_cryptodev_start(ts_params->valid_devs[0]);
12531 /* Launch a thread */
12532 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12533 rte_get_next_lcore(-1, 1, 0));
12535 /* Wait until reader exited. */
12536 rte_eal_mp_wait_lcore();
12538 /* Test with invalid crypto device */
12539 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12540 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12541 "Expected call to fail as crypto device is invalid");
12543 /* Test with invalid queue pair */
12544 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12545 ts_params->valid_devs[0],
12546 dev_info.max_nb_queue_pairs + 1, cb),
12547 "Expected call to fail as queue pair is invalid");
12549 /* Test with NULL callback */
12550 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12551 ts_params->valid_devs[0], qp_id, NULL),
12552 "Expected call to fail as callback is NULL");
12554 /* Test with valid configuration */
12555 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
12556 ts_params->valid_devs[0], qp_id, cb),
12557 "Failed test to remove callback on "
12558 "qp %u on cryptodev %u",
12559 qp_id, ts_params->valid_devs[0]);
12561 return TEST_SUCCESS;
12565 test_deq_callback_setup(void)
12567 struct crypto_testsuite_params *ts_params = &testsuite_params;
12568 struct rte_cryptodev_info dev_info;
12569 struct rte_cryptodev_qp_conf qp_conf = {
12570 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12573 struct rte_cryptodev_cb *cb;
12574 uint16_t qp_id = 0;
12576 /* Stop the device in case it's started so it can be configured */
12577 rte_cryptodev_stop(ts_params->valid_devs[0]);
12579 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12581 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12583 "Failed to configure cryptodev %u",
12584 ts_params->valid_devs[0]);
12586 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12587 qp_conf.mp_session = ts_params->session_mpool;
12588 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12590 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12591 ts_params->valid_devs[0], qp_id, &qp_conf,
12592 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12594 "rte_cryptodev_queue_pair_setup: num_inflights "
12595 "%u on qp %u on cryptodev %u",
12596 qp_conf.nb_descriptors, qp_id,
12597 ts_params->valid_devs[0]);
12599 /* Test with invalid crypto device */
12600 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
12601 qp_id, test_deq_callback, NULL);
12602 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12603 "cryptodev %u did not fail",
12604 qp_id, RTE_CRYPTO_MAX_DEVS);
12606 /* Test with invalid queue pair */
12607 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12608 dev_info.max_nb_queue_pairs + 1,
12609 test_deq_callback, NULL);
12610 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12611 "cryptodev %u did not fail",
12612 dev_info.max_nb_queue_pairs + 1,
12613 ts_params->valid_devs[0]);
12615 /* Test with NULL callback */
12616 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12617 qp_id, NULL, NULL);
12618 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12619 "cryptodev %u did not fail",
12620 qp_id, ts_params->valid_devs[0]);
12622 /* Test with valid configuration */
12623 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12624 qp_id, test_deq_callback, NULL);
12625 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12626 "qp %u on cryptodev %u",
12627 qp_id, ts_params->valid_devs[0]);
12629 rte_cryptodev_start(ts_params->valid_devs[0]);
12631 /* Launch a thread */
12632 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12633 rte_get_next_lcore(-1, 1, 0));
12635 /* Wait until reader exited. */
12636 rte_eal_mp_wait_lcore();
12638 /* Test with invalid crypto device */
12639 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12640 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12641 "Expected call to fail as crypto device is invalid");
12643 /* Test with invalid queue pair */
12644 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12645 ts_params->valid_devs[0],
12646 dev_info.max_nb_queue_pairs + 1, cb),
12647 "Expected call to fail as queue pair is invalid");
12649 /* Test with NULL callback */
12650 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12651 ts_params->valid_devs[0], qp_id, NULL),
12652 "Expected call to fail as callback is NULL");
12654 /* Test with valid configuration */
12655 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
12656 ts_params->valid_devs[0], qp_id, cb),
12657 "Failed test to remove callback on "
12658 "qp %u on cryptodev %u",
12659 qp_id, ts_params->valid_devs[0]);
12661 return TEST_SUCCESS;
12665 generate_gmac_large_plaintext(uint8_t *data)
12669 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
12670 memcpy(&data[i], &data[0], 32);
12674 create_gmac_operation(enum rte_crypto_auth_operation op,
12675 const struct gmac_test_data *tdata)
12677 struct crypto_testsuite_params *ts_params = &testsuite_params;
12678 struct crypto_unittest_params *ut_params = &unittest_params;
12679 struct rte_crypto_sym_op *sym_op;
12681 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12683 /* Generate Crypto op data structure */
12684 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12685 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12686 TEST_ASSERT_NOT_NULL(ut_params->op,
12687 "Failed to allocate symmetric crypto operation struct");
12689 sym_op = ut_params->op->sym;
12691 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12692 ut_params->ibuf, tdata->gmac_tag.len);
12693 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12694 "no room to append digest");
12696 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12697 ut_params->ibuf, plaintext_pad_len);
12699 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12700 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12701 tdata->gmac_tag.len);
12702 debug_hexdump(stdout, "digest:",
12703 sym_op->auth.digest.data,
12704 tdata->gmac_tag.len);
12707 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12708 uint8_t *, IV_OFFSET);
12710 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12712 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12714 sym_op->cipher.data.length = 0;
12715 sym_op->cipher.data.offset = 0;
12717 sym_op->auth.data.offset = 0;
12718 sym_op->auth.data.length = tdata->plaintext.len;
12724 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12725 const struct gmac_test_data *tdata,
12726 void *digest_mem, uint64_t digest_phys)
12728 struct crypto_testsuite_params *ts_params = &testsuite_params;
12729 struct crypto_unittest_params *ut_params = &unittest_params;
12730 struct rte_crypto_sym_op *sym_op;
12732 /* Generate Crypto op data structure */
12733 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12734 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12735 TEST_ASSERT_NOT_NULL(ut_params->op,
12736 "Failed to allocate symmetric crypto operation struct");
12738 sym_op = ut_params->op->sym;
12740 sym_op->auth.digest.data = digest_mem;
12741 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12742 "no room to append digest");
12744 sym_op->auth.digest.phys_addr = digest_phys;
12746 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12747 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12748 tdata->gmac_tag.len);
12749 debug_hexdump(stdout, "digest:",
12750 sym_op->auth.digest.data,
12751 tdata->gmac_tag.len);
12754 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12755 uint8_t *, IV_OFFSET);
12757 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12759 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12761 sym_op->cipher.data.length = 0;
12762 sym_op->cipher.data.offset = 0;
12764 sym_op->auth.data.offset = 0;
12765 sym_op->auth.data.length = tdata->plaintext.len;
12770 static int create_gmac_session(uint8_t dev_id,
12771 const struct gmac_test_data *tdata,
12772 enum rte_crypto_auth_operation auth_op)
12774 uint8_t auth_key[tdata->key.len];
12777 struct crypto_testsuite_params *ts_params = &testsuite_params;
12778 struct crypto_unittest_params *ut_params = &unittest_params;
12780 memcpy(auth_key, tdata->key.data, tdata->key.len);
12782 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12783 ut_params->auth_xform.next = NULL;
12785 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12786 ut_params->auth_xform.auth.op = auth_op;
12787 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12788 ut_params->auth_xform.auth.key.length = tdata->key.len;
12789 ut_params->auth_xform.auth.key.data = auth_key;
12790 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12791 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12794 ut_params->sess = rte_cryptodev_sym_session_create(
12795 ts_params->session_mpool);
12796 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12798 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12799 &ut_params->auth_xform,
12800 ts_params->session_priv_mpool);
12806 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12808 struct crypto_testsuite_params *ts_params = &testsuite_params;
12809 struct crypto_unittest_params *ut_params = &unittest_params;
12810 struct rte_cryptodev_info dev_info;
12812 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12813 uint64_t feat_flags = dev_info.feature_flags;
12815 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12816 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12817 printf("Device doesn't support RAW data-path APIs.\n");
12818 return TEST_SKIPPED;
12823 uint8_t *auth_tag, *plaintext;
12824 uint16_t plaintext_pad_len;
12826 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12827 "No GMAC length in the source data");
12829 /* Verify the capabilities */
12830 struct rte_cryptodev_sym_capability_idx cap_idx;
12831 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12832 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12833 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12835 return TEST_SKIPPED;
12837 retval = create_gmac_session(ts_params->valid_devs[0],
12838 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12840 if (retval == -ENOTSUP)
12841 return TEST_SKIPPED;
12845 if (tdata->plaintext.len > MBUF_SIZE)
12846 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12848 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12849 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12850 "Failed to allocate input buffer in mempool");
12852 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12853 rte_pktmbuf_tailroom(ut_params->ibuf));
12855 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12857 * Runtime generate the large plain text instead of use hard code
12858 * plain text vector. It is done to avoid create huge source file
12859 * with the test vector.
12861 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12862 generate_gmac_large_plaintext(tdata->plaintext.data);
12864 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12865 plaintext_pad_len);
12866 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12868 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12869 debug_hexdump(stdout, "plaintext:", plaintext,
12870 tdata->plaintext.len);
12872 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12878 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12880 ut_params->op->sym->m_src = ut_params->ibuf;
12882 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12883 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12885 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12886 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12887 ut_params->op, 0, 1, 0, 0);
12889 TEST_ASSERT_NOT_NULL(
12890 process_crypto_request(ts_params->valid_devs[0],
12891 ut_params->op), "failed to process sym crypto op");
12893 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12894 "crypto op processing failed");
12896 if (ut_params->op->sym->m_dst) {
12897 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12898 uint8_t *, plaintext_pad_len);
12900 auth_tag = plaintext + plaintext_pad_len;
12903 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12905 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12907 tdata->gmac_tag.data,
12908 tdata->gmac_tag.len,
12909 "GMAC Generated auth tag not as expected");
12915 test_AES_GMAC_authentication_test_case_1(void)
12917 return test_AES_GMAC_authentication(&gmac_test_case_1);
12921 test_AES_GMAC_authentication_test_case_2(void)
12923 return test_AES_GMAC_authentication(&gmac_test_case_2);
12927 test_AES_GMAC_authentication_test_case_3(void)
12929 return test_AES_GMAC_authentication(&gmac_test_case_3);
12933 test_AES_GMAC_authentication_test_case_4(void)
12935 return test_AES_GMAC_authentication(&gmac_test_case_4);
12939 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12941 struct crypto_testsuite_params *ts_params = &testsuite_params;
12942 struct crypto_unittest_params *ut_params = &unittest_params;
12944 uint32_t plaintext_pad_len;
12945 uint8_t *plaintext;
12946 struct rte_cryptodev_info dev_info;
12948 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12949 uint64_t feat_flags = dev_info.feature_flags;
12951 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12952 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12953 printf("Device doesn't support RAW data-path APIs.\n");
12954 return TEST_SKIPPED;
12957 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12958 "No GMAC length in the source data");
12960 /* Verify the capabilities */
12961 struct rte_cryptodev_sym_capability_idx cap_idx;
12962 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12963 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12964 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12966 return TEST_SKIPPED;
12968 retval = create_gmac_session(ts_params->valid_devs[0],
12969 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12971 if (retval == -ENOTSUP)
12972 return TEST_SKIPPED;
12976 if (tdata->plaintext.len > MBUF_SIZE)
12977 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12979 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12980 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12981 "Failed to allocate input buffer in mempool");
12983 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12984 rte_pktmbuf_tailroom(ut_params->ibuf));
12986 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12989 * Runtime generate the large plain text instead of use hard code
12990 * plain text vector. It is done to avoid create huge source file
12991 * with the test vector.
12993 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12994 generate_gmac_large_plaintext(tdata->plaintext.data);
12996 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12997 plaintext_pad_len);
12998 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13000 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
13001 debug_hexdump(stdout, "plaintext:", plaintext,
13002 tdata->plaintext.len);
13004 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
13010 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13012 ut_params->op->sym->m_src = ut_params->ibuf;
13014 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13015 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13017 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13018 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13019 ut_params->op, 0, 1, 0, 0);
13021 TEST_ASSERT_NOT_NULL(
13022 process_crypto_request(ts_params->valid_devs[0],
13023 ut_params->op), "failed to process sym crypto op");
13025 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13026 "crypto op processing failed");
13033 test_AES_GMAC_authentication_verify_test_case_1(void)
13035 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
13039 test_AES_GMAC_authentication_verify_test_case_2(void)
13041 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
13045 test_AES_GMAC_authentication_verify_test_case_3(void)
13047 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
13051 test_AES_GMAC_authentication_verify_test_case_4(void)
13053 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
13057 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
13060 struct crypto_testsuite_params *ts_params = &testsuite_params;
13061 struct crypto_unittest_params *ut_params = &unittest_params;
13062 struct rte_cryptodev_info dev_info;
13063 uint64_t feature_flags;
13064 unsigned int trn_data = 0;
13065 void *digest_mem = NULL;
13067 unsigned int to_trn = 0;
13068 struct rte_mbuf *buf = NULL;
13069 uint8_t *auth_tag, *plaintext;
13072 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
13073 "No GMAC length in the source data");
13075 /* Verify the capabilities */
13076 struct rte_cryptodev_sym_capability_idx cap_idx;
13077 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13078 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
13079 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13081 return TEST_SKIPPED;
13083 /* Check for any input SGL support */
13084 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13085 feature_flags = dev_info.feature_flags;
13087 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
13088 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
13089 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
13090 return TEST_SKIPPED;
13092 if (fragsz > tdata->plaintext.len)
13093 fragsz = tdata->plaintext.len;
13095 uint16_t plaintext_len = fragsz;
13097 retval = create_gmac_session(ts_params->valid_devs[0],
13098 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
13100 if (retval == -ENOTSUP)
13101 return TEST_SKIPPED;
13105 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13106 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13107 "Failed to allocate input buffer in mempool");
13109 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13110 rte_pktmbuf_tailroom(ut_params->ibuf));
13112 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13114 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13116 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13118 trn_data += plaintext_len;
13120 buf = ut_params->ibuf;
13123 * Loop until no more fragments
13126 while (trn_data < tdata->plaintext.len) {
13128 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13129 (tdata->plaintext.len - trn_data) : fragsz;
13131 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13134 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13135 rte_pktmbuf_tailroom(buf));
13137 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13140 memcpy(plaintext, tdata->plaintext.data + trn_data,
13142 trn_data += to_trn;
13143 if (trn_data == tdata->plaintext.len)
13144 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13145 tdata->gmac_tag.len);
13147 ut_params->ibuf->nb_segs = segs;
13150 * Place digest at the end of the last buffer
13152 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13155 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13156 + tdata->gmac_tag.len);
13157 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13158 tdata->plaintext.len);
13161 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
13162 tdata, digest_mem, digest_phys);
13167 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13169 ut_params->op->sym->m_src = ut_params->ibuf;
13171 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13172 return TEST_SKIPPED;
13174 TEST_ASSERT_NOT_NULL(
13175 process_crypto_request(ts_params->valid_devs[0],
13176 ut_params->op), "failed to process sym crypto op");
13178 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13179 "crypto op processing failed");
13181 auth_tag = digest_mem;
13182 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
13183 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13185 tdata->gmac_tag.data,
13186 tdata->gmac_tag.len,
13187 "GMAC Generated auth tag not as expected");
13192 /* Segment size not multiple of block size (16B) */
13194 test_AES_GMAC_authentication_SGL_40B(void)
13196 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
13200 test_AES_GMAC_authentication_SGL_80B(void)
13202 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
13206 test_AES_GMAC_authentication_SGL_2048B(void)
13208 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
13211 /* Segment size not multiple of block size (16B) */
13213 test_AES_GMAC_authentication_SGL_2047B(void)
13215 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
13218 struct test_crypto_vector {
13219 enum rte_crypto_cipher_algorithm crypto_algo;
13220 unsigned int cipher_offset;
13221 unsigned int cipher_len;
13234 const uint8_t *data;
13239 const uint8_t *data;
13243 enum rte_crypto_auth_algorithm auth_algo;
13244 unsigned int auth_offset;
13252 const uint8_t *data;
13262 static const struct test_crypto_vector
13263 hmac_sha1_test_crypto_vector = {
13264 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13266 .data = plaintext_hash,
13271 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13272 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13273 0xDE, 0xF4, 0xDE, 0xAD
13279 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
13280 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
13281 0x3F, 0x91, 0x64, 0x59
13287 static const struct test_crypto_vector
13288 aes128_gmac_test_vector = {
13289 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
13291 .data = plaintext_hash,
13296 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13297 0x08, 0x09, 0x0A, 0x0B
13303 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
13304 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
13310 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
13311 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
13317 static const struct test_crypto_vector
13318 aes128cbc_hmac_sha1_test_vector = {
13319 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
13320 .cipher_offset = 0,
13324 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
13325 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
13331 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13332 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
13337 .data = plaintext_hash,
13341 .data = ciphertext512_aes128cbc,
13344 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13348 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13349 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13350 0xDE, 0xF4, 0xDE, 0xAD
13356 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
13357 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
13358 0x18, 0x8C, 0x1D, 0x32
13364 static const struct test_crypto_vector
13365 aes128cbc_hmac_sha1_aad_test_vector = {
13366 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
13367 .cipher_offset = 8,
13371 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
13372 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
13378 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
13379 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
13384 .data = plaintext_hash,
13388 .data = ciphertext512_aes128cbc_aad,
13391 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
13395 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
13396 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
13397 0xDE, 0xF4, 0xDE, 0xAD
13403 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
13404 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
13405 0x62, 0x0F, 0xFB, 0x10
13412 data_corruption(uint8_t *data)
13418 tag_corruption(uint8_t *data, unsigned int tag_offset)
13420 data[tag_offset] += 1;
13424 create_auth_session(struct crypto_unittest_params *ut_params,
13426 const struct test_crypto_vector *reference,
13427 enum rte_crypto_auth_operation auth_op)
13429 struct crypto_testsuite_params *ts_params = &testsuite_params;
13430 uint8_t auth_key[reference->auth_key.len + 1];
13433 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13435 /* Setup Authentication Parameters */
13436 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13437 ut_params->auth_xform.auth.op = auth_op;
13438 ut_params->auth_xform.next = NULL;
13439 ut_params->auth_xform.auth.algo = reference->auth_algo;
13440 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13441 ut_params->auth_xform.auth.key.data = auth_key;
13442 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13444 /* Create Crypto session*/
13445 ut_params->sess = rte_cryptodev_sym_session_create(
13446 ts_params->session_mpool);
13447 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13449 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13450 &ut_params->auth_xform,
13451 ts_params->session_priv_mpool);
13457 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
13459 const struct test_crypto_vector *reference,
13460 enum rte_crypto_auth_operation auth_op,
13461 enum rte_crypto_cipher_operation cipher_op)
13463 struct crypto_testsuite_params *ts_params = &testsuite_params;
13464 uint8_t cipher_key[reference->cipher_key.len + 1];
13465 uint8_t auth_key[reference->auth_key.len + 1];
13468 memcpy(cipher_key, reference->cipher_key.data,
13469 reference->cipher_key.len);
13470 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13472 /* Setup Authentication Parameters */
13473 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13474 ut_params->auth_xform.auth.op = auth_op;
13475 ut_params->auth_xform.auth.algo = reference->auth_algo;
13476 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13477 ut_params->auth_xform.auth.key.data = auth_key;
13478 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13480 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
13481 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13482 ut_params->auth_xform.auth.iv.length = reference->iv.len;
13484 ut_params->auth_xform.next = &ut_params->cipher_xform;
13486 /* Setup Cipher Parameters */
13487 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13488 ut_params->cipher_xform.next = NULL;
13489 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13490 ut_params->cipher_xform.cipher.op = cipher_op;
13491 ut_params->cipher_xform.cipher.key.data = cipher_key;
13492 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13493 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13494 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13497 /* Create Crypto session*/
13498 ut_params->sess = rte_cryptodev_sym_session_create(
13499 ts_params->session_mpool);
13500 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13502 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13503 &ut_params->auth_xform,
13504 ts_params->session_priv_mpool);
13510 create_auth_operation(struct crypto_testsuite_params *ts_params,
13511 struct crypto_unittest_params *ut_params,
13512 const struct test_crypto_vector *reference,
13513 unsigned int auth_generate)
13515 /* Generate Crypto op data structure */
13516 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13517 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13518 TEST_ASSERT_NOT_NULL(ut_params->op,
13519 "Failed to allocate pktmbuf offload");
13521 /* Set crypto operation data parameters */
13522 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13524 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13526 /* set crypto operation source mbuf */
13527 sym_op->m_src = ut_params->ibuf;
13530 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13531 ut_params->ibuf, reference->digest.len);
13533 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13534 "no room to append auth tag");
13536 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13537 ut_params->ibuf, reference->plaintext.len);
13540 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13542 memcpy(sym_op->auth.digest.data,
13543 reference->digest.data,
13544 reference->digest.len);
13546 debug_hexdump(stdout, "digest:",
13547 sym_op->auth.digest.data,
13548 reference->digest.len);
13550 sym_op->auth.data.length = reference->plaintext.len;
13551 sym_op->auth.data.offset = 0;
13557 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
13558 struct crypto_unittest_params *ut_params,
13559 const struct test_crypto_vector *reference,
13560 unsigned int auth_generate)
13562 /* Generate Crypto op data structure */
13563 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13564 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13565 TEST_ASSERT_NOT_NULL(ut_params->op,
13566 "Failed to allocate pktmbuf offload");
13568 /* Set crypto operation data parameters */
13569 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13571 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13573 /* set crypto operation source mbuf */
13574 sym_op->m_src = ut_params->ibuf;
13577 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13578 ut_params->ibuf, reference->digest.len);
13580 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13581 "no room to append auth tag");
13583 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13584 ut_params->ibuf, reference->ciphertext.len);
13587 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13589 memcpy(sym_op->auth.digest.data,
13590 reference->digest.data,
13591 reference->digest.len);
13593 debug_hexdump(stdout, "digest:",
13594 sym_op->auth.digest.data,
13595 reference->digest.len);
13597 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13598 reference->iv.data, reference->iv.len);
13600 sym_op->cipher.data.length = 0;
13601 sym_op->cipher.data.offset = 0;
13603 sym_op->auth.data.length = reference->plaintext.len;
13604 sym_op->auth.data.offset = 0;
13610 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
13611 struct crypto_unittest_params *ut_params,
13612 const struct test_crypto_vector *reference,
13613 unsigned int auth_generate)
13615 /* Generate Crypto op data structure */
13616 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13617 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13618 TEST_ASSERT_NOT_NULL(ut_params->op,
13619 "Failed to allocate pktmbuf offload");
13621 /* Set crypto operation data parameters */
13622 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13624 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13626 /* set crypto operation source mbuf */
13627 sym_op->m_src = ut_params->ibuf;
13630 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13631 ut_params->ibuf, reference->digest.len);
13633 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13634 "no room to append auth tag");
13636 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13637 ut_params->ibuf, reference->ciphertext.len);
13640 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13642 memcpy(sym_op->auth.digest.data,
13643 reference->digest.data,
13644 reference->digest.len);
13646 debug_hexdump(stdout, "digest:",
13647 sym_op->auth.digest.data,
13648 reference->digest.len);
13650 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13651 reference->iv.data, reference->iv.len);
13653 sym_op->cipher.data.length = reference->cipher_len;
13654 sym_op->cipher.data.offset = reference->cipher_offset;
13656 sym_op->auth.data.length = reference->plaintext.len;
13657 sym_op->auth.data.offset = reference->auth_offset;
13663 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13664 struct crypto_unittest_params *ut_params,
13665 const struct test_crypto_vector *reference)
13667 return create_auth_operation(ts_params, ut_params, reference, 0);
13671 create_auth_verify_GMAC_operation(
13672 struct crypto_testsuite_params *ts_params,
13673 struct crypto_unittest_params *ut_params,
13674 const struct test_crypto_vector *reference)
13676 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
13680 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13681 struct crypto_unittest_params *ut_params,
13682 const struct test_crypto_vector *reference)
13684 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
13688 test_authentication_verify_fail_when_data_corruption(
13689 struct crypto_testsuite_params *ts_params,
13690 struct crypto_unittest_params *ut_params,
13691 const struct test_crypto_vector *reference,
13692 unsigned int data_corrupted)
13696 uint8_t *plaintext;
13697 struct rte_cryptodev_info dev_info;
13699 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13700 uint64_t feat_flags = dev_info.feature_flags;
13702 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13703 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13704 printf("Device doesn't support RAW data-path APIs.\n");
13705 return TEST_SKIPPED;
13708 /* Verify the capabilities */
13709 struct rte_cryptodev_sym_capability_idx cap_idx;
13710 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13711 cap_idx.algo.auth = reference->auth_algo;
13712 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13714 return TEST_SKIPPED;
13717 /* Create session */
13718 retval = create_auth_session(ut_params,
13719 ts_params->valid_devs[0],
13721 RTE_CRYPTO_AUTH_OP_VERIFY);
13723 if (retval == -ENOTSUP)
13724 return TEST_SKIPPED;
13728 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13729 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13730 "Failed to allocate input buffer in mempool");
13732 /* clear mbuf payload */
13733 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13734 rte_pktmbuf_tailroom(ut_params->ibuf));
13736 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13737 reference->plaintext.len);
13738 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13739 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13741 debug_hexdump(stdout, "plaintext:", plaintext,
13742 reference->plaintext.len);
13744 /* Create operation */
13745 retval = create_auth_verify_operation(ts_params, ut_params, reference);
13750 if (data_corrupted)
13751 data_corruption(plaintext);
13753 tag_corruption(plaintext, reference->plaintext.len);
13755 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13756 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13758 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13759 RTE_CRYPTO_OP_STATUS_SUCCESS,
13760 "authentication not failed");
13761 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13762 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13763 ut_params->op, 0, 1, 0, 0);
13765 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13768 if (ut_params->op == NULL)
13770 else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13777 test_authentication_verify_GMAC_fail_when_corruption(
13778 struct crypto_testsuite_params *ts_params,
13779 struct crypto_unittest_params *ut_params,
13780 const struct test_crypto_vector *reference,
13781 unsigned int data_corrupted)
13784 uint8_t *plaintext;
13785 struct rte_cryptodev_info dev_info;
13787 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13788 uint64_t feat_flags = dev_info.feature_flags;
13790 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13791 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13792 printf("Device doesn't support RAW data-path APIs.\n");
13793 return TEST_SKIPPED;
13796 /* Verify the capabilities */
13797 struct rte_cryptodev_sym_capability_idx cap_idx;
13798 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13799 cap_idx.algo.auth = reference->auth_algo;
13800 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13802 return TEST_SKIPPED;
13804 /* Create session */
13805 retval = create_auth_cipher_session(ut_params,
13806 ts_params->valid_devs[0],
13808 RTE_CRYPTO_AUTH_OP_VERIFY,
13809 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13813 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13814 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13815 "Failed to allocate input buffer in mempool");
13817 /* clear mbuf payload */
13818 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13819 rte_pktmbuf_tailroom(ut_params->ibuf));
13821 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13822 reference->plaintext.len);
13823 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13824 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13826 debug_hexdump(stdout, "plaintext:", plaintext,
13827 reference->plaintext.len);
13829 /* Create operation */
13830 retval = create_auth_verify_GMAC_operation(ts_params,
13837 if (data_corrupted)
13838 data_corruption(plaintext);
13840 tag_corruption(plaintext, reference->aad.len);
13842 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13843 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13845 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13846 RTE_CRYPTO_OP_STATUS_SUCCESS,
13847 "authentication not failed");
13848 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13849 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13850 ut_params->op, 0, 1, 0, 0);
13852 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13854 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13861 test_authenticated_decryption_fail_when_corruption(
13862 struct crypto_testsuite_params *ts_params,
13863 struct crypto_unittest_params *ut_params,
13864 const struct test_crypto_vector *reference,
13865 unsigned int data_corrupted)
13869 uint8_t *ciphertext;
13870 struct rte_cryptodev_info dev_info;
13872 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13873 uint64_t feat_flags = dev_info.feature_flags;
13875 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13876 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13877 printf("Device doesn't support RAW data-path APIs.\n");
13878 return TEST_SKIPPED;
13881 /* Verify the capabilities */
13882 struct rte_cryptodev_sym_capability_idx cap_idx;
13883 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13884 cap_idx.algo.auth = reference->auth_algo;
13885 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13887 return TEST_SKIPPED;
13888 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13889 cap_idx.algo.cipher = reference->crypto_algo;
13890 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13892 return TEST_SKIPPED;
13894 /* Create session */
13895 retval = create_auth_cipher_session(ut_params,
13896 ts_params->valid_devs[0],
13898 RTE_CRYPTO_AUTH_OP_VERIFY,
13899 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13901 if (retval == -ENOTSUP)
13902 return TEST_SKIPPED;
13906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13907 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13908 "Failed to allocate input buffer in mempool");
13910 /* clear mbuf payload */
13911 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13912 rte_pktmbuf_tailroom(ut_params->ibuf));
13914 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13915 reference->ciphertext.len);
13916 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13917 memcpy(ciphertext, reference->ciphertext.data,
13918 reference->ciphertext.len);
13920 /* Create operation */
13921 retval = create_cipher_auth_verify_operation(ts_params,
13928 if (data_corrupted)
13929 data_corruption(ciphertext);
13931 tag_corruption(ciphertext, reference->ciphertext.len);
13933 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13934 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13936 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13937 RTE_CRYPTO_OP_STATUS_SUCCESS,
13938 "authentication not failed");
13939 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13940 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13941 ut_params->op, 1, 1, 0, 0);
13943 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13945 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13952 test_authenticated_encrypt_with_esn(
13953 struct crypto_testsuite_params *ts_params,
13954 struct crypto_unittest_params *ut_params,
13955 const struct test_crypto_vector *reference)
13959 uint8_t *authciphertext, *plaintext, *auth_tag;
13960 uint16_t plaintext_pad_len;
13961 uint8_t cipher_key[reference->cipher_key.len + 1];
13962 uint8_t auth_key[reference->auth_key.len + 1];
13963 struct rte_cryptodev_info dev_info;
13966 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13967 uint64_t feat_flags = dev_info.feature_flags;
13969 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13970 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13971 printf("Device doesn't support RAW data-path APIs.\n");
13972 return TEST_SKIPPED;
13975 /* Verify the capabilities */
13976 struct rte_cryptodev_sym_capability_idx cap_idx;
13977 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13978 cap_idx.algo.auth = reference->auth_algo;
13979 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13981 return TEST_SKIPPED;
13982 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13983 cap_idx.algo.cipher = reference->crypto_algo;
13984 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13986 return TEST_SKIPPED;
13988 /* Create session */
13989 memcpy(cipher_key, reference->cipher_key.data,
13990 reference->cipher_key.len);
13991 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13993 /* Setup Cipher Parameters */
13994 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13995 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13996 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13997 ut_params->cipher_xform.cipher.key.data = cipher_key;
13998 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13999 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14000 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14002 ut_params->cipher_xform.next = &ut_params->auth_xform;
14004 /* Setup Authentication Parameters */
14005 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14006 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14007 ut_params->auth_xform.auth.algo = reference->auth_algo;
14008 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14009 ut_params->auth_xform.auth.key.data = auth_key;
14010 ut_params->auth_xform.auth.digest_length = reference->digest.len;
14011 ut_params->auth_xform.next = NULL;
14013 /* Create Crypto session*/
14014 ut_params->sess = rte_cryptodev_sym_session_create(
14015 ts_params->session_mpool);
14016 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14018 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
14020 &ut_params->cipher_xform,
14021 ts_params->session_priv_mpool);
14023 if (status == -ENOTSUP)
14024 return TEST_SKIPPED;
14026 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
14028 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14029 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14030 "Failed to allocate input buffer in mempool");
14032 /* clear mbuf payload */
14033 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14034 rte_pktmbuf_tailroom(ut_params->ibuf));
14036 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14037 reference->plaintext.len);
14038 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14039 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
14041 /* Create operation */
14042 retval = create_cipher_auth_operation(ts_params,
14049 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14050 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14052 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14053 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14054 ut_params->op, 1, 1, 0, 0);
14056 ut_params->op = process_crypto_request(
14057 ts_params->valid_devs[0], ut_params->op);
14059 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
14061 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14062 "crypto op processing failed");
14064 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
14066 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
14067 ut_params->op->sym->auth.data.offset);
14068 auth_tag = authciphertext + plaintext_pad_len;
14069 debug_hexdump(stdout, "ciphertext:", authciphertext,
14070 reference->ciphertext.len);
14071 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
14073 /* Validate obuf */
14074 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14076 reference->ciphertext.data,
14077 reference->ciphertext.len,
14078 "Ciphertext data not as expected");
14080 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14082 reference->digest.data,
14083 reference->digest.len,
14084 "Generated digest not as expected");
14086 return TEST_SUCCESS;
14091 test_authenticated_decrypt_with_esn(
14092 struct crypto_testsuite_params *ts_params,
14093 struct crypto_unittest_params *ut_params,
14094 const struct test_crypto_vector *reference)
14098 uint8_t *ciphertext;
14099 uint8_t cipher_key[reference->cipher_key.len + 1];
14100 uint8_t auth_key[reference->auth_key.len + 1];
14101 struct rte_cryptodev_info dev_info;
14103 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14104 uint64_t feat_flags = dev_info.feature_flags;
14106 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14107 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14108 printf("Device doesn't support RAW data-path APIs.\n");
14109 return TEST_SKIPPED;
14112 /* Verify the capabilities */
14113 struct rte_cryptodev_sym_capability_idx cap_idx;
14114 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14115 cap_idx.algo.auth = reference->auth_algo;
14116 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14118 return TEST_SKIPPED;
14119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14120 cap_idx.algo.cipher = reference->crypto_algo;
14121 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14123 return TEST_SKIPPED;
14125 /* Create session */
14126 memcpy(cipher_key, reference->cipher_key.data,
14127 reference->cipher_key.len);
14128 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
14130 /* Setup Authentication Parameters */
14131 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14132 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
14133 ut_params->auth_xform.auth.algo = reference->auth_algo;
14134 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
14135 ut_params->auth_xform.auth.key.data = auth_key;
14136 ut_params->auth_xform.auth.digest_length = reference->digest.len;
14137 ut_params->auth_xform.next = &ut_params->cipher_xform;
14139 /* Setup Cipher Parameters */
14140 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14141 ut_params->cipher_xform.next = NULL;
14142 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
14143 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
14144 ut_params->cipher_xform.cipher.key.data = cipher_key;
14145 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
14146 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
14147 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
14149 /* Create Crypto session*/
14150 ut_params->sess = rte_cryptodev_sym_session_create(
14151 ts_params->session_mpool);
14152 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14154 retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
14156 &ut_params->auth_xform,
14157 ts_params->session_priv_mpool);
14159 if (retval == -ENOTSUP)
14160 return TEST_SKIPPED;
14162 TEST_ASSERT_EQUAL(retval, 0, "Session init failed");
14164 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14165 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14166 "Failed to allocate input buffer in mempool");
14168 /* clear mbuf payload */
14169 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14170 rte_pktmbuf_tailroom(ut_params->ibuf));
14172 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14173 reference->ciphertext.len);
14174 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
14175 memcpy(ciphertext, reference->ciphertext.data,
14176 reference->ciphertext.len);
14178 /* Create operation */
14179 retval = create_cipher_auth_verify_operation(ts_params,
14186 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14187 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14189 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14190 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14191 ut_params->op, 1, 1, 0, 0);
14193 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
14196 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
14197 TEST_ASSERT_EQUAL(ut_params->op->status,
14198 RTE_CRYPTO_OP_STATUS_SUCCESS,
14199 "crypto op processing passed");
14201 ut_params->obuf = ut_params->op->sym->m_src;
14202 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
14208 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
14209 const struct aead_test_data *tdata,
14210 void *digest_mem, uint64_t digest_phys)
14212 struct crypto_testsuite_params *ts_params = &testsuite_params;
14213 struct crypto_unittest_params *ut_params = &unittest_params;
14215 const unsigned int auth_tag_len = tdata->auth_tag.len;
14216 const unsigned int iv_len = tdata->iv.len;
14217 unsigned int aad_len = tdata->aad.len;
14218 unsigned int aad_len_pad = 0;
14220 /* Generate Crypto op data structure */
14221 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14222 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14223 TEST_ASSERT_NOT_NULL(ut_params->op,
14224 "Failed to allocate symmetric crypto operation struct");
14226 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
14228 sym_op->aead.digest.data = digest_mem;
14230 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
14231 "no room to append digest");
14233 sym_op->aead.digest.phys_addr = digest_phys;
14235 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
14236 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
14238 debug_hexdump(stdout, "digest:",
14239 sym_op->aead.digest.data,
14243 /* Append aad data */
14244 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
14245 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14246 uint8_t *, IV_OFFSET);
14248 /* Copy IV 1 byte after the IV pointer, according to the API */
14249 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
14251 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
14253 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
14254 ut_params->ibuf, aad_len);
14255 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
14256 "no room to prepend aad");
14257 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
14260 memset(sym_op->aead.aad.data, 0, aad_len);
14261 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
14262 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
14264 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
14265 debug_hexdump(stdout, "aad:",
14266 sym_op->aead.aad.data, aad_len);
14268 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14269 uint8_t *, IV_OFFSET);
14271 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
14273 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
14275 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
14276 ut_params->ibuf, aad_len_pad);
14277 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
14278 "no room to prepend aad");
14279 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
14282 memset(sym_op->aead.aad.data, 0, aad_len);
14283 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
14285 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
14286 debug_hexdump(stdout, "aad:",
14287 sym_op->aead.aad.data, aad_len);
14290 sym_op->aead.data.length = tdata->plaintext.len;
14291 sym_op->aead.data.offset = aad_len_pad;
14296 #define SGL_MAX_NO 16
14299 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
14300 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
14302 struct crypto_testsuite_params *ts_params = &testsuite_params;
14303 struct crypto_unittest_params *ut_params = &unittest_params;
14304 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
14307 int to_trn_tbl[SGL_MAX_NO];
14309 unsigned int trn_data = 0;
14310 uint8_t *plaintext, *ciphertext, *auth_tag;
14311 struct rte_cryptodev_info dev_info;
14313 /* Verify the capabilities */
14314 struct rte_cryptodev_sym_capability_idx cap_idx;
14315 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
14316 cap_idx.algo.aead = tdata->algo;
14317 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14319 return TEST_SKIPPED;
14321 /* OOP not supported with CPU crypto */
14322 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14323 return TEST_SKIPPED;
14325 /* Detailed check for the particular SGL support flag */
14326 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14328 unsigned int sgl_in = fragsz < tdata->plaintext.len;
14329 if (sgl_in && (!(dev_info.feature_flags &
14330 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
14331 return TEST_SKIPPED;
14333 uint64_t feat_flags = dev_info.feature_flags;
14335 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14336 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14337 printf("Device doesn't support RAW data-path APIs.\n");
14338 return TEST_SKIPPED;
14341 unsigned int sgl_in = fragsz < tdata->plaintext.len;
14342 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
14343 tdata->plaintext.len;
14344 /* Raw data path API does not support OOP */
14345 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14346 return TEST_SKIPPED;
14347 if (sgl_in && !sgl_out) {
14348 if (!(dev_info.feature_flags &
14349 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
14350 return TEST_SKIPPED;
14351 } else if (!sgl_in && sgl_out) {
14352 if (!(dev_info.feature_flags &
14353 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
14354 return TEST_SKIPPED;
14355 } else if (sgl_in && sgl_out) {
14356 if (!(dev_info.feature_flags &
14357 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
14358 return TEST_SKIPPED;
14362 if (fragsz > tdata->plaintext.len)
14363 fragsz = tdata->plaintext.len;
14365 uint16_t plaintext_len = fragsz;
14366 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
14368 if (fragsz_oop > tdata->plaintext.len)
14369 frag_size_oop = tdata->plaintext.len;
14372 void *digest_mem = NULL;
14374 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
14376 if (tdata->plaintext.len % fragsz != 0) {
14377 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
14380 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
14385 * For out-op-place we need to alloc another mbuf
14388 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14389 rte_pktmbuf_append(ut_params->obuf,
14390 frag_size_oop + prepend_len);
14391 buf_oop = ut_params->obuf;
14394 /* Create AEAD session */
14395 retval = create_aead_session(ts_params->valid_devs[0],
14397 RTE_CRYPTO_AEAD_OP_ENCRYPT,
14398 tdata->key.data, tdata->key.len,
14399 tdata->aad.len, tdata->auth_tag.len,
14404 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14406 /* clear mbuf payload */
14407 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14408 rte_pktmbuf_tailroom(ut_params->ibuf));
14410 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14413 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
14415 trn_data += plaintext_len;
14417 buf = ut_params->ibuf;
14420 * Loop until no more fragments
14423 while (trn_data < tdata->plaintext.len) {
14425 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
14426 (tdata->plaintext.len - trn_data) : fragsz;
14428 to_trn_tbl[ecx++] = to_trn;
14430 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14433 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
14434 rte_pktmbuf_tailroom(buf));
14437 if (oop && !fragsz_oop) {
14438 buf_last_oop = buf_oop->next =
14439 rte_pktmbuf_alloc(ts_params->mbuf_pool);
14440 buf_oop = buf_oop->next;
14441 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14442 0, rte_pktmbuf_tailroom(buf_oop));
14443 rte_pktmbuf_append(buf_oop, to_trn);
14446 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
14449 memcpy(plaintext, tdata->plaintext.data + trn_data,
14451 trn_data += to_trn;
14452 if (trn_data == tdata->plaintext.len) {
14455 digest_mem = rte_pktmbuf_append(buf_oop,
14456 tdata->auth_tag.len);
14458 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14459 tdata->auth_tag.len);
14463 uint64_t digest_phys = 0;
14465 ut_params->ibuf->nb_segs = segs;
14468 if (fragsz_oop && oop) {
14472 if (frag_size_oop == tdata->plaintext.len) {
14473 digest_mem = rte_pktmbuf_append(ut_params->obuf,
14474 tdata->auth_tag.len);
14476 digest_phys = rte_pktmbuf_iova_offset(
14478 tdata->plaintext.len + prepend_len);
14481 trn_data = frag_size_oop;
14482 while (trn_data < tdata->plaintext.len) {
14485 (tdata->plaintext.len - trn_data <
14487 (tdata->plaintext.len - trn_data) :
14490 to_trn_tbl[ecx++] = to_trn;
14492 buf_last_oop = buf_oop->next =
14493 rte_pktmbuf_alloc(ts_params->mbuf_pool);
14494 buf_oop = buf_oop->next;
14495 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14496 0, rte_pktmbuf_tailroom(buf_oop));
14497 rte_pktmbuf_append(buf_oop, to_trn);
14499 trn_data += to_trn;
14501 if (trn_data == tdata->plaintext.len) {
14502 digest_mem = rte_pktmbuf_append(buf_oop,
14503 tdata->auth_tag.len);
14507 ut_params->obuf->nb_segs = segs;
14511 * Place digest at the end of the last buffer
14514 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14515 if (oop && buf_last_oop)
14516 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
14518 if (!digest_mem && !oop) {
14519 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14520 + tdata->auth_tag.len);
14521 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14522 tdata->plaintext.len);
14525 /* Create AEAD operation */
14526 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
14527 tdata, digest_mem, digest_phys);
14532 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14534 ut_params->op->sym->m_src = ut_params->ibuf;
14536 ut_params->op->sym->m_dst = ut_params->obuf;
14538 /* Process crypto operation */
14539 if (oop == IN_PLACE &&
14540 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14541 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
14542 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14543 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14544 ut_params->op, 0, 0, 0, 0);
14546 TEST_ASSERT_NOT_NULL(
14547 process_crypto_request(ts_params->valid_devs[0],
14548 ut_params->op), "failed to process sym crypto op");
14550 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14551 "crypto op processing failed");
14554 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
14555 uint8_t *, prepend_len);
14557 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14558 uint8_t *, prepend_len);
14562 fragsz = fragsz_oop;
14564 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14566 tdata->ciphertext.data,
14568 "Ciphertext data not as expected");
14570 buf = ut_params->op->sym->m_src->next;
14572 buf = ut_params->op->sym->m_dst->next;
14574 unsigned int off = fragsz;
14578 ciphertext = rte_pktmbuf_mtod(buf,
14581 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14583 tdata->ciphertext.data + off,
14585 "Ciphertext data not as expected");
14587 off += to_trn_tbl[ecx++];
14591 auth_tag = digest_mem;
14592 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14594 tdata->auth_tag.data,
14595 tdata->auth_tag.len,
14596 "Generated auth tag not as expected");
14602 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
14604 return test_authenticated_encryption_SGL(
14605 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
14609 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
14611 return test_authenticated_encryption_SGL(
14612 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
14616 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
14618 return test_authenticated_encryption_SGL(
14619 &gcm_test_case_8, OUT_OF_PLACE, 400,
14620 gcm_test_case_8.plaintext.len);
14624 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
14626 /* This test is not for OPENSSL PMD */
14627 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14628 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
14629 return TEST_SKIPPED;
14631 return test_authenticated_encryption_SGL(
14632 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
14636 test_authentication_verify_fail_when_data_corrupted(
14637 struct crypto_testsuite_params *ts_params,
14638 struct crypto_unittest_params *ut_params,
14639 const struct test_crypto_vector *reference)
14641 return test_authentication_verify_fail_when_data_corruption(
14642 ts_params, ut_params, reference, 1);
14646 test_authentication_verify_fail_when_tag_corrupted(
14647 struct crypto_testsuite_params *ts_params,
14648 struct crypto_unittest_params *ut_params,
14649 const struct test_crypto_vector *reference)
14651 return test_authentication_verify_fail_when_data_corruption(
14652 ts_params, ut_params, reference, 0);
14656 test_authentication_verify_GMAC_fail_when_data_corrupted(
14657 struct crypto_testsuite_params *ts_params,
14658 struct crypto_unittest_params *ut_params,
14659 const struct test_crypto_vector *reference)
14661 return test_authentication_verify_GMAC_fail_when_corruption(
14662 ts_params, ut_params, reference, 1);
14666 test_authentication_verify_GMAC_fail_when_tag_corrupted(
14667 struct crypto_testsuite_params *ts_params,
14668 struct crypto_unittest_params *ut_params,
14669 const struct test_crypto_vector *reference)
14671 return test_authentication_verify_GMAC_fail_when_corruption(
14672 ts_params, ut_params, reference, 0);
14676 test_authenticated_decryption_fail_when_data_corrupted(
14677 struct crypto_testsuite_params *ts_params,
14678 struct crypto_unittest_params *ut_params,
14679 const struct test_crypto_vector *reference)
14681 return test_authenticated_decryption_fail_when_corruption(
14682 ts_params, ut_params, reference, 1);
14686 test_authenticated_decryption_fail_when_tag_corrupted(
14687 struct crypto_testsuite_params *ts_params,
14688 struct crypto_unittest_params *ut_params,
14689 const struct test_crypto_vector *reference)
14691 return test_authenticated_decryption_fail_when_corruption(
14692 ts_params, ut_params, reference, 0);
14696 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
14698 return test_authentication_verify_fail_when_data_corrupted(
14699 &testsuite_params, &unittest_params,
14700 &hmac_sha1_test_crypto_vector);
14704 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14706 return test_authentication_verify_fail_when_tag_corrupted(
14707 &testsuite_params, &unittest_params,
14708 &hmac_sha1_test_crypto_vector);
14712 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14714 return test_authentication_verify_GMAC_fail_when_data_corrupted(
14715 &testsuite_params, &unittest_params,
14716 &aes128_gmac_test_vector);
14720 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14722 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14723 &testsuite_params, &unittest_params,
14724 &aes128_gmac_test_vector);
14728 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14730 return test_authenticated_decryption_fail_when_data_corrupted(
14733 &aes128cbc_hmac_sha1_test_vector);
14737 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14739 return test_authenticated_decryption_fail_when_tag_corrupted(
14742 &aes128cbc_hmac_sha1_test_vector);
14746 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14748 return test_authenticated_encrypt_with_esn(
14751 &aes128cbc_hmac_sha1_aad_test_vector);
14755 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14757 return test_authenticated_decrypt_with_esn(
14760 &aes128cbc_hmac_sha1_aad_test_vector);
14764 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14766 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14770 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14772 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14776 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14778 return test_authenticated_encryption_SGL(
14779 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14780 chacha20_poly1305_case_2.plaintext.len);
14783 #ifdef RTE_CRYPTO_SCHEDULER
14785 /* global AESNI worker IDs for the scheduler test */
14786 uint8_t aesni_ids[2];
14789 scheduler_testsuite_setup(void)
14792 int32_t nb_devs, ret;
14793 char vdev_args[VDEV_ARGS_SIZE] = {""};
14794 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14795 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14796 uint16_t worker_core_count = 0;
14797 uint16_t socket_id = 0;
14799 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14800 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14802 /* Identify the Worker Cores
14803 * Use 2 worker cores for the device args
14805 RTE_LCORE_FOREACH_WORKER(i) {
14806 if (worker_core_count > 1)
14808 snprintf(vdev_args, sizeof(vdev_args),
14809 "%s%d", temp_str, i);
14810 strcpy(temp_str, vdev_args);
14811 strlcat(temp_str, ";", sizeof(temp_str));
14812 worker_core_count++;
14813 socket_id = rte_lcore_to_socket_id(i);
14815 if (worker_core_count != 2) {
14816 RTE_LOG(ERR, USER1,
14817 "Cryptodev scheduler test require at least "
14818 "two worker cores to run. "
14819 "Please use the correct coremask.\n");
14820 return TEST_FAILED;
14822 strcpy(temp_str, vdev_args);
14823 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14824 temp_str, socket_id);
14825 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14826 nb_devs = rte_cryptodev_device_count_by_driver(
14827 rte_cryptodev_driver_id_get(
14828 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14830 ret = rte_vdev_init(
14831 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14833 TEST_ASSERT(ret == 0,
14834 "Failed to create instance %u of pmd : %s",
14835 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14838 return testsuite_setup();
14842 test_scheduler_attach_worker_op(void)
14844 struct crypto_testsuite_params *ts_params = &testsuite_params;
14845 uint8_t sched_id = ts_params->valid_devs[0];
14846 uint32_t i, nb_devs_attached = 0;
14848 char vdev_name[32];
14849 unsigned int count = rte_cryptodev_count();
14851 /* create 2 AESNI_MB vdevs on top of existing devices */
14852 for (i = count; i < count + 2; i++) {
14853 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14854 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14856 ret = rte_vdev_init(vdev_name, NULL);
14858 TEST_ASSERT(ret == 0,
14859 "Failed to create instance %u of"
14861 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14864 RTE_LOG(ERR, USER1,
14865 "Failed to create 2 AESNI MB PMDs.\n");
14866 return TEST_SKIPPED;
14870 /* attach 2 AESNI_MB cdevs */
14871 for (i = count; i < count + 2; i++) {
14872 struct rte_cryptodev_info info;
14873 unsigned int session_size;
14875 rte_cryptodev_info_get(i, &info);
14876 if (info.driver_id != rte_cryptodev_driver_id_get(
14877 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14880 session_size = rte_cryptodev_sym_get_private_session_size(i);
14882 * Create the session mempool again, since now there are new devices
14883 * to use the mempool.
14885 if (ts_params->session_mpool) {
14886 rte_mempool_free(ts_params->session_mpool);
14887 ts_params->session_mpool = NULL;
14889 if (ts_params->session_priv_mpool) {
14890 rte_mempool_free(ts_params->session_priv_mpool);
14891 ts_params->session_priv_mpool = NULL;
14894 if (info.sym.max_nb_sessions != 0 &&
14895 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14896 RTE_LOG(ERR, USER1,
14897 "Device does not support "
14898 "at least %u sessions\n",
14900 return TEST_FAILED;
14903 * Create mempool with maximum number of sessions,
14904 * to include the session headers
14906 if (ts_params->session_mpool == NULL) {
14907 ts_params->session_mpool =
14908 rte_cryptodev_sym_session_pool_create(
14910 MAX_NB_SESSIONS, 0, 0, 0,
14912 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14913 "session mempool allocation failed");
14917 * Create mempool with maximum number of sessions,
14918 * to include device specific session private data
14920 if (ts_params->session_priv_mpool == NULL) {
14921 ts_params->session_priv_mpool = rte_mempool_create(
14922 "test_sess_mp_priv",
14925 0, 0, NULL, NULL, NULL,
14926 NULL, SOCKET_ID_ANY,
14929 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14930 "session mempool allocation failed");
14933 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14934 ts_params->qp_conf.mp_session_private =
14935 ts_params->session_priv_mpool;
14937 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14940 TEST_ASSERT(ret == 0,
14941 "Failed to attach device %u of pmd : %s", i,
14942 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14944 aesni_ids[nb_devs_attached] = (uint8_t)i;
14946 nb_devs_attached++;
14953 test_scheduler_detach_worker_op(void)
14955 struct crypto_testsuite_params *ts_params = &testsuite_params;
14956 uint8_t sched_id = ts_params->valid_devs[0];
14960 for (i = 0; i < 2; i++) {
14961 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14963 TEST_ASSERT(ret == 0,
14964 "Failed to detach device %u", aesni_ids[i]);
14971 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14973 struct crypto_testsuite_params *ts_params = &testsuite_params;
14974 uint8_t sched_id = ts_params->valid_devs[0];
14976 return rte_cryptodev_scheduler_mode_set(sched_id,
14981 test_scheduler_mode_roundrobin_op(void)
14983 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14984 0, "Failed to set roundrobin mode");
14990 test_scheduler_mode_multicore_op(void)
14992 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14993 0, "Failed to set multicore mode");
14999 test_scheduler_mode_failover_op(void)
15001 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
15002 0, "Failed to set failover mode");
15008 test_scheduler_mode_pkt_size_distr_op(void)
15010 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
15011 0, "Failed to set pktsize mode");
15017 scheduler_multicore_testsuite_setup(void)
15019 if (test_scheduler_attach_worker_op() < 0)
15020 return TEST_SKIPPED;
15021 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
15022 return TEST_SKIPPED;
15027 scheduler_roundrobin_testsuite_setup(void)
15029 if (test_scheduler_attach_worker_op() < 0)
15030 return TEST_SKIPPED;
15031 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
15032 return TEST_SKIPPED;
15037 scheduler_failover_testsuite_setup(void)
15039 if (test_scheduler_attach_worker_op() < 0)
15040 return TEST_SKIPPED;
15041 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
15042 return TEST_SKIPPED;
15047 scheduler_pkt_size_distr_testsuite_setup(void)
15049 if (test_scheduler_attach_worker_op() < 0)
15050 return TEST_SKIPPED;
15051 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
15052 return TEST_SKIPPED;
15057 scheduler_mode_testsuite_teardown(void)
15059 test_scheduler_detach_worker_op();
15062 #endif /* RTE_CRYPTO_SCHEDULER */
15064 static struct unit_test_suite end_testsuite = {
15065 .suite_name = NULL,
15068 .unit_test_suites = NULL
15071 #ifdef RTE_LIB_SECURITY
15072 static struct unit_test_suite ipsec_proto_testsuite = {
15073 .suite_name = "IPsec Proto Unit Test Suite",
15074 .setup = ipsec_proto_testsuite_setup,
15075 .unit_test_cases = {
15076 TEST_CASE_NAMED_WITH_DATA(
15077 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
15078 ut_setup_security, ut_teardown,
15079 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
15080 TEST_CASE_NAMED_WITH_DATA(
15081 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
15082 ut_setup_security, ut_teardown,
15083 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
15084 TEST_CASE_NAMED_WITH_DATA(
15085 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
15086 ut_setup_security, ut_teardown,
15087 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
15088 TEST_CASE_NAMED_WITH_DATA(
15089 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15090 ut_setup_security, ut_teardown,
15091 test_ipsec_proto_known_vec,
15092 &pkt_aes_128_cbc_hmac_sha256),
15093 TEST_CASE_NAMED_WITH_DATA(
15094 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
15095 ut_setup_security, ut_teardown,
15096 test_ipsec_proto_known_vec,
15097 &pkt_aes_128_cbc_hmac_sha384),
15098 TEST_CASE_NAMED_WITH_DATA(
15099 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
15100 ut_setup_security, ut_teardown,
15101 test_ipsec_proto_known_vec,
15102 &pkt_aes_128_cbc_hmac_sha512),
15103 TEST_CASE_NAMED_WITH_DATA(
15104 "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
15105 ut_setup_security, ut_teardown,
15106 test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
15107 TEST_CASE_NAMED_WITH_DATA(
15108 "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15109 ut_setup_security, ut_teardown,
15110 test_ipsec_proto_known_vec,
15111 &pkt_aes_128_cbc_hmac_sha256_v6),
15112 TEST_CASE_NAMED_WITH_DATA(
15113 "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
15114 ut_setup_security, ut_teardown,
15115 test_ipsec_proto_known_vec,
15116 &pkt_null_aes_xcbc),
15117 TEST_CASE_NAMED_WITH_DATA(
15118 "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
15119 ut_setup_security, ut_teardown,
15120 test_ipsec_proto_known_vec,
15121 &pkt_ah_tunnel_sha256),
15122 TEST_CASE_NAMED_WITH_DATA(
15123 "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
15124 ut_setup_security, ut_teardown,
15125 test_ipsec_proto_known_vec,
15126 &pkt_ah_transport_sha256),
15127 TEST_CASE_NAMED_WITH_DATA(
15128 "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
15129 ut_setup_security, ut_teardown,
15130 test_ipsec_proto_known_vec,
15131 &pkt_ah_ipv4_aes_gmac_128),
15132 TEST_CASE_NAMED_WITH_DATA(
15133 "Outbound fragmented packet",
15134 ut_setup_security, ut_teardown,
15135 test_ipsec_proto_known_vec_fragmented,
15136 &pkt_aes_128_gcm_frag),
15137 TEST_CASE_NAMED_WITH_DATA(
15138 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
15139 ut_setup_security, ut_teardown,
15140 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
15141 TEST_CASE_NAMED_WITH_DATA(
15142 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
15143 ut_setup_security, ut_teardown,
15144 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
15145 TEST_CASE_NAMED_WITH_DATA(
15146 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
15147 ut_setup_security, ut_teardown,
15148 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
15149 TEST_CASE_NAMED_WITH_DATA(
15150 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
15151 ut_setup_security, ut_teardown,
15152 test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
15153 TEST_CASE_NAMED_WITH_DATA(
15154 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15155 ut_setup_security, ut_teardown,
15156 test_ipsec_proto_known_vec_inb,
15157 &pkt_aes_128_cbc_hmac_sha256),
15158 TEST_CASE_NAMED_WITH_DATA(
15159 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
15160 ut_setup_security, ut_teardown,
15161 test_ipsec_proto_known_vec_inb,
15162 &pkt_aes_128_cbc_hmac_sha384),
15163 TEST_CASE_NAMED_WITH_DATA(
15164 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
15165 ut_setup_security, ut_teardown,
15166 test_ipsec_proto_known_vec_inb,
15167 &pkt_aes_128_cbc_hmac_sha512),
15168 TEST_CASE_NAMED_WITH_DATA(
15169 "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
15170 ut_setup_security, ut_teardown,
15171 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
15172 TEST_CASE_NAMED_WITH_DATA(
15173 "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
15174 ut_setup_security, ut_teardown,
15175 test_ipsec_proto_known_vec_inb,
15176 &pkt_aes_128_cbc_hmac_sha256_v6),
15177 TEST_CASE_NAMED_WITH_DATA(
15178 "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
15179 ut_setup_security, ut_teardown,
15180 test_ipsec_proto_known_vec_inb,
15181 &pkt_null_aes_xcbc),
15182 TEST_CASE_NAMED_WITH_DATA(
15183 "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
15184 ut_setup_security, ut_teardown,
15185 test_ipsec_proto_known_vec_inb,
15186 &pkt_ah_tunnel_sha256),
15187 TEST_CASE_NAMED_WITH_DATA(
15188 "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
15189 ut_setup_security, ut_teardown,
15190 test_ipsec_proto_known_vec_inb,
15191 &pkt_ah_transport_sha256),
15192 TEST_CASE_NAMED_WITH_DATA(
15193 "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
15194 ut_setup_security, ut_teardown,
15195 test_ipsec_proto_known_vec_inb,
15196 &pkt_ah_ipv4_aes_gmac_128),
15197 TEST_CASE_NAMED_ST(
15198 "Combined test alg list",
15199 ut_setup_security, ut_teardown,
15200 test_ipsec_proto_display_list),
15201 TEST_CASE_NAMED_ST(
15202 "Combined test alg list (AH)",
15203 ut_setup_security, ut_teardown,
15204 test_ipsec_proto_ah_tunnel_ipv4),
15205 TEST_CASE_NAMED_ST(
15207 ut_setup_security, ut_teardown,
15208 test_ipsec_proto_iv_gen),
15209 TEST_CASE_NAMED_ST(
15210 "UDP encapsulation",
15211 ut_setup_security, ut_teardown,
15212 test_ipsec_proto_udp_encap),
15213 TEST_CASE_NAMED_ST(
15214 "UDP encapsulation ports verification test",
15215 ut_setup_security, ut_teardown,
15216 test_ipsec_proto_udp_ports_verify),
15217 TEST_CASE_NAMED_ST(
15218 "SA expiry packets soft",
15219 ut_setup_security, ut_teardown,
15220 test_ipsec_proto_sa_exp_pkts_soft),
15221 TEST_CASE_NAMED_ST(
15222 "SA expiry packets hard",
15223 ut_setup_security, ut_teardown,
15224 test_ipsec_proto_sa_exp_pkts_hard),
15225 TEST_CASE_NAMED_ST(
15226 "Negative test: ICV corruption",
15227 ut_setup_security, ut_teardown,
15228 test_ipsec_proto_err_icv_corrupt),
15229 TEST_CASE_NAMED_ST(
15230 "Tunnel dst addr verification",
15231 ut_setup_security, ut_teardown,
15232 test_ipsec_proto_tunnel_dst_addr_verify),
15233 TEST_CASE_NAMED_ST(
15234 "Tunnel src and dst addr verification",
15235 ut_setup_security, ut_teardown,
15236 test_ipsec_proto_tunnel_src_dst_addr_verify),
15237 TEST_CASE_NAMED_ST(
15238 "Inner IP checksum",
15239 ut_setup_security, ut_teardown,
15240 test_ipsec_proto_inner_ip_csum),
15241 TEST_CASE_NAMED_ST(
15242 "Inner L4 checksum",
15243 ut_setup_security, ut_teardown,
15244 test_ipsec_proto_inner_l4_csum),
15245 TEST_CASE_NAMED_ST(
15246 "Tunnel IPv4 in IPv4",
15247 ut_setup_security, ut_teardown,
15248 test_ipsec_proto_tunnel_v4_in_v4),
15249 TEST_CASE_NAMED_ST(
15250 "Tunnel IPv6 in IPv6",
15251 ut_setup_security, ut_teardown,
15252 test_ipsec_proto_tunnel_v6_in_v6),
15253 TEST_CASE_NAMED_ST(
15254 "Tunnel IPv4 in IPv6",
15255 ut_setup_security, ut_teardown,
15256 test_ipsec_proto_tunnel_v4_in_v6),
15257 TEST_CASE_NAMED_ST(
15258 "Tunnel IPv6 in IPv4",
15259 ut_setup_security, ut_teardown,
15260 test_ipsec_proto_tunnel_v6_in_v4),
15261 TEST_CASE_NAMED_ST(
15263 ut_setup_security, ut_teardown,
15264 test_ipsec_proto_transport_v4),
15265 TEST_CASE_NAMED_ST(
15266 "AH transport IPv4",
15267 ut_setup_security, ut_teardown,
15268 test_ipsec_proto_ah_transport_ipv4),
15269 TEST_CASE_NAMED_ST(
15270 "Transport l4 checksum",
15271 ut_setup_security, ut_teardown,
15272 test_ipsec_proto_transport_l4_csum),
15273 TEST_CASE_NAMED_ST(
15274 "Statistics: success",
15275 ut_setup_security, ut_teardown,
15276 test_ipsec_proto_stats),
15277 TEST_CASE_NAMED_ST(
15278 "Fragmented packet",
15279 ut_setup_security, ut_teardown,
15280 test_ipsec_proto_pkt_fragment),
15281 TEST_CASE_NAMED_ST(
15282 "Tunnel header copy DF (inner 0)",
15283 ut_setup_security, ut_teardown,
15284 test_ipsec_proto_copy_df_inner_0),
15285 TEST_CASE_NAMED_ST(
15286 "Tunnel header copy DF (inner 1)",
15287 ut_setup_security, ut_teardown,
15288 test_ipsec_proto_copy_df_inner_1),
15289 TEST_CASE_NAMED_ST(
15290 "Tunnel header set DF 0 (inner 1)",
15291 ut_setup_security, ut_teardown,
15292 test_ipsec_proto_set_df_0_inner_1),
15293 TEST_CASE_NAMED_ST(
15294 "Tunnel header set DF 1 (inner 0)",
15295 ut_setup_security, ut_teardown,
15296 test_ipsec_proto_set_df_1_inner_0),
15297 TEST_CASE_NAMED_ST(
15298 "Tunnel header IPv4 copy DSCP (inner 0)",
15299 ut_setup_security, ut_teardown,
15300 test_ipsec_proto_ipv4_copy_dscp_inner_0),
15301 TEST_CASE_NAMED_ST(
15302 "Tunnel header IPv4 copy DSCP (inner 1)",
15303 ut_setup_security, ut_teardown,
15304 test_ipsec_proto_ipv4_copy_dscp_inner_1),
15305 TEST_CASE_NAMED_ST(
15306 "Tunnel header IPv4 set DSCP 0 (inner 1)",
15307 ut_setup_security, ut_teardown,
15308 test_ipsec_proto_ipv4_set_dscp_0_inner_1),
15309 TEST_CASE_NAMED_ST(
15310 "Tunnel header IPv4 set DSCP 1 (inner 0)",
15311 ut_setup_security, ut_teardown,
15312 test_ipsec_proto_ipv4_set_dscp_1_inner_0),
15313 TEST_CASE_NAMED_ST(
15314 "Tunnel header IPv6 copy DSCP (inner 0)",
15315 ut_setup_security, ut_teardown,
15316 test_ipsec_proto_ipv6_copy_dscp_inner_0),
15317 TEST_CASE_NAMED_ST(
15318 "Tunnel header IPv6 copy DSCP (inner 1)",
15319 ut_setup_security, ut_teardown,
15320 test_ipsec_proto_ipv6_copy_dscp_inner_1),
15321 TEST_CASE_NAMED_ST(
15322 "Tunnel header IPv6 set DSCP 0 (inner 1)",
15323 ut_setup_security, ut_teardown,
15324 test_ipsec_proto_ipv6_set_dscp_0_inner_1),
15325 TEST_CASE_NAMED_ST(
15326 "Tunnel header IPv6 set DSCP 1 (inner 0)",
15327 ut_setup_security, ut_teardown,
15328 test_ipsec_proto_ipv6_set_dscp_1_inner_0),
15329 TEST_CASE_NAMED_WITH_DATA(
15330 "Antireplay with window size 1024",
15331 ut_setup_security, ut_teardown,
15332 test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
15333 TEST_CASE_NAMED_WITH_DATA(
15334 "Antireplay with window size 2048",
15335 ut_setup_security, ut_teardown,
15336 test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
15337 TEST_CASE_NAMED_WITH_DATA(
15338 "Antireplay with window size 4096",
15339 ut_setup_security, ut_teardown,
15340 test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
15341 TEST_CASE_NAMED_WITH_DATA(
15342 "ESN and Antireplay with window size 1024",
15343 ut_setup_security, ut_teardown,
15344 test_ipsec_proto_pkt_esn_antireplay1024,
15346 TEST_CASE_NAMED_WITH_DATA(
15347 "ESN and Antireplay with window size 2048",
15348 ut_setup_security, ut_teardown,
15349 test_ipsec_proto_pkt_esn_antireplay2048,
15351 TEST_CASE_NAMED_WITH_DATA(
15352 "ESN and Antireplay with window size 4096",
15353 ut_setup_security, ut_teardown,
15354 test_ipsec_proto_pkt_esn_antireplay4096,
15356 TEST_CASE_NAMED_ST(
15357 "Tunnel header IPv4 decrement inner TTL",
15358 ut_setup_security, ut_teardown,
15359 test_ipsec_proto_ipv4_ttl_decrement),
15360 TEST_CASE_NAMED_ST(
15361 "Tunnel header IPv6 decrement inner hop limit",
15362 ut_setup_security, ut_teardown,
15363 test_ipsec_proto_ipv6_hop_limit_decrement),
15364 TEST_CASES_END() /**< NULL terminate unit test array */
15368 static struct unit_test_suite pdcp_proto_testsuite = {
15369 .suite_name = "PDCP Proto Unit Test Suite",
15370 .setup = pdcp_proto_testsuite_setup,
15371 .unit_test_cases = {
15372 TEST_CASE_ST(ut_setup_security, ut_teardown,
15373 test_PDCP_PROTO_all),
15374 TEST_CASES_END() /**< NULL terminate unit test array */
15378 #define ADD_UPLINK_TESTCASE(data) \
15379 TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
15380 ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
15382 #define ADD_DOWNLINK_TESTCASE(data) \
15383 TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
15384 ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
15386 static struct unit_test_suite docsis_proto_testsuite = {
15387 .suite_name = "DOCSIS Proto Unit Test Suite",
15388 .setup = docsis_proto_testsuite_setup,
15389 .unit_test_cases = {
15391 ADD_UPLINK_TESTCASE(docsis_test_case_1)
15392 ADD_UPLINK_TESTCASE(docsis_test_case_2)
15393 ADD_UPLINK_TESTCASE(docsis_test_case_3)
15394 ADD_UPLINK_TESTCASE(docsis_test_case_4)
15395 ADD_UPLINK_TESTCASE(docsis_test_case_5)
15396 ADD_UPLINK_TESTCASE(docsis_test_case_6)
15397 ADD_UPLINK_TESTCASE(docsis_test_case_7)
15398 ADD_UPLINK_TESTCASE(docsis_test_case_8)
15399 ADD_UPLINK_TESTCASE(docsis_test_case_9)
15400 ADD_UPLINK_TESTCASE(docsis_test_case_10)
15401 ADD_UPLINK_TESTCASE(docsis_test_case_11)
15402 ADD_UPLINK_TESTCASE(docsis_test_case_12)
15403 ADD_UPLINK_TESTCASE(docsis_test_case_13)
15404 ADD_UPLINK_TESTCASE(docsis_test_case_14)
15405 ADD_UPLINK_TESTCASE(docsis_test_case_15)
15406 ADD_UPLINK_TESTCASE(docsis_test_case_16)
15407 ADD_UPLINK_TESTCASE(docsis_test_case_17)
15408 ADD_UPLINK_TESTCASE(docsis_test_case_18)
15409 ADD_UPLINK_TESTCASE(docsis_test_case_19)
15410 ADD_UPLINK_TESTCASE(docsis_test_case_20)
15411 ADD_UPLINK_TESTCASE(docsis_test_case_21)
15412 ADD_UPLINK_TESTCASE(docsis_test_case_22)
15413 ADD_UPLINK_TESTCASE(docsis_test_case_23)
15414 ADD_UPLINK_TESTCASE(docsis_test_case_24)
15415 ADD_UPLINK_TESTCASE(docsis_test_case_25)
15416 ADD_UPLINK_TESTCASE(docsis_test_case_26)
15418 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
15419 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
15420 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
15421 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
15422 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
15423 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
15424 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
15425 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
15426 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
15427 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
15428 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
15429 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
15430 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
15431 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
15432 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
15433 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
15434 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
15435 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
15436 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
15437 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
15438 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
15439 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
15440 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
15441 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
15442 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
15443 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
15444 TEST_CASES_END() /**< NULL terminate unit test array */
15449 static struct unit_test_suite cryptodev_gen_testsuite = {
15450 .suite_name = "Crypto General Unit Test Suite",
15451 .setup = crypto_gen_testsuite_setup,
15452 .unit_test_cases = {
15453 TEST_CASE_ST(ut_setup, ut_teardown,
15454 test_device_configure_invalid_dev_id),
15455 TEST_CASE_ST(ut_setup, ut_teardown,
15456 test_queue_pair_descriptor_setup),
15457 TEST_CASE_ST(ut_setup, ut_teardown,
15458 test_device_configure_invalid_queue_pair_ids),
15459 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
15460 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
15461 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
15462 TEST_CASES_END() /**< NULL terminate unit test array */
15466 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
15467 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
15468 .setup = negative_hmac_sha1_testsuite_setup,
15469 .unit_test_cases = {
15470 /** Negative tests */
15471 TEST_CASE_ST(ut_setup, ut_teardown,
15472 authentication_verify_HMAC_SHA1_fail_data_corrupt),
15473 TEST_CASE_ST(ut_setup, ut_teardown,
15474 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
15475 TEST_CASE_ST(ut_setup, ut_teardown,
15476 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
15477 TEST_CASE_ST(ut_setup, ut_teardown,
15478 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
15480 TEST_CASES_END() /**< NULL terminate unit test array */
15484 static struct unit_test_suite cryptodev_multi_session_testsuite = {
15485 .suite_name = "Multi Session Unit Test Suite",
15486 .setup = multi_session_testsuite_setup,
15487 .unit_test_cases = {
15488 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
15489 TEST_CASE_ST(ut_setup, ut_teardown,
15490 test_multi_session_random_usage),
15492 TEST_CASES_END() /**< NULL terminate unit test array */
15496 static struct unit_test_suite cryptodev_null_testsuite = {
15497 .suite_name = "NULL Test Suite",
15498 .setup = null_testsuite_setup,
15499 .unit_test_cases = {
15500 TEST_CASE_ST(ut_setup, ut_teardown,
15501 test_null_invalid_operation),
15502 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
15507 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
15508 .suite_name = "AES CCM Authenticated Test Suite",
15509 .setup = aes_ccm_auth_testsuite_setup,
15510 .unit_test_cases = {
15511 /** AES CCM Authenticated Encryption 128 bits key*/
15512 TEST_CASE_ST(ut_setup, ut_teardown,
15513 test_AES_CCM_authenticated_encryption_test_case_128_1),
15514 TEST_CASE_ST(ut_setup, ut_teardown,
15515 test_AES_CCM_authenticated_encryption_test_case_128_2),
15516 TEST_CASE_ST(ut_setup, ut_teardown,
15517 test_AES_CCM_authenticated_encryption_test_case_128_3),
15519 /** AES CCM Authenticated Decryption 128 bits key*/
15520 TEST_CASE_ST(ut_setup, ut_teardown,
15521 test_AES_CCM_authenticated_decryption_test_case_128_1),
15522 TEST_CASE_ST(ut_setup, ut_teardown,
15523 test_AES_CCM_authenticated_decryption_test_case_128_2),
15524 TEST_CASE_ST(ut_setup, ut_teardown,
15525 test_AES_CCM_authenticated_decryption_test_case_128_3),
15527 /** AES CCM Authenticated Encryption 192 bits key */
15528 TEST_CASE_ST(ut_setup, ut_teardown,
15529 test_AES_CCM_authenticated_encryption_test_case_192_1),
15530 TEST_CASE_ST(ut_setup, ut_teardown,
15531 test_AES_CCM_authenticated_encryption_test_case_192_2),
15532 TEST_CASE_ST(ut_setup, ut_teardown,
15533 test_AES_CCM_authenticated_encryption_test_case_192_3),
15535 /** AES CCM Authenticated Decryption 192 bits key*/
15536 TEST_CASE_ST(ut_setup, ut_teardown,
15537 test_AES_CCM_authenticated_decryption_test_case_192_1),
15538 TEST_CASE_ST(ut_setup, ut_teardown,
15539 test_AES_CCM_authenticated_decryption_test_case_192_2),
15540 TEST_CASE_ST(ut_setup, ut_teardown,
15541 test_AES_CCM_authenticated_decryption_test_case_192_3),
15543 /** AES CCM Authenticated Encryption 256 bits key */
15544 TEST_CASE_ST(ut_setup, ut_teardown,
15545 test_AES_CCM_authenticated_encryption_test_case_256_1),
15546 TEST_CASE_ST(ut_setup, ut_teardown,
15547 test_AES_CCM_authenticated_encryption_test_case_256_2),
15548 TEST_CASE_ST(ut_setup, ut_teardown,
15549 test_AES_CCM_authenticated_encryption_test_case_256_3),
15551 /** AES CCM Authenticated Decryption 256 bits key*/
15552 TEST_CASE_ST(ut_setup, ut_teardown,
15553 test_AES_CCM_authenticated_decryption_test_case_256_1),
15554 TEST_CASE_ST(ut_setup, ut_teardown,
15555 test_AES_CCM_authenticated_decryption_test_case_256_2),
15556 TEST_CASE_ST(ut_setup, ut_teardown,
15557 test_AES_CCM_authenticated_decryption_test_case_256_3),
15562 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
15563 .suite_name = "AES GCM Authenticated Test Suite",
15564 .setup = aes_gcm_auth_testsuite_setup,
15565 .unit_test_cases = {
15566 /** AES GCM Authenticated Encryption */
15567 TEST_CASE_ST(ut_setup, ut_teardown,
15568 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
15569 TEST_CASE_ST(ut_setup, ut_teardown,
15570 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
15571 TEST_CASE_ST(ut_setup, ut_teardown,
15572 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
15573 TEST_CASE_ST(ut_setup, ut_teardown,
15574 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
15575 TEST_CASE_ST(ut_setup, ut_teardown,
15576 test_AES_GCM_authenticated_encryption_test_case_1),
15577 TEST_CASE_ST(ut_setup, ut_teardown,
15578 test_AES_GCM_authenticated_encryption_test_case_2),
15579 TEST_CASE_ST(ut_setup, ut_teardown,
15580 test_AES_GCM_authenticated_encryption_test_case_3),
15581 TEST_CASE_ST(ut_setup, ut_teardown,
15582 test_AES_GCM_authenticated_encryption_test_case_4),
15583 TEST_CASE_ST(ut_setup, ut_teardown,
15584 test_AES_GCM_authenticated_encryption_test_case_5),
15585 TEST_CASE_ST(ut_setup, ut_teardown,
15586 test_AES_GCM_authenticated_encryption_test_case_6),
15587 TEST_CASE_ST(ut_setup, ut_teardown,
15588 test_AES_GCM_authenticated_encryption_test_case_7),
15589 TEST_CASE_ST(ut_setup, ut_teardown,
15590 test_AES_GCM_authenticated_encryption_test_case_8),
15591 TEST_CASE_ST(ut_setup, ut_teardown,
15592 test_AES_GCM_J0_authenticated_encryption_test_case_1),
15594 /** AES GCM Authenticated Decryption */
15595 TEST_CASE_ST(ut_setup, ut_teardown,
15596 test_AES_GCM_authenticated_decryption_test_case_1),
15597 TEST_CASE_ST(ut_setup, ut_teardown,
15598 test_AES_GCM_authenticated_decryption_test_case_2),
15599 TEST_CASE_ST(ut_setup, ut_teardown,
15600 test_AES_GCM_authenticated_decryption_test_case_3),
15601 TEST_CASE_ST(ut_setup, ut_teardown,
15602 test_AES_GCM_authenticated_decryption_test_case_4),
15603 TEST_CASE_ST(ut_setup, ut_teardown,
15604 test_AES_GCM_authenticated_decryption_test_case_5),
15605 TEST_CASE_ST(ut_setup, ut_teardown,
15606 test_AES_GCM_authenticated_decryption_test_case_6),
15607 TEST_CASE_ST(ut_setup, ut_teardown,
15608 test_AES_GCM_authenticated_decryption_test_case_7),
15609 TEST_CASE_ST(ut_setup, ut_teardown,
15610 test_AES_GCM_authenticated_decryption_test_case_8),
15611 TEST_CASE_ST(ut_setup, ut_teardown,
15612 test_AES_GCM_J0_authenticated_decryption_test_case_1),
15614 /** AES GCM Authenticated Encryption 192 bits key */
15615 TEST_CASE_ST(ut_setup, ut_teardown,
15616 test_AES_GCM_auth_encryption_test_case_192_1),
15617 TEST_CASE_ST(ut_setup, ut_teardown,
15618 test_AES_GCM_auth_encryption_test_case_192_2),
15619 TEST_CASE_ST(ut_setup, ut_teardown,
15620 test_AES_GCM_auth_encryption_test_case_192_3),
15621 TEST_CASE_ST(ut_setup, ut_teardown,
15622 test_AES_GCM_auth_encryption_test_case_192_4),
15623 TEST_CASE_ST(ut_setup, ut_teardown,
15624 test_AES_GCM_auth_encryption_test_case_192_5),
15625 TEST_CASE_ST(ut_setup, ut_teardown,
15626 test_AES_GCM_auth_encryption_test_case_192_6),
15627 TEST_CASE_ST(ut_setup, ut_teardown,
15628 test_AES_GCM_auth_encryption_test_case_192_7),
15630 /** AES GCM Authenticated Decryption 192 bits key */
15631 TEST_CASE_ST(ut_setup, ut_teardown,
15632 test_AES_GCM_auth_decryption_test_case_192_1),
15633 TEST_CASE_ST(ut_setup, ut_teardown,
15634 test_AES_GCM_auth_decryption_test_case_192_2),
15635 TEST_CASE_ST(ut_setup, ut_teardown,
15636 test_AES_GCM_auth_decryption_test_case_192_3),
15637 TEST_CASE_ST(ut_setup, ut_teardown,
15638 test_AES_GCM_auth_decryption_test_case_192_4),
15639 TEST_CASE_ST(ut_setup, ut_teardown,
15640 test_AES_GCM_auth_decryption_test_case_192_5),
15641 TEST_CASE_ST(ut_setup, ut_teardown,
15642 test_AES_GCM_auth_decryption_test_case_192_6),
15643 TEST_CASE_ST(ut_setup, ut_teardown,
15644 test_AES_GCM_auth_decryption_test_case_192_7),
15646 /** AES GCM Authenticated Encryption 256 bits key */
15647 TEST_CASE_ST(ut_setup, ut_teardown,
15648 test_AES_GCM_auth_encryption_test_case_256_1),
15649 TEST_CASE_ST(ut_setup, ut_teardown,
15650 test_AES_GCM_auth_encryption_test_case_256_2),
15651 TEST_CASE_ST(ut_setup, ut_teardown,
15652 test_AES_GCM_auth_encryption_test_case_256_3),
15653 TEST_CASE_ST(ut_setup, ut_teardown,
15654 test_AES_GCM_auth_encryption_test_case_256_4),
15655 TEST_CASE_ST(ut_setup, ut_teardown,
15656 test_AES_GCM_auth_encryption_test_case_256_5),
15657 TEST_CASE_ST(ut_setup, ut_teardown,
15658 test_AES_GCM_auth_encryption_test_case_256_6),
15659 TEST_CASE_ST(ut_setup, ut_teardown,
15660 test_AES_GCM_auth_encryption_test_case_256_7),
15662 /** AES GCM Authenticated Decryption 256 bits key */
15663 TEST_CASE_ST(ut_setup, ut_teardown,
15664 test_AES_GCM_auth_decryption_test_case_256_1),
15665 TEST_CASE_ST(ut_setup, ut_teardown,
15666 test_AES_GCM_auth_decryption_test_case_256_2),
15667 TEST_CASE_ST(ut_setup, ut_teardown,
15668 test_AES_GCM_auth_decryption_test_case_256_3),
15669 TEST_CASE_ST(ut_setup, ut_teardown,
15670 test_AES_GCM_auth_decryption_test_case_256_4),
15671 TEST_CASE_ST(ut_setup, ut_teardown,
15672 test_AES_GCM_auth_decryption_test_case_256_5),
15673 TEST_CASE_ST(ut_setup, ut_teardown,
15674 test_AES_GCM_auth_decryption_test_case_256_6),
15675 TEST_CASE_ST(ut_setup, ut_teardown,
15676 test_AES_GCM_auth_decryption_test_case_256_7),
15678 /** AES GCM Authenticated Encryption big aad size */
15679 TEST_CASE_ST(ut_setup, ut_teardown,
15680 test_AES_GCM_auth_encryption_test_case_aad_1),
15681 TEST_CASE_ST(ut_setup, ut_teardown,
15682 test_AES_GCM_auth_encryption_test_case_aad_2),
15684 /** AES GCM Authenticated Decryption big aad size */
15685 TEST_CASE_ST(ut_setup, ut_teardown,
15686 test_AES_GCM_auth_decryption_test_case_aad_1),
15687 TEST_CASE_ST(ut_setup, ut_teardown,
15688 test_AES_GCM_auth_decryption_test_case_aad_2),
15690 /** Out of place tests */
15691 TEST_CASE_ST(ut_setup, ut_teardown,
15692 test_AES_GCM_authenticated_encryption_oop_test_case_1),
15693 TEST_CASE_ST(ut_setup, ut_teardown,
15694 test_AES_GCM_authenticated_decryption_oop_test_case_1),
15696 /** Session-less tests */
15697 TEST_CASE_ST(ut_setup, ut_teardown,
15698 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
15699 TEST_CASE_ST(ut_setup, ut_teardown,
15700 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
15706 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
15707 .suite_name = "AES GMAC Authentication Test Suite",
15708 .setup = aes_gmac_auth_testsuite_setup,
15709 .unit_test_cases = {
15710 TEST_CASE_ST(ut_setup, ut_teardown,
15711 test_AES_GMAC_authentication_test_case_1),
15712 TEST_CASE_ST(ut_setup, ut_teardown,
15713 test_AES_GMAC_authentication_verify_test_case_1),
15714 TEST_CASE_ST(ut_setup, ut_teardown,
15715 test_AES_GMAC_authentication_test_case_2),
15716 TEST_CASE_ST(ut_setup, ut_teardown,
15717 test_AES_GMAC_authentication_verify_test_case_2),
15718 TEST_CASE_ST(ut_setup, ut_teardown,
15719 test_AES_GMAC_authentication_test_case_3),
15720 TEST_CASE_ST(ut_setup, ut_teardown,
15721 test_AES_GMAC_authentication_verify_test_case_3),
15722 TEST_CASE_ST(ut_setup, ut_teardown,
15723 test_AES_GMAC_authentication_test_case_4),
15724 TEST_CASE_ST(ut_setup, ut_teardown,
15725 test_AES_GMAC_authentication_verify_test_case_4),
15726 TEST_CASE_ST(ut_setup, ut_teardown,
15727 test_AES_GMAC_authentication_SGL_40B),
15728 TEST_CASE_ST(ut_setup, ut_teardown,
15729 test_AES_GMAC_authentication_SGL_80B),
15730 TEST_CASE_ST(ut_setup, ut_teardown,
15731 test_AES_GMAC_authentication_SGL_2048B),
15732 TEST_CASE_ST(ut_setup, ut_teardown,
15733 test_AES_GMAC_authentication_SGL_2047B),
15739 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
15740 .suite_name = "Chacha20-Poly1305 Test Suite",
15741 .setup = chacha20_poly1305_testsuite_setup,
15742 .unit_test_cases = {
15743 TEST_CASE_ST(ut_setup, ut_teardown,
15744 test_chacha20_poly1305_encrypt_test_case_rfc8439),
15745 TEST_CASE_ST(ut_setup, ut_teardown,
15746 test_chacha20_poly1305_decrypt_test_case_rfc8439),
15747 TEST_CASE_ST(ut_setup, ut_teardown,
15748 test_chacha20_poly1305_encrypt_SGL_out_of_place),
15753 static struct unit_test_suite cryptodev_snow3g_testsuite = {
15754 .suite_name = "SNOW 3G Test Suite",
15755 .setup = snow3g_testsuite_setup,
15756 .unit_test_cases = {
15757 /** SNOW 3G encrypt only (UEA2) */
15758 TEST_CASE_ST(ut_setup, ut_teardown,
15759 test_snow3g_encryption_test_case_1),
15760 TEST_CASE_ST(ut_setup, ut_teardown,
15761 test_snow3g_encryption_test_case_2),
15762 TEST_CASE_ST(ut_setup, ut_teardown,
15763 test_snow3g_encryption_test_case_3),
15764 TEST_CASE_ST(ut_setup, ut_teardown,
15765 test_snow3g_encryption_test_case_4),
15766 TEST_CASE_ST(ut_setup, ut_teardown,
15767 test_snow3g_encryption_test_case_5),
15769 TEST_CASE_ST(ut_setup, ut_teardown,
15770 test_snow3g_encryption_test_case_1_oop),
15771 TEST_CASE_ST(ut_setup, ut_teardown,
15772 test_snow3g_encryption_test_case_1_oop_sgl),
15773 TEST_CASE_ST(ut_setup, ut_teardown,
15774 test_snow3g_encryption_test_case_1_offset_oop),
15775 TEST_CASE_ST(ut_setup, ut_teardown,
15776 test_snow3g_decryption_test_case_1_oop),
15778 /** SNOW 3G generate auth, then encrypt (UEA2) */
15779 TEST_CASE_ST(ut_setup, ut_teardown,
15780 test_snow3g_auth_cipher_test_case_1),
15781 TEST_CASE_ST(ut_setup, ut_teardown,
15782 test_snow3g_auth_cipher_test_case_2),
15783 TEST_CASE_ST(ut_setup, ut_teardown,
15784 test_snow3g_auth_cipher_test_case_2_oop),
15785 TEST_CASE_ST(ut_setup, ut_teardown,
15786 test_snow3g_auth_cipher_part_digest_enc),
15787 TEST_CASE_ST(ut_setup, ut_teardown,
15788 test_snow3g_auth_cipher_part_digest_enc_oop),
15789 TEST_CASE_ST(ut_setup, ut_teardown,
15790 test_snow3g_auth_cipher_test_case_3_sgl),
15791 TEST_CASE_ST(ut_setup, ut_teardown,
15792 test_snow3g_auth_cipher_test_case_3_oop_sgl),
15793 TEST_CASE_ST(ut_setup, ut_teardown,
15794 test_snow3g_auth_cipher_part_digest_enc_sgl),
15795 TEST_CASE_ST(ut_setup, ut_teardown,
15796 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
15798 /** SNOW 3G decrypt (UEA2), then verify auth */
15799 TEST_CASE_ST(ut_setup, ut_teardown,
15800 test_snow3g_auth_cipher_verify_test_case_1),
15801 TEST_CASE_ST(ut_setup, ut_teardown,
15802 test_snow3g_auth_cipher_verify_test_case_2),
15803 TEST_CASE_ST(ut_setup, ut_teardown,
15804 test_snow3g_auth_cipher_verify_test_case_2_oop),
15805 TEST_CASE_ST(ut_setup, ut_teardown,
15806 test_snow3g_auth_cipher_verify_part_digest_enc),
15807 TEST_CASE_ST(ut_setup, ut_teardown,
15808 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
15809 TEST_CASE_ST(ut_setup, ut_teardown,
15810 test_snow3g_auth_cipher_verify_test_case_3_sgl),
15811 TEST_CASE_ST(ut_setup, ut_teardown,
15812 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
15813 TEST_CASE_ST(ut_setup, ut_teardown,
15814 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
15815 TEST_CASE_ST(ut_setup, ut_teardown,
15816 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
15818 /** SNOW 3G decrypt only (UEA2) */
15819 TEST_CASE_ST(ut_setup, ut_teardown,
15820 test_snow3g_decryption_test_case_1),
15821 TEST_CASE_ST(ut_setup, ut_teardown,
15822 test_snow3g_decryption_test_case_2),
15823 TEST_CASE_ST(ut_setup, ut_teardown,
15824 test_snow3g_decryption_test_case_3),
15825 TEST_CASE_ST(ut_setup, ut_teardown,
15826 test_snow3g_decryption_test_case_4),
15827 TEST_CASE_ST(ut_setup, ut_teardown,
15828 test_snow3g_decryption_test_case_5),
15829 TEST_CASE_ST(ut_setup, ut_teardown,
15830 test_snow3g_decryption_with_digest_test_case_1),
15831 TEST_CASE_ST(ut_setup, ut_teardown,
15832 test_snow3g_hash_generate_test_case_1),
15833 TEST_CASE_ST(ut_setup, ut_teardown,
15834 test_snow3g_hash_generate_test_case_2),
15835 TEST_CASE_ST(ut_setup, ut_teardown,
15836 test_snow3g_hash_generate_test_case_3),
15838 /* Tests with buffers which length is not byte-aligned */
15839 TEST_CASE_ST(ut_setup, ut_teardown,
15840 test_snow3g_hash_generate_test_case_4),
15841 TEST_CASE_ST(ut_setup, ut_teardown,
15842 test_snow3g_hash_generate_test_case_5),
15843 TEST_CASE_ST(ut_setup, ut_teardown,
15844 test_snow3g_hash_generate_test_case_6),
15845 TEST_CASE_ST(ut_setup, ut_teardown,
15846 test_snow3g_hash_verify_test_case_1),
15847 TEST_CASE_ST(ut_setup, ut_teardown,
15848 test_snow3g_hash_verify_test_case_2),
15849 TEST_CASE_ST(ut_setup, ut_teardown,
15850 test_snow3g_hash_verify_test_case_3),
15852 /* Tests with buffers which length is not byte-aligned */
15853 TEST_CASE_ST(ut_setup, ut_teardown,
15854 test_snow3g_hash_verify_test_case_4),
15855 TEST_CASE_ST(ut_setup, ut_teardown,
15856 test_snow3g_hash_verify_test_case_5),
15857 TEST_CASE_ST(ut_setup, ut_teardown,
15858 test_snow3g_hash_verify_test_case_6),
15859 TEST_CASE_ST(ut_setup, ut_teardown,
15860 test_snow3g_cipher_auth_test_case_1),
15861 TEST_CASE_ST(ut_setup, ut_teardown,
15862 test_snow3g_auth_cipher_with_digest_test_case_1),
15867 static struct unit_test_suite cryptodev_zuc_testsuite = {
15868 .suite_name = "ZUC Test Suite",
15869 .setup = zuc_testsuite_setup,
15870 .unit_test_cases = {
15871 /** ZUC encrypt only (EEA3) */
15872 TEST_CASE_ST(ut_setup, ut_teardown,
15873 test_zuc_encryption_test_case_1),
15874 TEST_CASE_ST(ut_setup, ut_teardown,
15875 test_zuc_encryption_test_case_2),
15876 TEST_CASE_ST(ut_setup, ut_teardown,
15877 test_zuc_encryption_test_case_3),
15878 TEST_CASE_ST(ut_setup, ut_teardown,
15879 test_zuc_encryption_test_case_4),
15880 TEST_CASE_ST(ut_setup, ut_teardown,
15881 test_zuc_encryption_test_case_5),
15882 TEST_CASE_ST(ut_setup, ut_teardown,
15883 test_zuc_encryption_test_case_6_sgl),
15885 /** ZUC authenticate (EIA3) */
15886 TEST_CASE_ST(ut_setup, ut_teardown,
15887 test_zuc_hash_generate_test_case_1),
15888 TEST_CASE_ST(ut_setup, ut_teardown,
15889 test_zuc_hash_generate_test_case_2),
15890 TEST_CASE_ST(ut_setup, ut_teardown,
15891 test_zuc_hash_generate_test_case_3),
15892 TEST_CASE_ST(ut_setup, ut_teardown,
15893 test_zuc_hash_generate_test_case_4),
15894 TEST_CASE_ST(ut_setup, ut_teardown,
15895 test_zuc_hash_generate_test_case_5),
15896 TEST_CASE_ST(ut_setup, ut_teardown,
15897 test_zuc_hash_generate_test_case_6),
15898 TEST_CASE_ST(ut_setup, ut_teardown,
15899 test_zuc_hash_generate_test_case_7),
15900 TEST_CASE_ST(ut_setup, ut_teardown,
15901 test_zuc_hash_generate_test_case_8),
15902 TEST_CASE_ST(ut_setup, ut_teardown,
15903 test_zuc_hash_generate_test_case_9),
15904 TEST_CASE_ST(ut_setup, ut_teardown,
15905 test_zuc_hash_generate_test_case_10),
15906 TEST_CASE_ST(ut_setup, ut_teardown,
15907 test_zuc_hash_generate_test_case_11),
15910 /** ZUC alg-chain (EEA3/EIA3) */
15911 TEST_CASE_ST(ut_setup, ut_teardown,
15912 test_zuc_cipher_auth_test_case_1),
15913 TEST_CASE_ST(ut_setup, ut_teardown,
15914 test_zuc_cipher_auth_test_case_2),
15916 /** ZUC generate auth, then encrypt (EEA3) */
15917 TEST_CASE_ST(ut_setup, ut_teardown,
15918 test_zuc_auth_cipher_test_case_1),
15919 TEST_CASE_ST(ut_setup, ut_teardown,
15920 test_zuc_auth_cipher_test_case_1_oop),
15921 TEST_CASE_ST(ut_setup, ut_teardown,
15922 test_zuc_auth_cipher_test_case_1_sgl),
15923 TEST_CASE_ST(ut_setup, ut_teardown,
15924 test_zuc_auth_cipher_test_case_1_oop_sgl),
15926 /** ZUC decrypt (EEA3), then verify auth */
15927 TEST_CASE_ST(ut_setup, ut_teardown,
15928 test_zuc_auth_cipher_verify_test_case_1),
15929 TEST_CASE_ST(ut_setup, ut_teardown,
15930 test_zuc_auth_cipher_verify_test_case_1_oop),
15931 TEST_CASE_ST(ut_setup, ut_teardown,
15932 test_zuc_auth_cipher_verify_test_case_1_sgl),
15933 TEST_CASE_ST(ut_setup, ut_teardown,
15934 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
15936 /** ZUC-256 encrypt only **/
15937 TEST_CASE_ST(ut_setup, ut_teardown,
15938 test_zuc256_encryption_test_case_1),
15939 TEST_CASE_ST(ut_setup, ut_teardown,
15940 test_zuc256_encryption_test_case_2),
15942 /** ZUC-256 authentication only **/
15943 TEST_CASE_ST(ut_setup, ut_teardown,
15944 test_zuc256_authentication_test_case_1),
15945 TEST_CASE_ST(ut_setup, ut_teardown,
15946 test_zuc256_authentication_test_case_2),
15952 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
15953 .suite_name = "HMAC_MD5 Authentication Test Suite",
15954 .setup = hmac_md5_auth_testsuite_setup,
15955 .unit_test_cases = {
15956 TEST_CASE_ST(ut_setup, ut_teardown,
15957 test_MD5_HMAC_generate_case_1),
15958 TEST_CASE_ST(ut_setup, ut_teardown,
15959 test_MD5_HMAC_verify_case_1),
15960 TEST_CASE_ST(ut_setup, ut_teardown,
15961 test_MD5_HMAC_generate_case_2),
15962 TEST_CASE_ST(ut_setup, ut_teardown,
15963 test_MD5_HMAC_verify_case_2),
15968 static struct unit_test_suite cryptodev_kasumi_testsuite = {
15969 .suite_name = "Kasumi Test Suite",
15970 .setup = kasumi_testsuite_setup,
15971 .unit_test_cases = {
15972 /** KASUMI hash only (UIA1) */
15973 TEST_CASE_ST(ut_setup, ut_teardown,
15974 test_kasumi_hash_generate_test_case_1),
15975 TEST_CASE_ST(ut_setup, ut_teardown,
15976 test_kasumi_hash_generate_test_case_2),
15977 TEST_CASE_ST(ut_setup, ut_teardown,
15978 test_kasumi_hash_generate_test_case_3),
15979 TEST_CASE_ST(ut_setup, ut_teardown,
15980 test_kasumi_hash_generate_test_case_4),
15981 TEST_CASE_ST(ut_setup, ut_teardown,
15982 test_kasumi_hash_generate_test_case_5),
15983 TEST_CASE_ST(ut_setup, ut_teardown,
15984 test_kasumi_hash_generate_test_case_6),
15986 TEST_CASE_ST(ut_setup, ut_teardown,
15987 test_kasumi_hash_verify_test_case_1),
15988 TEST_CASE_ST(ut_setup, ut_teardown,
15989 test_kasumi_hash_verify_test_case_2),
15990 TEST_CASE_ST(ut_setup, ut_teardown,
15991 test_kasumi_hash_verify_test_case_3),
15992 TEST_CASE_ST(ut_setup, ut_teardown,
15993 test_kasumi_hash_verify_test_case_4),
15994 TEST_CASE_ST(ut_setup, ut_teardown,
15995 test_kasumi_hash_verify_test_case_5),
15997 /** KASUMI encrypt only (UEA1) */
15998 TEST_CASE_ST(ut_setup, ut_teardown,
15999 test_kasumi_encryption_test_case_1),
16000 TEST_CASE_ST(ut_setup, ut_teardown,
16001 test_kasumi_encryption_test_case_1_sgl),
16002 TEST_CASE_ST(ut_setup, ut_teardown,
16003 test_kasumi_encryption_test_case_1_oop),
16004 TEST_CASE_ST(ut_setup, ut_teardown,
16005 test_kasumi_encryption_test_case_1_oop_sgl),
16006 TEST_CASE_ST(ut_setup, ut_teardown,
16007 test_kasumi_encryption_test_case_2),
16008 TEST_CASE_ST(ut_setup, ut_teardown,
16009 test_kasumi_encryption_test_case_3),
16010 TEST_CASE_ST(ut_setup, ut_teardown,
16011 test_kasumi_encryption_test_case_4),
16012 TEST_CASE_ST(ut_setup, ut_teardown,
16013 test_kasumi_encryption_test_case_5),
16015 /** KASUMI decrypt only (UEA1) */
16016 TEST_CASE_ST(ut_setup, ut_teardown,
16017 test_kasumi_decryption_test_case_1),
16018 TEST_CASE_ST(ut_setup, ut_teardown,
16019 test_kasumi_decryption_test_case_2),
16020 TEST_CASE_ST(ut_setup, ut_teardown,
16021 test_kasumi_decryption_test_case_3),
16022 TEST_CASE_ST(ut_setup, ut_teardown,
16023 test_kasumi_decryption_test_case_4),
16024 TEST_CASE_ST(ut_setup, ut_teardown,
16025 test_kasumi_decryption_test_case_5),
16026 TEST_CASE_ST(ut_setup, ut_teardown,
16027 test_kasumi_decryption_test_case_1_oop),
16028 TEST_CASE_ST(ut_setup, ut_teardown,
16029 test_kasumi_cipher_auth_test_case_1),
16031 /** KASUMI generate auth, then encrypt (F8) */
16032 TEST_CASE_ST(ut_setup, ut_teardown,
16033 test_kasumi_auth_cipher_test_case_1),
16034 TEST_CASE_ST(ut_setup, ut_teardown,
16035 test_kasumi_auth_cipher_test_case_2),
16036 TEST_CASE_ST(ut_setup, ut_teardown,
16037 test_kasumi_auth_cipher_test_case_2_oop),
16038 TEST_CASE_ST(ut_setup, ut_teardown,
16039 test_kasumi_auth_cipher_test_case_2_sgl),
16040 TEST_CASE_ST(ut_setup, ut_teardown,
16041 test_kasumi_auth_cipher_test_case_2_oop_sgl),
16043 /** KASUMI decrypt (F8), then verify auth */
16044 TEST_CASE_ST(ut_setup, ut_teardown,
16045 test_kasumi_auth_cipher_verify_test_case_1),
16046 TEST_CASE_ST(ut_setup, ut_teardown,
16047 test_kasumi_auth_cipher_verify_test_case_2),
16048 TEST_CASE_ST(ut_setup, ut_teardown,
16049 test_kasumi_auth_cipher_verify_test_case_2_oop),
16050 TEST_CASE_ST(ut_setup, ut_teardown,
16051 test_kasumi_auth_cipher_verify_test_case_2_sgl),
16052 TEST_CASE_ST(ut_setup, ut_teardown,
16053 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
16059 static struct unit_test_suite cryptodev_esn_testsuite = {
16060 .suite_name = "ESN Test Suite",
16061 .setup = esn_testsuite_setup,
16062 .unit_test_cases = {
16063 TEST_CASE_ST(ut_setup, ut_teardown,
16064 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
16065 TEST_CASE_ST(ut_setup, ut_teardown,
16066 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
16071 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
16072 .suite_name = "Negative AES GCM Test Suite",
16073 .setup = negative_aes_gcm_testsuite_setup,
16074 .unit_test_cases = {
16075 TEST_CASE_ST(ut_setup, ut_teardown,
16076 test_AES_GCM_auth_encryption_fail_iv_corrupt),
16077 TEST_CASE_ST(ut_setup, ut_teardown,
16078 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
16079 TEST_CASE_ST(ut_setup, ut_teardown,
16080 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
16081 TEST_CASE_ST(ut_setup, ut_teardown,
16082 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
16083 TEST_CASE_ST(ut_setup, ut_teardown,
16084 test_AES_GCM_auth_encryption_fail_aad_corrupt),
16085 TEST_CASE_ST(ut_setup, ut_teardown,
16086 test_AES_GCM_auth_encryption_fail_tag_corrupt),
16087 TEST_CASE_ST(ut_setup, ut_teardown,
16088 test_AES_GCM_auth_decryption_fail_iv_corrupt),
16089 TEST_CASE_ST(ut_setup, ut_teardown,
16090 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
16091 TEST_CASE_ST(ut_setup, ut_teardown,
16092 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
16093 TEST_CASE_ST(ut_setup, ut_teardown,
16094 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
16095 TEST_CASE_ST(ut_setup, ut_teardown,
16096 test_AES_GCM_auth_decryption_fail_aad_corrupt),
16097 TEST_CASE_ST(ut_setup, ut_teardown,
16098 test_AES_GCM_auth_decryption_fail_tag_corrupt),
16104 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
16105 .suite_name = "Negative AES GMAC Test Suite",
16106 .setup = negative_aes_gmac_testsuite_setup,
16107 .unit_test_cases = {
16108 TEST_CASE_ST(ut_setup, ut_teardown,
16109 authentication_verify_AES128_GMAC_fail_data_corrupt),
16110 TEST_CASE_ST(ut_setup, ut_teardown,
16111 authentication_verify_AES128_GMAC_fail_tag_corrupt),
16117 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
16118 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
16119 .setup = mixed_cipher_hash_testsuite_setup,
16120 .unit_test_cases = {
16121 /** AUTH AES CMAC + CIPHER AES CTR */
16122 TEST_CASE_ST(ut_setup, ut_teardown,
16123 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
16124 TEST_CASE_ST(ut_setup, ut_teardown,
16125 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
16126 TEST_CASE_ST(ut_setup, ut_teardown,
16127 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
16128 TEST_CASE_ST(ut_setup, ut_teardown,
16129 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
16130 TEST_CASE_ST(ut_setup, ut_teardown,
16131 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
16132 TEST_CASE_ST(ut_setup, ut_teardown,
16133 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
16134 TEST_CASE_ST(ut_setup, ut_teardown,
16135 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
16136 TEST_CASE_ST(ut_setup, ut_teardown,
16137 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
16139 /** AUTH ZUC + CIPHER SNOW3G */
16140 TEST_CASE_ST(ut_setup, ut_teardown,
16141 test_auth_zuc_cipher_snow_test_case_1),
16142 TEST_CASE_ST(ut_setup, ut_teardown,
16143 test_verify_auth_zuc_cipher_snow_test_case_1),
16144 /** AUTH AES CMAC + CIPHER SNOW3G */
16145 TEST_CASE_ST(ut_setup, ut_teardown,
16146 test_auth_aes_cmac_cipher_snow_test_case_1),
16147 TEST_CASE_ST(ut_setup, ut_teardown,
16148 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
16149 /** AUTH ZUC + CIPHER AES CTR */
16150 TEST_CASE_ST(ut_setup, ut_teardown,
16151 test_auth_zuc_cipher_aes_ctr_test_case_1),
16152 TEST_CASE_ST(ut_setup, ut_teardown,
16153 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
16154 /** AUTH SNOW3G + CIPHER AES CTR */
16155 TEST_CASE_ST(ut_setup, ut_teardown,
16156 test_auth_snow_cipher_aes_ctr_test_case_1),
16157 TEST_CASE_ST(ut_setup, ut_teardown,
16158 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
16159 /** AUTH SNOW3G + CIPHER ZUC */
16160 TEST_CASE_ST(ut_setup, ut_teardown,
16161 test_auth_snow_cipher_zuc_test_case_1),
16162 TEST_CASE_ST(ut_setup, ut_teardown,
16163 test_verify_auth_snow_cipher_zuc_test_case_1),
16164 /** AUTH AES CMAC + CIPHER ZUC */
16165 TEST_CASE_ST(ut_setup, ut_teardown,
16166 test_auth_aes_cmac_cipher_zuc_test_case_1),
16167 TEST_CASE_ST(ut_setup, ut_teardown,
16168 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
16170 /** AUTH NULL + CIPHER SNOW3G */
16171 TEST_CASE_ST(ut_setup, ut_teardown,
16172 test_auth_null_cipher_snow_test_case_1),
16173 TEST_CASE_ST(ut_setup, ut_teardown,
16174 test_verify_auth_null_cipher_snow_test_case_1),
16175 /** AUTH NULL + CIPHER ZUC */
16176 TEST_CASE_ST(ut_setup, ut_teardown,
16177 test_auth_null_cipher_zuc_test_case_1),
16178 TEST_CASE_ST(ut_setup, ut_teardown,
16179 test_verify_auth_null_cipher_zuc_test_case_1),
16180 /** AUTH SNOW3G + CIPHER NULL */
16181 TEST_CASE_ST(ut_setup, ut_teardown,
16182 test_auth_snow_cipher_null_test_case_1),
16183 TEST_CASE_ST(ut_setup, ut_teardown,
16184 test_verify_auth_snow_cipher_null_test_case_1),
16185 /** AUTH ZUC + CIPHER NULL */
16186 TEST_CASE_ST(ut_setup, ut_teardown,
16187 test_auth_zuc_cipher_null_test_case_1),
16188 TEST_CASE_ST(ut_setup, ut_teardown,
16189 test_verify_auth_zuc_cipher_null_test_case_1),
16190 /** AUTH NULL + CIPHER AES CTR */
16191 TEST_CASE_ST(ut_setup, ut_teardown,
16192 test_auth_null_cipher_aes_ctr_test_case_1),
16193 TEST_CASE_ST(ut_setup, ut_teardown,
16194 test_verify_auth_null_cipher_aes_ctr_test_case_1),
16195 /** AUTH AES CMAC + CIPHER NULL */
16196 TEST_CASE_ST(ut_setup, ut_teardown,
16197 test_auth_aes_cmac_cipher_null_test_case_1),
16198 TEST_CASE_ST(ut_setup, ut_teardown,
16199 test_verify_auth_aes_cmac_cipher_null_test_case_1),
16205 run_cryptodev_testsuite(const char *pmd_name)
16207 uint8_t ret, j, i = 0, blk_start_idx = 0;
16208 const enum blockcipher_test_type blk_suites[] = {
16209 BLKCIPHER_AES_CHAIN_TYPE,
16210 BLKCIPHER_AES_CIPHERONLY_TYPE,
16211 BLKCIPHER_AES_DOCSIS_TYPE,
16212 BLKCIPHER_3DES_CHAIN_TYPE,
16213 BLKCIPHER_3DES_CIPHERONLY_TYPE,
16214 BLKCIPHER_DES_CIPHERONLY_TYPE,
16215 BLKCIPHER_DES_DOCSIS_TYPE,
16216 BLKCIPHER_AUTHONLY_TYPE};
16217 struct unit_test_suite *static_suites[] = {
16218 &cryptodev_multi_session_testsuite,
16219 &cryptodev_null_testsuite,
16220 &cryptodev_aes_ccm_auth_testsuite,
16221 &cryptodev_aes_gcm_auth_testsuite,
16222 &cryptodev_aes_gmac_auth_testsuite,
16223 &cryptodev_snow3g_testsuite,
16224 &cryptodev_chacha20_poly1305_testsuite,
16225 &cryptodev_zuc_testsuite,
16226 &cryptodev_hmac_md5_auth_testsuite,
16227 &cryptodev_kasumi_testsuite,
16228 &cryptodev_esn_testsuite,
16229 &cryptodev_negative_aes_gcm_testsuite,
16230 &cryptodev_negative_aes_gmac_testsuite,
16231 &cryptodev_mixed_cipher_hash_testsuite,
16232 &cryptodev_negative_hmac_sha1_testsuite,
16233 &cryptodev_gen_testsuite,
16234 #ifdef RTE_LIB_SECURITY
16235 &ipsec_proto_testsuite,
16236 &pdcp_proto_testsuite,
16237 &docsis_proto_testsuite,
16241 static struct unit_test_suite ts = {
16242 .suite_name = "Cryptodev Unit Test Suite",
16243 .setup = testsuite_setup,
16244 .teardown = testsuite_teardown,
16245 .unit_test_cases = {TEST_CASES_END()}
16248 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
16250 if (gbl_driver_id == -1) {
16251 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
16252 return TEST_SKIPPED;
16255 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
16256 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
16258 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
16259 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
16260 ret = unit_test_suite_runner(&ts);
16262 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
16263 free(ts.unit_test_suites);
16268 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
16270 struct rte_cryptodev_info dev_info;
16271 uint8_t i, nb_devs;
16274 driver_id = rte_cryptodev_driver_id_get(pmd_name);
16275 if (driver_id == -1) {
16276 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
16277 return TEST_SKIPPED;
16280 nb_devs = rte_cryptodev_count();
16282 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
16283 return TEST_SKIPPED;
16286 for (i = 0; i < nb_devs; i++) {
16287 rte_cryptodev_info_get(i, &dev_info);
16288 if (dev_info.driver_id == driver_id) {
16289 if (!(dev_info.feature_flags & flag)) {
16290 RTE_LOG(INFO, USER1, "%s not supported\n",
16292 return TEST_SKIPPED;
16294 return 0; /* found */
16298 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
16299 return TEST_SKIPPED;
16303 test_cryptodev_qat(void)
16305 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
16309 test_cryptodev_virtio(void)
16311 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
16315 test_cryptodev_aesni_mb(void)
16317 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16321 test_cryptodev_cpu_aesni_mb(void)
16324 enum rte_security_session_action_type at = gbl_action_type;
16325 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
16326 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16327 gbl_action_type = at;
16332 test_cryptodev_chacha_poly_mb(void)
16335 enum rte_security_session_action_type at = gbl_action_type;
16336 rc = run_cryptodev_testsuite(
16337 RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
16338 gbl_action_type = at;
16343 test_cryptodev_openssl(void)
16345 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
16349 test_cryptodev_aesni_gcm(void)
16351 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
16355 test_cryptodev_cpu_aesni_gcm(void)
16358 enum rte_security_session_action_type at = gbl_action_type;
16359 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
16360 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
16361 gbl_action_type = at;
16366 test_cryptodev_mlx5(void)
16368 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
16372 test_cryptodev_null(void)
16374 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
16378 test_cryptodev_sw_snow3g(void)
16380 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
16384 test_cryptodev_sw_kasumi(void)
16386 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
16390 test_cryptodev_sw_zuc(void)
16392 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
16396 test_cryptodev_armv8(void)
16398 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
16402 test_cryptodev_mrvl(void)
16404 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
16407 #ifdef RTE_CRYPTO_SCHEDULER
16410 test_cryptodev_scheduler(void)
16412 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
16413 const enum blockcipher_test_type blk_suites[] = {
16414 BLKCIPHER_AES_CHAIN_TYPE,
16415 BLKCIPHER_AES_CIPHERONLY_TYPE,
16416 BLKCIPHER_AUTHONLY_TYPE
16418 static struct unit_test_suite scheduler_multicore = {
16419 .suite_name = "Scheduler Multicore Unit Test Suite",
16420 .setup = scheduler_multicore_testsuite_setup,
16421 .teardown = scheduler_mode_testsuite_teardown,
16422 .unit_test_cases = {TEST_CASES_END()}
16424 static struct unit_test_suite scheduler_round_robin = {
16425 .suite_name = "Scheduler Round Robin Unit Test Suite",
16426 .setup = scheduler_roundrobin_testsuite_setup,
16427 .teardown = scheduler_mode_testsuite_teardown,
16428 .unit_test_cases = {TEST_CASES_END()}
16430 static struct unit_test_suite scheduler_failover = {
16431 .suite_name = "Scheduler Failover Unit Test Suite",
16432 .setup = scheduler_failover_testsuite_setup,
16433 .teardown = scheduler_mode_testsuite_teardown,
16434 .unit_test_cases = {TEST_CASES_END()}
16436 static struct unit_test_suite scheduler_pkt_size_distr = {
16437 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
16438 .setup = scheduler_pkt_size_distr_testsuite_setup,
16439 .teardown = scheduler_mode_testsuite_teardown,
16440 .unit_test_cases = {TEST_CASES_END()}
16442 struct unit_test_suite *sched_mode_suites[] = {
16443 &scheduler_multicore,
16444 &scheduler_round_robin,
16445 &scheduler_failover,
16446 &scheduler_pkt_size_distr
16448 static struct unit_test_suite scheduler_config = {
16449 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
16450 .unit_test_cases = {
16451 TEST_CASE(test_scheduler_attach_worker_op),
16452 TEST_CASE(test_scheduler_mode_multicore_op),
16453 TEST_CASE(test_scheduler_mode_roundrobin_op),
16454 TEST_CASE(test_scheduler_mode_failover_op),
16455 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
16456 TEST_CASE(test_scheduler_detach_worker_op),
16458 TEST_CASES_END() /**< NULL terminate array */
16461 struct unit_test_suite *static_suites[] = {
16465 static struct unit_test_suite ts = {
16466 .suite_name = "Scheduler Unit Test Suite",
16467 .setup = scheduler_testsuite_setup,
16468 .teardown = testsuite_teardown,
16469 .unit_test_cases = {TEST_CASES_END()}
16472 gbl_driver_id = rte_cryptodev_driver_id_get(
16473 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16475 if (gbl_driver_id == -1) {
16476 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
16477 return TEST_SKIPPED;
16480 if (rte_cryptodev_driver_id_get(
16481 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
16482 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
16483 return TEST_SKIPPED;
16486 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
16488 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
16489 (struct unit_test_suite *) *
16490 (RTE_DIM(blk_suites) + 1));
16491 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
16492 blk_suites, RTE_DIM(blk_suites));
16493 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
16496 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
16497 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
16498 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
16499 RTE_DIM(sched_mode_suites));
16500 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
16501 ret = unit_test_suite_runner(&ts);
16503 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
16504 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
16505 (*sched_mode_suites[sched_i]),
16506 RTE_DIM(blk_suites));
16507 free(sched_mode_suites[sched_i]->unit_test_suites);
16509 free(ts.unit_test_suites);
16513 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
16518 test_cryptodev_dpaa2_sec(void)
16520 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
16524 test_cryptodev_dpaa_sec(void)
16526 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
16530 test_cryptodev_ccp(void)
16532 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
16536 test_cryptodev_octeontx(void)
16538 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
16542 test_cryptodev_caam_jr(void)
16544 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
16548 test_cryptodev_nitrox(void)
16550 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
16554 test_cryptodev_bcmfs(void)
16556 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
16560 test_cryptodev_qat_raw_api(void)
16562 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
16565 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16570 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16571 ret = run_cryptodev_testsuite(pmd_name);
16572 global_api_test_type = CRYPTODEV_API_TEST;
16578 test_cryptodev_cn9k(void)
16580 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
16584 test_cryptodev_cn10k(void)
16586 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
16590 test_cryptodev_dpaa2_sec_raw_api(void)
16592 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16595 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16600 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16601 ret = run_cryptodev_testsuite(pmd_name);
16602 global_api_test_type = CRYPTODEV_API_TEST;
16608 test_cryptodev_dpaa_sec_raw_api(void)
16610 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD);
16613 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16618 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16619 ret = run_cryptodev_testsuite(pmd_name);
16620 global_api_test_type = CRYPTODEV_API_TEST;
16625 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
16626 test_cryptodev_dpaa2_sec_raw_api);
16627 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
16628 test_cryptodev_dpaa_sec_raw_api);
16629 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
16630 test_cryptodev_qat_raw_api);
16631 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
16632 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
16633 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
16634 test_cryptodev_cpu_aesni_mb);
16635 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
16636 test_cryptodev_chacha_poly_mb);
16637 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
16638 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
16639 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
16640 test_cryptodev_cpu_aesni_gcm);
16641 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
16642 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
16643 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
16644 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
16645 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
16646 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
16647 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
16648 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
16649 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
16650 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
16651 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
16652 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
16653 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
16654 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
16655 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
16656 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
16657 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);