1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
19 #include <rte_cryptodev_pmd.h>
20 #include <rte_string_fns.h>
22 #ifdef RTE_CRYPTO_SCHEDULER
23 #include <rte_cryptodev_scheduler.h>
24 #include <rte_cryptodev_scheduler_operations.h>
27 #include <rte_lcore.h>
30 #include "test_cryptodev.h"
32 #include "test_cryptodev_blockcipher.h"
33 #include "test_cryptodev_aes_test_vectors.h"
34 #include "test_cryptodev_des_test_vectors.h"
35 #include "test_cryptodev_hash_test_vectors.h"
36 #include "test_cryptodev_kasumi_test_vectors.h"
37 #include "test_cryptodev_kasumi_hash_test_vectors.h"
38 #include "test_cryptodev_snow3g_test_vectors.h"
39 #include "test_cryptodev_snow3g_hash_test_vectors.h"
40 #include "test_cryptodev_zuc_test_vectors.h"
41 #include "test_cryptodev_aead_test_vectors.h"
42 #include "test_cryptodev_hmac_test_vectors.h"
43 #include "test_cryptodev_mixed_test_vectors.h"
44 #ifdef RTE_LIB_SECURITY
45 #include "test_cryptodev_security_pdcp_test_vectors.h"
46 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
47 #include "test_cryptodev_security_pdcp_test_func.h"
48 #include "test_cryptodev_security_docsis_test_vectors.h"
50 #define SDAP_DISABLED 0
51 #define SDAP_ENABLED 1
54 #define VDEV_ARGS_SIZE 100
55 #define MAX_NB_SESSIONS 4
57 #define MAX_DRV_SERVICE_CTX_SIZE 256
59 #define MAX_RAW_DEQUEUE_COUNT 65535
62 #define OUT_OF_PLACE 1
65 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_unittest_params {
76 struct rte_crypto_sym_xform cipher_xform;
77 struct rte_crypto_sym_xform auth_xform;
78 struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 struct rte_security_docsis_xform docsis_xform;
84 struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 struct rte_security_session *sec_session;
89 #ifdef RTE_LIB_SECURITY
90 enum rte_security_session_action_type type;
92 struct rte_crypto_op *op;
94 struct rte_mbuf *obuf, *ibuf;
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 (((num) + (align) - 1) & ~((align) - 1))
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
103 for (j = 0; j < num_child_ts; index++, j++) \
104 parent_ts.unit_test_suites[index] = child_ts[j]
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
107 for (j = 0; j < num_blk_types; index++, j++) \
108 parent_ts.unit_test_suites[index] = \
109 build_blockcipher_test_suite(blk_types[j])
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
112 for (j = index; j < index + num_blk_types; j++) \
113 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
131 static struct rte_mbuf *
132 setup_test_string(struct rte_mempool *mpool,
133 const char *string, size_t len, uint8_t blocksize)
135 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
136 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
141 memset(m->buf_addr, 0, m->buf_len);
142 dst = rte_pktmbuf_append(m, t_len);
148 rte_memcpy(dst, string, t_len);
150 memset(dst, 0, t_len);
156 /* Get number of bytes in X bits (rounding up) */
158 ceil_byte_length(uint32_t num_bits)
161 return ((num_bits >> 3) + 1);
163 return (num_bits >> 3);
167 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
168 uint8_t is_op_success)
170 struct rte_crypto_op *op = user_data;
171 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
172 RTE_CRYPTO_OP_STATUS_ERROR;
176 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
177 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
178 uint8_t len_in_bits, uint8_t cipher_iv_len)
180 struct rte_crypto_sym_op *sop = op->sym;
181 struct rte_crypto_op *ret_op = NULL;
182 struct rte_crypto_vec data_vec[UINT8_MAX];
183 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
184 union rte_crypto_sym_ofs ofs;
185 struct rte_crypto_sym_vec vec;
186 struct rte_crypto_sgl sgl;
188 union rte_cryptodev_session_ctx sess;
190 struct rte_crypto_raw_dp_ctx *ctx;
191 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
195 int ctx_service_size;
197 int enqueue_status, dequeue_status;
199 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
200 if (ctx_service_size < 0) {
201 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
205 ctx = malloc(ctx_service_size);
207 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
211 /* Both are enums, setting crypto_sess will suit any session type */
212 sess.crypto_sess = op->sym->session;
214 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
215 op->sess_type, sess, 0) < 0) {
216 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
222 aad_auth_iv.iova = 0;
223 aad_auth_iv.va = NULL;
230 vec.digest = &digest;
231 vec.aad = &aad_auth_iv;
232 vec.status = &status;
236 if (is_cipher && is_auth) {
237 cipher_offset = sop->cipher.data.offset;
238 cipher_len = sop->cipher.data.length;
239 auth_offset = sop->auth.data.offset;
240 auth_len = sop->auth.data.length;
241 max_len = RTE_MAX(cipher_offset + cipher_len,
242 auth_offset + auth_len);
244 max_len = max_len >> 3;
245 cipher_offset = cipher_offset >> 3;
246 auth_offset = auth_offset >> 3;
247 cipher_len = cipher_len >> 3;
248 auth_len = auth_len >> 3;
250 ofs.ofs.cipher.head = cipher_offset;
251 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
252 ofs.ofs.auth.head = auth_offset;
253 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
254 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
255 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
256 aad_auth_iv.va = rte_crypto_op_ctod_offset(
257 op, void *, IV_OFFSET + cipher_iv_len);
258 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
260 digest.va = (void *)sop->auth.digest.data;
261 digest.iova = sop->auth.digest.phys_addr;
263 } else if (is_cipher) {
264 cipher_offset = sop->cipher.data.offset;
265 cipher_len = sop->cipher.data.length;
266 max_len = cipher_len + cipher_offset;
268 max_len = max_len >> 3;
269 cipher_offset = cipher_offset >> 3;
270 cipher_len = cipher_len >> 3;
272 ofs.ofs.cipher.head = cipher_offset;
273 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
274 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
275 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
277 } else if (is_auth) {
278 auth_offset = sop->auth.data.offset;
279 auth_len = sop->auth.data.length;
280 max_len = auth_len + auth_offset;
282 max_len = max_len >> 3;
283 auth_offset = auth_offset >> 3;
284 auth_len = auth_len >> 3;
286 ofs.ofs.auth.head = auth_offset;
287 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
288 aad_auth_iv.va = rte_crypto_op_ctod_offset(
289 op, void *, IV_OFFSET + cipher_iv_len);
290 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
292 digest.va = (void *)sop->auth.digest.data;
293 digest.iova = sop->auth.digest.phys_addr;
296 cipher_offset = sop->aead.data.offset;
297 cipher_len = sop->aead.data.length;
298 max_len = cipher_len + cipher_offset;
300 max_len = max_len >> 3;
301 cipher_offset = cipher_offset >> 3;
302 cipher_len = cipher_len >> 3;
304 ofs.ofs.cipher.head = cipher_offset;
305 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
306 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
307 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
308 aad_auth_iv.va = (void *)sop->aead.aad.data;
309 aad_auth_iv.iova = sop->aead.aad.phys_addr;
310 digest.va = (void *)sop->aead.digest.data;
311 digest.iova = sop->aead.digest.phys_addr;
314 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
315 data_vec, RTE_DIM(data_vec));
316 if (n < 0 || n > sop->m_src->nb_segs) {
317 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
323 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
324 &enqueue_status) < 1) {
325 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
329 if (enqueue_status == 0) {
330 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
332 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
335 } else if (enqueue_status < 0) {
336 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
341 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
342 n = rte_cryptodev_raw_dequeue_burst(ctx,
343 NULL, 1, post_process_raw_dp_op,
344 (void **)&ret_op, 0, &n_success,
346 if (dequeue_status < 0) {
347 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
354 if (n == 1 && dequeue_status == 0) {
355 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
356 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
361 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
362 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
363 RTE_CRYPTO_OP_STATUS_SUCCESS;
370 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
373 struct rte_crypto_sym_op *sop;
374 union rte_crypto_sym_ofs ofs;
375 struct rte_crypto_sgl sgl;
376 struct rte_crypto_sym_vec symvec;
377 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
378 struct rte_crypto_vec vec[UINT8_MAX];
382 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
383 sop->aead.data.length, vec, RTE_DIM(vec));
385 if (n < 0 || n != sop->m_src->nb_segs) {
386 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
394 symvec.digest = &digest_ptr;
395 symvec.aad = &aad_ptr;
399 /* for CPU crypto the IOVA address is not required */
400 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
401 digest_ptr.va = (void *)sop->aead.digest.data;
402 aad_ptr.va = (void *)sop->aead.aad.data;
406 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
410 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
412 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
416 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
419 struct rte_crypto_sym_op *sop;
420 union rte_crypto_sym_ofs ofs;
421 struct rte_crypto_sgl sgl;
422 struct rte_crypto_sym_vec symvec;
423 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
424 struct rte_crypto_vec vec[UINT8_MAX];
428 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
429 sop->auth.data.length, vec, RTE_DIM(vec));
431 if (n < 0 || n != sop->m_src->nb_segs) {
432 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
440 symvec.digest = &digest_ptr;
444 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
445 digest_ptr.va = (void *)sop->auth.digest.data;
448 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
449 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
450 (sop->cipher.data.offset + sop->cipher.data.length);
452 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
456 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
458 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
461 static struct rte_crypto_op *
462 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
465 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
467 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
468 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
474 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
477 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
478 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
485 static struct crypto_testsuite_params testsuite_params = { NULL };
486 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
487 static struct crypto_unittest_params unittest_params;
490 testsuite_setup(void)
492 struct crypto_testsuite_params *ts_params = &testsuite_params;
493 struct rte_cryptodev_info info;
494 uint32_t i = 0, nb_devs, dev_id;
497 memset(ts_params, 0, sizeof(*ts_params));
499 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
500 if (ts_params->mbuf_pool == NULL) {
501 /* Not already created so create */
502 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
504 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
506 if (ts_params->mbuf_pool == NULL) {
507 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
512 ts_params->large_mbuf_pool = rte_mempool_lookup(
513 "CRYPTO_LARGE_MBUFPOOL");
514 if (ts_params->large_mbuf_pool == NULL) {
515 /* Not already created so create */
516 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
517 "CRYPTO_LARGE_MBUFPOOL",
520 if (ts_params->large_mbuf_pool == NULL) {
522 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
527 ts_params->op_mpool = rte_crypto_op_pool_create(
528 "MBUF_CRYPTO_SYM_OP_POOL",
529 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
530 NUM_MBUFS, MBUF_CACHE_SIZE,
532 sizeof(struct rte_crypto_sym_xform) +
535 if (ts_params->op_mpool == NULL) {
536 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
540 nb_devs = rte_cryptodev_count();
542 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
546 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
547 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
548 rte_cryptodev_driver_name_get(gbl_driver_id));
552 /* Create list of valid crypto devs */
553 for (i = 0; i < nb_devs; i++) {
554 rte_cryptodev_info_get(i, &info);
555 if (info.driver_id == gbl_driver_id)
556 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
559 if (ts_params->valid_dev_count < 1)
562 /* Set up all the qps on the first of the valid devices found */
564 dev_id = ts_params->valid_devs[0];
566 rte_cryptodev_info_get(dev_id, &info);
568 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
569 ts_params->conf.socket_id = SOCKET_ID_ANY;
570 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
572 unsigned int session_size =
573 rte_cryptodev_sym_get_private_session_size(dev_id);
575 #ifdef RTE_LIB_SECURITY
576 unsigned int security_session_size = rte_security_session_get_size(
577 rte_cryptodev_get_sec_ctx(dev_id));
579 if (session_size < security_session_size)
580 session_size = security_session_size;
583 * Create mempool with maximum number of sessions.
585 if (info.sym.max_nb_sessions != 0 &&
586 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
587 RTE_LOG(ERR, USER1, "Device does not support "
588 "at least %u sessions\n",
593 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
594 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
596 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
597 "session mempool allocation failed");
599 ts_params->session_priv_mpool = rte_mempool_create(
603 0, 0, NULL, NULL, NULL,
606 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
607 "session mempool allocation failed");
611 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
613 "Failed to configure cryptodev %u with %u qps",
614 dev_id, ts_params->conf.nb_queue_pairs);
616 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
617 ts_params->qp_conf.mp_session = ts_params->session_mpool;
618 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
620 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
621 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
622 dev_id, qp_id, &ts_params->qp_conf,
623 rte_cryptodev_socket_id(dev_id)),
624 "Failed to setup queue pair %u on cryptodev %u",
632 testsuite_teardown(void)
634 struct crypto_testsuite_params *ts_params = &testsuite_params;
637 if (ts_params->mbuf_pool != NULL) {
638 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
639 rte_mempool_avail_count(ts_params->mbuf_pool));
642 if (ts_params->op_mpool != NULL) {
643 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
644 rte_mempool_avail_count(ts_params->op_mpool));
647 /* Free session mempools */
648 if (ts_params->session_priv_mpool != NULL) {
649 rte_mempool_free(ts_params->session_priv_mpool);
650 ts_params->session_priv_mpool = NULL;
653 if (ts_params->session_mpool != NULL) {
654 rte_mempool_free(ts_params->session_mpool);
655 ts_params->session_mpool = NULL;
658 res = rte_cryptodev_close(ts_params->valid_devs[0]);
660 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
664 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
665 const int *algs, uint16_t num_algs)
667 uint8_t dev_id = testsuite_params.valid_devs[0];
668 bool some_alg_supported = FALSE;
671 for (i = 0; i < num_algs && !some_alg_supported; i++) {
672 struct rte_cryptodev_sym_capability_idx alg = {
675 if (rte_cryptodev_sym_capability_get(dev_id,
677 some_alg_supported = TRUE;
679 if (!some_alg_supported)
686 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
687 uint16_t num_ciphers)
689 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
690 (const int *) ciphers, num_ciphers);
694 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
697 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
698 (const int *) auths, num_auths);
702 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
705 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
706 (const int *) aeads, num_aeads);
710 null_testsuite_setup(void)
712 struct crypto_testsuite_params *ts_params = &testsuite_params;
713 uint8_t dev_id = ts_params->valid_devs[0];
714 struct rte_cryptodev_info dev_info;
715 const enum rte_crypto_cipher_algorithm ciphers[] = {
716 RTE_CRYPTO_CIPHER_NULL
718 const enum rte_crypto_auth_algorithm auths[] = {
722 rte_cryptodev_info_get(dev_id, &dev_info);
724 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
725 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
726 "testsuite not met\n");
730 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
731 && check_auth_capabilities_supported(auths,
732 RTE_DIM(auths)) != 0) {
733 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
734 "testsuite not met\n");
742 crypto_gen_testsuite_setup(void)
744 struct crypto_testsuite_params *ts_params = &testsuite_params;
745 uint8_t dev_id = ts_params->valid_devs[0];
746 struct rte_cryptodev_info dev_info;
748 rte_cryptodev_info_get(dev_id, &dev_info);
750 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
751 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
752 "testsuite not met\n");
759 #ifdef RTE_LIB_SECURITY
761 pdcp_proto_testsuite_setup(void)
763 struct crypto_testsuite_params *ts_params = &testsuite_params;
764 uint8_t dev_id = ts_params->valid_devs[0];
765 struct rte_cryptodev_info dev_info;
766 const enum rte_crypto_cipher_algorithm ciphers[] = {
767 RTE_CRYPTO_CIPHER_NULL,
768 RTE_CRYPTO_CIPHER_AES_CTR,
769 RTE_CRYPTO_CIPHER_ZUC_EEA3,
770 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
772 const enum rte_crypto_auth_algorithm auths[] = {
773 RTE_CRYPTO_AUTH_NULL,
774 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
775 RTE_CRYPTO_AUTH_AES_CMAC,
776 RTE_CRYPTO_AUTH_ZUC_EIA3
779 rte_cryptodev_info_get(dev_id, &dev_info);
781 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
782 !(dev_info.feature_flags &
783 RTE_CRYPTODEV_FF_SECURITY)) {
784 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
785 "testsuite not met\n");
789 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
790 && check_auth_capabilities_supported(auths,
791 RTE_DIM(auths)) != 0) {
792 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
793 "testsuite not met\n");
801 docsis_proto_testsuite_setup(void)
803 struct crypto_testsuite_params *ts_params = &testsuite_params;
804 uint8_t dev_id = ts_params->valid_devs[0];
805 struct rte_cryptodev_info dev_info;
806 const enum rte_crypto_cipher_algorithm ciphers[] = {
807 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
810 rte_cryptodev_info_get(dev_id, &dev_info);
812 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
813 !(dev_info.feature_flags &
814 RTE_CRYPTODEV_FF_SECURITY)) {
815 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
816 "Proto testsuite not met\n");
820 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
821 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
822 "testsuite not met\n");
831 aes_ccm_auth_testsuite_setup(void)
833 struct crypto_testsuite_params *ts_params = &testsuite_params;
834 uint8_t dev_id = ts_params->valid_devs[0];
835 struct rte_cryptodev_info dev_info;
836 const enum rte_crypto_aead_algorithm aeads[] = {
837 RTE_CRYPTO_AEAD_AES_CCM
840 rte_cryptodev_info_get(dev_id, &dev_info);
842 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
843 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
844 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
845 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
846 "testsuite not met\n");
850 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
851 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
852 "testsuite not met\n");
860 aes_gcm_auth_testsuite_setup(void)
862 struct crypto_testsuite_params *ts_params = &testsuite_params;
863 uint8_t dev_id = ts_params->valid_devs[0];
864 struct rte_cryptodev_info dev_info;
865 const enum rte_crypto_aead_algorithm aeads[] = {
866 RTE_CRYPTO_AEAD_AES_GCM
869 rte_cryptodev_info_get(dev_id, &dev_info);
871 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
872 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
873 "testsuite not met\n");
877 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
878 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
879 "testsuite not met\n");
887 aes_gmac_auth_testsuite_setup(void)
889 struct crypto_testsuite_params *ts_params = &testsuite_params;
890 uint8_t dev_id = ts_params->valid_devs[0];
891 struct rte_cryptodev_info dev_info;
892 const enum rte_crypto_auth_algorithm auths[] = {
893 RTE_CRYPTO_AUTH_AES_GMAC
896 rte_cryptodev_info_get(dev_id, &dev_info);
898 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
899 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
900 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
901 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
902 "testsuite not met\n");
906 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
907 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
908 "testsuite not met\n");
916 chacha20_poly1305_testsuite_setup(void)
918 struct crypto_testsuite_params *ts_params = &testsuite_params;
919 uint8_t dev_id = ts_params->valid_devs[0];
920 struct rte_cryptodev_info dev_info;
921 const enum rte_crypto_aead_algorithm aeads[] = {
922 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
925 rte_cryptodev_info_get(dev_id, &dev_info);
927 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
928 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
929 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
930 RTE_LOG(INFO, USER1, "Feature flag requirements for "
931 "Chacha20-Poly1305 testsuite not met\n");
935 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
936 RTE_LOG(INFO, USER1, "Capability requirements for "
937 "Chacha20-Poly1305 testsuite not met\n");
945 snow3g_testsuite_setup(void)
947 struct crypto_testsuite_params *ts_params = &testsuite_params;
948 uint8_t dev_id = ts_params->valid_devs[0];
949 struct rte_cryptodev_info dev_info;
950 const enum rte_crypto_cipher_algorithm ciphers[] = {
951 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
954 const enum rte_crypto_auth_algorithm auths[] = {
955 RTE_CRYPTO_AUTH_SNOW3G_UIA2
958 rte_cryptodev_info_get(dev_id, &dev_info);
960 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
961 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
962 "testsuite not met\n");
966 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
967 && check_auth_capabilities_supported(auths,
968 RTE_DIM(auths)) != 0) {
969 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
970 "testsuite not met\n");
978 zuc_testsuite_setup(void)
980 struct crypto_testsuite_params *ts_params = &testsuite_params;
981 uint8_t dev_id = ts_params->valid_devs[0];
982 struct rte_cryptodev_info dev_info;
983 const enum rte_crypto_cipher_algorithm ciphers[] = {
984 RTE_CRYPTO_CIPHER_ZUC_EEA3
986 const enum rte_crypto_auth_algorithm auths[] = {
987 RTE_CRYPTO_AUTH_ZUC_EIA3
990 rte_cryptodev_info_get(dev_id, &dev_info);
992 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
993 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
994 "testsuite not met\n");
998 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
999 && check_auth_capabilities_supported(auths,
1000 RTE_DIM(auths)) != 0) {
1001 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1002 "testsuite not met\n");
1003 return TEST_SKIPPED;
1010 hmac_md5_auth_testsuite_setup(void)
1012 struct crypto_testsuite_params *ts_params = &testsuite_params;
1013 uint8_t dev_id = ts_params->valid_devs[0];
1014 struct rte_cryptodev_info dev_info;
1015 const enum rte_crypto_auth_algorithm auths[] = {
1016 RTE_CRYPTO_AUTH_MD5_HMAC
1019 rte_cryptodev_info_get(dev_id, &dev_info);
1021 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1022 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1023 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1024 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1025 "Auth testsuite not met\n");
1026 return TEST_SKIPPED;
1029 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1030 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1031 "testsuite not met\n");
1032 return TEST_SKIPPED;
1039 kasumi_testsuite_setup(void)
1041 struct crypto_testsuite_params *ts_params = &testsuite_params;
1042 uint8_t dev_id = ts_params->valid_devs[0];
1043 struct rte_cryptodev_info dev_info;
1044 const enum rte_crypto_cipher_algorithm ciphers[] = {
1045 RTE_CRYPTO_CIPHER_KASUMI_F8
1047 const enum rte_crypto_auth_algorithm auths[] = {
1048 RTE_CRYPTO_AUTH_KASUMI_F9
1051 rte_cryptodev_info_get(dev_id, &dev_info);
1053 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1054 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1055 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1056 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1057 "testsuite not met\n");
1058 return TEST_SKIPPED;
1061 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1062 && check_auth_capabilities_supported(auths,
1063 RTE_DIM(auths)) != 0) {
1064 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1065 "testsuite not met\n");
1066 return TEST_SKIPPED;
1073 negative_aes_gcm_testsuite_setup(void)
1075 struct crypto_testsuite_params *ts_params = &testsuite_params;
1076 uint8_t dev_id = ts_params->valid_devs[0];
1077 struct rte_cryptodev_info dev_info;
1078 const enum rte_crypto_aead_algorithm aeads[] = {
1079 RTE_CRYPTO_AEAD_AES_GCM
1082 rte_cryptodev_info_get(dev_id, &dev_info);
1084 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1085 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1086 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1087 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1088 "AES GCM testsuite not met\n");
1089 return TEST_SKIPPED;
1092 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1093 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1094 "AES GCM testsuite not met\n");
1095 return TEST_SKIPPED;
1102 negative_aes_gmac_testsuite_setup(void)
1104 struct crypto_testsuite_params *ts_params = &testsuite_params;
1105 uint8_t dev_id = ts_params->valid_devs[0];
1106 struct rte_cryptodev_info dev_info;
1107 const enum rte_crypto_auth_algorithm auths[] = {
1108 RTE_CRYPTO_AUTH_AES_GMAC
1111 rte_cryptodev_info_get(dev_id, &dev_info);
1113 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1114 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1115 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1116 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1117 "AES GMAC testsuite not met\n");
1118 return TEST_SKIPPED;
1121 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1122 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1123 "AES GMAC testsuite not met\n");
1124 return TEST_SKIPPED;
1131 mixed_cipher_hash_testsuite_setup(void)
1133 struct crypto_testsuite_params *ts_params = &testsuite_params;
1134 uint8_t dev_id = ts_params->valid_devs[0];
1135 struct rte_cryptodev_info dev_info;
1136 uint64_t feat_flags;
1137 const enum rte_crypto_cipher_algorithm ciphers[] = {
1138 RTE_CRYPTO_CIPHER_NULL,
1139 RTE_CRYPTO_CIPHER_AES_CTR,
1140 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1141 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1143 const enum rte_crypto_auth_algorithm auths[] = {
1144 RTE_CRYPTO_AUTH_NULL,
1145 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1146 RTE_CRYPTO_AUTH_AES_CMAC,
1147 RTE_CRYPTO_AUTH_ZUC_EIA3
1150 rte_cryptodev_info_get(dev_id, &dev_info);
1151 feat_flags = dev_info.feature_flags;
1153 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1154 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1155 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1156 "Cipher Hash testsuite not met\n");
1157 return TEST_SKIPPED;
1160 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1161 && check_auth_capabilities_supported(auths,
1162 RTE_DIM(auths)) != 0) {
1163 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1164 "Cipher Hash testsuite not met\n");
1165 return TEST_SKIPPED;
1172 esn_testsuite_setup(void)
1174 struct crypto_testsuite_params *ts_params = &testsuite_params;
1175 uint8_t dev_id = ts_params->valid_devs[0];
1176 struct rte_cryptodev_info dev_info;
1177 const enum rte_crypto_cipher_algorithm ciphers[] = {
1178 RTE_CRYPTO_CIPHER_AES_CBC
1180 const enum rte_crypto_auth_algorithm auths[] = {
1181 RTE_CRYPTO_AUTH_SHA1_HMAC
1184 rte_cryptodev_info_get(dev_id, &dev_info);
1186 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1187 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1188 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1189 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1190 "testsuite not met\n");
1191 return TEST_SKIPPED;
1194 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1195 && check_auth_capabilities_supported(auths,
1196 RTE_DIM(auths)) != 0) {
1197 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1198 "testsuite not met\n");
1199 return TEST_SKIPPED;
1206 multi_session_testsuite_setup(void)
1208 struct crypto_testsuite_params *ts_params = &testsuite_params;
1209 uint8_t dev_id = ts_params->valid_devs[0];
1210 struct rte_cryptodev_info dev_info;
1211 const enum rte_crypto_cipher_algorithm ciphers[] = {
1212 RTE_CRYPTO_CIPHER_AES_CBC
1214 const enum rte_crypto_auth_algorithm auths[] = {
1215 RTE_CRYPTO_AUTH_SHA512_HMAC
1218 rte_cryptodev_info_get(dev_id, &dev_info);
1220 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1221 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1222 "Session testsuite not met\n");
1223 return TEST_SKIPPED;
1226 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1227 && check_auth_capabilities_supported(auths,
1228 RTE_DIM(auths)) != 0) {
1229 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1230 "Session testsuite not met\n");
1231 return TEST_SKIPPED;
1238 negative_hmac_sha1_testsuite_setup(void)
1240 struct crypto_testsuite_params *ts_params = &testsuite_params;
1241 uint8_t dev_id = ts_params->valid_devs[0];
1242 struct rte_cryptodev_info dev_info;
1243 const enum rte_crypto_cipher_algorithm ciphers[] = {
1244 RTE_CRYPTO_CIPHER_AES_CBC
1246 const enum rte_crypto_auth_algorithm auths[] = {
1247 RTE_CRYPTO_AUTH_SHA1_HMAC
1250 rte_cryptodev_info_get(dev_id, &dev_info);
1252 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1253 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1254 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1255 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1256 "HMAC SHA1 testsuite not met\n");
1257 return TEST_SKIPPED;
1260 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1261 && check_auth_capabilities_supported(auths,
1262 RTE_DIM(auths)) != 0) {
1263 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1264 "HMAC SHA1 testsuite not met\n");
1265 return TEST_SKIPPED;
1272 dev_configure_and_start(uint64_t ff_disable)
1274 struct crypto_testsuite_params *ts_params = &testsuite_params;
1275 struct crypto_unittest_params *ut_params = &unittest_params;
1279 /* Clear unit test parameters before running test */
1280 memset(ut_params, 0, sizeof(*ut_params));
1282 /* Reconfigure device to default parameters */
1283 ts_params->conf.socket_id = SOCKET_ID_ANY;
1284 ts_params->conf.ff_disable = ff_disable;
1285 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1286 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1287 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1289 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1291 "Failed to configure cryptodev %u",
1292 ts_params->valid_devs[0]);
1294 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1295 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1296 ts_params->valid_devs[0], qp_id,
1297 &ts_params->qp_conf,
1298 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1299 "Failed to setup queue pair %u on cryptodev %u",
1300 qp_id, ts_params->valid_devs[0]);
1304 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1306 /* Start the device */
1307 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1308 "Failed to start cryptodev %u",
1309 ts_params->valid_devs[0]);
1311 return TEST_SUCCESS;
1317 /* Configure and start the device with security feature disabled */
1318 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1322 ut_setup_security(void)
1324 /* Configure and start the device with no features disabled */
1325 return dev_configure_and_start(0);
1331 struct crypto_testsuite_params *ts_params = &testsuite_params;
1332 struct crypto_unittest_params *ut_params = &unittest_params;
1333 struct rte_cryptodev_stats stats;
1335 /* free crypto session structure */
1336 #ifdef RTE_LIB_SECURITY
1337 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1338 if (ut_params->sec_session) {
1339 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1340 (ts_params->valid_devs[0]),
1341 ut_params->sec_session);
1342 ut_params->sec_session = NULL;
1347 if (ut_params->sess) {
1348 rte_cryptodev_sym_session_clear(
1349 ts_params->valid_devs[0],
1351 rte_cryptodev_sym_session_free(ut_params->sess);
1352 ut_params->sess = NULL;
1356 /* free crypto operation structure */
1358 rte_crypto_op_free(ut_params->op);
1361 * free mbuf - both obuf and ibuf are usually the same,
1362 * so check if they point at the same address is necessary,
1363 * to avoid freeing the mbuf twice.
1365 if (ut_params->obuf) {
1366 rte_pktmbuf_free(ut_params->obuf);
1367 if (ut_params->ibuf == ut_params->obuf)
1368 ut_params->ibuf = 0;
1369 ut_params->obuf = 0;
1371 if (ut_params->ibuf) {
1372 rte_pktmbuf_free(ut_params->ibuf);
1373 ut_params->ibuf = 0;
1376 if (ts_params->mbuf_pool != NULL)
1377 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1378 rte_mempool_avail_count(ts_params->mbuf_pool));
1380 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1382 /* Stop the device */
1383 rte_cryptodev_stop(ts_params->valid_devs[0]);
1387 test_device_configure_invalid_dev_id(void)
1389 struct crypto_testsuite_params *ts_params = &testsuite_params;
1390 uint16_t dev_id, num_devs = 0;
1392 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1393 "Need at least %d devices for test", 1);
1395 /* valid dev_id values */
1396 dev_id = ts_params->valid_devs[0];
1398 /* Stop the device in case it's started so it can be configured */
1399 rte_cryptodev_stop(dev_id);
1401 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1402 "Failed test for rte_cryptodev_configure: "
1403 "invalid dev_num %u", dev_id);
1405 /* invalid dev_id values */
1408 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1409 "Failed test for rte_cryptodev_configure: "
1410 "invalid dev_num %u", dev_id);
1414 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1415 "Failed test for rte_cryptodev_configure:"
1416 "invalid dev_num %u", dev_id);
1418 return TEST_SUCCESS;
1422 test_device_configure_invalid_queue_pair_ids(void)
1424 struct crypto_testsuite_params *ts_params = &testsuite_params;
1425 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1427 /* Stop the device in case it's started so it can be configured */
1428 rte_cryptodev_stop(ts_params->valid_devs[0]);
1430 /* valid - max value queue pairs */
1431 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1433 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1435 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1436 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1438 /* valid - one queue pairs */
1439 ts_params->conf.nb_queue_pairs = 1;
1441 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1443 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1444 ts_params->valid_devs[0],
1445 ts_params->conf.nb_queue_pairs);
1448 /* invalid - zero queue pairs */
1449 ts_params->conf.nb_queue_pairs = 0;
1451 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1453 "Failed test for rte_cryptodev_configure, dev_id %u,"
1455 ts_params->valid_devs[0],
1456 ts_params->conf.nb_queue_pairs);
1459 /* invalid - max value supported by field queue pairs */
1460 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1462 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1464 "Failed test for rte_cryptodev_configure, dev_id %u,"
1466 ts_params->valid_devs[0],
1467 ts_params->conf.nb_queue_pairs);
1470 /* invalid - max value + 1 queue pairs */
1471 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1473 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1475 "Failed test for rte_cryptodev_configure, dev_id %u,"
1477 ts_params->valid_devs[0],
1478 ts_params->conf.nb_queue_pairs);
1480 /* revert to original testsuite value */
1481 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1483 return TEST_SUCCESS;
1487 test_queue_pair_descriptor_setup(void)
1489 struct crypto_testsuite_params *ts_params = &testsuite_params;
1490 struct rte_cryptodev_qp_conf qp_conf = {
1491 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1495 /* Stop the device in case it's started so it can be configured */
1496 rte_cryptodev_stop(ts_params->valid_devs[0]);
1498 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1500 "Failed to configure cryptodev %u",
1501 ts_params->valid_devs[0]);
1504 * Test various ring sizes on this device. memzones can't be
1505 * freed so are re-used if ring is released and re-created.
1507 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1508 qp_conf.mp_session = ts_params->session_mpool;
1509 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1511 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1512 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1513 ts_params->valid_devs[0], qp_id, &qp_conf,
1514 rte_cryptodev_socket_id(
1515 ts_params->valid_devs[0])),
1517 "rte_cryptodev_queue_pair_setup: num_inflights "
1518 "%u on qp %u on cryptodev %u",
1519 qp_conf.nb_descriptors, qp_id,
1520 ts_params->valid_devs[0]);
1523 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1525 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1526 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1527 ts_params->valid_devs[0], qp_id, &qp_conf,
1528 rte_cryptodev_socket_id(
1529 ts_params->valid_devs[0])),
1531 " rte_cryptodev_queue_pair_setup: num_inflights"
1532 " %u on qp %u on cryptodev %u",
1533 qp_conf.nb_descriptors, qp_id,
1534 ts_params->valid_devs[0]);
1537 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1539 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1540 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1541 ts_params->valid_devs[0], qp_id, &qp_conf,
1542 rte_cryptodev_socket_id(
1543 ts_params->valid_devs[0])),
1545 "rte_cryptodev_queue_pair_setup: num_inflights"
1546 " %u on qp %u on cryptodev %u",
1547 qp_conf.nb_descriptors, qp_id,
1548 ts_params->valid_devs[0]);
1551 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1553 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1554 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1555 ts_params->valid_devs[0], qp_id, &qp_conf,
1556 rte_cryptodev_socket_id(
1557 ts_params->valid_devs[0])),
1559 " rte_cryptodev_queue_pair_setup:"
1560 "num_inflights %u on qp %u on cryptodev %u",
1561 qp_conf.nb_descriptors, qp_id,
1562 ts_params->valid_devs[0]);
1565 /* test invalid queue pair id */
1566 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1568 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1570 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1571 ts_params->valid_devs[0],
1573 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1574 "Failed test for rte_cryptodev_queue_pair_setup:"
1575 "invalid qp %u on cryptodev %u",
1576 qp_id, ts_params->valid_devs[0]);
1578 qp_id = 0xffff; /*invalid*/
1580 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1581 ts_params->valid_devs[0],
1583 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1584 "Failed test for rte_cryptodev_queue_pair_setup:"
1585 "invalid qp %u on cryptodev %u",
1586 qp_id, ts_params->valid_devs[0]);
1588 return TEST_SUCCESS;
1591 /* ***** Plaintext data for tests ***** */
1593 const char catch_22_quote_1[] =
1594 "There was only one catch and that was Catch-22, which "
1595 "specified that a concern for one's safety in the face of "
1596 "dangers that were real and immediate was the process of a "
1597 "rational mind. Orr was crazy and could be grounded. All he "
1598 "had to do was ask; and as soon as he did, he would no longer "
1599 "be crazy and would have to fly more missions. Orr would be "
1600 "crazy to fly more missions and sane if he didn't, but if he "
1601 "was sane he had to fly them. If he flew them he was crazy "
1602 "and didn't have to; but if he didn't want to he was sane and "
1603 "had to. Yossarian was moved very deeply by the absolute "
1604 "simplicity of this clause of Catch-22 and let out a "
1605 "respectful whistle. \"That's some catch, that Catch-22\", he "
1606 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1608 const char catch_22_quote[] =
1609 "What a lousy earth! He wondered how many people were "
1610 "destitute that same night even in his own prosperous country, "
1611 "how many homes were shanties, how many husbands were drunk "
1612 "and wives socked, and how many children were bullied, abused, "
1613 "or abandoned. How many families hungered for food they could "
1614 "not afford to buy? How many hearts were broken? How many "
1615 "suicides would take place that same night, how many people "
1616 "would go insane? How many cockroaches and landlords would "
1617 "triumph? How many winners were losers, successes failures, "
1618 "and rich men poor men? How many wise guys were stupid? How "
1619 "many happy endings were unhappy endings? How many honest men "
1620 "were liars, brave men cowards, loyal men traitors, how many "
1621 "sainted men were corrupt, how many people in positions of "
1622 "trust had sold their souls to bodyguards, how many had never "
1623 "had souls? How many straight-and-narrow paths were crooked "
1624 "paths? How many best families were worst families and how "
1625 "many good people were bad people? When you added them all up "
1626 "and then subtracted, you might be left with only the children, "
1627 "and perhaps with Albert Einstein and an old violinist or "
1628 "sculptor somewhere.";
1630 #define QUOTE_480_BYTES (480)
1631 #define QUOTE_512_BYTES (512)
1632 #define QUOTE_768_BYTES (768)
1633 #define QUOTE_1024_BYTES (1024)
1637 /* ***** SHA1 Hash Tests ***** */
1639 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1641 static uint8_t hmac_sha1_key[] = {
1642 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1643 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1644 0xDE, 0xF4, 0xDE, 0xAD };
1646 /* ***** SHA224 Hash Tests ***** */
1648 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1651 /* ***** AES-CBC Cipher Tests ***** */
1653 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1654 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1656 static uint8_t aes_cbc_key[] = {
1657 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1658 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1660 static uint8_t aes_cbc_iv[] = {
1661 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1662 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1665 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1667 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1668 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1669 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1670 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1671 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1672 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1673 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1674 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1675 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1676 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1677 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1678 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1679 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1680 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1681 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1682 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1683 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1684 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1685 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1686 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1687 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1688 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1689 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1690 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1691 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1692 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1693 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1694 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1695 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1696 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1697 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1698 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1699 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1700 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1701 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1702 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1703 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1704 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1705 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1706 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1707 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1708 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1709 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1710 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1711 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1712 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1713 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1714 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1715 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1716 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1717 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1718 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1719 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1720 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1721 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1722 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1723 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1724 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1725 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1726 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1727 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1728 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1729 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1730 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1731 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1734 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1735 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1736 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1737 0x18, 0x8c, 0x1d, 0x32
1741 /* Multisession Vector context Test */
1742 /*Begin Session 0 */
1743 static uint8_t ms_aes_cbc_key0[] = {
1744 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1745 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1748 static uint8_t ms_aes_cbc_iv0[] = {
1749 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1750 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1753 static const uint8_t ms_aes_cbc_cipher0[] = {
1754 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1755 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1756 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1757 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1758 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1759 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1760 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1761 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1762 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1763 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1764 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1765 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1766 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1767 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1768 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1769 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1770 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1771 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1772 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1773 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1774 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1775 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1776 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1777 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1778 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1779 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1780 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1781 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1782 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1783 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1784 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1785 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1786 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1787 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1788 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1789 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1790 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1791 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1792 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1793 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1794 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1795 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1796 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1797 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1798 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1799 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1800 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1801 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1802 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1803 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1804 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1805 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1806 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1807 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1808 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1809 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1810 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1811 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1812 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1813 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1814 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1815 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1816 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1817 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1821 static uint8_t ms_hmac_key0[] = {
1822 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1823 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1824 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1825 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1826 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1827 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1828 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1829 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1832 static const uint8_t ms_hmac_digest0[] = {
1833 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1834 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1835 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1836 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1837 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1838 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1839 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1840 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1844 /* Begin session 1 */
1846 static uint8_t ms_aes_cbc_key1[] = {
1847 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1848 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1851 static uint8_t ms_aes_cbc_iv1[] = {
1852 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1853 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1856 static const uint8_t ms_aes_cbc_cipher1[] = {
1857 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1858 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1859 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1860 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1861 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1862 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1863 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1864 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1865 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1866 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1867 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1868 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1869 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1870 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1871 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1872 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1873 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1874 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1875 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1876 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1877 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1878 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1879 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1880 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1881 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1882 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1883 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1884 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1885 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1886 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1887 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1888 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1889 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1890 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1891 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1892 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1893 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1894 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1895 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1896 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1897 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1898 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1899 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1900 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1901 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1902 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1903 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1904 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1905 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1906 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1907 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1908 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1909 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1910 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1911 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1912 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1913 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1914 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1915 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1916 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1917 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1918 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1919 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1920 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1924 static uint8_t ms_hmac_key1[] = {
1925 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1926 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1927 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1928 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1929 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1930 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1931 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1932 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1935 static const uint8_t ms_hmac_digest1[] = {
1936 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1937 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1938 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1939 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1940 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1941 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1942 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1943 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1946 /* Begin Session 2 */
1947 static uint8_t ms_aes_cbc_key2[] = {
1948 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1949 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1952 static uint8_t ms_aes_cbc_iv2[] = {
1953 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1954 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1957 static const uint8_t ms_aes_cbc_cipher2[] = {
1958 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1959 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1960 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1961 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1962 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1963 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1964 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1965 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1966 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1967 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1968 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1969 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1970 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1971 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1972 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1973 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1974 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1975 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1976 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1977 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1978 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1979 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1980 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1981 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1982 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1983 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1984 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1985 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1986 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1987 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1988 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1989 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1990 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1991 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1992 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1993 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1994 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1995 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1996 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1997 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1998 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1999 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2000 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2001 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2002 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2003 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2004 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2005 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2006 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2007 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2008 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2009 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2010 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2011 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2012 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2013 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2014 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2015 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2016 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2017 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2018 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2019 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2020 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2021 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2024 static uint8_t ms_hmac_key2[] = {
2025 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2026 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2027 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2028 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2029 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2030 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2031 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2032 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2035 static const uint8_t ms_hmac_digest2[] = {
2036 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2037 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2038 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2039 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2040 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2041 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2042 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2043 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2050 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2052 struct crypto_testsuite_params *ts_params = &testsuite_params;
2053 struct crypto_unittest_params *ut_params = &unittest_params;
2055 /* Verify the capabilities */
2056 struct rte_cryptodev_sym_capability_idx cap_idx;
2057 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2058 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2059 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2061 return TEST_SKIPPED;
2062 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2063 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2064 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2066 return TEST_SKIPPED;
2068 /* Generate test mbuf data and space for digest */
2069 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2070 catch_22_quote, QUOTE_512_BYTES, 0);
2072 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2073 DIGEST_BYTE_LENGTH_SHA1);
2074 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2076 /* Setup Cipher Parameters */
2077 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2078 ut_params->cipher_xform.next = &ut_params->auth_xform;
2080 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2081 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2082 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2083 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2084 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2085 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2087 /* Setup HMAC Parameters */
2088 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2090 ut_params->auth_xform.next = NULL;
2092 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2093 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2094 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2095 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2096 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2098 ut_params->sess = rte_cryptodev_sym_session_create(
2099 ts_params->session_mpool);
2101 /* Create crypto session*/
2102 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2103 ut_params->sess, &ut_params->cipher_xform,
2104 ts_params->session_priv_mpool);
2105 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2107 /* Generate crypto op data structure */
2108 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2109 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2110 TEST_ASSERT_NOT_NULL(ut_params->op,
2111 "Failed to allocate symmetric crypto operation struct");
2113 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2115 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2117 /* set crypto operation source mbuf */
2118 sym_op->m_src = ut_params->ibuf;
2120 /* Set crypto operation authentication parameters */
2121 sym_op->auth.digest.data = ut_params->digest;
2122 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2123 ut_params->ibuf, QUOTE_512_BYTES);
2125 sym_op->auth.data.offset = 0;
2126 sym_op->auth.data.length = QUOTE_512_BYTES;
2128 /* Copy IV at the end of the crypto operation */
2129 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2130 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2132 /* Set crypto operation cipher parameters */
2133 sym_op->cipher.data.offset = 0;
2134 sym_op->cipher.data.length = QUOTE_512_BYTES;
2136 /* Process crypto operation */
2137 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2138 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2141 TEST_ASSERT_NOT_NULL(
2142 process_crypto_request(ts_params->valid_devs[0],
2144 "failed to process sym crypto op");
2146 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2147 "crypto op processing failed");
2150 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2153 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2154 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2156 "ciphertext data not as expected");
2158 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2160 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2161 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2162 gbl_driver_id == rte_cryptodev_driver_id_get(
2163 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2164 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2165 DIGEST_BYTE_LENGTH_SHA1,
2166 "Generated digest data not as expected");
2168 return TEST_SUCCESS;
2171 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2173 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2175 static uint8_t hmac_sha512_key[] = {
2176 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2177 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2178 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2179 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2180 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2181 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2182 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2183 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2185 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2186 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2187 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2188 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2189 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2190 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2191 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2192 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2193 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2198 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2199 struct crypto_unittest_params *ut_params,
2200 uint8_t *cipher_key,
2204 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2205 struct crypto_unittest_params *ut_params,
2206 struct crypto_testsuite_params *ts_params,
2207 const uint8_t *cipher,
2208 const uint8_t *digest,
2213 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2214 struct crypto_unittest_params *ut_params,
2215 uint8_t *cipher_key,
2219 /* Setup Cipher Parameters */
2220 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2221 ut_params->cipher_xform.next = NULL;
2223 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2224 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2225 ut_params->cipher_xform.cipher.key.data = cipher_key;
2226 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2227 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2228 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2230 /* Setup HMAC Parameters */
2231 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2232 ut_params->auth_xform.next = &ut_params->cipher_xform;
2234 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2235 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2236 ut_params->auth_xform.auth.key.data = hmac_key;
2237 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2238 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2240 return TEST_SUCCESS;
2245 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2246 struct crypto_unittest_params *ut_params,
2247 struct crypto_testsuite_params *ts_params,
2248 const uint8_t *cipher,
2249 const uint8_t *digest,
2252 /* Generate test mbuf data and digest */
2253 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2256 QUOTE_512_BYTES, 0);
2258 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2259 DIGEST_BYTE_LENGTH_SHA512);
2260 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2262 rte_memcpy(ut_params->digest,
2264 DIGEST_BYTE_LENGTH_SHA512);
2266 /* Generate Crypto op data structure */
2267 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2268 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2269 TEST_ASSERT_NOT_NULL(ut_params->op,
2270 "Failed to allocate symmetric crypto operation struct");
2272 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2274 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2276 /* set crypto operation source mbuf */
2277 sym_op->m_src = ut_params->ibuf;
2279 sym_op->auth.digest.data = ut_params->digest;
2280 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2281 ut_params->ibuf, QUOTE_512_BYTES);
2283 sym_op->auth.data.offset = 0;
2284 sym_op->auth.data.length = QUOTE_512_BYTES;
2286 /* Copy IV at the end of the crypto operation */
2287 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2288 iv, CIPHER_IV_LENGTH_AES_CBC);
2290 sym_op->cipher.data.offset = 0;
2291 sym_op->cipher.data.length = QUOTE_512_BYTES;
2293 /* Process crypto operation */
2294 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2295 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2297 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2298 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2299 ut_params->op, 1, 1, 0, 0);
2301 TEST_ASSERT_NOT_NULL(
2302 process_crypto_request(ts_params->valid_devs[0],
2304 "failed to process sym crypto op");
2306 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2307 "crypto op processing failed");
2309 ut_params->obuf = ut_params->op->sym->m_src;
2312 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2313 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2316 "Plaintext data not as expected");
2319 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2320 "Digest verification failed");
2322 return TEST_SUCCESS;
2325 /* ***** SNOW 3G Tests ***** */
2327 create_wireless_algo_hash_session(uint8_t dev_id,
2328 const uint8_t *key, const uint8_t key_len,
2329 const uint8_t iv_len, const uint8_t auth_len,
2330 enum rte_crypto_auth_operation op,
2331 enum rte_crypto_auth_algorithm algo)
2333 uint8_t hash_key[key_len];
2336 struct crypto_testsuite_params *ts_params = &testsuite_params;
2337 struct crypto_unittest_params *ut_params = &unittest_params;
2339 memcpy(hash_key, key, key_len);
2341 debug_hexdump(stdout, "key:", key, key_len);
2343 /* Setup Authentication Parameters */
2344 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2345 ut_params->auth_xform.next = NULL;
2347 ut_params->auth_xform.auth.op = op;
2348 ut_params->auth_xform.auth.algo = algo;
2349 ut_params->auth_xform.auth.key.length = key_len;
2350 ut_params->auth_xform.auth.key.data = hash_key;
2351 ut_params->auth_xform.auth.digest_length = auth_len;
2352 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2353 ut_params->auth_xform.auth.iv.length = iv_len;
2354 ut_params->sess = rte_cryptodev_sym_session_create(
2355 ts_params->session_mpool);
2357 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2358 &ut_params->auth_xform,
2359 ts_params->session_priv_mpool);
2360 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2361 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2366 create_wireless_algo_cipher_session(uint8_t dev_id,
2367 enum rte_crypto_cipher_operation op,
2368 enum rte_crypto_cipher_algorithm algo,
2369 const uint8_t *key, const uint8_t key_len,
2372 uint8_t cipher_key[key_len];
2374 struct crypto_testsuite_params *ts_params = &testsuite_params;
2375 struct crypto_unittest_params *ut_params = &unittest_params;
2377 memcpy(cipher_key, key, key_len);
2379 /* Setup Cipher Parameters */
2380 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2381 ut_params->cipher_xform.next = NULL;
2383 ut_params->cipher_xform.cipher.algo = algo;
2384 ut_params->cipher_xform.cipher.op = op;
2385 ut_params->cipher_xform.cipher.key.data = cipher_key;
2386 ut_params->cipher_xform.cipher.key.length = key_len;
2387 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2388 ut_params->cipher_xform.cipher.iv.length = iv_len;
2390 debug_hexdump(stdout, "key:", key, key_len);
2392 /* Create Crypto session */
2393 ut_params->sess = rte_cryptodev_sym_session_create(
2394 ts_params->session_mpool);
2396 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2397 &ut_params->cipher_xform,
2398 ts_params->session_priv_mpool);
2399 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2400 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2405 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2406 unsigned int cipher_len,
2407 unsigned int cipher_offset)
2409 struct crypto_testsuite_params *ts_params = &testsuite_params;
2410 struct crypto_unittest_params *ut_params = &unittest_params;
2412 /* Generate Crypto op data structure */
2413 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2414 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2415 TEST_ASSERT_NOT_NULL(ut_params->op,
2416 "Failed to allocate pktmbuf offload");
2418 /* Set crypto operation data parameters */
2419 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2421 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2423 /* set crypto operation source mbuf */
2424 sym_op->m_src = ut_params->ibuf;
2427 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2429 sym_op->cipher.data.length = cipher_len;
2430 sym_op->cipher.data.offset = cipher_offset;
2435 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2436 unsigned int cipher_len,
2437 unsigned int cipher_offset)
2439 struct crypto_testsuite_params *ts_params = &testsuite_params;
2440 struct crypto_unittest_params *ut_params = &unittest_params;
2442 /* Generate Crypto op data structure */
2443 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2444 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2445 TEST_ASSERT_NOT_NULL(ut_params->op,
2446 "Failed to allocate pktmbuf offload");
2448 /* Set crypto operation data parameters */
2449 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2451 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2453 /* set crypto operation source mbuf */
2454 sym_op->m_src = ut_params->ibuf;
2455 sym_op->m_dst = ut_params->obuf;
2458 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2460 sym_op->cipher.data.length = cipher_len;
2461 sym_op->cipher.data.offset = cipher_offset;
2466 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2467 enum rte_crypto_cipher_operation cipher_op,
2468 enum rte_crypto_auth_operation auth_op,
2469 enum rte_crypto_auth_algorithm auth_algo,
2470 enum rte_crypto_cipher_algorithm cipher_algo,
2471 const uint8_t *key, uint8_t key_len,
2472 uint8_t auth_iv_len, uint8_t auth_len,
2473 uint8_t cipher_iv_len)
2476 uint8_t cipher_auth_key[key_len];
2479 struct crypto_testsuite_params *ts_params = &testsuite_params;
2480 struct crypto_unittest_params *ut_params = &unittest_params;
2482 memcpy(cipher_auth_key, key, key_len);
2484 /* Setup Authentication Parameters */
2485 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2486 ut_params->auth_xform.next = NULL;
2488 ut_params->auth_xform.auth.op = auth_op;
2489 ut_params->auth_xform.auth.algo = auth_algo;
2490 ut_params->auth_xform.auth.key.length = key_len;
2491 /* Hash key = cipher key */
2492 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2493 ut_params->auth_xform.auth.digest_length = auth_len;
2494 /* Auth IV will be after cipher IV */
2495 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2496 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2498 /* Setup Cipher Parameters */
2499 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2500 ut_params->cipher_xform.next = &ut_params->auth_xform;
2502 ut_params->cipher_xform.cipher.algo = cipher_algo;
2503 ut_params->cipher_xform.cipher.op = cipher_op;
2504 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2505 ut_params->cipher_xform.cipher.key.length = key_len;
2506 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2507 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2509 debug_hexdump(stdout, "key:", key, key_len);
2511 /* Create Crypto session*/
2512 ut_params->sess = rte_cryptodev_sym_session_create(
2513 ts_params->session_mpool);
2514 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2516 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2517 &ut_params->cipher_xform,
2518 ts_params->session_priv_mpool);
2519 if (status == -ENOTSUP)
2520 return TEST_SKIPPED;
2522 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2527 create_wireless_cipher_auth_session(uint8_t dev_id,
2528 enum rte_crypto_cipher_operation cipher_op,
2529 enum rte_crypto_auth_operation auth_op,
2530 enum rte_crypto_auth_algorithm auth_algo,
2531 enum rte_crypto_cipher_algorithm cipher_algo,
2532 const struct wireless_test_data *tdata)
2534 const uint8_t key_len = tdata->key.len;
2535 uint8_t cipher_auth_key[key_len];
2538 struct crypto_testsuite_params *ts_params = &testsuite_params;
2539 struct crypto_unittest_params *ut_params = &unittest_params;
2540 const uint8_t *key = tdata->key.data;
2541 const uint8_t auth_len = tdata->digest.len;
2542 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2543 uint8_t auth_iv_len = tdata->auth_iv.len;
2545 memcpy(cipher_auth_key, key, key_len);
2547 /* Setup Authentication Parameters */
2548 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2549 ut_params->auth_xform.next = NULL;
2551 ut_params->auth_xform.auth.op = auth_op;
2552 ut_params->auth_xform.auth.algo = auth_algo;
2553 ut_params->auth_xform.auth.key.length = key_len;
2554 /* Hash key = cipher key */
2555 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2556 ut_params->auth_xform.auth.digest_length = auth_len;
2557 /* Auth IV will be after cipher IV */
2558 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2559 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2561 /* Setup Cipher Parameters */
2562 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2563 ut_params->cipher_xform.next = &ut_params->auth_xform;
2565 ut_params->cipher_xform.cipher.algo = cipher_algo;
2566 ut_params->cipher_xform.cipher.op = cipher_op;
2567 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2568 ut_params->cipher_xform.cipher.key.length = key_len;
2569 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2570 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2573 debug_hexdump(stdout, "key:", key, key_len);
2575 /* Create Crypto session*/
2576 ut_params->sess = rte_cryptodev_sym_session_create(
2577 ts_params->session_mpool);
2579 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2580 &ut_params->cipher_xform,
2581 ts_params->session_priv_mpool);
2582 if (status == -ENOTSUP)
2583 return TEST_SKIPPED;
2585 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2586 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2591 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2592 const struct wireless_test_data *tdata)
2594 return create_wireless_cipher_auth_session(dev_id,
2595 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2596 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2597 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2601 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2602 enum rte_crypto_cipher_operation cipher_op,
2603 enum rte_crypto_auth_operation auth_op,
2604 enum rte_crypto_auth_algorithm auth_algo,
2605 enum rte_crypto_cipher_algorithm cipher_algo,
2606 const uint8_t *key, const uint8_t key_len,
2607 uint8_t auth_iv_len, uint8_t auth_len,
2608 uint8_t cipher_iv_len)
2610 uint8_t auth_cipher_key[key_len];
2612 struct crypto_testsuite_params *ts_params = &testsuite_params;
2613 struct crypto_unittest_params *ut_params = &unittest_params;
2615 memcpy(auth_cipher_key, key, key_len);
2617 /* Setup Authentication Parameters */
2618 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2619 ut_params->auth_xform.auth.op = auth_op;
2620 ut_params->auth_xform.next = &ut_params->cipher_xform;
2621 ut_params->auth_xform.auth.algo = auth_algo;
2622 ut_params->auth_xform.auth.key.length = key_len;
2623 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2624 ut_params->auth_xform.auth.digest_length = auth_len;
2625 /* Auth IV will be after cipher IV */
2626 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2627 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2629 /* Setup Cipher Parameters */
2630 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2631 ut_params->cipher_xform.next = NULL;
2632 ut_params->cipher_xform.cipher.algo = cipher_algo;
2633 ut_params->cipher_xform.cipher.op = cipher_op;
2634 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2635 ut_params->cipher_xform.cipher.key.length = key_len;
2636 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2637 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2639 debug_hexdump(stdout, "key:", key, key_len);
2641 /* Create Crypto session*/
2642 ut_params->sess = rte_cryptodev_sym_session_create(
2643 ts_params->session_mpool);
2644 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2646 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2647 ut_params->auth_xform.next = NULL;
2648 ut_params->cipher_xform.next = &ut_params->auth_xform;
2649 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2650 &ut_params->cipher_xform,
2651 ts_params->session_priv_mpool);
2654 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2655 &ut_params->auth_xform,
2656 ts_params->session_priv_mpool);
2658 if (status == -ENOTSUP)
2659 return TEST_SKIPPED;
2661 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2667 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2668 unsigned int auth_tag_len,
2669 const uint8_t *iv, unsigned int iv_len,
2670 unsigned int data_pad_len,
2671 enum rte_crypto_auth_operation op,
2672 unsigned int auth_len, unsigned int auth_offset)
2674 struct crypto_testsuite_params *ts_params = &testsuite_params;
2676 struct crypto_unittest_params *ut_params = &unittest_params;
2678 /* Generate Crypto op data structure */
2679 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2680 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2681 TEST_ASSERT_NOT_NULL(ut_params->op,
2682 "Failed to allocate pktmbuf offload");
2684 /* Set crypto operation data parameters */
2685 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2687 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2689 /* set crypto operation source mbuf */
2690 sym_op->m_src = ut_params->ibuf;
2693 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2696 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2697 ut_params->ibuf, auth_tag_len);
2699 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2700 "no room to append auth tag");
2701 ut_params->digest = sym_op->auth.digest.data;
2702 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2703 ut_params->ibuf, data_pad_len);
2704 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2705 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2707 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2709 debug_hexdump(stdout, "digest:",
2710 sym_op->auth.digest.data,
2713 sym_op->auth.data.length = auth_len;
2714 sym_op->auth.data.offset = auth_offset;
2720 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2721 enum rte_crypto_auth_operation op)
2723 struct crypto_testsuite_params *ts_params = &testsuite_params;
2724 struct crypto_unittest_params *ut_params = &unittest_params;
2726 const uint8_t *auth_tag = tdata->digest.data;
2727 const unsigned int auth_tag_len = tdata->digest.len;
2728 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2729 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2731 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2732 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2733 const uint8_t *auth_iv = tdata->auth_iv.data;
2734 const uint8_t auth_iv_len = tdata->auth_iv.len;
2735 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2736 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2738 /* Generate Crypto op data structure */
2739 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2740 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2741 TEST_ASSERT_NOT_NULL(ut_params->op,
2742 "Failed to allocate pktmbuf offload");
2743 /* Set crypto operation data parameters */
2744 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2746 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2748 /* set crypto operation source mbuf */
2749 sym_op->m_src = ut_params->ibuf;
2752 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2753 ut_params->ibuf, auth_tag_len);
2755 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2756 "no room to append auth tag");
2757 ut_params->digest = sym_op->auth.digest.data;
2758 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2759 ut_params->ibuf, data_pad_len);
2760 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2761 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2763 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2765 debug_hexdump(stdout, "digest:",
2766 sym_op->auth.digest.data,
2769 /* Copy cipher and auth IVs at the end of the crypto operation */
2770 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2772 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2773 iv_ptr += cipher_iv_len;
2774 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2776 sym_op->cipher.data.length = cipher_len;
2777 sym_op->cipher.data.offset = 0;
2778 sym_op->auth.data.length = auth_len;
2779 sym_op->auth.data.offset = 0;
2785 create_zuc_cipher_hash_generate_operation(
2786 const struct wireless_test_data *tdata)
2788 return create_wireless_cipher_hash_operation(tdata,
2789 RTE_CRYPTO_AUTH_OP_GENERATE);
2793 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2794 const unsigned auth_tag_len,
2795 const uint8_t *auth_iv, uint8_t auth_iv_len,
2796 unsigned data_pad_len,
2797 enum rte_crypto_auth_operation op,
2798 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2799 const unsigned cipher_len, const unsigned cipher_offset,
2800 const unsigned auth_len, const unsigned auth_offset)
2802 struct crypto_testsuite_params *ts_params = &testsuite_params;
2803 struct crypto_unittest_params *ut_params = &unittest_params;
2805 enum rte_crypto_cipher_algorithm cipher_algo =
2806 ut_params->cipher_xform.cipher.algo;
2807 enum rte_crypto_auth_algorithm auth_algo =
2808 ut_params->auth_xform.auth.algo;
2810 /* Generate Crypto op data structure */
2811 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2812 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2813 TEST_ASSERT_NOT_NULL(ut_params->op,
2814 "Failed to allocate pktmbuf offload");
2815 /* Set crypto operation data parameters */
2816 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2818 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2820 /* set crypto operation source mbuf */
2821 sym_op->m_src = ut_params->ibuf;
2824 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2825 ut_params->ibuf, auth_tag_len);
2827 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2828 "no room to append auth tag");
2829 ut_params->digest = sym_op->auth.digest.data;
2831 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2832 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2833 ut_params->ibuf, data_pad_len);
2835 struct rte_mbuf *m = ut_params->ibuf;
2836 unsigned int offset = data_pad_len;
2838 while (offset > m->data_len && m->next != NULL) {
2839 offset -= m->data_len;
2842 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2846 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2847 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2849 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2851 debug_hexdump(stdout, "digest:",
2852 sym_op->auth.digest.data,
2855 /* Copy cipher and auth IVs at the end of the crypto operation */
2856 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2858 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2859 iv_ptr += cipher_iv_len;
2860 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2862 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2863 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2864 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2865 sym_op->cipher.data.length = cipher_len;
2866 sym_op->cipher.data.offset = cipher_offset;
2868 sym_op->cipher.data.length = cipher_len >> 3;
2869 sym_op->cipher.data.offset = cipher_offset >> 3;
2872 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2873 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2874 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2875 sym_op->auth.data.length = auth_len;
2876 sym_op->auth.data.offset = auth_offset;
2878 sym_op->auth.data.length = auth_len >> 3;
2879 sym_op->auth.data.offset = auth_offset >> 3;
2886 create_wireless_algo_auth_cipher_operation(
2887 const uint8_t *auth_tag, unsigned int auth_tag_len,
2888 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2889 const uint8_t *auth_iv, uint8_t auth_iv_len,
2890 unsigned int data_pad_len,
2891 unsigned int cipher_len, unsigned int cipher_offset,
2892 unsigned int auth_len, unsigned int auth_offset,
2893 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2895 struct crypto_testsuite_params *ts_params = &testsuite_params;
2896 struct crypto_unittest_params *ut_params = &unittest_params;
2898 enum rte_crypto_cipher_algorithm cipher_algo =
2899 ut_params->cipher_xform.cipher.algo;
2900 enum rte_crypto_auth_algorithm auth_algo =
2901 ut_params->auth_xform.auth.algo;
2903 /* Generate Crypto op data structure */
2904 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2905 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2906 TEST_ASSERT_NOT_NULL(ut_params->op,
2907 "Failed to allocate pktmbuf offload");
2909 /* Set crypto operation data parameters */
2910 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2912 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2914 /* set crypto operation mbufs */
2915 sym_op->m_src = ut_params->ibuf;
2916 if (op_mode == OUT_OF_PLACE)
2917 sym_op->m_dst = ut_params->obuf;
2921 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2922 (op_mode == IN_PLACE ?
2923 ut_params->ibuf : ut_params->obuf),
2924 uint8_t *, data_pad_len);
2925 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2926 (op_mode == IN_PLACE ?
2927 ut_params->ibuf : ut_params->obuf),
2929 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2931 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2932 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2933 sym_op->m_src : sym_op->m_dst);
2934 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2935 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2936 sgl_buf = sgl_buf->next;
2938 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2939 uint8_t *, remaining_off);
2940 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2942 memset(sym_op->auth.digest.data, 0, remaining_off);
2943 while (sgl_buf->next != NULL) {
2944 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2945 0, rte_pktmbuf_data_len(sgl_buf));
2946 sgl_buf = sgl_buf->next;
2950 /* Copy digest for the verification */
2952 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2954 /* Copy cipher and auth IVs at the end of the crypto operation */
2955 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2956 ut_params->op, uint8_t *, IV_OFFSET);
2958 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2959 iv_ptr += cipher_iv_len;
2960 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2962 /* Only copy over the offset data needed from src to dst in OOP,
2963 * if the auth and cipher offsets are not aligned
2965 if (op_mode == OUT_OF_PLACE) {
2966 if (cipher_offset > auth_offset)
2968 rte_pktmbuf_mtod_offset(
2970 uint8_t *, auth_offset >> 3),
2971 rte_pktmbuf_mtod_offset(
2973 uint8_t *, auth_offset >> 3),
2974 ((cipher_offset >> 3) - (auth_offset >> 3)));
2977 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2978 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2979 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2980 sym_op->cipher.data.length = cipher_len;
2981 sym_op->cipher.data.offset = cipher_offset;
2983 sym_op->cipher.data.length = cipher_len >> 3;
2984 sym_op->cipher.data.offset = cipher_offset >> 3;
2987 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2988 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2989 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2990 sym_op->auth.data.length = auth_len;
2991 sym_op->auth.data.offset = auth_offset;
2993 sym_op->auth.data.length = auth_len >> 3;
2994 sym_op->auth.data.offset = auth_offset >> 3;
3001 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3003 struct crypto_testsuite_params *ts_params = &testsuite_params;
3004 struct crypto_unittest_params *ut_params = &unittest_params;
3007 unsigned plaintext_pad_len;
3008 unsigned plaintext_len;
3010 struct rte_cryptodev_info dev_info;
3012 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3013 uint64_t feat_flags = dev_info.feature_flags;
3015 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3016 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3017 printf("Device doesn't support NON-Byte Aligned Data.\n");
3018 return TEST_SKIPPED;
3021 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3022 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3023 printf("Device doesn't support RAW data-path APIs.\n");
3024 return TEST_SKIPPED;
3027 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3028 return TEST_SKIPPED;
3030 /* Verify the capabilities */
3031 struct rte_cryptodev_sym_capability_idx cap_idx;
3032 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3033 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3034 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3036 return TEST_SKIPPED;
3038 /* Create SNOW 3G session */
3039 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3040 tdata->key.data, tdata->key.len,
3041 tdata->auth_iv.len, tdata->digest.len,
3042 RTE_CRYPTO_AUTH_OP_GENERATE,
3043 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3047 /* alloc mbuf and set payload */
3048 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3050 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3051 rte_pktmbuf_tailroom(ut_params->ibuf));
3053 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3054 /* Append data which is padded to a multiple of */
3055 /* the algorithms block size */
3056 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3057 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3059 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3061 /* Create SNOW 3G operation */
3062 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3063 tdata->auth_iv.data, tdata->auth_iv.len,
3064 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3065 tdata->validAuthLenInBits.len,
3070 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3071 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3072 ut_params->op, 0, 1, 1, 0);
3074 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3076 ut_params->obuf = ut_params->op->sym->m_src;
3077 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3078 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3079 + plaintext_pad_len;
3082 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3085 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3086 "SNOW 3G Generated auth tag not as expected");
3092 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3094 struct crypto_testsuite_params *ts_params = &testsuite_params;
3095 struct crypto_unittest_params *ut_params = &unittest_params;
3098 unsigned plaintext_pad_len;
3099 unsigned plaintext_len;
3101 struct rte_cryptodev_info dev_info;
3103 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3104 uint64_t feat_flags = dev_info.feature_flags;
3106 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3107 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3108 printf("Device doesn't support NON-Byte Aligned Data.\n");
3109 return TEST_SKIPPED;
3112 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3113 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3114 printf("Device doesn't support RAW data-path APIs.\n");
3115 return TEST_SKIPPED;
3118 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3119 return TEST_SKIPPED;
3121 /* Verify the capabilities */
3122 struct rte_cryptodev_sym_capability_idx cap_idx;
3123 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3124 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3125 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3127 return TEST_SKIPPED;
3129 /* Create SNOW 3G session */
3130 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3131 tdata->key.data, tdata->key.len,
3132 tdata->auth_iv.len, tdata->digest.len,
3133 RTE_CRYPTO_AUTH_OP_VERIFY,
3134 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3137 /* alloc mbuf and set payload */
3138 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3140 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3141 rte_pktmbuf_tailroom(ut_params->ibuf));
3143 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3144 /* Append data which is padded to a multiple of */
3145 /* the algorithms block size */
3146 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3147 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3149 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3151 /* Create SNOW 3G operation */
3152 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3154 tdata->auth_iv.data, tdata->auth_iv.len,
3156 RTE_CRYPTO_AUTH_OP_VERIFY,
3157 tdata->validAuthLenInBits.len,
3162 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3163 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3164 ut_params->op, 0, 1, 1, 0);
3166 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3168 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3169 ut_params->obuf = ut_params->op->sym->m_src;
3170 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3171 + plaintext_pad_len;
3174 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3183 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3185 struct crypto_testsuite_params *ts_params = &testsuite_params;
3186 struct crypto_unittest_params *ut_params = &unittest_params;
3189 unsigned plaintext_pad_len;
3190 unsigned plaintext_len;
3192 struct rte_cryptodev_info dev_info;
3194 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3195 uint64_t feat_flags = dev_info.feature_flags;
3197 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3198 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3199 printf("Device doesn't support RAW data-path APIs.\n");
3200 return TEST_SKIPPED;
3203 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3204 return TEST_SKIPPED;
3206 /* Verify the capabilities */
3207 struct rte_cryptodev_sym_capability_idx cap_idx;
3208 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3209 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3210 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3212 return TEST_SKIPPED;
3214 /* Create KASUMI session */
3215 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3216 tdata->key.data, tdata->key.len,
3217 0, tdata->digest.len,
3218 RTE_CRYPTO_AUTH_OP_GENERATE,
3219 RTE_CRYPTO_AUTH_KASUMI_F9);
3223 /* alloc mbuf and set payload */
3224 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3226 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3227 rte_pktmbuf_tailroom(ut_params->ibuf));
3229 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3230 /* Append data which is padded to a multiple of */
3231 /* the algorithms block size */
3232 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3233 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3235 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3237 /* Create KASUMI operation */
3238 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3240 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3241 tdata->plaintext.len,
3246 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3247 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3249 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3250 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3251 ut_params->op, 0, 1, 1, 0);
3253 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3256 ut_params->obuf = ut_params->op->sym->m_src;
3257 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3258 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3259 + plaintext_pad_len;
3262 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3265 DIGEST_BYTE_LENGTH_KASUMI_F9,
3266 "KASUMI Generated auth tag not as expected");
3272 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3274 struct crypto_testsuite_params *ts_params = &testsuite_params;
3275 struct crypto_unittest_params *ut_params = &unittest_params;
3278 unsigned plaintext_pad_len;
3279 unsigned plaintext_len;
3281 struct rte_cryptodev_info dev_info;
3283 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3284 uint64_t feat_flags = dev_info.feature_flags;
3286 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3287 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3288 printf("Device doesn't support RAW data-path APIs.\n");
3289 return TEST_SKIPPED;
3292 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3293 return TEST_SKIPPED;
3295 /* Verify the capabilities */
3296 struct rte_cryptodev_sym_capability_idx cap_idx;
3297 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3298 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3299 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3301 return TEST_SKIPPED;
3303 /* Create KASUMI session */
3304 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3305 tdata->key.data, tdata->key.len,
3306 0, tdata->digest.len,
3307 RTE_CRYPTO_AUTH_OP_VERIFY,
3308 RTE_CRYPTO_AUTH_KASUMI_F9);
3311 /* alloc mbuf and set payload */
3312 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3314 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3315 rte_pktmbuf_tailroom(ut_params->ibuf));
3317 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3318 /* Append data which is padded to a multiple */
3319 /* of the algorithms block size */
3320 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3321 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3323 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3325 /* Create KASUMI operation */
3326 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3330 RTE_CRYPTO_AUTH_OP_VERIFY,
3331 tdata->plaintext.len,
3336 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3337 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3338 ut_params->op, 0, 1, 1, 0);
3340 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3342 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3343 ut_params->obuf = ut_params->op->sym->m_src;
3344 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3345 + plaintext_pad_len;
3348 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3357 test_snow3g_hash_generate_test_case_1(void)
3359 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3363 test_snow3g_hash_generate_test_case_2(void)
3365 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3369 test_snow3g_hash_generate_test_case_3(void)
3371 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3375 test_snow3g_hash_generate_test_case_4(void)
3377 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3381 test_snow3g_hash_generate_test_case_5(void)
3383 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3387 test_snow3g_hash_generate_test_case_6(void)
3389 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3393 test_snow3g_hash_verify_test_case_1(void)
3395 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3400 test_snow3g_hash_verify_test_case_2(void)
3402 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3406 test_snow3g_hash_verify_test_case_3(void)
3408 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3412 test_snow3g_hash_verify_test_case_4(void)
3414 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3418 test_snow3g_hash_verify_test_case_5(void)
3420 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3424 test_snow3g_hash_verify_test_case_6(void)
3426 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3430 test_kasumi_hash_generate_test_case_1(void)
3432 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3436 test_kasumi_hash_generate_test_case_2(void)
3438 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3442 test_kasumi_hash_generate_test_case_3(void)
3444 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3448 test_kasumi_hash_generate_test_case_4(void)
3450 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3454 test_kasumi_hash_generate_test_case_5(void)
3456 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3460 test_kasumi_hash_generate_test_case_6(void)
3462 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3466 test_kasumi_hash_verify_test_case_1(void)
3468 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3472 test_kasumi_hash_verify_test_case_2(void)
3474 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3478 test_kasumi_hash_verify_test_case_3(void)
3480 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3484 test_kasumi_hash_verify_test_case_4(void)
3486 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3490 test_kasumi_hash_verify_test_case_5(void)
3492 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3496 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3498 struct crypto_testsuite_params *ts_params = &testsuite_params;
3499 struct crypto_unittest_params *ut_params = &unittest_params;
3502 uint8_t *plaintext, *ciphertext;
3503 unsigned plaintext_pad_len;
3504 unsigned plaintext_len;
3505 struct rte_cryptodev_info dev_info;
3507 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3508 uint64_t feat_flags = dev_info.feature_flags;
3510 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3511 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3512 printf("Device doesn't support RAW data-path APIs.\n");
3513 return TEST_SKIPPED;
3516 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3517 return TEST_SKIPPED;
3519 /* Verify the capabilities */
3520 struct rte_cryptodev_sym_capability_idx cap_idx;
3521 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3522 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3523 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3525 return TEST_SKIPPED;
3527 /* Create KASUMI session */
3528 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3529 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3530 RTE_CRYPTO_CIPHER_KASUMI_F8,
3531 tdata->key.data, tdata->key.len,
3532 tdata->cipher_iv.len);
3536 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3538 /* Clear mbuf payload */
3539 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3540 rte_pktmbuf_tailroom(ut_params->ibuf));
3542 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3543 /* Append data which is padded to a multiple */
3544 /* of the algorithms block size */
3545 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3546 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3548 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3550 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3552 /* Create KASUMI operation */
3553 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3554 tdata->cipher_iv.len,
3555 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3556 tdata->validCipherOffsetInBits.len);
3560 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3561 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3562 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3564 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3566 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3568 ut_params->obuf = ut_params->op->sym->m_dst;
3569 if (ut_params->obuf)
3570 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3572 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3574 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3576 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3577 (tdata->validCipherOffsetInBits.len >> 3);
3579 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3581 reference_ciphertext,
3582 tdata->validCipherLenInBits.len,
3583 "KASUMI Ciphertext data not as expected");
3588 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3590 struct crypto_testsuite_params *ts_params = &testsuite_params;
3591 struct crypto_unittest_params *ut_params = &unittest_params;
3595 unsigned int plaintext_pad_len;
3596 unsigned int plaintext_len;
3598 uint8_t buffer[10000];
3599 const uint8_t *ciphertext;
3601 struct rte_cryptodev_info dev_info;
3603 /* Verify the capabilities */
3604 struct rte_cryptodev_sym_capability_idx cap_idx;
3605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3606 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3609 return TEST_SKIPPED;
3611 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3613 uint64_t feat_flags = dev_info.feature_flags;
3615 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3616 printf("Device doesn't support in-place scatter-gather. "
3618 return TEST_SKIPPED;
3621 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3622 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3623 printf("Device doesn't support RAW data-path APIs.\n");
3624 return TEST_SKIPPED;
3627 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3628 return TEST_SKIPPED;
3630 /* Create KASUMI session */
3631 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3632 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3633 RTE_CRYPTO_CIPHER_KASUMI_F8,
3634 tdata->key.data, tdata->key.len,
3635 tdata->cipher_iv.len);
3639 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3642 /* Append data which is padded to a multiple */
3643 /* of the algorithms block size */
3644 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3646 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3647 plaintext_pad_len, 10, 0);
3649 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3651 /* Create KASUMI operation */
3652 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3653 tdata->cipher_iv.len,
3654 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3655 tdata->validCipherOffsetInBits.len);
3659 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3660 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3661 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3663 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3665 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3667 ut_params->obuf = ut_params->op->sym->m_dst;
3669 if (ut_params->obuf)
3670 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3671 plaintext_len, buffer);
3673 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3674 tdata->validCipherOffsetInBits.len >> 3,
3675 plaintext_len, buffer);
3678 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3680 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3681 (tdata->validCipherOffsetInBits.len >> 3);
3683 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3685 reference_ciphertext,
3686 tdata->validCipherLenInBits.len,
3687 "KASUMI Ciphertext data not as expected");
3692 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3694 struct crypto_testsuite_params *ts_params = &testsuite_params;
3695 struct crypto_unittest_params *ut_params = &unittest_params;
3698 uint8_t *plaintext, *ciphertext;
3699 unsigned plaintext_pad_len;
3700 unsigned plaintext_len;
3702 /* Verify the capabilities */
3703 struct rte_cryptodev_sym_capability_idx cap_idx;
3704 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3705 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3706 /* Data-path service does not support OOP */
3707 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3709 return TEST_SKIPPED;
3711 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3712 return TEST_SKIPPED;
3714 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3715 return TEST_SKIPPED;
3717 /* Create KASUMI session */
3718 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3719 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3720 RTE_CRYPTO_CIPHER_KASUMI_F8,
3721 tdata->key.data, tdata->key.len,
3722 tdata->cipher_iv.len);
3726 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3727 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3729 /* Clear mbuf payload */
3730 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3731 rte_pktmbuf_tailroom(ut_params->ibuf));
3733 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3734 /* Append data which is padded to a multiple */
3735 /* of the algorithms block size */
3736 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3737 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3739 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3740 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3742 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3744 /* Create KASUMI operation */
3745 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3746 tdata->cipher_iv.len,
3747 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3748 tdata->validCipherOffsetInBits.len);
3752 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3754 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3756 ut_params->obuf = ut_params->op->sym->m_dst;
3757 if (ut_params->obuf)
3758 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3760 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3762 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3764 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3765 (tdata->validCipherOffsetInBits.len >> 3);
3767 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3769 reference_ciphertext,
3770 tdata->validCipherLenInBits.len,
3771 "KASUMI Ciphertext data not as expected");
3776 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3778 struct crypto_testsuite_params *ts_params = &testsuite_params;
3779 struct crypto_unittest_params *ut_params = &unittest_params;
3782 unsigned int plaintext_pad_len;
3783 unsigned int plaintext_len;
3785 const uint8_t *ciphertext;
3786 uint8_t buffer[2048];
3788 struct rte_cryptodev_info dev_info;
3790 /* Verify the capabilities */
3791 struct rte_cryptodev_sym_capability_idx cap_idx;
3792 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3793 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3794 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3796 return TEST_SKIPPED;
3798 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3799 return TEST_SKIPPED;
3801 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3802 return TEST_SKIPPED;
3804 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3806 uint64_t feat_flags = dev_info.feature_flags;
3807 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3808 printf("Device doesn't support out-of-place scatter-gather "
3809 "in both input and output mbufs. "
3811 return TEST_SKIPPED;
3814 /* Create KASUMI session */
3815 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3816 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3817 RTE_CRYPTO_CIPHER_KASUMI_F8,
3818 tdata->key.data, tdata->key.len,
3819 tdata->cipher_iv.len);
3823 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3824 /* Append data which is padded to a multiple */
3825 /* of the algorithms block size */
3826 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3828 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3829 plaintext_pad_len, 10, 0);
3830 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3831 plaintext_pad_len, 3, 0);
3833 /* Append data which is padded to a multiple */
3834 /* of the algorithms block size */
3835 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3837 /* Create KASUMI operation */
3838 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3839 tdata->cipher_iv.len,
3840 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3841 tdata->validCipherOffsetInBits.len);
3845 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3847 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3849 ut_params->obuf = ut_params->op->sym->m_dst;
3850 if (ut_params->obuf)
3851 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3852 plaintext_pad_len, buffer);
3854 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3855 tdata->validCipherOffsetInBits.len >> 3,
3856 plaintext_pad_len, buffer);
3858 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3859 (tdata->validCipherOffsetInBits.len >> 3);
3861 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3863 reference_ciphertext,
3864 tdata->validCipherLenInBits.len,
3865 "KASUMI Ciphertext data not as expected");
3871 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3873 struct crypto_testsuite_params *ts_params = &testsuite_params;
3874 struct crypto_unittest_params *ut_params = &unittest_params;
3877 uint8_t *ciphertext, *plaintext;
3878 unsigned ciphertext_pad_len;
3879 unsigned ciphertext_len;
3881 /* Verify the capabilities */
3882 struct rte_cryptodev_sym_capability_idx cap_idx;
3883 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3884 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3885 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3887 return TEST_SKIPPED;
3889 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3890 return TEST_SKIPPED;
3892 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3893 return TEST_SKIPPED;
3895 /* Create KASUMI session */
3896 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3897 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3898 RTE_CRYPTO_CIPHER_KASUMI_F8,
3899 tdata->key.data, tdata->key.len,
3900 tdata->cipher_iv.len);
3904 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3905 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3907 /* Clear mbuf payload */
3908 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3909 rte_pktmbuf_tailroom(ut_params->ibuf));
3911 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3912 /* Append data which is padded to a multiple */
3913 /* of the algorithms block size */
3914 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3915 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3916 ciphertext_pad_len);
3917 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3918 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3920 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3922 /* Create KASUMI operation */
3923 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3924 tdata->cipher_iv.len,
3925 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3926 tdata->validCipherOffsetInBits.len);
3930 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3932 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3934 ut_params->obuf = ut_params->op->sym->m_dst;
3935 if (ut_params->obuf)
3936 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3938 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3940 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3942 const uint8_t *reference_plaintext = tdata->plaintext.data +
3943 (tdata->validCipherOffsetInBits.len >> 3);
3945 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3947 reference_plaintext,
3948 tdata->validCipherLenInBits.len,
3949 "KASUMI Plaintext data not as expected");
3954 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3956 struct crypto_testsuite_params *ts_params = &testsuite_params;
3957 struct crypto_unittest_params *ut_params = &unittest_params;
3960 uint8_t *ciphertext, *plaintext;
3961 unsigned ciphertext_pad_len;
3962 unsigned ciphertext_len;
3963 struct rte_cryptodev_info dev_info;
3965 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3966 uint64_t feat_flags = dev_info.feature_flags;
3968 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3969 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3970 printf("Device doesn't support RAW data-path APIs.\n");
3971 return TEST_SKIPPED;
3974 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3975 return TEST_SKIPPED;
3977 /* Verify the capabilities */
3978 struct rte_cryptodev_sym_capability_idx cap_idx;
3979 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3980 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3981 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3983 return TEST_SKIPPED;
3985 /* Create KASUMI session */
3986 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3987 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3988 RTE_CRYPTO_CIPHER_KASUMI_F8,
3989 tdata->key.data, tdata->key.len,
3990 tdata->cipher_iv.len);
3994 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3996 /* Clear mbuf payload */
3997 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3998 rte_pktmbuf_tailroom(ut_params->ibuf));
4000 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4001 /* Append data which is padded to a multiple */
4002 /* of the algorithms block size */
4003 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4004 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4005 ciphertext_pad_len);
4006 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4008 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4010 /* Create KASUMI operation */
4011 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4012 tdata->cipher_iv.len,
4013 tdata->ciphertext.len,
4014 tdata->validCipherOffsetInBits.len);
4018 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4019 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4020 ut_params->op, 1, 0, 1, 0);
4022 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4024 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4026 ut_params->obuf = ut_params->op->sym->m_dst;
4027 if (ut_params->obuf)
4028 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4030 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4032 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4034 const uint8_t *reference_plaintext = tdata->plaintext.data +
4035 (tdata->validCipherOffsetInBits.len >> 3);
4037 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4039 reference_plaintext,
4040 tdata->validCipherLenInBits.len,
4041 "KASUMI Plaintext data not as expected");
4046 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4048 struct crypto_testsuite_params *ts_params = &testsuite_params;
4049 struct crypto_unittest_params *ut_params = &unittest_params;
4052 uint8_t *plaintext, *ciphertext;
4053 unsigned plaintext_pad_len;
4054 unsigned plaintext_len;
4055 struct rte_cryptodev_info dev_info;
4057 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4058 uint64_t feat_flags = dev_info.feature_flags;
4060 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4061 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4062 printf("Device doesn't support RAW data-path APIs.\n");
4063 return TEST_SKIPPED;
4066 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4067 return TEST_SKIPPED;
4069 /* Verify the capabilities */
4070 struct rte_cryptodev_sym_capability_idx cap_idx;
4071 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4072 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4073 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4075 return TEST_SKIPPED;
4077 /* Create SNOW 3G session */
4078 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4079 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4080 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4081 tdata->key.data, tdata->key.len,
4082 tdata->cipher_iv.len);
4086 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4088 /* Clear mbuf payload */
4089 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4090 rte_pktmbuf_tailroom(ut_params->ibuf));
4092 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4093 /* Append data which is padded to a multiple of */
4094 /* the algorithms block size */
4095 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4096 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4098 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4100 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4102 /* Create SNOW 3G operation */
4103 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4104 tdata->cipher_iv.len,
4105 tdata->validCipherLenInBits.len,
4110 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4111 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4112 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4114 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4116 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4118 ut_params->obuf = ut_params->op->sym->m_dst;
4119 if (ut_params->obuf)
4120 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4122 ciphertext = plaintext;
4124 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4127 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4129 tdata->ciphertext.data,
4130 tdata->validDataLenInBits.len,
4131 "SNOW 3G Ciphertext data not as expected");
4137 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4139 struct crypto_testsuite_params *ts_params = &testsuite_params;
4140 struct crypto_unittest_params *ut_params = &unittest_params;
4141 uint8_t *plaintext, *ciphertext;
4144 unsigned plaintext_pad_len;
4145 unsigned plaintext_len;
4147 /* Verify the capabilities */
4148 struct rte_cryptodev_sym_capability_idx cap_idx;
4149 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4150 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4151 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4153 return TEST_SKIPPED;
4155 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4156 return TEST_SKIPPED;
4158 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4159 return TEST_SKIPPED;
4161 /* Create SNOW 3G session */
4162 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4163 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4164 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4165 tdata->key.data, tdata->key.len,
4166 tdata->cipher_iv.len);
4170 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4171 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4173 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4174 "Failed to allocate input buffer in mempool");
4175 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4176 "Failed to allocate output buffer in mempool");
4178 /* Clear mbuf payload */
4179 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4180 rte_pktmbuf_tailroom(ut_params->ibuf));
4182 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4183 /* Append data which is padded to a multiple of */
4184 /* the algorithms block size */
4185 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4186 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4188 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4189 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4191 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4193 /* Create SNOW 3G operation */
4194 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4195 tdata->cipher_iv.len,
4196 tdata->validCipherLenInBits.len,
4201 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4203 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4205 ut_params->obuf = ut_params->op->sym->m_dst;
4206 if (ut_params->obuf)
4207 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4209 ciphertext = plaintext;
4211 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4214 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4216 tdata->ciphertext.data,
4217 tdata->validDataLenInBits.len,
4218 "SNOW 3G Ciphertext data not as expected");
4223 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4225 struct crypto_testsuite_params *ts_params = &testsuite_params;
4226 struct crypto_unittest_params *ut_params = &unittest_params;
4229 unsigned int plaintext_pad_len;
4230 unsigned int plaintext_len;
4231 uint8_t buffer[10000];
4232 const uint8_t *ciphertext;
4234 struct rte_cryptodev_info dev_info;
4236 /* Verify the capabilities */
4237 struct rte_cryptodev_sym_capability_idx cap_idx;
4238 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4239 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4240 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4242 return TEST_SKIPPED;
4244 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4245 return TEST_SKIPPED;
4247 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4248 return TEST_SKIPPED;
4250 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4252 uint64_t feat_flags = dev_info.feature_flags;
4254 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4255 printf("Device doesn't support out-of-place scatter-gather "
4256 "in both input and output mbufs. "
4258 return TEST_SKIPPED;
4261 /* Create SNOW 3G session */
4262 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4263 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4264 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4265 tdata->key.data, tdata->key.len,
4266 tdata->cipher_iv.len);
4270 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4271 /* Append data which is padded to a multiple of */
4272 /* the algorithms block size */
4273 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4275 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4276 plaintext_pad_len, 10, 0);
4277 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4278 plaintext_pad_len, 3, 0);
4280 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4281 "Failed to allocate input buffer in mempool");
4282 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4283 "Failed to allocate output buffer in mempool");
4285 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4287 /* Create SNOW 3G operation */
4288 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4289 tdata->cipher_iv.len,
4290 tdata->validCipherLenInBits.len,
4295 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4297 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4299 ut_params->obuf = ut_params->op->sym->m_dst;
4300 if (ut_params->obuf)
4301 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4302 plaintext_len, buffer);
4304 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4305 plaintext_len, buffer);
4307 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4310 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4312 tdata->ciphertext.data,
4313 tdata->validDataLenInBits.len,
4314 "SNOW 3G Ciphertext data not as expected");
4319 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4321 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4323 uint8_t curr_byte, prev_byte;
4324 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4325 uint8_t lower_byte_mask = (1 << offset) - 1;
4328 prev_byte = buffer[0];
4329 buffer[0] >>= offset;
4331 for (i = 1; i < length_in_bytes; i++) {
4332 curr_byte = buffer[i];
4333 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4334 (curr_byte >> offset);
4335 prev_byte = curr_byte;
4340 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4342 struct crypto_testsuite_params *ts_params = &testsuite_params;
4343 struct crypto_unittest_params *ut_params = &unittest_params;
4344 uint8_t *plaintext, *ciphertext;
4346 uint32_t plaintext_len;
4347 uint32_t plaintext_pad_len;
4348 uint8_t extra_offset = 4;
4349 uint8_t *expected_ciphertext_shifted;
4350 struct rte_cryptodev_info dev_info;
4352 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4353 uint64_t feat_flags = dev_info.feature_flags;
4355 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4356 ((tdata->validDataLenInBits.len % 8) != 0)) {
4357 printf("Device doesn't support NON-Byte Aligned Data.\n");
4358 return TEST_SKIPPED;
4361 /* Verify the capabilities */
4362 struct rte_cryptodev_sym_capability_idx cap_idx;
4363 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4364 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4365 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4367 return TEST_SKIPPED;
4369 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4370 return TEST_SKIPPED;
4372 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4373 return TEST_SKIPPED;
4375 /* Create SNOW 3G session */
4376 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4377 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4378 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4379 tdata->key.data, tdata->key.len,
4380 tdata->cipher_iv.len);
4384 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4385 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4387 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4388 "Failed to allocate input buffer in mempool");
4389 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4390 "Failed to allocate output buffer in mempool");
4392 /* Clear mbuf payload */
4393 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4394 rte_pktmbuf_tailroom(ut_params->ibuf));
4396 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4398 * Append data which is padded to a
4399 * multiple of the algorithms block size
4401 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4403 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4406 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4408 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4409 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4411 #ifdef RTE_APP_TEST_DEBUG
4412 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4414 /* Create SNOW 3G operation */
4415 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4416 tdata->cipher_iv.len,
4417 tdata->validCipherLenInBits.len,
4422 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4424 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4426 ut_params->obuf = ut_params->op->sym->m_dst;
4427 if (ut_params->obuf)
4428 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4430 ciphertext = plaintext;
4432 #ifdef RTE_APP_TEST_DEBUG
4433 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4436 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4438 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4439 "failed to reserve memory for ciphertext shifted\n");
4441 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4442 ceil_byte_length(tdata->ciphertext.len));
4443 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4446 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4448 expected_ciphertext_shifted,
4449 tdata->validDataLenInBits.len,
4451 "SNOW 3G Ciphertext data not as expected");
4455 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4457 struct crypto_testsuite_params *ts_params = &testsuite_params;
4458 struct crypto_unittest_params *ut_params = &unittest_params;
4462 uint8_t *plaintext, *ciphertext;
4463 unsigned ciphertext_pad_len;
4464 unsigned ciphertext_len;
4465 struct rte_cryptodev_info dev_info;
4467 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4468 uint64_t feat_flags = dev_info.feature_flags;
4470 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4471 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4472 printf("Device doesn't support RAW data-path APIs.\n");
4473 return TEST_SKIPPED;
4476 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4477 return TEST_SKIPPED;
4479 /* Verify the capabilities */
4480 struct rte_cryptodev_sym_capability_idx cap_idx;
4481 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4482 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4483 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4485 return TEST_SKIPPED;
4487 /* Create SNOW 3G session */
4488 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4489 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4490 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4491 tdata->key.data, tdata->key.len,
4492 tdata->cipher_iv.len);
4496 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4498 /* Clear mbuf payload */
4499 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4500 rte_pktmbuf_tailroom(ut_params->ibuf));
4502 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4503 /* Append data which is padded to a multiple of */
4504 /* the algorithms block size */
4505 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4506 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4507 ciphertext_pad_len);
4508 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4510 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4512 /* Create SNOW 3G operation */
4513 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4514 tdata->cipher_iv.len,
4515 tdata->validCipherLenInBits.len,
4516 tdata->cipher.offset_bits);
4520 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4521 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4522 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4524 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4526 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4527 ut_params->obuf = ut_params->op->sym->m_dst;
4528 if (ut_params->obuf)
4529 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4531 plaintext = ciphertext;
4533 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4536 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4537 tdata->plaintext.data,
4538 tdata->validDataLenInBits.len,
4539 "SNOW 3G Plaintext data not as expected");
4543 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4545 struct crypto_testsuite_params *ts_params = &testsuite_params;
4546 struct crypto_unittest_params *ut_params = &unittest_params;
4550 uint8_t *plaintext, *ciphertext;
4551 unsigned ciphertext_pad_len;
4552 unsigned ciphertext_len;
4554 /* Verify the capabilities */
4555 struct rte_cryptodev_sym_capability_idx cap_idx;
4556 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4557 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4558 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4560 return TEST_SKIPPED;
4562 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4563 return TEST_SKIPPED;
4565 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4566 return TEST_SKIPPED;
4568 /* Create SNOW 3G session */
4569 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4570 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4571 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4572 tdata->key.data, tdata->key.len,
4573 tdata->cipher_iv.len);
4577 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4578 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4580 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4581 "Failed to allocate input buffer");
4582 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4583 "Failed to allocate output buffer");
4585 /* Clear mbuf payload */
4586 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4587 rte_pktmbuf_tailroom(ut_params->ibuf));
4589 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4590 rte_pktmbuf_tailroom(ut_params->obuf));
4592 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4593 /* Append data which is padded to a multiple of */
4594 /* the algorithms block size */
4595 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4596 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4597 ciphertext_pad_len);
4598 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4599 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4601 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4603 /* Create SNOW 3G operation */
4604 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4605 tdata->cipher_iv.len,
4606 tdata->validCipherLenInBits.len,
4611 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4613 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4614 ut_params->obuf = ut_params->op->sym->m_dst;
4615 if (ut_params->obuf)
4616 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4618 plaintext = ciphertext;
4620 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4623 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4624 tdata->plaintext.data,
4625 tdata->validDataLenInBits.len,
4626 "SNOW 3G Plaintext data not as expected");
4631 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4633 struct crypto_testsuite_params *ts_params = &testsuite_params;
4634 struct crypto_unittest_params *ut_params = &unittest_params;
4638 uint8_t *plaintext, *ciphertext;
4639 unsigned int plaintext_pad_len;
4640 unsigned int plaintext_len;
4642 struct rte_cryptodev_info dev_info;
4643 struct rte_cryptodev_sym_capability_idx cap_idx;
4645 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4646 uint64_t feat_flags = dev_info.feature_flags;
4648 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4649 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4650 (tdata->validDataLenInBits.len % 8 != 0))) {
4651 printf("Device doesn't support NON-Byte Aligned Data.\n");
4652 return TEST_SKIPPED;
4655 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4656 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4657 printf("Device doesn't support RAW data-path APIs.\n");
4658 return TEST_SKIPPED;
4661 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4662 return TEST_SKIPPED;
4664 /* Check if device supports ZUC EEA3 */
4665 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4666 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4668 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4670 return TEST_SKIPPED;
4672 /* Check if device supports ZUC EIA3 */
4673 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4674 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4676 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4678 return TEST_SKIPPED;
4680 /* Create ZUC session */
4681 retval = create_zuc_cipher_auth_encrypt_generate_session(
4682 ts_params->valid_devs[0],
4686 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4688 /* clear mbuf payload */
4689 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4690 rte_pktmbuf_tailroom(ut_params->ibuf));
4692 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4693 /* Append data which is padded to a multiple of */
4694 /* the algorithms block size */
4695 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4696 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4698 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4700 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4702 /* Create ZUC operation */
4703 retval = create_zuc_cipher_hash_generate_operation(tdata);
4707 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4708 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4709 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4711 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4713 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4714 ut_params->obuf = ut_params->op->sym->m_src;
4715 if (ut_params->obuf)
4716 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4718 ciphertext = plaintext;
4720 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4722 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4724 tdata->ciphertext.data,
4725 tdata->validDataLenInBits.len,
4726 "ZUC Ciphertext data not as expected");
4728 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4729 + plaintext_pad_len;
4732 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4736 "ZUC Generated auth tag not as expected");
4741 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4743 struct crypto_testsuite_params *ts_params = &testsuite_params;
4744 struct crypto_unittest_params *ut_params = &unittest_params;
4748 uint8_t *plaintext, *ciphertext;
4749 unsigned plaintext_pad_len;
4750 unsigned plaintext_len;
4751 struct rte_cryptodev_info dev_info;
4753 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4754 uint64_t feat_flags = dev_info.feature_flags;
4756 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4757 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4758 printf("Device doesn't support RAW data-path APIs.\n");
4759 return TEST_SKIPPED;
4762 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4763 return TEST_SKIPPED;
4765 /* Verify the capabilities */
4766 struct rte_cryptodev_sym_capability_idx cap_idx;
4767 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4768 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4769 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4771 return TEST_SKIPPED;
4772 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4773 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4774 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4776 return TEST_SKIPPED;
4778 /* Create SNOW 3G session */
4779 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4780 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4781 RTE_CRYPTO_AUTH_OP_GENERATE,
4782 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4783 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4784 tdata->key.data, tdata->key.len,
4785 tdata->auth_iv.len, tdata->digest.len,
4786 tdata->cipher_iv.len);
4789 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4791 /* clear mbuf payload */
4792 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4793 rte_pktmbuf_tailroom(ut_params->ibuf));
4795 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4796 /* Append data which is padded to a multiple of */
4797 /* the algorithms block size */
4798 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4799 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4801 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4803 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4805 /* Create SNOW 3G operation */
4806 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4807 tdata->digest.len, tdata->auth_iv.data,
4809 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4810 tdata->cipher_iv.data, tdata->cipher_iv.len,
4811 tdata->validCipherLenInBits.len,
4813 tdata->validAuthLenInBits.len,
4819 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4820 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4821 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4823 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4825 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4826 ut_params->obuf = ut_params->op->sym->m_src;
4827 if (ut_params->obuf)
4828 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4830 ciphertext = plaintext;
4832 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4834 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4836 tdata->ciphertext.data,
4837 tdata->validDataLenInBits.len,
4838 "SNOW 3G Ciphertext data not as expected");
4840 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4841 + plaintext_pad_len;
4844 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4847 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4848 "SNOW 3G Generated auth tag not as expected");
4853 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4854 uint8_t op_mode, uint8_t verify)
4856 struct crypto_testsuite_params *ts_params = &testsuite_params;
4857 struct crypto_unittest_params *ut_params = &unittest_params;
4861 uint8_t *plaintext = NULL, *ciphertext = NULL;
4862 unsigned int plaintext_pad_len;
4863 unsigned int plaintext_len;
4864 unsigned int ciphertext_pad_len;
4865 unsigned int ciphertext_len;
4867 struct rte_cryptodev_info dev_info;
4869 /* Verify the capabilities */
4870 struct rte_cryptodev_sym_capability_idx cap_idx;
4871 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4872 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4873 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4875 return TEST_SKIPPED;
4876 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4877 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4878 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4880 return TEST_SKIPPED;
4882 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4883 return TEST_SKIPPED;
4885 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4887 uint64_t feat_flags = dev_info.feature_flags;
4889 if (op_mode == OUT_OF_PLACE) {
4890 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4891 printf("Device doesn't support digest encrypted.\n");
4892 return TEST_SKIPPED;
4894 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4895 return TEST_SKIPPED;
4898 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4899 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4900 printf("Device doesn't support RAW data-path APIs.\n");
4901 return TEST_SKIPPED;
4904 /* Create SNOW 3G session */
4905 retval = create_wireless_algo_auth_cipher_session(
4906 ts_params->valid_devs[0],
4907 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4908 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4909 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4910 : RTE_CRYPTO_AUTH_OP_GENERATE),
4911 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4912 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4913 tdata->key.data, tdata->key.len,
4914 tdata->auth_iv.len, tdata->digest.len,
4915 tdata->cipher_iv.len);
4919 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4920 if (op_mode == OUT_OF_PLACE)
4921 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4923 /* clear mbuf payload */
4924 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4925 rte_pktmbuf_tailroom(ut_params->ibuf));
4926 if (op_mode == OUT_OF_PLACE)
4927 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4928 rte_pktmbuf_tailroom(ut_params->obuf));
4930 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4931 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4932 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4933 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4936 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4937 ciphertext_pad_len);
4938 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4939 if (op_mode == OUT_OF_PLACE)
4940 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4941 debug_hexdump(stdout, "ciphertext:", ciphertext,
4944 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4946 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4947 if (op_mode == OUT_OF_PLACE)
4948 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4949 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4952 /* Create SNOW 3G operation */
4953 retval = create_wireless_algo_auth_cipher_operation(
4954 tdata->digest.data, tdata->digest.len,
4955 tdata->cipher_iv.data, tdata->cipher_iv.len,
4956 tdata->auth_iv.data, tdata->auth_iv.len,
4957 (tdata->digest.offset_bytes == 0 ?
4958 (verify ? ciphertext_pad_len : plaintext_pad_len)
4959 : tdata->digest.offset_bytes),
4960 tdata->validCipherLenInBits.len,
4961 tdata->cipher.offset_bits,
4962 tdata->validAuthLenInBits.len,
4963 tdata->auth.offset_bits,
4964 op_mode, 0, verify);
4969 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4970 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4971 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4973 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4976 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4978 ut_params->obuf = (op_mode == IN_PLACE ?
4979 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4982 if (ut_params->obuf)
4983 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4986 plaintext = ciphertext +
4987 (tdata->cipher.offset_bits >> 3);
4989 debug_hexdump(stdout, "plaintext:", plaintext,
4990 (tdata->plaintext.len >> 3) - tdata->digest.len);
4991 debug_hexdump(stdout, "plaintext expected:",
4992 tdata->plaintext.data,
4993 (tdata->plaintext.len >> 3) - tdata->digest.len);
4995 if (ut_params->obuf)
4996 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4999 ciphertext = plaintext;
5001 debug_hexdump(stdout, "ciphertext:", ciphertext,
5003 debug_hexdump(stdout, "ciphertext expected:",
5004 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5006 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5007 + (tdata->digest.offset_bytes == 0 ?
5008 plaintext_pad_len : tdata->digest.offset_bytes);
5010 debug_hexdump(stdout, "digest:", ut_params->digest,
5012 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5018 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5020 tdata->plaintext.data,
5021 (tdata->plaintext.len - tdata->cipher.offset_bits -
5022 (tdata->digest.len << 3)),
5023 tdata->cipher.offset_bits,
5024 "SNOW 3G Plaintext data not as expected");
5026 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5028 tdata->ciphertext.data,
5029 (tdata->validDataLenInBits.len -
5030 tdata->cipher.offset_bits),
5031 tdata->cipher.offset_bits,
5032 "SNOW 3G Ciphertext data not as expected");
5034 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5037 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5038 "SNOW 3G Generated auth tag not as expected");
5044 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5045 uint8_t op_mode, uint8_t verify)
5047 struct crypto_testsuite_params *ts_params = &testsuite_params;
5048 struct crypto_unittest_params *ut_params = &unittest_params;
5052 const uint8_t *plaintext = NULL;
5053 const uint8_t *ciphertext = NULL;
5054 const uint8_t *digest = NULL;
5055 unsigned int plaintext_pad_len;
5056 unsigned int plaintext_len;
5057 unsigned int ciphertext_pad_len;
5058 unsigned int ciphertext_len;
5059 uint8_t buffer[10000];
5060 uint8_t digest_buffer[10000];
5062 struct rte_cryptodev_info dev_info;
5064 /* Verify the capabilities */
5065 struct rte_cryptodev_sym_capability_idx cap_idx;
5066 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5067 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5068 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5070 return TEST_SKIPPED;
5071 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5072 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5073 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5075 return TEST_SKIPPED;
5077 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5078 return TEST_SKIPPED;
5080 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5082 uint64_t feat_flags = dev_info.feature_flags;
5084 if (op_mode == IN_PLACE) {
5085 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5086 printf("Device doesn't support in-place scatter-gather "
5087 "in both input and output mbufs.\n");
5088 return TEST_SKIPPED;
5090 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5091 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5092 printf("Device doesn't support RAW data-path APIs.\n");
5093 return TEST_SKIPPED;
5096 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5097 return TEST_SKIPPED;
5098 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5099 printf("Device doesn't support out-of-place scatter-gather "
5100 "in both input and output mbufs.\n");
5101 return TEST_SKIPPED;
5103 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5104 printf("Device doesn't support digest encrypted.\n");
5105 return TEST_SKIPPED;
5109 /* Create SNOW 3G session */
5110 retval = create_wireless_algo_auth_cipher_session(
5111 ts_params->valid_devs[0],
5112 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5113 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5114 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5115 : RTE_CRYPTO_AUTH_OP_GENERATE),
5116 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5117 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5118 tdata->key.data, tdata->key.len,
5119 tdata->auth_iv.len, tdata->digest.len,
5120 tdata->cipher_iv.len);
5125 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5126 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5127 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5128 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5130 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5131 plaintext_pad_len, 15, 0);
5132 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5133 "Failed to allocate input buffer in mempool");
5135 if (op_mode == OUT_OF_PLACE) {
5136 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5137 plaintext_pad_len, 15, 0);
5138 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5139 "Failed to allocate output buffer in mempool");
5143 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5144 tdata->ciphertext.data);
5145 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5146 ciphertext_len, buffer);
5147 debug_hexdump(stdout, "ciphertext:", ciphertext,
5150 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5151 tdata->plaintext.data);
5152 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5153 plaintext_len, buffer);
5154 debug_hexdump(stdout, "plaintext:", plaintext,
5157 memset(buffer, 0, sizeof(buffer));
5159 /* Create SNOW 3G operation */
5160 retval = create_wireless_algo_auth_cipher_operation(
5161 tdata->digest.data, tdata->digest.len,
5162 tdata->cipher_iv.data, tdata->cipher_iv.len,
5163 tdata->auth_iv.data, tdata->auth_iv.len,
5164 (tdata->digest.offset_bytes == 0 ?
5165 (verify ? ciphertext_pad_len : plaintext_pad_len)
5166 : tdata->digest.offset_bytes),
5167 tdata->validCipherLenInBits.len,
5168 tdata->cipher.offset_bits,
5169 tdata->validAuthLenInBits.len,
5170 tdata->auth.offset_bits,
5171 op_mode, 1, verify);
5176 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5177 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5178 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5180 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5183 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5185 ut_params->obuf = (op_mode == IN_PLACE ?
5186 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5189 if (ut_params->obuf)
5190 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5191 plaintext_len, buffer);
5193 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5194 plaintext_len, buffer);
5196 debug_hexdump(stdout, "plaintext:", plaintext,
5197 (tdata->plaintext.len >> 3) - tdata->digest.len);
5198 debug_hexdump(stdout, "plaintext expected:",
5199 tdata->plaintext.data,
5200 (tdata->plaintext.len >> 3) - tdata->digest.len);
5202 if (ut_params->obuf)
5203 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5204 ciphertext_len, buffer);
5206 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5207 ciphertext_len, buffer);
5209 debug_hexdump(stdout, "ciphertext:", ciphertext,
5211 debug_hexdump(stdout, "ciphertext expected:",
5212 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5214 if (ut_params->obuf)
5215 digest = rte_pktmbuf_read(ut_params->obuf,
5216 (tdata->digest.offset_bytes == 0 ?
5217 plaintext_pad_len : tdata->digest.offset_bytes),
5218 tdata->digest.len, digest_buffer);
5220 digest = rte_pktmbuf_read(ut_params->ibuf,
5221 (tdata->digest.offset_bytes == 0 ?
5222 plaintext_pad_len : tdata->digest.offset_bytes),
5223 tdata->digest.len, digest_buffer);
5225 debug_hexdump(stdout, "digest:", digest,
5227 debug_hexdump(stdout, "digest expected:",
5228 tdata->digest.data, tdata->digest.len);
5233 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5235 tdata->plaintext.data,
5236 (tdata->plaintext.len - tdata->cipher.offset_bits -
5237 (tdata->digest.len << 3)),
5238 tdata->cipher.offset_bits,
5239 "SNOW 3G Plaintext data not as expected");
5241 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5243 tdata->ciphertext.data,
5244 (tdata->validDataLenInBits.len -
5245 tdata->cipher.offset_bits),
5246 tdata->cipher.offset_bits,
5247 "SNOW 3G Ciphertext data not as expected");
5249 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5252 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5253 "SNOW 3G Generated auth tag not as expected");
5259 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5260 uint8_t op_mode, uint8_t verify)
5262 struct crypto_testsuite_params *ts_params = &testsuite_params;
5263 struct crypto_unittest_params *ut_params = &unittest_params;
5267 uint8_t *plaintext = NULL, *ciphertext = NULL;
5268 unsigned int plaintext_pad_len;
5269 unsigned int plaintext_len;
5270 unsigned int ciphertext_pad_len;
5271 unsigned int ciphertext_len;
5273 struct rte_cryptodev_info dev_info;
5275 /* Verify the capabilities */
5276 struct rte_cryptodev_sym_capability_idx cap_idx;
5277 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5278 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5279 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5281 return TEST_SKIPPED;
5282 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5283 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5284 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5286 return TEST_SKIPPED;
5288 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5290 uint64_t feat_flags = dev_info.feature_flags;
5292 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5293 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5294 printf("Device doesn't support RAW data-path APIs.\n");
5295 return TEST_SKIPPED;
5298 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5299 return TEST_SKIPPED;
5301 if (op_mode == OUT_OF_PLACE) {
5302 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5303 return TEST_SKIPPED;
5304 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5305 printf("Device doesn't support digest encrypted.\n");
5306 return TEST_SKIPPED;
5310 /* Create KASUMI session */
5311 retval = create_wireless_algo_auth_cipher_session(
5312 ts_params->valid_devs[0],
5313 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5314 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5315 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5316 : RTE_CRYPTO_AUTH_OP_GENERATE),
5317 RTE_CRYPTO_AUTH_KASUMI_F9,
5318 RTE_CRYPTO_CIPHER_KASUMI_F8,
5319 tdata->key.data, tdata->key.len,
5320 0, tdata->digest.len,
5321 tdata->cipher_iv.len);
5326 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5327 if (op_mode == OUT_OF_PLACE)
5328 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5330 /* clear mbuf payload */
5331 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5332 rte_pktmbuf_tailroom(ut_params->ibuf));
5333 if (op_mode == OUT_OF_PLACE)
5334 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5335 rte_pktmbuf_tailroom(ut_params->obuf));
5337 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5338 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5339 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5340 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5343 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5344 ciphertext_pad_len);
5345 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5346 if (op_mode == OUT_OF_PLACE)
5347 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5348 debug_hexdump(stdout, "ciphertext:", ciphertext,
5351 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5353 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5354 if (op_mode == OUT_OF_PLACE)
5355 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5356 debug_hexdump(stdout, "plaintext:", plaintext,
5360 /* Create KASUMI operation */
5361 retval = create_wireless_algo_auth_cipher_operation(
5362 tdata->digest.data, tdata->digest.len,
5363 tdata->cipher_iv.data, tdata->cipher_iv.len,
5365 (tdata->digest.offset_bytes == 0 ?
5366 (verify ? ciphertext_pad_len : plaintext_pad_len)
5367 : tdata->digest.offset_bytes),
5368 tdata->validCipherLenInBits.len,
5369 tdata->validCipherOffsetInBits.len,
5370 tdata->validAuthLenInBits.len,
5372 op_mode, 0, verify);
5377 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5378 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5379 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5381 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5384 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5386 ut_params->obuf = (op_mode == IN_PLACE ?
5387 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5391 if (ut_params->obuf)
5392 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5395 plaintext = ciphertext;
5397 debug_hexdump(stdout, "plaintext:", plaintext,
5398 (tdata->plaintext.len >> 3) - tdata->digest.len);
5399 debug_hexdump(stdout, "plaintext expected:",
5400 tdata->plaintext.data,
5401 (tdata->plaintext.len >> 3) - tdata->digest.len);
5403 if (ut_params->obuf)
5404 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5407 ciphertext = plaintext;
5409 debug_hexdump(stdout, "ciphertext:", ciphertext,
5411 debug_hexdump(stdout, "ciphertext expected:",
5412 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5414 ut_params->digest = rte_pktmbuf_mtod(
5415 ut_params->obuf, uint8_t *) +
5416 (tdata->digest.offset_bytes == 0 ?
5417 plaintext_pad_len : tdata->digest.offset_bytes);
5419 debug_hexdump(stdout, "digest:", ut_params->digest,
5421 debug_hexdump(stdout, "digest expected:",
5422 tdata->digest.data, tdata->digest.len);
5427 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5429 tdata->plaintext.data,
5430 tdata->plaintext.len >> 3,
5431 "KASUMI Plaintext data not as expected");
5433 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5435 tdata->ciphertext.data,
5436 tdata->ciphertext.len >> 3,
5437 "KASUMI Ciphertext data not as expected");
5439 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5442 DIGEST_BYTE_LENGTH_KASUMI_F9,
5443 "KASUMI Generated auth tag not as expected");
5449 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5450 uint8_t op_mode, uint8_t verify)
5452 struct crypto_testsuite_params *ts_params = &testsuite_params;
5453 struct crypto_unittest_params *ut_params = &unittest_params;
5457 const uint8_t *plaintext = NULL;
5458 const uint8_t *ciphertext = NULL;
5459 const uint8_t *digest = NULL;
5460 unsigned int plaintext_pad_len;
5461 unsigned int plaintext_len;
5462 unsigned int ciphertext_pad_len;
5463 unsigned int ciphertext_len;
5464 uint8_t buffer[10000];
5465 uint8_t digest_buffer[10000];
5467 struct rte_cryptodev_info dev_info;
5469 /* Verify the capabilities */
5470 struct rte_cryptodev_sym_capability_idx cap_idx;
5471 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5472 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5473 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5475 return TEST_SKIPPED;
5476 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5477 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5478 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5480 return TEST_SKIPPED;
5482 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5483 return TEST_SKIPPED;
5485 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5487 uint64_t feat_flags = dev_info.feature_flags;
5489 if (op_mode == IN_PLACE) {
5490 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5491 printf("Device doesn't support in-place scatter-gather "
5492 "in both input and output mbufs.\n");
5493 return TEST_SKIPPED;
5495 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5496 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5497 printf("Device doesn't support RAW data-path APIs.\n");
5498 return TEST_SKIPPED;
5501 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5502 return TEST_SKIPPED;
5503 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5504 printf("Device doesn't support out-of-place scatter-gather "
5505 "in both input and output mbufs.\n");
5506 return TEST_SKIPPED;
5508 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5509 printf("Device doesn't support digest encrypted.\n");
5510 return TEST_SKIPPED;
5514 /* Create KASUMI session */
5515 retval = create_wireless_algo_auth_cipher_session(
5516 ts_params->valid_devs[0],
5517 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5518 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5519 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5520 : RTE_CRYPTO_AUTH_OP_GENERATE),
5521 RTE_CRYPTO_AUTH_KASUMI_F9,
5522 RTE_CRYPTO_CIPHER_KASUMI_F8,
5523 tdata->key.data, tdata->key.len,
5524 0, tdata->digest.len,
5525 tdata->cipher_iv.len);
5530 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5531 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5532 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5533 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5535 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5536 plaintext_pad_len, 15, 0);
5537 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5538 "Failed to allocate input buffer in mempool");
5540 if (op_mode == OUT_OF_PLACE) {
5541 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5542 plaintext_pad_len, 15, 0);
5543 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5544 "Failed to allocate output buffer in mempool");
5548 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5549 tdata->ciphertext.data);
5550 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5551 ciphertext_len, buffer);
5552 debug_hexdump(stdout, "ciphertext:", ciphertext,
5555 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5556 tdata->plaintext.data);
5557 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5558 plaintext_len, buffer);
5559 debug_hexdump(stdout, "plaintext:", plaintext,
5562 memset(buffer, 0, sizeof(buffer));
5564 /* Create KASUMI operation */
5565 retval = create_wireless_algo_auth_cipher_operation(
5566 tdata->digest.data, tdata->digest.len,
5567 tdata->cipher_iv.data, tdata->cipher_iv.len,
5569 (tdata->digest.offset_bytes == 0 ?
5570 (verify ? ciphertext_pad_len : plaintext_pad_len)
5571 : tdata->digest.offset_bytes),
5572 tdata->validCipherLenInBits.len,
5573 tdata->validCipherOffsetInBits.len,
5574 tdata->validAuthLenInBits.len,
5576 op_mode, 1, verify);
5581 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5582 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5583 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5585 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5588 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5590 ut_params->obuf = (op_mode == IN_PLACE ?
5591 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5594 if (ut_params->obuf)
5595 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5596 plaintext_len, buffer);
5598 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5599 plaintext_len, buffer);
5601 debug_hexdump(stdout, "plaintext:", plaintext,
5602 (tdata->plaintext.len >> 3) - tdata->digest.len);
5603 debug_hexdump(stdout, "plaintext expected:",
5604 tdata->plaintext.data,
5605 (tdata->plaintext.len >> 3) - tdata->digest.len);
5607 if (ut_params->obuf)
5608 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5609 ciphertext_len, buffer);
5611 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5612 ciphertext_len, buffer);
5614 debug_hexdump(stdout, "ciphertext:", ciphertext,
5616 debug_hexdump(stdout, "ciphertext expected:",
5617 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5619 if (ut_params->obuf)
5620 digest = rte_pktmbuf_read(ut_params->obuf,
5621 (tdata->digest.offset_bytes == 0 ?
5622 plaintext_pad_len : tdata->digest.offset_bytes),
5623 tdata->digest.len, digest_buffer);
5625 digest = rte_pktmbuf_read(ut_params->ibuf,
5626 (tdata->digest.offset_bytes == 0 ?
5627 plaintext_pad_len : tdata->digest.offset_bytes),
5628 tdata->digest.len, digest_buffer);
5630 debug_hexdump(stdout, "digest:", digest,
5632 debug_hexdump(stdout, "digest expected:",
5633 tdata->digest.data, tdata->digest.len);
5638 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5640 tdata->plaintext.data,
5641 tdata->plaintext.len >> 3,
5642 "KASUMI Plaintext data not as expected");
5644 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5646 tdata->ciphertext.data,
5647 tdata->validDataLenInBits.len,
5648 "KASUMI Ciphertext data not as expected");
5650 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5653 DIGEST_BYTE_LENGTH_KASUMI_F9,
5654 "KASUMI Generated auth tag not as expected");
5660 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5662 struct crypto_testsuite_params *ts_params = &testsuite_params;
5663 struct crypto_unittest_params *ut_params = &unittest_params;
5667 uint8_t *plaintext, *ciphertext;
5668 unsigned plaintext_pad_len;
5669 unsigned plaintext_len;
5670 struct rte_cryptodev_info dev_info;
5672 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5673 uint64_t feat_flags = dev_info.feature_flags;
5675 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5676 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5677 printf("Device doesn't support RAW data-path APIs.\n");
5678 return TEST_SKIPPED;
5681 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5682 return TEST_SKIPPED;
5684 /* Verify the capabilities */
5685 struct rte_cryptodev_sym_capability_idx cap_idx;
5686 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5687 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5688 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5690 return TEST_SKIPPED;
5691 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5692 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5693 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5695 return TEST_SKIPPED;
5697 /* Create KASUMI session */
5698 retval = create_wireless_algo_cipher_auth_session(
5699 ts_params->valid_devs[0],
5700 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5701 RTE_CRYPTO_AUTH_OP_GENERATE,
5702 RTE_CRYPTO_AUTH_KASUMI_F9,
5703 RTE_CRYPTO_CIPHER_KASUMI_F8,
5704 tdata->key.data, tdata->key.len,
5705 0, tdata->digest.len,
5706 tdata->cipher_iv.len);
5710 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5712 /* clear mbuf payload */
5713 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5714 rte_pktmbuf_tailroom(ut_params->ibuf));
5716 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5717 /* Append data which is padded to a multiple of */
5718 /* the algorithms block size */
5719 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5720 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5722 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5724 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5726 /* Create KASUMI operation */
5727 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5728 tdata->digest.len, NULL, 0,
5729 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5730 tdata->cipher_iv.data, tdata->cipher_iv.len,
5731 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5732 tdata->validCipherOffsetInBits.len,
5733 tdata->validAuthLenInBits.len,
5739 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5740 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5741 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5743 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5745 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5747 if (ut_params->op->sym->m_dst)
5748 ut_params->obuf = ut_params->op->sym->m_dst;
5750 ut_params->obuf = ut_params->op->sym->m_src;
5752 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5753 tdata->validCipherOffsetInBits.len >> 3);
5755 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5756 + plaintext_pad_len;
5758 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5759 (tdata->validCipherOffsetInBits.len >> 3);
5761 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5763 reference_ciphertext,
5764 tdata->validCipherLenInBits.len,
5765 "KASUMI Ciphertext data not as expected");
5768 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5771 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5772 "KASUMI Generated auth tag not as expected");
5777 test_zuc_encryption(const struct wireless_test_data *tdata)
5779 struct crypto_testsuite_params *ts_params = &testsuite_params;
5780 struct crypto_unittest_params *ut_params = &unittest_params;
5783 uint8_t *plaintext, *ciphertext;
5784 unsigned plaintext_pad_len;
5785 unsigned plaintext_len;
5786 struct rte_cryptodev_info dev_info;
5788 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5789 uint64_t feat_flags = dev_info.feature_flags;
5791 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5792 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5793 printf("Device doesn't support RAW data-path APIs.\n");
5794 return TEST_SKIPPED;
5797 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5798 return TEST_SKIPPED;
5800 struct rte_cryptodev_sym_capability_idx cap_idx;
5802 /* Check if device supports ZUC EEA3 */
5803 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5804 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5806 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5808 return TEST_SKIPPED;
5810 /* Create ZUC session */
5811 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5812 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5813 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5814 tdata->key.data, tdata->key.len,
5815 tdata->cipher_iv.len);
5819 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5821 /* Clear mbuf payload */
5822 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5823 rte_pktmbuf_tailroom(ut_params->ibuf));
5825 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5826 /* Append data which is padded to a multiple */
5827 /* of the algorithms block size */
5828 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5829 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5831 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5833 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5835 /* Create ZUC operation */
5836 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5837 tdata->cipher_iv.len,
5838 tdata->plaintext.len,
5843 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5844 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5845 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5847 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5849 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5851 ut_params->obuf = ut_params->op->sym->m_dst;
5852 if (ut_params->obuf)
5853 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5855 ciphertext = plaintext;
5857 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5860 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5862 tdata->ciphertext.data,
5863 tdata->validCipherLenInBits.len,
5864 "ZUC Ciphertext data not as expected");
5869 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5871 struct crypto_testsuite_params *ts_params = &testsuite_params;
5872 struct crypto_unittest_params *ut_params = &unittest_params;
5876 unsigned int plaintext_pad_len;
5877 unsigned int plaintext_len;
5878 const uint8_t *ciphertext;
5879 uint8_t ciphertext_buffer[2048];
5880 struct rte_cryptodev_info dev_info;
5882 struct rte_cryptodev_sym_capability_idx cap_idx;
5884 /* Check if device supports ZUC EEA3 */
5885 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5886 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5888 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5890 return TEST_SKIPPED;
5892 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5893 return TEST_SKIPPED;
5895 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5897 uint64_t feat_flags = dev_info.feature_flags;
5899 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5900 printf("Device doesn't support in-place scatter-gather. "
5902 return TEST_SKIPPED;
5905 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5906 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5907 printf("Device doesn't support RAW data-path APIs.\n");
5908 return TEST_SKIPPED;
5911 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5913 /* Append data which is padded to a multiple */
5914 /* of the algorithms block size */
5915 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5917 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5918 plaintext_pad_len, 10, 0);
5920 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5921 tdata->plaintext.data);
5923 /* Create ZUC session */
5924 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5925 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5926 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5927 tdata->key.data, tdata->key.len,
5928 tdata->cipher_iv.len);
5932 /* Clear mbuf payload */
5934 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5936 /* Create ZUC operation */
5937 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5938 tdata->cipher_iv.len, tdata->plaintext.len,
5943 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5944 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5945 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5947 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5949 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5951 ut_params->obuf = ut_params->op->sym->m_dst;
5952 if (ut_params->obuf)
5953 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5954 0, plaintext_len, ciphertext_buffer);
5956 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5957 0, plaintext_len, ciphertext_buffer);
5960 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5963 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5965 tdata->ciphertext.data,
5966 tdata->validCipherLenInBits.len,
5967 "ZUC Ciphertext data not as expected");
5973 test_zuc_authentication(const struct wireless_test_data *tdata)
5975 struct crypto_testsuite_params *ts_params = &testsuite_params;
5976 struct crypto_unittest_params *ut_params = &unittest_params;
5979 unsigned plaintext_pad_len;
5980 unsigned plaintext_len;
5983 struct rte_cryptodev_sym_capability_idx cap_idx;
5984 struct rte_cryptodev_info dev_info;
5986 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5987 uint64_t feat_flags = dev_info.feature_flags;
5989 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5990 (tdata->validAuthLenInBits.len % 8 != 0)) {
5991 printf("Device doesn't support NON-Byte Aligned Data.\n");
5992 return TEST_SKIPPED;
5995 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5996 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5997 printf("Device doesn't support RAW data-path APIs.\n");
5998 return TEST_SKIPPED;
6001 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6002 return TEST_SKIPPED;
6004 /* Check if device supports ZUC EIA3 */
6005 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6006 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6008 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6010 return TEST_SKIPPED;
6012 /* Create ZUC session */
6013 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6014 tdata->key.data, tdata->key.len,
6015 tdata->auth_iv.len, tdata->digest.len,
6016 RTE_CRYPTO_AUTH_OP_GENERATE,
6017 RTE_CRYPTO_AUTH_ZUC_EIA3);
6021 /* alloc mbuf and set payload */
6022 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6024 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6025 rte_pktmbuf_tailroom(ut_params->ibuf));
6027 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6028 /* Append data which is padded to a multiple of */
6029 /* the algorithms block size */
6030 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6031 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6033 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6035 /* Create ZUC operation */
6036 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6037 tdata->auth_iv.data, tdata->auth_iv.len,
6038 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6039 tdata->validAuthLenInBits.len,
6044 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6045 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6046 ut_params->op, 0, 1, 1, 0);
6048 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6050 ut_params->obuf = ut_params->op->sym->m_src;
6051 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6052 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6053 + plaintext_pad_len;
6056 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6060 "ZUC Generated auth tag not as expected");
6066 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6067 uint8_t op_mode, uint8_t verify)
6069 struct crypto_testsuite_params *ts_params = &testsuite_params;
6070 struct crypto_unittest_params *ut_params = &unittest_params;
6074 uint8_t *plaintext = NULL, *ciphertext = NULL;
6075 unsigned int plaintext_pad_len;
6076 unsigned int plaintext_len;
6077 unsigned int ciphertext_pad_len;
6078 unsigned int ciphertext_len;
6080 struct rte_cryptodev_info dev_info;
6081 struct rte_cryptodev_sym_capability_idx cap_idx;
6083 /* Check if device supports ZUC EIA3 */
6084 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6085 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6087 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6089 return TEST_SKIPPED;
6091 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6093 uint64_t feat_flags = dev_info.feature_flags;
6095 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6096 printf("Device doesn't support digest encrypted.\n");
6097 return TEST_SKIPPED;
6099 if (op_mode == IN_PLACE) {
6100 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6101 printf("Device doesn't support in-place scatter-gather "
6102 "in both input and output mbufs.\n");
6103 return TEST_SKIPPED;
6106 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6107 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6108 printf("Device doesn't support RAW data-path APIs.\n");
6109 return TEST_SKIPPED;
6112 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6113 return TEST_SKIPPED;
6114 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6115 printf("Device doesn't support out-of-place scatter-gather "
6116 "in both input and output mbufs.\n");
6117 return TEST_SKIPPED;
6121 /* Create ZUC session */
6122 retval = create_wireless_algo_auth_cipher_session(
6123 ts_params->valid_devs[0],
6124 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6125 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6126 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6127 : RTE_CRYPTO_AUTH_OP_GENERATE),
6128 RTE_CRYPTO_AUTH_ZUC_EIA3,
6129 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6130 tdata->key.data, tdata->key.len,
6131 tdata->auth_iv.len, tdata->digest.len,
6132 tdata->cipher_iv.len);
6137 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6138 if (op_mode == OUT_OF_PLACE)
6139 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6141 /* clear mbuf payload */
6142 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6143 rte_pktmbuf_tailroom(ut_params->ibuf));
6144 if (op_mode == OUT_OF_PLACE)
6145 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6146 rte_pktmbuf_tailroom(ut_params->obuf));
6148 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6149 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6150 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6151 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6154 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6155 ciphertext_pad_len);
6156 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6157 if (op_mode == OUT_OF_PLACE)
6158 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6159 debug_hexdump(stdout, "ciphertext:", ciphertext,
6162 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6164 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6165 if (op_mode == OUT_OF_PLACE)
6166 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6167 debug_hexdump(stdout, "plaintext:", plaintext,
6171 /* Create ZUC operation */
6172 retval = create_wireless_algo_auth_cipher_operation(
6173 tdata->digest.data, tdata->digest.len,
6174 tdata->cipher_iv.data, tdata->cipher_iv.len,
6175 tdata->auth_iv.data, tdata->auth_iv.len,
6176 (tdata->digest.offset_bytes == 0 ?
6177 (verify ? ciphertext_pad_len : plaintext_pad_len)
6178 : tdata->digest.offset_bytes),
6179 tdata->validCipherLenInBits.len,
6180 tdata->validCipherOffsetInBits.len,
6181 tdata->validAuthLenInBits.len,
6183 op_mode, 0, verify);
6188 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6189 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6190 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6192 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6195 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6197 ut_params->obuf = (op_mode == IN_PLACE ?
6198 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6202 if (ut_params->obuf)
6203 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6206 plaintext = ciphertext;
6208 debug_hexdump(stdout, "plaintext:", plaintext,
6209 (tdata->plaintext.len >> 3) - tdata->digest.len);
6210 debug_hexdump(stdout, "plaintext expected:",
6211 tdata->plaintext.data,
6212 (tdata->plaintext.len >> 3) - tdata->digest.len);
6214 if (ut_params->obuf)
6215 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6218 ciphertext = plaintext;
6220 debug_hexdump(stdout, "ciphertext:", ciphertext,
6222 debug_hexdump(stdout, "ciphertext expected:",
6223 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6225 ut_params->digest = rte_pktmbuf_mtod(
6226 ut_params->obuf, uint8_t *) +
6227 (tdata->digest.offset_bytes == 0 ?
6228 plaintext_pad_len : tdata->digest.offset_bytes);
6230 debug_hexdump(stdout, "digest:", ut_params->digest,
6232 debug_hexdump(stdout, "digest expected:",
6233 tdata->digest.data, tdata->digest.len);
6238 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6240 tdata->plaintext.data,
6241 tdata->plaintext.len >> 3,
6242 "ZUC Plaintext data not as expected");
6244 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6246 tdata->ciphertext.data,
6247 tdata->ciphertext.len >> 3,
6248 "ZUC Ciphertext data not as expected");
6250 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6253 DIGEST_BYTE_LENGTH_KASUMI_F9,
6254 "ZUC Generated auth tag not as expected");
6260 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6261 uint8_t op_mode, uint8_t verify)
6263 struct crypto_testsuite_params *ts_params = &testsuite_params;
6264 struct crypto_unittest_params *ut_params = &unittest_params;
6268 const uint8_t *plaintext = NULL;
6269 const uint8_t *ciphertext = NULL;
6270 const uint8_t *digest = NULL;
6271 unsigned int plaintext_pad_len;
6272 unsigned int plaintext_len;
6273 unsigned int ciphertext_pad_len;
6274 unsigned int ciphertext_len;
6275 uint8_t buffer[10000];
6276 uint8_t digest_buffer[10000];
6278 struct rte_cryptodev_info dev_info;
6279 struct rte_cryptodev_sym_capability_idx cap_idx;
6281 /* Check if device supports ZUC EIA3 */
6282 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6283 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6285 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6287 return TEST_SKIPPED;
6289 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6291 uint64_t feat_flags = dev_info.feature_flags;
6293 if (op_mode == IN_PLACE) {
6294 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6295 printf("Device doesn't support in-place scatter-gather "
6296 "in both input and output mbufs.\n");
6297 return TEST_SKIPPED;
6300 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6301 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6302 printf("Device doesn't support RAW data-path APIs.\n");
6303 return TEST_SKIPPED;
6306 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6307 return TEST_SKIPPED;
6308 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6309 printf("Device doesn't support out-of-place scatter-gather "
6310 "in both input and output mbufs.\n");
6311 return TEST_SKIPPED;
6313 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6314 printf("Device doesn't support digest encrypted.\n");
6315 return TEST_SKIPPED;
6319 /* Create ZUC session */
6320 retval = create_wireless_algo_auth_cipher_session(
6321 ts_params->valid_devs[0],
6322 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6323 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6324 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6325 : RTE_CRYPTO_AUTH_OP_GENERATE),
6326 RTE_CRYPTO_AUTH_ZUC_EIA3,
6327 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6328 tdata->key.data, tdata->key.len,
6329 tdata->auth_iv.len, tdata->digest.len,
6330 tdata->cipher_iv.len);
6335 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6336 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6337 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6338 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6340 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6341 plaintext_pad_len, 15, 0);
6342 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6343 "Failed to allocate input buffer in mempool");
6345 if (op_mode == OUT_OF_PLACE) {
6346 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6347 plaintext_pad_len, 15, 0);
6348 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6349 "Failed to allocate output buffer in mempool");
6353 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6354 tdata->ciphertext.data);
6355 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6356 ciphertext_len, buffer);
6357 debug_hexdump(stdout, "ciphertext:", ciphertext,
6360 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6361 tdata->plaintext.data);
6362 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6363 plaintext_len, buffer);
6364 debug_hexdump(stdout, "plaintext:", plaintext,
6367 memset(buffer, 0, sizeof(buffer));
6369 /* Create ZUC operation */
6370 retval = create_wireless_algo_auth_cipher_operation(
6371 tdata->digest.data, tdata->digest.len,
6372 tdata->cipher_iv.data, tdata->cipher_iv.len,
6374 (tdata->digest.offset_bytes == 0 ?
6375 (verify ? ciphertext_pad_len : plaintext_pad_len)
6376 : tdata->digest.offset_bytes),
6377 tdata->validCipherLenInBits.len,
6378 tdata->validCipherOffsetInBits.len,
6379 tdata->validAuthLenInBits.len,
6381 op_mode, 1, verify);
6386 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6387 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6388 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6390 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6393 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6395 ut_params->obuf = (op_mode == IN_PLACE ?
6396 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6399 if (ut_params->obuf)
6400 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6401 plaintext_len, buffer);
6403 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6404 plaintext_len, buffer);
6406 debug_hexdump(stdout, "plaintext:", plaintext,
6407 (tdata->plaintext.len >> 3) - tdata->digest.len);
6408 debug_hexdump(stdout, "plaintext expected:",
6409 tdata->plaintext.data,
6410 (tdata->plaintext.len >> 3) - tdata->digest.len);
6412 if (ut_params->obuf)
6413 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6414 ciphertext_len, buffer);
6416 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6417 ciphertext_len, buffer);
6419 debug_hexdump(stdout, "ciphertext:", ciphertext,
6421 debug_hexdump(stdout, "ciphertext expected:",
6422 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6424 if (ut_params->obuf)
6425 digest = rte_pktmbuf_read(ut_params->obuf,
6426 (tdata->digest.offset_bytes == 0 ?
6427 plaintext_pad_len : tdata->digest.offset_bytes),
6428 tdata->digest.len, digest_buffer);
6430 digest = rte_pktmbuf_read(ut_params->ibuf,
6431 (tdata->digest.offset_bytes == 0 ?
6432 plaintext_pad_len : tdata->digest.offset_bytes),
6433 tdata->digest.len, digest_buffer);
6435 debug_hexdump(stdout, "digest:", digest,
6437 debug_hexdump(stdout, "digest expected:",
6438 tdata->digest.data, tdata->digest.len);
6443 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6445 tdata->plaintext.data,
6446 tdata->plaintext.len >> 3,
6447 "ZUC Plaintext data not as expected");
6449 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6451 tdata->ciphertext.data,
6452 tdata->validDataLenInBits.len,
6453 "ZUC Ciphertext data not as expected");
6455 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6458 DIGEST_BYTE_LENGTH_KASUMI_F9,
6459 "ZUC Generated auth tag not as expected");
6465 test_kasumi_encryption_test_case_1(void)
6467 return test_kasumi_encryption(&kasumi_test_case_1);
6471 test_kasumi_encryption_test_case_1_sgl(void)
6473 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6477 test_kasumi_encryption_test_case_1_oop(void)
6479 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6483 test_kasumi_encryption_test_case_1_oop_sgl(void)
6485 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6489 test_kasumi_encryption_test_case_2(void)
6491 return test_kasumi_encryption(&kasumi_test_case_2);
6495 test_kasumi_encryption_test_case_3(void)
6497 return test_kasumi_encryption(&kasumi_test_case_3);
6501 test_kasumi_encryption_test_case_4(void)
6503 return test_kasumi_encryption(&kasumi_test_case_4);
6507 test_kasumi_encryption_test_case_5(void)
6509 return test_kasumi_encryption(&kasumi_test_case_5);
6513 test_kasumi_decryption_test_case_1(void)
6515 return test_kasumi_decryption(&kasumi_test_case_1);
6519 test_kasumi_decryption_test_case_1_oop(void)
6521 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6525 test_kasumi_decryption_test_case_2(void)
6527 return test_kasumi_decryption(&kasumi_test_case_2);
6531 test_kasumi_decryption_test_case_3(void)
6533 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6534 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6535 return TEST_SKIPPED;
6536 return test_kasumi_decryption(&kasumi_test_case_3);
6540 test_kasumi_decryption_test_case_4(void)
6542 return test_kasumi_decryption(&kasumi_test_case_4);
6546 test_kasumi_decryption_test_case_5(void)
6548 return test_kasumi_decryption(&kasumi_test_case_5);
6551 test_snow3g_encryption_test_case_1(void)
6553 return test_snow3g_encryption(&snow3g_test_case_1);
6557 test_snow3g_encryption_test_case_1_oop(void)
6559 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6563 test_snow3g_encryption_test_case_1_oop_sgl(void)
6565 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6570 test_snow3g_encryption_test_case_1_offset_oop(void)
6572 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6576 test_snow3g_encryption_test_case_2(void)
6578 return test_snow3g_encryption(&snow3g_test_case_2);
6582 test_snow3g_encryption_test_case_3(void)
6584 return test_snow3g_encryption(&snow3g_test_case_3);
6588 test_snow3g_encryption_test_case_4(void)
6590 return test_snow3g_encryption(&snow3g_test_case_4);
6594 test_snow3g_encryption_test_case_5(void)
6596 return test_snow3g_encryption(&snow3g_test_case_5);
6600 test_snow3g_decryption_test_case_1(void)
6602 return test_snow3g_decryption(&snow3g_test_case_1);
6606 test_snow3g_decryption_test_case_1_oop(void)
6608 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6612 test_snow3g_decryption_test_case_2(void)
6614 return test_snow3g_decryption(&snow3g_test_case_2);
6618 test_snow3g_decryption_test_case_3(void)
6620 return test_snow3g_decryption(&snow3g_test_case_3);
6624 test_snow3g_decryption_test_case_4(void)
6626 return test_snow3g_decryption(&snow3g_test_case_4);
6630 test_snow3g_decryption_test_case_5(void)
6632 return test_snow3g_decryption(&snow3g_test_case_5);
6636 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6637 * Pattern digest from snow3g_test_data must be allocated as
6638 * 4 last bytes in plaintext.
6641 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6642 struct snow3g_hash_test_data *output)
6644 if ((pattern != NULL) && (output != NULL)) {
6645 output->key.len = pattern->key.len;
6647 memcpy(output->key.data,
6648 pattern->key.data, pattern->key.len);
6650 output->auth_iv.len = pattern->auth_iv.len;
6652 memcpy(output->auth_iv.data,
6653 pattern->auth_iv.data, pattern->auth_iv.len);
6655 output->plaintext.len = pattern->plaintext.len;
6657 memcpy(output->plaintext.data,
6658 pattern->plaintext.data, pattern->plaintext.len >> 3);
6660 output->digest.len = pattern->digest.len;
6662 memcpy(output->digest.data,
6663 &pattern->plaintext.data[pattern->digest.offset_bytes],
6664 pattern->digest.len);
6666 output->validAuthLenInBits.len =
6667 pattern->validAuthLenInBits.len;
6672 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6675 test_snow3g_decryption_with_digest_test_case_1(void)
6677 struct snow3g_hash_test_data snow3g_hash_data;
6678 struct rte_cryptodev_info dev_info;
6679 struct crypto_testsuite_params *ts_params = &testsuite_params;
6681 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6682 uint64_t feat_flags = dev_info.feature_flags;
6684 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6685 printf("Device doesn't support encrypted digest operations.\n");
6686 return TEST_SKIPPED;
6690 * Function prepare data for hash veryfication test case.
6691 * Digest is allocated in 4 last bytes in plaintext, pattern.
6693 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6695 return test_snow3g_decryption(&snow3g_test_case_7) &
6696 test_snow3g_authentication_verify(&snow3g_hash_data);
6700 test_snow3g_cipher_auth_test_case_1(void)
6702 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6706 test_snow3g_auth_cipher_test_case_1(void)
6708 return test_snow3g_auth_cipher(
6709 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6713 test_snow3g_auth_cipher_test_case_2(void)
6715 return test_snow3g_auth_cipher(
6716 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6720 test_snow3g_auth_cipher_test_case_2_oop(void)
6722 return test_snow3g_auth_cipher(
6723 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6727 test_snow3g_auth_cipher_part_digest_enc(void)
6729 return test_snow3g_auth_cipher(
6730 &snow3g_auth_cipher_partial_digest_encryption,
6735 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6737 return test_snow3g_auth_cipher(
6738 &snow3g_auth_cipher_partial_digest_encryption,
6743 test_snow3g_auth_cipher_test_case_3_sgl(void)
6745 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6746 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6747 return TEST_SKIPPED;
6748 return test_snow3g_auth_cipher_sgl(
6749 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6753 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6755 return test_snow3g_auth_cipher_sgl(
6756 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6760 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6762 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6763 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6764 return TEST_SKIPPED;
6765 return test_snow3g_auth_cipher_sgl(
6766 &snow3g_auth_cipher_partial_digest_encryption,
6771 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6773 return test_snow3g_auth_cipher_sgl(
6774 &snow3g_auth_cipher_partial_digest_encryption,
6779 test_snow3g_auth_cipher_verify_test_case_1(void)
6781 return test_snow3g_auth_cipher(
6782 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6786 test_snow3g_auth_cipher_verify_test_case_2(void)
6788 return test_snow3g_auth_cipher(
6789 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6793 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6795 return test_snow3g_auth_cipher(
6796 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6800 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6802 return test_snow3g_auth_cipher(
6803 &snow3g_auth_cipher_partial_digest_encryption,
6808 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6810 return test_snow3g_auth_cipher(
6811 &snow3g_auth_cipher_partial_digest_encryption,
6816 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6818 return test_snow3g_auth_cipher_sgl(
6819 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6823 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6825 return test_snow3g_auth_cipher_sgl(
6826 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6830 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6832 return test_snow3g_auth_cipher_sgl(
6833 &snow3g_auth_cipher_partial_digest_encryption,
6838 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6840 return test_snow3g_auth_cipher_sgl(
6841 &snow3g_auth_cipher_partial_digest_encryption,
6846 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6848 return test_snow3g_auth_cipher(
6849 &snow3g_test_case_7, IN_PLACE, 0);
6853 test_kasumi_auth_cipher_test_case_1(void)
6855 return test_kasumi_auth_cipher(
6856 &kasumi_test_case_3, IN_PLACE, 0);
6860 test_kasumi_auth_cipher_test_case_2(void)
6862 return test_kasumi_auth_cipher(
6863 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6867 test_kasumi_auth_cipher_test_case_2_oop(void)
6869 return test_kasumi_auth_cipher(
6870 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6874 test_kasumi_auth_cipher_test_case_2_sgl(void)
6876 return test_kasumi_auth_cipher_sgl(
6877 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6881 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6883 return test_kasumi_auth_cipher_sgl(
6884 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6888 test_kasumi_auth_cipher_verify_test_case_1(void)
6890 return test_kasumi_auth_cipher(
6891 &kasumi_test_case_3, IN_PLACE, 1);
6895 test_kasumi_auth_cipher_verify_test_case_2(void)
6897 return test_kasumi_auth_cipher(
6898 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6902 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6904 return test_kasumi_auth_cipher(
6905 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6909 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6911 return test_kasumi_auth_cipher_sgl(
6912 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6916 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6918 return test_kasumi_auth_cipher_sgl(
6919 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6923 test_kasumi_cipher_auth_test_case_1(void)
6925 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6929 test_zuc_encryption_test_case_1(void)
6931 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6935 test_zuc_encryption_test_case_2(void)
6937 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6941 test_zuc_encryption_test_case_3(void)
6943 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6947 test_zuc_encryption_test_case_4(void)
6949 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6953 test_zuc_encryption_test_case_5(void)
6955 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6959 test_zuc_encryption_test_case_6_sgl(void)
6961 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6965 test_zuc_hash_generate_test_case_1(void)
6967 return test_zuc_authentication(&zuc_test_case_auth_1b);
6971 test_zuc_hash_generate_test_case_2(void)
6973 return test_zuc_authentication(&zuc_test_case_auth_90b);
6977 test_zuc_hash_generate_test_case_3(void)
6979 return test_zuc_authentication(&zuc_test_case_auth_577b);
6983 test_zuc_hash_generate_test_case_4(void)
6985 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6989 test_zuc_hash_generate_test_case_5(void)
6991 return test_zuc_authentication(&zuc_test_auth_5670b);
6995 test_zuc_hash_generate_test_case_6(void)
6997 return test_zuc_authentication(&zuc_test_case_auth_128b);
7001 test_zuc_hash_generate_test_case_7(void)
7003 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7007 test_zuc_hash_generate_test_case_8(void)
7009 return test_zuc_authentication(&zuc_test_case_auth_584b);
7013 test_zuc_cipher_auth_test_case_1(void)
7015 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7019 test_zuc_cipher_auth_test_case_2(void)
7021 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7025 test_zuc_auth_cipher_test_case_1(void)
7027 return test_zuc_auth_cipher(
7028 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7032 test_zuc_auth_cipher_test_case_1_oop(void)
7034 return test_zuc_auth_cipher(
7035 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7039 test_zuc_auth_cipher_test_case_1_sgl(void)
7041 return test_zuc_auth_cipher_sgl(
7042 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7046 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7048 return test_zuc_auth_cipher_sgl(
7049 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7053 test_zuc_auth_cipher_verify_test_case_1(void)
7055 return test_zuc_auth_cipher(
7056 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7060 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7062 return test_zuc_auth_cipher(
7063 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7067 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7069 return test_zuc_auth_cipher_sgl(
7070 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7074 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7076 return test_zuc_auth_cipher_sgl(
7077 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7081 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7083 uint8_t dev_id = testsuite_params.valid_devs[0];
7085 struct rte_cryptodev_sym_capability_idx cap_idx;
7087 /* Check if device supports particular cipher algorithm */
7088 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7089 cap_idx.algo.cipher = tdata->cipher_algo;
7090 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7091 return TEST_SKIPPED;
7093 /* Check if device supports particular hash algorithm */
7094 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7095 cap_idx.algo.auth = tdata->auth_algo;
7096 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7097 return TEST_SKIPPED;
7103 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7104 uint8_t op_mode, uint8_t verify)
7106 struct crypto_testsuite_params *ts_params = &testsuite_params;
7107 struct crypto_unittest_params *ut_params = &unittest_params;
7111 uint8_t *plaintext = NULL, *ciphertext = NULL;
7112 unsigned int plaintext_pad_len;
7113 unsigned int plaintext_len;
7114 unsigned int ciphertext_pad_len;
7115 unsigned int ciphertext_len;
7117 struct rte_cryptodev_info dev_info;
7118 struct rte_crypto_op *op;
7120 /* Check if device supports particular algorithms separately */
7121 if (test_mixed_check_if_unsupported(tdata))
7122 return TEST_SKIPPED;
7123 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7124 return TEST_SKIPPED;
7126 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7128 uint64_t feat_flags = dev_info.feature_flags;
7130 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7131 printf("Device doesn't support digest encrypted.\n");
7132 return TEST_SKIPPED;
7135 /* Create the session */
7137 retval = create_wireless_algo_cipher_auth_session(
7138 ts_params->valid_devs[0],
7139 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7140 RTE_CRYPTO_AUTH_OP_VERIFY,
7143 tdata->auth_key.data, tdata->auth_key.len,
7144 tdata->auth_iv.len, tdata->digest_enc.len,
7145 tdata->cipher_iv.len);
7147 retval = create_wireless_algo_auth_cipher_session(
7148 ts_params->valid_devs[0],
7149 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7150 RTE_CRYPTO_AUTH_OP_GENERATE,
7153 tdata->auth_key.data, tdata->auth_key.len,
7154 tdata->auth_iv.len, tdata->digest_enc.len,
7155 tdata->cipher_iv.len);
7159 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7160 if (op_mode == OUT_OF_PLACE)
7161 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7163 /* clear mbuf payload */
7164 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7165 rte_pktmbuf_tailroom(ut_params->ibuf));
7166 if (op_mode == OUT_OF_PLACE) {
7168 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7169 rte_pktmbuf_tailroom(ut_params->obuf));
7172 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7173 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7174 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7175 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7178 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7179 ciphertext_pad_len);
7180 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7181 if (op_mode == OUT_OF_PLACE)
7182 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7183 debug_hexdump(stdout, "ciphertext:", ciphertext,
7186 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7188 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7189 if (op_mode == OUT_OF_PLACE)
7190 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7191 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7194 /* Create the operation */
7195 retval = create_wireless_algo_auth_cipher_operation(
7196 tdata->digest_enc.data, tdata->digest_enc.len,
7197 tdata->cipher_iv.data, tdata->cipher_iv.len,
7198 tdata->auth_iv.data, tdata->auth_iv.len,
7199 (tdata->digest_enc.offset == 0 ?
7201 : tdata->digest_enc.offset),
7202 tdata->validCipherLen.len_bits,
7203 tdata->cipher.offset_bits,
7204 tdata->validAuthLen.len_bits,
7205 tdata->auth.offset_bits,
7206 op_mode, 0, verify);
7211 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7213 /* Check if the op failed because the device doesn't */
7214 /* support this particular combination of algorithms */
7215 if (op == NULL && ut_params->op->status ==
7216 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7217 printf("Device doesn't support this mixed combination. "
7219 return TEST_SKIPPED;
7223 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7225 ut_params->obuf = (op_mode == IN_PLACE ?
7226 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7229 if (ut_params->obuf)
7230 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7233 plaintext = ciphertext +
7234 (tdata->cipher.offset_bits >> 3);
7236 debug_hexdump(stdout, "plaintext:", plaintext,
7237 tdata->plaintext.len_bits >> 3);
7238 debug_hexdump(stdout, "plaintext expected:",
7239 tdata->plaintext.data,
7240 tdata->plaintext.len_bits >> 3);
7242 if (ut_params->obuf)
7243 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7246 ciphertext = plaintext;
7248 debug_hexdump(stdout, "ciphertext:", ciphertext,
7250 debug_hexdump(stdout, "ciphertext expected:",
7251 tdata->ciphertext.data,
7252 tdata->ciphertext.len_bits >> 3);
7254 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7255 + (tdata->digest_enc.offset == 0 ?
7256 plaintext_pad_len : tdata->digest_enc.offset);
7258 debug_hexdump(stdout, "digest:", ut_params->digest,
7259 tdata->digest_enc.len);
7260 debug_hexdump(stdout, "digest expected:",
7261 tdata->digest_enc.data,
7262 tdata->digest_enc.len);
7267 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7269 tdata->plaintext.data,
7270 tdata->plaintext.len_bits >> 3,
7271 "Plaintext data not as expected");
7273 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7275 tdata->ciphertext.data,
7276 tdata->validDataLen.len_bits,
7277 "Ciphertext data not as expected");
7279 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7281 tdata->digest_enc.data,
7282 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7283 "Generated auth tag not as expected");
7286 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7287 "crypto op processing failed");
7293 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7294 uint8_t op_mode, uint8_t verify)
7296 struct crypto_testsuite_params *ts_params = &testsuite_params;
7297 struct crypto_unittest_params *ut_params = &unittest_params;
7301 const uint8_t *plaintext = NULL;
7302 const uint8_t *ciphertext = NULL;
7303 const uint8_t *digest = NULL;
7304 unsigned int plaintext_pad_len;
7305 unsigned int plaintext_len;
7306 unsigned int ciphertext_pad_len;
7307 unsigned int ciphertext_len;
7308 uint8_t buffer[10000];
7309 uint8_t digest_buffer[10000];
7311 struct rte_cryptodev_info dev_info;
7312 struct rte_crypto_op *op;
7314 /* Check if device supports particular algorithms */
7315 if (test_mixed_check_if_unsupported(tdata))
7316 return TEST_SKIPPED;
7317 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7318 return TEST_SKIPPED;
7320 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7322 uint64_t feat_flags = dev_info.feature_flags;
7324 if (op_mode == IN_PLACE) {
7325 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7326 printf("Device doesn't support in-place scatter-gather "
7327 "in both input and output mbufs.\n");
7328 return TEST_SKIPPED;
7331 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7332 printf("Device doesn't support out-of-place scatter-gather "
7333 "in both input and output mbufs.\n");
7334 return TEST_SKIPPED;
7336 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7337 printf("Device doesn't support digest encrypted.\n");
7338 return TEST_SKIPPED;
7342 /* Create the session */
7344 retval = create_wireless_algo_cipher_auth_session(
7345 ts_params->valid_devs[0],
7346 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7347 RTE_CRYPTO_AUTH_OP_VERIFY,
7350 tdata->auth_key.data, tdata->auth_key.len,
7351 tdata->auth_iv.len, tdata->digest_enc.len,
7352 tdata->cipher_iv.len);
7354 retval = create_wireless_algo_auth_cipher_session(
7355 ts_params->valid_devs[0],
7356 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7357 RTE_CRYPTO_AUTH_OP_GENERATE,
7360 tdata->auth_key.data, tdata->auth_key.len,
7361 tdata->auth_iv.len, tdata->digest_enc.len,
7362 tdata->cipher_iv.len);
7366 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7367 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7368 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7369 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7371 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7372 ciphertext_pad_len, 15, 0);
7373 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7374 "Failed to allocate input buffer in mempool");
7376 if (op_mode == OUT_OF_PLACE) {
7377 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7378 plaintext_pad_len, 15, 0);
7379 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7380 "Failed to allocate output buffer in mempool");
7384 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7385 tdata->ciphertext.data);
7386 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7387 ciphertext_len, buffer);
7388 debug_hexdump(stdout, "ciphertext:", ciphertext,
7391 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7392 tdata->plaintext.data);
7393 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7394 plaintext_len, buffer);
7395 debug_hexdump(stdout, "plaintext:", plaintext,
7398 memset(buffer, 0, sizeof(buffer));
7400 /* Create the operation */
7401 retval = create_wireless_algo_auth_cipher_operation(
7402 tdata->digest_enc.data, tdata->digest_enc.len,
7403 tdata->cipher_iv.data, tdata->cipher_iv.len,
7404 tdata->auth_iv.data, tdata->auth_iv.len,
7405 (tdata->digest_enc.offset == 0 ?
7407 : tdata->digest_enc.offset),
7408 tdata->validCipherLen.len_bits,
7409 tdata->cipher.offset_bits,
7410 tdata->validAuthLen.len_bits,
7411 tdata->auth.offset_bits,
7412 op_mode, 1, verify);
7417 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7419 /* Check if the op failed because the device doesn't */
7420 /* support this particular combination of algorithms */
7421 if (op == NULL && ut_params->op->status ==
7422 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7423 printf("Device doesn't support this mixed combination. "
7425 return TEST_SKIPPED;
7429 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7431 ut_params->obuf = (op_mode == IN_PLACE ?
7432 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7435 if (ut_params->obuf)
7436 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7437 plaintext_len, buffer);
7439 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7440 plaintext_len, buffer);
7442 debug_hexdump(stdout, "plaintext:", plaintext,
7443 (tdata->plaintext.len_bits >> 3) -
7444 tdata->digest_enc.len);
7445 debug_hexdump(stdout, "plaintext expected:",
7446 tdata->plaintext.data,
7447 (tdata->plaintext.len_bits >> 3) -
7448 tdata->digest_enc.len);
7450 if (ut_params->obuf)
7451 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7452 ciphertext_len, buffer);
7454 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7455 ciphertext_len, buffer);
7457 debug_hexdump(stdout, "ciphertext:", ciphertext,
7459 debug_hexdump(stdout, "ciphertext expected:",
7460 tdata->ciphertext.data,
7461 tdata->ciphertext.len_bits >> 3);
7463 if (ut_params->obuf)
7464 digest = rte_pktmbuf_read(ut_params->obuf,
7465 (tdata->digest_enc.offset == 0 ?
7467 tdata->digest_enc.offset),
7468 tdata->digest_enc.len, digest_buffer);
7470 digest = rte_pktmbuf_read(ut_params->ibuf,
7471 (tdata->digest_enc.offset == 0 ?
7473 tdata->digest_enc.offset),
7474 tdata->digest_enc.len, digest_buffer);
7476 debug_hexdump(stdout, "digest:", digest,
7477 tdata->digest_enc.len);
7478 debug_hexdump(stdout, "digest expected:",
7479 tdata->digest_enc.data, tdata->digest_enc.len);
7484 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7486 tdata->plaintext.data,
7487 tdata->plaintext.len_bits >> 3,
7488 "Plaintext data not as expected");
7490 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7492 tdata->ciphertext.data,
7493 tdata->validDataLen.len_bits,
7494 "Ciphertext data not as expected");
7495 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7497 tdata->digest_enc.data,
7498 tdata->digest_enc.len,
7499 "Generated auth tag not as expected");
7502 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7503 "crypto op processing failed");
7508 /** AUTH AES CMAC + CIPHER AES CTR */
7511 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7513 return test_mixed_auth_cipher(
7514 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7518 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7520 return test_mixed_auth_cipher(
7521 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7525 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7527 return test_mixed_auth_cipher_sgl(
7528 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7532 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7534 return test_mixed_auth_cipher_sgl(
7535 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7539 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7541 return test_mixed_auth_cipher(
7542 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7546 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7548 return test_mixed_auth_cipher(
7549 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7553 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7555 return test_mixed_auth_cipher_sgl(
7556 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7560 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7562 return test_mixed_auth_cipher_sgl(
7563 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7566 /** MIXED AUTH + CIPHER */
7569 test_auth_zuc_cipher_snow_test_case_1(void)
7571 return test_mixed_auth_cipher(
7572 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7576 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7578 return test_mixed_auth_cipher(
7579 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7583 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7585 return test_mixed_auth_cipher(
7586 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7590 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7592 return test_mixed_auth_cipher(
7593 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7597 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7599 return test_mixed_auth_cipher(
7600 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7604 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7606 return test_mixed_auth_cipher(
7607 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7611 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7613 return test_mixed_auth_cipher(
7614 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7618 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7620 return test_mixed_auth_cipher(
7621 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7625 test_auth_snow_cipher_zuc_test_case_1(void)
7627 return test_mixed_auth_cipher(
7628 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7632 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7634 return test_mixed_auth_cipher(
7635 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7639 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7641 return test_mixed_auth_cipher(
7642 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7646 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7648 return test_mixed_auth_cipher(
7649 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7653 test_auth_null_cipher_snow_test_case_1(void)
7655 return test_mixed_auth_cipher(
7656 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7660 test_verify_auth_null_cipher_snow_test_case_1(void)
7662 return test_mixed_auth_cipher(
7663 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7667 test_auth_null_cipher_zuc_test_case_1(void)
7669 return test_mixed_auth_cipher(
7670 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7674 test_verify_auth_null_cipher_zuc_test_case_1(void)
7676 return test_mixed_auth_cipher(
7677 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7681 test_auth_snow_cipher_null_test_case_1(void)
7683 return test_mixed_auth_cipher(
7684 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7688 test_verify_auth_snow_cipher_null_test_case_1(void)
7690 return test_mixed_auth_cipher(
7691 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7695 test_auth_zuc_cipher_null_test_case_1(void)
7697 return test_mixed_auth_cipher(
7698 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7702 test_verify_auth_zuc_cipher_null_test_case_1(void)
7704 return test_mixed_auth_cipher(
7705 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7709 test_auth_null_cipher_aes_ctr_test_case_1(void)
7711 return test_mixed_auth_cipher(
7712 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7716 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7718 return test_mixed_auth_cipher(
7719 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7723 test_auth_aes_cmac_cipher_null_test_case_1(void)
7725 return test_mixed_auth_cipher(
7726 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7730 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7732 return test_mixed_auth_cipher(
7733 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7736 /* ***** AEAD algorithm Tests ***** */
7739 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7740 enum rte_crypto_aead_operation op,
7741 const uint8_t *key, const uint8_t key_len,
7742 const uint16_t aad_len, const uint8_t auth_len,
7745 uint8_t aead_key[key_len];
7747 struct crypto_testsuite_params *ts_params = &testsuite_params;
7748 struct crypto_unittest_params *ut_params = &unittest_params;
7750 memcpy(aead_key, key, key_len);
7752 /* Setup AEAD Parameters */
7753 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7754 ut_params->aead_xform.next = NULL;
7755 ut_params->aead_xform.aead.algo = algo;
7756 ut_params->aead_xform.aead.op = op;
7757 ut_params->aead_xform.aead.key.data = aead_key;
7758 ut_params->aead_xform.aead.key.length = key_len;
7759 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7760 ut_params->aead_xform.aead.iv.length = iv_len;
7761 ut_params->aead_xform.aead.digest_length = auth_len;
7762 ut_params->aead_xform.aead.aad_length = aad_len;
7764 debug_hexdump(stdout, "key:", key, key_len);
7766 /* Create Crypto session*/
7767 ut_params->sess = rte_cryptodev_sym_session_create(
7768 ts_params->session_mpool);
7770 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7771 &ut_params->aead_xform,
7772 ts_params->session_priv_mpool);
7774 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7780 create_aead_xform(struct rte_crypto_op *op,
7781 enum rte_crypto_aead_algorithm algo,
7782 enum rte_crypto_aead_operation aead_op,
7783 uint8_t *key, const uint8_t key_len,
7784 const uint8_t aad_len, const uint8_t auth_len,
7787 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7788 "failed to allocate space for crypto transform");
7790 struct rte_crypto_sym_op *sym_op = op->sym;
7792 /* Setup AEAD Parameters */
7793 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7794 sym_op->xform->next = NULL;
7795 sym_op->xform->aead.algo = algo;
7796 sym_op->xform->aead.op = aead_op;
7797 sym_op->xform->aead.key.data = key;
7798 sym_op->xform->aead.key.length = key_len;
7799 sym_op->xform->aead.iv.offset = IV_OFFSET;
7800 sym_op->xform->aead.iv.length = iv_len;
7801 sym_op->xform->aead.digest_length = auth_len;
7802 sym_op->xform->aead.aad_length = aad_len;
7804 debug_hexdump(stdout, "key:", key, key_len);
7810 create_aead_operation(enum rte_crypto_aead_operation op,
7811 const struct aead_test_data *tdata)
7813 struct crypto_testsuite_params *ts_params = &testsuite_params;
7814 struct crypto_unittest_params *ut_params = &unittest_params;
7816 uint8_t *plaintext, *ciphertext;
7817 unsigned int aad_pad_len, plaintext_pad_len;
7819 /* Generate Crypto op data structure */
7820 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7821 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7822 TEST_ASSERT_NOT_NULL(ut_params->op,
7823 "Failed to allocate symmetric crypto operation struct");
7825 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7827 /* Append aad data */
7828 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7829 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7830 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7832 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7833 "no room to append aad");
7835 sym_op->aead.aad.phys_addr =
7836 rte_pktmbuf_iova(ut_params->ibuf);
7837 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7838 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7839 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7842 /* Append IV at the end of the crypto operation*/
7843 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7844 uint8_t *, IV_OFFSET);
7846 /* Copy IV 1 byte after the IV pointer, according to the API */
7847 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7848 debug_hexdump(stdout, "iv:", iv_ptr,
7851 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7852 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7854 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7855 "no room to append aad");
7857 sym_op->aead.aad.phys_addr =
7858 rte_pktmbuf_iova(ut_params->ibuf);
7859 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7860 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7863 /* Append IV at the end of the crypto operation*/
7864 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7865 uint8_t *, IV_OFFSET);
7867 if (tdata->iv.len == 0) {
7868 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7869 debug_hexdump(stdout, "iv:", iv_ptr,
7872 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7873 debug_hexdump(stdout, "iv:", iv_ptr,
7878 /* Append plaintext/ciphertext */
7879 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7880 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7881 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7883 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7885 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7886 debug_hexdump(stdout, "plaintext:", plaintext,
7887 tdata->plaintext.len);
7889 if (ut_params->obuf) {
7890 ciphertext = (uint8_t *)rte_pktmbuf_append(
7892 plaintext_pad_len + aad_pad_len);
7893 TEST_ASSERT_NOT_NULL(ciphertext,
7894 "no room to append ciphertext");
7896 memset(ciphertext + aad_pad_len, 0,
7897 tdata->ciphertext.len);
7900 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7901 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7903 TEST_ASSERT_NOT_NULL(ciphertext,
7904 "no room to append ciphertext");
7906 memcpy(ciphertext, tdata->ciphertext.data,
7907 tdata->ciphertext.len);
7908 debug_hexdump(stdout, "ciphertext:", ciphertext,
7909 tdata->ciphertext.len);
7911 if (ut_params->obuf) {
7912 plaintext = (uint8_t *)rte_pktmbuf_append(
7914 plaintext_pad_len + aad_pad_len);
7915 TEST_ASSERT_NOT_NULL(plaintext,
7916 "no room to append plaintext");
7918 memset(plaintext + aad_pad_len, 0,
7919 tdata->plaintext.len);
7923 /* Append digest data */
7924 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7925 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7926 ut_params->obuf ? ut_params->obuf :
7928 tdata->auth_tag.len);
7929 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7930 "no room to append digest");
7931 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7932 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7933 ut_params->obuf ? ut_params->obuf :
7938 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7939 ut_params->ibuf, tdata->auth_tag.len);
7940 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7941 "no room to append digest");
7942 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7944 plaintext_pad_len + aad_pad_len);
7946 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7947 tdata->auth_tag.len);
7948 debug_hexdump(stdout, "digest:",
7949 sym_op->aead.digest.data,
7950 tdata->auth_tag.len);
7953 sym_op->aead.data.length = tdata->plaintext.len;
7954 sym_op->aead.data.offset = aad_pad_len;
7960 test_authenticated_encryption(const struct aead_test_data *tdata)
7962 struct crypto_testsuite_params *ts_params = &testsuite_params;
7963 struct crypto_unittest_params *ut_params = &unittest_params;
7966 uint8_t *ciphertext, *auth_tag;
7967 uint16_t plaintext_pad_len;
7969 struct rte_cryptodev_info dev_info;
7971 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7972 uint64_t feat_flags = dev_info.feature_flags;
7974 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7975 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7976 printf("Device doesn't support RAW data-path APIs.\n");
7977 return TEST_SKIPPED;
7980 /* Verify the capabilities */
7981 struct rte_cryptodev_sym_capability_idx cap_idx;
7982 const struct rte_cryptodev_symmetric_capability *capability;
7983 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7984 cap_idx.algo.aead = tdata->algo;
7985 capability = rte_cryptodev_sym_capability_get(
7986 ts_params->valid_devs[0], &cap_idx);
7987 if (capability == NULL)
7988 return TEST_SKIPPED;
7989 if (rte_cryptodev_sym_capability_check_aead(
7990 capability, tdata->key.len, tdata->auth_tag.len,
7991 tdata->aad.len, tdata->iv.len))
7992 return TEST_SKIPPED;
7994 /* Create AEAD session */
7995 retval = create_aead_session(ts_params->valid_devs[0],
7997 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7998 tdata->key.data, tdata->key.len,
7999 tdata->aad.len, tdata->auth_tag.len,
8004 if (tdata->aad.len > MBUF_SIZE) {
8005 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8006 /* Populate full size of add data */
8007 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8008 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8010 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8012 /* clear mbuf payload */
8013 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8014 rte_pktmbuf_tailroom(ut_params->ibuf));
8016 /* Create AEAD operation */
8017 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8021 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8023 ut_params->op->sym->m_src = ut_params->ibuf;
8025 /* Process crypto operation */
8026 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8027 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8028 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8029 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8030 ut_params->op, 0, 0, 0, 0);
8032 TEST_ASSERT_NOT_NULL(
8033 process_crypto_request(ts_params->valid_devs[0],
8034 ut_params->op), "failed to process sym crypto op");
8036 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8037 "crypto op processing failed");
8039 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8041 if (ut_params->op->sym->m_dst) {
8042 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8044 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8045 uint8_t *, plaintext_pad_len);
8047 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8049 ut_params->op->sym->cipher.data.offset);
8050 auth_tag = ciphertext + plaintext_pad_len;
8053 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8054 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8057 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8059 tdata->ciphertext.data,
8060 tdata->ciphertext.len,
8061 "Ciphertext data not as expected");
8063 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8065 tdata->auth_tag.data,
8066 tdata->auth_tag.len,
8067 "Generated auth tag not as expected");
8073 #ifdef RTE_LIB_SECURITY
8075 security_proto_supported(enum rte_security_session_action_type action,
8076 enum rte_security_session_protocol proto)
8078 struct crypto_testsuite_params *ts_params = &testsuite_params;
8080 const struct rte_security_capability *capabilities;
8081 const struct rte_security_capability *capability;
8084 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8085 rte_cryptodev_get_sec_ctx(
8086 ts_params->valid_devs[0]);
8089 capabilities = rte_security_capabilities_get(ctx);
8091 if (capabilities == NULL)
8094 while ((capability = &capabilities[i++])->action !=
8095 RTE_SECURITY_ACTION_TYPE_NONE) {
8096 if (capability->action == action &&
8097 capability->protocol == proto)
8104 /* Basic algorithm run function for async inplace mode.
8105 * Creates a session from input parameters and runs one operation
8106 * on input_vec. Checks the output of the crypto operation against
8109 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8110 enum rte_crypto_auth_operation opa,
8111 const uint8_t *input_vec, unsigned int input_vec_len,
8112 const uint8_t *output_vec,
8113 unsigned int output_vec_len,
8114 enum rte_crypto_cipher_algorithm cipher_alg,
8115 const uint8_t *cipher_key, uint32_t cipher_key_len,
8116 enum rte_crypto_auth_algorithm auth_alg,
8117 const uint8_t *auth_key, uint32_t auth_key_len,
8118 uint8_t bearer, enum rte_security_pdcp_domain domain,
8119 uint8_t packet_direction, uint8_t sn_size,
8120 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8122 struct crypto_testsuite_params *ts_params = &testsuite_params;
8123 struct crypto_unittest_params *ut_params = &unittest_params;
8125 int ret = TEST_SUCCESS;
8126 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8127 rte_cryptodev_get_sec_ctx(
8128 ts_params->valid_devs[0]);
8130 /* Verify the capabilities */
8131 struct rte_security_capability_idx sec_cap_idx;
8133 sec_cap_idx.action = ut_params->type;
8134 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8135 sec_cap_idx.pdcp.domain = domain;
8136 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8137 return TEST_SKIPPED;
8139 /* Generate test mbuf data */
8140 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8142 /* clear mbuf payload */
8143 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8144 rte_pktmbuf_tailroom(ut_params->ibuf));
8146 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8148 memcpy(plaintext, input_vec, input_vec_len);
8150 /* Out of place support */
8153 * For out-op-place we need to alloc another mbuf
8155 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8156 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8159 /* Setup Cipher Parameters */
8160 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8161 ut_params->cipher_xform.cipher.algo = cipher_alg;
8162 ut_params->cipher_xform.cipher.op = opc;
8163 ut_params->cipher_xform.cipher.key.data = cipher_key;
8164 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8165 ut_params->cipher_xform.cipher.iv.length =
8166 packet_direction ? 4 : 0;
8167 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8169 /* Setup HMAC Parameters if ICV header is required */
8170 if (auth_alg != 0) {
8171 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8172 ut_params->auth_xform.next = NULL;
8173 ut_params->auth_xform.auth.algo = auth_alg;
8174 ut_params->auth_xform.auth.op = opa;
8175 ut_params->auth_xform.auth.key.data = auth_key;
8176 ut_params->auth_xform.auth.key.length = auth_key_len;
8178 ut_params->cipher_xform.next = &ut_params->auth_xform;
8180 ut_params->cipher_xform.next = NULL;
8183 struct rte_security_session_conf sess_conf = {
8184 .action_type = ut_params->type,
8185 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8189 .pkt_dir = packet_direction,
8191 .hfn = packet_direction ? 0 : hfn,
8193 * hfn can be set as pdcp_test_hfn[i]
8194 * if hfn_ovrd is not set. Here, PDCP
8195 * packet direction is just used to
8196 * run half of the cases with session
8197 * HFN and other half with per packet
8200 .hfn_threshold = hfn_threshold,
8201 .hfn_ovrd = packet_direction ? 1 : 0,
8202 .sdap_enabled = sdap,
8204 .crypto_xform = &ut_params->cipher_xform
8207 /* Create security session */
8208 ut_params->sec_session = rte_security_session_create(ctx,
8209 &sess_conf, ts_params->session_mpool,
8210 ts_params->session_priv_mpool);
8212 if (!ut_params->sec_session) {
8213 printf("TestCase %s()-%d line %d failed %s: ",
8214 __func__, i, __LINE__, "Failed to allocate session");
8219 /* Generate crypto op data structure */
8220 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8221 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8222 if (!ut_params->op) {
8223 printf("TestCase %s()-%d line %d failed %s: ",
8224 __func__, i, __LINE__,
8225 "Failed to allocate symmetric crypto operation struct");
8230 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8231 uint32_t *, IV_OFFSET);
8232 *per_pkt_hfn = packet_direction ? hfn : 0;
8234 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8236 /* set crypto operation source mbuf */
8237 ut_params->op->sym->m_src = ut_params->ibuf;
8239 ut_params->op->sym->m_dst = ut_params->obuf;
8241 /* Process crypto operation */
8242 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8244 printf("TestCase %s()-%d line %d failed %s: ",
8245 __func__, i, __LINE__,
8246 "failed to process sym crypto op");
8251 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8252 printf("TestCase %s()-%d line %d failed %s: ",
8253 __func__, i, __LINE__, "crypto op processing failed");
8259 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8262 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8266 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8267 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8268 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8269 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8275 rte_crypto_op_free(ut_params->op);
8276 ut_params->op = NULL;
8278 if (ut_params->sec_session)
8279 rte_security_session_destroy(ctx, ut_params->sec_session);
8280 ut_params->sec_session = NULL;
8282 rte_pktmbuf_free(ut_params->ibuf);
8283 ut_params->ibuf = NULL;
8285 rte_pktmbuf_free(ut_params->obuf);
8286 ut_params->obuf = NULL;
8293 test_pdcp_proto_SGL(int i, int oop,
8294 enum rte_crypto_cipher_operation opc,
8295 enum rte_crypto_auth_operation opa,
8297 unsigned int input_vec_len,
8298 uint8_t *output_vec,
8299 unsigned int output_vec_len,
8301 uint32_t fragsz_oop)
8303 struct crypto_testsuite_params *ts_params = &testsuite_params;
8304 struct crypto_unittest_params *ut_params = &unittest_params;
8306 struct rte_mbuf *buf, *buf_oop = NULL;
8307 int ret = TEST_SUCCESS;
8311 unsigned int trn_data = 0;
8312 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8313 rte_cryptodev_get_sec_ctx(
8314 ts_params->valid_devs[0]);
8316 /* Verify the capabilities */
8317 struct rte_security_capability_idx sec_cap_idx;
8319 sec_cap_idx.action = ut_params->type;
8320 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8321 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8322 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8323 return TEST_SKIPPED;
8325 if (fragsz > input_vec_len)
8326 fragsz = input_vec_len;
8328 uint16_t plaintext_len = fragsz;
8329 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8331 if (fragsz_oop > output_vec_len)
8332 frag_size_oop = output_vec_len;
8335 if (input_vec_len % fragsz != 0) {
8336 if (input_vec_len / fragsz + 1 > 16)
8338 } else if (input_vec_len / fragsz > 16)
8341 /* Out of place support */
8344 * For out-op-place we need to alloc another mbuf
8346 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8347 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8348 buf_oop = ut_params->obuf;
8351 /* Generate test mbuf data */
8352 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8354 /* clear mbuf payload */
8355 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8356 rte_pktmbuf_tailroom(ut_params->ibuf));
8358 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8360 memcpy(plaintext, input_vec, plaintext_len);
8361 trn_data += plaintext_len;
8363 buf = ut_params->ibuf;
8366 * Loop until no more fragments
8369 while (trn_data < input_vec_len) {
8371 to_trn = (input_vec_len - trn_data < fragsz) ?
8372 (input_vec_len - trn_data) : fragsz;
8374 to_trn_tbl[ecx++] = to_trn;
8376 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8379 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8380 rte_pktmbuf_tailroom(buf));
8383 if (oop && !fragsz_oop) {
8385 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8386 buf_oop = buf_oop->next;
8387 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8388 0, rte_pktmbuf_tailroom(buf_oop));
8389 rte_pktmbuf_append(buf_oop, to_trn);
8392 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8395 memcpy(plaintext, input_vec + trn_data, to_trn);
8399 ut_params->ibuf->nb_segs = segs;
8402 if (fragsz_oop && oop) {
8406 trn_data = frag_size_oop;
8407 while (trn_data < output_vec_len) {
8410 (output_vec_len - trn_data <
8412 (output_vec_len - trn_data) :
8415 to_trn_tbl[ecx++] = to_trn;
8418 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8419 buf_oop = buf_oop->next;
8420 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8421 0, rte_pktmbuf_tailroom(buf_oop));
8422 rte_pktmbuf_append(buf_oop, to_trn);
8426 ut_params->obuf->nb_segs = segs;
8429 /* Setup Cipher Parameters */
8430 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8431 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8432 ut_params->cipher_xform.cipher.op = opc;
8433 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8434 ut_params->cipher_xform.cipher.key.length =
8435 pdcp_test_params[i].cipher_key_len;
8436 ut_params->cipher_xform.cipher.iv.length = 0;
8438 /* Setup HMAC Parameters if ICV header is required */
8439 if (pdcp_test_params[i].auth_alg != 0) {
8440 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8441 ut_params->auth_xform.next = NULL;
8442 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8443 ut_params->auth_xform.auth.op = opa;
8444 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8445 ut_params->auth_xform.auth.key.length =
8446 pdcp_test_params[i].auth_key_len;
8448 ut_params->cipher_xform.next = &ut_params->auth_xform;
8450 ut_params->cipher_xform.next = NULL;
8453 struct rte_security_session_conf sess_conf = {
8454 .action_type = ut_params->type,
8455 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8457 .bearer = pdcp_test_bearer[i],
8458 .domain = pdcp_test_params[i].domain,
8459 .pkt_dir = pdcp_test_packet_direction[i],
8460 .sn_size = pdcp_test_data_sn_size[i],
8461 .hfn = pdcp_test_hfn[i],
8462 .hfn_threshold = pdcp_test_hfn_threshold[i],
8465 .crypto_xform = &ut_params->cipher_xform
8468 /* Create security session */
8469 ut_params->sec_session = rte_security_session_create(ctx,
8470 &sess_conf, ts_params->session_mpool,
8471 ts_params->session_priv_mpool);
8473 if (!ut_params->sec_session) {
8474 printf("TestCase %s()-%d line %d failed %s: ",
8475 __func__, i, __LINE__, "Failed to allocate session");
8480 /* Generate crypto op data structure */
8481 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8482 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8483 if (!ut_params->op) {
8484 printf("TestCase %s()-%d line %d failed %s: ",
8485 __func__, i, __LINE__,
8486 "Failed to allocate symmetric crypto operation struct");
8491 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8493 /* set crypto operation source mbuf */
8494 ut_params->op->sym->m_src = ut_params->ibuf;
8496 ut_params->op->sym->m_dst = ut_params->obuf;
8498 /* Process crypto operation */
8499 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8501 printf("TestCase %s()-%d line %d failed %s: ",
8502 __func__, i, __LINE__,
8503 "failed to process sym crypto op");
8508 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8509 printf("TestCase %s()-%d line %d failed %s: ",
8510 __func__, i, __LINE__, "crypto op processing failed");
8516 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8519 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8523 fragsz = frag_size_oop;
8524 if (memcmp(ciphertext, output_vec, fragsz)) {
8525 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8526 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8527 rte_hexdump(stdout, "reference", output_vec, fragsz);
8532 buf = ut_params->op->sym->m_src->next;
8534 buf = ut_params->op->sym->m_dst->next;
8536 unsigned int off = fragsz;
8540 ciphertext = rte_pktmbuf_mtod(buf,
8542 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8543 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8544 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8545 rte_hexdump(stdout, "reference", output_vec + off,
8550 off += to_trn_tbl[ecx++];
8554 rte_crypto_op_free(ut_params->op);
8555 ut_params->op = NULL;
8557 if (ut_params->sec_session)
8558 rte_security_session_destroy(ctx, ut_params->sec_session);
8559 ut_params->sec_session = NULL;
8561 rte_pktmbuf_free(ut_params->ibuf);
8562 ut_params->ibuf = NULL;
8564 rte_pktmbuf_free(ut_params->obuf);
8565 ut_params->obuf = NULL;
8572 test_pdcp_proto_cplane_encap(int i)
8574 return test_pdcp_proto(
8575 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8576 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8577 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8578 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8579 pdcp_test_params[i].cipher_key_len,
8580 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8581 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8582 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8583 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8584 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8588 test_pdcp_proto_uplane_encap(int i)
8590 return test_pdcp_proto(
8591 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8592 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8593 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8594 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8595 pdcp_test_params[i].cipher_key_len,
8596 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8597 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8598 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8599 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8600 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8604 test_pdcp_proto_uplane_encap_with_int(int i)
8606 return test_pdcp_proto(
8607 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8608 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8609 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8610 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8611 pdcp_test_params[i].cipher_key_len,
8612 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8613 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8614 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8615 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8616 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8620 test_pdcp_proto_cplane_decap(int i)
8622 return test_pdcp_proto(
8623 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8624 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8625 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8626 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8627 pdcp_test_params[i].cipher_key_len,
8628 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8629 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8630 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8631 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8632 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8636 test_pdcp_proto_uplane_decap(int i)
8638 return test_pdcp_proto(
8639 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8640 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8641 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8642 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8643 pdcp_test_params[i].cipher_key_len,
8644 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8645 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8646 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8647 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8648 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8652 test_pdcp_proto_uplane_decap_with_int(int i)
8654 return test_pdcp_proto(
8655 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8656 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8657 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8658 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8659 pdcp_test_params[i].cipher_key_len,
8660 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8661 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8662 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8663 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8664 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8668 test_PDCP_PROTO_SGL_in_place_32B(void)
8670 /* i can be used for running any PDCP case
8671 * In this case it is uplane 12-bit AES-SNOW DL encap
8673 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8674 return test_pdcp_proto_SGL(i, IN_PLACE,
8675 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8676 RTE_CRYPTO_AUTH_OP_GENERATE,
8677 pdcp_test_data_in[i],
8678 pdcp_test_data_in_len[i],
8679 pdcp_test_data_out[i],
8680 pdcp_test_data_in_len[i]+4,
8684 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8686 /* i can be used for running any PDCP case
8687 * In this case it is uplane 18-bit NULL-NULL DL encap
8689 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8690 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8691 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8692 RTE_CRYPTO_AUTH_OP_GENERATE,
8693 pdcp_test_data_in[i],
8694 pdcp_test_data_in_len[i],
8695 pdcp_test_data_out[i],
8696 pdcp_test_data_in_len[i]+4,
8700 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8702 /* i can be used for running any PDCP case
8703 * In this case it is uplane 18-bit AES DL encap
8705 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8707 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8708 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8709 RTE_CRYPTO_AUTH_OP_GENERATE,
8710 pdcp_test_data_in[i],
8711 pdcp_test_data_in_len[i],
8712 pdcp_test_data_out[i],
8713 pdcp_test_data_in_len[i],
8717 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8719 /* i can be used for running any PDCP case
8720 * In this case it is cplane 12-bit AES-ZUC DL encap
8722 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8723 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8724 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8725 RTE_CRYPTO_AUTH_OP_GENERATE,
8726 pdcp_test_data_in[i],
8727 pdcp_test_data_in_len[i],
8728 pdcp_test_data_out[i],
8729 pdcp_test_data_in_len[i]+4,
8734 test_PDCP_SDAP_PROTO_encap_all(void)
8736 int i = 0, size = 0;
8737 int err, all_err = TEST_SUCCESS;
8738 const struct pdcp_sdap_test *cur_test;
8740 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8742 for (i = 0; i < size; i++) {
8743 cur_test = &list_pdcp_sdap_tests[i];
8744 err = test_pdcp_proto(
8745 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8746 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8747 cur_test->in_len, cur_test->data_out,
8748 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8749 cur_test->param.cipher_alg, cur_test->cipher_key,
8750 cur_test->param.cipher_key_len,
8751 cur_test->param.auth_alg,
8752 cur_test->auth_key, cur_test->param.auth_key_len,
8753 cur_test->bearer, cur_test->param.domain,
8754 cur_test->packet_direction, cur_test->sn_size,
8756 cur_test->hfn_threshold, SDAP_ENABLED);
8758 printf("\t%d) %s: Encapsulation failed\n",
8760 cur_test->param.name);
8763 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8764 cur_test->param.name);
8770 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8772 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8776 test_PDCP_SDAP_PROTO_decap_all(void)
8778 int i = 0, size = 0;
8779 int err, all_err = TEST_SUCCESS;
8780 const struct pdcp_sdap_test *cur_test;
8782 size = ARRAY_SIZE(list_pdcp_sdap_tests);
8784 for (i = 0; i < size; i++) {
8785 cur_test = &list_pdcp_sdap_tests[i];
8786 err = test_pdcp_proto(
8787 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8788 RTE_CRYPTO_AUTH_OP_VERIFY,
8790 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8791 cur_test->data_in, cur_test->in_len,
8792 cur_test->param.cipher_alg,
8793 cur_test->cipher_key, cur_test->param.cipher_key_len,
8794 cur_test->param.auth_alg, cur_test->auth_key,
8795 cur_test->param.auth_key_len, cur_test->bearer,
8796 cur_test->param.domain, cur_test->packet_direction,
8797 cur_test->sn_size, cur_test->hfn,
8798 cur_test->hfn_threshold, SDAP_ENABLED);
8800 printf("\t%d) %s: Decapsulation failed\n",
8802 cur_test->param.name);
8805 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8806 cur_test->param.name);
8812 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8814 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8818 test_PDCP_PROTO_all(void)
8820 struct crypto_testsuite_params *ts_params = &testsuite_params;
8821 struct crypto_unittest_params *ut_params = &unittest_params;
8822 struct rte_cryptodev_info dev_info;
8825 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8826 uint64_t feat_flags = dev_info.feature_flags;
8828 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8829 return TEST_SKIPPED;
8831 /* Set action type */
8832 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8833 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8836 if (security_proto_supported(ut_params->type,
8837 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8838 return TEST_SKIPPED;
8840 status = test_PDCP_PROTO_cplane_encap_all();
8841 status += test_PDCP_PROTO_cplane_decap_all();
8842 status += test_PDCP_PROTO_uplane_encap_all();
8843 status += test_PDCP_PROTO_uplane_decap_all();
8844 status += test_PDCP_PROTO_SGL_in_place_32B();
8845 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8846 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8847 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8848 status += test_PDCP_SDAP_PROTO_encap_all();
8849 status += test_PDCP_SDAP_PROTO_decap_all();
8854 return TEST_SUCCESS;
8858 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8860 struct crypto_testsuite_params *ts_params = &testsuite_params;
8861 struct crypto_unittest_params *ut_params = &unittest_params;
8862 uint8_t *plaintext, *ciphertext;
8864 int32_t cipher_len, crc_len;
8865 uint32_t crc_data_len;
8866 int ret = TEST_SUCCESS;
8868 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8869 rte_cryptodev_get_sec_ctx(
8870 ts_params->valid_devs[0]);
8872 /* Verify the capabilities */
8873 struct rte_security_capability_idx sec_cap_idx;
8874 const struct rte_security_capability *sec_cap;
8875 const struct rte_cryptodev_capabilities *crypto_cap;
8876 const struct rte_cryptodev_symmetric_capability *sym_cap;
8879 sec_cap_idx.action = ut_params->type;
8880 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8881 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8883 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8884 if (sec_cap == NULL)
8885 return TEST_SKIPPED;
8887 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8888 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8889 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8890 crypto_cap->sym.xform_type ==
8891 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8892 crypto_cap->sym.cipher.algo ==
8893 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8894 sym_cap = &crypto_cap->sym;
8895 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8902 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8903 return TEST_SKIPPED;
8905 /* Setup source mbuf payload */
8906 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8907 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8908 rte_pktmbuf_tailroom(ut_params->ibuf));
8910 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8911 d_td->ciphertext.len);
8913 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8915 /* Setup cipher session parameters */
8916 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8917 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8918 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8919 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8920 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8921 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8922 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8923 ut_params->cipher_xform.next = NULL;
8925 /* Setup DOCSIS session parameters */
8926 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8928 struct rte_security_session_conf sess_conf = {
8929 .action_type = ut_params->type,
8930 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8931 .docsis = ut_params->docsis_xform,
8932 .crypto_xform = &ut_params->cipher_xform,
8935 /* Create security session */
8936 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8937 ts_params->session_mpool,
8938 ts_params->session_priv_mpool);
8940 if (!ut_params->sec_session) {
8941 printf("TestCase %s(%d) line %d: %s\n",
8942 __func__, i, __LINE__, "failed to allocate session");
8947 /* Generate crypto op data structure */
8948 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8949 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8950 if (!ut_params->op) {
8951 printf("TestCase %s(%d) line %d: %s\n",
8952 __func__, i, __LINE__,
8953 "failed to allocate symmetric crypto operation");
8958 /* Setup CRC operation parameters */
8959 crc_len = d_td->ciphertext.no_crc == false ?
8960 (d_td->ciphertext.len -
8961 d_td->ciphertext.crc_offset -
8962 RTE_ETHER_CRC_LEN) :
8964 crc_len = crc_len > 0 ? crc_len : 0;
8965 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8966 ut_params->op->sym->auth.data.length = crc_len;
8967 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8969 /* Setup cipher operation parameters */
8970 cipher_len = d_td->ciphertext.no_cipher == false ?
8971 (d_td->ciphertext.len -
8972 d_td->ciphertext.cipher_offset) :
8974 cipher_len = cipher_len > 0 ? cipher_len : 0;
8975 ut_params->op->sym->cipher.data.length = cipher_len;
8976 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8978 /* Setup cipher IV */
8979 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8980 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8982 /* Attach session to operation */
8983 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8985 /* Set crypto operation mbufs */
8986 ut_params->op->sym->m_src = ut_params->ibuf;
8987 ut_params->op->sym->m_dst = NULL;
8989 /* Process crypto operation */
8990 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8992 printf("TestCase %s(%d) line %d: %s\n",
8993 __func__, i, __LINE__,
8994 "failed to process security crypto op");
8999 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9000 printf("TestCase %s(%d) line %d: %s\n",
9001 __func__, i, __LINE__, "crypto op processing failed");
9006 /* Validate plaintext */
9007 plaintext = ciphertext;
9009 if (memcmp(plaintext, d_td->plaintext.data,
9010 d_td->plaintext.len - crc_data_len)) {
9011 printf("TestCase %s(%d) line %d: %s\n",
9012 __func__, i, __LINE__, "plaintext not as expected\n");
9013 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9014 d_td->plaintext.len);
9015 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9021 rte_crypto_op_free(ut_params->op);
9022 ut_params->op = NULL;
9024 if (ut_params->sec_session)
9025 rte_security_session_destroy(ctx, ut_params->sec_session);
9026 ut_params->sec_session = NULL;
9028 rte_pktmbuf_free(ut_params->ibuf);
9029 ut_params->ibuf = NULL;
9035 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9037 struct crypto_testsuite_params *ts_params = &testsuite_params;
9038 struct crypto_unittest_params *ut_params = &unittest_params;
9039 uint8_t *plaintext, *ciphertext;
9041 int32_t cipher_len, crc_len;
9042 int ret = TEST_SUCCESS;
9044 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9045 rte_cryptodev_get_sec_ctx(
9046 ts_params->valid_devs[0]);
9048 /* Verify the capabilities */
9049 struct rte_security_capability_idx sec_cap_idx;
9050 const struct rte_security_capability *sec_cap;
9051 const struct rte_cryptodev_capabilities *crypto_cap;
9052 const struct rte_cryptodev_symmetric_capability *sym_cap;
9055 sec_cap_idx.action = ut_params->type;
9056 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9057 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9059 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9060 if (sec_cap == NULL)
9061 return TEST_SKIPPED;
9063 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9064 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9065 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9066 crypto_cap->sym.xform_type ==
9067 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9068 crypto_cap->sym.cipher.algo ==
9069 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9070 sym_cap = &crypto_cap->sym;
9071 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9078 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9079 return TEST_SKIPPED;
9081 /* Setup source mbuf payload */
9082 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9083 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9084 rte_pktmbuf_tailroom(ut_params->ibuf));
9086 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9087 d_td->plaintext.len);
9089 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9091 /* Setup cipher session parameters */
9092 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9093 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9094 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9095 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9096 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9097 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9098 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9099 ut_params->cipher_xform.next = NULL;
9101 /* Setup DOCSIS session parameters */
9102 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9104 struct rte_security_session_conf sess_conf = {
9105 .action_type = ut_params->type,
9106 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9107 .docsis = ut_params->docsis_xform,
9108 .crypto_xform = &ut_params->cipher_xform,
9111 /* Create security session */
9112 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9113 ts_params->session_mpool,
9114 ts_params->session_priv_mpool);
9116 if (!ut_params->sec_session) {
9117 printf("TestCase %s(%d) line %d: %s\n",
9118 __func__, i, __LINE__, "failed to allocate session");
9123 /* Generate crypto op data structure */
9124 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9125 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9126 if (!ut_params->op) {
9127 printf("TestCase %s(%d) line %d: %s\n",
9128 __func__, i, __LINE__,
9129 "failed to allocate security crypto operation");
9134 /* Setup CRC operation parameters */
9135 crc_len = d_td->plaintext.no_crc == false ?
9136 (d_td->plaintext.len -
9137 d_td->plaintext.crc_offset -
9138 RTE_ETHER_CRC_LEN) :
9140 crc_len = crc_len > 0 ? crc_len : 0;
9141 ut_params->op->sym->auth.data.length = crc_len;
9142 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9144 /* Setup cipher operation parameters */
9145 cipher_len = d_td->plaintext.no_cipher == false ?
9146 (d_td->plaintext.len -
9147 d_td->plaintext.cipher_offset) :
9149 cipher_len = cipher_len > 0 ? cipher_len : 0;
9150 ut_params->op->sym->cipher.data.length = cipher_len;
9151 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9153 /* Setup cipher IV */
9154 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9155 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9157 /* Attach session to operation */
9158 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9160 /* Set crypto operation mbufs */
9161 ut_params->op->sym->m_src = ut_params->ibuf;
9162 ut_params->op->sym->m_dst = NULL;
9164 /* Process crypto operation */
9165 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9167 printf("TestCase %s(%d) line %d: %s\n",
9168 __func__, i, __LINE__,
9169 "failed to process security crypto op");
9174 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9175 printf("TestCase %s(%d) line %d: %s\n",
9176 __func__, i, __LINE__, "crypto op processing failed");
9181 /* Validate ciphertext */
9182 ciphertext = plaintext;
9184 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9185 printf("TestCase %s(%d) line %d: %s\n",
9186 __func__, i, __LINE__, "ciphertext not as expected\n");
9187 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9188 d_td->ciphertext.len);
9189 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9195 rte_crypto_op_free(ut_params->op);
9196 ut_params->op = NULL;
9198 if (ut_params->sec_session)
9199 rte_security_session_destroy(ctx, ut_params->sec_session);
9200 ut_params->sec_session = NULL;
9202 rte_pktmbuf_free(ut_params->ibuf);
9203 ut_params->ibuf = NULL;
9208 #define TEST_DOCSIS_COUNT(func) do { \
9210 if (ret == TEST_SUCCESS) { \
9211 printf("\t%2d)", n++); \
9212 printf("+++++ PASSED:" #func"\n"); \
9214 } else if (ret == TEST_SKIPPED) { \
9215 printf("\t%2d)", n++); \
9216 printf("~~~~~ SKIPPED:" #func"\n"); \
9219 printf("\t%2d)", n++); \
9220 printf("----- FAILED:" #func"\n"); \
9226 test_DOCSIS_PROTO_uplink_all(void)
9228 int p = 0, s = 0, f = 0, n = 0;
9230 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9231 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9232 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9233 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9234 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9235 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9236 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9237 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9238 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9239 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9240 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9241 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9242 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9243 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9244 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9245 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9246 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9247 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9248 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9249 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9250 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9251 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9252 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9253 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9254 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9255 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9258 printf("## %s: %d passed out of %d (%d skipped)\n",
9265 test_DOCSIS_PROTO_downlink_all(void)
9267 int p = 0, s = 0, f = 0, n = 0;
9269 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9270 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9271 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9272 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9273 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9274 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9275 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9276 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9277 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9278 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9279 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9280 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9281 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9282 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9283 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9284 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9285 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9286 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9287 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9288 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9289 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9290 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9291 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9292 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9293 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9294 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9297 printf("## %s: %d passed out of %d (%d skipped)\n",
9304 test_DOCSIS_PROTO_all(void)
9306 struct crypto_testsuite_params *ts_params = &testsuite_params;
9307 struct crypto_unittest_params *ut_params = &unittest_params;
9308 struct rte_cryptodev_info dev_info;
9311 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9312 uint64_t feat_flags = dev_info.feature_flags;
9314 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9315 return TEST_SKIPPED;
9317 /* Set action type */
9318 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9319 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9322 if (security_proto_supported(ut_params->type,
9323 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9324 return TEST_SKIPPED;
9326 status = test_DOCSIS_PROTO_uplink_all();
9327 status += test_DOCSIS_PROTO_downlink_all();
9332 return TEST_SUCCESS;
9337 test_AES_GCM_authenticated_encryption_test_case_1(void)
9339 return test_authenticated_encryption(&gcm_test_case_1);
9343 test_AES_GCM_authenticated_encryption_test_case_2(void)
9345 return test_authenticated_encryption(&gcm_test_case_2);
9349 test_AES_GCM_authenticated_encryption_test_case_3(void)
9351 return test_authenticated_encryption(&gcm_test_case_3);
9355 test_AES_GCM_authenticated_encryption_test_case_4(void)
9357 return test_authenticated_encryption(&gcm_test_case_4);
9361 test_AES_GCM_authenticated_encryption_test_case_5(void)
9363 return test_authenticated_encryption(&gcm_test_case_5);
9367 test_AES_GCM_authenticated_encryption_test_case_6(void)
9369 return test_authenticated_encryption(&gcm_test_case_6);
9373 test_AES_GCM_authenticated_encryption_test_case_7(void)
9375 return test_authenticated_encryption(&gcm_test_case_7);
9379 test_AES_GCM_authenticated_encryption_test_case_8(void)
9381 return test_authenticated_encryption(&gcm_test_case_8);
9385 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9387 return test_authenticated_encryption(&gcm_J0_test_case_1);
9391 test_AES_GCM_auth_encryption_test_case_192_1(void)
9393 return test_authenticated_encryption(&gcm_test_case_192_1);
9397 test_AES_GCM_auth_encryption_test_case_192_2(void)
9399 return test_authenticated_encryption(&gcm_test_case_192_2);
9403 test_AES_GCM_auth_encryption_test_case_192_3(void)
9405 return test_authenticated_encryption(&gcm_test_case_192_3);
9409 test_AES_GCM_auth_encryption_test_case_192_4(void)
9411 return test_authenticated_encryption(&gcm_test_case_192_4);
9415 test_AES_GCM_auth_encryption_test_case_192_5(void)
9417 return test_authenticated_encryption(&gcm_test_case_192_5);
9421 test_AES_GCM_auth_encryption_test_case_192_6(void)
9423 return test_authenticated_encryption(&gcm_test_case_192_6);
9427 test_AES_GCM_auth_encryption_test_case_192_7(void)
9429 return test_authenticated_encryption(&gcm_test_case_192_7);
9433 test_AES_GCM_auth_encryption_test_case_256_1(void)
9435 return test_authenticated_encryption(&gcm_test_case_256_1);
9439 test_AES_GCM_auth_encryption_test_case_256_2(void)
9441 return test_authenticated_encryption(&gcm_test_case_256_2);
9445 test_AES_GCM_auth_encryption_test_case_256_3(void)
9447 return test_authenticated_encryption(&gcm_test_case_256_3);
9451 test_AES_GCM_auth_encryption_test_case_256_4(void)
9453 return test_authenticated_encryption(&gcm_test_case_256_4);
9457 test_AES_GCM_auth_encryption_test_case_256_5(void)
9459 return test_authenticated_encryption(&gcm_test_case_256_5);
9463 test_AES_GCM_auth_encryption_test_case_256_6(void)
9465 return test_authenticated_encryption(&gcm_test_case_256_6);
9469 test_AES_GCM_auth_encryption_test_case_256_7(void)
9471 return test_authenticated_encryption(&gcm_test_case_256_7);
9475 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9477 return test_authenticated_encryption(&gcm_test_case_aad_1);
9481 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9483 return test_authenticated_encryption(&gcm_test_case_aad_2);
9487 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9489 struct aead_test_data tdata;
9492 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9493 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9494 tdata.iv.data[0] += 1;
9495 res = test_authenticated_encryption(&tdata);
9496 if (res == TEST_SKIPPED)
9498 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9499 return TEST_SUCCESS;
9503 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9505 struct aead_test_data tdata;
9508 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9509 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9510 tdata.plaintext.data[0] += 1;
9511 res = test_authenticated_encryption(&tdata);
9512 if (res == TEST_SKIPPED)
9514 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9515 return TEST_SUCCESS;
9519 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9521 struct aead_test_data tdata;
9524 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9525 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9526 tdata.ciphertext.data[0] += 1;
9527 res = test_authenticated_encryption(&tdata);
9528 if (res == TEST_SKIPPED)
9530 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9531 return TEST_SUCCESS;
9535 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9537 struct aead_test_data tdata;
9540 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9541 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9543 res = test_authenticated_encryption(&tdata);
9544 if (res == TEST_SKIPPED)
9546 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9547 return TEST_SUCCESS;
9551 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9553 struct aead_test_data tdata;
9554 uint8_t aad[gcm_test_case_7.aad.len];
9557 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9558 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9559 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9561 tdata.aad.data = aad;
9562 res = test_authenticated_encryption(&tdata);
9563 if (res == TEST_SKIPPED)
9565 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9566 return TEST_SUCCESS;
9570 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9572 struct aead_test_data tdata;
9575 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9576 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9577 tdata.auth_tag.data[0] += 1;
9578 res = test_authenticated_encryption(&tdata);
9579 if (res == TEST_SKIPPED)
9581 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9582 return TEST_SUCCESS;
9586 test_authenticated_decryption(const struct aead_test_data *tdata)
9588 struct crypto_testsuite_params *ts_params = &testsuite_params;
9589 struct crypto_unittest_params *ut_params = &unittest_params;
9594 struct rte_cryptodev_info dev_info;
9596 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9597 uint64_t feat_flags = dev_info.feature_flags;
9599 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9600 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9601 printf("Device doesn't support RAW data-path APIs.\n");
9602 return TEST_SKIPPED;
9605 /* Verify the capabilities */
9606 struct rte_cryptodev_sym_capability_idx cap_idx;
9607 const struct rte_cryptodev_symmetric_capability *capability;
9608 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9609 cap_idx.algo.aead = tdata->algo;
9610 capability = rte_cryptodev_sym_capability_get(
9611 ts_params->valid_devs[0], &cap_idx);
9612 if (capability == NULL)
9613 return TEST_SKIPPED;
9614 if (rte_cryptodev_sym_capability_check_aead(
9615 capability, tdata->key.len, tdata->auth_tag.len,
9616 tdata->aad.len, tdata->iv.len))
9617 return TEST_SKIPPED;
9619 /* Create AEAD session */
9620 retval = create_aead_session(ts_params->valid_devs[0],
9622 RTE_CRYPTO_AEAD_OP_DECRYPT,
9623 tdata->key.data, tdata->key.len,
9624 tdata->aad.len, tdata->auth_tag.len,
9629 /* alloc mbuf and set payload */
9630 if (tdata->aad.len > MBUF_SIZE) {
9631 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9632 /* Populate full size of add data */
9633 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9634 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9636 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9638 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9639 rte_pktmbuf_tailroom(ut_params->ibuf));
9641 /* Create AEAD operation */
9642 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9646 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9648 ut_params->op->sym->m_src = ut_params->ibuf;
9650 /* Process crypto operation */
9651 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9652 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9653 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9654 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9655 ut_params->op, 0, 0, 0, 0);
9657 TEST_ASSERT_NOT_NULL(
9658 process_crypto_request(ts_params->valid_devs[0],
9659 ut_params->op), "failed to process sym crypto op");
9661 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9662 "crypto op processing failed");
9664 if (ut_params->op->sym->m_dst)
9665 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9668 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9670 ut_params->op->sym->cipher.data.offset);
9672 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9675 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9677 tdata->plaintext.data,
9678 tdata->plaintext.len,
9679 "Plaintext data not as expected");
9681 TEST_ASSERT_EQUAL(ut_params->op->status,
9682 RTE_CRYPTO_OP_STATUS_SUCCESS,
9683 "Authentication failed");
9689 test_AES_GCM_authenticated_decryption_test_case_1(void)
9691 return test_authenticated_decryption(&gcm_test_case_1);
9695 test_AES_GCM_authenticated_decryption_test_case_2(void)
9697 return test_authenticated_decryption(&gcm_test_case_2);
9701 test_AES_GCM_authenticated_decryption_test_case_3(void)
9703 return test_authenticated_decryption(&gcm_test_case_3);
9707 test_AES_GCM_authenticated_decryption_test_case_4(void)
9709 return test_authenticated_decryption(&gcm_test_case_4);
9713 test_AES_GCM_authenticated_decryption_test_case_5(void)
9715 return test_authenticated_decryption(&gcm_test_case_5);
9719 test_AES_GCM_authenticated_decryption_test_case_6(void)
9721 return test_authenticated_decryption(&gcm_test_case_6);
9725 test_AES_GCM_authenticated_decryption_test_case_7(void)
9727 return test_authenticated_decryption(&gcm_test_case_7);
9731 test_AES_GCM_authenticated_decryption_test_case_8(void)
9733 return test_authenticated_decryption(&gcm_test_case_8);
9737 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9739 return test_authenticated_decryption(&gcm_J0_test_case_1);
9743 test_AES_GCM_auth_decryption_test_case_192_1(void)
9745 return test_authenticated_decryption(&gcm_test_case_192_1);
9749 test_AES_GCM_auth_decryption_test_case_192_2(void)
9751 return test_authenticated_decryption(&gcm_test_case_192_2);
9755 test_AES_GCM_auth_decryption_test_case_192_3(void)
9757 return test_authenticated_decryption(&gcm_test_case_192_3);
9761 test_AES_GCM_auth_decryption_test_case_192_4(void)
9763 return test_authenticated_decryption(&gcm_test_case_192_4);
9767 test_AES_GCM_auth_decryption_test_case_192_5(void)
9769 return test_authenticated_decryption(&gcm_test_case_192_5);
9773 test_AES_GCM_auth_decryption_test_case_192_6(void)
9775 return test_authenticated_decryption(&gcm_test_case_192_6);
9779 test_AES_GCM_auth_decryption_test_case_192_7(void)
9781 return test_authenticated_decryption(&gcm_test_case_192_7);
9785 test_AES_GCM_auth_decryption_test_case_256_1(void)
9787 return test_authenticated_decryption(&gcm_test_case_256_1);
9791 test_AES_GCM_auth_decryption_test_case_256_2(void)
9793 return test_authenticated_decryption(&gcm_test_case_256_2);
9797 test_AES_GCM_auth_decryption_test_case_256_3(void)
9799 return test_authenticated_decryption(&gcm_test_case_256_3);
9803 test_AES_GCM_auth_decryption_test_case_256_4(void)
9805 return test_authenticated_decryption(&gcm_test_case_256_4);
9809 test_AES_GCM_auth_decryption_test_case_256_5(void)
9811 return test_authenticated_decryption(&gcm_test_case_256_5);
9815 test_AES_GCM_auth_decryption_test_case_256_6(void)
9817 return test_authenticated_decryption(&gcm_test_case_256_6);
9821 test_AES_GCM_auth_decryption_test_case_256_7(void)
9823 return test_authenticated_decryption(&gcm_test_case_256_7);
9827 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9829 return test_authenticated_decryption(&gcm_test_case_aad_1);
9833 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9835 return test_authenticated_decryption(&gcm_test_case_aad_2);
9839 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9841 struct aead_test_data tdata;
9844 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9845 tdata.iv.data[0] += 1;
9846 res = test_authenticated_decryption(&tdata);
9847 if (res == TEST_SKIPPED)
9849 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9850 return TEST_SUCCESS;
9854 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9856 struct aead_test_data tdata;
9859 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9860 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9861 tdata.plaintext.data[0] += 1;
9862 res = test_authenticated_decryption(&tdata);
9863 if (res == TEST_SKIPPED)
9865 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9866 return TEST_SUCCESS;
9870 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9872 struct aead_test_data tdata;
9875 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9876 tdata.ciphertext.data[0] += 1;
9877 res = test_authenticated_decryption(&tdata);
9878 if (res == TEST_SKIPPED)
9880 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9881 return TEST_SUCCESS;
9885 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9887 struct aead_test_data tdata;
9890 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9892 res = test_authenticated_decryption(&tdata);
9893 if (res == TEST_SKIPPED)
9895 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9896 return TEST_SUCCESS;
9900 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9902 struct aead_test_data tdata;
9903 uint8_t aad[gcm_test_case_7.aad.len];
9906 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9907 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9909 tdata.aad.data = aad;
9910 res = test_authenticated_decryption(&tdata);
9911 if (res == TEST_SKIPPED)
9913 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9914 return TEST_SUCCESS;
9918 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9920 struct aead_test_data tdata;
9923 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9924 tdata.auth_tag.data[0] += 1;
9925 res = test_authenticated_decryption(&tdata);
9926 if (res == TEST_SKIPPED)
9928 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9929 return TEST_SUCCESS;
9933 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9935 struct crypto_testsuite_params *ts_params = &testsuite_params;
9936 struct crypto_unittest_params *ut_params = &unittest_params;
9939 uint8_t *ciphertext, *auth_tag;
9940 uint16_t plaintext_pad_len;
9942 /* Verify the capabilities */
9943 struct rte_cryptodev_sym_capability_idx cap_idx;
9944 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9945 cap_idx.algo.aead = tdata->algo;
9946 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9948 return TEST_SKIPPED;
9950 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9951 return TEST_SKIPPED;
9953 /* not supported with CPU crypto */
9954 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9955 return TEST_SKIPPED;
9957 /* Create AEAD session */
9958 retval = create_aead_session(ts_params->valid_devs[0],
9960 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9961 tdata->key.data, tdata->key.len,
9962 tdata->aad.len, tdata->auth_tag.len,
9967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9968 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9970 /* clear mbuf payload */
9971 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9972 rte_pktmbuf_tailroom(ut_params->ibuf));
9973 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9974 rte_pktmbuf_tailroom(ut_params->obuf));
9976 /* Create AEAD operation */
9977 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9981 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9983 ut_params->op->sym->m_src = ut_params->ibuf;
9984 ut_params->op->sym->m_dst = ut_params->obuf;
9986 /* Process crypto operation */
9987 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9988 ut_params->op), "failed to process sym crypto op");
9990 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9991 "crypto op processing failed");
9993 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9995 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9996 ut_params->op->sym->cipher.data.offset);
9997 auth_tag = ciphertext + plaintext_pad_len;
9999 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10000 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10002 /* Validate obuf */
10003 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10005 tdata->ciphertext.data,
10006 tdata->ciphertext.len,
10007 "Ciphertext data not as expected");
10009 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10011 tdata->auth_tag.data,
10012 tdata->auth_tag.len,
10013 "Generated auth tag not as expected");
10020 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10022 return test_authenticated_encryption_oop(&gcm_test_case_5);
10026 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10028 struct crypto_testsuite_params *ts_params = &testsuite_params;
10029 struct crypto_unittest_params *ut_params = &unittest_params;
10032 uint8_t *plaintext;
10034 /* Verify the capabilities */
10035 struct rte_cryptodev_sym_capability_idx cap_idx;
10036 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10037 cap_idx.algo.aead = tdata->algo;
10038 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10040 return TEST_SKIPPED;
10042 /* not supported with CPU crypto and raw data-path APIs*/
10043 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10044 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10045 return TEST_SKIPPED;
10047 /* Create AEAD session */
10048 retval = create_aead_session(ts_params->valid_devs[0],
10050 RTE_CRYPTO_AEAD_OP_DECRYPT,
10051 tdata->key.data, tdata->key.len,
10052 tdata->aad.len, tdata->auth_tag.len,
10057 /* alloc mbuf and set payload */
10058 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10059 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10061 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10062 rte_pktmbuf_tailroom(ut_params->ibuf));
10063 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10064 rte_pktmbuf_tailroom(ut_params->obuf));
10066 /* Create AEAD operation */
10067 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10071 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10073 ut_params->op->sym->m_src = ut_params->ibuf;
10074 ut_params->op->sym->m_dst = ut_params->obuf;
10076 /* Process crypto operation */
10077 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10078 ut_params->op), "failed to process sym crypto op");
10080 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10081 "crypto op processing failed");
10083 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10084 ut_params->op->sym->cipher.data.offset);
10086 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10088 /* Validate obuf */
10089 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10091 tdata->plaintext.data,
10092 tdata->plaintext.len,
10093 "Plaintext data not as expected");
10095 TEST_ASSERT_EQUAL(ut_params->op->status,
10096 RTE_CRYPTO_OP_STATUS_SUCCESS,
10097 "Authentication failed");
10102 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10104 return test_authenticated_decryption_oop(&gcm_test_case_5);
10108 test_authenticated_encryption_sessionless(
10109 const struct aead_test_data *tdata)
10111 struct crypto_testsuite_params *ts_params = &testsuite_params;
10112 struct crypto_unittest_params *ut_params = &unittest_params;
10115 uint8_t *ciphertext, *auth_tag;
10116 uint16_t plaintext_pad_len;
10117 uint8_t key[tdata->key.len + 1];
10118 struct rte_cryptodev_info dev_info;
10120 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10121 uint64_t feat_flags = dev_info.feature_flags;
10123 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10124 printf("Device doesn't support Sessionless ops.\n");
10125 return TEST_SKIPPED;
10128 /* not supported with CPU crypto */
10129 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10130 return TEST_SKIPPED;
10132 /* Verify the capabilities */
10133 struct rte_cryptodev_sym_capability_idx cap_idx;
10134 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10135 cap_idx.algo.aead = tdata->algo;
10136 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10138 return TEST_SKIPPED;
10140 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10142 /* clear mbuf payload */
10143 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10144 rte_pktmbuf_tailroom(ut_params->ibuf));
10146 /* Create AEAD operation */
10147 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10151 /* Create GCM xform */
10152 memcpy(key, tdata->key.data, tdata->key.len);
10153 retval = create_aead_xform(ut_params->op,
10155 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10156 key, tdata->key.len,
10157 tdata->aad.len, tdata->auth_tag.len,
10162 ut_params->op->sym->m_src = ut_params->ibuf;
10164 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10165 RTE_CRYPTO_OP_SESSIONLESS,
10166 "crypto op session type not sessionless");
10168 /* Process crypto operation */
10169 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10170 ut_params->op), "failed to process sym crypto op");
10172 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10174 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10175 "crypto op status not success");
10177 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10179 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10180 ut_params->op->sym->cipher.data.offset);
10181 auth_tag = ciphertext + plaintext_pad_len;
10183 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10184 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10186 /* Validate obuf */
10187 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10189 tdata->ciphertext.data,
10190 tdata->ciphertext.len,
10191 "Ciphertext data not as expected");
10193 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10195 tdata->auth_tag.data,
10196 tdata->auth_tag.len,
10197 "Generated auth tag not as expected");
10204 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10206 return test_authenticated_encryption_sessionless(
10211 test_authenticated_decryption_sessionless(
10212 const struct aead_test_data *tdata)
10214 struct crypto_testsuite_params *ts_params = &testsuite_params;
10215 struct crypto_unittest_params *ut_params = &unittest_params;
10218 uint8_t *plaintext;
10219 uint8_t key[tdata->key.len + 1];
10220 struct rte_cryptodev_info dev_info;
10222 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10223 uint64_t feat_flags = dev_info.feature_flags;
10225 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10226 printf("Device doesn't support Sessionless ops.\n");
10227 return TEST_SKIPPED;
10230 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10231 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10232 printf("Device doesn't support RAW data-path APIs.\n");
10233 return TEST_SKIPPED;
10236 /* not supported with CPU crypto */
10237 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10238 return TEST_SKIPPED;
10240 /* Verify the capabilities */
10241 struct rte_cryptodev_sym_capability_idx cap_idx;
10242 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10243 cap_idx.algo.aead = tdata->algo;
10244 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10246 return TEST_SKIPPED;
10248 /* alloc mbuf and set payload */
10249 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10251 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10252 rte_pktmbuf_tailroom(ut_params->ibuf));
10254 /* Create AEAD operation */
10255 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10259 /* Create AEAD xform */
10260 memcpy(key, tdata->key.data, tdata->key.len);
10261 retval = create_aead_xform(ut_params->op,
10263 RTE_CRYPTO_AEAD_OP_DECRYPT,
10264 key, tdata->key.len,
10265 tdata->aad.len, tdata->auth_tag.len,
10270 ut_params->op->sym->m_src = ut_params->ibuf;
10272 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10273 RTE_CRYPTO_OP_SESSIONLESS,
10274 "crypto op session type not sessionless");
10276 /* Process crypto operation */
10277 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10278 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10279 ut_params->op, 0, 0, 0, 0);
10281 TEST_ASSERT_NOT_NULL(process_crypto_request(
10282 ts_params->valid_devs[0], ut_params->op),
10283 "failed to process sym crypto op");
10285 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10287 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10288 "crypto op status not success");
10290 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10291 ut_params->op->sym->cipher.data.offset);
10293 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10295 /* Validate obuf */
10296 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10298 tdata->plaintext.data,
10299 tdata->plaintext.len,
10300 "Plaintext data not as expected");
10302 TEST_ASSERT_EQUAL(ut_params->op->status,
10303 RTE_CRYPTO_OP_STATUS_SUCCESS,
10304 "Authentication failed");
10309 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10311 return test_authenticated_decryption_sessionless(
10316 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10318 return test_authenticated_encryption(&ccm_test_case_128_1);
10322 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10324 return test_authenticated_encryption(&ccm_test_case_128_2);
10328 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10330 return test_authenticated_encryption(&ccm_test_case_128_3);
10334 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10336 return test_authenticated_decryption(&ccm_test_case_128_1);
10340 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10342 return test_authenticated_decryption(&ccm_test_case_128_2);
10346 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10348 return test_authenticated_decryption(&ccm_test_case_128_3);
10352 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10354 return test_authenticated_encryption(&ccm_test_case_192_1);
10358 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10360 return test_authenticated_encryption(&ccm_test_case_192_2);
10364 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10366 return test_authenticated_encryption(&ccm_test_case_192_3);
10370 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10372 return test_authenticated_decryption(&ccm_test_case_192_1);
10376 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10378 return test_authenticated_decryption(&ccm_test_case_192_2);
10382 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10384 return test_authenticated_decryption(&ccm_test_case_192_3);
10388 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10390 return test_authenticated_encryption(&ccm_test_case_256_1);
10394 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10396 return test_authenticated_encryption(&ccm_test_case_256_2);
10400 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10402 return test_authenticated_encryption(&ccm_test_case_256_3);
10406 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10408 return test_authenticated_decryption(&ccm_test_case_256_1);
10412 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10414 return test_authenticated_decryption(&ccm_test_case_256_2);
10418 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10420 return test_authenticated_decryption(&ccm_test_case_256_3);
10426 struct crypto_testsuite_params *ts_params = &testsuite_params;
10427 struct rte_cryptodev_stats stats;
10429 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10430 return TEST_SKIPPED;
10432 /* Verify the capabilities */
10433 struct rte_cryptodev_sym_capability_idx cap_idx;
10434 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10435 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10436 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10438 return TEST_SKIPPED;
10439 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10440 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10441 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10443 return TEST_SKIPPED;
10445 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10447 return TEST_SKIPPED;
10449 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10450 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10451 &stats) == -ENODEV),
10452 "rte_cryptodev_stats_get invalid dev failed");
10453 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10454 "rte_cryptodev_stats_get invalid Param failed");
10456 /* Test expected values */
10457 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10458 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10460 "rte_cryptodev_stats_get failed");
10461 TEST_ASSERT((stats.enqueued_count == 1),
10462 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10463 TEST_ASSERT((stats.dequeued_count == 1),
10464 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10465 TEST_ASSERT((stats.enqueue_err_count == 0),
10466 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10467 TEST_ASSERT((stats.dequeue_err_count == 0),
10468 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10470 /* invalid device but should ignore and not reset device stats*/
10471 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10472 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10474 "rte_cryptodev_stats_get failed");
10475 TEST_ASSERT((stats.enqueued_count == 1),
10476 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10478 /* check that a valid reset clears stats */
10479 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10480 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10482 "rte_cryptodev_stats_get failed");
10483 TEST_ASSERT((stats.enqueued_count == 0),
10484 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10485 TEST_ASSERT((stats.dequeued_count == 0),
10486 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10488 return TEST_SUCCESS;
10491 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10492 struct crypto_unittest_params *ut_params,
10493 enum rte_crypto_auth_operation op,
10494 const struct HMAC_MD5_vector *test_case)
10498 memcpy(key, test_case->key.data, test_case->key.len);
10500 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10501 ut_params->auth_xform.next = NULL;
10502 ut_params->auth_xform.auth.op = op;
10504 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10506 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10507 ut_params->auth_xform.auth.key.length = test_case->key.len;
10508 ut_params->auth_xform.auth.key.data = key;
10510 ut_params->sess = rte_cryptodev_sym_session_create(
10511 ts_params->session_mpool);
10513 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10514 ut_params->sess, &ut_params->auth_xform,
10515 ts_params->session_priv_mpool);
10517 if (ut_params->sess == NULL)
10518 return TEST_FAILED;
10520 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10522 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10523 rte_pktmbuf_tailroom(ut_params->ibuf));
10528 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10529 const struct HMAC_MD5_vector *test_case,
10530 uint8_t **plaintext)
10532 uint16_t plaintext_pad_len;
10534 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10536 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10539 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10540 plaintext_pad_len);
10541 memcpy(*plaintext, test_case->plaintext.data,
10542 test_case->plaintext.len);
10544 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10545 ut_params->ibuf, MD5_DIGEST_LEN);
10546 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10547 "no room to append digest");
10548 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10549 ut_params->ibuf, plaintext_pad_len);
10551 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10552 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10553 test_case->auth_tag.len);
10556 sym_op->auth.data.offset = 0;
10557 sym_op->auth.data.length = test_case->plaintext.len;
10559 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10560 ut_params->op->sym->m_src = ut_params->ibuf;
10566 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10568 uint16_t plaintext_pad_len;
10569 uint8_t *plaintext, *auth_tag;
10571 struct crypto_testsuite_params *ts_params = &testsuite_params;
10572 struct crypto_unittest_params *ut_params = &unittest_params;
10573 struct rte_cryptodev_info dev_info;
10575 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10576 uint64_t feat_flags = dev_info.feature_flags;
10578 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10579 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10580 printf("Device doesn't support RAW data-path APIs.\n");
10581 return TEST_SKIPPED;
10584 /* Verify the capabilities */
10585 struct rte_cryptodev_sym_capability_idx cap_idx;
10586 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10587 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10588 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10590 return TEST_SKIPPED;
10592 if (MD5_HMAC_create_session(ts_params, ut_params,
10593 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10594 return TEST_FAILED;
10596 /* Generate Crypto op data structure */
10597 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10598 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10599 TEST_ASSERT_NOT_NULL(ut_params->op,
10600 "Failed to allocate symmetric crypto operation struct");
10602 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10605 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10606 return TEST_FAILED;
10608 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10609 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10611 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10612 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10613 ut_params->op, 0, 1, 0, 0);
10615 TEST_ASSERT_NOT_NULL(
10616 process_crypto_request(ts_params->valid_devs[0],
10618 "failed to process sym crypto op");
10620 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10621 "crypto op processing failed");
10623 if (ut_params->op->sym->m_dst) {
10624 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10625 uint8_t *, plaintext_pad_len);
10627 auth_tag = plaintext + plaintext_pad_len;
10630 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10632 test_case->auth_tag.data,
10633 test_case->auth_tag.len,
10634 "HMAC_MD5 generated tag not as expected");
10636 return TEST_SUCCESS;
10640 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10642 uint8_t *plaintext;
10644 struct crypto_testsuite_params *ts_params = &testsuite_params;
10645 struct crypto_unittest_params *ut_params = &unittest_params;
10646 struct rte_cryptodev_info dev_info;
10648 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10649 uint64_t feat_flags = dev_info.feature_flags;
10651 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10652 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10653 printf("Device doesn't support RAW data-path APIs.\n");
10654 return TEST_SKIPPED;
10657 /* Verify the capabilities */
10658 struct rte_cryptodev_sym_capability_idx cap_idx;
10659 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10660 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10661 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10663 return TEST_SKIPPED;
10665 if (MD5_HMAC_create_session(ts_params, ut_params,
10666 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10667 return TEST_FAILED;
10670 /* Generate Crypto op data structure */
10671 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10672 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10673 TEST_ASSERT_NOT_NULL(ut_params->op,
10674 "Failed to allocate symmetric crypto operation struct");
10676 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10677 return TEST_FAILED;
10679 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10680 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10682 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10683 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10684 ut_params->op, 0, 1, 0, 0);
10686 TEST_ASSERT_NOT_NULL(
10687 process_crypto_request(ts_params->valid_devs[0],
10689 "failed to process sym crypto op");
10691 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10692 "HMAC_MD5 crypto op processing failed");
10694 return TEST_SUCCESS;
10698 test_MD5_HMAC_generate_case_1(void)
10700 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10704 test_MD5_HMAC_verify_case_1(void)
10706 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10710 test_MD5_HMAC_generate_case_2(void)
10712 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10716 test_MD5_HMAC_verify_case_2(void)
10718 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10722 test_multi_session(void)
10724 struct crypto_testsuite_params *ts_params = &testsuite_params;
10725 struct crypto_unittest_params *ut_params = &unittest_params;
10727 struct rte_cryptodev_info dev_info;
10728 struct rte_cryptodev_sym_session **sessions;
10732 /* Verify the capabilities */
10733 struct rte_cryptodev_sym_capability_idx cap_idx;
10734 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10735 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10736 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10738 return TEST_SKIPPED;
10739 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10740 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10741 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10743 return TEST_SKIPPED;
10745 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10746 aes_cbc_key, hmac_sha512_key);
10749 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10751 sessions = rte_malloc(NULL,
10752 sizeof(struct rte_cryptodev_sym_session *) *
10753 (MAX_NB_SESSIONS + 1), 0);
10755 /* Create multiple crypto sessions*/
10756 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10758 sessions[i] = rte_cryptodev_sym_session_create(
10759 ts_params->session_mpool);
10761 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10762 sessions[i], &ut_params->auth_xform,
10763 ts_params->session_priv_mpool);
10764 TEST_ASSERT_NOT_NULL(sessions[i],
10765 "Session creation failed at session number %u",
10768 /* Attempt to send a request on each session */
10769 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10773 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10774 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10776 "Failed to perform decrypt on request number %u.", i);
10777 /* free crypto operation structure */
10779 rte_crypto_op_free(ut_params->op);
10782 * free mbuf - both obuf and ibuf are usually the same,
10783 * so check if they point at the same address is necessary,
10784 * to avoid freeing the mbuf twice.
10786 if (ut_params->obuf) {
10787 rte_pktmbuf_free(ut_params->obuf);
10788 if (ut_params->ibuf == ut_params->obuf)
10789 ut_params->ibuf = 0;
10790 ut_params->obuf = 0;
10792 if (ut_params->ibuf) {
10793 rte_pktmbuf_free(ut_params->ibuf);
10794 ut_params->ibuf = 0;
10798 sessions[i] = NULL;
10799 /* Next session create should fail */
10800 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10801 sessions[i], &ut_params->auth_xform,
10802 ts_params->session_priv_mpool);
10803 TEST_ASSERT_NULL(sessions[i],
10804 "Session creation succeeded unexpectedly!");
10806 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10807 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10809 rte_cryptodev_sym_session_free(sessions[i]);
10812 rte_free(sessions);
10814 return TEST_SUCCESS;
10817 struct multi_session_params {
10818 struct crypto_unittest_params ut_params;
10819 uint8_t *cipher_key;
10821 const uint8_t *cipher;
10822 const uint8_t *digest;
10826 #define MB_SESSION_NUMBER 3
10829 test_multi_session_random_usage(void)
10831 struct crypto_testsuite_params *ts_params = &testsuite_params;
10832 struct rte_cryptodev_info dev_info;
10833 struct rte_cryptodev_sym_session **sessions;
10835 struct multi_session_params ut_paramz[] = {
10838 .cipher_key = ms_aes_cbc_key0,
10839 .hmac_key = ms_hmac_key0,
10840 .cipher = ms_aes_cbc_cipher0,
10841 .digest = ms_hmac_digest0,
10842 .iv = ms_aes_cbc_iv0
10845 .cipher_key = ms_aes_cbc_key1,
10846 .hmac_key = ms_hmac_key1,
10847 .cipher = ms_aes_cbc_cipher1,
10848 .digest = ms_hmac_digest1,
10849 .iv = ms_aes_cbc_iv1
10852 .cipher_key = ms_aes_cbc_key2,
10853 .hmac_key = ms_hmac_key2,
10854 .cipher = ms_aes_cbc_cipher2,
10855 .digest = ms_hmac_digest2,
10856 .iv = ms_aes_cbc_iv2
10861 /* Verify the capabilities */
10862 struct rte_cryptodev_sym_capability_idx cap_idx;
10863 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10864 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10865 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10867 return TEST_SKIPPED;
10868 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10869 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10870 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10872 return TEST_SKIPPED;
10874 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10876 sessions = rte_malloc(NULL,
10877 (sizeof(struct rte_cryptodev_sym_session *)
10878 * MAX_NB_SESSIONS) + 1, 0);
10880 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10881 sessions[i] = rte_cryptodev_sym_session_create(
10882 ts_params->session_mpool);
10884 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10885 sizeof(struct crypto_unittest_params));
10887 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10888 &ut_paramz[i].ut_params,
10889 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10891 /* Create multiple crypto sessions*/
10892 rte_cryptodev_sym_session_init(
10893 ts_params->valid_devs[0],
10895 &ut_paramz[i].ut_params.auth_xform,
10896 ts_params->session_priv_mpool);
10898 TEST_ASSERT_NOT_NULL(sessions[i],
10899 "Session creation failed at session number %u",
10905 for (i = 0; i < 40000; i++) {
10907 j = rand() % MB_SESSION_NUMBER;
10909 TEST_ASSERT_SUCCESS(
10910 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10912 &ut_paramz[j].ut_params,
10913 ts_params, ut_paramz[j].cipher,
10914 ut_paramz[j].digest,
10916 "Failed to perform decrypt on request number %u.", i);
10918 if (ut_paramz[j].ut_params.op)
10919 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10922 * free mbuf - both obuf and ibuf are usually the same,
10923 * so check if they point at the same address is necessary,
10924 * to avoid freeing the mbuf twice.
10926 if (ut_paramz[j].ut_params.obuf) {
10927 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10928 if (ut_paramz[j].ut_params.ibuf
10929 == ut_paramz[j].ut_params.obuf)
10930 ut_paramz[j].ut_params.ibuf = 0;
10931 ut_paramz[j].ut_params.obuf = 0;
10933 if (ut_paramz[j].ut_params.ibuf) {
10934 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10935 ut_paramz[j].ut_params.ibuf = 0;
10939 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10940 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10942 rte_cryptodev_sym_session_free(sessions[i]);
10945 rte_free(sessions);
10947 return TEST_SUCCESS;
10950 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10951 0xab, 0xab, 0xab, 0xab,
10952 0xab, 0xab, 0xab, 0xab,
10953 0xab, 0xab, 0xab, 0xab};
10956 test_null_invalid_operation(void)
10958 struct crypto_testsuite_params *ts_params = &testsuite_params;
10959 struct crypto_unittest_params *ut_params = &unittest_params;
10962 /* This test is for NULL PMD only */
10963 if (gbl_driver_id != rte_cryptodev_driver_id_get(
10964 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10965 return TEST_SKIPPED;
10967 /* Setup Cipher Parameters */
10968 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10969 ut_params->cipher_xform.next = NULL;
10971 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10972 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10974 ut_params->sess = rte_cryptodev_sym_session_create(
10975 ts_params->session_mpool);
10977 /* Create Crypto session*/
10978 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10979 ut_params->sess, &ut_params->cipher_xform,
10980 ts_params->session_priv_mpool);
10981 TEST_ASSERT(ret < 0,
10982 "Session creation succeeded unexpectedly");
10985 /* Setup HMAC Parameters */
10986 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10987 ut_params->auth_xform.next = NULL;
10989 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10990 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10992 ut_params->sess = rte_cryptodev_sym_session_create(
10993 ts_params->session_mpool);
10995 /* Create Crypto session*/
10996 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10997 ut_params->sess, &ut_params->auth_xform,
10998 ts_params->session_priv_mpool);
10999 TEST_ASSERT(ret < 0,
11000 "Session creation succeeded unexpectedly");
11002 return TEST_SUCCESS;
11006 #define NULL_BURST_LENGTH (32)
11009 test_null_burst_operation(void)
11011 struct crypto_testsuite_params *ts_params = &testsuite_params;
11012 struct crypto_unittest_params *ut_params = &unittest_params;
11014 unsigned i, burst_len = NULL_BURST_LENGTH;
11016 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11017 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11019 /* This test is for NULL PMD only */
11020 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11021 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11022 return TEST_SKIPPED;
11024 /* Setup Cipher Parameters */
11025 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11026 ut_params->cipher_xform.next = &ut_params->auth_xform;
11028 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11029 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11031 /* Setup HMAC Parameters */
11032 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11033 ut_params->auth_xform.next = NULL;
11035 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11036 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11038 ut_params->sess = rte_cryptodev_sym_session_create(
11039 ts_params->session_mpool);
11041 /* Create Crypto session*/
11042 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11043 ut_params->sess, &ut_params->cipher_xform,
11044 ts_params->session_priv_mpool);
11045 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11047 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11048 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11049 burst_len, "failed to generate burst of crypto ops");
11051 /* Generate an operation for each mbuf in burst */
11052 for (i = 0; i < burst_len; i++) {
11053 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11055 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11057 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11061 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11063 burst[i]->sym->m_src = m;
11066 /* Process crypto operation */
11067 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11068 0, burst, burst_len),
11070 "Error enqueuing burst");
11072 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11073 0, burst_dequeued, burst_len),
11075 "Error dequeuing burst");
11078 for (i = 0; i < burst_len; i++) {
11080 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11081 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11083 "data not as expected");
11085 rte_pktmbuf_free(burst[i]->sym->m_src);
11086 rte_crypto_op_free(burst[i]);
11089 return TEST_SUCCESS;
11093 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11094 uint16_t nb_ops, void *user_param)
11096 RTE_SET_USED(dev_id);
11097 RTE_SET_USED(qp_id);
11099 RTE_SET_USED(user_param);
11101 printf("crypto enqueue callback called\n");
11106 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11107 uint16_t nb_ops, void *user_param)
11109 RTE_SET_USED(dev_id);
11110 RTE_SET_USED(qp_id);
11112 RTE_SET_USED(user_param);
11114 printf("crypto dequeue callback called\n");
11119 * Thread using enqueue/dequeue callback with RCU.
11122 test_enqdeq_callback_thread(void *arg)
11125 /* DP thread calls rte_cryptodev_enqueue_burst()/
11126 * rte_cryptodev_dequeue_burst() and invokes callback.
11128 test_null_burst_operation();
11133 test_enq_callback_setup(void)
11135 struct crypto_testsuite_params *ts_params = &testsuite_params;
11136 struct rte_cryptodev_info dev_info;
11137 struct rte_cryptodev_qp_conf qp_conf = {
11138 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11141 struct rte_cryptodev_cb *cb;
11142 uint16_t qp_id = 0;
11144 /* Stop the device in case it's started so it can be configured */
11145 rte_cryptodev_stop(ts_params->valid_devs[0]);
11147 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11149 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11151 "Failed to configure cryptodev %u",
11152 ts_params->valid_devs[0]);
11154 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11155 qp_conf.mp_session = ts_params->session_mpool;
11156 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11158 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11159 ts_params->valid_devs[0], qp_id, &qp_conf,
11160 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11162 "rte_cryptodev_queue_pair_setup: num_inflights "
11163 "%u on qp %u on cryptodev %u",
11164 qp_conf.nb_descriptors, qp_id,
11165 ts_params->valid_devs[0]);
11167 /* Test with invalid crypto device */
11168 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11169 qp_id, test_enq_callback, NULL);
11170 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11171 "cryptodev %u did not fail",
11172 qp_id, RTE_CRYPTO_MAX_DEVS);
11174 /* Test with invalid queue pair */
11175 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11176 dev_info.max_nb_queue_pairs + 1,
11177 test_enq_callback, NULL);
11178 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11179 "cryptodev %u did not fail",
11180 dev_info.max_nb_queue_pairs + 1,
11181 ts_params->valid_devs[0]);
11183 /* Test with NULL callback */
11184 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11185 qp_id, NULL, NULL);
11186 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11187 "cryptodev %u did not fail",
11188 qp_id, ts_params->valid_devs[0]);
11190 /* Test with valid configuration */
11191 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11192 qp_id, test_enq_callback, NULL);
11193 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11194 "qp %u on cryptodev %u",
11195 qp_id, ts_params->valid_devs[0]);
11197 rte_cryptodev_start(ts_params->valid_devs[0]);
11199 /* Launch a thread */
11200 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11201 rte_get_next_lcore(-1, 1, 0));
11203 /* Wait until reader exited. */
11204 rte_eal_mp_wait_lcore();
11206 /* Test with invalid crypto device */
11207 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11208 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11209 "Expected call to fail as crypto device is invalid");
11211 /* Test with invalid queue pair */
11212 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11213 ts_params->valid_devs[0],
11214 dev_info.max_nb_queue_pairs + 1, cb),
11215 "Expected call to fail as queue pair is invalid");
11217 /* Test with NULL callback */
11218 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11219 ts_params->valid_devs[0], qp_id, NULL),
11220 "Expected call to fail as callback is NULL");
11222 /* Test with valid configuration */
11223 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11224 ts_params->valid_devs[0], qp_id, cb),
11225 "Failed test to remove callback on "
11226 "qp %u on cryptodev %u",
11227 qp_id, ts_params->valid_devs[0]);
11229 return TEST_SUCCESS;
11233 test_deq_callback_setup(void)
11235 struct crypto_testsuite_params *ts_params = &testsuite_params;
11236 struct rte_cryptodev_info dev_info;
11237 struct rte_cryptodev_qp_conf qp_conf = {
11238 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11241 struct rte_cryptodev_cb *cb;
11242 uint16_t qp_id = 0;
11244 /* Stop the device in case it's started so it can be configured */
11245 rte_cryptodev_stop(ts_params->valid_devs[0]);
11247 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11249 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11251 "Failed to configure cryptodev %u",
11252 ts_params->valid_devs[0]);
11254 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11255 qp_conf.mp_session = ts_params->session_mpool;
11256 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11258 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11259 ts_params->valid_devs[0], qp_id, &qp_conf,
11260 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11262 "rte_cryptodev_queue_pair_setup: num_inflights "
11263 "%u on qp %u on cryptodev %u",
11264 qp_conf.nb_descriptors, qp_id,
11265 ts_params->valid_devs[0]);
11267 /* Test with invalid crypto device */
11268 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11269 qp_id, test_deq_callback, NULL);
11270 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11271 "cryptodev %u did not fail",
11272 qp_id, RTE_CRYPTO_MAX_DEVS);
11274 /* Test with invalid queue pair */
11275 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11276 dev_info.max_nb_queue_pairs + 1,
11277 test_deq_callback, NULL);
11278 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11279 "cryptodev %u did not fail",
11280 dev_info.max_nb_queue_pairs + 1,
11281 ts_params->valid_devs[0]);
11283 /* Test with NULL callback */
11284 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11285 qp_id, NULL, NULL);
11286 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11287 "cryptodev %u did not fail",
11288 qp_id, ts_params->valid_devs[0]);
11290 /* Test with valid configuration */
11291 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11292 qp_id, test_deq_callback, NULL);
11293 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11294 "qp %u on cryptodev %u",
11295 qp_id, ts_params->valid_devs[0]);
11297 rte_cryptodev_start(ts_params->valid_devs[0]);
11299 /* Launch a thread */
11300 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11301 rte_get_next_lcore(-1, 1, 0));
11303 /* Wait until reader exited. */
11304 rte_eal_mp_wait_lcore();
11306 /* Test with invalid crypto device */
11307 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11308 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11309 "Expected call to fail as crypto device is invalid");
11311 /* Test with invalid queue pair */
11312 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11313 ts_params->valid_devs[0],
11314 dev_info.max_nb_queue_pairs + 1, cb),
11315 "Expected call to fail as queue pair is invalid");
11317 /* Test with NULL callback */
11318 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11319 ts_params->valid_devs[0], qp_id, NULL),
11320 "Expected call to fail as callback is NULL");
11322 /* Test with valid configuration */
11323 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11324 ts_params->valid_devs[0], qp_id, cb),
11325 "Failed test to remove callback on "
11326 "qp %u on cryptodev %u",
11327 qp_id, ts_params->valid_devs[0]);
11329 return TEST_SUCCESS;
11333 generate_gmac_large_plaintext(uint8_t *data)
11337 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11338 memcpy(&data[i], &data[0], 32);
11342 create_gmac_operation(enum rte_crypto_auth_operation op,
11343 const struct gmac_test_data *tdata)
11345 struct crypto_testsuite_params *ts_params = &testsuite_params;
11346 struct crypto_unittest_params *ut_params = &unittest_params;
11347 struct rte_crypto_sym_op *sym_op;
11349 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11351 /* Generate Crypto op data structure */
11352 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11353 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11354 TEST_ASSERT_NOT_NULL(ut_params->op,
11355 "Failed to allocate symmetric crypto operation struct");
11357 sym_op = ut_params->op->sym;
11359 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11360 ut_params->ibuf, tdata->gmac_tag.len);
11361 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11362 "no room to append digest");
11364 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11365 ut_params->ibuf, plaintext_pad_len);
11367 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11368 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11369 tdata->gmac_tag.len);
11370 debug_hexdump(stdout, "digest:",
11371 sym_op->auth.digest.data,
11372 tdata->gmac_tag.len);
11375 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11376 uint8_t *, IV_OFFSET);
11378 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11380 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11382 sym_op->cipher.data.length = 0;
11383 sym_op->cipher.data.offset = 0;
11385 sym_op->auth.data.offset = 0;
11386 sym_op->auth.data.length = tdata->plaintext.len;
11392 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11393 const struct gmac_test_data *tdata,
11394 void *digest_mem, uint64_t digest_phys)
11396 struct crypto_testsuite_params *ts_params = &testsuite_params;
11397 struct crypto_unittest_params *ut_params = &unittest_params;
11398 struct rte_crypto_sym_op *sym_op;
11400 /* Generate Crypto op data structure */
11401 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11402 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11403 TEST_ASSERT_NOT_NULL(ut_params->op,
11404 "Failed to allocate symmetric crypto operation struct");
11406 sym_op = ut_params->op->sym;
11408 sym_op->auth.digest.data = digest_mem;
11409 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11410 "no room to append digest");
11412 sym_op->auth.digest.phys_addr = digest_phys;
11414 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11415 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11416 tdata->gmac_tag.len);
11417 debug_hexdump(stdout, "digest:",
11418 sym_op->auth.digest.data,
11419 tdata->gmac_tag.len);
11422 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11423 uint8_t *, IV_OFFSET);
11425 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11427 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11429 sym_op->cipher.data.length = 0;
11430 sym_op->cipher.data.offset = 0;
11432 sym_op->auth.data.offset = 0;
11433 sym_op->auth.data.length = tdata->plaintext.len;
11438 static int create_gmac_session(uint8_t dev_id,
11439 const struct gmac_test_data *tdata,
11440 enum rte_crypto_auth_operation auth_op)
11442 uint8_t auth_key[tdata->key.len];
11444 struct crypto_testsuite_params *ts_params = &testsuite_params;
11445 struct crypto_unittest_params *ut_params = &unittest_params;
11447 memcpy(auth_key, tdata->key.data, tdata->key.len);
11449 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11450 ut_params->auth_xform.next = NULL;
11452 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11453 ut_params->auth_xform.auth.op = auth_op;
11454 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11455 ut_params->auth_xform.auth.key.length = tdata->key.len;
11456 ut_params->auth_xform.auth.key.data = auth_key;
11457 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11458 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11461 ut_params->sess = rte_cryptodev_sym_session_create(
11462 ts_params->session_mpool);
11464 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11465 &ut_params->auth_xform,
11466 ts_params->session_priv_mpool);
11468 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11474 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11476 struct crypto_testsuite_params *ts_params = &testsuite_params;
11477 struct crypto_unittest_params *ut_params = &unittest_params;
11478 struct rte_cryptodev_info dev_info;
11480 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11481 uint64_t feat_flags = dev_info.feature_flags;
11483 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11484 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11485 printf("Device doesn't support RAW data-path APIs.\n");
11486 return TEST_SKIPPED;
11491 uint8_t *auth_tag, *plaintext;
11492 uint16_t plaintext_pad_len;
11494 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11495 "No GMAC length in the source data");
11497 /* Verify the capabilities */
11498 struct rte_cryptodev_sym_capability_idx cap_idx;
11499 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11500 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11501 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11503 return TEST_SKIPPED;
11505 retval = create_gmac_session(ts_params->valid_devs[0],
11506 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11511 if (tdata->plaintext.len > MBUF_SIZE)
11512 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11515 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11516 "Failed to allocate input buffer in mempool");
11518 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11519 rte_pktmbuf_tailroom(ut_params->ibuf));
11521 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11523 * Runtime generate the large plain text instead of use hard code
11524 * plain text vector. It is done to avoid create huge source file
11525 * with the test vector.
11527 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11528 generate_gmac_large_plaintext(tdata->plaintext.data);
11530 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11531 plaintext_pad_len);
11532 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11534 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11535 debug_hexdump(stdout, "plaintext:", plaintext,
11536 tdata->plaintext.len);
11538 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11544 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11546 ut_params->op->sym->m_src = ut_params->ibuf;
11548 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11549 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11551 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11552 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11553 ut_params->op, 0, 1, 0, 0);
11555 TEST_ASSERT_NOT_NULL(
11556 process_crypto_request(ts_params->valid_devs[0],
11557 ut_params->op), "failed to process sym crypto op");
11559 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11560 "crypto op processing failed");
11562 if (ut_params->op->sym->m_dst) {
11563 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11564 uint8_t *, plaintext_pad_len);
11566 auth_tag = plaintext + plaintext_pad_len;
11569 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11571 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11573 tdata->gmac_tag.data,
11574 tdata->gmac_tag.len,
11575 "GMAC Generated auth tag not as expected");
11581 test_AES_GMAC_authentication_test_case_1(void)
11583 return test_AES_GMAC_authentication(&gmac_test_case_1);
11587 test_AES_GMAC_authentication_test_case_2(void)
11589 return test_AES_GMAC_authentication(&gmac_test_case_2);
11593 test_AES_GMAC_authentication_test_case_3(void)
11595 return test_AES_GMAC_authentication(&gmac_test_case_3);
11599 test_AES_GMAC_authentication_test_case_4(void)
11601 return test_AES_GMAC_authentication(&gmac_test_case_4);
11605 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11607 struct crypto_testsuite_params *ts_params = &testsuite_params;
11608 struct crypto_unittest_params *ut_params = &unittest_params;
11610 uint32_t plaintext_pad_len;
11611 uint8_t *plaintext;
11612 struct rte_cryptodev_info dev_info;
11614 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11615 uint64_t feat_flags = dev_info.feature_flags;
11617 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11618 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11619 printf("Device doesn't support RAW data-path APIs.\n");
11620 return TEST_SKIPPED;
11623 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11624 "No GMAC length in the source data");
11626 /* Verify the capabilities */
11627 struct rte_cryptodev_sym_capability_idx cap_idx;
11628 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11629 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11630 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11632 return TEST_SKIPPED;
11634 retval = create_gmac_session(ts_params->valid_devs[0],
11635 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11640 if (tdata->plaintext.len > MBUF_SIZE)
11641 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11643 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11644 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11645 "Failed to allocate input buffer in mempool");
11647 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11648 rte_pktmbuf_tailroom(ut_params->ibuf));
11650 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11653 * Runtime generate the large plain text instead of use hard code
11654 * plain text vector. It is done to avoid create huge source file
11655 * with the test vector.
11657 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11658 generate_gmac_large_plaintext(tdata->plaintext.data);
11660 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11661 plaintext_pad_len);
11662 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11664 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11665 debug_hexdump(stdout, "plaintext:", plaintext,
11666 tdata->plaintext.len);
11668 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11674 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11676 ut_params->op->sym->m_src = ut_params->ibuf;
11678 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11679 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11681 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11682 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11683 ut_params->op, 0, 1, 0, 0);
11685 TEST_ASSERT_NOT_NULL(
11686 process_crypto_request(ts_params->valid_devs[0],
11687 ut_params->op), "failed to process sym crypto op");
11689 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11690 "crypto op processing failed");
11697 test_AES_GMAC_authentication_verify_test_case_1(void)
11699 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11703 test_AES_GMAC_authentication_verify_test_case_2(void)
11705 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11709 test_AES_GMAC_authentication_verify_test_case_3(void)
11711 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11715 test_AES_GMAC_authentication_verify_test_case_4(void)
11717 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11721 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11724 struct crypto_testsuite_params *ts_params = &testsuite_params;
11725 struct crypto_unittest_params *ut_params = &unittest_params;
11726 struct rte_cryptodev_info dev_info;
11727 uint64_t feature_flags;
11728 unsigned int trn_data = 0;
11729 void *digest_mem = NULL;
11731 unsigned int to_trn = 0;
11732 struct rte_mbuf *buf = NULL;
11733 uint8_t *auth_tag, *plaintext;
11736 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11737 "No GMAC length in the source data");
11739 /* Verify the capabilities */
11740 struct rte_cryptodev_sym_capability_idx cap_idx;
11741 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11742 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11743 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11745 return TEST_SKIPPED;
11747 /* Check for any input SGL support */
11748 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11749 feature_flags = dev_info.feature_flags;
11751 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11752 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11753 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11754 return TEST_SKIPPED;
11756 if (fragsz > tdata->plaintext.len)
11757 fragsz = tdata->plaintext.len;
11759 uint16_t plaintext_len = fragsz;
11761 retval = create_gmac_session(ts_params->valid_devs[0],
11762 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11767 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11768 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11769 "Failed to allocate input buffer in mempool");
11771 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11772 rte_pktmbuf_tailroom(ut_params->ibuf));
11774 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11776 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11778 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11780 trn_data += plaintext_len;
11782 buf = ut_params->ibuf;
11785 * Loop until no more fragments
11788 while (trn_data < tdata->plaintext.len) {
11790 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11791 (tdata->plaintext.len - trn_data) : fragsz;
11793 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11796 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11797 rte_pktmbuf_tailroom(buf));
11799 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11802 memcpy(plaintext, tdata->plaintext.data + trn_data,
11804 trn_data += to_trn;
11805 if (trn_data == tdata->plaintext.len)
11806 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11807 tdata->gmac_tag.len);
11809 ut_params->ibuf->nb_segs = segs;
11812 * Place digest at the end of the last buffer
11814 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11817 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11818 + tdata->gmac_tag.len);
11819 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11820 tdata->plaintext.len);
11823 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11824 tdata, digest_mem, digest_phys);
11829 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11831 ut_params->op->sym->m_src = ut_params->ibuf;
11833 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11834 return TEST_SKIPPED;
11836 TEST_ASSERT_NOT_NULL(
11837 process_crypto_request(ts_params->valid_devs[0],
11838 ut_params->op), "failed to process sym crypto op");
11840 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11841 "crypto op processing failed");
11843 auth_tag = digest_mem;
11844 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11845 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11847 tdata->gmac_tag.data,
11848 tdata->gmac_tag.len,
11849 "GMAC Generated auth tag not as expected");
11854 /* Segment size not multiple of block size (16B) */
11856 test_AES_GMAC_authentication_SGL_40B(void)
11858 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11862 test_AES_GMAC_authentication_SGL_80B(void)
11864 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11868 test_AES_GMAC_authentication_SGL_2048B(void)
11870 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11873 /* Segment size not multiple of block size (16B) */
11875 test_AES_GMAC_authentication_SGL_2047B(void)
11877 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11880 struct test_crypto_vector {
11881 enum rte_crypto_cipher_algorithm crypto_algo;
11882 unsigned int cipher_offset;
11883 unsigned int cipher_len;
11896 const uint8_t *data;
11901 const uint8_t *data;
11905 enum rte_crypto_auth_algorithm auth_algo;
11906 unsigned int auth_offset;
11914 const uint8_t *data;
11924 static const struct test_crypto_vector
11925 hmac_sha1_test_crypto_vector = {
11926 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11928 .data = plaintext_hash,
11933 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11934 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11935 0xDE, 0xF4, 0xDE, 0xAD
11941 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11942 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11943 0x3F, 0x91, 0x64, 0x59
11949 static const struct test_crypto_vector
11950 aes128_gmac_test_vector = {
11951 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11953 .data = plaintext_hash,
11958 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11959 0x08, 0x09, 0x0A, 0x0B
11965 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11966 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11972 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11973 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11979 static const struct test_crypto_vector
11980 aes128cbc_hmac_sha1_test_vector = {
11981 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11982 .cipher_offset = 0,
11986 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11987 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11993 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11994 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11999 .data = plaintext_hash,
12003 .data = ciphertext512_aes128cbc,
12006 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12010 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12011 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12012 0xDE, 0xF4, 0xDE, 0xAD
12018 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12019 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12020 0x18, 0x8C, 0x1D, 0x32
12026 static const struct test_crypto_vector
12027 aes128cbc_hmac_sha1_aad_test_vector = {
12028 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12029 .cipher_offset = 8,
12033 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12034 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12040 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12041 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12046 .data = plaintext_hash,
12050 .data = ciphertext512_aes128cbc_aad,
12053 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12057 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12058 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12059 0xDE, 0xF4, 0xDE, 0xAD
12065 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12066 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12067 0x62, 0x0F, 0xFB, 0x10
12074 data_corruption(uint8_t *data)
12080 tag_corruption(uint8_t *data, unsigned int tag_offset)
12082 data[tag_offset] += 1;
12086 create_auth_session(struct crypto_unittest_params *ut_params,
12088 const struct test_crypto_vector *reference,
12089 enum rte_crypto_auth_operation auth_op)
12091 struct crypto_testsuite_params *ts_params = &testsuite_params;
12092 uint8_t auth_key[reference->auth_key.len + 1];
12094 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12096 /* Setup Authentication Parameters */
12097 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12098 ut_params->auth_xform.auth.op = auth_op;
12099 ut_params->auth_xform.next = NULL;
12100 ut_params->auth_xform.auth.algo = reference->auth_algo;
12101 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12102 ut_params->auth_xform.auth.key.data = auth_key;
12103 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12105 /* Create Crypto session*/
12106 ut_params->sess = rte_cryptodev_sym_session_create(
12107 ts_params->session_mpool);
12109 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12110 &ut_params->auth_xform,
12111 ts_params->session_priv_mpool);
12113 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12119 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12121 const struct test_crypto_vector *reference,
12122 enum rte_crypto_auth_operation auth_op,
12123 enum rte_crypto_cipher_operation cipher_op)
12125 struct crypto_testsuite_params *ts_params = &testsuite_params;
12126 uint8_t cipher_key[reference->cipher_key.len + 1];
12127 uint8_t auth_key[reference->auth_key.len + 1];
12129 memcpy(cipher_key, reference->cipher_key.data,
12130 reference->cipher_key.len);
12131 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12133 /* Setup Authentication Parameters */
12134 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12135 ut_params->auth_xform.auth.op = auth_op;
12136 ut_params->auth_xform.auth.algo = reference->auth_algo;
12137 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12138 ut_params->auth_xform.auth.key.data = auth_key;
12139 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12141 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12142 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12143 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12145 ut_params->auth_xform.next = &ut_params->cipher_xform;
12147 /* Setup Cipher Parameters */
12148 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12149 ut_params->cipher_xform.next = NULL;
12150 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12151 ut_params->cipher_xform.cipher.op = cipher_op;
12152 ut_params->cipher_xform.cipher.key.data = cipher_key;
12153 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12154 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12155 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12158 /* Create Crypto session*/
12159 ut_params->sess = rte_cryptodev_sym_session_create(
12160 ts_params->session_mpool);
12162 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12163 &ut_params->auth_xform,
12164 ts_params->session_priv_mpool);
12166 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12172 create_auth_operation(struct crypto_testsuite_params *ts_params,
12173 struct crypto_unittest_params *ut_params,
12174 const struct test_crypto_vector *reference,
12175 unsigned int auth_generate)
12177 /* Generate Crypto op data structure */
12178 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12179 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12180 TEST_ASSERT_NOT_NULL(ut_params->op,
12181 "Failed to allocate pktmbuf offload");
12183 /* Set crypto operation data parameters */
12184 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12186 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12188 /* set crypto operation source mbuf */
12189 sym_op->m_src = ut_params->ibuf;
12192 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12193 ut_params->ibuf, reference->digest.len);
12195 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12196 "no room to append auth tag");
12198 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12199 ut_params->ibuf, reference->plaintext.len);
12202 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12204 memcpy(sym_op->auth.digest.data,
12205 reference->digest.data,
12206 reference->digest.len);
12208 debug_hexdump(stdout, "digest:",
12209 sym_op->auth.digest.data,
12210 reference->digest.len);
12212 sym_op->auth.data.length = reference->plaintext.len;
12213 sym_op->auth.data.offset = 0;
12219 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12220 struct crypto_unittest_params *ut_params,
12221 const struct test_crypto_vector *reference,
12222 unsigned int auth_generate)
12224 /* Generate Crypto op data structure */
12225 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12226 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12227 TEST_ASSERT_NOT_NULL(ut_params->op,
12228 "Failed to allocate pktmbuf offload");
12230 /* Set crypto operation data parameters */
12231 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12233 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12235 /* set crypto operation source mbuf */
12236 sym_op->m_src = ut_params->ibuf;
12239 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12240 ut_params->ibuf, reference->digest.len);
12242 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12243 "no room to append auth tag");
12245 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12246 ut_params->ibuf, reference->ciphertext.len);
12249 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12251 memcpy(sym_op->auth.digest.data,
12252 reference->digest.data,
12253 reference->digest.len);
12255 debug_hexdump(stdout, "digest:",
12256 sym_op->auth.digest.data,
12257 reference->digest.len);
12259 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12260 reference->iv.data, reference->iv.len);
12262 sym_op->cipher.data.length = 0;
12263 sym_op->cipher.data.offset = 0;
12265 sym_op->auth.data.length = reference->plaintext.len;
12266 sym_op->auth.data.offset = 0;
12272 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12273 struct crypto_unittest_params *ut_params,
12274 const struct test_crypto_vector *reference,
12275 unsigned int auth_generate)
12277 /* Generate Crypto op data structure */
12278 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12279 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12280 TEST_ASSERT_NOT_NULL(ut_params->op,
12281 "Failed to allocate pktmbuf offload");
12283 /* Set crypto operation data parameters */
12284 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12286 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12288 /* set crypto operation source mbuf */
12289 sym_op->m_src = ut_params->ibuf;
12292 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12293 ut_params->ibuf, reference->digest.len);
12295 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12296 "no room to append auth tag");
12298 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12299 ut_params->ibuf, reference->ciphertext.len);
12302 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12304 memcpy(sym_op->auth.digest.data,
12305 reference->digest.data,
12306 reference->digest.len);
12308 debug_hexdump(stdout, "digest:",
12309 sym_op->auth.digest.data,
12310 reference->digest.len);
12312 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12313 reference->iv.data, reference->iv.len);
12315 sym_op->cipher.data.length = reference->cipher_len;
12316 sym_op->cipher.data.offset = reference->cipher_offset;
12318 sym_op->auth.data.length = reference->plaintext.len;
12319 sym_op->auth.data.offset = reference->auth_offset;
12325 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12326 struct crypto_unittest_params *ut_params,
12327 const struct test_crypto_vector *reference)
12329 return create_auth_operation(ts_params, ut_params, reference, 0);
12333 create_auth_verify_GMAC_operation(
12334 struct crypto_testsuite_params *ts_params,
12335 struct crypto_unittest_params *ut_params,
12336 const struct test_crypto_vector *reference)
12338 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12342 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12343 struct crypto_unittest_params *ut_params,
12344 const struct test_crypto_vector *reference)
12346 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12350 test_authentication_verify_fail_when_data_corruption(
12351 struct crypto_testsuite_params *ts_params,
12352 struct crypto_unittest_params *ut_params,
12353 const struct test_crypto_vector *reference,
12354 unsigned int data_corrupted)
12358 uint8_t *plaintext;
12359 struct rte_cryptodev_info dev_info;
12361 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12362 uint64_t feat_flags = dev_info.feature_flags;
12364 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12365 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12366 printf("Device doesn't support RAW data-path APIs.\n");
12367 return TEST_SKIPPED;
12370 /* Verify the capabilities */
12371 struct rte_cryptodev_sym_capability_idx cap_idx;
12372 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12373 cap_idx.algo.auth = reference->auth_algo;
12374 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12376 return TEST_SKIPPED;
12379 /* Create session */
12380 retval = create_auth_session(ut_params,
12381 ts_params->valid_devs[0],
12383 RTE_CRYPTO_AUTH_OP_VERIFY);
12387 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12388 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12389 "Failed to allocate input buffer in mempool");
12391 /* clear mbuf payload */
12392 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12393 rte_pktmbuf_tailroom(ut_params->ibuf));
12395 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12396 reference->plaintext.len);
12397 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12398 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12400 debug_hexdump(stdout, "plaintext:", plaintext,
12401 reference->plaintext.len);
12403 /* Create operation */
12404 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12409 if (data_corrupted)
12410 data_corruption(plaintext);
12412 tag_corruption(plaintext, reference->plaintext.len);
12414 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12415 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12417 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12418 RTE_CRYPTO_OP_STATUS_SUCCESS,
12419 "authentication not failed");
12420 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12421 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12422 ut_params->op, 0, 1, 0, 0);
12424 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12426 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12433 test_authentication_verify_GMAC_fail_when_corruption(
12434 struct crypto_testsuite_params *ts_params,
12435 struct crypto_unittest_params *ut_params,
12436 const struct test_crypto_vector *reference,
12437 unsigned int data_corrupted)
12440 uint8_t *plaintext;
12441 struct rte_cryptodev_info dev_info;
12443 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12444 uint64_t feat_flags = dev_info.feature_flags;
12446 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12447 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12448 printf("Device doesn't support RAW data-path APIs.\n");
12449 return TEST_SKIPPED;
12452 /* Verify the capabilities */
12453 struct rte_cryptodev_sym_capability_idx cap_idx;
12454 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12455 cap_idx.algo.auth = reference->auth_algo;
12456 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12458 return TEST_SKIPPED;
12460 /* Create session */
12461 retval = create_auth_cipher_session(ut_params,
12462 ts_params->valid_devs[0],
12464 RTE_CRYPTO_AUTH_OP_VERIFY,
12465 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12469 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12470 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12471 "Failed to allocate input buffer in mempool");
12473 /* clear mbuf payload */
12474 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12475 rte_pktmbuf_tailroom(ut_params->ibuf));
12477 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12478 reference->plaintext.len);
12479 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12480 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12482 debug_hexdump(stdout, "plaintext:", plaintext,
12483 reference->plaintext.len);
12485 /* Create operation */
12486 retval = create_auth_verify_GMAC_operation(ts_params,
12493 if (data_corrupted)
12494 data_corruption(plaintext);
12496 tag_corruption(plaintext, reference->aad.len);
12498 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12499 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12501 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12502 RTE_CRYPTO_OP_STATUS_SUCCESS,
12503 "authentication not failed");
12504 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12505 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12506 ut_params->op, 0, 1, 0, 0);
12508 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12510 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12517 test_authenticated_decryption_fail_when_corruption(
12518 struct crypto_testsuite_params *ts_params,
12519 struct crypto_unittest_params *ut_params,
12520 const struct test_crypto_vector *reference,
12521 unsigned int data_corrupted)
12525 uint8_t *ciphertext;
12526 struct rte_cryptodev_info dev_info;
12528 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12529 uint64_t feat_flags = dev_info.feature_flags;
12531 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12532 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12533 printf("Device doesn't support RAW data-path APIs.\n");
12534 return TEST_SKIPPED;
12537 /* Verify the capabilities */
12538 struct rte_cryptodev_sym_capability_idx cap_idx;
12539 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12540 cap_idx.algo.auth = reference->auth_algo;
12541 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12543 return TEST_SKIPPED;
12544 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12545 cap_idx.algo.cipher = reference->crypto_algo;
12546 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12548 return TEST_SKIPPED;
12550 /* Create session */
12551 retval = create_auth_cipher_session(ut_params,
12552 ts_params->valid_devs[0],
12554 RTE_CRYPTO_AUTH_OP_VERIFY,
12555 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12560 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12561 "Failed to allocate input buffer in mempool");
12563 /* clear mbuf payload */
12564 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12565 rte_pktmbuf_tailroom(ut_params->ibuf));
12567 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12568 reference->ciphertext.len);
12569 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12570 memcpy(ciphertext, reference->ciphertext.data,
12571 reference->ciphertext.len);
12573 /* Create operation */
12574 retval = create_cipher_auth_verify_operation(ts_params,
12581 if (data_corrupted)
12582 data_corruption(ciphertext);
12584 tag_corruption(ciphertext, reference->ciphertext.len);
12586 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12587 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12589 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12590 RTE_CRYPTO_OP_STATUS_SUCCESS,
12591 "authentication not failed");
12592 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12593 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12594 ut_params->op, 1, 1, 0, 0);
12596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12598 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12605 test_authenticated_encrypt_with_esn(
12606 struct crypto_testsuite_params *ts_params,
12607 struct crypto_unittest_params *ut_params,
12608 const struct test_crypto_vector *reference)
12612 uint8_t *authciphertext, *plaintext, *auth_tag;
12613 uint16_t plaintext_pad_len;
12614 uint8_t cipher_key[reference->cipher_key.len + 1];
12615 uint8_t auth_key[reference->auth_key.len + 1];
12616 struct rte_cryptodev_info dev_info;
12618 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12619 uint64_t feat_flags = dev_info.feature_flags;
12621 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12622 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12623 printf("Device doesn't support RAW data-path APIs.\n");
12624 return TEST_SKIPPED;
12627 /* Verify the capabilities */
12628 struct rte_cryptodev_sym_capability_idx cap_idx;
12629 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12630 cap_idx.algo.auth = reference->auth_algo;
12631 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12633 return TEST_SKIPPED;
12634 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12635 cap_idx.algo.cipher = reference->crypto_algo;
12636 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12638 return TEST_SKIPPED;
12640 /* Create session */
12641 memcpy(cipher_key, reference->cipher_key.data,
12642 reference->cipher_key.len);
12643 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12645 /* Setup Cipher Parameters */
12646 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12647 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12648 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12649 ut_params->cipher_xform.cipher.key.data = cipher_key;
12650 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12651 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12652 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12654 ut_params->cipher_xform.next = &ut_params->auth_xform;
12656 /* Setup Authentication Parameters */
12657 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12658 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12659 ut_params->auth_xform.auth.algo = reference->auth_algo;
12660 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12661 ut_params->auth_xform.auth.key.data = auth_key;
12662 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12663 ut_params->auth_xform.next = NULL;
12665 /* Create Crypto session*/
12666 ut_params->sess = rte_cryptodev_sym_session_create(
12667 ts_params->session_mpool);
12669 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12671 &ut_params->cipher_xform,
12672 ts_params->session_priv_mpool);
12674 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12676 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12677 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12678 "Failed to allocate input buffer in mempool");
12680 /* clear mbuf payload */
12681 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12682 rte_pktmbuf_tailroom(ut_params->ibuf));
12684 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12685 reference->plaintext.len);
12686 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12687 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12689 /* Create operation */
12690 retval = create_cipher_auth_operation(ts_params,
12697 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12698 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12700 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12701 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12702 ut_params->op, 1, 1, 0, 0);
12704 ut_params->op = process_crypto_request(
12705 ts_params->valid_devs[0], ut_params->op);
12707 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12709 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12710 "crypto op processing failed");
12712 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12714 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12715 ut_params->op->sym->auth.data.offset);
12716 auth_tag = authciphertext + plaintext_pad_len;
12717 debug_hexdump(stdout, "ciphertext:", authciphertext,
12718 reference->ciphertext.len);
12719 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12721 /* Validate obuf */
12722 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12724 reference->ciphertext.data,
12725 reference->ciphertext.len,
12726 "Ciphertext data not as expected");
12728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12730 reference->digest.data,
12731 reference->digest.len,
12732 "Generated digest not as expected");
12734 return TEST_SUCCESS;
12739 test_authenticated_decrypt_with_esn(
12740 struct crypto_testsuite_params *ts_params,
12741 struct crypto_unittest_params *ut_params,
12742 const struct test_crypto_vector *reference)
12746 uint8_t *ciphertext;
12747 uint8_t cipher_key[reference->cipher_key.len + 1];
12748 uint8_t auth_key[reference->auth_key.len + 1];
12749 struct rte_cryptodev_info dev_info;
12751 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12752 uint64_t feat_flags = dev_info.feature_flags;
12754 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12755 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12756 printf("Device doesn't support RAW data-path APIs.\n");
12757 return TEST_SKIPPED;
12760 /* Verify the capabilities */
12761 struct rte_cryptodev_sym_capability_idx cap_idx;
12762 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12763 cap_idx.algo.auth = reference->auth_algo;
12764 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12766 return TEST_SKIPPED;
12767 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12768 cap_idx.algo.cipher = reference->crypto_algo;
12769 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12771 return TEST_SKIPPED;
12773 /* Create session */
12774 memcpy(cipher_key, reference->cipher_key.data,
12775 reference->cipher_key.len);
12776 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12778 /* Setup Authentication Parameters */
12779 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12780 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12781 ut_params->auth_xform.auth.algo = reference->auth_algo;
12782 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12783 ut_params->auth_xform.auth.key.data = auth_key;
12784 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12785 ut_params->auth_xform.next = &ut_params->cipher_xform;
12787 /* Setup Cipher Parameters */
12788 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12789 ut_params->cipher_xform.next = NULL;
12790 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12791 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12792 ut_params->cipher_xform.cipher.key.data = cipher_key;
12793 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12794 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12795 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12797 /* Create Crypto session*/
12798 ut_params->sess = rte_cryptodev_sym_session_create(
12799 ts_params->session_mpool);
12801 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12803 &ut_params->auth_xform,
12804 ts_params->session_priv_mpool);
12806 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12808 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12809 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12810 "Failed to allocate input buffer in mempool");
12812 /* clear mbuf payload */
12813 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12814 rte_pktmbuf_tailroom(ut_params->ibuf));
12816 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12817 reference->ciphertext.len);
12818 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12819 memcpy(ciphertext, reference->ciphertext.data,
12820 reference->ciphertext.len);
12822 /* Create operation */
12823 retval = create_cipher_auth_verify_operation(ts_params,
12830 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12831 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12833 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12834 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12835 ut_params->op, 1, 1, 0, 0);
12837 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12840 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12841 TEST_ASSERT_EQUAL(ut_params->op->status,
12842 RTE_CRYPTO_OP_STATUS_SUCCESS,
12843 "crypto op processing passed");
12845 ut_params->obuf = ut_params->op->sym->m_src;
12846 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12852 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12853 const struct aead_test_data *tdata,
12854 void *digest_mem, uint64_t digest_phys)
12856 struct crypto_testsuite_params *ts_params = &testsuite_params;
12857 struct crypto_unittest_params *ut_params = &unittest_params;
12859 const unsigned int auth_tag_len = tdata->auth_tag.len;
12860 const unsigned int iv_len = tdata->iv.len;
12861 unsigned int aad_len = tdata->aad.len;
12862 unsigned int aad_len_pad = 0;
12864 /* Generate Crypto op data structure */
12865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12867 TEST_ASSERT_NOT_NULL(ut_params->op,
12868 "Failed to allocate symmetric crypto operation struct");
12870 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12872 sym_op->aead.digest.data = digest_mem;
12874 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12875 "no room to append digest");
12877 sym_op->aead.digest.phys_addr = digest_phys;
12879 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12880 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12882 debug_hexdump(stdout, "digest:",
12883 sym_op->aead.digest.data,
12887 /* Append aad data */
12888 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12889 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12890 uint8_t *, IV_OFFSET);
12892 /* Copy IV 1 byte after the IV pointer, according to the API */
12893 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12895 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12897 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12898 ut_params->ibuf, aad_len);
12899 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12900 "no room to prepend aad");
12901 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12904 memset(sym_op->aead.aad.data, 0, aad_len);
12905 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12906 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12908 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12909 debug_hexdump(stdout, "aad:",
12910 sym_op->aead.aad.data, aad_len);
12912 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12913 uint8_t *, IV_OFFSET);
12915 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12917 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12919 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12920 ut_params->ibuf, aad_len_pad);
12921 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12922 "no room to prepend aad");
12923 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12926 memset(sym_op->aead.aad.data, 0, aad_len);
12927 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12929 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12930 debug_hexdump(stdout, "aad:",
12931 sym_op->aead.aad.data, aad_len);
12934 sym_op->aead.data.length = tdata->plaintext.len;
12935 sym_op->aead.data.offset = aad_len_pad;
12940 #define SGL_MAX_NO 16
12943 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12944 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12946 struct crypto_testsuite_params *ts_params = &testsuite_params;
12947 struct crypto_unittest_params *ut_params = &unittest_params;
12948 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12951 int to_trn_tbl[SGL_MAX_NO];
12953 unsigned int trn_data = 0;
12954 uint8_t *plaintext, *ciphertext, *auth_tag;
12955 struct rte_cryptodev_info dev_info;
12957 /* Verify the capabilities */
12958 struct rte_cryptodev_sym_capability_idx cap_idx;
12959 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12960 cap_idx.algo.aead = tdata->algo;
12961 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12963 return TEST_SKIPPED;
12965 /* OOP not supported with CPU crypto */
12966 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12967 return TEST_SKIPPED;
12969 /* Detailed check for the particular SGL support flag */
12970 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12972 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12973 if (sgl_in && (!(dev_info.feature_flags &
12974 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12975 return TEST_SKIPPED;
12977 uint64_t feat_flags = dev_info.feature_flags;
12979 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12980 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12981 printf("Device doesn't support RAW data-path APIs.\n");
12982 return TEST_SKIPPED;
12985 unsigned int sgl_in = fragsz < tdata->plaintext.len;
12986 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12987 tdata->plaintext.len;
12988 /* Raw data path API does not support OOP */
12989 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12990 return TEST_SKIPPED;
12991 if (sgl_in && !sgl_out) {
12992 if (!(dev_info.feature_flags &
12993 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12994 return TEST_SKIPPED;
12995 } else if (!sgl_in && sgl_out) {
12996 if (!(dev_info.feature_flags &
12997 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12998 return TEST_SKIPPED;
12999 } else if (sgl_in && sgl_out) {
13000 if (!(dev_info.feature_flags &
13001 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13002 return TEST_SKIPPED;
13006 if (fragsz > tdata->plaintext.len)
13007 fragsz = tdata->plaintext.len;
13009 uint16_t plaintext_len = fragsz;
13010 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13012 if (fragsz_oop > tdata->plaintext.len)
13013 frag_size_oop = tdata->plaintext.len;
13016 void *digest_mem = NULL;
13018 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13020 if (tdata->plaintext.len % fragsz != 0) {
13021 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13024 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13029 * For out-op-place we need to alloc another mbuf
13032 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13033 rte_pktmbuf_append(ut_params->obuf,
13034 frag_size_oop + prepend_len);
13035 buf_oop = ut_params->obuf;
13038 /* Create AEAD session */
13039 retval = create_aead_session(ts_params->valid_devs[0],
13041 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13042 tdata->key.data, tdata->key.len,
13043 tdata->aad.len, tdata->auth_tag.len,
13048 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13050 /* clear mbuf payload */
13051 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13052 rte_pktmbuf_tailroom(ut_params->ibuf));
13054 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13057 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13059 trn_data += plaintext_len;
13061 buf = ut_params->ibuf;
13064 * Loop until no more fragments
13067 while (trn_data < tdata->plaintext.len) {
13069 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13070 (tdata->plaintext.len - trn_data) : fragsz;
13072 to_trn_tbl[ecx++] = to_trn;
13074 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13077 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13078 rte_pktmbuf_tailroom(buf));
13081 if (oop && !fragsz_oop) {
13082 buf_last_oop = buf_oop->next =
13083 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13084 buf_oop = buf_oop->next;
13085 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13086 0, rte_pktmbuf_tailroom(buf_oop));
13087 rte_pktmbuf_append(buf_oop, to_trn);
13090 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13093 memcpy(plaintext, tdata->plaintext.data + trn_data,
13095 trn_data += to_trn;
13096 if (trn_data == tdata->plaintext.len) {
13099 digest_mem = rte_pktmbuf_append(buf_oop,
13100 tdata->auth_tag.len);
13102 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13103 tdata->auth_tag.len);
13107 uint64_t digest_phys = 0;
13109 ut_params->ibuf->nb_segs = segs;
13112 if (fragsz_oop && oop) {
13116 if (frag_size_oop == tdata->plaintext.len) {
13117 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13118 tdata->auth_tag.len);
13120 digest_phys = rte_pktmbuf_iova_offset(
13122 tdata->plaintext.len + prepend_len);
13125 trn_data = frag_size_oop;
13126 while (trn_data < tdata->plaintext.len) {
13129 (tdata->plaintext.len - trn_data <
13131 (tdata->plaintext.len - trn_data) :
13134 to_trn_tbl[ecx++] = to_trn;
13136 buf_last_oop = buf_oop->next =
13137 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13138 buf_oop = buf_oop->next;
13139 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13140 0, rte_pktmbuf_tailroom(buf_oop));
13141 rte_pktmbuf_append(buf_oop, to_trn);
13143 trn_data += to_trn;
13145 if (trn_data == tdata->plaintext.len) {
13146 digest_mem = rte_pktmbuf_append(buf_oop,
13147 tdata->auth_tag.len);
13151 ut_params->obuf->nb_segs = segs;
13155 * Place digest at the end of the last buffer
13158 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13159 if (oop && buf_last_oop)
13160 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13162 if (!digest_mem && !oop) {
13163 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13164 + tdata->auth_tag.len);
13165 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13166 tdata->plaintext.len);
13169 /* Create AEAD operation */
13170 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13171 tdata, digest_mem, digest_phys);
13176 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13178 ut_params->op->sym->m_src = ut_params->ibuf;
13180 ut_params->op->sym->m_dst = ut_params->obuf;
13182 /* Process crypto operation */
13183 if (oop == IN_PLACE &&
13184 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13185 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13186 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13187 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13188 ut_params->op, 0, 0, 0, 0);
13190 TEST_ASSERT_NOT_NULL(
13191 process_crypto_request(ts_params->valid_devs[0],
13192 ut_params->op), "failed to process sym crypto op");
13194 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13195 "crypto op processing failed");
13198 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13199 uint8_t *, prepend_len);
13201 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13202 uint8_t *, prepend_len);
13206 fragsz = fragsz_oop;
13208 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13210 tdata->ciphertext.data,
13212 "Ciphertext data not as expected");
13214 buf = ut_params->op->sym->m_src->next;
13216 buf = ut_params->op->sym->m_dst->next;
13218 unsigned int off = fragsz;
13222 ciphertext = rte_pktmbuf_mtod(buf,
13225 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13227 tdata->ciphertext.data + off,
13229 "Ciphertext data not as expected");
13231 off += to_trn_tbl[ecx++];
13235 auth_tag = digest_mem;
13236 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13238 tdata->auth_tag.data,
13239 tdata->auth_tag.len,
13240 "Generated auth tag not as expected");
13246 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13248 return test_authenticated_encryption_SGL(
13249 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13253 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13255 return test_authenticated_encryption_SGL(
13256 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13260 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13262 return test_authenticated_encryption_SGL(
13263 &gcm_test_case_8, OUT_OF_PLACE, 400,
13264 gcm_test_case_8.plaintext.len);
13268 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13270 /* This test is not for OPENSSL PMD */
13271 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13272 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13273 return TEST_SKIPPED;
13275 return test_authenticated_encryption_SGL(
13276 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13280 test_authentication_verify_fail_when_data_corrupted(
13281 struct crypto_testsuite_params *ts_params,
13282 struct crypto_unittest_params *ut_params,
13283 const struct test_crypto_vector *reference)
13285 return test_authentication_verify_fail_when_data_corruption(
13286 ts_params, ut_params, reference, 1);
13290 test_authentication_verify_fail_when_tag_corrupted(
13291 struct crypto_testsuite_params *ts_params,
13292 struct crypto_unittest_params *ut_params,
13293 const struct test_crypto_vector *reference)
13295 return test_authentication_verify_fail_when_data_corruption(
13296 ts_params, ut_params, reference, 0);
13300 test_authentication_verify_GMAC_fail_when_data_corrupted(
13301 struct crypto_testsuite_params *ts_params,
13302 struct crypto_unittest_params *ut_params,
13303 const struct test_crypto_vector *reference)
13305 return test_authentication_verify_GMAC_fail_when_corruption(
13306 ts_params, ut_params, reference, 1);
13310 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13311 struct crypto_testsuite_params *ts_params,
13312 struct crypto_unittest_params *ut_params,
13313 const struct test_crypto_vector *reference)
13315 return test_authentication_verify_GMAC_fail_when_corruption(
13316 ts_params, ut_params, reference, 0);
13320 test_authenticated_decryption_fail_when_data_corrupted(
13321 struct crypto_testsuite_params *ts_params,
13322 struct crypto_unittest_params *ut_params,
13323 const struct test_crypto_vector *reference)
13325 return test_authenticated_decryption_fail_when_corruption(
13326 ts_params, ut_params, reference, 1);
13330 test_authenticated_decryption_fail_when_tag_corrupted(
13331 struct crypto_testsuite_params *ts_params,
13332 struct crypto_unittest_params *ut_params,
13333 const struct test_crypto_vector *reference)
13335 return test_authenticated_decryption_fail_when_corruption(
13336 ts_params, ut_params, reference, 0);
13340 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13342 return test_authentication_verify_fail_when_data_corrupted(
13343 &testsuite_params, &unittest_params,
13344 &hmac_sha1_test_crypto_vector);
13348 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13350 return test_authentication_verify_fail_when_tag_corrupted(
13351 &testsuite_params, &unittest_params,
13352 &hmac_sha1_test_crypto_vector);
13356 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13358 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13359 &testsuite_params, &unittest_params,
13360 &aes128_gmac_test_vector);
13364 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13366 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13367 &testsuite_params, &unittest_params,
13368 &aes128_gmac_test_vector);
13372 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13374 return test_authenticated_decryption_fail_when_data_corrupted(
13377 &aes128cbc_hmac_sha1_test_vector);
13381 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13383 return test_authenticated_decryption_fail_when_tag_corrupted(
13386 &aes128cbc_hmac_sha1_test_vector);
13390 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13392 return test_authenticated_encrypt_with_esn(
13395 &aes128cbc_hmac_sha1_aad_test_vector);
13399 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13401 return test_authenticated_decrypt_with_esn(
13404 &aes128cbc_hmac_sha1_aad_test_vector);
13408 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13410 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13414 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13416 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13419 #ifdef RTE_CRYPTO_SCHEDULER
13421 /* global AESNI worker IDs for the scheduler test */
13422 uint8_t aesni_ids[2];
13425 scheduler_testsuite_setup(void)
13428 int32_t nb_devs, ret;
13429 char vdev_args[VDEV_ARGS_SIZE] = {""};
13430 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13431 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13432 uint16_t worker_core_count = 0;
13433 uint16_t socket_id = 0;
13435 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13436 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13438 /* Identify the Worker Cores
13439 * Use 2 worker cores for the device args
13441 RTE_LCORE_FOREACH_WORKER(i) {
13442 if (worker_core_count > 1)
13444 snprintf(vdev_args, sizeof(vdev_args),
13445 "%s%d", temp_str, i);
13446 strcpy(temp_str, vdev_args);
13447 strlcat(temp_str, ";", sizeof(temp_str));
13448 worker_core_count++;
13449 socket_id = rte_lcore_to_socket_id(i);
13451 if (worker_core_count != 2) {
13452 RTE_LOG(ERR, USER1,
13453 "Cryptodev scheduler test require at least "
13454 "two worker cores to run. "
13455 "Please use the correct coremask.\n");
13456 return TEST_FAILED;
13458 strcpy(temp_str, vdev_args);
13459 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13460 temp_str, socket_id);
13461 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13462 nb_devs = rte_cryptodev_device_count_by_driver(
13463 rte_cryptodev_driver_id_get(
13464 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13466 ret = rte_vdev_init(
13467 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13469 TEST_ASSERT(ret == 0,
13470 "Failed to create instance %u of pmd : %s",
13471 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13474 return testsuite_setup();
13478 test_scheduler_attach_worker_op(void)
13480 struct crypto_testsuite_params *ts_params = &testsuite_params;
13481 uint8_t sched_id = ts_params->valid_devs[0];
13482 uint32_t nb_devs, i, nb_devs_attached = 0;
13484 char vdev_name[32];
13486 /* create 2 AESNI_MB if necessary */
13487 nb_devs = rte_cryptodev_device_count_by_driver(
13488 rte_cryptodev_driver_id_get(
13489 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13491 for (i = nb_devs; i < 2; i++) {
13492 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13493 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13495 ret = rte_vdev_init(vdev_name, NULL);
13497 TEST_ASSERT(ret == 0,
13498 "Failed to create instance %u of"
13500 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13504 /* attach 2 AESNI_MB cdevs */
13505 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13507 struct rte_cryptodev_info info;
13508 unsigned int session_size;
13510 rte_cryptodev_info_get(i, &info);
13511 if (info.driver_id != rte_cryptodev_driver_id_get(
13512 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13515 session_size = rte_cryptodev_sym_get_private_session_size(i);
13517 * Create the session mempool again, since now there are new devices
13518 * to use the mempool.
13520 if (ts_params->session_mpool) {
13521 rte_mempool_free(ts_params->session_mpool);
13522 ts_params->session_mpool = NULL;
13524 if (ts_params->session_priv_mpool) {
13525 rte_mempool_free(ts_params->session_priv_mpool);
13526 ts_params->session_priv_mpool = NULL;
13529 if (info.sym.max_nb_sessions != 0 &&
13530 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13531 RTE_LOG(ERR, USER1,
13532 "Device does not support "
13533 "at least %u sessions\n",
13535 return TEST_FAILED;
13538 * Create mempool with maximum number of sessions,
13539 * to include the session headers
13541 if (ts_params->session_mpool == NULL) {
13542 ts_params->session_mpool =
13543 rte_cryptodev_sym_session_pool_create(
13545 MAX_NB_SESSIONS, 0, 0, 0,
13547 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13548 "session mempool allocation failed");
13552 * Create mempool with maximum number of sessions,
13553 * to include device specific session private data
13555 if (ts_params->session_priv_mpool == NULL) {
13556 ts_params->session_priv_mpool = rte_mempool_create(
13557 "test_sess_mp_priv",
13560 0, 0, NULL, NULL, NULL,
13561 NULL, SOCKET_ID_ANY,
13564 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13565 "session mempool allocation failed");
13568 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13569 ts_params->qp_conf.mp_session_private =
13570 ts_params->session_priv_mpool;
13572 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13575 TEST_ASSERT(ret == 0,
13576 "Failed to attach device %u of pmd : %s", i,
13577 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13579 aesni_ids[nb_devs_attached] = (uint8_t)i;
13581 nb_devs_attached++;
13588 test_scheduler_detach_worker_op(void)
13590 struct crypto_testsuite_params *ts_params = &testsuite_params;
13591 uint8_t sched_id = ts_params->valid_devs[0];
13595 for (i = 0; i < 2; i++) {
13596 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13598 TEST_ASSERT(ret == 0,
13599 "Failed to detach device %u", aesni_ids[i]);
13606 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13608 struct crypto_testsuite_params *ts_params = &testsuite_params;
13609 uint8_t sched_id = ts_params->valid_devs[0];
13611 return rte_cryptodev_scheduler_mode_set(sched_id,
13616 test_scheduler_mode_roundrobin_op(void)
13618 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13619 0, "Failed to set roundrobin mode");
13625 test_scheduler_mode_multicore_op(void)
13627 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13628 0, "Failed to set multicore mode");
13634 test_scheduler_mode_failover_op(void)
13636 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13637 0, "Failed to set failover mode");
13643 test_scheduler_mode_pkt_size_distr_op(void)
13645 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13646 0, "Failed to set pktsize mode");
13652 scheduler_multicore_testsuite_setup(void)
13654 if (test_scheduler_attach_worker_op() < 0)
13655 return TEST_SKIPPED;
13656 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
13657 return TEST_SKIPPED;
13662 scheduler_roundrobin_testsuite_setup(void)
13664 if (test_scheduler_attach_worker_op() < 0)
13665 return TEST_SKIPPED;
13666 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
13667 return TEST_SKIPPED;
13672 scheduler_failover_testsuite_setup(void)
13674 if (test_scheduler_attach_worker_op() < 0)
13675 return TEST_SKIPPED;
13676 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
13677 return TEST_SKIPPED;
13682 scheduler_pkt_size_distr_testsuite_setup(void)
13684 if (test_scheduler_attach_worker_op() < 0)
13685 return TEST_SKIPPED;
13686 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
13687 return TEST_SKIPPED;
13692 scheduler_mode_testsuite_teardown(void)
13694 test_scheduler_detach_worker_op();
13697 #endif /* RTE_CRYPTO_SCHEDULER */
13699 static struct unit_test_suite end_testsuite = {
13700 .suite_name = NULL,
13703 .unit_test_suites = NULL
13706 #ifdef RTE_LIB_SECURITY
13707 static struct unit_test_suite pdcp_proto_testsuite = {
13708 .suite_name = "PDCP Proto Unit Test Suite",
13709 .setup = pdcp_proto_testsuite_setup,
13710 .unit_test_cases = {
13711 TEST_CASE_ST(ut_setup_security, ut_teardown,
13712 test_PDCP_PROTO_all),
13713 TEST_CASES_END() /**< NULL terminate unit test array */
13717 static struct unit_test_suite docsis_proto_testsuite = {
13718 .suite_name = "Docsis Proto Unit Test Suite",
13719 .setup = docsis_proto_testsuite_setup,
13720 .unit_test_cases = {
13721 TEST_CASE_ST(ut_setup_security, ut_teardown,
13722 test_DOCSIS_PROTO_all),
13723 TEST_CASES_END() /**< NULL terminate unit test array */
13728 static struct unit_test_suite cryptodev_gen_testsuite = {
13729 .suite_name = "Crypto General Unit Test Suite",
13730 .setup = crypto_gen_testsuite_setup,
13731 .unit_test_cases = {
13732 TEST_CASE_ST(ut_setup, ut_teardown,
13733 test_device_configure_invalid_dev_id),
13734 TEST_CASE_ST(ut_setup, ut_teardown,
13735 test_queue_pair_descriptor_setup),
13736 TEST_CASE_ST(ut_setup, ut_teardown,
13737 test_device_configure_invalid_queue_pair_ids),
13738 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13739 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13740 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13741 TEST_CASES_END() /**< NULL terminate unit test array */
13745 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
13746 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
13747 .setup = negative_hmac_sha1_testsuite_setup,
13748 .unit_test_cases = {
13749 /** Negative tests */
13750 TEST_CASE_ST(ut_setup, ut_teardown,
13751 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13752 TEST_CASE_ST(ut_setup, ut_teardown,
13753 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13754 TEST_CASE_ST(ut_setup, ut_teardown,
13755 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13756 TEST_CASE_ST(ut_setup, ut_teardown,
13757 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13759 TEST_CASES_END() /**< NULL terminate unit test array */
13763 static struct unit_test_suite cryptodev_multi_session_testsuite = {
13764 .suite_name = "Multi Session Unit Test Suite",
13765 .setup = multi_session_testsuite_setup,
13766 .unit_test_cases = {
13767 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13768 TEST_CASE_ST(ut_setup, ut_teardown,
13769 test_multi_session_random_usage),
13771 TEST_CASES_END() /**< NULL terminate unit test array */
13775 static struct unit_test_suite cryptodev_null_testsuite = {
13776 .suite_name = "NULL Test Suite",
13777 .setup = null_testsuite_setup,
13778 .unit_test_cases = {
13779 TEST_CASE_ST(ut_setup, ut_teardown,
13780 test_null_invalid_operation),
13781 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13786 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
13787 .suite_name = "AES CCM Authenticated Test Suite",
13788 .setup = aes_ccm_auth_testsuite_setup,
13789 .unit_test_cases = {
13790 /** AES CCM Authenticated Encryption 128 bits key*/
13791 TEST_CASE_ST(ut_setup, ut_teardown,
13792 test_AES_CCM_authenticated_encryption_test_case_128_1),
13793 TEST_CASE_ST(ut_setup, ut_teardown,
13794 test_AES_CCM_authenticated_encryption_test_case_128_2),
13795 TEST_CASE_ST(ut_setup, ut_teardown,
13796 test_AES_CCM_authenticated_encryption_test_case_128_3),
13798 /** AES CCM Authenticated Decryption 128 bits key*/
13799 TEST_CASE_ST(ut_setup, ut_teardown,
13800 test_AES_CCM_authenticated_decryption_test_case_128_1),
13801 TEST_CASE_ST(ut_setup, ut_teardown,
13802 test_AES_CCM_authenticated_decryption_test_case_128_2),
13803 TEST_CASE_ST(ut_setup, ut_teardown,
13804 test_AES_CCM_authenticated_decryption_test_case_128_3),
13806 /** AES CCM Authenticated Encryption 192 bits key */
13807 TEST_CASE_ST(ut_setup, ut_teardown,
13808 test_AES_CCM_authenticated_encryption_test_case_192_1),
13809 TEST_CASE_ST(ut_setup, ut_teardown,
13810 test_AES_CCM_authenticated_encryption_test_case_192_2),
13811 TEST_CASE_ST(ut_setup, ut_teardown,
13812 test_AES_CCM_authenticated_encryption_test_case_192_3),
13814 /** AES CCM Authenticated Decryption 192 bits key*/
13815 TEST_CASE_ST(ut_setup, ut_teardown,
13816 test_AES_CCM_authenticated_decryption_test_case_192_1),
13817 TEST_CASE_ST(ut_setup, ut_teardown,
13818 test_AES_CCM_authenticated_decryption_test_case_192_2),
13819 TEST_CASE_ST(ut_setup, ut_teardown,
13820 test_AES_CCM_authenticated_decryption_test_case_192_3),
13822 /** AES CCM Authenticated Encryption 256 bits key */
13823 TEST_CASE_ST(ut_setup, ut_teardown,
13824 test_AES_CCM_authenticated_encryption_test_case_256_1),
13825 TEST_CASE_ST(ut_setup, ut_teardown,
13826 test_AES_CCM_authenticated_encryption_test_case_256_2),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 test_AES_CCM_authenticated_encryption_test_case_256_3),
13830 /** AES CCM Authenticated Decryption 256 bits key*/
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 test_AES_CCM_authenticated_decryption_test_case_256_1),
13833 TEST_CASE_ST(ut_setup, ut_teardown,
13834 test_AES_CCM_authenticated_decryption_test_case_256_2),
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 test_AES_CCM_authenticated_decryption_test_case_256_3),
13841 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
13842 .suite_name = "AES GCM Authenticated Test Suite",
13843 .setup = aes_gcm_auth_testsuite_setup,
13844 .unit_test_cases = {
13845 /** AES GCM Authenticated Encryption */
13846 TEST_CASE_ST(ut_setup, ut_teardown,
13847 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13848 TEST_CASE_ST(ut_setup, ut_teardown,
13849 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13850 TEST_CASE_ST(ut_setup, ut_teardown,
13851 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13852 TEST_CASE_ST(ut_setup, ut_teardown,
13853 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13854 TEST_CASE_ST(ut_setup, ut_teardown,
13855 test_AES_GCM_authenticated_encryption_test_case_1),
13856 TEST_CASE_ST(ut_setup, ut_teardown,
13857 test_AES_GCM_authenticated_encryption_test_case_2),
13858 TEST_CASE_ST(ut_setup, ut_teardown,
13859 test_AES_GCM_authenticated_encryption_test_case_3),
13860 TEST_CASE_ST(ut_setup, ut_teardown,
13861 test_AES_GCM_authenticated_encryption_test_case_4),
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_AES_GCM_authenticated_encryption_test_case_5),
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_AES_GCM_authenticated_encryption_test_case_6),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_AES_GCM_authenticated_encryption_test_case_7),
13868 TEST_CASE_ST(ut_setup, ut_teardown,
13869 test_AES_GCM_authenticated_encryption_test_case_8),
13870 TEST_CASE_ST(ut_setup, ut_teardown,
13871 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13873 /** AES GCM Authenticated Decryption */
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_AES_GCM_authenticated_decryption_test_case_1),
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_AES_GCM_authenticated_decryption_test_case_2),
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_AES_GCM_authenticated_decryption_test_case_3),
13880 TEST_CASE_ST(ut_setup, ut_teardown,
13881 test_AES_GCM_authenticated_decryption_test_case_4),
13882 TEST_CASE_ST(ut_setup, ut_teardown,
13883 test_AES_GCM_authenticated_decryption_test_case_5),
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_AES_GCM_authenticated_decryption_test_case_6),
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_AES_GCM_authenticated_decryption_test_case_7),
13888 TEST_CASE_ST(ut_setup, ut_teardown,
13889 test_AES_GCM_authenticated_decryption_test_case_8),
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13893 /** AES GCM Authenticated Encryption 192 bits key */
13894 TEST_CASE_ST(ut_setup, ut_teardown,
13895 test_AES_GCM_auth_encryption_test_case_192_1),
13896 TEST_CASE_ST(ut_setup, ut_teardown,
13897 test_AES_GCM_auth_encryption_test_case_192_2),
13898 TEST_CASE_ST(ut_setup, ut_teardown,
13899 test_AES_GCM_auth_encryption_test_case_192_3),
13900 TEST_CASE_ST(ut_setup, ut_teardown,
13901 test_AES_GCM_auth_encryption_test_case_192_4),
13902 TEST_CASE_ST(ut_setup, ut_teardown,
13903 test_AES_GCM_auth_encryption_test_case_192_5),
13904 TEST_CASE_ST(ut_setup, ut_teardown,
13905 test_AES_GCM_auth_encryption_test_case_192_6),
13906 TEST_CASE_ST(ut_setup, ut_teardown,
13907 test_AES_GCM_auth_encryption_test_case_192_7),
13909 /** AES GCM Authenticated Decryption 192 bits key */
13910 TEST_CASE_ST(ut_setup, ut_teardown,
13911 test_AES_GCM_auth_decryption_test_case_192_1),
13912 TEST_CASE_ST(ut_setup, ut_teardown,
13913 test_AES_GCM_auth_decryption_test_case_192_2),
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_AES_GCM_auth_decryption_test_case_192_3),
13916 TEST_CASE_ST(ut_setup, ut_teardown,
13917 test_AES_GCM_auth_decryption_test_case_192_4),
13918 TEST_CASE_ST(ut_setup, ut_teardown,
13919 test_AES_GCM_auth_decryption_test_case_192_5),
13920 TEST_CASE_ST(ut_setup, ut_teardown,
13921 test_AES_GCM_auth_decryption_test_case_192_6),
13922 TEST_CASE_ST(ut_setup, ut_teardown,
13923 test_AES_GCM_auth_decryption_test_case_192_7),
13925 /** AES GCM Authenticated Encryption 256 bits key */
13926 TEST_CASE_ST(ut_setup, ut_teardown,
13927 test_AES_GCM_auth_encryption_test_case_256_1),
13928 TEST_CASE_ST(ut_setup, ut_teardown,
13929 test_AES_GCM_auth_encryption_test_case_256_2),
13930 TEST_CASE_ST(ut_setup, ut_teardown,
13931 test_AES_GCM_auth_encryption_test_case_256_3),
13932 TEST_CASE_ST(ut_setup, ut_teardown,
13933 test_AES_GCM_auth_encryption_test_case_256_4),
13934 TEST_CASE_ST(ut_setup, ut_teardown,
13935 test_AES_GCM_auth_encryption_test_case_256_5),
13936 TEST_CASE_ST(ut_setup, ut_teardown,
13937 test_AES_GCM_auth_encryption_test_case_256_6),
13938 TEST_CASE_ST(ut_setup, ut_teardown,
13939 test_AES_GCM_auth_encryption_test_case_256_7),
13941 /** AES GCM Authenticated Decryption 256 bits key */
13942 TEST_CASE_ST(ut_setup, ut_teardown,
13943 test_AES_GCM_auth_decryption_test_case_256_1),
13944 TEST_CASE_ST(ut_setup, ut_teardown,
13945 test_AES_GCM_auth_decryption_test_case_256_2),
13946 TEST_CASE_ST(ut_setup, ut_teardown,
13947 test_AES_GCM_auth_decryption_test_case_256_3),
13948 TEST_CASE_ST(ut_setup, ut_teardown,
13949 test_AES_GCM_auth_decryption_test_case_256_4),
13950 TEST_CASE_ST(ut_setup, ut_teardown,
13951 test_AES_GCM_auth_decryption_test_case_256_5),
13952 TEST_CASE_ST(ut_setup, ut_teardown,
13953 test_AES_GCM_auth_decryption_test_case_256_6),
13954 TEST_CASE_ST(ut_setup, ut_teardown,
13955 test_AES_GCM_auth_decryption_test_case_256_7),
13957 /** AES GCM Authenticated Encryption big aad size */
13958 TEST_CASE_ST(ut_setup, ut_teardown,
13959 test_AES_GCM_auth_encryption_test_case_aad_1),
13960 TEST_CASE_ST(ut_setup, ut_teardown,
13961 test_AES_GCM_auth_encryption_test_case_aad_2),
13963 /** AES GCM Authenticated Decryption big aad size */
13964 TEST_CASE_ST(ut_setup, ut_teardown,
13965 test_AES_GCM_auth_decryption_test_case_aad_1),
13966 TEST_CASE_ST(ut_setup, ut_teardown,
13967 test_AES_GCM_auth_decryption_test_case_aad_2),
13969 /** Out of place tests */
13970 TEST_CASE_ST(ut_setup, ut_teardown,
13971 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13972 TEST_CASE_ST(ut_setup, ut_teardown,
13973 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13975 /** Session-less tests */
13976 TEST_CASE_ST(ut_setup, ut_teardown,
13977 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13978 TEST_CASE_ST(ut_setup, ut_teardown,
13979 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13985 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
13986 .suite_name = "AES GMAC Authentication Test Suite",
13987 .setup = aes_gmac_auth_testsuite_setup,
13988 .unit_test_cases = {
13989 TEST_CASE_ST(ut_setup, ut_teardown,
13990 test_AES_GMAC_authentication_test_case_1),
13991 TEST_CASE_ST(ut_setup, ut_teardown,
13992 test_AES_GMAC_authentication_verify_test_case_1),
13993 TEST_CASE_ST(ut_setup, ut_teardown,
13994 test_AES_GMAC_authentication_test_case_2),
13995 TEST_CASE_ST(ut_setup, ut_teardown,
13996 test_AES_GMAC_authentication_verify_test_case_2),
13997 TEST_CASE_ST(ut_setup, ut_teardown,
13998 test_AES_GMAC_authentication_test_case_3),
13999 TEST_CASE_ST(ut_setup, ut_teardown,
14000 test_AES_GMAC_authentication_verify_test_case_3),
14001 TEST_CASE_ST(ut_setup, ut_teardown,
14002 test_AES_GMAC_authentication_test_case_4),
14003 TEST_CASE_ST(ut_setup, ut_teardown,
14004 test_AES_GMAC_authentication_verify_test_case_4),
14005 TEST_CASE_ST(ut_setup, ut_teardown,
14006 test_AES_GMAC_authentication_SGL_40B),
14007 TEST_CASE_ST(ut_setup, ut_teardown,
14008 test_AES_GMAC_authentication_SGL_80B),
14009 TEST_CASE_ST(ut_setup, ut_teardown,
14010 test_AES_GMAC_authentication_SGL_2048B),
14011 TEST_CASE_ST(ut_setup, ut_teardown,
14012 test_AES_GMAC_authentication_SGL_2047B),
14018 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14019 .suite_name = "Chacha20-Poly1305 Test Suite",
14020 .setup = chacha20_poly1305_testsuite_setup,
14021 .unit_test_cases = {
14022 TEST_CASE_ST(ut_setup, ut_teardown,
14023 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14024 TEST_CASE_ST(ut_setup, ut_teardown,
14025 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14030 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14031 .suite_name = "SNOW 3G Test Suite",
14032 .setup = snow3g_testsuite_setup,
14033 .unit_test_cases = {
14034 /** SNOW 3G encrypt only (UEA2) */
14035 TEST_CASE_ST(ut_setup, ut_teardown,
14036 test_snow3g_encryption_test_case_1),
14037 TEST_CASE_ST(ut_setup, ut_teardown,
14038 test_snow3g_encryption_test_case_2),
14039 TEST_CASE_ST(ut_setup, ut_teardown,
14040 test_snow3g_encryption_test_case_3),
14041 TEST_CASE_ST(ut_setup, ut_teardown,
14042 test_snow3g_encryption_test_case_4),
14043 TEST_CASE_ST(ut_setup, ut_teardown,
14044 test_snow3g_encryption_test_case_5),
14046 TEST_CASE_ST(ut_setup, ut_teardown,
14047 test_snow3g_encryption_test_case_1_oop),
14048 TEST_CASE_ST(ut_setup, ut_teardown,
14049 test_snow3g_encryption_test_case_1_oop_sgl),
14050 TEST_CASE_ST(ut_setup, ut_teardown,
14051 test_snow3g_encryption_test_case_1_offset_oop),
14052 TEST_CASE_ST(ut_setup, ut_teardown,
14053 test_snow3g_decryption_test_case_1_oop),
14055 /** SNOW 3G generate auth, then encrypt (UEA2) */
14056 TEST_CASE_ST(ut_setup, ut_teardown,
14057 test_snow3g_auth_cipher_test_case_1),
14058 TEST_CASE_ST(ut_setup, ut_teardown,
14059 test_snow3g_auth_cipher_test_case_2),
14060 TEST_CASE_ST(ut_setup, ut_teardown,
14061 test_snow3g_auth_cipher_test_case_2_oop),
14062 TEST_CASE_ST(ut_setup, ut_teardown,
14063 test_snow3g_auth_cipher_part_digest_enc),
14064 TEST_CASE_ST(ut_setup, ut_teardown,
14065 test_snow3g_auth_cipher_part_digest_enc_oop),
14066 TEST_CASE_ST(ut_setup, ut_teardown,
14067 test_snow3g_auth_cipher_test_case_3_sgl),
14068 TEST_CASE_ST(ut_setup, ut_teardown,
14069 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14070 TEST_CASE_ST(ut_setup, ut_teardown,
14071 test_snow3g_auth_cipher_part_digest_enc_sgl),
14072 TEST_CASE_ST(ut_setup, ut_teardown,
14073 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14075 /** SNOW 3G decrypt (UEA2), then verify auth */
14076 TEST_CASE_ST(ut_setup, ut_teardown,
14077 test_snow3g_auth_cipher_verify_test_case_1),
14078 TEST_CASE_ST(ut_setup, ut_teardown,
14079 test_snow3g_auth_cipher_verify_test_case_2),
14080 TEST_CASE_ST(ut_setup, ut_teardown,
14081 test_snow3g_auth_cipher_verify_test_case_2_oop),
14082 TEST_CASE_ST(ut_setup, ut_teardown,
14083 test_snow3g_auth_cipher_verify_part_digest_enc),
14084 TEST_CASE_ST(ut_setup, ut_teardown,
14085 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14086 TEST_CASE_ST(ut_setup, ut_teardown,
14087 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14088 TEST_CASE_ST(ut_setup, ut_teardown,
14089 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14090 TEST_CASE_ST(ut_setup, ut_teardown,
14091 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14092 TEST_CASE_ST(ut_setup, ut_teardown,
14093 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14095 /** SNOW 3G decrypt only (UEA2) */
14096 TEST_CASE_ST(ut_setup, ut_teardown,
14097 test_snow3g_decryption_test_case_1),
14098 TEST_CASE_ST(ut_setup, ut_teardown,
14099 test_snow3g_decryption_test_case_2),
14100 TEST_CASE_ST(ut_setup, ut_teardown,
14101 test_snow3g_decryption_test_case_3),
14102 TEST_CASE_ST(ut_setup, ut_teardown,
14103 test_snow3g_decryption_test_case_4),
14104 TEST_CASE_ST(ut_setup, ut_teardown,
14105 test_snow3g_decryption_test_case_5),
14106 TEST_CASE_ST(ut_setup, ut_teardown,
14107 test_snow3g_decryption_with_digest_test_case_1),
14108 TEST_CASE_ST(ut_setup, ut_teardown,
14109 test_snow3g_hash_generate_test_case_1),
14110 TEST_CASE_ST(ut_setup, ut_teardown,
14111 test_snow3g_hash_generate_test_case_2),
14112 TEST_CASE_ST(ut_setup, ut_teardown,
14113 test_snow3g_hash_generate_test_case_3),
14115 /* Tests with buffers which length is not byte-aligned */
14116 TEST_CASE_ST(ut_setup, ut_teardown,
14117 test_snow3g_hash_generate_test_case_4),
14118 TEST_CASE_ST(ut_setup, ut_teardown,
14119 test_snow3g_hash_generate_test_case_5),
14120 TEST_CASE_ST(ut_setup, ut_teardown,
14121 test_snow3g_hash_generate_test_case_6),
14122 TEST_CASE_ST(ut_setup, ut_teardown,
14123 test_snow3g_hash_verify_test_case_1),
14124 TEST_CASE_ST(ut_setup, ut_teardown,
14125 test_snow3g_hash_verify_test_case_2),
14126 TEST_CASE_ST(ut_setup, ut_teardown,
14127 test_snow3g_hash_verify_test_case_3),
14129 /* Tests with buffers which length is not byte-aligned */
14130 TEST_CASE_ST(ut_setup, ut_teardown,
14131 test_snow3g_hash_verify_test_case_4),
14132 TEST_CASE_ST(ut_setup, ut_teardown,
14133 test_snow3g_hash_verify_test_case_5),
14134 TEST_CASE_ST(ut_setup, ut_teardown,
14135 test_snow3g_hash_verify_test_case_6),
14136 TEST_CASE_ST(ut_setup, ut_teardown,
14137 test_snow3g_cipher_auth_test_case_1),
14138 TEST_CASE_ST(ut_setup, ut_teardown,
14139 test_snow3g_auth_cipher_with_digest_test_case_1),
14144 static struct unit_test_suite cryptodev_zuc_testsuite = {
14145 .suite_name = "ZUC Test Suite",
14146 .setup = zuc_testsuite_setup,
14147 .unit_test_cases = {
14148 /** ZUC encrypt only (EEA3) */
14149 TEST_CASE_ST(ut_setup, ut_teardown,
14150 test_zuc_encryption_test_case_1),
14151 TEST_CASE_ST(ut_setup, ut_teardown,
14152 test_zuc_encryption_test_case_2),
14153 TEST_CASE_ST(ut_setup, ut_teardown,
14154 test_zuc_encryption_test_case_3),
14155 TEST_CASE_ST(ut_setup, ut_teardown,
14156 test_zuc_encryption_test_case_4),
14157 TEST_CASE_ST(ut_setup, ut_teardown,
14158 test_zuc_encryption_test_case_5),
14159 TEST_CASE_ST(ut_setup, ut_teardown,
14160 test_zuc_encryption_test_case_6_sgl),
14162 /** ZUC authenticate (EIA3) */
14163 TEST_CASE_ST(ut_setup, ut_teardown,
14164 test_zuc_hash_generate_test_case_1),
14165 TEST_CASE_ST(ut_setup, ut_teardown,
14166 test_zuc_hash_generate_test_case_2),
14167 TEST_CASE_ST(ut_setup, ut_teardown,
14168 test_zuc_hash_generate_test_case_3),
14169 TEST_CASE_ST(ut_setup, ut_teardown,
14170 test_zuc_hash_generate_test_case_4),
14171 TEST_CASE_ST(ut_setup, ut_teardown,
14172 test_zuc_hash_generate_test_case_5),
14173 TEST_CASE_ST(ut_setup, ut_teardown,
14174 test_zuc_hash_generate_test_case_6),
14175 TEST_CASE_ST(ut_setup, ut_teardown,
14176 test_zuc_hash_generate_test_case_7),
14177 TEST_CASE_ST(ut_setup, ut_teardown,
14178 test_zuc_hash_generate_test_case_8),
14180 /** ZUC alg-chain (EEA3/EIA3) */
14181 TEST_CASE_ST(ut_setup, ut_teardown,
14182 test_zuc_cipher_auth_test_case_1),
14183 TEST_CASE_ST(ut_setup, ut_teardown,
14184 test_zuc_cipher_auth_test_case_2),
14186 /** ZUC generate auth, then encrypt (EEA3) */
14187 TEST_CASE_ST(ut_setup, ut_teardown,
14188 test_zuc_auth_cipher_test_case_1),
14189 TEST_CASE_ST(ut_setup, ut_teardown,
14190 test_zuc_auth_cipher_test_case_1_oop),
14191 TEST_CASE_ST(ut_setup, ut_teardown,
14192 test_zuc_auth_cipher_test_case_1_sgl),
14193 TEST_CASE_ST(ut_setup, ut_teardown,
14194 test_zuc_auth_cipher_test_case_1_oop_sgl),
14196 /** ZUC decrypt (EEA3), then verify auth */
14197 TEST_CASE_ST(ut_setup, ut_teardown,
14198 test_zuc_auth_cipher_verify_test_case_1),
14199 TEST_CASE_ST(ut_setup, ut_teardown,
14200 test_zuc_auth_cipher_verify_test_case_1_oop),
14201 TEST_CASE_ST(ut_setup, ut_teardown,
14202 test_zuc_auth_cipher_verify_test_case_1_sgl),
14203 TEST_CASE_ST(ut_setup, ut_teardown,
14204 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14209 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14210 .suite_name = "HMAC_MD5 Authentication Test Suite",
14211 .setup = hmac_md5_auth_testsuite_setup,
14212 .unit_test_cases = {
14213 TEST_CASE_ST(ut_setup, ut_teardown,
14214 test_MD5_HMAC_generate_case_1),
14215 TEST_CASE_ST(ut_setup, ut_teardown,
14216 test_MD5_HMAC_verify_case_1),
14217 TEST_CASE_ST(ut_setup, ut_teardown,
14218 test_MD5_HMAC_generate_case_2),
14219 TEST_CASE_ST(ut_setup, ut_teardown,
14220 test_MD5_HMAC_verify_case_2),
14225 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14226 .suite_name = "Kasumi Test Suite",
14227 .setup = kasumi_testsuite_setup,
14228 .unit_test_cases = {
14229 /** KASUMI hash only (UIA1) */
14230 TEST_CASE_ST(ut_setup, ut_teardown,
14231 test_kasumi_hash_generate_test_case_1),
14232 TEST_CASE_ST(ut_setup, ut_teardown,
14233 test_kasumi_hash_generate_test_case_2),
14234 TEST_CASE_ST(ut_setup, ut_teardown,
14235 test_kasumi_hash_generate_test_case_3),
14236 TEST_CASE_ST(ut_setup, ut_teardown,
14237 test_kasumi_hash_generate_test_case_4),
14238 TEST_CASE_ST(ut_setup, ut_teardown,
14239 test_kasumi_hash_generate_test_case_5),
14240 TEST_CASE_ST(ut_setup, ut_teardown,
14241 test_kasumi_hash_generate_test_case_6),
14243 TEST_CASE_ST(ut_setup, ut_teardown,
14244 test_kasumi_hash_verify_test_case_1),
14245 TEST_CASE_ST(ut_setup, ut_teardown,
14246 test_kasumi_hash_verify_test_case_2),
14247 TEST_CASE_ST(ut_setup, ut_teardown,
14248 test_kasumi_hash_verify_test_case_3),
14249 TEST_CASE_ST(ut_setup, ut_teardown,
14250 test_kasumi_hash_verify_test_case_4),
14251 TEST_CASE_ST(ut_setup, ut_teardown,
14252 test_kasumi_hash_verify_test_case_5),
14254 /** KASUMI encrypt only (UEA1) */
14255 TEST_CASE_ST(ut_setup, ut_teardown,
14256 test_kasumi_encryption_test_case_1),
14257 TEST_CASE_ST(ut_setup, ut_teardown,
14258 test_kasumi_encryption_test_case_1_sgl),
14259 TEST_CASE_ST(ut_setup, ut_teardown,
14260 test_kasumi_encryption_test_case_1_oop),
14261 TEST_CASE_ST(ut_setup, ut_teardown,
14262 test_kasumi_encryption_test_case_1_oop_sgl),
14263 TEST_CASE_ST(ut_setup, ut_teardown,
14264 test_kasumi_encryption_test_case_2),
14265 TEST_CASE_ST(ut_setup, ut_teardown,
14266 test_kasumi_encryption_test_case_3),
14267 TEST_CASE_ST(ut_setup, ut_teardown,
14268 test_kasumi_encryption_test_case_4),
14269 TEST_CASE_ST(ut_setup, ut_teardown,
14270 test_kasumi_encryption_test_case_5),
14272 /** KASUMI decrypt only (UEA1) */
14273 TEST_CASE_ST(ut_setup, ut_teardown,
14274 test_kasumi_decryption_test_case_1),
14275 TEST_CASE_ST(ut_setup, ut_teardown,
14276 test_kasumi_decryption_test_case_2),
14277 TEST_CASE_ST(ut_setup, ut_teardown,
14278 test_kasumi_decryption_test_case_3),
14279 TEST_CASE_ST(ut_setup, ut_teardown,
14280 test_kasumi_decryption_test_case_4),
14281 TEST_CASE_ST(ut_setup, ut_teardown,
14282 test_kasumi_decryption_test_case_5),
14283 TEST_CASE_ST(ut_setup, ut_teardown,
14284 test_kasumi_decryption_test_case_1_oop),
14286 TEST_CASE_ST(ut_setup, ut_teardown,
14287 test_kasumi_cipher_auth_test_case_1),
14289 /** KASUMI generate auth, then encrypt (F8) */
14290 TEST_CASE_ST(ut_setup, ut_teardown,
14291 test_kasumi_auth_cipher_test_case_1),
14292 TEST_CASE_ST(ut_setup, ut_teardown,
14293 test_kasumi_auth_cipher_test_case_2),
14294 TEST_CASE_ST(ut_setup, ut_teardown,
14295 test_kasumi_auth_cipher_test_case_2_oop),
14296 TEST_CASE_ST(ut_setup, ut_teardown,
14297 test_kasumi_auth_cipher_test_case_2_sgl),
14298 TEST_CASE_ST(ut_setup, ut_teardown,
14299 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14301 /** KASUMI decrypt (F8), then verify auth */
14302 TEST_CASE_ST(ut_setup, ut_teardown,
14303 test_kasumi_auth_cipher_verify_test_case_1),
14304 TEST_CASE_ST(ut_setup, ut_teardown,
14305 test_kasumi_auth_cipher_verify_test_case_2),
14306 TEST_CASE_ST(ut_setup, ut_teardown,
14307 test_kasumi_auth_cipher_verify_test_case_2_oop),
14308 TEST_CASE_ST(ut_setup, ut_teardown,
14309 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14310 TEST_CASE_ST(ut_setup, ut_teardown,
14311 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14317 static struct unit_test_suite cryptodev_esn_testsuite = {
14318 .suite_name = "ESN Test Suite",
14319 .setup = esn_testsuite_setup,
14320 .unit_test_cases = {
14321 TEST_CASE_ST(ut_setup, ut_teardown,
14322 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14323 TEST_CASE_ST(ut_setup, ut_teardown,
14324 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14329 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14330 .suite_name = "Negative AES GCM Test Suite",
14331 .setup = negative_aes_gcm_testsuite_setup,
14332 .unit_test_cases = {
14333 TEST_CASE_ST(ut_setup, ut_teardown,
14334 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14335 TEST_CASE_ST(ut_setup, ut_teardown,
14336 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14337 TEST_CASE_ST(ut_setup, ut_teardown,
14338 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14339 TEST_CASE_ST(ut_setup, ut_teardown,
14340 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14341 TEST_CASE_ST(ut_setup, ut_teardown,
14342 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14343 TEST_CASE_ST(ut_setup, ut_teardown,
14344 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14345 TEST_CASE_ST(ut_setup, ut_teardown,
14346 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14347 TEST_CASE_ST(ut_setup, ut_teardown,
14348 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14349 TEST_CASE_ST(ut_setup, ut_teardown,
14350 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14351 TEST_CASE_ST(ut_setup, ut_teardown,
14352 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14353 TEST_CASE_ST(ut_setup, ut_teardown,
14354 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14355 TEST_CASE_ST(ut_setup, ut_teardown,
14356 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14362 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14363 .suite_name = "Negative AES GMAC Test Suite",
14364 .setup = negative_aes_gmac_testsuite_setup,
14365 .unit_test_cases = {
14366 TEST_CASE_ST(ut_setup, ut_teardown,
14367 authentication_verify_AES128_GMAC_fail_data_corrupt),
14368 TEST_CASE_ST(ut_setup, ut_teardown,
14369 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14375 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14376 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14377 .setup = mixed_cipher_hash_testsuite_setup,
14378 .unit_test_cases = {
14379 /** AUTH AES CMAC + CIPHER AES CTR */
14380 TEST_CASE_ST(ut_setup, ut_teardown,
14381 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14382 TEST_CASE_ST(ut_setup, ut_teardown,
14383 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14384 TEST_CASE_ST(ut_setup, ut_teardown,
14385 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14386 TEST_CASE_ST(ut_setup, ut_teardown,
14387 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14388 TEST_CASE_ST(ut_setup, ut_teardown,
14389 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14390 TEST_CASE_ST(ut_setup, ut_teardown,
14391 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14392 TEST_CASE_ST(ut_setup, ut_teardown,
14393 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14394 TEST_CASE_ST(ut_setup, ut_teardown,
14395 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14397 /** AUTH ZUC + CIPHER SNOW3G */
14398 TEST_CASE_ST(ut_setup, ut_teardown,
14399 test_auth_zuc_cipher_snow_test_case_1),
14400 TEST_CASE_ST(ut_setup, ut_teardown,
14401 test_verify_auth_zuc_cipher_snow_test_case_1),
14402 /** AUTH AES CMAC + CIPHER SNOW3G */
14403 TEST_CASE_ST(ut_setup, ut_teardown,
14404 test_auth_aes_cmac_cipher_snow_test_case_1),
14405 TEST_CASE_ST(ut_setup, ut_teardown,
14406 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14407 /** AUTH ZUC + CIPHER AES CTR */
14408 TEST_CASE_ST(ut_setup, ut_teardown,
14409 test_auth_zuc_cipher_aes_ctr_test_case_1),
14410 TEST_CASE_ST(ut_setup, ut_teardown,
14411 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14412 /** AUTH SNOW3G + CIPHER AES CTR */
14413 TEST_CASE_ST(ut_setup, ut_teardown,
14414 test_auth_snow_cipher_aes_ctr_test_case_1),
14415 TEST_CASE_ST(ut_setup, ut_teardown,
14416 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14417 /** AUTH SNOW3G + CIPHER ZUC */
14418 TEST_CASE_ST(ut_setup, ut_teardown,
14419 test_auth_snow_cipher_zuc_test_case_1),
14420 TEST_CASE_ST(ut_setup, ut_teardown,
14421 test_verify_auth_snow_cipher_zuc_test_case_1),
14422 /** AUTH AES CMAC + CIPHER ZUC */
14423 TEST_CASE_ST(ut_setup, ut_teardown,
14424 test_auth_aes_cmac_cipher_zuc_test_case_1),
14425 TEST_CASE_ST(ut_setup, ut_teardown,
14426 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14428 /** AUTH NULL + CIPHER SNOW3G */
14429 TEST_CASE_ST(ut_setup, ut_teardown,
14430 test_auth_null_cipher_snow_test_case_1),
14431 TEST_CASE_ST(ut_setup, ut_teardown,
14432 test_verify_auth_null_cipher_snow_test_case_1),
14433 /** AUTH NULL + CIPHER ZUC */
14434 TEST_CASE_ST(ut_setup, ut_teardown,
14435 test_auth_null_cipher_zuc_test_case_1),
14436 TEST_CASE_ST(ut_setup, ut_teardown,
14437 test_verify_auth_null_cipher_zuc_test_case_1),
14438 /** AUTH SNOW3G + CIPHER NULL */
14439 TEST_CASE_ST(ut_setup, ut_teardown,
14440 test_auth_snow_cipher_null_test_case_1),
14441 TEST_CASE_ST(ut_setup, ut_teardown,
14442 test_verify_auth_snow_cipher_null_test_case_1),
14443 /** AUTH ZUC + CIPHER NULL */
14444 TEST_CASE_ST(ut_setup, ut_teardown,
14445 test_auth_zuc_cipher_null_test_case_1),
14446 TEST_CASE_ST(ut_setup, ut_teardown,
14447 test_verify_auth_zuc_cipher_null_test_case_1),
14448 /** AUTH NULL + CIPHER AES CTR */
14449 TEST_CASE_ST(ut_setup, ut_teardown,
14450 test_auth_null_cipher_aes_ctr_test_case_1),
14451 TEST_CASE_ST(ut_setup, ut_teardown,
14452 test_verify_auth_null_cipher_aes_ctr_test_case_1),
14453 /** AUTH AES CMAC + CIPHER NULL */
14454 TEST_CASE_ST(ut_setup, ut_teardown,
14455 test_auth_aes_cmac_cipher_null_test_case_1),
14456 TEST_CASE_ST(ut_setup, ut_teardown,
14457 test_verify_auth_aes_cmac_cipher_null_test_case_1),
14463 run_cryptodev_testsuite(const char *pmd_name)
14465 uint8_t ret, j, i = 0, blk_start_idx = 0;
14466 const enum blockcipher_test_type blk_suites[] = {
14467 BLKCIPHER_AES_CHAIN_TYPE,
14468 BLKCIPHER_AES_CIPHERONLY_TYPE,
14469 BLKCIPHER_AES_DOCSIS_TYPE,
14470 BLKCIPHER_3DES_CHAIN_TYPE,
14471 BLKCIPHER_3DES_CIPHERONLY_TYPE,
14472 BLKCIPHER_DES_CIPHERONLY_TYPE,
14473 BLKCIPHER_DES_DOCSIS_TYPE,
14474 BLKCIPHER_AUTHONLY_TYPE};
14475 struct unit_test_suite *static_suites[] = {
14476 &cryptodev_multi_session_testsuite,
14477 &cryptodev_null_testsuite,
14478 &cryptodev_aes_ccm_auth_testsuite,
14479 &cryptodev_aes_gcm_auth_testsuite,
14480 &cryptodev_aes_gmac_auth_testsuite,
14481 &cryptodev_snow3g_testsuite,
14482 &cryptodev_chacha20_poly1305_testsuite,
14483 &cryptodev_zuc_testsuite,
14484 &cryptodev_hmac_md5_auth_testsuite,
14485 &cryptodev_kasumi_testsuite,
14486 &cryptodev_esn_testsuite,
14487 &cryptodev_negative_aes_gcm_testsuite,
14488 &cryptodev_negative_aes_gmac_testsuite,
14489 &cryptodev_mixed_cipher_hash_testsuite,
14490 &cryptodev_negative_hmac_sha1_testsuite,
14491 &cryptodev_gen_testsuite,
14492 #ifdef RTE_LIB_SECURITY
14493 &pdcp_proto_testsuite,
14494 &docsis_proto_testsuite,
14498 static struct unit_test_suite ts = {
14499 .suite_name = "Cryptodev Unit Test Suite",
14500 .setup = testsuite_setup,
14501 .teardown = testsuite_teardown,
14502 .unit_test_cases = {TEST_CASES_END()}
14505 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
14507 if (gbl_driver_id == -1) {
14508 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
14509 return TEST_SKIPPED;
14512 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14513 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
14515 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
14516 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14517 ret = unit_test_suite_runner(&ts);
14519 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
14520 free(ts.unit_test_suites);
14525 test_cryptodev_qat(void)
14527 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14531 test_cryptodev_virtio(void)
14533 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14537 test_cryptodev_aesni_mb(void)
14539 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14543 test_cryptodev_cpu_aesni_mb(void)
14546 enum rte_security_session_action_type at = gbl_action_type;
14547 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14548 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14549 gbl_action_type = at;
14554 test_cryptodev_openssl(void)
14556 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14560 test_cryptodev_aesni_gcm(void)
14562 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14566 test_cryptodev_cpu_aesni_gcm(void)
14569 enum rte_security_session_action_type at = gbl_action_type;
14570 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14571 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14572 gbl_action_type = at;
14577 test_cryptodev_null(void)
14579 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14583 test_cryptodev_sw_snow3g(void)
14585 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14589 test_cryptodev_sw_kasumi(void)
14591 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14595 test_cryptodev_sw_zuc(void)
14597 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14601 test_cryptodev_armv8(void)
14603 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14607 test_cryptodev_mrvl(void)
14609 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14612 #ifdef RTE_CRYPTO_SCHEDULER
14615 test_cryptodev_scheduler(void)
14617 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
14618 const enum blockcipher_test_type blk_suites[] = {
14619 BLKCIPHER_AES_CHAIN_TYPE,
14620 BLKCIPHER_AES_CIPHERONLY_TYPE,
14621 BLKCIPHER_AUTHONLY_TYPE
14623 static struct unit_test_suite scheduler_multicore = {
14624 .suite_name = "Scheduler Multicore Unit Test Suite",
14625 .setup = scheduler_multicore_testsuite_setup,
14626 .teardown = scheduler_mode_testsuite_teardown,
14627 .unit_test_cases = {TEST_CASES_END()}
14629 static struct unit_test_suite scheduler_round_robin = {
14630 .suite_name = "Scheduler Round Robin Unit Test Suite",
14631 .setup = scheduler_roundrobin_testsuite_setup,
14632 .teardown = scheduler_mode_testsuite_teardown,
14633 .unit_test_cases = {TEST_CASES_END()}
14635 static struct unit_test_suite scheduler_failover = {
14636 .suite_name = "Scheduler Failover Unit Test Suite",
14637 .setup = scheduler_failover_testsuite_setup,
14638 .teardown = scheduler_mode_testsuite_teardown,
14639 .unit_test_cases = {TEST_CASES_END()}
14641 static struct unit_test_suite scheduler_pkt_size_distr = {
14642 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
14643 .setup = scheduler_pkt_size_distr_testsuite_setup,
14644 .teardown = scheduler_mode_testsuite_teardown,
14645 .unit_test_cases = {TEST_CASES_END()}
14647 struct unit_test_suite *sched_mode_suites[] = {
14648 &scheduler_multicore,
14649 &scheduler_round_robin,
14650 &scheduler_failover,
14651 &scheduler_pkt_size_distr
14653 static struct unit_test_suite scheduler_config = {
14654 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
14655 .unit_test_cases = {
14656 TEST_CASE(test_scheduler_attach_worker_op),
14657 TEST_CASE(test_scheduler_mode_multicore_op),
14658 TEST_CASE(test_scheduler_mode_roundrobin_op),
14659 TEST_CASE(test_scheduler_mode_failover_op),
14660 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
14661 TEST_CASE(test_scheduler_detach_worker_op),
14663 TEST_CASES_END() /**< NULL terminate array */
14666 struct unit_test_suite *static_suites[] = {
14670 static struct unit_test_suite ts = {
14671 .suite_name = "Scheduler Unit Test Suite",
14672 .setup = scheduler_testsuite_setup,
14673 .teardown = testsuite_teardown,
14674 .unit_test_cases = {TEST_CASES_END()}
14677 gbl_driver_id = rte_cryptodev_driver_id_get(
14678 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14680 if (gbl_driver_id == -1) {
14681 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14682 return TEST_SKIPPED;
14685 if (rte_cryptodev_driver_id_get(
14686 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14687 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14688 return TEST_SKIPPED;
14691 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14693 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
14694 (struct unit_test_suite *) *
14695 (RTE_DIM(blk_suites) + 1));
14696 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
14697 blk_suites, RTE_DIM(blk_suites));
14698 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
14701 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14702 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
14703 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
14704 RTE_DIM(sched_mode_suites));
14705 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14706 ret = unit_test_suite_runner(&ts);
14708 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14709 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
14710 (*sched_mode_suites[sched_i]),
14711 RTE_DIM(blk_suites));
14712 free(sched_mode_suites[sched_i]->unit_test_suites);
14714 free(ts.unit_test_suites);
14718 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14723 test_cryptodev_dpaa2_sec(void)
14725 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14729 test_cryptodev_dpaa_sec(void)
14731 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14735 test_cryptodev_ccp(void)
14737 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14741 test_cryptodev_octeontx(void)
14743 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14747 test_cryptodev_octeontx2(void)
14749 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14753 test_cryptodev_caam_jr(void)
14755 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14759 test_cryptodev_nitrox(void)
14761 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14765 test_cryptodev_bcmfs(void)
14767 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14771 test_cryptodev_qat_raw_api(void)
14775 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14776 ret = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14777 global_api_test_type = CRYPTODEV_API_TEST;
14783 test_cryptodev_cn9k(void)
14785 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
14789 test_cryptodev_cn10k(void)
14791 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
14794 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14795 test_cryptodev_qat_raw_api);
14796 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14797 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14798 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14799 test_cryptodev_cpu_aesni_mb);
14800 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14801 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14802 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14803 test_cryptodev_cpu_aesni_gcm);
14804 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14805 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14806 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14807 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14808 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14809 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14810 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14811 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14812 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14813 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14814 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14815 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14816 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14817 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14818 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
14819 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
14820 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);