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 *op_mpool;
64 struct rte_cryptodev_config conf;
65 struct rte_cryptodev_qp_conf qp_conf;
67 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
68 uint8_t valid_dev_count;
71 struct crypto_unittest_params {
72 struct rte_crypto_sym_xform cipher_xform;
73 struct rte_crypto_sym_xform auth_xform;
75 struct rte_cryptodev_sym_session *sess;
77 struct rte_crypto_op *op;
79 struct rte_mbuf *obuf, *ibuf;
84 #define ALIGN_POW2_ROUNDUP(num, align) \
85 (((num) + (align) - 1) & ~((align) - 1))
88 * Forward declarations.
91 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
92 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
96 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
97 struct crypto_unittest_params *ut_params,
98 struct crypto_testsuite_params *ts_param,
99 const uint8_t *cipher,
100 const uint8_t *digest,
103 static struct rte_mbuf *
104 setup_test_string(struct rte_mempool *mpool,
105 const char *string, size_t len, uint8_t blocksize)
107 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
108 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
110 memset(m->buf_addr, 0, m->buf_len);
112 char *dst = rte_pktmbuf_append(m, t_len);
119 rte_memcpy(dst, string, t_len);
121 memset(dst, 0, t_len);
127 /* Get number of bytes in X bits (rounding up) */
129 ceil_byte_length(uint32_t num_bits)
132 return ((num_bits >> 3) + 1);
134 return (num_bits >> 3);
137 static struct rte_crypto_op *
138 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
140 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
141 printf("Error sending packet for encryption");
147 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
153 static struct crypto_testsuite_params testsuite_params = { NULL };
154 static struct crypto_unittest_params unittest_params;
157 testsuite_setup(void)
159 struct crypto_testsuite_params *ts_params = &testsuite_params;
160 struct rte_cryptodev_info info;
161 unsigned i, nb_devs, dev_id;
165 memset(ts_params, 0, sizeof(*ts_params));
167 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
168 if (ts_params->mbuf_pool == NULL) {
169 /* Not already created so create */
170 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
172 NUM_MBUFS, MBUF_CACHE_SIZE, 0, UINT16_MAX,
174 if (ts_params->mbuf_pool == NULL) {
175 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
180 ts_params->op_mpool = rte_crypto_op_pool_create(
181 "MBUF_CRYPTO_SYM_OP_POOL",
182 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
183 NUM_MBUFS, MBUF_CACHE_SIZE,
185 sizeof(struct rte_crypto_sym_xform),
187 if (ts_params->op_mpool == NULL) {
188 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
192 /* Create 2 AESNI MB devices if required */
193 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
194 #ifndef RTE_LIBRTE_PMD_AESNI_MB
195 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
196 " enabled in config file to run this testsuite.\n");
199 nb_devs = rte_cryptodev_count_devtype(
200 RTE_CRYPTODEV_AESNI_MB_PMD);
202 for (i = nb_devs; i < 2; i++) {
203 ret = rte_eal_vdev_init(
204 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
206 TEST_ASSERT(ret == 0,
207 "Failed to create instance %u of"
209 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
214 /* Create 2 AESNI GCM devices if required */
215 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
216 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
217 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
218 " enabled in config file to run this testsuite.\n");
221 nb_devs = rte_cryptodev_count_devtype(
222 RTE_CRYPTODEV_AESNI_GCM_PMD);
224 for (i = nb_devs; i < 2; i++) {
225 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
226 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
227 "Failed to create instance %u of"
229 i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
234 /* Create 2 SNOW 3G devices if required */
235 if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
236 #ifndef RTE_LIBRTE_PMD_SNOW3G
237 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
238 " enabled in config file to run this testsuite.\n");
241 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
243 for (i = nb_devs; i < 2; i++) {
244 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
245 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
246 "Failed to create instance %u of"
248 i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
253 /* Create 2 KASUMI devices if required */
254 if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
255 #ifndef RTE_LIBRTE_PMD_KASUMI
256 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
257 " enabled in config file to run this testsuite.\n");
260 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
262 for (i = nb_devs; i < 2; i++) {
263 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
264 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
265 "Failed to create instance %u of"
267 i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
272 /* Create 2 ZUC devices if required */
273 if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
274 #ifndef RTE_LIBRTE_PMD_ZUC
275 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
276 " enabled in config file to run this testsuite.\n");
279 nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
281 for (i = nb_devs; i < 2; i++) {
282 TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
283 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
284 "Failed to create instance %u of"
286 i, RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
291 /* Create 2 NULL devices if required */
292 if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
293 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
294 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
295 " enabled in config file to run this testsuite.\n");
298 nb_devs = rte_cryptodev_count_devtype(
299 RTE_CRYPTODEV_NULL_PMD);
301 for (i = nb_devs; i < 2; i++) {
302 int dev_id = rte_eal_vdev_init(
303 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
305 TEST_ASSERT(dev_id >= 0,
306 "Failed to create instance %u of"
308 i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
313 /* Create 2 LIBCRYPTO devices if required */
314 if (gbl_cryptodev_type == RTE_CRYPTODEV_LIBCRYPTO_PMD) {
315 #ifndef RTE_LIBRTE_PMD_LIBCRYPTO
316 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_LIBCRYPTO must be"
317 " enabled in config file to run this testsuite.\n");
320 nb_devs = rte_cryptodev_count_devtype(
321 RTE_CRYPTODEV_LIBCRYPTO_PMD);
323 for (i = nb_devs; i < 2; i++) {
324 ret = rte_eal_vdev_init(
325 RTE_STR(CRYPTODEV_NAME_LIBCRYPTO_PMD),
328 TEST_ASSERT(ret == 0, "Failed to create "
329 "instance %u of pmd : %s", i,
330 RTE_STR(CRYPTODEV_NAME_LIBCRYPTO_PMD));
335 #ifndef RTE_LIBRTE_PMD_QAT
336 if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
337 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
338 "in config file to run this testsuite.\n");
343 nb_devs = rte_cryptodev_count();
345 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
349 /* Create list of valid crypto devs */
350 for (i = 0; i < nb_devs; i++) {
351 rte_cryptodev_info_get(i, &info);
352 if (info.dev_type == gbl_cryptodev_type)
353 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
356 if (ts_params->valid_dev_count < 1)
359 /* Set up all the qps on the first of the valid devices found */
361 dev_id = ts_params->valid_devs[0];
363 rte_cryptodev_info_get(dev_id, &info);
365 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
366 ts_params->conf.socket_id = SOCKET_ID_ANY;
367 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
369 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
371 "Failed to configure cryptodev %u with %u qps",
372 dev_id, ts_params->conf.nb_queue_pairs);
374 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
376 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
377 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
378 dev_id, qp_id, &ts_params->qp_conf,
379 rte_cryptodev_socket_id(dev_id)),
380 "Failed to setup queue pair %u on cryptodev %u",
388 testsuite_teardown(void)
390 struct crypto_testsuite_params *ts_params = &testsuite_params;
392 if (ts_params->mbuf_pool != NULL) {
393 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
394 rte_mempool_avail_count(ts_params->mbuf_pool));
397 if (ts_params->op_mpool != NULL) {
398 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
399 rte_mempool_avail_count(ts_params->op_mpool));
407 struct crypto_testsuite_params *ts_params = &testsuite_params;
408 struct crypto_unittest_params *ut_params = &unittest_params;
412 /* Clear unit test parameters before running test */
413 memset(ut_params, 0, sizeof(*ut_params));
415 /* Reconfigure device to default parameters */
416 ts_params->conf.nb_queue_pairs = DEFAULT_NUM_QPS_PER_QAT_DEVICE;
417 ts_params->conf.socket_id = SOCKET_ID_ANY;
418 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
420 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
422 "Failed to configure cryptodev %u",
423 ts_params->valid_devs[0]);
425 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
426 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
427 ts_params->valid_devs[0], qp_id,
429 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
430 "Failed to setup queue pair %u on cryptodev %u",
431 qp_id, ts_params->valid_devs[0]);
435 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
437 /* Start the device */
438 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
439 "Failed to start cryptodev %u",
440 ts_params->valid_devs[0]);
448 struct crypto_testsuite_params *ts_params = &testsuite_params;
449 struct crypto_unittest_params *ut_params = &unittest_params;
450 struct rte_cryptodev_stats stats;
452 /* free crypto session structure */
453 if (ut_params->sess) {
454 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
456 ut_params->sess = NULL;
459 /* free crypto operation structure */
461 rte_crypto_op_free(ut_params->op);
464 * free mbuf - both obuf and ibuf are usually the same,
465 * so check if they point at the same address is necessary,
466 * to avoid freeing the mbuf twice.
468 if (ut_params->obuf) {
469 rte_pktmbuf_free(ut_params->obuf);
470 if (ut_params->ibuf == ut_params->obuf)
474 if (ut_params->ibuf) {
475 rte_pktmbuf_free(ut_params->ibuf);
479 if (ts_params->mbuf_pool != NULL)
480 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
481 rte_mempool_avail_count(ts_params->mbuf_pool));
483 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
485 /* Stop the device */
486 rte_cryptodev_stop(ts_params->valid_devs[0]);
490 test_device_configure_invalid_dev_id(void)
492 struct crypto_testsuite_params *ts_params = &testsuite_params;
493 uint16_t dev_id, num_devs = 0;
495 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
496 "Need at least %d devices for test", 1);
498 /* valid dev_id values */
499 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
501 /* Stop the device in case it's started so it can be configured */
502 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
504 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
505 "Failed test for rte_cryptodev_configure: "
506 "invalid dev_num %u", dev_id);
508 /* invalid dev_id values */
511 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
512 "Failed test for rte_cryptodev_configure: "
513 "invalid dev_num %u", dev_id);
517 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
518 "Failed test for rte_cryptodev_configure:"
519 "invalid dev_num %u", dev_id);
525 test_device_configure_invalid_queue_pair_ids(void)
527 struct crypto_testsuite_params *ts_params = &testsuite_params;
529 /* Stop the device in case it's started so it can be configured */
530 rte_cryptodev_stop(ts_params->valid_devs[0]);
532 /* valid - one queue pairs */
533 ts_params->conf.nb_queue_pairs = 1;
535 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
537 "Failed to configure cryptodev: dev_id %u, qp_id %u",
538 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
541 /* valid - max value queue pairs */
542 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
544 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
546 "Failed to configure cryptodev: dev_id %u, qp_id %u",
547 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
550 /* invalid - zero queue pairs */
551 ts_params->conf.nb_queue_pairs = 0;
553 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
555 "Failed test for rte_cryptodev_configure, dev_id %u,"
557 ts_params->valid_devs[0],
558 ts_params->conf.nb_queue_pairs);
561 /* invalid - max value supported by field queue pairs */
562 ts_params->conf.nb_queue_pairs = UINT16_MAX;
564 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
566 "Failed test for rte_cryptodev_configure, dev_id %u,"
568 ts_params->valid_devs[0],
569 ts_params->conf.nb_queue_pairs);
572 /* invalid - max value + 1 queue pairs */
573 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
575 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
577 "Failed test for rte_cryptodev_configure, dev_id %u,"
579 ts_params->valid_devs[0],
580 ts_params->conf.nb_queue_pairs);
586 test_queue_pair_descriptor_setup(void)
588 struct crypto_testsuite_params *ts_params = &testsuite_params;
589 struct rte_cryptodev_info dev_info;
590 struct rte_cryptodev_qp_conf qp_conf = {
591 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
596 /* Stop the device in case it's started so it can be configured */
597 rte_cryptodev_stop(ts_params->valid_devs[0]);
600 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
602 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
604 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
605 &ts_params->conf), "Failed to configure cryptodev %u",
606 ts_params->valid_devs[0]);
610 * Test various ring sizes on this device. memzones can't be
611 * freed so are re-used if ring is released and re-created.
613 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
615 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
616 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
617 ts_params->valid_devs[0], qp_id, &qp_conf,
618 rte_cryptodev_socket_id(
619 ts_params->valid_devs[0])),
621 "rte_cryptodev_queue_pair_setup: num_inflights "
622 "%u on qp %u on cryptodev %u",
623 qp_conf.nb_descriptors, qp_id,
624 ts_params->valid_devs[0]);
627 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
629 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
630 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
631 ts_params->valid_devs[0], qp_id, &qp_conf,
632 rte_cryptodev_socket_id(
633 ts_params->valid_devs[0])),
635 " rte_cryptodev_queue_pair_setup: num_inflights"
636 " %u on qp %u on cryptodev %u",
637 qp_conf.nb_descriptors, qp_id,
638 ts_params->valid_devs[0]);
641 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
643 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
644 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
645 ts_params->valid_devs[0], qp_id, &qp_conf,
646 rte_cryptodev_socket_id(
647 ts_params->valid_devs[0])),
649 "rte_cryptodev_queue_pair_setup: num_inflights"
650 " %u on qp %u on cryptodev %u",
651 qp_conf.nb_descriptors, qp_id,
652 ts_params->valid_devs[0]);
655 /* invalid number of descriptors - max supported + 2 */
656 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
658 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
659 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
660 ts_params->valid_devs[0], qp_id, &qp_conf,
661 rte_cryptodev_socket_id(
662 ts_params->valid_devs[0])),
663 "Unexpectedly passed test for "
664 "rte_cryptodev_queue_pair_setup:"
665 "num_inflights %u on qp %u on cryptodev %u",
666 qp_conf.nb_descriptors, qp_id,
667 ts_params->valid_devs[0]);
670 /* invalid number of descriptors - max value of parameter */
671 qp_conf.nb_descriptors = UINT32_MAX-1;
673 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
674 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
675 ts_params->valid_devs[0], qp_id, &qp_conf,
676 rte_cryptodev_socket_id(
677 ts_params->valid_devs[0])),
678 "Unexpectedly passed test for "
679 "rte_cryptodev_queue_pair_setup:"
680 "num_inflights %u on qp %u on cryptodev %u",
681 qp_conf.nb_descriptors, qp_id,
682 ts_params->valid_devs[0]);
685 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
687 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
688 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
689 ts_params->valid_devs[0], qp_id, &qp_conf,
690 rte_cryptodev_socket_id(
691 ts_params->valid_devs[0])),
693 " rte_cryptodev_queue_pair_setup:"
694 "num_inflights %u on qp %u on cryptodev %u",
695 qp_conf.nb_descriptors, qp_id,
696 ts_params->valid_devs[0]);
699 /* invalid number of descriptors - max supported + 1 */
700 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
702 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
703 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
704 ts_params->valid_devs[0], qp_id, &qp_conf,
705 rte_cryptodev_socket_id(
706 ts_params->valid_devs[0])),
707 "Unexpectedly passed test for "
708 "rte_cryptodev_queue_pair_setup:"
709 "num_inflights %u on qp %u on cryptodev %u",
710 qp_conf.nb_descriptors, qp_id,
711 ts_params->valid_devs[0]);
714 /* test invalid queue pair id */
715 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
717 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
719 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
720 ts_params->valid_devs[0],
722 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
723 "Failed test for rte_cryptodev_queue_pair_setup:"
724 "invalid qp %u on cryptodev %u",
725 qp_id, ts_params->valid_devs[0]);
727 qp_id = 0xffff; /*invalid*/
729 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
730 ts_params->valid_devs[0],
732 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
733 "Failed test for rte_cryptodev_queue_pair_setup:"
734 "invalid qp %u on cryptodev %u",
735 qp_id, ts_params->valid_devs[0]);
740 /* ***** Plaintext data for tests ***** */
742 const char catch_22_quote_1[] =
743 "There was only one catch and that was Catch-22, which "
744 "specified that a concern for one's safety in the face of "
745 "dangers that were real and immediate was the process of a "
746 "rational mind. Orr was crazy and could be grounded. All he "
747 "had to do was ask; and as soon as he did, he would no longer "
748 "be crazy and would have to fly more missions. Orr would be "
749 "crazy to fly more missions and sane if he didn't, but if he "
750 "was sane he had to fly them. If he flew them he was crazy "
751 "and didn't have to; but if he didn't want to he was sane and "
752 "had to. Yossarian was moved very deeply by the absolute "
753 "simplicity of this clause of Catch-22 and let out a "
754 "respectful whistle. \"That's some catch, that Catch-22\", he "
755 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
757 const char catch_22_quote[] =
758 "What a lousy earth! He wondered how many people were "
759 "destitute that same night even in his own prosperous country, "
760 "how many homes were shanties, how many husbands were drunk "
761 "and wives socked, and how many children were bullied, abused, "
762 "or abandoned. How many families hungered for food they could "
763 "not afford to buy? How many hearts were broken? How many "
764 "suicides would take place that same night, how many people "
765 "would go insane? How many cockroaches and landlords would "
766 "triumph? How many winners were losers, successes failures, "
767 "and rich men poor men? How many wise guys were stupid? How "
768 "many happy endings were unhappy endings? How many honest men "
769 "were liars, brave men cowards, loyal men traitors, how many "
770 "sainted men were corrupt, how many people in positions of "
771 "trust had sold their souls to bodyguards, how many had never "
772 "had souls? How many straight-and-narrow paths were crooked "
773 "paths? How many best families were worst families and how "
774 "many good people were bad people? When you added them all up "
775 "and then subtracted, you might be left with only the children, "
776 "and perhaps with Albert Einstein and an old violinist or "
777 "sculptor somewhere.";
779 #define QUOTE_480_BYTES (480)
780 #define QUOTE_512_BYTES (512)
781 #define QUOTE_768_BYTES (768)
782 #define QUOTE_1024_BYTES (1024)
786 /* ***** SHA1 Hash Tests ***** */
788 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
790 static uint8_t hmac_sha1_key[] = {
791 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
792 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
793 0xDE, 0xF4, 0xDE, 0xAD };
795 /* ***** SHA224 Hash Tests ***** */
797 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
800 /* ***** AES-CBC Cipher Tests ***** */
802 #define CIPHER_KEY_LENGTH_AES_CBC (16)
803 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
805 static uint8_t aes_cbc_key[] = {
806 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
807 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
809 static uint8_t aes_cbc_iv[] = {
810 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
811 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
814 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
816 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
817 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
818 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
819 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
820 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
821 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
822 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
823 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
824 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
825 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
826 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
827 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
828 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
829 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
830 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
831 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
832 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
833 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
834 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
835 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
836 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
837 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
838 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
839 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
840 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
841 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
842 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
843 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
844 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
845 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
846 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
847 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
848 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
849 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
850 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
851 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
852 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
853 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
854 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
855 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
856 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
857 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
858 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
859 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
860 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
861 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
862 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
863 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
864 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
865 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
866 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
867 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
868 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
869 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
870 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
871 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
872 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
873 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
874 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
875 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
876 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
877 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
878 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
879 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
880 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
883 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
884 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
885 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
886 0x18, 0x8c, 0x1d, 0x32
890 /* Multisession Vector context Test */
892 static uint8_t ms_aes_cbc_key0[] = {
893 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
894 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
897 static uint8_t ms_aes_cbc_iv0[] = {
898 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
899 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
902 static const uint8_t ms_aes_cbc_cipher0[] = {
903 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
904 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
905 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
906 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
907 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
908 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
909 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
910 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
911 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
912 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
913 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
914 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
915 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
916 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
917 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
918 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
919 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
920 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
921 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
922 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
923 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
924 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
925 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
926 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
927 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
928 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
929 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
930 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
931 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
932 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
933 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
934 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
935 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
936 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
937 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
938 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
939 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
940 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
941 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
942 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
943 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
944 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
945 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
946 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
947 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
948 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
949 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
950 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
951 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
952 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
953 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
954 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
955 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
956 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
957 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
958 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
959 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
960 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
961 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
962 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
963 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
964 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
965 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
966 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
970 static uint8_t ms_hmac_key0[] = {
971 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
972 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
973 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
974 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
975 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
976 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
977 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
978 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
981 static const uint8_t ms_hmac_digest0[] = {
982 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
983 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
984 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
985 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
986 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
987 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
988 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
989 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
993 /* Begin session 1 */
995 static uint8_t ms_aes_cbc_key1[] = {
996 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
997 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1000 static uint8_t ms_aes_cbc_iv1[] = {
1001 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1002 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1005 static const uint8_t ms_aes_cbc_cipher1[] = {
1006 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1007 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1008 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1009 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1010 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1011 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1012 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1013 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1014 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1015 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1016 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1017 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1018 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1019 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1020 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1021 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1022 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1023 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1024 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1025 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1026 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1027 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1028 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1029 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1030 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1031 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1032 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1033 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1034 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1035 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1036 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1037 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1038 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1039 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1040 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1041 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1042 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1043 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1044 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1045 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1046 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1047 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1048 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1049 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1050 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1051 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1052 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1053 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1054 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1055 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1056 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1057 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1058 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1059 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1060 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1061 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1062 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1063 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1064 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1065 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1066 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1067 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1068 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1069 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1073 static uint8_t ms_hmac_key1[] = {
1074 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1075 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1076 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1077 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1078 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1079 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1080 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1081 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1084 static const uint8_t ms_hmac_digest1[] = {
1085 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1086 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1087 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1088 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1089 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1090 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1091 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1092 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1095 /* Begin Session 2 */
1096 static uint8_t ms_aes_cbc_key2[] = {
1097 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1098 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1101 static uint8_t ms_aes_cbc_iv2[] = {
1102 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1103 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1106 static const uint8_t ms_aes_cbc_cipher2[] = {
1107 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1108 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1109 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1110 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1111 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1112 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1113 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1114 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1115 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1116 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1117 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1118 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1119 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1120 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1121 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1122 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1123 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1124 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1125 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1126 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1127 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1128 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1129 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1130 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1131 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1132 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1133 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1134 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1135 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1136 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1137 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1138 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1139 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1140 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1141 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1142 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1143 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1144 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1145 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1146 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1147 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1148 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1149 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1150 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1151 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1152 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1153 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1154 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1155 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1156 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1157 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1158 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1159 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1160 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1161 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1162 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1163 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1164 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1165 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1166 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1167 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1168 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1169 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1170 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1173 static uint8_t ms_hmac_key2[] = {
1174 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1175 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1176 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1177 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1178 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1179 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1180 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1181 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1184 static const uint8_t ms_hmac_digest2[] = {
1185 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1186 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1187 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1188 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1189 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1190 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1191 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1192 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1199 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1201 struct crypto_testsuite_params *ts_params = &testsuite_params;
1202 struct crypto_unittest_params *ut_params = &unittest_params;
1204 /* Generate test mbuf data and space for digest */
1205 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1206 catch_22_quote, QUOTE_512_BYTES, 0);
1208 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1209 DIGEST_BYTE_LENGTH_SHA1);
1210 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1212 /* Setup Cipher Parameters */
1213 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1214 ut_params->cipher_xform.next = &ut_params->auth_xform;
1216 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1217 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1218 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1219 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1221 /* Setup HMAC Parameters */
1222 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1224 ut_params->auth_xform.next = NULL;
1226 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1227 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1228 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1229 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1230 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1232 /* Create crypto session*/
1233 ut_params->sess = rte_cryptodev_sym_session_create(
1234 ts_params->valid_devs[0],
1235 &ut_params->cipher_xform);
1236 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1238 /* Generate crypto op data structure */
1239 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1240 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1241 TEST_ASSERT_NOT_NULL(ut_params->op,
1242 "Failed to allocate symmetric crypto operation struct");
1244 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1246 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1248 /* set crypto operation source mbuf */
1249 sym_op->m_src = ut_params->ibuf;
1251 /* Set crypto operation authentication parameters */
1252 sym_op->auth.digest.data = ut_params->digest;
1253 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1254 ut_params->ibuf, QUOTE_512_BYTES);
1255 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1257 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1258 sym_op->auth.data.length = QUOTE_512_BYTES;
1260 /* Set crypto operation cipher parameters */
1261 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1262 CIPHER_IV_LENGTH_AES_CBC);
1263 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1264 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1266 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1267 CIPHER_IV_LENGTH_AES_CBC);
1269 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1270 sym_op->cipher.data.length = QUOTE_512_BYTES;
1272 /* Process crypto operation */
1273 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1274 ut_params->op), "failed to process sym crypto op");
1276 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1277 "crypto op processing failed");
1280 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1281 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1283 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1284 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1286 "ciphertext data not as expected");
1288 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1290 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1291 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1292 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1293 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1294 DIGEST_BYTE_LENGTH_SHA1,
1295 "Generated digest data not as expected");
1297 return TEST_SUCCESS;
1300 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1302 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1304 static uint8_t hmac_sha512_key[] = {
1305 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1306 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1307 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1308 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1309 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1310 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1311 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1312 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1314 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1315 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1316 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1317 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1318 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1319 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1320 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1321 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1322 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1327 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1328 struct crypto_unittest_params *ut_params,
1329 uint8_t *cipher_key,
1333 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1334 struct crypto_unittest_params *ut_params,
1335 struct crypto_testsuite_params *ts_params,
1336 const uint8_t *cipher,
1337 const uint8_t *digest,
1342 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1343 struct crypto_unittest_params *ut_params,
1344 uint8_t *cipher_key,
1348 /* Setup Cipher Parameters */
1349 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1350 ut_params->cipher_xform.next = NULL;
1352 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1353 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1354 ut_params->cipher_xform.cipher.key.data = cipher_key;
1355 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1357 /* Setup HMAC Parameters */
1358 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1359 ut_params->auth_xform.next = &ut_params->cipher_xform;
1361 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1362 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1363 ut_params->auth_xform.auth.key.data = hmac_key;
1364 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1365 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1367 return TEST_SUCCESS;
1372 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1373 struct crypto_unittest_params *ut_params,
1374 struct crypto_testsuite_params *ts_params,
1375 const uint8_t *cipher,
1376 const uint8_t *digest,
1379 /* Generate test mbuf data and digest */
1380 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1383 QUOTE_512_BYTES, 0);
1385 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1386 DIGEST_BYTE_LENGTH_SHA512);
1387 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1389 rte_memcpy(ut_params->digest,
1391 DIGEST_BYTE_LENGTH_SHA512);
1393 /* Generate Crypto op data structure */
1394 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1395 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1396 TEST_ASSERT_NOT_NULL(ut_params->op,
1397 "Failed to allocate symmetric crypto operation struct");
1399 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1401 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1403 /* set crypto operation source mbuf */
1404 sym_op->m_src = ut_params->ibuf;
1406 sym_op->auth.digest.data = ut_params->digest;
1407 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1408 ut_params->ibuf, QUOTE_512_BYTES);
1409 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1411 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1412 sym_op->auth.data.length = QUOTE_512_BYTES;
1414 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1415 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1416 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1417 ut_params->ibuf, 0);
1418 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1420 rte_memcpy(sym_op->cipher.iv.data, iv,
1421 CIPHER_IV_LENGTH_AES_CBC);
1423 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1424 sym_op->cipher.data.length = QUOTE_512_BYTES;
1426 /* Process crypto operation */
1427 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1428 ut_params->op), "failed to process sym crypto op");
1430 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1431 "crypto op processing failed");
1433 ut_params->obuf = ut_params->op->sym->m_src;
1436 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1437 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1438 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1440 "Plaintext data not as expected");
1443 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1444 "Digest verification failed");
1446 return TEST_SUCCESS;
1450 test_AES_chain_mb_all(void)
1452 struct crypto_testsuite_params *ts_params = &testsuite_params;
1455 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1456 ts_params->op_mpool, ts_params->valid_devs[0],
1457 RTE_CRYPTODEV_AESNI_MB_PMD,
1458 BLKCIPHER_AES_CHAIN_TYPE);
1460 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1462 return TEST_SUCCESS;
1466 test_AES_chain_libcrypto_all(void)
1468 struct crypto_testsuite_params *ts_params = &testsuite_params;
1471 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1472 ts_params->op_mpool, ts_params->valid_devs[0],
1473 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1474 BLKCIPHER_AES_CHAIN_TYPE);
1476 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1478 return TEST_SUCCESS;
1482 test_AES_cipheronly_libcrypto_all(void)
1484 struct crypto_testsuite_params *ts_params = &testsuite_params;
1487 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1488 ts_params->op_mpool, ts_params->valid_devs[0],
1489 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1490 BLKCIPHER_AES_CIPHERONLY_TYPE);
1492 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1494 return TEST_SUCCESS;
1498 test_AES_chain_qat_all(void)
1500 struct crypto_testsuite_params *ts_params = &testsuite_params;
1503 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1504 ts_params->op_mpool, ts_params->valid_devs[0],
1505 RTE_CRYPTODEV_QAT_SYM_PMD,
1506 BLKCIPHER_AES_CHAIN_TYPE);
1508 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1510 return TEST_SUCCESS;
1514 test_authonly_libcrypto_all(void)
1516 struct crypto_testsuite_params *ts_params = &testsuite_params;
1519 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1520 ts_params->op_mpool, ts_params->valid_devs[0],
1521 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1522 BLKCIPHER_AUTHONLY_TYPE);
1524 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1526 return TEST_SUCCESS;
1529 /* ***** SNOW 3G Tests ***** */
1531 create_wireless_algo_hash_session(uint8_t dev_id,
1532 const uint8_t *key, const uint8_t key_len,
1533 const uint8_t aad_len, const uint8_t auth_len,
1534 enum rte_crypto_auth_operation op,
1535 enum rte_crypto_auth_algorithm algo)
1537 uint8_t hash_key[key_len];
1539 struct crypto_unittest_params *ut_params = &unittest_params;
1541 memcpy(hash_key, key, key_len);
1543 TEST_HEXDUMP(stdout, "key:", key, key_len);
1545 /* Setup Authentication Parameters */
1546 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1547 ut_params->auth_xform.next = NULL;
1549 ut_params->auth_xform.auth.op = op;
1550 ut_params->auth_xform.auth.algo = algo;
1551 ut_params->auth_xform.auth.key.length = key_len;
1552 ut_params->auth_xform.auth.key.data = hash_key;
1553 ut_params->auth_xform.auth.digest_length = auth_len;
1554 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1555 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1556 &ut_params->auth_xform);
1557 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1562 create_wireless_algo_cipher_session(uint8_t dev_id,
1563 enum rte_crypto_cipher_operation op,
1564 enum rte_crypto_cipher_algorithm algo,
1565 const uint8_t *key, const uint8_t key_len)
1567 uint8_t cipher_key[key_len];
1569 struct crypto_unittest_params *ut_params = &unittest_params;
1571 memcpy(cipher_key, key, key_len);
1573 /* Setup Cipher Parameters */
1574 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1575 ut_params->cipher_xform.next = NULL;
1577 ut_params->cipher_xform.cipher.algo = algo;
1578 ut_params->cipher_xform.cipher.op = op;
1579 ut_params->cipher_xform.cipher.key.data = cipher_key;
1580 ut_params->cipher_xform.cipher.key.length = key_len;
1582 TEST_HEXDUMP(stdout, "key:", key, key_len);
1584 /* Create Crypto session */
1585 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1588 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1593 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1594 const unsigned cipher_len,
1595 const unsigned cipher_offset,
1596 enum rte_crypto_cipher_algorithm algo)
1598 struct crypto_testsuite_params *ts_params = &testsuite_params;
1599 struct crypto_unittest_params *ut_params = &unittest_params;
1600 unsigned iv_pad_len = 0;
1602 /* Generate Crypto op data structure */
1603 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1604 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1605 TEST_ASSERT_NOT_NULL(ut_params->op,
1606 "Failed to allocate pktmbuf offload");
1608 /* Set crypto operation data parameters */
1609 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1611 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1613 /* set crypto operation source mbuf */
1614 sym_op->m_src = ut_params->ibuf;
1617 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1618 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1620 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1622 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1625 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1627 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1628 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1629 sym_op->cipher.iv.length = iv_pad_len;
1631 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1632 sym_op->cipher.data.length = cipher_len;
1633 sym_op->cipher.data.offset = cipher_offset;
1638 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1639 const unsigned cipher_len,
1640 const unsigned cipher_offset,
1641 enum rte_crypto_cipher_algorithm algo)
1643 struct crypto_testsuite_params *ts_params = &testsuite_params;
1644 struct crypto_unittest_params *ut_params = &unittest_params;
1645 unsigned iv_pad_len = 0;
1647 /* Generate Crypto op data structure */
1648 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1649 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1650 TEST_ASSERT_NOT_NULL(ut_params->op,
1651 "Failed to allocate pktmbuf offload");
1653 /* Set crypto operation data parameters */
1654 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1656 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1658 /* set crypto operation source mbuf */
1659 sym_op->m_src = ut_params->ibuf;
1660 sym_op->m_dst = ut_params->obuf;
1663 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1664 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1666 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1667 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1670 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1672 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1673 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1674 sym_op->cipher.iv.length = iv_pad_len;
1676 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1677 sym_op->cipher.data.length = cipher_len;
1678 sym_op->cipher.data.offset = cipher_offset;
1683 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1684 enum rte_crypto_cipher_operation cipher_op,
1685 enum rte_crypto_auth_operation auth_op,
1686 enum rte_crypto_auth_algorithm auth_algo,
1687 enum rte_crypto_cipher_algorithm cipher_algo,
1688 const uint8_t *key, const uint8_t key_len,
1689 const uint8_t aad_len, const uint8_t auth_len)
1692 uint8_t cipher_auth_key[key_len];
1694 struct crypto_unittest_params *ut_params = &unittest_params;
1696 memcpy(cipher_auth_key, key, key_len);
1698 /* Setup Authentication Parameters */
1699 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1700 ut_params->auth_xform.next = NULL;
1702 ut_params->auth_xform.auth.op = auth_op;
1703 ut_params->auth_xform.auth.algo = auth_algo;
1704 ut_params->auth_xform.auth.key.length = key_len;
1705 /* Hash key = cipher key */
1706 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1707 ut_params->auth_xform.auth.digest_length = auth_len;
1708 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1710 /* Setup Cipher Parameters */
1711 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1712 ut_params->cipher_xform.next = &ut_params->auth_xform;
1714 ut_params->cipher_xform.cipher.algo = cipher_algo;
1715 ut_params->cipher_xform.cipher.op = cipher_op;
1716 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1717 ut_params->cipher_xform.cipher.key.length = key_len;
1719 TEST_HEXDUMP(stdout, "key:", key, key_len);
1721 /* Create Crypto session*/
1722 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1723 &ut_params->cipher_xform);
1725 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1730 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1731 enum rte_crypto_cipher_operation cipher_op,
1732 enum rte_crypto_auth_operation auth_op,
1733 enum rte_crypto_auth_algorithm auth_algo,
1734 enum rte_crypto_cipher_algorithm cipher_algo,
1735 const uint8_t *key, const uint8_t key_len,
1736 const uint8_t aad_len, const uint8_t auth_len)
1738 uint8_t auth_cipher_key[key_len];
1740 struct crypto_unittest_params *ut_params = &unittest_params;
1742 memcpy(auth_cipher_key, key, key_len);
1744 /* Setup Authentication Parameters */
1745 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1746 ut_params->auth_xform.auth.op = auth_op;
1747 ut_params->auth_xform.next = &ut_params->cipher_xform;
1748 ut_params->auth_xform.auth.algo = auth_algo;
1749 ut_params->auth_xform.auth.key.length = key_len;
1750 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1751 ut_params->auth_xform.auth.digest_length = auth_len;
1752 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1754 /* Setup Cipher Parameters */
1755 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1756 ut_params->cipher_xform.next = NULL;
1757 ut_params->cipher_xform.cipher.algo = cipher_algo;
1758 ut_params->cipher_xform.cipher.op = cipher_op;
1759 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1760 ut_params->cipher_xform.cipher.key.length = key_len;
1762 TEST_HEXDUMP(stdout, "key:", key, key_len);
1764 /* Create Crypto session*/
1765 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1766 &ut_params->auth_xform);
1768 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1774 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1775 const unsigned auth_tag_len,
1776 const uint8_t *aad, const unsigned aad_len,
1777 unsigned data_pad_len,
1778 enum rte_crypto_auth_operation op,
1779 enum rte_crypto_auth_algorithm algo,
1780 const unsigned auth_len, const unsigned auth_offset)
1782 struct crypto_testsuite_params *ts_params = &testsuite_params;
1784 struct crypto_unittest_params *ut_params = &unittest_params;
1786 unsigned aad_buffer_len;
1788 /* Generate Crypto op data structure */
1789 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1790 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1791 TEST_ASSERT_NOT_NULL(ut_params->op,
1792 "Failed to allocate pktmbuf offload");
1794 /* Set crypto operation data parameters */
1795 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1797 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1799 /* set crypto operation source mbuf */
1800 sym_op->m_src = ut_params->ibuf;
1804 * Always allocate the aad up to the block size.
1805 * The cryptodev API calls out -
1806 * - the array must be big enough to hold the AAD, plus any
1807 * space to round this up to the nearest multiple of the
1808 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1810 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1811 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1813 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1814 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1815 ut_params->ibuf, aad_buffer_len);
1816 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1817 "no room to prepend aad");
1818 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1820 sym_op->auth.aad.length = aad_len;
1822 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1823 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1825 TEST_HEXDUMP(stdout, "aad:",
1826 sym_op->auth.aad.data, aad_len);
1829 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1830 ut_params->ibuf, auth_tag_len);
1832 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1833 "no room to append auth tag");
1834 ut_params->digest = sym_op->auth.digest.data;
1835 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1836 ut_params->ibuf, data_pad_len + aad_len);
1837 sym_op->auth.digest.length = auth_tag_len;
1838 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1839 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1841 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1843 TEST_HEXDUMP(stdout, "digest:",
1844 sym_op->auth.digest.data,
1845 sym_op->auth.digest.length);
1847 sym_op->auth.data.length = auth_len;
1848 sym_op->auth.data.offset = auth_offset;
1854 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1855 const unsigned auth_tag_len,
1856 const uint8_t *aad, const uint8_t aad_len,
1857 unsigned data_pad_len,
1858 enum rte_crypto_auth_operation op,
1859 enum rte_crypto_auth_algorithm auth_algo,
1860 enum rte_crypto_cipher_algorithm cipher_algo,
1861 const uint8_t *iv, const uint8_t iv_len,
1862 const unsigned cipher_len, const unsigned cipher_offset,
1863 const unsigned auth_len, const unsigned auth_offset)
1865 struct crypto_testsuite_params *ts_params = &testsuite_params;
1866 struct crypto_unittest_params *ut_params = &unittest_params;
1868 unsigned iv_pad_len = 0;
1869 unsigned aad_buffer_len;
1871 /* Generate Crypto op data structure */
1872 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1873 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1874 TEST_ASSERT_NOT_NULL(ut_params->op,
1875 "Failed to allocate pktmbuf offload");
1876 /* Set crypto operation data parameters */
1877 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1879 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1881 /* set crypto operation source mbuf */
1882 sym_op->m_src = ut_params->ibuf;
1885 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1886 ut_params->ibuf, auth_tag_len);
1888 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1889 "no room to append auth tag");
1890 ut_params->digest = sym_op->auth.digest.data;
1891 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1892 ut_params->ibuf, data_pad_len);
1893 sym_op->auth.digest.length = auth_tag_len;
1894 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1895 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1897 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1899 TEST_HEXDUMP(stdout, "digest:",
1900 sym_op->auth.digest.data,
1901 sym_op->auth.digest.length);
1905 * Always allocate the aad up to the block size.
1906 * The cryptodev API calls out -
1907 * - the array must be big enough to hold the AAD, plus any
1908 * space to round this up to the nearest multiple of the
1909 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1911 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1912 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1914 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1915 sym_op->auth.aad.data =
1916 (uint8_t *)rte_pktmbuf_prepend(
1917 ut_params->ibuf, aad_buffer_len);
1918 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1919 "no room to prepend aad");
1920 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1922 sym_op->auth.aad.length = aad_len;
1923 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1924 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1925 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1928 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1929 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1931 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1932 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1933 ut_params->ibuf, iv_pad_len);
1935 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1936 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1937 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1938 sym_op->cipher.iv.length = iv_pad_len;
1939 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1940 sym_op->cipher.data.length = cipher_len;
1941 sym_op->cipher.data.offset = cipher_offset + auth_offset;
1942 sym_op->auth.data.length = auth_len;
1943 sym_op->auth.data.offset = auth_offset + cipher_offset;
1949 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
1950 const uint8_t *iv, const uint8_t iv_len,
1951 const uint8_t *aad, const uint8_t aad_len,
1952 unsigned data_pad_len,
1953 const unsigned cipher_len, const unsigned cipher_offset,
1954 const unsigned auth_len, const unsigned auth_offset,
1955 enum rte_crypto_auth_algorithm auth_algo,
1956 enum rte_crypto_cipher_algorithm cipher_algo)
1958 struct crypto_testsuite_params *ts_params = &testsuite_params;
1959 struct crypto_unittest_params *ut_params = &unittest_params;
1961 unsigned iv_pad_len = 0;
1962 unsigned aad_buffer_len = 0;
1964 /* Generate Crypto op data structure */
1965 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1966 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1967 TEST_ASSERT_NOT_NULL(ut_params->op,
1968 "Failed to allocate pktmbuf offload");
1970 /* Set crypto operation data parameters */
1971 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1973 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1975 /* set crypto operation source mbuf */
1976 sym_op->m_src = ut_params->ibuf;
1979 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1980 ut_params->ibuf, auth_tag_len);
1982 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1983 "no room to append auth tag");
1985 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1986 ut_params->ibuf, data_pad_len);
1987 sym_op->auth.digest.length = auth_tag_len;
1989 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1991 TEST_HEXDUMP(stdout, "digest:",
1992 sym_op->auth.digest.data,
1993 sym_op->auth.digest.length);
1997 * Always allocate the aad up to the block size.
1998 * The cryptodev API calls out -
1999 * - the array must be big enough to hold the AAD, plus any
2000 * space to round this up to the nearest multiple of the
2001 * block size (8 bytes for KASUMI 16 bytes).
2003 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2004 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2006 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2007 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2008 ut_params->ibuf, aad_buffer_len);
2009 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2010 "no room to prepend aad");
2011 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2013 sym_op->auth.aad.length = aad_len;
2014 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2015 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2016 TEST_HEXDUMP(stdout, "aad:",
2017 sym_op->auth.aad.data, aad_len);
2020 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2021 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2023 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2025 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2026 ut_params->ibuf, iv_pad_len);
2027 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2029 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2030 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2031 sym_op->cipher.iv.length = iv_pad_len;
2033 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2035 sym_op->cipher.data.length = cipher_len;
2036 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2038 sym_op->auth.data.length = auth_len;
2039 sym_op->auth.data.offset = auth_offset + cipher_offset;
2045 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2047 struct crypto_testsuite_params *ts_params = &testsuite_params;
2048 struct crypto_unittest_params *ut_params = &unittest_params;
2051 unsigned plaintext_pad_len;
2052 unsigned plaintext_len;
2055 /* Create SNOW 3G session */
2056 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2057 tdata->key.data, tdata->key.len,
2058 tdata->aad.len, tdata->digest.len,
2059 RTE_CRYPTO_AUTH_OP_GENERATE,
2060 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2064 /* alloc mbuf and set payload */
2065 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2067 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2068 rte_pktmbuf_tailroom(ut_params->ibuf));
2070 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2071 /* Append data which is padded to a multiple of */
2072 /* the algorithms block size */
2073 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2074 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2076 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2078 /* Create SNOW 3G operation */
2079 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2080 tdata->aad.data, tdata->aad.len,
2081 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2082 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2083 tdata->validAuthLenInBits.len,
2084 tdata->validAuthOffsetLenInBits.len);
2088 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2090 ut_params->obuf = ut_params->op->sym->m_src;
2091 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2092 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2093 + plaintext_pad_len + tdata->aad.len;
2096 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2099 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2100 "SNOW 3G Generated auth tag not as expected");
2106 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2108 struct crypto_testsuite_params *ts_params = &testsuite_params;
2109 struct crypto_unittest_params *ut_params = &unittest_params;
2112 unsigned plaintext_pad_len;
2113 unsigned plaintext_len;
2116 /* Create SNOW 3G session */
2117 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2118 tdata->key.data, tdata->key.len,
2119 tdata->aad.len, tdata->digest.len,
2120 RTE_CRYPTO_AUTH_OP_VERIFY,
2121 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2124 /* alloc mbuf and set payload */
2125 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2127 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2128 rte_pktmbuf_tailroom(ut_params->ibuf));
2130 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2131 /* Append data which is padded to a multiple of */
2132 /* the algorithms block size */
2133 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2134 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2136 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2138 /* Create SNOW 3G operation */
2139 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2141 tdata->aad.data, tdata->aad.len,
2143 RTE_CRYPTO_AUTH_OP_VERIFY,
2144 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2145 tdata->validAuthLenInBits.len,
2146 tdata->validAuthOffsetLenInBits.len);
2150 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2152 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2153 ut_params->obuf = ut_params->op->sym->m_src;
2154 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2155 + plaintext_pad_len + tdata->aad.len;
2158 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2167 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2169 struct crypto_testsuite_params *ts_params = &testsuite_params;
2170 struct crypto_unittest_params *ut_params = &unittest_params;
2173 unsigned plaintext_pad_len;
2174 unsigned plaintext_len;
2177 /* Create KASUMI session */
2178 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2179 tdata->key.data, tdata->key.len,
2180 tdata->aad.len, tdata->digest.len,
2181 RTE_CRYPTO_AUTH_OP_GENERATE,
2182 RTE_CRYPTO_AUTH_KASUMI_F9);
2186 /* alloc mbuf and set payload */
2187 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2189 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2190 rte_pktmbuf_tailroom(ut_params->ibuf));
2192 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2193 /* Append data which is padded to a multiple of */
2194 /* the algorithms block size */
2195 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2196 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2198 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2200 /* Create KASUMI operation */
2201 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2202 tdata->aad.data, tdata->aad.len,
2203 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2204 RTE_CRYPTO_AUTH_KASUMI_F9,
2205 tdata->validAuthLenInBits.len,
2206 tdata->validAuthOffsetLenInBits.len);
2210 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2212 ut_params->obuf = ut_params->op->sym->m_src;
2213 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2214 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2215 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2218 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2221 DIGEST_BYTE_LENGTH_KASUMI_F9,
2222 "KASUMI Generated auth tag not as expected");
2228 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2230 struct crypto_testsuite_params *ts_params = &testsuite_params;
2231 struct crypto_unittest_params *ut_params = &unittest_params;
2234 unsigned plaintext_pad_len;
2235 unsigned plaintext_len;
2238 /* Create KASUMI session */
2239 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2240 tdata->key.data, tdata->key.len,
2241 tdata->aad.len, tdata->digest.len,
2242 RTE_CRYPTO_AUTH_OP_VERIFY,
2243 RTE_CRYPTO_AUTH_KASUMI_F9);
2246 /* alloc mbuf and set payload */
2247 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2249 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2250 rte_pktmbuf_tailroom(ut_params->ibuf));
2252 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2253 /* Append data which is padded to a multiple */
2254 /* of the algorithms block size */
2255 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2256 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2258 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2260 /* Create KASUMI operation */
2261 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2263 tdata->aad.data, tdata->aad.len,
2265 RTE_CRYPTO_AUTH_OP_VERIFY,
2266 RTE_CRYPTO_AUTH_KASUMI_F9,
2267 tdata->validAuthLenInBits.len,
2268 tdata->validAuthOffsetLenInBits.len);
2272 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2274 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2275 ut_params->obuf = ut_params->op->sym->m_src;
2276 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2277 + plaintext_pad_len + tdata->aad.len;
2280 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2289 test_snow3g_hash_generate_test_case_1(void)
2291 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2295 test_snow3g_hash_generate_test_case_2(void)
2297 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2301 test_snow3g_hash_generate_test_case_3(void)
2303 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2307 test_snow3g_hash_generate_test_case_4(void)
2309 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2313 test_snow3g_hash_generate_test_case_5(void)
2315 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2319 test_snow3g_hash_generate_test_case_6(void)
2321 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2325 test_snow3g_hash_verify_test_case_1(void)
2327 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2332 test_snow3g_hash_verify_test_case_2(void)
2334 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2338 test_snow3g_hash_verify_test_case_3(void)
2340 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2344 test_snow3g_hash_verify_test_case_4(void)
2346 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2350 test_snow3g_hash_verify_test_case_5(void)
2352 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2356 test_snow3g_hash_verify_test_case_6(void)
2358 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2362 test_kasumi_hash_generate_test_case_1(void)
2364 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2368 test_kasumi_hash_generate_test_case_2(void)
2370 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2374 test_kasumi_hash_generate_test_case_3(void)
2376 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2380 test_kasumi_hash_generate_test_case_4(void)
2382 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2386 test_kasumi_hash_generate_test_case_5(void)
2388 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2392 test_kasumi_hash_generate_test_case_6(void)
2394 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2398 test_kasumi_hash_verify_test_case_1(void)
2400 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2404 test_kasumi_hash_verify_test_case_2(void)
2406 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2410 test_kasumi_hash_verify_test_case_3(void)
2412 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2416 test_kasumi_hash_verify_test_case_4(void)
2418 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2422 test_kasumi_hash_verify_test_case_5(void)
2424 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2428 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2430 struct crypto_testsuite_params *ts_params = &testsuite_params;
2431 struct crypto_unittest_params *ut_params = &unittest_params;
2434 uint8_t *plaintext, *ciphertext;
2435 unsigned plaintext_pad_len;
2436 unsigned plaintext_len;
2438 /* Create KASUMI session */
2439 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2440 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2441 RTE_CRYPTO_CIPHER_KASUMI_F8,
2442 tdata->key.data, tdata->key.len);
2446 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2448 /* Clear mbuf payload */
2449 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2450 rte_pktmbuf_tailroom(ut_params->ibuf));
2452 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2453 /* Append data which is padded to a multiple */
2454 /* of the algorithms block size */
2455 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2456 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2458 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2460 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2462 /* Create KASUMI operation */
2463 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2464 tdata->plaintext.len,
2465 tdata->validCipherOffsetLenInBits.len,
2466 RTE_CRYPTO_CIPHER_KASUMI_F8);
2470 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2472 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2474 ut_params->obuf = ut_params->op->sym->m_dst;
2475 if (ut_params->obuf)
2476 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2479 ciphertext = plaintext;
2481 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2484 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2486 tdata->ciphertext.data,
2487 tdata->validCipherLenInBits.len,
2488 "KASUMI Ciphertext data not as expected");
2493 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2495 struct crypto_testsuite_params *ts_params = &testsuite_params;
2496 struct crypto_unittest_params *ut_params = &unittest_params;
2499 uint8_t *plaintext, *ciphertext;
2500 unsigned plaintext_pad_len;
2501 unsigned plaintext_len;
2503 /* Create KASUMI session */
2504 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2505 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2506 RTE_CRYPTO_CIPHER_KASUMI_F8,
2507 tdata->key.data, tdata->key.len);
2511 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2512 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2514 /* Clear mbuf payload */
2515 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2516 rte_pktmbuf_tailroom(ut_params->ibuf));
2518 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2519 /* Append data which is padded to a multiple */
2520 /* of the algorithms block size */
2521 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2522 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2524 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2525 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2527 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2529 /* Create KASUMI operation */
2530 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2532 tdata->plaintext.len,
2533 tdata->validCipherOffsetLenInBits.len,
2534 RTE_CRYPTO_CIPHER_KASUMI_F8);
2538 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2540 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2542 ut_params->obuf = ut_params->op->sym->m_dst;
2543 if (ut_params->obuf)
2544 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2547 ciphertext = plaintext;
2549 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2552 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2554 tdata->ciphertext.data,
2555 tdata->validCipherLenInBits.len,
2556 "KASUMI Ciphertext data not as expected");
2561 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2563 struct crypto_testsuite_params *ts_params = &testsuite_params;
2564 struct crypto_unittest_params *ut_params = &unittest_params;
2567 uint8_t *ciphertext, *plaintext;
2568 unsigned ciphertext_pad_len;
2569 unsigned ciphertext_len;
2571 /* Create KASUMI session */
2572 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2573 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2574 RTE_CRYPTO_CIPHER_KASUMI_F8,
2575 tdata->key.data, tdata->key.len);
2579 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2580 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2582 /* Clear mbuf payload */
2583 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2584 rte_pktmbuf_tailroom(ut_params->ibuf));
2586 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2587 /* Append data which is padded to a multiple */
2588 /* of the algorithms block size */
2589 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2590 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2591 ciphertext_pad_len);
2592 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2593 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2595 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2597 /* Create KASUMI operation */
2598 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2600 tdata->ciphertext.len,
2601 tdata->validCipherOffsetLenInBits.len,
2602 RTE_CRYPTO_CIPHER_KASUMI_F8);
2606 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2608 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2610 ut_params->obuf = ut_params->op->sym->m_dst;
2611 if (ut_params->obuf)
2612 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2615 plaintext = ciphertext;
2617 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2620 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2622 tdata->plaintext.data,
2623 tdata->validCipherLenInBits.len,
2624 "KASUMI Plaintext data not as expected");
2629 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2631 struct crypto_testsuite_params *ts_params = &testsuite_params;
2632 struct crypto_unittest_params *ut_params = &unittest_params;
2635 uint8_t *ciphertext, *plaintext;
2636 unsigned ciphertext_pad_len;
2637 unsigned ciphertext_len;
2639 /* Create KASUMI session */
2640 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2641 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2642 RTE_CRYPTO_CIPHER_KASUMI_F8,
2643 tdata->key.data, tdata->key.len);
2647 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2649 /* Clear mbuf payload */
2650 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2651 rte_pktmbuf_tailroom(ut_params->ibuf));
2653 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2654 /* Append data which is padded to a multiple */
2655 /* of the algorithms block size */
2656 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2657 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2658 ciphertext_pad_len);
2659 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2661 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2663 /* Create KASUMI operation */
2664 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2666 tdata->ciphertext.len,
2667 tdata->validCipherOffsetLenInBits.len,
2668 RTE_CRYPTO_CIPHER_KASUMI_F8);
2672 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2674 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2676 ut_params->obuf = ut_params->op->sym->m_dst;
2677 if (ut_params->obuf)
2678 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2681 plaintext = ciphertext;
2683 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2686 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2688 tdata->plaintext.data,
2689 tdata->validCipherLenInBits.len,
2690 "KASUMI Plaintext data not as expected");
2695 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2697 struct crypto_testsuite_params *ts_params = &testsuite_params;
2698 struct crypto_unittest_params *ut_params = &unittest_params;
2701 uint8_t *plaintext, *ciphertext;
2702 unsigned plaintext_pad_len;
2703 unsigned plaintext_len;
2705 /* Create SNOW 3G session */
2706 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2707 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2708 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2709 tdata->key.data, tdata->key.len);
2713 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2715 /* Clear mbuf payload */
2716 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2717 rte_pktmbuf_tailroom(ut_params->ibuf));
2719 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2720 /* Append data which is padded to a multiple of */
2721 /* the algorithms block size */
2722 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2723 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2725 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2727 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2729 /* Create SNOW 3G operation */
2730 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2731 tdata->validCipherLenInBits.len,
2732 tdata->validCipherOffsetLenInBits.len,
2733 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2737 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2739 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2741 ut_params->obuf = ut_params->op->sym->m_dst;
2742 if (ut_params->obuf)
2743 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2746 ciphertext = plaintext;
2748 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2751 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2753 tdata->ciphertext.data,
2754 tdata->validDataLenInBits.len,
2755 "SNOW 3G Ciphertext data not as expected");
2761 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2763 struct crypto_testsuite_params *ts_params = &testsuite_params;
2764 struct crypto_unittest_params *ut_params = &unittest_params;
2765 uint8_t *plaintext, *ciphertext;
2768 unsigned plaintext_pad_len;
2769 unsigned plaintext_len;
2771 /* Create SNOW 3G session */
2772 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2773 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2774 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2775 tdata->key.data, tdata->key.len);
2779 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2780 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2782 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2783 "Failed to allocate input buffer in mempool");
2784 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2785 "Failed to allocate output buffer in mempool");
2787 /* Clear mbuf payload */
2788 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2789 rte_pktmbuf_tailroom(ut_params->ibuf));
2791 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2792 /* Append data which is padded to a multiple of */
2793 /* the algorithms block size */
2794 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2795 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2797 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2798 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2800 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2802 /* Create SNOW 3G operation */
2803 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2805 tdata->validCipherLenInBits.len,
2806 tdata->validCipherOffsetLenInBits.len,
2807 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2811 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2813 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2815 ut_params->obuf = ut_params->op->sym->m_dst;
2816 if (ut_params->obuf)
2817 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2820 ciphertext = plaintext;
2822 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2825 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2827 tdata->ciphertext.data,
2828 tdata->validDataLenInBits.len,
2829 "SNOW 3G Ciphertext data not as expected");
2833 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2835 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2837 uint8_t curr_byte, prev_byte;
2838 uint32_t length_in_bytes = ceil_byte_length(length + offset);
2839 uint8_t lower_byte_mask = (1 << offset) - 1;
2842 prev_byte = buffer[0];
2843 buffer[0] >>= offset;
2845 for (i = 1; i < length_in_bytes; i++) {
2846 curr_byte = buffer[i];
2847 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2848 (curr_byte >> offset);
2849 prev_byte = curr_byte;
2854 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2856 struct crypto_testsuite_params *ts_params = &testsuite_params;
2857 struct crypto_unittest_params *ut_params = &unittest_params;
2858 uint8_t *plaintext, *ciphertext;
2860 uint32_t plaintext_len;
2861 uint32_t plaintext_pad_len;
2862 uint8_t extra_offset = 4;
2863 uint8_t *expected_ciphertext_shifted;
2865 /* Create SNOW 3G session */
2866 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2867 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2868 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2869 tdata->key.data, tdata->key.len);
2873 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2874 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2876 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2877 "Failed to allocate input buffer in mempool");
2878 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2879 "Failed to allocate output buffer in mempool");
2881 /* Clear mbuf payload */
2882 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2883 rte_pktmbuf_tailroom(ut_params->ibuf));
2885 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2887 * Append data which is padded to a
2888 * multiple of the algorithms block size
2890 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2892 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2895 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2897 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2898 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2900 #ifdef RTE_APP_TEST_DEBUG
2901 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2903 /* Create SNOW 3G operation */
2904 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2906 tdata->validCipherLenInBits.len,
2907 tdata->validCipherOffsetLenInBits.len +
2909 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2913 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2915 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2917 ut_params->obuf = ut_params->op->sym->m_dst;
2918 if (ut_params->obuf)
2919 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2922 ciphertext = plaintext;
2924 #ifdef RTE_APP_TEST_DEBUG
2925 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2928 expected_ciphertext_shifted = rte_malloc(NULL,
2929 ceil_byte_length(plaintext_len + extra_offset), 0);
2931 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2932 "failed to reserve memory for ciphertext shifted\n");
2934 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
2935 ceil_byte_length(tdata->ciphertext.len));
2936 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
2939 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
2941 expected_ciphertext_shifted,
2942 tdata->validDataLenInBits.len,
2944 "SNOW 3G Ciphertext data not as expected");
2948 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2950 struct crypto_testsuite_params *ts_params = &testsuite_params;
2951 struct crypto_unittest_params *ut_params = &unittest_params;
2955 uint8_t *plaintext, *ciphertext;
2956 unsigned ciphertext_pad_len;
2957 unsigned ciphertext_len;
2959 /* Create SNOW 3G session */
2960 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2961 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2962 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2963 tdata->key.data, tdata->key.len);
2967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2969 /* Clear mbuf payload */
2970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2971 rte_pktmbuf_tailroom(ut_params->ibuf));
2973 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2974 /* Append data which is padded to a multiple of */
2975 /* the algorithms block size */
2976 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
2977 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2978 ciphertext_pad_len);
2979 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2981 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2983 /* Create SNOW 3G operation */
2984 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2985 tdata->validCipherLenInBits.len,
2986 tdata->validCipherOffsetLenInBits.len,
2987 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2991 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2993 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2994 ut_params->obuf = ut_params->op->sym->m_dst;
2995 if (ut_params->obuf)
2996 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2999 plaintext = ciphertext;
3001 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3004 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3005 tdata->plaintext.data,
3006 tdata->validDataLenInBits.len,
3007 "SNOW 3G Plaintext data not as expected");
3011 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3013 struct crypto_testsuite_params *ts_params = &testsuite_params;
3014 struct crypto_unittest_params *ut_params = &unittest_params;
3018 uint8_t *plaintext, *ciphertext;
3019 unsigned ciphertext_pad_len;
3020 unsigned ciphertext_len;
3022 /* Create SNOW 3G session */
3023 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3024 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3025 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3026 tdata->key.data, tdata->key.len);
3030 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3031 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3033 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3034 "Failed to allocate input buffer");
3035 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3036 "Failed to allocate output buffer");
3038 /* Clear mbuf payload */
3039 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3040 rte_pktmbuf_tailroom(ut_params->ibuf));
3042 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3043 rte_pktmbuf_tailroom(ut_params->obuf));
3045 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3046 /* Append data which is padded to a multiple of */
3047 /* the algorithms block size */
3048 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3049 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3050 ciphertext_pad_len);
3051 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3052 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3054 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3056 /* Create SNOW 3G operation */
3057 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3059 tdata->validCipherLenInBits.len,
3060 tdata->validCipherOffsetLenInBits.len,
3061 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3065 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3067 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3068 ut_params->obuf = ut_params->op->sym->m_dst;
3069 if (ut_params->obuf)
3070 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3073 plaintext = ciphertext;
3075 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3078 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3079 tdata->plaintext.data,
3080 tdata->validDataLenInBits.len,
3081 "SNOW 3G Plaintext data not as expected");
3086 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3088 struct crypto_testsuite_params *ts_params = &testsuite_params;
3089 struct crypto_unittest_params *ut_params = &unittest_params;
3093 uint8_t *plaintext, *ciphertext;
3094 unsigned plaintext_pad_len;
3095 unsigned plaintext_len;
3097 /* Create SNOW 3G session */
3098 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3099 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3100 RTE_CRYPTO_AUTH_OP_GENERATE,
3101 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3102 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3103 tdata->key.data, tdata->key.len,
3104 tdata->aad.len, tdata->digest.len);
3107 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3109 /* clear mbuf payload */
3110 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3111 rte_pktmbuf_tailroom(ut_params->ibuf));
3113 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3114 /* Append data which is padded to a multiple of */
3115 /* the algorithms block size */
3116 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3117 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3119 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3121 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3123 /* Create SNOW 3G operation */
3124 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3125 tdata->digest.len, tdata->aad.data,
3126 tdata->aad.len, /*tdata->plaintext.len,*/
3127 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3128 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3129 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3130 tdata->iv.data, tdata->iv.len,
3131 tdata->validCipherLenInBits.len,
3132 tdata->validCipherOffsetLenInBits.len,
3133 tdata->validAuthLenInBits.len,
3134 tdata->validAuthOffsetLenInBits.len
3139 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3141 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3142 ut_params->obuf = ut_params->op->sym->m_src;
3143 if (ut_params->obuf)
3144 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3145 + tdata->iv.len + tdata->aad.len;
3147 ciphertext = plaintext;
3149 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3151 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3153 tdata->ciphertext.data,
3154 tdata->validDataLenInBits.len,
3155 "SNOW 3G Ciphertext data not as expected");
3157 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3158 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3161 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3164 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3165 "SNOW 3G Generated auth tag not as expected");
3169 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3171 struct crypto_testsuite_params *ts_params = &testsuite_params;
3172 struct crypto_unittest_params *ut_params = &unittest_params;
3176 uint8_t *plaintext, *ciphertext;
3177 unsigned plaintext_pad_len;
3178 unsigned plaintext_len;
3180 /* Create SNOW 3G session */
3181 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3182 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3183 RTE_CRYPTO_AUTH_OP_GENERATE,
3184 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3185 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3186 tdata->key.data, tdata->key.len,
3187 tdata->aad.len, tdata->digest.len);
3191 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3193 /* clear mbuf payload */
3194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3195 rte_pktmbuf_tailroom(ut_params->ibuf));
3197 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3198 /* Append data which is padded to a multiple of */
3199 /* the algorithms block size */
3200 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3201 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3203 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3205 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3207 /* Create SNOW 3G operation */
3208 retval = create_wireless_algo_auth_cipher_operation(
3210 tdata->iv.data, tdata->iv.len,
3211 tdata->aad.data, tdata->aad.len,
3213 tdata->validCipherLenInBits.len,
3214 tdata->validCipherOffsetLenInBits.len,
3215 tdata->validAuthLenInBits.len,
3216 tdata->validAuthOffsetLenInBits.len,
3217 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3218 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3224 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3226 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3227 ut_params->obuf = ut_params->op->sym->m_src;
3228 if (ut_params->obuf)
3229 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3230 + tdata->aad.len + tdata->iv.len;
3232 ciphertext = plaintext;
3234 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3235 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3236 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3239 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3241 tdata->ciphertext.data,
3242 tdata->validDataLenInBits.len,
3243 "SNOW 3G Ciphertext data not as expected");
3246 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3249 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3250 "SNOW 3G Generated auth tag not as expected");
3255 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3257 struct crypto_testsuite_params *ts_params = &testsuite_params;
3258 struct crypto_unittest_params *ut_params = &unittest_params;
3262 uint8_t *plaintext, *ciphertext;
3263 unsigned plaintext_pad_len;
3264 unsigned plaintext_len;
3266 /* Create KASUMI session */
3267 retval = create_wireless_algo_auth_cipher_session(
3268 ts_params->valid_devs[0],
3269 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3270 RTE_CRYPTO_AUTH_OP_GENERATE,
3271 RTE_CRYPTO_AUTH_KASUMI_F9,
3272 RTE_CRYPTO_CIPHER_KASUMI_F8,
3273 tdata->key.data, tdata->key.len,
3274 tdata->aad.len, tdata->digest.len);
3277 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3279 /* clear mbuf payload */
3280 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3281 rte_pktmbuf_tailroom(ut_params->ibuf));
3283 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3284 /* Append data which is padded to a multiple of */
3285 /* the algorithms block size */
3286 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3287 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3289 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3291 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3293 /* Create KASUMI operation */
3294 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3295 tdata->iv.data, tdata->iv.len,
3296 tdata->aad.data, tdata->aad.len,
3298 tdata->validCipherLenInBits.len,
3299 tdata->validCipherOffsetLenInBits.len,
3300 tdata->validAuthLenInBits.len,
3301 tdata->validAuthOffsetLenInBits.len,
3302 RTE_CRYPTO_AUTH_KASUMI_F9,
3303 RTE_CRYPTO_CIPHER_KASUMI_F8
3309 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3311 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3312 ut_params->obuf = ut_params->op->sym->m_src;
3313 if (ut_params->obuf)
3314 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3315 + tdata->iv.len + tdata->aad.len;
3317 ciphertext = plaintext;
3320 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3322 tdata->ciphertext.data,
3323 tdata->validCipherLenInBits.len,
3324 "KASUMI Ciphertext data not as expected");
3325 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3326 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3329 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3332 DIGEST_BYTE_LENGTH_KASUMI_F9,
3333 "KASUMI Generated auth tag not as expected");
3338 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3340 struct crypto_testsuite_params *ts_params = &testsuite_params;
3341 struct crypto_unittest_params *ut_params = &unittest_params;
3345 uint8_t *plaintext, *ciphertext;
3346 unsigned plaintext_pad_len;
3347 unsigned plaintext_len;
3349 /* Create KASUMI session */
3350 retval = create_wireless_algo_cipher_auth_session(
3351 ts_params->valid_devs[0],
3352 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3353 RTE_CRYPTO_AUTH_OP_GENERATE,
3354 RTE_CRYPTO_AUTH_KASUMI_F9,
3355 RTE_CRYPTO_CIPHER_KASUMI_F8,
3356 tdata->key.data, tdata->key.len,
3357 tdata->aad.len, tdata->digest.len);
3361 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3363 /* clear mbuf payload */
3364 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3365 rte_pktmbuf_tailroom(ut_params->ibuf));
3367 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3368 /* Append data which is padded to a multiple of */
3369 /* the algorithms block size */
3370 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3371 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3373 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3375 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3377 /* Create KASUMI operation */
3378 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3379 tdata->digest.len, tdata->aad.data,
3381 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3382 RTE_CRYPTO_AUTH_KASUMI_F9,
3383 RTE_CRYPTO_CIPHER_KASUMI_F8,
3384 tdata->iv.data, tdata->iv.len,
3385 tdata->validCipherLenInBits.len,
3386 tdata->validCipherOffsetLenInBits.len,
3387 tdata->validAuthLenInBits.len,
3388 tdata->validAuthOffsetLenInBits.len
3393 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3395 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3396 ut_params->obuf = ut_params->op->sym->m_src;
3397 if (ut_params->obuf)
3398 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3399 + tdata->aad.len + tdata->iv.len;
3401 ciphertext = plaintext;
3403 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3404 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3407 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3409 tdata->ciphertext.data,
3410 tdata->validCipherLenInBits.len,
3411 "KASUMI Ciphertext data not as expected");
3414 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3417 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3418 "KASUMI Generated auth tag not as expected");
3423 test_zuc_encryption(const struct zuc_test_data *tdata)
3425 struct crypto_testsuite_params *ts_params = &testsuite_params;
3426 struct crypto_unittest_params *ut_params = &unittest_params;
3429 uint8_t *plaintext, *ciphertext;
3430 unsigned plaintext_pad_len;
3431 unsigned plaintext_len;
3433 /* Create ZUC session */
3434 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3435 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3436 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3437 tdata->key.data, tdata->key.len);
3441 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3443 /* Clear mbuf payload */
3444 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3445 rte_pktmbuf_tailroom(ut_params->ibuf));
3447 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3448 /* Append data which is padded to a multiple */
3449 /* of the algorithms block size */
3450 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3451 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3453 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3455 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3457 /* Create ZUC operation */
3458 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3459 tdata->plaintext.len,
3460 tdata->validCipherOffsetLenInBits.len,
3461 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3465 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3467 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3469 ut_params->obuf = ut_params->op->sym->m_dst;
3470 if (ut_params->obuf)
3471 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3474 ciphertext = plaintext;
3476 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3479 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3481 tdata->ciphertext.data,
3482 tdata->validCipherLenInBits.len,
3483 "ZUC Ciphertext data not as expected");
3488 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3490 struct crypto_testsuite_params *ts_params = &testsuite_params;
3491 struct crypto_unittest_params *ut_params = &unittest_params;
3494 unsigned plaintext_pad_len;
3495 unsigned plaintext_len;
3498 /* Create ZUC session */
3499 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3500 tdata->key.data, tdata->key.len,
3501 tdata->aad.len, tdata->digest.len,
3502 RTE_CRYPTO_AUTH_OP_GENERATE,
3503 RTE_CRYPTO_AUTH_ZUC_EIA3);
3507 /* alloc mbuf and set payload */
3508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3510 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3511 rte_pktmbuf_tailroom(ut_params->ibuf));
3513 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3514 /* Append data which is padded to a multiple of */
3515 /* the algorithms block size */
3516 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3517 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3519 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3521 /* Create ZUC operation */
3522 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3523 tdata->aad.data, tdata->aad.len,
3524 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3525 RTE_CRYPTO_AUTH_ZUC_EIA3,
3526 tdata->validAuthLenInBits.len,
3527 tdata->validAuthOffsetLenInBits.len);
3531 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3533 ut_params->obuf = ut_params->op->sym->m_src;
3534 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3535 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3536 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3539 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3542 DIGEST_BYTE_LENGTH_KASUMI_F9,
3543 "ZUC Generated auth tag not as expected");
3549 test_kasumi_encryption_test_case_1(void)
3551 return test_kasumi_encryption(&kasumi_test_case_1);
3555 test_kasumi_encryption_test_case_1_oop(void)
3557 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3561 test_kasumi_encryption_test_case_2(void)
3563 return test_kasumi_encryption(&kasumi_test_case_2);
3567 test_kasumi_encryption_test_case_3(void)
3569 return test_kasumi_encryption(&kasumi_test_case_3);
3573 test_kasumi_encryption_test_case_4(void)
3575 return test_kasumi_encryption(&kasumi_test_case_4);
3579 test_kasumi_encryption_test_case_5(void)
3581 return test_kasumi_encryption(&kasumi_test_case_5);
3585 test_kasumi_decryption_test_case_1(void)
3587 return test_kasumi_decryption(&kasumi_test_case_1);
3591 test_kasumi_decryption_test_case_1_oop(void)
3593 return test_kasumi_decryption_oop(&kasumi_test_case_1);
3597 test_kasumi_decryption_test_case_2(void)
3599 return test_kasumi_decryption(&kasumi_test_case_2);
3603 test_kasumi_decryption_test_case_3(void)
3605 return test_kasumi_decryption(&kasumi_test_case_3);
3609 test_kasumi_decryption_test_case_4(void)
3611 return test_kasumi_decryption(&kasumi_test_case_4);
3615 test_kasumi_decryption_test_case_5(void)
3617 return test_kasumi_decryption(&kasumi_test_case_5);
3620 test_snow3g_encryption_test_case_1(void)
3622 return test_snow3g_encryption(&snow3g_test_case_1);
3626 test_snow3g_encryption_test_case_1_oop(void)
3628 return test_snow3g_encryption_oop(&snow3g_test_case_1);
3632 test_snow3g_encryption_test_case_1_offset_oop(void)
3634 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
3638 test_snow3g_encryption_test_case_2(void)
3640 return test_snow3g_encryption(&snow3g_test_case_2);
3644 test_snow3g_encryption_test_case_3(void)
3646 return test_snow3g_encryption(&snow3g_test_case_3);
3650 test_snow3g_encryption_test_case_4(void)
3652 return test_snow3g_encryption(&snow3g_test_case_4);
3656 test_snow3g_encryption_test_case_5(void)
3658 return test_snow3g_encryption(&snow3g_test_case_5);
3662 test_snow3g_decryption_test_case_1(void)
3664 return test_snow3g_decryption(&snow3g_test_case_1);
3668 test_snow3g_decryption_test_case_1_oop(void)
3670 return test_snow3g_decryption_oop(&snow3g_test_case_1);
3674 test_snow3g_decryption_test_case_2(void)
3676 return test_snow3g_decryption(&snow3g_test_case_2);
3680 test_snow3g_decryption_test_case_3(void)
3682 return test_snow3g_decryption(&snow3g_test_case_3);
3686 test_snow3g_decryption_test_case_4(void)
3688 return test_snow3g_decryption(&snow3g_test_case_4);
3692 test_snow3g_decryption_test_case_5(void)
3694 return test_snow3g_decryption(&snow3g_test_case_5);
3697 test_snow3g_cipher_auth_test_case_1(void)
3699 return test_snow3g_cipher_auth(&snow3g_test_case_3);
3703 test_snow3g_auth_cipher_test_case_1(void)
3705 return test_snow3g_auth_cipher(&snow3g_test_case_6);
3709 test_kasumi_auth_cipher_test_case_1(void)
3711 return test_kasumi_auth_cipher(&kasumi_test_case_3);
3715 test_kasumi_cipher_auth_test_case_1(void)
3717 return test_kasumi_cipher_auth(&kasumi_test_case_6);
3721 test_zuc_encryption_test_case_1(void)
3723 return test_zuc_encryption(&zuc_test_case_1);
3727 test_zuc_encryption_test_case_2(void)
3729 return test_zuc_encryption(&zuc_test_case_2);
3733 test_zuc_encryption_test_case_3(void)
3735 return test_zuc_encryption(&zuc_test_case_3);
3739 test_zuc_encryption_test_case_4(void)
3741 return test_zuc_encryption(&zuc_test_case_4);
3745 test_zuc_encryption_test_case_5(void)
3747 return test_zuc_encryption(&zuc_test_case_5);
3751 test_zuc_hash_generate_test_case_1(void)
3753 return test_zuc_authentication(&zuc_hash_test_case_1);
3757 test_zuc_hash_generate_test_case_2(void)
3759 return test_zuc_authentication(&zuc_hash_test_case_2);
3763 test_zuc_hash_generate_test_case_3(void)
3765 return test_zuc_authentication(&zuc_hash_test_case_3);
3769 test_zuc_hash_generate_test_case_4(void)
3771 return test_zuc_authentication(&zuc_hash_test_case_4);
3775 test_zuc_hash_generate_test_case_5(void)
3777 return test_zuc_authentication(&zuc_hash_test_case_5);
3781 test_3DES_chain_qat_all(void)
3783 struct crypto_testsuite_params *ts_params = &testsuite_params;
3786 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3787 ts_params->op_mpool, ts_params->valid_devs[0],
3788 RTE_CRYPTODEV_QAT_SYM_PMD,
3789 BLKCIPHER_3DES_CHAIN_TYPE);
3791 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3793 return TEST_SUCCESS;
3797 test_3DES_cipheronly_qat_all(void)
3799 struct crypto_testsuite_params *ts_params = &testsuite_params;
3802 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3803 ts_params->op_mpool, ts_params->valid_devs[0],
3804 RTE_CRYPTODEV_QAT_SYM_PMD,
3805 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3807 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3809 return TEST_SUCCESS;
3813 test_3DES_chain_libcrypto_all(void)
3815 struct crypto_testsuite_params *ts_params = &testsuite_params;
3818 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3819 ts_params->op_mpool, ts_params->valid_devs[0],
3820 RTE_CRYPTODEV_LIBCRYPTO_PMD,
3821 BLKCIPHER_3DES_CHAIN_TYPE);
3823 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3825 return TEST_SUCCESS;
3829 test_3DES_cipheronly_libcrypto_all(void)
3831 struct crypto_testsuite_params *ts_params = &testsuite_params;
3834 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3835 ts_params->op_mpool, ts_params->valid_devs[0],
3836 RTE_CRYPTODEV_LIBCRYPTO_PMD,
3837 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3839 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3841 return TEST_SUCCESS;
3844 /* ***** AES-GCM Tests ***** */
3847 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3848 const uint8_t *key, const uint8_t key_len,
3849 const uint8_t aad_len, const uint8_t auth_len,
3850 enum rte_crypto_auth_operation auth_op)
3852 uint8_t cipher_key[key_len];
3854 struct crypto_unittest_params *ut_params = &unittest_params;
3856 memcpy(cipher_key, key, key_len);
3858 /* Setup Cipher Parameters */
3859 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3860 ut_params->cipher_xform.next = NULL;
3862 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3863 ut_params->auth_xform.auth.op = auth_op;
3864 ut_params->cipher_xform.cipher.op = op;
3865 ut_params->cipher_xform.cipher.key.data = cipher_key;
3866 ut_params->cipher_xform.cipher.key.length = key_len;
3868 TEST_HEXDUMP(stdout, "key:", key, key_len);
3870 /* Setup Authentication Parameters */
3871 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3872 ut_params->auth_xform.next = NULL;
3874 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3876 ut_params->auth_xform.auth.digest_length = auth_len;
3877 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3878 ut_params->auth_xform.auth.key.length = 0;
3879 ut_params->auth_xform.auth.key.data = NULL;
3881 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3882 ut_params->cipher_xform.next = &ut_params->auth_xform;
3884 /* Create Crypto session*/
3885 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3886 &ut_params->cipher_xform);
3887 } else {/* Create Crypto session*/
3888 ut_params->auth_xform.next = &ut_params->cipher_xform;
3889 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3890 &ut_params->auth_xform);
3893 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3899 create_gcm_operation(enum rte_crypto_cipher_operation op,
3900 const uint8_t *auth_tag, const unsigned auth_tag_len,
3901 const uint8_t *iv, const unsigned iv_len,
3902 const uint8_t *aad, const unsigned aad_len,
3903 const unsigned data_len, unsigned data_pad_len)
3905 struct crypto_testsuite_params *ts_params = &testsuite_params;
3906 struct crypto_unittest_params *ut_params = &unittest_params;
3908 unsigned iv_pad_len = 0, aad_buffer_len;
3910 /* Generate Crypto op data structure */
3911 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3912 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3913 TEST_ASSERT_NOT_NULL(ut_params->op,
3914 "Failed to allocate symmetric crypto operation struct");
3916 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3918 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3919 ut_params->ibuf, auth_tag_len);
3920 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3921 "no room to append digest");
3922 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3923 ut_params->ibuf, data_pad_len);
3924 sym_op->auth.digest.length = auth_tag_len;
3926 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3927 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3928 TEST_HEXDUMP(stdout, "digest:",
3929 sym_op->auth.digest.data,
3930 sym_op->auth.digest.length);
3934 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3936 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3937 ut_params->ibuf, iv_pad_len);
3938 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3940 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3941 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3942 sym_op->cipher.iv.length = iv_len;
3944 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3947 * Always allocate the aad up to the block size.
3948 * The cryptodev API calls out -
3949 * - the array must be big enough to hold the AAD, plus any
3950 * space to round this up to the nearest multiple of the
3951 * block size (16 bytes).
3953 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
3955 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
3956 ut_params->ibuf, aad_buffer_len);
3957 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
3958 "no room to prepend aad");
3959 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
3961 sym_op->auth.aad.length = aad_len;
3963 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
3964 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
3966 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
3967 TEST_HEXDUMP(stdout, "aad:",
3968 sym_op->auth.aad.data, aad_len);
3970 sym_op->cipher.data.length = data_len;
3971 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
3973 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
3974 sym_op->auth.data.length = data_len;
3980 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
3982 struct crypto_testsuite_params *ts_params = &testsuite_params;
3983 struct crypto_unittest_params *ut_params = &unittest_params;
3987 uint8_t *plaintext, *ciphertext, *auth_tag;
3988 uint16_t plaintext_pad_len;
3990 /* Create GCM session */
3991 retval = create_gcm_session(ts_params->valid_devs[0],
3992 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3993 tdata->key.data, tdata->key.len,
3994 tdata->aad.len, tdata->auth_tag.len,
3995 RTE_CRYPTO_AUTH_OP_GENERATE);
4000 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4002 /* clear mbuf payload */
4003 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4004 rte_pktmbuf_tailroom(ut_params->ibuf));
4007 * Append data which is padded to a multiple
4008 * of the algorithms block size
4010 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4012 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4014 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4016 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4018 /* Create GCM opertaion */
4019 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4020 tdata->auth_tag.data, tdata->auth_tag.len,
4021 tdata->iv.data, tdata->iv.len,
4022 tdata->aad.data, tdata->aad.len,
4023 tdata->plaintext.len, plaintext_pad_len);
4027 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4029 ut_params->op->sym->m_src = ut_params->ibuf;
4031 /* Process crypto operation */
4032 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4033 ut_params->op), "failed to process sym crypto op");
4035 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4036 "crypto op processing failed");
4038 if (ut_params->op->sym->m_dst) {
4039 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4041 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4042 uint8_t *, plaintext_pad_len);
4044 ciphertext = plaintext;
4045 auth_tag = plaintext + plaintext_pad_len;
4048 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4049 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4052 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4054 tdata->ciphertext.data,
4055 tdata->ciphertext.len,
4056 "GCM Ciphertext data not as expected");
4058 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4060 tdata->auth_tag.data,
4061 tdata->auth_tag.len,
4062 "GCM Generated auth tag not as expected");
4069 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4071 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4075 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4077 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4081 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4083 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4087 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4089 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4093 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4095 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4099 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4101 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4105 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4107 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4111 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4113 struct crypto_testsuite_params *ts_params = &testsuite_params;
4114 struct crypto_unittest_params *ut_params = &unittest_params;
4118 uint8_t *plaintext, *ciphertext;
4119 uint16_t ciphertext_pad_len;
4121 /* Create GCM session */
4122 retval = create_gcm_session(ts_params->valid_devs[0],
4123 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4124 tdata->key.data, tdata->key.len,
4125 tdata->aad.len, tdata->auth_tag.len,
4126 RTE_CRYPTO_AUTH_OP_VERIFY);
4131 /* alloc mbuf and set payload */
4132 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4134 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4135 rte_pktmbuf_tailroom(ut_params->ibuf));
4137 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4139 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4140 ciphertext_pad_len);
4141 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
4143 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4145 /* Create GCM opertaion */
4146 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
4147 tdata->auth_tag.data, tdata->auth_tag.len,
4148 tdata->iv.data, tdata->iv.len,
4149 tdata->aad.data, tdata->aad.len,
4150 tdata->ciphertext.len, ciphertext_pad_len);
4155 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4157 ut_params->op->sym->m_src = ut_params->ibuf;
4159 /* Process crypto operation */
4160 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4161 ut_params->op), "failed to process sym crypto op");
4163 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4164 "crypto op processing failed");
4166 if (ut_params->op->sym->m_dst)
4167 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4170 plaintext = ciphertext;
4172 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4175 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4177 tdata->plaintext.data,
4178 tdata->plaintext.len,
4179 "GCM plaintext data not as expected");
4181 TEST_ASSERT_EQUAL(ut_params->op->status,
4182 RTE_CRYPTO_OP_STATUS_SUCCESS,
4183 "GCM authentication failed");
4188 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4190 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4194 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4196 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4200 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4202 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4206 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4208 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4212 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4214 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4218 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4220 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4224 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4226 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4232 struct crypto_testsuite_params *ts_params = &testsuite_params;
4233 struct rte_cryptodev_stats stats;
4234 struct rte_cryptodev *dev;
4235 cryptodev_stats_get_t temp_pfn;
4237 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4238 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
4239 &stats) == -ENODEV),
4240 "rte_cryptodev_stats_get invalid dev failed");
4241 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
4242 "rte_cryptodev_stats_get invalid Param failed");
4243 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
4244 temp_pfn = dev->dev_ops->stats_get;
4245 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
4246 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
4248 "rte_cryptodev_stats_get invalid Param failed");
4249 dev->dev_ops->stats_get = temp_pfn;
4251 /* Test expected values */
4253 test_AES_CBC_HMAC_SHA1_encrypt_digest();
4255 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4257 "rte_cryptodev_stats_get failed");
4258 TEST_ASSERT((stats.enqueued_count == 1),
4259 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4260 TEST_ASSERT((stats.dequeued_count == 1),
4261 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4262 TEST_ASSERT((stats.enqueue_err_count == 0),
4263 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4264 TEST_ASSERT((stats.dequeue_err_count == 0),
4265 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4267 /* invalid device but should ignore and not reset device stats*/
4268 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
4269 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4271 "rte_cryptodev_stats_get failed");
4272 TEST_ASSERT((stats.enqueued_count == 1),
4273 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4275 /* check that a valid reset clears stats */
4276 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4277 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4279 "rte_cryptodev_stats_get failed");
4280 TEST_ASSERT((stats.enqueued_count == 0),
4281 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4282 TEST_ASSERT((stats.dequeued_count == 0),
4283 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4285 return TEST_SUCCESS;
4288 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
4289 struct crypto_unittest_params *ut_params,
4290 enum rte_crypto_auth_operation op,
4291 const struct HMAC_MD5_vector *test_case)
4295 memcpy(key, test_case->key.data, test_case->key.len);
4297 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4298 ut_params->auth_xform.next = NULL;
4299 ut_params->auth_xform.auth.op = op;
4301 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
4303 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
4304 ut_params->auth_xform.auth.add_auth_data_length = 0;
4305 ut_params->auth_xform.auth.key.length = test_case->key.len;
4306 ut_params->auth_xform.auth.key.data = key;
4308 ut_params->sess = rte_cryptodev_sym_session_create(
4309 ts_params->valid_devs[0], &ut_params->auth_xform);
4311 if (ut_params->sess == NULL)
4314 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4317 rte_pktmbuf_tailroom(ut_params->ibuf));
4322 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
4323 const struct HMAC_MD5_vector *test_case,
4324 uint8_t **plaintext)
4326 uint16_t plaintext_pad_len;
4328 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4330 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4333 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4335 memcpy(*plaintext, test_case->plaintext.data,
4336 test_case->plaintext.len);
4338 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4339 ut_params->ibuf, MD5_DIGEST_LEN);
4340 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4341 "no room to append digest");
4342 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4343 ut_params->ibuf, plaintext_pad_len);
4344 sym_op->auth.digest.length = MD5_DIGEST_LEN;
4346 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
4347 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
4348 test_case->auth_tag.len);
4351 sym_op->auth.data.offset = 0;
4352 sym_op->auth.data.length = test_case->plaintext.len;
4354 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4355 ut_params->op->sym->m_src = ut_params->ibuf;
4361 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
4363 uint16_t plaintext_pad_len;
4364 uint8_t *plaintext, *auth_tag;
4366 struct crypto_testsuite_params *ts_params = &testsuite_params;
4367 struct crypto_unittest_params *ut_params = &unittest_params;
4369 if (MD5_HMAC_create_session(ts_params, ut_params,
4370 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
4373 /* Generate Crypto op data structure */
4374 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4375 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4376 TEST_ASSERT_NOT_NULL(ut_params->op,
4377 "Failed to allocate symmetric crypto operation struct");
4379 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4382 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4385 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4386 ut_params->op), "failed to process sym crypto op");
4388 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4389 "crypto op processing failed");
4391 if (ut_params->op->sym->m_dst) {
4392 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4393 uint8_t *, plaintext_pad_len);
4395 auth_tag = plaintext + plaintext_pad_len;
4398 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4400 test_case->auth_tag.data,
4401 test_case->auth_tag.len,
4402 "HMAC_MD5 generated tag not as expected");
4404 return TEST_SUCCESS;
4408 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
4412 struct crypto_testsuite_params *ts_params = &testsuite_params;
4413 struct crypto_unittest_params *ut_params = &unittest_params;
4415 if (MD5_HMAC_create_session(ts_params, ut_params,
4416 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
4420 /* Generate Crypto op data structure */
4421 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4422 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4423 TEST_ASSERT_NOT_NULL(ut_params->op,
4424 "Failed to allocate symmetric crypto operation struct");
4426 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4429 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4430 ut_params->op), "failed to process sym crypto op");
4432 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4433 "HMAC_MD5 crypto op processing failed");
4435 return TEST_SUCCESS;
4439 test_MD5_HMAC_generate_case_1(void)
4441 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
4445 test_MD5_HMAC_verify_case_1(void)
4447 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
4451 test_MD5_HMAC_generate_case_2(void)
4453 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
4457 test_MD5_HMAC_verify_case_2(void)
4459 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
4463 test_multi_session(void)
4465 struct crypto_testsuite_params *ts_params = &testsuite_params;
4466 struct crypto_unittest_params *ut_params = &unittest_params;
4468 struct rte_cryptodev_info dev_info;
4469 struct rte_cryptodev_sym_session **sessions;
4473 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
4474 aes_cbc_key, hmac_sha512_key);
4477 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4479 sessions = rte_malloc(NULL,
4480 (sizeof(struct rte_cryptodev_sym_session *) *
4481 dev_info.sym.max_nb_sessions) + 1, 0);
4483 /* Create multiple crypto sessions*/
4484 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
4485 sessions[i] = rte_cryptodev_sym_session_create(
4486 ts_params->valid_devs[0],
4487 &ut_params->auth_xform);
4488 TEST_ASSERT_NOT_NULL(sessions[i],
4489 "Session creation failed at session number %u",
4492 /* Attempt to send a request on each session */
4493 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
4497 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
4498 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
4500 "Failed to perform decrypt on request number %u.", i);
4501 /* free crypto operation structure */
4503 rte_crypto_op_free(ut_params->op);
4506 * free mbuf - both obuf and ibuf are usually the same,
4507 * so check if they point at the same address is necessary,
4508 * to avoid freeing the mbuf twice.
4510 if (ut_params->obuf) {
4511 rte_pktmbuf_free(ut_params->obuf);
4512 if (ut_params->ibuf == ut_params->obuf)
4513 ut_params->ibuf = 0;
4514 ut_params->obuf = 0;
4516 if (ut_params->ibuf) {
4517 rte_pktmbuf_free(ut_params->ibuf);
4518 ut_params->ibuf = 0;
4522 /* Next session create should fail */
4523 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
4524 &ut_params->auth_xform);
4525 TEST_ASSERT_NULL(sessions[i],
4526 "Session creation succeeded unexpectedly!");
4528 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
4529 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4534 return TEST_SUCCESS;
4537 struct multi_session_params {
4538 struct crypto_unittest_params ut_params;
4539 uint8_t *cipher_key;
4541 const uint8_t *cipher;
4542 const uint8_t *digest;
4546 #define MB_SESSION_NUMBER 3
4549 test_multi_session_random_usage(void)
4551 struct crypto_testsuite_params *ts_params = &testsuite_params;
4552 struct rte_cryptodev_info dev_info;
4553 struct rte_cryptodev_sym_session **sessions;
4555 struct multi_session_params ut_paramz[] = {
4558 .cipher_key = ms_aes_cbc_key0,
4559 .hmac_key = ms_hmac_key0,
4560 .cipher = ms_aes_cbc_cipher0,
4561 .digest = ms_hmac_digest0,
4562 .iv = ms_aes_cbc_iv0
4565 .cipher_key = ms_aes_cbc_key1,
4566 .hmac_key = ms_hmac_key1,
4567 .cipher = ms_aes_cbc_cipher1,
4568 .digest = ms_hmac_digest1,
4569 .iv = ms_aes_cbc_iv1
4572 .cipher_key = ms_aes_cbc_key2,
4573 .hmac_key = ms_hmac_key2,
4574 .cipher = ms_aes_cbc_cipher2,
4575 .digest = ms_hmac_digest2,
4576 .iv = ms_aes_cbc_iv2
4581 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4583 sessions = rte_malloc(NULL,
4584 (sizeof(struct rte_cryptodev_sym_session *)
4585 * dev_info.sym.max_nb_sessions) + 1, 0);
4587 for (i = 0; i < MB_SESSION_NUMBER; i++) {
4588 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
4589 sizeof(struct crypto_unittest_params));
4591 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
4592 &ut_paramz[i].ut_params,
4593 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
4595 /* Create multiple crypto sessions*/
4596 sessions[i] = rte_cryptodev_sym_session_create(
4597 ts_params->valid_devs[0],
4598 &ut_paramz[i].ut_params.auth_xform);
4600 TEST_ASSERT_NOT_NULL(sessions[i],
4601 "Session creation failed at session number %u",
4607 for (i = 0; i < 40000; i++) {
4609 j = rand() % MB_SESSION_NUMBER;
4611 TEST_ASSERT_SUCCESS(
4612 test_AES_CBC_HMAC_SHA512_decrypt_perform(
4614 &ut_paramz[j].ut_params,
4615 ts_params, ut_paramz[j].cipher,
4616 ut_paramz[j].digest,
4618 "Failed to perform decrypt on request number %u.", i);
4620 if (ut_paramz[j].ut_params.op)
4621 rte_crypto_op_free(ut_paramz[j].ut_params.op);
4624 * free mbuf - both obuf and ibuf are usually the same,
4625 * so check if they point at the same address is necessary,
4626 * to avoid freeing the mbuf twice.
4628 if (ut_paramz[j].ut_params.obuf) {
4629 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
4630 if (ut_paramz[j].ut_params.ibuf
4631 == ut_paramz[j].ut_params.obuf)
4632 ut_paramz[j].ut_params.ibuf = 0;
4633 ut_paramz[j].ut_params.obuf = 0;
4635 if (ut_paramz[j].ut_params.ibuf) {
4636 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
4637 ut_paramz[j].ut_params.ibuf = 0;
4641 for (i = 0; i < MB_SESSION_NUMBER; i++)
4642 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4647 return TEST_SUCCESS;
4651 test_null_cipher_only_operation(void)
4653 struct crypto_testsuite_params *ts_params = &testsuite_params;
4654 struct crypto_unittest_params *ut_params = &unittest_params;
4656 /* Generate test mbuf data and space for digest */
4657 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4658 catch_22_quote, QUOTE_512_BYTES, 0);
4660 /* Setup Cipher Parameters */
4661 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4662 ut_params->cipher_xform.next = NULL;
4664 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4665 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4667 /* Create Crypto session*/
4668 ut_params->sess = rte_cryptodev_sym_session_create(
4669 ts_params->valid_devs[0], &ut_params->cipher_xform);
4670 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4672 /* Generate Crypto op data structure */
4673 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4674 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4675 TEST_ASSERT_NOT_NULL(ut_params->op,
4676 "Failed to allocate symmetric crypto operation struct");
4678 /* Set crypto operation data parameters */
4679 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4681 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4683 /* set crypto operation source mbuf */
4684 sym_op->m_src = ut_params->ibuf;
4686 sym_op->cipher.data.offset = 0;
4687 sym_op->cipher.data.length = QUOTE_512_BYTES;
4689 /* Process crypto operation */
4690 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4692 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4694 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4695 "crypto operation processing failed");
4698 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4699 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4702 "Ciphertext data not as expected");
4704 return TEST_SUCCESS;
4708 test_null_auth_only_operation(void)
4710 struct crypto_testsuite_params *ts_params = &testsuite_params;
4711 struct crypto_unittest_params *ut_params = &unittest_params;
4713 /* Generate test mbuf data and space for digest */
4714 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4715 catch_22_quote, QUOTE_512_BYTES, 0);
4717 /* Setup HMAC Parameters */
4718 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4719 ut_params->auth_xform.next = NULL;
4721 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4722 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4724 /* Create Crypto session*/
4725 ut_params->sess = rte_cryptodev_sym_session_create(
4726 ts_params->valid_devs[0], &ut_params->auth_xform);
4727 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4729 /* Generate Crypto op data structure */
4730 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4731 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4732 TEST_ASSERT_NOT_NULL(ut_params->op,
4733 "Failed to allocate symmetric crypto operation struct");
4735 /* Set crypto operation data parameters */
4736 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4738 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4740 sym_op->m_src = ut_params->ibuf;
4742 sym_op->auth.data.offset = 0;
4743 sym_op->auth.data.length = QUOTE_512_BYTES;
4745 /* Process crypto operation */
4746 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4748 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4750 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4751 "crypto operation processing failed");
4753 return TEST_SUCCESS;
4757 test_null_cipher_auth_operation(void)
4759 struct crypto_testsuite_params *ts_params = &testsuite_params;
4760 struct crypto_unittest_params *ut_params = &unittest_params;
4762 /* Generate test mbuf data and space for digest */
4763 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4764 catch_22_quote, QUOTE_512_BYTES, 0);
4766 /* Setup Cipher Parameters */
4767 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4768 ut_params->cipher_xform.next = &ut_params->auth_xform;
4770 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4771 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4773 /* Setup HMAC Parameters */
4774 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4775 ut_params->auth_xform.next = NULL;
4777 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4778 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4780 /* Create Crypto session*/
4781 ut_params->sess = rte_cryptodev_sym_session_create(
4782 ts_params->valid_devs[0], &ut_params->cipher_xform);
4783 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4785 /* Generate Crypto op data structure */
4786 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4787 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4788 TEST_ASSERT_NOT_NULL(ut_params->op,
4789 "Failed to allocate symmetric crypto operation struct");
4791 /* Set crypto operation data parameters */
4792 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4794 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4796 sym_op->m_src = ut_params->ibuf;
4798 sym_op->cipher.data.offset = 0;
4799 sym_op->cipher.data.length = QUOTE_512_BYTES;
4801 sym_op->auth.data.offset = 0;
4802 sym_op->auth.data.length = QUOTE_512_BYTES;
4804 /* Process crypto operation */
4805 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4807 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4809 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4810 "crypto operation processing failed");
4813 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4814 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4817 "Ciphertext data not as expected");
4819 return TEST_SUCCESS;
4823 test_null_auth_cipher_operation(void)
4825 struct crypto_testsuite_params *ts_params = &testsuite_params;
4826 struct crypto_unittest_params *ut_params = &unittest_params;
4828 /* Generate test mbuf data and space for digest */
4829 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4830 catch_22_quote, QUOTE_512_BYTES, 0);
4832 /* Setup Cipher Parameters */
4833 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4834 ut_params->cipher_xform.next = NULL;
4836 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4837 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4839 /* Setup HMAC Parameters */
4840 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4841 ut_params->auth_xform.next = &ut_params->cipher_xform;
4843 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4844 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4846 /* Create Crypto session*/
4847 ut_params->sess = rte_cryptodev_sym_session_create(
4848 ts_params->valid_devs[0], &ut_params->cipher_xform);
4849 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4851 /* Generate Crypto op data structure */
4852 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4853 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4854 TEST_ASSERT_NOT_NULL(ut_params->op,
4855 "Failed to allocate symmetric crypto operation struct");
4857 /* Set crypto operation data parameters */
4858 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4860 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4862 sym_op->m_src = ut_params->ibuf;
4864 sym_op->cipher.data.offset = 0;
4865 sym_op->cipher.data.length = QUOTE_512_BYTES;
4867 sym_op->auth.data.offset = 0;
4868 sym_op->auth.data.length = QUOTE_512_BYTES;
4870 /* Process crypto operation */
4871 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4873 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4875 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4876 "crypto operation processing failed");
4879 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4880 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4883 "Ciphertext data not as expected");
4885 return TEST_SUCCESS;
4890 test_null_invalid_operation(void)
4892 struct crypto_testsuite_params *ts_params = &testsuite_params;
4893 struct crypto_unittest_params *ut_params = &unittest_params;
4895 /* Setup Cipher Parameters */
4896 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4897 ut_params->cipher_xform.next = NULL;
4899 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
4900 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4902 /* Create Crypto session*/
4903 ut_params->sess = rte_cryptodev_sym_session_create(
4904 ts_params->valid_devs[0], &ut_params->cipher_xform);
4905 TEST_ASSERT_NULL(ut_params->sess,
4906 "Session creation succeeded unexpectedly");
4909 /* Setup HMAC Parameters */
4910 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4911 ut_params->auth_xform.next = NULL;
4913 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
4914 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4916 /* Create Crypto session*/
4917 ut_params->sess = rte_cryptodev_sym_session_create(
4918 ts_params->valid_devs[0], &ut_params->auth_xform);
4919 TEST_ASSERT_NULL(ut_params->sess,
4920 "Session creation succeeded unexpectedly");
4922 return TEST_SUCCESS;
4926 #define NULL_BURST_LENGTH (32)
4929 test_null_burst_operation(void)
4931 struct crypto_testsuite_params *ts_params = &testsuite_params;
4932 struct crypto_unittest_params *ut_params = &unittest_params;
4934 unsigned i, burst_len = NULL_BURST_LENGTH;
4936 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
4937 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
4939 /* Setup Cipher Parameters */
4940 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4941 ut_params->cipher_xform.next = &ut_params->auth_xform;
4943 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4944 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4946 /* Setup HMAC Parameters */
4947 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4948 ut_params->auth_xform.next = NULL;
4950 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4951 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4953 /* Create Crypto session*/
4954 ut_params->sess = rte_cryptodev_sym_session_create(
4955 ts_params->valid_devs[0], &ut_params->cipher_xform);
4956 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4958 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
4959 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
4960 burst_len, "failed to generate burst of crypto ops");
4962 /* Generate an operation for each mbuf in burst */
4963 for (i = 0; i < burst_len; i++) {
4964 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4966 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
4968 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
4972 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
4974 burst[i]->sym->m_src = m;
4977 /* Process crypto operation */
4978 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
4979 0, burst, burst_len),
4981 "Error enqueuing burst");
4983 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
4984 0, burst_dequeued, burst_len),
4986 "Error dequeuing burst");
4989 for (i = 0; i < burst_len; i++) {
4991 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
4992 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
4994 "data not as expected");
4996 rte_pktmbuf_free(burst[i]->sym->m_src);
4997 rte_crypto_op_free(burst[i]);
5000 return TEST_SUCCESS;
5004 generate_gmac_large_plaintext(uint8_t *data)
5008 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5009 memcpy(&data[i], &data[0], 32);
5013 create_gmac_operation(enum rte_crypto_auth_operation op,
5014 const struct gmac_test_data *tdata)
5016 struct crypto_testsuite_params *ts_params = &testsuite_params;
5017 struct crypto_unittest_params *ut_params = &unittest_params;
5018 struct rte_crypto_sym_op *sym_op;
5020 unsigned iv_pad_len;
5021 unsigned aad_pad_len;
5023 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5024 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5027 * Runtime generate the large plain text instead of use hard code
5028 * plain text vector. It is done to avoid create huge source file
5029 * with the test vector.
5031 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5032 generate_gmac_large_plaintext(tdata->aad.data);
5034 /* Generate Crypto op data structure */
5035 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5036 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5037 TEST_ASSERT_NOT_NULL(ut_params->op,
5038 "Failed to allocate symmetric crypto operation struct");
5040 sym_op = ut_params->op->sym;
5041 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5043 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5044 "no room to append aad");
5046 sym_op->auth.aad.length = tdata->aad.len;
5047 sym_op->auth.aad.phys_addr =
5048 rte_pktmbuf_mtophys(ut_params->ibuf);
5049 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5051 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5052 ut_params->ibuf, tdata->gmac_tag.len);
5053 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5054 "no room to append digest");
5056 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5057 ut_params->ibuf, aad_pad_len);
5058 sym_op->auth.digest.length = tdata->gmac_tag.len;
5060 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5061 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
5062 tdata->gmac_tag.len);
5063 TEST_HEXDUMP(stdout, "digest:",
5064 sym_op->auth.digest.data,
5065 sym_op->auth.digest.length);
5068 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5069 ut_params->ibuf, iv_pad_len);
5070 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5072 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5073 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5074 sym_op->cipher.iv.length = tdata->iv.len;
5076 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
5078 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
5080 sym_op->cipher.data.length = 0;
5081 sym_op->cipher.data.offset = 0;
5083 sym_op->auth.data.offset = 0;
5084 sym_op->auth.data.length = 0;
5089 static int create_gmac_session(uint8_t dev_id,
5090 enum rte_crypto_cipher_operation op,
5091 const struct gmac_test_data *tdata,
5092 enum rte_crypto_auth_operation auth_op)
5094 uint8_t cipher_key[tdata->key.len];
5096 struct crypto_unittest_params *ut_params = &unittest_params;
5098 memcpy(cipher_key, tdata->key.data, tdata->key.len);
5100 /* For GMAC we setup cipher parameters */
5101 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5102 ut_params->cipher_xform.next = NULL;
5103 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
5104 ut_params->cipher_xform.cipher.op = op;
5105 ut_params->cipher_xform.cipher.key.data = cipher_key;
5106 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
5108 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5109 ut_params->auth_xform.next = NULL;
5111 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
5112 ut_params->auth_xform.auth.op = auth_op;
5113 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
5114 ut_params->auth_xform.auth.add_auth_data_length = 0;
5115 ut_params->auth_xform.auth.key.length = 0;
5116 ut_params->auth_xform.auth.key.data = NULL;
5118 ut_params->cipher_xform.next = &ut_params->auth_xform;
5120 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5121 &ut_params->cipher_xform);
5123 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5129 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
5131 struct crypto_testsuite_params *ts_params = &testsuite_params;
5132 struct crypto_unittest_params *ut_params = &unittest_params;
5136 uint8_t *auth_tag, *p;
5137 uint16_t aad_pad_len;
5139 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5140 "No GMAC length in the source data");
5142 retval = create_gmac_session(ts_params->valid_devs[0],
5143 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5144 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
5149 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5151 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5152 rte_pktmbuf_tailroom(ut_params->ibuf));
5154 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5156 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
5158 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
5164 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5166 ut_params->op->sym->m_src = ut_params->ibuf;
5168 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5169 ut_params->op), "failed to process sym crypto op");
5171 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5172 "crypto op processing failed");
5174 if (ut_params->op->sym->m_dst) {
5175 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5176 uint8_t *, aad_pad_len);
5178 auth_tag = p + aad_pad_len;
5181 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
5183 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5185 tdata->gmac_tag.data,
5186 tdata->gmac_tag.len,
5187 "GMAC Generated auth tag not as expected");
5193 test_AES_GMAC_authentication_test_case_1(void)
5195 return test_AES_GMAC_authentication(&gmac_test_case_1);
5199 test_AES_GMAC_authentication_test_case_2(void)
5201 return test_AES_GMAC_authentication(&gmac_test_case_2);
5205 test_AES_GMAC_authentication_test_case_3(void)
5207 return test_AES_GMAC_authentication(&gmac_test_case_3);
5211 test_AES_GMAC_authentication_test_case_4(void)
5213 return test_AES_GMAC_authentication(&gmac_test_case_4);
5217 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
5219 struct crypto_testsuite_params *ts_params = &testsuite_params;
5220 struct crypto_unittest_params *ut_params = &unittest_params;
5223 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5224 "No GMAC length in the source data");
5226 retval = create_gmac_session(ts_params->valid_devs[0],
5227 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5228 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
5233 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5235 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5236 rte_pktmbuf_tailroom(ut_params->ibuf));
5238 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
5244 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5246 ut_params->op->sym->m_src = ut_params->ibuf;
5248 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5249 ut_params->op), "failed to process sym crypto op");
5251 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5252 "crypto op processing failed");
5259 test_AES_GMAC_authentication_verify_test_case_1(void)
5261 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
5265 test_AES_GMAC_authentication_verify_test_case_2(void)
5267 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
5271 test_AES_GMAC_authentication_verify_test_case_3(void)
5273 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
5277 test_AES_GMAC_authentication_verify_test_case_4(void)
5279 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
5282 struct test_crypto_vector {
5283 enum rte_crypto_cipher_algorithm crypto_algo;
5296 const uint8_t *data;
5301 const uint8_t *data;
5305 enum rte_crypto_auth_algorithm auth_algo;
5313 const uint8_t *data;
5323 static const struct test_crypto_vector
5324 hmac_sha1_test_crypto_vector = {
5325 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5327 .data = plaintext_hash,
5332 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5333 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5334 0xDE, 0xF4, 0xDE, 0xAD
5340 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
5341 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
5342 0x3F, 0x91, 0x64, 0x59
5348 static const struct test_crypto_vector
5349 aes128_gmac_test_vector = {
5350 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
5351 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
5353 .data = plaintext_hash,
5358 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5359 0x08, 0x09, 0x0A, 0x0B
5365 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5366 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
5372 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
5373 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
5379 static const struct test_crypto_vector
5380 aes128cbc_hmac_sha1_test_vector = {
5381 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
5384 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
5385 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
5391 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5392 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
5397 .data = plaintext_hash,
5401 .data = ciphertext512_aes128cbc,
5404 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5407 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5408 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5409 0xDE, 0xF4, 0xDE, 0xAD
5415 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
5416 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5417 0x18, 0x8C, 0x1D, 0x32
5424 data_corruption(uint8_t *data)
5430 tag_corruption(uint8_t *data, unsigned int tag_offset)
5432 data[tag_offset] += 1;
5436 create_auth_session(struct crypto_unittest_params *ut_params,
5438 const struct test_crypto_vector *reference,
5439 enum rte_crypto_auth_operation auth_op)
5441 uint8_t auth_key[reference->auth_key.len + 1];
5443 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5445 /* Setup Authentication Parameters */
5446 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5447 ut_params->auth_xform.auth.op = auth_op;
5448 ut_params->auth_xform.next = NULL;
5449 ut_params->auth_xform.auth.algo = reference->auth_algo;
5450 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5451 ut_params->auth_xform.auth.key.data = auth_key;
5452 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5453 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5455 /* Create Crypto session*/
5456 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5457 &ut_params->auth_xform);
5459 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5465 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
5467 const struct test_crypto_vector *reference,
5468 enum rte_crypto_auth_operation auth_op,
5469 enum rte_crypto_cipher_operation cipher_op)
5471 uint8_t cipher_key[reference->cipher_key.len + 1];
5472 uint8_t auth_key[reference->auth_key.len + 1];
5474 memcpy(cipher_key, reference->cipher_key.data,
5475 reference->cipher_key.len);
5476 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5478 /* Setup Authentication Parameters */
5479 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5480 ut_params->auth_xform.auth.op = auth_op;
5481 ut_params->auth_xform.next = &ut_params->cipher_xform;
5482 ut_params->auth_xform.auth.algo = reference->auth_algo;
5483 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5484 ut_params->auth_xform.auth.key.data = auth_key;
5485 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5486 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5488 /* Setup Cipher Parameters */
5489 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5490 ut_params->cipher_xform.next = NULL;
5491 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
5492 ut_params->cipher_xform.cipher.op = cipher_op;
5493 ut_params->cipher_xform.cipher.key.data = cipher_key;
5494 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
5496 /* Create Crypto session*/
5497 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5498 &ut_params->auth_xform);
5500 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5506 create_auth_operation(struct crypto_testsuite_params *ts_params,
5507 struct crypto_unittest_params *ut_params,
5508 const struct test_crypto_vector *reference,
5509 unsigned int auth_generate)
5511 /* Generate Crypto op data structure */
5512 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5513 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5514 TEST_ASSERT_NOT_NULL(ut_params->op,
5515 "Failed to allocate pktmbuf offload");
5517 /* Set crypto operation data parameters */
5518 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5520 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5522 /* set crypto operation source mbuf */
5523 sym_op->m_src = ut_params->ibuf;
5526 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5527 ut_params->ibuf, reference->digest.len);
5529 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5530 "no room to append auth tag");
5532 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5533 ut_params->ibuf, reference->plaintext.len);
5534 sym_op->auth.digest.length = reference->digest.len;
5537 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5539 memcpy(sym_op->auth.digest.data,
5540 reference->digest.data,
5541 reference->digest.len);
5543 TEST_HEXDUMP(stdout, "digest:",
5544 sym_op->auth.digest.data,
5545 sym_op->auth.digest.length);
5547 sym_op->auth.data.length = reference->plaintext.len;
5548 sym_op->auth.data.offset = 0;
5554 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
5555 struct crypto_unittest_params *ut_params,
5556 const struct test_crypto_vector *reference,
5557 unsigned int auth_generate)
5559 /* Generate Crypto op data structure */
5560 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5561 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5562 TEST_ASSERT_NOT_NULL(ut_params->op,
5563 "Failed to allocate pktmbuf offload");
5565 /* Set crypto operation data parameters */
5566 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5568 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5570 /* set crypto operation source mbuf */
5571 sym_op->m_src = ut_params->ibuf;
5574 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5575 reference->aad.len);
5576 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
5577 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
5579 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
5581 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5582 sym_op->auth.aad.length = reference->aad.len;
5585 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5586 ut_params->ibuf, reference->digest.len);
5588 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5589 "no room to append auth tag");
5591 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5592 ut_params->ibuf, reference->ciphertext.len);
5593 sym_op->auth.digest.length = reference->digest.len;
5596 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5598 memcpy(sym_op->auth.digest.data,
5599 reference->digest.data,
5600 reference->digest.len);
5602 TEST_HEXDUMP(stdout, "digest:",
5603 sym_op->auth.digest.data,
5604 sym_op->auth.digest.length);
5606 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5607 ut_params->ibuf, reference->iv.len);
5608 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5610 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5611 sym_op->cipher.iv.length = reference->iv.len;
5613 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5615 sym_op->cipher.data.length = 0;
5616 sym_op->cipher.data.offset = 0;
5618 sym_op->auth.data.length = 0;
5619 sym_op->auth.data.offset = 0;
5625 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
5626 struct crypto_unittest_params *ut_params,
5627 const struct test_crypto_vector *reference,
5628 unsigned int auth_generate)
5630 /* Generate Crypto op data structure */
5631 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5632 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5633 TEST_ASSERT_NOT_NULL(ut_params->op,
5634 "Failed to allocate pktmbuf offload");
5636 /* Set crypto operation data parameters */
5637 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5639 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5641 /* set crypto operation source mbuf */
5642 sym_op->m_src = ut_params->ibuf;
5645 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5646 ut_params->ibuf, reference->digest.len);
5648 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5649 "no room to append auth tag");
5651 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5652 ut_params->ibuf, reference->ciphertext.len);
5653 sym_op->auth.digest.length = reference->digest.len;
5656 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5658 memcpy(sym_op->auth.digest.data,
5659 reference->digest.data,
5660 reference->digest.len);
5662 TEST_HEXDUMP(stdout, "digest:",
5663 sym_op->auth.digest.data,
5664 sym_op->auth.digest.length);
5666 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5667 ut_params->ibuf, reference->iv.len);
5668 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5670 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5671 sym_op->cipher.iv.length = reference->iv.len;
5673 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5675 sym_op->cipher.data.length = reference->ciphertext.len;
5676 sym_op->cipher.data.offset = reference->iv.len;
5678 sym_op->auth.data.length = reference->ciphertext.len;
5679 sym_op->auth.data.offset = reference->iv.len;
5685 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5686 struct crypto_unittest_params *ut_params,
5687 const struct test_crypto_vector *reference)
5689 return create_auth_operation(ts_params, ut_params, reference, 0);
5693 create_auth_verify_GMAC_operation(
5694 struct crypto_testsuite_params *ts_params,
5695 struct crypto_unittest_params *ut_params,
5696 const struct test_crypto_vector *reference)
5698 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
5702 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5703 struct crypto_unittest_params *ut_params,
5704 const struct test_crypto_vector *reference)
5706 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
5710 test_authentication_verify_fail_when_data_corruption(
5711 struct crypto_testsuite_params *ts_params,
5712 struct crypto_unittest_params *ut_params,
5713 const struct test_crypto_vector *reference,
5714 unsigned int data_corrupted)
5720 /* Create session */
5721 retval = create_auth_session(ut_params,
5722 ts_params->valid_devs[0],
5724 RTE_CRYPTO_AUTH_OP_VERIFY);
5728 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5729 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5730 "Failed to allocate input buffer in mempool");
5732 /* clear mbuf payload */
5733 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5734 rte_pktmbuf_tailroom(ut_params->ibuf));
5736 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5737 reference->plaintext.len);
5738 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5739 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
5741 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
5743 /* Create operation */
5744 retval = create_auth_verify_operation(ts_params, ut_params, reference);
5750 data_corruption(plaintext);
5752 tag_corruption(plaintext, reference->plaintext.len);
5754 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5756 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5757 TEST_ASSERT_EQUAL(ut_params->op->status,
5758 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5759 "authentication not failed");
5761 ut_params->obuf = ut_params->op->sym->m_src;
5762 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5768 test_authentication_verify_GMAC_fail_when_corruption(
5769 struct crypto_testsuite_params *ts_params,
5770 struct crypto_unittest_params *ut_params,
5771 const struct test_crypto_vector *reference,
5772 unsigned int data_corrupted)
5776 /* Create session */
5777 retval = create_auth_cipher_session(ut_params,
5778 ts_params->valid_devs[0],
5780 RTE_CRYPTO_AUTH_OP_VERIFY,
5781 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5785 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5786 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5787 "Failed to allocate input buffer in mempool");
5789 /* clear mbuf payload */
5790 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5791 rte_pktmbuf_tailroom(ut_params->ibuf));
5793 /* Create operation */
5794 retval = create_auth_verify_GMAC_operation(ts_params,
5802 data_corruption(ut_params->op->sym->auth.aad.data);
5804 tag_corruption(ut_params->op->sym->auth.aad.data,
5805 reference->aad.len);
5807 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5809 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5810 TEST_ASSERT_EQUAL(ut_params->op->status,
5811 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5812 "authentication not failed");
5814 ut_params->obuf = ut_params->op->sym->m_src;
5815 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5821 test_authenticated_decryption_fail_when_corruption(
5822 struct crypto_testsuite_params *ts_params,
5823 struct crypto_unittest_params *ut_params,
5824 const struct test_crypto_vector *reference,
5825 unsigned int data_corrupted)
5829 uint8_t *ciphertext;
5831 /* Create session */
5832 retval = create_auth_cipher_session(ut_params,
5833 ts_params->valid_devs[0],
5835 RTE_CRYPTO_AUTH_OP_VERIFY,
5836 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5840 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5841 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5842 "Failed to allocate input buffer in mempool");
5844 /* clear mbuf payload */
5845 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5846 rte_pktmbuf_tailroom(ut_params->ibuf));
5848 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5849 reference->ciphertext.len);
5850 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
5851 memcpy(ciphertext, reference->ciphertext.data,
5852 reference->ciphertext.len);
5854 /* Create operation */
5855 retval = create_cipher_auth_verify_operation(ts_params,
5863 data_corruption(ciphertext);
5865 tag_corruption(ciphertext, reference->ciphertext.len);
5867 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5870 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5871 TEST_ASSERT_EQUAL(ut_params->op->status,
5872 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5873 "authentication not failed");
5875 ut_params->obuf = ut_params->op->sym->m_src;
5876 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5882 test_authentication_verify_fail_when_data_corrupted(
5883 struct crypto_testsuite_params *ts_params,
5884 struct crypto_unittest_params *ut_params,
5885 const struct test_crypto_vector *reference)
5887 return test_authentication_verify_fail_when_data_corruption(
5888 ts_params, ut_params, reference, 1);
5892 test_authentication_verify_fail_when_tag_corrupted(
5893 struct crypto_testsuite_params *ts_params,
5894 struct crypto_unittest_params *ut_params,
5895 const struct test_crypto_vector *reference)
5897 return test_authentication_verify_fail_when_data_corruption(
5898 ts_params, ut_params, reference, 0);
5902 test_authentication_verify_GMAC_fail_when_data_corrupted(
5903 struct crypto_testsuite_params *ts_params,
5904 struct crypto_unittest_params *ut_params,
5905 const struct test_crypto_vector *reference)
5907 return test_authentication_verify_GMAC_fail_when_corruption(
5908 ts_params, ut_params, reference, 1);
5912 test_authentication_verify_GMAC_fail_when_tag_corrupted(
5913 struct crypto_testsuite_params *ts_params,
5914 struct crypto_unittest_params *ut_params,
5915 const struct test_crypto_vector *reference)
5917 return test_authentication_verify_GMAC_fail_when_corruption(
5918 ts_params, ut_params, reference, 0);
5922 test_authenticated_decryption_fail_when_data_corrupted(
5923 struct crypto_testsuite_params *ts_params,
5924 struct crypto_unittest_params *ut_params,
5925 const struct test_crypto_vector *reference)
5927 return test_authenticated_decryption_fail_when_corruption(
5928 ts_params, ut_params, reference, 1);
5932 test_authenticated_decryption_fail_when_tag_corrupted(
5933 struct crypto_testsuite_params *ts_params,
5934 struct crypto_unittest_params *ut_params,
5935 const struct test_crypto_vector *reference)
5937 return test_authenticated_decryption_fail_when_corruption(
5938 ts_params, ut_params, reference, 0);
5942 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
5944 return test_authentication_verify_fail_when_data_corrupted(
5945 &testsuite_params, &unittest_params,
5946 &hmac_sha1_test_crypto_vector);
5950 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
5952 return test_authentication_verify_fail_when_tag_corrupted(
5953 &testsuite_params, &unittest_params,
5954 &hmac_sha1_test_crypto_vector);
5958 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
5960 return test_authentication_verify_GMAC_fail_when_data_corrupted(
5961 &testsuite_params, &unittest_params,
5962 &aes128_gmac_test_vector);
5966 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
5968 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
5969 &testsuite_params, &unittest_params,
5970 &aes128_gmac_test_vector);
5974 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
5976 return test_authenticated_decryption_fail_when_data_corrupted(
5979 &aes128cbc_hmac_sha1_test_vector);
5983 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
5985 return test_authenticated_decryption_fail_when_tag_corrupted(
5988 &aes128cbc_hmac_sha1_test_vector);
5991 static struct unit_test_suite cryptodev_qat_testsuite = {
5992 .suite_name = "Crypto QAT Unit Test Suite",
5993 .setup = testsuite_setup,
5994 .teardown = testsuite_teardown,
5995 .unit_test_cases = {
5996 TEST_CASE_ST(ut_setup, ut_teardown,
5997 test_device_configure_invalid_dev_id),
5998 TEST_CASE_ST(ut_setup, ut_teardown,
5999 test_device_configure_invalid_queue_pair_ids),
6000 TEST_CASE_ST(ut_setup, ut_teardown,
6001 test_queue_pair_descriptor_setup),
6002 TEST_CASE_ST(ut_setup, ut_teardown,
6003 test_multi_session),
6005 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
6006 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
6007 TEST_CASE_ST(ut_setup, ut_teardown,
6008 test_3DES_cipheronly_qat_all),
6009 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
6011 /** AES GCM Authenticated Encryption */
6012 TEST_CASE_ST(ut_setup, ut_teardown,
6013 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6014 TEST_CASE_ST(ut_setup, ut_teardown,
6015 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6016 TEST_CASE_ST(ut_setup, ut_teardown,
6017 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6018 TEST_CASE_ST(ut_setup, ut_teardown,
6019 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6020 TEST_CASE_ST(ut_setup, ut_teardown,
6021 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6022 TEST_CASE_ST(ut_setup, ut_teardown,
6023 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6024 TEST_CASE_ST(ut_setup, ut_teardown,
6025 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6027 /** AES GCM Authenticated Decryption */
6028 TEST_CASE_ST(ut_setup, ut_teardown,
6029 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6030 TEST_CASE_ST(ut_setup, ut_teardown,
6031 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6032 TEST_CASE_ST(ut_setup, ut_teardown,
6033 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6034 TEST_CASE_ST(ut_setup, ut_teardown,
6035 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6036 TEST_CASE_ST(ut_setup, ut_teardown,
6037 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6038 TEST_CASE_ST(ut_setup, ut_teardown,
6039 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6040 TEST_CASE_ST(ut_setup, ut_teardown,
6041 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6043 /** AES GMAC Authentication */
6044 TEST_CASE_ST(ut_setup, ut_teardown,
6045 test_AES_GMAC_authentication_test_case_1),
6046 TEST_CASE_ST(ut_setup, ut_teardown,
6047 test_AES_GMAC_authentication_verify_test_case_1),
6048 TEST_CASE_ST(ut_setup, ut_teardown,
6049 test_AES_GMAC_authentication_test_case_2),
6050 TEST_CASE_ST(ut_setup, ut_teardown,
6051 test_AES_GMAC_authentication_verify_test_case_2),
6052 TEST_CASE_ST(ut_setup, ut_teardown,
6053 test_AES_GMAC_authentication_test_case_3),
6054 TEST_CASE_ST(ut_setup, ut_teardown,
6055 test_AES_GMAC_authentication_verify_test_case_3),
6057 /** SNOW 3G encrypt only (UEA2) */
6058 TEST_CASE_ST(ut_setup, ut_teardown,
6059 test_snow3g_encryption_test_case_1),
6060 TEST_CASE_ST(ut_setup, ut_teardown,
6061 test_snow3g_encryption_test_case_2),
6062 TEST_CASE_ST(ut_setup, ut_teardown,
6063 test_snow3g_encryption_test_case_3),
6064 TEST_CASE_ST(ut_setup, ut_teardown,
6065 test_snow3g_encryption_test_case_4),
6066 TEST_CASE_ST(ut_setup, ut_teardown,
6067 test_snow3g_encryption_test_case_5),
6069 TEST_CASE_ST(ut_setup, ut_teardown,
6070 test_snow3g_encryption_test_case_1_oop),
6071 TEST_CASE_ST(ut_setup, ut_teardown,
6072 test_snow3g_decryption_test_case_1_oop),
6074 /** SNOW 3G decrypt only (UEA2) */
6075 TEST_CASE_ST(ut_setup, ut_teardown,
6076 test_snow3g_decryption_test_case_1),
6077 TEST_CASE_ST(ut_setup, ut_teardown,
6078 test_snow3g_decryption_test_case_2),
6079 TEST_CASE_ST(ut_setup, ut_teardown,
6080 test_snow3g_decryption_test_case_3),
6081 TEST_CASE_ST(ut_setup, ut_teardown,
6082 test_snow3g_decryption_test_case_4),
6083 TEST_CASE_ST(ut_setup, ut_teardown,
6084 test_snow3g_decryption_test_case_5),
6085 TEST_CASE_ST(ut_setup, ut_teardown,
6086 test_snow3g_hash_generate_test_case_1),
6087 TEST_CASE_ST(ut_setup, ut_teardown,
6088 test_snow3g_hash_generate_test_case_2),
6089 TEST_CASE_ST(ut_setup, ut_teardown,
6090 test_snow3g_hash_generate_test_case_3),
6091 TEST_CASE_ST(ut_setup, ut_teardown,
6092 test_snow3g_hash_verify_test_case_1),
6093 TEST_CASE_ST(ut_setup, ut_teardown,
6094 test_snow3g_hash_verify_test_case_2),
6095 TEST_CASE_ST(ut_setup, ut_teardown,
6096 test_snow3g_hash_verify_test_case_3),
6097 TEST_CASE_ST(ut_setup, ut_teardown,
6098 test_snow3g_cipher_auth_test_case_1),
6099 TEST_CASE_ST(ut_setup, ut_teardown,
6100 test_snow3g_auth_cipher_test_case_1),
6102 /** HMAC_MD5 Authentication */
6103 TEST_CASE_ST(ut_setup, ut_teardown,
6104 test_MD5_HMAC_generate_case_1),
6105 TEST_CASE_ST(ut_setup, ut_teardown,
6106 test_MD5_HMAC_verify_case_1),
6107 TEST_CASE_ST(ut_setup, ut_teardown,
6108 test_MD5_HMAC_generate_case_2),
6109 TEST_CASE_ST(ut_setup, ut_teardown,
6110 test_MD5_HMAC_verify_case_2),
6113 TEST_CASE_ST(ut_setup, ut_teardown,
6114 test_null_auth_only_operation),
6115 TEST_CASE_ST(ut_setup, ut_teardown,
6116 test_null_cipher_only_operation),
6117 TEST_CASE_ST(ut_setup, ut_teardown,
6118 test_null_cipher_auth_operation),
6119 TEST_CASE_ST(ut_setup, ut_teardown,
6120 test_null_auth_cipher_operation),
6122 TEST_CASE_ST(ut_setup, ut_teardown,
6123 test_kasumi_hash_generate_test_case_6),
6126 TEST_CASE_ST(ut_setup, ut_teardown,
6127 test_kasumi_encryption_test_case_1),
6128 TEST_CASE_ST(ut_setup, ut_teardown,
6129 test_kasumi_encryption_test_case_3),
6130 TEST_CASE_ST(ut_setup, ut_teardown,
6131 test_kasumi_auth_cipher_test_case_1),
6132 TEST_CASE_ST(ut_setup, ut_teardown,
6133 test_kasumi_cipher_auth_test_case_1),
6135 TEST_CASES_END() /**< NULL terminate unit test array */
6139 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
6140 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
6141 .setup = testsuite_setup,
6142 .teardown = testsuite_teardown,
6143 .unit_test_cases = {
6144 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
6146 TEST_CASES_END() /**< NULL terminate unit test array */
6150 static struct unit_test_suite cryptodev_libcrypto_testsuite = {
6151 .suite_name = "Crypto Device LIBCRYPTO Unit Test Suite",
6152 .setup = testsuite_setup,
6153 .teardown = testsuite_teardown,
6154 .unit_test_cases = {
6155 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
6156 TEST_CASE_ST(ut_setup, ut_teardown,
6157 test_multi_session_random_usage),
6158 TEST_CASE_ST(ut_setup, ut_teardown,
6159 test_AES_chain_libcrypto_all),
6160 TEST_CASE_ST(ut_setup, ut_teardown,
6161 test_AES_cipheronly_libcrypto_all),
6162 TEST_CASE_ST(ut_setup, ut_teardown,
6163 test_3DES_chain_libcrypto_all),
6164 TEST_CASE_ST(ut_setup, ut_teardown,
6165 test_3DES_cipheronly_libcrypto_all),
6166 TEST_CASE_ST(ut_setup, ut_teardown,
6167 test_authonly_libcrypto_all),
6169 /** AES GCM Authenticated Encryption */
6170 TEST_CASE_ST(ut_setup, ut_teardown,
6171 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6172 TEST_CASE_ST(ut_setup, ut_teardown,
6173 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6174 TEST_CASE_ST(ut_setup, ut_teardown,
6175 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6176 TEST_CASE_ST(ut_setup, ut_teardown,
6177 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6178 TEST_CASE_ST(ut_setup, ut_teardown,
6179 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6180 TEST_CASE_ST(ut_setup, ut_teardown,
6181 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6182 TEST_CASE_ST(ut_setup, ut_teardown,
6183 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6185 /** AES GCM Authenticated Decryption */
6186 TEST_CASE_ST(ut_setup, ut_teardown,
6187 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6188 TEST_CASE_ST(ut_setup, ut_teardown,
6189 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6190 TEST_CASE_ST(ut_setup, ut_teardown,
6191 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6192 TEST_CASE_ST(ut_setup, ut_teardown,
6193 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6194 TEST_CASE_ST(ut_setup, ut_teardown,
6195 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6196 TEST_CASE_ST(ut_setup, ut_teardown,
6197 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6198 TEST_CASE_ST(ut_setup, ut_teardown,
6199 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6201 /** AES GMAC Authentication */
6202 TEST_CASE_ST(ut_setup, ut_teardown,
6203 test_AES_GMAC_authentication_test_case_1),
6204 TEST_CASE_ST(ut_setup, ut_teardown,
6205 test_AES_GMAC_authentication_verify_test_case_1),
6206 TEST_CASE_ST(ut_setup, ut_teardown,
6207 test_AES_GMAC_authentication_test_case_2),
6208 TEST_CASE_ST(ut_setup, ut_teardown,
6209 test_AES_GMAC_authentication_verify_test_case_2),
6210 TEST_CASE_ST(ut_setup, ut_teardown,
6211 test_AES_GMAC_authentication_test_case_3),
6212 TEST_CASE_ST(ut_setup, ut_teardown,
6213 test_AES_GMAC_authentication_verify_test_case_3),
6214 TEST_CASE_ST(ut_setup, ut_teardown,
6215 test_AES_GMAC_authentication_test_case_4),
6216 TEST_CASE_ST(ut_setup, ut_teardown,
6217 test_AES_GMAC_authentication_verify_test_case_4),
6219 /** Negative tests */
6220 TEST_CASE_ST(ut_setup, ut_teardown,
6221 authentication_verify_HMAC_SHA1_fail_data_corrupt),
6222 TEST_CASE_ST(ut_setup, ut_teardown,
6223 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6224 TEST_CASE_ST(ut_setup, ut_teardown,
6225 authentication_verify_AES128_GMAC_fail_data_corrupt),
6226 TEST_CASE_ST(ut_setup, ut_teardown,
6227 authentication_verify_AES128_GMAC_fail_tag_corrupt),
6228 TEST_CASE_ST(ut_setup, ut_teardown,
6229 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6230 TEST_CASE_ST(ut_setup, ut_teardown,
6231 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6233 TEST_CASES_END() /**< NULL terminate unit test array */
6237 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
6238 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
6239 .setup = testsuite_setup,
6240 .teardown = testsuite_teardown,
6241 .unit_test_cases = {
6242 /** AES GCM Authenticated Encryption */
6243 TEST_CASE_ST(ut_setup, ut_teardown,
6244 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6245 TEST_CASE_ST(ut_setup, ut_teardown,
6246 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6247 TEST_CASE_ST(ut_setup, ut_teardown,
6248 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6249 TEST_CASE_ST(ut_setup, ut_teardown,
6250 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6251 TEST_CASE_ST(ut_setup, ut_teardown,
6252 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6253 TEST_CASE_ST(ut_setup, ut_teardown,
6254 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6255 TEST_CASE_ST(ut_setup, ut_teardown,
6256 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6258 /** AES GCM Authenticated Decryption */
6259 TEST_CASE_ST(ut_setup, ut_teardown,
6260 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6261 TEST_CASE_ST(ut_setup, ut_teardown,
6262 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6263 TEST_CASE_ST(ut_setup, ut_teardown,
6264 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6265 TEST_CASE_ST(ut_setup, ut_teardown,
6266 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6267 TEST_CASE_ST(ut_setup, ut_teardown,
6268 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6269 TEST_CASE_ST(ut_setup, ut_teardown,
6270 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6271 TEST_CASE_ST(ut_setup, ut_teardown,
6272 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6274 TEST_CASES_END() /**< NULL terminate unit test array */
6278 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
6279 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
6280 .setup = testsuite_setup,
6281 .teardown = testsuite_teardown,
6282 .unit_test_cases = {
6283 /** KASUMI encrypt only (UEA1) */
6284 TEST_CASE_ST(ut_setup, ut_teardown,
6285 test_kasumi_encryption_test_case_1),
6286 TEST_CASE_ST(ut_setup, ut_teardown,
6287 test_kasumi_encryption_test_case_2),
6288 TEST_CASE_ST(ut_setup, ut_teardown,
6289 test_kasumi_encryption_test_case_3),
6290 TEST_CASE_ST(ut_setup, ut_teardown,
6291 test_kasumi_encryption_test_case_4),
6292 TEST_CASE_ST(ut_setup, ut_teardown,
6293 test_kasumi_encryption_test_case_5),
6294 /** KASUMI decrypt only (UEA1) */
6295 TEST_CASE_ST(ut_setup, ut_teardown,
6296 test_kasumi_decryption_test_case_1),
6297 TEST_CASE_ST(ut_setup, ut_teardown,
6298 test_kasumi_decryption_test_case_2),
6299 TEST_CASE_ST(ut_setup, ut_teardown,
6300 test_kasumi_decryption_test_case_3),
6301 TEST_CASE_ST(ut_setup, ut_teardown,
6302 test_kasumi_decryption_test_case_4),
6303 TEST_CASE_ST(ut_setup, ut_teardown,
6304 test_kasumi_decryption_test_case_5),
6306 TEST_CASE_ST(ut_setup, ut_teardown,
6307 test_kasumi_encryption_test_case_1_oop),
6308 TEST_CASE_ST(ut_setup, ut_teardown,
6309 test_kasumi_decryption_test_case_1_oop),
6311 /** KASUMI hash only (UIA1) */
6312 TEST_CASE_ST(ut_setup, ut_teardown,
6313 test_kasumi_hash_generate_test_case_1),
6314 TEST_CASE_ST(ut_setup, ut_teardown,
6315 test_kasumi_hash_generate_test_case_2),
6316 TEST_CASE_ST(ut_setup, ut_teardown,
6317 test_kasumi_hash_generate_test_case_3),
6318 TEST_CASE_ST(ut_setup, ut_teardown,
6319 test_kasumi_hash_generate_test_case_4),
6320 TEST_CASE_ST(ut_setup, ut_teardown,
6321 test_kasumi_hash_generate_test_case_5),
6322 TEST_CASE_ST(ut_setup, ut_teardown,
6323 test_kasumi_hash_generate_test_case_6),
6324 TEST_CASE_ST(ut_setup, ut_teardown,
6325 test_kasumi_hash_verify_test_case_1),
6326 TEST_CASE_ST(ut_setup, ut_teardown,
6327 test_kasumi_hash_verify_test_case_2),
6328 TEST_CASE_ST(ut_setup, ut_teardown,
6329 test_kasumi_hash_verify_test_case_3),
6330 TEST_CASE_ST(ut_setup, ut_teardown,
6331 test_kasumi_hash_verify_test_case_4),
6332 TEST_CASE_ST(ut_setup, ut_teardown,
6333 test_kasumi_hash_verify_test_case_5),
6334 TEST_CASE_ST(ut_setup, ut_teardown,
6335 test_kasumi_auth_cipher_test_case_1),
6336 TEST_CASE_ST(ut_setup, ut_teardown,
6337 test_kasumi_cipher_auth_test_case_1),
6338 TEST_CASES_END() /**< NULL terminate unit test array */
6341 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
6342 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
6343 .setup = testsuite_setup,
6344 .teardown = testsuite_teardown,
6345 .unit_test_cases = {
6346 /** SNOW 3G encrypt only (UEA2) */
6347 TEST_CASE_ST(ut_setup, ut_teardown,
6348 test_snow3g_encryption_test_case_1),
6349 TEST_CASE_ST(ut_setup, ut_teardown,
6350 test_snow3g_encryption_test_case_2),
6351 TEST_CASE_ST(ut_setup, ut_teardown,
6352 test_snow3g_encryption_test_case_3),
6353 TEST_CASE_ST(ut_setup, ut_teardown,
6354 test_snow3g_encryption_test_case_4),
6355 TEST_CASE_ST(ut_setup, ut_teardown,
6356 test_snow3g_encryption_test_case_5),
6358 TEST_CASE_ST(ut_setup, ut_teardown,
6359 test_snow3g_encryption_test_case_1_oop),
6360 TEST_CASE_ST(ut_setup, ut_teardown,
6361 test_snow3g_decryption_test_case_1_oop),
6363 TEST_CASE_ST(ut_setup, ut_teardown,
6364 test_snow3g_encryption_test_case_1_offset_oop),
6366 /** SNOW 3G decrypt only (UEA2) */
6367 TEST_CASE_ST(ut_setup, ut_teardown,
6368 test_snow3g_decryption_test_case_1),
6369 TEST_CASE_ST(ut_setup, ut_teardown,
6370 test_snow3g_decryption_test_case_2),
6371 TEST_CASE_ST(ut_setup, ut_teardown,
6372 test_snow3g_decryption_test_case_3),
6373 TEST_CASE_ST(ut_setup, ut_teardown,
6374 test_snow3g_decryption_test_case_4),
6375 TEST_CASE_ST(ut_setup, ut_teardown,
6376 test_snow3g_decryption_test_case_5),
6377 TEST_CASE_ST(ut_setup, ut_teardown,
6378 test_snow3g_hash_generate_test_case_1),
6379 TEST_CASE_ST(ut_setup, ut_teardown,
6380 test_snow3g_hash_generate_test_case_2),
6381 TEST_CASE_ST(ut_setup, ut_teardown,
6382 test_snow3g_hash_generate_test_case_3),
6383 /* Tests with buffers which length is not byte-aligned */
6384 TEST_CASE_ST(ut_setup, ut_teardown,
6385 test_snow3g_hash_generate_test_case_4),
6386 TEST_CASE_ST(ut_setup, ut_teardown,
6387 test_snow3g_hash_generate_test_case_5),
6388 TEST_CASE_ST(ut_setup, ut_teardown,
6389 test_snow3g_hash_generate_test_case_6),
6390 TEST_CASE_ST(ut_setup, ut_teardown,
6391 test_snow3g_hash_verify_test_case_1),
6392 TEST_CASE_ST(ut_setup, ut_teardown,
6393 test_snow3g_hash_verify_test_case_2),
6394 TEST_CASE_ST(ut_setup, ut_teardown,
6395 test_snow3g_hash_verify_test_case_3),
6396 /* Tests with buffers which length is not byte-aligned */
6397 TEST_CASE_ST(ut_setup, ut_teardown,
6398 test_snow3g_hash_verify_test_case_4),
6399 TEST_CASE_ST(ut_setup, ut_teardown,
6400 test_snow3g_hash_verify_test_case_5),
6401 TEST_CASE_ST(ut_setup, ut_teardown,
6402 test_snow3g_hash_verify_test_case_6),
6403 TEST_CASE_ST(ut_setup, ut_teardown,
6404 test_snow3g_cipher_auth_test_case_1),
6405 TEST_CASE_ST(ut_setup, ut_teardown,
6406 test_snow3g_auth_cipher_test_case_1),
6408 TEST_CASES_END() /**< NULL terminate unit test array */
6412 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
6413 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
6414 .setup = testsuite_setup,
6415 .teardown = testsuite_teardown,
6416 .unit_test_cases = {
6417 /** ZUC encrypt only (EEA3) */
6418 TEST_CASE_ST(ut_setup, ut_teardown,
6419 test_zuc_encryption_test_case_1),
6420 TEST_CASE_ST(ut_setup, ut_teardown,
6421 test_zuc_encryption_test_case_2),
6422 TEST_CASE_ST(ut_setup, ut_teardown,
6423 test_zuc_encryption_test_case_3),
6424 TEST_CASE_ST(ut_setup, ut_teardown,
6425 test_zuc_encryption_test_case_4),
6426 TEST_CASE_ST(ut_setup, ut_teardown,
6427 test_zuc_encryption_test_case_5),
6428 TEST_CASE_ST(ut_setup, ut_teardown,
6429 test_zuc_hash_generate_test_case_1),
6430 TEST_CASE_ST(ut_setup, ut_teardown,
6431 test_zuc_hash_generate_test_case_2),
6432 TEST_CASE_ST(ut_setup, ut_teardown,
6433 test_zuc_hash_generate_test_case_3),
6434 TEST_CASE_ST(ut_setup, ut_teardown,
6435 test_zuc_hash_generate_test_case_4),
6436 TEST_CASE_ST(ut_setup, ut_teardown,
6437 test_zuc_hash_generate_test_case_5),
6438 TEST_CASES_END() /**< NULL terminate unit test array */
6442 static struct unit_test_suite cryptodev_null_testsuite = {
6443 .suite_name = "Crypto Device NULL Unit Test Suite",
6444 .setup = testsuite_setup,
6445 .teardown = testsuite_teardown,
6446 .unit_test_cases = {
6447 TEST_CASE_ST(ut_setup, ut_teardown,
6448 test_null_auth_only_operation),
6449 TEST_CASE_ST(ut_setup, ut_teardown,
6450 test_null_cipher_only_operation),
6451 TEST_CASE_ST(ut_setup, ut_teardown,
6452 test_null_cipher_auth_operation),
6453 TEST_CASE_ST(ut_setup, ut_teardown,
6454 test_null_auth_cipher_operation),
6455 TEST_CASE_ST(ut_setup, ut_teardown,
6456 test_null_invalid_operation),
6457 TEST_CASE_ST(ut_setup, ut_teardown,
6458 test_null_burst_operation),
6460 TEST_CASES_END() /**< NULL terminate unit test array */
6465 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
6467 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
6468 return unit_test_suite_runner(&cryptodev_qat_testsuite);
6472 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
6474 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
6476 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
6480 test_cryptodev_libcrypto(void)
6482 gbl_cryptodev_type = RTE_CRYPTODEV_LIBCRYPTO_PMD;
6484 return unit_test_suite_runner(&cryptodev_libcrypto_testsuite);
6488 test_cryptodev_aesni_gcm(void)
6490 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
6492 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
6496 test_cryptodev_null(void)
6498 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
6500 return unit_test_suite_runner(&cryptodev_null_testsuite);
6504 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
6506 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
6508 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
6512 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
6514 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
6516 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
6520 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
6522 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
6524 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
6527 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
6528 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
6529 REGISTER_TEST_COMMAND(cryptodev_libcrypto_autotest, test_cryptodev_libcrypto);
6530 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
6531 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
6532 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
6533 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
6534 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);