1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
19 #include <rte_cryptodev_pmd.h>
20 #include <rte_string_fns.h>
22 #ifdef RTE_CRYPTO_SCHEDULER
23 #include <rte_cryptodev_scheduler.h>
24 #include <rte_cryptodev_scheduler_operations.h>
27 #include <rte_lcore.h>
30 #include "test_cryptodev.h"
32 #include "test_cryptodev_blockcipher.h"
33 #include "test_cryptodev_aes_test_vectors.h"
34 #include "test_cryptodev_des_test_vectors.h"
35 #include "test_cryptodev_hash_test_vectors.h"
36 #include "test_cryptodev_kasumi_test_vectors.h"
37 #include "test_cryptodev_kasumi_hash_test_vectors.h"
38 #include "test_cryptodev_snow3g_test_vectors.h"
39 #include "test_cryptodev_snow3g_hash_test_vectors.h"
40 #include "test_cryptodev_zuc_test_vectors.h"
41 #include "test_cryptodev_aead_test_vectors.h"
42 #include "test_cryptodev_hmac_test_vectors.h"
43 #include "test_cryptodev_mixed_test_vectors.h"
44 #ifdef RTE_LIB_SECURITY
45 #include "test_cryptodev_security_pdcp_test_vectors.h"
46 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
47 #include "test_cryptodev_security_pdcp_test_func.h"
48 #include "test_cryptodev_security_docsis_test_vectors.h"
50 #define SDAP_DISABLED 0
51 #define SDAP_ENABLED 1
54 #define VDEV_ARGS_SIZE 100
55 #define MAX_NB_SESSIONS 4
57 #define MAX_DRV_SERVICE_CTX_SIZE 256
59 #define MAX_RAW_DEQUEUE_COUNT 65535
62 #define OUT_OF_PLACE 1
64 static int gbl_driver_id;
66 static enum rte_security_session_action_type gbl_action_type =
67 RTE_SECURITY_ACTION_TYPE_NONE;
69 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
74 struct rte_crypto_sym_xform aead_xform;
75 #ifdef RTE_LIB_SECURITY
76 struct rte_security_docsis_xform docsis_xform;
80 struct rte_cryptodev_sym_session *sess;
81 #ifdef RTE_LIB_SECURITY
82 struct rte_security_session *sec_session;
85 #ifdef RTE_LIB_SECURITY
86 enum rte_security_session_action_type type;
88 struct rte_crypto_op *op;
90 struct rte_mbuf *obuf, *ibuf;
95 #define ALIGN_POW2_ROUNDUP(num, align) \
96 (((num) + (align) - 1) & ~((align) - 1))
98 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
99 for (j = 0; j < num_child_ts; index++, j++) \
100 parent_ts.unit_test_suites[index] = child_ts[j]
102 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
103 for (j = 0; j < num_blk_types; index++, j++) \
104 parent_ts.unit_test_suites[index] = \
105 build_blockcipher_test_suite(blk_types[j])
107 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
108 for (j = index; j < index + num_blk_types; j++) \
109 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
112 * Forward declarations.
115 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
116 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
120 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
121 struct crypto_unittest_params *ut_params,
122 struct crypto_testsuite_params *ts_param,
123 const uint8_t *cipher,
124 const uint8_t *digest,
127 static struct rte_mbuf *
128 setup_test_string(struct rte_mempool *mpool,
129 const char *string, size_t len, uint8_t blocksize)
131 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
132 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
137 memset(m->buf_addr, 0, m->buf_len);
138 dst = rte_pktmbuf_append(m, t_len);
144 rte_memcpy(dst, string, t_len);
146 memset(dst, 0, t_len);
152 /* Get number of bytes in X bits (rounding up) */
154 ceil_byte_length(uint32_t num_bits)
157 return ((num_bits >> 3) + 1);
159 return (num_bits >> 3);
163 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
164 uint8_t is_op_success)
166 struct rte_crypto_op *op = user_data;
167 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
168 RTE_CRYPTO_OP_STATUS_ERROR;
172 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
173 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
174 uint8_t len_in_bits, uint8_t cipher_iv_len)
176 struct rte_crypto_sym_op *sop = op->sym;
177 struct rte_crypto_op *ret_op = NULL;
178 struct rte_crypto_vec data_vec[UINT8_MAX];
179 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
180 union rte_crypto_sym_ofs ofs;
181 struct rte_crypto_sym_vec vec;
182 struct rte_crypto_sgl sgl;
184 union rte_cryptodev_session_ctx sess;
186 struct rte_crypto_raw_dp_ctx *ctx;
187 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
191 int ctx_service_size;
193 int enqueue_status, dequeue_status;
195 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
196 if (ctx_service_size < 0) {
197 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
201 ctx = malloc(ctx_service_size);
203 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
207 /* Both are enums, setting crypto_sess will suit any session type */
208 sess.crypto_sess = op->sym->session;
210 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
211 op->sess_type, sess, 0) < 0) {
212 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
218 aad_auth_iv.iova = 0;
219 aad_auth_iv.va = NULL;
226 vec.digest = &digest;
227 vec.aad = &aad_auth_iv;
228 vec.status = &status;
232 if (is_cipher && is_auth) {
233 cipher_offset = sop->cipher.data.offset;
234 cipher_len = sop->cipher.data.length;
235 auth_offset = sop->auth.data.offset;
236 auth_len = sop->auth.data.length;
237 max_len = RTE_MAX(cipher_offset + cipher_len,
238 auth_offset + auth_len);
240 max_len = max_len >> 3;
241 cipher_offset = cipher_offset >> 3;
242 auth_offset = auth_offset >> 3;
243 cipher_len = cipher_len >> 3;
244 auth_len = auth_len >> 3;
246 ofs.ofs.cipher.head = cipher_offset;
247 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
248 ofs.ofs.auth.head = auth_offset;
249 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
250 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
251 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
252 aad_auth_iv.va = rte_crypto_op_ctod_offset(
253 op, void *, IV_OFFSET + cipher_iv_len);
254 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
256 digest.va = (void *)sop->auth.digest.data;
257 digest.iova = sop->auth.digest.phys_addr;
259 } else if (is_cipher) {
260 cipher_offset = sop->cipher.data.offset;
261 cipher_len = sop->cipher.data.length;
262 max_len = cipher_len + cipher_offset;
264 max_len = max_len >> 3;
265 cipher_offset = cipher_offset >> 3;
266 cipher_len = cipher_len >> 3;
268 ofs.ofs.cipher.head = cipher_offset;
269 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
270 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
271 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
273 } else if (is_auth) {
274 auth_offset = sop->auth.data.offset;
275 auth_len = sop->auth.data.length;
276 max_len = auth_len + auth_offset;
278 max_len = max_len >> 3;
279 auth_offset = auth_offset >> 3;
280 auth_len = auth_len >> 3;
282 ofs.ofs.auth.head = auth_offset;
283 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
284 aad_auth_iv.va = rte_crypto_op_ctod_offset(
285 op, void *, IV_OFFSET + cipher_iv_len);
286 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
288 digest.va = (void *)sop->auth.digest.data;
289 digest.iova = sop->auth.digest.phys_addr;
292 cipher_offset = sop->aead.data.offset;
293 cipher_len = sop->aead.data.length;
294 max_len = cipher_len + cipher_offset;
296 max_len = max_len >> 3;
297 cipher_offset = cipher_offset >> 3;
298 cipher_len = cipher_len >> 3;
300 ofs.ofs.cipher.head = cipher_offset;
301 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
302 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
303 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
304 aad_auth_iv.va = (void *)sop->aead.aad.data;
305 aad_auth_iv.iova = sop->aead.aad.phys_addr;
306 digest.va = (void *)sop->aead.digest.data;
307 digest.iova = sop->aead.digest.phys_addr;
310 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
311 data_vec, RTE_DIM(data_vec));
312 if (n < 0 || n > sop->m_src->nb_segs) {
313 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
319 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
320 &enqueue_status) < 1) {
321 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
325 if (enqueue_status == 0) {
326 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
328 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
331 } else if (enqueue_status < 0) {
332 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
337 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
338 n = rte_cryptodev_raw_dequeue_burst(ctx,
339 NULL, 1, post_process_raw_dp_op,
340 (void **)&ret_op, 0, &n_success,
342 if (dequeue_status < 0) {
343 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
350 if (n == 1 && dequeue_status == 0) {
351 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
352 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
357 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
358 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
359 RTE_CRYPTO_OP_STATUS_SUCCESS;
366 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
369 struct rte_crypto_sym_op *sop;
370 union rte_crypto_sym_ofs ofs;
371 struct rte_crypto_sgl sgl;
372 struct rte_crypto_sym_vec symvec;
373 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
374 struct rte_crypto_vec vec[UINT8_MAX];
378 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
379 sop->aead.data.length, vec, RTE_DIM(vec));
381 if (n < 0 || n != sop->m_src->nb_segs) {
382 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
390 symvec.digest = &digest_ptr;
391 symvec.aad = &aad_ptr;
395 /* for CPU crypto the IOVA address is not required */
396 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
397 digest_ptr.va = (void *)sop->aead.digest.data;
398 aad_ptr.va = (void *)sop->aead.aad.data;
402 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
406 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
408 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
412 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
415 struct rte_crypto_sym_op *sop;
416 union rte_crypto_sym_ofs ofs;
417 struct rte_crypto_sgl sgl;
418 struct rte_crypto_sym_vec symvec;
419 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
420 struct rte_crypto_vec vec[UINT8_MAX];
424 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
425 sop->auth.data.length, vec, RTE_DIM(vec));
427 if (n < 0 || n != sop->m_src->nb_segs) {
428 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
436 symvec.digest = &digest_ptr;
440 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
441 digest_ptr.va = (void *)sop->auth.digest.data;
444 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
445 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
446 (sop->cipher.data.offset + sop->cipher.data.length);
448 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
452 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
454 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
457 static struct rte_crypto_op *
458 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
461 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
463 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
464 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
470 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
473 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
474 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
481 static struct crypto_testsuite_params testsuite_params = { NULL };
482 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
483 static struct crypto_unittest_params unittest_params;
486 testsuite_setup(void)
488 struct crypto_testsuite_params *ts_params = &testsuite_params;
489 struct rte_cryptodev_info info;
490 uint32_t i = 0, nb_devs, dev_id;
493 memset(ts_params, 0, sizeof(*ts_params));
495 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
496 if (ts_params->mbuf_pool == NULL) {
497 /* Not already created so create */
498 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
500 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
502 if (ts_params->mbuf_pool == NULL) {
503 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
508 ts_params->large_mbuf_pool = rte_mempool_lookup(
509 "CRYPTO_LARGE_MBUFPOOL");
510 if (ts_params->large_mbuf_pool == NULL) {
511 /* Not already created so create */
512 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
513 "CRYPTO_LARGE_MBUFPOOL",
516 if (ts_params->large_mbuf_pool == NULL) {
518 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
523 ts_params->op_mpool = rte_crypto_op_pool_create(
524 "MBUF_CRYPTO_SYM_OP_POOL",
525 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
526 NUM_MBUFS, MBUF_CACHE_SIZE,
528 sizeof(struct rte_crypto_sym_xform) +
531 if (ts_params->op_mpool == NULL) {
532 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
536 nb_devs = rte_cryptodev_count();
538 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
542 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
543 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
544 rte_cryptodev_driver_name_get(gbl_driver_id));
548 /* Create list of valid crypto devs */
549 for (i = 0; i < nb_devs; i++) {
550 rte_cryptodev_info_get(i, &info);
551 if (info.driver_id == gbl_driver_id)
552 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
555 if (ts_params->valid_dev_count < 1)
558 /* Set up all the qps on the first of the valid devices found */
560 dev_id = ts_params->valid_devs[0];
562 rte_cryptodev_info_get(dev_id, &info);
564 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
565 ts_params->conf.socket_id = SOCKET_ID_ANY;
566 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
568 unsigned int session_size =
569 rte_cryptodev_sym_get_private_session_size(dev_id);
571 #ifdef RTE_LIB_SECURITY
572 unsigned int security_session_size = rte_security_session_get_size(
573 rte_cryptodev_get_sec_ctx(dev_id));
575 if (session_size < security_session_size)
576 session_size = security_session_size;
579 * Create mempool with maximum number of sessions.
581 if (info.sym.max_nb_sessions != 0 &&
582 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
583 RTE_LOG(ERR, USER1, "Device does not support "
584 "at least %u sessions\n",
589 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
590 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
592 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
593 "session mempool allocation failed");
595 ts_params->session_priv_mpool = rte_mempool_create(
599 0, 0, NULL, NULL, NULL,
602 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
603 "session mempool allocation failed");
607 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
609 "Failed to configure cryptodev %u with %u qps",
610 dev_id, ts_params->conf.nb_queue_pairs);
612 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
613 ts_params->qp_conf.mp_session = ts_params->session_mpool;
614 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
616 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
617 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
618 dev_id, qp_id, &ts_params->qp_conf,
619 rte_cryptodev_socket_id(dev_id)),
620 "Failed to setup queue pair %u on cryptodev %u",
628 testsuite_teardown(void)
630 struct crypto_testsuite_params *ts_params = &testsuite_params;
633 if (ts_params->mbuf_pool != NULL) {
634 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
635 rte_mempool_avail_count(ts_params->mbuf_pool));
638 if (ts_params->op_mpool != NULL) {
639 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
640 rte_mempool_avail_count(ts_params->op_mpool));
643 /* Free session mempools */
644 if (ts_params->session_priv_mpool != NULL) {
645 rte_mempool_free(ts_params->session_priv_mpool);
646 ts_params->session_priv_mpool = NULL;
649 if (ts_params->session_mpool != NULL) {
650 rte_mempool_free(ts_params->session_mpool);
651 ts_params->session_mpool = NULL;
654 res = rte_cryptodev_close(ts_params->valid_devs[0]);
656 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
660 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
661 const int *algs, uint16_t num_algs)
663 uint8_t dev_id = testsuite_params.valid_devs[0];
664 bool some_alg_supported = FALSE;
667 for (i = 0; i < num_algs && !some_alg_supported; i++) {
668 struct rte_cryptodev_sym_capability_idx alg = {
671 if (rte_cryptodev_sym_capability_get(dev_id,
673 some_alg_supported = TRUE;
675 if (!some_alg_supported)
682 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
683 uint16_t num_ciphers)
685 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
686 (const int *) ciphers, num_ciphers);
690 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
693 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
694 (const int *) auths, num_auths);
698 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
701 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
702 (const int *) aeads, num_aeads);
706 null_testsuite_setup(void)
708 struct crypto_testsuite_params *ts_params = &testsuite_params;
709 uint8_t dev_id = ts_params->valid_devs[0];
710 struct rte_cryptodev_info dev_info;
711 const enum rte_crypto_cipher_algorithm ciphers[] = {
712 RTE_CRYPTO_CIPHER_NULL
714 const enum rte_crypto_auth_algorithm auths[] = {
718 rte_cryptodev_info_get(dev_id, &dev_info);
720 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
721 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
722 "testsuite not met\n");
726 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
727 && check_auth_capabilities_supported(auths,
728 RTE_DIM(auths)) != 0) {
729 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
730 "testsuite not met\n");
738 crypto_gen_testsuite_setup(void)
740 struct crypto_testsuite_params *ts_params = &testsuite_params;
741 uint8_t dev_id = ts_params->valid_devs[0];
742 struct rte_cryptodev_info dev_info;
744 rte_cryptodev_info_get(dev_id, &dev_info);
746 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
747 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
748 "testsuite not met\n");
755 #ifdef RTE_LIB_SECURITY
757 pdcp_proto_testsuite_setup(void)
759 struct crypto_testsuite_params *ts_params = &testsuite_params;
760 uint8_t dev_id = ts_params->valid_devs[0];
761 struct rte_cryptodev_info dev_info;
762 const enum rte_crypto_cipher_algorithm ciphers[] = {
763 RTE_CRYPTO_CIPHER_NULL,
764 RTE_CRYPTO_CIPHER_AES_CTR,
765 RTE_CRYPTO_CIPHER_ZUC_EEA3,
766 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
768 const enum rte_crypto_auth_algorithm auths[] = {
769 RTE_CRYPTO_AUTH_NULL,
770 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
771 RTE_CRYPTO_AUTH_AES_CMAC,
772 RTE_CRYPTO_AUTH_ZUC_EIA3
775 rte_cryptodev_info_get(dev_id, &dev_info);
777 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
778 !(dev_info.feature_flags &
779 RTE_CRYPTODEV_FF_SECURITY)) {
780 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
781 "testsuite not met\n");
785 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
786 && check_auth_capabilities_supported(auths,
787 RTE_DIM(auths)) != 0) {
788 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
789 "testsuite not met\n");
797 docsis_proto_testsuite_setup(void)
799 struct crypto_testsuite_params *ts_params = &testsuite_params;
800 uint8_t dev_id = ts_params->valid_devs[0];
801 struct rte_cryptodev_info dev_info;
802 const enum rte_crypto_cipher_algorithm ciphers[] = {
803 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
806 rte_cryptodev_info_get(dev_id, &dev_info);
808 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
809 !(dev_info.feature_flags &
810 RTE_CRYPTODEV_FF_SECURITY)) {
811 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
812 "Proto testsuite not met\n");
816 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
817 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
818 "testsuite not met\n");
827 aes_ccm_auth_testsuite_setup(void)
829 struct crypto_testsuite_params *ts_params = &testsuite_params;
830 uint8_t dev_id = ts_params->valid_devs[0];
831 struct rte_cryptodev_info dev_info;
832 const enum rte_crypto_aead_algorithm aeads[] = {
833 RTE_CRYPTO_AEAD_AES_CCM
836 rte_cryptodev_info_get(dev_id, &dev_info);
838 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
839 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
840 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
841 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
842 "testsuite not met\n");
846 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
847 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
848 "testsuite not met\n");
856 aes_gcm_auth_testsuite_setup(void)
858 struct crypto_testsuite_params *ts_params = &testsuite_params;
859 uint8_t dev_id = ts_params->valid_devs[0];
860 struct rte_cryptodev_info dev_info;
861 const enum rte_crypto_aead_algorithm aeads[] = {
862 RTE_CRYPTO_AEAD_AES_GCM
865 rte_cryptodev_info_get(dev_id, &dev_info);
867 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
868 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
869 "testsuite not met\n");
873 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
874 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
875 "testsuite not met\n");
883 aes_gmac_auth_testsuite_setup(void)
885 struct crypto_testsuite_params *ts_params = &testsuite_params;
886 uint8_t dev_id = ts_params->valid_devs[0];
887 struct rte_cryptodev_info dev_info;
888 const enum rte_crypto_auth_algorithm auths[] = {
889 RTE_CRYPTO_AUTH_AES_GMAC
892 rte_cryptodev_info_get(dev_id, &dev_info);
894 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
895 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
896 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
897 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
898 "testsuite not met\n");
902 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
903 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
904 "testsuite not met\n");
912 chacha20_poly1305_testsuite_setup(void)
914 struct crypto_testsuite_params *ts_params = &testsuite_params;
915 uint8_t dev_id = ts_params->valid_devs[0];
916 struct rte_cryptodev_info dev_info;
917 const enum rte_crypto_aead_algorithm aeads[] = {
918 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
921 rte_cryptodev_info_get(dev_id, &dev_info);
923 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
924 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
925 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
926 RTE_LOG(INFO, USER1, "Feature flag requirements for "
927 "Chacha20-Poly1305 testsuite not met\n");
931 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
932 RTE_LOG(INFO, USER1, "Capability requirements for "
933 "Chacha20-Poly1305 testsuite not met\n");
941 snow3g_testsuite_setup(void)
943 struct crypto_testsuite_params *ts_params = &testsuite_params;
944 uint8_t dev_id = ts_params->valid_devs[0];
945 struct rte_cryptodev_info dev_info;
946 const enum rte_crypto_cipher_algorithm ciphers[] = {
947 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
950 const enum rte_crypto_auth_algorithm auths[] = {
951 RTE_CRYPTO_AUTH_SNOW3G_UIA2
954 rte_cryptodev_info_get(dev_id, &dev_info);
956 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
957 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
958 "testsuite not met\n");
962 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
963 && check_auth_capabilities_supported(auths,
964 RTE_DIM(auths)) != 0) {
965 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
966 "testsuite not met\n");
974 zuc_testsuite_setup(void)
976 struct crypto_testsuite_params *ts_params = &testsuite_params;
977 uint8_t dev_id = ts_params->valid_devs[0];
978 struct rte_cryptodev_info dev_info;
979 const enum rte_crypto_cipher_algorithm ciphers[] = {
980 RTE_CRYPTO_CIPHER_ZUC_EEA3
982 const enum rte_crypto_auth_algorithm auths[] = {
983 RTE_CRYPTO_AUTH_ZUC_EIA3
986 rte_cryptodev_info_get(dev_id, &dev_info);
988 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
989 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
990 "testsuite not met\n");
994 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
995 && check_auth_capabilities_supported(auths,
996 RTE_DIM(auths)) != 0) {
997 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
998 "testsuite not met\n");
1006 hmac_md5_auth_testsuite_setup(void)
1008 struct crypto_testsuite_params *ts_params = &testsuite_params;
1009 uint8_t dev_id = ts_params->valid_devs[0];
1010 struct rte_cryptodev_info dev_info;
1011 const enum rte_crypto_auth_algorithm auths[] = {
1012 RTE_CRYPTO_AUTH_MD5_HMAC
1015 rte_cryptodev_info_get(dev_id, &dev_info);
1017 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1018 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1019 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1020 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1021 "Auth testsuite not met\n");
1022 return TEST_SKIPPED;
1025 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1026 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1027 "testsuite not met\n");
1028 return TEST_SKIPPED;
1035 kasumi_testsuite_setup(void)
1037 struct crypto_testsuite_params *ts_params = &testsuite_params;
1038 uint8_t dev_id = ts_params->valid_devs[0];
1039 struct rte_cryptodev_info dev_info;
1040 const enum rte_crypto_cipher_algorithm ciphers[] = {
1041 RTE_CRYPTO_CIPHER_KASUMI_F8
1043 const enum rte_crypto_auth_algorithm auths[] = {
1044 RTE_CRYPTO_AUTH_KASUMI_F9
1047 rte_cryptodev_info_get(dev_id, &dev_info);
1049 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1050 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1051 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1052 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1053 "testsuite not met\n");
1054 return TEST_SKIPPED;
1057 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1058 && check_auth_capabilities_supported(auths,
1059 RTE_DIM(auths)) != 0) {
1060 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1061 "testsuite not met\n");
1062 return TEST_SKIPPED;
1069 negative_aes_gcm_testsuite_setup(void)
1071 struct crypto_testsuite_params *ts_params = &testsuite_params;
1072 uint8_t dev_id = ts_params->valid_devs[0];
1073 struct rte_cryptodev_info dev_info;
1074 const enum rte_crypto_aead_algorithm aeads[] = {
1075 RTE_CRYPTO_AEAD_AES_GCM
1078 rte_cryptodev_info_get(dev_id, &dev_info);
1080 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1081 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1082 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1083 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1084 "AES GCM testsuite not met\n");
1085 return TEST_SKIPPED;
1088 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1089 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1090 "AES GCM testsuite not met\n");
1091 return TEST_SKIPPED;
1098 negative_aes_gmac_testsuite_setup(void)
1100 struct crypto_testsuite_params *ts_params = &testsuite_params;
1101 uint8_t dev_id = ts_params->valid_devs[0];
1102 struct rte_cryptodev_info dev_info;
1103 const enum rte_crypto_auth_algorithm auths[] = {
1104 RTE_CRYPTO_AUTH_AES_GMAC
1107 rte_cryptodev_info_get(dev_id, &dev_info);
1109 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1110 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1111 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1112 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1113 "AES GMAC testsuite not met\n");
1114 return TEST_SKIPPED;
1117 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1118 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1119 "AES GMAC testsuite not met\n");
1120 return TEST_SKIPPED;
1127 mixed_cipher_hash_testsuite_setup(void)
1129 struct crypto_testsuite_params *ts_params = &testsuite_params;
1130 uint8_t dev_id = ts_params->valid_devs[0];
1131 struct rte_cryptodev_info dev_info;
1132 uint64_t feat_flags;
1133 const enum rte_crypto_cipher_algorithm ciphers[] = {
1134 RTE_CRYPTO_CIPHER_NULL,
1135 RTE_CRYPTO_CIPHER_AES_CTR,
1136 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1137 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1139 const enum rte_crypto_auth_algorithm auths[] = {
1140 RTE_CRYPTO_AUTH_NULL,
1141 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1142 RTE_CRYPTO_AUTH_AES_CMAC,
1143 RTE_CRYPTO_AUTH_ZUC_EIA3
1146 rte_cryptodev_info_get(dev_id, &dev_info);
1147 feat_flags = dev_info.feature_flags;
1149 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1150 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1151 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1152 "Cipher Hash testsuite not met\n");
1153 return TEST_SKIPPED;
1156 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1157 && check_auth_capabilities_supported(auths,
1158 RTE_DIM(auths)) != 0) {
1159 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1160 "Cipher Hash testsuite not met\n");
1161 return TEST_SKIPPED;
1168 esn_testsuite_setup(void)
1170 struct crypto_testsuite_params *ts_params = &testsuite_params;
1171 uint8_t dev_id = ts_params->valid_devs[0];
1172 struct rte_cryptodev_info dev_info;
1173 const enum rte_crypto_cipher_algorithm ciphers[] = {
1174 RTE_CRYPTO_CIPHER_AES_CBC
1176 const enum rte_crypto_auth_algorithm auths[] = {
1177 RTE_CRYPTO_AUTH_SHA1_HMAC
1180 rte_cryptodev_info_get(dev_id, &dev_info);
1182 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1183 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1184 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1185 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1186 "testsuite not met\n");
1187 return TEST_SKIPPED;
1190 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1191 && check_auth_capabilities_supported(auths,
1192 RTE_DIM(auths)) != 0) {
1193 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1194 "testsuite not met\n");
1195 return TEST_SKIPPED;
1202 multi_session_testsuite_setup(void)
1204 struct crypto_testsuite_params *ts_params = &testsuite_params;
1205 uint8_t dev_id = ts_params->valid_devs[0];
1206 struct rte_cryptodev_info dev_info;
1207 const enum rte_crypto_cipher_algorithm ciphers[] = {
1208 RTE_CRYPTO_CIPHER_AES_CBC
1210 const enum rte_crypto_auth_algorithm auths[] = {
1211 RTE_CRYPTO_AUTH_SHA512_HMAC
1214 rte_cryptodev_info_get(dev_id, &dev_info);
1216 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1217 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1218 "Session testsuite not met\n");
1219 return TEST_SKIPPED;
1222 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1223 && check_auth_capabilities_supported(auths,
1224 RTE_DIM(auths)) != 0) {
1225 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1226 "Session testsuite not met\n");
1227 return TEST_SKIPPED;
1234 negative_hmac_sha1_testsuite_setup(void)
1236 struct crypto_testsuite_params *ts_params = &testsuite_params;
1237 uint8_t dev_id = ts_params->valid_devs[0];
1238 struct rte_cryptodev_info dev_info;
1239 const enum rte_crypto_cipher_algorithm ciphers[] = {
1240 RTE_CRYPTO_CIPHER_AES_CBC
1242 const enum rte_crypto_auth_algorithm auths[] = {
1243 RTE_CRYPTO_AUTH_SHA1_HMAC
1246 rte_cryptodev_info_get(dev_id, &dev_info);
1248 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1249 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1250 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1251 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1252 "HMAC SHA1 testsuite not met\n");
1253 return TEST_SKIPPED;
1256 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1257 && check_auth_capabilities_supported(auths,
1258 RTE_DIM(auths)) != 0) {
1259 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1260 "HMAC SHA1 testsuite not met\n");
1261 return TEST_SKIPPED;
1268 dev_configure_and_start(uint64_t ff_disable)
1270 struct crypto_testsuite_params *ts_params = &testsuite_params;
1271 struct crypto_unittest_params *ut_params = &unittest_params;
1275 /* Clear unit test parameters before running test */
1276 memset(ut_params, 0, sizeof(*ut_params));
1278 /* Reconfigure device to default parameters */
1279 ts_params->conf.socket_id = SOCKET_ID_ANY;
1280 ts_params->conf.ff_disable = ff_disable;
1281 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1282 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1283 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1285 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1287 "Failed to configure cryptodev %u",
1288 ts_params->valid_devs[0]);
1290 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1291 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1292 ts_params->valid_devs[0], qp_id,
1293 &ts_params->qp_conf,
1294 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1295 "Failed to setup queue pair %u on cryptodev %u",
1296 qp_id, ts_params->valid_devs[0]);
1300 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1302 /* Start the device */
1303 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1304 "Failed to start cryptodev %u",
1305 ts_params->valid_devs[0]);
1307 return TEST_SUCCESS;
1313 /* Configure and start the device with security feature disabled */
1314 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1318 ut_setup_security(void)
1320 /* Configure and start the device with no features disabled */
1321 return dev_configure_and_start(0);
1327 struct crypto_testsuite_params *ts_params = &testsuite_params;
1328 struct crypto_unittest_params *ut_params = &unittest_params;
1329 struct rte_cryptodev_stats stats;
1331 /* free crypto session structure */
1332 #ifdef RTE_LIB_SECURITY
1333 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1334 if (ut_params->sec_session) {
1335 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1336 (ts_params->valid_devs[0]),
1337 ut_params->sec_session);
1338 ut_params->sec_session = NULL;
1343 if (ut_params->sess) {
1344 rte_cryptodev_sym_session_clear(
1345 ts_params->valid_devs[0],
1347 rte_cryptodev_sym_session_free(ut_params->sess);
1348 ut_params->sess = NULL;
1352 /* free crypto operation structure */
1354 rte_crypto_op_free(ut_params->op);
1357 * free mbuf - both obuf and ibuf are usually the same,
1358 * so check if they point at the same address is necessary,
1359 * to avoid freeing the mbuf twice.
1361 if (ut_params->obuf) {
1362 rte_pktmbuf_free(ut_params->obuf);
1363 if (ut_params->ibuf == ut_params->obuf)
1364 ut_params->ibuf = 0;
1365 ut_params->obuf = 0;
1367 if (ut_params->ibuf) {
1368 rte_pktmbuf_free(ut_params->ibuf);
1369 ut_params->ibuf = 0;
1372 if (ts_params->mbuf_pool != NULL)
1373 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1374 rte_mempool_avail_count(ts_params->mbuf_pool));
1376 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1378 /* Stop the device */
1379 rte_cryptodev_stop(ts_params->valid_devs[0]);
1383 test_device_configure_invalid_dev_id(void)
1385 struct crypto_testsuite_params *ts_params = &testsuite_params;
1386 uint16_t dev_id, num_devs = 0;
1388 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1389 "Need at least %d devices for test", 1);
1391 /* valid dev_id values */
1392 dev_id = ts_params->valid_devs[0];
1394 /* Stop the device in case it's started so it can be configured */
1395 rte_cryptodev_stop(dev_id);
1397 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1398 "Failed test for rte_cryptodev_configure: "
1399 "invalid dev_num %u", dev_id);
1401 /* invalid dev_id values */
1404 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1405 "Failed test for rte_cryptodev_configure: "
1406 "invalid dev_num %u", dev_id);
1410 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1411 "Failed test for rte_cryptodev_configure:"
1412 "invalid dev_num %u", dev_id);
1414 return TEST_SUCCESS;
1418 test_device_configure_invalid_queue_pair_ids(void)
1420 struct crypto_testsuite_params *ts_params = &testsuite_params;
1421 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1423 /* Stop the device in case it's started so it can be configured */
1424 rte_cryptodev_stop(ts_params->valid_devs[0]);
1426 /* valid - max value queue pairs */
1427 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1429 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1431 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1432 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1434 /* valid - one queue pairs */
1435 ts_params->conf.nb_queue_pairs = 1;
1437 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1439 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1440 ts_params->valid_devs[0],
1441 ts_params->conf.nb_queue_pairs);
1444 /* invalid - zero queue pairs */
1445 ts_params->conf.nb_queue_pairs = 0;
1447 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1449 "Failed test for rte_cryptodev_configure, dev_id %u,"
1451 ts_params->valid_devs[0],
1452 ts_params->conf.nb_queue_pairs);
1455 /* invalid - max value supported by field queue pairs */
1456 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1458 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1460 "Failed test for rte_cryptodev_configure, dev_id %u,"
1462 ts_params->valid_devs[0],
1463 ts_params->conf.nb_queue_pairs);
1466 /* invalid - max value + 1 queue pairs */
1467 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1469 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1471 "Failed test for rte_cryptodev_configure, dev_id %u,"
1473 ts_params->valid_devs[0],
1474 ts_params->conf.nb_queue_pairs);
1476 /* revert to original testsuite value */
1477 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1479 return TEST_SUCCESS;
1483 test_queue_pair_descriptor_setup(void)
1485 struct crypto_testsuite_params *ts_params = &testsuite_params;
1486 struct rte_cryptodev_qp_conf qp_conf = {
1487 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1491 /* Stop the device in case it's started so it can be configured */
1492 rte_cryptodev_stop(ts_params->valid_devs[0]);
1494 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1496 "Failed to configure cryptodev %u",
1497 ts_params->valid_devs[0]);
1500 * Test various ring sizes on this device. memzones can't be
1501 * freed so are re-used if ring is released and re-created.
1503 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1504 qp_conf.mp_session = ts_params->session_mpool;
1505 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1507 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1508 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1509 ts_params->valid_devs[0], qp_id, &qp_conf,
1510 rte_cryptodev_socket_id(
1511 ts_params->valid_devs[0])),
1513 "rte_cryptodev_queue_pair_setup: num_inflights "
1514 "%u on qp %u on cryptodev %u",
1515 qp_conf.nb_descriptors, qp_id,
1516 ts_params->valid_devs[0]);
1519 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1521 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1522 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1523 ts_params->valid_devs[0], qp_id, &qp_conf,
1524 rte_cryptodev_socket_id(
1525 ts_params->valid_devs[0])),
1527 " rte_cryptodev_queue_pair_setup: num_inflights"
1528 " %u on qp %u on cryptodev %u",
1529 qp_conf.nb_descriptors, qp_id,
1530 ts_params->valid_devs[0]);
1533 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1535 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1536 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1537 ts_params->valid_devs[0], qp_id, &qp_conf,
1538 rte_cryptodev_socket_id(
1539 ts_params->valid_devs[0])),
1541 "rte_cryptodev_queue_pair_setup: num_inflights"
1542 " %u on qp %u on cryptodev %u",
1543 qp_conf.nb_descriptors, qp_id,
1544 ts_params->valid_devs[0]);
1547 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1549 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1550 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1551 ts_params->valid_devs[0], qp_id, &qp_conf,
1552 rte_cryptodev_socket_id(
1553 ts_params->valid_devs[0])),
1555 " rte_cryptodev_queue_pair_setup:"
1556 "num_inflights %u on qp %u on cryptodev %u",
1557 qp_conf.nb_descriptors, qp_id,
1558 ts_params->valid_devs[0]);
1561 /* test invalid queue pair id */
1562 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1564 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1566 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1567 ts_params->valid_devs[0],
1569 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1570 "Failed test for rte_cryptodev_queue_pair_setup:"
1571 "invalid qp %u on cryptodev %u",
1572 qp_id, ts_params->valid_devs[0]);
1574 qp_id = 0xffff; /*invalid*/
1576 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1577 ts_params->valid_devs[0],
1579 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1580 "Failed test for rte_cryptodev_queue_pair_setup:"
1581 "invalid qp %u on cryptodev %u",
1582 qp_id, ts_params->valid_devs[0]);
1584 return TEST_SUCCESS;
1587 /* ***** Plaintext data for tests ***** */
1589 const char catch_22_quote_1[] =
1590 "There was only one catch and that was Catch-22, which "
1591 "specified that a concern for one's safety in the face of "
1592 "dangers that were real and immediate was the process of a "
1593 "rational mind. Orr was crazy and could be grounded. All he "
1594 "had to do was ask; and as soon as he did, he would no longer "
1595 "be crazy and would have to fly more missions. Orr would be "
1596 "crazy to fly more missions and sane if he didn't, but if he "
1597 "was sane he had to fly them. If he flew them he was crazy "
1598 "and didn't have to; but if he didn't want to he was sane and "
1599 "had to. Yossarian was moved very deeply by the absolute "
1600 "simplicity of this clause of Catch-22 and let out a "
1601 "respectful whistle. \"That's some catch, that Catch-22\", he "
1602 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1604 const char catch_22_quote[] =
1605 "What a lousy earth! He wondered how many people were "
1606 "destitute that same night even in his own prosperous country, "
1607 "how many homes were shanties, how many husbands were drunk "
1608 "and wives socked, and how many children were bullied, abused, "
1609 "or abandoned. How many families hungered for food they could "
1610 "not afford to buy? How many hearts were broken? How many "
1611 "suicides would take place that same night, how many people "
1612 "would go insane? How many cockroaches and landlords would "
1613 "triumph? How many winners were losers, successes failures, "
1614 "and rich men poor men? How many wise guys were stupid? How "
1615 "many happy endings were unhappy endings? How many honest men "
1616 "were liars, brave men cowards, loyal men traitors, how many "
1617 "sainted men were corrupt, how many people in positions of "
1618 "trust had sold their souls to bodyguards, how many had never "
1619 "had souls? How many straight-and-narrow paths were crooked "
1620 "paths? How many best families were worst families and how "
1621 "many good people were bad people? When you added them all up "
1622 "and then subtracted, you might be left with only the children, "
1623 "and perhaps with Albert Einstein and an old violinist or "
1624 "sculptor somewhere.";
1626 #define QUOTE_480_BYTES (480)
1627 #define QUOTE_512_BYTES (512)
1628 #define QUOTE_768_BYTES (768)
1629 #define QUOTE_1024_BYTES (1024)
1633 /* ***** SHA1 Hash Tests ***** */
1635 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1637 static uint8_t hmac_sha1_key[] = {
1638 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1639 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1640 0xDE, 0xF4, 0xDE, 0xAD };
1642 /* ***** SHA224 Hash Tests ***** */
1644 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1647 /* ***** AES-CBC Cipher Tests ***** */
1649 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1650 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1652 static uint8_t aes_cbc_key[] = {
1653 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1654 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1656 static uint8_t aes_cbc_iv[] = {
1657 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1658 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1661 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1663 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1664 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1665 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1666 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1667 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1668 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1669 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1670 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1671 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1672 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1673 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1674 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1675 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1676 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1677 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1678 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1679 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1680 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1681 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1682 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1683 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1684 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1685 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1686 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1687 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1688 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1689 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1690 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1691 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1692 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1693 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1694 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1695 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1696 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1697 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1698 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1699 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1700 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1701 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1702 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1703 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1704 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1705 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1706 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1707 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1708 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1709 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1710 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1711 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1712 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1713 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1714 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1715 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1716 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1717 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1718 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1719 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1720 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1721 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1722 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1723 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1724 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1725 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1726 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1727 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1730 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1731 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1732 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1733 0x18, 0x8c, 0x1d, 0x32
1737 /* Multisession Vector context Test */
1738 /*Begin Session 0 */
1739 static uint8_t ms_aes_cbc_key0[] = {
1740 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1741 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1744 static uint8_t ms_aes_cbc_iv0[] = {
1745 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1746 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1749 static const uint8_t ms_aes_cbc_cipher0[] = {
1750 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1751 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1752 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1753 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1754 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1755 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1756 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1757 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1758 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1759 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1760 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1761 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1762 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1763 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1764 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1765 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1766 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1767 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1768 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1769 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1770 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1771 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1772 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1773 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1774 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1775 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1776 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1777 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1778 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1779 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1780 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1781 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1782 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1783 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1784 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1785 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1786 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1787 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1788 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1789 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1790 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1791 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1792 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1793 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1794 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1795 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1796 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1797 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1798 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1799 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1800 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1801 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1802 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1803 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1804 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1805 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1806 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1807 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1808 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1809 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1810 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1811 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1812 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1813 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1817 static uint8_t ms_hmac_key0[] = {
1818 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1819 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1820 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1821 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1822 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1823 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1824 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1825 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1828 static const uint8_t ms_hmac_digest0[] = {
1829 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1830 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1831 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1832 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1833 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1834 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1835 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1836 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1840 /* Begin session 1 */
1842 static uint8_t ms_aes_cbc_key1[] = {
1843 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1844 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1847 static uint8_t ms_aes_cbc_iv1[] = {
1848 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1849 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1852 static const uint8_t ms_aes_cbc_cipher1[] = {
1853 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1854 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1855 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1856 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1857 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1858 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1859 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1860 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1861 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1862 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1863 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1864 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1865 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1866 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1867 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1868 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1869 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1870 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1871 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1872 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1873 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1874 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1875 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1876 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1877 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1878 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1879 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1880 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1881 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1882 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1883 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1884 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1885 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1886 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1887 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1888 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1889 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1890 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1891 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1892 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1893 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1894 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1895 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1896 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1897 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1898 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1899 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1900 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1901 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1902 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1903 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1904 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1905 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1906 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1907 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1908 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1909 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1910 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1911 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1912 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1913 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1914 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1915 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1916 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1920 static uint8_t ms_hmac_key1[] = {
1921 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1922 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1923 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1924 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1925 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1926 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1927 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1928 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1931 static const uint8_t ms_hmac_digest1[] = {
1932 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1933 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1934 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1935 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1936 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1937 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1938 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1939 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1942 /* Begin Session 2 */
1943 static uint8_t ms_aes_cbc_key2[] = {
1944 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1945 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1948 static uint8_t ms_aes_cbc_iv2[] = {
1949 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1950 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1953 static const uint8_t ms_aes_cbc_cipher2[] = {
1954 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1955 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1956 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1957 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1958 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1959 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1960 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1961 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1962 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1963 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1964 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1965 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1966 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1967 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1968 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1969 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1970 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1971 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1972 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1973 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1974 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1975 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1976 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1977 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1978 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1979 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1980 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1981 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1982 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1983 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1984 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1985 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1986 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1987 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1988 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1989 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1990 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1991 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1992 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1993 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1994 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1995 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1996 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1997 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1998 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1999 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2000 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2001 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2002 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2003 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2004 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2005 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2006 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2007 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2008 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2009 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2010 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2011 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2012 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2013 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2014 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2015 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2016 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2017 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2020 static uint8_t ms_hmac_key2[] = {
2021 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2022 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2023 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2024 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2025 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2026 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2027 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2028 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2031 static const uint8_t ms_hmac_digest2[] = {
2032 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2033 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2034 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2035 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2036 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2037 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2038 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2039 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2046 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2048 struct crypto_testsuite_params *ts_params = &testsuite_params;
2049 struct crypto_unittest_params *ut_params = &unittest_params;
2051 /* Verify the capabilities */
2052 struct rte_cryptodev_sym_capability_idx cap_idx;
2053 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2054 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2055 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2057 return TEST_SKIPPED;
2058 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2059 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2060 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2062 return TEST_SKIPPED;
2064 /* Generate test mbuf data and space for digest */
2065 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2066 catch_22_quote, QUOTE_512_BYTES, 0);
2068 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2069 DIGEST_BYTE_LENGTH_SHA1);
2070 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2072 /* Setup Cipher Parameters */
2073 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2074 ut_params->cipher_xform.next = &ut_params->auth_xform;
2076 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2077 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2078 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2079 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2080 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2081 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2083 /* Setup HMAC Parameters */
2084 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2086 ut_params->auth_xform.next = NULL;
2088 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2089 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2090 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2091 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2092 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2094 ut_params->sess = rte_cryptodev_sym_session_create(
2095 ts_params->session_mpool);
2097 /* Create crypto session*/
2098 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2099 ut_params->sess, &ut_params->cipher_xform,
2100 ts_params->session_priv_mpool);
2101 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2103 /* Generate crypto op data structure */
2104 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2105 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2106 TEST_ASSERT_NOT_NULL(ut_params->op,
2107 "Failed to allocate symmetric crypto operation struct");
2109 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2111 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2113 /* set crypto operation source mbuf */
2114 sym_op->m_src = ut_params->ibuf;
2116 /* Set crypto operation authentication parameters */
2117 sym_op->auth.digest.data = ut_params->digest;
2118 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2119 ut_params->ibuf, QUOTE_512_BYTES);
2121 sym_op->auth.data.offset = 0;
2122 sym_op->auth.data.length = QUOTE_512_BYTES;
2124 /* Copy IV at the end of the crypto operation */
2125 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2126 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2128 /* Set crypto operation cipher parameters */
2129 sym_op->cipher.data.offset = 0;
2130 sym_op->cipher.data.length = QUOTE_512_BYTES;
2132 /* Process crypto operation */
2133 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2134 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2137 TEST_ASSERT_NOT_NULL(
2138 process_crypto_request(ts_params->valid_devs[0],
2140 "failed to process sym crypto op");
2142 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2143 "crypto op processing failed");
2146 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2149 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2150 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2152 "ciphertext data not as expected");
2154 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2156 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2157 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2158 gbl_driver_id == rte_cryptodev_driver_id_get(
2159 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2160 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2161 DIGEST_BYTE_LENGTH_SHA1,
2162 "Generated digest data not as expected");
2164 return TEST_SUCCESS;
2167 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2169 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2171 static uint8_t hmac_sha512_key[] = {
2172 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2173 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2174 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2175 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2176 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2177 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2178 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2179 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2181 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2182 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2183 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2184 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2185 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2186 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2187 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2188 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2189 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2194 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2195 struct crypto_unittest_params *ut_params,
2196 uint8_t *cipher_key,
2200 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2201 struct crypto_unittest_params *ut_params,
2202 struct crypto_testsuite_params *ts_params,
2203 const uint8_t *cipher,
2204 const uint8_t *digest,
2209 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2210 struct crypto_unittest_params *ut_params,
2211 uint8_t *cipher_key,
2215 /* Setup Cipher Parameters */
2216 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2217 ut_params->cipher_xform.next = NULL;
2219 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2220 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2221 ut_params->cipher_xform.cipher.key.data = cipher_key;
2222 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2223 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2224 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2226 /* Setup HMAC Parameters */
2227 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2228 ut_params->auth_xform.next = &ut_params->cipher_xform;
2230 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2231 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2232 ut_params->auth_xform.auth.key.data = hmac_key;
2233 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2234 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2236 return TEST_SUCCESS;
2241 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2242 struct crypto_unittest_params *ut_params,
2243 struct crypto_testsuite_params *ts_params,
2244 const uint8_t *cipher,
2245 const uint8_t *digest,
2248 /* Generate test mbuf data and digest */
2249 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2252 QUOTE_512_BYTES, 0);
2254 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2255 DIGEST_BYTE_LENGTH_SHA512);
2256 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2258 rte_memcpy(ut_params->digest,
2260 DIGEST_BYTE_LENGTH_SHA512);
2262 /* Generate Crypto op data structure */
2263 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2264 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2265 TEST_ASSERT_NOT_NULL(ut_params->op,
2266 "Failed to allocate symmetric crypto operation struct");
2268 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2270 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2272 /* set crypto operation source mbuf */
2273 sym_op->m_src = ut_params->ibuf;
2275 sym_op->auth.digest.data = ut_params->digest;
2276 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2277 ut_params->ibuf, QUOTE_512_BYTES);
2279 sym_op->auth.data.offset = 0;
2280 sym_op->auth.data.length = QUOTE_512_BYTES;
2282 /* Copy IV at the end of the crypto operation */
2283 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2284 iv, CIPHER_IV_LENGTH_AES_CBC);
2286 sym_op->cipher.data.offset = 0;
2287 sym_op->cipher.data.length = QUOTE_512_BYTES;
2289 /* Process crypto operation */
2290 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2291 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2293 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2294 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2295 ut_params->op, 1, 1, 0, 0);
2297 TEST_ASSERT_NOT_NULL(
2298 process_crypto_request(ts_params->valid_devs[0],
2300 "failed to process sym crypto op");
2302 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2303 "crypto op processing failed");
2305 ut_params->obuf = ut_params->op->sym->m_src;
2308 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2309 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2312 "Plaintext data not as expected");
2315 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2316 "Digest verification failed");
2318 return TEST_SUCCESS;
2321 /* ***** SNOW 3G Tests ***** */
2323 create_wireless_algo_hash_session(uint8_t dev_id,
2324 const uint8_t *key, const uint8_t key_len,
2325 const uint8_t iv_len, const uint8_t auth_len,
2326 enum rte_crypto_auth_operation op,
2327 enum rte_crypto_auth_algorithm algo)
2329 uint8_t hash_key[key_len];
2332 struct crypto_testsuite_params *ts_params = &testsuite_params;
2333 struct crypto_unittest_params *ut_params = &unittest_params;
2335 memcpy(hash_key, key, key_len);
2337 debug_hexdump(stdout, "key:", key, key_len);
2339 /* Setup Authentication Parameters */
2340 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2341 ut_params->auth_xform.next = NULL;
2343 ut_params->auth_xform.auth.op = op;
2344 ut_params->auth_xform.auth.algo = algo;
2345 ut_params->auth_xform.auth.key.length = key_len;
2346 ut_params->auth_xform.auth.key.data = hash_key;
2347 ut_params->auth_xform.auth.digest_length = auth_len;
2348 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2349 ut_params->auth_xform.auth.iv.length = iv_len;
2350 ut_params->sess = rte_cryptodev_sym_session_create(
2351 ts_params->session_mpool);
2353 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2354 &ut_params->auth_xform,
2355 ts_params->session_priv_mpool);
2356 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2357 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2362 create_wireless_algo_cipher_session(uint8_t dev_id,
2363 enum rte_crypto_cipher_operation op,
2364 enum rte_crypto_cipher_algorithm algo,
2365 const uint8_t *key, const uint8_t key_len,
2368 uint8_t cipher_key[key_len];
2370 struct crypto_testsuite_params *ts_params = &testsuite_params;
2371 struct crypto_unittest_params *ut_params = &unittest_params;
2373 memcpy(cipher_key, key, key_len);
2375 /* Setup Cipher Parameters */
2376 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2377 ut_params->cipher_xform.next = NULL;
2379 ut_params->cipher_xform.cipher.algo = algo;
2380 ut_params->cipher_xform.cipher.op = op;
2381 ut_params->cipher_xform.cipher.key.data = cipher_key;
2382 ut_params->cipher_xform.cipher.key.length = key_len;
2383 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2384 ut_params->cipher_xform.cipher.iv.length = iv_len;
2386 debug_hexdump(stdout, "key:", key, key_len);
2388 /* Create Crypto session */
2389 ut_params->sess = rte_cryptodev_sym_session_create(
2390 ts_params->session_mpool);
2392 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2393 &ut_params->cipher_xform,
2394 ts_params->session_priv_mpool);
2395 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2396 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2401 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2402 unsigned int cipher_len,
2403 unsigned int cipher_offset)
2405 struct crypto_testsuite_params *ts_params = &testsuite_params;
2406 struct crypto_unittest_params *ut_params = &unittest_params;
2408 /* Generate Crypto op data structure */
2409 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2410 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2411 TEST_ASSERT_NOT_NULL(ut_params->op,
2412 "Failed to allocate pktmbuf offload");
2414 /* Set crypto operation data parameters */
2415 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2417 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2419 /* set crypto operation source mbuf */
2420 sym_op->m_src = ut_params->ibuf;
2423 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2425 sym_op->cipher.data.length = cipher_len;
2426 sym_op->cipher.data.offset = cipher_offset;
2431 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2432 unsigned int cipher_len,
2433 unsigned int cipher_offset)
2435 struct crypto_testsuite_params *ts_params = &testsuite_params;
2436 struct crypto_unittest_params *ut_params = &unittest_params;
2438 /* Generate Crypto op data structure */
2439 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2440 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2441 TEST_ASSERT_NOT_NULL(ut_params->op,
2442 "Failed to allocate pktmbuf offload");
2444 /* Set crypto operation data parameters */
2445 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2447 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2449 /* set crypto operation source mbuf */
2450 sym_op->m_src = ut_params->ibuf;
2451 sym_op->m_dst = ut_params->obuf;
2454 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2456 sym_op->cipher.data.length = cipher_len;
2457 sym_op->cipher.data.offset = cipher_offset;
2462 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2463 enum rte_crypto_cipher_operation cipher_op,
2464 enum rte_crypto_auth_operation auth_op,
2465 enum rte_crypto_auth_algorithm auth_algo,
2466 enum rte_crypto_cipher_algorithm cipher_algo,
2467 const uint8_t *key, uint8_t key_len,
2468 uint8_t auth_iv_len, uint8_t auth_len,
2469 uint8_t cipher_iv_len)
2472 uint8_t cipher_auth_key[key_len];
2475 struct crypto_testsuite_params *ts_params = &testsuite_params;
2476 struct crypto_unittest_params *ut_params = &unittest_params;
2478 memcpy(cipher_auth_key, key, key_len);
2480 /* Setup Authentication Parameters */
2481 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2482 ut_params->auth_xform.next = NULL;
2484 ut_params->auth_xform.auth.op = auth_op;
2485 ut_params->auth_xform.auth.algo = auth_algo;
2486 ut_params->auth_xform.auth.key.length = key_len;
2487 /* Hash key = cipher key */
2488 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2489 ut_params->auth_xform.auth.digest_length = auth_len;
2490 /* Auth IV will be after cipher IV */
2491 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2492 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2494 /* Setup Cipher Parameters */
2495 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2496 ut_params->cipher_xform.next = &ut_params->auth_xform;
2498 ut_params->cipher_xform.cipher.algo = cipher_algo;
2499 ut_params->cipher_xform.cipher.op = cipher_op;
2500 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2501 ut_params->cipher_xform.cipher.key.length = key_len;
2502 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2503 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2505 debug_hexdump(stdout, "key:", key, key_len);
2507 /* Create Crypto session*/
2508 ut_params->sess = rte_cryptodev_sym_session_create(
2509 ts_params->session_mpool);
2510 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2512 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2513 &ut_params->cipher_xform,
2514 ts_params->session_priv_mpool);
2515 if (status == -ENOTSUP)
2516 return TEST_SKIPPED;
2518 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2523 create_wireless_cipher_auth_session(uint8_t dev_id,
2524 enum rte_crypto_cipher_operation cipher_op,
2525 enum rte_crypto_auth_operation auth_op,
2526 enum rte_crypto_auth_algorithm auth_algo,
2527 enum rte_crypto_cipher_algorithm cipher_algo,
2528 const struct wireless_test_data *tdata)
2530 const uint8_t key_len = tdata->key.len;
2531 uint8_t cipher_auth_key[key_len];
2534 struct crypto_testsuite_params *ts_params = &testsuite_params;
2535 struct crypto_unittest_params *ut_params = &unittest_params;
2536 const uint8_t *key = tdata->key.data;
2537 const uint8_t auth_len = tdata->digest.len;
2538 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2539 uint8_t auth_iv_len = tdata->auth_iv.len;
2541 memcpy(cipher_auth_key, key, key_len);
2543 /* Setup Authentication Parameters */
2544 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2545 ut_params->auth_xform.next = NULL;
2547 ut_params->auth_xform.auth.op = auth_op;
2548 ut_params->auth_xform.auth.algo = auth_algo;
2549 ut_params->auth_xform.auth.key.length = key_len;
2550 /* Hash key = cipher key */
2551 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2552 ut_params->auth_xform.auth.digest_length = auth_len;
2553 /* Auth IV will be after cipher IV */
2554 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2555 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2557 /* Setup Cipher Parameters */
2558 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2559 ut_params->cipher_xform.next = &ut_params->auth_xform;
2561 ut_params->cipher_xform.cipher.algo = cipher_algo;
2562 ut_params->cipher_xform.cipher.op = cipher_op;
2563 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2564 ut_params->cipher_xform.cipher.key.length = key_len;
2565 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2566 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2569 debug_hexdump(stdout, "key:", key, key_len);
2571 /* Create Crypto session*/
2572 ut_params->sess = rte_cryptodev_sym_session_create(
2573 ts_params->session_mpool);
2575 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2576 &ut_params->cipher_xform,
2577 ts_params->session_priv_mpool);
2578 if (status == -ENOTSUP)
2579 return TEST_SKIPPED;
2581 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2582 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2587 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2588 const struct wireless_test_data *tdata)
2590 return create_wireless_cipher_auth_session(dev_id,
2591 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2592 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2593 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2597 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2598 enum rte_crypto_cipher_operation cipher_op,
2599 enum rte_crypto_auth_operation auth_op,
2600 enum rte_crypto_auth_algorithm auth_algo,
2601 enum rte_crypto_cipher_algorithm cipher_algo,
2602 const uint8_t *key, const uint8_t key_len,
2603 uint8_t auth_iv_len, uint8_t auth_len,
2604 uint8_t cipher_iv_len)
2606 uint8_t auth_cipher_key[key_len];
2608 struct crypto_testsuite_params *ts_params = &testsuite_params;
2609 struct crypto_unittest_params *ut_params = &unittest_params;
2611 memcpy(auth_cipher_key, key, key_len);
2613 /* Setup Authentication Parameters */
2614 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2615 ut_params->auth_xform.auth.op = auth_op;
2616 ut_params->auth_xform.next = &ut_params->cipher_xform;
2617 ut_params->auth_xform.auth.algo = auth_algo;
2618 ut_params->auth_xform.auth.key.length = key_len;
2619 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2620 ut_params->auth_xform.auth.digest_length = auth_len;
2621 /* Auth IV will be after cipher IV */
2622 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2623 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2625 /* Setup Cipher Parameters */
2626 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2627 ut_params->cipher_xform.next = NULL;
2628 ut_params->cipher_xform.cipher.algo = cipher_algo;
2629 ut_params->cipher_xform.cipher.op = cipher_op;
2630 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2631 ut_params->cipher_xform.cipher.key.length = key_len;
2632 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2633 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2635 debug_hexdump(stdout, "key:", key, key_len);
2637 /* Create Crypto session*/
2638 ut_params->sess = rte_cryptodev_sym_session_create(
2639 ts_params->session_mpool);
2640 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2642 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2643 ut_params->auth_xform.next = NULL;
2644 ut_params->cipher_xform.next = &ut_params->auth_xform;
2645 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2646 &ut_params->cipher_xform,
2647 ts_params->session_priv_mpool);
2650 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2651 &ut_params->auth_xform,
2652 ts_params->session_priv_mpool);
2654 if (status == -ENOTSUP)
2655 return TEST_SKIPPED;
2657 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2663 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2664 unsigned int auth_tag_len,
2665 const uint8_t *iv, unsigned int iv_len,
2666 unsigned int data_pad_len,
2667 enum rte_crypto_auth_operation op,
2668 unsigned int auth_len, unsigned int auth_offset)
2670 struct crypto_testsuite_params *ts_params = &testsuite_params;
2672 struct crypto_unittest_params *ut_params = &unittest_params;
2674 /* Generate Crypto op data structure */
2675 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2676 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2677 TEST_ASSERT_NOT_NULL(ut_params->op,
2678 "Failed to allocate pktmbuf offload");
2680 /* Set crypto operation data parameters */
2681 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2683 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2685 /* set crypto operation source mbuf */
2686 sym_op->m_src = ut_params->ibuf;
2689 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2692 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2693 ut_params->ibuf, auth_tag_len);
2695 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2696 "no room to append auth tag");
2697 ut_params->digest = sym_op->auth.digest.data;
2698 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2699 ut_params->ibuf, data_pad_len);
2700 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2701 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2703 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2705 debug_hexdump(stdout, "digest:",
2706 sym_op->auth.digest.data,
2709 sym_op->auth.data.length = auth_len;
2710 sym_op->auth.data.offset = auth_offset;
2716 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2717 enum rte_crypto_auth_operation op)
2719 struct crypto_testsuite_params *ts_params = &testsuite_params;
2720 struct crypto_unittest_params *ut_params = &unittest_params;
2722 const uint8_t *auth_tag = tdata->digest.data;
2723 const unsigned int auth_tag_len = tdata->digest.len;
2724 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2725 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2727 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2728 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2729 const uint8_t *auth_iv = tdata->auth_iv.data;
2730 const uint8_t auth_iv_len = tdata->auth_iv.len;
2731 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2732 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2734 /* Generate Crypto op data structure */
2735 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2736 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2737 TEST_ASSERT_NOT_NULL(ut_params->op,
2738 "Failed to allocate pktmbuf offload");
2739 /* Set crypto operation data parameters */
2740 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2742 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2744 /* set crypto operation source mbuf */
2745 sym_op->m_src = ut_params->ibuf;
2748 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2749 ut_params->ibuf, auth_tag_len);
2751 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2752 "no room to append auth tag");
2753 ut_params->digest = sym_op->auth.digest.data;
2754 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2755 ut_params->ibuf, data_pad_len);
2756 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2757 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2759 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2761 debug_hexdump(stdout, "digest:",
2762 sym_op->auth.digest.data,
2765 /* Copy cipher and auth IVs at the end of the crypto operation */
2766 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2768 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2769 iv_ptr += cipher_iv_len;
2770 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2772 sym_op->cipher.data.length = cipher_len;
2773 sym_op->cipher.data.offset = 0;
2774 sym_op->auth.data.length = auth_len;
2775 sym_op->auth.data.offset = 0;
2781 create_zuc_cipher_hash_generate_operation(
2782 const struct wireless_test_data *tdata)
2784 return create_wireless_cipher_hash_operation(tdata,
2785 RTE_CRYPTO_AUTH_OP_GENERATE);
2789 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2790 const unsigned auth_tag_len,
2791 const uint8_t *auth_iv, uint8_t auth_iv_len,
2792 unsigned data_pad_len,
2793 enum rte_crypto_auth_operation op,
2794 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2795 const unsigned cipher_len, const unsigned cipher_offset,
2796 const unsigned auth_len, const unsigned auth_offset)
2798 struct crypto_testsuite_params *ts_params = &testsuite_params;
2799 struct crypto_unittest_params *ut_params = &unittest_params;
2801 enum rte_crypto_cipher_algorithm cipher_algo =
2802 ut_params->cipher_xform.cipher.algo;
2803 enum rte_crypto_auth_algorithm auth_algo =
2804 ut_params->auth_xform.auth.algo;
2806 /* Generate Crypto op data structure */
2807 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2808 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2809 TEST_ASSERT_NOT_NULL(ut_params->op,
2810 "Failed to allocate pktmbuf offload");
2811 /* Set crypto operation data parameters */
2812 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2814 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2816 /* set crypto operation source mbuf */
2817 sym_op->m_src = ut_params->ibuf;
2820 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2821 ut_params->ibuf, auth_tag_len);
2823 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2824 "no room to append auth tag");
2825 ut_params->digest = sym_op->auth.digest.data;
2827 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2828 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2829 ut_params->ibuf, data_pad_len);
2831 struct rte_mbuf *m = ut_params->ibuf;
2832 unsigned int offset = data_pad_len;
2834 while (offset > m->data_len && m->next != NULL) {
2835 offset -= m->data_len;
2838 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2842 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2843 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2845 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2847 debug_hexdump(stdout, "digest:",
2848 sym_op->auth.digest.data,
2851 /* Copy cipher and auth IVs at the end of the crypto operation */
2852 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2854 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2855 iv_ptr += cipher_iv_len;
2856 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2858 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2859 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2860 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2861 sym_op->cipher.data.length = cipher_len;
2862 sym_op->cipher.data.offset = cipher_offset;
2864 sym_op->cipher.data.length = cipher_len >> 3;
2865 sym_op->cipher.data.offset = cipher_offset >> 3;
2868 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2869 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2870 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2871 sym_op->auth.data.length = auth_len;
2872 sym_op->auth.data.offset = auth_offset;
2874 sym_op->auth.data.length = auth_len >> 3;
2875 sym_op->auth.data.offset = auth_offset >> 3;
2882 create_wireless_algo_auth_cipher_operation(
2883 const uint8_t *auth_tag, unsigned int auth_tag_len,
2884 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2885 const uint8_t *auth_iv, uint8_t auth_iv_len,
2886 unsigned int data_pad_len,
2887 unsigned int cipher_len, unsigned int cipher_offset,
2888 unsigned int auth_len, unsigned int auth_offset,
2889 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2891 struct crypto_testsuite_params *ts_params = &testsuite_params;
2892 struct crypto_unittest_params *ut_params = &unittest_params;
2894 enum rte_crypto_cipher_algorithm cipher_algo =
2895 ut_params->cipher_xform.cipher.algo;
2896 enum rte_crypto_auth_algorithm auth_algo =
2897 ut_params->auth_xform.auth.algo;
2899 /* Generate Crypto op data structure */
2900 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2901 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2902 TEST_ASSERT_NOT_NULL(ut_params->op,
2903 "Failed to allocate pktmbuf offload");
2905 /* Set crypto operation data parameters */
2906 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2908 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2910 /* set crypto operation mbufs */
2911 sym_op->m_src = ut_params->ibuf;
2912 if (op_mode == OUT_OF_PLACE)
2913 sym_op->m_dst = ut_params->obuf;
2917 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2918 (op_mode == IN_PLACE ?
2919 ut_params->ibuf : ut_params->obuf),
2920 uint8_t *, data_pad_len);
2921 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2922 (op_mode == IN_PLACE ?
2923 ut_params->ibuf : ut_params->obuf),
2925 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2927 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2928 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2929 sym_op->m_src : sym_op->m_dst);
2930 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2931 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2932 sgl_buf = sgl_buf->next;
2934 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2935 uint8_t *, remaining_off);
2936 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2938 memset(sym_op->auth.digest.data, 0, remaining_off);
2939 while (sgl_buf->next != NULL) {
2940 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2941 0, rte_pktmbuf_data_len(sgl_buf));
2942 sgl_buf = sgl_buf->next;
2946 /* Copy digest for the verification */
2948 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2950 /* Copy cipher and auth IVs at the end of the crypto operation */
2951 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2952 ut_params->op, uint8_t *, IV_OFFSET);
2954 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2955 iv_ptr += cipher_iv_len;
2956 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2958 /* Only copy over the offset data needed from src to dst in OOP,
2959 * if the auth and cipher offsets are not aligned
2961 if (op_mode == OUT_OF_PLACE) {
2962 if (cipher_offset > auth_offset)
2964 rte_pktmbuf_mtod_offset(
2966 uint8_t *, auth_offset >> 3),
2967 rte_pktmbuf_mtod_offset(
2969 uint8_t *, auth_offset >> 3),
2970 ((cipher_offset >> 3) - (auth_offset >> 3)));
2973 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2974 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2975 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2976 sym_op->cipher.data.length = cipher_len;
2977 sym_op->cipher.data.offset = cipher_offset;
2979 sym_op->cipher.data.length = cipher_len >> 3;
2980 sym_op->cipher.data.offset = cipher_offset >> 3;
2983 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2984 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2985 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2986 sym_op->auth.data.length = auth_len;
2987 sym_op->auth.data.offset = auth_offset;
2989 sym_op->auth.data.length = auth_len >> 3;
2990 sym_op->auth.data.offset = auth_offset >> 3;
2997 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2999 struct crypto_testsuite_params *ts_params = &testsuite_params;
3000 struct crypto_unittest_params *ut_params = &unittest_params;
3003 unsigned plaintext_pad_len;
3004 unsigned plaintext_len;
3006 struct rte_cryptodev_info dev_info;
3008 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3009 uint64_t feat_flags = dev_info.feature_flags;
3011 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3012 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3013 printf("Device doesn't support NON-Byte Aligned Data.\n");
3014 return TEST_SKIPPED;
3017 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3018 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3019 printf("Device doesn't support RAW data-path APIs.\n");
3020 return TEST_SKIPPED;
3023 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3024 return TEST_SKIPPED;
3026 /* Verify the capabilities */
3027 struct rte_cryptodev_sym_capability_idx cap_idx;
3028 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3029 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3030 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3032 return TEST_SKIPPED;
3034 /* Create SNOW 3G session */
3035 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3036 tdata->key.data, tdata->key.len,
3037 tdata->auth_iv.len, tdata->digest.len,
3038 RTE_CRYPTO_AUTH_OP_GENERATE,
3039 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3043 /* alloc mbuf and set payload */
3044 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3046 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3047 rte_pktmbuf_tailroom(ut_params->ibuf));
3049 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3050 /* Append data which is padded to a multiple of */
3051 /* the algorithms block size */
3052 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3053 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3055 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3057 /* Create SNOW 3G operation */
3058 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3059 tdata->auth_iv.data, tdata->auth_iv.len,
3060 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3061 tdata->validAuthLenInBits.len,
3066 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3067 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3068 ut_params->op, 0, 1, 1, 0);
3070 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3072 ut_params->obuf = ut_params->op->sym->m_src;
3073 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3074 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3075 + plaintext_pad_len;
3078 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3081 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3082 "SNOW 3G Generated auth tag not as expected");
3088 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3090 struct crypto_testsuite_params *ts_params = &testsuite_params;
3091 struct crypto_unittest_params *ut_params = &unittest_params;
3094 unsigned plaintext_pad_len;
3095 unsigned plaintext_len;
3097 struct rte_cryptodev_info dev_info;
3099 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3100 uint64_t feat_flags = dev_info.feature_flags;
3102 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3103 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3104 printf("Device doesn't support NON-Byte Aligned Data.\n");
3105 return TEST_SKIPPED;
3108 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3109 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3110 printf("Device doesn't support RAW data-path APIs.\n");
3111 return TEST_SKIPPED;
3114 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3115 return TEST_SKIPPED;
3117 /* Verify the capabilities */
3118 struct rte_cryptodev_sym_capability_idx cap_idx;
3119 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3120 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3121 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3123 return TEST_SKIPPED;
3125 /* Create SNOW 3G session */
3126 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3127 tdata->key.data, tdata->key.len,
3128 tdata->auth_iv.len, tdata->digest.len,
3129 RTE_CRYPTO_AUTH_OP_VERIFY,
3130 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3133 /* alloc mbuf and set payload */
3134 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3136 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3137 rte_pktmbuf_tailroom(ut_params->ibuf));
3139 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3140 /* Append data which is padded to a multiple of */
3141 /* the algorithms block size */
3142 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3143 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3145 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3147 /* Create SNOW 3G operation */
3148 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3150 tdata->auth_iv.data, tdata->auth_iv.len,
3152 RTE_CRYPTO_AUTH_OP_VERIFY,
3153 tdata->validAuthLenInBits.len,
3158 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3159 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3160 ut_params->op, 0, 1, 1, 0);
3162 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3164 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3165 ut_params->obuf = ut_params->op->sym->m_src;
3166 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3167 + plaintext_pad_len;
3170 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3179 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3181 struct crypto_testsuite_params *ts_params = &testsuite_params;
3182 struct crypto_unittest_params *ut_params = &unittest_params;
3185 unsigned plaintext_pad_len;
3186 unsigned plaintext_len;
3188 struct rte_cryptodev_info dev_info;
3190 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3191 uint64_t feat_flags = dev_info.feature_flags;
3193 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3194 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3195 printf("Device doesn't support RAW data-path APIs.\n");
3196 return TEST_SKIPPED;
3199 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3200 return TEST_SKIPPED;
3202 /* Verify the capabilities */
3203 struct rte_cryptodev_sym_capability_idx cap_idx;
3204 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3205 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3206 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3208 return TEST_SKIPPED;
3210 /* Create KASUMI session */
3211 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3212 tdata->key.data, tdata->key.len,
3213 0, tdata->digest.len,
3214 RTE_CRYPTO_AUTH_OP_GENERATE,
3215 RTE_CRYPTO_AUTH_KASUMI_F9);
3219 /* alloc mbuf and set payload */
3220 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3222 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3223 rte_pktmbuf_tailroom(ut_params->ibuf));
3225 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3226 /* Append data which is padded to a multiple of */
3227 /* the algorithms block size */
3228 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3229 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3231 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3233 /* Create KASUMI operation */
3234 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3236 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3237 tdata->plaintext.len,
3242 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3243 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3245 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3246 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3247 ut_params->op, 0, 1, 1, 0);
3249 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3252 ut_params->obuf = ut_params->op->sym->m_src;
3253 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3254 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3255 + plaintext_pad_len;
3258 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3261 DIGEST_BYTE_LENGTH_KASUMI_F9,
3262 "KASUMI Generated auth tag not as expected");
3268 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3270 struct crypto_testsuite_params *ts_params = &testsuite_params;
3271 struct crypto_unittest_params *ut_params = &unittest_params;
3274 unsigned plaintext_pad_len;
3275 unsigned plaintext_len;
3277 struct rte_cryptodev_info dev_info;
3279 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3280 uint64_t feat_flags = dev_info.feature_flags;
3282 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3283 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3284 printf("Device doesn't support RAW data-path APIs.\n");
3285 return TEST_SKIPPED;
3288 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3289 return TEST_SKIPPED;
3291 /* Verify the capabilities */
3292 struct rte_cryptodev_sym_capability_idx cap_idx;
3293 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3294 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3295 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3297 return TEST_SKIPPED;
3299 /* Create KASUMI session */
3300 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3301 tdata->key.data, tdata->key.len,
3302 0, tdata->digest.len,
3303 RTE_CRYPTO_AUTH_OP_VERIFY,
3304 RTE_CRYPTO_AUTH_KASUMI_F9);
3307 /* alloc mbuf and set payload */
3308 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3310 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3311 rte_pktmbuf_tailroom(ut_params->ibuf));
3313 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3314 /* Append data which is padded to a multiple */
3315 /* of the algorithms block size */
3316 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3317 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3319 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3321 /* Create KASUMI operation */
3322 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3326 RTE_CRYPTO_AUTH_OP_VERIFY,
3327 tdata->plaintext.len,
3332 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3333 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3334 ut_params->op, 0, 1, 1, 0);
3336 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3338 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3339 ut_params->obuf = ut_params->op->sym->m_src;
3340 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3341 + plaintext_pad_len;
3344 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3353 test_snow3g_hash_generate_test_case_1(void)
3355 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3359 test_snow3g_hash_generate_test_case_2(void)
3361 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3365 test_snow3g_hash_generate_test_case_3(void)
3367 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3371 test_snow3g_hash_generate_test_case_4(void)
3373 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3377 test_snow3g_hash_generate_test_case_5(void)
3379 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3383 test_snow3g_hash_generate_test_case_6(void)
3385 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3389 test_snow3g_hash_verify_test_case_1(void)
3391 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3396 test_snow3g_hash_verify_test_case_2(void)
3398 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3402 test_snow3g_hash_verify_test_case_3(void)
3404 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3408 test_snow3g_hash_verify_test_case_4(void)
3410 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3414 test_snow3g_hash_verify_test_case_5(void)
3416 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3420 test_snow3g_hash_verify_test_case_6(void)
3422 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3426 test_kasumi_hash_generate_test_case_1(void)
3428 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3432 test_kasumi_hash_generate_test_case_2(void)
3434 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3438 test_kasumi_hash_generate_test_case_3(void)
3440 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3444 test_kasumi_hash_generate_test_case_4(void)
3446 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3450 test_kasumi_hash_generate_test_case_5(void)
3452 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3456 test_kasumi_hash_generate_test_case_6(void)
3458 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3462 test_kasumi_hash_verify_test_case_1(void)
3464 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3468 test_kasumi_hash_verify_test_case_2(void)
3470 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3474 test_kasumi_hash_verify_test_case_3(void)
3476 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3480 test_kasumi_hash_verify_test_case_4(void)
3482 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3486 test_kasumi_hash_verify_test_case_5(void)
3488 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3492 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3494 struct crypto_testsuite_params *ts_params = &testsuite_params;
3495 struct crypto_unittest_params *ut_params = &unittest_params;
3498 uint8_t *plaintext, *ciphertext;
3499 unsigned plaintext_pad_len;
3500 unsigned plaintext_len;
3501 struct rte_cryptodev_info dev_info;
3503 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3504 uint64_t feat_flags = dev_info.feature_flags;
3506 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3507 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3508 printf("Device doesn't support RAW data-path APIs.\n");
3509 return TEST_SKIPPED;
3512 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3513 return TEST_SKIPPED;
3515 /* Verify the capabilities */
3516 struct rte_cryptodev_sym_capability_idx cap_idx;
3517 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3518 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3519 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3521 return TEST_SKIPPED;
3523 /* Create KASUMI session */
3524 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3525 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3526 RTE_CRYPTO_CIPHER_KASUMI_F8,
3527 tdata->key.data, tdata->key.len,
3528 tdata->cipher_iv.len);
3532 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3534 /* Clear mbuf payload */
3535 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3536 rte_pktmbuf_tailroom(ut_params->ibuf));
3538 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3539 /* Append data which is padded to a multiple */
3540 /* of the algorithms block size */
3541 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3542 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3544 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3546 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3548 /* Create KASUMI operation */
3549 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3550 tdata->cipher_iv.len,
3551 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3552 tdata->validCipherOffsetInBits.len);
3556 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3557 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3558 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3560 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3562 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3564 ut_params->obuf = ut_params->op->sym->m_dst;
3565 if (ut_params->obuf)
3566 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3568 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3570 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3572 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3573 (tdata->validCipherOffsetInBits.len >> 3);
3575 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3577 reference_ciphertext,
3578 tdata->validCipherLenInBits.len,
3579 "KASUMI Ciphertext data not as expected");
3584 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3586 struct crypto_testsuite_params *ts_params = &testsuite_params;
3587 struct crypto_unittest_params *ut_params = &unittest_params;
3591 unsigned int plaintext_pad_len;
3592 unsigned int plaintext_len;
3594 uint8_t buffer[10000];
3595 const uint8_t *ciphertext;
3597 struct rte_cryptodev_info dev_info;
3599 /* Verify the capabilities */
3600 struct rte_cryptodev_sym_capability_idx cap_idx;
3601 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3602 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3603 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3605 return TEST_SKIPPED;
3607 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3609 uint64_t feat_flags = dev_info.feature_flags;
3611 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3612 printf("Device doesn't support in-place scatter-gather. "
3614 return TEST_SKIPPED;
3617 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3618 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3619 printf("Device doesn't support RAW data-path APIs.\n");
3620 return TEST_SKIPPED;
3623 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3624 return TEST_SKIPPED;
3626 /* Create KASUMI session */
3627 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3628 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3629 RTE_CRYPTO_CIPHER_KASUMI_F8,
3630 tdata->key.data, tdata->key.len,
3631 tdata->cipher_iv.len);
3635 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3638 /* Append data which is padded to a multiple */
3639 /* of the algorithms block size */
3640 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3642 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3643 plaintext_pad_len, 10, 0);
3645 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3647 /* Create KASUMI operation */
3648 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3649 tdata->cipher_iv.len,
3650 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3651 tdata->validCipherOffsetInBits.len);
3655 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3656 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3657 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3659 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3663 ut_params->obuf = ut_params->op->sym->m_dst;
3665 if (ut_params->obuf)
3666 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3667 plaintext_len, buffer);
3669 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3670 tdata->validCipherOffsetInBits.len >> 3,
3671 plaintext_len, buffer);
3674 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3676 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3677 (tdata->validCipherOffsetInBits.len >> 3);
3679 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3681 reference_ciphertext,
3682 tdata->validCipherLenInBits.len,
3683 "KASUMI Ciphertext data not as expected");
3688 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3690 struct crypto_testsuite_params *ts_params = &testsuite_params;
3691 struct crypto_unittest_params *ut_params = &unittest_params;
3694 uint8_t *plaintext, *ciphertext;
3695 unsigned plaintext_pad_len;
3696 unsigned plaintext_len;
3698 /* Verify the capabilities */
3699 struct rte_cryptodev_sym_capability_idx cap_idx;
3700 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3701 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3702 /* Data-path service does not support OOP */
3703 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3705 return TEST_SKIPPED;
3707 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3708 return TEST_SKIPPED;
3710 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3711 return TEST_SKIPPED;
3713 /* Create KASUMI session */
3714 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3715 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3716 RTE_CRYPTO_CIPHER_KASUMI_F8,
3717 tdata->key.data, tdata->key.len,
3718 tdata->cipher_iv.len);
3722 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3723 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3725 /* Clear mbuf payload */
3726 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3727 rte_pktmbuf_tailroom(ut_params->ibuf));
3729 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3730 /* Append data which is padded to a multiple */
3731 /* of the algorithms block size */
3732 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3733 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3735 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3736 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3738 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3740 /* Create KASUMI operation */
3741 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3742 tdata->cipher_iv.len,
3743 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3744 tdata->validCipherOffsetInBits.len);
3748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3752 ut_params->obuf = ut_params->op->sym->m_dst;
3753 if (ut_params->obuf)
3754 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3756 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3758 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3760 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3761 (tdata->validCipherOffsetInBits.len >> 3);
3763 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3765 reference_ciphertext,
3766 tdata->validCipherLenInBits.len,
3767 "KASUMI Ciphertext data not as expected");
3772 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3774 struct crypto_testsuite_params *ts_params = &testsuite_params;
3775 struct crypto_unittest_params *ut_params = &unittest_params;
3778 unsigned int plaintext_pad_len;
3779 unsigned int plaintext_len;
3781 const uint8_t *ciphertext;
3782 uint8_t buffer[2048];
3784 struct rte_cryptodev_info dev_info;
3786 /* Verify the capabilities */
3787 struct rte_cryptodev_sym_capability_idx cap_idx;
3788 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3789 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3790 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3792 return TEST_SKIPPED;
3794 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3795 return TEST_SKIPPED;
3797 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3798 return TEST_SKIPPED;
3800 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3802 uint64_t feat_flags = dev_info.feature_flags;
3803 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3804 printf("Device doesn't support out-of-place scatter-gather "
3805 "in both input and output mbufs. "
3807 return TEST_SKIPPED;
3810 /* Create KASUMI session */
3811 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3812 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3813 RTE_CRYPTO_CIPHER_KASUMI_F8,
3814 tdata->key.data, tdata->key.len,
3815 tdata->cipher_iv.len);
3819 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3820 /* Append data which is padded to a multiple */
3821 /* of the algorithms block size */
3822 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3824 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3825 plaintext_pad_len, 10, 0);
3826 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3827 plaintext_pad_len, 3, 0);
3829 /* Append data which is padded to a multiple */
3830 /* of the algorithms block size */
3831 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3833 /* Create KASUMI operation */
3834 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3835 tdata->cipher_iv.len,
3836 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3837 tdata->validCipherOffsetInBits.len);
3841 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3843 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3845 ut_params->obuf = ut_params->op->sym->m_dst;
3846 if (ut_params->obuf)
3847 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3848 plaintext_pad_len, buffer);
3850 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3851 tdata->validCipherOffsetInBits.len >> 3,
3852 plaintext_pad_len, buffer);
3854 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3855 (tdata->validCipherOffsetInBits.len >> 3);
3857 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3859 reference_ciphertext,
3860 tdata->validCipherLenInBits.len,
3861 "KASUMI Ciphertext data not as expected");
3867 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3869 struct crypto_testsuite_params *ts_params = &testsuite_params;
3870 struct crypto_unittest_params *ut_params = &unittest_params;
3873 uint8_t *ciphertext, *plaintext;
3874 unsigned ciphertext_pad_len;
3875 unsigned ciphertext_len;
3877 /* Verify the capabilities */
3878 struct rte_cryptodev_sym_capability_idx cap_idx;
3879 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3880 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3881 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3883 return TEST_SKIPPED;
3885 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3886 return TEST_SKIPPED;
3888 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3889 return TEST_SKIPPED;
3891 /* Create KASUMI session */
3892 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3893 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3894 RTE_CRYPTO_CIPHER_KASUMI_F8,
3895 tdata->key.data, tdata->key.len,
3896 tdata->cipher_iv.len);
3900 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3901 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3903 /* Clear mbuf payload */
3904 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3905 rte_pktmbuf_tailroom(ut_params->ibuf));
3907 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3908 /* Append data which is padded to a multiple */
3909 /* of the algorithms block size */
3910 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3911 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3912 ciphertext_pad_len);
3913 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3914 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3916 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3918 /* Create KASUMI operation */
3919 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3920 tdata->cipher_iv.len,
3921 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3922 tdata->validCipherOffsetInBits.len);
3926 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3928 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3930 ut_params->obuf = ut_params->op->sym->m_dst;
3931 if (ut_params->obuf)
3932 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3934 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3936 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3938 const uint8_t *reference_plaintext = tdata->plaintext.data +
3939 (tdata->validCipherOffsetInBits.len >> 3);
3941 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3943 reference_plaintext,
3944 tdata->validCipherLenInBits.len,
3945 "KASUMI Plaintext data not as expected");
3950 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3952 struct crypto_testsuite_params *ts_params = &testsuite_params;
3953 struct crypto_unittest_params *ut_params = &unittest_params;
3956 uint8_t *ciphertext, *plaintext;
3957 unsigned ciphertext_pad_len;
3958 unsigned ciphertext_len;
3959 struct rte_cryptodev_info dev_info;
3961 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3962 uint64_t feat_flags = dev_info.feature_flags;
3964 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3965 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3966 printf("Device doesn't support RAW data-path APIs.\n");
3967 return TEST_SKIPPED;
3970 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3971 return TEST_SKIPPED;
3973 /* Verify the capabilities */
3974 struct rte_cryptodev_sym_capability_idx cap_idx;
3975 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3976 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3977 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3979 return TEST_SKIPPED;
3981 /* Create KASUMI session */
3982 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3983 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3984 RTE_CRYPTO_CIPHER_KASUMI_F8,
3985 tdata->key.data, tdata->key.len,
3986 tdata->cipher_iv.len);
3990 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3992 /* Clear mbuf payload */
3993 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3994 rte_pktmbuf_tailroom(ut_params->ibuf));
3996 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3997 /* Append data which is padded to a multiple */
3998 /* of the algorithms block size */
3999 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4000 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4001 ciphertext_pad_len);
4002 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4004 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4006 /* Create KASUMI operation */
4007 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4008 tdata->cipher_iv.len,
4009 tdata->ciphertext.len,
4010 tdata->validCipherOffsetInBits.len);
4014 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4015 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4016 ut_params->op, 1, 0, 1, 0);
4018 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4020 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4022 ut_params->obuf = ut_params->op->sym->m_dst;
4023 if (ut_params->obuf)
4024 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4026 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4028 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4030 const uint8_t *reference_plaintext = tdata->plaintext.data +
4031 (tdata->validCipherOffsetInBits.len >> 3);
4033 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4035 reference_plaintext,
4036 tdata->validCipherLenInBits.len,
4037 "KASUMI Plaintext data not as expected");
4042 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4044 struct crypto_testsuite_params *ts_params = &testsuite_params;
4045 struct crypto_unittest_params *ut_params = &unittest_params;
4048 uint8_t *plaintext, *ciphertext;
4049 unsigned plaintext_pad_len;
4050 unsigned plaintext_len;
4051 struct rte_cryptodev_info dev_info;
4053 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4054 uint64_t feat_flags = dev_info.feature_flags;
4056 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4057 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4058 printf("Device doesn't support RAW data-path APIs.\n");
4059 return TEST_SKIPPED;
4062 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4063 return TEST_SKIPPED;
4065 /* Verify the capabilities */
4066 struct rte_cryptodev_sym_capability_idx cap_idx;
4067 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4068 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4069 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4071 return TEST_SKIPPED;
4073 /* Create SNOW 3G session */
4074 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4075 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4076 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4077 tdata->key.data, tdata->key.len,
4078 tdata->cipher_iv.len);
4082 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4084 /* Clear mbuf payload */
4085 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4086 rte_pktmbuf_tailroom(ut_params->ibuf));
4088 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4089 /* Append data which is padded to a multiple of */
4090 /* the algorithms block size */
4091 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4092 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4094 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4096 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4098 /* Create SNOW 3G operation */
4099 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4100 tdata->cipher_iv.len,
4101 tdata->validCipherLenInBits.len,
4106 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4107 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4108 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4110 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4112 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4114 ut_params->obuf = ut_params->op->sym->m_dst;
4115 if (ut_params->obuf)
4116 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4118 ciphertext = plaintext;
4120 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4123 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4125 tdata->ciphertext.data,
4126 tdata->validDataLenInBits.len,
4127 "SNOW 3G Ciphertext data not as expected");
4133 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4135 struct crypto_testsuite_params *ts_params = &testsuite_params;
4136 struct crypto_unittest_params *ut_params = &unittest_params;
4137 uint8_t *plaintext, *ciphertext;
4140 unsigned plaintext_pad_len;
4141 unsigned plaintext_len;
4143 /* Verify the capabilities */
4144 struct rte_cryptodev_sym_capability_idx cap_idx;
4145 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4146 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4147 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4149 return TEST_SKIPPED;
4151 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4152 return TEST_SKIPPED;
4154 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4155 return TEST_SKIPPED;
4157 /* Create SNOW 3G session */
4158 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4159 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4160 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4161 tdata->key.data, tdata->key.len,
4162 tdata->cipher_iv.len);
4166 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4167 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4169 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4170 "Failed to allocate input buffer in mempool");
4171 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4172 "Failed to allocate output buffer in mempool");
4174 /* Clear mbuf payload */
4175 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4176 rte_pktmbuf_tailroom(ut_params->ibuf));
4178 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4179 /* Append data which is padded to a multiple of */
4180 /* the algorithms block size */
4181 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4182 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4184 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4185 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4187 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4189 /* Create SNOW 3G operation */
4190 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4191 tdata->cipher_iv.len,
4192 tdata->validCipherLenInBits.len,
4197 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4199 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4201 ut_params->obuf = ut_params->op->sym->m_dst;
4202 if (ut_params->obuf)
4203 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4205 ciphertext = plaintext;
4207 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4210 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4212 tdata->ciphertext.data,
4213 tdata->validDataLenInBits.len,
4214 "SNOW 3G Ciphertext data not as expected");
4219 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4221 struct crypto_testsuite_params *ts_params = &testsuite_params;
4222 struct crypto_unittest_params *ut_params = &unittest_params;
4225 unsigned int plaintext_pad_len;
4226 unsigned int plaintext_len;
4227 uint8_t buffer[10000];
4228 const uint8_t *ciphertext;
4230 struct rte_cryptodev_info dev_info;
4232 /* Verify the capabilities */
4233 struct rte_cryptodev_sym_capability_idx cap_idx;
4234 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4235 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4236 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4238 return TEST_SKIPPED;
4240 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4241 return TEST_SKIPPED;
4243 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4244 return TEST_SKIPPED;
4246 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4248 uint64_t feat_flags = dev_info.feature_flags;
4250 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4251 printf("Device doesn't support out-of-place scatter-gather "
4252 "in both input and output mbufs. "
4254 return TEST_SKIPPED;
4257 /* Create SNOW 3G session */
4258 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4259 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4260 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4261 tdata->key.data, tdata->key.len,
4262 tdata->cipher_iv.len);
4266 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4267 /* Append data which is padded to a multiple of */
4268 /* the algorithms block size */
4269 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4271 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4272 plaintext_pad_len, 10, 0);
4273 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4274 plaintext_pad_len, 3, 0);
4276 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4277 "Failed to allocate input buffer in mempool");
4278 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4279 "Failed to allocate output buffer in mempool");
4281 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4283 /* Create SNOW 3G operation */
4284 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4285 tdata->cipher_iv.len,
4286 tdata->validCipherLenInBits.len,
4291 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4295 ut_params->obuf = ut_params->op->sym->m_dst;
4296 if (ut_params->obuf)
4297 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4298 plaintext_len, buffer);
4300 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4301 plaintext_len, buffer);
4303 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4306 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4308 tdata->ciphertext.data,
4309 tdata->validDataLenInBits.len,
4310 "SNOW 3G Ciphertext data not as expected");
4315 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4317 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4319 uint8_t curr_byte, prev_byte;
4320 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4321 uint8_t lower_byte_mask = (1 << offset) - 1;
4324 prev_byte = buffer[0];
4325 buffer[0] >>= offset;
4327 for (i = 1; i < length_in_bytes; i++) {
4328 curr_byte = buffer[i];
4329 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4330 (curr_byte >> offset);
4331 prev_byte = curr_byte;
4336 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4338 struct crypto_testsuite_params *ts_params = &testsuite_params;
4339 struct crypto_unittest_params *ut_params = &unittest_params;
4340 uint8_t *plaintext, *ciphertext;
4342 uint32_t plaintext_len;
4343 uint32_t plaintext_pad_len;
4344 uint8_t extra_offset = 4;
4345 uint8_t *expected_ciphertext_shifted;
4346 struct rte_cryptodev_info dev_info;
4348 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4349 uint64_t feat_flags = dev_info.feature_flags;
4351 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4352 ((tdata->validDataLenInBits.len % 8) != 0)) {
4353 printf("Device doesn't support NON-Byte Aligned Data.\n");
4354 return TEST_SKIPPED;
4357 /* Verify the capabilities */
4358 struct rte_cryptodev_sym_capability_idx cap_idx;
4359 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4360 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4361 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4363 return TEST_SKIPPED;
4365 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4366 return TEST_SKIPPED;
4368 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4369 return TEST_SKIPPED;
4371 /* Create SNOW 3G session */
4372 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4373 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4374 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4375 tdata->key.data, tdata->key.len,
4376 tdata->cipher_iv.len);
4380 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4381 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4383 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4384 "Failed to allocate input buffer in mempool");
4385 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4386 "Failed to allocate output buffer in mempool");
4388 /* Clear mbuf payload */
4389 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4390 rte_pktmbuf_tailroom(ut_params->ibuf));
4392 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4394 * Append data which is padded to a
4395 * multiple of the algorithms block size
4397 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4399 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4402 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4404 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4405 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4407 #ifdef RTE_APP_TEST_DEBUG
4408 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4410 /* Create SNOW 3G operation */
4411 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4412 tdata->cipher_iv.len,
4413 tdata->validCipherLenInBits.len,
4418 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4420 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4422 ut_params->obuf = ut_params->op->sym->m_dst;
4423 if (ut_params->obuf)
4424 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4426 ciphertext = plaintext;
4428 #ifdef RTE_APP_TEST_DEBUG
4429 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4432 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4434 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4435 "failed to reserve memory for ciphertext shifted\n");
4437 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4438 ceil_byte_length(tdata->ciphertext.len));
4439 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4442 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4444 expected_ciphertext_shifted,
4445 tdata->validDataLenInBits.len,
4447 "SNOW 3G Ciphertext data not as expected");
4451 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4453 struct crypto_testsuite_params *ts_params = &testsuite_params;
4454 struct crypto_unittest_params *ut_params = &unittest_params;
4458 uint8_t *plaintext, *ciphertext;
4459 unsigned ciphertext_pad_len;
4460 unsigned ciphertext_len;
4461 struct rte_cryptodev_info dev_info;
4463 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4464 uint64_t feat_flags = dev_info.feature_flags;
4466 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4467 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4468 printf("Device doesn't support RAW data-path APIs.\n");
4469 return TEST_SKIPPED;
4472 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4473 return TEST_SKIPPED;
4475 /* Verify the capabilities */
4476 struct rte_cryptodev_sym_capability_idx cap_idx;
4477 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4478 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4479 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4481 return TEST_SKIPPED;
4483 /* Create SNOW 3G session */
4484 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4485 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4486 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4487 tdata->key.data, tdata->key.len,
4488 tdata->cipher_iv.len);
4492 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4494 /* Clear mbuf payload */
4495 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4496 rte_pktmbuf_tailroom(ut_params->ibuf));
4498 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4499 /* Append data which is padded to a multiple of */
4500 /* the algorithms block size */
4501 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4502 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4503 ciphertext_pad_len);
4504 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4506 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4508 /* Create SNOW 3G operation */
4509 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4510 tdata->cipher_iv.len,
4511 tdata->validCipherLenInBits.len,
4512 tdata->cipher.offset_bits);
4516 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4517 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4518 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4520 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4522 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4523 ut_params->obuf = ut_params->op->sym->m_dst;
4524 if (ut_params->obuf)
4525 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4527 plaintext = ciphertext;
4529 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4532 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4533 tdata->plaintext.data,
4534 tdata->validDataLenInBits.len,
4535 "SNOW 3G Plaintext data not as expected");
4539 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4541 struct crypto_testsuite_params *ts_params = &testsuite_params;
4542 struct crypto_unittest_params *ut_params = &unittest_params;
4546 uint8_t *plaintext, *ciphertext;
4547 unsigned ciphertext_pad_len;
4548 unsigned ciphertext_len;
4550 /* Verify the capabilities */
4551 struct rte_cryptodev_sym_capability_idx cap_idx;
4552 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4553 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4554 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4556 return TEST_SKIPPED;
4558 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4559 return TEST_SKIPPED;
4561 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4562 return TEST_SKIPPED;
4564 /* Create SNOW 3G session */
4565 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4566 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4567 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4568 tdata->key.data, tdata->key.len,
4569 tdata->cipher_iv.len);
4573 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4574 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4576 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4577 "Failed to allocate input buffer");
4578 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4579 "Failed to allocate output buffer");
4581 /* Clear mbuf payload */
4582 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4583 rte_pktmbuf_tailroom(ut_params->ibuf));
4585 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4586 rte_pktmbuf_tailroom(ut_params->obuf));
4588 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4589 /* Append data which is padded to a multiple of */
4590 /* the algorithms block size */
4591 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4592 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4593 ciphertext_pad_len);
4594 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4595 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4597 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4599 /* Create SNOW 3G operation */
4600 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4601 tdata->cipher_iv.len,
4602 tdata->validCipherLenInBits.len,
4607 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4609 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4610 ut_params->obuf = ut_params->op->sym->m_dst;
4611 if (ut_params->obuf)
4612 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4614 plaintext = ciphertext;
4616 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4619 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4620 tdata->plaintext.data,
4621 tdata->validDataLenInBits.len,
4622 "SNOW 3G Plaintext data not as expected");
4627 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4629 struct crypto_testsuite_params *ts_params = &testsuite_params;
4630 struct crypto_unittest_params *ut_params = &unittest_params;
4634 uint8_t *plaintext, *ciphertext;
4635 unsigned int plaintext_pad_len;
4636 unsigned int plaintext_len;
4638 struct rte_cryptodev_info dev_info;
4639 struct rte_cryptodev_sym_capability_idx cap_idx;
4641 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4642 uint64_t feat_flags = dev_info.feature_flags;
4644 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4645 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4646 (tdata->validDataLenInBits.len % 8 != 0))) {
4647 printf("Device doesn't support NON-Byte Aligned Data.\n");
4648 return TEST_SKIPPED;
4651 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4652 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4653 printf("Device doesn't support RAW data-path APIs.\n");
4654 return TEST_SKIPPED;
4657 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4658 return TEST_SKIPPED;
4660 /* Check if device supports ZUC EEA3 */
4661 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4662 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4664 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4666 return TEST_SKIPPED;
4668 /* Check if device supports ZUC EIA3 */
4669 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4670 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4672 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4674 return TEST_SKIPPED;
4676 /* Create ZUC session */
4677 retval = create_zuc_cipher_auth_encrypt_generate_session(
4678 ts_params->valid_devs[0],
4682 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4684 /* clear mbuf payload */
4685 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4686 rte_pktmbuf_tailroom(ut_params->ibuf));
4688 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4689 /* Append data which is padded to a multiple of */
4690 /* the algorithms block size */
4691 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4692 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4694 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4696 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4698 /* Create ZUC operation */
4699 retval = create_zuc_cipher_hash_generate_operation(tdata);
4703 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4704 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4705 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4707 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4709 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4710 ut_params->obuf = ut_params->op->sym->m_src;
4711 if (ut_params->obuf)
4712 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4714 ciphertext = plaintext;
4716 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4718 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4720 tdata->ciphertext.data,
4721 tdata->validDataLenInBits.len,
4722 "ZUC Ciphertext data not as expected");
4724 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4725 + plaintext_pad_len;
4728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4732 "ZUC Generated auth tag not as expected");
4737 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4739 struct crypto_testsuite_params *ts_params = &testsuite_params;
4740 struct crypto_unittest_params *ut_params = &unittest_params;
4744 uint8_t *plaintext, *ciphertext;
4745 unsigned plaintext_pad_len;
4746 unsigned plaintext_len;
4747 struct rte_cryptodev_info dev_info;
4749 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4750 uint64_t feat_flags = dev_info.feature_flags;
4752 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4753 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4754 printf("Device doesn't support RAW data-path APIs.\n");
4755 return TEST_SKIPPED;
4758 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4759 return TEST_SKIPPED;
4761 /* Verify the capabilities */
4762 struct rte_cryptodev_sym_capability_idx cap_idx;
4763 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4764 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4765 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4767 return TEST_SKIPPED;
4768 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4769 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4770 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4772 return TEST_SKIPPED;
4774 /* Create SNOW 3G session */
4775 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4776 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4777 RTE_CRYPTO_AUTH_OP_GENERATE,
4778 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4779 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4780 tdata->key.data, tdata->key.len,
4781 tdata->auth_iv.len, tdata->digest.len,
4782 tdata->cipher_iv.len);
4785 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4787 /* clear mbuf payload */
4788 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4789 rte_pktmbuf_tailroom(ut_params->ibuf));
4791 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4792 /* Append data which is padded to a multiple of */
4793 /* the algorithms block size */
4794 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4795 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4797 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4799 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4801 /* Create SNOW 3G operation */
4802 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4803 tdata->digest.len, tdata->auth_iv.data,
4805 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4806 tdata->cipher_iv.data, tdata->cipher_iv.len,
4807 tdata->validCipherLenInBits.len,
4809 tdata->validAuthLenInBits.len,
4815 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4816 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4817 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4819 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4821 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4822 ut_params->obuf = ut_params->op->sym->m_src;
4823 if (ut_params->obuf)
4824 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4826 ciphertext = plaintext;
4828 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4830 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4832 tdata->ciphertext.data,
4833 tdata->validDataLenInBits.len,
4834 "SNOW 3G Ciphertext data not as expected");
4836 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4837 + plaintext_pad_len;
4840 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4843 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4844 "SNOW 3G Generated auth tag not as expected");
4849 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4850 uint8_t op_mode, uint8_t verify)
4852 struct crypto_testsuite_params *ts_params = &testsuite_params;
4853 struct crypto_unittest_params *ut_params = &unittest_params;
4857 uint8_t *plaintext = NULL, *ciphertext = NULL;
4858 unsigned int plaintext_pad_len;
4859 unsigned int plaintext_len;
4860 unsigned int ciphertext_pad_len;
4861 unsigned int ciphertext_len;
4863 struct rte_cryptodev_info dev_info;
4865 /* Verify the capabilities */
4866 struct rte_cryptodev_sym_capability_idx cap_idx;
4867 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4868 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4869 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4871 return TEST_SKIPPED;
4872 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4873 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4874 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4876 return TEST_SKIPPED;
4878 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4879 return TEST_SKIPPED;
4881 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4883 uint64_t feat_flags = dev_info.feature_flags;
4885 if (op_mode == OUT_OF_PLACE) {
4886 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4887 printf("Device doesn't support digest encrypted.\n");
4888 return TEST_SKIPPED;
4890 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4891 return TEST_SKIPPED;
4894 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4895 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4896 printf("Device doesn't support RAW data-path APIs.\n");
4897 return TEST_SKIPPED;
4900 /* Create SNOW 3G session */
4901 retval = create_wireless_algo_auth_cipher_session(
4902 ts_params->valid_devs[0],
4903 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4904 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4905 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4906 : RTE_CRYPTO_AUTH_OP_GENERATE),
4907 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4908 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4909 tdata->key.data, tdata->key.len,
4910 tdata->auth_iv.len, tdata->digest.len,
4911 tdata->cipher_iv.len);
4915 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4916 if (op_mode == OUT_OF_PLACE)
4917 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4919 /* clear mbuf payload */
4920 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4921 rte_pktmbuf_tailroom(ut_params->ibuf));
4922 if (op_mode == OUT_OF_PLACE)
4923 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4924 rte_pktmbuf_tailroom(ut_params->obuf));
4926 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4927 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4928 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4929 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4932 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4933 ciphertext_pad_len);
4934 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4935 if (op_mode == OUT_OF_PLACE)
4936 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4937 debug_hexdump(stdout, "ciphertext:", ciphertext,
4940 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4942 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4943 if (op_mode == OUT_OF_PLACE)
4944 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4945 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4948 /* Create SNOW 3G operation */
4949 retval = create_wireless_algo_auth_cipher_operation(
4950 tdata->digest.data, tdata->digest.len,
4951 tdata->cipher_iv.data, tdata->cipher_iv.len,
4952 tdata->auth_iv.data, tdata->auth_iv.len,
4953 (tdata->digest.offset_bytes == 0 ?
4954 (verify ? ciphertext_pad_len : plaintext_pad_len)
4955 : tdata->digest.offset_bytes),
4956 tdata->validCipherLenInBits.len,
4957 tdata->cipher.offset_bits,
4958 tdata->validAuthLenInBits.len,
4959 tdata->auth.offset_bits,
4960 op_mode, 0, verify);
4965 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4966 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4967 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4969 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4972 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4974 ut_params->obuf = (op_mode == IN_PLACE ?
4975 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4978 if (ut_params->obuf)
4979 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4982 plaintext = ciphertext +
4983 (tdata->cipher.offset_bits >> 3);
4985 debug_hexdump(stdout, "plaintext:", plaintext,
4986 (tdata->plaintext.len >> 3) - tdata->digest.len);
4987 debug_hexdump(stdout, "plaintext expected:",
4988 tdata->plaintext.data,
4989 (tdata->plaintext.len >> 3) - tdata->digest.len);
4991 if (ut_params->obuf)
4992 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4995 ciphertext = plaintext;
4997 debug_hexdump(stdout, "ciphertext:", ciphertext,
4999 debug_hexdump(stdout, "ciphertext expected:",
5000 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5002 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5003 + (tdata->digest.offset_bytes == 0 ?
5004 plaintext_pad_len : tdata->digest.offset_bytes);
5006 debug_hexdump(stdout, "digest:", ut_params->digest,
5008 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5014 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5016 tdata->plaintext.data,
5017 (tdata->plaintext.len - tdata->cipher.offset_bits -
5018 (tdata->digest.len << 3)),
5019 tdata->cipher.offset_bits,
5020 "SNOW 3G Plaintext data not as expected");
5022 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5024 tdata->ciphertext.data,
5025 (tdata->validDataLenInBits.len -
5026 tdata->cipher.offset_bits),
5027 tdata->cipher.offset_bits,
5028 "SNOW 3G Ciphertext data not as expected");
5030 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5033 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5034 "SNOW 3G Generated auth tag not as expected");
5040 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5041 uint8_t op_mode, uint8_t verify)
5043 struct crypto_testsuite_params *ts_params = &testsuite_params;
5044 struct crypto_unittest_params *ut_params = &unittest_params;
5048 const uint8_t *plaintext = NULL;
5049 const uint8_t *ciphertext = NULL;
5050 const uint8_t *digest = NULL;
5051 unsigned int plaintext_pad_len;
5052 unsigned int plaintext_len;
5053 unsigned int ciphertext_pad_len;
5054 unsigned int ciphertext_len;
5055 uint8_t buffer[10000];
5056 uint8_t digest_buffer[10000];
5058 struct rte_cryptodev_info dev_info;
5060 /* Verify the capabilities */
5061 struct rte_cryptodev_sym_capability_idx cap_idx;
5062 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5063 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5064 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5066 return TEST_SKIPPED;
5067 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5068 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5069 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5071 return TEST_SKIPPED;
5073 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5074 return TEST_SKIPPED;
5076 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5078 uint64_t feat_flags = dev_info.feature_flags;
5080 if (op_mode == IN_PLACE) {
5081 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5082 printf("Device doesn't support in-place scatter-gather "
5083 "in both input and output mbufs.\n");
5084 return TEST_SKIPPED;
5086 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5087 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5088 printf("Device doesn't support RAW data-path APIs.\n");
5089 return TEST_SKIPPED;
5092 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5093 return TEST_SKIPPED;
5094 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5095 printf("Device doesn't support out-of-place scatter-gather "
5096 "in both input and output mbufs.\n");
5097 return TEST_SKIPPED;
5099 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5100 printf("Device doesn't support digest encrypted.\n");
5101 return TEST_SKIPPED;
5105 /* Create SNOW 3G session */
5106 retval = create_wireless_algo_auth_cipher_session(
5107 ts_params->valid_devs[0],
5108 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5109 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5110 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5111 : RTE_CRYPTO_AUTH_OP_GENERATE),
5112 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5113 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5114 tdata->key.data, tdata->key.len,
5115 tdata->auth_iv.len, tdata->digest.len,
5116 tdata->cipher_iv.len);
5121 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5122 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5123 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5124 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5126 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5127 plaintext_pad_len, 15, 0);
5128 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5129 "Failed to allocate input buffer in mempool");
5131 if (op_mode == OUT_OF_PLACE) {
5132 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5133 plaintext_pad_len, 15, 0);
5134 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5135 "Failed to allocate output buffer in mempool");
5139 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5140 tdata->ciphertext.data);
5141 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5142 ciphertext_len, buffer);
5143 debug_hexdump(stdout, "ciphertext:", ciphertext,
5146 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5147 tdata->plaintext.data);
5148 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5149 plaintext_len, buffer);
5150 debug_hexdump(stdout, "plaintext:", plaintext,
5153 memset(buffer, 0, sizeof(buffer));
5155 /* Create SNOW 3G operation */
5156 retval = create_wireless_algo_auth_cipher_operation(
5157 tdata->digest.data, tdata->digest.len,
5158 tdata->cipher_iv.data, tdata->cipher_iv.len,
5159 tdata->auth_iv.data, tdata->auth_iv.len,
5160 (tdata->digest.offset_bytes == 0 ?
5161 (verify ? ciphertext_pad_len : plaintext_pad_len)
5162 : tdata->digest.offset_bytes),
5163 tdata->validCipherLenInBits.len,
5164 tdata->cipher.offset_bits,
5165 tdata->validAuthLenInBits.len,
5166 tdata->auth.offset_bits,
5167 op_mode, 1, verify);
5172 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5173 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5174 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5176 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5179 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5181 ut_params->obuf = (op_mode == IN_PLACE ?
5182 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5185 if (ut_params->obuf)
5186 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5187 plaintext_len, buffer);
5189 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5190 plaintext_len, buffer);
5192 debug_hexdump(stdout, "plaintext:", plaintext,
5193 (tdata->plaintext.len >> 3) - tdata->digest.len);
5194 debug_hexdump(stdout, "plaintext expected:",
5195 tdata->plaintext.data,
5196 (tdata->plaintext.len >> 3) - tdata->digest.len);
5198 if (ut_params->obuf)
5199 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5200 ciphertext_len, buffer);
5202 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5203 ciphertext_len, buffer);
5205 debug_hexdump(stdout, "ciphertext:", ciphertext,
5207 debug_hexdump(stdout, "ciphertext expected:",
5208 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5210 if (ut_params->obuf)
5211 digest = rte_pktmbuf_read(ut_params->obuf,
5212 (tdata->digest.offset_bytes == 0 ?
5213 plaintext_pad_len : tdata->digest.offset_bytes),
5214 tdata->digest.len, digest_buffer);
5216 digest = rte_pktmbuf_read(ut_params->ibuf,
5217 (tdata->digest.offset_bytes == 0 ?
5218 plaintext_pad_len : tdata->digest.offset_bytes),
5219 tdata->digest.len, digest_buffer);
5221 debug_hexdump(stdout, "digest:", digest,
5223 debug_hexdump(stdout, "digest expected:",
5224 tdata->digest.data, tdata->digest.len);
5229 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5231 tdata->plaintext.data,
5232 (tdata->plaintext.len - tdata->cipher.offset_bits -
5233 (tdata->digest.len << 3)),
5234 tdata->cipher.offset_bits,
5235 "SNOW 3G Plaintext data not as expected");
5237 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5239 tdata->ciphertext.data,
5240 (tdata->validDataLenInBits.len -
5241 tdata->cipher.offset_bits),
5242 tdata->cipher.offset_bits,
5243 "SNOW 3G Ciphertext data not as expected");
5245 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5248 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5249 "SNOW 3G Generated auth tag not as expected");
5255 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5256 uint8_t op_mode, uint8_t verify)
5258 struct crypto_testsuite_params *ts_params = &testsuite_params;
5259 struct crypto_unittest_params *ut_params = &unittest_params;
5263 uint8_t *plaintext = NULL, *ciphertext = NULL;
5264 unsigned int plaintext_pad_len;
5265 unsigned int plaintext_len;
5266 unsigned int ciphertext_pad_len;
5267 unsigned int ciphertext_len;
5269 struct rte_cryptodev_info dev_info;
5271 /* Verify the capabilities */
5272 struct rte_cryptodev_sym_capability_idx cap_idx;
5273 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5274 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5275 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5277 return TEST_SKIPPED;
5278 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5279 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5280 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5282 return TEST_SKIPPED;
5284 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5286 uint64_t feat_flags = dev_info.feature_flags;
5288 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5289 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5290 printf("Device doesn't support RAW data-path APIs.\n");
5291 return TEST_SKIPPED;
5294 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5295 return TEST_SKIPPED;
5297 if (op_mode == OUT_OF_PLACE) {
5298 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5299 return TEST_SKIPPED;
5300 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5301 printf("Device doesn't support digest encrypted.\n");
5302 return TEST_SKIPPED;
5306 /* Create KASUMI session */
5307 retval = create_wireless_algo_auth_cipher_session(
5308 ts_params->valid_devs[0],
5309 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5310 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5311 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5312 : RTE_CRYPTO_AUTH_OP_GENERATE),
5313 RTE_CRYPTO_AUTH_KASUMI_F9,
5314 RTE_CRYPTO_CIPHER_KASUMI_F8,
5315 tdata->key.data, tdata->key.len,
5316 0, tdata->digest.len,
5317 tdata->cipher_iv.len);
5322 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5323 if (op_mode == OUT_OF_PLACE)
5324 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5326 /* clear mbuf payload */
5327 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5328 rte_pktmbuf_tailroom(ut_params->ibuf));
5329 if (op_mode == OUT_OF_PLACE)
5330 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5331 rte_pktmbuf_tailroom(ut_params->obuf));
5333 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5334 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5335 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5336 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5339 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5340 ciphertext_pad_len);
5341 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5342 if (op_mode == OUT_OF_PLACE)
5343 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5344 debug_hexdump(stdout, "ciphertext:", ciphertext,
5347 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5349 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5350 if (op_mode == OUT_OF_PLACE)
5351 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5352 debug_hexdump(stdout, "plaintext:", plaintext,
5356 /* Create KASUMI operation */
5357 retval = create_wireless_algo_auth_cipher_operation(
5358 tdata->digest.data, tdata->digest.len,
5359 tdata->cipher_iv.data, tdata->cipher_iv.len,
5361 (tdata->digest.offset_bytes == 0 ?
5362 (verify ? ciphertext_pad_len : plaintext_pad_len)
5363 : tdata->digest.offset_bytes),
5364 tdata->validCipherLenInBits.len,
5365 tdata->validCipherOffsetInBits.len,
5366 tdata->validAuthLenInBits.len,
5368 op_mode, 0, verify);
5373 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5374 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5375 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5377 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5380 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5382 ut_params->obuf = (op_mode == IN_PLACE ?
5383 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5387 if (ut_params->obuf)
5388 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5391 plaintext = ciphertext;
5393 debug_hexdump(stdout, "plaintext:", plaintext,
5394 (tdata->plaintext.len >> 3) - tdata->digest.len);
5395 debug_hexdump(stdout, "plaintext expected:",
5396 tdata->plaintext.data,
5397 (tdata->plaintext.len >> 3) - tdata->digest.len);
5399 if (ut_params->obuf)
5400 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5403 ciphertext = plaintext;
5405 debug_hexdump(stdout, "ciphertext:", ciphertext,
5407 debug_hexdump(stdout, "ciphertext expected:",
5408 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5410 ut_params->digest = rte_pktmbuf_mtod(
5411 ut_params->obuf, uint8_t *) +
5412 (tdata->digest.offset_bytes == 0 ?
5413 plaintext_pad_len : tdata->digest.offset_bytes);
5415 debug_hexdump(stdout, "digest:", ut_params->digest,
5417 debug_hexdump(stdout, "digest expected:",
5418 tdata->digest.data, tdata->digest.len);
5423 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5425 tdata->plaintext.data,
5426 tdata->plaintext.len >> 3,
5427 "KASUMI Plaintext data not as expected");
5429 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5431 tdata->ciphertext.data,
5432 tdata->ciphertext.len >> 3,
5433 "KASUMI Ciphertext data not as expected");
5435 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5438 DIGEST_BYTE_LENGTH_KASUMI_F9,
5439 "KASUMI Generated auth tag not as expected");
5445 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5446 uint8_t op_mode, uint8_t verify)
5448 struct crypto_testsuite_params *ts_params = &testsuite_params;
5449 struct crypto_unittest_params *ut_params = &unittest_params;
5453 const uint8_t *plaintext = NULL;
5454 const uint8_t *ciphertext = NULL;
5455 const uint8_t *digest = NULL;
5456 unsigned int plaintext_pad_len;
5457 unsigned int plaintext_len;
5458 unsigned int ciphertext_pad_len;
5459 unsigned int ciphertext_len;
5460 uint8_t buffer[10000];
5461 uint8_t digest_buffer[10000];
5463 struct rte_cryptodev_info dev_info;
5465 /* Verify the capabilities */
5466 struct rte_cryptodev_sym_capability_idx cap_idx;
5467 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5468 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5469 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5471 return TEST_SKIPPED;
5472 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5473 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5474 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5476 return TEST_SKIPPED;
5478 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5479 return TEST_SKIPPED;
5481 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5483 uint64_t feat_flags = dev_info.feature_flags;
5485 if (op_mode == IN_PLACE) {
5486 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5487 printf("Device doesn't support in-place scatter-gather "
5488 "in both input and output mbufs.\n");
5489 return TEST_SKIPPED;
5491 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5492 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5493 printf("Device doesn't support RAW data-path APIs.\n");
5494 return TEST_SKIPPED;
5497 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5498 return TEST_SKIPPED;
5499 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5500 printf("Device doesn't support out-of-place scatter-gather "
5501 "in both input and output mbufs.\n");
5502 return TEST_SKIPPED;
5504 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5505 printf("Device doesn't support digest encrypted.\n");
5506 return TEST_SKIPPED;
5510 /* Create KASUMI session */
5511 retval = create_wireless_algo_auth_cipher_session(
5512 ts_params->valid_devs[0],
5513 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5514 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5515 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5516 : RTE_CRYPTO_AUTH_OP_GENERATE),
5517 RTE_CRYPTO_AUTH_KASUMI_F9,
5518 RTE_CRYPTO_CIPHER_KASUMI_F8,
5519 tdata->key.data, tdata->key.len,
5520 0, tdata->digest.len,
5521 tdata->cipher_iv.len);
5526 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5527 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5528 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5529 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5531 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5532 plaintext_pad_len, 15, 0);
5533 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5534 "Failed to allocate input buffer in mempool");
5536 if (op_mode == OUT_OF_PLACE) {
5537 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5538 plaintext_pad_len, 15, 0);
5539 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5540 "Failed to allocate output buffer in mempool");
5544 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5545 tdata->ciphertext.data);
5546 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5547 ciphertext_len, buffer);
5548 debug_hexdump(stdout, "ciphertext:", ciphertext,
5551 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5552 tdata->plaintext.data);
5553 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5554 plaintext_len, buffer);
5555 debug_hexdump(stdout, "plaintext:", plaintext,
5558 memset(buffer, 0, sizeof(buffer));
5560 /* Create KASUMI operation */
5561 retval = create_wireless_algo_auth_cipher_operation(
5562 tdata->digest.data, tdata->digest.len,
5563 tdata->cipher_iv.data, tdata->cipher_iv.len,
5565 (tdata->digest.offset_bytes == 0 ?
5566 (verify ? ciphertext_pad_len : plaintext_pad_len)
5567 : tdata->digest.offset_bytes),
5568 tdata->validCipherLenInBits.len,
5569 tdata->validCipherOffsetInBits.len,
5570 tdata->validAuthLenInBits.len,
5572 op_mode, 1, verify);
5577 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5578 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5579 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5581 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5584 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5586 ut_params->obuf = (op_mode == IN_PLACE ?
5587 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5590 if (ut_params->obuf)
5591 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5592 plaintext_len, buffer);
5594 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5595 plaintext_len, buffer);
5597 debug_hexdump(stdout, "plaintext:", plaintext,
5598 (tdata->plaintext.len >> 3) - tdata->digest.len);
5599 debug_hexdump(stdout, "plaintext expected:",
5600 tdata->plaintext.data,
5601 (tdata->plaintext.len >> 3) - tdata->digest.len);
5603 if (ut_params->obuf)
5604 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5605 ciphertext_len, buffer);
5607 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5608 ciphertext_len, buffer);
5610 debug_hexdump(stdout, "ciphertext:", ciphertext,
5612 debug_hexdump(stdout, "ciphertext expected:",
5613 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5615 if (ut_params->obuf)
5616 digest = rte_pktmbuf_read(ut_params->obuf,
5617 (tdata->digest.offset_bytes == 0 ?
5618 plaintext_pad_len : tdata->digest.offset_bytes),
5619 tdata->digest.len, digest_buffer);
5621 digest = rte_pktmbuf_read(ut_params->ibuf,
5622 (tdata->digest.offset_bytes == 0 ?
5623 plaintext_pad_len : tdata->digest.offset_bytes),
5624 tdata->digest.len, digest_buffer);
5626 debug_hexdump(stdout, "digest:", digest,
5628 debug_hexdump(stdout, "digest expected:",
5629 tdata->digest.data, tdata->digest.len);
5634 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5636 tdata->plaintext.data,
5637 tdata->plaintext.len >> 3,
5638 "KASUMI Plaintext data not as expected");
5640 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5642 tdata->ciphertext.data,
5643 tdata->validDataLenInBits.len,
5644 "KASUMI Ciphertext data not as expected");
5646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5649 DIGEST_BYTE_LENGTH_KASUMI_F9,
5650 "KASUMI Generated auth tag not as expected");
5656 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5658 struct crypto_testsuite_params *ts_params = &testsuite_params;
5659 struct crypto_unittest_params *ut_params = &unittest_params;
5663 uint8_t *plaintext, *ciphertext;
5664 unsigned plaintext_pad_len;
5665 unsigned plaintext_len;
5666 struct rte_cryptodev_info dev_info;
5668 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5669 uint64_t feat_flags = dev_info.feature_flags;
5671 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5672 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5673 printf("Device doesn't support RAW data-path APIs.\n");
5674 return TEST_SKIPPED;
5677 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5678 return TEST_SKIPPED;
5680 /* Verify the capabilities */
5681 struct rte_cryptodev_sym_capability_idx cap_idx;
5682 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5683 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5684 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5686 return TEST_SKIPPED;
5687 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5688 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5689 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5691 return TEST_SKIPPED;
5693 /* Create KASUMI session */
5694 retval = create_wireless_algo_cipher_auth_session(
5695 ts_params->valid_devs[0],
5696 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5697 RTE_CRYPTO_AUTH_OP_GENERATE,
5698 RTE_CRYPTO_AUTH_KASUMI_F9,
5699 RTE_CRYPTO_CIPHER_KASUMI_F8,
5700 tdata->key.data, tdata->key.len,
5701 0, tdata->digest.len,
5702 tdata->cipher_iv.len);
5706 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5708 /* clear mbuf payload */
5709 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5710 rte_pktmbuf_tailroom(ut_params->ibuf));
5712 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5713 /* Append data which is padded to a multiple of */
5714 /* the algorithms block size */
5715 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5716 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5718 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5720 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5722 /* Create KASUMI operation */
5723 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5724 tdata->digest.len, NULL, 0,
5725 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5726 tdata->cipher_iv.data, tdata->cipher_iv.len,
5727 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5728 tdata->validCipherOffsetInBits.len,
5729 tdata->validAuthLenInBits.len,
5735 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5736 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5737 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5739 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5741 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5743 if (ut_params->op->sym->m_dst)
5744 ut_params->obuf = ut_params->op->sym->m_dst;
5746 ut_params->obuf = ut_params->op->sym->m_src;
5748 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5749 tdata->validCipherOffsetInBits.len >> 3);
5751 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5752 + plaintext_pad_len;
5754 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5755 (tdata->validCipherOffsetInBits.len >> 3);
5757 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5759 reference_ciphertext,
5760 tdata->validCipherLenInBits.len,
5761 "KASUMI Ciphertext data not as expected");
5764 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5767 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5768 "KASUMI Generated auth tag not as expected");
5773 test_zuc_encryption(const struct wireless_test_data *tdata)
5775 struct crypto_testsuite_params *ts_params = &testsuite_params;
5776 struct crypto_unittest_params *ut_params = &unittest_params;
5779 uint8_t *plaintext, *ciphertext;
5780 unsigned plaintext_pad_len;
5781 unsigned plaintext_len;
5782 struct rte_cryptodev_info dev_info;
5784 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5785 uint64_t feat_flags = dev_info.feature_flags;
5787 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5788 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5789 printf("Device doesn't support RAW data-path APIs.\n");
5790 return TEST_SKIPPED;
5793 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5794 return TEST_SKIPPED;
5796 struct rte_cryptodev_sym_capability_idx cap_idx;
5798 /* Check if device supports ZUC EEA3 */
5799 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5800 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5802 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5804 return TEST_SKIPPED;
5806 /* Create ZUC session */
5807 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5808 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5809 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5810 tdata->key.data, tdata->key.len,
5811 tdata->cipher_iv.len);
5815 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5817 /* Clear mbuf payload */
5818 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5819 rte_pktmbuf_tailroom(ut_params->ibuf));
5821 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5822 /* Append data which is padded to a multiple */
5823 /* of the algorithms block size */
5824 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5825 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5827 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5829 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5831 /* Create ZUC operation */
5832 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5833 tdata->cipher_iv.len,
5834 tdata->plaintext.len,
5839 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5840 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5841 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5843 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5845 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5847 ut_params->obuf = ut_params->op->sym->m_dst;
5848 if (ut_params->obuf)
5849 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5851 ciphertext = plaintext;
5853 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5856 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5858 tdata->ciphertext.data,
5859 tdata->validCipherLenInBits.len,
5860 "ZUC Ciphertext data not as expected");
5865 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5867 struct crypto_testsuite_params *ts_params = &testsuite_params;
5868 struct crypto_unittest_params *ut_params = &unittest_params;
5872 unsigned int plaintext_pad_len;
5873 unsigned int plaintext_len;
5874 const uint8_t *ciphertext;
5875 uint8_t ciphertext_buffer[2048];
5876 struct rte_cryptodev_info dev_info;
5878 struct rte_cryptodev_sym_capability_idx cap_idx;
5880 /* Check if device supports ZUC EEA3 */
5881 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5882 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5884 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5886 return TEST_SKIPPED;
5888 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5889 return TEST_SKIPPED;
5891 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5893 uint64_t feat_flags = dev_info.feature_flags;
5895 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5896 printf("Device doesn't support in-place scatter-gather. "
5898 return TEST_SKIPPED;
5901 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5902 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5903 printf("Device doesn't support RAW data-path APIs.\n");
5904 return TEST_SKIPPED;
5907 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5909 /* Append data which is padded to a multiple */
5910 /* of the algorithms block size */
5911 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5913 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5914 plaintext_pad_len, 10, 0);
5916 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5917 tdata->plaintext.data);
5919 /* Create ZUC session */
5920 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5921 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5922 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5923 tdata->key.data, tdata->key.len,
5924 tdata->cipher_iv.len);
5928 /* Clear mbuf payload */
5930 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5932 /* Create ZUC operation */
5933 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5934 tdata->cipher_iv.len, tdata->plaintext.len,
5939 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5940 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5941 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5943 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5945 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5947 ut_params->obuf = ut_params->op->sym->m_dst;
5948 if (ut_params->obuf)
5949 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5950 0, plaintext_len, ciphertext_buffer);
5952 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5953 0, plaintext_len, ciphertext_buffer);
5956 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5959 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5961 tdata->ciphertext.data,
5962 tdata->validCipherLenInBits.len,
5963 "ZUC Ciphertext data not as expected");
5969 test_zuc_authentication(const struct wireless_test_data *tdata)
5971 struct crypto_testsuite_params *ts_params = &testsuite_params;
5972 struct crypto_unittest_params *ut_params = &unittest_params;
5975 unsigned plaintext_pad_len;
5976 unsigned plaintext_len;
5979 struct rte_cryptodev_sym_capability_idx cap_idx;
5980 struct rte_cryptodev_info dev_info;
5982 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5983 uint64_t feat_flags = dev_info.feature_flags;
5985 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5986 (tdata->validAuthLenInBits.len % 8 != 0)) {
5987 printf("Device doesn't support NON-Byte Aligned Data.\n");
5988 return TEST_SKIPPED;
5991 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5992 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5993 printf("Device doesn't support RAW data-path APIs.\n");
5994 return TEST_SKIPPED;
5997 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5998 return TEST_SKIPPED;
6000 /* Check if device supports ZUC EIA3 */
6001 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6002 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6004 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6006 return TEST_SKIPPED;
6008 /* Create ZUC session */
6009 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6010 tdata->key.data, tdata->key.len,
6011 tdata->auth_iv.len, tdata->digest.len,
6012 RTE_CRYPTO_AUTH_OP_GENERATE,
6013 RTE_CRYPTO_AUTH_ZUC_EIA3);
6017 /* alloc mbuf and set payload */
6018 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6020 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6021 rte_pktmbuf_tailroom(ut_params->ibuf));
6023 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6024 /* Append data which is padded to a multiple of */
6025 /* the algorithms block size */
6026 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6027 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6029 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6031 /* Create ZUC operation */
6032 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6033 tdata->auth_iv.data, tdata->auth_iv.len,
6034 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6035 tdata->validAuthLenInBits.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, 0, 1, 1, 0);
6044 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6046 ut_params->obuf = ut_params->op->sym->m_src;
6047 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6048 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6049 + plaintext_pad_len;
6052 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6056 "ZUC Generated auth tag not as expected");
6062 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6063 uint8_t op_mode, uint8_t verify)
6065 struct crypto_testsuite_params *ts_params = &testsuite_params;
6066 struct crypto_unittest_params *ut_params = &unittest_params;
6070 uint8_t *plaintext = NULL, *ciphertext = NULL;
6071 unsigned int plaintext_pad_len;
6072 unsigned int plaintext_len;
6073 unsigned int ciphertext_pad_len;
6074 unsigned int ciphertext_len;
6076 struct rte_cryptodev_info dev_info;
6077 struct rte_cryptodev_sym_capability_idx cap_idx;
6079 /* Check if device supports ZUC EIA3 */
6080 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6081 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6083 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
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_DIGEST_ENCRYPTED)) {
6092 printf("Device doesn't support digest encrypted.\n");
6093 return TEST_SKIPPED;
6095 if (op_mode == IN_PLACE) {
6096 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6097 printf("Device doesn't support in-place scatter-gather "
6098 "in both input and output mbufs.\n");
6099 return TEST_SKIPPED;
6102 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6103 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6104 printf("Device doesn't support RAW data-path APIs.\n");
6105 return TEST_SKIPPED;
6108 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6109 return TEST_SKIPPED;
6110 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6111 printf("Device doesn't support out-of-place scatter-gather "
6112 "in both input and output mbufs.\n");
6113 return TEST_SKIPPED;
6117 /* Create ZUC session */
6118 retval = create_wireless_algo_auth_cipher_session(
6119 ts_params->valid_devs[0],
6120 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6121 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6122 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6123 : RTE_CRYPTO_AUTH_OP_GENERATE),
6124 RTE_CRYPTO_AUTH_ZUC_EIA3,
6125 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6126 tdata->key.data, tdata->key.len,
6127 tdata->auth_iv.len, tdata->digest.len,
6128 tdata->cipher_iv.len);
6133 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6134 if (op_mode == OUT_OF_PLACE)
6135 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6137 /* clear mbuf payload */
6138 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6139 rte_pktmbuf_tailroom(ut_params->ibuf));
6140 if (op_mode == OUT_OF_PLACE)
6141 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6142 rte_pktmbuf_tailroom(ut_params->obuf));
6144 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6145 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6146 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6147 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6150 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6151 ciphertext_pad_len);
6152 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6153 if (op_mode == OUT_OF_PLACE)
6154 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6155 debug_hexdump(stdout, "ciphertext:", ciphertext,
6158 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6160 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6161 if (op_mode == OUT_OF_PLACE)
6162 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6163 debug_hexdump(stdout, "plaintext:", plaintext,
6167 /* Create ZUC operation */
6168 retval = create_wireless_algo_auth_cipher_operation(
6169 tdata->digest.data, tdata->digest.len,
6170 tdata->cipher_iv.data, tdata->cipher_iv.len,
6171 tdata->auth_iv.data, tdata->auth_iv.len,
6172 (tdata->digest.offset_bytes == 0 ?
6173 (verify ? ciphertext_pad_len : plaintext_pad_len)
6174 : tdata->digest.offset_bytes),
6175 tdata->validCipherLenInBits.len,
6176 tdata->validCipherOffsetInBits.len,
6177 tdata->validAuthLenInBits.len,
6179 op_mode, 0, verify);
6184 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6185 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6186 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6188 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6193 ut_params->obuf = (op_mode == IN_PLACE ?
6194 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6198 if (ut_params->obuf)
6199 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6202 plaintext = ciphertext;
6204 debug_hexdump(stdout, "plaintext:", plaintext,
6205 (tdata->plaintext.len >> 3) - tdata->digest.len);
6206 debug_hexdump(stdout, "plaintext expected:",
6207 tdata->plaintext.data,
6208 (tdata->plaintext.len >> 3) - tdata->digest.len);
6210 if (ut_params->obuf)
6211 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6214 ciphertext = plaintext;
6216 debug_hexdump(stdout, "ciphertext:", ciphertext,
6218 debug_hexdump(stdout, "ciphertext expected:",
6219 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6221 ut_params->digest = rte_pktmbuf_mtod(
6222 ut_params->obuf, uint8_t *) +
6223 (tdata->digest.offset_bytes == 0 ?
6224 plaintext_pad_len : tdata->digest.offset_bytes);
6226 debug_hexdump(stdout, "digest:", ut_params->digest,
6228 debug_hexdump(stdout, "digest expected:",
6229 tdata->digest.data, tdata->digest.len);
6234 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6236 tdata->plaintext.data,
6237 tdata->plaintext.len >> 3,
6238 "ZUC Plaintext data not as expected");
6240 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6242 tdata->ciphertext.data,
6243 tdata->ciphertext.len >> 3,
6244 "ZUC Ciphertext data not as expected");
6246 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6249 DIGEST_BYTE_LENGTH_KASUMI_F9,
6250 "ZUC Generated auth tag not as expected");
6256 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6257 uint8_t op_mode, uint8_t verify)
6259 struct crypto_testsuite_params *ts_params = &testsuite_params;
6260 struct crypto_unittest_params *ut_params = &unittest_params;
6264 const uint8_t *plaintext = NULL;
6265 const uint8_t *ciphertext = NULL;
6266 const uint8_t *digest = NULL;
6267 unsigned int plaintext_pad_len;
6268 unsigned int plaintext_len;
6269 unsigned int ciphertext_pad_len;
6270 unsigned int ciphertext_len;
6271 uint8_t buffer[10000];
6272 uint8_t digest_buffer[10000];
6274 struct rte_cryptodev_info dev_info;
6275 struct rte_cryptodev_sym_capability_idx cap_idx;
6277 /* Check if device supports ZUC EIA3 */
6278 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6279 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6281 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6283 return TEST_SKIPPED;
6285 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6287 uint64_t feat_flags = dev_info.feature_flags;
6289 if (op_mode == IN_PLACE) {
6290 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6291 printf("Device doesn't support in-place scatter-gather "
6292 "in both input and output mbufs.\n");
6293 return TEST_SKIPPED;
6296 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6297 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6298 printf("Device doesn't support RAW data-path APIs.\n");
6299 return TEST_SKIPPED;
6302 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6303 return TEST_SKIPPED;
6304 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6305 printf("Device doesn't support out-of-place scatter-gather "
6306 "in both input and output mbufs.\n");
6307 return TEST_SKIPPED;
6309 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6310 printf("Device doesn't support digest encrypted.\n");
6311 return TEST_SKIPPED;
6315 /* Create ZUC session */
6316 retval = create_wireless_algo_auth_cipher_session(
6317 ts_params->valid_devs[0],
6318 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6319 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6320 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6321 : RTE_CRYPTO_AUTH_OP_GENERATE),
6322 RTE_CRYPTO_AUTH_ZUC_EIA3,
6323 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6324 tdata->key.data, tdata->key.len,
6325 tdata->auth_iv.len, tdata->digest.len,
6326 tdata->cipher_iv.len);
6331 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6332 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6333 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6334 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6336 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6337 plaintext_pad_len, 15, 0);
6338 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6339 "Failed to allocate input buffer in mempool");
6341 if (op_mode == OUT_OF_PLACE) {
6342 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6343 plaintext_pad_len, 15, 0);
6344 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6345 "Failed to allocate output buffer in mempool");
6349 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6350 tdata->ciphertext.data);
6351 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6352 ciphertext_len, buffer);
6353 debug_hexdump(stdout, "ciphertext:", ciphertext,
6356 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6357 tdata->plaintext.data);
6358 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6359 plaintext_len, buffer);
6360 debug_hexdump(stdout, "plaintext:", plaintext,
6363 memset(buffer, 0, sizeof(buffer));
6365 /* Create ZUC operation */
6366 retval = create_wireless_algo_auth_cipher_operation(
6367 tdata->digest.data, tdata->digest.len,
6368 tdata->cipher_iv.data, tdata->cipher_iv.len,
6370 (tdata->digest.offset_bytes == 0 ?
6371 (verify ? ciphertext_pad_len : plaintext_pad_len)
6372 : tdata->digest.offset_bytes),
6373 tdata->validCipherLenInBits.len,
6374 tdata->validCipherOffsetInBits.len,
6375 tdata->validAuthLenInBits.len,
6377 op_mode, 1, verify);
6382 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6383 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6384 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6386 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6389 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6391 ut_params->obuf = (op_mode == IN_PLACE ?
6392 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6395 if (ut_params->obuf)
6396 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6397 plaintext_len, buffer);
6399 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6400 plaintext_len, buffer);
6402 debug_hexdump(stdout, "plaintext:", plaintext,
6403 (tdata->plaintext.len >> 3) - tdata->digest.len);
6404 debug_hexdump(stdout, "plaintext expected:",
6405 tdata->plaintext.data,
6406 (tdata->plaintext.len >> 3) - tdata->digest.len);
6408 if (ut_params->obuf)
6409 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6410 ciphertext_len, buffer);
6412 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6413 ciphertext_len, buffer);
6415 debug_hexdump(stdout, "ciphertext:", ciphertext,
6417 debug_hexdump(stdout, "ciphertext expected:",
6418 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6420 if (ut_params->obuf)
6421 digest = rte_pktmbuf_read(ut_params->obuf,
6422 (tdata->digest.offset_bytes == 0 ?
6423 plaintext_pad_len : tdata->digest.offset_bytes),
6424 tdata->digest.len, digest_buffer);
6426 digest = rte_pktmbuf_read(ut_params->ibuf,
6427 (tdata->digest.offset_bytes == 0 ?
6428 plaintext_pad_len : tdata->digest.offset_bytes),
6429 tdata->digest.len, digest_buffer);
6431 debug_hexdump(stdout, "digest:", digest,
6433 debug_hexdump(stdout, "digest expected:",
6434 tdata->digest.data, tdata->digest.len);
6439 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6441 tdata->plaintext.data,
6442 tdata->plaintext.len >> 3,
6443 "ZUC Plaintext data not as expected");
6445 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6447 tdata->ciphertext.data,
6448 tdata->validDataLenInBits.len,
6449 "ZUC Ciphertext data not as expected");
6451 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6454 DIGEST_BYTE_LENGTH_KASUMI_F9,
6455 "ZUC Generated auth tag not as expected");
6461 test_kasumi_encryption_test_case_1(void)
6463 return test_kasumi_encryption(&kasumi_test_case_1);
6467 test_kasumi_encryption_test_case_1_sgl(void)
6469 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6473 test_kasumi_encryption_test_case_1_oop(void)
6475 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6479 test_kasumi_encryption_test_case_1_oop_sgl(void)
6481 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6485 test_kasumi_encryption_test_case_2(void)
6487 return test_kasumi_encryption(&kasumi_test_case_2);
6491 test_kasumi_encryption_test_case_3(void)
6493 return test_kasumi_encryption(&kasumi_test_case_3);
6497 test_kasumi_encryption_test_case_4(void)
6499 return test_kasumi_encryption(&kasumi_test_case_4);
6503 test_kasumi_encryption_test_case_5(void)
6505 return test_kasumi_encryption(&kasumi_test_case_5);
6509 test_kasumi_decryption_test_case_1(void)
6511 return test_kasumi_decryption(&kasumi_test_case_1);
6515 test_kasumi_decryption_test_case_1_oop(void)
6517 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6521 test_kasumi_decryption_test_case_2(void)
6523 return test_kasumi_decryption(&kasumi_test_case_2);
6527 test_kasumi_decryption_test_case_3(void)
6529 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6530 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6531 return TEST_SKIPPED;
6532 return test_kasumi_decryption(&kasumi_test_case_3);
6536 test_kasumi_decryption_test_case_4(void)
6538 return test_kasumi_decryption(&kasumi_test_case_4);
6542 test_kasumi_decryption_test_case_5(void)
6544 return test_kasumi_decryption(&kasumi_test_case_5);
6547 test_snow3g_encryption_test_case_1(void)
6549 return test_snow3g_encryption(&snow3g_test_case_1);
6553 test_snow3g_encryption_test_case_1_oop(void)
6555 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6559 test_snow3g_encryption_test_case_1_oop_sgl(void)
6561 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6566 test_snow3g_encryption_test_case_1_offset_oop(void)
6568 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6572 test_snow3g_encryption_test_case_2(void)
6574 return test_snow3g_encryption(&snow3g_test_case_2);
6578 test_snow3g_encryption_test_case_3(void)
6580 return test_snow3g_encryption(&snow3g_test_case_3);
6584 test_snow3g_encryption_test_case_4(void)
6586 return test_snow3g_encryption(&snow3g_test_case_4);
6590 test_snow3g_encryption_test_case_5(void)
6592 return test_snow3g_encryption(&snow3g_test_case_5);
6596 test_snow3g_decryption_test_case_1(void)
6598 return test_snow3g_decryption(&snow3g_test_case_1);
6602 test_snow3g_decryption_test_case_1_oop(void)
6604 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6608 test_snow3g_decryption_test_case_2(void)
6610 return test_snow3g_decryption(&snow3g_test_case_2);
6614 test_snow3g_decryption_test_case_3(void)
6616 return test_snow3g_decryption(&snow3g_test_case_3);
6620 test_snow3g_decryption_test_case_4(void)
6622 return test_snow3g_decryption(&snow3g_test_case_4);
6626 test_snow3g_decryption_test_case_5(void)
6628 return test_snow3g_decryption(&snow3g_test_case_5);
6632 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6633 * Pattern digest from snow3g_test_data must be allocated as
6634 * 4 last bytes in plaintext.
6637 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6638 struct snow3g_hash_test_data *output)
6640 if ((pattern != NULL) && (output != NULL)) {
6641 output->key.len = pattern->key.len;
6643 memcpy(output->key.data,
6644 pattern->key.data, pattern->key.len);
6646 output->auth_iv.len = pattern->auth_iv.len;
6648 memcpy(output->auth_iv.data,
6649 pattern->auth_iv.data, pattern->auth_iv.len);
6651 output->plaintext.len = pattern->plaintext.len;
6653 memcpy(output->plaintext.data,
6654 pattern->plaintext.data, pattern->plaintext.len >> 3);
6656 output->digest.len = pattern->digest.len;
6658 memcpy(output->digest.data,
6659 &pattern->plaintext.data[pattern->digest.offset_bytes],
6660 pattern->digest.len);
6662 output->validAuthLenInBits.len =
6663 pattern->validAuthLenInBits.len;
6668 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6671 test_snow3g_decryption_with_digest_test_case_1(void)
6673 struct snow3g_hash_test_data snow3g_hash_data;
6674 struct rte_cryptodev_info dev_info;
6675 struct crypto_testsuite_params *ts_params = &testsuite_params;
6677 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6678 uint64_t feat_flags = dev_info.feature_flags;
6680 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6681 printf("Device doesn't support encrypted digest operations.\n");
6682 return TEST_SKIPPED;
6686 * Function prepare data for hash veryfication test case.
6687 * Digest is allocated in 4 last bytes in plaintext, pattern.
6689 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6691 return test_snow3g_decryption(&snow3g_test_case_7) &
6692 test_snow3g_authentication_verify(&snow3g_hash_data);
6696 test_snow3g_cipher_auth_test_case_1(void)
6698 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6702 test_snow3g_auth_cipher_test_case_1(void)
6704 return test_snow3g_auth_cipher(
6705 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6709 test_snow3g_auth_cipher_test_case_2(void)
6711 return test_snow3g_auth_cipher(
6712 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6716 test_snow3g_auth_cipher_test_case_2_oop(void)
6718 return test_snow3g_auth_cipher(
6719 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6723 test_snow3g_auth_cipher_part_digest_enc(void)
6725 return test_snow3g_auth_cipher(
6726 &snow3g_auth_cipher_partial_digest_encryption,
6731 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6733 return test_snow3g_auth_cipher(
6734 &snow3g_auth_cipher_partial_digest_encryption,
6739 test_snow3g_auth_cipher_test_case_3_sgl(void)
6741 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6742 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6743 return TEST_SKIPPED;
6744 return test_snow3g_auth_cipher_sgl(
6745 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6749 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6751 return test_snow3g_auth_cipher_sgl(
6752 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6756 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6758 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6759 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6760 return TEST_SKIPPED;
6761 return test_snow3g_auth_cipher_sgl(
6762 &snow3g_auth_cipher_partial_digest_encryption,
6767 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6769 return test_snow3g_auth_cipher_sgl(
6770 &snow3g_auth_cipher_partial_digest_encryption,
6775 test_snow3g_auth_cipher_verify_test_case_1(void)
6777 return test_snow3g_auth_cipher(
6778 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6782 test_snow3g_auth_cipher_verify_test_case_2(void)
6784 return test_snow3g_auth_cipher(
6785 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6789 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6791 return test_snow3g_auth_cipher(
6792 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6796 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6798 return test_snow3g_auth_cipher(
6799 &snow3g_auth_cipher_partial_digest_encryption,
6804 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6806 return test_snow3g_auth_cipher(
6807 &snow3g_auth_cipher_partial_digest_encryption,
6812 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6814 return test_snow3g_auth_cipher_sgl(
6815 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6819 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6821 return test_snow3g_auth_cipher_sgl(
6822 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6826 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6828 return test_snow3g_auth_cipher_sgl(
6829 &snow3g_auth_cipher_partial_digest_encryption,
6834 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6836 return test_snow3g_auth_cipher_sgl(
6837 &snow3g_auth_cipher_partial_digest_encryption,
6842 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6844 return test_snow3g_auth_cipher(
6845 &snow3g_test_case_7, IN_PLACE, 0);
6849 test_kasumi_auth_cipher_test_case_1(void)
6851 return test_kasumi_auth_cipher(
6852 &kasumi_test_case_3, IN_PLACE, 0);
6856 test_kasumi_auth_cipher_test_case_2(void)
6858 return test_kasumi_auth_cipher(
6859 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6863 test_kasumi_auth_cipher_test_case_2_oop(void)
6865 return test_kasumi_auth_cipher(
6866 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6870 test_kasumi_auth_cipher_test_case_2_sgl(void)
6872 return test_kasumi_auth_cipher_sgl(
6873 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6877 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6879 return test_kasumi_auth_cipher_sgl(
6880 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6884 test_kasumi_auth_cipher_verify_test_case_1(void)
6886 return test_kasumi_auth_cipher(
6887 &kasumi_test_case_3, IN_PLACE, 1);
6891 test_kasumi_auth_cipher_verify_test_case_2(void)
6893 return test_kasumi_auth_cipher(
6894 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6898 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6900 return test_kasumi_auth_cipher(
6901 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6905 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6907 return test_kasumi_auth_cipher_sgl(
6908 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6912 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6914 return test_kasumi_auth_cipher_sgl(
6915 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6919 test_kasumi_cipher_auth_test_case_1(void)
6921 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6925 test_zuc_encryption_test_case_1(void)
6927 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6931 test_zuc_encryption_test_case_2(void)
6933 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6937 test_zuc_encryption_test_case_3(void)
6939 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6943 test_zuc_encryption_test_case_4(void)
6945 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6949 test_zuc_encryption_test_case_5(void)
6951 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6955 test_zuc_encryption_test_case_6_sgl(void)
6957 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6961 test_zuc_hash_generate_test_case_1(void)
6963 return test_zuc_authentication(&zuc_test_case_auth_1b);
6967 test_zuc_hash_generate_test_case_2(void)
6969 return test_zuc_authentication(&zuc_test_case_auth_90b);
6973 test_zuc_hash_generate_test_case_3(void)
6975 return test_zuc_authentication(&zuc_test_case_auth_577b);
6979 test_zuc_hash_generate_test_case_4(void)
6981 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6985 test_zuc_hash_generate_test_case_5(void)
6987 return test_zuc_authentication(&zuc_test_auth_5670b);
6991 test_zuc_hash_generate_test_case_6(void)
6993 return test_zuc_authentication(&zuc_test_case_auth_128b);
6997 test_zuc_hash_generate_test_case_7(void)
6999 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7003 test_zuc_hash_generate_test_case_8(void)
7005 return test_zuc_authentication(&zuc_test_case_auth_584b);
7009 test_zuc_cipher_auth_test_case_1(void)
7011 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7015 test_zuc_cipher_auth_test_case_2(void)
7017 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7021 test_zuc_auth_cipher_test_case_1(void)
7023 return test_zuc_auth_cipher(
7024 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7028 test_zuc_auth_cipher_test_case_1_oop(void)
7030 return test_zuc_auth_cipher(
7031 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7035 test_zuc_auth_cipher_test_case_1_sgl(void)
7037 return test_zuc_auth_cipher_sgl(
7038 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7042 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7044 return test_zuc_auth_cipher_sgl(
7045 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7049 test_zuc_auth_cipher_verify_test_case_1(void)
7051 return test_zuc_auth_cipher(
7052 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7056 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7058 return test_zuc_auth_cipher(
7059 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7063 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7065 return test_zuc_auth_cipher_sgl(
7066 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7070 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7072 return test_zuc_auth_cipher_sgl(
7073 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7077 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7079 uint8_t dev_id = testsuite_params.valid_devs[0];
7081 struct rte_cryptodev_sym_capability_idx cap_idx;
7083 /* Check if device supports particular cipher algorithm */
7084 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7085 cap_idx.algo.cipher = tdata->cipher_algo;
7086 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7087 return TEST_SKIPPED;
7089 /* Check if device supports particular hash algorithm */
7090 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7091 cap_idx.algo.auth = tdata->auth_algo;
7092 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7093 return TEST_SKIPPED;
7099 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7100 uint8_t op_mode, uint8_t verify)
7102 struct crypto_testsuite_params *ts_params = &testsuite_params;
7103 struct crypto_unittest_params *ut_params = &unittest_params;
7107 uint8_t *plaintext = NULL, *ciphertext = NULL;
7108 unsigned int plaintext_pad_len;
7109 unsigned int plaintext_len;
7110 unsigned int ciphertext_pad_len;
7111 unsigned int ciphertext_len;
7113 struct rte_cryptodev_info dev_info;
7114 struct rte_crypto_op *op;
7116 /* Check if device supports particular algorithms separately */
7117 if (test_mixed_check_if_unsupported(tdata))
7118 return TEST_SKIPPED;
7119 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7120 return TEST_SKIPPED;
7122 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7124 uint64_t feat_flags = dev_info.feature_flags;
7126 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7127 printf("Device doesn't support digest encrypted.\n");
7128 return TEST_SKIPPED;
7131 /* Create the session */
7133 retval = create_wireless_algo_cipher_auth_session(
7134 ts_params->valid_devs[0],
7135 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7136 RTE_CRYPTO_AUTH_OP_VERIFY,
7139 tdata->auth_key.data, tdata->auth_key.len,
7140 tdata->auth_iv.len, tdata->digest_enc.len,
7141 tdata->cipher_iv.len);
7143 retval = create_wireless_algo_auth_cipher_session(
7144 ts_params->valid_devs[0],
7145 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7146 RTE_CRYPTO_AUTH_OP_GENERATE,
7149 tdata->auth_key.data, tdata->auth_key.len,
7150 tdata->auth_iv.len, tdata->digest_enc.len,
7151 tdata->cipher_iv.len);
7155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7156 if (op_mode == OUT_OF_PLACE)
7157 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7159 /* clear mbuf payload */
7160 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7161 rte_pktmbuf_tailroom(ut_params->ibuf));
7162 if (op_mode == OUT_OF_PLACE) {
7164 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7165 rte_pktmbuf_tailroom(ut_params->obuf));
7168 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7169 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7170 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7171 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7174 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7175 ciphertext_pad_len);
7176 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7177 if (op_mode == OUT_OF_PLACE)
7178 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7179 debug_hexdump(stdout, "ciphertext:", ciphertext,
7182 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7184 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7185 if (op_mode == OUT_OF_PLACE)
7186 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7187 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7190 /* Create the operation */
7191 retval = create_wireless_algo_auth_cipher_operation(
7192 tdata->digest_enc.data, tdata->digest_enc.len,
7193 tdata->cipher_iv.data, tdata->cipher_iv.len,
7194 tdata->auth_iv.data, tdata->auth_iv.len,
7195 (tdata->digest_enc.offset == 0 ?
7197 : tdata->digest_enc.offset),
7198 tdata->validCipherLen.len_bits,
7199 tdata->cipher.offset_bits,
7200 tdata->validAuthLen.len_bits,
7201 tdata->auth.offset_bits,
7202 op_mode, 0, verify);
7207 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7209 /* Check if the op failed because the device doesn't */
7210 /* support this particular combination of algorithms */
7211 if (op == NULL && ut_params->op->status ==
7212 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7213 printf("Device doesn't support this mixed combination. "
7215 return TEST_SKIPPED;
7219 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7221 ut_params->obuf = (op_mode == IN_PLACE ?
7222 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7225 if (ut_params->obuf)
7226 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7229 plaintext = ciphertext +
7230 (tdata->cipher.offset_bits >> 3);
7232 debug_hexdump(stdout, "plaintext:", plaintext,
7233 tdata->plaintext.len_bits >> 3);
7234 debug_hexdump(stdout, "plaintext expected:",
7235 tdata->plaintext.data,
7236 tdata->plaintext.len_bits >> 3);
7238 if (ut_params->obuf)
7239 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7242 ciphertext = plaintext;
7244 debug_hexdump(stdout, "ciphertext:", ciphertext,
7246 debug_hexdump(stdout, "ciphertext expected:",
7247 tdata->ciphertext.data,
7248 tdata->ciphertext.len_bits >> 3);
7250 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7251 + (tdata->digest_enc.offset == 0 ?
7252 plaintext_pad_len : tdata->digest_enc.offset);
7254 debug_hexdump(stdout, "digest:", ut_params->digest,
7255 tdata->digest_enc.len);
7256 debug_hexdump(stdout, "digest expected:",
7257 tdata->digest_enc.data,
7258 tdata->digest_enc.len);
7263 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7265 tdata->plaintext.data,
7266 tdata->plaintext.len_bits >> 3,
7267 "Plaintext data not as expected");
7269 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7271 tdata->ciphertext.data,
7272 tdata->validDataLen.len_bits,
7273 "Ciphertext data not as expected");
7275 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7277 tdata->digest_enc.data,
7278 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7279 "Generated auth tag not as expected");
7282 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7283 "crypto op processing failed");
7289 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7290 uint8_t op_mode, uint8_t verify)
7292 struct crypto_testsuite_params *ts_params = &testsuite_params;
7293 struct crypto_unittest_params *ut_params = &unittest_params;
7297 const uint8_t *plaintext = NULL;
7298 const uint8_t *ciphertext = NULL;
7299 const uint8_t *digest = NULL;
7300 unsigned int plaintext_pad_len;
7301 unsigned int plaintext_len;
7302 unsigned int ciphertext_pad_len;
7303 unsigned int ciphertext_len;
7304 uint8_t buffer[10000];
7305 uint8_t digest_buffer[10000];
7307 struct rte_cryptodev_info dev_info;
7308 struct rte_crypto_op *op;
7310 /* Check if device supports particular algorithms */
7311 if (test_mixed_check_if_unsupported(tdata))
7312 return TEST_SKIPPED;
7313 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7314 return TEST_SKIPPED;
7316 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7318 uint64_t feat_flags = dev_info.feature_flags;
7320 if (op_mode == IN_PLACE) {
7321 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7322 printf("Device doesn't support in-place scatter-gather "
7323 "in both input and output mbufs.\n");
7324 return TEST_SKIPPED;
7327 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7328 printf("Device doesn't support out-of-place scatter-gather "
7329 "in both input and output mbufs.\n");
7330 return TEST_SKIPPED;
7332 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7333 printf("Device doesn't support digest encrypted.\n");
7334 return TEST_SKIPPED;
7338 /* Create the session */
7340 retval = create_wireless_algo_cipher_auth_session(
7341 ts_params->valid_devs[0],
7342 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7343 RTE_CRYPTO_AUTH_OP_VERIFY,
7346 tdata->auth_key.data, tdata->auth_key.len,
7347 tdata->auth_iv.len, tdata->digest_enc.len,
7348 tdata->cipher_iv.len);
7350 retval = create_wireless_algo_auth_cipher_session(
7351 ts_params->valid_devs[0],
7352 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7353 RTE_CRYPTO_AUTH_OP_GENERATE,
7356 tdata->auth_key.data, tdata->auth_key.len,
7357 tdata->auth_iv.len, tdata->digest_enc.len,
7358 tdata->cipher_iv.len);
7362 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7363 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7364 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7365 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7367 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7368 ciphertext_pad_len, 15, 0);
7369 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7370 "Failed to allocate input buffer in mempool");
7372 if (op_mode == OUT_OF_PLACE) {
7373 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7374 plaintext_pad_len, 15, 0);
7375 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7376 "Failed to allocate output buffer in mempool");
7380 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7381 tdata->ciphertext.data);
7382 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7383 ciphertext_len, buffer);
7384 debug_hexdump(stdout, "ciphertext:", ciphertext,
7387 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7388 tdata->plaintext.data);
7389 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7390 plaintext_len, buffer);
7391 debug_hexdump(stdout, "plaintext:", plaintext,
7394 memset(buffer, 0, sizeof(buffer));
7396 /* Create the operation */
7397 retval = create_wireless_algo_auth_cipher_operation(
7398 tdata->digest_enc.data, tdata->digest_enc.len,
7399 tdata->cipher_iv.data, tdata->cipher_iv.len,
7400 tdata->auth_iv.data, tdata->auth_iv.len,
7401 (tdata->digest_enc.offset == 0 ?
7403 : tdata->digest_enc.offset),
7404 tdata->validCipherLen.len_bits,
7405 tdata->cipher.offset_bits,
7406 tdata->validAuthLen.len_bits,
7407 tdata->auth.offset_bits,
7408 op_mode, 1, verify);
7413 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7415 /* Check if the op failed because the device doesn't */
7416 /* support this particular combination of algorithms */
7417 if (op == NULL && ut_params->op->status ==
7418 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7419 printf("Device doesn't support this mixed combination. "
7421 return TEST_SKIPPED;
7425 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7427 ut_params->obuf = (op_mode == IN_PLACE ?
7428 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7431 if (ut_params->obuf)
7432 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7433 plaintext_len, buffer);
7435 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7436 plaintext_len, buffer);
7438 debug_hexdump(stdout, "plaintext:", plaintext,
7439 (tdata->plaintext.len_bits >> 3) -
7440 tdata->digest_enc.len);
7441 debug_hexdump(stdout, "plaintext expected:",
7442 tdata->plaintext.data,
7443 (tdata->plaintext.len_bits >> 3) -
7444 tdata->digest_enc.len);
7446 if (ut_params->obuf)
7447 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7448 ciphertext_len, buffer);
7450 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7451 ciphertext_len, buffer);
7453 debug_hexdump(stdout, "ciphertext:", ciphertext,
7455 debug_hexdump(stdout, "ciphertext expected:",
7456 tdata->ciphertext.data,
7457 tdata->ciphertext.len_bits >> 3);
7459 if (ut_params->obuf)
7460 digest = rte_pktmbuf_read(ut_params->obuf,
7461 (tdata->digest_enc.offset == 0 ?
7463 tdata->digest_enc.offset),
7464 tdata->digest_enc.len, digest_buffer);
7466 digest = rte_pktmbuf_read(ut_params->ibuf,
7467 (tdata->digest_enc.offset == 0 ?
7469 tdata->digest_enc.offset),
7470 tdata->digest_enc.len, digest_buffer);
7472 debug_hexdump(stdout, "digest:", digest,
7473 tdata->digest_enc.len);
7474 debug_hexdump(stdout, "digest expected:",
7475 tdata->digest_enc.data, tdata->digest_enc.len);
7480 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7482 tdata->plaintext.data,
7483 tdata->plaintext.len_bits >> 3,
7484 "Plaintext data not as expected");
7486 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7488 tdata->ciphertext.data,
7489 tdata->validDataLen.len_bits,
7490 "Ciphertext data not as expected");
7491 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7493 tdata->digest_enc.data,
7494 tdata->digest_enc.len,
7495 "Generated auth tag not as expected");
7498 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7499 "crypto op processing failed");
7504 /** AUTH AES CMAC + CIPHER AES CTR */
7507 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7509 return test_mixed_auth_cipher(
7510 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7514 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7516 return test_mixed_auth_cipher(
7517 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7521 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7523 return test_mixed_auth_cipher_sgl(
7524 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7528 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7530 return test_mixed_auth_cipher_sgl(
7531 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7535 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7537 return test_mixed_auth_cipher(
7538 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7542 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7544 return test_mixed_auth_cipher(
7545 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7549 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7551 return test_mixed_auth_cipher_sgl(
7552 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7556 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7558 return test_mixed_auth_cipher_sgl(
7559 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7562 /** MIXED AUTH + CIPHER */
7565 test_auth_zuc_cipher_snow_test_case_1(void)
7567 return test_mixed_auth_cipher(
7568 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7572 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7574 return test_mixed_auth_cipher(
7575 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7579 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7581 return test_mixed_auth_cipher(
7582 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7586 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7588 return test_mixed_auth_cipher(
7589 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7593 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7595 return test_mixed_auth_cipher(
7596 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7600 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7602 return test_mixed_auth_cipher(
7603 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7607 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7609 return test_mixed_auth_cipher(
7610 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7614 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7616 return test_mixed_auth_cipher(
7617 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7621 test_auth_snow_cipher_zuc_test_case_1(void)
7623 return test_mixed_auth_cipher(
7624 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7628 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7630 return test_mixed_auth_cipher(
7631 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7635 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7637 return test_mixed_auth_cipher(
7638 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7642 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7644 return test_mixed_auth_cipher(
7645 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7649 test_auth_null_cipher_snow_test_case_1(void)
7651 return test_mixed_auth_cipher(
7652 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7656 test_verify_auth_null_cipher_snow_test_case_1(void)
7658 return test_mixed_auth_cipher(
7659 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7663 test_auth_null_cipher_zuc_test_case_1(void)
7665 return test_mixed_auth_cipher(
7666 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7670 test_verify_auth_null_cipher_zuc_test_case_1(void)
7672 return test_mixed_auth_cipher(
7673 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7677 test_auth_snow_cipher_null_test_case_1(void)
7679 return test_mixed_auth_cipher(
7680 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7684 test_verify_auth_snow_cipher_null_test_case_1(void)
7686 return test_mixed_auth_cipher(
7687 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7691 test_auth_zuc_cipher_null_test_case_1(void)
7693 return test_mixed_auth_cipher(
7694 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7698 test_verify_auth_zuc_cipher_null_test_case_1(void)
7700 return test_mixed_auth_cipher(
7701 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7705 test_auth_null_cipher_aes_ctr_test_case_1(void)
7707 return test_mixed_auth_cipher(
7708 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7712 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7714 return test_mixed_auth_cipher(
7715 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7719 test_auth_aes_cmac_cipher_null_test_case_1(void)
7721 return test_mixed_auth_cipher(
7722 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7726 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7728 return test_mixed_auth_cipher(
7729 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7732 /* ***** AEAD algorithm Tests ***** */
7735 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7736 enum rte_crypto_aead_operation op,
7737 const uint8_t *key, const uint8_t key_len,
7738 const uint16_t aad_len, const uint8_t auth_len,
7741 uint8_t aead_key[key_len];
7743 struct crypto_testsuite_params *ts_params = &testsuite_params;
7744 struct crypto_unittest_params *ut_params = &unittest_params;
7746 memcpy(aead_key, key, key_len);
7748 /* Setup AEAD Parameters */
7749 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7750 ut_params->aead_xform.next = NULL;
7751 ut_params->aead_xform.aead.algo = algo;
7752 ut_params->aead_xform.aead.op = op;
7753 ut_params->aead_xform.aead.key.data = aead_key;
7754 ut_params->aead_xform.aead.key.length = key_len;
7755 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7756 ut_params->aead_xform.aead.iv.length = iv_len;
7757 ut_params->aead_xform.aead.digest_length = auth_len;
7758 ut_params->aead_xform.aead.aad_length = aad_len;
7760 debug_hexdump(stdout, "key:", key, key_len);
7762 /* Create Crypto session*/
7763 ut_params->sess = rte_cryptodev_sym_session_create(
7764 ts_params->session_mpool);
7766 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7767 &ut_params->aead_xform,
7768 ts_params->session_priv_mpool);
7770 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7776 create_aead_xform(struct rte_crypto_op *op,
7777 enum rte_crypto_aead_algorithm algo,
7778 enum rte_crypto_aead_operation aead_op,
7779 uint8_t *key, const uint8_t key_len,
7780 const uint8_t aad_len, const uint8_t auth_len,
7783 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7784 "failed to allocate space for crypto transform");
7786 struct rte_crypto_sym_op *sym_op = op->sym;
7788 /* Setup AEAD Parameters */
7789 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7790 sym_op->xform->next = NULL;
7791 sym_op->xform->aead.algo = algo;
7792 sym_op->xform->aead.op = aead_op;
7793 sym_op->xform->aead.key.data = key;
7794 sym_op->xform->aead.key.length = key_len;
7795 sym_op->xform->aead.iv.offset = IV_OFFSET;
7796 sym_op->xform->aead.iv.length = iv_len;
7797 sym_op->xform->aead.digest_length = auth_len;
7798 sym_op->xform->aead.aad_length = aad_len;
7800 debug_hexdump(stdout, "key:", key, key_len);
7806 create_aead_operation(enum rte_crypto_aead_operation op,
7807 const struct aead_test_data *tdata)
7809 struct crypto_testsuite_params *ts_params = &testsuite_params;
7810 struct crypto_unittest_params *ut_params = &unittest_params;
7812 uint8_t *plaintext, *ciphertext;
7813 unsigned int aad_pad_len, plaintext_pad_len;
7815 /* Generate Crypto op data structure */
7816 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7817 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7818 TEST_ASSERT_NOT_NULL(ut_params->op,
7819 "Failed to allocate symmetric crypto operation struct");
7821 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7823 /* Append aad data */
7824 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7825 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7826 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7828 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7829 "no room to append aad");
7831 sym_op->aead.aad.phys_addr =
7832 rte_pktmbuf_iova(ut_params->ibuf);
7833 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7834 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7835 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7838 /* Append IV at the end of the crypto operation*/
7839 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7840 uint8_t *, IV_OFFSET);
7842 /* Copy IV 1 byte after the IV pointer, according to the API */
7843 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7844 debug_hexdump(stdout, "iv:", iv_ptr,
7847 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7848 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7850 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7851 "no room to append aad");
7853 sym_op->aead.aad.phys_addr =
7854 rte_pktmbuf_iova(ut_params->ibuf);
7855 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7856 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7859 /* Append IV at the end of the crypto operation*/
7860 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7861 uint8_t *, IV_OFFSET);
7863 if (tdata->iv.len == 0) {
7864 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7865 debug_hexdump(stdout, "iv:", iv_ptr,
7868 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7869 debug_hexdump(stdout, "iv:", iv_ptr,
7874 /* Append plaintext/ciphertext */
7875 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7876 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7877 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7879 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7881 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7882 debug_hexdump(stdout, "plaintext:", plaintext,
7883 tdata->plaintext.len);
7885 if (ut_params->obuf) {
7886 ciphertext = (uint8_t *)rte_pktmbuf_append(
7888 plaintext_pad_len + aad_pad_len);
7889 TEST_ASSERT_NOT_NULL(ciphertext,
7890 "no room to append ciphertext");
7892 memset(ciphertext + aad_pad_len, 0,
7893 tdata->ciphertext.len);
7896 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7897 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7899 TEST_ASSERT_NOT_NULL(ciphertext,
7900 "no room to append ciphertext");
7902 memcpy(ciphertext, tdata->ciphertext.data,
7903 tdata->ciphertext.len);
7904 debug_hexdump(stdout, "ciphertext:", ciphertext,
7905 tdata->ciphertext.len);
7907 if (ut_params->obuf) {
7908 plaintext = (uint8_t *)rte_pktmbuf_append(
7910 plaintext_pad_len + aad_pad_len);
7911 TEST_ASSERT_NOT_NULL(plaintext,
7912 "no room to append plaintext");
7914 memset(plaintext + aad_pad_len, 0,
7915 tdata->plaintext.len);
7919 /* Append digest data */
7920 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7921 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7922 ut_params->obuf ? ut_params->obuf :
7924 tdata->auth_tag.len);
7925 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7926 "no room to append digest");
7927 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7928 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7929 ut_params->obuf ? ut_params->obuf :
7934 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7935 ut_params->ibuf, tdata->auth_tag.len);
7936 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7937 "no room to append digest");
7938 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7940 plaintext_pad_len + aad_pad_len);
7942 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7943 tdata->auth_tag.len);
7944 debug_hexdump(stdout, "digest:",
7945 sym_op->aead.digest.data,
7946 tdata->auth_tag.len);
7949 sym_op->aead.data.length = tdata->plaintext.len;
7950 sym_op->aead.data.offset = aad_pad_len;
7956 test_authenticated_encryption(const struct aead_test_data *tdata)
7958 struct crypto_testsuite_params *ts_params = &testsuite_params;
7959 struct crypto_unittest_params *ut_params = &unittest_params;
7962 uint8_t *ciphertext, *auth_tag;
7963 uint16_t plaintext_pad_len;
7965 struct rte_cryptodev_info dev_info;
7967 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7968 uint64_t feat_flags = dev_info.feature_flags;
7970 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7971 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7972 printf("Device doesn't support RAW data-path APIs.\n");
7973 return TEST_SKIPPED;
7976 /* Verify the capabilities */
7977 struct rte_cryptodev_sym_capability_idx cap_idx;
7978 const struct rte_cryptodev_symmetric_capability *capability;
7979 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7980 cap_idx.algo.aead = tdata->algo;
7981 capability = rte_cryptodev_sym_capability_get(
7982 ts_params->valid_devs[0], &cap_idx);
7983 if (capability == NULL)
7984 return TEST_SKIPPED;
7985 if (rte_cryptodev_sym_capability_check_aead(
7986 capability, tdata->key.len, tdata->auth_tag.len,
7987 tdata->aad.len, tdata->iv.len))
7988 return TEST_SKIPPED;
7990 /* Create AEAD session */
7991 retval = create_aead_session(ts_params->valid_devs[0],
7993 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7994 tdata->key.data, tdata->key.len,
7995 tdata->aad.len, tdata->auth_tag.len,
8000 if (tdata->aad.len > MBUF_SIZE) {
8001 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8002 /* Populate full size of add data */
8003 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8004 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8006 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8008 /* clear mbuf payload */
8009 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8010 rte_pktmbuf_tailroom(ut_params->ibuf));
8012 /* Create AEAD operation */
8013 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8017 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8019 ut_params->op->sym->m_src = ut_params->ibuf;
8021 /* Process crypto operation */
8022 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8023 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8024 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8025 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8026 ut_params->op, 0, 0, 0, 0);
8028 TEST_ASSERT_NOT_NULL(
8029 process_crypto_request(ts_params->valid_devs[0],
8030 ut_params->op), "failed to process sym crypto op");
8032 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8033 "crypto op processing failed");
8035 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8037 if (ut_params->op->sym->m_dst) {
8038 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8040 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8041 uint8_t *, plaintext_pad_len);
8043 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8045 ut_params->op->sym->cipher.data.offset);
8046 auth_tag = ciphertext + plaintext_pad_len;
8049 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8050 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8053 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8055 tdata->ciphertext.data,
8056 tdata->ciphertext.len,
8057 "Ciphertext data not as expected");
8059 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8061 tdata->auth_tag.data,
8062 tdata->auth_tag.len,
8063 "Generated auth tag not as expected");
8069 #ifdef RTE_LIB_SECURITY
8071 security_proto_supported(enum rte_security_session_action_type action,
8072 enum rte_security_session_protocol proto)
8074 struct crypto_testsuite_params *ts_params = &testsuite_params;
8076 const struct rte_security_capability *capabilities;
8077 const struct rte_security_capability *capability;
8080 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8081 rte_cryptodev_get_sec_ctx(
8082 ts_params->valid_devs[0]);
8085 capabilities = rte_security_capabilities_get(ctx);
8087 if (capabilities == NULL)
8090 while ((capability = &capabilities[i++])->action !=
8091 RTE_SECURITY_ACTION_TYPE_NONE) {
8092 if (capability->action == action &&
8093 capability->protocol == proto)
8100 /* Basic algorithm run function for async inplace mode.
8101 * Creates a session from input parameters and runs one operation
8102 * on input_vec. Checks the output of the crypto operation against
8105 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8106 enum rte_crypto_auth_operation opa,
8107 const uint8_t *input_vec, unsigned int input_vec_len,
8108 const uint8_t *output_vec,
8109 unsigned int output_vec_len,
8110 enum rte_crypto_cipher_algorithm cipher_alg,
8111 const uint8_t *cipher_key, uint32_t cipher_key_len,
8112 enum rte_crypto_auth_algorithm auth_alg,
8113 const uint8_t *auth_key, uint32_t auth_key_len,
8114 uint8_t bearer, enum rte_security_pdcp_domain domain,
8115 uint8_t packet_direction, uint8_t sn_size,
8116 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8118 struct crypto_testsuite_params *ts_params = &testsuite_params;
8119 struct crypto_unittest_params *ut_params = &unittest_params;
8121 int ret = TEST_SUCCESS;
8122 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8123 rte_cryptodev_get_sec_ctx(
8124 ts_params->valid_devs[0]);
8126 /* Verify the capabilities */
8127 struct rte_security_capability_idx sec_cap_idx;
8129 sec_cap_idx.action = ut_params->type;
8130 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8131 sec_cap_idx.pdcp.domain = domain;
8132 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8133 return TEST_SKIPPED;
8135 /* Generate test mbuf data */
8136 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8138 /* clear mbuf payload */
8139 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8140 rte_pktmbuf_tailroom(ut_params->ibuf));
8142 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8144 memcpy(plaintext, input_vec, input_vec_len);
8146 /* Out of place support */
8149 * For out-op-place we need to alloc another mbuf
8151 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8152 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8155 /* Setup Cipher Parameters */
8156 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8157 ut_params->cipher_xform.cipher.algo = cipher_alg;
8158 ut_params->cipher_xform.cipher.op = opc;
8159 ut_params->cipher_xform.cipher.key.data = cipher_key;
8160 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8161 ut_params->cipher_xform.cipher.iv.length =
8162 packet_direction ? 4 : 0;
8163 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8165 /* Setup HMAC Parameters if ICV header is required */
8166 if (auth_alg != 0) {
8167 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8168 ut_params->auth_xform.next = NULL;
8169 ut_params->auth_xform.auth.algo = auth_alg;
8170 ut_params->auth_xform.auth.op = opa;
8171 ut_params->auth_xform.auth.key.data = auth_key;
8172 ut_params->auth_xform.auth.key.length = auth_key_len;
8174 ut_params->cipher_xform.next = &ut_params->auth_xform;
8176 ut_params->cipher_xform.next = NULL;
8179 struct rte_security_session_conf sess_conf = {
8180 .action_type = ut_params->type,
8181 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8185 .pkt_dir = packet_direction,
8187 .hfn = packet_direction ? 0 : hfn,
8189 * hfn can be set as pdcp_test_hfn[i]
8190 * if hfn_ovrd is not set. Here, PDCP
8191 * packet direction is just used to
8192 * run half of the cases with session
8193 * HFN and other half with per packet
8196 .hfn_threshold = hfn_threshold,
8197 .hfn_ovrd = packet_direction ? 1 : 0,
8198 .sdap_enabled = sdap,
8200 .crypto_xform = &ut_params->cipher_xform
8203 /* Create security session */
8204 ut_params->sec_session = rte_security_session_create(ctx,
8205 &sess_conf, ts_params->session_mpool,
8206 ts_params->session_priv_mpool);
8208 if (!ut_params->sec_session) {
8209 printf("TestCase %s()-%d line %d failed %s: ",
8210 __func__, i, __LINE__, "Failed to allocate session");
8215 /* Generate crypto op data structure */
8216 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8217 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8218 if (!ut_params->op) {
8219 printf("TestCase %s()-%d line %d failed %s: ",
8220 __func__, i, __LINE__,
8221 "Failed to allocate symmetric crypto operation struct");
8226 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8227 uint32_t *, IV_OFFSET);
8228 *per_pkt_hfn = packet_direction ? hfn : 0;
8230 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8232 /* set crypto operation source mbuf */
8233 ut_params->op->sym->m_src = ut_params->ibuf;
8235 ut_params->op->sym->m_dst = ut_params->obuf;
8237 /* Process crypto operation */
8238 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8240 printf("TestCase %s()-%d line %d failed %s: ",
8241 __func__, i, __LINE__,
8242 "failed to process sym crypto op");
8247 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8248 printf("TestCase %s()-%d line %d failed %s: ",
8249 __func__, i, __LINE__, "crypto op processing failed");
8255 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8258 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8262 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8263 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8264 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8265 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8271 rte_crypto_op_free(ut_params->op);
8272 ut_params->op = NULL;
8274 if (ut_params->sec_session)
8275 rte_security_session_destroy(ctx, ut_params->sec_session);
8276 ut_params->sec_session = NULL;
8278 rte_pktmbuf_free(ut_params->ibuf);
8279 ut_params->ibuf = NULL;
8281 rte_pktmbuf_free(ut_params->obuf);
8282 ut_params->obuf = NULL;
8289 test_pdcp_proto_SGL(int i, int oop,
8290 enum rte_crypto_cipher_operation opc,
8291 enum rte_crypto_auth_operation opa,
8293 unsigned int input_vec_len,
8294 uint8_t *output_vec,
8295 unsigned int output_vec_len,
8297 uint32_t fragsz_oop)
8299 struct crypto_testsuite_params *ts_params = &testsuite_params;
8300 struct crypto_unittest_params *ut_params = &unittest_params;
8302 struct rte_mbuf *buf, *buf_oop = NULL;
8303 int ret = TEST_SUCCESS;
8307 unsigned int trn_data = 0;
8308 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8309 rte_cryptodev_get_sec_ctx(
8310 ts_params->valid_devs[0]);
8312 /* Verify the capabilities */
8313 struct rte_security_capability_idx sec_cap_idx;
8315 sec_cap_idx.action = ut_params->type;
8316 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8317 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8318 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8319 return TEST_SKIPPED;
8321 if (fragsz > input_vec_len)
8322 fragsz = input_vec_len;
8324 uint16_t plaintext_len = fragsz;
8325 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8327 if (fragsz_oop > output_vec_len)
8328 frag_size_oop = output_vec_len;
8331 if (input_vec_len % fragsz != 0) {
8332 if (input_vec_len / fragsz + 1 > 16)
8334 } else if (input_vec_len / fragsz > 16)
8337 /* Out of place support */
8340 * For out-op-place we need to alloc another mbuf
8342 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8343 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8344 buf_oop = ut_params->obuf;
8347 /* Generate test mbuf data */
8348 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8350 /* clear mbuf payload */
8351 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8352 rte_pktmbuf_tailroom(ut_params->ibuf));
8354 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8356 memcpy(plaintext, input_vec, plaintext_len);
8357 trn_data += plaintext_len;
8359 buf = ut_params->ibuf;
8362 * Loop until no more fragments
8365 while (trn_data < input_vec_len) {
8367 to_trn = (input_vec_len - trn_data < fragsz) ?
8368 (input_vec_len - trn_data) : fragsz;
8370 to_trn_tbl[ecx++] = to_trn;
8372 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8375 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8376 rte_pktmbuf_tailroom(buf));
8379 if (oop && !fragsz_oop) {
8381 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8382 buf_oop = buf_oop->next;
8383 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8384 0, rte_pktmbuf_tailroom(buf_oop));
8385 rte_pktmbuf_append(buf_oop, to_trn);
8388 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8391 memcpy(plaintext, input_vec + trn_data, to_trn);
8395 ut_params->ibuf->nb_segs = segs;
8398 if (fragsz_oop && oop) {
8402 trn_data = frag_size_oop;
8403 while (trn_data < output_vec_len) {
8406 (output_vec_len - trn_data <
8408 (output_vec_len - trn_data) :
8411 to_trn_tbl[ecx++] = to_trn;
8414 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8415 buf_oop = buf_oop->next;
8416 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8417 0, rte_pktmbuf_tailroom(buf_oop));
8418 rte_pktmbuf_append(buf_oop, to_trn);
8422 ut_params->obuf->nb_segs = segs;
8425 /* Setup Cipher Parameters */
8426 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8427 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8428 ut_params->cipher_xform.cipher.op = opc;
8429 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8430 ut_params->cipher_xform.cipher.key.length =
8431 pdcp_test_params[i].cipher_key_len;
8432 ut_params->cipher_xform.cipher.iv.length = 0;
8434 /* Setup HMAC Parameters if ICV header is required */
8435 if (pdcp_test_params[i].auth_alg != 0) {
8436 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8437 ut_params->auth_xform.next = NULL;
8438 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8439 ut_params->auth_xform.auth.op = opa;
8440 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8441 ut_params->auth_xform.auth.key.length =
8442 pdcp_test_params[i].auth_key_len;
8444 ut_params->cipher_xform.next = &ut_params->auth_xform;
8446 ut_params->cipher_xform.next = NULL;
8449 struct rte_security_session_conf sess_conf = {
8450 .action_type = ut_params->type,
8451 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8453 .bearer = pdcp_test_bearer[i],
8454 .domain = pdcp_test_params[i].domain,
8455 .pkt_dir = pdcp_test_packet_direction[i],
8456 .sn_size = pdcp_test_data_sn_size[i],
8457 .hfn = pdcp_test_hfn[i],
8458 .hfn_threshold = pdcp_test_hfn_threshold[i],
8461 .crypto_xform = &ut_params->cipher_xform
8464 /* Create security session */
8465 ut_params->sec_session = rte_security_session_create(ctx,
8466 &sess_conf, ts_params->session_mpool,
8467 ts_params->session_priv_mpool);
8469 if (!ut_params->sec_session) {
8470 printf("TestCase %s()-%d line %d failed %s: ",
8471 __func__, i, __LINE__, "Failed to allocate session");
8476 /* Generate crypto op data structure */
8477 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8478 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8479 if (!ut_params->op) {
8480 printf("TestCase %s()-%d line %d failed %s: ",
8481 __func__, i, __LINE__,
8482 "Failed to allocate symmetric crypto operation struct");
8487 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8489 /* set crypto operation source mbuf */
8490 ut_params->op->sym->m_src = ut_params->ibuf;
8492 ut_params->op->sym->m_dst = ut_params->obuf;
8494 /* Process crypto operation */
8495 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8497 printf("TestCase %s()-%d line %d failed %s: ",
8498 __func__, i, __LINE__,
8499 "failed to process sym crypto op");
8504 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8505 printf("TestCase %s()-%d line %d failed %s: ",
8506 __func__, i, __LINE__, "crypto op processing failed");
8512 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8515 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8519 fragsz = frag_size_oop;
8520 if (memcmp(ciphertext, output_vec, fragsz)) {
8521 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8522 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8523 rte_hexdump(stdout, "reference", output_vec, fragsz);
8528 buf = ut_params->op->sym->m_src->next;
8530 buf = ut_params->op->sym->m_dst->next;
8532 unsigned int off = fragsz;
8536 ciphertext = rte_pktmbuf_mtod(buf,
8538 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8539 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8540 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8541 rte_hexdump(stdout, "reference", output_vec + off,
8546 off += to_trn_tbl[ecx++];
8550 rte_crypto_op_free(ut_params->op);
8551 ut_params->op = NULL;
8553 if (ut_params->sec_session)
8554 rte_security_session_destroy(ctx, ut_params->sec_session);
8555 ut_params->sec_session = NULL;
8557 rte_pktmbuf_free(ut_params->ibuf);
8558 ut_params->ibuf = NULL;
8560 rte_pktmbuf_free(ut_params->obuf);
8561 ut_params->obuf = NULL;
8568 test_pdcp_proto_cplane_encap(int i)
8570 return test_pdcp_proto(
8571 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8572 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8573 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8574 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8575 pdcp_test_params[i].cipher_key_len,
8576 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8577 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8578 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8579 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8580 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8584 test_pdcp_proto_uplane_encap(int i)
8586 return test_pdcp_proto(
8587 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8588 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8589 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8590 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8591 pdcp_test_params[i].cipher_key_len,
8592 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8593 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8594 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8595 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8596 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8600 test_pdcp_proto_uplane_encap_with_int(int i)
8602 return test_pdcp_proto(
8603 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8604 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8605 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8606 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8607 pdcp_test_params[i].cipher_key_len,
8608 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8609 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8610 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8611 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8612 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8616 test_pdcp_proto_cplane_decap(int i)
8618 return test_pdcp_proto(
8619 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8620 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8621 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8622 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8623 pdcp_test_params[i].cipher_key_len,
8624 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8625 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8626 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8627 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8628 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8632 test_pdcp_proto_uplane_decap(int i)
8634 return test_pdcp_proto(
8635 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8636 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8637 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8638 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8639 pdcp_test_params[i].cipher_key_len,
8640 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8641 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8642 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8643 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8644 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8648 test_pdcp_proto_uplane_decap_with_int(int i)
8650 return test_pdcp_proto(
8651 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8652 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8653 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8654 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8655 pdcp_test_params[i].cipher_key_len,
8656 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8657 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8658 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8659 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8660 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8664 test_PDCP_PROTO_SGL_in_place_32B(void)
8666 /* i can be used for running any PDCP case
8667 * In this case it is uplane 12-bit AES-SNOW DL encap
8669 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8670 return test_pdcp_proto_SGL(i, IN_PLACE,
8671 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8672 RTE_CRYPTO_AUTH_OP_GENERATE,
8673 pdcp_test_data_in[i],
8674 pdcp_test_data_in_len[i],
8675 pdcp_test_data_out[i],
8676 pdcp_test_data_in_len[i]+4,
8680 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8682 /* i can be used for running any PDCP case
8683 * In this case it is uplane 18-bit NULL-NULL DL encap
8685 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8686 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8687 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8688 RTE_CRYPTO_AUTH_OP_GENERATE,
8689 pdcp_test_data_in[i],
8690 pdcp_test_data_in_len[i],
8691 pdcp_test_data_out[i],
8692 pdcp_test_data_in_len[i]+4,
8696 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8698 /* i can be used for running any PDCP case
8699 * In this case it is uplane 18-bit AES DL encap
8701 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8703 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8704 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8705 RTE_CRYPTO_AUTH_OP_GENERATE,
8706 pdcp_test_data_in[i],
8707 pdcp_test_data_in_len[i],
8708 pdcp_test_data_out[i],
8709 pdcp_test_data_in_len[i],
8713 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8715 /* i can be used for running any PDCP case
8716 * In this case it is cplane 12-bit AES-ZUC DL encap
8718 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8719 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8720 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8721 RTE_CRYPTO_AUTH_OP_GENERATE,
8722 pdcp_test_data_in[i],
8723 pdcp_test_data_in_len[i],
8724 pdcp_test_data_out[i],
8725 pdcp_test_data_in_len[i]+4,
8730 test_PDCP_SDAP_PROTO_encap_all(void)
8732 int i = 0, size = 0;
8733 int err, all_err = TEST_SUCCESS;
8734 const struct pdcp_sdap_test *cur_test;
8736 size = RTE_DIM(list_pdcp_sdap_tests);
8738 for (i = 0; i < size; i++) {
8739 cur_test = &list_pdcp_sdap_tests[i];
8740 err = test_pdcp_proto(
8741 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8742 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8743 cur_test->in_len, cur_test->data_out,
8744 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8745 cur_test->param.cipher_alg, cur_test->cipher_key,
8746 cur_test->param.cipher_key_len,
8747 cur_test->param.auth_alg,
8748 cur_test->auth_key, cur_test->param.auth_key_len,
8749 cur_test->bearer, cur_test->param.domain,
8750 cur_test->packet_direction, cur_test->sn_size,
8752 cur_test->hfn_threshold, SDAP_ENABLED);
8754 printf("\t%d) %s: Encapsulation failed\n",
8756 cur_test->param.name);
8759 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8760 cur_test->param.name);
8766 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8768 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8772 test_PDCP_SDAP_PROTO_decap_all(void)
8774 int i = 0, size = 0;
8775 int err, all_err = TEST_SUCCESS;
8776 const struct pdcp_sdap_test *cur_test;
8778 size = RTE_DIM(list_pdcp_sdap_tests);
8780 for (i = 0; i < size; i++) {
8781 cur_test = &list_pdcp_sdap_tests[i];
8782 err = test_pdcp_proto(
8783 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8784 RTE_CRYPTO_AUTH_OP_VERIFY,
8786 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8787 cur_test->data_in, cur_test->in_len,
8788 cur_test->param.cipher_alg,
8789 cur_test->cipher_key, cur_test->param.cipher_key_len,
8790 cur_test->param.auth_alg, cur_test->auth_key,
8791 cur_test->param.auth_key_len, cur_test->bearer,
8792 cur_test->param.domain, cur_test->packet_direction,
8793 cur_test->sn_size, cur_test->hfn,
8794 cur_test->hfn_threshold, SDAP_ENABLED);
8796 printf("\t%d) %s: Decapsulation failed\n",
8798 cur_test->param.name);
8801 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8802 cur_test->param.name);
8808 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8810 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8814 test_PDCP_PROTO_all(void)
8816 struct crypto_testsuite_params *ts_params = &testsuite_params;
8817 struct crypto_unittest_params *ut_params = &unittest_params;
8818 struct rte_cryptodev_info dev_info;
8821 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8822 uint64_t feat_flags = dev_info.feature_flags;
8824 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8825 return TEST_SKIPPED;
8827 /* Set action type */
8828 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8829 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8832 if (security_proto_supported(ut_params->type,
8833 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8834 return TEST_SKIPPED;
8836 status = test_PDCP_PROTO_cplane_encap_all();
8837 status += test_PDCP_PROTO_cplane_decap_all();
8838 status += test_PDCP_PROTO_uplane_encap_all();
8839 status += test_PDCP_PROTO_uplane_decap_all();
8840 status += test_PDCP_PROTO_SGL_in_place_32B();
8841 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8842 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8843 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8844 status += test_PDCP_SDAP_PROTO_encap_all();
8845 status += test_PDCP_SDAP_PROTO_decap_all();
8850 return TEST_SUCCESS;
8854 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8856 struct crypto_testsuite_params *ts_params = &testsuite_params;
8857 struct crypto_unittest_params *ut_params = &unittest_params;
8858 uint8_t *plaintext, *ciphertext;
8860 int32_t cipher_len, crc_len;
8861 uint32_t crc_data_len;
8862 int ret = TEST_SUCCESS;
8864 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8865 rte_cryptodev_get_sec_ctx(
8866 ts_params->valid_devs[0]);
8868 /* Verify the capabilities */
8869 struct rte_security_capability_idx sec_cap_idx;
8870 const struct rte_security_capability *sec_cap;
8871 const struct rte_cryptodev_capabilities *crypto_cap;
8872 const struct rte_cryptodev_symmetric_capability *sym_cap;
8875 sec_cap_idx.action = ut_params->type;
8876 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8877 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8879 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8880 if (sec_cap == NULL)
8881 return TEST_SKIPPED;
8883 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8884 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8885 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8886 crypto_cap->sym.xform_type ==
8887 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8888 crypto_cap->sym.cipher.algo ==
8889 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8890 sym_cap = &crypto_cap->sym;
8891 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8898 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8899 return TEST_SKIPPED;
8901 /* Setup source mbuf payload */
8902 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8903 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8904 rte_pktmbuf_tailroom(ut_params->ibuf));
8906 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8907 d_td->ciphertext.len);
8909 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8911 /* Setup cipher session parameters */
8912 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8913 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8914 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8915 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8916 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8917 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8918 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8919 ut_params->cipher_xform.next = NULL;
8921 /* Setup DOCSIS session parameters */
8922 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8924 struct rte_security_session_conf sess_conf = {
8925 .action_type = ut_params->type,
8926 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8927 .docsis = ut_params->docsis_xform,
8928 .crypto_xform = &ut_params->cipher_xform,
8931 /* Create security session */
8932 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8933 ts_params->session_mpool,
8934 ts_params->session_priv_mpool);
8936 if (!ut_params->sec_session) {
8937 printf("TestCase %s(%d) line %d: %s\n",
8938 __func__, i, __LINE__, "failed to allocate session");
8943 /* Generate crypto op data structure */
8944 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8945 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8946 if (!ut_params->op) {
8947 printf("TestCase %s(%d) line %d: %s\n",
8948 __func__, i, __LINE__,
8949 "failed to allocate symmetric crypto operation");
8954 /* Setup CRC operation parameters */
8955 crc_len = d_td->ciphertext.no_crc == false ?
8956 (d_td->ciphertext.len -
8957 d_td->ciphertext.crc_offset -
8958 RTE_ETHER_CRC_LEN) :
8960 crc_len = crc_len > 0 ? crc_len : 0;
8961 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8962 ut_params->op->sym->auth.data.length = crc_len;
8963 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8965 /* Setup cipher operation parameters */
8966 cipher_len = d_td->ciphertext.no_cipher == false ?
8967 (d_td->ciphertext.len -
8968 d_td->ciphertext.cipher_offset) :
8970 cipher_len = cipher_len > 0 ? cipher_len : 0;
8971 ut_params->op->sym->cipher.data.length = cipher_len;
8972 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8974 /* Setup cipher IV */
8975 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8976 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8978 /* Attach session to operation */
8979 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8981 /* Set crypto operation mbufs */
8982 ut_params->op->sym->m_src = ut_params->ibuf;
8983 ut_params->op->sym->m_dst = NULL;
8985 /* Process crypto operation */
8986 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8988 printf("TestCase %s(%d) line %d: %s\n",
8989 __func__, i, __LINE__,
8990 "failed to process security crypto op");
8995 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8996 printf("TestCase %s(%d) line %d: %s\n",
8997 __func__, i, __LINE__, "crypto op processing failed");
9002 /* Validate plaintext */
9003 plaintext = ciphertext;
9005 if (memcmp(plaintext, d_td->plaintext.data,
9006 d_td->plaintext.len - crc_data_len)) {
9007 printf("TestCase %s(%d) line %d: %s\n",
9008 __func__, i, __LINE__, "plaintext not as expected\n");
9009 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9010 d_td->plaintext.len);
9011 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9017 rte_crypto_op_free(ut_params->op);
9018 ut_params->op = NULL;
9020 if (ut_params->sec_session)
9021 rte_security_session_destroy(ctx, ut_params->sec_session);
9022 ut_params->sec_session = NULL;
9024 rte_pktmbuf_free(ut_params->ibuf);
9025 ut_params->ibuf = NULL;
9031 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9033 struct crypto_testsuite_params *ts_params = &testsuite_params;
9034 struct crypto_unittest_params *ut_params = &unittest_params;
9035 uint8_t *plaintext, *ciphertext;
9037 int32_t cipher_len, crc_len;
9038 int ret = TEST_SUCCESS;
9040 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9041 rte_cryptodev_get_sec_ctx(
9042 ts_params->valid_devs[0]);
9044 /* Verify the capabilities */
9045 struct rte_security_capability_idx sec_cap_idx;
9046 const struct rte_security_capability *sec_cap;
9047 const struct rte_cryptodev_capabilities *crypto_cap;
9048 const struct rte_cryptodev_symmetric_capability *sym_cap;
9051 sec_cap_idx.action = ut_params->type;
9052 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9053 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9055 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9056 if (sec_cap == NULL)
9057 return TEST_SKIPPED;
9059 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9060 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9061 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9062 crypto_cap->sym.xform_type ==
9063 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9064 crypto_cap->sym.cipher.algo ==
9065 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9066 sym_cap = &crypto_cap->sym;
9067 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9074 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9075 return TEST_SKIPPED;
9077 /* Setup source mbuf payload */
9078 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9079 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9080 rte_pktmbuf_tailroom(ut_params->ibuf));
9082 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9083 d_td->plaintext.len);
9085 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9087 /* Setup cipher session parameters */
9088 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9089 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9090 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9091 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9092 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9093 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9094 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9095 ut_params->cipher_xform.next = NULL;
9097 /* Setup DOCSIS session parameters */
9098 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9100 struct rte_security_session_conf sess_conf = {
9101 .action_type = ut_params->type,
9102 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9103 .docsis = ut_params->docsis_xform,
9104 .crypto_xform = &ut_params->cipher_xform,
9107 /* Create security session */
9108 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9109 ts_params->session_mpool,
9110 ts_params->session_priv_mpool);
9112 if (!ut_params->sec_session) {
9113 printf("TestCase %s(%d) line %d: %s\n",
9114 __func__, i, __LINE__, "failed to allocate session");
9119 /* Generate crypto op data structure */
9120 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9121 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9122 if (!ut_params->op) {
9123 printf("TestCase %s(%d) line %d: %s\n",
9124 __func__, i, __LINE__,
9125 "failed to allocate security crypto operation");
9130 /* Setup CRC operation parameters */
9131 crc_len = d_td->plaintext.no_crc == false ?
9132 (d_td->plaintext.len -
9133 d_td->plaintext.crc_offset -
9134 RTE_ETHER_CRC_LEN) :
9136 crc_len = crc_len > 0 ? crc_len : 0;
9137 ut_params->op->sym->auth.data.length = crc_len;
9138 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9140 /* Setup cipher operation parameters */
9141 cipher_len = d_td->plaintext.no_cipher == false ?
9142 (d_td->plaintext.len -
9143 d_td->plaintext.cipher_offset) :
9145 cipher_len = cipher_len > 0 ? cipher_len : 0;
9146 ut_params->op->sym->cipher.data.length = cipher_len;
9147 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9149 /* Setup cipher IV */
9150 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9151 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9153 /* Attach session to operation */
9154 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9156 /* Set crypto operation mbufs */
9157 ut_params->op->sym->m_src = ut_params->ibuf;
9158 ut_params->op->sym->m_dst = NULL;
9160 /* Process crypto operation */
9161 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9163 printf("TestCase %s(%d) line %d: %s\n",
9164 __func__, i, __LINE__,
9165 "failed to process security crypto op");
9170 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9171 printf("TestCase %s(%d) line %d: %s\n",
9172 __func__, i, __LINE__, "crypto op processing failed");
9177 /* Validate ciphertext */
9178 ciphertext = plaintext;
9180 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9181 printf("TestCase %s(%d) line %d: %s\n",
9182 __func__, i, __LINE__, "ciphertext not as expected\n");
9183 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9184 d_td->ciphertext.len);
9185 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9191 rte_crypto_op_free(ut_params->op);
9192 ut_params->op = NULL;
9194 if (ut_params->sec_session)
9195 rte_security_session_destroy(ctx, ut_params->sec_session);
9196 ut_params->sec_session = NULL;
9198 rte_pktmbuf_free(ut_params->ibuf);
9199 ut_params->ibuf = NULL;
9204 #define TEST_DOCSIS_COUNT(func) do { \
9206 if (ret == TEST_SUCCESS) { \
9207 printf("\t%2d)", n++); \
9208 printf("+++++ PASSED:" #func"\n"); \
9210 } else if (ret == TEST_SKIPPED) { \
9211 printf("\t%2d)", n++); \
9212 printf("~~~~~ SKIPPED:" #func"\n"); \
9215 printf("\t%2d)", n++); \
9216 printf("----- FAILED:" #func"\n"); \
9222 test_DOCSIS_PROTO_uplink_all(void)
9224 int p = 0, s = 0, f = 0, n = 0;
9226 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9227 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9228 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9229 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9230 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9231 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9232 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9233 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9234 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9235 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9236 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9237 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9238 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9239 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9240 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9241 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9242 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9243 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9244 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9245 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9246 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9247 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9248 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9249 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9250 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9251 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9254 printf("## %s: %d passed out of %d (%d skipped)\n",
9261 test_DOCSIS_PROTO_downlink_all(void)
9263 int p = 0, s = 0, f = 0, n = 0;
9265 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9266 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9267 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9268 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9269 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9270 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9271 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9272 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9273 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9274 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9275 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9276 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9277 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9278 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9279 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9280 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9281 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9282 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9283 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9284 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9285 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9286 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9287 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9288 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9289 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9290 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9293 printf("## %s: %d passed out of %d (%d skipped)\n",
9300 test_DOCSIS_PROTO_all(void)
9302 struct crypto_testsuite_params *ts_params = &testsuite_params;
9303 struct crypto_unittest_params *ut_params = &unittest_params;
9304 struct rte_cryptodev_info dev_info;
9307 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9308 uint64_t feat_flags = dev_info.feature_flags;
9310 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9311 return TEST_SKIPPED;
9313 /* Set action type */
9314 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9315 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9318 if (security_proto_supported(ut_params->type,
9319 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9320 return TEST_SKIPPED;
9322 status = test_DOCSIS_PROTO_uplink_all();
9323 status += test_DOCSIS_PROTO_downlink_all();
9328 return TEST_SUCCESS;
9333 test_AES_GCM_authenticated_encryption_test_case_1(void)
9335 return test_authenticated_encryption(&gcm_test_case_1);
9339 test_AES_GCM_authenticated_encryption_test_case_2(void)
9341 return test_authenticated_encryption(&gcm_test_case_2);
9345 test_AES_GCM_authenticated_encryption_test_case_3(void)
9347 return test_authenticated_encryption(&gcm_test_case_3);
9351 test_AES_GCM_authenticated_encryption_test_case_4(void)
9353 return test_authenticated_encryption(&gcm_test_case_4);
9357 test_AES_GCM_authenticated_encryption_test_case_5(void)
9359 return test_authenticated_encryption(&gcm_test_case_5);
9363 test_AES_GCM_authenticated_encryption_test_case_6(void)
9365 return test_authenticated_encryption(&gcm_test_case_6);
9369 test_AES_GCM_authenticated_encryption_test_case_7(void)
9371 return test_authenticated_encryption(&gcm_test_case_7);
9375 test_AES_GCM_authenticated_encryption_test_case_8(void)
9377 return test_authenticated_encryption(&gcm_test_case_8);
9381 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9383 return test_authenticated_encryption(&gcm_J0_test_case_1);
9387 test_AES_GCM_auth_encryption_test_case_192_1(void)
9389 return test_authenticated_encryption(&gcm_test_case_192_1);
9393 test_AES_GCM_auth_encryption_test_case_192_2(void)
9395 return test_authenticated_encryption(&gcm_test_case_192_2);
9399 test_AES_GCM_auth_encryption_test_case_192_3(void)
9401 return test_authenticated_encryption(&gcm_test_case_192_3);
9405 test_AES_GCM_auth_encryption_test_case_192_4(void)
9407 return test_authenticated_encryption(&gcm_test_case_192_4);
9411 test_AES_GCM_auth_encryption_test_case_192_5(void)
9413 return test_authenticated_encryption(&gcm_test_case_192_5);
9417 test_AES_GCM_auth_encryption_test_case_192_6(void)
9419 return test_authenticated_encryption(&gcm_test_case_192_6);
9423 test_AES_GCM_auth_encryption_test_case_192_7(void)
9425 return test_authenticated_encryption(&gcm_test_case_192_7);
9429 test_AES_GCM_auth_encryption_test_case_256_1(void)
9431 return test_authenticated_encryption(&gcm_test_case_256_1);
9435 test_AES_GCM_auth_encryption_test_case_256_2(void)
9437 return test_authenticated_encryption(&gcm_test_case_256_2);
9441 test_AES_GCM_auth_encryption_test_case_256_3(void)
9443 return test_authenticated_encryption(&gcm_test_case_256_3);
9447 test_AES_GCM_auth_encryption_test_case_256_4(void)
9449 return test_authenticated_encryption(&gcm_test_case_256_4);
9453 test_AES_GCM_auth_encryption_test_case_256_5(void)
9455 return test_authenticated_encryption(&gcm_test_case_256_5);
9459 test_AES_GCM_auth_encryption_test_case_256_6(void)
9461 return test_authenticated_encryption(&gcm_test_case_256_6);
9465 test_AES_GCM_auth_encryption_test_case_256_7(void)
9467 return test_authenticated_encryption(&gcm_test_case_256_7);
9471 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9473 return test_authenticated_encryption(&gcm_test_case_aad_1);
9477 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9479 return test_authenticated_encryption(&gcm_test_case_aad_2);
9483 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9485 struct aead_test_data tdata;
9488 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9489 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9490 tdata.iv.data[0] += 1;
9491 res = test_authenticated_encryption(&tdata);
9492 if (res == TEST_SKIPPED)
9494 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9495 return TEST_SUCCESS;
9499 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9501 struct aead_test_data tdata;
9504 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9505 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9506 tdata.plaintext.data[0] += 1;
9507 res = test_authenticated_encryption(&tdata);
9508 if (res == TEST_SKIPPED)
9510 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9511 return TEST_SUCCESS;
9515 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9517 struct aead_test_data tdata;
9520 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9521 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9522 tdata.ciphertext.data[0] += 1;
9523 res = test_authenticated_encryption(&tdata);
9524 if (res == TEST_SKIPPED)
9526 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9527 return TEST_SUCCESS;
9531 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9533 struct aead_test_data tdata;
9536 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9537 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9539 res = test_authenticated_encryption(&tdata);
9540 if (res == TEST_SKIPPED)
9542 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9543 return TEST_SUCCESS;
9547 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9549 struct aead_test_data tdata;
9550 uint8_t aad[gcm_test_case_7.aad.len];
9553 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9554 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9555 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9557 tdata.aad.data = aad;
9558 res = test_authenticated_encryption(&tdata);
9559 if (res == TEST_SKIPPED)
9561 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9562 return TEST_SUCCESS;
9566 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9568 struct aead_test_data tdata;
9571 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9572 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9573 tdata.auth_tag.data[0] += 1;
9574 res = test_authenticated_encryption(&tdata);
9575 if (res == TEST_SKIPPED)
9577 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9578 return TEST_SUCCESS;
9582 test_authenticated_decryption(const struct aead_test_data *tdata)
9584 struct crypto_testsuite_params *ts_params = &testsuite_params;
9585 struct crypto_unittest_params *ut_params = &unittest_params;
9590 struct rte_cryptodev_info dev_info;
9592 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9593 uint64_t feat_flags = dev_info.feature_flags;
9595 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9596 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9597 printf("Device doesn't support RAW data-path APIs.\n");
9598 return TEST_SKIPPED;
9601 /* Verify the capabilities */
9602 struct rte_cryptodev_sym_capability_idx cap_idx;
9603 const struct rte_cryptodev_symmetric_capability *capability;
9604 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9605 cap_idx.algo.aead = tdata->algo;
9606 capability = rte_cryptodev_sym_capability_get(
9607 ts_params->valid_devs[0], &cap_idx);
9608 if (capability == NULL)
9609 return TEST_SKIPPED;
9610 if (rte_cryptodev_sym_capability_check_aead(
9611 capability, tdata->key.len, tdata->auth_tag.len,
9612 tdata->aad.len, tdata->iv.len))
9613 return TEST_SKIPPED;
9615 /* Create AEAD session */
9616 retval = create_aead_session(ts_params->valid_devs[0],
9618 RTE_CRYPTO_AEAD_OP_DECRYPT,
9619 tdata->key.data, tdata->key.len,
9620 tdata->aad.len, tdata->auth_tag.len,
9625 /* alloc mbuf and set payload */
9626 if (tdata->aad.len > MBUF_SIZE) {
9627 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9628 /* Populate full size of add data */
9629 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9630 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9632 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9634 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9635 rte_pktmbuf_tailroom(ut_params->ibuf));
9637 /* Create AEAD operation */
9638 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9642 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9644 ut_params->op->sym->m_src = ut_params->ibuf;
9646 /* Process crypto operation */
9647 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9648 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9649 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9650 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9651 ut_params->op, 0, 0, 0, 0);
9653 TEST_ASSERT_NOT_NULL(
9654 process_crypto_request(ts_params->valid_devs[0],
9655 ut_params->op), "failed to process sym crypto op");
9657 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9658 "crypto op processing failed");
9660 if (ut_params->op->sym->m_dst)
9661 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9664 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9666 ut_params->op->sym->cipher.data.offset);
9668 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9671 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9673 tdata->plaintext.data,
9674 tdata->plaintext.len,
9675 "Plaintext data not as expected");
9677 TEST_ASSERT_EQUAL(ut_params->op->status,
9678 RTE_CRYPTO_OP_STATUS_SUCCESS,
9679 "Authentication failed");
9685 test_AES_GCM_authenticated_decryption_test_case_1(void)
9687 return test_authenticated_decryption(&gcm_test_case_1);
9691 test_AES_GCM_authenticated_decryption_test_case_2(void)
9693 return test_authenticated_decryption(&gcm_test_case_2);
9697 test_AES_GCM_authenticated_decryption_test_case_3(void)
9699 return test_authenticated_decryption(&gcm_test_case_3);
9703 test_AES_GCM_authenticated_decryption_test_case_4(void)
9705 return test_authenticated_decryption(&gcm_test_case_4);
9709 test_AES_GCM_authenticated_decryption_test_case_5(void)
9711 return test_authenticated_decryption(&gcm_test_case_5);
9715 test_AES_GCM_authenticated_decryption_test_case_6(void)
9717 return test_authenticated_decryption(&gcm_test_case_6);
9721 test_AES_GCM_authenticated_decryption_test_case_7(void)
9723 return test_authenticated_decryption(&gcm_test_case_7);
9727 test_AES_GCM_authenticated_decryption_test_case_8(void)
9729 return test_authenticated_decryption(&gcm_test_case_8);
9733 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9735 return test_authenticated_decryption(&gcm_J0_test_case_1);
9739 test_AES_GCM_auth_decryption_test_case_192_1(void)
9741 return test_authenticated_decryption(&gcm_test_case_192_1);
9745 test_AES_GCM_auth_decryption_test_case_192_2(void)
9747 return test_authenticated_decryption(&gcm_test_case_192_2);
9751 test_AES_GCM_auth_decryption_test_case_192_3(void)
9753 return test_authenticated_decryption(&gcm_test_case_192_3);
9757 test_AES_GCM_auth_decryption_test_case_192_4(void)
9759 return test_authenticated_decryption(&gcm_test_case_192_4);
9763 test_AES_GCM_auth_decryption_test_case_192_5(void)
9765 return test_authenticated_decryption(&gcm_test_case_192_5);
9769 test_AES_GCM_auth_decryption_test_case_192_6(void)
9771 return test_authenticated_decryption(&gcm_test_case_192_6);
9775 test_AES_GCM_auth_decryption_test_case_192_7(void)
9777 return test_authenticated_decryption(&gcm_test_case_192_7);
9781 test_AES_GCM_auth_decryption_test_case_256_1(void)
9783 return test_authenticated_decryption(&gcm_test_case_256_1);
9787 test_AES_GCM_auth_decryption_test_case_256_2(void)
9789 return test_authenticated_decryption(&gcm_test_case_256_2);
9793 test_AES_GCM_auth_decryption_test_case_256_3(void)
9795 return test_authenticated_decryption(&gcm_test_case_256_3);
9799 test_AES_GCM_auth_decryption_test_case_256_4(void)
9801 return test_authenticated_decryption(&gcm_test_case_256_4);
9805 test_AES_GCM_auth_decryption_test_case_256_5(void)
9807 return test_authenticated_decryption(&gcm_test_case_256_5);
9811 test_AES_GCM_auth_decryption_test_case_256_6(void)
9813 return test_authenticated_decryption(&gcm_test_case_256_6);
9817 test_AES_GCM_auth_decryption_test_case_256_7(void)
9819 return test_authenticated_decryption(&gcm_test_case_256_7);
9823 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9825 return test_authenticated_decryption(&gcm_test_case_aad_1);
9829 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9831 return test_authenticated_decryption(&gcm_test_case_aad_2);
9835 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9837 struct aead_test_data tdata;
9840 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9841 tdata.iv.data[0] += 1;
9842 res = test_authenticated_decryption(&tdata);
9843 if (res == TEST_SKIPPED)
9845 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9846 return TEST_SUCCESS;
9850 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9852 struct aead_test_data tdata;
9855 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9856 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9857 tdata.plaintext.data[0] += 1;
9858 res = test_authenticated_decryption(&tdata);
9859 if (res == TEST_SKIPPED)
9861 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9862 return TEST_SUCCESS;
9866 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9868 struct aead_test_data tdata;
9871 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9872 tdata.ciphertext.data[0] += 1;
9873 res = test_authenticated_decryption(&tdata);
9874 if (res == TEST_SKIPPED)
9876 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9877 return TEST_SUCCESS;
9881 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9883 struct aead_test_data tdata;
9886 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9888 res = test_authenticated_decryption(&tdata);
9889 if (res == TEST_SKIPPED)
9891 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9892 return TEST_SUCCESS;
9896 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9898 struct aead_test_data tdata;
9899 uint8_t aad[gcm_test_case_7.aad.len];
9902 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9903 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9905 tdata.aad.data = aad;
9906 res = test_authenticated_decryption(&tdata);
9907 if (res == TEST_SKIPPED)
9909 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9910 return TEST_SUCCESS;
9914 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9916 struct aead_test_data tdata;
9919 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9920 tdata.auth_tag.data[0] += 1;
9921 res = test_authenticated_decryption(&tdata);
9922 if (res == TEST_SKIPPED)
9924 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9925 return TEST_SUCCESS;
9929 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9931 struct crypto_testsuite_params *ts_params = &testsuite_params;
9932 struct crypto_unittest_params *ut_params = &unittest_params;
9935 uint8_t *ciphertext, *auth_tag;
9936 uint16_t plaintext_pad_len;
9938 /* Verify the capabilities */
9939 struct rte_cryptodev_sym_capability_idx cap_idx;
9940 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9941 cap_idx.algo.aead = tdata->algo;
9942 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9944 return TEST_SKIPPED;
9946 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9947 return TEST_SKIPPED;
9949 /* not supported with CPU crypto */
9950 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9951 return TEST_SKIPPED;
9953 /* Create AEAD session */
9954 retval = create_aead_session(ts_params->valid_devs[0],
9956 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9957 tdata->key.data, tdata->key.len,
9958 tdata->aad.len, tdata->auth_tag.len,
9963 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9964 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9966 /* clear mbuf payload */
9967 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9968 rte_pktmbuf_tailroom(ut_params->ibuf));
9969 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9970 rte_pktmbuf_tailroom(ut_params->obuf));
9972 /* Create AEAD operation */
9973 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9977 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9979 ut_params->op->sym->m_src = ut_params->ibuf;
9980 ut_params->op->sym->m_dst = ut_params->obuf;
9982 /* Process crypto operation */
9983 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9984 ut_params->op), "failed to process sym crypto op");
9986 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9987 "crypto op processing failed");
9989 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9991 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9992 ut_params->op->sym->cipher.data.offset);
9993 auth_tag = ciphertext + plaintext_pad_len;
9995 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9996 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9999 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10001 tdata->ciphertext.data,
10002 tdata->ciphertext.len,
10003 "Ciphertext data not as expected");
10005 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10007 tdata->auth_tag.data,
10008 tdata->auth_tag.len,
10009 "Generated auth tag not as expected");
10016 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10018 return test_authenticated_encryption_oop(&gcm_test_case_5);
10022 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10024 struct crypto_testsuite_params *ts_params = &testsuite_params;
10025 struct crypto_unittest_params *ut_params = &unittest_params;
10028 uint8_t *plaintext;
10030 /* Verify the capabilities */
10031 struct rte_cryptodev_sym_capability_idx cap_idx;
10032 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10033 cap_idx.algo.aead = tdata->algo;
10034 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10036 return TEST_SKIPPED;
10038 /* not supported with CPU crypto and raw data-path APIs*/
10039 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10040 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10041 return TEST_SKIPPED;
10043 /* Create AEAD session */
10044 retval = create_aead_session(ts_params->valid_devs[0],
10046 RTE_CRYPTO_AEAD_OP_DECRYPT,
10047 tdata->key.data, tdata->key.len,
10048 tdata->aad.len, tdata->auth_tag.len,
10053 /* alloc mbuf and set payload */
10054 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10055 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10057 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10058 rte_pktmbuf_tailroom(ut_params->ibuf));
10059 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10060 rte_pktmbuf_tailroom(ut_params->obuf));
10062 /* Create AEAD operation */
10063 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10067 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10069 ut_params->op->sym->m_src = ut_params->ibuf;
10070 ut_params->op->sym->m_dst = ut_params->obuf;
10072 /* Process crypto operation */
10073 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10074 ut_params->op), "failed to process sym crypto op");
10076 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10077 "crypto op processing failed");
10079 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10080 ut_params->op->sym->cipher.data.offset);
10082 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10084 /* Validate obuf */
10085 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10087 tdata->plaintext.data,
10088 tdata->plaintext.len,
10089 "Plaintext data not as expected");
10091 TEST_ASSERT_EQUAL(ut_params->op->status,
10092 RTE_CRYPTO_OP_STATUS_SUCCESS,
10093 "Authentication failed");
10098 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10100 return test_authenticated_decryption_oop(&gcm_test_case_5);
10104 test_authenticated_encryption_sessionless(
10105 const struct aead_test_data *tdata)
10107 struct crypto_testsuite_params *ts_params = &testsuite_params;
10108 struct crypto_unittest_params *ut_params = &unittest_params;
10111 uint8_t *ciphertext, *auth_tag;
10112 uint16_t plaintext_pad_len;
10113 uint8_t key[tdata->key.len + 1];
10114 struct rte_cryptodev_info dev_info;
10116 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10117 uint64_t feat_flags = dev_info.feature_flags;
10119 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10120 printf("Device doesn't support Sessionless ops.\n");
10121 return TEST_SKIPPED;
10124 /* not supported with CPU crypto */
10125 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10126 return TEST_SKIPPED;
10128 /* Verify the capabilities */
10129 struct rte_cryptodev_sym_capability_idx cap_idx;
10130 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10131 cap_idx.algo.aead = tdata->algo;
10132 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10134 return TEST_SKIPPED;
10136 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10138 /* clear mbuf payload */
10139 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10140 rte_pktmbuf_tailroom(ut_params->ibuf));
10142 /* Create AEAD operation */
10143 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10147 /* Create GCM xform */
10148 memcpy(key, tdata->key.data, tdata->key.len);
10149 retval = create_aead_xform(ut_params->op,
10151 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10152 key, tdata->key.len,
10153 tdata->aad.len, tdata->auth_tag.len,
10158 ut_params->op->sym->m_src = ut_params->ibuf;
10160 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10161 RTE_CRYPTO_OP_SESSIONLESS,
10162 "crypto op session type not sessionless");
10164 /* Process crypto operation */
10165 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10166 ut_params->op), "failed to process sym crypto op");
10168 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10170 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10171 "crypto op status not success");
10173 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10175 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10176 ut_params->op->sym->cipher.data.offset);
10177 auth_tag = ciphertext + plaintext_pad_len;
10179 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10180 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10182 /* Validate obuf */
10183 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10185 tdata->ciphertext.data,
10186 tdata->ciphertext.len,
10187 "Ciphertext data not as expected");
10189 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10191 tdata->auth_tag.data,
10192 tdata->auth_tag.len,
10193 "Generated auth tag not as expected");
10200 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10202 return test_authenticated_encryption_sessionless(
10207 test_authenticated_decryption_sessionless(
10208 const struct aead_test_data *tdata)
10210 struct crypto_testsuite_params *ts_params = &testsuite_params;
10211 struct crypto_unittest_params *ut_params = &unittest_params;
10214 uint8_t *plaintext;
10215 uint8_t key[tdata->key.len + 1];
10216 struct rte_cryptodev_info dev_info;
10218 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10219 uint64_t feat_flags = dev_info.feature_flags;
10221 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10222 printf("Device doesn't support Sessionless ops.\n");
10223 return TEST_SKIPPED;
10226 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10227 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10228 printf("Device doesn't support RAW data-path APIs.\n");
10229 return TEST_SKIPPED;
10232 /* not supported with CPU crypto */
10233 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10234 return TEST_SKIPPED;
10236 /* Verify the capabilities */
10237 struct rte_cryptodev_sym_capability_idx cap_idx;
10238 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10239 cap_idx.algo.aead = tdata->algo;
10240 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10242 return TEST_SKIPPED;
10244 /* alloc mbuf and set payload */
10245 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10248 rte_pktmbuf_tailroom(ut_params->ibuf));
10250 /* Create AEAD operation */
10251 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10255 /* Create AEAD xform */
10256 memcpy(key, tdata->key.data, tdata->key.len);
10257 retval = create_aead_xform(ut_params->op,
10259 RTE_CRYPTO_AEAD_OP_DECRYPT,
10260 key, tdata->key.len,
10261 tdata->aad.len, tdata->auth_tag.len,
10266 ut_params->op->sym->m_src = ut_params->ibuf;
10268 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10269 RTE_CRYPTO_OP_SESSIONLESS,
10270 "crypto op session type not sessionless");
10272 /* Process crypto operation */
10273 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10274 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10275 ut_params->op, 0, 0, 0, 0);
10277 TEST_ASSERT_NOT_NULL(process_crypto_request(
10278 ts_params->valid_devs[0], ut_params->op),
10279 "failed to process sym crypto op");
10281 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10283 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10284 "crypto op status not success");
10286 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10287 ut_params->op->sym->cipher.data.offset);
10289 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10291 /* Validate obuf */
10292 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10294 tdata->plaintext.data,
10295 tdata->plaintext.len,
10296 "Plaintext data not as expected");
10298 TEST_ASSERT_EQUAL(ut_params->op->status,
10299 RTE_CRYPTO_OP_STATUS_SUCCESS,
10300 "Authentication failed");
10305 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10307 return test_authenticated_decryption_sessionless(
10312 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10314 return test_authenticated_encryption(&ccm_test_case_128_1);
10318 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10320 return test_authenticated_encryption(&ccm_test_case_128_2);
10324 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10326 return test_authenticated_encryption(&ccm_test_case_128_3);
10330 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10332 return test_authenticated_decryption(&ccm_test_case_128_1);
10336 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10338 return test_authenticated_decryption(&ccm_test_case_128_2);
10342 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10344 return test_authenticated_decryption(&ccm_test_case_128_3);
10348 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10350 return test_authenticated_encryption(&ccm_test_case_192_1);
10354 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10356 return test_authenticated_encryption(&ccm_test_case_192_2);
10360 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10362 return test_authenticated_encryption(&ccm_test_case_192_3);
10366 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10368 return test_authenticated_decryption(&ccm_test_case_192_1);
10372 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10374 return test_authenticated_decryption(&ccm_test_case_192_2);
10378 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10380 return test_authenticated_decryption(&ccm_test_case_192_3);
10384 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10386 return test_authenticated_encryption(&ccm_test_case_256_1);
10390 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10392 return test_authenticated_encryption(&ccm_test_case_256_2);
10396 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10398 return test_authenticated_encryption(&ccm_test_case_256_3);
10402 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10404 return test_authenticated_decryption(&ccm_test_case_256_1);
10408 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10410 return test_authenticated_decryption(&ccm_test_case_256_2);
10414 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10416 return test_authenticated_decryption(&ccm_test_case_256_3);
10422 struct crypto_testsuite_params *ts_params = &testsuite_params;
10423 struct rte_cryptodev_stats stats;
10425 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10426 return TEST_SKIPPED;
10428 /* Verify the capabilities */
10429 struct rte_cryptodev_sym_capability_idx cap_idx;
10430 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10431 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10432 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10434 return TEST_SKIPPED;
10435 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10436 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10437 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10439 return TEST_SKIPPED;
10441 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10443 return TEST_SKIPPED;
10445 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10446 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10447 &stats) == -ENODEV),
10448 "rte_cryptodev_stats_get invalid dev failed");
10449 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10450 "rte_cryptodev_stats_get invalid Param failed");
10452 /* Test expected values */
10453 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10454 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10456 "rte_cryptodev_stats_get failed");
10457 TEST_ASSERT((stats.enqueued_count == 1),
10458 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10459 TEST_ASSERT((stats.dequeued_count == 1),
10460 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10461 TEST_ASSERT((stats.enqueue_err_count == 0),
10462 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10463 TEST_ASSERT((stats.dequeue_err_count == 0),
10464 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10466 /* invalid device but should ignore and not reset device stats*/
10467 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10468 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10470 "rte_cryptodev_stats_get failed");
10471 TEST_ASSERT((stats.enqueued_count == 1),
10472 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10474 /* check that a valid reset clears stats */
10475 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10476 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10478 "rte_cryptodev_stats_get failed");
10479 TEST_ASSERT((stats.enqueued_count == 0),
10480 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10481 TEST_ASSERT((stats.dequeued_count == 0),
10482 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10484 return TEST_SUCCESS;
10487 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10488 struct crypto_unittest_params *ut_params,
10489 enum rte_crypto_auth_operation op,
10490 const struct HMAC_MD5_vector *test_case)
10494 memcpy(key, test_case->key.data, test_case->key.len);
10496 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10497 ut_params->auth_xform.next = NULL;
10498 ut_params->auth_xform.auth.op = op;
10500 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10502 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10503 ut_params->auth_xform.auth.key.length = test_case->key.len;
10504 ut_params->auth_xform.auth.key.data = key;
10506 ut_params->sess = rte_cryptodev_sym_session_create(
10507 ts_params->session_mpool);
10509 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10510 ut_params->sess, &ut_params->auth_xform,
10511 ts_params->session_priv_mpool);
10513 if (ut_params->sess == NULL)
10514 return TEST_FAILED;
10516 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10518 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10519 rte_pktmbuf_tailroom(ut_params->ibuf));
10524 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10525 const struct HMAC_MD5_vector *test_case,
10526 uint8_t **plaintext)
10528 uint16_t plaintext_pad_len;
10530 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10532 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10535 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10536 plaintext_pad_len);
10537 memcpy(*plaintext, test_case->plaintext.data,
10538 test_case->plaintext.len);
10540 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10541 ut_params->ibuf, MD5_DIGEST_LEN);
10542 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10543 "no room to append digest");
10544 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10545 ut_params->ibuf, plaintext_pad_len);
10547 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10548 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10549 test_case->auth_tag.len);
10552 sym_op->auth.data.offset = 0;
10553 sym_op->auth.data.length = test_case->plaintext.len;
10555 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10556 ut_params->op->sym->m_src = ut_params->ibuf;
10562 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10564 uint16_t plaintext_pad_len;
10565 uint8_t *plaintext, *auth_tag;
10567 struct crypto_testsuite_params *ts_params = &testsuite_params;
10568 struct crypto_unittest_params *ut_params = &unittest_params;
10569 struct rte_cryptodev_info dev_info;
10571 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10572 uint64_t feat_flags = dev_info.feature_flags;
10574 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10575 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10576 printf("Device doesn't support RAW data-path APIs.\n");
10577 return TEST_SKIPPED;
10580 /* Verify the capabilities */
10581 struct rte_cryptodev_sym_capability_idx cap_idx;
10582 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10583 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10584 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10586 return TEST_SKIPPED;
10588 if (MD5_HMAC_create_session(ts_params, ut_params,
10589 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10590 return TEST_FAILED;
10592 /* Generate Crypto op data structure */
10593 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10594 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10595 TEST_ASSERT_NOT_NULL(ut_params->op,
10596 "Failed to allocate symmetric crypto operation struct");
10598 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10601 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10602 return TEST_FAILED;
10604 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10605 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10607 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10608 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10609 ut_params->op, 0, 1, 0, 0);
10611 TEST_ASSERT_NOT_NULL(
10612 process_crypto_request(ts_params->valid_devs[0],
10614 "failed to process sym crypto op");
10616 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10617 "crypto op processing failed");
10619 if (ut_params->op->sym->m_dst) {
10620 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10621 uint8_t *, plaintext_pad_len);
10623 auth_tag = plaintext + plaintext_pad_len;
10626 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10628 test_case->auth_tag.data,
10629 test_case->auth_tag.len,
10630 "HMAC_MD5 generated tag not as expected");
10632 return TEST_SUCCESS;
10636 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10638 uint8_t *plaintext;
10640 struct crypto_testsuite_params *ts_params = &testsuite_params;
10641 struct crypto_unittest_params *ut_params = &unittest_params;
10642 struct rte_cryptodev_info dev_info;
10644 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10645 uint64_t feat_flags = dev_info.feature_flags;
10647 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10648 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10649 printf("Device doesn't support RAW data-path APIs.\n");
10650 return TEST_SKIPPED;
10653 /* Verify the capabilities */
10654 struct rte_cryptodev_sym_capability_idx cap_idx;
10655 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10656 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10657 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10659 return TEST_SKIPPED;
10661 if (MD5_HMAC_create_session(ts_params, ut_params,
10662 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10663 return TEST_FAILED;
10666 /* Generate Crypto op data structure */
10667 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10668 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10669 TEST_ASSERT_NOT_NULL(ut_params->op,
10670 "Failed to allocate symmetric crypto operation struct");
10672 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10673 return TEST_FAILED;
10675 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10676 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10678 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10679 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10680 ut_params->op, 0, 1, 0, 0);
10682 TEST_ASSERT_NOT_NULL(
10683 process_crypto_request(ts_params->valid_devs[0],
10685 "failed to process sym crypto op");
10687 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10688 "HMAC_MD5 crypto op processing failed");
10690 return TEST_SUCCESS;
10694 test_MD5_HMAC_generate_case_1(void)
10696 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10700 test_MD5_HMAC_verify_case_1(void)
10702 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10706 test_MD5_HMAC_generate_case_2(void)
10708 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10712 test_MD5_HMAC_verify_case_2(void)
10714 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10718 test_multi_session(void)
10720 struct crypto_testsuite_params *ts_params = &testsuite_params;
10721 struct crypto_unittest_params *ut_params = &unittest_params;
10723 struct rte_cryptodev_info dev_info;
10724 struct rte_cryptodev_sym_session **sessions;
10728 /* Verify the capabilities */
10729 struct rte_cryptodev_sym_capability_idx cap_idx;
10730 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10731 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10732 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10734 return TEST_SKIPPED;
10735 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10736 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10737 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10739 return TEST_SKIPPED;
10741 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10742 aes_cbc_key, hmac_sha512_key);
10745 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10747 sessions = rte_malloc(NULL,
10748 sizeof(struct rte_cryptodev_sym_session *) *
10749 (MAX_NB_SESSIONS + 1), 0);
10751 /* Create multiple crypto sessions*/
10752 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10754 sessions[i] = rte_cryptodev_sym_session_create(
10755 ts_params->session_mpool);
10757 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10758 sessions[i], &ut_params->auth_xform,
10759 ts_params->session_priv_mpool);
10760 TEST_ASSERT_NOT_NULL(sessions[i],
10761 "Session creation failed at session number %u",
10764 /* Attempt to send a request on each session */
10765 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10769 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10770 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10772 "Failed to perform decrypt on request number %u.", i);
10773 /* free crypto operation structure */
10775 rte_crypto_op_free(ut_params->op);
10778 * free mbuf - both obuf and ibuf are usually the same,
10779 * so check if they point at the same address is necessary,
10780 * to avoid freeing the mbuf twice.
10782 if (ut_params->obuf) {
10783 rte_pktmbuf_free(ut_params->obuf);
10784 if (ut_params->ibuf == ut_params->obuf)
10785 ut_params->ibuf = 0;
10786 ut_params->obuf = 0;
10788 if (ut_params->ibuf) {
10789 rte_pktmbuf_free(ut_params->ibuf);
10790 ut_params->ibuf = 0;
10794 sessions[i] = NULL;
10795 /* Next session create should fail */
10796 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10797 sessions[i], &ut_params->auth_xform,
10798 ts_params->session_priv_mpool);
10799 TEST_ASSERT_NULL(sessions[i],
10800 "Session creation succeeded unexpectedly!");
10802 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10803 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10805 rte_cryptodev_sym_session_free(sessions[i]);
10808 rte_free(sessions);
10810 return TEST_SUCCESS;
10813 struct multi_session_params {
10814 struct crypto_unittest_params ut_params;
10815 uint8_t *cipher_key;
10817 const uint8_t *cipher;
10818 const uint8_t *digest;
10822 #define MB_SESSION_NUMBER 3
10825 test_multi_session_random_usage(void)
10827 struct crypto_testsuite_params *ts_params = &testsuite_params;
10828 struct rte_cryptodev_info dev_info;
10829 struct rte_cryptodev_sym_session **sessions;
10831 struct multi_session_params ut_paramz[] = {
10834 .cipher_key = ms_aes_cbc_key0,
10835 .hmac_key = ms_hmac_key0,
10836 .cipher = ms_aes_cbc_cipher0,
10837 .digest = ms_hmac_digest0,
10838 .iv = ms_aes_cbc_iv0
10841 .cipher_key = ms_aes_cbc_key1,
10842 .hmac_key = ms_hmac_key1,
10843 .cipher = ms_aes_cbc_cipher1,
10844 .digest = ms_hmac_digest1,
10845 .iv = ms_aes_cbc_iv1
10848 .cipher_key = ms_aes_cbc_key2,
10849 .hmac_key = ms_hmac_key2,
10850 .cipher = ms_aes_cbc_cipher2,
10851 .digest = ms_hmac_digest2,
10852 .iv = ms_aes_cbc_iv2
10857 /* Verify the capabilities */
10858 struct rte_cryptodev_sym_capability_idx cap_idx;
10859 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10860 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10861 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10863 return TEST_SKIPPED;
10864 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10865 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10866 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10868 return TEST_SKIPPED;
10870 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10872 sessions = rte_malloc(NULL,
10873 (sizeof(struct rte_cryptodev_sym_session *)
10874 * MAX_NB_SESSIONS) + 1, 0);
10876 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10877 sessions[i] = rte_cryptodev_sym_session_create(
10878 ts_params->session_mpool);
10880 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10881 sizeof(struct crypto_unittest_params));
10883 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10884 &ut_paramz[i].ut_params,
10885 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10887 /* Create multiple crypto sessions*/
10888 rte_cryptodev_sym_session_init(
10889 ts_params->valid_devs[0],
10891 &ut_paramz[i].ut_params.auth_xform,
10892 ts_params->session_priv_mpool);
10894 TEST_ASSERT_NOT_NULL(sessions[i],
10895 "Session creation failed at session number %u",
10901 for (i = 0; i < 40000; i++) {
10903 j = rand() % MB_SESSION_NUMBER;
10905 TEST_ASSERT_SUCCESS(
10906 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10908 &ut_paramz[j].ut_params,
10909 ts_params, ut_paramz[j].cipher,
10910 ut_paramz[j].digest,
10912 "Failed to perform decrypt on request number %u.", i);
10914 if (ut_paramz[j].ut_params.op)
10915 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10918 * free mbuf - both obuf and ibuf are usually the same,
10919 * so check if they point at the same address is necessary,
10920 * to avoid freeing the mbuf twice.
10922 if (ut_paramz[j].ut_params.obuf) {
10923 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10924 if (ut_paramz[j].ut_params.ibuf
10925 == ut_paramz[j].ut_params.obuf)
10926 ut_paramz[j].ut_params.ibuf = 0;
10927 ut_paramz[j].ut_params.obuf = 0;
10929 if (ut_paramz[j].ut_params.ibuf) {
10930 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10931 ut_paramz[j].ut_params.ibuf = 0;
10935 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10936 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10938 rte_cryptodev_sym_session_free(sessions[i]);
10941 rte_free(sessions);
10943 return TEST_SUCCESS;
10946 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10947 0xab, 0xab, 0xab, 0xab,
10948 0xab, 0xab, 0xab, 0xab,
10949 0xab, 0xab, 0xab, 0xab};
10952 test_null_invalid_operation(void)
10954 struct crypto_testsuite_params *ts_params = &testsuite_params;
10955 struct crypto_unittest_params *ut_params = &unittest_params;
10958 /* This test is for NULL PMD only */
10959 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10960 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10961 return TEST_SKIPPED;
10963 /* Setup Cipher Parameters */
10964 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10965 ut_params->cipher_xform.next = NULL;
10967 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10968 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10970 ut_params->sess = rte_cryptodev_sym_session_create(
10971 ts_params->session_mpool);
10973 /* Create Crypto session*/
10974 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10975 ut_params->sess, &ut_params->cipher_xform,
10976 ts_params->session_priv_mpool);
10977 TEST_ASSERT(ret < 0,
10978 "Session creation succeeded unexpectedly");
10981 /* Setup HMAC Parameters */
10982 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10983 ut_params->auth_xform.next = NULL;
10985 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10986 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10988 ut_params->sess = rte_cryptodev_sym_session_create(
10989 ts_params->session_mpool);
10991 /* Create Crypto session*/
10992 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10993 ut_params->sess, &ut_params->auth_xform,
10994 ts_params->session_priv_mpool);
10995 TEST_ASSERT(ret < 0,
10996 "Session creation succeeded unexpectedly");
10998 return TEST_SUCCESS;
11002 #define NULL_BURST_LENGTH (32)
11005 test_null_burst_operation(void)
11007 struct crypto_testsuite_params *ts_params = &testsuite_params;
11008 struct crypto_unittest_params *ut_params = &unittest_params;
11010 unsigned i, burst_len = NULL_BURST_LENGTH;
11012 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11013 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11015 /* This test is for NULL PMD only */
11016 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11017 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11018 return TEST_SKIPPED;
11020 /* Setup Cipher Parameters */
11021 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11022 ut_params->cipher_xform.next = &ut_params->auth_xform;
11024 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11025 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11027 /* Setup HMAC Parameters */
11028 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11029 ut_params->auth_xform.next = NULL;
11031 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11032 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11034 ut_params->sess = rte_cryptodev_sym_session_create(
11035 ts_params->session_mpool);
11037 /* Create Crypto session*/
11038 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11039 ut_params->sess, &ut_params->cipher_xform,
11040 ts_params->session_priv_mpool);
11041 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11043 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11044 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11045 burst_len, "failed to generate burst of crypto ops");
11047 /* Generate an operation for each mbuf in burst */
11048 for (i = 0; i < burst_len; i++) {
11049 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11051 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11053 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11057 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11059 burst[i]->sym->m_src = m;
11062 /* Process crypto operation */
11063 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11064 0, burst, burst_len),
11066 "Error enqueuing burst");
11068 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11069 0, burst_dequeued, burst_len),
11071 "Error dequeuing burst");
11074 for (i = 0; i < burst_len; i++) {
11076 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11077 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11079 "data not as expected");
11081 rte_pktmbuf_free(burst[i]->sym->m_src);
11082 rte_crypto_op_free(burst[i]);
11085 return TEST_SUCCESS;
11089 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11090 uint16_t nb_ops, void *user_param)
11092 RTE_SET_USED(dev_id);
11093 RTE_SET_USED(qp_id);
11095 RTE_SET_USED(user_param);
11097 printf("crypto enqueue callback called\n");
11102 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11103 uint16_t nb_ops, void *user_param)
11105 RTE_SET_USED(dev_id);
11106 RTE_SET_USED(qp_id);
11108 RTE_SET_USED(user_param);
11110 printf("crypto dequeue callback called\n");
11115 * Thread using enqueue/dequeue callback with RCU.
11118 test_enqdeq_callback_thread(void *arg)
11121 /* DP thread calls rte_cryptodev_enqueue_burst()/
11122 * rte_cryptodev_dequeue_burst() and invokes callback.
11124 test_null_burst_operation();
11129 test_enq_callback_setup(void)
11131 struct crypto_testsuite_params *ts_params = &testsuite_params;
11132 struct rte_cryptodev_info dev_info;
11133 struct rte_cryptodev_qp_conf qp_conf = {
11134 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11137 struct rte_cryptodev_cb *cb;
11138 uint16_t qp_id = 0;
11140 /* Stop the device in case it's started so it can be configured */
11141 rte_cryptodev_stop(ts_params->valid_devs[0]);
11143 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11145 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11147 "Failed to configure cryptodev %u",
11148 ts_params->valid_devs[0]);
11150 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11151 qp_conf.mp_session = ts_params->session_mpool;
11152 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11154 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11155 ts_params->valid_devs[0], qp_id, &qp_conf,
11156 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11158 "rte_cryptodev_queue_pair_setup: num_inflights "
11159 "%u on qp %u on cryptodev %u",
11160 qp_conf.nb_descriptors, qp_id,
11161 ts_params->valid_devs[0]);
11163 /* Test with invalid crypto device */
11164 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11165 qp_id, test_enq_callback, NULL);
11166 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11167 "cryptodev %u did not fail",
11168 qp_id, RTE_CRYPTO_MAX_DEVS);
11170 /* Test with invalid queue pair */
11171 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11172 dev_info.max_nb_queue_pairs + 1,
11173 test_enq_callback, NULL);
11174 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11175 "cryptodev %u did not fail",
11176 dev_info.max_nb_queue_pairs + 1,
11177 ts_params->valid_devs[0]);
11179 /* Test with NULL callback */
11180 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11181 qp_id, NULL, NULL);
11182 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11183 "cryptodev %u did not fail",
11184 qp_id, ts_params->valid_devs[0]);
11186 /* Test with valid configuration */
11187 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11188 qp_id, test_enq_callback, NULL);
11189 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11190 "qp %u on cryptodev %u",
11191 qp_id, ts_params->valid_devs[0]);
11193 rte_cryptodev_start(ts_params->valid_devs[0]);
11195 /* Launch a thread */
11196 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11197 rte_get_next_lcore(-1, 1, 0));
11199 /* Wait until reader exited. */
11200 rte_eal_mp_wait_lcore();
11202 /* Test with invalid crypto device */
11203 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11204 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11205 "Expected call to fail as crypto device is invalid");
11207 /* Test with invalid queue pair */
11208 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11209 ts_params->valid_devs[0],
11210 dev_info.max_nb_queue_pairs + 1, cb),
11211 "Expected call to fail as queue pair is invalid");
11213 /* Test with NULL callback */
11214 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11215 ts_params->valid_devs[0], qp_id, NULL),
11216 "Expected call to fail as callback is NULL");
11218 /* Test with valid configuration */
11219 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11220 ts_params->valid_devs[0], qp_id, cb),
11221 "Failed test to remove callback on "
11222 "qp %u on cryptodev %u",
11223 qp_id, ts_params->valid_devs[0]);
11225 return TEST_SUCCESS;
11229 test_deq_callback_setup(void)
11231 struct crypto_testsuite_params *ts_params = &testsuite_params;
11232 struct rte_cryptodev_info dev_info;
11233 struct rte_cryptodev_qp_conf qp_conf = {
11234 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11237 struct rte_cryptodev_cb *cb;
11238 uint16_t qp_id = 0;
11240 /* Stop the device in case it's started so it can be configured */
11241 rte_cryptodev_stop(ts_params->valid_devs[0]);
11243 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11245 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11247 "Failed to configure cryptodev %u",
11248 ts_params->valid_devs[0]);
11250 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11251 qp_conf.mp_session = ts_params->session_mpool;
11252 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11254 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11255 ts_params->valid_devs[0], qp_id, &qp_conf,
11256 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11258 "rte_cryptodev_queue_pair_setup: num_inflights "
11259 "%u on qp %u on cryptodev %u",
11260 qp_conf.nb_descriptors, qp_id,
11261 ts_params->valid_devs[0]);
11263 /* Test with invalid crypto device */
11264 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11265 qp_id, test_deq_callback, NULL);
11266 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11267 "cryptodev %u did not fail",
11268 qp_id, RTE_CRYPTO_MAX_DEVS);
11270 /* Test with invalid queue pair */
11271 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11272 dev_info.max_nb_queue_pairs + 1,
11273 test_deq_callback, NULL);
11274 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11275 "cryptodev %u did not fail",
11276 dev_info.max_nb_queue_pairs + 1,
11277 ts_params->valid_devs[0]);
11279 /* Test with NULL callback */
11280 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11281 qp_id, NULL, NULL);
11282 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11283 "cryptodev %u did not fail",
11284 qp_id, ts_params->valid_devs[0]);
11286 /* Test with valid configuration */
11287 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11288 qp_id, test_deq_callback, NULL);
11289 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11290 "qp %u on cryptodev %u",
11291 qp_id, ts_params->valid_devs[0]);
11293 rte_cryptodev_start(ts_params->valid_devs[0]);
11295 /* Launch a thread */
11296 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11297 rte_get_next_lcore(-1, 1, 0));
11299 /* Wait until reader exited. */
11300 rte_eal_mp_wait_lcore();
11302 /* Test with invalid crypto device */
11303 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11304 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11305 "Expected call to fail as crypto device is invalid");
11307 /* Test with invalid queue pair */
11308 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11309 ts_params->valid_devs[0],
11310 dev_info.max_nb_queue_pairs + 1, cb),
11311 "Expected call to fail as queue pair is invalid");
11313 /* Test with NULL callback */
11314 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11315 ts_params->valid_devs[0], qp_id, NULL),
11316 "Expected call to fail as callback is NULL");
11318 /* Test with valid configuration */
11319 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11320 ts_params->valid_devs[0], qp_id, cb),
11321 "Failed test to remove callback on "
11322 "qp %u on cryptodev %u",
11323 qp_id, ts_params->valid_devs[0]);
11325 return TEST_SUCCESS;
11329 generate_gmac_large_plaintext(uint8_t *data)
11333 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11334 memcpy(&data[i], &data[0], 32);
11338 create_gmac_operation(enum rte_crypto_auth_operation op,
11339 const struct gmac_test_data *tdata)
11341 struct crypto_testsuite_params *ts_params = &testsuite_params;
11342 struct crypto_unittest_params *ut_params = &unittest_params;
11343 struct rte_crypto_sym_op *sym_op;
11345 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11347 /* Generate Crypto op data structure */
11348 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11349 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11350 TEST_ASSERT_NOT_NULL(ut_params->op,
11351 "Failed to allocate symmetric crypto operation struct");
11353 sym_op = ut_params->op->sym;
11355 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11356 ut_params->ibuf, tdata->gmac_tag.len);
11357 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11358 "no room to append digest");
11360 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11361 ut_params->ibuf, plaintext_pad_len);
11363 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11364 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11365 tdata->gmac_tag.len);
11366 debug_hexdump(stdout, "digest:",
11367 sym_op->auth.digest.data,
11368 tdata->gmac_tag.len);
11371 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11372 uint8_t *, IV_OFFSET);
11374 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11376 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11378 sym_op->cipher.data.length = 0;
11379 sym_op->cipher.data.offset = 0;
11381 sym_op->auth.data.offset = 0;
11382 sym_op->auth.data.length = tdata->plaintext.len;
11388 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11389 const struct gmac_test_data *tdata,
11390 void *digest_mem, uint64_t digest_phys)
11392 struct crypto_testsuite_params *ts_params = &testsuite_params;
11393 struct crypto_unittest_params *ut_params = &unittest_params;
11394 struct rte_crypto_sym_op *sym_op;
11396 /* Generate Crypto op data structure */
11397 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11398 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11399 TEST_ASSERT_NOT_NULL(ut_params->op,
11400 "Failed to allocate symmetric crypto operation struct");
11402 sym_op = ut_params->op->sym;
11404 sym_op->auth.digest.data = digest_mem;
11405 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11406 "no room to append digest");
11408 sym_op->auth.digest.phys_addr = digest_phys;
11410 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11411 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11412 tdata->gmac_tag.len);
11413 debug_hexdump(stdout, "digest:",
11414 sym_op->auth.digest.data,
11415 tdata->gmac_tag.len);
11418 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11419 uint8_t *, IV_OFFSET);
11421 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11423 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11425 sym_op->cipher.data.length = 0;
11426 sym_op->cipher.data.offset = 0;
11428 sym_op->auth.data.offset = 0;
11429 sym_op->auth.data.length = tdata->plaintext.len;
11434 static int create_gmac_session(uint8_t dev_id,
11435 const struct gmac_test_data *tdata,
11436 enum rte_crypto_auth_operation auth_op)
11438 uint8_t auth_key[tdata->key.len];
11440 struct crypto_testsuite_params *ts_params = &testsuite_params;
11441 struct crypto_unittest_params *ut_params = &unittest_params;
11443 memcpy(auth_key, tdata->key.data, tdata->key.len);
11445 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11446 ut_params->auth_xform.next = NULL;
11448 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11449 ut_params->auth_xform.auth.op = auth_op;
11450 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11451 ut_params->auth_xform.auth.key.length = tdata->key.len;
11452 ut_params->auth_xform.auth.key.data = auth_key;
11453 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11454 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11457 ut_params->sess = rte_cryptodev_sym_session_create(
11458 ts_params->session_mpool);
11460 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11461 &ut_params->auth_xform,
11462 ts_params->session_priv_mpool);
11464 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11470 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11472 struct crypto_testsuite_params *ts_params = &testsuite_params;
11473 struct crypto_unittest_params *ut_params = &unittest_params;
11474 struct rte_cryptodev_info dev_info;
11476 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11477 uint64_t feat_flags = dev_info.feature_flags;
11479 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11480 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11481 printf("Device doesn't support RAW data-path APIs.\n");
11482 return TEST_SKIPPED;
11487 uint8_t *auth_tag, *plaintext;
11488 uint16_t plaintext_pad_len;
11490 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11491 "No GMAC length in the source data");
11493 /* Verify the capabilities */
11494 struct rte_cryptodev_sym_capability_idx cap_idx;
11495 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11496 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11497 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11499 return TEST_SKIPPED;
11501 retval = create_gmac_session(ts_params->valid_devs[0],
11502 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11507 if (tdata->plaintext.len > MBUF_SIZE)
11508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11510 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11511 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11512 "Failed to allocate input buffer in mempool");
11514 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11515 rte_pktmbuf_tailroom(ut_params->ibuf));
11517 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11519 * Runtime generate the large plain text instead of use hard code
11520 * plain text vector. It is done to avoid create huge source file
11521 * with the test vector.
11523 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11524 generate_gmac_large_plaintext(tdata->plaintext.data);
11526 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11527 plaintext_pad_len);
11528 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11530 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11531 debug_hexdump(stdout, "plaintext:", plaintext,
11532 tdata->plaintext.len);
11534 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11540 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11542 ut_params->op->sym->m_src = ut_params->ibuf;
11544 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11545 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11547 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11548 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11549 ut_params->op, 0, 1, 0, 0);
11551 TEST_ASSERT_NOT_NULL(
11552 process_crypto_request(ts_params->valid_devs[0],
11553 ut_params->op), "failed to process sym crypto op");
11555 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11556 "crypto op processing failed");
11558 if (ut_params->op->sym->m_dst) {
11559 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11560 uint8_t *, plaintext_pad_len);
11562 auth_tag = plaintext + plaintext_pad_len;
11565 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11567 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11569 tdata->gmac_tag.data,
11570 tdata->gmac_tag.len,
11571 "GMAC Generated auth tag not as expected");
11577 test_AES_GMAC_authentication_test_case_1(void)
11579 return test_AES_GMAC_authentication(&gmac_test_case_1);
11583 test_AES_GMAC_authentication_test_case_2(void)
11585 return test_AES_GMAC_authentication(&gmac_test_case_2);
11589 test_AES_GMAC_authentication_test_case_3(void)
11591 return test_AES_GMAC_authentication(&gmac_test_case_3);
11595 test_AES_GMAC_authentication_test_case_4(void)
11597 return test_AES_GMAC_authentication(&gmac_test_case_4);
11601 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11603 struct crypto_testsuite_params *ts_params = &testsuite_params;
11604 struct crypto_unittest_params *ut_params = &unittest_params;
11606 uint32_t plaintext_pad_len;
11607 uint8_t *plaintext;
11608 struct rte_cryptodev_info dev_info;
11610 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11611 uint64_t feat_flags = dev_info.feature_flags;
11613 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11614 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11615 printf("Device doesn't support RAW data-path APIs.\n");
11616 return TEST_SKIPPED;
11619 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11620 "No GMAC length in the source data");
11622 /* Verify the capabilities */
11623 struct rte_cryptodev_sym_capability_idx cap_idx;
11624 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11625 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11626 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11628 return TEST_SKIPPED;
11630 retval = create_gmac_session(ts_params->valid_devs[0],
11631 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11636 if (tdata->plaintext.len > MBUF_SIZE)
11637 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11639 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11640 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11641 "Failed to allocate input buffer in mempool");
11643 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11644 rte_pktmbuf_tailroom(ut_params->ibuf));
11646 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11649 * Runtime generate the large plain text instead of use hard code
11650 * plain text vector. It is done to avoid create huge source file
11651 * with the test vector.
11653 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11654 generate_gmac_large_plaintext(tdata->plaintext.data);
11656 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11657 plaintext_pad_len);
11658 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11660 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11661 debug_hexdump(stdout, "plaintext:", plaintext,
11662 tdata->plaintext.len);
11664 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11670 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11672 ut_params->op->sym->m_src = ut_params->ibuf;
11674 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11675 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11677 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11678 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11679 ut_params->op, 0, 1, 0, 0);
11681 TEST_ASSERT_NOT_NULL(
11682 process_crypto_request(ts_params->valid_devs[0],
11683 ut_params->op), "failed to process sym crypto op");
11685 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11686 "crypto op processing failed");
11693 test_AES_GMAC_authentication_verify_test_case_1(void)
11695 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11699 test_AES_GMAC_authentication_verify_test_case_2(void)
11701 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11705 test_AES_GMAC_authentication_verify_test_case_3(void)
11707 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11711 test_AES_GMAC_authentication_verify_test_case_4(void)
11713 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11717 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11720 struct crypto_testsuite_params *ts_params = &testsuite_params;
11721 struct crypto_unittest_params *ut_params = &unittest_params;
11722 struct rte_cryptodev_info dev_info;
11723 uint64_t feature_flags;
11724 unsigned int trn_data = 0;
11725 void *digest_mem = NULL;
11727 unsigned int to_trn = 0;
11728 struct rte_mbuf *buf = NULL;
11729 uint8_t *auth_tag, *plaintext;
11732 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11733 "No GMAC length in the source data");
11735 /* Verify the capabilities */
11736 struct rte_cryptodev_sym_capability_idx cap_idx;
11737 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11738 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11739 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11741 return TEST_SKIPPED;
11743 /* Check for any input SGL support */
11744 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11745 feature_flags = dev_info.feature_flags;
11747 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11748 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11749 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11750 return TEST_SKIPPED;
11752 if (fragsz > tdata->plaintext.len)
11753 fragsz = tdata->plaintext.len;
11755 uint16_t plaintext_len = fragsz;
11757 retval = create_gmac_session(ts_params->valid_devs[0],
11758 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11763 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11764 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11765 "Failed to allocate input buffer in mempool");
11767 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11768 rte_pktmbuf_tailroom(ut_params->ibuf));
11770 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11772 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11774 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11776 trn_data += plaintext_len;
11778 buf = ut_params->ibuf;
11781 * Loop until no more fragments
11784 while (trn_data < tdata->plaintext.len) {
11786 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11787 (tdata->plaintext.len - trn_data) : fragsz;
11789 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11792 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11793 rte_pktmbuf_tailroom(buf));
11795 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11798 memcpy(plaintext, tdata->plaintext.data + trn_data,
11800 trn_data += to_trn;
11801 if (trn_data == tdata->plaintext.len)
11802 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11803 tdata->gmac_tag.len);
11805 ut_params->ibuf->nb_segs = segs;
11808 * Place digest at the end of the last buffer
11810 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11813 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11814 + tdata->gmac_tag.len);
11815 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11816 tdata->plaintext.len);
11819 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11820 tdata, digest_mem, digest_phys);
11825 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11827 ut_params->op->sym->m_src = ut_params->ibuf;
11829 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11830 return TEST_SKIPPED;
11832 TEST_ASSERT_NOT_NULL(
11833 process_crypto_request(ts_params->valid_devs[0],
11834 ut_params->op), "failed to process sym crypto op");
11836 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11837 "crypto op processing failed");
11839 auth_tag = digest_mem;
11840 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11841 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11843 tdata->gmac_tag.data,
11844 tdata->gmac_tag.len,
11845 "GMAC Generated auth tag not as expected");
11850 /* Segment size not multiple of block size (16B) */
11852 test_AES_GMAC_authentication_SGL_40B(void)
11854 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11858 test_AES_GMAC_authentication_SGL_80B(void)
11860 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11864 test_AES_GMAC_authentication_SGL_2048B(void)
11866 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11869 /* Segment size not multiple of block size (16B) */
11871 test_AES_GMAC_authentication_SGL_2047B(void)
11873 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11876 struct test_crypto_vector {
11877 enum rte_crypto_cipher_algorithm crypto_algo;
11878 unsigned int cipher_offset;
11879 unsigned int cipher_len;
11892 const uint8_t *data;
11897 const uint8_t *data;
11901 enum rte_crypto_auth_algorithm auth_algo;
11902 unsigned int auth_offset;
11910 const uint8_t *data;
11920 static const struct test_crypto_vector
11921 hmac_sha1_test_crypto_vector = {
11922 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11924 .data = plaintext_hash,
11929 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11930 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11931 0xDE, 0xF4, 0xDE, 0xAD
11937 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11938 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11939 0x3F, 0x91, 0x64, 0x59
11945 static const struct test_crypto_vector
11946 aes128_gmac_test_vector = {
11947 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11949 .data = plaintext_hash,
11954 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11955 0x08, 0x09, 0x0A, 0x0B
11961 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11962 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11968 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11969 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11975 static const struct test_crypto_vector
11976 aes128cbc_hmac_sha1_test_vector = {
11977 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11978 .cipher_offset = 0,
11982 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11983 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11989 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11990 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11995 .data = plaintext_hash,
11999 .data = ciphertext512_aes128cbc,
12002 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12006 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12007 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12008 0xDE, 0xF4, 0xDE, 0xAD
12014 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12015 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12016 0x18, 0x8C, 0x1D, 0x32
12022 static const struct test_crypto_vector
12023 aes128cbc_hmac_sha1_aad_test_vector = {
12024 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12025 .cipher_offset = 8,
12029 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12030 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12036 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12037 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12042 .data = plaintext_hash,
12046 .data = ciphertext512_aes128cbc_aad,
12049 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12053 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12054 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12055 0xDE, 0xF4, 0xDE, 0xAD
12061 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12062 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12063 0x62, 0x0F, 0xFB, 0x10
12070 data_corruption(uint8_t *data)
12076 tag_corruption(uint8_t *data, unsigned int tag_offset)
12078 data[tag_offset] += 1;
12082 create_auth_session(struct crypto_unittest_params *ut_params,
12084 const struct test_crypto_vector *reference,
12085 enum rte_crypto_auth_operation auth_op)
12087 struct crypto_testsuite_params *ts_params = &testsuite_params;
12088 uint8_t auth_key[reference->auth_key.len + 1];
12090 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12092 /* Setup Authentication Parameters */
12093 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12094 ut_params->auth_xform.auth.op = auth_op;
12095 ut_params->auth_xform.next = NULL;
12096 ut_params->auth_xform.auth.algo = reference->auth_algo;
12097 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12098 ut_params->auth_xform.auth.key.data = auth_key;
12099 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12101 /* Create Crypto session*/
12102 ut_params->sess = rte_cryptodev_sym_session_create(
12103 ts_params->session_mpool);
12105 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12106 &ut_params->auth_xform,
12107 ts_params->session_priv_mpool);
12109 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12115 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12117 const struct test_crypto_vector *reference,
12118 enum rte_crypto_auth_operation auth_op,
12119 enum rte_crypto_cipher_operation cipher_op)
12121 struct crypto_testsuite_params *ts_params = &testsuite_params;
12122 uint8_t cipher_key[reference->cipher_key.len + 1];
12123 uint8_t auth_key[reference->auth_key.len + 1];
12125 memcpy(cipher_key, reference->cipher_key.data,
12126 reference->cipher_key.len);
12127 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12129 /* Setup Authentication Parameters */
12130 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12131 ut_params->auth_xform.auth.op = auth_op;
12132 ut_params->auth_xform.auth.algo = reference->auth_algo;
12133 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12134 ut_params->auth_xform.auth.key.data = auth_key;
12135 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12137 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12138 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12139 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12141 ut_params->auth_xform.next = &ut_params->cipher_xform;
12143 /* Setup Cipher Parameters */
12144 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12145 ut_params->cipher_xform.next = NULL;
12146 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12147 ut_params->cipher_xform.cipher.op = cipher_op;
12148 ut_params->cipher_xform.cipher.key.data = cipher_key;
12149 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12150 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12151 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12154 /* Create Crypto session*/
12155 ut_params->sess = rte_cryptodev_sym_session_create(
12156 ts_params->session_mpool);
12158 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12159 &ut_params->auth_xform,
12160 ts_params->session_priv_mpool);
12162 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12168 create_auth_operation(struct crypto_testsuite_params *ts_params,
12169 struct crypto_unittest_params *ut_params,
12170 const struct test_crypto_vector *reference,
12171 unsigned int auth_generate)
12173 /* Generate Crypto op data structure */
12174 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12175 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12176 TEST_ASSERT_NOT_NULL(ut_params->op,
12177 "Failed to allocate pktmbuf offload");
12179 /* Set crypto operation data parameters */
12180 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12182 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12184 /* set crypto operation source mbuf */
12185 sym_op->m_src = ut_params->ibuf;
12188 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12189 ut_params->ibuf, reference->digest.len);
12191 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12192 "no room to append auth tag");
12194 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12195 ut_params->ibuf, reference->plaintext.len);
12198 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12200 memcpy(sym_op->auth.digest.data,
12201 reference->digest.data,
12202 reference->digest.len);
12204 debug_hexdump(stdout, "digest:",
12205 sym_op->auth.digest.data,
12206 reference->digest.len);
12208 sym_op->auth.data.length = reference->plaintext.len;
12209 sym_op->auth.data.offset = 0;
12215 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12216 struct crypto_unittest_params *ut_params,
12217 const struct test_crypto_vector *reference,
12218 unsigned int auth_generate)
12220 /* Generate Crypto op data structure */
12221 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12222 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12223 TEST_ASSERT_NOT_NULL(ut_params->op,
12224 "Failed to allocate pktmbuf offload");
12226 /* Set crypto operation data parameters */
12227 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12229 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12231 /* set crypto operation source mbuf */
12232 sym_op->m_src = ut_params->ibuf;
12235 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12236 ut_params->ibuf, reference->digest.len);
12238 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12239 "no room to append auth tag");
12241 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12242 ut_params->ibuf, reference->ciphertext.len);
12245 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12247 memcpy(sym_op->auth.digest.data,
12248 reference->digest.data,
12249 reference->digest.len);
12251 debug_hexdump(stdout, "digest:",
12252 sym_op->auth.digest.data,
12253 reference->digest.len);
12255 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12256 reference->iv.data, reference->iv.len);
12258 sym_op->cipher.data.length = 0;
12259 sym_op->cipher.data.offset = 0;
12261 sym_op->auth.data.length = reference->plaintext.len;
12262 sym_op->auth.data.offset = 0;
12268 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12269 struct crypto_unittest_params *ut_params,
12270 const struct test_crypto_vector *reference,
12271 unsigned int auth_generate)
12273 /* Generate Crypto op data structure */
12274 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12275 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12276 TEST_ASSERT_NOT_NULL(ut_params->op,
12277 "Failed to allocate pktmbuf offload");
12279 /* Set crypto operation data parameters */
12280 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12282 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12284 /* set crypto operation source mbuf */
12285 sym_op->m_src = ut_params->ibuf;
12288 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12289 ut_params->ibuf, reference->digest.len);
12291 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12292 "no room to append auth tag");
12294 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12295 ut_params->ibuf, reference->ciphertext.len);
12298 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12300 memcpy(sym_op->auth.digest.data,
12301 reference->digest.data,
12302 reference->digest.len);
12304 debug_hexdump(stdout, "digest:",
12305 sym_op->auth.digest.data,
12306 reference->digest.len);
12308 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12309 reference->iv.data, reference->iv.len);
12311 sym_op->cipher.data.length = reference->cipher_len;
12312 sym_op->cipher.data.offset = reference->cipher_offset;
12314 sym_op->auth.data.length = reference->plaintext.len;
12315 sym_op->auth.data.offset = reference->auth_offset;
12321 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12322 struct crypto_unittest_params *ut_params,
12323 const struct test_crypto_vector *reference)
12325 return create_auth_operation(ts_params, ut_params, reference, 0);
12329 create_auth_verify_GMAC_operation(
12330 struct crypto_testsuite_params *ts_params,
12331 struct crypto_unittest_params *ut_params,
12332 const struct test_crypto_vector *reference)
12334 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12338 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12339 struct crypto_unittest_params *ut_params,
12340 const struct test_crypto_vector *reference)
12342 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12346 test_authentication_verify_fail_when_data_corruption(
12347 struct crypto_testsuite_params *ts_params,
12348 struct crypto_unittest_params *ut_params,
12349 const struct test_crypto_vector *reference,
12350 unsigned int data_corrupted)
12354 uint8_t *plaintext;
12355 struct rte_cryptodev_info dev_info;
12357 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12358 uint64_t feat_flags = dev_info.feature_flags;
12360 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12361 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12362 printf("Device doesn't support RAW data-path APIs.\n");
12363 return TEST_SKIPPED;
12366 /* Verify the capabilities */
12367 struct rte_cryptodev_sym_capability_idx cap_idx;
12368 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12369 cap_idx.algo.auth = reference->auth_algo;
12370 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12372 return TEST_SKIPPED;
12375 /* Create session */
12376 retval = create_auth_session(ut_params,
12377 ts_params->valid_devs[0],
12379 RTE_CRYPTO_AUTH_OP_VERIFY);
12383 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12384 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12385 "Failed to allocate input buffer in mempool");
12387 /* clear mbuf payload */
12388 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12389 rte_pktmbuf_tailroom(ut_params->ibuf));
12391 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12392 reference->plaintext.len);
12393 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12394 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12396 debug_hexdump(stdout, "plaintext:", plaintext,
12397 reference->plaintext.len);
12399 /* Create operation */
12400 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12405 if (data_corrupted)
12406 data_corruption(plaintext);
12408 tag_corruption(plaintext, reference->plaintext.len);
12410 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12411 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12413 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12414 RTE_CRYPTO_OP_STATUS_SUCCESS,
12415 "authentication not failed");
12416 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12417 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12418 ut_params->op, 0, 1, 0, 0);
12420 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12422 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12429 test_authentication_verify_GMAC_fail_when_corruption(
12430 struct crypto_testsuite_params *ts_params,
12431 struct crypto_unittest_params *ut_params,
12432 const struct test_crypto_vector *reference,
12433 unsigned int data_corrupted)
12436 uint8_t *plaintext;
12437 struct rte_cryptodev_info dev_info;
12439 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12440 uint64_t feat_flags = dev_info.feature_flags;
12442 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12443 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12444 printf("Device doesn't support RAW data-path APIs.\n");
12445 return TEST_SKIPPED;
12448 /* Verify the capabilities */
12449 struct rte_cryptodev_sym_capability_idx cap_idx;
12450 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12451 cap_idx.algo.auth = reference->auth_algo;
12452 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12454 return TEST_SKIPPED;
12456 /* Create session */
12457 retval = create_auth_cipher_session(ut_params,
12458 ts_params->valid_devs[0],
12460 RTE_CRYPTO_AUTH_OP_VERIFY,
12461 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12465 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12466 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12467 "Failed to allocate input buffer in mempool");
12469 /* clear mbuf payload */
12470 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12471 rte_pktmbuf_tailroom(ut_params->ibuf));
12473 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12474 reference->plaintext.len);
12475 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12476 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12478 debug_hexdump(stdout, "plaintext:", plaintext,
12479 reference->plaintext.len);
12481 /* Create operation */
12482 retval = create_auth_verify_GMAC_operation(ts_params,
12489 if (data_corrupted)
12490 data_corruption(plaintext);
12492 tag_corruption(plaintext, reference->aad.len);
12494 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12495 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12497 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12498 RTE_CRYPTO_OP_STATUS_SUCCESS,
12499 "authentication not failed");
12500 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12501 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12502 ut_params->op, 0, 1, 0, 0);
12504 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12506 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12513 test_authenticated_decryption_fail_when_corruption(
12514 struct crypto_testsuite_params *ts_params,
12515 struct crypto_unittest_params *ut_params,
12516 const struct test_crypto_vector *reference,
12517 unsigned int data_corrupted)
12521 uint8_t *ciphertext;
12522 struct rte_cryptodev_info dev_info;
12524 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12525 uint64_t feat_flags = dev_info.feature_flags;
12527 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12528 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12529 printf("Device doesn't support RAW data-path APIs.\n");
12530 return TEST_SKIPPED;
12533 /* Verify the capabilities */
12534 struct rte_cryptodev_sym_capability_idx cap_idx;
12535 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12536 cap_idx.algo.auth = reference->auth_algo;
12537 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12539 return TEST_SKIPPED;
12540 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12541 cap_idx.algo.cipher = reference->crypto_algo;
12542 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12544 return TEST_SKIPPED;
12546 /* Create session */
12547 retval = create_auth_cipher_session(ut_params,
12548 ts_params->valid_devs[0],
12550 RTE_CRYPTO_AUTH_OP_VERIFY,
12551 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12555 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12556 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12557 "Failed to allocate input buffer in mempool");
12559 /* clear mbuf payload */
12560 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12561 rte_pktmbuf_tailroom(ut_params->ibuf));
12563 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12564 reference->ciphertext.len);
12565 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12566 memcpy(ciphertext, reference->ciphertext.data,
12567 reference->ciphertext.len);
12569 /* Create operation */
12570 retval = create_cipher_auth_verify_operation(ts_params,
12577 if (data_corrupted)
12578 data_corruption(ciphertext);
12580 tag_corruption(ciphertext, reference->ciphertext.len);
12582 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12583 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12585 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12586 RTE_CRYPTO_OP_STATUS_SUCCESS,
12587 "authentication not failed");
12588 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12589 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12590 ut_params->op, 1, 1, 0, 0);
12592 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12594 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12601 test_authenticated_encrypt_with_esn(
12602 struct crypto_testsuite_params *ts_params,
12603 struct crypto_unittest_params *ut_params,
12604 const struct test_crypto_vector *reference)
12608 uint8_t *authciphertext, *plaintext, *auth_tag;
12609 uint16_t plaintext_pad_len;
12610 uint8_t cipher_key[reference->cipher_key.len + 1];
12611 uint8_t auth_key[reference->auth_key.len + 1];
12612 struct rte_cryptodev_info dev_info;
12614 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12615 uint64_t feat_flags = dev_info.feature_flags;
12617 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12618 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12619 printf("Device doesn't support RAW data-path APIs.\n");
12620 return TEST_SKIPPED;
12623 /* Verify the capabilities */
12624 struct rte_cryptodev_sym_capability_idx cap_idx;
12625 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12626 cap_idx.algo.auth = reference->auth_algo;
12627 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12629 return TEST_SKIPPED;
12630 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12631 cap_idx.algo.cipher = reference->crypto_algo;
12632 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12634 return TEST_SKIPPED;
12636 /* Create session */
12637 memcpy(cipher_key, reference->cipher_key.data,
12638 reference->cipher_key.len);
12639 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12641 /* Setup Cipher Parameters */
12642 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12643 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12644 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12645 ut_params->cipher_xform.cipher.key.data = cipher_key;
12646 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12647 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12648 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12650 ut_params->cipher_xform.next = &ut_params->auth_xform;
12652 /* Setup Authentication Parameters */
12653 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12654 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12655 ut_params->auth_xform.auth.algo = reference->auth_algo;
12656 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12657 ut_params->auth_xform.auth.key.data = auth_key;
12658 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12659 ut_params->auth_xform.next = NULL;
12661 /* Create Crypto session*/
12662 ut_params->sess = rte_cryptodev_sym_session_create(
12663 ts_params->session_mpool);
12665 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12667 &ut_params->cipher_xform,
12668 ts_params->session_priv_mpool);
12670 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12672 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12673 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12674 "Failed to allocate input buffer in mempool");
12676 /* clear mbuf payload */
12677 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12678 rte_pktmbuf_tailroom(ut_params->ibuf));
12680 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12681 reference->plaintext.len);
12682 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12683 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12685 /* Create operation */
12686 retval = create_cipher_auth_operation(ts_params,
12693 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12694 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12696 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12697 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12698 ut_params->op, 1, 1, 0, 0);
12700 ut_params->op = process_crypto_request(
12701 ts_params->valid_devs[0], ut_params->op);
12703 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12705 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12706 "crypto op processing failed");
12708 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12710 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12711 ut_params->op->sym->auth.data.offset);
12712 auth_tag = authciphertext + plaintext_pad_len;
12713 debug_hexdump(stdout, "ciphertext:", authciphertext,
12714 reference->ciphertext.len);
12715 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12717 /* Validate obuf */
12718 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12720 reference->ciphertext.data,
12721 reference->ciphertext.len,
12722 "Ciphertext data not as expected");
12724 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12726 reference->digest.data,
12727 reference->digest.len,
12728 "Generated digest not as expected");
12730 return TEST_SUCCESS;
12735 test_authenticated_decrypt_with_esn(
12736 struct crypto_testsuite_params *ts_params,
12737 struct crypto_unittest_params *ut_params,
12738 const struct test_crypto_vector *reference)
12742 uint8_t *ciphertext;
12743 uint8_t cipher_key[reference->cipher_key.len + 1];
12744 uint8_t auth_key[reference->auth_key.len + 1];
12745 struct rte_cryptodev_info dev_info;
12747 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12748 uint64_t feat_flags = dev_info.feature_flags;
12750 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12751 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12752 printf("Device doesn't support RAW data-path APIs.\n");
12753 return TEST_SKIPPED;
12756 /* Verify the capabilities */
12757 struct rte_cryptodev_sym_capability_idx cap_idx;
12758 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12759 cap_idx.algo.auth = reference->auth_algo;
12760 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12762 return TEST_SKIPPED;
12763 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12764 cap_idx.algo.cipher = reference->crypto_algo;
12765 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12767 return TEST_SKIPPED;
12769 /* Create session */
12770 memcpy(cipher_key, reference->cipher_key.data,
12771 reference->cipher_key.len);
12772 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12774 /* Setup Authentication Parameters */
12775 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12776 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12777 ut_params->auth_xform.auth.algo = reference->auth_algo;
12778 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12779 ut_params->auth_xform.auth.key.data = auth_key;
12780 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12781 ut_params->auth_xform.next = &ut_params->cipher_xform;
12783 /* Setup Cipher Parameters */
12784 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12785 ut_params->cipher_xform.next = NULL;
12786 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12787 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12788 ut_params->cipher_xform.cipher.key.data = cipher_key;
12789 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12790 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12791 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12793 /* Create Crypto session*/
12794 ut_params->sess = rte_cryptodev_sym_session_create(
12795 ts_params->session_mpool);
12797 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12799 &ut_params->auth_xform,
12800 ts_params->session_priv_mpool);
12802 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12804 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12805 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12806 "Failed to allocate input buffer in mempool");
12808 /* clear mbuf payload */
12809 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12810 rte_pktmbuf_tailroom(ut_params->ibuf));
12812 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12813 reference->ciphertext.len);
12814 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12815 memcpy(ciphertext, reference->ciphertext.data,
12816 reference->ciphertext.len);
12818 /* Create operation */
12819 retval = create_cipher_auth_verify_operation(ts_params,
12826 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12827 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12829 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12830 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12831 ut_params->op, 1, 1, 0, 0);
12833 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12836 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12837 TEST_ASSERT_EQUAL(ut_params->op->status,
12838 RTE_CRYPTO_OP_STATUS_SUCCESS,
12839 "crypto op processing passed");
12841 ut_params->obuf = ut_params->op->sym->m_src;
12842 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12848 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12849 const struct aead_test_data *tdata,
12850 void *digest_mem, uint64_t digest_phys)
12852 struct crypto_testsuite_params *ts_params = &testsuite_params;
12853 struct crypto_unittest_params *ut_params = &unittest_params;
12855 const unsigned int auth_tag_len = tdata->auth_tag.len;
12856 const unsigned int iv_len = tdata->iv.len;
12857 unsigned int aad_len = tdata->aad.len;
12858 unsigned int aad_len_pad = 0;
12860 /* Generate Crypto op data structure */
12861 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12862 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12863 TEST_ASSERT_NOT_NULL(ut_params->op,
12864 "Failed to allocate symmetric crypto operation struct");
12866 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12868 sym_op->aead.digest.data = digest_mem;
12870 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12871 "no room to append digest");
12873 sym_op->aead.digest.phys_addr = digest_phys;
12875 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12876 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12878 debug_hexdump(stdout, "digest:",
12879 sym_op->aead.digest.data,
12883 /* Append aad data */
12884 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12885 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12886 uint8_t *, IV_OFFSET);
12888 /* Copy IV 1 byte after the IV pointer, according to the API */
12889 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12891 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12893 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12894 ut_params->ibuf, aad_len);
12895 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12896 "no room to prepend aad");
12897 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12900 memset(sym_op->aead.aad.data, 0, aad_len);
12901 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12902 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12904 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12905 debug_hexdump(stdout, "aad:",
12906 sym_op->aead.aad.data, aad_len);
12908 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12909 uint8_t *, IV_OFFSET);
12911 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12913 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12915 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12916 ut_params->ibuf, aad_len_pad);
12917 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12918 "no room to prepend aad");
12919 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12922 memset(sym_op->aead.aad.data, 0, aad_len);
12923 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12925 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12926 debug_hexdump(stdout, "aad:",
12927 sym_op->aead.aad.data, aad_len);
12930 sym_op->aead.data.length = tdata->plaintext.len;
12931 sym_op->aead.data.offset = aad_len_pad;
12936 #define SGL_MAX_NO 16
12939 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12940 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12942 struct crypto_testsuite_params *ts_params = &testsuite_params;
12943 struct crypto_unittest_params *ut_params = &unittest_params;
12944 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12947 int to_trn_tbl[SGL_MAX_NO];
12949 unsigned int trn_data = 0;
12950 uint8_t *plaintext, *ciphertext, *auth_tag;
12951 struct rte_cryptodev_info dev_info;
12953 /* Verify the capabilities */
12954 struct rte_cryptodev_sym_capability_idx cap_idx;
12955 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12956 cap_idx.algo.aead = tdata->algo;
12957 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12959 return TEST_SKIPPED;
12961 /* OOP not supported with CPU crypto */
12962 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12963 return TEST_SKIPPED;
12965 /* Detailed check for the particular SGL support flag */
12966 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12968 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12969 if (sgl_in && (!(dev_info.feature_flags &
12970 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12971 return TEST_SKIPPED;
12973 uint64_t feat_flags = dev_info.feature_flags;
12975 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12976 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12977 printf("Device doesn't support RAW data-path APIs.\n");
12978 return TEST_SKIPPED;
12981 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12982 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12983 tdata->plaintext.len;
12984 /* Raw data path API does not support OOP */
12985 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12986 return TEST_SKIPPED;
12987 if (sgl_in && !sgl_out) {
12988 if (!(dev_info.feature_flags &
12989 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12990 return TEST_SKIPPED;
12991 } else if (!sgl_in && sgl_out) {
12992 if (!(dev_info.feature_flags &
12993 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12994 return TEST_SKIPPED;
12995 } else if (sgl_in && sgl_out) {
12996 if (!(dev_info.feature_flags &
12997 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
12998 return TEST_SKIPPED;
13002 if (fragsz > tdata->plaintext.len)
13003 fragsz = tdata->plaintext.len;
13005 uint16_t plaintext_len = fragsz;
13006 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13008 if (fragsz_oop > tdata->plaintext.len)
13009 frag_size_oop = tdata->plaintext.len;
13012 void *digest_mem = NULL;
13014 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13016 if (tdata->plaintext.len % fragsz != 0) {
13017 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13020 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13025 * For out-op-place we need to alloc another mbuf
13028 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13029 rte_pktmbuf_append(ut_params->obuf,
13030 frag_size_oop + prepend_len);
13031 buf_oop = ut_params->obuf;
13034 /* Create AEAD session */
13035 retval = create_aead_session(ts_params->valid_devs[0],
13037 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13038 tdata->key.data, tdata->key.len,
13039 tdata->aad.len, tdata->auth_tag.len,
13044 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13046 /* clear mbuf payload */
13047 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13048 rte_pktmbuf_tailroom(ut_params->ibuf));
13050 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13053 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13055 trn_data += plaintext_len;
13057 buf = ut_params->ibuf;
13060 * Loop until no more fragments
13063 while (trn_data < tdata->plaintext.len) {
13065 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13066 (tdata->plaintext.len - trn_data) : fragsz;
13068 to_trn_tbl[ecx++] = to_trn;
13070 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13073 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13074 rte_pktmbuf_tailroom(buf));
13077 if (oop && !fragsz_oop) {
13078 buf_last_oop = buf_oop->next =
13079 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13080 buf_oop = buf_oop->next;
13081 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13082 0, rte_pktmbuf_tailroom(buf_oop));
13083 rte_pktmbuf_append(buf_oop, to_trn);
13086 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13089 memcpy(plaintext, tdata->plaintext.data + trn_data,
13091 trn_data += to_trn;
13092 if (trn_data == tdata->plaintext.len) {
13095 digest_mem = rte_pktmbuf_append(buf_oop,
13096 tdata->auth_tag.len);
13098 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13099 tdata->auth_tag.len);
13103 uint64_t digest_phys = 0;
13105 ut_params->ibuf->nb_segs = segs;
13108 if (fragsz_oop && oop) {
13112 if (frag_size_oop == tdata->plaintext.len) {
13113 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13114 tdata->auth_tag.len);
13116 digest_phys = rte_pktmbuf_iova_offset(
13118 tdata->plaintext.len + prepend_len);
13121 trn_data = frag_size_oop;
13122 while (trn_data < tdata->plaintext.len) {
13125 (tdata->plaintext.len - trn_data <
13127 (tdata->plaintext.len - trn_data) :
13130 to_trn_tbl[ecx++] = to_trn;
13132 buf_last_oop = buf_oop->next =
13133 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13134 buf_oop = buf_oop->next;
13135 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13136 0, rte_pktmbuf_tailroom(buf_oop));
13137 rte_pktmbuf_append(buf_oop, to_trn);
13139 trn_data += to_trn;
13141 if (trn_data == tdata->plaintext.len) {
13142 digest_mem = rte_pktmbuf_append(buf_oop,
13143 tdata->auth_tag.len);
13147 ut_params->obuf->nb_segs = segs;
13151 * Place digest at the end of the last buffer
13154 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13155 if (oop && buf_last_oop)
13156 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13158 if (!digest_mem && !oop) {
13159 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13160 + tdata->auth_tag.len);
13161 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13162 tdata->plaintext.len);
13165 /* Create AEAD operation */
13166 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13167 tdata, digest_mem, digest_phys);
13172 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13174 ut_params->op->sym->m_src = ut_params->ibuf;
13176 ut_params->op->sym->m_dst = ut_params->obuf;
13178 /* Process crypto operation */
13179 if (oop == IN_PLACE &&
13180 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13181 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13182 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13183 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13184 ut_params->op, 0, 0, 0, 0);
13186 TEST_ASSERT_NOT_NULL(
13187 process_crypto_request(ts_params->valid_devs[0],
13188 ut_params->op), "failed to process sym crypto op");
13190 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13191 "crypto op processing failed");
13194 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13195 uint8_t *, prepend_len);
13197 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13198 uint8_t *, prepend_len);
13202 fragsz = fragsz_oop;
13204 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13206 tdata->ciphertext.data,
13208 "Ciphertext data not as expected");
13210 buf = ut_params->op->sym->m_src->next;
13212 buf = ut_params->op->sym->m_dst->next;
13214 unsigned int off = fragsz;
13218 ciphertext = rte_pktmbuf_mtod(buf,
13221 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13223 tdata->ciphertext.data + off,
13225 "Ciphertext data not as expected");
13227 off += to_trn_tbl[ecx++];
13231 auth_tag = digest_mem;
13232 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13234 tdata->auth_tag.data,
13235 tdata->auth_tag.len,
13236 "Generated auth tag not as expected");
13242 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13244 return test_authenticated_encryption_SGL(
13245 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13249 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13251 return test_authenticated_encryption_SGL(
13252 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13256 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13258 return test_authenticated_encryption_SGL(
13259 &gcm_test_case_8, OUT_OF_PLACE, 400,
13260 gcm_test_case_8.plaintext.len);
13264 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13266 /* This test is not for OPENSSL PMD */
13267 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13268 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13269 return TEST_SKIPPED;
13271 return test_authenticated_encryption_SGL(
13272 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13276 test_authentication_verify_fail_when_data_corrupted(
13277 struct crypto_testsuite_params *ts_params,
13278 struct crypto_unittest_params *ut_params,
13279 const struct test_crypto_vector *reference)
13281 return test_authentication_verify_fail_when_data_corruption(
13282 ts_params, ut_params, reference, 1);
13286 test_authentication_verify_fail_when_tag_corrupted(
13287 struct crypto_testsuite_params *ts_params,
13288 struct crypto_unittest_params *ut_params,
13289 const struct test_crypto_vector *reference)
13291 return test_authentication_verify_fail_when_data_corruption(
13292 ts_params, ut_params, reference, 0);
13296 test_authentication_verify_GMAC_fail_when_data_corrupted(
13297 struct crypto_testsuite_params *ts_params,
13298 struct crypto_unittest_params *ut_params,
13299 const struct test_crypto_vector *reference)
13301 return test_authentication_verify_GMAC_fail_when_corruption(
13302 ts_params, ut_params, reference, 1);
13306 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13307 struct crypto_testsuite_params *ts_params,
13308 struct crypto_unittest_params *ut_params,
13309 const struct test_crypto_vector *reference)
13311 return test_authentication_verify_GMAC_fail_when_corruption(
13312 ts_params, ut_params, reference, 0);
13316 test_authenticated_decryption_fail_when_data_corrupted(
13317 struct crypto_testsuite_params *ts_params,
13318 struct crypto_unittest_params *ut_params,
13319 const struct test_crypto_vector *reference)
13321 return test_authenticated_decryption_fail_when_corruption(
13322 ts_params, ut_params, reference, 1);
13326 test_authenticated_decryption_fail_when_tag_corrupted(
13327 struct crypto_testsuite_params *ts_params,
13328 struct crypto_unittest_params *ut_params,
13329 const struct test_crypto_vector *reference)
13331 return test_authenticated_decryption_fail_when_corruption(
13332 ts_params, ut_params, reference, 0);
13336 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13338 return test_authentication_verify_fail_when_data_corrupted(
13339 &testsuite_params, &unittest_params,
13340 &hmac_sha1_test_crypto_vector);
13344 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13346 return test_authentication_verify_fail_when_tag_corrupted(
13347 &testsuite_params, &unittest_params,
13348 &hmac_sha1_test_crypto_vector);
13352 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13354 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13355 &testsuite_params, &unittest_params,
13356 &aes128_gmac_test_vector);
13360 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13362 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13363 &testsuite_params, &unittest_params,
13364 &aes128_gmac_test_vector);
13368 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13370 return test_authenticated_decryption_fail_when_data_corrupted(
13373 &aes128cbc_hmac_sha1_test_vector);
13377 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13379 return test_authenticated_decryption_fail_when_tag_corrupted(
13382 &aes128cbc_hmac_sha1_test_vector);
13386 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13388 return test_authenticated_encrypt_with_esn(
13391 &aes128cbc_hmac_sha1_aad_test_vector);
13395 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13397 return test_authenticated_decrypt_with_esn(
13400 &aes128cbc_hmac_sha1_aad_test_vector);
13404 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13406 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13410 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13412 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13415 #ifdef RTE_CRYPTO_SCHEDULER
13417 /* global AESNI worker IDs for the scheduler test */
13418 uint8_t aesni_ids[2];
13421 scheduler_testsuite_setup(void)
13424 int32_t nb_devs, ret;
13425 char vdev_args[VDEV_ARGS_SIZE] = {""};
13426 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13427 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13428 uint16_t worker_core_count = 0;
13429 uint16_t socket_id = 0;
13431 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13432 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13434 /* Identify the Worker Cores
13435 * Use 2 worker cores for the device args
13437 RTE_LCORE_FOREACH_WORKER(i) {
13438 if (worker_core_count > 1)
13440 snprintf(vdev_args, sizeof(vdev_args),
13441 "%s%d", temp_str, i);
13442 strcpy(temp_str, vdev_args);
13443 strlcat(temp_str, ";", sizeof(temp_str));
13444 worker_core_count++;
13445 socket_id = rte_lcore_to_socket_id(i);
13447 if (worker_core_count != 2) {
13448 RTE_LOG(ERR, USER1,
13449 "Cryptodev scheduler test require at least "
13450 "two worker cores to run. "
13451 "Please use the correct coremask.\n");
13452 return TEST_FAILED;
13454 strcpy(temp_str, vdev_args);
13455 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13456 temp_str, socket_id);
13457 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13458 nb_devs = rte_cryptodev_device_count_by_driver(
13459 rte_cryptodev_driver_id_get(
13460 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13462 ret = rte_vdev_init(
13463 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13465 TEST_ASSERT(ret == 0,
13466 "Failed to create instance %u of pmd : %s",
13467 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13470 return testsuite_setup();
13474 test_scheduler_attach_worker_op(void)
13476 struct crypto_testsuite_params *ts_params = &testsuite_params;
13477 uint8_t sched_id = ts_params->valid_devs[0];
13478 uint32_t nb_devs, i, nb_devs_attached = 0;
13480 char vdev_name[32];
13482 /* create 2 AESNI_MB if necessary */
13483 nb_devs = rte_cryptodev_device_count_by_driver(
13484 rte_cryptodev_driver_id_get(
13485 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13487 for (i = nb_devs; i < 2; i++) {
13488 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13489 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13491 ret = rte_vdev_init(vdev_name, NULL);
13493 TEST_ASSERT(ret == 0,
13494 "Failed to create instance %u of"
13496 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13500 /* attach 2 AESNI_MB cdevs */
13501 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13503 struct rte_cryptodev_info info;
13504 unsigned int session_size;
13506 rte_cryptodev_info_get(i, &info);
13507 if (info.driver_id != rte_cryptodev_driver_id_get(
13508 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13511 session_size = rte_cryptodev_sym_get_private_session_size(i);
13513 * Create the session mempool again, since now there are new devices
13514 * to use the mempool.
13516 if (ts_params->session_mpool) {
13517 rte_mempool_free(ts_params->session_mpool);
13518 ts_params->session_mpool = NULL;
13520 if (ts_params->session_priv_mpool) {
13521 rte_mempool_free(ts_params->session_priv_mpool);
13522 ts_params->session_priv_mpool = NULL;
13525 if (info.sym.max_nb_sessions != 0 &&
13526 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13527 RTE_LOG(ERR, USER1,
13528 "Device does not support "
13529 "at least %u sessions\n",
13531 return TEST_FAILED;
13534 * Create mempool with maximum number of sessions,
13535 * to include the session headers
13537 if (ts_params->session_mpool == NULL) {
13538 ts_params->session_mpool =
13539 rte_cryptodev_sym_session_pool_create(
13541 MAX_NB_SESSIONS, 0, 0, 0,
13543 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13544 "session mempool allocation failed");
13548 * Create mempool with maximum number of sessions,
13549 * to include device specific session private data
13551 if (ts_params->session_priv_mpool == NULL) {
13552 ts_params->session_priv_mpool = rte_mempool_create(
13553 "test_sess_mp_priv",
13556 0, 0, NULL, NULL, NULL,
13557 NULL, SOCKET_ID_ANY,
13560 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13561 "session mempool allocation failed");
13564 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13565 ts_params->qp_conf.mp_session_private =
13566 ts_params->session_priv_mpool;
13568 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13571 TEST_ASSERT(ret == 0,
13572 "Failed to attach device %u of pmd : %s", i,
13573 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13575 aesni_ids[nb_devs_attached] = (uint8_t)i;
13577 nb_devs_attached++;
13584 test_scheduler_detach_worker_op(void)
13586 struct crypto_testsuite_params *ts_params = &testsuite_params;
13587 uint8_t sched_id = ts_params->valid_devs[0];
13591 for (i = 0; i < 2; i++) {
13592 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13594 TEST_ASSERT(ret == 0,
13595 "Failed to detach device %u", aesni_ids[i]);
13602 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13604 struct crypto_testsuite_params *ts_params = &testsuite_params;
13605 uint8_t sched_id = ts_params->valid_devs[0];
13607 return rte_cryptodev_scheduler_mode_set(sched_id,
13612 test_scheduler_mode_roundrobin_op(void)
13614 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13615 0, "Failed to set roundrobin mode");
13621 test_scheduler_mode_multicore_op(void)
13623 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13624 0, "Failed to set multicore mode");
13630 test_scheduler_mode_failover_op(void)
13632 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13633 0, "Failed to set failover mode");
13639 test_scheduler_mode_pkt_size_distr_op(void)
13641 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13642 0, "Failed to set pktsize mode");
13648 scheduler_multicore_testsuite_setup(void)
13650 if (test_scheduler_attach_worker_op() < 0)
13651 return TEST_SKIPPED;
13652 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
13653 return TEST_SKIPPED;
13658 scheduler_roundrobin_testsuite_setup(void)
13660 if (test_scheduler_attach_worker_op() < 0)
13661 return TEST_SKIPPED;
13662 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
13663 return TEST_SKIPPED;
13668 scheduler_failover_testsuite_setup(void)
13670 if (test_scheduler_attach_worker_op() < 0)
13671 return TEST_SKIPPED;
13672 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
13673 return TEST_SKIPPED;
13678 scheduler_pkt_size_distr_testsuite_setup(void)
13680 if (test_scheduler_attach_worker_op() < 0)
13681 return TEST_SKIPPED;
13682 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
13683 return TEST_SKIPPED;
13688 scheduler_mode_testsuite_teardown(void)
13690 test_scheduler_detach_worker_op();
13693 #endif /* RTE_CRYPTO_SCHEDULER */
13695 static struct unit_test_suite end_testsuite = {
13696 .suite_name = NULL,
13699 .unit_test_suites = NULL
13702 #ifdef RTE_LIB_SECURITY
13703 static struct unit_test_suite pdcp_proto_testsuite = {
13704 .suite_name = "PDCP Proto Unit Test Suite",
13705 .setup = pdcp_proto_testsuite_setup,
13706 .unit_test_cases = {
13707 TEST_CASE_ST(ut_setup_security, ut_teardown,
13708 test_PDCP_PROTO_all),
13709 TEST_CASES_END() /**< NULL terminate unit test array */
13713 static struct unit_test_suite docsis_proto_testsuite = {
13714 .suite_name = "Docsis Proto Unit Test Suite",
13715 .setup = docsis_proto_testsuite_setup,
13716 .unit_test_cases = {
13717 TEST_CASE_ST(ut_setup_security, ut_teardown,
13718 test_DOCSIS_PROTO_all),
13719 TEST_CASES_END() /**< NULL terminate unit test array */
13724 static struct unit_test_suite cryptodev_gen_testsuite = {
13725 .suite_name = "Crypto General Unit Test Suite",
13726 .setup = crypto_gen_testsuite_setup,
13727 .unit_test_cases = {
13728 TEST_CASE_ST(ut_setup, ut_teardown,
13729 test_device_configure_invalid_dev_id),
13730 TEST_CASE_ST(ut_setup, ut_teardown,
13731 test_queue_pair_descriptor_setup),
13732 TEST_CASE_ST(ut_setup, ut_teardown,
13733 test_device_configure_invalid_queue_pair_ids),
13734 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13735 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13736 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13737 TEST_CASES_END() /**< NULL terminate unit test array */
13741 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
13742 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
13743 .setup = negative_hmac_sha1_testsuite_setup,
13744 .unit_test_cases = {
13745 /** Negative tests */
13746 TEST_CASE_ST(ut_setup, ut_teardown,
13747 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13748 TEST_CASE_ST(ut_setup, ut_teardown,
13749 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13750 TEST_CASE_ST(ut_setup, ut_teardown,
13751 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13752 TEST_CASE_ST(ut_setup, ut_teardown,
13753 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13755 TEST_CASES_END() /**< NULL terminate unit test array */
13759 static struct unit_test_suite cryptodev_multi_session_testsuite = {
13760 .suite_name = "Multi Session Unit Test Suite",
13761 .setup = multi_session_testsuite_setup,
13762 .unit_test_cases = {
13763 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13764 TEST_CASE_ST(ut_setup, ut_teardown,
13765 test_multi_session_random_usage),
13767 TEST_CASES_END() /**< NULL terminate unit test array */
13771 static struct unit_test_suite cryptodev_null_testsuite = {
13772 .suite_name = "NULL Test Suite",
13773 .setup = null_testsuite_setup,
13774 .unit_test_cases = {
13775 TEST_CASE_ST(ut_setup, ut_teardown,
13776 test_null_invalid_operation),
13777 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13782 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
13783 .suite_name = "AES CCM Authenticated Test Suite",
13784 .setup = aes_ccm_auth_testsuite_setup,
13785 .unit_test_cases = {
13786 /** AES CCM Authenticated Encryption 128 bits key*/
13787 TEST_CASE_ST(ut_setup, ut_teardown,
13788 test_AES_CCM_authenticated_encryption_test_case_128_1),
13789 TEST_CASE_ST(ut_setup, ut_teardown,
13790 test_AES_CCM_authenticated_encryption_test_case_128_2),
13791 TEST_CASE_ST(ut_setup, ut_teardown,
13792 test_AES_CCM_authenticated_encryption_test_case_128_3),
13794 /** AES CCM Authenticated Decryption 128 bits key*/
13795 TEST_CASE_ST(ut_setup, ut_teardown,
13796 test_AES_CCM_authenticated_decryption_test_case_128_1),
13797 TEST_CASE_ST(ut_setup, ut_teardown,
13798 test_AES_CCM_authenticated_decryption_test_case_128_2),
13799 TEST_CASE_ST(ut_setup, ut_teardown,
13800 test_AES_CCM_authenticated_decryption_test_case_128_3),
13802 /** AES CCM Authenticated Encryption 192 bits key */
13803 TEST_CASE_ST(ut_setup, ut_teardown,
13804 test_AES_CCM_authenticated_encryption_test_case_192_1),
13805 TEST_CASE_ST(ut_setup, ut_teardown,
13806 test_AES_CCM_authenticated_encryption_test_case_192_2),
13807 TEST_CASE_ST(ut_setup, ut_teardown,
13808 test_AES_CCM_authenticated_encryption_test_case_192_3),
13810 /** AES CCM Authenticated Decryption 192 bits key*/
13811 TEST_CASE_ST(ut_setup, ut_teardown,
13812 test_AES_CCM_authenticated_decryption_test_case_192_1),
13813 TEST_CASE_ST(ut_setup, ut_teardown,
13814 test_AES_CCM_authenticated_decryption_test_case_192_2),
13815 TEST_CASE_ST(ut_setup, ut_teardown,
13816 test_AES_CCM_authenticated_decryption_test_case_192_3),
13818 /** AES CCM Authenticated Encryption 256 bits key */
13819 TEST_CASE_ST(ut_setup, ut_teardown,
13820 test_AES_CCM_authenticated_encryption_test_case_256_1),
13821 TEST_CASE_ST(ut_setup, ut_teardown,
13822 test_AES_CCM_authenticated_encryption_test_case_256_2),
13823 TEST_CASE_ST(ut_setup, ut_teardown,
13824 test_AES_CCM_authenticated_encryption_test_case_256_3),
13826 /** AES CCM Authenticated Decryption 256 bits key*/
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 test_AES_CCM_authenticated_decryption_test_case_256_1),
13829 TEST_CASE_ST(ut_setup, ut_teardown,
13830 test_AES_CCM_authenticated_decryption_test_case_256_2),
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 test_AES_CCM_authenticated_decryption_test_case_256_3),
13837 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
13838 .suite_name = "AES GCM Authenticated Test Suite",
13839 .setup = aes_gcm_auth_testsuite_setup,
13840 .unit_test_cases = {
13841 /** AES GCM Authenticated Encryption */
13842 TEST_CASE_ST(ut_setup, ut_teardown,
13843 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13844 TEST_CASE_ST(ut_setup, ut_teardown,
13845 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13846 TEST_CASE_ST(ut_setup, ut_teardown,
13847 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13848 TEST_CASE_ST(ut_setup, ut_teardown,
13849 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13850 TEST_CASE_ST(ut_setup, ut_teardown,
13851 test_AES_GCM_authenticated_encryption_test_case_1),
13852 TEST_CASE_ST(ut_setup, ut_teardown,
13853 test_AES_GCM_authenticated_encryption_test_case_2),
13854 TEST_CASE_ST(ut_setup, ut_teardown,
13855 test_AES_GCM_authenticated_encryption_test_case_3),
13856 TEST_CASE_ST(ut_setup, ut_teardown,
13857 test_AES_GCM_authenticated_encryption_test_case_4),
13858 TEST_CASE_ST(ut_setup, ut_teardown,
13859 test_AES_GCM_authenticated_encryption_test_case_5),
13860 TEST_CASE_ST(ut_setup, ut_teardown,
13861 test_AES_GCM_authenticated_encryption_test_case_6),
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_AES_GCM_authenticated_encryption_test_case_7),
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_AES_GCM_authenticated_encryption_test_case_8),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13869 /** AES GCM Authenticated Decryption */
13870 TEST_CASE_ST(ut_setup, ut_teardown,
13871 test_AES_GCM_authenticated_decryption_test_case_1),
13872 TEST_CASE_ST(ut_setup, ut_teardown,
13873 test_AES_GCM_authenticated_decryption_test_case_2),
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_AES_GCM_authenticated_decryption_test_case_3),
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_AES_GCM_authenticated_decryption_test_case_4),
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_AES_GCM_authenticated_decryption_test_case_5),
13880 TEST_CASE_ST(ut_setup, ut_teardown,
13881 test_AES_GCM_authenticated_decryption_test_case_6),
13882 TEST_CASE_ST(ut_setup, ut_teardown,
13883 test_AES_GCM_authenticated_decryption_test_case_7),
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_AES_GCM_authenticated_decryption_test_case_8),
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13889 /** AES GCM Authenticated Encryption 192 bits key */
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_AES_GCM_auth_encryption_test_case_192_1),
13892 TEST_CASE_ST(ut_setup, ut_teardown,
13893 test_AES_GCM_auth_encryption_test_case_192_2),
13894 TEST_CASE_ST(ut_setup, ut_teardown,
13895 test_AES_GCM_auth_encryption_test_case_192_3),
13896 TEST_CASE_ST(ut_setup, ut_teardown,
13897 test_AES_GCM_auth_encryption_test_case_192_4),
13898 TEST_CASE_ST(ut_setup, ut_teardown,
13899 test_AES_GCM_auth_encryption_test_case_192_5),
13900 TEST_CASE_ST(ut_setup, ut_teardown,
13901 test_AES_GCM_auth_encryption_test_case_192_6),
13902 TEST_CASE_ST(ut_setup, ut_teardown,
13903 test_AES_GCM_auth_encryption_test_case_192_7),
13905 /** AES GCM Authenticated Decryption 192 bits key */
13906 TEST_CASE_ST(ut_setup, ut_teardown,
13907 test_AES_GCM_auth_decryption_test_case_192_1),
13908 TEST_CASE_ST(ut_setup, ut_teardown,
13909 test_AES_GCM_auth_decryption_test_case_192_2),
13910 TEST_CASE_ST(ut_setup, ut_teardown,
13911 test_AES_GCM_auth_decryption_test_case_192_3),
13912 TEST_CASE_ST(ut_setup, ut_teardown,
13913 test_AES_GCM_auth_decryption_test_case_192_4),
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_AES_GCM_auth_decryption_test_case_192_5),
13916 TEST_CASE_ST(ut_setup, ut_teardown,
13917 test_AES_GCM_auth_decryption_test_case_192_6),
13918 TEST_CASE_ST(ut_setup, ut_teardown,
13919 test_AES_GCM_auth_decryption_test_case_192_7),
13921 /** AES GCM Authenticated Encryption 256 bits key */
13922 TEST_CASE_ST(ut_setup, ut_teardown,
13923 test_AES_GCM_auth_encryption_test_case_256_1),
13924 TEST_CASE_ST(ut_setup, ut_teardown,
13925 test_AES_GCM_auth_encryption_test_case_256_2),
13926 TEST_CASE_ST(ut_setup, ut_teardown,
13927 test_AES_GCM_auth_encryption_test_case_256_3),
13928 TEST_CASE_ST(ut_setup, ut_teardown,
13929 test_AES_GCM_auth_encryption_test_case_256_4),
13930 TEST_CASE_ST(ut_setup, ut_teardown,
13931 test_AES_GCM_auth_encryption_test_case_256_5),
13932 TEST_CASE_ST(ut_setup, ut_teardown,
13933 test_AES_GCM_auth_encryption_test_case_256_6),
13934 TEST_CASE_ST(ut_setup, ut_teardown,
13935 test_AES_GCM_auth_encryption_test_case_256_7),
13937 /** AES GCM Authenticated Decryption 256 bits key */
13938 TEST_CASE_ST(ut_setup, ut_teardown,
13939 test_AES_GCM_auth_decryption_test_case_256_1),
13940 TEST_CASE_ST(ut_setup, ut_teardown,
13941 test_AES_GCM_auth_decryption_test_case_256_2),
13942 TEST_CASE_ST(ut_setup, ut_teardown,
13943 test_AES_GCM_auth_decryption_test_case_256_3),
13944 TEST_CASE_ST(ut_setup, ut_teardown,
13945 test_AES_GCM_auth_decryption_test_case_256_4),
13946 TEST_CASE_ST(ut_setup, ut_teardown,
13947 test_AES_GCM_auth_decryption_test_case_256_5),
13948 TEST_CASE_ST(ut_setup, ut_teardown,
13949 test_AES_GCM_auth_decryption_test_case_256_6),
13950 TEST_CASE_ST(ut_setup, ut_teardown,
13951 test_AES_GCM_auth_decryption_test_case_256_7),
13953 /** AES GCM Authenticated Encryption big aad size */
13954 TEST_CASE_ST(ut_setup, ut_teardown,
13955 test_AES_GCM_auth_encryption_test_case_aad_1),
13956 TEST_CASE_ST(ut_setup, ut_teardown,
13957 test_AES_GCM_auth_encryption_test_case_aad_2),
13959 /** AES GCM Authenticated Decryption big aad size */
13960 TEST_CASE_ST(ut_setup, ut_teardown,
13961 test_AES_GCM_auth_decryption_test_case_aad_1),
13962 TEST_CASE_ST(ut_setup, ut_teardown,
13963 test_AES_GCM_auth_decryption_test_case_aad_2),
13965 /** Out of place tests */
13966 TEST_CASE_ST(ut_setup, ut_teardown,
13967 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13968 TEST_CASE_ST(ut_setup, ut_teardown,
13969 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13971 /** Session-less tests */
13972 TEST_CASE_ST(ut_setup, ut_teardown,
13973 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13974 TEST_CASE_ST(ut_setup, ut_teardown,
13975 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13981 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
13982 .suite_name = "AES GMAC Authentication Test Suite",
13983 .setup = aes_gmac_auth_testsuite_setup,
13984 .unit_test_cases = {
13985 TEST_CASE_ST(ut_setup, ut_teardown,
13986 test_AES_GMAC_authentication_test_case_1),
13987 TEST_CASE_ST(ut_setup, ut_teardown,
13988 test_AES_GMAC_authentication_verify_test_case_1),
13989 TEST_CASE_ST(ut_setup, ut_teardown,
13990 test_AES_GMAC_authentication_test_case_2),
13991 TEST_CASE_ST(ut_setup, ut_teardown,
13992 test_AES_GMAC_authentication_verify_test_case_2),
13993 TEST_CASE_ST(ut_setup, ut_teardown,
13994 test_AES_GMAC_authentication_test_case_3),
13995 TEST_CASE_ST(ut_setup, ut_teardown,
13996 test_AES_GMAC_authentication_verify_test_case_3),
13997 TEST_CASE_ST(ut_setup, ut_teardown,
13998 test_AES_GMAC_authentication_test_case_4),
13999 TEST_CASE_ST(ut_setup, ut_teardown,
14000 test_AES_GMAC_authentication_verify_test_case_4),
14001 TEST_CASE_ST(ut_setup, ut_teardown,
14002 test_AES_GMAC_authentication_SGL_40B),
14003 TEST_CASE_ST(ut_setup, ut_teardown,
14004 test_AES_GMAC_authentication_SGL_80B),
14005 TEST_CASE_ST(ut_setup, ut_teardown,
14006 test_AES_GMAC_authentication_SGL_2048B),
14007 TEST_CASE_ST(ut_setup, ut_teardown,
14008 test_AES_GMAC_authentication_SGL_2047B),
14014 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14015 .suite_name = "Chacha20-Poly1305 Test Suite",
14016 .setup = chacha20_poly1305_testsuite_setup,
14017 .unit_test_cases = {
14018 TEST_CASE_ST(ut_setup, ut_teardown,
14019 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14020 TEST_CASE_ST(ut_setup, ut_teardown,
14021 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14026 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14027 .suite_name = "SNOW 3G Test Suite",
14028 .setup = snow3g_testsuite_setup,
14029 .unit_test_cases = {
14030 /** SNOW 3G encrypt only (UEA2) */
14031 TEST_CASE_ST(ut_setup, ut_teardown,
14032 test_snow3g_encryption_test_case_1),
14033 TEST_CASE_ST(ut_setup, ut_teardown,
14034 test_snow3g_encryption_test_case_2),
14035 TEST_CASE_ST(ut_setup, ut_teardown,
14036 test_snow3g_encryption_test_case_3),
14037 TEST_CASE_ST(ut_setup, ut_teardown,
14038 test_snow3g_encryption_test_case_4),
14039 TEST_CASE_ST(ut_setup, ut_teardown,
14040 test_snow3g_encryption_test_case_5),
14042 TEST_CASE_ST(ut_setup, ut_teardown,
14043 test_snow3g_encryption_test_case_1_oop),
14044 TEST_CASE_ST(ut_setup, ut_teardown,
14045 test_snow3g_encryption_test_case_1_oop_sgl),
14046 TEST_CASE_ST(ut_setup, ut_teardown,
14047 test_snow3g_encryption_test_case_1_offset_oop),
14048 TEST_CASE_ST(ut_setup, ut_teardown,
14049 test_snow3g_decryption_test_case_1_oop),
14051 /** SNOW 3G generate auth, then encrypt (UEA2) */
14052 TEST_CASE_ST(ut_setup, ut_teardown,
14053 test_snow3g_auth_cipher_test_case_1),
14054 TEST_CASE_ST(ut_setup, ut_teardown,
14055 test_snow3g_auth_cipher_test_case_2),
14056 TEST_CASE_ST(ut_setup, ut_teardown,
14057 test_snow3g_auth_cipher_test_case_2_oop),
14058 TEST_CASE_ST(ut_setup, ut_teardown,
14059 test_snow3g_auth_cipher_part_digest_enc),
14060 TEST_CASE_ST(ut_setup, ut_teardown,
14061 test_snow3g_auth_cipher_part_digest_enc_oop),
14062 TEST_CASE_ST(ut_setup, ut_teardown,
14063 test_snow3g_auth_cipher_test_case_3_sgl),
14064 TEST_CASE_ST(ut_setup, ut_teardown,
14065 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14066 TEST_CASE_ST(ut_setup, ut_teardown,
14067 test_snow3g_auth_cipher_part_digest_enc_sgl),
14068 TEST_CASE_ST(ut_setup, ut_teardown,
14069 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14071 /** SNOW 3G decrypt (UEA2), then verify auth */
14072 TEST_CASE_ST(ut_setup, ut_teardown,
14073 test_snow3g_auth_cipher_verify_test_case_1),
14074 TEST_CASE_ST(ut_setup, ut_teardown,
14075 test_snow3g_auth_cipher_verify_test_case_2),
14076 TEST_CASE_ST(ut_setup, ut_teardown,
14077 test_snow3g_auth_cipher_verify_test_case_2_oop),
14078 TEST_CASE_ST(ut_setup, ut_teardown,
14079 test_snow3g_auth_cipher_verify_part_digest_enc),
14080 TEST_CASE_ST(ut_setup, ut_teardown,
14081 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14082 TEST_CASE_ST(ut_setup, ut_teardown,
14083 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14084 TEST_CASE_ST(ut_setup, ut_teardown,
14085 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14086 TEST_CASE_ST(ut_setup, ut_teardown,
14087 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14088 TEST_CASE_ST(ut_setup, ut_teardown,
14089 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14091 /** SNOW 3G decrypt only (UEA2) */
14092 TEST_CASE_ST(ut_setup, ut_teardown,
14093 test_snow3g_decryption_test_case_1),
14094 TEST_CASE_ST(ut_setup, ut_teardown,
14095 test_snow3g_decryption_test_case_2),
14096 TEST_CASE_ST(ut_setup, ut_teardown,
14097 test_snow3g_decryption_test_case_3),
14098 TEST_CASE_ST(ut_setup, ut_teardown,
14099 test_snow3g_decryption_test_case_4),
14100 TEST_CASE_ST(ut_setup, ut_teardown,
14101 test_snow3g_decryption_test_case_5),
14102 TEST_CASE_ST(ut_setup, ut_teardown,
14103 test_snow3g_decryption_with_digest_test_case_1),
14104 TEST_CASE_ST(ut_setup, ut_teardown,
14105 test_snow3g_hash_generate_test_case_1),
14106 TEST_CASE_ST(ut_setup, ut_teardown,
14107 test_snow3g_hash_generate_test_case_2),
14108 TEST_CASE_ST(ut_setup, ut_teardown,
14109 test_snow3g_hash_generate_test_case_3),
14111 /* Tests with buffers which length is not byte-aligned */
14112 TEST_CASE_ST(ut_setup, ut_teardown,
14113 test_snow3g_hash_generate_test_case_4),
14114 TEST_CASE_ST(ut_setup, ut_teardown,
14115 test_snow3g_hash_generate_test_case_5),
14116 TEST_CASE_ST(ut_setup, ut_teardown,
14117 test_snow3g_hash_generate_test_case_6),
14118 TEST_CASE_ST(ut_setup, ut_teardown,
14119 test_snow3g_hash_verify_test_case_1),
14120 TEST_CASE_ST(ut_setup, ut_teardown,
14121 test_snow3g_hash_verify_test_case_2),
14122 TEST_CASE_ST(ut_setup, ut_teardown,
14123 test_snow3g_hash_verify_test_case_3),
14125 /* Tests with buffers which length is not byte-aligned */
14126 TEST_CASE_ST(ut_setup, ut_teardown,
14127 test_snow3g_hash_verify_test_case_4),
14128 TEST_CASE_ST(ut_setup, ut_teardown,
14129 test_snow3g_hash_verify_test_case_5),
14130 TEST_CASE_ST(ut_setup, ut_teardown,
14131 test_snow3g_hash_verify_test_case_6),
14132 TEST_CASE_ST(ut_setup, ut_teardown,
14133 test_snow3g_cipher_auth_test_case_1),
14134 TEST_CASE_ST(ut_setup, ut_teardown,
14135 test_snow3g_auth_cipher_with_digest_test_case_1),
14140 static struct unit_test_suite cryptodev_zuc_testsuite = {
14141 .suite_name = "ZUC Test Suite",
14142 .setup = zuc_testsuite_setup,
14143 .unit_test_cases = {
14144 /** ZUC encrypt only (EEA3) */
14145 TEST_CASE_ST(ut_setup, ut_teardown,
14146 test_zuc_encryption_test_case_1),
14147 TEST_CASE_ST(ut_setup, ut_teardown,
14148 test_zuc_encryption_test_case_2),
14149 TEST_CASE_ST(ut_setup, ut_teardown,
14150 test_zuc_encryption_test_case_3),
14151 TEST_CASE_ST(ut_setup, ut_teardown,
14152 test_zuc_encryption_test_case_4),
14153 TEST_CASE_ST(ut_setup, ut_teardown,
14154 test_zuc_encryption_test_case_5),
14155 TEST_CASE_ST(ut_setup, ut_teardown,
14156 test_zuc_encryption_test_case_6_sgl),
14158 /** ZUC authenticate (EIA3) */
14159 TEST_CASE_ST(ut_setup, ut_teardown,
14160 test_zuc_hash_generate_test_case_1),
14161 TEST_CASE_ST(ut_setup, ut_teardown,
14162 test_zuc_hash_generate_test_case_2),
14163 TEST_CASE_ST(ut_setup, ut_teardown,
14164 test_zuc_hash_generate_test_case_3),
14165 TEST_CASE_ST(ut_setup, ut_teardown,
14166 test_zuc_hash_generate_test_case_4),
14167 TEST_CASE_ST(ut_setup, ut_teardown,
14168 test_zuc_hash_generate_test_case_5),
14169 TEST_CASE_ST(ut_setup, ut_teardown,
14170 test_zuc_hash_generate_test_case_6),
14171 TEST_CASE_ST(ut_setup, ut_teardown,
14172 test_zuc_hash_generate_test_case_7),
14173 TEST_CASE_ST(ut_setup, ut_teardown,
14174 test_zuc_hash_generate_test_case_8),
14176 /** ZUC alg-chain (EEA3/EIA3) */
14177 TEST_CASE_ST(ut_setup, ut_teardown,
14178 test_zuc_cipher_auth_test_case_1),
14179 TEST_CASE_ST(ut_setup, ut_teardown,
14180 test_zuc_cipher_auth_test_case_2),
14182 /** ZUC generate auth, then encrypt (EEA3) */
14183 TEST_CASE_ST(ut_setup, ut_teardown,
14184 test_zuc_auth_cipher_test_case_1),
14185 TEST_CASE_ST(ut_setup, ut_teardown,
14186 test_zuc_auth_cipher_test_case_1_oop),
14187 TEST_CASE_ST(ut_setup, ut_teardown,
14188 test_zuc_auth_cipher_test_case_1_sgl),
14189 TEST_CASE_ST(ut_setup, ut_teardown,
14190 test_zuc_auth_cipher_test_case_1_oop_sgl),
14192 /** ZUC decrypt (EEA3), then verify auth */
14193 TEST_CASE_ST(ut_setup, ut_teardown,
14194 test_zuc_auth_cipher_verify_test_case_1),
14195 TEST_CASE_ST(ut_setup, ut_teardown,
14196 test_zuc_auth_cipher_verify_test_case_1_oop),
14197 TEST_CASE_ST(ut_setup, ut_teardown,
14198 test_zuc_auth_cipher_verify_test_case_1_sgl),
14199 TEST_CASE_ST(ut_setup, ut_teardown,
14200 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14205 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14206 .suite_name = "HMAC_MD5 Authentication Test Suite",
14207 .setup = hmac_md5_auth_testsuite_setup,
14208 .unit_test_cases = {
14209 TEST_CASE_ST(ut_setup, ut_teardown,
14210 test_MD5_HMAC_generate_case_1),
14211 TEST_CASE_ST(ut_setup, ut_teardown,
14212 test_MD5_HMAC_verify_case_1),
14213 TEST_CASE_ST(ut_setup, ut_teardown,
14214 test_MD5_HMAC_generate_case_2),
14215 TEST_CASE_ST(ut_setup, ut_teardown,
14216 test_MD5_HMAC_verify_case_2),
14221 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14222 .suite_name = "Kasumi Test Suite",
14223 .setup = kasumi_testsuite_setup,
14224 .unit_test_cases = {
14225 /** KASUMI hash only (UIA1) */
14226 TEST_CASE_ST(ut_setup, ut_teardown,
14227 test_kasumi_hash_generate_test_case_1),
14228 TEST_CASE_ST(ut_setup, ut_teardown,
14229 test_kasumi_hash_generate_test_case_2),
14230 TEST_CASE_ST(ut_setup, ut_teardown,
14231 test_kasumi_hash_generate_test_case_3),
14232 TEST_CASE_ST(ut_setup, ut_teardown,
14233 test_kasumi_hash_generate_test_case_4),
14234 TEST_CASE_ST(ut_setup, ut_teardown,
14235 test_kasumi_hash_generate_test_case_5),
14236 TEST_CASE_ST(ut_setup, ut_teardown,
14237 test_kasumi_hash_generate_test_case_6),
14239 TEST_CASE_ST(ut_setup, ut_teardown,
14240 test_kasumi_hash_verify_test_case_1),
14241 TEST_CASE_ST(ut_setup, ut_teardown,
14242 test_kasumi_hash_verify_test_case_2),
14243 TEST_CASE_ST(ut_setup, ut_teardown,
14244 test_kasumi_hash_verify_test_case_3),
14245 TEST_CASE_ST(ut_setup, ut_teardown,
14246 test_kasumi_hash_verify_test_case_4),
14247 TEST_CASE_ST(ut_setup, ut_teardown,
14248 test_kasumi_hash_verify_test_case_5),
14250 /** KASUMI encrypt only (UEA1) */
14251 TEST_CASE_ST(ut_setup, ut_teardown,
14252 test_kasumi_encryption_test_case_1),
14253 TEST_CASE_ST(ut_setup, ut_teardown,
14254 test_kasumi_encryption_test_case_1_sgl),
14255 TEST_CASE_ST(ut_setup, ut_teardown,
14256 test_kasumi_encryption_test_case_1_oop),
14257 TEST_CASE_ST(ut_setup, ut_teardown,
14258 test_kasumi_encryption_test_case_1_oop_sgl),
14259 TEST_CASE_ST(ut_setup, ut_teardown,
14260 test_kasumi_encryption_test_case_2),
14261 TEST_CASE_ST(ut_setup, ut_teardown,
14262 test_kasumi_encryption_test_case_3),
14263 TEST_CASE_ST(ut_setup, ut_teardown,
14264 test_kasumi_encryption_test_case_4),
14265 TEST_CASE_ST(ut_setup, ut_teardown,
14266 test_kasumi_encryption_test_case_5),
14268 /** KASUMI decrypt only (UEA1) */
14269 TEST_CASE_ST(ut_setup, ut_teardown,
14270 test_kasumi_decryption_test_case_1),
14271 TEST_CASE_ST(ut_setup, ut_teardown,
14272 test_kasumi_decryption_test_case_2),
14273 TEST_CASE_ST(ut_setup, ut_teardown,
14274 test_kasumi_decryption_test_case_3),
14275 TEST_CASE_ST(ut_setup, ut_teardown,
14276 test_kasumi_decryption_test_case_4),
14277 TEST_CASE_ST(ut_setup, ut_teardown,
14278 test_kasumi_decryption_test_case_5),
14279 TEST_CASE_ST(ut_setup, ut_teardown,
14280 test_kasumi_decryption_test_case_1_oop),
14282 TEST_CASE_ST(ut_setup, ut_teardown,
14283 test_kasumi_cipher_auth_test_case_1),
14285 /** KASUMI generate auth, then encrypt (F8) */
14286 TEST_CASE_ST(ut_setup, ut_teardown,
14287 test_kasumi_auth_cipher_test_case_1),
14288 TEST_CASE_ST(ut_setup, ut_teardown,
14289 test_kasumi_auth_cipher_test_case_2),
14290 TEST_CASE_ST(ut_setup, ut_teardown,
14291 test_kasumi_auth_cipher_test_case_2_oop),
14292 TEST_CASE_ST(ut_setup, ut_teardown,
14293 test_kasumi_auth_cipher_test_case_2_sgl),
14294 TEST_CASE_ST(ut_setup, ut_teardown,
14295 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14297 /** KASUMI decrypt (F8), then verify auth */
14298 TEST_CASE_ST(ut_setup, ut_teardown,
14299 test_kasumi_auth_cipher_verify_test_case_1),
14300 TEST_CASE_ST(ut_setup, ut_teardown,
14301 test_kasumi_auth_cipher_verify_test_case_2),
14302 TEST_CASE_ST(ut_setup, ut_teardown,
14303 test_kasumi_auth_cipher_verify_test_case_2_oop),
14304 TEST_CASE_ST(ut_setup, ut_teardown,
14305 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14306 TEST_CASE_ST(ut_setup, ut_teardown,
14307 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14313 static struct unit_test_suite cryptodev_esn_testsuite = {
14314 .suite_name = "ESN Test Suite",
14315 .setup = esn_testsuite_setup,
14316 .unit_test_cases = {
14317 TEST_CASE_ST(ut_setup, ut_teardown,
14318 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14319 TEST_CASE_ST(ut_setup, ut_teardown,
14320 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14325 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14326 .suite_name = "Negative AES GCM Test Suite",
14327 .setup = negative_aes_gcm_testsuite_setup,
14328 .unit_test_cases = {
14329 TEST_CASE_ST(ut_setup, ut_teardown,
14330 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14331 TEST_CASE_ST(ut_setup, ut_teardown,
14332 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14333 TEST_CASE_ST(ut_setup, ut_teardown,
14334 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14335 TEST_CASE_ST(ut_setup, ut_teardown,
14336 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14337 TEST_CASE_ST(ut_setup, ut_teardown,
14338 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14339 TEST_CASE_ST(ut_setup, ut_teardown,
14340 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14341 TEST_CASE_ST(ut_setup, ut_teardown,
14342 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14343 TEST_CASE_ST(ut_setup, ut_teardown,
14344 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14345 TEST_CASE_ST(ut_setup, ut_teardown,
14346 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14347 TEST_CASE_ST(ut_setup, ut_teardown,
14348 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14349 TEST_CASE_ST(ut_setup, ut_teardown,
14350 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14351 TEST_CASE_ST(ut_setup, ut_teardown,
14352 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14358 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14359 .suite_name = "Negative AES GMAC Test Suite",
14360 .setup = negative_aes_gmac_testsuite_setup,
14361 .unit_test_cases = {
14362 TEST_CASE_ST(ut_setup, ut_teardown,
14363 authentication_verify_AES128_GMAC_fail_data_corrupt),
14364 TEST_CASE_ST(ut_setup, ut_teardown,
14365 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14371 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14372 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14373 .setup = mixed_cipher_hash_testsuite_setup,
14374 .unit_test_cases = {
14375 /** AUTH AES CMAC + CIPHER AES CTR */
14376 TEST_CASE_ST(ut_setup, ut_teardown,
14377 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14378 TEST_CASE_ST(ut_setup, ut_teardown,
14379 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14380 TEST_CASE_ST(ut_setup, ut_teardown,
14381 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14382 TEST_CASE_ST(ut_setup, ut_teardown,
14383 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14384 TEST_CASE_ST(ut_setup, ut_teardown,
14385 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14386 TEST_CASE_ST(ut_setup, ut_teardown,
14387 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14388 TEST_CASE_ST(ut_setup, ut_teardown,
14389 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14390 TEST_CASE_ST(ut_setup, ut_teardown,
14391 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14393 /** AUTH ZUC + CIPHER SNOW3G */
14394 TEST_CASE_ST(ut_setup, ut_teardown,
14395 test_auth_zuc_cipher_snow_test_case_1),
14396 TEST_CASE_ST(ut_setup, ut_teardown,
14397 test_verify_auth_zuc_cipher_snow_test_case_1),
14398 /** AUTH AES CMAC + CIPHER SNOW3G */
14399 TEST_CASE_ST(ut_setup, ut_teardown,
14400 test_auth_aes_cmac_cipher_snow_test_case_1),
14401 TEST_CASE_ST(ut_setup, ut_teardown,
14402 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14403 /** AUTH ZUC + CIPHER AES CTR */
14404 TEST_CASE_ST(ut_setup, ut_teardown,
14405 test_auth_zuc_cipher_aes_ctr_test_case_1),
14406 TEST_CASE_ST(ut_setup, ut_teardown,
14407 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14408 /** AUTH SNOW3G + CIPHER AES CTR */
14409 TEST_CASE_ST(ut_setup, ut_teardown,
14410 test_auth_snow_cipher_aes_ctr_test_case_1),
14411 TEST_CASE_ST(ut_setup, ut_teardown,
14412 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14413 /** AUTH SNOW3G + CIPHER ZUC */
14414 TEST_CASE_ST(ut_setup, ut_teardown,
14415 test_auth_snow_cipher_zuc_test_case_1),
14416 TEST_CASE_ST(ut_setup, ut_teardown,
14417 test_verify_auth_snow_cipher_zuc_test_case_1),
14418 /** AUTH AES CMAC + CIPHER ZUC */
14419 TEST_CASE_ST(ut_setup, ut_teardown,
14420 test_auth_aes_cmac_cipher_zuc_test_case_1),
14421 TEST_CASE_ST(ut_setup, ut_teardown,
14422 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14424 /** AUTH NULL + CIPHER SNOW3G */
14425 TEST_CASE_ST(ut_setup, ut_teardown,
14426 test_auth_null_cipher_snow_test_case_1),
14427 TEST_CASE_ST(ut_setup, ut_teardown,
14428 test_verify_auth_null_cipher_snow_test_case_1),
14429 /** AUTH NULL + CIPHER ZUC */
14430 TEST_CASE_ST(ut_setup, ut_teardown,
14431 test_auth_null_cipher_zuc_test_case_1),
14432 TEST_CASE_ST(ut_setup, ut_teardown,
14433 test_verify_auth_null_cipher_zuc_test_case_1),
14434 /** AUTH SNOW3G + CIPHER NULL */
14435 TEST_CASE_ST(ut_setup, ut_teardown,
14436 test_auth_snow_cipher_null_test_case_1),
14437 TEST_CASE_ST(ut_setup, ut_teardown,
14438 test_verify_auth_snow_cipher_null_test_case_1),
14439 /** AUTH ZUC + CIPHER NULL */
14440 TEST_CASE_ST(ut_setup, ut_teardown,
14441 test_auth_zuc_cipher_null_test_case_1),
14442 TEST_CASE_ST(ut_setup, ut_teardown,
14443 test_verify_auth_zuc_cipher_null_test_case_1),
14444 /** AUTH NULL + CIPHER AES CTR */
14445 TEST_CASE_ST(ut_setup, ut_teardown,
14446 test_auth_null_cipher_aes_ctr_test_case_1),
14447 TEST_CASE_ST(ut_setup, ut_teardown,
14448 test_verify_auth_null_cipher_aes_ctr_test_case_1),
14449 /** AUTH AES CMAC + CIPHER NULL */
14450 TEST_CASE_ST(ut_setup, ut_teardown,
14451 test_auth_aes_cmac_cipher_null_test_case_1),
14452 TEST_CASE_ST(ut_setup, ut_teardown,
14453 test_verify_auth_aes_cmac_cipher_null_test_case_1),
14459 run_cryptodev_testsuite(const char *pmd_name)
14461 uint8_t ret, j, i = 0, blk_start_idx = 0;
14462 const enum blockcipher_test_type blk_suites[] = {
14463 BLKCIPHER_AES_CHAIN_TYPE,
14464 BLKCIPHER_AES_CIPHERONLY_TYPE,
14465 BLKCIPHER_AES_DOCSIS_TYPE,
14466 BLKCIPHER_3DES_CHAIN_TYPE,
14467 BLKCIPHER_3DES_CIPHERONLY_TYPE,
14468 BLKCIPHER_DES_CIPHERONLY_TYPE,
14469 BLKCIPHER_DES_DOCSIS_TYPE,
14470 BLKCIPHER_AUTHONLY_TYPE};
14471 struct unit_test_suite *static_suites[] = {
14472 &cryptodev_multi_session_testsuite,
14473 &cryptodev_null_testsuite,
14474 &cryptodev_aes_ccm_auth_testsuite,
14475 &cryptodev_aes_gcm_auth_testsuite,
14476 &cryptodev_aes_gmac_auth_testsuite,
14477 &cryptodev_snow3g_testsuite,
14478 &cryptodev_chacha20_poly1305_testsuite,
14479 &cryptodev_zuc_testsuite,
14480 &cryptodev_hmac_md5_auth_testsuite,
14481 &cryptodev_kasumi_testsuite,
14482 &cryptodev_esn_testsuite,
14483 &cryptodev_negative_aes_gcm_testsuite,
14484 &cryptodev_negative_aes_gmac_testsuite,
14485 &cryptodev_mixed_cipher_hash_testsuite,
14486 &cryptodev_negative_hmac_sha1_testsuite,
14487 &cryptodev_gen_testsuite,
14488 #ifdef RTE_LIB_SECURITY
14489 &pdcp_proto_testsuite,
14490 &docsis_proto_testsuite,
14494 static struct unit_test_suite ts = {
14495 .suite_name = "Cryptodev Unit Test Suite",
14496 .setup = testsuite_setup,
14497 .teardown = testsuite_teardown,
14498 .unit_test_cases = {TEST_CASES_END()}
14501 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
14503 if (gbl_driver_id == -1) {
14504 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
14505 return TEST_SKIPPED;
14508 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14509 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
14511 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
14512 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14513 ret = unit_test_suite_runner(&ts);
14515 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
14516 free(ts.unit_test_suites);
14521 test_cryptodev_qat(void)
14523 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14527 test_cryptodev_virtio(void)
14529 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14533 test_cryptodev_aesni_mb(void)
14535 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14539 test_cryptodev_cpu_aesni_mb(void)
14542 enum rte_security_session_action_type at = gbl_action_type;
14543 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14544 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14545 gbl_action_type = at;
14550 test_cryptodev_openssl(void)
14552 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14556 test_cryptodev_aesni_gcm(void)
14558 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14562 test_cryptodev_cpu_aesni_gcm(void)
14565 enum rte_security_session_action_type at = gbl_action_type;
14566 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14567 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14568 gbl_action_type = at;
14573 test_cryptodev_null(void)
14575 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14579 test_cryptodev_sw_snow3g(void)
14581 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14585 test_cryptodev_sw_kasumi(void)
14587 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14591 test_cryptodev_sw_zuc(void)
14593 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14597 test_cryptodev_armv8(void)
14599 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14603 test_cryptodev_mrvl(void)
14605 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14608 #ifdef RTE_CRYPTO_SCHEDULER
14611 test_cryptodev_scheduler(void)
14613 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
14614 const enum blockcipher_test_type blk_suites[] = {
14615 BLKCIPHER_AES_CHAIN_TYPE,
14616 BLKCIPHER_AES_CIPHERONLY_TYPE,
14617 BLKCIPHER_AUTHONLY_TYPE
14619 static struct unit_test_suite scheduler_multicore = {
14620 .suite_name = "Scheduler Multicore Unit Test Suite",
14621 .setup = scheduler_multicore_testsuite_setup,
14622 .teardown = scheduler_mode_testsuite_teardown,
14623 .unit_test_cases = {TEST_CASES_END()}
14625 static struct unit_test_suite scheduler_round_robin = {
14626 .suite_name = "Scheduler Round Robin Unit Test Suite",
14627 .setup = scheduler_roundrobin_testsuite_setup,
14628 .teardown = scheduler_mode_testsuite_teardown,
14629 .unit_test_cases = {TEST_CASES_END()}
14631 static struct unit_test_suite scheduler_failover = {
14632 .suite_name = "Scheduler Failover Unit Test Suite",
14633 .setup = scheduler_failover_testsuite_setup,
14634 .teardown = scheduler_mode_testsuite_teardown,
14635 .unit_test_cases = {TEST_CASES_END()}
14637 static struct unit_test_suite scheduler_pkt_size_distr = {
14638 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
14639 .setup = scheduler_pkt_size_distr_testsuite_setup,
14640 .teardown = scheduler_mode_testsuite_teardown,
14641 .unit_test_cases = {TEST_CASES_END()}
14643 struct unit_test_suite *sched_mode_suites[] = {
14644 &scheduler_multicore,
14645 &scheduler_round_robin,
14646 &scheduler_failover,
14647 &scheduler_pkt_size_distr
14649 static struct unit_test_suite scheduler_config = {
14650 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
14651 .unit_test_cases = {
14652 TEST_CASE(test_scheduler_attach_worker_op),
14653 TEST_CASE(test_scheduler_mode_multicore_op),
14654 TEST_CASE(test_scheduler_mode_roundrobin_op),
14655 TEST_CASE(test_scheduler_mode_failover_op),
14656 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
14657 TEST_CASE(test_scheduler_detach_worker_op),
14659 TEST_CASES_END() /**< NULL terminate array */
14662 struct unit_test_suite *static_suites[] = {
14666 static struct unit_test_suite ts = {
14667 .suite_name = "Scheduler Unit Test Suite",
14668 .setup = scheduler_testsuite_setup,
14669 .teardown = testsuite_teardown,
14670 .unit_test_cases = {TEST_CASES_END()}
14673 gbl_driver_id = rte_cryptodev_driver_id_get(
14674 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14676 if (gbl_driver_id == -1) {
14677 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14678 return TEST_SKIPPED;
14681 if (rte_cryptodev_driver_id_get(
14682 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14683 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14684 return TEST_SKIPPED;
14687 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14689 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
14690 (struct unit_test_suite *) *
14691 (RTE_DIM(blk_suites) + 1));
14692 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
14693 blk_suites, RTE_DIM(blk_suites));
14694 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
14697 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14698 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
14699 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
14700 RTE_DIM(sched_mode_suites));
14701 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14702 ret = unit_test_suite_runner(&ts);
14704 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14705 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
14706 (*sched_mode_suites[sched_i]),
14707 RTE_DIM(blk_suites));
14708 free(sched_mode_suites[sched_i]->unit_test_suites);
14710 free(ts.unit_test_suites);
14714 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14719 test_cryptodev_dpaa2_sec(void)
14721 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14725 test_cryptodev_dpaa_sec(void)
14727 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14731 test_cryptodev_ccp(void)
14733 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14737 test_cryptodev_octeontx(void)
14739 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14743 test_cryptodev_octeontx2(void)
14745 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14749 test_cryptodev_caam_jr(void)
14751 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14755 test_cryptodev_nitrox(void)
14757 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14761 test_cryptodev_bcmfs(void)
14763 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14767 test_cryptodev_qat_raw_api(void)
14771 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14772 ret = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14773 global_api_test_type = CRYPTODEV_API_TEST;
14779 test_cryptodev_cn9k(void)
14781 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
14785 test_cryptodev_cn10k(void)
14787 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
14790 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14791 test_cryptodev_qat_raw_api);
14792 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14793 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14794 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14795 test_cryptodev_cpu_aesni_mb);
14796 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14797 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14798 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14799 test_cryptodev_cpu_aesni_gcm);
14800 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14801 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14802 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14803 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14804 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14805 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14806 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14807 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14808 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14809 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14810 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14811 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14812 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14813 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14814 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
14815 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
14816 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);