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_string_fns.h>
21 #ifdef RTE_CRYPTO_SCHEDULER
22 #include <rte_cryptodev_scheduler.h>
23 #include <rte_cryptodev_scheduler_operations.h>
26 #include <rte_lcore.h>
29 #include "test_cryptodev.h"
31 #include "test_cryptodev_blockcipher.h"
32 #include "test_cryptodev_aes_test_vectors.h"
33 #include "test_cryptodev_des_test_vectors.h"
34 #include "test_cryptodev_hash_test_vectors.h"
35 #include "test_cryptodev_kasumi_test_vectors.h"
36 #include "test_cryptodev_kasumi_hash_test_vectors.h"
37 #include "test_cryptodev_snow3g_test_vectors.h"
38 #include "test_cryptodev_snow3g_hash_test_vectors.h"
39 #include "test_cryptodev_zuc_test_vectors.h"
40 #include "test_cryptodev_aead_test_vectors.h"
41 #include "test_cryptodev_hmac_test_vectors.h"
42 #include "test_cryptodev_mixed_test_vectors.h"
43 #ifdef RTE_LIB_SECURITY
44 #include "test_cryptodev_security_pdcp_test_vectors.h"
45 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
46 #include "test_cryptodev_security_pdcp_test_func.h"
47 #include "test_cryptodev_security_docsis_test_vectors.h"
49 #define SDAP_DISABLED 0
50 #define SDAP_ENABLED 1
53 #define VDEV_ARGS_SIZE 100
54 #define MAX_NB_SESSIONS 4
56 #define MAX_DRV_SERVICE_CTX_SIZE 256
58 #define MAX_RAW_DEQUEUE_COUNT 65535
61 #define OUT_OF_PLACE 1
63 static int gbl_driver_id;
65 static enum rte_security_session_action_type gbl_action_type =
66 RTE_SECURITY_ACTION_TYPE_NONE;
68 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
70 struct crypto_unittest_params {
71 struct rte_crypto_sym_xform cipher_xform;
72 struct rte_crypto_sym_xform auth_xform;
73 struct rte_crypto_sym_xform aead_xform;
74 #ifdef RTE_LIB_SECURITY
75 struct rte_security_docsis_xform docsis_xform;
79 struct rte_cryptodev_sym_session *sess;
80 #ifdef RTE_LIB_SECURITY
81 struct rte_security_session *sec_session;
84 #ifdef RTE_LIB_SECURITY
85 enum rte_security_session_action_type type;
87 struct rte_crypto_op *op;
89 struct rte_mbuf *obuf, *ibuf;
94 #define ALIGN_POW2_ROUNDUP(num, align) \
95 (((num) + (align) - 1) & ~((align) - 1))
97 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
98 for (j = 0; j < num_child_ts; index++, j++) \
99 parent_ts.unit_test_suites[index] = child_ts[j]
101 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
102 for (j = 0; j < num_blk_types; index++, j++) \
103 parent_ts.unit_test_suites[index] = \
104 build_blockcipher_test_suite(blk_types[j])
106 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
107 for (j = index; j < index + num_blk_types; j++) \
108 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
111 * Forward declarations.
114 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
115 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
119 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
120 struct crypto_unittest_params *ut_params,
121 struct crypto_testsuite_params *ts_param,
122 const uint8_t *cipher,
123 const uint8_t *digest,
126 static struct rte_mbuf *
127 setup_test_string(struct rte_mempool *mpool,
128 const char *string, size_t len, uint8_t blocksize)
130 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
131 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
136 memset(m->buf_addr, 0, m->buf_len);
137 dst = rte_pktmbuf_append(m, t_len);
143 rte_memcpy(dst, string, t_len);
145 memset(dst, 0, t_len);
151 /* Get number of bytes in X bits (rounding up) */
153 ceil_byte_length(uint32_t num_bits)
156 return ((num_bits >> 3) + 1);
158 return (num_bits >> 3);
162 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
163 uint8_t is_op_success)
165 struct rte_crypto_op *op = user_data;
166 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
167 RTE_CRYPTO_OP_STATUS_ERROR;
171 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
172 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
173 uint8_t len_in_bits, uint8_t cipher_iv_len)
175 struct rte_crypto_sym_op *sop = op->sym;
176 struct rte_crypto_op *ret_op = NULL;
177 struct rte_crypto_vec data_vec[UINT8_MAX];
178 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
179 union rte_crypto_sym_ofs ofs;
180 struct rte_crypto_sym_vec vec;
181 struct rte_crypto_sgl sgl;
183 union rte_cryptodev_session_ctx sess;
185 struct rte_crypto_raw_dp_ctx *ctx;
186 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
190 int ctx_service_size;
192 int enqueue_status, dequeue_status;
194 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
195 if (ctx_service_size < 0) {
196 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
200 ctx = malloc(ctx_service_size);
202 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
206 /* Both are enums, setting crypto_sess will suit any session type */
207 sess.crypto_sess = op->sym->session;
209 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
210 op->sess_type, sess, 0) < 0) {
211 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
217 aad_auth_iv.iova = 0;
218 aad_auth_iv.va = NULL;
225 vec.digest = &digest;
226 vec.aad = &aad_auth_iv;
227 vec.status = &status;
231 if (is_cipher && is_auth) {
232 cipher_offset = sop->cipher.data.offset;
233 cipher_len = sop->cipher.data.length;
234 auth_offset = sop->auth.data.offset;
235 auth_len = sop->auth.data.length;
236 max_len = RTE_MAX(cipher_offset + cipher_len,
237 auth_offset + auth_len);
239 max_len = max_len >> 3;
240 cipher_offset = cipher_offset >> 3;
241 auth_offset = auth_offset >> 3;
242 cipher_len = cipher_len >> 3;
243 auth_len = auth_len >> 3;
245 ofs.ofs.cipher.head = cipher_offset;
246 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
247 ofs.ofs.auth.head = auth_offset;
248 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
249 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
250 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
251 aad_auth_iv.va = rte_crypto_op_ctod_offset(
252 op, void *, IV_OFFSET + cipher_iv_len);
253 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
255 digest.va = (void *)sop->auth.digest.data;
256 digest.iova = sop->auth.digest.phys_addr;
258 } else if (is_cipher) {
259 cipher_offset = sop->cipher.data.offset;
260 cipher_len = sop->cipher.data.length;
261 max_len = cipher_len + cipher_offset;
263 max_len = max_len >> 3;
264 cipher_offset = cipher_offset >> 3;
265 cipher_len = cipher_len >> 3;
267 ofs.ofs.cipher.head = cipher_offset;
268 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
269 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
270 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
272 } else if (is_auth) {
273 auth_offset = sop->auth.data.offset;
274 auth_len = sop->auth.data.length;
275 max_len = auth_len + auth_offset;
277 max_len = max_len >> 3;
278 auth_offset = auth_offset >> 3;
279 auth_len = auth_len >> 3;
281 ofs.ofs.auth.head = auth_offset;
282 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
283 aad_auth_iv.va = rte_crypto_op_ctod_offset(
284 op, void *, IV_OFFSET + cipher_iv_len);
285 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
287 digest.va = (void *)sop->auth.digest.data;
288 digest.iova = sop->auth.digest.phys_addr;
291 cipher_offset = sop->aead.data.offset;
292 cipher_len = sop->aead.data.length;
293 max_len = cipher_len + cipher_offset;
295 max_len = max_len >> 3;
296 cipher_offset = cipher_offset >> 3;
297 cipher_len = cipher_len >> 3;
299 ofs.ofs.cipher.head = cipher_offset;
300 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
301 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
302 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
303 aad_auth_iv.va = (void *)sop->aead.aad.data;
304 aad_auth_iv.iova = sop->aead.aad.phys_addr;
305 digest.va = (void *)sop->aead.digest.data;
306 digest.iova = sop->aead.digest.phys_addr;
309 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
310 data_vec, RTE_DIM(data_vec));
311 if (n < 0 || n > sop->m_src->nb_segs) {
312 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
318 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
319 &enqueue_status) < 1) {
320 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
324 if (enqueue_status == 0) {
325 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
327 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
330 } else if (enqueue_status < 0) {
331 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
336 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
337 n = rte_cryptodev_raw_dequeue_burst(ctx,
338 NULL, 1, post_process_raw_dp_op,
339 (void **)&ret_op, 0, &n_success,
341 if (dequeue_status < 0) {
342 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
349 if (n == 1 && dequeue_status == 0) {
350 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
351 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
356 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
357 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
358 RTE_CRYPTO_OP_STATUS_SUCCESS;
365 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
368 struct rte_crypto_sym_op *sop;
369 union rte_crypto_sym_ofs ofs;
370 struct rte_crypto_sgl sgl;
371 struct rte_crypto_sym_vec symvec;
372 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
373 struct rte_crypto_vec vec[UINT8_MAX];
377 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
378 sop->aead.data.length, vec, RTE_DIM(vec));
380 if (n < 0 || n != sop->m_src->nb_segs) {
381 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
389 symvec.digest = &digest_ptr;
390 symvec.aad = &aad_ptr;
394 /* for CPU crypto the IOVA address is not required */
395 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
396 digest_ptr.va = (void *)sop->aead.digest.data;
397 aad_ptr.va = (void *)sop->aead.aad.data;
401 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
405 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
407 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
411 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
414 struct rte_crypto_sym_op *sop;
415 union rte_crypto_sym_ofs ofs;
416 struct rte_crypto_sgl sgl;
417 struct rte_crypto_sym_vec symvec;
418 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
419 struct rte_crypto_vec vec[UINT8_MAX];
423 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
424 sop->auth.data.length, vec, RTE_DIM(vec));
426 if (n < 0 || n != sop->m_src->nb_segs) {
427 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
435 symvec.digest = &digest_ptr;
439 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
440 digest_ptr.va = (void *)sop->auth.digest.data;
443 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
444 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
445 (sop->cipher.data.offset + sop->cipher.data.length);
447 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
451 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
453 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
456 static struct rte_crypto_op *
457 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
460 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
462 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
463 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
469 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
472 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
473 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
480 static struct crypto_testsuite_params testsuite_params = { NULL };
481 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
482 static struct crypto_unittest_params unittest_params;
485 testsuite_setup(void)
487 struct crypto_testsuite_params *ts_params = &testsuite_params;
488 struct rte_cryptodev_info info;
489 uint32_t i = 0, nb_devs, dev_id;
492 memset(ts_params, 0, sizeof(*ts_params));
494 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
495 if (ts_params->mbuf_pool == NULL) {
496 /* Not already created so create */
497 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
499 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
501 if (ts_params->mbuf_pool == NULL) {
502 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
507 ts_params->large_mbuf_pool = rte_mempool_lookup(
508 "CRYPTO_LARGE_MBUFPOOL");
509 if (ts_params->large_mbuf_pool == NULL) {
510 /* Not already created so create */
511 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
512 "CRYPTO_LARGE_MBUFPOOL",
515 if (ts_params->large_mbuf_pool == NULL) {
517 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
522 ts_params->op_mpool = rte_crypto_op_pool_create(
523 "MBUF_CRYPTO_SYM_OP_POOL",
524 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
525 NUM_MBUFS, MBUF_CACHE_SIZE,
527 sizeof(struct rte_crypto_sym_xform) +
530 if (ts_params->op_mpool == NULL) {
531 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
535 nb_devs = rte_cryptodev_count();
537 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
541 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
542 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
543 rte_cryptodev_driver_name_get(gbl_driver_id));
547 /* Create list of valid crypto devs */
548 for (i = 0; i < nb_devs; i++) {
549 rte_cryptodev_info_get(i, &info);
550 if (info.driver_id == gbl_driver_id)
551 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
554 if (ts_params->valid_dev_count < 1)
557 /* Set up all the qps on the first of the valid devices found */
559 dev_id = ts_params->valid_devs[0];
561 rte_cryptodev_info_get(dev_id, &info);
563 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
564 ts_params->conf.socket_id = SOCKET_ID_ANY;
565 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
567 unsigned int session_size =
568 rte_cryptodev_sym_get_private_session_size(dev_id);
570 #ifdef RTE_LIB_SECURITY
571 unsigned int security_session_size = rte_security_session_get_size(
572 rte_cryptodev_get_sec_ctx(dev_id));
574 if (session_size < security_session_size)
575 session_size = security_session_size;
578 * Create mempool with maximum number of sessions.
580 if (info.sym.max_nb_sessions != 0 &&
581 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
582 RTE_LOG(ERR, USER1, "Device does not support "
583 "at least %u sessions\n",
588 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
589 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
591 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
592 "session mempool allocation failed");
594 ts_params->session_priv_mpool = rte_mempool_create(
598 0, 0, NULL, NULL, NULL,
601 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
602 "session mempool allocation failed");
606 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
608 "Failed to configure cryptodev %u with %u qps",
609 dev_id, ts_params->conf.nb_queue_pairs);
611 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
612 ts_params->qp_conf.mp_session = ts_params->session_mpool;
613 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
615 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
616 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
617 dev_id, qp_id, &ts_params->qp_conf,
618 rte_cryptodev_socket_id(dev_id)),
619 "Failed to setup queue pair %u on cryptodev %u",
627 testsuite_teardown(void)
629 struct crypto_testsuite_params *ts_params = &testsuite_params;
632 if (ts_params->mbuf_pool != NULL) {
633 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
634 rte_mempool_avail_count(ts_params->mbuf_pool));
637 if (ts_params->op_mpool != NULL) {
638 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
639 rte_mempool_avail_count(ts_params->op_mpool));
642 /* Free session mempools */
643 if (ts_params->session_priv_mpool != NULL) {
644 rte_mempool_free(ts_params->session_priv_mpool);
645 ts_params->session_priv_mpool = NULL;
648 if (ts_params->session_mpool != NULL) {
649 rte_mempool_free(ts_params->session_mpool);
650 ts_params->session_mpool = NULL;
653 res = rte_cryptodev_close(ts_params->valid_devs[0]);
655 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
659 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
660 const int *algs, uint16_t num_algs)
662 uint8_t dev_id = testsuite_params.valid_devs[0];
663 bool some_alg_supported = FALSE;
666 for (i = 0; i < num_algs && !some_alg_supported; i++) {
667 struct rte_cryptodev_sym_capability_idx alg = {
670 if (rte_cryptodev_sym_capability_get(dev_id,
672 some_alg_supported = TRUE;
674 if (!some_alg_supported)
681 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
682 uint16_t num_ciphers)
684 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
685 (const int *) ciphers, num_ciphers);
689 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
692 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
693 (const int *) auths, num_auths);
697 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
700 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
701 (const int *) aeads, num_aeads);
705 null_testsuite_setup(void)
707 struct crypto_testsuite_params *ts_params = &testsuite_params;
708 uint8_t dev_id = ts_params->valid_devs[0];
709 struct rte_cryptodev_info dev_info;
710 const enum rte_crypto_cipher_algorithm ciphers[] = {
711 RTE_CRYPTO_CIPHER_NULL
713 const enum rte_crypto_auth_algorithm auths[] = {
717 rte_cryptodev_info_get(dev_id, &dev_info);
719 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
720 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
721 "testsuite not met\n");
725 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
726 && check_auth_capabilities_supported(auths,
727 RTE_DIM(auths)) != 0) {
728 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
729 "testsuite not met\n");
737 crypto_gen_testsuite_setup(void)
739 struct crypto_testsuite_params *ts_params = &testsuite_params;
740 uint8_t dev_id = ts_params->valid_devs[0];
741 struct rte_cryptodev_info dev_info;
743 rte_cryptodev_info_get(dev_id, &dev_info);
745 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
746 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
747 "testsuite not met\n");
754 #ifdef RTE_LIB_SECURITY
756 pdcp_proto_testsuite_setup(void)
758 struct crypto_testsuite_params *ts_params = &testsuite_params;
759 uint8_t dev_id = ts_params->valid_devs[0];
760 struct rte_cryptodev_info dev_info;
761 const enum rte_crypto_cipher_algorithm ciphers[] = {
762 RTE_CRYPTO_CIPHER_NULL,
763 RTE_CRYPTO_CIPHER_AES_CTR,
764 RTE_CRYPTO_CIPHER_ZUC_EEA3,
765 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
767 const enum rte_crypto_auth_algorithm auths[] = {
768 RTE_CRYPTO_AUTH_NULL,
769 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
770 RTE_CRYPTO_AUTH_AES_CMAC,
771 RTE_CRYPTO_AUTH_ZUC_EIA3
774 rte_cryptodev_info_get(dev_id, &dev_info);
776 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
777 !(dev_info.feature_flags &
778 RTE_CRYPTODEV_FF_SECURITY)) {
779 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
780 "testsuite not met\n");
784 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
785 && check_auth_capabilities_supported(auths,
786 RTE_DIM(auths)) != 0) {
787 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
788 "testsuite not met\n");
796 docsis_proto_testsuite_setup(void)
798 struct crypto_testsuite_params *ts_params = &testsuite_params;
799 uint8_t dev_id = ts_params->valid_devs[0];
800 struct rte_cryptodev_info dev_info;
801 const enum rte_crypto_cipher_algorithm ciphers[] = {
802 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
805 rte_cryptodev_info_get(dev_id, &dev_info);
807 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
808 !(dev_info.feature_flags &
809 RTE_CRYPTODEV_FF_SECURITY)) {
810 RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
811 "Proto testsuite not met\n");
815 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
816 RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
817 "testsuite not met\n");
826 aes_ccm_auth_testsuite_setup(void)
828 struct crypto_testsuite_params *ts_params = &testsuite_params;
829 uint8_t dev_id = ts_params->valid_devs[0];
830 struct rte_cryptodev_info dev_info;
831 const enum rte_crypto_aead_algorithm aeads[] = {
832 RTE_CRYPTO_AEAD_AES_CCM
835 rte_cryptodev_info_get(dev_id, &dev_info);
837 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
838 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
839 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
840 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
841 "testsuite not met\n");
845 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
846 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
847 "testsuite not met\n");
855 aes_gcm_auth_testsuite_setup(void)
857 struct crypto_testsuite_params *ts_params = &testsuite_params;
858 uint8_t dev_id = ts_params->valid_devs[0];
859 struct rte_cryptodev_info dev_info;
860 const enum rte_crypto_aead_algorithm aeads[] = {
861 RTE_CRYPTO_AEAD_AES_GCM
864 rte_cryptodev_info_get(dev_id, &dev_info);
866 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
867 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
868 "testsuite not met\n");
872 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
873 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
874 "testsuite not met\n");
882 aes_gmac_auth_testsuite_setup(void)
884 struct crypto_testsuite_params *ts_params = &testsuite_params;
885 uint8_t dev_id = ts_params->valid_devs[0];
886 struct rte_cryptodev_info dev_info;
887 const enum rte_crypto_auth_algorithm auths[] = {
888 RTE_CRYPTO_AUTH_AES_GMAC
891 rte_cryptodev_info_get(dev_id, &dev_info);
893 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
894 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
895 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
896 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
897 "testsuite not met\n");
901 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
902 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
903 "testsuite not met\n");
911 chacha20_poly1305_testsuite_setup(void)
913 struct crypto_testsuite_params *ts_params = &testsuite_params;
914 uint8_t dev_id = ts_params->valid_devs[0];
915 struct rte_cryptodev_info dev_info;
916 const enum rte_crypto_aead_algorithm aeads[] = {
917 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
920 rte_cryptodev_info_get(dev_id, &dev_info);
922 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
923 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
924 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
925 RTE_LOG(INFO, USER1, "Feature flag requirements for "
926 "Chacha20-Poly1305 testsuite not met\n");
930 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
931 RTE_LOG(INFO, USER1, "Capability requirements for "
932 "Chacha20-Poly1305 testsuite not met\n");
940 snow3g_testsuite_setup(void)
942 struct crypto_testsuite_params *ts_params = &testsuite_params;
943 uint8_t dev_id = ts_params->valid_devs[0];
944 struct rte_cryptodev_info dev_info;
945 const enum rte_crypto_cipher_algorithm ciphers[] = {
946 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
949 const enum rte_crypto_auth_algorithm auths[] = {
950 RTE_CRYPTO_AUTH_SNOW3G_UIA2
953 rte_cryptodev_info_get(dev_id, &dev_info);
955 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
956 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
957 "testsuite not met\n");
961 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
962 && check_auth_capabilities_supported(auths,
963 RTE_DIM(auths)) != 0) {
964 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
965 "testsuite not met\n");
973 zuc_testsuite_setup(void)
975 struct crypto_testsuite_params *ts_params = &testsuite_params;
976 uint8_t dev_id = ts_params->valid_devs[0];
977 struct rte_cryptodev_info dev_info;
978 const enum rte_crypto_cipher_algorithm ciphers[] = {
979 RTE_CRYPTO_CIPHER_ZUC_EEA3
981 const enum rte_crypto_auth_algorithm auths[] = {
982 RTE_CRYPTO_AUTH_ZUC_EIA3
985 rte_cryptodev_info_get(dev_id, &dev_info);
987 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
988 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
989 "testsuite not met\n");
993 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
994 && check_auth_capabilities_supported(auths,
995 RTE_DIM(auths)) != 0) {
996 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
997 "testsuite not met\n");
1005 hmac_md5_auth_testsuite_setup(void)
1007 struct crypto_testsuite_params *ts_params = &testsuite_params;
1008 uint8_t dev_id = ts_params->valid_devs[0];
1009 struct rte_cryptodev_info dev_info;
1010 const enum rte_crypto_auth_algorithm auths[] = {
1011 RTE_CRYPTO_AUTH_MD5_HMAC
1014 rte_cryptodev_info_get(dev_id, &dev_info);
1016 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1017 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1018 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1019 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1020 "Auth testsuite not met\n");
1021 return TEST_SKIPPED;
1024 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1025 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1026 "testsuite not met\n");
1027 return TEST_SKIPPED;
1034 kasumi_testsuite_setup(void)
1036 struct crypto_testsuite_params *ts_params = &testsuite_params;
1037 uint8_t dev_id = ts_params->valid_devs[0];
1038 struct rte_cryptodev_info dev_info;
1039 const enum rte_crypto_cipher_algorithm ciphers[] = {
1040 RTE_CRYPTO_CIPHER_KASUMI_F8
1042 const enum rte_crypto_auth_algorithm auths[] = {
1043 RTE_CRYPTO_AUTH_KASUMI_F9
1046 rte_cryptodev_info_get(dev_id, &dev_info);
1048 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1049 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1050 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1051 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1052 "testsuite not met\n");
1053 return TEST_SKIPPED;
1056 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1057 && check_auth_capabilities_supported(auths,
1058 RTE_DIM(auths)) != 0) {
1059 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1060 "testsuite not met\n");
1061 return TEST_SKIPPED;
1068 negative_aes_gcm_testsuite_setup(void)
1070 struct crypto_testsuite_params *ts_params = &testsuite_params;
1071 uint8_t dev_id = ts_params->valid_devs[0];
1072 struct rte_cryptodev_info dev_info;
1073 const enum rte_crypto_aead_algorithm aeads[] = {
1074 RTE_CRYPTO_AEAD_AES_GCM
1077 rte_cryptodev_info_get(dev_id, &dev_info);
1079 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1080 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1081 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1082 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1083 "AES GCM testsuite not met\n");
1084 return TEST_SKIPPED;
1087 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1088 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1089 "AES GCM testsuite not met\n");
1090 return TEST_SKIPPED;
1097 negative_aes_gmac_testsuite_setup(void)
1099 struct crypto_testsuite_params *ts_params = &testsuite_params;
1100 uint8_t dev_id = ts_params->valid_devs[0];
1101 struct rte_cryptodev_info dev_info;
1102 const enum rte_crypto_auth_algorithm auths[] = {
1103 RTE_CRYPTO_AUTH_AES_GMAC
1106 rte_cryptodev_info_get(dev_id, &dev_info);
1108 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1109 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1110 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1111 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1112 "AES GMAC testsuite not met\n");
1113 return TEST_SKIPPED;
1116 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1117 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1118 "AES GMAC testsuite not met\n");
1119 return TEST_SKIPPED;
1126 mixed_cipher_hash_testsuite_setup(void)
1128 struct crypto_testsuite_params *ts_params = &testsuite_params;
1129 uint8_t dev_id = ts_params->valid_devs[0];
1130 struct rte_cryptodev_info dev_info;
1131 uint64_t feat_flags;
1132 const enum rte_crypto_cipher_algorithm ciphers[] = {
1133 RTE_CRYPTO_CIPHER_NULL,
1134 RTE_CRYPTO_CIPHER_AES_CTR,
1135 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1136 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1138 const enum rte_crypto_auth_algorithm auths[] = {
1139 RTE_CRYPTO_AUTH_NULL,
1140 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1141 RTE_CRYPTO_AUTH_AES_CMAC,
1142 RTE_CRYPTO_AUTH_ZUC_EIA3
1145 rte_cryptodev_info_get(dev_id, &dev_info);
1146 feat_flags = dev_info.feature_flags;
1148 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1149 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1150 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1151 "Cipher Hash testsuite not met\n");
1152 return TEST_SKIPPED;
1155 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1156 && check_auth_capabilities_supported(auths,
1157 RTE_DIM(auths)) != 0) {
1158 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1159 "Cipher Hash testsuite not met\n");
1160 return TEST_SKIPPED;
1167 esn_testsuite_setup(void)
1169 struct crypto_testsuite_params *ts_params = &testsuite_params;
1170 uint8_t dev_id = ts_params->valid_devs[0];
1171 struct rte_cryptodev_info dev_info;
1172 const enum rte_crypto_cipher_algorithm ciphers[] = {
1173 RTE_CRYPTO_CIPHER_AES_CBC
1175 const enum rte_crypto_auth_algorithm auths[] = {
1176 RTE_CRYPTO_AUTH_SHA1_HMAC
1179 rte_cryptodev_info_get(dev_id, &dev_info);
1181 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1182 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1183 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1184 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1185 "testsuite not met\n");
1186 return TEST_SKIPPED;
1189 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1190 && check_auth_capabilities_supported(auths,
1191 RTE_DIM(auths)) != 0) {
1192 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1193 "testsuite not met\n");
1194 return TEST_SKIPPED;
1201 multi_session_testsuite_setup(void)
1203 struct crypto_testsuite_params *ts_params = &testsuite_params;
1204 uint8_t dev_id = ts_params->valid_devs[0];
1205 struct rte_cryptodev_info dev_info;
1206 const enum rte_crypto_cipher_algorithm ciphers[] = {
1207 RTE_CRYPTO_CIPHER_AES_CBC
1209 const enum rte_crypto_auth_algorithm auths[] = {
1210 RTE_CRYPTO_AUTH_SHA512_HMAC
1213 rte_cryptodev_info_get(dev_id, &dev_info);
1215 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1216 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1217 "Session testsuite not met\n");
1218 return TEST_SKIPPED;
1221 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1222 && check_auth_capabilities_supported(auths,
1223 RTE_DIM(auths)) != 0) {
1224 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1225 "Session testsuite not met\n");
1226 return TEST_SKIPPED;
1233 negative_hmac_sha1_testsuite_setup(void)
1235 struct crypto_testsuite_params *ts_params = &testsuite_params;
1236 uint8_t dev_id = ts_params->valid_devs[0];
1237 struct rte_cryptodev_info dev_info;
1238 const enum rte_crypto_cipher_algorithm ciphers[] = {
1239 RTE_CRYPTO_CIPHER_AES_CBC
1241 const enum rte_crypto_auth_algorithm auths[] = {
1242 RTE_CRYPTO_AUTH_SHA1_HMAC
1245 rte_cryptodev_info_get(dev_id, &dev_info);
1247 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1248 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1249 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1250 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1251 "HMAC SHA1 testsuite not met\n");
1252 return TEST_SKIPPED;
1255 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1256 && check_auth_capabilities_supported(auths,
1257 RTE_DIM(auths)) != 0) {
1258 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1259 "HMAC SHA1 testsuite not met\n");
1260 return TEST_SKIPPED;
1267 dev_configure_and_start(uint64_t ff_disable)
1269 struct crypto_testsuite_params *ts_params = &testsuite_params;
1270 struct crypto_unittest_params *ut_params = &unittest_params;
1274 /* Clear unit test parameters before running test */
1275 memset(ut_params, 0, sizeof(*ut_params));
1277 /* Reconfigure device to default parameters */
1278 ts_params->conf.socket_id = SOCKET_ID_ANY;
1279 ts_params->conf.ff_disable = ff_disable;
1280 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1281 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1282 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1284 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1286 "Failed to configure cryptodev %u",
1287 ts_params->valid_devs[0]);
1289 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1290 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1291 ts_params->valid_devs[0], qp_id,
1292 &ts_params->qp_conf,
1293 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1294 "Failed to setup queue pair %u on cryptodev %u",
1295 qp_id, ts_params->valid_devs[0]);
1299 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1301 /* Start the device */
1302 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1303 "Failed to start cryptodev %u",
1304 ts_params->valid_devs[0]);
1306 return TEST_SUCCESS;
1312 /* Configure and start the device with security feature disabled */
1313 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1317 ut_setup_security(void)
1319 /* Configure and start the device with no features disabled */
1320 return dev_configure_and_start(0);
1326 struct crypto_testsuite_params *ts_params = &testsuite_params;
1327 struct crypto_unittest_params *ut_params = &unittest_params;
1328 struct rte_cryptodev_stats stats;
1330 /* free crypto session structure */
1331 #ifdef RTE_LIB_SECURITY
1332 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1333 if (ut_params->sec_session) {
1334 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1335 (ts_params->valid_devs[0]),
1336 ut_params->sec_session);
1337 ut_params->sec_session = NULL;
1342 if (ut_params->sess) {
1343 rte_cryptodev_sym_session_clear(
1344 ts_params->valid_devs[0],
1346 rte_cryptodev_sym_session_free(ut_params->sess);
1347 ut_params->sess = NULL;
1351 /* free crypto operation structure */
1353 rte_crypto_op_free(ut_params->op);
1356 * free mbuf - both obuf and ibuf are usually the same,
1357 * so check if they point at the same address is necessary,
1358 * to avoid freeing the mbuf twice.
1360 if (ut_params->obuf) {
1361 rte_pktmbuf_free(ut_params->obuf);
1362 if (ut_params->ibuf == ut_params->obuf)
1363 ut_params->ibuf = 0;
1364 ut_params->obuf = 0;
1366 if (ut_params->ibuf) {
1367 rte_pktmbuf_free(ut_params->ibuf);
1368 ut_params->ibuf = 0;
1371 if (ts_params->mbuf_pool != NULL)
1372 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1373 rte_mempool_avail_count(ts_params->mbuf_pool));
1375 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1377 /* Stop the device */
1378 rte_cryptodev_stop(ts_params->valid_devs[0]);
1382 test_device_configure_invalid_dev_id(void)
1384 struct crypto_testsuite_params *ts_params = &testsuite_params;
1385 uint16_t dev_id, num_devs = 0;
1387 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1388 "Need at least %d devices for test", 1);
1390 /* valid dev_id values */
1391 dev_id = ts_params->valid_devs[0];
1393 /* Stop the device in case it's started so it can be configured */
1394 rte_cryptodev_stop(dev_id);
1396 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1397 "Failed test for rte_cryptodev_configure: "
1398 "invalid dev_num %u", dev_id);
1400 /* invalid dev_id values */
1403 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1404 "Failed test for rte_cryptodev_configure: "
1405 "invalid dev_num %u", dev_id);
1409 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1410 "Failed test for rte_cryptodev_configure:"
1411 "invalid dev_num %u", dev_id);
1413 return TEST_SUCCESS;
1417 test_device_configure_invalid_queue_pair_ids(void)
1419 struct crypto_testsuite_params *ts_params = &testsuite_params;
1420 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1422 /* Stop the device in case it's started so it can be configured */
1423 rte_cryptodev_stop(ts_params->valid_devs[0]);
1425 /* valid - max value queue pairs */
1426 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1428 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1430 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1431 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1433 /* valid - one queue pairs */
1434 ts_params->conf.nb_queue_pairs = 1;
1436 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1438 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1439 ts_params->valid_devs[0],
1440 ts_params->conf.nb_queue_pairs);
1443 /* invalid - zero queue pairs */
1444 ts_params->conf.nb_queue_pairs = 0;
1446 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1448 "Failed test for rte_cryptodev_configure, dev_id %u,"
1450 ts_params->valid_devs[0],
1451 ts_params->conf.nb_queue_pairs);
1454 /* invalid - max value supported by field queue pairs */
1455 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1457 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1459 "Failed test for rte_cryptodev_configure, dev_id %u,"
1461 ts_params->valid_devs[0],
1462 ts_params->conf.nb_queue_pairs);
1465 /* invalid - max value + 1 queue pairs */
1466 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1468 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1470 "Failed test for rte_cryptodev_configure, dev_id %u,"
1472 ts_params->valid_devs[0],
1473 ts_params->conf.nb_queue_pairs);
1475 /* revert to original testsuite value */
1476 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1478 return TEST_SUCCESS;
1482 test_queue_pair_descriptor_setup(void)
1484 struct crypto_testsuite_params *ts_params = &testsuite_params;
1485 struct rte_cryptodev_qp_conf qp_conf = {
1486 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1490 /* Stop the device in case it's started so it can be configured */
1491 rte_cryptodev_stop(ts_params->valid_devs[0]);
1493 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1495 "Failed to configure cryptodev %u",
1496 ts_params->valid_devs[0]);
1499 * Test various ring sizes on this device. memzones can't be
1500 * freed so are re-used if ring is released and re-created.
1502 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1503 qp_conf.mp_session = ts_params->session_mpool;
1504 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1506 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1507 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1508 ts_params->valid_devs[0], qp_id, &qp_conf,
1509 rte_cryptodev_socket_id(
1510 ts_params->valid_devs[0])),
1512 "rte_cryptodev_queue_pair_setup: num_inflights "
1513 "%u on qp %u on cryptodev %u",
1514 qp_conf.nb_descriptors, qp_id,
1515 ts_params->valid_devs[0]);
1518 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1520 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1521 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1522 ts_params->valid_devs[0], qp_id, &qp_conf,
1523 rte_cryptodev_socket_id(
1524 ts_params->valid_devs[0])),
1526 " rte_cryptodev_queue_pair_setup: num_inflights"
1527 " %u on qp %u on cryptodev %u",
1528 qp_conf.nb_descriptors, qp_id,
1529 ts_params->valid_devs[0]);
1532 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1534 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1535 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1536 ts_params->valid_devs[0], qp_id, &qp_conf,
1537 rte_cryptodev_socket_id(
1538 ts_params->valid_devs[0])),
1540 "rte_cryptodev_queue_pair_setup: num_inflights"
1541 " %u on qp %u on cryptodev %u",
1542 qp_conf.nb_descriptors, qp_id,
1543 ts_params->valid_devs[0]);
1546 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1548 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1549 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1550 ts_params->valid_devs[0], qp_id, &qp_conf,
1551 rte_cryptodev_socket_id(
1552 ts_params->valid_devs[0])),
1554 " rte_cryptodev_queue_pair_setup:"
1555 "num_inflights %u on qp %u on cryptodev %u",
1556 qp_conf.nb_descriptors, qp_id,
1557 ts_params->valid_devs[0]);
1560 /* test invalid queue pair id */
1561 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1563 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1565 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1566 ts_params->valid_devs[0],
1568 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1569 "Failed test for rte_cryptodev_queue_pair_setup:"
1570 "invalid qp %u on cryptodev %u",
1571 qp_id, ts_params->valid_devs[0]);
1573 qp_id = 0xffff; /*invalid*/
1575 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1576 ts_params->valid_devs[0],
1578 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1579 "Failed test for rte_cryptodev_queue_pair_setup:"
1580 "invalid qp %u on cryptodev %u",
1581 qp_id, ts_params->valid_devs[0]);
1583 return TEST_SUCCESS;
1586 /* ***** Plaintext data for tests ***** */
1588 const char catch_22_quote_1[] =
1589 "There was only one catch and that was Catch-22, which "
1590 "specified that a concern for one's safety in the face of "
1591 "dangers that were real and immediate was the process of a "
1592 "rational mind. Orr was crazy and could be grounded. All he "
1593 "had to do was ask; and as soon as he did, he would no longer "
1594 "be crazy and would have to fly more missions. Orr would be "
1595 "crazy to fly more missions and sane if he didn't, but if he "
1596 "was sane he had to fly them. If he flew them he was crazy "
1597 "and didn't have to; but if he didn't want to he was sane and "
1598 "had to. Yossarian was moved very deeply by the absolute "
1599 "simplicity of this clause of Catch-22 and let out a "
1600 "respectful whistle. \"That's some catch, that Catch-22\", he "
1601 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1603 const char catch_22_quote[] =
1604 "What a lousy earth! He wondered how many people were "
1605 "destitute that same night even in his own prosperous country, "
1606 "how many homes were shanties, how many husbands were drunk "
1607 "and wives socked, and how many children were bullied, abused, "
1608 "or abandoned. How many families hungered for food they could "
1609 "not afford to buy? How many hearts were broken? How many "
1610 "suicides would take place that same night, how many people "
1611 "would go insane? How many cockroaches and landlords would "
1612 "triumph? How many winners were losers, successes failures, "
1613 "and rich men poor men? How many wise guys were stupid? How "
1614 "many happy endings were unhappy endings? How many honest men "
1615 "were liars, brave men cowards, loyal men traitors, how many "
1616 "sainted men were corrupt, how many people in positions of "
1617 "trust had sold their souls to bodyguards, how many had never "
1618 "had souls? How many straight-and-narrow paths were crooked "
1619 "paths? How many best families were worst families and how "
1620 "many good people were bad people? When you added them all up "
1621 "and then subtracted, you might be left with only the children, "
1622 "and perhaps with Albert Einstein and an old violinist or "
1623 "sculptor somewhere.";
1625 #define QUOTE_480_BYTES (480)
1626 #define QUOTE_512_BYTES (512)
1627 #define QUOTE_768_BYTES (768)
1628 #define QUOTE_1024_BYTES (1024)
1632 /* ***** SHA1 Hash Tests ***** */
1634 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1636 static uint8_t hmac_sha1_key[] = {
1637 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1638 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1639 0xDE, 0xF4, 0xDE, 0xAD };
1641 /* ***** SHA224 Hash Tests ***** */
1643 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1646 /* ***** AES-CBC Cipher Tests ***** */
1648 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1649 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1651 static uint8_t aes_cbc_key[] = {
1652 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1653 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1655 static uint8_t aes_cbc_iv[] = {
1656 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1657 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1660 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1662 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1663 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1664 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1665 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1666 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1667 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1668 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1669 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1670 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1671 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1672 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1673 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1674 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1675 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1676 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1677 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1678 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1679 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1680 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1681 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1682 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1683 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1684 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1685 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1686 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1687 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1688 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1689 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1690 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1691 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1692 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1693 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1694 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1695 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1696 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1697 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1698 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1699 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1700 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1701 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1702 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1703 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1704 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1705 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1706 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1707 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1708 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1709 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1710 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1711 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1712 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1713 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1714 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1715 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1716 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1717 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1718 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1719 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1720 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1721 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1722 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1723 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1724 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1725 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1726 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1729 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1730 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1731 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1732 0x18, 0x8c, 0x1d, 0x32
1736 /* Multisession Vector context Test */
1737 /*Begin Session 0 */
1738 static uint8_t ms_aes_cbc_key0[] = {
1739 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1740 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1743 static uint8_t ms_aes_cbc_iv0[] = {
1744 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1745 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1748 static const uint8_t ms_aes_cbc_cipher0[] = {
1749 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1750 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1751 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1752 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1753 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1754 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1755 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1756 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1757 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1758 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1759 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1760 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1761 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1762 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1763 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1764 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1765 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1766 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1767 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1768 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1769 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1770 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1771 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1772 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1773 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1774 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1775 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1776 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1777 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1778 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1779 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1780 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1781 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1782 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1783 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1784 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1785 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1786 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1787 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1788 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1789 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1790 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1791 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1792 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1793 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1794 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1795 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1796 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1797 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1798 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1799 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1800 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1801 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1802 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1803 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1804 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1805 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1806 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1807 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1808 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1809 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1810 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1811 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1812 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1816 static uint8_t ms_hmac_key0[] = {
1817 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1818 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1819 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1820 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1821 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1822 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1823 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1824 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1827 static const uint8_t ms_hmac_digest0[] = {
1828 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1829 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1830 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1831 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1832 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1833 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1834 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1835 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1839 /* Begin session 1 */
1841 static uint8_t ms_aes_cbc_key1[] = {
1842 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1843 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1846 static uint8_t ms_aes_cbc_iv1[] = {
1847 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1848 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1851 static const uint8_t ms_aes_cbc_cipher1[] = {
1852 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1853 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1854 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1855 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1856 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1857 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1858 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1859 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1860 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1861 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1862 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1863 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1864 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1865 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1866 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1867 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1868 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1869 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1870 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1871 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1872 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1873 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1874 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1875 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1876 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1877 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1878 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1879 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1880 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1881 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1882 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1883 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1884 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1885 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1886 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1887 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1888 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1889 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1890 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1891 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1892 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1893 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1894 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1895 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1896 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1897 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1898 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1899 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1900 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1901 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1902 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1903 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1904 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1905 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1906 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1907 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1908 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1909 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1910 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1911 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1912 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1913 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1914 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1915 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1919 static uint8_t ms_hmac_key1[] = {
1920 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1921 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1922 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1923 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1924 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1925 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1926 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1927 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1930 static const uint8_t ms_hmac_digest1[] = {
1931 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1932 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1933 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1934 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1935 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1936 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1937 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1938 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1941 /* Begin Session 2 */
1942 static uint8_t ms_aes_cbc_key2[] = {
1943 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1944 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1947 static uint8_t ms_aes_cbc_iv2[] = {
1948 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1949 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1952 static const uint8_t ms_aes_cbc_cipher2[] = {
1953 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1954 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1955 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1956 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1957 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1958 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1959 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1960 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1961 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1962 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1963 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1964 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1965 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1966 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1967 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1968 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1969 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1970 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1971 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1972 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1973 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1974 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1975 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1976 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1977 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1978 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1979 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1980 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1981 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1982 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1983 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1984 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1985 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1986 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1987 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1988 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1989 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1990 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1991 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1992 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1993 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1994 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1995 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1996 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1997 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1998 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1999 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2000 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2001 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2002 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2003 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2004 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2005 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2006 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2007 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2008 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2009 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2010 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2011 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2012 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2013 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2014 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2015 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2016 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2019 static uint8_t ms_hmac_key2[] = {
2020 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2021 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2022 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2023 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2024 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2025 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2026 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2027 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2030 static const uint8_t ms_hmac_digest2[] = {
2031 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2032 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2033 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2034 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2035 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2036 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2037 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2038 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2045 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2047 struct crypto_testsuite_params *ts_params = &testsuite_params;
2048 struct crypto_unittest_params *ut_params = &unittest_params;
2050 /* Verify the capabilities */
2051 struct rte_cryptodev_sym_capability_idx cap_idx;
2052 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2053 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2054 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2056 return TEST_SKIPPED;
2057 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2058 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2059 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2061 return TEST_SKIPPED;
2063 /* Generate test mbuf data and space for digest */
2064 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2065 catch_22_quote, QUOTE_512_BYTES, 0);
2067 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2068 DIGEST_BYTE_LENGTH_SHA1);
2069 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2071 /* Setup Cipher Parameters */
2072 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2073 ut_params->cipher_xform.next = &ut_params->auth_xform;
2075 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2076 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2077 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2078 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2079 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2080 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2082 /* Setup HMAC Parameters */
2083 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2085 ut_params->auth_xform.next = NULL;
2087 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2088 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2089 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2090 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2091 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2093 ut_params->sess = rte_cryptodev_sym_session_create(
2094 ts_params->session_mpool);
2096 /* Create crypto session*/
2097 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2098 ut_params->sess, &ut_params->cipher_xform,
2099 ts_params->session_priv_mpool);
2100 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2102 /* Generate crypto op data structure */
2103 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2104 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2105 TEST_ASSERT_NOT_NULL(ut_params->op,
2106 "Failed to allocate symmetric crypto operation struct");
2108 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2110 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2112 /* set crypto operation source mbuf */
2113 sym_op->m_src = ut_params->ibuf;
2115 /* Set crypto operation authentication parameters */
2116 sym_op->auth.digest.data = ut_params->digest;
2117 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2118 ut_params->ibuf, QUOTE_512_BYTES);
2120 sym_op->auth.data.offset = 0;
2121 sym_op->auth.data.length = QUOTE_512_BYTES;
2123 /* Copy IV at the end of the crypto operation */
2124 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2125 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2127 /* Set crypto operation cipher parameters */
2128 sym_op->cipher.data.offset = 0;
2129 sym_op->cipher.data.length = QUOTE_512_BYTES;
2131 /* Process crypto operation */
2132 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2133 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2136 TEST_ASSERT_NOT_NULL(
2137 process_crypto_request(ts_params->valid_devs[0],
2139 "failed to process sym crypto op");
2141 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2142 "crypto op processing failed");
2145 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2148 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2149 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2151 "ciphertext data not as expected");
2153 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2155 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2156 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2157 gbl_driver_id == rte_cryptodev_driver_id_get(
2158 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2159 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2160 DIGEST_BYTE_LENGTH_SHA1,
2161 "Generated digest data not as expected");
2163 return TEST_SUCCESS;
2166 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2168 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2170 static uint8_t hmac_sha512_key[] = {
2171 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2172 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2173 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2174 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2175 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2176 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2177 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2178 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2180 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2181 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2182 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2183 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2184 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2185 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2186 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2187 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2188 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2193 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2194 struct crypto_unittest_params *ut_params,
2195 uint8_t *cipher_key,
2199 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2200 struct crypto_unittest_params *ut_params,
2201 struct crypto_testsuite_params *ts_params,
2202 const uint8_t *cipher,
2203 const uint8_t *digest,
2208 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2209 struct crypto_unittest_params *ut_params,
2210 uint8_t *cipher_key,
2214 /* Setup Cipher Parameters */
2215 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2216 ut_params->cipher_xform.next = NULL;
2218 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2219 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2220 ut_params->cipher_xform.cipher.key.data = cipher_key;
2221 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2222 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2223 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2225 /* Setup HMAC Parameters */
2226 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2227 ut_params->auth_xform.next = &ut_params->cipher_xform;
2229 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2230 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2231 ut_params->auth_xform.auth.key.data = hmac_key;
2232 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2233 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2235 return TEST_SUCCESS;
2240 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2241 struct crypto_unittest_params *ut_params,
2242 struct crypto_testsuite_params *ts_params,
2243 const uint8_t *cipher,
2244 const uint8_t *digest,
2247 /* Generate test mbuf data and digest */
2248 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2251 QUOTE_512_BYTES, 0);
2253 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2254 DIGEST_BYTE_LENGTH_SHA512);
2255 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2257 rte_memcpy(ut_params->digest,
2259 DIGEST_BYTE_LENGTH_SHA512);
2261 /* Generate Crypto op data structure */
2262 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2263 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2264 TEST_ASSERT_NOT_NULL(ut_params->op,
2265 "Failed to allocate symmetric crypto operation struct");
2267 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2269 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2271 /* set crypto operation source mbuf */
2272 sym_op->m_src = ut_params->ibuf;
2274 sym_op->auth.digest.data = ut_params->digest;
2275 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2276 ut_params->ibuf, QUOTE_512_BYTES);
2278 sym_op->auth.data.offset = 0;
2279 sym_op->auth.data.length = QUOTE_512_BYTES;
2281 /* Copy IV at the end of the crypto operation */
2282 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2283 iv, CIPHER_IV_LENGTH_AES_CBC);
2285 sym_op->cipher.data.offset = 0;
2286 sym_op->cipher.data.length = QUOTE_512_BYTES;
2288 /* Process crypto operation */
2289 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2290 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2292 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2293 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2294 ut_params->op, 1, 1, 0, 0);
2296 TEST_ASSERT_NOT_NULL(
2297 process_crypto_request(ts_params->valid_devs[0],
2299 "failed to process sym crypto op");
2301 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2302 "crypto op processing failed");
2304 ut_params->obuf = ut_params->op->sym->m_src;
2307 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2308 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2311 "Plaintext data not as expected");
2314 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2315 "Digest verification failed");
2317 return TEST_SUCCESS;
2320 /* ***** SNOW 3G Tests ***** */
2322 create_wireless_algo_hash_session(uint8_t dev_id,
2323 const uint8_t *key, const uint8_t key_len,
2324 const uint8_t iv_len, const uint8_t auth_len,
2325 enum rte_crypto_auth_operation op,
2326 enum rte_crypto_auth_algorithm algo)
2328 uint8_t hash_key[key_len];
2331 struct crypto_testsuite_params *ts_params = &testsuite_params;
2332 struct crypto_unittest_params *ut_params = &unittest_params;
2334 memcpy(hash_key, key, key_len);
2336 debug_hexdump(stdout, "key:", key, key_len);
2338 /* Setup Authentication Parameters */
2339 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2340 ut_params->auth_xform.next = NULL;
2342 ut_params->auth_xform.auth.op = op;
2343 ut_params->auth_xform.auth.algo = algo;
2344 ut_params->auth_xform.auth.key.length = key_len;
2345 ut_params->auth_xform.auth.key.data = hash_key;
2346 ut_params->auth_xform.auth.digest_length = auth_len;
2347 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2348 ut_params->auth_xform.auth.iv.length = iv_len;
2349 ut_params->sess = rte_cryptodev_sym_session_create(
2350 ts_params->session_mpool);
2352 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2353 &ut_params->auth_xform,
2354 ts_params->session_priv_mpool);
2355 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2356 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2361 create_wireless_algo_cipher_session(uint8_t dev_id,
2362 enum rte_crypto_cipher_operation op,
2363 enum rte_crypto_cipher_algorithm algo,
2364 const uint8_t *key, const uint8_t key_len,
2367 uint8_t cipher_key[key_len];
2369 struct crypto_testsuite_params *ts_params = &testsuite_params;
2370 struct crypto_unittest_params *ut_params = &unittest_params;
2372 memcpy(cipher_key, key, key_len);
2374 /* Setup Cipher Parameters */
2375 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2376 ut_params->cipher_xform.next = NULL;
2378 ut_params->cipher_xform.cipher.algo = algo;
2379 ut_params->cipher_xform.cipher.op = op;
2380 ut_params->cipher_xform.cipher.key.data = cipher_key;
2381 ut_params->cipher_xform.cipher.key.length = key_len;
2382 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2383 ut_params->cipher_xform.cipher.iv.length = iv_len;
2385 debug_hexdump(stdout, "key:", key, key_len);
2387 /* Create Crypto session */
2388 ut_params->sess = rte_cryptodev_sym_session_create(
2389 ts_params->session_mpool);
2391 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2392 &ut_params->cipher_xform,
2393 ts_params->session_priv_mpool);
2394 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2395 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2400 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2401 unsigned int cipher_len,
2402 unsigned int cipher_offset)
2404 struct crypto_testsuite_params *ts_params = &testsuite_params;
2405 struct crypto_unittest_params *ut_params = &unittest_params;
2407 /* Generate Crypto op data structure */
2408 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2409 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2410 TEST_ASSERT_NOT_NULL(ut_params->op,
2411 "Failed to allocate pktmbuf offload");
2413 /* Set crypto operation data parameters */
2414 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2416 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2418 /* set crypto operation source mbuf */
2419 sym_op->m_src = ut_params->ibuf;
2422 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2424 sym_op->cipher.data.length = cipher_len;
2425 sym_op->cipher.data.offset = cipher_offset;
2430 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2431 unsigned int cipher_len,
2432 unsigned int cipher_offset)
2434 struct crypto_testsuite_params *ts_params = &testsuite_params;
2435 struct crypto_unittest_params *ut_params = &unittest_params;
2437 /* Generate Crypto op data structure */
2438 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2439 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2440 TEST_ASSERT_NOT_NULL(ut_params->op,
2441 "Failed to allocate pktmbuf offload");
2443 /* Set crypto operation data parameters */
2444 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2446 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2448 /* set crypto operation source mbuf */
2449 sym_op->m_src = ut_params->ibuf;
2450 sym_op->m_dst = ut_params->obuf;
2453 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2455 sym_op->cipher.data.length = cipher_len;
2456 sym_op->cipher.data.offset = cipher_offset;
2461 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2462 enum rte_crypto_cipher_operation cipher_op,
2463 enum rte_crypto_auth_operation auth_op,
2464 enum rte_crypto_auth_algorithm auth_algo,
2465 enum rte_crypto_cipher_algorithm cipher_algo,
2466 const uint8_t *key, uint8_t key_len,
2467 uint8_t auth_iv_len, uint8_t auth_len,
2468 uint8_t cipher_iv_len)
2471 uint8_t cipher_auth_key[key_len];
2474 struct crypto_testsuite_params *ts_params = &testsuite_params;
2475 struct crypto_unittest_params *ut_params = &unittest_params;
2477 memcpy(cipher_auth_key, key, key_len);
2479 /* Setup Authentication Parameters */
2480 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2481 ut_params->auth_xform.next = NULL;
2483 ut_params->auth_xform.auth.op = auth_op;
2484 ut_params->auth_xform.auth.algo = auth_algo;
2485 ut_params->auth_xform.auth.key.length = key_len;
2486 /* Hash key = cipher key */
2487 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2488 ut_params->auth_xform.auth.digest_length = auth_len;
2489 /* Auth IV will be after cipher IV */
2490 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2491 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2493 /* Setup Cipher Parameters */
2494 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2495 ut_params->cipher_xform.next = &ut_params->auth_xform;
2497 ut_params->cipher_xform.cipher.algo = cipher_algo;
2498 ut_params->cipher_xform.cipher.op = cipher_op;
2499 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2500 ut_params->cipher_xform.cipher.key.length = key_len;
2501 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2502 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2504 debug_hexdump(stdout, "key:", key, key_len);
2506 /* Create Crypto session*/
2507 ut_params->sess = rte_cryptodev_sym_session_create(
2508 ts_params->session_mpool);
2509 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2511 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2512 &ut_params->cipher_xform,
2513 ts_params->session_priv_mpool);
2514 if (status == -ENOTSUP)
2515 return TEST_SKIPPED;
2517 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2522 create_wireless_cipher_auth_session(uint8_t dev_id,
2523 enum rte_crypto_cipher_operation cipher_op,
2524 enum rte_crypto_auth_operation auth_op,
2525 enum rte_crypto_auth_algorithm auth_algo,
2526 enum rte_crypto_cipher_algorithm cipher_algo,
2527 const struct wireless_test_data *tdata)
2529 const uint8_t key_len = tdata->key.len;
2530 uint8_t cipher_auth_key[key_len];
2533 struct crypto_testsuite_params *ts_params = &testsuite_params;
2534 struct crypto_unittest_params *ut_params = &unittest_params;
2535 const uint8_t *key = tdata->key.data;
2536 const uint8_t auth_len = tdata->digest.len;
2537 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2538 uint8_t auth_iv_len = tdata->auth_iv.len;
2540 memcpy(cipher_auth_key, key, key_len);
2542 /* Setup Authentication Parameters */
2543 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2544 ut_params->auth_xform.next = NULL;
2546 ut_params->auth_xform.auth.op = auth_op;
2547 ut_params->auth_xform.auth.algo = auth_algo;
2548 ut_params->auth_xform.auth.key.length = key_len;
2549 /* Hash key = cipher key */
2550 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2551 ut_params->auth_xform.auth.digest_length = auth_len;
2552 /* Auth IV will be after cipher IV */
2553 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2554 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2556 /* Setup Cipher Parameters */
2557 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2558 ut_params->cipher_xform.next = &ut_params->auth_xform;
2560 ut_params->cipher_xform.cipher.algo = cipher_algo;
2561 ut_params->cipher_xform.cipher.op = cipher_op;
2562 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2563 ut_params->cipher_xform.cipher.key.length = key_len;
2564 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2565 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2568 debug_hexdump(stdout, "key:", key, key_len);
2570 /* Create Crypto session*/
2571 ut_params->sess = rte_cryptodev_sym_session_create(
2572 ts_params->session_mpool);
2574 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2575 &ut_params->cipher_xform,
2576 ts_params->session_priv_mpool);
2577 if (status == -ENOTSUP)
2578 return TEST_SKIPPED;
2580 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2581 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2586 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2587 const struct wireless_test_data *tdata)
2589 return create_wireless_cipher_auth_session(dev_id,
2590 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2591 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2592 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2596 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2597 enum rte_crypto_cipher_operation cipher_op,
2598 enum rte_crypto_auth_operation auth_op,
2599 enum rte_crypto_auth_algorithm auth_algo,
2600 enum rte_crypto_cipher_algorithm cipher_algo,
2601 const uint8_t *key, const uint8_t key_len,
2602 uint8_t auth_iv_len, uint8_t auth_len,
2603 uint8_t cipher_iv_len)
2605 uint8_t auth_cipher_key[key_len];
2607 struct crypto_testsuite_params *ts_params = &testsuite_params;
2608 struct crypto_unittest_params *ut_params = &unittest_params;
2610 memcpy(auth_cipher_key, key, key_len);
2612 /* Setup Authentication Parameters */
2613 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2614 ut_params->auth_xform.auth.op = auth_op;
2615 ut_params->auth_xform.next = &ut_params->cipher_xform;
2616 ut_params->auth_xform.auth.algo = auth_algo;
2617 ut_params->auth_xform.auth.key.length = key_len;
2618 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2619 ut_params->auth_xform.auth.digest_length = auth_len;
2620 /* Auth IV will be after cipher IV */
2621 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2622 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2624 /* Setup Cipher Parameters */
2625 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2626 ut_params->cipher_xform.next = NULL;
2627 ut_params->cipher_xform.cipher.algo = cipher_algo;
2628 ut_params->cipher_xform.cipher.op = cipher_op;
2629 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2630 ut_params->cipher_xform.cipher.key.length = key_len;
2631 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2632 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2634 debug_hexdump(stdout, "key:", key, key_len);
2636 /* Create Crypto session*/
2637 ut_params->sess = rte_cryptodev_sym_session_create(
2638 ts_params->session_mpool);
2639 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2641 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2642 ut_params->auth_xform.next = NULL;
2643 ut_params->cipher_xform.next = &ut_params->auth_xform;
2644 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2645 &ut_params->cipher_xform,
2646 ts_params->session_priv_mpool);
2649 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2650 &ut_params->auth_xform,
2651 ts_params->session_priv_mpool);
2653 if (status == -ENOTSUP)
2654 return TEST_SKIPPED;
2656 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2662 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2663 unsigned int auth_tag_len,
2664 const uint8_t *iv, unsigned int iv_len,
2665 unsigned int data_pad_len,
2666 enum rte_crypto_auth_operation op,
2667 unsigned int auth_len, unsigned int auth_offset)
2669 struct crypto_testsuite_params *ts_params = &testsuite_params;
2671 struct crypto_unittest_params *ut_params = &unittest_params;
2673 /* Generate Crypto op data structure */
2674 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2675 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2676 TEST_ASSERT_NOT_NULL(ut_params->op,
2677 "Failed to allocate pktmbuf offload");
2679 /* Set crypto operation data parameters */
2680 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2682 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2684 /* set crypto operation source mbuf */
2685 sym_op->m_src = ut_params->ibuf;
2688 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2691 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2692 ut_params->ibuf, auth_tag_len);
2694 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2695 "no room to append auth tag");
2696 ut_params->digest = sym_op->auth.digest.data;
2697 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2698 ut_params->ibuf, data_pad_len);
2699 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2700 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2702 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2704 debug_hexdump(stdout, "digest:",
2705 sym_op->auth.digest.data,
2708 sym_op->auth.data.length = auth_len;
2709 sym_op->auth.data.offset = auth_offset;
2715 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2716 enum rte_crypto_auth_operation op)
2718 struct crypto_testsuite_params *ts_params = &testsuite_params;
2719 struct crypto_unittest_params *ut_params = &unittest_params;
2721 const uint8_t *auth_tag = tdata->digest.data;
2722 const unsigned int auth_tag_len = tdata->digest.len;
2723 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2724 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2726 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2727 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2728 const uint8_t *auth_iv = tdata->auth_iv.data;
2729 const uint8_t auth_iv_len = tdata->auth_iv.len;
2730 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2731 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2733 /* Generate Crypto op data structure */
2734 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2735 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2736 TEST_ASSERT_NOT_NULL(ut_params->op,
2737 "Failed to allocate pktmbuf offload");
2738 /* Set crypto operation data parameters */
2739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2741 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2743 /* set crypto operation source mbuf */
2744 sym_op->m_src = ut_params->ibuf;
2747 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2748 ut_params->ibuf, auth_tag_len);
2750 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2751 "no room to append auth tag");
2752 ut_params->digest = sym_op->auth.digest.data;
2753 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2754 ut_params->ibuf, data_pad_len);
2755 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2756 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2758 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2760 debug_hexdump(stdout, "digest:",
2761 sym_op->auth.digest.data,
2764 /* Copy cipher and auth IVs at the end of the crypto operation */
2765 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2767 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2768 iv_ptr += cipher_iv_len;
2769 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2771 sym_op->cipher.data.length = cipher_len;
2772 sym_op->cipher.data.offset = 0;
2773 sym_op->auth.data.length = auth_len;
2774 sym_op->auth.data.offset = 0;
2780 create_zuc_cipher_hash_generate_operation(
2781 const struct wireless_test_data *tdata)
2783 return create_wireless_cipher_hash_operation(tdata,
2784 RTE_CRYPTO_AUTH_OP_GENERATE);
2788 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2789 const unsigned auth_tag_len,
2790 const uint8_t *auth_iv, uint8_t auth_iv_len,
2791 unsigned data_pad_len,
2792 enum rte_crypto_auth_operation op,
2793 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2794 const unsigned cipher_len, const unsigned cipher_offset,
2795 const unsigned auth_len, const unsigned auth_offset)
2797 struct crypto_testsuite_params *ts_params = &testsuite_params;
2798 struct crypto_unittest_params *ut_params = &unittest_params;
2800 enum rte_crypto_cipher_algorithm cipher_algo =
2801 ut_params->cipher_xform.cipher.algo;
2802 enum rte_crypto_auth_algorithm auth_algo =
2803 ut_params->auth_xform.auth.algo;
2805 /* Generate Crypto op data structure */
2806 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2807 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2808 TEST_ASSERT_NOT_NULL(ut_params->op,
2809 "Failed to allocate pktmbuf offload");
2810 /* Set crypto operation data parameters */
2811 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2813 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2815 /* set crypto operation source mbuf */
2816 sym_op->m_src = ut_params->ibuf;
2819 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2820 ut_params->ibuf, auth_tag_len);
2822 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2823 "no room to append auth tag");
2824 ut_params->digest = sym_op->auth.digest.data;
2826 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2827 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2828 ut_params->ibuf, data_pad_len);
2830 struct rte_mbuf *m = ut_params->ibuf;
2831 unsigned int offset = data_pad_len;
2833 while (offset > m->data_len && m->next != NULL) {
2834 offset -= m->data_len;
2837 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2841 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2842 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2844 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2846 debug_hexdump(stdout, "digest:",
2847 sym_op->auth.digest.data,
2850 /* Copy cipher and auth IVs at the end of the crypto operation */
2851 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2853 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2854 iv_ptr += cipher_iv_len;
2855 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2857 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2858 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2859 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2860 sym_op->cipher.data.length = cipher_len;
2861 sym_op->cipher.data.offset = cipher_offset;
2863 sym_op->cipher.data.length = cipher_len >> 3;
2864 sym_op->cipher.data.offset = cipher_offset >> 3;
2867 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2868 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2869 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2870 sym_op->auth.data.length = auth_len;
2871 sym_op->auth.data.offset = auth_offset;
2873 sym_op->auth.data.length = auth_len >> 3;
2874 sym_op->auth.data.offset = auth_offset >> 3;
2881 create_wireless_algo_auth_cipher_operation(
2882 const uint8_t *auth_tag, unsigned int auth_tag_len,
2883 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2884 const uint8_t *auth_iv, uint8_t auth_iv_len,
2885 unsigned int data_pad_len,
2886 unsigned int cipher_len, unsigned int cipher_offset,
2887 unsigned int auth_len, unsigned int auth_offset,
2888 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2890 struct crypto_testsuite_params *ts_params = &testsuite_params;
2891 struct crypto_unittest_params *ut_params = &unittest_params;
2893 enum rte_crypto_cipher_algorithm cipher_algo =
2894 ut_params->cipher_xform.cipher.algo;
2895 enum rte_crypto_auth_algorithm auth_algo =
2896 ut_params->auth_xform.auth.algo;
2898 /* Generate Crypto op data structure */
2899 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2900 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2901 TEST_ASSERT_NOT_NULL(ut_params->op,
2902 "Failed to allocate pktmbuf offload");
2904 /* Set crypto operation data parameters */
2905 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2907 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2909 /* set crypto operation mbufs */
2910 sym_op->m_src = ut_params->ibuf;
2911 if (op_mode == OUT_OF_PLACE)
2912 sym_op->m_dst = ut_params->obuf;
2916 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2917 (op_mode == IN_PLACE ?
2918 ut_params->ibuf : ut_params->obuf),
2919 uint8_t *, data_pad_len);
2920 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2921 (op_mode == IN_PLACE ?
2922 ut_params->ibuf : ut_params->obuf),
2924 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2926 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2927 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2928 sym_op->m_src : sym_op->m_dst);
2929 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2930 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2931 sgl_buf = sgl_buf->next;
2933 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2934 uint8_t *, remaining_off);
2935 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2937 memset(sym_op->auth.digest.data, 0, remaining_off);
2938 while (sgl_buf->next != NULL) {
2939 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2940 0, rte_pktmbuf_data_len(sgl_buf));
2941 sgl_buf = sgl_buf->next;
2945 /* Copy digest for the verification */
2947 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2949 /* Copy cipher and auth IVs at the end of the crypto operation */
2950 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2951 ut_params->op, uint8_t *, IV_OFFSET);
2953 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2954 iv_ptr += cipher_iv_len;
2955 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2957 /* Only copy over the offset data needed from src to dst in OOP,
2958 * if the auth and cipher offsets are not aligned
2960 if (op_mode == OUT_OF_PLACE) {
2961 if (cipher_offset > auth_offset)
2963 rte_pktmbuf_mtod_offset(
2965 uint8_t *, auth_offset >> 3),
2966 rte_pktmbuf_mtod_offset(
2968 uint8_t *, auth_offset >> 3),
2969 ((cipher_offset >> 3) - (auth_offset >> 3)));
2972 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2973 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2974 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2975 sym_op->cipher.data.length = cipher_len;
2976 sym_op->cipher.data.offset = cipher_offset;
2978 sym_op->cipher.data.length = cipher_len >> 3;
2979 sym_op->cipher.data.offset = cipher_offset >> 3;
2982 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2983 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2984 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2985 sym_op->auth.data.length = auth_len;
2986 sym_op->auth.data.offset = auth_offset;
2988 sym_op->auth.data.length = auth_len >> 3;
2989 sym_op->auth.data.offset = auth_offset >> 3;
2996 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2998 struct crypto_testsuite_params *ts_params = &testsuite_params;
2999 struct crypto_unittest_params *ut_params = &unittest_params;
3002 unsigned plaintext_pad_len;
3003 unsigned plaintext_len;
3005 struct rte_cryptodev_info dev_info;
3007 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3008 uint64_t feat_flags = dev_info.feature_flags;
3010 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3011 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3012 printf("Device doesn't support NON-Byte Aligned Data.\n");
3013 return TEST_SKIPPED;
3016 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3017 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3018 printf("Device doesn't support RAW data-path APIs.\n");
3019 return TEST_SKIPPED;
3022 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3023 return TEST_SKIPPED;
3025 /* Verify the capabilities */
3026 struct rte_cryptodev_sym_capability_idx cap_idx;
3027 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3028 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3029 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3031 return TEST_SKIPPED;
3033 /* Create SNOW 3G session */
3034 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3035 tdata->key.data, tdata->key.len,
3036 tdata->auth_iv.len, tdata->digest.len,
3037 RTE_CRYPTO_AUTH_OP_GENERATE,
3038 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3042 /* alloc mbuf and set payload */
3043 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3045 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3046 rte_pktmbuf_tailroom(ut_params->ibuf));
3048 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3049 /* Append data which is padded to a multiple of */
3050 /* the algorithms block size */
3051 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3052 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3054 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3056 /* Create SNOW 3G operation */
3057 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3058 tdata->auth_iv.data, tdata->auth_iv.len,
3059 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3060 tdata->validAuthLenInBits.len,
3065 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3066 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3067 ut_params->op, 0, 1, 1, 0);
3069 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3071 ut_params->obuf = ut_params->op->sym->m_src;
3072 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3073 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3074 + plaintext_pad_len;
3077 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3080 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3081 "SNOW 3G Generated auth tag not as expected");
3087 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3089 struct crypto_testsuite_params *ts_params = &testsuite_params;
3090 struct crypto_unittest_params *ut_params = &unittest_params;
3093 unsigned plaintext_pad_len;
3094 unsigned plaintext_len;
3096 struct rte_cryptodev_info dev_info;
3098 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3099 uint64_t feat_flags = dev_info.feature_flags;
3101 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3102 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3103 printf("Device doesn't support NON-Byte Aligned Data.\n");
3104 return TEST_SKIPPED;
3107 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3108 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3109 printf("Device doesn't support RAW data-path APIs.\n");
3110 return TEST_SKIPPED;
3113 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3114 return TEST_SKIPPED;
3116 /* Verify the capabilities */
3117 struct rte_cryptodev_sym_capability_idx cap_idx;
3118 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3119 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3120 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3122 return TEST_SKIPPED;
3124 /* Create SNOW 3G session */
3125 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3126 tdata->key.data, tdata->key.len,
3127 tdata->auth_iv.len, tdata->digest.len,
3128 RTE_CRYPTO_AUTH_OP_VERIFY,
3129 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3132 /* alloc mbuf and set payload */
3133 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3135 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3136 rte_pktmbuf_tailroom(ut_params->ibuf));
3138 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3139 /* Append data which is padded to a multiple of */
3140 /* the algorithms block size */
3141 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3142 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3144 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3146 /* Create SNOW 3G operation */
3147 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3149 tdata->auth_iv.data, tdata->auth_iv.len,
3151 RTE_CRYPTO_AUTH_OP_VERIFY,
3152 tdata->validAuthLenInBits.len,
3157 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3158 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3159 ut_params->op, 0, 1, 1, 0);
3161 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3163 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3164 ut_params->obuf = ut_params->op->sym->m_src;
3165 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3166 + plaintext_pad_len;
3169 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3178 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3180 struct crypto_testsuite_params *ts_params = &testsuite_params;
3181 struct crypto_unittest_params *ut_params = &unittest_params;
3184 unsigned plaintext_pad_len;
3185 unsigned plaintext_len;
3187 struct rte_cryptodev_info dev_info;
3189 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3190 uint64_t feat_flags = dev_info.feature_flags;
3192 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3193 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3194 printf("Device doesn't support RAW data-path APIs.\n");
3195 return TEST_SKIPPED;
3198 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3199 return TEST_SKIPPED;
3201 /* Verify the capabilities */
3202 struct rte_cryptodev_sym_capability_idx cap_idx;
3203 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3204 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3205 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3207 return TEST_SKIPPED;
3209 /* Create KASUMI session */
3210 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3211 tdata->key.data, tdata->key.len,
3212 0, tdata->digest.len,
3213 RTE_CRYPTO_AUTH_OP_GENERATE,
3214 RTE_CRYPTO_AUTH_KASUMI_F9);
3218 /* alloc mbuf and set payload */
3219 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3221 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3222 rte_pktmbuf_tailroom(ut_params->ibuf));
3224 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3225 /* Append data which is padded to a multiple of */
3226 /* the algorithms block size */
3227 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3228 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3230 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3232 /* Create KASUMI operation */
3233 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3235 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3236 tdata->plaintext.len,
3241 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3242 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3244 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3245 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3246 ut_params->op, 0, 1, 1, 0);
3248 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3251 ut_params->obuf = ut_params->op->sym->m_src;
3252 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3253 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3254 + plaintext_pad_len;
3257 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3260 DIGEST_BYTE_LENGTH_KASUMI_F9,
3261 "KASUMI Generated auth tag not as expected");
3267 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3269 struct crypto_testsuite_params *ts_params = &testsuite_params;
3270 struct crypto_unittest_params *ut_params = &unittest_params;
3273 unsigned plaintext_pad_len;
3274 unsigned plaintext_len;
3276 struct rte_cryptodev_info dev_info;
3278 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3279 uint64_t feat_flags = dev_info.feature_flags;
3281 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3282 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3283 printf("Device doesn't support RAW data-path APIs.\n");
3284 return TEST_SKIPPED;
3287 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3288 return TEST_SKIPPED;
3290 /* Verify the capabilities */
3291 struct rte_cryptodev_sym_capability_idx cap_idx;
3292 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3293 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3294 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3296 return TEST_SKIPPED;
3298 /* Create KASUMI session */
3299 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3300 tdata->key.data, tdata->key.len,
3301 0, tdata->digest.len,
3302 RTE_CRYPTO_AUTH_OP_VERIFY,
3303 RTE_CRYPTO_AUTH_KASUMI_F9);
3306 /* alloc mbuf and set payload */
3307 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3309 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3310 rte_pktmbuf_tailroom(ut_params->ibuf));
3312 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3313 /* Append data which is padded to a multiple */
3314 /* of the algorithms block size */
3315 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3316 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3318 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3320 /* Create KASUMI operation */
3321 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3325 RTE_CRYPTO_AUTH_OP_VERIFY,
3326 tdata->plaintext.len,
3331 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3332 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3333 ut_params->op, 0, 1, 1, 0);
3335 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3337 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3338 ut_params->obuf = ut_params->op->sym->m_src;
3339 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3340 + plaintext_pad_len;
3343 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3352 test_snow3g_hash_generate_test_case_1(void)
3354 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3358 test_snow3g_hash_generate_test_case_2(void)
3360 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3364 test_snow3g_hash_generate_test_case_3(void)
3366 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3370 test_snow3g_hash_generate_test_case_4(void)
3372 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3376 test_snow3g_hash_generate_test_case_5(void)
3378 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3382 test_snow3g_hash_generate_test_case_6(void)
3384 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3388 test_snow3g_hash_verify_test_case_1(void)
3390 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3395 test_snow3g_hash_verify_test_case_2(void)
3397 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3401 test_snow3g_hash_verify_test_case_3(void)
3403 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3407 test_snow3g_hash_verify_test_case_4(void)
3409 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3413 test_snow3g_hash_verify_test_case_5(void)
3415 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3419 test_snow3g_hash_verify_test_case_6(void)
3421 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3425 test_kasumi_hash_generate_test_case_1(void)
3427 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3431 test_kasumi_hash_generate_test_case_2(void)
3433 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3437 test_kasumi_hash_generate_test_case_3(void)
3439 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3443 test_kasumi_hash_generate_test_case_4(void)
3445 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3449 test_kasumi_hash_generate_test_case_5(void)
3451 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3455 test_kasumi_hash_generate_test_case_6(void)
3457 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3461 test_kasumi_hash_verify_test_case_1(void)
3463 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3467 test_kasumi_hash_verify_test_case_2(void)
3469 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3473 test_kasumi_hash_verify_test_case_3(void)
3475 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3479 test_kasumi_hash_verify_test_case_4(void)
3481 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3485 test_kasumi_hash_verify_test_case_5(void)
3487 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3491 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3493 struct crypto_testsuite_params *ts_params = &testsuite_params;
3494 struct crypto_unittest_params *ut_params = &unittest_params;
3497 uint8_t *plaintext, *ciphertext;
3498 unsigned plaintext_pad_len;
3499 unsigned plaintext_len;
3500 struct rte_cryptodev_info dev_info;
3502 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3503 uint64_t feat_flags = dev_info.feature_flags;
3505 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3506 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3507 printf("Device doesn't support RAW data-path APIs.\n");
3508 return TEST_SKIPPED;
3511 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3512 return TEST_SKIPPED;
3514 /* Verify the capabilities */
3515 struct rte_cryptodev_sym_capability_idx cap_idx;
3516 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3517 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3518 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3520 return TEST_SKIPPED;
3522 /* Create KASUMI session */
3523 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3524 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3525 RTE_CRYPTO_CIPHER_KASUMI_F8,
3526 tdata->key.data, tdata->key.len,
3527 tdata->cipher_iv.len);
3531 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3533 /* Clear mbuf payload */
3534 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3535 rte_pktmbuf_tailroom(ut_params->ibuf));
3537 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3538 /* Append data which is padded to a multiple */
3539 /* of the algorithms block size */
3540 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3541 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3543 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3545 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3547 /* Create KASUMI operation */
3548 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3549 tdata->cipher_iv.len,
3550 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3551 tdata->validCipherOffsetInBits.len);
3555 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3556 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3557 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3559 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3561 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3563 ut_params->obuf = ut_params->op->sym->m_dst;
3564 if (ut_params->obuf)
3565 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3567 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3569 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3571 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3572 (tdata->validCipherOffsetInBits.len >> 3);
3574 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3576 reference_ciphertext,
3577 tdata->validCipherLenInBits.len,
3578 "KASUMI Ciphertext data not as expected");
3583 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3585 struct crypto_testsuite_params *ts_params = &testsuite_params;
3586 struct crypto_unittest_params *ut_params = &unittest_params;
3590 unsigned int plaintext_pad_len;
3591 unsigned int plaintext_len;
3593 uint8_t buffer[10000];
3594 const uint8_t *ciphertext;
3596 struct rte_cryptodev_info dev_info;
3598 /* Verify the capabilities */
3599 struct rte_cryptodev_sym_capability_idx cap_idx;
3600 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3601 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3602 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3604 return TEST_SKIPPED;
3606 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3608 uint64_t feat_flags = dev_info.feature_flags;
3610 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3611 printf("Device doesn't support in-place scatter-gather. "
3613 return TEST_SKIPPED;
3616 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3617 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3618 printf("Device doesn't support RAW data-path APIs.\n");
3619 return TEST_SKIPPED;
3622 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3623 return TEST_SKIPPED;
3625 /* Create KASUMI session */
3626 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3627 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3628 RTE_CRYPTO_CIPHER_KASUMI_F8,
3629 tdata->key.data, tdata->key.len,
3630 tdata->cipher_iv.len);
3634 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3637 /* Append data which is padded to a multiple */
3638 /* of the algorithms block size */
3639 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3641 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3642 plaintext_pad_len, 10, 0);
3644 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3646 /* Create KASUMI operation */
3647 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3648 tdata->cipher_iv.len,
3649 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3650 tdata->validCipherOffsetInBits.len);
3654 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3655 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3656 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3658 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3660 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3662 ut_params->obuf = ut_params->op->sym->m_dst;
3664 if (ut_params->obuf)
3665 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3666 plaintext_len, buffer);
3668 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3669 tdata->validCipherOffsetInBits.len >> 3,
3670 plaintext_len, buffer);
3673 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3675 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3676 (tdata->validCipherOffsetInBits.len >> 3);
3678 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3680 reference_ciphertext,
3681 tdata->validCipherLenInBits.len,
3682 "KASUMI Ciphertext data not as expected");
3687 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3689 struct crypto_testsuite_params *ts_params = &testsuite_params;
3690 struct crypto_unittest_params *ut_params = &unittest_params;
3693 uint8_t *plaintext, *ciphertext;
3694 unsigned plaintext_pad_len;
3695 unsigned plaintext_len;
3697 /* Verify the capabilities */
3698 struct rte_cryptodev_sym_capability_idx cap_idx;
3699 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3700 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3701 /* Data-path service does not support OOP */
3702 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3704 return TEST_SKIPPED;
3706 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3707 return TEST_SKIPPED;
3709 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3710 return TEST_SKIPPED;
3712 /* Create KASUMI session */
3713 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3714 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3715 RTE_CRYPTO_CIPHER_KASUMI_F8,
3716 tdata->key.data, tdata->key.len,
3717 tdata->cipher_iv.len);
3721 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3722 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3724 /* Clear mbuf payload */
3725 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3726 rte_pktmbuf_tailroom(ut_params->ibuf));
3728 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3729 /* Append data which is padded to a multiple */
3730 /* of the algorithms block size */
3731 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3732 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3734 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3735 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3737 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3739 /* Create KASUMI operation */
3740 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3741 tdata->cipher_iv.len,
3742 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3743 tdata->validCipherOffsetInBits.len);
3747 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3749 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3751 ut_params->obuf = ut_params->op->sym->m_dst;
3752 if (ut_params->obuf)
3753 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3755 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3757 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3759 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3760 (tdata->validCipherOffsetInBits.len >> 3);
3762 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3764 reference_ciphertext,
3765 tdata->validCipherLenInBits.len,
3766 "KASUMI Ciphertext data not as expected");
3771 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3773 struct crypto_testsuite_params *ts_params = &testsuite_params;
3774 struct crypto_unittest_params *ut_params = &unittest_params;
3777 unsigned int plaintext_pad_len;
3778 unsigned int plaintext_len;
3780 const uint8_t *ciphertext;
3781 uint8_t buffer[2048];
3783 struct rte_cryptodev_info dev_info;
3785 /* Verify the capabilities */
3786 struct rte_cryptodev_sym_capability_idx cap_idx;
3787 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3788 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3789 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3791 return TEST_SKIPPED;
3793 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3794 return TEST_SKIPPED;
3796 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3797 return TEST_SKIPPED;
3799 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3801 uint64_t feat_flags = dev_info.feature_flags;
3802 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3803 printf("Device doesn't support out-of-place scatter-gather "
3804 "in both input and output mbufs. "
3806 return TEST_SKIPPED;
3809 /* Create KASUMI session */
3810 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3811 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3812 RTE_CRYPTO_CIPHER_KASUMI_F8,
3813 tdata->key.data, tdata->key.len,
3814 tdata->cipher_iv.len);
3818 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3819 /* Append data which is padded to a multiple */
3820 /* of the algorithms block size */
3821 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3823 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3824 plaintext_pad_len, 10, 0);
3825 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3826 plaintext_pad_len, 3, 0);
3828 /* Append data which is padded to a multiple */
3829 /* of the algorithms block size */
3830 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3832 /* Create KASUMI operation */
3833 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3834 tdata->cipher_iv.len,
3835 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3836 tdata->validCipherOffsetInBits.len);
3840 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3842 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3844 ut_params->obuf = ut_params->op->sym->m_dst;
3845 if (ut_params->obuf)
3846 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3847 plaintext_pad_len, buffer);
3849 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3850 tdata->validCipherOffsetInBits.len >> 3,
3851 plaintext_pad_len, buffer);
3853 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3854 (tdata->validCipherOffsetInBits.len >> 3);
3856 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3858 reference_ciphertext,
3859 tdata->validCipherLenInBits.len,
3860 "KASUMI Ciphertext data not as expected");
3866 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3868 struct crypto_testsuite_params *ts_params = &testsuite_params;
3869 struct crypto_unittest_params *ut_params = &unittest_params;
3872 uint8_t *ciphertext, *plaintext;
3873 unsigned ciphertext_pad_len;
3874 unsigned ciphertext_len;
3876 /* Verify the capabilities */
3877 struct rte_cryptodev_sym_capability_idx cap_idx;
3878 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3879 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3880 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3882 return TEST_SKIPPED;
3884 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3885 return TEST_SKIPPED;
3887 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3888 return TEST_SKIPPED;
3890 /* Create KASUMI session */
3891 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3892 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3893 RTE_CRYPTO_CIPHER_KASUMI_F8,
3894 tdata->key.data, tdata->key.len,
3895 tdata->cipher_iv.len);
3899 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3900 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3902 /* Clear mbuf payload */
3903 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3904 rte_pktmbuf_tailroom(ut_params->ibuf));
3906 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3907 /* Append data which is padded to a multiple */
3908 /* of the algorithms block size */
3909 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3910 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3911 ciphertext_pad_len);
3912 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3913 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3915 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3917 /* Create KASUMI operation */
3918 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3919 tdata->cipher_iv.len,
3920 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3921 tdata->validCipherOffsetInBits.len);
3925 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3927 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3929 ut_params->obuf = ut_params->op->sym->m_dst;
3930 if (ut_params->obuf)
3931 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3933 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3935 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3937 const uint8_t *reference_plaintext = tdata->plaintext.data +
3938 (tdata->validCipherOffsetInBits.len >> 3);
3940 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3942 reference_plaintext,
3943 tdata->validCipherLenInBits.len,
3944 "KASUMI Plaintext data not as expected");
3949 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3951 struct crypto_testsuite_params *ts_params = &testsuite_params;
3952 struct crypto_unittest_params *ut_params = &unittest_params;
3955 uint8_t *ciphertext, *plaintext;
3956 unsigned ciphertext_pad_len;
3957 unsigned ciphertext_len;
3958 struct rte_cryptodev_info dev_info;
3960 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3961 uint64_t feat_flags = dev_info.feature_flags;
3963 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3964 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3965 printf("Device doesn't support RAW data-path APIs.\n");
3966 return TEST_SKIPPED;
3969 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3970 return TEST_SKIPPED;
3972 /* Verify the capabilities */
3973 struct rte_cryptodev_sym_capability_idx cap_idx;
3974 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3975 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3976 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3978 return TEST_SKIPPED;
3980 /* Create KASUMI session */
3981 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3982 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3983 RTE_CRYPTO_CIPHER_KASUMI_F8,
3984 tdata->key.data, tdata->key.len,
3985 tdata->cipher_iv.len);
3989 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3991 /* Clear mbuf payload */
3992 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3993 rte_pktmbuf_tailroom(ut_params->ibuf));
3995 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3996 /* Append data which is padded to a multiple */
3997 /* of the algorithms block size */
3998 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3999 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4000 ciphertext_pad_len);
4001 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4003 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4005 /* Create KASUMI operation */
4006 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4007 tdata->cipher_iv.len,
4008 tdata->ciphertext.len,
4009 tdata->validCipherOffsetInBits.len);
4013 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4014 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4015 ut_params->op, 1, 0, 1, 0);
4017 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4019 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4021 ut_params->obuf = ut_params->op->sym->m_dst;
4022 if (ut_params->obuf)
4023 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4025 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4027 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4029 const uint8_t *reference_plaintext = tdata->plaintext.data +
4030 (tdata->validCipherOffsetInBits.len >> 3);
4032 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4034 reference_plaintext,
4035 tdata->validCipherLenInBits.len,
4036 "KASUMI Plaintext data not as expected");
4041 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4043 struct crypto_testsuite_params *ts_params = &testsuite_params;
4044 struct crypto_unittest_params *ut_params = &unittest_params;
4047 uint8_t *plaintext, *ciphertext;
4048 unsigned plaintext_pad_len;
4049 unsigned plaintext_len;
4050 struct rte_cryptodev_info dev_info;
4052 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4053 uint64_t feat_flags = dev_info.feature_flags;
4055 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4056 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4057 printf("Device doesn't support RAW data-path APIs.\n");
4058 return TEST_SKIPPED;
4061 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4062 return TEST_SKIPPED;
4064 /* Verify the capabilities */
4065 struct rte_cryptodev_sym_capability_idx cap_idx;
4066 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4067 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4068 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4070 return TEST_SKIPPED;
4072 /* Create SNOW 3G session */
4073 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4074 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4075 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4076 tdata->key.data, tdata->key.len,
4077 tdata->cipher_iv.len);
4081 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4083 /* Clear mbuf payload */
4084 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4085 rte_pktmbuf_tailroom(ut_params->ibuf));
4087 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4088 /* Append data which is padded to a multiple of */
4089 /* the algorithms block size */
4090 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4091 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4093 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4095 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4097 /* Create SNOW 3G operation */
4098 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4099 tdata->cipher_iv.len,
4100 tdata->validCipherLenInBits.len,
4105 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4106 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4107 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4109 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4111 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4113 ut_params->obuf = ut_params->op->sym->m_dst;
4114 if (ut_params->obuf)
4115 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4117 ciphertext = plaintext;
4119 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4122 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4124 tdata->ciphertext.data,
4125 tdata->validDataLenInBits.len,
4126 "SNOW 3G Ciphertext data not as expected");
4132 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4134 struct crypto_testsuite_params *ts_params = &testsuite_params;
4135 struct crypto_unittest_params *ut_params = &unittest_params;
4136 uint8_t *plaintext, *ciphertext;
4139 unsigned plaintext_pad_len;
4140 unsigned plaintext_len;
4142 /* Verify the capabilities */
4143 struct rte_cryptodev_sym_capability_idx cap_idx;
4144 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4145 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4146 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4148 return TEST_SKIPPED;
4150 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4151 return TEST_SKIPPED;
4153 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4154 return TEST_SKIPPED;
4156 /* Create SNOW 3G session */
4157 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4158 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4159 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4160 tdata->key.data, tdata->key.len,
4161 tdata->cipher_iv.len);
4165 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4166 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4168 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4169 "Failed to allocate input buffer in mempool");
4170 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4171 "Failed to allocate output buffer in mempool");
4173 /* Clear mbuf payload */
4174 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4175 rte_pktmbuf_tailroom(ut_params->ibuf));
4177 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4178 /* Append data which is padded to a multiple of */
4179 /* the algorithms block size */
4180 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4181 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4183 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4184 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4186 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4188 /* Create SNOW 3G operation */
4189 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4190 tdata->cipher_iv.len,
4191 tdata->validCipherLenInBits.len,
4196 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4198 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4200 ut_params->obuf = ut_params->op->sym->m_dst;
4201 if (ut_params->obuf)
4202 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4204 ciphertext = plaintext;
4206 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4209 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4211 tdata->ciphertext.data,
4212 tdata->validDataLenInBits.len,
4213 "SNOW 3G Ciphertext data not as expected");
4218 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4220 struct crypto_testsuite_params *ts_params = &testsuite_params;
4221 struct crypto_unittest_params *ut_params = &unittest_params;
4224 unsigned int plaintext_pad_len;
4225 unsigned int plaintext_len;
4226 uint8_t buffer[10000];
4227 const uint8_t *ciphertext;
4229 struct rte_cryptodev_info dev_info;
4231 /* Verify the capabilities */
4232 struct rte_cryptodev_sym_capability_idx cap_idx;
4233 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4234 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4235 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4237 return TEST_SKIPPED;
4239 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4240 return TEST_SKIPPED;
4242 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4243 return TEST_SKIPPED;
4245 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4247 uint64_t feat_flags = dev_info.feature_flags;
4249 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4250 printf("Device doesn't support out-of-place scatter-gather "
4251 "in both input and output mbufs. "
4253 return TEST_SKIPPED;
4256 /* Create SNOW 3G session */
4257 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4258 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4259 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4260 tdata->key.data, tdata->key.len,
4261 tdata->cipher_iv.len);
4265 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4266 /* Append data which is padded to a multiple of */
4267 /* the algorithms block size */
4268 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4270 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4271 plaintext_pad_len, 10, 0);
4272 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4273 plaintext_pad_len, 3, 0);
4275 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4276 "Failed to allocate input buffer in mempool");
4277 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4278 "Failed to allocate output buffer in mempool");
4280 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4282 /* Create SNOW 3G operation */
4283 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4284 tdata->cipher_iv.len,
4285 tdata->validCipherLenInBits.len,
4290 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4292 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4294 ut_params->obuf = ut_params->op->sym->m_dst;
4295 if (ut_params->obuf)
4296 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4297 plaintext_len, buffer);
4299 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4300 plaintext_len, buffer);
4302 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4305 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4307 tdata->ciphertext.data,
4308 tdata->validDataLenInBits.len,
4309 "SNOW 3G Ciphertext data not as expected");
4314 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4316 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4318 uint8_t curr_byte, prev_byte;
4319 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4320 uint8_t lower_byte_mask = (1 << offset) - 1;
4323 prev_byte = buffer[0];
4324 buffer[0] >>= offset;
4326 for (i = 1; i < length_in_bytes; i++) {
4327 curr_byte = buffer[i];
4328 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4329 (curr_byte >> offset);
4330 prev_byte = curr_byte;
4335 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4337 struct crypto_testsuite_params *ts_params = &testsuite_params;
4338 struct crypto_unittest_params *ut_params = &unittest_params;
4339 uint8_t *plaintext, *ciphertext;
4341 uint32_t plaintext_len;
4342 uint32_t plaintext_pad_len;
4343 uint8_t extra_offset = 4;
4344 uint8_t *expected_ciphertext_shifted;
4345 struct rte_cryptodev_info dev_info;
4347 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4348 uint64_t feat_flags = dev_info.feature_flags;
4350 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4351 ((tdata->validDataLenInBits.len % 8) != 0)) {
4352 printf("Device doesn't support NON-Byte Aligned Data.\n");
4353 return TEST_SKIPPED;
4356 /* Verify the capabilities */
4357 struct rte_cryptodev_sym_capability_idx cap_idx;
4358 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4359 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4360 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4362 return TEST_SKIPPED;
4364 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4365 return TEST_SKIPPED;
4367 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4368 return TEST_SKIPPED;
4370 /* Create SNOW 3G session */
4371 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4372 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4373 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4374 tdata->key.data, tdata->key.len,
4375 tdata->cipher_iv.len);
4379 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4380 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4382 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4383 "Failed to allocate input buffer in mempool");
4384 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4385 "Failed to allocate output buffer in mempool");
4387 /* Clear mbuf payload */
4388 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4389 rte_pktmbuf_tailroom(ut_params->ibuf));
4391 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4393 * Append data which is padded to a
4394 * multiple of the algorithms block size
4396 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4398 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4401 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4403 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4404 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4406 #ifdef RTE_APP_TEST_DEBUG
4407 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4409 /* Create SNOW 3G operation */
4410 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4411 tdata->cipher_iv.len,
4412 tdata->validCipherLenInBits.len,
4417 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4419 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4421 ut_params->obuf = ut_params->op->sym->m_dst;
4422 if (ut_params->obuf)
4423 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4425 ciphertext = plaintext;
4427 #ifdef RTE_APP_TEST_DEBUG
4428 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4431 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4433 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4434 "failed to reserve memory for ciphertext shifted\n");
4436 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4437 ceil_byte_length(tdata->ciphertext.len));
4438 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4441 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4443 expected_ciphertext_shifted,
4444 tdata->validDataLenInBits.len,
4446 "SNOW 3G Ciphertext data not as expected");
4450 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4452 struct crypto_testsuite_params *ts_params = &testsuite_params;
4453 struct crypto_unittest_params *ut_params = &unittest_params;
4457 uint8_t *plaintext, *ciphertext;
4458 unsigned ciphertext_pad_len;
4459 unsigned ciphertext_len;
4460 struct rte_cryptodev_info dev_info;
4462 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4463 uint64_t feat_flags = dev_info.feature_flags;
4465 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4466 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4467 printf("Device doesn't support RAW data-path APIs.\n");
4468 return TEST_SKIPPED;
4471 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4472 return TEST_SKIPPED;
4474 /* Verify the capabilities */
4475 struct rte_cryptodev_sym_capability_idx cap_idx;
4476 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4477 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4478 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4480 return TEST_SKIPPED;
4482 /* Create SNOW 3G session */
4483 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4484 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4485 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4486 tdata->key.data, tdata->key.len,
4487 tdata->cipher_iv.len);
4491 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4493 /* Clear mbuf payload */
4494 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4495 rte_pktmbuf_tailroom(ut_params->ibuf));
4497 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4498 /* Append data which is padded to a multiple of */
4499 /* the algorithms block size */
4500 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4501 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4502 ciphertext_pad_len);
4503 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4505 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4507 /* Create SNOW 3G operation */
4508 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4509 tdata->cipher_iv.len,
4510 tdata->validCipherLenInBits.len,
4511 tdata->cipher.offset_bits);
4515 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4516 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4517 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4519 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4521 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4522 ut_params->obuf = ut_params->op->sym->m_dst;
4523 if (ut_params->obuf)
4524 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4526 plaintext = ciphertext;
4528 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4531 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4532 tdata->plaintext.data,
4533 tdata->validDataLenInBits.len,
4534 "SNOW 3G Plaintext data not as expected");
4538 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4540 struct crypto_testsuite_params *ts_params = &testsuite_params;
4541 struct crypto_unittest_params *ut_params = &unittest_params;
4545 uint8_t *plaintext, *ciphertext;
4546 unsigned ciphertext_pad_len;
4547 unsigned ciphertext_len;
4549 /* Verify the capabilities */
4550 struct rte_cryptodev_sym_capability_idx cap_idx;
4551 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4552 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4553 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4555 return TEST_SKIPPED;
4557 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4558 return TEST_SKIPPED;
4560 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4561 return TEST_SKIPPED;
4563 /* Create SNOW 3G session */
4564 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4565 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4566 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4567 tdata->key.data, tdata->key.len,
4568 tdata->cipher_iv.len);
4572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4573 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4575 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4576 "Failed to allocate input buffer");
4577 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4578 "Failed to allocate output buffer");
4580 /* Clear mbuf payload */
4581 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4582 rte_pktmbuf_tailroom(ut_params->ibuf));
4584 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4585 rte_pktmbuf_tailroom(ut_params->obuf));
4587 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4588 /* Append data which is padded to a multiple of */
4589 /* the algorithms block size */
4590 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4591 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4592 ciphertext_pad_len);
4593 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4594 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4596 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4598 /* Create SNOW 3G operation */
4599 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4600 tdata->cipher_iv.len,
4601 tdata->validCipherLenInBits.len,
4606 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4608 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4609 ut_params->obuf = ut_params->op->sym->m_dst;
4610 if (ut_params->obuf)
4611 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4613 plaintext = ciphertext;
4615 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4618 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4619 tdata->plaintext.data,
4620 tdata->validDataLenInBits.len,
4621 "SNOW 3G Plaintext data not as expected");
4626 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4628 struct crypto_testsuite_params *ts_params = &testsuite_params;
4629 struct crypto_unittest_params *ut_params = &unittest_params;
4633 uint8_t *plaintext, *ciphertext;
4634 unsigned int plaintext_pad_len;
4635 unsigned int plaintext_len;
4637 struct rte_cryptodev_info dev_info;
4638 struct rte_cryptodev_sym_capability_idx cap_idx;
4640 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4641 uint64_t feat_flags = dev_info.feature_flags;
4643 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4644 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4645 (tdata->validDataLenInBits.len % 8 != 0))) {
4646 printf("Device doesn't support NON-Byte Aligned Data.\n");
4647 return TEST_SKIPPED;
4650 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4651 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4652 printf("Device doesn't support RAW data-path APIs.\n");
4653 return TEST_SKIPPED;
4656 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4657 return TEST_SKIPPED;
4659 /* Check if device supports ZUC EEA3 */
4660 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4661 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4663 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4665 return TEST_SKIPPED;
4667 /* Check if device supports ZUC EIA3 */
4668 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4669 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4671 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4673 return TEST_SKIPPED;
4675 /* Create ZUC session */
4676 retval = create_zuc_cipher_auth_encrypt_generate_session(
4677 ts_params->valid_devs[0],
4681 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4683 /* clear mbuf payload */
4684 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4685 rte_pktmbuf_tailroom(ut_params->ibuf));
4687 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4688 /* Append data which is padded to a multiple of */
4689 /* the algorithms block size */
4690 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4691 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4693 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4695 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4697 /* Create ZUC operation */
4698 retval = create_zuc_cipher_hash_generate_operation(tdata);
4702 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4703 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4704 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4706 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4708 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4709 ut_params->obuf = ut_params->op->sym->m_src;
4710 if (ut_params->obuf)
4711 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4713 ciphertext = plaintext;
4715 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4717 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4719 tdata->ciphertext.data,
4720 tdata->validDataLenInBits.len,
4721 "ZUC Ciphertext data not as expected");
4723 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4724 + plaintext_pad_len;
4727 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4731 "ZUC Generated auth tag not as expected");
4736 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4738 struct crypto_testsuite_params *ts_params = &testsuite_params;
4739 struct crypto_unittest_params *ut_params = &unittest_params;
4743 uint8_t *plaintext, *ciphertext;
4744 unsigned plaintext_pad_len;
4745 unsigned plaintext_len;
4746 struct rte_cryptodev_info dev_info;
4748 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4749 uint64_t feat_flags = dev_info.feature_flags;
4751 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4752 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4753 printf("Device doesn't support RAW data-path APIs.\n");
4754 return TEST_SKIPPED;
4757 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4758 return TEST_SKIPPED;
4760 /* Verify the capabilities */
4761 struct rte_cryptodev_sym_capability_idx cap_idx;
4762 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4763 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4764 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4766 return TEST_SKIPPED;
4767 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4768 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4769 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4771 return TEST_SKIPPED;
4773 /* Create SNOW 3G session */
4774 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4775 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4776 RTE_CRYPTO_AUTH_OP_GENERATE,
4777 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4778 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4779 tdata->key.data, tdata->key.len,
4780 tdata->auth_iv.len, tdata->digest.len,
4781 tdata->cipher_iv.len);
4784 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4786 /* clear mbuf payload */
4787 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4788 rte_pktmbuf_tailroom(ut_params->ibuf));
4790 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4791 /* Append data which is padded to a multiple of */
4792 /* the algorithms block size */
4793 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4794 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4796 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4798 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4800 /* Create SNOW 3G operation */
4801 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4802 tdata->digest.len, tdata->auth_iv.data,
4804 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4805 tdata->cipher_iv.data, tdata->cipher_iv.len,
4806 tdata->validCipherLenInBits.len,
4808 tdata->validAuthLenInBits.len,
4814 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4815 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4816 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4818 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4820 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4821 ut_params->obuf = ut_params->op->sym->m_src;
4822 if (ut_params->obuf)
4823 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4825 ciphertext = plaintext;
4827 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4829 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4831 tdata->ciphertext.data,
4832 tdata->validDataLenInBits.len,
4833 "SNOW 3G Ciphertext data not as expected");
4835 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4836 + plaintext_pad_len;
4839 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4842 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4843 "SNOW 3G Generated auth tag not as expected");
4848 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4849 uint8_t op_mode, uint8_t verify)
4851 struct crypto_testsuite_params *ts_params = &testsuite_params;
4852 struct crypto_unittest_params *ut_params = &unittest_params;
4856 uint8_t *plaintext = NULL, *ciphertext = NULL;
4857 unsigned int plaintext_pad_len;
4858 unsigned int plaintext_len;
4859 unsigned int ciphertext_pad_len;
4860 unsigned int ciphertext_len;
4862 struct rte_cryptodev_info dev_info;
4864 /* Verify the capabilities */
4865 struct rte_cryptodev_sym_capability_idx cap_idx;
4866 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4867 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4868 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4870 return TEST_SKIPPED;
4871 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4872 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4873 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4875 return TEST_SKIPPED;
4877 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4878 return TEST_SKIPPED;
4880 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4882 uint64_t feat_flags = dev_info.feature_flags;
4884 if (op_mode == OUT_OF_PLACE) {
4885 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4886 printf("Device doesn't support digest encrypted.\n");
4887 return TEST_SKIPPED;
4889 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4890 return TEST_SKIPPED;
4893 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4894 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4895 printf("Device doesn't support RAW data-path APIs.\n");
4896 return TEST_SKIPPED;
4899 /* Create SNOW 3G session */
4900 retval = create_wireless_algo_auth_cipher_session(
4901 ts_params->valid_devs[0],
4902 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4903 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4904 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4905 : RTE_CRYPTO_AUTH_OP_GENERATE),
4906 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4907 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4908 tdata->key.data, tdata->key.len,
4909 tdata->auth_iv.len, tdata->digest.len,
4910 tdata->cipher_iv.len);
4914 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4915 if (op_mode == OUT_OF_PLACE)
4916 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4918 /* clear mbuf payload */
4919 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4920 rte_pktmbuf_tailroom(ut_params->ibuf));
4921 if (op_mode == OUT_OF_PLACE)
4922 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4923 rte_pktmbuf_tailroom(ut_params->obuf));
4925 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4926 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4927 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4928 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4931 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4932 ciphertext_pad_len);
4933 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4934 if (op_mode == OUT_OF_PLACE)
4935 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4936 debug_hexdump(stdout, "ciphertext:", ciphertext,
4939 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4941 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4942 if (op_mode == OUT_OF_PLACE)
4943 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4944 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4947 /* Create SNOW 3G operation */
4948 retval = create_wireless_algo_auth_cipher_operation(
4949 tdata->digest.data, tdata->digest.len,
4950 tdata->cipher_iv.data, tdata->cipher_iv.len,
4951 tdata->auth_iv.data, tdata->auth_iv.len,
4952 (tdata->digest.offset_bytes == 0 ?
4953 (verify ? ciphertext_pad_len : plaintext_pad_len)
4954 : tdata->digest.offset_bytes),
4955 tdata->validCipherLenInBits.len,
4956 tdata->cipher.offset_bits,
4957 tdata->validAuthLenInBits.len,
4958 tdata->auth.offset_bits,
4959 op_mode, 0, verify);
4964 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4965 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4966 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4968 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4971 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4973 ut_params->obuf = (op_mode == IN_PLACE ?
4974 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4977 if (ut_params->obuf)
4978 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4981 plaintext = ciphertext +
4982 (tdata->cipher.offset_bits >> 3);
4984 debug_hexdump(stdout, "plaintext:", plaintext,
4985 (tdata->plaintext.len >> 3) - tdata->digest.len);
4986 debug_hexdump(stdout, "plaintext expected:",
4987 tdata->plaintext.data,
4988 (tdata->plaintext.len >> 3) - tdata->digest.len);
4990 if (ut_params->obuf)
4991 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4994 ciphertext = plaintext;
4996 debug_hexdump(stdout, "ciphertext:", ciphertext,
4998 debug_hexdump(stdout, "ciphertext expected:",
4999 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5001 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5002 + (tdata->digest.offset_bytes == 0 ?
5003 plaintext_pad_len : tdata->digest.offset_bytes);
5005 debug_hexdump(stdout, "digest:", ut_params->digest,
5007 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5013 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5015 tdata->plaintext.data,
5016 (tdata->plaintext.len - tdata->cipher.offset_bits -
5017 (tdata->digest.len << 3)),
5018 tdata->cipher.offset_bits,
5019 "SNOW 3G Plaintext data not as expected");
5021 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5023 tdata->ciphertext.data,
5024 (tdata->validDataLenInBits.len -
5025 tdata->cipher.offset_bits),
5026 tdata->cipher.offset_bits,
5027 "SNOW 3G Ciphertext data not as expected");
5029 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5032 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5033 "SNOW 3G Generated auth tag not as expected");
5039 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5040 uint8_t op_mode, uint8_t verify)
5042 struct crypto_testsuite_params *ts_params = &testsuite_params;
5043 struct crypto_unittest_params *ut_params = &unittest_params;
5047 const uint8_t *plaintext = NULL;
5048 const uint8_t *ciphertext = NULL;
5049 const uint8_t *digest = NULL;
5050 unsigned int plaintext_pad_len;
5051 unsigned int plaintext_len;
5052 unsigned int ciphertext_pad_len;
5053 unsigned int ciphertext_len;
5054 uint8_t buffer[10000];
5055 uint8_t digest_buffer[10000];
5057 struct rte_cryptodev_info dev_info;
5059 /* Verify the capabilities */
5060 struct rte_cryptodev_sym_capability_idx cap_idx;
5061 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5062 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5063 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5065 return TEST_SKIPPED;
5066 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5067 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5068 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5070 return TEST_SKIPPED;
5072 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5073 return TEST_SKIPPED;
5075 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5077 uint64_t feat_flags = dev_info.feature_flags;
5079 if (op_mode == IN_PLACE) {
5080 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5081 printf("Device doesn't support in-place scatter-gather "
5082 "in both input and output mbufs.\n");
5083 return TEST_SKIPPED;
5085 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5086 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5087 printf("Device doesn't support RAW data-path APIs.\n");
5088 return TEST_SKIPPED;
5091 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5092 return TEST_SKIPPED;
5093 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5094 printf("Device doesn't support out-of-place scatter-gather "
5095 "in both input and output mbufs.\n");
5096 return TEST_SKIPPED;
5098 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5099 printf("Device doesn't support digest encrypted.\n");
5100 return TEST_SKIPPED;
5104 /* Create SNOW 3G session */
5105 retval = create_wireless_algo_auth_cipher_session(
5106 ts_params->valid_devs[0],
5107 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5108 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5109 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5110 : RTE_CRYPTO_AUTH_OP_GENERATE),
5111 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5112 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5113 tdata->key.data, tdata->key.len,
5114 tdata->auth_iv.len, tdata->digest.len,
5115 tdata->cipher_iv.len);
5120 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5121 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5122 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5123 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5125 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5126 plaintext_pad_len, 15, 0);
5127 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5128 "Failed to allocate input buffer in mempool");
5130 if (op_mode == OUT_OF_PLACE) {
5131 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5132 plaintext_pad_len, 15, 0);
5133 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5134 "Failed to allocate output buffer in mempool");
5138 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5139 tdata->ciphertext.data);
5140 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5141 ciphertext_len, buffer);
5142 debug_hexdump(stdout, "ciphertext:", ciphertext,
5145 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5146 tdata->plaintext.data);
5147 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5148 plaintext_len, buffer);
5149 debug_hexdump(stdout, "plaintext:", plaintext,
5152 memset(buffer, 0, sizeof(buffer));
5154 /* Create SNOW 3G operation */
5155 retval = create_wireless_algo_auth_cipher_operation(
5156 tdata->digest.data, tdata->digest.len,
5157 tdata->cipher_iv.data, tdata->cipher_iv.len,
5158 tdata->auth_iv.data, tdata->auth_iv.len,
5159 (tdata->digest.offset_bytes == 0 ?
5160 (verify ? ciphertext_pad_len : plaintext_pad_len)
5161 : tdata->digest.offset_bytes),
5162 tdata->validCipherLenInBits.len,
5163 tdata->cipher.offset_bits,
5164 tdata->validAuthLenInBits.len,
5165 tdata->auth.offset_bits,
5166 op_mode, 1, verify);
5171 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5172 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5173 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5175 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5178 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5180 ut_params->obuf = (op_mode == IN_PLACE ?
5181 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5184 if (ut_params->obuf)
5185 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5186 plaintext_len, buffer);
5188 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5189 plaintext_len, buffer);
5191 debug_hexdump(stdout, "plaintext:", plaintext,
5192 (tdata->plaintext.len >> 3) - tdata->digest.len);
5193 debug_hexdump(stdout, "plaintext expected:",
5194 tdata->plaintext.data,
5195 (tdata->plaintext.len >> 3) - tdata->digest.len);
5197 if (ut_params->obuf)
5198 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5199 ciphertext_len, buffer);
5201 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5202 ciphertext_len, buffer);
5204 debug_hexdump(stdout, "ciphertext:", ciphertext,
5206 debug_hexdump(stdout, "ciphertext expected:",
5207 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5209 if (ut_params->obuf)
5210 digest = rte_pktmbuf_read(ut_params->obuf,
5211 (tdata->digest.offset_bytes == 0 ?
5212 plaintext_pad_len : tdata->digest.offset_bytes),
5213 tdata->digest.len, digest_buffer);
5215 digest = rte_pktmbuf_read(ut_params->ibuf,
5216 (tdata->digest.offset_bytes == 0 ?
5217 plaintext_pad_len : tdata->digest.offset_bytes),
5218 tdata->digest.len, digest_buffer);
5220 debug_hexdump(stdout, "digest:", digest,
5222 debug_hexdump(stdout, "digest expected:",
5223 tdata->digest.data, tdata->digest.len);
5228 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5230 tdata->plaintext.data,
5231 (tdata->plaintext.len - tdata->cipher.offset_bits -
5232 (tdata->digest.len << 3)),
5233 tdata->cipher.offset_bits,
5234 "SNOW 3G Plaintext data not as expected");
5236 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5238 tdata->ciphertext.data,
5239 (tdata->validDataLenInBits.len -
5240 tdata->cipher.offset_bits),
5241 tdata->cipher.offset_bits,
5242 "SNOW 3G Ciphertext data not as expected");
5244 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5247 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5248 "SNOW 3G Generated auth tag not as expected");
5254 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5255 uint8_t op_mode, uint8_t verify)
5257 struct crypto_testsuite_params *ts_params = &testsuite_params;
5258 struct crypto_unittest_params *ut_params = &unittest_params;
5262 uint8_t *plaintext = NULL, *ciphertext = NULL;
5263 unsigned int plaintext_pad_len;
5264 unsigned int plaintext_len;
5265 unsigned int ciphertext_pad_len;
5266 unsigned int ciphertext_len;
5268 struct rte_cryptodev_info dev_info;
5270 /* Verify the capabilities */
5271 struct rte_cryptodev_sym_capability_idx cap_idx;
5272 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5273 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5274 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5276 return TEST_SKIPPED;
5277 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5278 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5279 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5281 return TEST_SKIPPED;
5283 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5285 uint64_t feat_flags = dev_info.feature_flags;
5287 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5288 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5289 printf("Device doesn't support RAW data-path APIs.\n");
5290 return TEST_SKIPPED;
5293 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5294 return TEST_SKIPPED;
5296 if (op_mode == OUT_OF_PLACE) {
5297 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5298 return TEST_SKIPPED;
5299 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5300 printf("Device doesn't support digest encrypted.\n");
5301 return TEST_SKIPPED;
5305 /* Create KASUMI session */
5306 retval = create_wireless_algo_auth_cipher_session(
5307 ts_params->valid_devs[0],
5308 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5309 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5310 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5311 : RTE_CRYPTO_AUTH_OP_GENERATE),
5312 RTE_CRYPTO_AUTH_KASUMI_F9,
5313 RTE_CRYPTO_CIPHER_KASUMI_F8,
5314 tdata->key.data, tdata->key.len,
5315 0, tdata->digest.len,
5316 tdata->cipher_iv.len);
5321 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5322 if (op_mode == OUT_OF_PLACE)
5323 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5325 /* clear mbuf payload */
5326 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5327 rte_pktmbuf_tailroom(ut_params->ibuf));
5328 if (op_mode == OUT_OF_PLACE)
5329 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5330 rte_pktmbuf_tailroom(ut_params->obuf));
5332 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5333 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5334 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5335 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5338 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5339 ciphertext_pad_len);
5340 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5341 if (op_mode == OUT_OF_PLACE)
5342 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5343 debug_hexdump(stdout, "ciphertext:", ciphertext,
5346 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5348 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5349 if (op_mode == OUT_OF_PLACE)
5350 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5351 debug_hexdump(stdout, "plaintext:", plaintext,
5355 /* Create KASUMI operation */
5356 retval = create_wireless_algo_auth_cipher_operation(
5357 tdata->digest.data, tdata->digest.len,
5358 tdata->cipher_iv.data, tdata->cipher_iv.len,
5360 (tdata->digest.offset_bytes == 0 ?
5361 (verify ? ciphertext_pad_len : plaintext_pad_len)
5362 : tdata->digest.offset_bytes),
5363 tdata->validCipherLenInBits.len,
5364 tdata->validCipherOffsetInBits.len,
5365 tdata->validAuthLenInBits.len,
5367 op_mode, 0, verify);
5372 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5373 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5374 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5376 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5379 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5381 ut_params->obuf = (op_mode == IN_PLACE ?
5382 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5386 if (ut_params->obuf)
5387 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5390 plaintext = ciphertext;
5392 debug_hexdump(stdout, "plaintext:", plaintext,
5393 (tdata->plaintext.len >> 3) - tdata->digest.len);
5394 debug_hexdump(stdout, "plaintext expected:",
5395 tdata->plaintext.data,
5396 (tdata->plaintext.len >> 3) - tdata->digest.len);
5398 if (ut_params->obuf)
5399 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5402 ciphertext = plaintext;
5404 debug_hexdump(stdout, "ciphertext:", ciphertext,
5406 debug_hexdump(stdout, "ciphertext expected:",
5407 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5409 ut_params->digest = rte_pktmbuf_mtod(
5410 ut_params->obuf, uint8_t *) +
5411 (tdata->digest.offset_bytes == 0 ?
5412 plaintext_pad_len : tdata->digest.offset_bytes);
5414 debug_hexdump(stdout, "digest:", ut_params->digest,
5416 debug_hexdump(stdout, "digest expected:",
5417 tdata->digest.data, tdata->digest.len);
5422 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5424 tdata->plaintext.data,
5425 tdata->plaintext.len >> 3,
5426 "KASUMI Plaintext data not as expected");
5428 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5430 tdata->ciphertext.data,
5431 tdata->ciphertext.len >> 3,
5432 "KASUMI Ciphertext data not as expected");
5434 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5437 DIGEST_BYTE_LENGTH_KASUMI_F9,
5438 "KASUMI Generated auth tag not as expected");
5444 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5445 uint8_t op_mode, uint8_t verify)
5447 struct crypto_testsuite_params *ts_params = &testsuite_params;
5448 struct crypto_unittest_params *ut_params = &unittest_params;
5452 const uint8_t *plaintext = NULL;
5453 const uint8_t *ciphertext = NULL;
5454 const uint8_t *digest = NULL;
5455 unsigned int plaintext_pad_len;
5456 unsigned int plaintext_len;
5457 unsigned int ciphertext_pad_len;
5458 unsigned int ciphertext_len;
5459 uint8_t buffer[10000];
5460 uint8_t digest_buffer[10000];
5462 struct rte_cryptodev_info dev_info;
5464 /* Verify the capabilities */
5465 struct rte_cryptodev_sym_capability_idx cap_idx;
5466 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5467 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5468 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5470 return TEST_SKIPPED;
5471 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5472 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5473 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5475 return TEST_SKIPPED;
5477 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5478 return TEST_SKIPPED;
5480 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5482 uint64_t feat_flags = dev_info.feature_flags;
5484 if (op_mode == IN_PLACE) {
5485 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5486 printf("Device doesn't support in-place scatter-gather "
5487 "in both input and output mbufs.\n");
5488 return TEST_SKIPPED;
5490 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5491 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5492 printf("Device doesn't support RAW data-path APIs.\n");
5493 return TEST_SKIPPED;
5496 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5497 return TEST_SKIPPED;
5498 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5499 printf("Device doesn't support out-of-place scatter-gather "
5500 "in both input and output mbufs.\n");
5501 return TEST_SKIPPED;
5503 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5504 printf("Device doesn't support digest encrypted.\n");
5505 return TEST_SKIPPED;
5509 /* Create KASUMI session */
5510 retval = create_wireless_algo_auth_cipher_session(
5511 ts_params->valid_devs[0],
5512 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5513 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5514 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5515 : RTE_CRYPTO_AUTH_OP_GENERATE),
5516 RTE_CRYPTO_AUTH_KASUMI_F9,
5517 RTE_CRYPTO_CIPHER_KASUMI_F8,
5518 tdata->key.data, tdata->key.len,
5519 0, tdata->digest.len,
5520 tdata->cipher_iv.len);
5525 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5526 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5527 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5528 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5530 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5531 plaintext_pad_len, 15, 0);
5532 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5533 "Failed to allocate input buffer in mempool");
5535 if (op_mode == OUT_OF_PLACE) {
5536 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5537 plaintext_pad_len, 15, 0);
5538 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5539 "Failed to allocate output buffer in mempool");
5543 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5544 tdata->ciphertext.data);
5545 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5546 ciphertext_len, buffer);
5547 debug_hexdump(stdout, "ciphertext:", ciphertext,
5550 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5551 tdata->plaintext.data);
5552 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5553 plaintext_len, buffer);
5554 debug_hexdump(stdout, "plaintext:", plaintext,
5557 memset(buffer, 0, sizeof(buffer));
5559 /* Create KASUMI operation */
5560 retval = create_wireless_algo_auth_cipher_operation(
5561 tdata->digest.data, tdata->digest.len,
5562 tdata->cipher_iv.data, tdata->cipher_iv.len,
5564 (tdata->digest.offset_bytes == 0 ?
5565 (verify ? ciphertext_pad_len : plaintext_pad_len)
5566 : tdata->digest.offset_bytes),
5567 tdata->validCipherLenInBits.len,
5568 tdata->validCipherOffsetInBits.len,
5569 tdata->validAuthLenInBits.len,
5571 op_mode, 1, verify);
5576 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5577 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5578 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5580 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5583 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5585 ut_params->obuf = (op_mode == IN_PLACE ?
5586 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5589 if (ut_params->obuf)
5590 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5591 plaintext_len, buffer);
5593 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5594 plaintext_len, buffer);
5596 debug_hexdump(stdout, "plaintext:", plaintext,
5597 (tdata->plaintext.len >> 3) - tdata->digest.len);
5598 debug_hexdump(stdout, "plaintext expected:",
5599 tdata->plaintext.data,
5600 (tdata->plaintext.len >> 3) - tdata->digest.len);
5602 if (ut_params->obuf)
5603 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5604 ciphertext_len, buffer);
5606 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5607 ciphertext_len, buffer);
5609 debug_hexdump(stdout, "ciphertext:", ciphertext,
5611 debug_hexdump(stdout, "ciphertext expected:",
5612 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5614 if (ut_params->obuf)
5615 digest = rte_pktmbuf_read(ut_params->obuf,
5616 (tdata->digest.offset_bytes == 0 ?
5617 plaintext_pad_len : tdata->digest.offset_bytes),
5618 tdata->digest.len, digest_buffer);
5620 digest = rte_pktmbuf_read(ut_params->ibuf,
5621 (tdata->digest.offset_bytes == 0 ?
5622 plaintext_pad_len : tdata->digest.offset_bytes),
5623 tdata->digest.len, digest_buffer);
5625 debug_hexdump(stdout, "digest:", digest,
5627 debug_hexdump(stdout, "digest expected:",
5628 tdata->digest.data, tdata->digest.len);
5633 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5635 tdata->plaintext.data,
5636 tdata->plaintext.len >> 3,
5637 "KASUMI Plaintext data not as expected");
5639 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5641 tdata->ciphertext.data,
5642 tdata->validDataLenInBits.len,
5643 "KASUMI Ciphertext data not as expected");
5645 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5648 DIGEST_BYTE_LENGTH_KASUMI_F9,
5649 "KASUMI Generated auth tag not as expected");
5655 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5657 struct crypto_testsuite_params *ts_params = &testsuite_params;
5658 struct crypto_unittest_params *ut_params = &unittest_params;
5662 uint8_t *plaintext, *ciphertext;
5663 unsigned plaintext_pad_len;
5664 unsigned plaintext_len;
5665 struct rte_cryptodev_info dev_info;
5667 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5668 uint64_t feat_flags = dev_info.feature_flags;
5670 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5671 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5672 printf("Device doesn't support RAW data-path APIs.\n");
5673 return TEST_SKIPPED;
5676 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5677 return TEST_SKIPPED;
5679 /* Verify the capabilities */
5680 struct rte_cryptodev_sym_capability_idx cap_idx;
5681 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5682 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5683 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5685 return TEST_SKIPPED;
5686 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5687 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5688 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5690 return TEST_SKIPPED;
5692 /* Create KASUMI session */
5693 retval = create_wireless_algo_cipher_auth_session(
5694 ts_params->valid_devs[0],
5695 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5696 RTE_CRYPTO_AUTH_OP_GENERATE,
5697 RTE_CRYPTO_AUTH_KASUMI_F9,
5698 RTE_CRYPTO_CIPHER_KASUMI_F8,
5699 tdata->key.data, tdata->key.len,
5700 0, tdata->digest.len,
5701 tdata->cipher_iv.len);
5705 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5707 /* clear mbuf payload */
5708 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5709 rte_pktmbuf_tailroom(ut_params->ibuf));
5711 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5712 /* Append data which is padded to a multiple of */
5713 /* the algorithms block size */
5714 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5715 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5717 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5719 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5721 /* Create KASUMI operation */
5722 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5723 tdata->digest.len, NULL, 0,
5724 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5725 tdata->cipher_iv.data, tdata->cipher_iv.len,
5726 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5727 tdata->validCipherOffsetInBits.len,
5728 tdata->validAuthLenInBits.len,
5734 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5735 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5736 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5738 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5740 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5742 if (ut_params->op->sym->m_dst)
5743 ut_params->obuf = ut_params->op->sym->m_dst;
5745 ut_params->obuf = ut_params->op->sym->m_src;
5747 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5748 tdata->validCipherOffsetInBits.len >> 3);
5750 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5751 + plaintext_pad_len;
5753 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5754 (tdata->validCipherOffsetInBits.len >> 3);
5756 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5758 reference_ciphertext,
5759 tdata->validCipherLenInBits.len,
5760 "KASUMI Ciphertext data not as expected");
5763 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5766 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5767 "KASUMI Generated auth tag not as expected");
5772 test_zuc_encryption(const struct wireless_test_data *tdata)
5774 struct crypto_testsuite_params *ts_params = &testsuite_params;
5775 struct crypto_unittest_params *ut_params = &unittest_params;
5778 uint8_t *plaintext, *ciphertext;
5779 unsigned plaintext_pad_len;
5780 unsigned plaintext_len;
5781 struct rte_cryptodev_info dev_info;
5783 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5784 uint64_t feat_flags = dev_info.feature_flags;
5786 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5787 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5788 printf("Device doesn't support RAW data-path APIs.\n");
5789 return TEST_SKIPPED;
5792 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5793 return TEST_SKIPPED;
5795 struct rte_cryptodev_sym_capability_idx cap_idx;
5797 /* Check if device supports ZUC EEA3 */
5798 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5799 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5801 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5803 return TEST_SKIPPED;
5805 /* Create ZUC session */
5806 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5807 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5808 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5809 tdata->key.data, tdata->key.len,
5810 tdata->cipher_iv.len);
5814 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5816 /* Clear mbuf payload */
5817 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5818 rte_pktmbuf_tailroom(ut_params->ibuf));
5820 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5821 /* Append data which is padded to a multiple */
5822 /* of the algorithms block size */
5823 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5824 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5826 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5828 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5830 /* Create ZUC operation */
5831 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5832 tdata->cipher_iv.len,
5833 tdata->plaintext.len,
5838 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5839 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5840 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5842 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5844 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5846 ut_params->obuf = ut_params->op->sym->m_dst;
5847 if (ut_params->obuf)
5848 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5850 ciphertext = plaintext;
5852 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5855 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5857 tdata->ciphertext.data,
5858 tdata->validCipherLenInBits.len,
5859 "ZUC Ciphertext data not as expected");
5864 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5866 struct crypto_testsuite_params *ts_params = &testsuite_params;
5867 struct crypto_unittest_params *ut_params = &unittest_params;
5871 unsigned int plaintext_pad_len;
5872 unsigned int plaintext_len;
5873 const uint8_t *ciphertext;
5874 uint8_t ciphertext_buffer[2048];
5875 struct rte_cryptodev_info dev_info;
5877 struct rte_cryptodev_sym_capability_idx cap_idx;
5879 /* Check if device supports ZUC EEA3 */
5880 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5881 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5883 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5885 return TEST_SKIPPED;
5887 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5888 return TEST_SKIPPED;
5890 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5892 uint64_t feat_flags = dev_info.feature_flags;
5894 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5895 printf("Device doesn't support in-place scatter-gather. "
5897 return TEST_SKIPPED;
5900 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5901 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5902 printf("Device doesn't support RAW data-path APIs.\n");
5903 return TEST_SKIPPED;
5906 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5908 /* Append data which is padded to a multiple */
5909 /* of the algorithms block size */
5910 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5912 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5913 plaintext_pad_len, 10, 0);
5915 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5916 tdata->plaintext.data);
5918 /* Create ZUC session */
5919 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5920 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5921 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5922 tdata->key.data, tdata->key.len,
5923 tdata->cipher_iv.len);
5927 /* Clear mbuf payload */
5929 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5931 /* Create ZUC operation */
5932 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5933 tdata->cipher_iv.len, tdata->plaintext.len,
5938 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5939 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5940 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5942 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5944 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5946 ut_params->obuf = ut_params->op->sym->m_dst;
5947 if (ut_params->obuf)
5948 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5949 0, plaintext_len, ciphertext_buffer);
5951 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5952 0, plaintext_len, ciphertext_buffer);
5955 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5958 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5960 tdata->ciphertext.data,
5961 tdata->validCipherLenInBits.len,
5962 "ZUC Ciphertext data not as expected");
5968 test_zuc_authentication(const struct wireless_test_data *tdata)
5970 struct crypto_testsuite_params *ts_params = &testsuite_params;
5971 struct crypto_unittest_params *ut_params = &unittest_params;
5974 unsigned plaintext_pad_len;
5975 unsigned plaintext_len;
5978 struct rte_cryptodev_sym_capability_idx cap_idx;
5979 struct rte_cryptodev_info dev_info;
5981 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5982 uint64_t feat_flags = dev_info.feature_flags;
5984 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5985 (tdata->validAuthLenInBits.len % 8 != 0)) {
5986 printf("Device doesn't support NON-Byte Aligned Data.\n");
5987 return TEST_SKIPPED;
5990 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5991 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5992 printf("Device doesn't support RAW data-path APIs.\n");
5993 return TEST_SKIPPED;
5996 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5997 return TEST_SKIPPED;
5999 /* Check if device supports ZUC EIA3 */
6000 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6001 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6003 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6005 return TEST_SKIPPED;
6007 /* Create ZUC session */
6008 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6009 tdata->key.data, tdata->key.len,
6010 tdata->auth_iv.len, tdata->digest.len,
6011 RTE_CRYPTO_AUTH_OP_GENERATE,
6012 RTE_CRYPTO_AUTH_ZUC_EIA3);
6016 /* alloc mbuf and set payload */
6017 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6019 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6020 rte_pktmbuf_tailroom(ut_params->ibuf));
6022 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6023 /* Append data which is padded to a multiple of */
6024 /* the algorithms block size */
6025 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6026 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6028 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6030 /* Create ZUC operation */
6031 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6032 tdata->auth_iv.data, tdata->auth_iv.len,
6033 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6034 tdata->validAuthLenInBits.len,
6039 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6040 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6041 ut_params->op, 0, 1, 1, 0);
6043 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6045 ut_params->obuf = ut_params->op->sym->m_src;
6046 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6047 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6048 + plaintext_pad_len;
6051 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6055 "ZUC Generated auth tag not as expected");
6061 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6062 uint8_t op_mode, uint8_t verify)
6064 struct crypto_testsuite_params *ts_params = &testsuite_params;
6065 struct crypto_unittest_params *ut_params = &unittest_params;
6069 uint8_t *plaintext = NULL, *ciphertext = NULL;
6070 unsigned int plaintext_pad_len;
6071 unsigned int plaintext_len;
6072 unsigned int ciphertext_pad_len;
6073 unsigned int ciphertext_len;
6075 struct rte_cryptodev_info dev_info;
6076 struct rte_cryptodev_sym_capability_idx cap_idx;
6078 /* Check if device supports ZUC EIA3 */
6079 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6080 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6082 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6084 return TEST_SKIPPED;
6086 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6088 uint64_t feat_flags = dev_info.feature_flags;
6090 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6091 printf("Device doesn't support digest encrypted.\n");
6092 return TEST_SKIPPED;
6094 if (op_mode == IN_PLACE) {
6095 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6096 printf("Device doesn't support in-place scatter-gather "
6097 "in both input and output mbufs.\n");
6098 return TEST_SKIPPED;
6101 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6102 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6103 printf("Device doesn't support RAW data-path APIs.\n");
6104 return TEST_SKIPPED;
6107 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6108 return TEST_SKIPPED;
6109 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6110 printf("Device doesn't support out-of-place scatter-gather "
6111 "in both input and output mbufs.\n");
6112 return TEST_SKIPPED;
6116 /* Create ZUC session */
6117 retval = create_wireless_algo_auth_cipher_session(
6118 ts_params->valid_devs[0],
6119 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6120 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6121 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6122 : RTE_CRYPTO_AUTH_OP_GENERATE),
6123 RTE_CRYPTO_AUTH_ZUC_EIA3,
6124 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6125 tdata->key.data, tdata->key.len,
6126 tdata->auth_iv.len, tdata->digest.len,
6127 tdata->cipher_iv.len);
6132 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6133 if (op_mode == OUT_OF_PLACE)
6134 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6136 /* clear mbuf payload */
6137 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6138 rte_pktmbuf_tailroom(ut_params->ibuf));
6139 if (op_mode == OUT_OF_PLACE)
6140 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6141 rte_pktmbuf_tailroom(ut_params->obuf));
6143 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6144 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6145 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6146 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6149 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6150 ciphertext_pad_len);
6151 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6152 if (op_mode == OUT_OF_PLACE)
6153 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6154 debug_hexdump(stdout, "ciphertext:", ciphertext,
6157 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6159 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6160 if (op_mode == OUT_OF_PLACE)
6161 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6162 debug_hexdump(stdout, "plaintext:", plaintext,
6166 /* Create ZUC operation */
6167 retval = create_wireless_algo_auth_cipher_operation(
6168 tdata->digest.data, tdata->digest.len,
6169 tdata->cipher_iv.data, tdata->cipher_iv.len,
6170 tdata->auth_iv.data, tdata->auth_iv.len,
6171 (tdata->digest.offset_bytes == 0 ?
6172 (verify ? ciphertext_pad_len : plaintext_pad_len)
6173 : tdata->digest.offset_bytes),
6174 tdata->validCipherLenInBits.len,
6175 tdata->validCipherOffsetInBits.len,
6176 tdata->validAuthLenInBits.len,
6178 op_mode, 0, verify);
6183 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6184 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6185 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6187 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6190 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6192 ut_params->obuf = (op_mode == IN_PLACE ?
6193 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6197 if (ut_params->obuf)
6198 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6201 plaintext = ciphertext;
6203 debug_hexdump(stdout, "plaintext:", plaintext,
6204 (tdata->plaintext.len >> 3) - tdata->digest.len);
6205 debug_hexdump(stdout, "plaintext expected:",
6206 tdata->plaintext.data,
6207 (tdata->plaintext.len >> 3) - tdata->digest.len);
6209 if (ut_params->obuf)
6210 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6213 ciphertext = plaintext;
6215 debug_hexdump(stdout, "ciphertext:", ciphertext,
6217 debug_hexdump(stdout, "ciphertext expected:",
6218 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6220 ut_params->digest = rte_pktmbuf_mtod(
6221 ut_params->obuf, uint8_t *) +
6222 (tdata->digest.offset_bytes == 0 ?
6223 plaintext_pad_len : tdata->digest.offset_bytes);
6225 debug_hexdump(stdout, "digest:", ut_params->digest,
6227 debug_hexdump(stdout, "digest expected:",
6228 tdata->digest.data, tdata->digest.len);
6233 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6235 tdata->plaintext.data,
6236 tdata->plaintext.len >> 3,
6237 "ZUC Plaintext data not as expected");
6239 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6241 tdata->ciphertext.data,
6242 tdata->ciphertext.len >> 3,
6243 "ZUC Ciphertext data not as expected");
6245 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6248 DIGEST_BYTE_LENGTH_KASUMI_F9,
6249 "ZUC Generated auth tag not as expected");
6255 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6256 uint8_t op_mode, uint8_t verify)
6258 struct crypto_testsuite_params *ts_params = &testsuite_params;
6259 struct crypto_unittest_params *ut_params = &unittest_params;
6263 const uint8_t *plaintext = NULL;
6264 const uint8_t *ciphertext = NULL;
6265 const uint8_t *digest = NULL;
6266 unsigned int plaintext_pad_len;
6267 unsigned int plaintext_len;
6268 unsigned int ciphertext_pad_len;
6269 unsigned int ciphertext_len;
6270 uint8_t buffer[10000];
6271 uint8_t digest_buffer[10000];
6273 struct rte_cryptodev_info dev_info;
6274 struct rte_cryptodev_sym_capability_idx cap_idx;
6276 /* Check if device supports ZUC EIA3 */
6277 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6278 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6280 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6282 return TEST_SKIPPED;
6284 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6286 uint64_t feat_flags = dev_info.feature_flags;
6288 if (op_mode == IN_PLACE) {
6289 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6290 printf("Device doesn't support in-place scatter-gather "
6291 "in both input and output mbufs.\n");
6292 return TEST_SKIPPED;
6295 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6296 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6297 printf("Device doesn't support RAW data-path APIs.\n");
6298 return TEST_SKIPPED;
6301 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6302 return TEST_SKIPPED;
6303 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6304 printf("Device doesn't support out-of-place scatter-gather "
6305 "in both input and output mbufs.\n");
6306 return TEST_SKIPPED;
6308 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6309 printf("Device doesn't support digest encrypted.\n");
6310 return TEST_SKIPPED;
6314 /* Create ZUC session */
6315 retval = create_wireless_algo_auth_cipher_session(
6316 ts_params->valid_devs[0],
6317 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6318 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6319 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6320 : RTE_CRYPTO_AUTH_OP_GENERATE),
6321 RTE_CRYPTO_AUTH_ZUC_EIA3,
6322 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6323 tdata->key.data, tdata->key.len,
6324 tdata->auth_iv.len, tdata->digest.len,
6325 tdata->cipher_iv.len);
6330 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6331 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6332 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6333 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6335 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6336 plaintext_pad_len, 15, 0);
6337 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6338 "Failed to allocate input buffer in mempool");
6340 if (op_mode == OUT_OF_PLACE) {
6341 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6342 plaintext_pad_len, 15, 0);
6343 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6344 "Failed to allocate output buffer in mempool");
6348 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6349 tdata->ciphertext.data);
6350 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6351 ciphertext_len, buffer);
6352 debug_hexdump(stdout, "ciphertext:", ciphertext,
6355 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6356 tdata->plaintext.data);
6357 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6358 plaintext_len, buffer);
6359 debug_hexdump(stdout, "plaintext:", plaintext,
6362 memset(buffer, 0, sizeof(buffer));
6364 /* Create ZUC operation */
6365 retval = create_wireless_algo_auth_cipher_operation(
6366 tdata->digest.data, tdata->digest.len,
6367 tdata->cipher_iv.data, tdata->cipher_iv.len,
6369 (tdata->digest.offset_bytes == 0 ?
6370 (verify ? ciphertext_pad_len : plaintext_pad_len)
6371 : tdata->digest.offset_bytes),
6372 tdata->validCipherLenInBits.len,
6373 tdata->validCipherOffsetInBits.len,
6374 tdata->validAuthLenInBits.len,
6376 op_mode, 1, verify);
6381 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6382 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6383 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6385 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6388 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6390 ut_params->obuf = (op_mode == IN_PLACE ?
6391 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6394 if (ut_params->obuf)
6395 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6396 plaintext_len, buffer);
6398 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6399 plaintext_len, buffer);
6401 debug_hexdump(stdout, "plaintext:", plaintext,
6402 (tdata->plaintext.len >> 3) - tdata->digest.len);
6403 debug_hexdump(stdout, "plaintext expected:",
6404 tdata->plaintext.data,
6405 (tdata->plaintext.len >> 3) - tdata->digest.len);
6407 if (ut_params->obuf)
6408 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6409 ciphertext_len, buffer);
6411 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6412 ciphertext_len, buffer);
6414 debug_hexdump(stdout, "ciphertext:", ciphertext,
6416 debug_hexdump(stdout, "ciphertext expected:",
6417 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6419 if (ut_params->obuf)
6420 digest = rte_pktmbuf_read(ut_params->obuf,
6421 (tdata->digest.offset_bytes == 0 ?
6422 plaintext_pad_len : tdata->digest.offset_bytes),
6423 tdata->digest.len, digest_buffer);
6425 digest = rte_pktmbuf_read(ut_params->ibuf,
6426 (tdata->digest.offset_bytes == 0 ?
6427 plaintext_pad_len : tdata->digest.offset_bytes),
6428 tdata->digest.len, digest_buffer);
6430 debug_hexdump(stdout, "digest:", digest,
6432 debug_hexdump(stdout, "digest expected:",
6433 tdata->digest.data, tdata->digest.len);
6438 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6440 tdata->plaintext.data,
6441 tdata->plaintext.len >> 3,
6442 "ZUC Plaintext data not as expected");
6444 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6446 tdata->ciphertext.data,
6447 tdata->validDataLenInBits.len,
6448 "ZUC Ciphertext data not as expected");
6450 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6453 DIGEST_BYTE_LENGTH_KASUMI_F9,
6454 "ZUC Generated auth tag not as expected");
6460 test_kasumi_encryption_test_case_1(void)
6462 return test_kasumi_encryption(&kasumi_test_case_1);
6466 test_kasumi_encryption_test_case_1_sgl(void)
6468 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6472 test_kasumi_encryption_test_case_1_oop(void)
6474 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6478 test_kasumi_encryption_test_case_1_oop_sgl(void)
6480 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6484 test_kasumi_encryption_test_case_2(void)
6486 return test_kasumi_encryption(&kasumi_test_case_2);
6490 test_kasumi_encryption_test_case_3(void)
6492 return test_kasumi_encryption(&kasumi_test_case_3);
6496 test_kasumi_encryption_test_case_4(void)
6498 return test_kasumi_encryption(&kasumi_test_case_4);
6502 test_kasumi_encryption_test_case_5(void)
6504 return test_kasumi_encryption(&kasumi_test_case_5);
6508 test_kasumi_decryption_test_case_1(void)
6510 return test_kasumi_decryption(&kasumi_test_case_1);
6514 test_kasumi_decryption_test_case_1_oop(void)
6516 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6520 test_kasumi_decryption_test_case_2(void)
6522 return test_kasumi_decryption(&kasumi_test_case_2);
6526 test_kasumi_decryption_test_case_3(void)
6528 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6529 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6530 return TEST_SKIPPED;
6531 return test_kasumi_decryption(&kasumi_test_case_3);
6535 test_kasumi_decryption_test_case_4(void)
6537 return test_kasumi_decryption(&kasumi_test_case_4);
6541 test_kasumi_decryption_test_case_5(void)
6543 return test_kasumi_decryption(&kasumi_test_case_5);
6546 test_snow3g_encryption_test_case_1(void)
6548 return test_snow3g_encryption(&snow3g_test_case_1);
6552 test_snow3g_encryption_test_case_1_oop(void)
6554 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6558 test_snow3g_encryption_test_case_1_oop_sgl(void)
6560 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6565 test_snow3g_encryption_test_case_1_offset_oop(void)
6567 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6571 test_snow3g_encryption_test_case_2(void)
6573 return test_snow3g_encryption(&snow3g_test_case_2);
6577 test_snow3g_encryption_test_case_3(void)
6579 return test_snow3g_encryption(&snow3g_test_case_3);
6583 test_snow3g_encryption_test_case_4(void)
6585 return test_snow3g_encryption(&snow3g_test_case_4);
6589 test_snow3g_encryption_test_case_5(void)
6591 return test_snow3g_encryption(&snow3g_test_case_5);
6595 test_snow3g_decryption_test_case_1(void)
6597 return test_snow3g_decryption(&snow3g_test_case_1);
6601 test_snow3g_decryption_test_case_1_oop(void)
6603 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6607 test_snow3g_decryption_test_case_2(void)
6609 return test_snow3g_decryption(&snow3g_test_case_2);
6613 test_snow3g_decryption_test_case_3(void)
6615 return test_snow3g_decryption(&snow3g_test_case_3);
6619 test_snow3g_decryption_test_case_4(void)
6621 return test_snow3g_decryption(&snow3g_test_case_4);
6625 test_snow3g_decryption_test_case_5(void)
6627 return test_snow3g_decryption(&snow3g_test_case_5);
6631 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6632 * Pattern digest from snow3g_test_data must be allocated as
6633 * 4 last bytes in plaintext.
6636 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6637 struct snow3g_hash_test_data *output)
6639 if ((pattern != NULL) && (output != NULL)) {
6640 output->key.len = pattern->key.len;
6642 memcpy(output->key.data,
6643 pattern->key.data, pattern->key.len);
6645 output->auth_iv.len = pattern->auth_iv.len;
6647 memcpy(output->auth_iv.data,
6648 pattern->auth_iv.data, pattern->auth_iv.len);
6650 output->plaintext.len = pattern->plaintext.len;
6652 memcpy(output->plaintext.data,
6653 pattern->plaintext.data, pattern->plaintext.len >> 3);
6655 output->digest.len = pattern->digest.len;
6657 memcpy(output->digest.data,
6658 &pattern->plaintext.data[pattern->digest.offset_bytes],
6659 pattern->digest.len);
6661 output->validAuthLenInBits.len =
6662 pattern->validAuthLenInBits.len;
6667 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6670 test_snow3g_decryption_with_digest_test_case_1(void)
6672 struct snow3g_hash_test_data snow3g_hash_data;
6673 struct rte_cryptodev_info dev_info;
6674 struct crypto_testsuite_params *ts_params = &testsuite_params;
6676 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6677 uint64_t feat_flags = dev_info.feature_flags;
6679 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6680 printf("Device doesn't support encrypted digest operations.\n");
6681 return TEST_SKIPPED;
6685 * Function prepare data for hash veryfication test case.
6686 * Digest is allocated in 4 last bytes in plaintext, pattern.
6688 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6690 return test_snow3g_decryption(&snow3g_test_case_7) &
6691 test_snow3g_authentication_verify(&snow3g_hash_data);
6695 test_snow3g_cipher_auth_test_case_1(void)
6697 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6701 test_snow3g_auth_cipher_test_case_1(void)
6703 return test_snow3g_auth_cipher(
6704 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6708 test_snow3g_auth_cipher_test_case_2(void)
6710 return test_snow3g_auth_cipher(
6711 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6715 test_snow3g_auth_cipher_test_case_2_oop(void)
6717 return test_snow3g_auth_cipher(
6718 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6722 test_snow3g_auth_cipher_part_digest_enc(void)
6724 return test_snow3g_auth_cipher(
6725 &snow3g_auth_cipher_partial_digest_encryption,
6730 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6732 return test_snow3g_auth_cipher(
6733 &snow3g_auth_cipher_partial_digest_encryption,
6738 test_snow3g_auth_cipher_test_case_3_sgl(void)
6740 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6741 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6742 return TEST_SKIPPED;
6743 return test_snow3g_auth_cipher_sgl(
6744 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6748 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6750 return test_snow3g_auth_cipher_sgl(
6751 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6755 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6757 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6758 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6759 return TEST_SKIPPED;
6760 return test_snow3g_auth_cipher_sgl(
6761 &snow3g_auth_cipher_partial_digest_encryption,
6766 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6768 return test_snow3g_auth_cipher_sgl(
6769 &snow3g_auth_cipher_partial_digest_encryption,
6774 test_snow3g_auth_cipher_verify_test_case_1(void)
6776 return test_snow3g_auth_cipher(
6777 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6781 test_snow3g_auth_cipher_verify_test_case_2(void)
6783 return test_snow3g_auth_cipher(
6784 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6788 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6790 return test_snow3g_auth_cipher(
6791 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6795 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6797 return test_snow3g_auth_cipher(
6798 &snow3g_auth_cipher_partial_digest_encryption,
6803 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6805 return test_snow3g_auth_cipher(
6806 &snow3g_auth_cipher_partial_digest_encryption,
6811 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6813 return test_snow3g_auth_cipher_sgl(
6814 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6818 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6820 return test_snow3g_auth_cipher_sgl(
6821 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6825 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6827 return test_snow3g_auth_cipher_sgl(
6828 &snow3g_auth_cipher_partial_digest_encryption,
6833 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6835 return test_snow3g_auth_cipher_sgl(
6836 &snow3g_auth_cipher_partial_digest_encryption,
6841 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6843 return test_snow3g_auth_cipher(
6844 &snow3g_test_case_7, IN_PLACE, 0);
6848 test_kasumi_auth_cipher_test_case_1(void)
6850 return test_kasumi_auth_cipher(
6851 &kasumi_test_case_3, IN_PLACE, 0);
6855 test_kasumi_auth_cipher_test_case_2(void)
6857 return test_kasumi_auth_cipher(
6858 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6862 test_kasumi_auth_cipher_test_case_2_oop(void)
6864 return test_kasumi_auth_cipher(
6865 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6869 test_kasumi_auth_cipher_test_case_2_sgl(void)
6871 return test_kasumi_auth_cipher_sgl(
6872 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6876 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6878 return test_kasumi_auth_cipher_sgl(
6879 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6883 test_kasumi_auth_cipher_verify_test_case_1(void)
6885 return test_kasumi_auth_cipher(
6886 &kasumi_test_case_3, IN_PLACE, 1);
6890 test_kasumi_auth_cipher_verify_test_case_2(void)
6892 return test_kasumi_auth_cipher(
6893 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6897 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6899 return test_kasumi_auth_cipher(
6900 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6904 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6906 return test_kasumi_auth_cipher_sgl(
6907 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6911 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6913 return test_kasumi_auth_cipher_sgl(
6914 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6918 test_kasumi_cipher_auth_test_case_1(void)
6920 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6924 test_zuc_encryption_test_case_1(void)
6926 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6930 test_zuc_encryption_test_case_2(void)
6932 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6936 test_zuc_encryption_test_case_3(void)
6938 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6942 test_zuc_encryption_test_case_4(void)
6944 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6948 test_zuc_encryption_test_case_5(void)
6950 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6954 test_zuc_encryption_test_case_6_sgl(void)
6956 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6960 test_zuc_hash_generate_test_case_1(void)
6962 return test_zuc_authentication(&zuc_test_case_auth_1b);
6966 test_zuc_hash_generate_test_case_2(void)
6968 return test_zuc_authentication(&zuc_test_case_auth_90b);
6972 test_zuc_hash_generate_test_case_3(void)
6974 return test_zuc_authentication(&zuc_test_case_auth_577b);
6978 test_zuc_hash_generate_test_case_4(void)
6980 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6984 test_zuc_hash_generate_test_case_5(void)
6986 return test_zuc_authentication(&zuc_test_auth_5670b);
6990 test_zuc_hash_generate_test_case_6(void)
6992 return test_zuc_authentication(&zuc_test_case_auth_128b);
6996 test_zuc_hash_generate_test_case_7(void)
6998 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7002 test_zuc_hash_generate_test_case_8(void)
7004 return test_zuc_authentication(&zuc_test_case_auth_584b);
7008 test_zuc_cipher_auth_test_case_1(void)
7010 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7014 test_zuc_cipher_auth_test_case_2(void)
7016 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7020 test_zuc_auth_cipher_test_case_1(void)
7022 return test_zuc_auth_cipher(
7023 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7027 test_zuc_auth_cipher_test_case_1_oop(void)
7029 return test_zuc_auth_cipher(
7030 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7034 test_zuc_auth_cipher_test_case_1_sgl(void)
7036 return test_zuc_auth_cipher_sgl(
7037 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7041 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7043 return test_zuc_auth_cipher_sgl(
7044 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7048 test_zuc_auth_cipher_verify_test_case_1(void)
7050 return test_zuc_auth_cipher(
7051 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7055 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7057 return test_zuc_auth_cipher(
7058 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7062 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7064 return test_zuc_auth_cipher_sgl(
7065 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7069 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7071 return test_zuc_auth_cipher_sgl(
7072 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7076 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7078 uint8_t dev_id = testsuite_params.valid_devs[0];
7080 struct rte_cryptodev_sym_capability_idx cap_idx;
7082 /* Check if device supports particular cipher algorithm */
7083 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7084 cap_idx.algo.cipher = tdata->cipher_algo;
7085 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7086 return TEST_SKIPPED;
7088 /* Check if device supports particular hash algorithm */
7089 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7090 cap_idx.algo.auth = tdata->auth_algo;
7091 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7092 return TEST_SKIPPED;
7098 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7099 uint8_t op_mode, uint8_t verify)
7101 struct crypto_testsuite_params *ts_params = &testsuite_params;
7102 struct crypto_unittest_params *ut_params = &unittest_params;
7106 uint8_t *plaintext = NULL, *ciphertext = NULL;
7107 unsigned int plaintext_pad_len;
7108 unsigned int plaintext_len;
7109 unsigned int ciphertext_pad_len;
7110 unsigned int ciphertext_len;
7112 struct rte_cryptodev_info dev_info;
7113 struct rte_crypto_op *op;
7115 /* Check if device supports particular algorithms separately */
7116 if (test_mixed_check_if_unsupported(tdata))
7117 return TEST_SKIPPED;
7118 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7119 return TEST_SKIPPED;
7121 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7123 uint64_t feat_flags = dev_info.feature_flags;
7125 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7126 printf("Device doesn't support digest encrypted.\n");
7127 return TEST_SKIPPED;
7130 /* Create the session */
7132 retval = create_wireless_algo_cipher_auth_session(
7133 ts_params->valid_devs[0],
7134 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7135 RTE_CRYPTO_AUTH_OP_VERIFY,
7138 tdata->auth_key.data, tdata->auth_key.len,
7139 tdata->auth_iv.len, tdata->digest_enc.len,
7140 tdata->cipher_iv.len);
7142 retval = create_wireless_algo_auth_cipher_session(
7143 ts_params->valid_devs[0],
7144 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7145 RTE_CRYPTO_AUTH_OP_GENERATE,
7148 tdata->auth_key.data, tdata->auth_key.len,
7149 tdata->auth_iv.len, tdata->digest_enc.len,
7150 tdata->cipher_iv.len);
7154 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7155 if (op_mode == OUT_OF_PLACE)
7156 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7158 /* clear mbuf payload */
7159 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7160 rte_pktmbuf_tailroom(ut_params->ibuf));
7161 if (op_mode == OUT_OF_PLACE) {
7163 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7164 rte_pktmbuf_tailroom(ut_params->obuf));
7167 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7168 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7169 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7170 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7173 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7174 ciphertext_pad_len);
7175 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7176 if (op_mode == OUT_OF_PLACE)
7177 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7178 debug_hexdump(stdout, "ciphertext:", ciphertext,
7181 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7183 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7184 if (op_mode == OUT_OF_PLACE)
7185 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7186 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7189 /* Create the operation */
7190 retval = create_wireless_algo_auth_cipher_operation(
7191 tdata->digest_enc.data, tdata->digest_enc.len,
7192 tdata->cipher_iv.data, tdata->cipher_iv.len,
7193 tdata->auth_iv.data, tdata->auth_iv.len,
7194 (tdata->digest_enc.offset == 0 ?
7196 : tdata->digest_enc.offset),
7197 tdata->validCipherLen.len_bits,
7198 tdata->cipher.offset_bits,
7199 tdata->validAuthLen.len_bits,
7200 tdata->auth.offset_bits,
7201 op_mode, 0, verify);
7206 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7208 /* Check if the op failed because the device doesn't */
7209 /* support this particular combination of algorithms */
7210 if (op == NULL && ut_params->op->status ==
7211 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7212 printf("Device doesn't support this mixed combination. "
7214 return TEST_SKIPPED;
7218 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7220 ut_params->obuf = (op_mode == IN_PLACE ?
7221 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7224 if (ut_params->obuf)
7225 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7228 plaintext = ciphertext +
7229 (tdata->cipher.offset_bits >> 3);
7231 debug_hexdump(stdout, "plaintext:", plaintext,
7232 tdata->plaintext.len_bits >> 3);
7233 debug_hexdump(stdout, "plaintext expected:",
7234 tdata->plaintext.data,
7235 tdata->plaintext.len_bits >> 3);
7237 if (ut_params->obuf)
7238 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7241 ciphertext = plaintext;
7243 debug_hexdump(stdout, "ciphertext:", ciphertext,
7245 debug_hexdump(stdout, "ciphertext expected:",
7246 tdata->ciphertext.data,
7247 tdata->ciphertext.len_bits >> 3);
7249 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7250 + (tdata->digest_enc.offset == 0 ?
7251 plaintext_pad_len : tdata->digest_enc.offset);
7253 debug_hexdump(stdout, "digest:", ut_params->digest,
7254 tdata->digest_enc.len);
7255 debug_hexdump(stdout, "digest expected:",
7256 tdata->digest_enc.data,
7257 tdata->digest_enc.len);
7262 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7264 tdata->plaintext.data,
7265 tdata->plaintext.len_bits >> 3,
7266 "Plaintext data not as expected");
7268 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7270 tdata->ciphertext.data,
7271 tdata->validDataLen.len_bits,
7272 "Ciphertext data not as expected");
7274 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7276 tdata->digest_enc.data,
7277 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7278 "Generated auth tag not as expected");
7281 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7282 "crypto op processing failed");
7288 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7289 uint8_t op_mode, uint8_t verify)
7291 struct crypto_testsuite_params *ts_params = &testsuite_params;
7292 struct crypto_unittest_params *ut_params = &unittest_params;
7296 const uint8_t *plaintext = NULL;
7297 const uint8_t *ciphertext = NULL;
7298 const uint8_t *digest = NULL;
7299 unsigned int plaintext_pad_len;
7300 unsigned int plaintext_len;
7301 unsigned int ciphertext_pad_len;
7302 unsigned int ciphertext_len;
7303 uint8_t buffer[10000];
7304 uint8_t digest_buffer[10000];
7306 struct rte_cryptodev_info dev_info;
7307 struct rte_crypto_op *op;
7309 /* Check if device supports particular algorithms */
7310 if (test_mixed_check_if_unsupported(tdata))
7311 return TEST_SKIPPED;
7312 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7313 return TEST_SKIPPED;
7315 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7317 uint64_t feat_flags = dev_info.feature_flags;
7319 if (op_mode == IN_PLACE) {
7320 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7321 printf("Device doesn't support in-place scatter-gather "
7322 "in both input and output mbufs.\n");
7323 return TEST_SKIPPED;
7326 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7327 printf("Device doesn't support out-of-place scatter-gather "
7328 "in both input and output mbufs.\n");
7329 return TEST_SKIPPED;
7331 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7332 printf("Device doesn't support digest encrypted.\n");
7333 return TEST_SKIPPED;
7337 /* Create the session */
7339 retval = create_wireless_algo_cipher_auth_session(
7340 ts_params->valid_devs[0],
7341 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7342 RTE_CRYPTO_AUTH_OP_VERIFY,
7345 tdata->auth_key.data, tdata->auth_key.len,
7346 tdata->auth_iv.len, tdata->digest_enc.len,
7347 tdata->cipher_iv.len);
7349 retval = create_wireless_algo_auth_cipher_session(
7350 ts_params->valid_devs[0],
7351 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7352 RTE_CRYPTO_AUTH_OP_GENERATE,
7355 tdata->auth_key.data, tdata->auth_key.len,
7356 tdata->auth_iv.len, tdata->digest_enc.len,
7357 tdata->cipher_iv.len);
7361 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7362 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7363 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7364 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7366 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7367 ciphertext_pad_len, 15, 0);
7368 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7369 "Failed to allocate input buffer in mempool");
7371 if (op_mode == OUT_OF_PLACE) {
7372 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7373 plaintext_pad_len, 15, 0);
7374 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7375 "Failed to allocate output buffer in mempool");
7379 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7380 tdata->ciphertext.data);
7381 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7382 ciphertext_len, buffer);
7383 debug_hexdump(stdout, "ciphertext:", ciphertext,
7386 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7387 tdata->plaintext.data);
7388 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7389 plaintext_len, buffer);
7390 debug_hexdump(stdout, "plaintext:", plaintext,
7393 memset(buffer, 0, sizeof(buffer));
7395 /* Create the operation */
7396 retval = create_wireless_algo_auth_cipher_operation(
7397 tdata->digest_enc.data, tdata->digest_enc.len,
7398 tdata->cipher_iv.data, tdata->cipher_iv.len,
7399 tdata->auth_iv.data, tdata->auth_iv.len,
7400 (tdata->digest_enc.offset == 0 ?
7402 : tdata->digest_enc.offset),
7403 tdata->validCipherLen.len_bits,
7404 tdata->cipher.offset_bits,
7405 tdata->validAuthLen.len_bits,
7406 tdata->auth.offset_bits,
7407 op_mode, 1, verify);
7412 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7414 /* Check if the op failed because the device doesn't */
7415 /* support this particular combination of algorithms */
7416 if (op == NULL && ut_params->op->status ==
7417 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7418 printf("Device doesn't support this mixed combination. "
7420 return TEST_SKIPPED;
7424 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7426 ut_params->obuf = (op_mode == IN_PLACE ?
7427 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7430 if (ut_params->obuf)
7431 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7432 plaintext_len, buffer);
7434 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7435 plaintext_len, buffer);
7437 debug_hexdump(stdout, "plaintext:", plaintext,
7438 (tdata->plaintext.len_bits >> 3) -
7439 tdata->digest_enc.len);
7440 debug_hexdump(stdout, "plaintext expected:",
7441 tdata->plaintext.data,
7442 (tdata->plaintext.len_bits >> 3) -
7443 tdata->digest_enc.len);
7445 if (ut_params->obuf)
7446 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7447 ciphertext_len, buffer);
7449 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7450 ciphertext_len, buffer);
7452 debug_hexdump(stdout, "ciphertext:", ciphertext,
7454 debug_hexdump(stdout, "ciphertext expected:",
7455 tdata->ciphertext.data,
7456 tdata->ciphertext.len_bits >> 3);
7458 if (ut_params->obuf)
7459 digest = rte_pktmbuf_read(ut_params->obuf,
7460 (tdata->digest_enc.offset == 0 ?
7462 tdata->digest_enc.offset),
7463 tdata->digest_enc.len, digest_buffer);
7465 digest = rte_pktmbuf_read(ut_params->ibuf,
7466 (tdata->digest_enc.offset == 0 ?
7468 tdata->digest_enc.offset),
7469 tdata->digest_enc.len, digest_buffer);
7471 debug_hexdump(stdout, "digest:", digest,
7472 tdata->digest_enc.len);
7473 debug_hexdump(stdout, "digest expected:",
7474 tdata->digest_enc.data, tdata->digest_enc.len);
7479 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7481 tdata->plaintext.data,
7482 tdata->plaintext.len_bits >> 3,
7483 "Plaintext data not as expected");
7485 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7487 tdata->ciphertext.data,
7488 tdata->validDataLen.len_bits,
7489 "Ciphertext data not as expected");
7490 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7492 tdata->digest_enc.data,
7493 tdata->digest_enc.len,
7494 "Generated auth tag not as expected");
7497 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7498 "crypto op processing failed");
7503 /** AUTH AES CMAC + CIPHER AES CTR */
7506 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7508 return test_mixed_auth_cipher(
7509 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7513 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7515 return test_mixed_auth_cipher(
7516 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7520 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7522 return test_mixed_auth_cipher_sgl(
7523 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7527 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7529 return test_mixed_auth_cipher_sgl(
7530 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7534 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7536 return test_mixed_auth_cipher(
7537 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7541 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7543 return test_mixed_auth_cipher(
7544 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7548 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7550 return test_mixed_auth_cipher_sgl(
7551 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7555 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7557 return test_mixed_auth_cipher_sgl(
7558 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7561 /** MIXED AUTH + CIPHER */
7564 test_auth_zuc_cipher_snow_test_case_1(void)
7566 return test_mixed_auth_cipher(
7567 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7571 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7573 return test_mixed_auth_cipher(
7574 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7578 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7580 return test_mixed_auth_cipher(
7581 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7585 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7587 return test_mixed_auth_cipher(
7588 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7592 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7594 return test_mixed_auth_cipher(
7595 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7599 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7601 return test_mixed_auth_cipher(
7602 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7606 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7608 return test_mixed_auth_cipher(
7609 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7613 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7615 return test_mixed_auth_cipher(
7616 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7620 test_auth_snow_cipher_zuc_test_case_1(void)
7622 return test_mixed_auth_cipher(
7623 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7627 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7629 return test_mixed_auth_cipher(
7630 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7634 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7636 return test_mixed_auth_cipher(
7637 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7641 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7643 return test_mixed_auth_cipher(
7644 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7648 test_auth_null_cipher_snow_test_case_1(void)
7650 return test_mixed_auth_cipher(
7651 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7655 test_verify_auth_null_cipher_snow_test_case_1(void)
7657 return test_mixed_auth_cipher(
7658 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7662 test_auth_null_cipher_zuc_test_case_1(void)
7664 return test_mixed_auth_cipher(
7665 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7669 test_verify_auth_null_cipher_zuc_test_case_1(void)
7671 return test_mixed_auth_cipher(
7672 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7676 test_auth_snow_cipher_null_test_case_1(void)
7678 return test_mixed_auth_cipher(
7679 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7683 test_verify_auth_snow_cipher_null_test_case_1(void)
7685 return test_mixed_auth_cipher(
7686 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7690 test_auth_zuc_cipher_null_test_case_1(void)
7692 return test_mixed_auth_cipher(
7693 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7697 test_verify_auth_zuc_cipher_null_test_case_1(void)
7699 return test_mixed_auth_cipher(
7700 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7704 test_auth_null_cipher_aes_ctr_test_case_1(void)
7706 return test_mixed_auth_cipher(
7707 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7711 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7713 return test_mixed_auth_cipher(
7714 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7718 test_auth_aes_cmac_cipher_null_test_case_1(void)
7720 return test_mixed_auth_cipher(
7721 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7725 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7727 return test_mixed_auth_cipher(
7728 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7731 /* ***** AEAD algorithm Tests ***** */
7734 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7735 enum rte_crypto_aead_operation op,
7736 const uint8_t *key, const uint8_t key_len,
7737 const uint16_t aad_len, const uint8_t auth_len,
7740 uint8_t aead_key[key_len];
7742 struct crypto_testsuite_params *ts_params = &testsuite_params;
7743 struct crypto_unittest_params *ut_params = &unittest_params;
7745 memcpy(aead_key, key, key_len);
7747 /* Setup AEAD Parameters */
7748 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7749 ut_params->aead_xform.next = NULL;
7750 ut_params->aead_xform.aead.algo = algo;
7751 ut_params->aead_xform.aead.op = op;
7752 ut_params->aead_xform.aead.key.data = aead_key;
7753 ut_params->aead_xform.aead.key.length = key_len;
7754 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7755 ut_params->aead_xform.aead.iv.length = iv_len;
7756 ut_params->aead_xform.aead.digest_length = auth_len;
7757 ut_params->aead_xform.aead.aad_length = aad_len;
7759 debug_hexdump(stdout, "key:", key, key_len);
7761 /* Create Crypto session*/
7762 ut_params->sess = rte_cryptodev_sym_session_create(
7763 ts_params->session_mpool);
7765 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7766 &ut_params->aead_xform,
7767 ts_params->session_priv_mpool);
7769 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7775 create_aead_xform(struct rte_crypto_op *op,
7776 enum rte_crypto_aead_algorithm algo,
7777 enum rte_crypto_aead_operation aead_op,
7778 uint8_t *key, const uint8_t key_len,
7779 const uint8_t aad_len, const uint8_t auth_len,
7782 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7783 "failed to allocate space for crypto transform");
7785 struct rte_crypto_sym_op *sym_op = op->sym;
7787 /* Setup AEAD Parameters */
7788 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7789 sym_op->xform->next = NULL;
7790 sym_op->xform->aead.algo = algo;
7791 sym_op->xform->aead.op = aead_op;
7792 sym_op->xform->aead.key.data = key;
7793 sym_op->xform->aead.key.length = key_len;
7794 sym_op->xform->aead.iv.offset = IV_OFFSET;
7795 sym_op->xform->aead.iv.length = iv_len;
7796 sym_op->xform->aead.digest_length = auth_len;
7797 sym_op->xform->aead.aad_length = aad_len;
7799 debug_hexdump(stdout, "key:", key, key_len);
7805 create_aead_operation(enum rte_crypto_aead_operation op,
7806 const struct aead_test_data *tdata)
7808 struct crypto_testsuite_params *ts_params = &testsuite_params;
7809 struct crypto_unittest_params *ut_params = &unittest_params;
7811 uint8_t *plaintext, *ciphertext;
7812 unsigned int aad_pad_len, plaintext_pad_len;
7814 /* Generate Crypto op data structure */
7815 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7816 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7817 TEST_ASSERT_NOT_NULL(ut_params->op,
7818 "Failed to allocate symmetric crypto operation struct");
7820 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7822 /* Append aad data */
7823 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7824 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7825 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7827 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7828 "no room to append aad");
7830 sym_op->aead.aad.phys_addr =
7831 rte_pktmbuf_iova(ut_params->ibuf);
7832 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7833 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7834 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7837 /* Append IV at the end of the crypto operation*/
7838 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7839 uint8_t *, IV_OFFSET);
7841 /* Copy IV 1 byte after the IV pointer, according to the API */
7842 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7843 debug_hexdump(stdout, "iv:", iv_ptr,
7846 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7847 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7849 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7850 "no room to append aad");
7852 sym_op->aead.aad.phys_addr =
7853 rte_pktmbuf_iova(ut_params->ibuf);
7854 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7855 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7858 /* Append IV at the end of the crypto operation*/
7859 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7860 uint8_t *, IV_OFFSET);
7862 if (tdata->iv.len == 0) {
7863 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7864 debug_hexdump(stdout, "iv:", iv_ptr,
7867 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7868 debug_hexdump(stdout, "iv:", iv_ptr,
7873 /* Append plaintext/ciphertext */
7874 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7875 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7876 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7878 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7880 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7881 debug_hexdump(stdout, "plaintext:", plaintext,
7882 tdata->plaintext.len);
7884 if (ut_params->obuf) {
7885 ciphertext = (uint8_t *)rte_pktmbuf_append(
7887 plaintext_pad_len + aad_pad_len);
7888 TEST_ASSERT_NOT_NULL(ciphertext,
7889 "no room to append ciphertext");
7891 memset(ciphertext + aad_pad_len, 0,
7892 tdata->ciphertext.len);
7895 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7896 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7898 TEST_ASSERT_NOT_NULL(ciphertext,
7899 "no room to append ciphertext");
7901 memcpy(ciphertext, tdata->ciphertext.data,
7902 tdata->ciphertext.len);
7903 debug_hexdump(stdout, "ciphertext:", ciphertext,
7904 tdata->ciphertext.len);
7906 if (ut_params->obuf) {
7907 plaintext = (uint8_t *)rte_pktmbuf_append(
7909 plaintext_pad_len + aad_pad_len);
7910 TEST_ASSERT_NOT_NULL(plaintext,
7911 "no room to append plaintext");
7913 memset(plaintext + aad_pad_len, 0,
7914 tdata->plaintext.len);
7918 /* Append digest data */
7919 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7920 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7921 ut_params->obuf ? ut_params->obuf :
7923 tdata->auth_tag.len);
7924 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7925 "no room to append digest");
7926 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7927 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7928 ut_params->obuf ? ut_params->obuf :
7933 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7934 ut_params->ibuf, tdata->auth_tag.len);
7935 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7936 "no room to append digest");
7937 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7939 plaintext_pad_len + aad_pad_len);
7941 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7942 tdata->auth_tag.len);
7943 debug_hexdump(stdout, "digest:",
7944 sym_op->aead.digest.data,
7945 tdata->auth_tag.len);
7948 sym_op->aead.data.length = tdata->plaintext.len;
7949 sym_op->aead.data.offset = aad_pad_len;
7955 test_authenticated_encryption(const struct aead_test_data *tdata)
7957 struct crypto_testsuite_params *ts_params = &testsuite_params;
7958 struct crypto_unittest_params *ut_params = &unittest_params;
7961 uint8_t *ciphertext, *auth_tag;
7962 uint16_t plaintext_pad_len;
7964 struct rte_cryptodev_info dev_info;
7966 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7967 uint64_t feat_flags = dev_info.feature_flags;
7969 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7970 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7971 printf("Device doesn't support RAW data-path APIs.\n");
7972 return TEST_SKIPPED;
7975 /* Verify the capabilities */
7976 struct rte_cryptodev_sym_capability_idx cap_idx;
7977 const struct rte_cryptodev_symmetric_capability *capability;
7978 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7979 cap_idx.algo.aead = tdata->algo;
7980 capability = rte_cryptodev_sym_capability_get(
7981 ts_params->valid_devs[0], &cap_idx);
7982 if (capability == NULL)
7983 return TEST_SKIPPED;
7984 if (rte_cryptodev_sym_capability_check_aead(
7985 capability, tdata->key.len, tdata->auth_tag.len,
7986 tdata->aad.len, tdata->iv.len))
7987 return TEST_SKIPPED;
7989 /* Create AEAD session */
7990 retval = create_aead_session(ts_params->valid_devs[0],
7992 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7993 tdata->key.data, tdata->key.len,
7994 tdata->aad.len, tdata->auth_tag.len,
7999 if (tdata->aad.len > MBUF_SIZE) {
8000 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8001 /* Populate full size of add data */
8002 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8003 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8005 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8007 /* clear mbuf payload */
8008 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8009 rte_pktmbuf_tailroom(ut_params->ibuf));
8011 /* Create AEAD operation */
8012 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8016 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8018 ut_params->op->sym->m_src = ut_params->ibuf;
8020 /* Process crypto operation */
8021 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8022 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8023 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8024 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8025 ut_params->op, 0, 0, 0, 0);
8027 TEST_ASSERT_NOT_NULL(
8028 process_crypto_request(ts_params->valid_devs[0],
8029 ut_params->op), "failed to process sym crypto op");
8031 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8032 "crypto op processing failed");
8034 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8036 if (ut_params->op->sym->m_dst) {
8037 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8039 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8040 uint8_t *, plaintext_pad_len);
8042 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8044 ut_params->op->sym->cipher.data.offset);
8045 auth_tag = ciphertext + plaintext_pad_len;
8048 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8049 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8052 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8054 tdata->ciphertext.data,
8055 tdata->ciphertext.len,
8056 "Ciphertext data not as expected");
8058 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8060 tdata->auth_tag.data,
8061 tdata->auth_tag.len,
8062 "Generated auth tag not as expected");
8068 #ifdef RTE_LIB_SECURITY
8070 security_proto_supported(enum rte_security_session_action_type action,
8071 enum rte_security_session_protocol proto)
8073 struct crypto_testsuite_params *ts_params = &testsuite_params;
8075 const struct rte_security_capability *capabilities;
8076 const struct rte_security_capability *capability;
8079 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8080 rte_cryptodev_get_sec_ctx(
8081 ts_params->valid_devs[0]);
8084 capabilities = rte_security_capabilities_get(ctx);
8086 if (capabilities == NULL)
8089 while ((capability = &capabilities[i++])->action !=
8090 RTE_SECURITY_ACTION_TYPE_NONE) {
8091 if (capability->action == action &&
8092 capability->protocol == proto)
8099 /* Basic algorithm run function for async inplace mode.
8100 * Creates a session from input parameters and runs one operation
8101 * on input_vec. Checks the output of the crypto operation against
8104 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8105 enum rte_crypto_auth_operation opa,
8106 const uint8_t *input_vec, unsigned int input_vec_len,
8107 const uint8_t *output_vec,
8108 unsigned int output_vec_len,
8109 enum rte_crypto_cipher_algorithm cipher_alg,
8110 const uint8_t *cipher_key, uint32_t cipher_key_len,
8111 enum rte_crypto_auth_algorithm auth_alg,
8112 const uint8_t *auth_key, uint32_t auth_key_len,
8113 uint8_t bearer, enum rte_security_pdcp_domain domain,
8114 uint8_t packet_direction, uint8_t sn_size,
8115 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8117 struct crypto_testsuite_params *ts_params = &testsuite_params;
8118 struct crypto_unittest_params *ut_params = &unittest_params;
8120 int ret = TEST_SUCCESS;
8121 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8122 rte_cryptodev_get_sec_ctx(
8123 ts_params->valid_devs[0]);
8125 /* Verify the capabilities */
8126 struct rte_security_capability_idx sec_cap_idx;
8128 sec_cap_idx.action = ut_params->type;
8129 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8130 sec_cap_idx.pdcp.domain = domain;
8131 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8132 return TEST_SKIPPED;
8134 /* Generate test mbuf data */
8135 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8137 /* clear mbuf payload */
8138 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8139 rte_pktmbuf_tailroom(ut_params->ibuf));
8141 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8143 memcpy(plaintext, input_vec, input_vec_len);
8145 /* Out of place support */
8148 * For out-op-place we need to alloc another mbuf
8150 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8151 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8154 /* Setup Cipher Parameters */
8155 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8156 ut_params->cipher_xform.cipher.algo = cipher_alg;
8157 ut_params->cipher_xform.cipher.op = opc;
8158 ut_params->cipher_xform.cipher.key.data = cipher_key;
8159 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8160 ut_params->cipher_xform.cipher.iv.length =
8161 packet_direction ? 4 : 0;
8162 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8164 /* Setup HMAC Parameters if ICV header is required */
8165 if (auth_alg != 0) {
8166 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8167 ut_params->auth_xform.next = NULL;
8168 ut_params->auth_xform.auth.algo = auth_alg;
8169 ut_params->auth_xform.auth.op = opa;
8170 ut_params->auth_xform.auth.key.data = auth_key;
8171 ut_params->auth_xform.auth.key.length = auth_key_len;
8173 ut_params->cipher_xform.next = &ut_params->auth_xform;
8175 ut_params->cipher_xform.next = NULL;
8178 struct rte_security_session_conf sess_conf = {
8179 .action_type = ut_params->type,
8180 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8184 .pkt_dir = packet_direction,
8186 .hfn = packet_direction ? 0 : hfn,
8188 * hfn can be set as pdcp_test_hfn[i]
8189 * if hfn_ovrd is not set. Here, PDCP
8190 * packet direction is just used to
8191 * run half of the cases with session
8192 * HFN and other half with per packet
8195 .hfn_threshold = hfn_threshold,
8196 .hfn_ovrd = packet_direction ? 1 : 0,
8197 .sdap_enabled = sdap,
8199 .crypto_xform = &ut_params->cipher_xform
8202 /* Create security session */
8203 ut_params->sec_session = rte_security_session_create(ctx,
8204 &sess_conf, ts_params->session_mpool,
8205 ts_params->session_priv_mpool);
8207 if (!ut_params->sec_session) {
8208 printf("TestCase %s()-%d line %d failed %s: ",
8209 __func__, i, __LINE__, "Failed to allocate session");
8214 /* Generate crypto op data structure */
8215 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8216 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8217 if (!ut_params->op) {
8218 printf("TestCase %s()-%d line %d failed %s: ",
8219 __func__, i, __LINE__,
8220 "Failed to allocate symmetric crypto operation struct");
8225 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8226 uint32_t *, IV_OFFSET);
8227 *per_pkt_hfn = packet_direction ? hfn : 0;
8229 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8231 /* set crypto operation source mbuf */
8232 ut_params->op->sym->m_src = ut_params->ibuf;
8234 ut_params->op->sym->m_dst = ut_params->obuf;
8236 /* Process crypto operation */
8237 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8239 printf("TestCase %s()-%d line %d failed %s: ",
8240 __func__, i, __LINE__,
8241 "failed to process sym crypto op");
8246 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8247 printf("TestCase %s()-%d line %d failed %s: ",
8248 __func__, i, __LINE__, "crypto op processing failed");
8254 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8257 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8261 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8262 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8263 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8264 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8270 rte_crypto_op_free(ut_params->op);
8271 ut_params->op = NULL;
8273 if (ut_params->sec_session)
8274 rte_security_session_destroy(ctx, ut_params->sec_session);
8275 ut_params->sec_session = NULL;
8277 rte_pktmbuf_free(ut_params->ibuf);
8278 ut_params->ibuf = NULL;
8280 rte_pktmbuf_free(ut_params->obuf);
8281 ut_params->obuf = NULL;
8288 test_pdcp_proto_SGL(int i, int oop,
8289 enum rte_crypto_cipher_operation opc,
8290 enum rte_crypto_auth_operation opa,
8292 unsigned int input_vec_len,
8293 uint8_t *output_vec,
8294 unsigned int output_vec_len,
8296 uint32_t fragsz_oop)
8298 struct crypto_testsuite_params *ts_params = &testsuite_params;
8299 struct crypto_unittest_params *ut_params = &unittest_params;
8301 struct rte_mbuf *buf, *buf_oop = NULL;
8302 int ret = TEST_SUCCESS;
8306 unsigned int trn_data = 0;
8307 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8308 rte_cryptodev_get_sec_ctx(
8309 ts_params->valid_devs[0]);
8311 /* Verify the capabilities */
8312 struct rte_security_capability_idx sec_cap_idx;
8314 sec_cap_idx.action = ut_params->type;
8315 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8316 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8317 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8318 return TEST_SKIPPED;
8320 if (fragsz > input_vec_len)
8321 fragsz = input_vec_len;
8323 uint16_t plaintext_len = fragsz;
8324 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8326 if (fragsz_oop > output_vec_len)
8327 frag_size_oop = output_vec_len;
8330 if (input_vec_len % fragsz != 0) {
8331 if (input_vec_len / fragsz + 1 > 16)
8333 } else if (input_vec_len / fragsz > 16)
8336 /* Out of place support */
8339 * For out-op-place we need to alloc another mbuf
8341 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8342 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8343 buf_oop = ut_params->obuf;
8346 /* Generate test mbuf data */
8347 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8349 /* clear mbuf payload */
8350 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8351 rte_pktmbuf_tailroom(ut_params->ibuf));
8353 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8355 memcpy(plaintext, input_vec, plaintext_len);
8356 trn_data += plaintext_len;
8358 buf = ut_params->ibuf;
8361 * Loop until no more fragments
8364 while (trn_data < input_vec_len) {
8366 to_trn = (input_vec_len - trn_data < fragsz) ?
8367 (input_vec_len - trn_data) : fragsz;
8369 to_trn_tbl[ecx++] = to_trn;
8371 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8374 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8375 rte_pktmbuf_tailroom(buf));
8378 if (oop && !fragsz_oop) {
8380 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8381 buf_oop = buf_oop->next;
8382 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8383 0, rte_pktmbuf_tailroom(buf_oop));
8384 rte_pktmbuf_append(buf_oop, to_trn);
8387 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8390 memcpy(plaintext, input_vec + trn_data, to_trn);
8394 ut_params->ibuf->nb_segs = segs;
8397 if (fragsz_oop && oop) {
8401 trn_data = frag_size_oop;
8402 while (trn_data < output_vec_len) {
8405 (output_vec_len - trn_data <
8407 (output_vec_len - trn_data) :
8410 to_trn_tbl[ecx++] = to_trn;
8413 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8414 buf_oop = buf_oop->next;
8415 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8416 0, rte_pktmbuf_tailroom(buf_oop));
8417 rte_pktmbuf_append(buf_oop, to_trn);
8421 ut_params->obuf->nb_segs = segs;
8424 /* Setup Cipher Parameters */
8425 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8426 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8427 ut_params->cipher_xform.cipher.op = opc;
8428 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8429 ut_params->cipher_xform.cipher.key.length =
8430 pdcp_test_params[i].cipher_key_len;
8431 ut_params->cipher_xform.cipher.iv.length = 0;
8433 /* Setup HMAC Parameters if ICV header is required */
8434 if (pdcp_test_params[i].auth_alg != 0) {
8435 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8436 ut_params->auth_xform.next = NULL;
8437 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8438 ut_params->auth_xform.auth.op = opa;
8439 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8440 ut_params->auth_xform.auth.key.length =
8441 pdcp_test_params[i].auth_key_len;
8443 ut_params->cipher_xform.next = &ut_params->auth_xform;
8445 ut_params->cipher_xform.next = NULL;
8448 struct rte_security_session_conf sess_conf = {
8449 .action_type = ut_params->type,
8450 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8452 .bearer = pdcp_test_bearer[i],
8453 .domain = pdcp_test_params[i].domain,
8454 .pkt_dir = pdcp_test_packet_direction[i],
8455 .sn_size = pdcp_test_data_sn_size[i],
8456 .hfn = pdcp_test_hfn[i],
8457 .hfn_threshold = pdcp_test_hfn_threshold[i],
8460 .crypto_xform = &ut_params->cipher_xform
8463 /* Create security session */
8464 ut_params->sec_session = rte_security_session_create(ctx,
8465 &sess_conf, ts_params->session_mpool,
8466 ts_params->session_priv_mpool);
8468 if (!ut_params->sec_session) {
8469 printf("TestCase %s()-%d line %d failed %s: ",
8470 __func__, i, __LINE__, "Failed to allocate session");
8475 /* Generate crypto op data structure */
8476 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8477 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8478 if (!ut_params->op) {
8479 printf("TestCase %s()-%d line %d failed %s: ",
8480 __func__, i, __LINE__,
8481 "Failed to allocate symmetric crypto operation struct");
8486 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8488 /* set crypto operation source mbuf */
8489 ut_params->op->sym->m_src = ut_params->ibuf;
8491 ut_params->op->sym->m_dst = ut_params->obuf;
8493 /* Process crypto operation */
8494 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8496 printf("TestCase %s()-%d line %d failed %s: ",
8497 __func__, i, __LINE__,
8498 "failed to process sym crypto op");
8503 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8504 printf("TestCase %s()-%d line %d failed %s: ",
8505 __func__, i, __LINE__, "crypto op processing failed");
8511 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8514 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8518 fragsz = frag_size_oop;
8519 if (memcmp(ciphertext, output_vec, fragsz)) {
8520 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8521 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8522 rte_hexdump(stdout, "reference", output_vec, fragsz);
8527 buf = ut_params->op->sym->m_src->next;
8529 buf = ut_params->op->sym->m_dst->next;
8531 unsigned int off = fragsz;
8535 ciphertext = rte_pktmbuf_mtod(buf,
8537 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8538 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8539 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8540 rte_hexdump(stdout, "reference", output_vec + off,
8545 off += to_trn_tbl[ecx++];
8549 rte_crypto_op_free(ut_params->op);
8550 ut_params->op = NULL;
8552 if (ut_params->sec_session)
8553 rte_security_session_destroy(ctx, ut_params->sec_session);
8554 ut_params->sec_session = NULL;
8556 rte_pktmbuf_free(ut_params->ibuf);
8557 ut_params->ibuf = NULL;
8559 rte_pktmbuf_free(ut_params->obuf);
8560 ut_params->obuf = NULL;
8567 test_pdcp_proto_cplane_encap(int i)
8569 return test_pdcp_proto(
8570 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8571 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8572 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8573 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8574 pdcp_test_params[i].cipher_key_len,
8575 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8576 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8577 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8578 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8579 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8583 test_pdcp_proto_uplane_encap(int i)
8585 return test_pdcp_proto(
8586 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8587 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8588 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8589 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8590 pdcp_test_params[i].cipher_key_len,
8591 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8592 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8593 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8594 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8595 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8599 test_pdcp_proto_uplane_encap_with_int(int i)
8601 return test_pdcp_proto(
8602 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8603 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8604 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8605 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8606 pdcp_test_params[i].cipher_key_len,
8607 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8608 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8609 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8610 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8611 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8615 test_pdcp_proto_cplane_decap(int i)
8617 return test_pdcp_proto(
8618 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8619 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8620 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8621 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8622 pdcp_test_params[i].cipher_key_len,
8623 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8624 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8625 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8626 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8627 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8631 test_pdcp_proto_uplane_decap(int i)
8633 return test_pdcp_proto(
8634 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8635 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8636 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8637 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8638 pdcp_test_params[i].cipher_key_len,
8639 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8640 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8641 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8642 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8643 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8647 test_pdcp_proto_uplane_decap_with_int(int i)
8649 return test_pdcp_proto(
8650 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8651 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8652 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8653 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8654 pdcp_test_params[i].cipher_key_len,
8655 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8656 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8657 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8658 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8659 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8663 test_PDCP_PROTO_SGL_in_place_32B(void)
8665 /* i can be used for running any PDCP case
8666 * In this case it is uplane 12-bit AES-SNOW DL encap
8668 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8669 return test_pdcp_proto_SGL(i, IN_PLACE,
8670 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8671 RTE_CRYPTO_AUTH_OP_GENERATE,
8672 pdcp_test_data_in[i],
8673 pdcp_test_data_in_len[i],
8674 pdcp_test_data_out[i],
8675 pdcp_test_data_in_len[i]+4,
8679 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8681 /* i can be used for running any PDCP case
8682 * In this case it is uplane 18-bit NULL-NULL DL encap
8684 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8685 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8686 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8687 RTE_CRYPTO_AUTH_OP_GENERATE,
8688 pdcp_test_data_in[i],
8689 pdcp_test_data_in_len[i],
8690 pdcp_test_data_out[i],
8691 pdcp_test_data_in_len[i]+4,
8695 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8697 /* i can be used for running any PDCP case
8698 * In this case it is uplane 18-bit AES DL encap
8700 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8702 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8703 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8704 RTE_CRYPTO_AUTH_OP_GENERATE,
8705 pdcp_test_data_in[i],
8706 pdcp_test_data_in_len[i],
8707 pdcp_test_data_out[i],
8708 pdcp_test_data_in_len[i],
8712 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8714 /* i can be used for running any PDCP case
8715 * In this case it is cplane 12-bit AES-ZUC DL encap
8717 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8718 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8719 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8720 RTE_CRYPTO_AUTH_OP_GENERATE,
8721 pdcp_test_data_in[i],
8722 pdcp_test_data_in_len[i],
8723 pdcp_test_data_out[i],
8724 pdcp_test_data_in_len[i]+4,
8729 test_PDCP_SDAP_PROTO_encap_all(void)
8731 int i = 0, size = 0;
8732 int err, all_err = TEST_SUCCESS;
8733 const struct pdcp_sdap_test *cur_test;
8735 size = RTE_DIM(list_pdcp_sdap_tests);
8737 for (i = 0; i < size; i++) {
8738 cur_test = &list_pdcp_sdap_tests[i];
8739 err = test_pdcp_proto(
8740 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8741 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8742 cur_test->in_len, cur_test->data_out,
8743 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8744 cur_test->param.cipher_alg, cur_test->cipher_key,
8745 cur_test->param.cipher_key_len,
8746 cur_test->param.auth_alg,
8747 cur_test->auth_key, cur_test->param.auth_key_len,
8748 cur_test->bearer, cur_test->param.domain,
8749 cur_test->packet_direction, cur_test->sn_size,
8751 cur_test->hfn_threshold, SDAP_ENABLED);
8753 printf("\t%d) %s: Encapsulation failed\n",
8755 cur_test->param.name);
8758 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8759 cur_test->param.name);
8765 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8767 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8771 test_PDCP_PROTO_short_mac(void)
8773 int i = 0, size = 0;
8774 int err, all_err = TEST_SUCCESS;
8775 const struct pdcp_short_mac_test *cur_test;
8777 size = RTE_DIM(list_pdcp_smac_tests);
8779 for (i = 0; i < size; i++) {
8780 cur_test = &list_pdcp_smac_tests[i];
8781 err = test_pdcp_proto(
8782 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8783 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8784 cur_test->in_len, cur_test->data_out,
8785 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8786 RTE_CRYPTO_CIPHER_NULL, NULL,
8787 0, cur_test->param.auth_alg,
8788 cur_test->auth_key, cur_test->param.auth_key_len,
8789 0, cur_test->param.domain, 0, 0,
8792 printf("\t%d) %s: Short MAC test failed\n",
8794 cur_test->param.name);
8797 printf("\t%d) %s: Short MAC test PASS\n",
8799 cur_test->param.name);
8800 rte_hexdump(stdout, "MAC I",
8801 cur_test->data_out + cur_test->in_len + 2,
8808 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8810 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8815 test_PDCP_SDAP_PROTO_decap_all(void)
8817 int i = 0, size = 0;
8818 int err, all_err = TEST_SUCCESS;
8819 const struct pdcp_sdap_test *cur_test;
8821 size = RTE_DIM(list_pdcp_sdap_tests);
8823 for (i = 0; i < size; i++) {
8824 cur_test = &list_pdcp_sdap_tests[i];
8825 err = test_pdcp_proto(
8826 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8827 RTE_CRYPTO_AUTH_OP_VERIFY,
8829 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8830 cur_test->data_in, cur_test->in_len,
8831 cur_test->param.cipher_alg,
8832 cur_test->cipher_key, cur_test->param.cipher_key_len,
8833 cur_test->param.auth_alg, cur_test->auth_key,
8834 cur_test->param.auth_key_len, cur_test->bearer,
8835 cur_test->param.domain, cur_test->packet_direction,
8836 cur_test->sn_size, cur_test->hfn,
8837 cur_test->hfn_threshold, SDAP_ENABLED);
8839 printf("\t%d) %s: Decapsulation failed\n",
8841 cur_test->param.name);
8844 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8845 cur_test->param.name);
8851 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8853 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8857 test_PDCP_PROTO_all(void)
8859 struct crypto_testsuite_params *ts_params = &testsuite_params;
8860 struct crypto_unittest_params *ut_params = &unittest_params;
8861 struct rte_cryptodev_info dev_info;
8864 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8865 uint64_t feat_flags = dev_info.feature_flags;
8867 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8868 return TEST_SKIPPED;
8870 /* Set action type */
8871 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8872 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8875 if (security_proto_supported(ut_params->type,
8876 RTE_SECURITY_PROTOCOL_PDCP) < 0)
8877 return TEST_SKIPPED;
8879 status = test_PDCP_PROTO_cplane_encap_all();
8880 status += test_PDCP_PROTO_cplane_decap_all();
8881 status += test_PDCP_PROTO_uplane_encap_all();
8882 status += test_PDCP_PROTO_uplane_decap_all();
8883 status += test_PDCP_PROTO_SGL_in_place_32B();
8884 status += test_PDCP_PROTO_SGL_oop_32B_128B();
8885 status += test_PDCP_PROTO_SGL_oop_32B_40B();
8886 status += test_PDCP_PROTO_SGL_oop_128B_32B();
8887 status += test_PDCP_SDAP_PROTO_encap_all();
8888 status += test_PDCP_SDAP_PROTO_decap_all();
8893 return TEST_SUCCESS;
8897 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8899 struct crypto_testsuite_params *ts_params = &testsuite_params;
8900 struct crypto_unittest_params *ut_params = &unittest_params;
8901 uint8_t *plaintext, *ciphertext;
8903 int32_t cipher_len, crc_len;
8904 uint32_t crc_data_len;
8905 int ret = TEST_SUCCESS;
8907 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8908 rte_cryptodev_get_sec_ctx(
8909 ts_params->valid_devs[0]);
8911 /* Verify the capabilities */
8912 struct rte_security_capability_idx sec_cap_idx;
8913 const struct rte_security_capability *sec_cap;
8914 const struct rte_cryptodev_capabilities *crypto_cap;
8915 const struct rte_cryptodev_symmetric_capability *sym_cap;
8918 sec_cap_idx.action = ut_params->type;
8919 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8920 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8922 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8923 if (sec_cap == NULL)
8924 return TEST_SKIPPED;
8926 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8927 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8928 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8929 crypto_cap->sym.xform_type ==
8930 RTE_CRYPTO_SYM_XFORM_CIPHER &&
8931 crypto_cap->sym.cipher.algo ==
8932 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8933 sym_cap = &crypto_cap->sym;
8934 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8941 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8942 return TEST_SKIPPED;
8944 /* Setup source mbuf payload */
8945 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8946 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8947 rte_pktmbuf_tailroom(ut_params->ibuf));
8949 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8950 d_td->ciphertext.len);
8952 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8954 /* Setup cipher session parameters */
8955 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8956 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8957 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8958 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8959 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8960 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8961 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8962 ut_params->cipher_xform.next = NULL;
8964 /* Setup DOCSIS session parameters */
8965 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8967 struct rte_security_session_conf sess_conf = {
8968 .action_type = ut_params->type,
8969 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8970 .docsis = ut_params->docsis_xform,
8971 .crypto_xform = &ut_params->cipher_xform,
8974 /* Create security session */
8975 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8976 ts_params->session_mpool,
8977 ts_params->session_priv_mpool);
8979 if (!ut_params->sec_session) {
8980 printf("TestCase %s(%d) line %d: %s\n",
8981 __func__, i, __LINE__, "failed to allocate session");
8986 /* Generate crypto op data structure */
8987 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8988 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8989 if (!ut_params->op) {
8990 printf("TestCase %s(%d) line %d: %s\n",
8991 __func__, i, __LINE__,
8992 "failed to allocate symmetric crypto operation");
8997 /* Setup CRC operation parameters */
8998 crc_len = d_td->ciphertext.no_crc == false ?
8999 (d_td->ciphertext.len -
9000 d_td->ciphertext.crc_offset -
9001 RTE_ETHER_CRC_LEN) :
9003 crc_len = crc_len > 0 ? crc_len : 0;
9004 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9005 ut_params->op->sym->auth.data.length = crc_len;
9006 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9008 /* Setup cipher operation parameters */
9009 cipher_len = d_td->ciphertext.no_cipher == false ?
9010 (d_td->ciphertext.len -
9011 d_td->ciphertext.cipher_offset) :
9013 cipher_len = cipher_len > 0 ? cipher_len : 0;
9014 ut_params->op->sym->cipher.data.length = cipher_len;
9015 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9017 /* Setup cipher IV */
9018 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9019 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9021 /* Attach session to operation */
9022 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9024 /* Set crypto operation mbufs */
9025 ut_params->op->sym->m_src = ut_params->ibuf;
9026 ut_params->op->sym->m_dst = NULL;
9028 /* Process crypto operation */
9029 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9031 printf("TestCase %s(%d) line %d: %s\n",
9032 __func__, i, __LINE__,
9033 "failed to process security crypto op");
9038 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9039 printf("TestCase %s(%d) line %d: %s\n",
9040 __func__, i, __LINE__, "crypto op processing failed");
9045 /* Validate plaintext */
9046 plaintext = ciphertext;
9048 if (memcmp(plaintext, d_td->plaintext.data,
9049 d_td->plaintext.len - crc_data_len)) {
9050 printf("TestCase %s(%d) line %d: %s\n",
9051 __func__, i, __LINE__, "plaintext not as expected\n");
9052 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9053 d_td->plaintext.len);
9054 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9060 rte_crypto_op_free(ut_params->op);
9061 ut_params->op = NULL;
9063 if (ut_params->sec_session)
9064 rte_security_session_destroy(ctx, ut_params->sec_session);
9065 ut_params->sec_session = NULL;
9067 rte_pktmbuf_free(ut_params->ibuf);
9068 ut_params->ibuf = NULL;
9074 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9076 struct crypto_testsuite_params *ts_params = &testsuite_params;
9077 struct crypto_unittest_params *ut_params = &unittest_params;
9078 uint8_t *plaintext, *ciphertext;
9080 int32_t cipher_len, crc_len;
9081 int ret = TEST_SUCCESS;
9083 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9084 rte_cryptodev_get_sec_ctx(
9085 ts_params->valid_devs[0]);
9087 /* Verify the capabilities */
9088 struct rte_security_capability_idx sec_cap_idx;
9089 const struct rte_security_capability *sec_cap;
9090 const struct rte_cryptodev_capabilities *crypto_cap;
9091 const struct rte_cryptodev_symmetric_capability *sym_cap;
9094 sec_cap_idx.action = ut_params->type;
9095 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9096 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9098 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9099 if (sec_cap == NULL)
9100 return TEST_SKIPPED;
9102 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9103 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9104 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9105 crypto_cap->sym.xform_type ==
9106 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9107 crypto_cap->sym.cipher.algo ==
9108 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9109 sym_cap = &crypto_cap->sym;
9110 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9117 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9118 return TEST_SKIPPED;
9120 /* Setup source mbuf payload */
9121 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9122 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9123 rte_pktmbuf_tailroom(ut_params->ibuf));
9125 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9126 d_td->plaintext.len);
9128 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9130 /* Setup cipher session parameters */
9131 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9132 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9133 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9134 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9135 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9136 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9137 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9138 ut_params->cipher_xform.next = NULL;
9140 /* Setup DOCSIS session parameters */
9141 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9143 struct rte_security_session_conf sess_conf = {
9144 .action_type = ut_params->type,
9145 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9146 .docsis = ut_params->docsis_xform,
9147 .crypto_xform = &ut_params->cipher_xform,
9150 /* Create security session */
9151 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9152 ts_params->session_mpool,
9153 ts_params->session_priv_mpool);
9155 if (!ut_params->sec_session) {
9156 printf("TestCase %s(%d) line %d: %s\n",
9157 __func__, i, __LINE__, "failed to allocate session");
9162 /* Generate crypto op data structure */
9163 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9164 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9165 if (!ut_params->op) {
9166 printf("TestCase %s(%d) line %d: %s\n",
9167 __func__, i, __LINE__,
9168 "failed to allocate security crypto operation");
9173 /* Setup CRC operation parameters */
9174 crc_len = d_td->plaintext.no_crc == false ?
9175 (d_td->plaintext.len -
9176 d_td->plaintext.crc_offset -
9177 RTE_ETHER_CRC_LEN) :
9179 crc_len = crc_len > 0 ? crc_len : 0;
9180 ut_params->op->sym->auth.data.length = crc_len;
9181 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9183 /* Setup cipher operation parameters */
9184 cipher_len = d_td->plaintext.no_cipher == false ?
9185 (d_td->plaintext.len -
9186 d_td->plaintext.cipher_offset) :
9188 cipher_len = cipher_len > 0 ? cipher_len : 0;
9189 ut_params->op->sym->cipher.data.length = cipher_len;
9190 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9192 /* Setup cipher IV */
9193 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9194 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9196 /* Attach session to operation */
9197 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9199 /* Set crypto operation mbufs */
9200 ut_params->op->sym->m_src = ut_params->ibuf;
9201 ut_params->op->sym->m_dst = NULL;
9203 /* Process crypto operation */
9204 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9206 printf("TestCase %s(%d) line %d: %s\n",
9207 __func__, i, __LINE__,
9208 "failed to process security crypto op");
9213 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9214 printf("TestCase %s(%d) line %d: %s\n",
9215 __func__, i, __LINE__, "crypto op processing failed");
9220 /* Validate ciphertext */
9221 ciphertext = plaintext;
9223 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9224 printf("TestCase %s(%d) line %d: %s\n",
9225 __func__, i, __LINE__, "ciphertext not as expected\n");
9226 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9227 d_td->ciphertext.len);
9228 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9234 rte_crypto_op_free(ut_params->op);
9235 ut_params->op = NULL;
9237 if (ut_params->sec_session)
9238 rte_security_session_destroy(ctx, ut_params->sec_session);
9239 ut_params->sec_session = NULL;
9241 rte_pktmbuf_free(ut_params->ibuf);
9242 ut_params->ibuf = NULL;
9247 #define TEST_DOCSIS_COUNT(func) do { \
9249 if (ret == TEST_SUCCESS) { \
9250 printf("\t%2d)", n++); \
9251 printf("+++++ PASSED:" #func"\n"); \
9253 } else if (ret == TEST_SKIPPED) { \
9254 printf("\t%2d)", n++); \
9255 printf("~~~~~ SKIPPED:" #func"\n"); \
9258 printf("\t%2d)", n++); \
9259 printf("----- FAILED:" #func"\n"); \
9265 test_DOCSIS_PROTO_uplink_all(void)
9267 int p = 0, s = 0, f = 0, n = 0;
9269 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9270 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9271 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9272 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9273 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9274 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9275 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9276 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9277 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9278 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9279 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9280 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9281 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9282 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9283 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9284 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9285 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9286 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9287 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9288 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9289 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9290 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9291 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9292 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9293 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9294 TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9297 printf("## %s: %d passed out of %d (%d skipped)\n",
9304 test_DOCSIS_PROTO_downlink_all(void)
9306 int p = 0, s = 0, f = 0, n = 0;
9308 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9309 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9310 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9311 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9312 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9313 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9314 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9315 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9316 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9317 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9318 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9319 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9320 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9321 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9322 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9323 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9324 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9325 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9326 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9327 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9328 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9329 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9330 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9331 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9332 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9333 TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9336 printf("## %s: %d passed out of %d (%d skipped)\n",
9343 test_DOCSIS_PROTO_all(void)
9345 struct crypto_testsuite_params *ts_params = &testsuite_params;
9346 struct crypto_unittest_params *ut_params = &unittest_params;
9347 struct rte_cryptodev_info dev_info;
9350 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9351 uint64_t feat_flags = dev_info.feature_flags;
9353 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9354 return TEST_SKIPPED;
9356 /* Set action type */
9357 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9358 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9361 if (security_proto_supported(ut_params->type,
9362 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9363 return TEST_SKIPPED;
9365 status = test_DOCSIS_PROTO_uplink_all();
9366 status += test_DOCSIS_PROTO_downlink_all();
9371 return TEST_SUCCESS;
9376 test_AES_GCM_authenticated_encryption_test_case_1(void)
9378 return test_authenticated_encryption(&gcm_test_case_1);
9382 test_AES_GCM_authenticated_encryption_test_case_2(void)
9384 return test_authenticated_encryption(&gcm_test_case_2);
9388 test_AES_GCM_authenticated_encryption_test_case_3(void)
9390 return test_authenticated_encryption(&gcm_test_case_3);
9394 test_AES_GCM_authenticated_encryption_test_case_4(void)
9396 return test_authenticated_encryption(&gcm_test_case_4);
9400 test_AES_GCM_authenticated_encryption_test_case_5(void)
9402 return test_authenticated_encryption(&gcm_test_case_5);
9406 test_AES_GCM_authenticated_encryption_test_case_6(void)
9408 return test_authenticated_encryption(&gcm_test_case_6);
9412 test_AES_GCM_authenticated_encryption_test_case_7(void)
9414 return test_authenticated_encryption(&gcm_test_case_7);
9418 test_AES_GCM_authenticated_encryption_test_case_8(void)
9420 return test_authenticated_encryption(&gcm_test_case_8);
9424 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9426 return test_authenticated_encryption(&gcm_J0_test_case_1);
9430 test_AES_GCM_auth_encryption_test_case_192_1(void)
9432 return test_authenticated_encryption(&gcm_test_case_192_1);
9436 test_AES_GCM_auth_encryption_test_case_192_2(void)
9438 return test_authenticated_encryption(&gcm_test_case_192_2);
9442 test_AES_GCM_auth_encryption_test_case_192_3(void)
9444 return test_authenticated_encryption(&gcm_test_case_192_3);
9448 test_AES_GCM_auth_encryption_test_case_192_4(void)
9450 return test_authenticated_encryption(&gcm_test_case_192_4);
9454 test_AES_GCM_auth_encryption_test_case_192_5(void)
9456 return test_authenticated_encryption(&gcm_test_case_192_5);
9460 test_AES_GCM_auth_encryption_test_case_192_6(void)
9462 return test_authenticated_encryption(&gcm_test_case_192_6);
9466 test_AES_GCM_auth_encryption_test_case_192_7(void)
9468 return test_authenticated_encryption(&gcm_test_case_192_7);
9472 test_AES_GCM_auth_encryption_test_case_256_1(void)
9474 return test_authenticated_encryption(&gcm_test_case_256_1);
9478 test_AES_GCM_auth_encryption_test_case_256_2(void)
9480 return test_authenticated_encryption(&gcm_test_case_256_2);
9484 test_AES_GCM_auth_encryption_test_case_256_3(void)
9486 return test_authenticated_encryption(&gcm_test_case_256_3);
9490 test_AES_GCM_auth_encryption_test_case_256_4(void)
9492 return test_authenticated_encryption(&gcm_test_case_256_4);
9496 test_AES_GCM_auth_encryption_test_case_256_5(void)
9498 return test_authenticated_encryption(&gcm_test_case_256_5);
9502 test_AES_GCM_auth_encryption_test_case_256_6(void)
9504 return test_authenticated_encryption(&gcm_test_case_256_6);
9508 test_AES_GCM_auth_encryption_test_case_256_7(void)
9510 return test_authenticated_encryption(&gcm_test_case_256_7);
9514 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9516 return test_authenticated_encryption(&gcm_test_case_aad_1);
9520 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9522 return test_authenticated_encryption(&gcm_test_case_aad_2);
9526 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9528 struct aead_test_data tdata;
9531 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9532 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9533 tdata.iv.data[0] += 1;
9534 res = test_authenticated_encryption(&tdata);
9535 if (res == TEST_SKIPPED)
9537 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9538 return TEST_SUCCESS;
9542 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9544 struct aead_test_data tdata;
9547 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9548 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9549 tdata.plaintext.data[0] += 1;
9550 res = test_authenticated_encryption(&tdata);
9551 if (res == TEST_SKIPPED)
9553 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9554 return TEST_SUCCESS;
9558 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9560 struct aead_test_data tdata;
9563 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9564 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9565 tdata.ciphertext.data[0] += 1;
9566 res = test_authenticated_encryption(&tdata);
9567 if (res == TEST_SKIPPED)
9569 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9570 return TEST_SUCCESS;
9574 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9576 struct aead_test_data tdata;
9579 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9580 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9582 res = test_authenticated_encryption(&tdata);
9583 if (res == TEST_SKIPPED)
9585 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9586 return TEST_SUCCESS;
9590 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9592 struct aead_test_data tdata;
9593 uint8_t aad[gcm_test_case_7.aad.len];
9596 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9597 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9598 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9600 tdata.aad.data = aad;
9601 res = test_authenticated_encryption(&tdata);
9602 if (res == TEST_SKIPPED)
9604 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9605 return TEST_SUCCESS;
9609 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9611 struct aead_test_data tdata;
9614 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9615 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9616 tdata.auth_tag.data[0] += 1;
9617 res = test_authenticated_encryption(&tdata);
9618 if (res == TEST_SKIPPED)
9620 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9621 return TEST_SUCCESS;
9625 test_authenticated_decryption(const struct aead_test_data *tdata)
9627 struct crypto_testsuite_params *ts_params = &testsuite_params;
9628 struct crypto_unittest_params *ut_params = &unittest_params;
9633 struct rte_cryptodev_info dev_info;
9635 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9636 uint64_t feat_flags = dev_info.feature_flags;
9638 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9639 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9640 printf("Device doesn't support RAW data-path APIs.\n");
9641 return TEST_SKIPPED;
9644 /* Verify the capabilities */
9645 struct rte_cryptodev_sym_capability_idx cap_idx;
9646 const struct rte_cryptodev_symmetric_capability *capability;
9647 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9648 cap_idx.algo.aead = tdata->algo;
9649 capability = rte_cryptodev_sym_capability_get(
9650 ts_params->valid_devs[0], &cap_idx);
9651 if (capability == NULL)
9652 return TEST_SKIPPED;
9653 if (rte_cryptodev_sym_capability_check_aead(
9654 capability, tdata->key.len, tdata->auth_tag.len,
9655 tdata->aad.len, tdata->iv.len))
9656 return TEST_SKIPPED;
9658 /* Create AEAD session */
9659 retval = create_aead_session(ts_params->valid_devs[0],
9661 RTE_CRYPTO_AEAD_OP_DECRYPT,
9662 tdata->key.data, tdata->key.len,
9663 tdata->aad.len, tdata->auth_tag.len,
9668 /* alloc mbuf and set payload */
9669 if (tdata->aad.len > MBUF_SIZE) {
9670 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9671 /* Populate full size of add data */
9672 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9673 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9675 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9677 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9678 rte_pktmbuf_tailroom(ut_params->ibuf));
9680 /* Create AEAD operation */
9681 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9685 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9687 ut_params->op->sym->m_src = ut_params->ibuf;
9689 /* Process crypto operation */
9690 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9691 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9692 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9693 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9694 ut_params->op, 0, 0, 0, 0);
9696 TEST_ASSERT_NOT_NULL(
9697 process_crypto_request(ts_params->valid_devs[0],
9698 ut_params->op), "failed to process sym crypto op");
9700 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9701 "crypto op processing failed");
9703 if (ut_params->op->sym->m_dst)
9704 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9707 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9709 ut_params->op->sym->cipher.data.offset);
9711 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9714 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9716 tdata->plaintext.data,
9717 tdata->plaintext.len,
9718 "Plaintext data not as expected");
9720 TEST_ASSERT_EQUAL(ut_params->op->status,
9721 RTE_CRYPTO_OP_STATUS_SUCCESS,
9722 "Authentication failed");
9728 test_AES_GCM_authenticated_decryption_test_case_1(void)
9730 return test_authenticated_decryption(&gcm_test_case_1);
9734 test_AES_GCM_authenticated_decryption_test_case_2(void)
9736 return test_authenticated_decryption(&gcm_test_case_2);
9740 test_AES_GCM_authenticated_decryption_test_case_3(void)
9742 return test_authenticated_decryption(&gcm_test_case_3);
9746 test_AES_GCM_authenticated_decryption_test_case_4(void)
9748 return test_authenticated_decryption(&gcm_test_case_4);
9752 test_AES_GCM_authenticated_decryption_test_case_5(void)
9754 return test_authenticated_decryption(&gcm_test_case_5);
9758 test_AES_GCM_authenticated_decryption_test_case_6(void)
9760 return test_authenticated_decryption(&gcm_test_case_6);
9764 test_AES_GCM_authenticated_decryption_test_case_7(void)
9766 return test_authenticated_decryption(&gcm_test_case_7);
9770 test_AES_GCM_authenticated_decryption_test_case_8(void)
9772 return test_authenticated_decryption(&gcm_test_case_8);
9776 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9778 return test_authenticated_decryption(&gcm_J0_test_case_1);
9782 test_AES_GCM_auth_decryption_test_case_192_1(void)
9784 return test_authenticated_decryption(&gcm_test_case_192_1);
9788 test_AES_GCM_auth_decryption_test_case_192_2(void)
9790 return test_authenticated_decryption(&gcm_test_case_192_2);
9794 test_AES_GCM_auth_decryption_test_case_192_3(void)
9796 return test_authenticated_decryption(&gcm_test_case_192_3);
9800 test_AES_GCM_auth_decryption_test_case_192_4(void)
9802 return test_authenticated_decryption(&gcm_test_case_192_4);
9806 test_AES_GCM_auth_decryption_test_case_192_5(void)
9808 return test_authenticated_decryption(&gcm_test_case_192_5);
9812 test_AES_GCM_auth_decryption_test_case_192_6(void)
9814 return test_authenticated_decryption(&gcm_test_case_192_6);
9818 test_AES_GCM_auth_decryption_test_case_192_7(void)
9820 return test_authenticated_decryption(&gcm_test_case_192_7);
9824 test_AES_GCM_auth_decryption_test_case_256_1(void)
9826 return test_authenticated_decryption(&gcm_test_case_256_1);
9830 test_AES_GCM_auth_decryption_test_case_256_2(void)
9832 return test_authenticated_decryption(&gcm_test_case_256_2);
9836 test_AES_GCM_auth_decryption_test_case_256_3(void)
9838 return test_authenticated_decryption(&gcm_test_case_256_3);
9842 test_AES_GCM_auth_decryption_test_case_256_4(void)
9844 return test_authenticated_decryption(&gcm_test_case_256_4);
9848 test_AES_GCM_auth_decryption_test_case_256_5(void)
9850 return test_authenticated_decryption(&gcm_test_case_256_5);
9854 test_AES_GCM_auth_decryption_test_case_256_6(void)
9856 return test_authenticated_decryption(&gcm_test_case_256_6);
9860 test_AES_GCM_auth_decryption_test_case_256_7(void)
9862 return test_authenticated_decryption(&gcm_test_case_256_7);
9866 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9868 return test_authenticated_decryption(&gcm_test_case_aad_1);
9872 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9874 return test_authenticated_decryption(&gcm_test_case_aad_2);
9878 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9880 struct aead_test_data tdata;
9883 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9884 tdata.iv.data[0] += 1;
9885 res = test_authenticated_decryption(&tdata);
9886 if (res == TEST_SKIPPED)
9888 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9889 return TEST_SUCCESS;
9893 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9895 struct aead_test_data tdata;
9898 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9899 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9900 tdata.plaintext.data[0] += 1;
9901 res = test_authenticated_decryption(&tdata);
9902 if (res == TEST_SKIPPED)
9904 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9905 return TEST_SUCCESS;
9909 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9911 struct aead_test_data tdata;
9914 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9915 tdata.ciphertext.data[0] += 1;
9916 res = test_authenticated_decryption(&tdata);
9917 if (res == TEST_SKIPPED)
9919 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9920 return TEST_SUCCESS;
9924 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9926 struct aead_test_data tdata;
9929 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9931 res = test_authenticated_decryption(&tdata);
9932 if (res == TEST_SKIPPED)
9934 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9935 return TEST_SUCCESS;
9939 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9941 struct aead_test_data tdata;
9942 uint8_t aad[gcm_test_case_7.aad.len];
9945 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9946 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9948 tdata.aad.data = aad;
9949 res = test_authenticated_decryption(&tdata);
9950 if (res == TEST_SKIPPED)
9952 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9953 return TEST_SUCCESS;
9957 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9959 struct aead_test_data tdata;
9962 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9963 tdata.auth_tag.data[0] += 1;
9964 res = test_authenticated_decryption(&tdata);
9965 if (res == TEST_SKIPPED)
9967 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9968 return TEST_SUCCESS;
9972 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9974 struct crypto_testsuite_params *ts_params = &testsuite_params;
9975 struct crypto_unittest_params *ut_params = &unittest_params;
9978 uint8_t *ciphertext, *auth_tag;
9979 uint16_t plaintext_pad_len;
9981 /* Verify the capabilities */
9982 struct rte_cryptodev_sym_capability_idx cap_idx;
9983 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9984 cap_idx.algo.aead = tdata->algo;
9985 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9987 return TEST_SKIPPED;
9989 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9990 return TEST_SKIPPED;
9992 /* not supported with CPU crypto */
9993 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9994 return TEST_SKIPPED;
9996 /* Create AEAD session */
9997 retval = create_aead_session(ts_params->valid_devs[0],
9999 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10000 tdata->key.data, tdata->key.len,
10001 tdata->aad.len, tdata->auth_tag.len,
10006 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10007 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10009 /* clear mbuf payload */
10010 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10011 rte_pktmbuf_tailroom(ut_params->ibuf));
10012 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10013 rte_pktmbuf_tailroom(ut_params->obuf));
10015 /* Create AEAD operation */
10016 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10020 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10022 ut_params->op->sym->m_src = ut_params->ibuf;
10023 ut_params->op->sym->m_dst = ut_params->obuf;
10025 /* Process crypto operation */
10026 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10027 ut_params->op), "failed to process sym crypto op");
10029 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10030 "crypto op processing failed");
10032 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10034 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10035 ut_params->op->sym->cipher.data.offset);
10036 auth_tag = ciphertext + plaintext_pad_len;
10038 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10039 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10041 /* Validate obuf */
10042 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10044 tdata->ciphertext.data,
10045 tdata->ciphertext.len,
10046 "Ciphertext data not as expected");
10048 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10050 tdata->auth_tag.data,
10051 tdata->auth_tag.len,
10052 "Generated auth tag not as expected");
10059 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10061 return test_authenticated_encryption_oop(&gcm_test_case_5);
10065 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10067 struct crypto_testsuite_params *ts_params = &testsuite_params;
10068 struct crypto_unittest_params *ut_params = &unittest_params;
10071 uint8_t *plaintext;
10073 /* Verify the capabilities */
10074 struct rte_cryptodev_sym_capability_idx cap_idx;
10075 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10076 cap_idx.algo.aead = tdata->algo;
10077 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10079 return TEST_SKIPPED;
10081 /* not supported with CPU crypto and raw data-path APIs*/
10082 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10083 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10084 return TEST_SKIPPED;
10086 /* Create AEAD session */
10087 retval = create_aead_session(ts_params->valid_devs[0],
10089 RTE_CRYPTO_AEAD_OP_DECRYPT,
10090 tdata->key.data, tdata->key.len,
10091 tdata->aad.len, tdata->auth_tag.len,
10096 /* alloc mbuf and set payload */
10097 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10098 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10100 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10101 rte_pktmbuf_tailroom(ut_params->ibuf));
10102 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10103 rte_pktmbuf_tailroom(ut_params->obuf));
10105 /* Create AEAD operation */
10106 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10110 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10112 ut_params->op->sym->m_src = ut_params->ibuf;
10113 ut_params->op->sym->m_dst = ut_params->obuf;
10115 /* Process crypto operation */
10116 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10117 ut_params->op), "failed to process sym crypto op");
10119 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10120 "crypto op processing failed");
10122 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10123 ut_params->op->sym->cipher.data.offset);
10125 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10127 /* Validate obuf */
10128 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10130 tdata->plaintext.data,
10131 tdata->plaintext.len,
10132 "Plaintext data not as expected");
10134 TEST_ASSERT_EQUAL(ut_params->op->status,
10135 RTE_CRYPTO_OP_STATUS_SUCCESS,
10136 "Authentication failed");
10141 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10143 return test_authenticated_decryption_oop(&gcm_test_case_5);
10147 test_authenticated_encryption_sessionless(
10148 const struct aead_test_data *tdata)
10150 struct crypto_testsuite_params *ts_params = &testsuite_params;
10151 struct crypto_unittest_params *ut_params = &unittest_params;
10154 uint8_t *ciphertext, *auth_tag;
10155 uint16_t plaintext_pad_len;
10156 uint8_t key[tdata->key.len + 1];
10157 struct rte_cryptodev_info dev_info;
10159 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10160 uint64_t feat_flags = dev_info.feature_flags;
10162 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10163 printf("Device doesn't support Sessionless ops.\n");
10164 return TEST_SKIPPED;
10167 /* not supported with CPU crypto */
10168 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10169 return TEST_SKIPPED;
10171 /* Verify the capabilities */
10172 struct rte_cryptodev_sym_capability_idx cap_idx;
10173 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10174 cap_idx.algo.aead = tdata->algo;
10175 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10177 return TEST_SKIPPED;
10179 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10181 /* clear mbuf payload */
10182 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10183 rte_pktmbuf_tailroom(ut_params->ibuf));
10185 /* Create AEAD operation */
10186 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10190 /* Create GCM xform */
10191 memcpy(key, tdata->key.data, tdata->key.len);
10192 retval = create_aead_xform(ut_params->op,
10194 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10195 key, tdata->key.len,
10196 tdata->aad.len, tdata->auth_tag.len,
10201 ut_params->op->sym->m_src = ut_params->ibuf;
10203 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10204 RTE_CRYPTO_OP_SESSIONLESS,
10205 "crypto op session type not sessionless");
10207 /* Process crypto operation */
10208 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10209 ut_params->op), "failed to process sym crypto op");
10211 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10213 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10214 "crypto op status not success");
10216 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10218 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10219 ut_params->op->sym->cipher.data.offset);
10220 auth_tag = ciphertext + plaintext_pad_len;
10222 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10223 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10225 /* Validate obuf */
10226 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10228 tdata->ciphertext.data,
10229 tdata->ciphertext.len,
10230 "Ciphertext data not as expected");
10232 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10234 tdata->auth_tag.data,
10235 tdata->auth_tag.len,
10236 "Generated auth tag not as expected");
10243 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10245 return test_authenticated_encryption_sessionless(
10250 test_authenticated_decryption_sessionless(
10251 const struct aead_test_data *tdata)
10253 struct crypto_testsuite_params *ts_params = &testsuite_params;
10254 struct crypto_unittest_params *ut_params = &unittest_params;
10257 uint8_t *plaintext;
10258 uint8_t key[tdata->key.len + 1];
10259 struct rte_cryptodev_info dev_info;
10261 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10262 uint64_t feat_flags = dev_info.feature_flags;
10264 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10265 printf("Device doesn't support Sessionless ops.\n");
10266 return TEST_SKIPPED;
10269 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10270 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10271 printf("Device doesn't support RAW data-path APIs.\n");
10272 return TEST_SKIPPED;
10275 /* not supported with CPU crypto */
10276 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10277 return TEST_SKIPPED;
10279 /* Verify the capabilities */
10280 struct rte_cryptodev_sym_capability_idx cap_idx;
10281 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10282 cap_idx.algo.aead = tdata->algo;
10283 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10285 return TEST_SKIPPED;
10287 /* alloc mbuf and set payload */
10288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10290 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10291 rte_pktmbuf_tailroom(ut_params->ibuf));
10293 /* Create AEAD operation */
10294 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10298 /* Create AEAD xform */
10299 memcpy(key, tdata->key.data, tdata->key.len);
10300 retval = create_aead_xform(ut_params->op,
10302 RTE_CRYPTO_AEAD_OP_DECRYPT,
10303 key, tdata->key.len,
10304 tdata->aad.len, tdata->auth_tag.len,
10309 ut_params->op->sym->m_src = ut_params->ibuf;
10311 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10312 RTE_CRYPTO_OP_SESSIONLESS,
10313 "crypto op session type not sessionless");
10315 /* Process crypto operation */
10316 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10317 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10318 ut_params->op, 0, 0, 0, 0);
10320 TEST_ASSERT_NOT_NULL(process_crypto_request(
10321 ts_params->valid_devs[0], ut_params->op),
10322 "failed to process sym crypto op");
10324 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10326 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10327 "crypto op status not success");
10329 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10330 ut_params->op->sym->cipher.data.offset);
10332 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10334 /* Validate obuf */
10335 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10337 tdata->plaintext.data,
10338 tdata->plaintext.len,
10339 "Plaintext data not as expected");
10341 TEST_ASSERT_EQUAL(ut_params->op->status,
10342 RTE_CRYPTO_OP_STATUS_SUCCESS,
10343 "Authentication failed");
10348 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10350 return test_authenticated_decryption_sessionless(
10355 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10357 return test_authenticated_encryption(&ccm_test_case_128_1);
10361 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10363 return test_authenticated_encryption(&ccm_test_case_128_2);
10367 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10369 return test_authenticated_encryption(&ccm_test_case_128_3);
10373 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10375 return test_authenticated_decryption(&ccm_test_case_128_1);
10379 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10381 return test_authenticated_decryption(&ccm_test_case_128_2);
10385 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10387 return test_authenticated_decryption(&ccm_test_case_128_3);
10391 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10393 return test_authenticated_encryption(&ccm_test_case_192_1);
10397 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10399 return test_authenticated_encryption(&ccm_test_case_192_2);
10403 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10405 return test_authenticated_encryption(&ccm_test_case_192_3);
10409 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10411 return test_authenticated_decryption(&ccm_test_case_192_1);
10415 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10417 return test_authenticated_decryption(&ccm_test_case_192_2);
10421 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10423 return test_authenticated_decryption(&ccm_test_case_192_3);
10427 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10429 return test_authenticated_encryption(&ccm_test_case_256_1);
10433 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10435 return test_authenticated_encryption(&ccm_test_case_256_2);
10439 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10441 return test_authenticated_encryption(&ccm_test_case_256_3);
10445 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10447 return test_authenticated_decryption(&ccm_test_case_256_1);
10451 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10453 return test_authenticated_decryption(&ccm_test_case_256_2);
10457 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10459 return test_authenticated_decryption(&ccm_test_case_256_3);
10465 struct crypto_testsuite_params *ts_params = &testsuite_params;
10466 struct rte_cryptodev_stats stats;
10468 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10469 return TEST_SKIPPED;
10471 /* Verify the capabilities */
10472 struct rte_cryptodev_sym_capability_idx cap_idx;
10473 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10474 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10475 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10477 return TEST_SKIPPED;
10478 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10479 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10480 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10482 return TEST_SKIPPED;
10484 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10486 return TEST_SKIPPED;
10488 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10489 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10490 &stats) == -ENODEV),
10491 "rte_cryptodev_stats_get invalid dev failed");
10492 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10493 "rte_cryptodev_stats_get invalid Param failed");
10495 /* Test expected values */
10496 test_AES_CBC_HMAC_SHA1_encrypt_digest();
10497 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10499 "rte_cryptodev_stats_get failed");
10500 TEST_ASSERT((stats.enqueued_count == 1),
10501 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10502 TEST_ASSERT((stats.dequeued_count == 1),
10503 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10504 TEST_ASSERT((stats.enqueue_err_count == 0),
10505 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10506 TEST_ASSERT((stats.dequeue_err_count == 0),
10507 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10509 /* invalid device but should ignore and not reset device stats*/
10510 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10511 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10513 "rte_cryptodev_stats_get failed");
10514 TEST_ASSERT((stats.enqueued_count == 1),
10515 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10517 /* check that a valid reset clears stats */
10518 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10519 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10521 "rte_cryptodev_stats_get failed");
10522 TEST_ASSERT((stats.enqueued_count == 0),
10523 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10524 TEST_ASSERT((stats.dequeued_count == 0),
10525 "rte_cryptodev_stats_get returned unexpected enqueued stat");
10527 return TEST_SUCCESS;
10530 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10531 struct crypto_unittest_params *ut_params,
10532 enum rte_crypto_auth_operation op,
10533 const struct HMAC_MD5_vector *test_case)
10537 memcpy(key, test_case->key.data, test_case->key.len);
10539 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10540 ut_params->auth_xform.next = NULL;
10541 ut_params->auth_xform.auth.op = op;
10543 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10545 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10546 ut_params->auth_xform.auth.key.length = test_case->key.len;
10547 ut_params->auth_xform.auth.key.data = key;
10549 ut_params->sess = rte_cryptodev_sym_session_create(
10550 ts_params->session_mpool);
10552 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10553 ut_params->sess, &ut_params->auth_xform,
10554 ts_params->session_priv_mpool);
10556 if (ut_params->sess == NULL)
10557 return TEST_FAILED;
10559 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10561 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10562 rte_pktmbuf_tailroom(ut_params->ibuf));
10567 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10568 const struct HMAC_MD5_vector *test_case,
10569 uint8_t **plaintext)
10571 uint16_t plaintext_pad_len;
10573 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10575 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10578 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10579 plaintext_pad_len);
10580 memcpy(*plaintext, test_case->plaintext.data,
10581 test_case->plaintext.len);
10583 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10584 ut_params->ibuf, MD5_DIGEST_LEN);
10585 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10586 "no room to append digest");
10587 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10588 ut_params->ibuf, plaintext_pad_len);
10590 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10591 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10592 test_case->auth_tag.len);
10595 sym_op->auth.data.offset = 0;
10596 sym_op->auth.data.length = test_case->plaintext.len;
10598 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10599 ut_params->op->sym->m_src = ut_params->ibuf;
10605 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10607 uint16_t plaintext_pad_len;
10608 uint8_t *plaintext, *auth_tag;
10610 struct crypto_testsuite_params *ts_params = &testsuite_params;
10611 struct crypto_unittest_params *ut_params = &unittest_params;
10612 struct rte_cryptodev_info dev_info;
10614 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10615 uint64_t feat_flags = dev_info.feature_flags;
10617 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10618 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10619 printf("Device doesn't support RAW data-path APIs.\n");
10620 return TEST_SKIPPED;
10623 /* Verify the capabilities */
10624 struct rte_cryptodev_sym_capability_idx cap_idx;
10625 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10626 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10627 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10629 return TEST_SKIPPED;
10631 if (MD5_HMAC_create_session(ts_params, ut_params,
10632 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10633 return TEST_FAILED;
10635 /* Generate Crypto op data structure */
10636 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10637 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10638 TEST_ASSERT_NOT_NULL(ut_params->op,
10639 "Failed to allocate symmetric crypto operation struct");
10641 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10644 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10645 return TEST_FAILED;
10647 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10648 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10650 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10651 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10652 ut_params->op, 0, 1, 0, 0);
10654 TEST_ASSERT_NOT_NULL(
10655 process_crypto_request(ts_params->valid_devs[0],
10657 "failed to process sym crypto op");
10659 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10660 "crypto op processing failed");
10662 if (ut_params->op->sym->m_dst) {
10663 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10664 uint8_t *, plaintext_pad_len);
10666 auth_tag = plaintext + plaintext_pad_len;
10669 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10671 test_case->auth_tag.data,
10672 test_case->auth_tag.len,
10673 "HMAC_MD5 generated tag not as expected");
10675 return TEST_SUCCESS;
10679 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10681 uint8_t *plaintext;
10683 struct crypto_testsuite_params *ts_params = &testsuite_params;
10684 struct crypto_unittest_params *ut_params = &unittest_params;
10685 struct rte_cryptodev_info dev_info;
10687 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10688 uint64_t feat_flags = dev_info.feature_flags;
10690 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10691 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10692 printf("Device doesn't support RAW data-path APIs.\n");
10693 return TEST_SKIPPED;
10696 /* Verify the capabilities */
10697 struct rte_cryptodev_sym_capability_idx cap_idx;
10698 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10699 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10700 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10702 return TEST_SKIPPED;
10704 if (MD5_HMAC_create_session(ts_params, ut_params,
10705 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10706 return TEST_FAILED;
10709 /* Generate Crypto op data structure */
10710 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10711 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10712 TEST_ASSERT_NOT_NULL(ut_params->op,
10713 "Failed to allocate symmetric crypto operation struct");
10715 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10716 return TEST_FAILED;
10718 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10719 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10721 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10722 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10723 ut_params->op, 0, 1, 0, 0);
10725 TEST_ASSERT_NOT_NULL(
10726 process_crypto_request(ts_params->valid_devs[0],
10728 "failed to process sym crypto op");
10730 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10731 "HMAC_MD5 crypto op processing failed");
10733 return TEST_SUCCESS;
10737 test_MD5_HMAC_generate_case_1(void)
10739 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10743 test_MD5_HMAC_verify_case_1(void)
10745 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10749 test_MD5_HMAC_generate_case_2(void)
10751 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10755 test_MD5_HMAC_verify_case_2(void)
10757 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10761 test_multi_session(void)
10763 struct crypto_testsuite_params *ts_params = &testsuite_params;
10764 struct crypto_unittest_params *ut_params = &unittest_params;
10766 struct rte_cryptodev_info dev_info;
10767 struct rte_cryptodev_sym_session **sessions;
10771 /* Verify the capabilities */
10772 struct rte_cryptodev_sym_capability_idx cap_idx;
10773 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10774 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10775 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10777 return TEST_SKIPPED;
10778 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10779 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10780 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10782 return TEST_SKIPPED;
10784 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10785 aes_cbc_key, hmac_sha512_key);
10788 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10790 sessions = rte_malloc(NULL,
10791 sizeof(struct rte_cryptodev_sym_session *) *
10792 (MAX_NB_SESSIONS + 1), 0);
10794 /* Create multiple crypto sessions*/
10795 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10797 sessions[i] = rte_cryptodev_sym_session_create(
10798 ts_params->session_mpool);
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_NOT_NULL(sessions[i],
10804 "Session creation failed at session number %u",
10807 /* Attempt to send a request on each session */
10808 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10812 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10813 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10815 "Failed to perform decrypt on request number %u.", i);
10816 /* free crypto operation structure */
10818 rte_crypto_op_free(ut_params->op);
10821 * free mbuf - both obuf and ibuf are usually the same,
10822 * so check if they point at the same address is necessary,
10823 * to avoid freeing the mbuf twice.
10825 if (ut_params->obuf) {
10826 rte_pktmbuf_free(ut_params->obuf);
10827 if (ut_params->ibuf == ut_params->obuf)
10828 ut_params->ibuf = 0;
10829 ut_params->obuf = 0;
10831 if (ut_params->ibuf) {
10832 rte_pktmbuf_free(ut_params->ibuf);
10833 ut_params->ibuf = 0;
10837 sessions[i] = NULL;
10838 /* Next session create should fail */
10839 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10840 sessions[i], &ut_params->auth_xform,
10841 ts_params->session_priv_mpool);
10842 TEST_ASSERT_NULL(sessions[i],
10843 "Session creation succeeded unexpectedly!");
10845 for (i = 0; i < MAX_NB_SESSIONS; i++) {
10846 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10848 rte_cryptodev_sym_session_free(sessions[i]);
10851 rte_free(sessions);
10853 return TEST_SUCCESS;
10856 struct multi_session_params {
10857 struct crypto_unittest_params ut_params;
10858 uint8_t *cipher_key;
10860 const uint8_t *cipher;
10861 const uint8_t *digest;
10865 #define MB_SESSION_NUMBER 3
10868 test_multi_session_random_usage(void)
10870 struct crypto_testsuite_params *ts_params = &testsuite_params;
10871 struct rte_cryptodev_info dev_info;
10872 struct rte_cryptodev_sym_session **sessions;
10874 struct multi_session_params ut_paramz[] = {
10877 .cipher_key = ms_aes_cbc_key0,
10878 .hmac_key = ms_hmac_key0,
10879 .cipher = ms_aes_cbc_cipher0,
10880 .digest = ms_hmac_digest0,
10881 .iv = ms_aes_cbc_iv0
10884 .cipher_key = ms_aes_cbc_key1,
10885 .hmac_key = ms_hmac_key1,
10886 .cipher = ms_aes_cbc_cipher1,
10887 .digest = ms_hmac_digest1,
10888 .iv = ms_aes_cbc_iv1
10891 .cipher_key = ms_aes_cbc_key2,
10892 .hmac_key = ms_hmac_key2,
10893 .cipher = ms_aes_cbc_cipher2,
10894 .digest = ms_hmac_digest2,
10895 .iv = ms_aes_cbc_iv2
10900 /* Verify the capabilities */
10901 struct rte_cryptodev_sym_capability_idx cap_idx;
10902 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10903 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10904 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10906 return TEST_SKIPPED;
10907 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10908 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10909 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10911 return TEST_SKIPPED;
10913 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10915 sessions = rte_malloc(NULL,
10916 (sizeof(struct rte_cryptodev_sym_session *)
10917 * MAX_NB_SESSIONS) + 1, 0);
10919 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10920 sessions[i] = rte_cryptodev_sym_session_create(
10921 ts_params->session_mpool);
10923 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10924 sizeof(struct crypto_unittest_params));
10926 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10927 &ut_paramz[i].ut_params,
10928 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10930 /* Create multiple crypto sessions*/
10931 rte_cryptodev_sym_session_init(
10932 ts_params->valid_devs[0],
10934 &ut_paramz[i].ut_params.auth_xform,
10935 ts_params->session_priv_mpool);
10937 TEST_ASSERT_NOT_NULL(sessions[i],
10938 "Session creation failed at session number %u",
10944 for (i = 0; i < 40000; i++) {
10946 j = rand() % MB_SESSION_NUMBER;
10948 TEST_ASSERT_SUCCESS(
10949 test_AES_CBC_HMAC_SHA512_decrypt_perform(
10951 &ut_paramz[j].ut_params,
10952 ts_params, ut_paramz[j].cipher,
10953 ut_paramz[j].digest,
10955 "Failed to perform decrypt on request number %u.", i);
10957 if (ut_paramz[j].ut_params.op)
10958 rte_crypto_op_free(ut_paramz[j].ut_params.op);
10961 * free mbuf - both obuf and ibuf are usually the same,
10962 * so check if they point at the same address is necessary,
10963 * to avoid freeing the mbuf twice.
10965 if (ut_paramz[j].ut_params.obuf) {
10966 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10967 if (ut_paramz[j].ut_params.ibuf
10968 == ut_paramz[j].ut_params.obuf)
10969 ut_paramz[j].ut_params.ibuf = 0;
10970 ut_paramz[j].ut_params.obuf = 0;
10972 if (ut_paramz[j].ut_params.ibuf) {
10973 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10974 ut_paramz[j].ut_params.ibuf = 0;
10978 for (i = 0; i < MB_SESSION_NUMBER; i++) {
10979 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10981 rte_cryptodev_sym_session_free(sessions[i]);
10984 rte_free(sessions);
10986 return TEST_SUCCESS;
10989 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10990 0xab, 0xab, 0xab, 0xab,
10991 0xab, 0xab, 0xab, 0xab,
10992 0xab, 0xab, 0xab, 0xab};
10995 test_null_invalid_operation(void)
10997 struct crypto_testsuite_params *ts_params = &testsuite_params;
10998 struct crypto_unittest_params *ut_params = &unittest_params;
11001 /* This test is for NULL PMD only */
11002 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11003 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11004 return TEST_SKIPPED;
11006 /* Setup Cipher Parameters */
11007 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11008 ut_params->cipher_xform.next = NULL;
11010 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11011 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11013 ut_params->sess = rte_cryptodev_sym_session_create(
11014 ts_params->session_mpool);
11016 /* Create Crypto session*/
11017 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11018 ut_params->sess, &ut_params->cipher_xform,
11019 ts_params->session_priv_mpool);
11020 TEST_ASSERT(ret < 0,
11021 "Session creation succeeded unexpectedly");
11024 /* Setup HMAC Parameters */
11025 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11026 ut_params->auth_xform.next = NULL;
11028 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11029 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11031 ut_params->sess = rte_cryptodev_sym_session_create(
11032 ts_params->session_mpool);
11034 /* Create Crypto session*/
11035 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11036 ut_params->sess, &ut_params->auth_xform,
11037 ts_params->session_priv_mpool);
11038 TEST_ASSERT(ret < 0,
11039 "Session creation succeeded unexpectedly");
11041 return TEST_SUCCESS;
11045 #define NULL_BURST_LENGTH (32)
11048 test_null_burst_operation(void)
11050 struct crypto_testsuite_params *ts_params = &testsuite_params;
11051 struct crypto_unittest_params *ut_params = &unittest_params;
11053 unsigned i, burst_len = NULL_BURST_LENGTH;
11055 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11056 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11058 /* This test is for NULL PMD only */
11059 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11060 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11061 return TEST_SKIPPED;
11063 /* Setup Cipher Parameters */
11064 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11065 ut_params->cipher_xform.next = &ut_params->auth_xform;
11067 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11068 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11070 /* Setup HMAC Parameters */
11071 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11072 ut_params->auth_xform.next = NULL;
11074 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11075 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11077 ut_params->sess = rte_cryptodev_sym_session_create(
11078 ts_params->session_mpool);
11080 /* Create Crypto session*/
11081 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11082 ut_params->sess, &ut_params->cipher_xform,
11083 ts_params->session_priv_mpool);
11084 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11086 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11087 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11088 burst_len, "failed to generate burst of crypto ops");
11090 /* Generate an operation for each mbuf in burst */
11091 for (i = 0; i < burst_len; i++) {
11092 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11094 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11096 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11100 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11102 burst[i]->sym->m_src = m;
11105 /* Process crypto operation */
11106 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11107 0, burst, burst_len),
11109 "Error enqueuing burst");
11111 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11112 0, burst_dequeued, burst_len),
11114 "Error dequeuing burst");
11117 for (i = 0; i < burst_len; i++) {
11119 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11120 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11122 "data not as expected");
11124 rte_pktmbuf_free(burst[i]->sym->m_src);
11125 rte_crypto_op_free(burst[i]);
11128 return TEST_SUCCESS;
11132 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11133 uint16_t nb_ops, void *user_param)
11135 RTE_SET_USED(dev_id);
11136 RTE_SET_USED(qp_id);
11138 RTE_SET_USED(user_param);
11140 printf("crypto enqueue callback called\n");
11145 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11146 uint16_t nb_ops, void *user_param)
11148 RTE_SET_USED(dev_id);
11149 RTE_SET_USED(qp_id);
11151 RTE_SET_USED(user_param);
11153 printf("crypto dequeue callback called\n");
11158 * Thread using enqueue/dequeue callback with RCU.
11161 test_enqdeq_callback_thread(void *arg)
11164 /* DP thread calls rte_cryptodev_enqueue_burst()/
11165 * rte_cryptodev_dequeue_burst() and invokes callback.
11167 test_null_burst_operation();
11172 test_enq_callback_setup(void)
11174 struct crypto_testsuite_params *ts_params = &testsuite_params;
11175 struct rte_cryptodev_info dev_info;
11176 struct rte_cryptodev_qp_conf qp_conf = {
11177 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11180 struct rte_cryptodev_cb *cb;
11181 uint16_t qp_id = 0;
11183 /* Stop the device in case it's started so it can be configured */
11184 rte_cryptodev_stop(ts_params->valid_devs[0]);
11186 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11188 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11190 "Failed to configure cryptodev %u",
11191 ts_params->valid_devs[0]);
11193 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11194 qp_conf.mp_session = ts_params->session_mpool;
11195 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11197 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11198 ts_params->valid_devs[0], qp_id, &qp_conf,
11199 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11201 "rte_cryptodev_queue_pair_setup: num_inflights "
11202 "%u on qp %u on cryptodev %u",
11203 qp_conf.nb_descriptors, qp_id,
11204 ts_params->valid_devs[0]);
11206 /* Test with invalid crypto device */
11207 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11208 qp_id, test_enq_callback, NULL);
11209 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11210 "cryptodev %u did not fail",
11211 qp_id, RTE_CRYPTO_MAX_DEVS);
11213 /* Test with invalid queue pair */
11214 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11215 dev_info.max_nb_queue_pairs + 1,
11216 test_enq_callback, NULL);
11217 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11218 "cryptodev %u did not fail",
11219 dev_info.max_nb_queue_pairs + 1,
11220 ts_params->valid_devs[0]);
11222 /* Test with NULL callback */
11223 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11224 qp_id, NULL, NULL);
11225 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11226 "cryptodev %u did not fail",
11227 qp_id, ts_params->valid_devs[0]);
11229 /* Test with valid configuration */
11230 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11231 qp_id, test_enq_callback, NULL);
11232 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11233 "qp %u on cryptodev %u",
11234 qp_id, ts_params->valid_devs[0]);
11236 rte_cryptodev_start(ts_params->valid_devs[0]);
11238 /* Launch a thread */
11239 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11240 rte_get_next_lcore(-1, 1, 0));
11242 /* Wait until reader exited. */
11243 rte_eal_mp_wait_lcore();
11245 /* Test with invalid crypto device */
11246 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11247 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11248 "Expected call to fail as crypto device is invalid");
11250 /* Test with invalid queue pair */
11251 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11252 ts_params->valid_devs[0],
11253 dev_info.max_nb_queue_pairs + 1, cb),
11254 "Expected call to fail as queue pair is invalid");
11256 /* Test with NULL callback */
11257 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11258 ts_params->valid_devs[0], qp_id, NULL),
11259 "Expected call to fail as callback is NULL");
11261 /* Test with valid configuration */
11262 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11263 ts_params->valid_devs[0], qp_id, cb),
11264 "Failed test to remove callback on "
11265 "qp %u on cryptodev %u",
11266 qp_id, ts_params->valid_devs[0]);
11268 return TEST_SUCCESS;
11272 test_deq_callback_setup(void)
11274 struct crypto_testsuite_params *ts_params = &testsuite_params;
11275 struct rte_cryptodev_info dev_info;
11276 struct rte_cryptodev_qp_conf qp_conf = {
11277 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
11280 struct rte_cryptodev_cb *cb;
11281 uint16_t qp_id = 0;
11283 /* Stop the device in case it's started so it can be configured */
11284 rte_cryptodev_stop(ts_params->valid_devs[0]);
11286 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11288 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11290 "Failed to configure cryptodev %u",
11291 ts_params->valid_devs[0]);
11293 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11294 qp_conf.mp_session = ts_params->session_mpool;
11295 qp_conf.mp_session_private = ts_params->session_priv_mpool;
11297 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11298 ts_params->valid_devs[0], qp_id, &qp_conf,
11299 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11301 "rte_cryptodev_queue_pair_setup: num_inflights "
11302 "%u on qp %u on cryptodev %u",
11303 qp_conf.nb_descriptors, qp_id,
11304 ts_params->valid_devs[0]);
11306 /* Test with invalid crypto device */
11307 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11308 qp_id, test_deq_callback, NULL);
11309 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11310 "cryptodev %u did not fail",
11311 qp_id, RTE_CRYPTO_MAX_DEVS);
11313 /* Test with invalid queue pair */
11314 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11315 dev_info.max_nb_queue_pairs + 1,
11316 test_deq_callback, NULL);
11317 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11318 "cryptodev %u did not fail",
11319 dev_info.max_nb_queue_pairs + 1,
11320 ts_params->valid_devs[0]);
11322 /* Test with NULL callback */
11323 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11324 qp_id, NULL, NULL);
11325 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11326 "cryptodev %u did not fail",
11327 qp_id, ts_params->valid_devs[0]);
11329 /* Test with valid configuration */
11330 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11331 qp_id, test_deq_callback, NULL);
11332 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11333 "qp %u on cryptodev %u",
11334 qp_id, ts_params->valid_devs[0]);
11336 rte_cryptodev_start(ts_params->valid_devs[0]);
11338 /* Launch a thread */
11339 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11340 rte_get_next_lcore(-1, 1, 0));
11342 /* Wait until reader exited. */
11343 rte_eal_mp_wait_lcore();
11345 /* Test with invalid crypto device */
11346 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11347 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11348 "Expected call to fail as crypto device is invalid");
11350 /* Test with invalid queue pair */
11351 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11352 ts_params->valid_devs[0],
11353 dev_info.max_nb_queue_pairs + 1, cb),
11354 "Expected call to fail as queue pair is invalid");
11356 /* Test with NULL callback */
11357 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11358 ts_params->valid_devs[0], qp_id, NULL),
11359 "Expected call to fail as callback is NULL");
11361 /* Test with valid configuration */
11362 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11363 ts_params->valid_devs[0], qp_id, cb),
11364 "Failed test to remove callback on "
11365 "qp %u on cryptodev %u",
11366 qp_id, ts_params->valid_devs[0]);
11368 return TEST_SUCCESS;
11372 generate_gmac_large_plaintext(uint8_t *data)
11376 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11377 memcpy(&data[i], &data[0], 32);
11381 create_gmac_operation(enum rte_crypto_auth_operation op,
11382 const struct gmac_test_data *tdata)
11384 struct crypto_testsuite_params *ts_params = &testsuite_params;
11385 struct crypto_unittest_params *ut_params = &unittest_params;
11386 struct rte_crypto_sym_op *sym_op;
11388 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11390 /* Generate Crypto op data structure */
11391 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11392 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11393 TEST_ASSERT_NOT_NULL(ut_params->op,
11394 "Failed to allocate symmetric crypto operation struct");
11396 sym_op = ut_params->op->sym;
11398 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11399 ut_params->ibuf, tdata->gmac_tag.len);
11400 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11401 "no room to append digest");
11403 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11404 ut_params->ibuf, plaintext_pad_len);
11406 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11407 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11408 tdata->gmac_tag.len);
11409 debug_hexdump(stdout, "digest:",
11410 sym_op->auth.digest.data,
11411 tdata->gmac_tag.len);
11414 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11415 uint8_t *, IV_OFFSET);
11417 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11419 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11421 sym_op->cipher.data.length = 0;
11422 sym_op->cipher.data.offset = 0;
11424 sym_op->auth.data.offset = 0;
11425 sym_op->auth.data.length = tdata->plaintext.len;
11431 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11432 const struct gmac_test_data *tdata,
11433 void *digest_mem, uint64_t digest_phys)
11435 struct crypto_testsuite_params *ts_params = &testsuite_params;
11436 struct crypto_unittest_params *ut_params = &unittest_params;
11437 struct rte_crypto_sym_op *sym_op;
11439 /* Generate Crypto op data structure */
11440 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11441 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11442 TEST_ASSERT_NOT_NULL(ut_params->op,
11443 "Failed to allocate symmetric crypto operation struct");
11445 sym_op = ut_params->op->sym;
11447 sym_op->auth.digest.data = digest_mem;
11448 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11449 "no room to append digest");
11451 sym_op->auth.digest.phys_addr = digest_phys;
11453 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11454 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11455 tdata->gmac_tag.len);
11456 debug_hexdump(stdout, "digest:",
11457 sym_op->auth.digest.data,
11458 tdata->gmac_tag.len);
11461 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11462 uint8_t *, IV_OFFSET);
11464 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11466 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11468 sym_op->cipher.data.length = 0;
11469 sym_op->cipher.data.offset = 0;
11471 sym_op->auth.data.offset = 0;
11472 sym_op->auth.data.length = tdata->plaintext.len;
11477 static int create_gmac_session(uint8_t dev_id,
11478 const struct gmac_test_data *tdata,
11479 enum rte_crypto_auth_operation auth_op)
11481 uint8_t auth_key[tdata->key.len];
11483 struct crypto_testsuite_params *ts_params = &testsuite_params;
11484 struct crypto_unittest_params *ut_params = &unittest_params;
11486 memcpy(auth_key, tdata->key.data, tdata->key.len);
11488 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11489 ut_params->auth_xform.next = NULL;
11491 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11492 ut_params->auth_xform.auth.op = auth_op;
11493 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11494 ut_params->auth_xform.auth.key.length = tdata->key.len;
11495 ut_params->auth_xform.auth.key.data = auth_key;
11496 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11497 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11500 ut_params->sess = rte_cryptodev_sym_session_create(
11501 ts_params->session_mpool);
11503 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11504 &ut_params->auth_xform,
11505 ts_params->session_priv_mpool);
11507 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11513 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11515 struct crypto_testsuite_params *ts_params = &testsuite_params;
11516 struct crypto_unittest_params *ut_params = &unittest_params;
11517 struct rte_cryptodev_info dev_info;
11519 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11520 uint64_t feat_flags = dev_info.feature_flags;
11522 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11523 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11524 printf("Device doesn't support RAW data-path APIs.\n");
11525 return TEST_SKIPPED;
11530 uint8_t *auth_tag, *plaintext;
11531 uint16_t plaintext_pad_len;
11533 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11534 "No GMAC length in the source data");
11536 /* Verify the capabilities */
11537 struct rte_cryptodev_sym_capability_idx cap_idx;
11538 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11539 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11540 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11542 return TEST_SKIPPED;
11544 retval = create_gmac_session(ts_params->valid_devs[0],
11545 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11550 if (tdata->plaintext.len > MBUF_SIZE)
11551 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11553 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11554 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11555 "Failed to allocate input buffer in mempool");
11557 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11558 rte_pktmbuf_tailroom(ut_params->ibuf));
11560 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11562 * Runtime generate the large plain text instead of use hard code
11563 * plain text vector. It is done to avoid create huge source file
11564 * with the test vector.
11566 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11567 generate_gmac_large_plaintext(tdata->plaintext.data);
11569 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11570 plaintext_pad_len);
11571 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11573 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11574 debug_hexdump(stdout, "plaintext:", plaintext,
11575 tdata->plaintext.len);
11577 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11583 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11585 ut_params->op->sym->m_src = ut_params->ibuf;
11587 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11588 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11590 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11591 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11592 ut_params->op, 0, 1, 0, 0);
11594 TEST_ASSERT_NOT_NULL(
11595 process_crypto_request(ts_params->valid_devs[0],
11596 ut_params->op), "failed to process sym crypto op");
11598 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11599 "crypto op processing failed");
11601 if (ut_params->op->sym->m_dst) {
11602 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11603 uint8_t *, plaintext_pad_len);
11605 auth_tag = plaintext + plaintext_pad_len;
11608 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11610 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11612 tdata->gmac_tag.data,
11613 tdata->gmac_tag.len,
11614 "GMAC Generated auth tag not as expected");
11620 test_AES_GMAC_authentication_test_case_1(void)
11622 return test_AES_GMAC_authentication(&gmac_test_case_1);
11626 test_AES_GMAC_authentication_test_case_2(void)
11628 return test_AES_GMAC_authentication(&gmac_test_case_2);
11632 test_AES_GMAC_authentication_test_case_3(void)
11634 return test_AES_GMAC_authentication(&gmac_test_case_3);
11638 test_AES_GMAC_authentication_test_case_4(void)
11640 return test_AES_GMAC_authentication(&gmac_test_case_4);
11644 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11646 struct crypto_testsuite_params *ts_params = &testsuite_params;
11647 struct crypto_unittest_params *ut_params = &unittest_params;
11649 uint32_t plaintext_pad_len;
11650 uint8_t *plaintext;
11651 struct rte_cryptodev_info dev_info;
11653 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11654 uint64_t feat_flags = dev_info.feature_flags;
11656 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11657 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11658 printf("Device doesn't support RAW data-path APIs.\n");
11659 return TEST_SKIPPED;
11662 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11663 "No GMAC length in the source data");
11665 /* Verify the capabilities */
11666 struct rte_cryptodev_sym_capability_idx cap_idx;
11667 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11668 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11669 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11671 return TEST_SKIPPED;
11673 retval = create_gmac_session(ts_params->valid_devs[0],
11674 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11679 if (tdata->plaintext.len > MBUF_SIZE)
11680 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11682 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11683 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11684 "Failed to allocate input buffer in mempool");
11686 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11687 rte_pktmbuf_tailroom(ut_params->ibuf));
11689 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11692 * Runtime generate the large plain text instead of use hard code
11693 * plain text vector. It is done to avoid create huge source file
11694 * with the test vector.
11696 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11697 generate_gmac_large_plaintext(tdata->plaintext.data);
11699 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11700 plaintext_pad_len);
11701 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11703 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11704 debug_hexdump(stdout, "plaintext:", plaintext,
11705 tdata->plaintext.len);
11707 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11713 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11715 ut_params->op->sym->m_src = ut_params->ibuf;
11717 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11718 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11720 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11721 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11722 ut_params->op, 0, 1, 0, 0);
11724 TEST_ASSERT_NOT_NULL(
11725 process_crypto_request(ts_params->valid_devs[0],
11726 ut_params->op), "failed to process sym crypto op");
11728 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11729 "crypto op processing failed");
11736 test_AES_GMAC_authentication_verify_test_case_1(void)
11738 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11742 test_AES_GMAC_authentication_verify_test_case_2(void)
11744 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11748 test_AES_GMAC_authentication_verify_test_case_3(void)
11750 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11754 test_AES_GMAC_authentication_verify_test_case_4(void)
11756 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11760 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11763 struct crypto_testsuite_params *ts_params = &testsuite_params;
11764 struct crypto_unittest_params *ut_params = &unittest_params;
11765 struct rte_cryptodev_info dev_info;
11766 uint64_t feature_flags;
11767 unsigned int trn_data = 0;
11768 void *digest_mem = NULL;
11770 unsigned int to_trn = 0;
11771 struct rte_mbuf *buf = NULL;
11772 uint8_t *auth_tag, *plaintext;
11775 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11776 "No GMAC length in the source data");
11778 /* Verify the capabilities */
11779 struct rte_cryptodev_sym_capability_idx cap_idx;
11780 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11781 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11782 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11784 return TEST_SKIPPED;
11786 /* Check for any input SGL support */
11787 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11788 feature_flags = dev_info.feature_flags;
11790 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11791 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11792 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11793 return TEST_SKIPPED;
11795 if (fragsz > tdata->plaintext.len)
11796 fragsz = tdata->plaintext.len;
11798 uint16_t plaintext_len = fragsz;
11800 retval = create_gmac_session(ts_params->valid_devs[0],
11801 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11806 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11807 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11808 "Failed to allocate input buffer in mempool");
11810 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11811 rte_pktmbuf_tailroom(ut_params->ibuf));
11813 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11815 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11817 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11819 trn_data += plaintext_len;
11821 buf = ut_params->ibuf;
11824 * Loop until no more fragments
11827 while (trn_data < tdata->plaintext.len) {
11829 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11830 (tdata->plaintext.len - trn_data) : fragsz;
11832 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11835 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11836 rte_pktmbuf_tailroom(buf));
11838 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11841 memcpy(plaintext, tdata->plaintext.data + trn_data,
11843 trn_data += to_trn;
11844 if (trn_data == tdata->plaintext.len)
11845 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11846 tdata->gmac_tag.len);
11848 ut_params->ibuf->nb_segs = segs;
11851 * Place digest at the end of the last buffer
11853 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11856 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11857 + tdata->gmac_tag.len);
11858 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11859 tdata->plaintext.len);
11862 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11863 tdata, digest_mem, digest_phys);
11868 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11870 ut_params->op->sym->m_src = ut_params->ibuf;
11872 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11873 return TEST_SKIPPED;
11875 TEST_ASSERT_NOT_NULL(
11876 process_crypto_request(ts_params->valid_devs[0],
11877 ut_params->op), "failed to process sym crypto op");
11879 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11880 "crypto op processing failed");
11882 auth_tag = digest_mem;
11883 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11884 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11886 tdata->gmac_tag.data,
11887 tdata->gmac_tag.len,
11888 "GMAC Generated auth tag not as expected");
11893 /* Segment size not multiple of block size (16B) */
11895 test_AES_GMAC_authentication_SGL_40B(void)
11897 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11901 test_AES_GMAC_authentication_SGL_80B(void)
11903 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11907 test_AES_GMAC_authentication_SGL_2048B(void)
11909 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11912 /* Segment size not multiple of block size (16B) */
11914 test_AES_GMAC_authentication_SGL_2047B(void)
11916 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11919 struct test_crypto_vector {
11920 enum rte_crypto_cipher_algorithm crypto_algo;
11921 unsigned int cipher_offset;
11922 unsigned int cipher_len;
11935 const uint8_t *data;
11940 const uint8_t *data;
11944 enum rte_crypto_auth_algorithm auth_algo;
11945 unsigned int auth_offset;
11953 const uint8_t *data;
11963 static const struct test_crypto_vector
11964 hmac_sha1_test_crypto_vector = {
11965 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11967 .data = plaintext_hash,
11972 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11973 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11974 0xDE, 0xF4, 0xDE, 0xAD
11980 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11981 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11982 0x3F, 0x91, 0x64, 0x59
11988 static const struct test_crypto_vector
11989 aes128_gmac_test_vector = {
11990 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11992 .data = plaintext_hash,
11997 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11998 0x08, 0x09, 0x0A, 0x0B
12004 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12005 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12011 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12012 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12018 static const struct test_crypto_vector
12019 aes128cbc_hmac_sha1_test_vector = {
12020 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12021 .cipher_offset = 0,
12025 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12026 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12032 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12033 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12038 .data = plaintext_hash,
12042 .data = ciphertext512_aes128cbc,
12045 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12049 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12050 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12051 0xDE, 0xF4, 0xDE, 0xAD
12057 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12058 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12059 0x18, 0x8C, 0x1D, 0x32
12065 static const struct test_crypto_vector
12066 aes128cbc_hmac_sha1_aad_test_vector = {
12067 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12068 .cipher_offset = 8,
12072 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12073 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12079 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12080 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12085 .data = plaintext_hash,
12089 .data = ciphertext512_aes128cbc_aad,
12092 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12096 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12097 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12098 0xDE, 0xF4, 0xDE, 0xAD
12104 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12105 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12106 0x62, 0x0F, 0xFB, 0x10
12113 data_corruption(uint8_t *data)
12119 tag_corruption(uint8_t *data, unsigned int tag_offset)
12121 data[tag_offset] += 1;
12125 create_auth_session(struct crypto_unittest_params *ut_params,
12127 const struct test_crypto_vector *reference,
12128 enum rte_crypto_auth_operation auth_op)
12130 struct crypto_testsuite_params *ts_params = &testsuite_params;
12131 uint8_t auth_key[reference->auth_key.len + 1];
12133 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12135 /* Setup Authentication Parameters */
12136 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12137 ut_params->auth_xform.auth.op = auth_op;
12138 ut_params->auth_xform.next = NULL;
12139 ut_params->auth_xform.auth.algo = reference->auth_algo;
12140 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12141 ut_params->auth_xform.auth.key.data = auth_key;
12142 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12144 /* Create Crypto session*/
12145 ut_params->sess = rte_cryptodev_sym_session_create(
12146 ts_params->session_mpool);
12148 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12149 &ut_params->auth_xform,
12150 ts_params->session_priv_mpool);
12152 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12158 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12160 const struct test_crypto_vector *reference,
12161 enum rte_crypto_auth_operation auth_op,
12162 enum rte_crypto_cipher_operation cipher_op)
12164 struct crypto_testsuite_params *ts_params = &testsuite_params;
12165 uint8_t cipher_key[reference->cipher_key.len + 1];
12166 uint8_t auth_key[reference->auth_key.len + 1];
12168 memcpy(cipher_key, reference->cipher_key.data,
12169 reference->cipher_key.len);
12170 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12172 /* Setup Authentication Parameters */
12173 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12174 ut_params->auth_xform.auth.op = auth_op;
12175 ut_params->auth_xform.auth.algo = reference->auth_algo;
12176 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12177 ut_params->auth_xform.auth.key.data = auth_key;
12178 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12180 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12181 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12182 ut_params->auth_xform.auth.iv.length = reference->iv.len;
12184 ut_params->auth_xform.next = &ut_params->cipher_xform;
12186 /* Setup Cipher Parameters */
12187 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12188 ut_params->cipher_xform.next = NULL;
12189 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12190 ut_params->cipher_xform.cipher.op = cipher_op;
12191 ut_params->cipher_xform.cipher.key.data = cipher_key;
12192 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12193 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12194 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12197 /* Create Crypto session*/
12198 ut_params->sess = rte_cryptodev_sym_session_create(
12199 ts_params->session_mpool);
12201 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12202 &ut_params->auth_xform,
12203 ts_params->session_priv_mpool);
12205 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12211 create_auth_operation(struct crypto_testsuite_params *ts_params,
12212 struct crypto_unittest_params *ut_params,
12213 const struct test_crypto_vector *reference,
12214 unsigned int auth_generate)
12216 /* Generate Crypto op data structure */
12217 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12218 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12219 TEST_ASSERT_NOT_NULL(ut_params->op,
12220 "Failed to allocate pktmbuf offload");
12222 /* Set crypto operation data parameters */
12223 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12225 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12227 /* set crypto operation source mbuf */
12228 sym_op->m_src = ut_params->ibuf;
12231 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12232 ut_params->ibuf, reference->digest.len);
12234 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12235 "no room to append auth tag");
12237 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12238 ut_params->ibuf, reference->plaintext.len);
12241 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12243 memcpy(sym_op->auth.digest.data,
12244 reference->digest.data,
12245 reference->digest.len);
12247 debug_hexdump(stdout, "digest:",
12248 sym_op->auth.digest.data,
12249 reference->digest.len);
12251 sym_op->auth.data.length = reference->plaintext.len;
12252 sym_op->auth.data.offset = 0;
12258 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12259 struct crypto_unittest_params *ut_params,
12260 const struct test_crypto_vector *reference,
12261 unsigned int auth_generate)
12263 /* Generate Crypto op data structure */
12264 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12265 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12266 TEST_ASSERT_NOT_NULL(ut_params->op,
12267 "Failed to allocate pktmbuf offload");
12269 /* Set crypto operation data parameters */
12270 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12272 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12274 /* set crypto operation source mbuf */
12275 sym_op->m_src = ut_params->ibuf;
12278 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12279 ut_params->ibuf, reference->digest.len);
12281 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12282 "no room to append auth tag");
12284 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12285 ut_params->ibuf, reference->ciphertext.len);
12288 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12290 memcpy(sym_op->auth.digest.data,
12291 reference->digest.data,
12292 reference->digest.len);
12294 debug_hexdump(stdout, "digest:",
12295 sym_op->auth.digest.data,
12296 reference->digest.len);
12298 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12299 reference->iv.data, reference->iv.len);
12301 sym_op->cipher.data.length = 0;
12302 sym_op->cipher.data.offset = 0;
12304 sym_op->auth.data.length = reference->plaintext.len;
12305 sym_op->auth.data.offset = 0;
12311 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12312 struct crypto_unittest_params *ut_params,
12313 const struct test_crypto_vector *reference,
12314 unsigned int auth_generate)
12316 /* Generate Crypto op data structure */
12317 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12318 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12319 TEST_ASSERT_NOT_NULL(ut_params->op,
12320 "Failed to allocate pktmbuf offload");
12322 /* Set crypto operation data parameters */
12323 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12325 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12327 /* set crypto operation source mbuf */
12328 sym_op->m_src = ut_params->ibuf;
12331 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12332 ut_params->ibuf, reference->digest.len);
12334 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12335 "no room to append auth tag");
12337 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12338 ut_params->ibuf, reference->ciphertext.len);
12341 memset(sym_op->auth.digest.data, 0, reference->digest.len);
12343 memcpy(sym_op->auth.digest.data,
12344 reference->digest.data,
12345 reference->digest.len);
12347 debug_hexdump(stdout, "digest:",
12348 sym_op->auth.digest.data,
12349 reference->digest.len);
12351 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12352 reference->iv.data, reference->iv.len);
12354 sym_op->cipher.data.length = reference->cipher_len;
12355 sym_op->cipher.data.offset = reference->cipher_offset;
12357 sym_op->auth.data.length = reference->plaintext.len;
12358 sym_op->auth.data.offset = reference->auth_offset;
12364 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12365 struct crypto_unittest_params *ut_params,
12366 const struct test_crypto_vector *reference)
12368 return create_auth_operation(ts_params, ut_params, reference, 0);
12372 create_auth_verify_GMAC_operation(
12373 struct crypto_testsuite_params *ts_params,
12374 struct crypto_unittest_params *ut_params,
12375 const struct test_crypto_vector *reference)
12377 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12381 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12382 struct crypto_unittest_params *ut_params,
12383 const struct test_crypto_vector *reference)
12385 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12389 test_authentication_verify_fail_when_data_corruption(
12390 struct crypto_testsuite_params *ts_params,
12391 struct crypto_unittest_params *ut_params,
12392 const struct test_crypto_vector *reference,
12393 unsigned int data_corrupted)
12397 uint8_t *plaintext;
12398 struct rte_cryptodev_info dev_info;
12400 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12401 uint64_t feat_flags = dev_info.feature_flags;
12403 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12404 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12405 printf("Device doesn't support RAW data-path APIs.\n");
12406 return TEST_SKIPPED;
12409 /* Verify the capabilities */
12410 struct rte_cryptodev_sym_capability_idx cap_idx;
12411 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12412 cap_idx.algo.auth = reference->auth_algo;
12413 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12415 return TEST_SKIPPED;
12418 /* Create session */
12419 retval = create_auth_session(ut_params,
12420 ts_params->valid_devs[0],
12422 RTE_CRYPTO_AUTH_OP_VERIFY);
12426 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12427 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12428 "Failed to allocate input buffer in mempool");
12430 /* clear mbuf payload */
12431 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12432 rte_pktmbuf_tailroom(ut_params->ibuf));
12434 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12435 reference->plaintext.len);
12436 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12437 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12439 debug_hexdump(stdout, "plaintext:", plaintext,
12440 reference->plaintext.len);
12442 /* Create operation */
12443 retval = create_auth_verify_operation(ts_params, ut_params, reference);
12448 if (data_corrupted)
12449 data_corruption(plaintext);
12451 tag_corruption(plaintext, reference->plaintext.len);
12453 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12454 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12456 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12457 RTE_CRYPTO_OP_STATUS_SUCCESS,
12458 "authentication not failed");
12459 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12460 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12461 ut_params->op, 0, 1, 0, 0);
12463 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12465 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12472 test_authentication_verify_GMAC_fail_when_corruption(
12473 struct crypto_testsuite_params *ts_params,
12474 struct crypto_unittest_params *ut_params,
12475 const struct test_crypto_vector *reference,
12476 unsigned int data_corrupted)
12479 uint8_t *plaintext;
12480 struct rte_cryptodev_info dev_info;
12482 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12483 uint64_t feat_flags = dev_info.feature_flags;
12485 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12486 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12487 printf("Device doesn't support RAW data-path APIs.\n");
12488 return TEST_SKIPPED;
12491 /* Verify the capabilities */
12492 struct rte_cryptodev_sym_capability_idx cap_idx;
12493 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12494 cap_idx.algo.auth = reference->auth_algo;
12495 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12497 return TEST_SKIPPED;
12499 /* Create session */
12500 retval = create_auth_cipher_session(ut_params,
12501 ts_params->valid_devs[0],
12503 RTE_CRYPTO_AUTH_OP_VERIFY,
12504 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12509 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12510 "Failed to allocate input buffer in mempool");
12512 /* clear mbuf payload */
12513 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12514 rte_pktmbuf_tailroom(ut_params->ibuf));
12516 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12517 reference->plaintext.len);
12518 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12519 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12521 debug_hexdump(stdout, "plaintext:", plaintext,
12522 reference->plaintext.len);
12524 /* Create operation */
12525 retval = create_auth_verify_GMAC_operation(ts_params,
12532 if (data_corrupted)
12533 data_corruption(plaintext);
12535 tag_corruption(plaintext, reference->aad.len);
12537 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12538 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12540 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12541 RTE_CRYPTO_OP_STATUS_SUCCESS,
12542 "authentication not failed");
12543 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12544 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12545 ut_params->op, 0, 1, 0, 0);
12547 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12549 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12556 test_authenticated_decryption_fail_when_corruption(
12557 struct crypto_testsuite_params *ts_params,
12558 struct crypto_unittest_params *ut_params,
12559 const struct test_crypto_vector *reference,
12560 unsigned int data_corrupted)
12564 uint8_t *ciphertext;
12565 struct rte_cryptodev_info dev_info;
12567 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12568 uint64_t feat_flags = dev_info.feature_flags;
12570 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12571 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12572 printf("Device doesn't support RAW data-path APIs.\n");
12573 return TEST_SKIPPED;
12576 /* Verify the capabilities */
12577 struct rte_cryptodev_sym_capability_idx cap_idx;
12578 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12579 cap_idx.algo.auth = reference->auth_algo;
12580 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12582 return TEST_SKIPPED;
12583 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12584 cap_idx.algo.cipher = reference->crypto_algo;
12585 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12587 return TEST_SKIPPED;
12589 /* Create session */
12590 retval = create_auth_cipher_session(ut_params,
12591 ts_params->valid_devs[0],
12593 RTE_CRYPTO_AUTH_OP_VERIFY,
12594 RTE_CRYPTO_CIPHER_OP_DECRYPT);
12598 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12599 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12600 "Failed to allocate input buffer in mempool");
12602 /* clear mbuf payload */
12603 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12604 rte_pktmbuf_tailroom(ut_params->ibuf));
12606 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12607 reference->ciphertext.len);
12608 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12609 memcpy(ciphertext, reference->ciphertext.data,
12610 reference->ciphertext.len);
12612 /* Create operation */
12613 retval = create_cipher_auth_verify_operation(ts_params,
12620 if (data_corrupted)
12621 data_corruption(ciphertext);
12623 tag_corruption(ciphertext, reference->ciphertext.len);
12625 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12626 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12628 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12629 RTE_CRYPTO_OP_STATUS_SUCCESS,
12630 "authentication not failed");
12631 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12632 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12633 ut_params->op, 1, 1, 0, 0);
12635 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12637 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12644 test_authenticated_encrypt_with_esn(
12645 struct crypto_testsuite_params *ts_params,
12646 struct crypto_unittest_params *ut_params,
12647 const struct test_crypto_vector *reference)
12651 uint8_t *authciphertext, *plaintext, *auth_tag;
12652 uint16_t plaintext_pad_len;
12653 uint8_t cipher_key[reference->cipher_key.len + 1];
12654 uint8_t auth_key[reference->auth_key.len + 1];
12655 struct rte_cryptodev_info dev_info;
12657 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12658 uint64_t feat_flags = dev_info.feature_flags;
12660 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12661 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12662 printf("Device doesn't support RAW data-path APIs.\n");
12663 return TEST_SKIPPED;
12666 /* Verify the capabilities */
12667 struct rte_cryptodev_sym_capability_idx cap_idx;
12668 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12669 cap_idx.algo.auth = reference->auth_algo;
12670 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12672 return TEST_SKIPPED;
12673 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12674 cap_idx.algo.cipher = reference->crypto_algo;
12675 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12677 return TEST_SKIPPED;
12679 /* Create session */
12680 memcpy(cipher_key, reference->cipher_key.data,
12681 reference->cipher_key.len);
12682 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12684 /* Setup Cipher Parameters */
12685 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12686 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12687 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12688 ut_params->cipher_xform.cipher.key.data = cipher_key;
12689 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12690 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12691 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12693 ut_params->cipher_xform.next = &ut_params->auth_xform;
12695 /* Setup Authentication Parameters */
12696 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12697 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12698 ut_params->auth_xform.auth.algo = reference->auth_algo;
12699 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12700 ut_params->auth_xform.auth.key.data = auth_key;
12701 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12702 ut_params->auth_xform.next = NULL;
12704 /* Create Crypto session*/
12705 ut_params->sess = rte_cryptodev_sym_session_create(
12706 ts_params->session_mpool);
12708 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12710 &ut_params->cipher_xform,
12711 ts_params->session_priv_mpool);
12713 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12715 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12716 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12717 "Failed to allocate input buffer in mempool");
12719 /* clear mbuf payload */
12720 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12721 rte_pktmbuf_tailroom(ut_params->ibuf));
12723 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12724 reference->plaintext.len);
12725 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12726 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12728 /* Create operation */
12729 retval = create_cipher_auth_operation(ts_params,
12736 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12737 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12739 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12740 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12741 ut_params->op, 1, 1, 0, 0);
12743 ut_params->op = process_crypto_request(
12744 ts_params->valid_devs[0], ut_params->op);
12746 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12748 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12749 "crypto op processing failed");
12751 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12753 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12754 ut_params->op->sym->auth.data.offset);
12755 auth_tag = authciphertext + plaintext_pad_len;
12756 debug_hexdump(stdout, "ciphertext:", authciphertext,
12757 reference->ciphertext.len);
12758 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12760 /* Validate obuf */
12761 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12763 reference->ciphertext.data,
12764 reference->ciphertext.len,
12765 "Ciphertext data not as expected");
12767 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12769 reference->digest.data,
12770 reference->digest.len,
12771 "Generated digest not as expected");
12773 return TEST_SUCCESS;
12778 test_authenticated_decrypt_with_esn(
12779 struct crypto_testsuite_params *ts_params,
12780 struct crypto_unittest_params *ut_params,
12781 const struct test_crypto_vector *reference)
12785 uint8_t *ciphertext;
12786 uint8_t cipher_key[reference->cipher_key.len + 1];
12787 uint8_t auth_key[reference->auth_key.len + 1];
12788 struct rte_cryptodev_info dev_info;
12790 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12791 uint64_t feat_flags = dev_info.feature_flags;
12793 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12794 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12795 printf("Device doesn't support RAW data-path APIs.\n");
12796 return TEST_SKIPPED;
12799 /* Verify the capabilities */
12800 struct rte_cryptodev_sym_capability_idx cap_idx;
12801 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12802 cap_idx.algo.auth = reference->auth_algo;
12803 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12805 return TEST_SKIPPED;
12806 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12807 cap_idx.algo.cipher = reference->crypto_algo;
12808 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12810 return TEST_SKIPPED;
12812 /* Create session */
12813 memcpy(cipher_key, reference->cipher_key.data,
12814 reference->cipher_key.len);
12815 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12817 /* Setup Authentication Parameters */
12818 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12819 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12820 ut_params->auth_xform.auth.algo = reference->auth_algo;
12821 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12822 ut_params->auth_xform.auth.key.data = auth_key;
12823 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12824 ut_params->auth_xform.next = &ut_params->cipher_xform;
12826 /* Setup Cipher Parameters */
12827 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12828 ut_params->cipher_xform.next = NULL;
12829 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12830 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12831 ut_params->cipher_xform.cipher.key.data = cipher_key;
12832 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12833 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12834 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12836 /* Create Crypto session*/
12837 ut_params->sess = rte_cryptodev_sym_session_create(
12838 ts_params->session_mpool);
12840 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12842 &ut_params->auth_xform,
12843 ts_params->session_priv_mpool);
12845 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12847 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12848 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12849 "Failed to allocate input buffer in mempool");
12851 /* clear mbuf payload */
12852 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12853 rte_pktmbuf_tailroom(ut_params->ibuf));
12855 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12856 reference->ciphertext.len);
12857 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12858 memcpy(ciphertext, reference->ciphertext.data,
12859 reference->ciphertext.len);
12861 /* Create operation */
12862 retval = create_cipher_auth_verify_operation(ts_params,
12869 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12870 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12872 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12873 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12874 ut_params->op, 1, 1, 0, 0);
12876 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12879 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12880 TEST_ASSERT_EQUAL(ut_params->op->status,
12881 RTE_CRYPTO_OP_STATUS_SUCCESS,
12882 "crypto op processing passed");
12884 ut_params->obuf = ut_params->op->sym->m_src;
12885 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12891 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12892 const struct aead_test_data *tdata,
12893 void *digest_mem, uint64_t digest_phys)
12895 struct crypto_testsuite_params *ts_params = &testsuite_params;
12896 struct crypto_unittest_params *ut_params = &unittest_params;
12898 const unsigned int auth_tag_len = tdata->auth_tag.len;
12899 const unsigned int iv_len = tdata->iv.len;
12900 unsigned int aad_len = tdata->aad.len;
12901 unsigned int aad_len_pad = 0;
12903 /* Generate Crypto op data structure */
12904 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12905 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12906 TEST_ASSERT_NOT_NULL(ut_params->op,
12907 "Failed to allocate symmetric crypto operation struct");
12909 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12911 sym_op->aead.digest.data = digest_mem;
12913 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12914 "no room to append digest");
12916 sym_op->aead.digest.phys_addr = digest_phys;
12918 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12919 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12921 debug_hexdump(stdout, "digest:",
12922 sym_op->aead.digest.data,
12926 /* Append aad data */
12927 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12928 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12929 uint8_t *, IV_OFFSET);
12931 /* Copy IV 1 byte after the IV pointer, according to the API */
12932 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12934 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12936 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12937 ut_params->ibuf, aad_len);
12938 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12939 "no room to prepend aad");
12940 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12943 memset(sym_op->aead.aad.data, 0, aad_len);
12944 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
12945 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12947 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12948 debug_hexdump(stdout, "aad:",
12949 sym_op->aead.aad.data, aad_len);
12951 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12952 uint8_t *, IV_OFFSET);
12954 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12956 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12958 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12959 ut_params->ibuf, aad_len_pad);
12960 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12961 "no room to prepend aad");
12962 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12965 memset(sym_op->aead.aad.data, 0, aad_len);
12966 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12968 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12969 debug_hexdump(stdout, "aad:",
12970 sym_op->aead.aad.data, aad_len);
12973 sym_op->aead.data.length = tdata->plaintext.len;
12974 sym_op->aead.data.offset = aad_len_pad;
12979 #define SGL_MAX_NO 16
12982 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12983 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12985 struct crypto_testsuite_params *ts_params = &testsuite_params;
12986 struct crypto_unittest_params *ut_params = &unittest_params;
12987 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12990 int to_trn_tbl[SGL_MAX_NO];
12992 unsigned int trn_data = 0;
12993 uint8_t *plaintext, *ciphertext, *auth_tag;
12994 struct rte_cryptodev_info dev_info;
12996 /* Verify the capabilities */
12997 struct rte_cryptodev_sym_capability_idx cap_idx;
12998 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12999 cap_idx.algo.aead = tdata->algo;
13000 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13002 return TEST_SKIPPED;
13004 /* OOP not supported with CPU crypto */
13005 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13006 return TEST_SKIPPED;
13008 /* Detailed check for the particular SGL support flag */
13009 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13011 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13012 if (sgl_in && (!(dev_info.feature_flags &
13013 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13014 return TEST_SKIPPED;
13016 uint64_t feat_flags = dev_info.feature_flags;
13018 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13019 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13020 printf("Device doesn't support RAW data-path APIs.\n");
13021 return TEST_SKIPPED;
13024 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13025 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13026 tdata->plaintext.len;
13027 /* Raw data path API does not support OOP */
13028 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13029 return TEST_SKIPPED;
13030 if (sgl_in && !sgl_out) {
13031 if (!(dev_info.feature_flags &
13032 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13033 return TEST_SKIPPED;
13034 } else if (!sgl_in && sgl_out) {
13035 if (!(dev_info.feature_flags &
13036 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13037 return TEST_SKIPPED;
13038 } else if (sgl_in && sgl_out) {
13039 if (!(dev_info.feature_flags &
13040 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13041 return TEST_SKIPPED;
13045 if (fragsz > tdata->plaintext.len)
13046 fragsz = tdata->plaintext.len;
13048 uint16_t plaintext_len = fragsz;
13049 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13051 if (fragsz_oop > tdata->plaintext.len)
13052 frag_size_oop = tdata->plaintext.len;
13055 void *digest_mem = NULL;
13057 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13059 if (tdata->plaintext.len % fragsz != 0) {
13060 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13063 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13068 * For out-op-place we need to alloc another mbuf
13071 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13072 rte_pktmbuf_append(ut_params->obuf,
13073 frag_size_oop + prepend_len);
13074 buf_oop = ut_params->obuf;
13077 /* Create AEAD session */
13078 retval = create_aead_session(ts_params->valid_devs[0],
13080 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13081 tdata->key.data, tdata->key.len,
13082 tdata->aad.len, tdata->auth_tag.len,
13087 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13089 /* clear mbuf payload */
13090 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13091 rte_pktmbuf_tailroom(ut_params->ibuf));
13093 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13096 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13098 trn_data += plaintext_len;
13100 buf = ut_params->ibuf;
13103 * Loop until no more fragments
13106 while (trn_data < tdata->plaintext.len) {
13108 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13109 (tdata->plaintext.len - trn_data) : fragsz;
13111 to_trn_tbl[ecx++] = to_trn;
13113 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13116 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13117 rte_pktmbuf_tailroom(buf));
13120 if (oop && !fragsz_oop) {
13121 buf_last_oop = buf_oop->next =
13122 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13123 buf_oop = buf_oop->next;
13124 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13125 0, rte_pktmbuf_tailroom(buf_oop));
13126 rte_pktmbuf_append(buf_oop, to_trn);
13129 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13132 memcpy(plaintext, tdata->plaintext.data + trn_data,
13134 trn_data += to_trn;
13135 if (trn_data == tdata->plaintext.len) {
13138 digest_mem = rte_pktmbuf_append(buf_oop,
13139 tdata->auth_tag.len);
13141 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13142 tdata->auth_tag.len);
13146 uint64_t digest_phys = 0;
13148 ut_params->ibuf->nb_segs = segs;
13151 if (fragsz_oop && oop) {
13155 if (frag_size_oop == tdata->plaintext.len) {
13156 digest_mem = rte_pktmbuf_append(ut_params->obuf,
13157 tdata->auth_tag.len);
13159 digest_phys = rte_pktmbuf_iova_offset(
13161 tdata->plaintext.len + prepend_len);
13164 trn_data = frag_size_oop;
13165 while (trn_data < tdata->plaintext.len) {
13168 (tdata->plaintext.len - trn_data <
13170 (tdata->plaintext.len - trn_data) :
13173 to_trn_tbl[ecx++] = to_trn;
13175 buf_last_oop = buf_oop->next =
13176 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13177 buf_oop = buf_oop->next;
13178 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13179 0, rte_pktmbuf_tailroom(buf_oop));
13180 rte_pktmbuf_append(buf_oop, to_trn);
13182 trn_data += to_trn;
13184 if (trn_data == tdata->plaintext.len) {
13185 digest_mem = rte_pktmbuf_append(buf_oop,
13186 tdata->auth_tag.len);
13190 ut_params->obuf->nb_segs = segs;
13194 * Place digest at the end of the last buffer
13197 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13198 if (oop && buf_last_oop)
13199 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13201 if (!digest_mem && !oop) {
13202 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13203 + tdata->auth_tag.len);
13204 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13205 tdata->plaintext.len);
13208 /* Create AEAD operation */
13209 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13210 tdata, digest_mem, digest_phys);
13215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13217 ut_params->op->sym->m_src = ut_params->ibuf;
13219 ut_params->op->sym->m_dst = ut_params->obuf;
13221 /* Process crypto operation */
13222 if (oop == IN_PLACE &&
13223 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13224 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13225 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13226 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13227 ut_params->op, 0, 0, 0, 0);
13229 TEST_ASSERT_NOT_NULL(
13230 process_crypto_request(ts_params->valid_devs[0],
13231 ut_params->op), "failed to process sym crypto op");
13233 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13234 "crypto op processing failed");
13237 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13238 uint8_t *, prepend_len);
13240 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13241 uint8_t *, prepend_len);
13245 fragsz = fragsz_oop;
13247 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13249 tdata->ciphertext.data,
13251 "Ciphertext data not as expected");
13253 buf = ut_params->op->sym->m_src->next;
13255 buf = ut_params->op->sym->m_dst->next;
13257 unsigned int off = fragsz;
13261 ciphertext = rte_pktmbuf_mtod(buf,
13264 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13266 tdata->ciphertext.data + off,
13268 "Ciphertext data not as expected");
13270 off += to_trn_tbl[ecx++];
13274 auth_tag = digest_mem;
13275 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13277 tdata->auth_tag.data,
13278 tdata->auth_tag.len,
13279 "Generated auth tag not as expected");
13285 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13287 return test_authenticated_encryption_SGL(
13288 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13292 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13294 return test_authenticated_encryption_SGL(
13295 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13299 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13301 return test_authenticated_encryption_SGL(
13302 &gcm_test_case_8, OUT_OF_PLACE, 400,
13303 gcm_test_case_8.plaintext.len);
13307 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13309 /* This test is not for OPENSSL PMD */
13310 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13311 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13312 return TEST_SKIPPED;
13314 return test_authenticated_encryption_SGL(
13315 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13319 test_authentication_verify_fail_when_data_corrupted(
13320 struct crypto_testsuite_params *ts_params,
13321 struct crypto_unittest_params *ut_params,
13322 const struct test_crypto_vector *reference)
13324 return test_authentication_verify_fail_when_data_corruption(
13325 ts_params, ut_params, reference, 1);
13329 test_authentication_verify_fail_when_tag_corrupted(
13330 struct crypto_testsuite_params *ts_params,
13331 struct crypto_unittest_params *ut_params,
13332 const struct test_crypto_vector *reference)
13334 return test_authentication_verify_fail_when_data_corruption(
13335 ts_params, ut_params, reference, 0);
13339 test_authentication_verify_GMAC_fail_when_data_corrupted(
13340 struct crypto_testsuite_params *ts_params,
13341 struct crypto_unittest_params *ut_params,
13342 const struct test_crypto_vector *reference)
13344 return test_authentication_verify_GMAC_fail_when_corruption(
13345 ts_params, ut_params, reference, 1);
13349 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13350 struct crypto_testsuite_params *ts_params,
13351 struct crypto_unittest_params *ut_params,
13352 const struct test_crypto_vector *reference)
13354 return test_authentication_verify_GMAC_fail_when_corruption(
13355 ts_params, ut_params, reference, 0);
13359 test_authenticated_decryption_fail_when_data_corrupted(
13360 struct crypto_testsuite_params *ts_params,
13361 struct crypto_unittest_params *ut_params,
13362 const struct test_crypto_vector *reference)
13364 return test_authenticated_decryption_fail_when_corruption(
13365 ts_params, ut_params, reference, 1);
13369 test_authenticated_decryption_fail_when_tag_corrupted(
13370 struct crypto_testsuite_params *ts_params,
13371 struct crypto_unittest_params *ut_params,
13372 const struct test_crypto_vector *reference)
13374 return test_authenticated_decryption_fail_when_corruption(
13375 ts_params, ut_params, reference, 0);
13379 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13381 return test_authentication_verify_fail_when_data_corrupted(
13382 &testsuite_params, &unittest_params,
13383 &hmac_sha1_test_crypto_vector);
13387 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13389 return test_authentication_verify_fail_when_tag_corrupted(
13390 &testsuite_params, &unittest_params,
13391 &hmac_sha1_test_crypto_vector);
13395 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13397 return test_authentication_verify_GMAC_fail_when_data_corrupted(
13398 &testsuite_params, &unittest_params,
13399 &aes128_gmac_test_vector);
13403 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13405 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13406 &testsuite_params, &unittest_params,
13407 &aes128_gmac_test_vector);
13411 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13413 return test_authenticated_decryption_fail_when_data_corrupted(
13416 &aes128cbc_hmac_sha1_test_vector);
13420 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13422 return test_authenticated_decryption_fail_when_tag_corrupted(
13425 &aes128cbc_hmac_sha1_test_vector);
13429 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13431 return test_authenticated_encrypt_with_esn(
13434 &aes128cbc_hmac_sha1_aad_test_vector);
13438 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13440 return test_authenticated_decrypt_with_esn(
13443 &aes128cbc_hmac_sha1_aad_test_vector);
13447 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13449 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13453 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13455 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13458 #ifdef RTE_CRYPTO_SCHEDULER
13460 /* global AESNI worker IDs for the scheduler test */
13461 uint8_t aesni_ids[2];
13464 scheduler_testsuite_setup(void)
13467 int32_t nb_devs, ret;
13468 char vdev_args[VDEV_ARGS_SIZE] = {""};
13469 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13470 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
13471 uint16_t worker_core_count = 0;
13472 uint16_t socket_id = 0;
13474 if (gbl_driver_id == rte_cryptodev_driver_id_get(
13475 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13477 /* Identify the Worker Cores
13478 * Use 2 worker cores for the device args
13480 RTE_LCORE_FOREACH_WORKER(i) {
13481 if (worker_core_count > 1)
13483 snprintf(vdev_args, sizeof(vdev_args),
13484 "%s%d", temp_str, i);
13485 strcpy(temp_str, vdev_args);
13486 strlcat(temp_str, ";", sizeof(temp_str));
13487 worker_core_count++;
13488 socket_id = rte_lcore_to_socket_id(i);
13490 if (worker_core_count != 2) {
13491 RTE_LOG(ERR, USER1,
13492 "Cryptodev scheduler test require at least "
13493 "two worker cores to run. "
13494 "Please use the correct coremask.\n");
13495 return TEST_FAILED;
13497 strcpy(temp_str, vdev_args);
13498 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13499 temp_str, socket_id);
13500 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13501 nb_devs = rte_cryptodev_device_count_by_driver(
13502 rte_cryptodev_driver_id_get(
13503 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13505 ret = rte_vdev_init(
13506 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13508 TEST_ASSERT(ret == 0,
13509 "Failed to create instance %u of pmd : %s",
13510 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13513 return testsuite_setup();
13517 test_scheduler_attach_worker_op(void)
13519 struct crypto_testsuite_params *ts_params = &testsuite_params;
13520 uint8_t sched_id = ts_params->valid_devs[0];
13521 uint32_t i, nb_devs_attached = 0;
13523 char vdev_name[32];
13524 unsigned int count = rte_cryptodev_count();
13526 /* create 2 AESNI_MB vdevs on top of existing devices */
13527 for (i = count; i < count + 2; i++) {
13528 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13529 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13531 ret = rte_vdev_init(vdev_name, NULL);
13533 TEST_ASSERT(ret == 0,
13534 "Failed to create instance %u of"
13536 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13539 RTE_LOG(ERR, USER1,
13540 "Failed to create 2 AESNI MB PMDs.\n");
13541 return TEST_SKIPPED;
13545 /* attach 2 AESNI_MB cdevs */
13546 for (i = count; i < count + 2; i++) {
13547 struct rte_cryptodev_info info;
13548 unsigned int session_size;
13550 rte_cryptodev_info_get(i, &info);
13551 if (info.driver_id != rte_cryptodev_driver_id_get(
13552 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13555 session_size = rte_cryptodev_sym_get_private_session_size(i);
13557 * Create the session mempool again, since now there are new devices
13558 * to use the mempool.
13560 if (ts_params->session_mpool) {
13561 rte_mempool_free(ts_params->session_mpool);
13562 ts_params->session_mpool = NULL;
13564 if (ts_params->session_priv_mpool) {
13565 rte_mempool_free(ts_params->session_priv_mpool);
13566 ts_params->session_priv_mpool = NULL;
13569 if (info.sym.max_nb_sessions != 0 &&
13570 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13571 RTE_LOG(ERR, USER1,
13572 "Device does not support "
13573 "at least %u sessions\n",
13575 return TEST_FAILED;
13578 * Create mempool with maximum number of sessions,
13579 * to include the session headers
13581 if (ts_params->session_mpool == NULL) {
13582 ts_params->session_mpool =
13583 rte_cryptodev_sym_session_pool_create(
13585 MAX_NB_SESSIONS, 0, 0, 0,
13587 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13588 "session mempool allocation failed");
13592 * Create mempool with maximum number of sessions,
13593 * to include device specific session private data
13595 if (ts_params->session_priv_mpool == NULL) {
13596 ts_params->session_priv_mpool = rte_mempool_create(
13597 "test_sess_mp_priv",
13600 0, 0, NULL, NULL, NULL,
13601 NULL, SOCKET_ID_ANY,
13604 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13605 "session mempool allocation failed");
13608 ts_params->qp_conf.mp_session = ts_params->session_mpool;
13609 ts_params->qp_conf.mp_session_private =
13610 ts_params->session_priv_mpool;
13612 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13615 TEST_ASSERT(ret == 0,
13616 "Failed to attach device %u of pmd : %s", i,
13617 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13619 aesni_ids[nb_devs_attached] = (uint8_t)i;
13621 nb_devs_attached++;
13628 test_scheduler_detach_worker_op(void)
13630 struct crypto_testsuite_params *ts_params = &testsuite_params;
13631 uint8_t sched_id = ts_params->valid_devs[0];
13635 for (i = 0; i < 2; i++) {
13636 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13638 TEST_ASSERT(ret == 0,
13639 "Failed to detach device %u", aesni_ids[i]);
13646 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13648 struct crypto_testsuite_params *ts_params = &testsuite_params;
13649 uint8_t sched_id = ts_params->valid_devs[0];
13651 return rte_cryptodev_scheduler_mode_set(sched_id,
13656 test_scheduler_mode_roundrobin_op(void)
13658 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13659 0, "Failed to set roundrobin mode");
13665 test_scheduler_mode_multicore_op(void)
13667 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13668 0, "Failed to set multicore mode");
13674 test_scheduler_mode_failover_op(void)
13676 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13677 0, "Failed to set failover mode");
13683 test_scheduler_mode_pkt_size_distr_op(void)
13685 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13686 0, "Failed to set pktsize mode");
13692 scheduler_multicore_testsuite_setup(void)
13694 if (test_scheduler_attach_worker_op() < 0)
13695 return TEST_SKIPPED;
13696 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
13697 return TEST_SKIPPED;
13702 scheduler_roundrobin_testsuite_setup(void)
13704 if (test_scheduler_attach_worker_op() < 0)
13705 return TEST_SKIPPED;
13706 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
13707 return TEST_SKIPPED;
13712 scheduler_failover_testsuite_setup(void)
13714 if (test_scheduler_attach_worker_op() < 0)
13715 return TEST_SKIPPED;
13716 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
13717 return TEST_SKIPPED;
13722 scheduler_pkt_size_distr_testsuite_setup(void)
13724 if (test_scheduler_attach_worker_op() < 0)
13725 return TEST_SKIPPED;
13726 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
13727 return TEST_SKIPPED;
13732 scheduler_mode_testsuite_teardown(void)
13734 test_scheduler_detach_worker_op();
13737 #endif /* RTE_CRYPTO_SCHEDULER */
13739 static struct unit_test_suite end_testsuite = {
13740 .suite_name = NULL,
13743 .unit_test_suites = NULL
13746 #ifdef RTE_LIB_SECURITY
13747 static struct unit_test_suite pdcp_proto_testsuite = {
13748 .suite_name = "PDCP Proto Unit Test Suite",
13749 .setup = pdcp_proto_testsuite_setup,
13750 .unit_test_cases = {
13751 TEST_CASE_ST(ut_setup_security, ut_teardown,
13752 test_PDCP_PROTO_all),
13753 TEST_CASES_END() /**< NULL terminate unit test array */
13757 static struct unit_test_suite docsis_proto_testsuite = {
13758 .suite_name = "Docsis Proto Unit Test Suite",
13759 .setup = docsis_proto_testsuite_setup,
13760 .unit_test_cases = {
13761 TEST_CASE_ST(ut_setup_security, ut_teardown,
13762 test_DOCSIS_PROTO_all),
13763 TEST_CASES_END() /**< NULL terminate unit test array */
13768 static struct unit_test_suite cryptodev_gen_testsuite = {
13769 .suite_name = "Crypto General Unit Test Suite",
13770 .setup = crypto_gen_testsuite_setup,
13771 .unit_test_cases = {
13772 TEST_CASE_ST(ut_setup, ut_teardown,
13773 test_device_configure_invalid_dev_id),
13774 TEST_CASE_ST(ut_setup, ut_teardown,
13775 test_queue_pair_descriptor_setup),
13776 TEST_CASE_ST(ut_setup, ut_teardown,
13777 test_device_configure_invalid_queue_pair_ids),
13778 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13779 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13780 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13781 TEST_CASES_END() /**< NULL terminate unit test array */
13785 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
13786 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
13787 .setup = negative_hmac_sha1_testsuite_setup,
13788 .unit_test_cases = {
13789 /** Negative tests */
13790 TEST_CASE_ST(ut_setup, ut_teardown,
13791 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13792 TEST_CASE_ST(ut_setup, ut_teardown,
13793 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13794 TEST_CASE_ST(ut_setup, ut_teardown,
13795 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13796 TEST_CASE_ST(ut_setup, ut_teardown,
13797 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13799 TEST_CASES_END() /**< NULL terminate unit test array */
13803 static struct unit_test_suite cryptodev_multi_session_testsuite = {
13804 .suite_name = "Multi Session Unit Test Suite",
13805 .setup = multi_session_testsuite_setup,
13806 .unit_test_cases = {
13807 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_multi_session_random_usage),
13811 TEST_CASES_END() /**< NULL terminate unit test array */
13815 static struct unit_test_suite cryptodev_null_testsuite = {
13816 .suite_name = "NULL Test Suite",
13817 .setup = null_testsuite_setup,
13818 .unit_test_cases = {
13819 TEST_CASE_ST(ut_setup, ut_teardown,
13820 test_null_invalid_operation),
13821 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13826 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
13827 .suite_name = "AES CCM Authenticated Test Suite",
13828 .setup = aes_ccm_auth_testsuite_setup,
13829 .unit_test_cases = {
13830 /** AES CCM Authenticated Encryption 128 bits key*/
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 test_AES_CCM_authenticated_encryption_test_case_128_1),
13833 TEST_CASE_ST(ut_setup, ut_teardown,
13834 test_AES_CCM_authenticated_encryption_test_case_128_2),
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 test_AES_CCM_authenticated_encryption_test_case_128_3),
13838 /** AES CCM Authenticated Decryption 128 bits key*/
13839 TEST_CASE_ST(ut_setup, ut_teardown,
13840 test_AES_CCM_authenticated_decryption_test_case_128_1),
13841 TEST_CASE_ST(ut_setup, ut_teardown,
13842 test_AES_CCM_authenticated_decryption_test_case_128_2),
13843 TEST_CASE_ST(ut_setup, ut_teardown,
13844 test_AES_CCM_authenticated_decryption_test_case_128_3),
13846 /** AES CCM Authenticated Encryption 192 bits key */
13847 TEST_CASE_ST(ut_setup, ut_teardown,
13848 test_AES_CCM_authenticated_encryption_test_case_192_1),
13849 TEST_CASE_ST(ut_setup, ut_teardown,
13850 test_AES_CCM_authenticated_encryption_test_case_192_2),
13851 TEST_CASE_ST(ut_setup, ut_teardown,
13852 test_AES_CCM_authenticated_encryption_test_case_192_3),
13854 /** AES CCM Authenticated Decryption 192 bits key*/
13855 TEST_CASE_ST(ut_setup, ut_teardown,
13856 test_AES_CCM_authenticated_decryption_test_case_192_1),
13857 TEST_CASE_ST(ut_setup, ut_teardown,
13858 test_AES_CCM_authenticated_decryption_test_case_192_2),
13859 TEST_CASE_ST(ut_setup, ut_teardown,
13860 test_AES_CCM_authenticated_decryption_test_case_192_3),
13862 /** AES CCM Authenticated Encryption 256 bits key */
13863 TEST_CASE_ST(ut_setup, ut_teardown,
13864 test_AES_CCM_authenticated_encryption_test_case_256_1),
13865 TEST_CASE_ST(ut_setup, ut_teardown,
13866 test_AES_CCM_authenticated_encryption_test_case_256_2),
13867 TEST_CASE_ST(ut_setup, ut_teardown,
13868 test_AES_CCM_authenticated_encryption_test_case_256_3),
13870 /** AES CCM Authenticated Decryption 256 bits key*/
13871 TEST_CASE_ST(ut_setup, ut_teardown,
13872 test_AES_CCM_authenticated_decryption_test_case_256_1),
13873 TEST_CASE_ST(ut_setup, ut_teardown,
13874 test_AES_CCM_authenticated_decryption_test_case_256_2),
13875 TEST_CASE_ST(ut_setup, ut_teardown,
13876 test_AES_CCM_authenticated_decryption_test_case_256_3),
13881 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
13882 .suite_name = "AES GCM Authenticated Test Suite",
13883 .setup = aes_gcm_auth_testsuite_setup,
13884 .unit_test_cases = {
13885 /** AES GCM Authenticated Encryption */
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13888 TEST_CASE_ST(ut_setup, ut_teardown,
13889 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13892 TEST_CASE_ST(ut_setup, ut_teardown,
13893 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13894 TEST_CASE_ST(ut_setup, ut_teardown,
13895 test_AES_GCM_authenticated_encryption_test_case_1),
13896 TEST_CASE_ST(ut_setup, ut_teardown,
13897 test_AES_GCM_authenticated_encryption_test_case_2),
13898 TEST_CASE_ST(ut_setup, ut_teardown,
13899 test_AES_GCM_authenticated_encryption_test_case_3),
13900 TEST_CASE_ST(ut_setup, ut_teardown,
13901 test_AES_GCM_authenticated_encryption_test_case_4),
13902 TEST_CASE_ST(ut_setup, ut_teardown,
13903 test_AES_GCM_authenticated_encryption_test_case_5),
13904 TEST_CASE_ST(ut_setup, ut_teardown,
13905 test_AES_GCM_authenticated_encryption_test_case_6),
13906 TEST_CASE_ST(ut_setup, ut_teardown,
13907 test_AES_GCM_authenticated_encryption_test_case_7),
13908 TEST_CASE_ST(ut_setup, ut_teardown,
13909 test_AES_GCM_authenticated_encryption_test_case_8),
13910 TEST_CASE_ST(ut_setup, ut_teardown,
13911 test_AES_GCM_J0_authenticated_encryption_test_case_1),
13913 /** AES GCM Authenticated Decryption */
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_AES_GCM_authenticated_decryption_test_case_1),
13916 TEST_CASE_ST(ut_setup, ut_teardown,
13917 test_AES_GCM_authenticated_decryption_test_case_2),
13918 TEST_CASE_ST(ut_setup, ut_teardown,
13919 test_AES_GCM_authenticated_decryption_test_case_3),
13920 TEST_CASE_ST(ut_setup, ut_teardown,
13921 test_AES_GCM_authenticated_decryption_test_case_4),
13922 TEST_CASE_ST(ut_setup, ut_teardown,
13923 test_AES_GCM_authenticated_decryption_test_case_5),
13924 TEST_CASE_ST(ut_setup, ut_teardown,
13925 test_AES_GCM_authenticated_decryption_test_case_6),
13926 TEST_CASE_ST(ut_setup, ut_teardown,
13927 test_AES_GCM_authenticated_decryption_test_case_7),
13928 TEST_CASE_ST(ut_setup, ut_teardown,
13929 test_AES_GCM_authenticated_decryption_test_case_8),
13930 TEST_CASE_ST(ut_setup, ut_teardown,
13931 test_AES_GCM_J0_authenticated_decryption_test_case_1),
13933 /** AES GCM Authenticated Encryption 192 bits key */
13934 TEST_CASE_ST(ut_setup, ut_teardown,
13935 test_AES_GCM_auth_encryption_test_case_192_1),
13936 TEST_CASE_ST(ut_setup, ut_teardown,
13937 test_AES_GCM_auth_encryption_test_case_192_2),
13938 TEST_CASE_ST(ut_setup, ut_teardown,
13939 test_AES_GCM_auth_encryption_test_case_192_3),
13940 TEST_CASE_ST(ut_setup, ut_teardown,
13941 test_AES_GCM_auth_encryption_test_case_192_4),
13942 TEST_CASE_ST(ut_setup, ut_teardown,
13943 test_AES_GCM_auth_encryption_test_case_192_5),
13944 TEST_CASE_ST(ut_setup, ut_teardown,
13945 test_AES_GCM_auth_encryption_test_case_192_6),
13946 TEST_CASE_ST(ut_setup, ut_teardown,
13947 test_AES_GCM_auth_encryption_test_case_192_7),
13949 /** AES GCM Authenticated Decryption 192 bits key */
13950 TEST_CASE_ST(ut_setup, ut_teardown,
13951 test_AES_GCM_auth_decryption_test_case_192_1),
13952 TEST_CASE_ST(ut_setup, ut_teardown,
13953 test_AES_GCM_auth_decryption_test_case_192_2),
13954 TEST_CASE_ST(ut_setup, ut_teardown,
13955 test_AES_GCM_auth_decryption_test_case_192_3),
13956 TEST_CASE_ST(ut_setup, ut_teardown,
13957 test_AES_GCM_auth_decryption_test_case_192_4),
13958 TEST_CASE_ST(ut_setup, ut_teardown,
13959 test_AES_GCM_auth_decryption_test_case_192_5),
13960 TEST_CASE_ST(ut_setup, ut_teardown,
13961 test_AES_GCM_auth_decryption_test_case_192_6),
13962 TEST_CASE_ST(ut_setup, ut_teardown,
13963 test_AES_GCM_auth_decryption_test_case_192_7),
13965 /** AES GCM Authenticated Encryption 256 bits key */
13966 TEST_CASE_ST(ut_setup, ut_teardown,
13967 test_AES_GCM_auth_encryption_test_case_256_1),
13968 TEST_CASE_ST(ut_setup, ut_teardown,
13969 test_AES_GCM_auth_encryption_test_case_256_2),
13970 TEST_CASE_ST(ut_setup, ut_teardown,
13971 test_AES_GCM_auth_encryption_test_case_256_3),
13972 TEST_CASE_ST(ut_setup, ut_teardown,
13973 test_AES_GCM_auth_encryption_test_case_256_4),
13974 TEST_CASE_ST(ut_setup, ut_teardown,
13975 test_AES_GCM_auth_encryption_test_case_256_5),
13976 TEST_CASE_ST(ut_setup, ut_teardown,
13977 test_AES_GCM_auth_encryption_test_case_256_6),
13978 TEST_CASE_ST(ut_setup, ut_teardown,
13979 test_AES_GCM_auth_encryption_test_case_256_7),
13981 /** AES GCM Authenticated Decryption 256 bits key */
13982 TEST_CASE_ST(ut_setup, ut_teardown,
13983 test_AES_GCM_auth_decryption_test_case_256_1),
13984 TEST_CASE_ST(ut_setup, ut_teardown,
13985 test_AES_GCM_auth_decryption_test_case_256_2),
13986 TEST_CASE_ST(ut_setup, ut_teardown,
13987 test_AES_GCM_auth_decryption_test_case_256_3),
13988 TEST_CASE_ST(ut_setup, ut_teardown,
13989 test_AES_GCM_auth_decryption_test_case_256_4),
13990 TEST_CASE_ST(ut_setup, ut_teardown,
13991 test_AES_GCM_auth_decryption_test_case_256_5),
13992 TEST_CASE_ST(ut_setup, ut_teardown,
13993 test_AES_GCM_auth_decryption_test_case_256_6),
13994 TEST_CASE_ST(ut_setup, ut_teardown,
13995 test_AES_GCM_auth_decryption_test_case_256_7),
13997 /** AES GCM Authenticated Encryption big aad size */
13998 TEST_CASE_ST(ut_setup, ut_teardown,
13999 test_AES_GCM_auth_encryption_test_case_aad_1),
14000 TEST_CASE_ST(ut_setup, ut_teardown,
14001 test_AES_GCM_auth_encryption_test_case_aad_2),
14003 /** AES GCM Authenticated Decryption big aad size */
14004 TEST_CASE_ST(ut_setup, ut_teardown,
14005 test_AES_GCM_auth_decryption_test_case_aad_1),
14006 TEST_CASE_ST(ut_setup, ut_teardown,
14007 test_AES_GCM_auth_decryption_test_case_aad_2),
14009 /** Out of place tests */
14010 TEST_CASE_ST(ut_setup, ut_teardown,
14011 test_AES_GCM_authenticated_encryption_oop_test_case_1),
14012 TEST_CASE_ST(ut_setup, ut_teardown,
14013 test_AES_GCM_authenticated_decryption_oop_test_case_1),
14015 /** Session-less tests */
14016 TEST_CASE_ST(ut_setup, ut_teardown,
14017 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
14018 TEST_CASE_ST(ut_setup, ut_teardown,
14019 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
14025 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
14026 .suite_name = "AES GMAC Authentication Test Suite",
14027 .setup = aes_gmac_auth_testsuite_setup,
14028 .unit_test_cases = {
14029 TEST_CASE_ST(ut_setup, ut_teardown,
14030 test_AES_GMAC_authentication_test_case_1),
14031 TEST_CASE_ST(ut_setup, ut_teardown,
14032 test_AES_GMAC_authentication_verify_test_case_1),
14033 TEST_CASE_ST(ut_setup, ut_teardown,
14034 test_AES_GMAC_authentication_test_case_2),
14035 TEST_CASE_ST(ut_setup, ut_teardown,
14036 test_AES_GMAC_authentication_verify_test_case_2),
14037 TEST_CASE_ST(ut_setup, ut_teardown,
14038 test_AES_GMAC_authentication_test_case_3),
14039 TEST_CASE_ST(ut_setup, ut_teardown,
14040 test_AES_GMAC_authentication_verify_test_case_3),
14041 TEST_CASE_ST(ut_setup, ut_teardown,
14042 test_AES_GMAC_authentication_test_case_4),
14043 TEST_CASE_ST(ut_setup, ut_teardown,
14044 test_AES_GMAC_authentication_verify_test_case_4),
14045 TEST_CASE_ST(ut_setup, ut_teardown,
14046 test_AES_GMAC_authentication_SGL_40B),
14047 TEST_CASE_ST(ut_setup, ut_teardown,
14048 test_AES_GMAC_authentication_SGL_80B),
14049 TEST_CASE_ST(ut_setup, ut_teardown,
14050 test_AES_GMAC_authentication_SGL_2048B),
14051 TEST_CASE_ST(ut_setup, ut_teardown,
14052 test_AES_GMAC_authentication_SGL_2047B),
14058 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
14059 .suite_name = "Chacha20-Poly1305 Test Suite",
14060 .setup = chacha20_poly1305_testsuite_setup,
14061 .unit_test_cases = {
14062 TEST_CASE_ST(ut_setup, ut_teardown,
14063 test_chacha20_poly1305_encrypt_test_case_rfc8439),
14064 TEST_CASE_ST(ut_setup, ut_teardown,
14065 test_chacha20_poly1305_decrypt_test_case_rfc8439),
14070 static struct unit_test_suite cryptodev_snow3g_testsuite = {
14071 .suite_name = "SNOW 3G Test Suite",
14072 .setup = snow3g_testsuite_setup,
14073 .unit_test_cases = {
14074 /** SNOW 3G encrypt only (UEA2) */
14075 TEST_CASE_ST(ut_setup, ut_teardown,
14076 test_snow3g_encryption_test_case_1),
14077 TEST_CASE_ST(ut_setup, ut_teardown,
14078 test_snow3g_encryption_test_case_2),
14079 TEST_CASE_ST(ut_setup, ut_teardown,
14080 test_snow3g_encryption_test_case_3),
14081 TEST_CASE_ST(ut_setup, ut_teardown,
14082 test_snow3g_encryption_test_case_4),
14083 TEST_CASE_ST(ut_setup, ut_teardown,
14084 test_snow3g_encryption_test_case_5),
14086 TEST_CASE_ST(ut_setup, ut_teardown,
14087 test_PDCP_PROTO_short_mac),
14088 TEST_CASE_ST(ut_setup, ut_teardown,
14089 test_snow3g_encryption_test_case_1_oop),
14090 TEST_CASE_ST(ut_setup, ut_teardown,
14091 test_snow3g_encryption_test_case_1_oop_sgl),
14092 TEST_CASE_ST(ut_setup, ut_teardown,
14093 test_snow3g_encryption_test_case_1_offset_oop),
14094 TEST_CASE_ST(ut_setup, ut_teardown,
14095 test_snow3g_decryption_test_case_1_oop),
14097 /** SNOW 3G generate auth, then encrypt (UEA2) */
14098 TEST_CASE_ST(ut_setup, ut_teardown,
14099 test_snow3g_auth_cipher_test_case_1),
14100 TEST_CASE_ST(ut_setup, ut_teardown,
14101 test_snow3g_auth_cipher_test_case_2),
14102 TEST_CASE_ST(ut_setup, ut_teardown,
14103 test_snow3g_auth_cipher_test_case_2_oop),
14104 TEST_CASE_ST(ut_setup, ut_teardown,
14105 test_snow3g_auth_cipher_part_digest_enc),
14106 TEST_CASE_ST(ut_setup, ut_teardown,
14107 test_snow3g_auth_cipher_part_digest_enc_oop),
14108 TEST_CASE_ST(ut_setup, ut_teardown,
14109 test_snow3g_auth_cipher_test_case_3_sgl),
14110 TEST_CASE_ST(ut_setup, ut_teardown,
14111 test_snow3g_auth_cipher_test_case_3_oop_sgl),
14112 TEST_CASE_ST(ut_setup, ut_teardown,
14113 test_snow3g_auth_cipher_part_digest_enc_sgl),
14114 TEST_CASE_ST(ut_setup, ut_teardown,
14115 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14117 /** SNOW 3G decrypt (UEA2), then verify auth */
14118 TEST_CASE_ST(ut_setup, ut_teardown,
14119 test_snow3g_auth_cipher_verify_test_case_1),
14120 TEST_CASE_ST(ut_setup, ut_teardown,
14121 test_snow3g_auth_cipher_verify_test_case_2),
14122 TEST_CASE_ST(ut_setup, ut_teardown,
14123 test_snow3g_auth_cipher_verify_test_case_2_oop),
14124 TEST_CASE_ST(ut_setup, ut_teardown,
14125 test_snow3g_auth_cipher_verify_part_digest_enc),
14126 TEST_CASE_ST(ut_setup, ut_teardown,
14127 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14128 TEST_CASE_ST(ut_setup, ut_teardown,
14129 test_snow3g_auth_cipher_verify_test_case_3_sgl),
14130 TEST_CASE_ST(ut_setup, ut_teardown,
14131 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14132 TEST_CASE_ST(ut_setup, ut_teardown,
14133 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14134 TEST_CASE_ST(ut_setup, ut_teardown,
14135 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14137 /** SNOW 3G decrypt only (UEA2) */
14138 TEST_CASE_ST(ut_setup, ut_teardown,
14139 test_snow3g_decryption_test_case_1),
14140 TEST_CASE_ST(ut_setup, ut_teardown,
14141 test_snow3g_decryption_test_case_2),
14142 TEST_CASE_ST(ut_setup, ut_teardown,
14143 test_snow3g_decryption_test_case_3),
14144 TEST_CASE_ST(ut_setup, ut_teardown,
14145 test_snow3g_decryption_test_case_4),
14146 TEST_CASE_ST(ut_setup, ut_teardown,
14147 test_snow3g_decryption_test_case_5),
14148 TEST_CASE_ST(ut_setup, ut_teardown,
14149 test_snow3g_decryption_with_digest_test_case_1),
14150 TEST_CASE_ST(ut_setup, ut_teardown,
14151 test_snow3g_hash_generate_test_case_1),
14152 TEST_CASE_ST(ut_setup, ut_teardown,
14153 test_snow3g_hash_generate_test_case_2),
14154 TEST_CASE_ST(ut_setup, ut_teardown,
14155 test_snow3g_hash_generate_test_case_3),
14157 /* Tests with buffers which length is not byte-aligned */
14158 TEST_CASE_ST(ut_setup, ut_teardown,
14159 test_snow3g_hash_generate_test_case_4),
14160 TEST_CASE_ST(ut_setup, ut_teardown,
14161 test_snow3g_hash_generate_test_case_5),
14162 TEST_CASE_ST(ut_setup, ut_teardown,
14163 test_snow3g_hash_generate_test_case_6),
14164 TEST_CASE_ST(ut_setup, ut_teardown,
14165 test_snow3g_hash_verify_test_case_1),
14166 TEST_CASE_ST(ut_setup, ut_teardown,
14167 test_snow3g_hash_verify_test_case_2),
14168 TEST_CASE_ST(ut_setup, ut_teardown,
14169 test_snow3g_hash_verify_test_case_3),
14171 /* Tests with buffers which length is not byte-aligned */
14172 TEST_CASE_ST(ut_setup, ut_teardown,
14173 test_snow3g_hash_verify_test_case_4),
14174 TEST_CASE_ST(ut_setup, ut_teardown,
14175 test_snow3g_hash_verify_test_case_5),
14176 TEST_CASE_ST(ut_setup, ut_teardown,
14177 test_snow3g_hash_verify_test_case_6),
14178 TEST_CASE_ST(ut_setup, ut_teardown,
14179 test_snow3g_cipher_auth_test_case_1),
14180 TEST_CASE_ST(ut_setup, ut_teardown,
14181 test_snow3g_auth_cipher_with_digest_test_case_1),
14186 static struct unit_test_suite cryptodev_zuc_testsuite = {
14187 .suite_name = "ZUC Test Suite",
14188 .setup = zuc_testsuite_setup,
14189 .unit_test_cases = {
14190 /** ZUC encrypt only (EEA3) */
14191 TEST_CASE_ST(ut_setup, ut_teardown,
14192 test_zuc_encryption_test_case_1),
14193 TEST_CASE_ST(ut_setup, ut_teardown,
14194 test_zuc_encryption_test_case_2),
14195 TEST_CASE_ST(ut_setup, ut_teardown,
14196 test_zuc_encryption_test_case_3),
14197 TEST_CASE_ST(ut_setup, ut_teardown,
14198 test_zuc_encryption_test_case_4),
14199 TEST_CASE_ST(ut_setup, ut_teardown,
14200 test_zuc_encryption_test_case_5),
14201 TEST_CASE_ST(ut_setup, ut_teardown,
14202 test_zuc_encryption_test_case_6_sgl),
14204 /** ZUC authenticate (EIA3) */
14205 TEST_CASE_ST(ut_setup, ut_teardown,
14206 test_zuc_hash_generate_test_case_1),
14207 TEST_CASE_ST(ut_setup, ut_teardown,
14208 test_zuc_hash_generate_test_case_2),
14209 TEST_CASE_ST(ut_setup, ut_teardown,
14210 test_zuc_hash_generate_test_case_3),
14211 TEST_CASE_ST(ut_setup, ut_teardown,
14212 test_zuc_hash_generate_test_case_4),
14213 TEST_CASE_ST(ut_setup, ut_teardown,
14214 test_zuc_hash_generate_test_case_5),
14215 TEST_CASE_ST(ut_setup, ut_teardown,
14216 test_zuc_hash_generate_test_case_6),
14217 TEST_CASE_ST(ut_setup, ut_teardown,
14218 test_zuc_hash_generate_test_case_7),
14219 TEST_CASE_ST(ut_setup, ut_teardown,
14220 test_zuc_hash_generate_test_case_8),
14222 /** ZUC alg-chain (EEA3/EIA3) */
14223 TEST_CASE_ST(ut_setup, ut_teardown,
14224 test_zuc_cipher_auth_test_case_1),
14225 TEST_CASE_ST(ut_setup, ut_teardown,
14226 test_zuc_cipher_auth_test_case_2),
14228 /** ZUC generate auth, then encrypt (EEA3) */
14229 TEST_CASE_ST(ut_setup, ut_teardown,
14230 test_zuc_auth_cipher_test_case_1),
14231 TEST_CASE_ST(ut_setup, ut_teardown,
14232 test_zuc_auth_cipher_test_case_1_oop),
14233 TEST_CASE_ST(ut_setup, ut_teardown,
14234 test_zuc_auth_cipher_test_case_1_sgl),
14235 TEST_CASE_ST(ut_setup, ut_teardown,
14236 test_zuc_auth_cipher_test_case_1_oop_sgl),
14238 /** ZUC decrypt (EEA3), then verify auth */
14239 TEST_CASE_ST(ut_setup, ut_teardown,
14240 test_zuc_auth_cipher_verify_test_case_1),
14241 TEST_CASE_ST(ut_setup, ut_teardown,
14242 test_zuc_auth_cipher_verify_test_case_1_oop),
14243 TEST_CASE_ST(ut_setup, ut_teardown,
14244 test_zuc_auth_cipher_verify_test_case_1_sgl),
14245 TEST_CASE_ST(ut_setup, ut_teardown,
14246 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14251 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
14252 .suite_name = "HMAC_MD5 Authentication Test Suite",
14253 .setup = hmac_md5_auth_testsuite_setup,
14254 .unit_test_cases = {
14255 TEST_CASE_ST(ut_setup, ut_teardown,
14256 test_MD5_HMAC_generate_case_1),
14257 TEST_CASE_ST(ut_setup, ut_teardown,
14258 test_MD5_HMAC_verify_case_1),
14259 TEST_CASE_ST(ut_setup, ut_teardown,
14260 test_MD5_HMAC_generate_case_2),
14261 TEST_CASE_ST(ut_setup, ut_teardown,
14262 test_MD5_HMAC_verify_case_2),
14267 static struct unit_test_suite cryptodev_kasumi_testsuite = {
14268 .suite_name = "Kasumi Test Suite",
14269 .setup = kasumi_testsuite_setup,
14270 .unit_test_cases = {
14271 /** KASUMI hash only (UIA1) */
14272 TEST_CASE_ST(ut_setup, ut_teardown,
14273 test_kasumi_hash_generate_test_case_1),
14274 TEST_CASE_ST(ut_setup, ut_teardown,
14275 test_kasumi_hash_generate_test_case_2),
14276 TEST_CASE_ST(ut_setup, ut_teardown,
14277 test_kasumi_hash_generate_test_case_3),
14278 TEST_CASE_ST(ut_setup, ut_teardown,
14279 test_kasumi_hash_generate_test_case_4),
14280 TEST_CASE_ST(ut_setup, ut_teardown,
14281 test_kasumi_hash_generate_test_case_5),
14282 TEST_CASE_ST(ut_setup, ut_teardown,
14283 test_kasumi_hash_generate_test_case_6),
14285 TEST_CASE_ST(ut_setup, ut_teardown,
14286 test_kasumi_hash_verify_test_case_1),
14287 TEST_CASE_ST(ut_setup, ut_teardown,
14288 test_kasumi_hash_verify_test_case_2),
14289 TEST_CASE_ST(ut_setup, ut_teardown,
14290 test_kasumi_hash_verify_test_case_3),
14291 TEST_CASE_ST(ut_setup, ut_teardown,
14292 test_kasumi_hash_verify_test_case_4),
14293 TEST_CASE_ST(ut_setup, ut_teardown,
14294 test_kasumi_hash_verify_test_case_5),
14296 /** KASUMI encrypt only (UEA1) */
14297 TEST_CASE_ST(ut_setup, ut_teardown,
14298 test_kasumi_encryption_test_case_1),
14299 TEST_CASE_ST(ut_setup, ut_teardown,
14300 test_kasumi_encryption_test_case_1_sgl),
14301 TEST_CASE_ST(ut_setup, ut_teardown,
14302 test_kasumi_encryption_test_case_1_oop),
14303 TEST_CASE_ST(ut_setup, ut_teardown,
14304 test_kasumi_encryption_test_case_1_oop_sgl),
14305 TEST_CASE_ST(ut_setup, ut_teardown,
14306 test_kasumi_encryption_test_case_2),
14307 TEST_CASE_ST(ut_setup, ut_teardown,
14308 test_kasumi_encryption_test_case_3),
14309 TEST_CASE_ST(ut_setup, ut_teardown,
14310 test_kasumi_encryption_test_case_4),
14311 TEST_CASE_ST(ut_setup, ut_teardown,
14312 test_kasumi_encryption_test_case_5),
14314 /** KASUMI decrypt only (UEA1) */
14315 TEST_CASE_ST(ut_setup, ut_teardown,
14316 test_kasumi_decryption_test_case_1),
14317 TEST_CASE_ST(ut_setup, ut_teardown,
14318 test_kasumi_decryption_test_case_2),
14319 TEST_CASE_ST(ut_setup, ut_teardown,
14320 test_kasumi_decryption_test_case_3),
14321 TEST_CASE_ST(ut_setup, ut_teardown,
14322 test_kasumi_decryption_test_case_4),
14323 TEST_CASE_ST(ut_setup, ut_teardown,
14324 test_kasumi_decryption_test_case_5),
14325 TEST_CASE_ST(ut_setup, ut_teardown,
14326 test_kasumi_decryption_test_case_1_oop),
14328 TEST_CASE_ST(ut_setup, ut_teardown,
14329 test_PDCP_PROTO_short_mac),
14330 TEST_CASE_ST(ut_setup, ut_teardown,
14331 test_kasumi_cipher_auth_test_case_1),
14333 /** KASUMI generate auth, then encrypt (F8) */
14334 TEST_CASE_ST(ut_setup, ut_teardown,
14335 test_kasumi_auth_cipher_test_case_1),
14336 TEST_CASE_ST(ut_setup, ut_teardown,
14337 test_kasumi_auth_cipher_test_case_2),
14338 TEST_CASE_ST(ut_setup, ut_teardown,
14339 test_kasumi_auth_cipher_test_case_2_oop),
14340 TEST_CASE_ST(ut_setup, ut_teardown,
14341 test_kasumi_auth_cipher_test_case_2_sgl),
14342 TEST_CASE_ST(ut_setup, ut_teardown,
14343 test_kasumi_auth_cipher_test_case_2_oop_sgl),
14345 /** KASUMI decrypt (F8), then verify auth */
14346 TEST_CASE_ST(ut_setup, ut_teardown,
14347 test_kasumi_auth_cipher_verify_test_case_1),
14348 TEST_CASE_ST(ut_setup, ut_teardown,
14349 test_kasumi_auth_cipher_verify_test_case_2),
14350 TEST_CASE_ST(ut_setup, ut_teardown,
14351 test_kasumi_auth_cipher_verify_test_case_2_oop),
14352 TEST_CASE_ST(ut_setup, ut_teardown,
14353 test_kasumi_auth_cipher_verify_test_case_2_sgl),
14354 TEST_CASE_ST(ut_setup, ut_teardown,
14355 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14361 static struct unit_test_suite cryptodev_esn_testsuite = {
14362 .suite_name = "ESN Test Suite",
14363 .setup = esn_testsuite_setup,
14364 .unit_test_cases = {
14365 TEST_CASE_ST(ut_setup, ut_teardown,
14366 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14367 TEST_CASE_ST(ut_setup, ut_teardown,
14368 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14373 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
14374 .suite_name = "Negative AES GCM Test Suite",
14375 .setup = negative_aes_gcm_testsuite_setup,
14376 .unit_test_cases = {
14377 TEST_CASE_ST(ut_setup, ut_teardown,
14378 test_AES_GCM_auth_encryption_fail_iv_corrupt),
14379 TEST_CASE_ST(ut_setup, ut_teardown,
14380 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14381 TEST_CASE_ST(ut_setup, ut_teardown,
14382 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14383 TEST_CASE_ST(ut_setup, ut_teardown,
14384 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14385 TEST_CASE_ST(ut_setup, ut_teardown,
14386 test_AES_GCM_auth_encryption_fail_aad_corrupt),
14387 TEST_CASE_ST(ut_setup, ut_teardown,
14388 test_AES_GCM_auth_encryption_fail_tag_corrupt),
14389 TEST_CASE_ST(ut_setup, ut_teardown,
14390 test_AES_GCM_auth_decryption_fail_iv_corrupt),
14391 TEST_CASE_ST(ut_setup, ut_teardown,
14392 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14393 TEST_CASE_ST(ut_setup, ut_teardown,
14394 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14395 TEST_CASE_ST(ut_setup, ut_teardown,
14396 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14397 TEST_CASE_ST(ut_setup, ut_teardown,
14398 test_AES_GCM_auth_decryption_fail_aad_corrupt),
14399 TEST_CASE_ST(ut_setup, ut_teardown,
14400 test_AES_GCM_auth_decryption_fail_tag_corrupt),
14406 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
14407 .suite_name = "Negative AES GMAC Test Suite",
14408 .setup = negative_aes_gmac_testsuite_setup,
14409 .unit_test_cases = {
14410 TEST_CASE_ST(ut_setup, ut_teardown,
14411 authentication_verify_AES128_GMAC_fail_data_corrupt),
14412 TEST_CASE_ST(ut_setup, ut_teardown,
14413 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14419 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
14420 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14421 .setup = mixed_cipher_hash_testsuite_setup,
14422 .unit_test_cases = {
14423 /** AUTH AES CMAC + CIPHER AES CTR */
14424 TEST_CASE_ST(ut_setup, ut_teardown,
14425 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14426 TEST_CASE_ST(ut_setup, ut_teardown,
14427 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14428 TEST_CASE_ST(ut_setup, ut_teardown,
14429 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14430 TEST_CASE_ST(ut_setup, ut_teardown,
14431 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14432 TEST_CASE_ST(ut_setup, ut_teardown,
14433 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14434 TEST_CASE_ST(ut_setup, ut_teardown,
14435 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14436 TEST_CASE_ST(ut_setup, ut_teardown,
14437 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14438 TEST_CASE_ST(ut_setup, ut_teardown,
14439 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14441 /** AUTH ZUC + CIPHER SNOW3G */
14442 TEST_CASE_ST(ut_setup, ut_teardown,
14443 test_auth_zuc_cipher_snow_test_case_1),
14444 TEST_CASE_ST(ut_setup, ut_teardown,
14445 test_verify_auth_zuc_cipher_snow_test_case_1),
14446 /** AUTH AES CMAC + CIPHER SNOW3G */
14447 TEST_CASE_ST(ut_setup, ut_teardown,
14448 test_auth_aes_cmac_cipher_snow_test_case_1),
14449 TEST_CASE_ST(ut_setup, ut_teardown,
14450 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14451 /** AUTH ZUC + CIPHER AES CTR */
14452 TEST_CASE_ST(ut_setup, ut_teardown,
14453 test_auth_zuc_cipher_aes_ctr_test_case_1),
14454 TEST_CASE_ST(ut_setup, ut_teardown,
14455 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14456 /** AUTH SNOW3G + CIPHER AES CTR */
14457 TEST_CASE_ST(ut_setup, ut_teardown,
14458 test_auth_snow_cipher_aes_ctr_test_case_1),
14459 TEST_CASE_ST(ut_setup, ut_teardown,
14460 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14461 /** AUTH SNOW3G + CIPHER ZUC */
14462 TEST_CASE_ST(ut_setup, ut_teardown,
14463 test_auth_snow_cipher_zuc_test_case_1),
14464 TEST_CASE_ST(ut_setup, ut_teardown,
14465 test_verify_auth_snow_cipher_zuc_test_case_1),
14466 /** AUTH AES CMAC + CIPHER ZUC */
14467 TEST_CASE_ST(ut_setup, ut_teardown,
14468 test_auth_aes_cmac_cipher_zuc_test_case_1),
14469 TEST_CASE_ST(ut_setup, ut_teardown,
14470 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14472 /** AUTH NULL + CIPHER SNOW3G */
14473 TEST_CASE_ST(ut_setup, ut_teardown,
14474 test_auth_null_cipher_snow_test_case_1),
14475 TEST_CASE_ST(ut_setup, ut_teardown,
14476 test_verify_auth_null_cipher_snow_test_case_1),
14477 /** AUTH NULL + CIPHER ZUC */
14478 TEST_CASE_ST(ut_setup, ut_teardown,
14479 test_auth_null_cipher_zuc_test_case_1),
14480 TEST_CASE_ST(ut_setup, ut_teardown,
14481 test_verify_auth_null_cipher_zuc_test_case_1),
14482 /** AUTH SNOW3G + CIPHER NULL */
14483 TEST_CASE_ST(ut_setup, ut_teardown,
14484 test_auth_snow_cipher_null_test_case_1),
14485 TEST_CASE_ST(ut_setup, ut_teardown,
14486 test_verify_auth_snow_cipher_null_test_case_1),
14487 /** AUTH ZUC + CIPHER NULL */
14488 TEST_CASE_ST(ut_setup, ut_teardown,
14489 test_auth_zuc_cipher_null_test_case_1),
14490 TEST_CASE_ST(ut_setup, ut_teardown,
14491 test_verify_auth_zuc_cipher_null_test_case_1),
14492 /** AUTH NULL + CIPHER AES CTR */
14493 TEST_CASE_ST(ut_setup, ut_teardown,
14494 test_auth_null_cipher_aes_ctr_test_case_1),
14495 TEST_CASE_ST(ut_setup, ut_teardown,
14496 test_verify_auth_null_cipher_aes_ctr_test_case_1),
14497 /** AUTH AES CMAC + CIPHER NULL */
14498 TEST_CASE_ST(ut_setup, ut_teardown,
14499 test_auth_aes_cmac_cipher_null_test_case_1),
14500 TEST_CASE_ST(ut_setup, ut_teardown,
14501 test_verify_auth_aes_cmac_cipher_null_test_case_1),
14507 run_cryptodev_testsuite(const char *pmd_name)
14509 uint8_t ret, j, i = 0, blk_start_idx = 0;
14510 const enum blockcipher_test_type blk_suites[] = {
14511 BLKCIPHER_AES_CHAIN_TYPE,
14512 BLKCIPHER_AES_CIPHERONLY_TYPE,
14513 BLKCIPHER_AES_DOCSIS_TYPE,
14514 BLKCIPHER_3DES_CHAIN_TYPE,
14515 BLKCIPHER_3DES_CIPHERONLY_TYPE,
14516 BLKCIPHER_DES_CIPHERONLY_TYPE,
14517 BLKCIPHER_DES_DOCSIS_TYPE,
14518 BLKCIPHER_AUTHONLY_TYPE};
14519 struct unit_test_suite *static_suites[] = {
14520 &cryptodev_multi_session_testsuite,
14521 &cryptodev_null_testsuite,
14522 &cryptodev_aes_ccm_auth_testsuite,
14523 &cryptodev_aes_gcm_auth_testsuite,
14524 &cryptodev_aes_gmac_auth_testsuite,
14525 &cryptodev_snow3g_testsuite,
14526 &cryptodev_chacha20_poly1305_testsuite,
14527 &cryptodev_zuc_testsuite,
14528 &cryptodev_hmac_md5_auth_testsuite,
14529 &cryptodev_kasumi_testsuite,
14530 &cryptodev_esn_testsuite,
14531 &cryptodev_negative_aes_gcm_testsuite,
14532 &cryptodev_negative_aes_gmac_testsuite,
14533 &cryptodev_mixed_cipher_hash_testsuite,
14534 &cryptodev_negative_hmac_sha1_testsuite,
14535 &cryptodev_gen_testsuite,
14536 #ifdef RTE_LIB_SECURITY
14537 &pdcp_proto_testsuite,
14538 &docsis_proto_testsuite,
14542 static struct unit_test_suite ts = {
14543 .suite_name = "Cryptodev Unit Test Suite",
14544 .setup = testsuite_setup,
14545 .teardown = testsuite_teardown,
14546 .unit_test_cases = {TEST_CASES_END()}
14549 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
14551 if (gbl_driver_id == -1) {
14552 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
14553 return TEST_SKIPPED;
14556 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14557 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
14559 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
14560 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14561 ret = unit_test_suite_runner(&ts);
14563 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
14564 free(ts.unit_test_suites);
14569 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
14571 struct rte_cryptodev_info dev_info;
14572 uint8_t i, nb_devs;
14575 driver_id = rte_cryptodev_driver_id_get(pmd_name);
14576 if (driver_id == -1) {
14577 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
14578 return TEST_SKIPPED;
14581 nb_devs = rte_cryptodev_count();
14583 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
14584 return TEST_SKIPPED;
14587 for (i = 0; i < nb_devs; i++) {
14588 rte_cryptodev_info_get(i, &dev_info);
14589 if (dev_info.driver_id == driver_id) {
14590 if (!(dev_info.feature_flags & flag)) {
14591 RTE_LOG(INFO, USER1, "%s not supported\n",
14593 return TEST_SKIPPED;
14595 return 0; /* found */
14599 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
14600 return TEST_SKIPPED;
14604 test_cryptodev_qat(void)
14606 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14610 test_cryptodev_virtio(void)
14612 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14616 test_cryptodev_aesni_mb(void)
14618 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14622 test_cryptodev_cpu_aesni_mb(void)
14625 enum rte_security_session_action_type at = gbl_action_type;
14626 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14627 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14628 gbl_action_type = at;
14633 test_cryptodev_openssl(void)
14635 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14639 test_cryptodev_aesni_gcm(void)
14641 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14645 test_cryptodev_cpu_aesni_gcm(void)
14648 enum rte_security_session_action_type at = gbl_action_type;
14649 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14650 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14651 gbl_action_type = at;
14656 test_cryptodev_mlx5(void)
14658 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
14662 test_cryptodev_null(void)
14664 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14668 test_cryptodev_sw_snow3g(void)
14670 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14674 test_cryptodev_sw_kasumi(void)
14676 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14680 test_cryptodev_sw_zuc(void)
14682 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14686 test_cryptodev_armv8(void)
14688 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14692 test_cryptodev_mrvl(void)
14694 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14697 #ifdef RTE_CRYPTO_SCHEDULER
14700 test_cryptodev_scheduler(void)
14702 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
14703 const enum blockcipher_test_type blk_suites[] = {
14704 BLKCIPHER_AES_CHAIN_TYPE,
14705 BLKCIPHER_AES_CIPHERONLY_TYPE,
14706 BLKCIPHER_AUTHONLY_TYPE
14708 static struct unit_test_suite scheduler_multicore = {
14709 .suite_name = "Scheduler Multicore Unit Test Suite",
14710 .setup = scheduler_multicore_testsuite_setup,
14711 .teardown = scheduler_mode_testsuite_teardown,
14712 .unit_test_cases = {TEST_CASES_END()}
14714 static struct unit_test_suite scheduler_round_robin = {
14715 .suite_name = "Scheduler Round Robin Unit Test Suite",
14716 .setup = scheduler_roundrobin_testsuite_setup,
14717 .teardown = scheduler_mode_testsuite_teardown,
14718 .unit_test_cases = {TEST_CASES_END()}
14720 static struct unit_test_suite scheduler_failover = {
14721 .suite_name = "Scheduler Failover Unit Test Suite",
14722 .setup = scheduler_failover_testsuite_setup,
14723 .teardown = scheduler_mode_testsuite_teardown,
14724 .unit_test_cases = {TEST_CASES_END()}
14726 static struct unit_test_suite scheduler_pkt_size_distr = {
14727 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
14728 .setup = scheduler_pkt_size_distr_testsuite_setup,
14729 .teardown = scheduler_mode_testsuite_teardown,
14730 .unit_test_cases = {TEST_CASES_END()}
14732 struct unit_test_suite *sched_mode_suites[] = {
14733 &scheduler_multicore,
14734 &scheduler_round_robin,
14735 &scheduler_failover,
14736 &scheduler_pkt_size_distr
14738 static struct unit_test_suite scheduler_config = {
14739 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
14740 .unit_test_cases = {
14741 TEST_CASE(test_scheduler_attach_worker_op),
14742 TEST_CASE(test_scheduler_mode_multicore_op),
14743 TEST_CASE(test_scheduler_mode_roundrobin_op),
14744 TEST_CASE(test_scheduler_mode_failover_op),
14745 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
14746 TEST_CASE(test_scheduler_detach_worker_op),
14748 TEST_CASES_END() /**< NULL terminate array */
14751 struct unit_test_suite *static_suites[] = {
14755 static struct unit_test_suite ts = {
14756 .suite_name = "Scheduler Unit Test Suite",
14757 .setup = scheduler_testsuite_setup,
14758 .teardown = testsuite_teardown,
14759 .unit_test_cases = {TEST_CASES_END()}
14762 gbl_driver_id = rte_cryptodev_driver_id_get(
14763 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14765 if (gbl_driver_id == -1) {
14766 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14767 return TEST_SKIPPED;
14770 if (rte_cryptodev_driver_id_get(
14771 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14772 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14773 return TEST_SKIPPED;
14776 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14778 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
14779 (struct unit_test_suite *) *
14780 (RTE_DIM(blk_suites) + 1));
14781 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
14782 blk_suites, RTE_DIM(blk_suites));
14783 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
14786 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14787 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
14788 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
14789 RTE_DIM(sched_mode_suites));
14790 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14791 ret = unit_test_suite_runner(&ts);
14793 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14794 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
14795 (*sched_mode_suites[sched_i]),
14796 RTE_DIM(blk_suites));
14797 free(sched_mode_suites[sched_i]->unit_test_suites);
14799 free(ts.unit_test_suites);
14803 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14808 test_cryptodev_dpaa2_sec(void)
14810 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14814 test_cryptodev_dpaa_sec(void)
14816 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14820 test_cryptodev_ccp(void)
14822 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14826 test_cryptodev_octeontx(void)
14828 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14832 test_cryptodev_octeontx2(void)
14834 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14838 test_cryptodev_caam_jr(void)
14840 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14844 test_cryptodev_nitrox(void)
14846 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14850 test_cryptodev_bcmfs(void)
14852 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14856 test_cryptodev_qat_raw_api(void)
14858 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
14861 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
14866 global_api_test_type = CRYPTODEV_RAW_API_TEST;
14867 ret = run_cryptodev_testsuite(pmd_name);
14868 global_api_test_type = CRYPTODEV_API_TEST;
14874 test_cryptodev_cn9k(void)
14876 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
14880 test_cryptodev_cn10k(void)
14882 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
14885 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14886 test_cryptodev_qat_raw_api);
14887 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14888 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14889 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14890 test_cryptodev_cpu_aesni_mb);
14891 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14892 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14893 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14894 test_cryptodev_cpu_aesni_gcm);
14895 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
14896 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14897 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14898 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14899 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14900 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14901 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14902 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14903 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14904 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14905 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14906 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14907 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14908 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14909 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14910 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
14911 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
14912 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);