4 * Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
39 #include <rte_crypto.h>
40 #include <rte_cryptodev.h>
41 #include <rte_cryptodev_pmd.h>
44 #include "test_cryptodev.h"
46 #include "test_cryptodev_blockcipher.h"
47 #include "test_cryptodev_aes_test_vectors.h"
48 #include "test_cryptodev_des_test_vectors.h"
49 #include "test_cryptodev_hash_test_vectors.h"
50 #include "test_cryptodev_kasumi_test_vectors.h"
51 #include "test_cryptodev_kasumi_hash_test_vectors.h"
52 #include "test_cryptodev_snow3g_test_vectors.h"
53 #include "test_cryptodev_snow3g_hash_test_vectors.h"
54 #include "test_cryptodev_zuc_test_vectors.h"
55 #include "test_cryptodev_zuc_hash_test_vectors.h"
56 #include "test_cryptodev_gcm_test_vectors.h"
57 #include "test_cryptodev_hmac_test_vectors.h"
59 static enum rte_cryptodev_type gbl_cryptodev_type;
61 struct crypto_testsuite_params {
62 struct rte_mempool *mbuf_pool;
63 struct rte_mempool *large_mbuf_pool;
64 struct rte_mempool *op_mpool;
65 struct rte_cryptodev_config conf;
66 struct rte_cryptodev_qp_conf qp_conf;
68 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
69 uint8_t valid_dev_count;
72 struct crypto_unittest_params {
73 struct rte_crypto_sym_xform cipher_xform;
74 struct rte_crypto_sym_xform auth_xform;
76 struct rte_cryptodev_sym_session *sess;
78 struct rte_crypto_op *op;
80 struct rte_mbuf *obuf, *ibuf;
85 #define ALIGN_POW2_ROUNDUP(num, align) \
86 (((num) + (align) - 1) & ~((align) - 1))
89 * Forward declarations.
92 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
93 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
97 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
98 struct crypto_unittest_params *ut_params,
99 struct crypto_testsuite_params *ts_param,
100 const uint8_t *cipher,
101 const uint8_t *digest,
104 static struct rte_mbuf *
105 setup_test_string(struct rte_mempool *mpool,
106 const char *string, size_t len, uint8_t blocksize)
108 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
109 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
111 memset(m->buf_addr, 0, m->buf_len);
113 char *dst = rte_pktmbuf_append(m, t_len);
120 rte_memcpy(dst, string, t_len);
122 memset(dst, 0, t_len);
128 /* Get number of bytes in X bits (rounding up) */
130 ceil_byte_length(uint32_t num_bits)
133 return ((num_bits >> 3) + 1);
135 return (num_bits >> 3);
138 static struct rte_crypto_op *
139 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
141 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
142 printf("Error sending packet for encryption");
148 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
154 static struct crypto_testsuite_params testsuite_params = { NULL };
155 static struct crypto_unittest_params unittest_params;
158 testsuite_setup(void)
160 struct crypto_testsuite_params *ts_params = &testsuite_params;
161 struct rte_cryptodev_info info;
162 unsigned i, nb_devs, dev_id;
166 memset(ts_params, 0, sizeof(*ts_params));
168 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
169 if (ts_params->mbuf_pool == NULL) {
170 /* Not already created so create */
171 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
173 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
175 if (ts_params->mbuf_pool == NULL) {
176 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
181 ts_params->large_mbuf_pool = rte_mempool_lookup(
182 "CRYPTO_LARGE_MBUFPOOL");
183 if (ts_params->large_mbuf_pool == NULL) {
184 /* Not already created so create */
185 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
186 "CRYPTO_LARGE_MBUFPOOL",
189 if (ts_params->large_mbuf_pool == NULL) {
191 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
196 ts_params->op_mpool = rte_crypto_op_pool_create(
197 "MBUF_CRYPTO_SYM_OP_POOL",
198 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
199 NUM_MBUFS, MBUF_CACHE_SIZE,
201 sizeof(struct rte_crypto_sym_xform),
203 if (ts_params->op_mpool == NULL) {
204 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
208 /* Create 2 AESNI MB devices if required */
209 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
210 #ifndef RTE_LIBRTE_PMD_AESNI_MB
211 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
212 " enabled in config file to run this testsuite.\n");
215 nb_devs = rte_cryptodev_count_devtype(
216 RTE_CRYPTODEV_AESNI_MB_PMD);
218 for (i = nb_devs; i < 2; i++) {
219 ret = rte_eal_vdev_init(
220 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
222 TEST_ASSERT(ret == 0,
223 "Failed to create instance %u of"
225 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
230 /* Create 2 AESNI GCM devices if required */
231 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
232 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
233 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
234 " enabled in config file to run this testsuite.\n");
237 nb_devs = rte_cryptodev_count_devtype(
238 RTE_CRYPTODEV_AESNI_GCM_PMD);
240 for (i = nb_devs; i < 2; i++) {
241 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
242 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
243 "Failed to create instance %u of"
245 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
250 /* Create 2 SNOW 3G devices if required */
251 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
252 #ifndef RTE_LIBRTE_PMD_SNOW3G
253 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
254 " enabled in config file to run this testsuite.\n");
257 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
259 for (i = nb_devs; i < 2; i++) {
260 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
261 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
262 "Failed to create instance %u of"
264 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
269 /* Create 2 KASUMI devices if required */
270 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
271 #ifndef RTE_LIBRTE_PMD_KASUMI
272 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
273 " enabled in config file to run this testsuite.\n");
276 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
278 for (i = nb_devs; i < 2; i++) {
279 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
280 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
281 "Failed to create instance %u of"
283 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
288 /* Create 2 ZUC devices if required */
289 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
290 #ifndef RTE_LIBRTE_PMD_ZUC
291 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
292 " enabled in config file to run this testsuite.\n");
295 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
297 for (i = nb_devs; i < 2; i++) {
298 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
299 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
300 "Failed to create instance %u of"
302 i, RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
307 /* Create 2 NULL devices if required */
308 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
309 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
310 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
311 " enabled in config file to run this testsuite.\n");
314 nb_devs = rte_cryptodev_count_devtype(
315 RTE_CRYPTODEV_NULL_PMD);
317 for (i = nb_devs; i < 2; i++) {
318 int dev_id = rte_eal_vdev_init(
319 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
321 TEST_ASSERT(dev_id >= 0,
322 "Failed to create instance %u of"
324 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
329 /* Create 2 OPENSSL devices if required */
330 if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
331 #ifndef RTE_LIBRTE_PMD_OPENSSL
332 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
333 " enabled in config file to run this testsuite.\n");
336 nb_devs = rte_cryptodev_count_devtype(
337 RTE_CRYPTODEV_OPENSSL_PMD);
339 for (i = nb_devs; i < 2; i++) {
340 ret = rte_eal_vdev_init(
341 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
344 TEST_ASSERT(ret == 0, "Failed to create "
345 "instance %u of pmd : %s", i,
346 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
351 /* Create 2 ARMv8 devices if required */
352 if (gbl_cryptodev_type == RTE_CRYPTODEV_ARMV8_PMD) {
353 #ifndef RTE_LIBRTE_PMD_ARMV8_CRYPTO
354 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO must be"
355 " enabled in config file to run this testsuite.\n");
358 nb_devs = rte_cryptodev_count_devtype(
359 RTE_CRYPTODEV_ARMV8_PMD);
361 for (i = nb_devs; i < 2; i++) {
362 ret = rte_eal_vdev_init(
363 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
366 TEST_ASSERT(ret == 0, "Failed to create "
367 "instance %u of pmd : %s", i,
368 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
373 #ifndef RTE_LIBRTE_PMD_QAT
374 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
375 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
376 "in config file to run this testsuite.\n");
381 nb_devs = rte_cryptodev_count();
383 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
387 /* Create list of valid crypto devs */
388 for (i = 0; i < nb_devs; i++) {
389 rte_cryptodev_info_get(i, &info);
390 if (info.dev_type == gbl_cryptodev_type)
391 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
394 if (ts_params->valid_dev_count < 1)
397 /* Set up all the qps on the first of the valid devices found */
399 dev_id = ts_params->valid_devs[0];
401 rte_cryptodev_info_get(dev_id, &info);
403 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
404 ts_params->conf.socket_id = SOCKET_ID_ANY;
405 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
407 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
409 "Failed to configure cryptodev %u with %u qps",
410 dev_id, ts_params->conf.nb_queue_pairs);
412 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
414 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
415 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
416 dev_id, qp_id, &ts_params->qp_conf,
417 rte_cryptodev_socket_id(dev_id)),
418 "Failed to setup queue pair %u on cryptodev %u",
426 testsuite_teardown(void)
428 struct crypto_testsuite_params *ts_params = &testsuite_params;
430 if (ts_params->mbuf_pool != NULL) {
431 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
432 rte_mempool_avail_count(ts_params->mbuf_pool));
435 if (ts_params->op_mpool != NULL) {
436 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
437 rte_mempool_avail_count(ts_params->op_mpool));
445 struct crypto_testsuite_params *ts_params = &testsuite_params;
446 struct crypto_unittest_params *ut_params = &unittest_params;
450 /* Clear unit test parameters before running test */
451 memset(ut_params, 0, sizeof(*ut_params));
453 /* Reconfigure device to default parameters */
454 ts_params->conf.socket_id = SOCKET_ID_ANY;
455 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
457 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
459 "Failed to configure cryptodev %u",
460 ts_params->valid_devs[0]);
462 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
463 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
464 ts_params->valid_devs[0], qp_id,
466 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
467 "Failed to setup queue pair %u on cryptodev %u",
468 qp_id, ts_params->valid_devs[0]);
472 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
474 /* Start the device */
475 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
476 "Failed to start cryptodev %u",
477 ts_params->valid_devs[0]);
485 struct crypto_testsuite_params *ts_params = &testsuite_params;
486 struct crypto_unittest_params *ut_params = &unittest_params;
487 struct rte_cryptodev_stats stats;
489 /* free crypto session structure */
490 if (ut_params->sess) {
491 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
493 ut_params->sess = NULL;
496 /* free crypto operation structure */
498 rte_crypto_op_free(ut_params->op);
501 * free mbuf - both obuf and ibuf are usually the same,
502 * so check if they point at the same address is necessary,
503 * to avoid freeing the mbuf twice.
505 if (ut_params->obuf) {
506 rte_pktmbuf_free(ut_params->obuf);
507 if (ut_params->ibuf == ut_params->obuf)
511 if (ut_params->ibuf) {
512 rte_pktmbuf_free(ut_params->ibuf);
516 if (ts_params->mbuf_pool != NULL)
517 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
518 rte_mempool_avail_count(ts_params->mbuf_pool));
520 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
522 /* Stop the device */
523 rte_cryptodev_stop(ts_params->valid_devs[0]);
527 test_device_configure_invalid_dev_id(void)
529 struct crypto_testsuite_params *ts_params = &testsuite_params;
530 uint16_t dev_id, num_devs = 0;
532 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
533 "Need at least %d devices for test", 1);
535 /* valid dev_id values */
536 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
538 /* Stop the device in case it's started so it can be configured */
539 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
541 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
542 "Failed test for rte_cryptodev_configure: "
543 "invalid dev_num %u", dev_id);
545 /* invalid dev_id values */
548 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
549 "Failed test for rte_cryptodev_configure: "
550 "invalid dev_num %u", dev_id);
554 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
555 "Failed test for rte_cryptodev_configure:"
556 "invalid dev_num %u", dev_id);
562 test_device_configure_invalid_queue_pair_ids(void)
564 struct crypto_testsuite_params *ts_params = &testsuite_params;
565 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
567 /* Stop the device in case it's started so it can be configured */
568 rte_cryptodev_stop(ts_params->valid_devs[0]);
570 /* valid - one queue pairs */
571 ts_params->conf.nb_queue_pairs = 1;
573 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
575 "Failed to configure cryptodev: dev_id %u, qp_id %u",
576 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
579 /* valid - max value queue pairs */
580 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
582 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
584 "Failed to configure cryptodev: dev_id %u, qp_id %u",
585 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
588 /* invalid - zero queue pairs */
589 ts_params->conf.nb_queue_pairs = 0;
591 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
593 "Failed test for rte_cryptodev_configure, dev_id %u,"
595 ts_params->valid_devs[0],
596 ts_params->conf.nb_queue_pairs);
599 /* invalid - max value supported by field queue pairs */
600 ts_params->conf.nb_queue_pairs = UINT16_MAX;
602 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
604 "Failed test for rte_cryptodev_configure, dev_id %u,"
606 ts_params->valid_devs[0],
607 ts_params->conf.nb_queue_pairs);
610 /* invalid - max value + 1 queue pairs */
611 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
613 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
615 "Failed test for rte_cryptodev_configure, dev_id %u,"
617 ts_params->valid_devs[0],
618 ts_params->conf.nb_queue_pairs);
620 /* revert to original testsuite value */
621 ts_params->conf.nb_queue_pairs = orig_nb_qps;
627 test_queue_pair_descriptor_setup(void)
629 struct crypto_testsuite_params *ts_params = &testsuite_params;
630 struct rte_cryptodev_info dev_info;
631 struct rte_cryptodev_qp_conf qp_conf = {
632 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
637 /* Stop the device in case it's started so it can be configured */
638 rte_cryptodev_stop(ts_params->valid_devs[0]);
641 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
643 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
645 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
646 &ts_params->conf), "Failed to configure cryptodev %u",
647 ts_params->valid_devs[0]);
651 * Test various ring sizes on this device. memzones can't be
652 * freed so are re-used if ring is released and re-created.
654 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
656 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
657 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
658 ts_params->valid_devs[0], qp_id, &qp_conf,
659 rte_cryptodev_socket_id(
660 ts_params->valid_devs[0])),
662 "rte_cryptodev_queue_pair_setup: num_inflights "
663 "%u on qp %u on cryptodev %u",
664 qp_conf.nb_descriptors, qp_id,
665 ts_params->valid_devs[0]);
668 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
670 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
671 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
672 ts_params->valid_devs[0], qp_id, &qp_conf,
673 rte_cryptodev_socket_id(
674 ts_params->valid_devs[0])),
676 " rte_cryptodev_queue_pair_setup: num_inflights"
677 " %u on qp %u on cryptodev %u",
678 qp_conf.nb_descriptors, qp_id,
679 ts_params->valid_devs[0]);
682 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
684 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
685 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
686 ts_params->valid_devs[0], qp_id, &qp_conf,
687 rte_cryptodev_socket_id(
688 ts_params->valid_devs[0])),
690 "rte_cryptodev_queue_pair_setup: num_inflights"
691 " %u on qp %u on cryptodev %u",
692 qp_conf.nb_descriptors, qp_id,
693 ts_params->valid_devs[0]);
696 /* invalid number of descriptors - max supported + 2 */
697 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
699 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
700 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
701 ts_params->valid_devs[0], qp_id, &qp_conf,
702 rte_cryptodev_socket_id(
703 ts_params->valid_devs[0])),
704 "Unexpectedly passed test for "
705 "rte_cryptodev_queue_pair_setup:"
706 "num_inflights %u on qp %u on cryptodev %u",
707 qp_conf.nb_descriptors, qp_id,
708 ts_params->valid_devs[0]);
711 /* invalid number of descriptors - max value of parameter */
712 qp_conf.nb_descriptors = UINT32_MAX-1;
714 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
715 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
716 ts_params->valid_devs[0], qp_id, &qp_conf,
717 rte_cryptodev_socket_id(
718 ts_params->valid_devs[0])),
719 "Unexpectedly passed test for "
720 "rte_cryptodev_queue_pair_setup:"
721 "num_inflights %u on qp %u on cryptodev %u",
722 qp_conf.nb_descriptors, qp_id,
723 ts_params->valid_devs[0]);
726 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
728 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
729 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
730 ts_params->valid_devs[0], qp_id, &qp_conf,
731 rte_cryptodev_socket_id(
732 ts_params->valid_devs[0])),
734 " rte_cryptodev_queue_pair_setup:"
735 "num_inflights %u on qp %u on cryptodev %u",
736 qp_conf.nb_descriptors, qp_id,
737 ts_params->valid_devs[0]);
740 /* invalid number of descriptors - max supported + 1 */
741 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
743 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
744 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
745 ts_params->valid_devs[0], qp_id, &qp_conf,
746 rte_cryptodev_socket_id(
747 ts_params->valid_devs[0])),
748 "Unexpectedly passed test for "
749 "rte_cryptodev_queue_pair_setup:"
750 "num_inflights %u on qp %u on cryptodev %u",
751 qp_conf.nb_descriptors, qp_id,
752 ts_params->valid_devs[0]);
755 /* test invalid queue pair id */
756 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
758 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
760 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
761 ts_params->valid_devs[0],
763 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
764 "Failed test for rte_cryptodev_queue_pair_setup:"
765 "invalid qp %u on cryptodev %u",
766 qp_id, ts_params->valid_devs[0]);
768 qp_id = 0xffff; /*invalid*/
770 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
771 ts_params->valid_devs[0],
773 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
774 "Failed test for rte_cryptodev_queue_pair_setup:"
775 "invalid qp %u on cryptodev %u",
776 qp_id, ts_params->valid_devs[0]);
781 /* ***** Plaintext data for tests ***** */
783 const char catch_22_quote_1[] =
784 "There was only one catch and that was Catch-22, which "
785 "specified that a concern for one's safety in the face of "
786 "dangers that were real and immediate was the process of a "
787 "rational mind. Orr was crazy and could be grounded. All he "
788 "had to do was ask; and as soon as he did, he would no longer "
789 "be crazy and would have to fly more missions. Orr would be "
790 "crazy to fly more missions and sane if he didn't, but if he "
791 "was sane he had to fly them. If he flew them he was crazy "
792 "and didn't have to; but if he didn't want to he was sane and "
793 "had to. Yossarian was moved very deeply by the absolute "
794 "simplicity of this clause of Catch-22 and let out a "
795 "respectful whistle. \"That's some catch, that Catch-22\", he "
796 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
798 const char catch_22_quote[] =
799 "What a lousy earth! He wondered how many people were "
800 "destitute that same night even in his own prosperous country, "
801 "how many homes were shanties, how many husbands were drunk "
802 "and wives socked, and how many children were bullied, abused, "
803 "or abandoned. How many families hungered for food they could "
804 "not afford to buy? How many hearts were broken? How many "
805 "suicides would take place that same night, how many people "
806 "would go insane? How many cockroaches and landlords would "
807 "triumph? How many winners were losers, successes failures, "
808 "and rich men poor men? How many wise guys were stupid? How "
809 "many happy endings were unhappy endings? How many honest men "
810 "were liars, brave men cowards, loyal men traitors, how many "
811 "sainted men were corrupt, how many people in positions of "
812 "trust had sold their souls to bodyguards, how many had never "
813 "had souls? How many straight-and-narrow paths were crooked "
814 "paths? How many best families were worst families and how "
815 "many good people were bad people? When you added them all up "
816 "and then subtracted, you might be left with only the children, "
817 "and perhaps with Albert Einstein and an old violinist or "
818 "sculptor somewhere.";
820 #define QUOTE_480_BYTES (480)
821 #define QUOTE_512_BYTES (512)
822 #define QUOTE_768_BYTES (768)
823 #define QUOTE_1024_BYTES (1024)
827 /* ***** SHA1 Hash Tests ***** */
829 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
831 static uint8_t hmac_sha1_key[] = {
832 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
833 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
834 0xDE, 0xF4, 0xDE, 0xAD };
836 /* ***** SHA224 Hash Tests ***** */
838 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
841 /* ***** AES-CBC Cipher Tests ***** */
843 #define CIPHER_KEY_LENGTH_AES_CBC (16)
844 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
846 static uint8_t aes_cbc_key[] = {
847 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
848 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
850 static uint8_t aes_cbc_iv[] = {
851 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
852 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
855 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
857 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
858 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
859 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
860 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
861 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
862 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
863 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
864 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
865 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
866 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
867 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
868 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
869 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
870 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
871 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
872 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
873 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
874 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
875 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
876 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
877 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
878 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
879 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
880 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
881 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
882 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
883 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
884 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
885 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
886 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
887 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
888 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
889 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
890 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
891 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
892 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
893 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
894 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
895 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
896 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
897 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
898 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
899 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
900 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
901 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
902 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
903 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
904 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
905 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
906 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
907 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
908 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
909 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
910 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
911 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
912 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
913 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
914 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
915 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
916 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
917 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
918 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
919 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
920 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
921 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
924 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
925 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
926 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
927 0x18, 0x8c, 0x1d, 0x32
931 /* Multisession Vector context Test */
933 static uint8_t ms_aes_cbc_key0[] = {
934 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
935 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
938 static uint8_t ms_aes_cbc_iv0[] = {
939 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
940 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
943 static const uint8_t ms_aes_cbc_cipher0[] = {
944 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
945 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
946 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
947 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
948 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
949 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
950 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
951 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
952 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
953 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
954 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
955 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
956 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
957 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
958 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
959 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
960 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
961 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
962 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
963 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
964 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
965 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
966 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
967 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
968 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
969 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
970 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
971 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
972 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
973 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
974 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
975 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
976 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
977 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
978 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
979 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
980 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
981 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
982 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
983 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
984 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
985 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
986 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
987 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
988 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
989 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
990 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
991 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
992 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
993 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
994 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
995 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
996 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
997 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
998 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
999 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1000 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1001 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1002 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1003 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1004 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1005 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1006 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1007 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1011 static uint8_t ms_hmac_key0[] = {
1012 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1013 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1014 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1015 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1016 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1017 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1018 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1019 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1022 static const uint8_t ms_hmac_digest0[] = {
1023 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1024 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1025 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1026 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1027 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1028 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1029 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1030 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1034 /* Begin session 1 */
1036 static uint8_t ms_aes_cbc_key1[] = {
1037 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1038 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1041 static uint8_t ms_aes_cbc_iv1[] = {
1042 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1043 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1046 static const uint8_t ms_aes_cbc_cipher1[] = {
1047 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1048 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1049 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1050 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1051 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1052 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1053 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1054 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1055 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1056 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1057 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1058 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1059 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1060 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1061 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1062 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1063 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1064 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1065 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1066 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1067 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1068 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1069 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1070 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1071 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1072 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1073 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1074 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1075 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1076 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1077 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1078 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1079 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1080 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1081 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1082 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1083 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1084 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1085 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1086 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1087 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1088 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1089 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1090 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1091 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1092 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1093 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1094 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1095 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1096 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1097 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1098 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1099 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1100 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1101 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1102 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1103 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1104 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1105 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1106 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1107 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1108 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1109 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1110 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1114 static uint8_t ms_hmac_key1[] = {
1115 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1116 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1117 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1118 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1119 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1120 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1121 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1122 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1125 static const uint8_t ms_hmac_digest1[] = {
1126 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1127 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1128 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1129 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1130 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1131 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1132 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1133 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1136 /* Begin Session 2 */
1137 static uint8_t ms_aes_cbc_key2[] = {
1138 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1139 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1142 static uint8_t ms_aes_cbc_iv2[] = {
1143 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1144 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1147 static const uint8_t ms_aes_cbc_cipher2[] = {
1148 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1149 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1150 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1151 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1152 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1153 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1154 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1155 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1156 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1157 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1158 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1159 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1160 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1161 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1162 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1163 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1164 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1165 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1166 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1167 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1168 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1169 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1170 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1171 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1172 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1173 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1174 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1175 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1176 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1177 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1178 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1179 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1180 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1181 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1182 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1183 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1184 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1185 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1186 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1187 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1188 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1189 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1190 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1191 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1192 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1193 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1194 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1195 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1196 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1197 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1198 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1199 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1200 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1201 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1202 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1203 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1204 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1205 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1206 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1207 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1208 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1209 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1210 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1211 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1214 static uint8_t ms_hmac_key2[] = {
1215 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1216 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1217 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1218 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1219 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1220 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1221 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1222 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1225 static const uint8_t ms_hmac_digest2[] = {
1226 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1227 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1228 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1229 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1230 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1231 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1232 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1233 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1240 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1242 struct crypto_testsuite_params *ts_params = &testsuite_params;
1243 struct crypto_unittest_params *ut_params = &unittest_params;
1245 /* Generate test mbuf data and space for digest */
1246 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1247 catch_22_quote, QUOTE_512_BYTES, 0);
1249 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1250 DIGEST_BYTE_LENGTH_SHA1);
1251 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1253 /* Setup Cipher Parameters */
1254 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1255 ut_params->cipher_xform.next = &ut_params->auth_xform;
1257 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1258 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1259 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1260 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1262 /* Setup HMAC Parameters */
1263 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1265 ut_params->auth_xform.next = NULL;
1267 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1268 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1269 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1270 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1271 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1273 /* Create crypto session*/
1274 ut_params->sess = rte_cryptodev_sym_session_create(
1275 ts_params->valid_devs[0],
1276 &ut_params->cipher_xform);
1277 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1279 /* Generate crypto op data structure */
1280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1282 TEST_ASSERT_NOT_NULL(ut_params->op,
1283 "Failed to allocate symmetric crypto operation struct");
1285 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1287 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1289 /* set crypto operation source mbuf */
1290 sym_op->m_src = ut_params->ibuf;
1292 /* Set crypto operation authentication parameters */
1293 sym_op->auth.digest.data = ut_params->digest;
1294 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1295 ut_params->ibuf, QUOTE_512_BYTES);
1296 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1298 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1299 sym_op->auth.data.length = QUOTE_512_BYTES;
1301 /* Set crypto operation cipher parameters */
1302 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1303 CIPHER_IV_LENGTH_AES_CBC);
1304 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1305 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1307 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1308 CIPHER_IV_LENGTH_AES_CBC);
1310 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1311 sym_op->cipher.data.length = QUOTE_512_BYTES;
1313 /* Process crypto operation */
1314 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1315 ut_params->op), "failed to process sym crypto op");
1317 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1318 "crypto op processing failed");
1321 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1322 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1324 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1325 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1327 "ciphertext data not as expected");
1329 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1331 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1332 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1333 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1334 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1335 DIGEST_BYTE_LENGTH_SHA1,
1336 "Generated digest data not as expected");
1338 return TEST_SUCCESS;
1341 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1343 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1345 static uint8_t hmac_sha512_key[] = {
1346 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1347 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1348 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1349 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1350 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1351 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1352 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1353 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1355 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1356 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1357 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1358 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1359 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1360 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1361 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1362 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1363 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1368 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1369 struct crypto_unittest_params *ut_params,
1370 uint8_t *cipher_key,
1374 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1375 struct crypto_unittest_params *ut_params,
1376 struct crypto_testsuite_params *ts_params,
1377 const uint8_t *cipher,
1378 const uint8_t *digest,
1383 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1384 struct crypto_unittest_params *ut_params,
1385 uint8_t *cipher_key,
1389 /* Setup Cipher Parameters */
1390 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1391 ut_params->cipher_xform.next = NULL;
1393 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1394 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1395 ut_params->cipher_xform.cipher.key.data = cipher_key;
1396 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1398 /* Setup HMAC Parameters */
1399 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1400 ut_params->auth_xform.next = &ut_params->cipher_xform;
1402 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1403 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1404 ut_params->auth_xform.auth.key.data = hmac_key;
1405 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1406 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1408 return TEST_SUCCESS;
1413 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1414 struct crypto_unittest_params *ut_params,
1415 struct crypto_testsuite_params *ts_params,
1416 const uint8_t *cipher,
1417 const uint8_t *digest,
1420 /* Generate test mbuf data and digest */
1421 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1424 QUOTE_512_BYTES, 0);
1426 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1427 DIGEST_BYTE_LENGTH_SHA512);
1428 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1430 rte_memcpy(ut_params->digest,
1432 DIGEST_BYTE_LENGTH_SHA512);
1434 /* Generate Crypto op data structure */
1435 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1436 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1437 TEST_ASSERT_NOT_NULL(ut_params->op,
1438 "Failed to allocate symmetric crypto operation struct");
1440 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1442 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1444 /* set crypto operation source mbuf */
1445 sym_op->m_src = ut_params->ibuf;
1447 sym_op->auth.digest.data = ut_params->digest;
1448 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1449 ut_params->ibuf, QUOTE_512_BYTES);
1450 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1452 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1453 sym_op->auth.data.length = QUOTE_512_BYTES;
1455 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1456 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1457 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1458 ut_params->ibuf, 0);
1459 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1461 rte_memcpy(sym_op->cipher.iv.data, iv,
1462 CIPHER_IV_LENGTH_AES_CBC);
1464 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1465 sym_op->cipher.data.length = QUOTE_512_BYTES;
1467 /* Process crypto operation */
1468 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1469 ut_params->op), "failed to process sym crypto op");
1471 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1472 "crypto op processing failed");
1474 ut_params->obuf = ut_params->op->sym->m_src;
1477 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1478 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1479 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1481 "Plaintext data not as expected");
1484 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1485 "Digest verification failed");
1487 return TEST_SUCCESS;
1491 test_AES_cipheronly_mb_all(void)
1493 struct crypto_testsuite_params *ts_params = &testsuite_params;
1496 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1497 ts_params->op_mpool, ts_params->valid_devs[0],
1498 RTE_CRYPTODEV_AESNI_MB_PMD,
1499 BLKCIPHER_AES_CIPHERONLY_TYPE);
1501 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1503 return TEST_SUCCESS;
1507 test_authonly_mb_all(void)
1509 struct crypto_testsuite_params *ts_params = &testsuite_params;
1512 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1513 ts_params->op_mpool, ts_params->valid_devs[0],
1514 RTE_CRYPTODEV_AESNI_MB_PMD,
1515 BLKCIPHER_AUTHONLY_TYPE);
1517 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1519 return TEST_SUCCESS;
1523 test_AES_chain_mb_all(void)
1525 struct crypto_testsuite_params *ts_params = &testsuite_params;
1528 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1529 ts_params->op_mpool, ts_params->valid_devs[0],
1530 RTE_CRYPTODEV_AESNI_MB_PMD,
1531 BLKCIPHER_AES_CHAIN_TYPE);
1533 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1535 return TEST_SUCCESS;
1539 test_AES_chain_openssl_all(void)
1541 struct crypto_testsuite_params *ts_params = &testsuite_params;
1544 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1545 ts_params->op_mpool, ts_params->valid_devs[0],
1546 RTE_CRYPTODEV_OPENSSL_PMD,
1547 BLKCIPHER_AES_CHAIN_TYPE);
1549 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1551 return TEST_SUCCESS;
1555 test_AES_cipheronly_openssl_all(void)
1557 struct crypto_testsuite_params *ts_params = &testsuite_params;
1560 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1561 ts_params->op_mpool, ts_params->valid_devs[0],
1562 RTE_CRYPTODEV_OPENSSL_PMD,
1563 BLKCIPHER_AES_CIPHERONLY_TYPE);
1565 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1567 return TEST_SUCCESS;
1571 test_AES_chain_qat_all(void)
1573 struct crypto_testsuite_params *ts_params = &testsuite_params;
1576 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1577 ts_params->op_mpool, ts_params->valid_devs[0],
1578 RTE_CRYPTODEV_QAT_SYM_PMD,
1579 BLKCIPHER_AES_CHAIN_TYPE);
1581 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1583 return TEST_SUCCESS;
1587 test_AES_cipheronly_qat_all(void)
1589 struct crypto_testsuite_params *ts_params = &testsuite_params;
1592 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1593 ts_params->op_mpool, ts_params->valid_devs[0],
1594 RTE_CRYPTODEV_QAT_SYM_PMD,
1595 BLKCIPHER_AES_CIPHERONLY_TYPE);
1597 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1599 return TEST_SUCCESS;
1603 test_authonly_openssl_all(void)
1605 struct crypto_testsuite_params *ts_params = &testsuite_params;
1608 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1609 ts_params->op_mpool, ts_params->valid_devs[0],
1610 RTE_CRYPTODEV_OPENSSL_PMD,
1611 BLKCIPHER_AUTHONLY_TYPE);
1613 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1615 return TEST_SUCCESS;
1619 test_AES_chain_armv8_all(void)
1621 struct crypto_testsuite_params *ts_params = &testsuite_params;
1624 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1625 ts_params->op_mpool, ts_params->valid_devs[0],
1626 RTE_CRYPTODEV_ARMV8_PMD,
1627 BLKCIPHER_AES_CHAIN_TYPE);
1629 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1631 return TEST_SUCCESS;
1634 /* ***** SNOW 3G Tests ***** */
1636 create_wireless_algo_hash_session(uint8_t dev_id,
1637 const uint8_t *key, const uint8_t key_len,
1638 const uint8_t aad_len, const uint8_t auth_len,
1639 enum rte_crypto_auth_operation op,
1640 enum rte_crypto_auth_algorithm algo)
1642 uint8_t hash_key[key_len];
1644 struct crypto_unittest_params *ut_params = &unittest_params;
1646 memcpy(hash_key, key, key_len);
1648 TEST_HEXDUMP(stdout, "key:", key, key_len);
1650 /* Setup Authentication Parameters */
1651 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1652 ut_params->auth_xform.next = NULL;
1654 ut_params->auth_xform.auth.op = op;
1655 ut_params->auth_xform.auth.algo = algo;
1656 ut_params->auth_xform.auth.key.length = key_len;
1657 ut_params->auth_xform.auth.key.data = hash_key;
1658 ut_params->auth_xform.auth.digest_length = auth_len;
1659 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1660 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1661 &ut_params->auth_xform);
1662 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1667 create_wireless_algo_cipher_session(uint8_t dev_id,
1668 enum rte_crypto_cipher_operation op,
1669 enum rte_crypto_cipher_algorithm algo,
1670 const uint8_t *key, const uint8_t key_len)
1672 uint8_t cipher_key[key_len];
1674 struct crypto_unittest_params *ut_params = &unittest_params;
1676 memcpy(cipher_key, key, key_len);
1678 /* Setup Cipher Parameters */
1679 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1680 ut_params->cipher_xform.next = NULL;
1682 ut_params->cipher_xform.cipher.algo = algo;
1683 ut_params->cipher_xform.cipher.op = op;
1684 ut_params->cipher_xform.cipher.key.data = cipher_key;
1685 ut_params->cipher_xform.cipher.key.length = key_len;
1687 TEST_HEXDUMP(stdout, "key:", key, key_len);
1689 /* Create Crypto session */
1690 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1693 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1698 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1699 const unsigned cipher_len,
1700 const unsigned cipher_offset,
1701 enum rte_crypto_cipher_algorithm algo)
1703 struct crypto_testsuite_params *ts_params = &testsuite_params;
1704 struct crypto_unittest_params *ut_params = &unittest_params;
1705 unsigned iv_pad_len = 0;
1707 /* Generate Crypto op data structure */
1708 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1709 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1710 TEST_ASSERT_NOT_NULL(ut_params->op,
1711 "Failed to allocate pktmbuf offload");
1713 /* Set crypto operation data parameters */
1714 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1716 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1718 /* set crypto operation source mbuf */
1719 sym_op->m_src = ut_params->ibuf;
1722 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1723 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1725 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1727 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1730 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1732 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1733 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1734 sym_op->cipher.iv.length = iv_pad_len;
1736 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1737 sym_op->cipher.data.length = cipher_len;
1738 sym_op->cipher.data.offset = cipher_offset;
1743 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1744 const unsigned cipher_len,
1745 const unsigned cipher_offset,
1746 enum rte_crypto_cipher_algorithm algo)
1748 struct crypto_testsuite_params *ts_params = &testsuite_params;
1749 struct crypto_unittest_params *ut_params = &unittest_params;
1750 unsigned iv_pad_len = 0;
1752 /* Generate Crypto op data structure */
1753 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1754 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1755 TEST_ASSERT_NOT_NULL(ut_params->op,
1756 "Failed to allocate pktmbuf offload");
1758 /* Set crypto operation data parameters */
1759 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1761 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1763 /* set crypto operation source mbuf */
1764 sym_op->m_src = ut_params->ibuf;
1765 sym_op->m_dst = ut_params->obuf;
1768 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1769 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1771 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1772 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1775 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1777 /* For OOP operation both buffers must have the same size */
1778 if (ut_params->obuf)
1779 rte_pktmbuf_prepend(ut_params->obuf, iv_pad_len);
1781 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1782 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1783 sym_op->cipher.iv.length = iv_pad_len;
1785 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1786 sym_op->cipher.data.length = cipher_len;
1787 sym_op->cipher.data.offset = cipher_offset;
1792 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1793 enum rte_crypto_cipher_operation cipher_op,
1794 enum rte_crypto_auth_operation auth_op,
1795 enum rte_crypto_auth_algorithm auth_algo,
1796 enum rte_crypto_cipher_algorithm cipher_algo,
1797 const uint8_t *key, const uint8_t key_len,
1798 const uint8_t aad_len, const uint8_t auth_len)
1801 uint8_t cipher_auth_key[key_len];
1803 struct crypto_unittest_params *ut_params = &unittest_params;
1805 memcpy(cipher_auth_key, key, key_len);
1807 /* Setup Authentication Parameters */
1808 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1809 ut_params->auth_xform.next = NULL;
1811 ut_params->auth_xform.auth.op = auth_op;
1812 ut_params->auth_xform.auth.algo = auth_algo;
1813 ut_params->auth_xform.auth.key.length = key_len;
1814 /* Hash key = cipher key */
1815 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1816 ut_params->auth_xform.auth.digest_length = auth_len;
1817 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1819 /* Setup Cipher Parameters */
1820 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1821 ut_params->cipher_xform.next = &ut_params->auth_xform;
1823 ut_params->cipher_xform.cipher.algo = cipher_algo;
1824 ut_params->cipher_xform.cipher.op = cipher_op;
1825 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1826 ut_params->cipher_xform.cipher.key.length = key_len;
1828 TEST_HEXDUMP(stdout, "key:", key, key_len);
1830 /* Create Crypto session*/
1831 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1832 &ut_params->cipher_xform);
1834 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1839 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1840 enum rte_crypto_cipher_operation cipher_op,
1841 enum rte_crypto_auth_operation auth_op,
1842 enum rte_crypto_auth_algorithm auth_algo,
1843 enum rte_crypto_cipher_algorithm cipher_algo,
1844 const uint8_t *key, const uint8_t key_len,
1845 const uint8_t aad_len, const uint8_t auth_len)
1847 uint8_t auth_cipher_key[key_len];
1849 struct crypto_unittest_params *ut_params = &unittest_params;
1851 memcpy(auth_cipher_key, key, key_len);
1853 /* Setup Authentication Parameters */
1854 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1855 ut_params->auth_xform.auth.op = auth_op;
1856 ut_params->auth_xform.next = &ut_params->cipher_xform;
1857 ut_params->auth_xform.auth.algo = auth_algo;
1858 ut_params->auth_xform.auth.key.length = key_len;
1859 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1860 ut_params->auth_xform.auth.digest_length = auth_len;
1861 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1863 /* Setup Cipher Parameters */
1864 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1865 ut_params->cipher_xform.next = NULL;
1866 ut_params->cipher_xform.cipher.algo = cipher_algo;
1867 ut_params->cipher_xform.cipher.op = cipher_op;
1868 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1869 ut_params->cipher_xform.cipher.key.length = key_len;
1871 TEST_HEXDUMP(stdout, "key:", key, key_len);
1873 /* Create Crypto session*/
1874 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1875 &ut_params->auth_xform);
1877 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1883 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1884 const unsigned auth_tag_len,
1885 const uint8_t *aad, const unsigned aad_len,
1886 unsigned data_pad_len,
1887 enum rte_crypto_auth_operation op,
1888 enum rte_crypto_auth_algorithm algo,
1889 const unsigned auth_len, const unsigned auth_offset)
1891 struct crypto_testsuite_params *ts_params = &testsuite_params;
1893 struct crypto_unittest_params *ut_params = &unittest_params;
1895 unsigned aad_buffer_len;
1897 /* Generate Crypto op data structure */
1898 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1899 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1900 TEST_ASSERT_NOT_NULL(ut_params->op,
1901 "Failed to allocate pktmbuf offload");
1903 /* Set crypto operation data parameters */
1904 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1906 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1908 /* set crypto operation source mbuf */
1909 sym_op->m_src = ut_params->ibuf;
1913 * Always allocate the aad up to the block size.
1914 * The cryptodev API calls out -
1915 * - the array must be big enough to hold the AAD, plus any
1916 * space to round this up to the nearest multiple of the
1917 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1919 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1920 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1922 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1923 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1924 ut_params->ibuf, aad_buffer_len);
1925 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1926 "no room to prepend aad");
1927 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1929 sym_op->auth.aad.length = aad_len;
1931 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1932 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1934 TEST_HEXDUMP(stdout, "aad:",
1935 sym_op->auth.aad.data, aad_len);
1938 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1939 ut_params->ibuf, auth_tag_len);
1941 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1942 "no room to append auth tag");
1943 ut_params->digest = sym_op->auth.digest.data;
1944 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1945 ut_params->ibuf, data_pad_len + aad_len);
1946 sym_op->auth.digest.length = auth_tag_len;
1947 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1948 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1950 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1952 TEST_HEXDUMP(stdout, "digest:",
1953 sym_op->auth.digest.data,
1954 sym_op->auth.digest.length);
1956 sym_op->auth.data.length = auth_len;
1957 sym_op->auth.data.offset = auth_offset;
1963 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1964 const unsigned auth_tag_len,
1965 const uint8_t *aad, const uint8_t aad_len,
1966 unsigned data_pad_len,
1967 enum rte_crypto_auth_operation op,
1968 enum rte_crypto_auth_algorithm auth_algo,
1969 enum rte_crypto_cipher_algorithm cipher_algo,
1970 const uint8_t *iv, const uint8_t iv_len,
1971 const unsigned cipher_len, const unsigned cipher_offset,
1972 const unsigned auth_len, const unsigned auth_offset)
1974 struct crypto_testsuite_params *ts_params = &testsuite_params;
1975 struct crypto_unittest_params *ut_params = &unittest_params;
1977 unsigned iv_pad_len = 0;
1978 unsigned aad_buffer_len;
1980 /* Generate Crypto op data structure */
1981 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1982 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1983 TEST_ASSERT_NOT_NULL(ut_params->op,
1984 "Failed to allocate pktmbuf offload");
1985 /* Set crypto operation data parameters */
1986 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1988 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1990 /* set crypto operation source mbuf */
1991 sym_op->m_src = ut_params->ibuf;
1994 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1995 ut_params->ibuf, auth_tag_len);
1997 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1998 "no room to append auth tag");
1999 ut_params->digest = sym_op->auth.digest.data;
2000 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2001 ut_params->ibuf, data_pad_len);
2002 sym_op->auth.digest.length = auth_tag_len;
2003 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2004 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2006 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2008 TEST_HEXDUMP(stdout, "digest:",
2009 sym_op->auth.digest.data,
2010 sym_op->auth.digest.length);
2014 * Always allocate the aad up to the block size.
2015 * The cryptodev API calls out -
2016 * - the array must be big enough to hold the AAD, plus any
2017 * space to round this up to the nearest multiple of the
2018 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
2020 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2021 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2023 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2024 sym_op->auth.aad.data =
2025 (uint8_t *)rte_pktmbuf_prepend(
2026 ut_params->ibuf, aad_buffer_len);
2027 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2028 "no room to prepend aad");
2029 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2031 sym_op->auth.aad.length = aad_len;
2032 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2033 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2034 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
2037 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2038 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2040 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2041 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2042 ut_params->ibuf, iv_pad_len);
2044 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2045 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2046 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2047 sym_op->cipher.iv.length = iv_pad_len;
2048 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2049 sym_op->cipher.data.length = cipher_len;
2050 sym_op->cipher.data.offset = cipher_offset + auth_offset;
2051 sym_op->auth.data.length = auth_len;
2052 sym_op->auth.data.offset = auth_offset + cipher_offset;
2058 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
2059 const uint8_t *iv, const uint8_t iv_len,
2060 const uint8_t *aad, const uint8_t aad_len,
2061 unsigned data_pad_len,
2062 const unsigned cipher_len, const unsigned cipher_offset,
2063 const unsigned auth_len, const unsigned auth_offset,
2064 enum rte_crypto_auth_algorithm auth_algo,
2065 enum rte_crypto_cipher_algorithm cipher_algo)
2067 struct crypto_testsuite_params *ts_params = &testsuite_params;
2068 struct crypto_unittest_params *ut_params = &unittest_params;
2070 unsigned iv_pad_len = 0;
2071 unsigned aad_buffer_len = 0;
2073 /* Generate Crypto op data structure */
2074 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2075 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2076 TEST_ASSERT_NOT_NULL(ut_params->op,
2077 "Failed to allocate pktmbuf offload");
2079 /* Set crypto operation data parameters */
2080 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2082 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2084 /* set crypto operation source mbuf */
2085 sym_op->m_src = ut_params->ibuf;
2088 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2089 ut_params->ibuf, auth_tag_len);
2091 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2092 "no room to append auth tag");
2094 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2095 ut_params->ibuf, data_pad_len);
2096 sym_op->auth.digest.length = auth_tag_len;
2098 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2100 TEST_HEXDUMP(stdout, "digest:",
2101 sym_op->auth.digest.data,
2102 sym_op->auth.digest.length);
2106 * Always allocate the aad up to the block size.
2107 * The cryptodev API calls out -
2108 * - the array must be big enough to hold the AAD, plus any
2109 * space to round this up to the nearest multiple of the
2110 * block size (8 bytes for KASUMI 16 bytes).
2112 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2113 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2115 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2116 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2117 ut_params->ibuf, aad_buffer_len);
2118 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2119 "no room to prepend aad");
2120 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2122 sym_op->auth.aad.length = aad_len;
2123 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2124 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2125 TEST_HEXDUMP(stdout, "aad:",
2126 sym_op->auth.aad.data, aad_len);
2129 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2130 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2132 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2134 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2135 ut_params->ibuf, iv_pad_len);
2136 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2138 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2139 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2140 sym_op->cipher.iv.length = iv_pad_len;
2142 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2144 sym_op->cipher.data.length = cipher_len;
2145 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2147 sym_op->auth.data.length = auth_len;
2148 sym_op->auth.data.offset = auth_offset + cipher_offset;
2154 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2156 struct crypto_testsuite_params *ts_params = &testsuite_params;
2157 struct crypto_unittest_params *ut_params = &unittest_params;
2160 unsigned plaintext_pad_len;
2161 unsigned plaintext_len;
2164 /* Create SNOW 3G session */
2165 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2166 tdata->key.data, tdata->key.len,
2167 tdata->aad.len, tdata->digest.len,
2168 RTE_CRYPTO_AUTH_OP_GENERATE,
2169 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2173 /* alloc mbuf and set payload */
2174 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2176 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2177 rte_pktmbuf_tailroom(ut_params->ibuf));
2179 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2180 /* Append data which is padded to a multiple of */
2181 /* the algorithms block size */
2182 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2183 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2185 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2187 /* Create SNOW 3G operation */
2188 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2189 tdata->aad.data, tdata->aad.len,
2190 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2191 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2192 tdata->validAuthLenInBits.len,
2193 tdata->validAuthOffsetLenInBits.len);
2197 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2199 ut_params->obuf = ut_params->op->sym->m_src;
2200 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2201 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2202 + plaintext_pad_len + tdata->aad.len;
2205 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2208 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2209 "SNOW 3G Generated auth tag not as expected");
2215 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2217 struct crypto_testsuite_params *ts_params = &testsuite_params;
2218 struct crypto_unittest_params *ut_params = &unittest_params;
2221 unsigned plaintext_pad_len;
2222 unsigned plaintext_len;
2225 /* Create SNOW 3G session */
2226 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2227 tdata->key.data, tdata->key.len,
2228 tdata->aad.len, tdata->digest.len,
2229 RTE_CRYPTO_AUTH_OP_VERIFY,
2230 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2233 /* alloc mbuf and set payload */
2234 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2236 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2237 rte_pktmbuf_tailroom(ut_params->ibuf));
2239 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2240 /* Append data which is padded to a multiple of */
2241 /* the algorithms block size */
2242 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2243 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2245 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2247 /* Create SNOW 3G operation */
2248 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2250 tdata->aad.data, tdata->aad.len,
2252 RTE_CRYPTO_AUTH_OP_VERIFY,
2253 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2254 tdata->validAuthLenInBits.len,
2255 tdata->validAuthOffsetLenInBits.len);
2259 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2261 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2262 ut_params->obuf = ut_params->op->sym->m_src;
2263 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2264 + plaintext_pad_len + tdata->aad.len;
2267 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2276 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2278 struct crypto_testsuite_params *ts_params = &testsuite_params;
2279 struct crypto_unittest_params *ut_params = &unittest_params;
2282 unsigned plaintext_pad_len;
2283 unsigned plaintext_len;
2286 /* Create KASUMI session */
2287 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2288 tdata->key.data, tdata->key.len,
2289 tdata->aad.len, tdata->digest.len,
2290 RTE_CRYPTO_AUTH_OP_GENERATE,
2291 RTE_CRYPTO_AUTH_KASUMI_F9);
2295 /* alloc mbuf and set payload */
2296 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2298 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2299 rte_pktmbuf_tailroom(ut_params->ibuf));
2301 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2302 /* Append data which is padded to a multiple of */
2303 /* the algorithms block size */
2304 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2305 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2307 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2309 /* Create KASUMI operation */
2310 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2311 tdata->aad.data, tdata->aad.len,
2312 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2313 RTE_CRYPTO_AUTH_KASUMI_F9,
2314 tdata->validAuthLenInBits.len,
2315 tdata->validAuthOffsetLenInBits.len);
2319 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2321 ut_params->obuf = ut_params->op->sym->m_src;
2322 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2323 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2324 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2327 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2330 DIGEST_BYTE_LENGTH_KASUMI_F9,
2331 "KASUMI Generated auth tag not as expected");
2337 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2339 struct crypto_testsuite_params *ts_params = &testsuite_params;
2340 struct crypto_unittest_params *ut_params = &unittest_params;
2343 unsigned plaintext_pad_len;
2344 unsigned plaintext_len;
2347 /* Create KASUMI session */
2348 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2349 tdata->key.data, tdata->key.len,
2350 tdata->aad.len, tdata->digest.len,
2351 RTE_CRYPTO_AUTH_OP_VERIFY,
2352 RTE_CRYPTO_AUTH_KASUMI_F9);
2355 /* alloc mbuf and set payload */
2356 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2358 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2359 rte_pktmbuf_tailroom(ut_params->ibuf));
2361 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2362 /* Append data which is padded to a multiple */
2363 /* of the algorithms block size */
2364 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2365 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2367 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2369 /* Create KASUMI operation */
2370 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2372 tdata->aad.data, tdata->aad.len,
2374 RTE_CRYPTO_AUTH_OP_VERIFY,
2375 RTE_CRYPTO_AUTH_KASUMI_F9,
2376 tdata->validAuthLenInBits.len,
2377 tdata->validAuthOffsetLenInBits.len);
2381 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2383 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2384 ut_params->obuf = ut_params->op->sym->m_src;
2385 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2386 + plaintext_pad_len + tdata->aad.len;
2389 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2398 test_snow3g_hash_generate_test_case_1(void)
2400 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2404 test_snow3g_hash_generate_test_case_2(void)
2406 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2410 test_snow3g_hash_generate_test_case_3(void)
2412 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2416 test_snow3g_hash_generate_test_case_4(void)
2418 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2422 test_snow3g_hash_generate_test_case_5(void)
2424 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2428 test_snow3g_hash_generate_test_case_6(void)
2430 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2434 test_snow3g_hash_verify_test_case_1(void)
2436 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2441 test_snow3g_hash_verify_test_case_2(void)
2443 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2447 test_snow3g_hash_verify_test_case_3(void)
2449 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2453 test_snow3g_hash_verify_test_case_4(void)
2455 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2459 test_snow3g_hash_verify_test_case_5(void)
2461 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2465 test_snow3g_hash_verify_test_case_6(void)
2467 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2471 test_kasumi_hash_generate_test_case_1(void)
2473 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2477 test_kasumi_hash_generate_test_case_2(void)
2479 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2483 test_kasumi_hash_generate_test_case_3(void)
2485 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2489 test_kasumi_hash_generate_test_case_4(void)
2491 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2495 test_kasumi_hash_generate_test_case_5(void)
2497 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2501 test_kasumi_hash_generate_test_case_6(void)
2503 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2507 test_kasumi_hash_verify_test_case_1(void)
2509 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2513 test_kasumi_hash_verify_test_case_2(void)
2515 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2519 test_kasumi_hash_verify_test_case_3(void)
2521 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2525 test_kasumi_hash_verify_test_case_4(void)
2527 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2531 test_kasumi_hash_verify_test_case_5(void)
2533 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2537 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2539 struct crypto_testsuite_params *ts_params = &testsuite_params;
2540 struct crypto_unittest_params *ut_params = &unittest_params;
2543 uint8_t *plaintext, *ciphertext;
2544 unsigned plaintext_pad_len;
2545 unsigned plaintext_len;
2547 /* Create KASUMI session */
2548 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2549 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2550 RTE_CRYPTO_CIPHER_KASUMI_F8,
2551 tdata->key.data, tdata->key.len);
2555 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2557 /* Clear mbuf payload */
2558 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2559 rte_pktmbuf_tailroom(ut_params->ibuf));
2561 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2562 /* Append data which is padded to a multiple */
2563 /* of the algorithms block size */
2564 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2565 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2567 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2569 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2571 /* Create KASUMI operation */
2572 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2573 tdata->plaintext.len,
2574 tdata->validCipherOffsetLenInBits.len,
2575 RTE_CRYPTO_CIPHER_KASUMI_F8);
2579 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2581 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2583 ut_params->obuf = ut_params->op->sym->m_dst;
2584 if (ut_params->obuf)
2585 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2588 ciphertext = plaintext;
2590 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2593 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2595 tdata->ciphertext.data,
2596 tdata->validCipherLenInBits.len,
2597 "KASUMI Ciphertext data not as expected");
2602 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
2604 struct crypto_testsuite_params *ts_params = &testsuite_params;
2605 struct crypto_unittest_params *ut_params = &unittest_params;
2609 unsigned int plaintext_pad_len;
2610 unsigned int plaintext_len;
2612 uint8_t buffer[10000];
2613 const uint8_t *ciphertext;
2615 struct rte_cryptodev_info dev_info;
2617 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2618 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2619 printf("Device doesn't support scatter-gather. "
2624 /* Create KASUMI session */
2625 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2626 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2627 RTE_CRYPTO_CIPHER_KASUMI_F8,
2628 tdata->key.data, tdata->key.len);
2632 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2635 /* Append data which is padded to a multiple */
2636 /* of the algorithms block size */
2637 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2639 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2640 plaintext_pad_len, 10, 0);
2642 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2644 /* Create KASUMI operation */
2645 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2647 tdata->plaintext.len,
2648 tdata->validCipherOffsetLenInBits.len,
2649 RTE_CRYPTO_CIPHER_KASUMI_F8);
2653 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2655 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2657 ut_params->obuf = ut_params->op->sym->m_dst;
2659 if (ut_params->obuf)
2660 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2661 plaintext_len, buffer);
2663 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2664 plaintext_len, buffer);
2667 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2670 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2672 tdata->ciphertext.data,
2673 tdata->validCipherLenInBits.len,
2674 "KASUMI Ciphertext data not as expected");
2679 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2681 struct crypto_testsuite_params *ts_params = &testsuite_params;
2682 struct crypto_unittest_params *ut_params = &unittest_params;
2685 uint8_t *plaintext, *ciphertext;
2686 unsigned plaintext_pad_len;
2687 unsigned plaintext_len;
2689 /* Create KASUMI session */
2690 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2691 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2692 RTE_CRYPTO_CIPHER_KASUMI_F8,
2693 tdata->key.data, tdata->key.len);
2697 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2698 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2700 /* Clear mbuf payload */
2701 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2702 rte_pktmbuf_tailroom(ut_params->ibuf));
2704 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2705 /* Append data which is padded to a multiple */
2706 /* of the algorithms block size */
2707 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2708 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2710 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2711 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2713 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2715 /* Create KASUMI operation */
2716 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2718 tdata->plaintext.len,
2719 tdata->validCipherOffsetLenInBits.len,
2720 RTE_CRYPTO_CIPHER_KASUMI_F8);
2724 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2726 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2728 ut_params->obuf = ut_params->op->sym->m_dst;
2729 if (ut_params->obuf)
2730 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2733 ciphertext = plaintext;
2735 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2738 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2740 tdata->ciphertext.data,
2741 tdata->validCipherLenInBits.len,
2742 "KASUMI Ciphertext data not as expected");
2747 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
2749 struct crypto_testsuite_params *ts_params = &testsuite_params;
2750 struct crypto_unittest_params *ut_params = &unittest_params;
2753 unsigned int plaintext_pad_len;
2754 unsigned int plaintext_len;
2756 const uint8_t *ciphertext;
2757 uint8_t buffer[2048];
2759 struct rte_cryptodev_info dev_info;
2761 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
2762 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
2763 printf("Device doesn't support scatter-gather. "
2768 /* Create KASUMI session */
2769 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2770 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2771 RTE_CRYPTO_CIPHER_KASUMI_F8,
2772 tdata->key.data, tdata->key.len);
2776 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2777 /* Append data which is padded to a multiple */
2778 /* of the algorithms block size */
2779 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2781 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
2782 plaintext_pad_len, 10, 0);
2783 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
2784 plaintext_pad_len, 3, 0);
2786 /* Append data which is padded to a multiple */
2787 /* of the algorithms block size */
2788 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
2790 /* Create KASUMI operation */
2791 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2793 tdata->plaintext.len,
2794 tdata->validCipherOffsetLenInBits.len,
2795 RTE_CRYPTO_CIPHER_KASUMI_F8);
2799 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2801 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2803 ut_params->obuf = ut_params->op->sym->m_dst;
2804 if (ut_params->obuf)
2805 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
2806 plaintext_pad_len, buffer);
2808 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
2809 plaintext_pad_len, buffer);
2812 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2814 tdata->ciphertext.data,
2815 tdata->validCipherLenInBits.len,
2816 "KASUMI Ciphertext data not as expected");
2822 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2824 struct crypto_testsuite_params *ts_params = &testsuite_params;
2825 struct crypto_unittest_params *ut_params = &unittest_params;
2828 uint8_t *ciphertext, *plaintext;
2829 unsigned ciphertext_pad_len;
2830 unsigned ciphertext_len;
2832 /* Create KASUMI session */
2833 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2834 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2835 RTE_CRYPTO_CIPHER_KASUMI_F8,
2836 tdata->key.data, tdata->key.len);
2840 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2841 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2843 /* Clear mbuf payload */
2844 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2845 rte_pktmbuf_tailroom(ut_params->ibuf));
2847 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2848 /* Append data which is padded to a multiple */
2849 /* of the algorithms block size */
2850 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2851 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2852 ciphertext_pad_len);
2853 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2854 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2856 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2858 /* Create KASUMI operation */
2859 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2861 tdata->ciphertext.len,
2862 tdata->validCipherOffsetLenInBits.len,
2863 RTE_CRYPTO_CIPHER_KASUMI_F8);
2867 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2869 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2871 ut_params->obuf = ut_params->op->sym->m_dst;
2872 if (ut_params->obuf)
2873 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2876 plaintext = ciphertext;
2878 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2881 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2883 tdata->plaintext.data,
2884 tdata->validCipherLenInBits.len,
2885 "KASUMI Plaintext data not as expected");
2890 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2892 struct crypto_testsuite_params *ts_params = &testsuite_params;
2893 struct crypto_unittest_params *ut_params = &unittest_params;
2896 uint8_t *ciphertext, *plaintext;
2897 unsigned ciphertext_pad_len;
2898 unsigned ciphertext_len;
2900 /* Create KASUMI session */
2901 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2902 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2903 RTE_CRYPTO_CIPHER_KASUMI_F8,
2904 tdata->key.data, tdata->key.len);
2908 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2910 /* Clear mbuf payload */
2911 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2912 rte_pktmbuf_tailroom(ut_params->ibuf));
2914 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2915 /* Append data which is padded to a multiple */
2916 /* of the algorithms block size */
2917 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2918 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2919 ciphertext_pad_len);
2920 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2922 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2924 /* Create KASUMI operation */
2925 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2927 tdata->ciphertext.len,
2928 tdata->validCipherOffsetLenInBits.len,
2929 RTE_CRYPTO_CIPHER_KASUMI_F8);
2933 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2935 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2937 ut_params->obuf = ut_params->op->sym->m_dst;
2938 if (ut_params->obuf)
2939 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2942 plaintext = ciphertext;
2944 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2947 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2949 tdata->plaintext.data,
2950 tdata->validCipherLenInBits.len,
2951 "KASUMI Plaintext data not as expected");
2956 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2958 struct crypto_testsuite_params *ts_params = &testsuite_params;
2959 struct crypto_unittest_params *ut_params = &unittest_params;
2962 uint8_t *plaintext, *ciphertext;
2963 unsigned plaintext_pad_len;
2964 unsigned plaintext_len;
2966 /* Create SNOW 3G session */
2967 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2968 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2969 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2970 tdata->key.data, tdata->key.len);
2974 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2976 /* Clear mbuf payload */
2977 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2978 rte_pktmbuf_tailroom(ut_params->ibuf));
2980 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2981 /* Append data which is padded to a multiple of */
2982 /* the algorithms block size */
2983 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2984 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2986 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2988 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2990 /* Create SNOW 3G operation */
2991 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2992 tdata->validCipherLenInBits.len,
2993 tdata->validCipherOffsetLenInBits.len,
2994 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2998 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3000 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3002 ut_params->obuf = ut_params->op->sym->m_dst;
3003 if (ut_params->obuf)
3004 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3007 ciphertext = plaintext;
3009 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3012 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3014 tdata->ciphertext.data,
3015 tdata->validDataLenInBits.len,
3016 "SNOW 3G Ciphertext data not as expected");
3022 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3024 struct crypto_testsuite_params *ts_params = &testsuite_params;
3025 struct crypto_unittest_params *ut_params = &unittest_params;
3026 uint8_t *plaintext, *ciphertext;
3029 unsigned plaintext_pad_len;
3030 unsigned plaintext_len;
3032 /* Create SNOW 3G session */
3033 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3034 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3035 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3036 tdata->key.data, tdata->key.len);
3040 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3041 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3043 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3044 "Failed to allocate input buffer in mempool");
3045 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3046 "Failed to allocate output buffer in mempool");
3048 /* Clear mbuf payload */
3049 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3050 rte_pktmbuf_tailroom(ut_params->ibuf));
3052 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3053 /* Append data which is padded to a multiple of */
3054 /* the algorithms block size */
3055 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3056 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3058 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3059 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3061 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3063 /* Create SNOW 3G operation */
3064 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3066 tdata->validCipherLenInBits.len,
3067 tdata->validCipherOffsetLenInBits.len,
3068 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3072 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3074 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3076 ut_params->obuf = ut_params->op->sym->m_dst;
3077 if (ut_params->obuf)
3078 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3081 ciphertext = plaintext;
3083 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3086 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3088 tdata->ciphertext.data,
3089 tdata->validDataLenInBits.len,
3090 "SNOW 3G Ciphertext data not as expected");
3095 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3097 struct crypto_testsuite_params *ts_params = &testsuite_params;
3098 struct crypto_unittest_params *ut_params = &unittest_params;
3101 unsigned int plaintext_pad_len;
3102 unsigned int plaintext_len;
3103 uint8_t buffer[10000];
3104 const uint8_t *ciphertext;
3106 struct rte_cryptodev_info dev_info;
3108 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3109 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3110 printf("Device doesn't support scatter-gather. "
3115 /* Create SNOW 3G session */
3116 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3117 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3118 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3119 tdata->key.data, tdata->key.len);
3123 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3124 /* Append data which is padded to a multiple of */
3125 /* the algorithms block size */
3126 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3128 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3129 plaintext_pad_len, 10, 0);
3130 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3131 plaintext_pad_len, 3, 0);
3133 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3134 "Failed to allocate input buffer in mempool");
3135 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3136 "Failed to allocate output buffer in mempool");
3138 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3140 /* Create SNOW 3G operation */
3141 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3143 tdata->validCipherLenInBits.len,
3144 tdata->validCipherOffsetLenInBits.len,
3145 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3149 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3151 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3153 ut_params->obuf = ut_params->op->sym->m_dst;
3154 if (ut_params->obuf)
3155 ciphertext = rte_pktmbuf_read(ut_params->obuf, tdata->iv.len,
3156 plaintext_len, buffer);
3158 ciphertext = rte_pktmbuf_read(ut_params->ibuf, tdata->iv.len,
3159 plaintext_len, buffer);
3161 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3164 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3166 tdata->ciphertext.data,
3167 tdata->validDataLenInBits.len,
3168 "SNOW 3G Ciphertext data not as expected");
3173 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3175 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3177 uint8_t curr_byte, prev_byte;
3178 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3179 uint8_t lower_byte_mask = (1 << offset) - 1;
3182 prev_byte = buffer[0];
3183 buffer[0] >>= offset;
3185 for (i = 1; i < length_in_bytes; i++) {
3186 curr_byte = buffer[i];
3187 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3188 (curr_byte >> offset);
3189 prev_byte = curr_byte;
3194 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3196 struct crypto_testsuite_params *ts_params = &testsuite_params;
3197 struct crypto_unittest_params *ut_params = &unittest_params;
3198 uint8_t *plaintext, *ciphertext;
3200 uint32_t plaintext_len;
3201 uint32_t plaintext_pad_len;
3202 uint8_t extra_offset = 4;
3203 uint8_t *expected_ciphertext_shifted;
3205 /* Create SNOW 3G session */
3206 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3207 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3208 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3209 tdata->key.data, tdata->key.len);
3213 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3214 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3216 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3217 "Failed to allocate input buffer in mempool");
3218 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3219 "Failed to allocate output buffer in mempool");
3221 /* Clear mbuf payload */
3222 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3223 rte_pktmbuf_tailroom(ut_params->ibuf));
3225 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3227 * Append data which is padded to a
3228 * multiple of the algorithms block size
3230 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3232 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3235 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3237 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3238 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3240 #ifdef RTE_APP_TEST_DEBUG
3241 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3243 /* Create SNOW 3G operation */
3244 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3246 tdata->validCipherLenInBits.len,
3247 tdata->validCipherOffsetLenInBits.len +
3249 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3253 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3255 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3257 ut_params->obuf = ut_params->op->sym->m_dst;
3258 if (ut_params->obuf)
3259 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3262 ciphertext = plaintext;
3264 #ifdef RTE_APP_TEST_DEBUG
3265 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3268 expected_ciphertext_shifted = rte_malloc(NULL,
3269 ceil_byte_length(plaintext_len + extra_offset), 0);
3271 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3272 "failed to reserve memory for ciphertext shifted\n");
3274 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3275 ceil_byte_length(tdata->ciphertext.len));
3276 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3279 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3281 expected_ciphertext_shifted,
3282 tdata->validDataLenInBits.len,
3284 "SNOW 3G Ciphertext data not as expected");
3288 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3290 struct crypto_testsuite_params *ts_params = &testsuite_params;
3291 struct crypto_unittest_params *ut_params = &unittest_params;
3295 uint8_t *plaintext, *ciphertext;
3296 unsigned ciphertext_pad_len;
3297 unsigned ciphertext_len;
3299 /* Create SNOW 3G session */
3300 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3301 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3302 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3303 tdata->key.data, tdata->key.len);
3307 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3309 /* Clear mbuf payload */
3310 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3311 rte_pktmbuf_tailroom(ut_params->ibuf));
3313 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3314 /* Append data which is padded to a multiple of */
3315 /* the algorithms block size */
3316 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3317 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3318 ciphertext_pad_len);
3319 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3321 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3323 /* Create SNOW 3G operation */
3324 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3325 tdata->validCipherLenInBits.len,
3326 tdata->validCipherOffsetLenInBits.len,
3327 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3331 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3333 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3334 ut_params->obuf = ut_params->op->sym->m_dst;
3335 if (ut_params->obuf)
3336 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3339 plaintext = ciphertext;
3341 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3344 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3345 tdata->plaintext.data,
3346 tdata->validDataLenInBits.len,
3347 "SNOW 3G Plaintext data not as expected");
3351 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3353 struct crypto_testsuite_params *ts_params = &testsuite_params;
3354 struct crypto_unittest_params *ut_params = &unittest_params;
3358 uint8_t *plaintext, *ciphertext;
3359 unsigned ciphertext_pad_len;
3360 unsigned ciphertext_len;
3362 /* Create SNOW 3G session */
3363 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3364 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3365 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3366 tdata->key.data, tdata->key.len);
3370 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3371 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3373 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3374 "Failed to allocate input buffer");
3375 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3376 "Failed to allocate output buffer");
3378 /* Clear mbuf payload */
3379 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3380 rte_pktmbuf_tailroom(ut_params->ibuf));
3382 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3383 rte_pktmbuf_tailroom(ut_params->obuf));
3385 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3386 /* Append data which is padded to a multiple of */
3387 /* the algorithms block size */
3388 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3389 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3390 ciphertext_pad_len);
3391 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3392 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3394 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3396 /* Create SNOW 3G operation */
3397 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3399 tdata->validCipherLenInBits.len,
3400 tdata->validCipherOffsetLenInBits.len,
3401 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3405 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3407 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3408 ut_params->obuf = ut_params->op->sym->m_dst;
3409 if (ut_params->obuf)
3410 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3413 plaintext = ciphertext;
3415 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3418 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3419 tdata->plaintext.data,
3420 tdata->validDataLenInBits.len,
3421 "SNOW 3G Plaintext data not as expected");
3426 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3428 struct crypto_testsuite_params *ts_params = &testsuite_params;
3429 struct crypto_unittest_params *ut_params = &unittest_params;
3433 uint8_t *plaintext, *ciphertext;
3434 unsigned plaintext_pad_len;
3435 unsigned plaintext_len;
3437 /* Create SNOW 3G session */
3438 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3439 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3440 RTE_CRYPTO_AUTH_OP_GENERATE,
3441 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3442 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3443 tdata->key.data, tdata->key.len,
3444 tdata->aad.len, tdata->digest.len);
3447 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3449 /* clear mbuf payload */
3450 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3451 rte_pktmbuf_tailroom(ut_params->ibuf));
3453 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3454 /* Append data which is padded to a multiple of */
3455 /* the algorithms block size */
3456 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3457 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3459 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3461 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3463 /* Create SNOW 3G operation */
3464 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3465 tdata->digest.len, tdata->aad.data,
3466 tdata->aad.len, /*tdata->plaintext.len,*/
3467 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3468 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3469 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3470 tdata->iv.data, tdata->iv.len,
3471 tdata->validCipherLenInBits.len,
3472 tdata->validCipherOffsetLenInBits.len,
3473 tdata->validAuthLenInBits.len,
3474 tdata->validAuthOffsetLenInBits.len
3479 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3481 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3482 ut_params->obuf = ut_params->op->sym->m_src;
3483 if (ut_params->obuf)
3484 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3485 + tdata->iv.len + tdata->aad.len;
3487 ciphertext = plaintext;
3489 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3491 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3493 tdata->ciphertext.data,
3494 tdata->validDataLenInBits.len,
3495 "SNOW 3G Ciphertext data not as expected");
3497 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3498 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3501 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3504 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3505 "SNOW 3G Generated auth tag not as expected");
3509 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3511 struct crypto_testsuite_params *ts_params = &testsuite_params;
3512 struct crypto_unittest_params *ut_params = &unittest_params;
3516 uint8_t *plaintext, *ciphertext;
3517 unsigned plaintext_pad_len;
3518 unsigned plaintext_len;
3520 /* Create SNOW 3G session */
3521 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3522 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3523 RTE_CRYPTO_AUTH_OP_GENERATE,
3524 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3525 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3526 tdata->key.data, tdata->key.len,
3527 tdata->aad.len, tdata->digest.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 of */
3539 /* the algorithms block size */
3540 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3541 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3543 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3545 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3547 /* Create SNOW 3G operation */
3548 retval = create_wireless_algo_auth_cipher_operation(
3550 tdata->iv.data, tdata->iv.len,
3551 tdata->aad.data, tdata->aad.len,
3553 tdata->validCipherLenInBits.len,
3554 tdata->validCipherOffsetLenInBits.len,
3555 tdata->validAuthLenInBits.len,
3556 tdata->validAuthOffsetLenInBits.len,
3557 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3558 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3564 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3566 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3567 ut_params->obuf = ut_params->op->sym->m_src;
3568 if (ut_params->obuf)
3569 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3570 + tdata->aad.len + tdata->iv.len;
3572 ciphertext = plaintext;
3574 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3575 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3576 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3579 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3581 tdata->ciphertext.data,
3582 tdata->validDataLenInBits.len,
3583 "SNOW 3G Ciphertext data not as expected");
3586 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3589 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3590 "SNOW 3G Generated auth tag not as expected");
3595 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3597 struct crypto_testsuite_params *ts_params = &testsuite_params;
3598 struct crypto_unittest_params *ut_params = &unittest_params;
3602 uint8_t *plaintext, *ciphertext;
3603 unsigned plaintext_pad_len;
3604 unsigned plaintext_len;
3606 /* Create KASUMI session */
3607 retval = create_wireless_algo_auth_cipher_session(
3608 ts_params->valid_devs[0],
3609 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3610 RTE_CRYPTO_AUTH_OP_GENERATE,
3611 RTE_CRYPTO_AUTH_KASUMI_F9,
3612 RTE_CRYPTO_CIPHER_KASUMI_F8,
3613 tdata->key.data, tdata->key.len,
3614 tdata->aad.len, tdata->digest.len);
3617 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3619 /* clear mbuf payload */
3620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3621 rte_pktmbuf_tailroom(ut_params->ibuf));
3623 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3624 /* Append data which is padded to a multiple of */
3625 /* the algorithms block size */
3626 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3627 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3629 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3631 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3633 /* Create KASUMI operation */
3634 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3635 tdata->iv.data, tdata->iv.len,
3636 tdata->aad.data, tdata->aad.len,
3638 tdata->validCipherLenInBits.len,
3639 tdata->validCipherOffsetLenInBits.len,
3640 tdata->validAuthLenInBits.len,
3641 tdata->validAuthOffsetLenInBits.len,
3642 RTE_CRYPTO_AUTH_KASUMI_F9,
3643 RTE_CRYPTO_CIPHER_KASUMI_F8
3649 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3651 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3652 ut_params->obuf = ut_params->op->sym->m_src;
3653 if (ut_params->obuf)
3654 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3655 + tdata->iv.len + tdata->aad.len;
3657 ciphertext = plaintext;
3660 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3662 tdata->ciphertext.data,
3663 tdata->validCipherLenInBits.len,
3664 "KASUMI Ciphertext data not as expected");
3665 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3666 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3669 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3672 DIGEST_BYTE_LENGTH_KASUMI_F9,
3673 "KASUMI Generated auth tag not as expected");
3678 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3680 struct crypto_testsuite_params *ts_params = &testsuite_params;
3681 struct crypto_unittest_params *ut_params = &unittest_params;
3685 uint8_t *plaintext, *ciphertext;
3686 unsigned plaintext_pad_len;
3687 unsigned plaintext_len;
3689 /* Create KASUMI session */
3690 retval = create_wireless_algo_cipher_auth_session(
3691 ts_params->valid_devs[0],
3692 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3693 RTE_CRYPTO_AUTH_OP_GENERATE,
3694 RTE_CRYPTO_AUTH_KASUMI_F9,
3695 RTE_CRYPTO_CIPHER_KASUMI_F8,
3696 tdata->key.data, tdata->key.len,
3697 tdata->aad.len, tdata->digest.len);
3701 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3703 /* clear mbuf payload */
3704 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3705 rte_pktmbuf_tailroom(ut_params->ibuf));
3707 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3708 /* Append data which is padded to a multiple of */
3709 /* the algorithms block size */
3710 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3711 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3713 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3715 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3717 /* Create KASUMI operation */
3718 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3719 tdata->digest.len, tdata->aad.data,
3721 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3722 RTE_CRYPTO_AUTH_KASUMI_F9,
3723 RTE_CRYPTO_CIPHER_KASUMI_F8,
3724 tdata->iv.data, tdata->iv.len,
3725 tdata->validCipherLenInBits.len,
3726 tdata->validCipherOffsetLenInBits.len,
3727 tdata->validAuthLenInBits.len,
3728 tdata->validAuthOffsetLenInBits.len
3733 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3735 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3736 ut_params->obuf = ut_params->op->sym->m_src;
3737 if (ut_params->obuf)
3738 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3739 + tdata->aad.len + tdata->iv.len;
3741 ciphertext = plaintext;
3743 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3744 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3747 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3749 tdata->ciphertext.data,
3750 tdata->validCipherLenInBits.len,
3751 "KASUMI Ciphertext data not as expected");
3754 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3757 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3758 "KASUMI Generated auth tag not as expected");
3763 test_zuc_encryption(const struct zuc_test_data *tdata)
3765 struct crypto_testsuite_params *ts_params = &testsuite_params;
3766 struct crypto_unittest_params *ut_params = &unittest_params;
3769 uint8_t *plaintext, *ciphertext;
3770 unsigned plaintext_pad_len;
3771 unsigned plaintext_len;
3773 /* Create ZUC session */
3774 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3775 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3776 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3777 tdata->key.data, tdata->key.len);
3781 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3783 /* Clear mbuf payload */
3784 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3785 rte_pktmbuf_tailroom(ut_params->ibuf));
3787 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3788 /* Append data which is padded to a multiple */
3789 /* of the algorithms block size */
3790 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3791 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3793 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3795 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3797 /* Create ZUC operation */
3798 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3799 tdata->plaintext.len,
3800 tdata->validCipherOffsetLenInBits.len,
3801 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3805 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3807 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3809 ut_params->obuf = ut_params->op->sym->m_dst;
3810 if (ut_params->obuf)
3811 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3814 ciphertext = plaintext;
3816 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3819 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3821 tdata->ciphertext.data,
3822 tdata->validCipherLenInBits.len,
3823 "ZUC Ciphertext data not as expected");
3828 test_zuc_encryption_sgl(const struct zuc_test_data *tdata)
3830 struct crypto_testsuite_params *ts_params = &testsuite_params;
3831 struct crypto_unittest_params *ut_params = &unittest_params;
3835 unsigned int plaintext_pad_len;
3836 unsigned int plaintext_len;
3837 const uint8_t *ciphertext;
3838 uint8_t ciphertext_buffer[2048];
3839 struct rte_cryptodev_info dev_info;
3841 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3842 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3843 printf("Device doesn't support scatter-gather. "
3848 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3850 /* Append data which is padded to a multiple */
3851 /* of the algorithms block size */
3852 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3854 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3855 plaintext_pad_len, 10, 0);
3857 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
3858 tdata->plaintext.data);
3860 /* Create ZUC session */
3861 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3862 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3863 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3864 tdata->key.data, tdata->key.len);
3868 /* Clear mbuf payload */
3870 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3872 /* Create ZUC operation */
3873 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
3874 tdata->iv.len, tdata->plaintext.len,
3875 tdata->validCipherOffsetLenInBits.len,
3876 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3880 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3882 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3884 ut_params->obuf = ut_params->op->sym->m_dst;
3885 if (ut_params->obuf)
3886 ciphertext = rte_pktmbuf_read(ut_params->obuf,
3887 tdata->iv.len, plaintext_len, ciphertext_buffer);
3889 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3890 tdata->iv.len, plaintext_len, ciphertext_buffer);
3893 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3896 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3898 tdata->ciphertext.data,
3899 tdata->validCipherLenInBits.len,
3900 "ZUC Ciphertext data not as expected");
3906 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3908 struct crypto_testsuite_params *ts_params = &testsuite_params;
3909 struct crypto_unittest_params *ut_params = &unittest_params;
3912 unsigned plaintext_pad_len;
3913 unsigned plaintext_len;
3916 /* Create ZUC session */
3917 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3918 tdata->key.data, tdata->key.len,
3919 tdata->aad.len, tdata->digest.len,
3920 RTE_CRYPTO_AUTH_OP_GENERATE,
3921 RTE_CRYPTO_AUTH_ZUC_EIA3);
3925 /* alloc mbuf and set payload */
3926 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3928 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3929 rte_pktmbuf_tailroom(ut_params->ibuf));
3931 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3932 /* Append data which is padded to a multiple of */
3933 /* the algorithms block size */
3934 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3935 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3937 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3939 /* Create ZUC operation */
3940 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3941 tdata->aad.data, tdata->aad.len,
3942 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3943 RTE_CRYPTO_AUTH_ZUC_EIA3,
3944 tdata->validAuthLenInBits.len,
3945 tdata->validAuthOffsetLenInBits.len);
3949 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3951 ut_params->obuf = ut_params->op->sym->m_src;
3952 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3953 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3954 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3957 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3960 DIGEST_BYTE_LENGTH_KASUMI_F9,
3961 "ZUC Generated auth tag not as expected");
3967 test_kasumi_encryption_test_case_1(void)
3969 return test_kasumi_encryption(&kasumi_test_case_1);
3973 test_kasumi_encryption_test_case_1_sgl(void)
3975 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
3979 test_kasumi_encryption_test_case_1_oop(void)
3981 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3985 test_kasumi_encryption_test_case_1_oop_sgl(void)
3987 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
3991 test_kasumi_encryption_test_case_2(void)
3993 return test_kasumi_encryption(&kasumi_test_case_2);
3997 test_kasumi_encryption_test_case_3(void)
3999 return test_kasumi_encryption(&kasumi_test_case_3);
4003 test_kasumi_encryption_test_case_4(void)
4005 return test_kasumi_encryption(&kasumi_test_case_4);
4009 test_kasumi_encryption_test_case_5(void)
4011 return test_kasumi_encryption(&kasumi_test_case_5);
4015 test_kasumi_decryption_test_case_1(void)
4017 return test_kasumi_decryption(&kasumi_test_case_1);
4021 test_kasumi_decryption_test_case_1_oop(void)
4023 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4027 test_kasumi_decryption_test_case_2(void)
4029 return test_kasumi_decryption(&kasumi_test_case_2);
4033 test_kasumi_decryption_test_case_3(void)
4035 return test_kasumi_decryption(&kasumi_test_case_3);
4039 test_kasumi_decryption_test_case_4(void)
4041 return test_kasumi_decryption(&kasumi_test_case_4);
4045 test_kasumi_decryption_test_case_5(void)
4047 return test_kasumi_decryption(&kasumi_test_case_5);
4050 test_snow3g_encryption_test_case_1(void)
4052 return test_snow3g_encryption(&snow3g_test_case_1);
4056 test_snow3g_encryption_test_case_1_oop(void)
4058 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4062 test_snow3g_encryption_test_case_1_oop_sgl(void)
4064 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4069 test_snow3g_encryption_test_case_1_offset_oop(void)
4071 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4075 test_snow3g_encryption_test_case_2(void)
4077 return test_snow3g_encryption(&snow3g_test_case_2);
4081 test_snow3g_encryption_test_case_3(void)
4083 return test_snow3g_encryption(&snow3g_test_case_3);
4087 test_snow3g_encryption_test_case_4(void)
4089 return test_snow3g_encryption(&snow3g_test_case_4);
4093 test_snow3g_encryption_test_case_5(void)
4095 return test_snow3g_encryption(&snow3g_test_case_5);
4099 test_snow3g_decryption_test_case_1(void)
4101 return test_snow3g_decryption(&snow3g_test_case_1);
4105 test_snow3g_decryption_test_case_1_oop(void)
4107 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4111 test_snow3g_decryption_test_case_2(void)
4113 return test_snow3g_decryption(&snow3g_test_case_2);
4117 test_snow3g_decryption_test_case_3(void)
4119 return test_snow3g_decryption(&snow3g_test_case_3);
4123 test_snow3g_decryption_test_case_4(void)
4125 return test_snow3g_decryption(&snow3g_test_case_4);
4129 test_snow3g_decryption_test_case_5(void)
4131 return test_snow3g_decryption(&snow3g_test_case_5);
4134 test_snow3g_cipher_auth_test_case_1(void)
4136 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4140 test_snow3g_auth_cipher_test_case_1(void)
4142 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4146 test_kasumi_auth_cipher_test_case_1(void)
4148 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4152 test_kasumi_cipher_auth_test_case_1(void)
4154 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4158 test_zuc_encryption_test_case_1(void)
4160 return test_zuc_encryption(&zuc_test_case_1);
4164 test_zuc_encryption_test_case_2(void)
4166 return test_zuc_encryption(&zuc_test_case_2);
4170 test_zuc_encryption_test_case_3(void)
4172 return test_zuc_encryption(&zuc_test_case_3);
4176 test_zuc_encryption_test_case_4(void)
4178 return test_zuc_encryption(&zuc_test_case_4);
4182 test_zuc_encryption_test_case_5(void)
4184 return test_zuc_encryption(&zuc_test_case_5);
4188 test_zuc_encryption_test_case_6_sgl(void)
4190 return test_zuc_encryption_sgl(&zuc_test_case_1);
4194 test_zuc_hash_generate_test_case_1(void)
4196 return test_zuc_authentication(&zuc_hash_test_case_1);
4200 test_zuc_hash_generate_test_case_2(void)
4202 return test_zuc_authentication(&zuc_hash_test_case_2);
4206 test_zuc_hash_generate_test_case_3(void)
4208 return test_zuc_authentication(&zuc_hash_test_case_3);
4212 test_zuc_hash_generate_test_case_4(void)
4214 return test_zuc_authentication(&zuc_hash_test_case_4);
4218 test_zuc_hash_generate_test_case_5(void)
4220 return test_zuc_authentication(&zuc_hash_test_case_5);
4224 test_3DES_chain_qat_all(void)
4226 struct crypto_testsuite_params *ts_params = &testsuite_params;
4229 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4230 ts_params->op_mpool, ts_params->valid_devs[0],
4231 RTE_CRYPTODEV_QAT_SYM_PMD,
4232 BLKCIPHER_3DES_CHAIN_TYPE);
4234 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4236 return TEST_SUCCESS;
4240 test_DES_cipheronly_qat_all(void)
4242 struct crypto_testsuite_params *ts_params = &testsuite_params;
4245 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4246 ts_params->op_mpool, ts_params->valid_devs[0],
4247 RTE_CRYPTODEV_QAT_SYM_PMD,
4248 BLKCIPHER_DES_CIPHERONLY_TYPE);
4250 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4252 return TEST_SUCCESS;
4256 test_3DES_cipheronly_qat_all(void)
4258 struct crypto_testsuite_params *ts_params = &testsuite_params;
4261 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4262 ts_params->op_mpool, ts_params->valid_devs[0],
4263 RTE_CRYPTODEV_QAT_SYM_PMD,
4264 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4266 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4268 return TEST_SUCCESS;
4272 test_3DES_chain_openssl_all(void)
4274 struct crypto_testsuite_params *ts_params = &testsuite_params;
4277 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4278 ts_params->op_mpool, ts_params->valid_devs[0],
4279 RTE_CRYPTODEV_OPENSSL_PMD,
4280 BLKCIPHER_3DES_CHAIN_TYPE);
4282 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4284 return TEST_SUCCESS;
4288 test_3DES_cipheronly_openssl_all(void)
4290 struct crypto_testsuite_params *ts_params = &testsuite_params;
4293 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4294 ts_params->op_mpool, ts_params->valid_devs[0],
4295 RTE_CRYPTODEV_OPENSSL_PMD,
4296 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4298 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4300 return TEST_SUCCESS;
4303 /* ***** AES-GCM Tests ***** */
4306 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
4307 const uint8_t *key, const uint8_t key_len,
4308 const uint8_t aad_len, const uint8_t auth_len,
4309 enum rte_crypto_auth_operation auth_op)
4311 uint8_t cipher_key[key_len];
4313 struct crypto_unittest_params *ut_params = &unittest_params;
4315 memcpy(cipher_key, key, key_len);
4317 /* Setup Cipher Parameters */
4318 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4319 ut_params->cipher_xform.next = NULL;
4321 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4322 ut_params->auth_xform.auth.op = auth_op;
4323 ut_params->cipher_xform.cipher.op = op;
4324 ut_params->cipher_xform.cipher.key.data = cipher_key;
4325 ut_params->cipher_xform.cipher.key.length = key_len;
4327 TEST_HEXDUMP(stdout, "key:", key, key_len);
4329 /* Setup Authentication Parameters */
4330 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4331 ut_params->auth_xform.next = NULL;
4333 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4335 ut_params->auth_xform.auth.digest_length = auth_len;
4336 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
4337 ut_params->auth_xform.auth.key.length = 0;
4338 ut_params->auth_xform.auth.key.data = NULL;
4340 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4341 ut_params->cipher_xform.next = &ut_params->auth_xform;
4343 /* Create Crypto session*/
4344 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4345 &ut_params->cipher_xform);
4346 } else {/* Create Crypto session*/
4347 ut_params->auth_xform.next = &ut_params->cipher_xform;
4348 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
4349 &ut_params->auth_xform);
4352 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4358 create_gcm_xforms(struct rte_crypto_op *op,
4359 enum rte_crypto_cipher_operation cipher_op,
4360 uint8_t *key, const uint8_t key_len,
4361 const uint8_t aad_len, const uint8_t auth_len,
4362 enum rte_crypto_auth_operation auth_op)
4364 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 2),
4365 "failed to allocate space for crypto transforms");
4367 struct rte_crypto_sym_op *sym_op = op->sym;
4369 /* Setup Cipher Parameters */
4370 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4371 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
4372 sym_op->xform->cipher.op = cipher_op;
4373 sym_op->xform->cipher.key.data = key;
4374 sym_op->xform->cipher.key.length = key_len;
4376 TEST_HEXDUMP(stdout, "key:", key, key_len);
4378 /* Setup Authentication Parameters */
4379 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
4380 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
4381 sym_op->xform->next->auth.op = auth_op;
4382 sym_op->xform->next->auth.digest_length = auth_len;
4383 sym_op->xform->next->auth.add_auth_data_length = aad_len;
4384 sym_op->xform->next->auth.key.length = 0;
4385 sym_op->xform->next->auth.key.data = NULL;
4386 sym_op->xform->next->next = NULL;
4392 create_gcm_operation(enum rte_crypto_cipher_operation op,
4393 const struct gcm_test_data *tdata)
4395 struct crypto_testsuite_params *ts_params = &testsuite_params;
4396 struct crypto_unittest_params *ut_params = &unittest_params;
4398 uint8_t *plaintext, *ciphertext;
4399 unsigned int iv_pad_len, aad_pad_len, plaintext_pad_len;
4401 /* Generate Crypto op data structure */
4402 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4403 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4404 TEST_ASSERT_NOT_NULL(ut_params->op,
4405 "Failed to allocate symmetric crypto operation struct");
4407 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4409 /* Append aad data */
4410 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
4411 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4413 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4414 "no room to append aad");
4416 sym_op->auth.aad.length = tdata->aad.len;
4417 sym_op->auth.aad.phys_addr =
4418 rte_pktmbuf_mtophys(ut_params->ibuf);
4419 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
4420 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data,
4421 sym_op->auth.aad.length);
4424 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
4425 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
4426 ut_params->ibuf, iv_pad_len);
4427 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
4429 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
4430 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
4431 sym_op->cipher.iv.length = tdata->iv.len;
4433 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
4434 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data,
4435 sym_op->cipher.iv.length);
4437 /* Append plaintext/ciphertext */
4438 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4439 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4440 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4442 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
4444 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4445 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
4446 tdata->plaintext.len);
4448 if (ut_params->obuf) {
4449 ciphertext = (uint8_t *)rte_pktmbuf_append(
4451 plaintext_pad_len + aad_pad_len +
4453 TEST_ASSERT_NOT_NULL(ciphertext,
4454 "no room to append ciphertext");
4456 memset(ciphertext + aad_pad_len + iv_pad_len, 0,
4457 tdata->ciphertext.len);
4460 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4461 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4463 TEST_ASSERT_NOT_NULL(ciphertext,
4464 "no room to append ciphertext");
4466 memcpy(ciphertext, tdata->ciphertext.data,
4467 tdata->ciphertext.len);
4468 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
4469 tdata->ciphertext.len);
4471 if (ut_params->obuf) {
4472 plaintext = (uint8_t *)rte_pktmbuf_append(
4474 plaintext_pad_len + aad_pad_len +
4476 TEST_ASSERT_NOT_NULL(plaintext,
4477 "no room to append plaintext");
4479 memset(plaintext + aad_pad_len + iv_pad_len, 0,
4480 tdata->plaintext.len);
4484 /* Append digest data */
4485 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
4486 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4487 ut_params->obuf ? ut_params->obuf :
4489 tdata->auth_tag.len);
4490 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4491 "no room to append digest");
4492 memset(sym_op->auth.digest.data, 0, tdata->auth_tag.len);
4493 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4494 ut_params->obuf ? ut_params->obuf :
4497 aad_pad_len + iv_pad_len);
4498 sym_op->auth.digest.length = tdata->auth_tag.len;
4500 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4501 ut_params->ibuf, tdata->auth_tag.len);
4502 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4503 "no room to append digest");
4504 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4506 plaintext_pad_len + aad_pad_len + iv_pad_len);
4507 sym_op->auth.digest.length = tdata->auth_tag.len;
4509 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
4510 tdata->auth_tag.len);
4511 TEST_HEXDUMP(stdout, "digest:",
4512 sym_op->auth.digest.data,
4513 sym_op->auth.digest.length);
4516 sym_op->cipher.data.length = tdata->plaintext.len;
4517 sym_op->cipher.data.offset = aad_pad_len + iv_pad_len;
4519 sym_op->auth.data.length = tdata->plaintext.len;
4520 sym_op->auth.data.offset = aad_pad_len + iv_pad_len;
4526 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4528 struct crypto_testsuite_params *ts_params = &testsuite_params;
4529 struct crypto_unittest_params *ut_params = &unittest_params;
4532 uint8_t *ciphertext, *auth_tag;
4533 uint16_t plaintext_pad_len;
4536 /* Create GCM session */
4537 retval = create_gcm_session(ts_params->valid_devs[0],
4538 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4539 tdata->key.data, tdata->key.len,
4540 tdata->aad.len, tdata->auth_tag.len,
4541 RTE_CRYPTO_AUTH_OP_GENERATE);
4545 if (tdata->aad.len > MBUF_SIZE) {
4546 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4547 /* Populate full size of add data */
4548 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4549 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4551 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4553 /* clear mbuf payload */
4554 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4555 rte_pktmbuf_tailroom(ut_params->ibuf));
4557 /* Create GCM operation */
4558 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4562 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4564 ut_params->op->sym->m_src = ut_params->ibuf;
4566 /* Process crypto operation */
4567 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4568 ut_params->op), "failed to process sym crypto op");
4570 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4571 "crypto op processing failed");
4573 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4575 if (ut_params->op->sym->m_dst) {
4576 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4578 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4579 uint8_t *, plaintext_pad_len);
4581 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4583 ut_params->op->sym->cipher.data.offset);
4584 auth_tag = ciphertext + plaintext_pad_len;
4587 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4588 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4591 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4593 tdata->ciphertext.data,
4594 tdata->ciphertext.len,
4595 "GCM Ciphertext data not as expected");
4597 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4599 tdata->auth_tag.data,
4600 tdata->auth_tag.len,
4601 "GCM Generated auth tag not as expected");
4608 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4610 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4614 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4616 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4620 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4622 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4626 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4628 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4632 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4634 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4638 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4640 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4644 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4646 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4650 test_mb_AES_GCM_auth_encryption_test_case_256_1(void)
4652 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_1);
4656 test_mb_AES_GCM_auth_encryption_test_case_256_2(void)
4658 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_2);
4662 test_mb_AES_GCM_auth_encryption_test_case_256_3(void)
4664 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_3);
4668 test_mb_AES_GCM_auth_encryption_test_case_256_4(void)
4670 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_4);
4674 test_mb_AES_GCM_auth_encryption_test_case_256_5(void)
4676 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_5);
4680 test_mb_AES_GCM_auth_encryption_test_case_256_6(void)
4682 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_6);
4686 test_mb_AES_GCM_auth_encryption_test_case_256_7(void)
4688 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_256_7);
4692 test_mb_AES_GCM_auth_encryption_test_case_aad_1(void)
4694 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_1);
4698 test_mb_AES_GCM_auth_encryption_test_case_aad_2(void)
4700 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_aad_2);
4704 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4706 struct crypto_testsuite_params *ts_params = &testsuite_params;
4707 struct crypto_unittest_params *ut_params = &unittest_params;
4713 /* Create GCM session */
4714 retval = create_gcm_session(ts_params->valid_devs[0],
4715 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4716 tdata->key.data, tdata->key.len,
4717 tdata->aad.len, tdata->auth_tag.len,
4718 RTE_CRYPTO_AUTH_OP_VERIFY);
4722 /* alloc mbuf and set payload */
4723 if (tdata->aad.len > MBUF_SIZE) {
4724 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
4725 /* Populate full size of add data */
4726 for (i = 32; i < GCM_MAX_AAD_LENGTH; i += 32)
4727 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
4729 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4731 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4732 rte_pktmbuf_tailroom(ut_params->ibuf));
4734 /* Create GCM operation */
4735 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
4739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4741 ut_params->op->sym->m_src = ut_params->ibuf;
4743 /* Process crypto operation */
4744 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4745 ut_params->op), "failed to process sym crypto op");
4747 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4748 "crypto op processing failed");
4750 if (ut_params->op->sym->m_dst)
4751 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4754 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
4756 ut_params->op->sym->cipher.data.offset);
4758 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4761 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4763 tdata->plaintext.data,
4764 tdata->plaintext.len,
4765 "GCM plaintext data not as expected");
4767 TEST_ASSERT_EQUAL(ut_params->op->status,
4768 RTE_CRYPTO_OP_STATUS_SUCCESS,
4769 "GCM authentication failed");
4774 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4776 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4780 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4782 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4786 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4788 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4792 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4794 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4798 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4800 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4804 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4806 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4810 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4812 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4816 test_mb_AES_GCM_auth_decryption_test_case_256_1(void)
4818 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_1);
4822 test_mb_AES_GCM_auth_decryption_test_case_256_2(void)
4824 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_2);
4828 test_mb_AES_GCM_auth_decryption_test_case_256_3(void)
4830 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_3);
4834 test_mb_AES_GCM_auth_decryption_test_case_256_4(void)
4836 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_4);
4840 test_mb_AES_GCM_auth_decryption_test_case_256_5(void)
4842 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_5);
4846 test_mb_AES_GCM_auth_decryption_test_case_256_6(void)
4848 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_6);
4852 test_mb_AES_GCM_auth_decryption_test_case_256_7(void)
4854 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_256_7);
4858 test_mb_AES_GCM_auth_decryption_test_case_aad_1(void)
4860 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_1);
4864 test_mb_AES_GCM_auth_decryption_test_case_aad_2(void)
4866 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_aad_2);
4870 test_AES_GCM_authenticated_encryption_oop(const struct gcm_test_data *tdata)
4872 struct crypto_testsuite_params *ts_params = &testsuite_params;
4873 struct crypto_unittest_params *ut_params = &unittest_params;
4876 uint8_t *ciphertext, *auth_tag;
4877 uint16_t plaintext_pad_len;
4879 /* Create GCM session */
4880 retval = create_gcm_session(ts_params->valid_devs[0],
4881 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4882 tdata->key.data, tdata->key.len,
4883 tdata->aad.len, tdata->auth_tag.len,
4884 RTE_CRYPTO_AUTH_OP_GENERATE);
4888 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4889 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4891 /* clear mbuf payload */
4892 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4893 rte_pktmbuf_tailroom(ut_params->ibuf));
4894 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4895 rte_pktmbuf_tailroom(ut_params->obuf));
4897 /* Create GCM operation */
4898 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
4902 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4904 ut_params->op->sym->m_src = ut_params->ibuf;
4905 ut_params->op->sym->m_dst = ut_params->obuf;
4907 /* Process crypto operation */
4908 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4909 ut_params->op), "failed to process sym crypto op");
4911 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4912 "crypto op processing failed");
4914 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4916 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4917 ut_params->op->sym->cipher.data.offset);
4918 auth_tag = ciphertext + plaintext_pad_len;
4920 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4921 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4924 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4926 tdata->ciphertext.data,
4927 tdata->ciphertext.len,
4928 "GCM Ciphertext data not as expected");
4930 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4932 tdata->auth_tag.data,
4933 tdata->auth_tag.len,
4934 "GCM Generated auth tag not as expected");
4941 test_mb_AES_GCM_authenticated_encryption_oop(void)
4943 return test_AES_GCM_authenticated_encryption_oop(&gcm_test_case_5);
4947 test_AES_GCM_authenticated_decryption_oop(const struct gcm_test_data *tdata)
4949 struct crypto_testsuite_params *ts_params = &testsuite_params;
4950 struct crypto_unittest_params *ut_params = &unittest_params;
4955 /* Create GCM session */
4956 retval = create_gcm_session(ts_params->valid_devs[0],
4957 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4958 tdata->key.data, tdata->key.len,
4959 tdata->aad.len, tdata->auth_tag.len,
4960 RTE_CRYPTO_AUTH_OP_VERIFY);
4964 /* alloc mbuf and set payload */
4965 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4966 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4968 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4969 rte_pktmbuf_tailroom(ut_params->ibuf));
4970 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4971 rte_pktmbuf_tailroom(ut_params->obuf));
4973 /* Create GCM operation */
4974 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
4978 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4980 ut_params->op->sym->m_src = ut_params->ibuf;
4981 ut_params->op->sym->m_dst = ut_params->obuf;
4983 /* Process crypto operation */
4984 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4985 ut_params->op), "failed to process sym crypto op");
4987 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4988 "crypto op processing failed");
4990 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4991 ut_params->op->sym->cipher.data.offset);
4993 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4996 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4998 tdata->plaintext.data,
4999 tdata->plaintext.len,
5000 "GCM plaintext data not as expected");
5002 TEST_ASSERT_EQUAL(ut_params->op->status,
5003 RTE_CRYPTO_OP_STATUS_SUCCESS,
5004 "GCM authentication failed");
5009 test_mb_AES_GCM_authenticated_decryption_oop(void)
5011 return test_AES_GCM_authenticated_decryption_oop(&gcm_test_case_5);
5015 test_AES_GCM_authenticated_encryption_sessionless(
5016 const struct gcm_test_data *tdata)
5018 struct crypto_testsuite_params *ts_params = &testsuite_params;
5019 struct crypto_unittest_params *ut_params = &unittest_params;
5022 uint8_t *ciphertext, *auth_tag;
5023 uint16_t plaintext_pad_len;
5024 uint8_t key[tdata->key.len + 1];
5026 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5028 /* clear mbuf payload */
5029 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5030 rte_pktmbuf_tailroom(ut_params->ibuf));
5032 /* Create GCM operation */
5033 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT, tdata);
5037 /* Create GCM xforms */
5038 memcpy(key, tdata->key.data, tdata->key.len);
5039 retval = create_gcm_xforms(ut_params->op,
5040 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5041 key, tdata->key.len,
5042 tdata->aad.len, tdata->auth_tag.len,
5043 RTE_CRYPTO_AUTH_OP_GENERATE);
5047 ut_params->op->sym->m_src = ut_params->ibuf;
5049 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5050 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5051 "crypto op session type not sessionless");
5053 /* Process crypto operation */
5054 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5055 ut_params->op), "failed to process sym crypto op");
5057 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5059 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5060 "crypto op status not success");
5062 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5064 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5065 ut_params->op->sym->cipher.data.offset);
5066 auth_tag = ciphertext + plaintext_pad_len;
5068 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5069 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5072 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5074 tdata->ciphertext.data,
5075 tdata->ciphertext.len,
5076 "GCM Ciphertext data not as expected");
5078 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5080 tdata->auth_tag.data,
5081 tdata->auth_tag.len,
5082 "GCM Generated auth tag not as expected");
5089 test_mb_AES_GCM_authenticated_encryption_sessionless(void)
5091 return test_AES_GCM_authenticated_encryption_sessionless(
5096 test_AES_GCM_authenticated_decryption_sessionless(
5097 const struct gcm_test_data *tdata)
5099 struct crypto_testsuite_params *ts_params = &testsuite_params;
5100 struct crypto_unittest_params *ut_params = &unittest_params;
5104 uint8_t key[tdata->key.len + 1];
5106 /* alloc mbuf and set payload */
5107 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5109 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5110 rte_pktmbuf_tailroom(ut_params->ibuf));
5112 /* Create GCM operation */
5113 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT, tdata);
5117 /* Create GCM xforms */
5118 memcpy(key, tdata->key.data, tdata->key.len);
5119 retval = create_gcm_xforms(ut_params->op,
5120 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5121 key, tdata->key.len,
5122 tdata->aad.len, tdata->auth_tag.len,
5123 RTE_CRYPTO_AUTH_OP_VERIFY);
5127 ut_params->op->sym->m_src = ut_params->ibuf;
5129 TEST_ASSERT_EQUAL(ut_params->op->sym->sess_type,
5130 RTE_CRYPTO_SYM_OP_SESSIONLESS,
5131 "crypto op session type not sessionless");
5133 /* Process crypto operation */
5134 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5135 ut_params->op), "failed to process sym crypto op");
5137 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5139 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5140 "crypto op status not success");
5142 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5143 ut_params->op->sym->cipher.data.offset);
5145 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5148 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5150 tdata->plaintext.data,
5151 tdata->plaintext.len,
5152 "GCM plaintext data not as expected");
5154 TEST_ASSERT_EQUAL(ut_params->op->status,
5155 RTE_CRYPTO_OP_STATUS_SUCCESS,
5156 "GCM authentication failed");
5161 test_mb_AES_GCM_authenticated_decryption_sessionless(void)
5163 return test_AES_GCM_authenticated_decryption_sessionless(
5170 struct crypto_testsuite_params *ts_params = &testsuite_params;
5171 struct rte_cryptodev_stats stats;
5172 struct rte_cryptodev *dev;
5173 cryptodev_stats_get_t temp_pfn;
5175 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5176 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
5177 &stats) == -ENODEV),
5178 "rte_cryptodev_stats_get invalid dev failed");
5179 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
5180 "rte_cryptodev_stats_get invalid Param failed");
5181 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
5182 temp_pfn = dev->dev_ops->stats_get;
5183 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
5184 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
5186 "rte_cryptodev_stats_get invalid Param failed");
5187 dev->dev_ops->stats_get = temp_pfn;
5189 /* Test expected values */
5191 test_AES_CBC_HMAC_SHA1_encrypt_digest();
5193 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5195 "rte_cryptodev_stats_get failed");
5196 TEST_ASSERT((stats.enqueued_count == 1),
5197 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5198 TEST_ASSERT((stats.dequeued_count == 1),
5199 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5200 TEST_ASSERT((stats.enqueue_err_count == 0),
5201 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5202 TEST_ASSERT((stats.dequeue_err_count == 0),
5203 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5205 /* invalid device but should ignore and not reset device stats*/
5206 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
5207 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5209 "rte_cryptodev_stats_get failed");
5210 TEST_ASSERT((stats.enqueued_count == 1),
5211 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5213 /* check that a valid reset clears stats */
5214 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
5215 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
5217 "rte_cryptodev_stats_get failed");
5218 TEST_ASSERT((stats.enqueued_count == 0),
5219 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5220 TEST_ASSERT((stats.dequeued_count == 0),
5221 "rte_cryptodev_stats_get returned unexpected enqueued stat");
5223 return TEST_SUCCESS;
5226 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
5227 struct crypto_unittest_params *ut_params,
5228 enum rte_crypto_auth_operation op,
5229 const struct HMAC_MD5_vector *test_case)
5233 memcpy(key, test_case->key.data, test_case->key.len);
5235 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5236 ut_params->auth_xform.next = NULL;
5237 ut_params->auth_xform.auth.op = op;
5239 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
5241 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
5242 ut_params->auth_xform.auth.add_auth_data_length = 0;
5243 ut_params->auth_xform.auth.key.length = test_case->key.len;
5244 ut_params->auth_xform.auth.key.data = key;
5246 ut_params->sess = rte_cryptodev_sym_session_create(
5247 ts_params->valid_devs[0], &ut_params->auth_xform);
5249 if (ut_params->sess == NULL)
5252 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5254 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5255 rte_pktmbuf_tailroom(ut_params->ibuf));
5260 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
5261 const struct HMAC_MD5_vector *test_case,
5262 uint8_t **plaintext)
5264 uint16_t plaintext_pad_len;
5266 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5268 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5271 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5273 memcpy(*plaintext, test_case->plaintext.data,
5274 test_case->plaintext.len);
5276 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5277 ut_params->ibuf, MD5_DIGEST_LEN);
5278 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5279 "no room to append digest");
5280 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5281 ut_params->ibuf, plaintext_pad_len);
5282 sym_op->auth.digest.length = MD5_DIGEST_LEN;
5284 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5285 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
5286 test_case->auth_tag.len);
5289 sym_op->auth.data.offset = 0;
5290 sym_op->auth.data.length = test_case->plaintext.len;
5292 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5293 ut_params->op->sym->m_src = ut_params->ibuf;
5299 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
5301 uint16_t plaintext_pad_len;
5302 uint8_t *plaintext, *auth_tag;
5304 struct crypto_testsuite_params *ts_params = &testsuite_params;
5305 struct crypto_unittest_params *ut_params = &unittest_params;
5307 if (MD5_HMAC_create_session(ts_params, ut_params,
5308 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
5311 /* Generate Crypto op data structure */
5312 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5313 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5314 TEST_ASSERT_NOT_NULL(ut_params->op,
5315 "Failed to allocate symmetric crypto operation struct");
5317 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
5320 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5323 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5324 ut_params->op), "failed to process sym crypto op");
5326 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5327 "crypto op processing failed");
5329 if (ut_params->op->sym->m_dst) {
5330 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5331 uint8_t *, plaintext_pad_len);
5333 auth_tag = plaintext + plaintext_pad_len;
5336 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5338 test_case->auth_tag.data,
5339 test_case->auth_tag.len,
5340 "HMAC_MD5 generated tag not as expected");
5342 return TEST_SUCCESS;
5346 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
5350 struct crypto_testsuite_params *ts_params = &testsuite_params;
5351 struct crypto_unittest_params *ut_params = &unittest_params;
5353 if (MD5_HMAC_create_session(ts_params, ut_params,
5354 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
5358 /* Generate Crypto op data structure */
5359 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5360 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5361 TEST_ASSERT_NOT_NULL(ut_params->op,
5362 "Failed to allocate symmetric crypto operation struct");
5364 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
5367 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5368 ut_params->op), "failed to process sym crypto op");
5370 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5371 "HMAC_MD5 crypto op processing failed");
5373 return TEST_SUCCESS;
5377 test_MD5_HMAC_generate_case_1(void)
5379 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
5383 test_MD5_HMAC_verify_case_1(void)
5385 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
5389 test_MD5_HMAC_generate_case_2(void)
5391 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
5395 test_MD5_HMAC_verify_case_2(void)
5397 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
5401 test_multi_session(void)
5403 struct crypto_testsuite_params *ts_params = &testsuite_params;
5404 struct crypto_unittest_params *ut_params = &unittest_params;
5406 struct rte_cryptodev_info dev_info;
5407 struct rte_cryptodev_sym_session **sessions;
5411 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
5412 aes_cbc_key, hmac_sha512_key);
5415 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5417 sessions = rte_malloc(NULL,
5418 (sizeof(struct rte_cryptodev_sym_session *) *
5419 dev_info.sym.max_nb_sessions) + 1, 0);
5421 /* Create multiple crypto sessions*/
5422 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
5423 sessions[i] = rte_cryptodev_sym_session_create(
5424 ts_params->valid_devs[0],
5425 &ut_params->auth_xform);
5426 TEST_ASSERT_NOT_NULL(sessions[i],
5427 "Session creation failed at session number %u",
5430 /* Attempt to send a request on each session */
5431 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
5435 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
5436 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
5438 "Failed to perform decrypt on request number %u.", i);
5439 /* free crypto operation structure */
5441 rte_crypto_op_free(ut_params->op);
5444 * free mbuf - both obuf and ibuf are usually the same,
5445 * so check if they point at the same address is necessary,
5446 * to avoid freeing the mbuf twice.
5448 if (ut_params->obuf) {
5449 rte_pktmbuf_free(ut_params->obuf);
5450 if (ut_params->ibuf == ut_params->obuf)
5451 ut_params->ibuf = 0;
5452 ut_params->obuf = 0;
5454 if (ut_params->ibuf) {
5455 rte_pktmbuf_free(ut_params->ibuf);
5456 ut_params->ibuf = 0;
5460 /* Next session create should fail */
5461 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
5462 &ut_params->auth_xform);
5463 TEST_ASSERT_NULL(sessions[i],
5464 "Session creation succeeded unexpectedly!");
5466 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
5467 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5472 return TEST_SUCCESS;
5475 struct multi_session_params {
5476 struct crypto_unittest_params ut_params;
5477 uint8_t *cipher_key;
5479 const uint8_t *cipher;
5480 const uint8_t *digest;
5484 #define MB_SESSION_NUMBER 3
5487 test_multi_session_random_usage(void)
5489 struct crypto_testsuite_params *ts_params = &testsuite_params;
5490 struct rte_cryptodev_info dev_info;
5491 struct rte_cryptodev_sym_session **sessions;
5493 struct multi_session_params ut_paramz[] = {
5496 .cipher_key = ms_aes_cbc_key0,
5497 .hmac_key = ms_hmac_key0,
5498 .cipher = ms_aes_cbc_cipher0,
5499 .digest = ms_hmac_digest0,
5500 .iv = ms_aes_cbc_iv0
5503 .cipher_key = ms_aes_cbc_key1,
5504 .hmac_key = ms_hmac_key1,
5505 .cipher = ms_aes_cbc_cipher1,
5506 .digest = ms_hmac_digest1,
5507 .iv = ms_aes_cbc_iv1
5510 .cipher_key = ms_aes_cbc_key2,
5511 .hmac_key = ms_hmac_key2,
5512 .cipher = ms_aes_cbc_cipher2,
5513 .digest = ms_hmac_digest2,
5514 .iv = ms_aes_cbc_iv2
5519 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5521 sessions = rte_malloc(NULL,
5522 (sizeof(struct rte_cryptodev_sym_session *)
5523 * dev_info.sym.max_nb_sessions) + 1, 0);
5525 for (i = 0; i < MB_SESSION_NUMBER; i++) {
5526 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
5527 sizeof(struct crypto_unittest_params));
5529 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
5530 &ut_paramz[i].ut_params,
5531 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
5533 /* Create multiple crypto sessions*/
5534 sessions[i] = rte_cryptodev_sym_session_create(
5535 ts_params->valid_devs[0],
5536 &ut_paramz[i].ut_params.auth_xform);
5538 TEST_ASSERT_NOT_NULL(sessions[i],
5539 "Session creation failed at session number %u",
5545 for (i = 0; i < 40000; i++) {
5547 j = rand() % MB_SESSION_NUMBER;
5549 TEST_ASSERT_SUCCESS(
5550 test_AES_CBC_HMAC_SHA512_decrypt_perform(
5552 &ut_paramz[j].ut_params,
5553 ts_params, ut_paramz[j].cipher,
5554 ut_paramz[j].digest,
5556 "Failed to perform decrypt on request number %u.", i);
5558 if (ut_paramz[j].ut_params.op)
5559 rte_crypto_op_free(ut_paramz[j].ut_params.op);
5562 * free mbuf - both obuf and ibuf are usually the same,
5563 * so check if they point at the same address is necessary,
5564 * to avoid freeing the mbuf twice.
5566 if (ut_paramz[j].ut_params.obuf) {
5567 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
5568 if (ut_paramz[j].ut_params.ibuf
5569 == ut_paramz[j].ut_params.obuf)
5570 ut_paramz[j].ut_params.ibuf = 0;
5571 ut_paramz[j].ut_params.obuf = 0;
5573 if (ut_paramz[j].ut_params.ibuf) {
5574 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
5575 ut_paramz[j].ut_params.ibuf = 0;
5579 for (i = 0; i < MB_SESSION_NUMBER; i++)
5580 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
5585 return TEST_SUCCESS;
5589 test_null_cipher_only_operation(void)
5591 struct crypto_testsuite_params *ts_params = &testsuite_params;
5592 struct crypto_unittest_params *ut_params = &unittest_params;
5594 /* Generate test mbuf data and space for digest */
5595 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5596 catch_22_quote, QUOTE_512_BYTES, 0);
5598 /* Setup Cipher Parameters */
5599 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5600 ut_params->cipher_xform.next = NULL;
5602 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5603 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5605 /* Create Crypto session*/
5606 ut_params->sess = rte_cryptodev_sym_session_create(
5607 ts_params->valid_devs[0], &ut_params->cipher_xform);
5608 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5610 /* Generate Crypto op data structure */
5611 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5612 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5613 TEST_ASSERT_NOT_NULL(ut_params->op,
5614 "Failed to allocate symmetric crypto operation struct");
5616 /* Set crypto operation data parameters */
5617 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5619 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5621 /* set crypto operation source mbuf */
5622 sym_op->m_src = ut_params->ibuf;
5624 sym_op->cipher.data.offset = 0;
5625 sym_op->cipher.data.length = QUOTE_512_BYTES;
5627 /* Process crypto operation */
5628 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5630 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5632 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5633 "crypto operation processing failed");
5636 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5637 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5640 "Ciphertext data not as expected");
5642 return TEST_SUCCESS;
5646 test_null_auth_only_operation(void)
5648 struct crypto_testsuite_params *ts_params = &testsuite_params;
5649 struct crypto_unittest_params *ut_params = &unittest_params;
5651 /* Generate test mbuf data and space for digest */
5652 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5653 catch_22_quote, QUOTE_512_BYTES, 0);
5655 /* Setup HMAC Parameters */
5656 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5657 ut_params->auth_xform.next = NULL;
5659 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5660 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5662 /* Create Crypto session*/
5663 ut_params->sess = rte_cryptodev_sym_session_create(
5664 ts_params->valid_devs[0], &ut_params->auth_xform);
5665 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5667 /* Generate Crypto op data structure */
5668 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5669 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5670 TEST_ASSERT_NOT_NULL(ut_params->op,
5671 "Failed to allocate symmetric crypto operation struct");
5673 /* Set crypto operation data parameters */
5674 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5676 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5678 sym_op->m_src = ut_params->ibuf;
5680 sym_op->auth.data.offset = 0;
5681 sym_op->auth.data.length = QUOTE_512_BYTES;
5683 /* Process crypto operation */
5684 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5686 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5688 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5689 "crypto operation processing failed");
5691 return TEST_SUCCESS;
5695 test_null_cipher_auth_operation(void)
5697 struct crypto_testsuite_params *ts_params = &testsuite_params;
5698 struct crypto_unittest_params *ut_params = &unittest_params;
5700 /* Generate test mbuf data and space for digest */
5701 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5702 catch_22_quote, QUOTE_512_BYTES, 0);
5704 /* Setup Cipher Parameters */
5705 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5706 ut_params->cipher_xform.next = &ut_params->auth_xform;
5708 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5709 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5711 /* Setup HMAC Parameters */
5712 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5713 ut_params->auth_xform.next = NULL;
5715 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5716 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5718 /* Create Crypto session*/
5719 ut_params->sess = rte_cryptodev_sym_session_create(
5720 ts_params->valid_devs[0], &ut_params->cipher_xform);
5721 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5723 /* Generate Crypto op data structure */
5724 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5725 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5726 TEST_ASSERT_NOT_NULL(ut_params->op,
5727 "Failed to allocate symmetric crypto operation struct");
5729 /* Set crypto operation data parameters */
5730 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5732 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5734 sym_op->m_src = ut_params->ibuf;
5736 sym_op->cipher.data.offset = 0;
5737 sym_op->cipher.data.length = QUOTE_512_BYTES;
5739 sym_op->auth.data.offset = 0;
5740 sym_op->auth.data.length = QUOTE_512_BYTES;
5742 /* Process crypto operation */
5743 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5745 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5747 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5748 "crypto operation processing failed");
5751 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5752 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5755 "Ciphertext data not as expected");
5757 return TEST_SUCCESS;
5761 test_null_auth_cipher_operation(void)
5763 struct crypto_testsuite_params *ts_params = &testsuite_params;
5764 struct crypto_unittest_params *ut_params = &unittest_params;
5766 /* Generate test mbuf data and space for digest */
5767 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
5768 catch_22_quote, QUOTE_512_BYTES, 0);
5770 /* Setup Cipher Parameters */
5771 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5772 ut_params->cipher_xform.next = NULL;
5774 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5775 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5777 /* Setup HMAC Parameters */
5778 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5779 ut_params->auth_xform.next = &ut_params->cipher_xform;
5781 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5782 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5784 /* Create Crypto session*/
5785 ut_params->sess = rte_cryptodev_sym_session_create(
5786 ts_params->valid_devs[0], &ut_params->cipher_xform);
5787 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5789 /* Generate Crypto op data structure */
5790 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5791 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5792 TEST_ASSERT_NOT_NULL(ut_params->op,
5793 "Failed to allocate symmetric crypto operation struct");
5795 /* Set crypto operation data parameters */
5796 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5798 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5800 sym_op->m_src = ut_params->ibuf;
5802 sym_op->cipher.data.offset = 0;
5803 sym_op->cipher.data.length = QUOTE_512_BYTES;
5805 sym_op->auth.data.offset = 0;
5806 sym_op->auth.data.length = QUOTE_512_BYTES;
5808 /* Process crypto operation */
5809 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5811 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
5813 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5814 "crypto operation processing failed");
5817 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5818 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
5821 "Ciphertext data not as expected");
5823 return TEST_SUCCESS;
5828 test_null_invalid_operation(void)
5830 struct crypto_testsuite_params *ts_params = &testsuite_params;
5831 struct crypto_unittest_params *ut_params = &unittest_params;
5833 /* Setup Cipher Parameters */
5834 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5835 ut_params->cipher_xform.next = NULL;
5837 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
5838 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5840 /* Create Crypto session*/
5841 ut_params->sess = rte_cryptodev_sym_session_create(
5842 ts_params->valid_devs[0], &ut_params->cipher_xform);
5843 TEST_ASSERT_NULL(ut_params->sess,
5844 "Session creation succeeded unexpectedly");
5847 /* Setup HMAC Parameters */
5848 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5849 ut_params->auth_xform.next = NULL;
5851 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
5852 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5854 /* Create Crypto session*/
5855 ut_params->sess = rte_cryptodev_sym_session_create(
5856 ts_params->valid_devs[0], &ut_params->auth_xform);
5857 TEST_ASSERT_NULL(ut_params->sess,
5858 "Session creation succeeded unexpectedly");
5860 return TEST_SUCCESS;
5864 #define NULL_BURST_LENGTH (32)
5867 test_null_burst_operation(void)
5869 struct crypto_testsuite_params *ts_params = &testsuite_params;
5870 struct crypto_unittest_params *ut_params = &unittest_params;
5872 unsigned i, burst_len = NULL_BURST_LENGTH;
5874 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
5875 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
5877 /* Setup Cipher Parameters */
5878 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5879 ut_params->cipher_xform.next = &ut_params->auth_xform;
5881 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
5882 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
5884 /* Setup HMAC Parameters */
5885 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5886 ut_params->auth_xform.next = NULL;
5888 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5889 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5891 /* Create Crypto session*/
5892 ut_params->sess = rte_cryptodev_sym_session_create(
5893 ts_params->valid_devs[0], &ut_params->cipher_xform);
5894 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5896 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
5897 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
5898 burst_len, "failed to generate burst of crypto ops");
5900 /* Generate an operation for each mbuf in burst */
5901 for (i = 0; i < burst_len; i++) {
5902 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5904 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
5906 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
5910 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
5912 burst[i]->sym->m_src = m;
5915 /* Process crypto operation */
5916 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
5917 0, burst, burst_len),
5919 "Error enqueuing burst");
5921 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
5922 0, burst_dequeued, burst_len),
5924 "Error dequeuing burst");
5927 for (i = 0; i < burst_len; i++) {
5929 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
5930 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
5932 "data not as expected");
5934 rte_pktmbuf_free(burst[i]->sym->m_src);
5935 rte_crypto_op_free(burst[i]);
5938 return TEST_SUCCESS;
5942 generate_gmac_large_plaintext(uint8_t *data)
5946 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5947 memcpy(&data[i], &data[0], 32);
5951 create_gmac_operation(enum rte_crypto_auth_operation op,
5952 const struct gmac_test_data *tdata)
5954 struct crypto_testsuite_params *ts_params = &testsuite_params;
5955 struct crypto_unittest_params *ut_params = &unittest_params;
5956 struct rte_crypto_sym_op *sym_op;
5958 unsigned iv_pad_len;
5959 unsigned aad_pad_len;
5961 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5962 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5965 * Runtime generate the large plain text instead of use hard code
5966 * plain text vector. It is done to avoid create huge source file
5967 * with the test vector.
5969 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5970 generate_gmac_large_plaintext(tdata->aad.data);
5972 /* Generate Crypto op data structure */
5973 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5974 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5975 TEST_ASSERT_NOT_NULL(ut_params->op,
5976 "Failed to allocate symmetric crypto operation struct");
5978 sym_op = ut_params->op->sym;
5979 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5981 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5982 "no room to append aad");
5984 sym_op->auth.aad.length = tdata->aad.len;
5985 sym_op->auth.aad.phys_addr =
5986 rte_pktmbuf_mtophys(ut_params->ibuf);
5987 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5989 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5990 ut_params->ibuf, tdata->gmac_tag.len);
5991 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5992 "no room to append digest");
5994 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5995 ut_params->ibuf, aad_pad_len);
5996 sym_op->auth.digest.length = tdata->gmac_tag.len;
5998 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5999 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6000 tdata->gmac_tag.len);
6001 TEST_HEXDUMP(stdout, "digest:",
6002 sym_op->auth.digest.data,
6003 sym_op->auth.digest.length);
6006 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6007 ut_params->ibuf, iv_pad_len);
6008 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6010 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6011 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6012 sym_op->cipher.iv.length = tdata->iv.len;
6014 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
6016 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6018 sym_op->cipher.data.length = 0;
6019 sym_op->cipher.data.offset = 0;
6021 sym_op->auth.data.offset = 0;
6022 sym_op->auth.data.length = 0;
6027 static int create_gmac_session(uint8_t dev_id,
6028 enum rte_crypto_cipher_operation op,
6029 const struct gmac_test_data *tdata,
6030 enum rte_crypto_auth_operation auth_op)
6032 uint8_t cipher_key[tdata->key.len];
6034 struct crypto_unittest_params *ut_params = &unittest_params;
6036 memcpy(cipher_key, tdata->key.data, tdata->key.len);
6038 /* For GMAC we setup cipher parameters */
6039 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6040 ut_params->cipher_xform.next = NULL;
6041 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
6042 ut_params->cipher_xform.cipher.op = op;
6043 ut_params->cipher_xform.cipher.key.data = cipher_key;
6044 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
6046 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6047 ut_params->auth_xform.next = NULL;
6049 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6050 ut_params->auth_xform.auth.op = auth_op;
6051 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6052 ut_params->auth_xform.auth.add_auth_data_length = 0;
6053 ut_params->auth_xform.auth.key.length = 0;
6054 ut_params->auth_xform.auth.key.data = NULL;
6056 ut_params->cipher_xform.next = &ut_params->auth_xform;
6058 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6059 &ut_params->cipher_xform);
6061 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6067 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
6069 struct crypto_testsuite_params *ts_params = &testsuite_params;
6070 struct crypto_unittest_params *ut_params = &unittest_params;
6074 uint8_t *auth_tag, *p;
6075 uint16_t aad_pad_len;
6077 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6078 "No GMAC length in the source data");
6080 retval = create_gmac_session(ts_params->valid_devs[0],
6081 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6082 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
6087 if (tdata->aad.len > MBUF_SIZE)
6088 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6090 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6091 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6092 "Failed to allocate input buffer in mempool");
6094 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6095 rte_pktmbuf_tailroom(ut_params->ibuf));
6097 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6099 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
6101 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
6107 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6109 ut_params->op->sym->m_src = ut_params->ibuf;
6111 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6112 ut_params->op), "failed to process sym crypto op");
6114 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6115 "crypto op processing failed");
6117 if (ut_params->op->sym->m_dst) {
6118 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6119 uint8_t *, aad_pad_len);
6121 auth_tag = p + aad_pad_len;
6124 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
6126 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6128 tdata->gmac_tag.data,
6129 tdata->gmac_tag.len,
6130 "GMAC Generated auth tag not as expected");
6136 test_AES_GMAC_authentication_test_case_1(void)
6138 return test_AES_GMAC_authentication(&gmac_test_case_1);
6142 test_AES_GMAC_authentication_test_case_2(void)
6144 return test_AES_GMAC_authentication(&gmac_test_case_2);
6148 test_AES_GMAC_authentication_test_case_3(void)
6150 return test_AES_GMAC_authentication(&gmac_test_case_3);
6154 test_AES_GMAC_authentication_test_case_4(void)
6156 return test_AES_GMAC_authentication(&gmac_test_case_4);
6160 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
6162 struct crypto_testsuite_params *ts_params = &testsuite_params;
6163 struct crypto_unittest_params *ut_params = &unittest_params;
6166 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
6167 "No GMAC length in the source data");
6169 retval = create_gmac_session(ts_params->valid_devs[0],
6170 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6171 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
6176 if (tdata->aad.len > MBUF_SIZE)
6177 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6179 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6180 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6181 "Failed to allocate input buffer in mempool");
6183 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6184 rte_pktmbuf_tailroom(ut_params->ibuf));
6186 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
6192 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6194 ut_params->op->sym->m_src = ut_params->ibuf;
6196 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6197 ut_params->op), "failed to process sym crypto op");
6199 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6200 "crypto op processing failed");
6207 test_AES_GMAC_authentication_verify_test_case_1(void)
6209 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
6213 test_AES_GMAC_authentication_verify_test_case_2(void)
6215 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
6219 test_AES_GMAC_authentication_verify_test_case_3(void)
6221 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
6225 test_AES_GMAC_authentication_verify_test_case_4(void)
6227 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
6230 struct test_crypto_vector {
6231 enum rte_crypto_cipher_algorithm crypto_algo;
6244 const uint8_t *data;
6249 const uint8_t *data;
6253 enum rte_crypto_auth_algorithm auth_algo;
6261 const uint8_t *data;
6271 static const struct test_crypto_vector
6272 hmac_sha1_test_crypto_vector = {
6273 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6275 .data = plaintext_hash,
6280 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6281 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6282 0xDE, 0xF4, 0xDE, 0xAD
6288 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
6289 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
6290 0x3F, 0x91, 0x64, 0x59
6296 static const struct test_crypto_vector
6297 aes128_gmac_test_vector = {
6298 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
6299 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
6301 .data = plaintext_hash,
6306 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6307 0x08, 0x09, 0x0A, 0x0B
6313 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6314 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
6320 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
6321 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
6327 static const struct test_crypto_vector
6328 aes128cbc_hmac_sha1_test_vector = {
6329 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
6332 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
6333 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
6339 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
6340 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
6345 .data = plaintext_hash,
6349 .data = ciphertext512_aes128cbc,
6352 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
6355 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
6356 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
6357 0xDE, 0xF4, 0xDE, 0xAD
6363 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
6364 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
6365 0x18, 0x8C, 0x1D, 0x32
6372 data_corruption(uint8_t *data)
6378 tag_corruption(uint8_t *data, unsigned int tag_offset)
6380 data[tag_offset] += 1;
6384 create_auth_session(struct crypto_unittest_params *ut_params,
6386 const struct test_crypto_vector *reference,
6387 enum rte_crypto_auth_operation auth_op)
6389 uint8_t auth_key[reference->auth_key.len + 1];
6391 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6393 /* Setup Authentication Parameters */
6394 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6395 ut_params->auth_xform.auth.op = auth_op;
6396 ut_params->auth_xform.next = NULL;
6397 ut_params->auth_xform.auth.algo = reference->auth_algo;
6398 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6399 ut_params->auth_xform.auth.key.data = auth_key;
6400 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6401 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6403 /* Create Crypto session*/
6404 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6405 &ut_params->auth_xform);
6407 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6413 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
6415 const struct test_crypto_vector *reference,
6416 enum rte_crypto_auth_operation auth_op,
6417 enum rte_crypto_cipher_operation cipher_op)
6419 uint8_t cipher_key[reference->cipher_key.len + 1];
6420 uint8_t auth_key[reference->auth_key.len + 1];
6422 memcpy(cipher_key, reference->cipher_key.data,
6423 reference->cipher_key.len);
6424 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
6426 /* Setup Authentication Parameters */
6427 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6428 ut_params->auth_xform.auth.op = auth_op;
6429 ut_params->auth_xform.next = &ut_params->cipher_xform;
6430 ut_params->auth_xform.auth.algo = reference->auth_algo;
6431 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
6432 ut_params->auth_xform.auth.key.data = auth_key;
6433 ut_params->auth_xform.auth.digest_length = reference->digest.len;
6434 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
6436 /* Setup Cipher Parameters */
6437 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6438 ut_params->cipher_xform.next = NULL;
6439 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
6440 ut_params->cipher_xform.cipher.op = cipher_op;
6441 ut_params->cipher_xform.cipher.key.data = cipher_key;
6442 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
6444 /* Create Crypto session*/
6445 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
6446 &ut_params->auth_xform);
6448 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6454 create_auth_operation(struct crypto_testsuite_params *ts_params,
6455 struct crypto_unittest_params *ut_params,
6456 const struct test_crypto_vector *reference,
6457 unsigned int auth_generate)
6459 /* Generate Crypto op data structure */
6460 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6461 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6462 TEST_ASSERT_NOT_NULL(ut_params->op,
6463 "Failed to allocate pktmbuf offload");
6465 /* Set crypto operation data parameters */
6466 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6468 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6470 /* set crypto operation source mbuf */
6471 sym_op->m_src = ut_params->ibuf;
6474 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6475 ut_params->ibuf, reference->digest.len);
6477 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6478 "no room to append auth tag");
6480 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6481 ut_params->ibuf, reference->plaintext.len);
6482 sym_op->auth.digest.length = reference->digest.len;
6485 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6487 memcpy(sym_op->auth.digest.data,
6488 reference->digest.data,
6489 reference->digest.len);
6491 TEST_HEXDUMP(stdout, "digest:",
6492 sym_op->auth.digest.data,
6493 sym_op->auth.digest.length);
6495 sym_op->auth.data.length = reference->plaintext.len;
6496 sym_op->auth.data.offset = 0;
6502 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
6503 struct crypto_unittest_params *ut_params,
6504 const struct test_crypto_vector *reference,
6505 unsigned int auth_generate)
6507 /* Generate Crypto op data structure */
6508 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6509 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6510 TEST_ASSERT_NOT_NULL(ut_params->op,
6511 "Failed to allocate pktmbuf offload");
6513 /* Set crypto operation data parameters */
6514 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6516 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6518 /* set crypto operation source mbuf */
6519 sym_op->m_src = ut_params->ibuf;
6522 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6523 reference->aad.len);
6524 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
6525 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
6527 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
6529 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6530 sym_op->auth.aad.length = reference->aad.len;
6533 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6534 ut_params->ibuf, reference->digest.len);
6536 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6537 "no room to append auth tag");
6539 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6540 ut_params->ibuf, reference->ciphertext.len);
6541 sym_op->auth.digest.length = reference->digest.len;
6544 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6546 memcpy(sym_op->auth.digest.data,
6547 reference->digest.data,
6548 reference->digest.len);
6550 TEST_HEXDUMP(stdout, "digest:",
6551 sym_op->auth.digest.data,
6552 sym_op->auth.digest.length);
6554 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6555 ut_params->ibuf, reference->iv.len);
6556 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6558 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6559 sym_op->cipher.iv.length = reference->iv.len;
6561 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6563 sym_op->cipher.data.length = 0;
6564 sym_op->cipher.data.offset = 0;
6566 sym_op->auth.data.length = 0;
6567 sym_op->auth.data.offset = 0;
6573 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
6574 struct crypto_unittest_params *ut_params,
6575 const struct test_crypto_vector *reference,
6576 unsigned int auth_generate)
6578 /* Generate Crypto op data structure */
6579 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6580 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6581 TEST_ASSERT_NOT_NULL(ut_params->op,
6582 "Failed to allocate pktmbuf offload");
6584 /* Set crypto operation data parameters */
6585 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6587 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6589 /* set crypto operation source mbuf */
6590 sym_op->m_src = ut_params->ibuf;
6593 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6594 ut_params->ibuf, reference->digest.len);
6596 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6597 "no room to append auth tag");
6599 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
6600 ut_params->ibuf, reference->ciphertext.len);
6601 sym_op->auth.digest.length = reference->digest.len;
6604 memset(sym_op->auth.digest.data, 0, reference->digest.len);
6606 memcpy(sym_op->auth.digest.data,
6607 reference->digest.data,
6608 reference->digest.len);
6610 TEST_HEXDUMP(stdout, "digest:",
6611 sym_op->auth.digest.data,
6612 sym_op->auth.digest.length);
6614 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6615 ut_params->ibuf, reference->iv.len);
6616 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
6618 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6619 sym_op->cipher.iv.length = reference->iv.len;
6621 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
6623 sym_op->cipher.data.length = reference->ciphertext.len;
6624 sym_op->cipher.data.offset = reference->iv.len;
6626 sym_op->auth.data.length = reference->ciphertext.len;
6627 sym_op->auth.data.offset = reference->iv.len;
6633 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6634 struct crypto_unittest_params *ut_params,
6635 const struct test_crypto_vector *reference)
6637 return create_auth_operation(ts_params, ut_params, reference, 0);
6641 create_auth_verify_GMAC_operation(
6642 struct crypto_testsuite_params *ts_params,
6643 struct crypto_unittest_params *ut_params,
6644 const struct test_crypto_vector *reference)
6646 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
6650 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
6651 struct crypto_unittest_params *ut_params,
6652 const struct test_crypto_vector *reference)
6654 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
6658 test_authentication_verify_fail_when_data_corruption(
6659 struct crypto_testsuite_params *ts_params,
6660 struct crypto_unittest_params *ut_params,
6661 const struct test_crypto_vector *reference,
6662 unsigned int data_corrupted)
6668 /* Create session */
6669 retval = create_auth_session(ut_params,
6670 ts_params->valid_devs[0],
6672 RTE_CRYPTO_AUTH_OP_VERIFY);
6676 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6677 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6678 "Failed to allocate input buffer in mempool");
6680 /* clear mbuf payload */
6681 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6682 rte_pktmbuf_tailroom(ut_params->ibuf));
6684 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6685 reference->plaintext.len);
6686 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6687 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
6689 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
6691 /* Create operation */
6692 retval = create_auth_verify_operation(ts_params, ut_params, reference);
6698 data_corruption(plaintext);
6700 tag_corruption(plaintext, reference->plaintext.len);
6702 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6704 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6705 TEST_ASSERT_EQUAL(ut_params->op->status,
6706 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6707 "authentication not failed");
6709 ut_params->obuf = ut_params->op->sym->m_src;
6710 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6716 test_authentication_verify_GMAC_fail_when_corruption(
6717 struct crypto_testsuite_params *ts_params,
6718 struct crypto_unittest_params *ut_params,
6719 const struct test_crypto_vector *reference,
6720 unsigned int data_corrupted)
6724 /* Create session */
6725 retval = create_auth_cipher_session(ut_params,
6726 ts_params->valid_devs[0],
6728 RTE_CRYPTO_AUTH_OP_VERIFY,
6729 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6733 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6734 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6735 "Failed to allocate input buffer in mempool");
6737 /* clear mbuf payload */
6738 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6739 rte_pktmbuf_tailroom(ut_params->ibuf));
6741 /* Create operation */
6742 retval = create_auth_verify_GMAC_operation(ts_params,
6750 data_corruption(ut_params->op->sym->auth.aad.data);
6752 tag_corruption(ut_params->op->sym->auth.aad.data,
6753 reference->aad.len);
6755 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6757 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6758 TEST_ASSERT_EQUAL(ut_params->op->status,
6759 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6760 "authentication not failed");
6762 ut_params->obuf = ut_params->op->sym->m_src;
6763 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6769 test_authenticated_decryption_fail_when_corruption(
6770 struct crypto_testsuite_params *ts_params,
6771 struct crypto_unittest_params *ut_params,
6772 const struct test_crypto_vector *reference,
6773 unsigned int data_corrupted)
6777 uint8_t *ciphertext;
6779 /* Create session */
6780 retval = create_auth_cipher_session(ut_params,
6781 ts_params->valid_devs[0],
6783 RTE_CRYPTO_AUTH_OP_VERIFY,
6784 RTE_CRYPTO_CIPHER_OP_DECRYPT);
6788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6789 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6790 "Failed to allocate input buffer in mempool");
6792 /* clear mbuf payload */
6793 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6794 rte_pktmbuf_tailroom(ut_params->ibuf));
6796 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6797 reference->ciphertext.len);
6798 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
6799 memcpy(ciphertext, reference->ciphertext.data,
6800 reference->ciphertext.len);
6802 /* Create operation */
6803 retval = create_cipher_auth_verify_operation(ts_params,
6811 data_corruption(ciphertext);
6813 tag_corruption(ciphertext, reference->ciphertext.len);
6815 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6818 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6819 TEST_ASSERT_EQUAL(ut_params->op->status,
6820 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
6821 "authentication not failed");
6823 ut_params->obuf = ut_params->op->sym->m_src;
6824 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
6830 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
6831 const struct gcm_test_data *tdata,
6832 void *digest_mem, uint64_t digest_phys)
6834 struct crypto_testsuite_params *ts_params = &testsuite_params;
6835 struct crypto_unittest_params *ut_params = &unittest_params;
6837 const unsigned int auth_tag_len = tdata->auth_tag.len;
6838 const unsigned int iv_len = tdata->iv.len;
6839 const unsigned int aad_len = tdata->aad.len;
6841 unsigned int iv_pad_len = 0;
6843 /* Generate Crypto op data structure */
6844 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6845 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6846 TEST_ASSERT_NOT_NULL(ut_params->op,
6847 "Failed to allocate symmetric crypto operation struct");
6849 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6851 sym_op->auth.digest.data = digest_mem;
6853 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6854 "no room to append digest");
6856 sym_op->auth.digest.phys_addr = digest_phys;
6857 sym_op->auth.digest.length = auth_tag_len;
6859 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
6860 rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
6862 TEST_HEXDUMP(stdout, "digest:",
6863 sym_op->auth.digest.data,
6864 sym_op->auth.digest.length);
6867 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
6869 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
6870 ut_params->ibuf, iv_pad_len);
6872 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
6873 "no room to prepend iv");
6875 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
6876 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
6877 sym_op->cipher.iv.length = iv_len;
6879 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
6881 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
6882 ut_params->ibuf, aad_len);
6883 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
6884 "no room to prepend aad");
6885 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
6887 sym_op->auth.aad.length = aad_len;
6889 memset(sym_op->auth.aad.data, 0, aad_len);
6890 rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
6892 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6893 TEST_HEXDUMP(stdout, "aad:",
6894 sym_op->auth.aad.data, aad_len);
6896 sym_op->cipher.data.length = tdata->plaintext.len;
6897 sym_op->cipher.data.offset = aad_len + iv_pad_len;
6899 sym_op->auth.data.offset = aad_len + iv_pad_len;
6900 sym_op->auth.data.length = tdata->plaintext.len;
6905 #define SGL_MAX_NO 16
6908 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
6909 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
6911 struct crypto_testsuite_params *ts_params = &testsuite_params;
6912 struct crypto_unittest_params *ut_params = &unittest_params;
6913 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
6916 int to_trn_tbl[SGL_MAX_NO];
6918 unsigned int trn_data = 0;
6919 uint8_t *plaintext, *ciphertext, *auth_tag;
6921 if (fragsz > tdata->plaintext.len)
6922 fragsz = tdata->plaintext.len;
6924 uint16_t plaintext_len = fragsz;
6925 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
6927 if (fragsz_oop > tdata->plaintext.len)
6928 frag_size_oop = tdata->plaintext.len;
6931 void *digest_mem = NULL;
6933 uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
6936 if (tdata->plaintext.len % fragsz != 0) {
6937 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
6940 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
6945 * For out-op-place we need to alloc another mbuf
6948 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6949 rte_pktmbuf_append(ut_params->obuf,
6950 frag_size_oop + prepend_len);
6951 buf_oop = ut_params->obuf;
6954 /* Create GCM session */
6955 retval = create_gcm_session(ts_params->valid_devs[0],
6956 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6957 tdata->key.data, tdata->key.len,
6958 tdata->aad.len, tdata->auth_tag.len,
6959 RTE_CRYPTO_AUTH_OP_GENERATE);
6963 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6965 /* clear mbuf payload */
6966 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6967 rte_pktmbuf_tailroom(ut_params->ibuf));
6969 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6972 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6974 trn_data += plaintext_len;
6976 buf = ut_params->ibuf;
6979 * Loop until no more fragments
6982 while (trn_data < tdata->plaintext.len) {
6984 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
6985 (tdata->plaintext.len - trn_data) : fragsz;
6987 to_trn_tbl[ecx++] = to_trn;
6989 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6992 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
6993 rte_pktmbuf_tailroom(buf));
6996 if (oop && !fragsz_oop) {
6997 buf_last_oop = buf_oop->next =
6998 rte_pktmbuf_alloc(ts_params->mbuf_pool);
6999 buf_oop = buf_oop->next;
7000 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7001 0, rte_pktmbuf_tailroom(buf_oop));
7002 rte_pktmbuf_append(buf_oop, to_trn);
7005 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7008 memcpy(plaintext, tdata->plaintext.data + trn_data,
7011 if (trn_data == tdata->plaintext.len) {
7014 digest_mem = rte_pktmbuf_append(buf_oop,
7015 tdata->auth_tag.len);
7017 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7018 tdata->auth_tag.len);
7022 uint64_t digest_phys = 0;
7024 ut_params->ibuf->nb_segs = segs;
7027 if (fragsz_oop && oop) {
7031 if (frag_size_oop == tdata->plaintext.len) {
7032 digest_mem = rte_pktmbuf_append(ut_params->obuf,
7033 tdata->auth_tag.len);
7035 digest_phys = rte_pktmbuf_mtophys_offset(
7037 tdata->plaintext.len + prepend_len);
7040 trn_data = frag_size_oop;
7041 while (trn_data < tdata->plaintext.len) {
7044 (tdata->plaintext.len - trn_data <
7046 (tdata->plaintext.len - trn_data) :
7049 to_trn_tbl[ecx++] = to_trn;
7051 buf_last_oop = buf_oop->next =
7052 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7053 buf_oop = buf_oop->next;
7054 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7055 0, rte_pktmbuf_tailroom(buf_oop));
7056 rte_pktmbuf_append(buf_oop, to_trn);
7060 if (trn_data == tdata->plaintext.len) {
7061 digest_mem = rte_pktmbuf_append(buf_oop,
7062 tdata->auth_tag.len);
7066 ut_params->obuf->nb_segs = segs;
7070 * Place digest at the end of the last buffer
7073 digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
7074 if (oop && buf_last_oop)
7075 digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
7077 if (!digest_mem && !oop) {
7078 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7079 + tdata->auth_tag.len);
7080 digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
7081 tdata->plaintext.len);
7084 /* Create GCM opertaion */
7085 retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7086 tdata, digest_mem, digest_phys);
7091 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7093 ut_params->op->sym->m_src = ut_params->ibuf;
7095 ut_params->op->sym->m_dst = ut_params->obuf;
7097 /* Process crypto operation */
7098 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7099 ut_params->op), "failed to process sym crypto op");
7101 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7102 "crypto op processing failed");
7105 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7106 uint8_t *, prepend_len);
7108 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7109 uint8_t *, prepend_len);
7113 fragsz = fragsz_oop;
7115 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7117 tdata->ciphertext.data,
7119 "GCM Ciphertext data not as expected");
7121 buf = ut_params->op->sym->m_src->next;
7123 buf = ut_params->op->sym->m_dst->next;
7125 unsigned int off = fragsz;
7129 ciphertext = rte_pktmbuf_mtod(buf,
7132 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7134 tdata->ciphertext.data + off,
7136 "GCM Ciphertext data not as expected");
7138 off += to_trn_tbl[ecx++];
7142 auth_tag = digest_mem;
7143 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7145 tdata->auth_tag.data,
7146 tdata->auth_tag.len,
7147 "GCM Generated auth tag not as expected");
7153 #define OUT_OF_PLACE 1
7156 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
7158 return test_AES_GCM_authenticated_encryption_SGL(
7159 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
7163 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
7165 return test_AES_GCM_authenticated_encryption_SGL(
7166 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
7170 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
7172 return test_AES_GCM_authenticated_encryption_SGL(
7173 &gcm_test_case_8, OUT_OF_PLACE, 400,
7174 gcm_test_case_8.plaintext.len);
7178 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
7181 return test_AES_GCM_authenticated_encryption_SGL(
7182 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
7186 test_authentication_verify_fail_when_data_corrupted(
7187 struct crypto_testsuite_params *ts_params,
7188 struct crypto_unittest_params *ut_params,
7189 const struct test_crypto_vector *reference)
7191 return test_authentication_verify_fail_when_data_corruption(
7192 ts_params, ut_params, reference, 1);
7196 test_authentication_verify_fail_when_tag_corrupted(
7197 struct crypto_testsuite_params *ts_params,
7198 struct crypto_unittest_params *ut_params,
7199 const struct test_crypto_vector *reference)
7201 return test_authentication_verify_fail_when_data_corruption(
7202 ts_params, ut_params, reference, 0);
7206 test_authentication_verify_GMAC_fail_when_data_corrupted(
7207 struct crypto_testsuite_params *ts_params,
7208 struct crypto_unittest_params *ut_params,
7209 const struct test_crypto_vector *reference)
7211 return test_authentication_verify_GMAC_fail_when_corruption(
7212 ts_params, ut_params, reference, 1);
7216 test_authentication_verify_GMAC_fail_when_tag_corrupted(
7217 struct crypto_testsuite_params *ts_params,
7218 struct crypto_unittest_params *ut_params,
7219 const struct test_crypto_vector *reference)
7221 return test_authentication_verify_GMAC_fail_when_corruption(
7222 ts_params, ut_params, reference, 0);
7226 test_authenticated_decryption_fail_when_data_corrupted(
7227 struct crypto_testsuite_params *ts_params,
7228 struct crypto_unittest_params *ut_params,
7229 const struct test_crypto_vector *reference)
7231 return test_authenticated_decryption_fail_when_corruption(
7232 ts_params, ut_params, reference, 1);
7236 test_authenticated_decryption_fail_when_tag_corrupted(
7237 struct crypto_testsuite_params *ts_params,
7238 struct crypto_unittest_params *ut_params,
7239 const struct test_crypto_vector *reference)
7241 return test_authenticated_decryption_fail_when_corruption(
7242 ts_params, ut_params, reference, 0);
7246 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
7248 return test_authentication_verify_fail_when_data_corrupted(
7249 &testsuite_params, &unittest_params,
7250 &hmac_sha1_test_crypto_vector);
7254 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
7256 return test_authentication_verify_fail_when_tag_corrupted(
7257 &testsuite_params, &unittest_params,
7258 &hmac_sha1_test_crypto_vector);
7262 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
7264 return test_authentication_verify_GMAC_fail_when_data_corrupted(
7265 &testsuite_params, &unittest_params,
7266 &aes128_gmac_test_vector);
7270 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
7272 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
7273 &testsuite_params, &unittest_params,
7274 &aes128_gmac_test_vector);
7278 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
7280 return test_authenticated_decryption_fail_when_data_corrupted(
7283 &aes128cbc_hmac_sha1_test_vector);
7287 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
7289 return test_authenticated_decryption_fail_when_tag_corrupted(
7292 &aes128cbc_hmac_sha1_test_vector);
7295 static struct unit_test_suite cryptodev_qat_testsuite = {
7296 .suite_name = "Crypto QAT Unit Test Suite",
7297 .setup = testsuite_setup,
7298 .teardown = testsuite_teardown,
7299 .unit_test_cases = {
7300 TEST_CASE_ST(ut_setup, ut_teardown,
7301 test_device_configure_invalid_dev_id),
7302 TEST_CASE_ST(ut_setup, ut_teardown,
7303 test_device_configure_invalid_queue_pair_ids),
7304 TEST_CASE_ST(ut_setup, ut_teardown,
7305 test_queue_pair_descriptor_setup),
7306 TEST_CASE_ST(ut_setup, ut_teardown,
7307 test_multi_session),
7309 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
7310 TEST_CASE_ST(ut_setup, ut_teardown,
7311 test_AES_cipheronly_qat_all),
7312 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
7313 TEST_CASE_ST(ut_setup, ut_teardown,
7314 test_3DES_cipheronly_qat_all),
7315 TEST_CASE_ST(ut_setup, ut_teardown,
7316 test_DES_cipheronly_qat_all),
7317 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
7319 /** AES GCM Authenticated Encryption */
7320 TEST_CASE_ST(ut_setup, ut_teardown,
7321 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
7322 TEST_CASE_ST(ut_setup, ut_teardown,
7323 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
7324 TEST_CASE_ST(ut_setup, ut_teardown,
7325 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
7326 TEST_CASE_ST(ut_setup, ut_teardown,
7327 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7328 TEST_CASE_ST(ut_setup, ut_teardown,
7329 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7330 TEST_CASE_ST(ut_setup, ut_teardown,
7331 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7332 TEST_CASE_ST(ut_setup, ut_teardown,
7333 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7334 TEST_CASE_ST(ut_setup, ut_teardown,
7335 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7336 TEST_CASE_ST(ut_setup, ut_teardown,
7337 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7338 TEST_CASE_ST(ut_setup, ut_teardown,
7339 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7341 /** AES GCM Authenticated Decryption */
7342 TEST_CASE_ST(ut_setup, ut_teardown,
7343 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7344 TEST_CASE_ST(ut_setup, ut_teardown,
7345 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7346 TEST_CASE_ST(ut_setup, ut_teardown,
7347 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7348 TEST_CASE_ST(ut_setup, ut_teardown,
7349 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7350 TEST_CASE_ST(ut_setup, ut_teardown,
7351 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7352 TEST_CASE_ST(ut_setup, ut_teardown,
7353 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7354 TEST_CASE_ST(ut_setup, ut_teardown,
7355 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7357 /** AES GMAC Authentication */
7358 TEST_CASE_ST(ut_setup, ut_teardown,
7359 test_AES_GMAC_authentication_test_case_1),
7360 TEST_CASE_ST(ut_setup, ut_teardown,
7361 test_AES_GMAC_authentication_verify_test_case_1),
7362 TEST_CASE_ST(ut_setup, ut_teardown,
7363 test_AES_GMAC_authentication_test_case_2),
7364 TEST_CASE_ST(ut_setup, ut_teardown,
7365 test_AES_GMAC_authentication_verify_test_case_2),
7366 TEST_CASE_ST(ut_setup, ut_teardown,
7367 test_AES_GMAC_authentication_test_case_3),
7368 TEST_CASE_ST(ut_setup, ut_teardown,
7369 test_AES_GMAC_authentication_verify_test_case_3),
7371 /** SNOW 3G encrypt only (UEA2) */
7372 TEST_CASE_ST(ut_setup, ut_teardown,
7373 test_snow3g_encryption_test_case_1),
7374 TEST_CASE_ST(ut_setup, ut_teardown,
7375 test_snow3g_encryption_test_case_2),
7376 TEST_CASE_ST(ut_setup, ut_teardown,
7377 test_snow3g_encryption_test_case_3),
7378 TEST_CASE_ST(ut_setup, ut_teardown,
7379 test_snow3g_encryption_test_case_4),
7380 TEST_CASE_ST(ut_setup, ut_teardown,
7381 test_snow3g_encryption_test_case_5),
7383 TEST_CASE_ST(ut_setup, ut_teardown,
7384 test_snow3g_encryption_test_case_1_oop),
7385 TEST_CASE_ST(ut_setup, ut_teardown,
7386 test_snow3g_decryption_test_case_1_oop),
7388 /** SNOW 3G decrypt only (UEA2) */
7389 TEST_CASE_ST(ut_setup, ut_teardown,
7390 test_snow3g_decryption_test_case_1),
7391 TEST_CASE_ST(ut_setup, ut_teardown,
7392 test_snow3g_decryption_test_case_2),
7393 TEST_CASE_ST(ut_setup, ut_teardown,
7394 test_snow3g_decryption_test_case_3),
7395 TEST_CASE_ST(ut_setup, ut_teardown,
7396 test_snow3g_decryption_test_case_4),
7397 TEST_CASE_ST(ut_setup, ut_teardown,
7398 test_snow3g_decryption_test_case_5),
7399 TEST_CASE_ST(ut_setup, ut_teardown,
7400 test_snow3g_hash_generate_test_case_1),
7401 TEST_CASE_ST(ut_setup, ut_teardown,
7402 test_snow3g_hash_generate_test_case_2),
7403 TEST_CASE_ST(ut_setup, ut_teardown,
7404 test_snow3g_hash_generate_test_case_3),
7405 TEST_CASE_ST(ut_setup, ut_teardown,
7406 test_snow3g_hash_verify_test_case_1),
7407 TEST_CASE_ST(ut_setup, ut_teardown,
7408 test_snow3g_hash_verify_test_case_2),
7409 TEST_CASE_ST(ut_setup, ut_teardown,
7410 test_snow3g_hash_verify_test_case_3),
7411 TEST_CASE_ST(ut_setup, ut_teardown,
7412 test_snow3g_cipher_auth_test_case_1),
7413 TEST_CASE_ST(ut_setup, ut_teardown,
7414 test_snow3g_auth_cipher_test_case_1),
7416 /** HMAC_MD5 Authentication */
7417 TEST_CASE_ST(ut_setup, ut_teardown,
7418 test_MD5_HMAC_generate_case_1),
7419 TEST_CASE_ST(ut_setup, ut_teardown,
7420 test_MD5_HMAC_verify_case_1),
7421 TEST_CASE_ST(ut_setup, ut_teardown,
7422 test_MD5_HMAC_generate_case_2),
7423 TEST_CASE_ST(ut_setup, ut_teardown,
7424 test_MD5_HMAC_verify_case_2),
7427 TEST_CASE_ST(ut_setup, ut_teardown,
7428 test_null_auth_only_operation),
7429 TEST_CASE_ST(ut_setup, ut_teardown,
7430 test_null_cipher_only_operation),
7431 TEST_CASE_ST(ut_setup, ut_teardown,
7432 test_null_cipher_auth_operation),
7433 TEST_CASE_ST(ut_setup, ut_teardown,
7434 test_null_auth_cipher_operation),
7436 TEST_CASE_ST(ut_setup, ut_teardown,
7437 test_kasumi_hash_generate_test_case_6),
7440 TEST_CASE_ST(ut_setup, ut_teardown,
7441 test_kasumi_encryption_test_case_1),
7442 TEST_CASE_ST(ut_setup, ut_teardown,
7443 test_kasumi_encryption_test_case_3),
7444 TEST_CASE_ST(ut_setup, ut_teardown,
7445 test_kasumi_auth_cipher_test_case_1),
7446 TEST_CASE_ST(ut_setup, ut_teardown,
7447 test_kasumi_cipher_auth_test_case_1),
7449 /** Negative tests */
7450 TEST_CASE_ST(ut_setup, ut_teardown,
7451 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7452 TEST_CASE_ST(ut_setup, ut_teardown,
7453 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7454 TEST_CASE_ST(ut_setup, ut_teardown,
7455 authentication_verify_AES128_GMAC_fail_data_corrupt),
7456 TEST_CASE_ST(ut_setup, ut_teardown,
7457 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7458 TEST_CASE_ST(ut_setup, ut_teardown,
7459 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7460 TEST_CASE_ST(ut_setup, ut_teardown,
7461 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7463 TEST_CASES_END() /**< NULL terminate unit test array */
7467 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
7468 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
7469 .setup = testsuite_setup,
7470 .teardown = testsuite_teardown,
7471 .unit_test_cases = {
7472 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
7473 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
7474 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
7476 TEST_CASES_END() /**< NULL terminate unit test array */
7480 static struct unit_test_suite cryptodev_openssl_testsuite = {
7481 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
7482 .setup = testsuite_setup,
7483 .teardown = testsuite_teardown,
7484 .unit_test_cases = {
7485 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
7486 TEST_CASE_ST(ut_setup, ut_teardown,
7487 test_multi_session_random_usage),
7488 TEST_CASE_ST(ut_setup, ut_teardown,
7489 test_AES_chain_openssl_all),
7490 TEST_CASE_ST(ut_setup, ut_teardown,
7491 test_AES_cipheronly_openssl_all),
7492 TEST_CASE_ST(ut_setup, ut_teardown,
7493 test_3DES_chain_openssl_all),
7494 TEST_CASE_ST(ut_setup, ut_teardown,
7495 test_3DES_cipheronly_openssl_all),
7496 TEST_CASE_ST(ut_setup, ut_teardown,
7497 test_authonly_openssl_all),
7499 /** AES GCM Authenticated Encryption */
7500 TEST_CASE_ST(ut_setup, ut_teardown,
7501 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7502 TEST_CASE_ST(ut_setup, ut_teardown,
7503 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7504 TEST_CASE_ST(ut_setup, ut_teardown,
7505 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7506 TEST_CASE_ST(ut_setup, ut_teardown,
7507 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7508 TEST_CASE_ST(ut_setup, ut_teardown,
7509 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7510 TEST_CASE_ST(ut_setup, ut_teardown,
7511 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7512 TEST_CASE_ST(ut_setup, ut_teardown,
7513 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7515 /** AES GCM Authenticated Decryption */
7516 TEST_CASE_ST(ut_setup, ut_teardown,
7517 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7518 TEST_CASE_ST(ut_setup, ut_teardown,
7519 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7520 TEST_CASE_ST(ut_setup, ut_teardown,
7521 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7522 TEST_CASE_ST(ut_setup, ut_teardown,
7523 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7524 TEST_CASE_ST(ut_setup, ut_teardown,
7525 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7526 TEST_CASE_ST(ut_setup, ut_teardown,
7527 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7528 TEST_CASE_ST(ut_setup, ut_teardown,
7529 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7531 /** AES GMAC Authentication */
7532 TEST_CASE_ST(ut_setup, ut_teardown,
7533 test_AES_GMAC_authentication_test_case_1),
7534 TEST_CASE_ST(ut_setup, ut_teardown,
7535 test_AES_GMAC_authentication_verify_test_case_1),
7536 TEST_CASE_ST(ut_setup, ut_teardown,
7537 test_AES_GMAC_authentication_test_case_2),
7538 TEST_CASE_ST(ut_setup, ut_teardown,
7539 test_AES_GMAC_authentication_verify_test_case_2),
7540 TEST_CASE_ST(ut_setup, ut_teardown,
7541 test_AES_GMAC_authentication_test_case_3),
7542 TEST_CASE_ST(ut_setup, ut_teardown,
7543 test_AES_GMAC_authentication_verify_test_case_3),
7544 TEST_CASE_ST(ut_setup, ut_teardown,
7545 test_AES_GMAC_authentication_test_case_4),
7546 TEST_CASE_ST(ut_setup, ut_teardown,
7547 test_AES_GMAC_authentication_verify_test_case_4),
7549 /** Scatter-Gather */
7550 TEST_CASE_ST(ut_setup, ut_teardown,
7551 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7553 /** Negative tests */
7554 TEST_CASE_ST(ut_setup, ut_teardown,
7555 authentication_verify_HMAC_SHA1_fail_data_corrupt),
7556 TEST_CASE_ST(ut_setup, ut_teardown,
7557 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
7558 TEST_CASE_ST(ut_setup, ut_teardown,
7559 authentication_verify_AES128_GMAC_fail_data_corrupt),
7560 TEST_CASE_ST(ut_setup, ut_teardown,
7561 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7562 TEST_CASE_ST(ut_setup, ut_teardown,
7563 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7564 TEST_CASE_ST(ut_setup, ut_teardown,
7565 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7567 TEST_CASES_END() /**< NULL terminate unit test array */
7571 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
7572 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
7573 .setup = testsuite_setup,
7574 .teardown = testsuite_teardown,
7575 .unit_test_cases = {
7576 /** AES GCM Authenticated Encryption */
7577 TEST_CASE_ST(ut_setup, ut_teardown,
7578 test_mb_AES_GCM_authenticated_encryption_test_case_1),
7579 TEST_CASE_ST(ut_setup, ut_teardown,
7580 test_mb_AES_GCM_authenticated_encryption_test_case_2),
7581 TEST_CASE_ST(ut_setup, ut_teardown,
7582 test_mb_AES_GCM_authenticated_encryption_test_case_3),
7583 TEST_CASE_ST(ut_setup, ut_teardown,
7584 test_mb_AES_GCM_authenticated_encryption_test_case_4),
7585 TEST_CASE_ST(ut_setup, ut_teardown,
7586 test_mb_AES_GCM_authenticated_encryption_test_case_5),
7587 TEST_CASE_ST(ut_setup, ut_teardown,
7588 test_mb_AES_GCM_authenticated_encryption_test_case_6),
7589 TEST_CASE_ST(ut_setup, ut_teardown,
7590 test_mb_AES_GCM_authenticated_encryption_test_case_7),
7592 /** AES GCM Authenticated Decryption */
7593 TEST_CASE_ST(ut_setup, ut_teardown,
7594 test_mb_AES_GCM_authenticated_decryption_test_case_1),
7595 TEST_CASE_ST(ut_setup, ut_teardown,
7596 test_mb_AES_GCM_authenticated_decryption_test_case_2),
7597 TEST_CASE_ST(ut_setup, ut_teardown,
7598 test_mb_AES_GCM_authenticated_decryption_test_case_3),
7599 TEST_CASE_ST(ut_setup, ut_teardown,
7600 test_mb_AES_GCM_authenticated_decryption_test_case_4),
7601 TEST_CASE_ST(ut_setup, ut_teardown,
7602 test_mb_AES_GCM_authenticated_decryption_test_case_5),
7603 TEST_CASE_ST(ut_setup, ut_teardown,
7604 test_mb_AES_GCM_authenticated_decryption_test_case_6),
7605 TEST_CASE_ST(ut_setup, ut_teardown,
7606 test_mb_AES_GCM_authenticated_decryption_test_case_7),
7608 /** AES GCM Authenticated Encryption 256 bits key */
7609 TEST_CASE_ST(ut_setup, ut_teardown,
7610 test_mb_AES_GCM_auth_encryption_test_case_256_1),
7611 TEST_CASE_ST(ut_setup, ut_teardown,
7612 test_mb_AES_GCM_auth_encryption_test_case_256_2),
7613 TEST_CASE_ST(ut_setup, ut_teardown,
7614 test_mb_AES_GCM_auth_encryption_test_case_256_3),
7615 TEST_CASE_ST(ut_setup, ut_teardown,
7616 test_mb_AES_GCM_auth_encryption_test_case_256_4),
7617 TEST_CASE_ST(ut_setup, ut_teardown,
7618 test_mb_AES_GCM_auth_encryption_test_case_256_5),
7619 TEST_CASE_ST(ut_setup, ut_teardown,
7620 test_mb_AES_GCM_auth_encryption_test_case_256_6),
7621 TEST_CASE_ST(ut_setup, ut_teardown,
7622 test_mb_AES_GCM_auth_encryption_test_case_256_7),
7624 /** AES GCM Authenticated Decryption 256 bits key */
7625 TEST_CASE_ST(ut_setup, ut_teardown,
7626 test_mb_AES_GCM_auth_decryption_test_case_256_1),
7627 TEST_CASE_ST(ut_setup, ut_teardown,
7628 test_mb_AES_GCM_auth_decryption_test_case_256_2),
7629 TEST_CASE_ST(ut_setup, ut_teardown,
7630 test_mb_AES_GCM_auth_decryption_test_case_256_3),
7631 TEST_CASE_ST(ut_setup, ut_teardown,
7632 test_mb_AES_GCM_auth_decryption_test_case_256_4),
7633 TEST_CASE_ST(ut_setup, ut_teardown,
7634 test_mb_AES_GCM_auth_decryption_test_case_256_5),
7635 TEST_CASE_ST(ut_setup, ut_teardown,
7636 test_mb_AES_GCM_auth_decryption_test_case_256_6),
7637 TEST_CASE_ST(ut_setup, ut_teardown,
7638 test_mb_AES_GCM_auth_decryption_test_case_256_7),
7640 /** AES GCM Authenticated Encryption big aad size */
7641 TEST_CASE_ST(ut_setup, ut_teardown,
7642 test_mb_AES_GCM_auth_encryption_test_case_aad_1),
7643 TEST_CASE_ST(ut_setup, ut_teardown,
7644 test_mb_AES_GCM_auth_encryption_test_case_aad_2),
7646 /** AES GCM Authenticated Decryption big aad size */
7647 TEST_CASE_ST(ut_setup, ut_teardown,
7648 test_mb_AES_GCM_auth_decryption_test_case_aad_1),
7649 TEST_CASE_ST(ut_setup, ut_teardown,
7650 test_mb_AES_GCM_auth_decryption_test_case_aad_2),
7652 /** AES GMAC Authentication */
7653 TEST_CASE_ST(ut_setup, ut_teardown,
7654 test_AES_GMAC_authentication_test_case_1),
7655 TEST_CASE_ST(ut_setup, ut_teardown,
7656 test_AES_GMAC_authentication_verify_test_case_1),
7657 TEST_CASE_ST(ut_setup, ut_teardown,
7658 test_AES_GMAC_authentication_test_case_3),
7659 TEST_CASE_ST(ut_setup, ut_teardown,
7660 test_AES_GMAC_authentication_verify_test_case_3),
7661 TEST_CASE_ST(ut_setup, ut_teardown,
7662 test_AES_GMAC_authentication_test_case_4),
7663 TEST_CASE_ST(ut_setup, ut_teardown,
7664 test_AES_GMAC_authentication_verify_test_case_4),
7666 /** Negative tests */
7667 TEST_CASE_ST(ut_setup, ut_teardown,
7668 authentication_verify_AES128_GMAC_fail_data_corrupt),
7669 TEST_CASE_ST(ut_setup, ut_teardown,
7670 authentication_verify_AES128_GMAC_fail_tag_corrupt),
7672 /** Out of place tests */
7673 TEST_CASE_ST(ut_setup, ut_teardown,
7674 test_mb_AES_GCM_authenticated_encryption_oop),
7675 TEST_CASE_ST(ut_setup, ut_teardown,
7676 test_mb_AES_GCM_authenticated_decryption_oop),
7678 /** Session-less tests */
7679 TEST_CASE_ST(ut_setup, ut_teardown,
7680 test_mb_AES_GCM_authenticated_encryption_sessionless),
7681 TEST_CASE_ST(ut_setup, ut_teardown,
7682 test_mb_AES_GCM_authenticated_decryption_sessionless),
7684 /** Scatter-Gather */
7685 TEST_CASE_ST(ut_setup, ut_teardown,
7686 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
7688 TEST_CASES_END() /**< NULL terminate unit test array */
7692 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
7693 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
7694 .setup = testsuite_setup,
7695 .teardown = testsuite_teardown,
7696 .unit_test_cases = {
7697 /** KASUMI encrypt only (UEA1) */
7698 TEST_CASE_ST(ut_setup, ut_teardown,
7699 test_kasumi_encryption_test_case_1),
7700 TEST_CASE_ST(ut_setup, ut_teardown,
7701 test_kasumi_encryption_test_case_1_sgl),
7702 TEST_CASE_ST(ut_setup, ut_teardown,
7703 test_kasumi_encryption_test_case_2),
7704 TEST_CASE_ST(ut_setup, ut_teardown,
7705 test_kasumi_encryption_test_case_3),
7706 TEST_CASE_ST(ut_setup, ut_teardown,
7707 test_kasumi_encryption_test_case_4),
7708 TEST_CASE_ST(ut_setup, ut_teardown,
7709 test_kasumi_encryption_test_case_5),
7710 /** KASUMI decrypt only (UEA1) */
7711 TEST_CASE_ST(ut_setup, ut_teardown,
7712 test_kasumi_decryption_test_case_1),
7713 TEST_CASE_ST(ut_setup, ut_teardown,
7714 test_kasumi_decryption_test_case_2),
7715 TEST_CASE_ST(ut_setup, ut_teardown,
7716 test_kasumi_decryption_test_case_3),
7717 TEST_CASE_ST(ut_setup, ut_teardown,
7718 test_kasumi_decryption_test_case_4),
7719 TEST_CASE_ST(ut_setup, ut_teardown,
7720 test_kasumi_decryption_test_case_5),
7722 TEST_CASE_ST(ut_setup, ut_teardown,
7723 test_kasumi_encryption_test_case_1_oop),
7724 TEST_CASE_ST(ut_setup, ut_teardown,
7725 test_kasumi_encryption_test_case_1_oop_sgl),
7728 TEST_CASE_ST(ut_setup, ut_teardown,
7729 test_kasumi_decryption_test_case_1_oop),
7731 /** KASUMI hash only (UIA1) */
7732 TEST_CASE_ST(ut_setup, ut_teardown,
7733 test_kasumi_hash_generate_test_case_1),
7734 TEST_CASE_ST(ut_setup, ut_teardown,
7735 test_kasumi_hash_generate_test_case_2),
7736 TEST_CASE_ST(ut_setup, ut_teardown,
7737 test_kasumi_hash_generate_test_case_3),
7738 TEST_CASE_ST(ut_setup, ut_teardown,
7739 test_kasumi_hash_generate_test_case_4),
7740 TEST_CASE_ST(ut_setup, ut_teardown,
7741 test_kasumi_hash_generate_test_case_5),
7742 TEST_CASE_ST(ut_setup, ut_teardown,
7743 test_kasumi_hash_generate_test_case_6),
7744 TEST_CASE_ST(ut_setup, ut_teardown,
7745 test_kasumi_hash_verify_test_case_1),
7746 TEST_CASE_ST(ut_setup, ut_teardown,
7747 test_kasumi_hash_verify_test_case_2),
7748 TEST_CASE_ST(ut_setup, ut_teardown,
7749 test_kasumi_hash_verify_test_case_3),
7750 TEST_CASE_ST(ut_setup, ut_teardown,
7751 test_kasumi_hash_verify_test_case_4),
7752 TEST_CASE_ST(ut_setup, ut_teardown,
7753 test_kasumi_hash_verify_test_case_5),
7754 TEST_CASE_ST(ut_setup, ut_teardown,
7755 test_kasumi_auth_cipher_test_case_1),
7756 TEST_CASE_ST(ut_setup, ut_teardown,
7757 test_kasumi_cipher_auth_test_case_1),
7758 TEST_CASES_END() /**< NULL terminate unit test array */
7761 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
7762 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
7763 .setup = testsuite_setup,
7764 .teardown = testsuite_teardown,
7765 .unit_test_cases = {
7766 /** SNOW 3G encrypt only (UEA2) */
7767 TEST_CASE_ST(ut_setup, ut_teardown,
7768 test_snow3g_encryption_test_case_1),
7769 TEST_CASE_ST(ut_setup, ut_teardown,
7770 test_snow3g_encryption_test_case_2),
7771 TEST_CASE_ST(ut_setup, ut_teardown,
7772 test_snow3g_encryption_test_case_3),
7773 TEST_CASE_ST(ut_setup, ut_teardown,
7774 test_snow3g_encryption_test_case_4),
7775 TEST_CASE_ST(ut_setup, ut_teardown,
7776 test_snow3g_encryption_test_case_5),
7778 TEST_CASE_ST(ut_setup, ut_teardown,
7779 test_snow3g_encryption_test_case_1_oop),
7780 TEST_CASE_ST(ut_setup, ut_teardown,
7781 test_snow3g_encryption_test_case_1_oop_sgl),
7782 TEST_CASE_ST(ut_setup, ut_teardown,
7783 test_snow3g_decryption_test_case_1_oop),
7785 TEST_CASE_ST(ut_setup, ut_teardown,
7786 test_snow3g_encryption_test_case_1_offset_oop),
7788 /** SNOW 3G decrypt only (UEA2) */
7789 TEST_CASE_ST(ut_setup, ut_teardown,
7790 test_snow3g_decryption_test_case_1),
7791 TEST_CASE_ST(ut_setup, ut_teardown,
7792 test_snow3g_decryption_test_case_2),
7793 TEST_CASE_ST(ut_setup, ut_teardown,
7794 test_snow3g_decryption_test_case_3),
7795 TEST_CASE_ST(ut_setup, ut_teardown,
7796 test_snow3g_decryption_test_case_4),
7797 TEST_CASE_ST(ut_setup, ut_teardown,
7798 test_snow3g_decryption_test_case_5),
7799 TEST_CASE_ST(ut_setup, ut_teardown,
7800 test_snow3g_hash_generate_test_case_1),
7801 TEST_CASE_ST(ut_setup, ut_teardown,
7802 test_snow3g_hash_generate_test_case_2),
7803 TEST_CASE_ST(ut_setup, ut_teardown,
7804 test_snow3g_hash_generate_test_case_3),
7805 /* Tests with buffers which length is not byte-aligned */
7806 TEST_CASE_ST(ut_setup, ut_teardown,
7807 test_snow3g_hash_generate_test_case_4),
7808 TEST_CASE_ST(ut_setup, ut_teardown,
7809 test_snow3g_hash_generate_test_case_5),
7810 TEST_CASE_ST(ut_setup, ut_teardown,
7811 test_snow3g_hash_generate_test_case_6),
7812 TEST_CASE_ST(ut_setup, ut_teardown,
7813 test_snow3g_hash_verify_test_case_1),
7814 TEST_CASE_ST(ut_setup, ut_teardown,
7815 test_snow3g_hash_verify_test_case_2),
7816 TEST_CASE_ST(ut_setup, ut_teardown,
7817 test_snow3g_hash_verify_test_case_3),
7818 /* Tests with buffers which length is not byte-aligned */
7819 TEST_CASE_ST(ut_setup, ut_teardown,
7820 test_snow3g_hash_verify_test_case_4),
7821 TEST_CASE_ST(ut_setup, ut_teardown,
7822 test_snow3g_hash_verify_test_case_5),
7823 TEST_CASE_ST(ut_setup, ut_teardown,
7824 test_snow3g_hash_verify_test_case_6),
7825 TEST_CASE_ST(ut_setup, ut_teardown,
7826 test_snow3g_cipher_auth_test_case_1),
7827 TEST_CASE_ST(ut_setup, ut_teardown,
7828 test_snow3g_auth_cipher_test_case_1),
7830 TEST_CASES_END() /**< NULL terminate unit test array */
7834 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
7835 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
7836 .setup = testsuite_setup,
7837 .teardown = testsuite_teardown,
7838 .unit_test_cases = {
7839 /** ZUC encrypt only (EEA3) */
7840 TEST_CASE_ST(ut_setup, ut_teardown,
7841 test_zuc_encryption_test_case_1),
7842 TEST_CASE_ST(ut_setup, ut_teardown,
7843 test_zuc_encryption_test_case_2),
7844 TEST_CASE_ST(ut_setup, ut_teardown,
7845 test_zuc_encryption_test_case_3),
7846 TEST_CASE_ST(ut_setup, ut_teardown,
7847 test_zuc_encryption_test_case_4),
7848 TEST_CASE_ST(ut_setup, ut_teardown,
7849 test_zuc_encryption_test_case_5),
7850 TEST_CASE_ST(ut_setup, ut_teardown,
7851 test_zuc_hash_generate_test_case_1),
7852 TEST_CASE_ST(ut_setup, ut_teardown,
7853 test_zuc_hash_generate_test_case_2),
7854 TEST_CASE_ST(ut_setup, ut_teardown,
7855 test_zuc_hash_generate_test_case_3),
7856 TEST_CASE_ST(ut_setup, ut_teardown,
7857 test_zuc_hash_generate_test_case_4),
7858 TEST_CASE_ST(ut_setup, ut_teardown,
7859 test_zuc_hash_generate_test_case_5),
7860 TEST_CASE_ST(ut_setup, ut_teardown,
7861 test_zuc_encryption_test_case_6_sgl),
7862 TEST_CASES_END() /**< NULL terminate unit test array */
7866 static struct unit_test_suite cryptodev_null_testsuite = {
7867 .suite_name = "Crypto Device NULL Unit Test Suite",
7868 .setup = testsuite_setup,
7869 .teardown = testsuite_teardown,
7870 .unit_test_cases = {
7871 TEST_CASE_ST(ut_setup, ut_teardown,
7872 test_null_auth_only_operation),
7873 TEST_CASE_ST(ut_setup, ut_teardown,
7874 test_null_cipher_only_operation),
7875 TEST_CASE_ST(ut_setup, ut_teardown,
7876 test_null_cipher_auth_operation),
7877 TEST_CASE_ST(ut_setup, ut_teardown,
7878 test_null_auth_cipher_operation),
7879 TEST_CASE_ST(ut_setup, ut_teardown,
7880 test_null_invalid_operation),
7881 TEST_CASE_ST(ut_setup, ut_teardown,
7882 test_null_burst_operation),
7884 TEST_CASES_END() /**< NULL terminate unit test array */
7888 static struct unit_test_suite cryptodev_armv8_testsuite = {
7889 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
7890 .setup = testsuite_setup,
7891 .teardown = testsuite_teardown,
7892 .unit_test_cases = {
7893 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
7895 /** Negative tests */
7896 TEST_CASE_ST(ut_setup, ut_teardown,
7897 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
7898 TEST_CASE_ST(ut_setup, ut_teardown,
7899 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
7901 TEST_CASES_END() /**< NULL terminate unit test array */
7906 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
7908 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
7909 return unit_test_suite_runner(&cryptodev_qat_testsuite);
7913 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
7915 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
7917 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
7921 test_cryptodev_openssl(void)
7923 gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
7925 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
7929 test_cryptodev_aesni_gcm(void)
7931 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
7933 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
7937 test_cryptodev_null(void)
7939 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
7941 return unit_test_suite_runner(&cryptodev_null_testsuite);
7945 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
7947 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
7949 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
7953 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
7955 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
7957 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
7961 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
7963 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
7965 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
7969 test_cryptodev_armv8(void)
7971 gbl_cryptodev_type = RTE_CRYPTODEV_ARMV8_PMD;
7973 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
7976 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
7977 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
7978 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
7979 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
7980 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
7981 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
7982 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
7983 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
7984 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);