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.socket_id = SOCKET_ID_ANY;
417 ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
419 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
421 "Failed to configure cryptodev %u",
422 ts_params->valid_devs[0]);
424 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
425 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
426 ts_params->valid_devs[0], qp_id,
428 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
429 "Failed to setup queue pair %u on cryptodev %u",
430 qp_id, ts_params->valid_devs[0]);
434 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
436 /* Start the device */
437 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
438 "Failed to start cryptodev %u",
439 ts_params->valid_devs[0]);
447 struct crypto_testsuite_params *ts_params = &testsuite_params;
448 struct crypto_unittest_params *ut_params = &unittest_params;
449 struct rte_cryptodev_stats stats;
451 /* free crypto session structure */
452 if (ut_params->sess) {
453 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
455 ut_params->sess = NULL;
458 /* free crypto operation structure */
460 rte_crypto_op_free(ut_params->op);
463 * free mbuf - both obuf and ibuf are usually the same,
464 * so check if they point at the same address is necessary,
465 * to avoid freeing the mbuf twice.
467 if (ut_params->obuf) {
468 rte_pktmbuf_free(ut_params->obuf);
469 if (ut_params->ibuf == ut_params->obuf)
473 if (ut_params->ibuf) {
474 rte_pktmbuf_free(ut_params->ibuf);
478 if (ts_params->mbuf_pool != NULL)
479 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
480 rte_mempool_avail_count(ts_params->mbuf_pool));
482 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
484 /* Stop the device */
485 rte_cryptodev_stop(ts_params->valid_devs[0]);
489 test_device_configure_invalid_dev_id(void)
491 struct crypto_testsuite_params *ts_params = &testsuite_params;
492 uint16_t dev_id, num_devs = 0;
494 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
495 "Need at least %d devices for test", 1);
497 /* valid dev_id values */
498 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
500 /* Stop the device in case it's started so it can be configured */
501 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
503 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
504 "Failed test for rte_cryptodev_configure: "
505 "invalid dev_num %u", dev_id);
507 /* invalid dev_id values */
510 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
511 "Failed test for rte_cryptodev_configure: "
512 "invalid dev_num %u", dev_id);
516 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
517 "Failed test for rte_cryptodev_configure:"
518 "invalid dev_num %u", dev_id);
524 test_device_configure_invalid_queue_pair_ids(void)
526 struct crypto_testsuite_params *ts_params = &testsuite_params;
527 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
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);
582 /* revert to original testsuite value */
583 ts_params->conf.nb_queue_pairs = orig_nb_qps;
589 test_queue_pair_descriptor_setup(void)
591 struct crypto_testsuite_params *ts_params = &testsuite_params;
592 struct rte_cryptodev_info dev_info;
593 struct rte_cryptodev_qp_conf qp_conf = {
594 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
599 /* Stop the device in case it's started so it can be configured */
600 rte_cryptodev_stop(ts_params->valid_devs[0]);
603 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
605 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
607 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
608 &ts_params->conf), "Failed to configure cryptodev %u",
609 ts_params->valid_devs[0]);
613 * Test various ring sizes on this device. memzones can't be
614 * freed so are re-used if ring is released and re-created.
616 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
618 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
619 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
620 ts_params->valid_devs[0], qp_id, &qp_conf,
621 rte_cryptodev_socket_id(
622 ts_params->valid_devs[0])),
624 "rte_cryptodev_queue_pair_setup: num_inflights "
625 "%u on qp %u on cryptodev %u",
626 qp_conf.nb_descriptors, qp_id,
627 ts_params->valid_devs[0]);
630 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
632 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
633 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
634 ts_params->valid_devs[0], qp_id, &qp_conf,
635 rte_cryptodev_socket_id(
636 ts_params->valid_devs[0])),
638 " rte_cryptodev_queue_pair_setup: num_inflights"
639 " %u on qp %u on cryptodev %u",
640 qp_conf.nb_descriptors, qp_id,
641 ts_params->valid_devs[0]);
644 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
646 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
647 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
648 ts_params->valid_devs[0], qp_id, &qp_conf,
649 rte_cryptodev_socket_id(
650 ts_params->valid_devs[0])),
652 "rte_cryptodev_queue_pair_setup: num_inflights"
653 " %u on qp %u on cryptodev %u",
654 qp_conf.nb_descriptors, qp_id,
655 ts_params->valid_devs[0]);
658 /* invalid number of descriptors - max supported + 2 */
659 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
661 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
662 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
663 ts_params->valid_devs[0], qp_id, &qp_conf,
664 rte_cryptodev_socket_id(
665 ts_params->valid_devs[0])),
666 "Unexpectedly passed test for "
667 "rte_cryptodev_queue_pair_setup:"
668 "num_inflights %u on qp %u on cryptodev %u",
669 qp_conf.nb_descriptors, qp_id,
670 ts_params->valid_devs[0]);
673 /* invalid number of descriptors - max value of parameter */
674 qp_conf.nb_descriptors = UINT32_MAX-1;
676 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
677 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
678 ts_params->valid_devs[0], qp_id, &qp_conf,
679 rte_cryptodev_socket_id(
680 ts_params->valid_devs[0])),
681 "Unexpectedly passed test for "
682 "rte_cryptodev_queue_pair_setup:"
683 "num_inflights %u on qp %u on cryptodev %u",
684 qp_conf.nb_descriptors, qp_id,
685 ts_params->valid_devs[0]);
688 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
690 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
691 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
692 ts_params->valid_devs[0], qp_id, &qp_conf,
693 rte_cryptodev_socket_id(
694 ts_params->valid_devs[0])),
696 " rte_cryptodev_queue_pair_setup:"
697 "num_inflights %u on qp %u on cryptodev %u",
698 qp_conf.nb_descriptors, qp_id,
699 ts_params->valid_devs[0]);
702 /* invalid number of descriptors - max supported + 1 */
703 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
705 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
706 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
707 ts_params->valid_devs[0], qp_id, &qp_conf,
708 rte_cryptodev_socket_id(
709 ts_params->valid_devs[0])),
710 "Unexpectedly passed test for "
711 "rte_cryptodev_queue_pair_setup:"
712 "num_inflights %u on qp %u on cryptodev %u",
713 qp_conf.nb_descriptors, qp_id,
714 ts_params->valid_devs[0]);
717 /* test invalid queue pair id */
718 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
720 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
722 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
723 ts_params->valid_devs[0],
725 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
726 "Failed test for rte_cryptodev_queue_pair_setup:"
727 "invalid qp %u on cryptodev %u",
728 qp_id, ts_params->valid_devs[0]);
730 qp_id = 0xffff; /*invalid*/
732 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
733 ts_params->valid_devs[0],
735 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
736 "Failed test for rte_cryptodev_queue_pair_setup:"
737 "invalid qp %u on cryptodev %u",
738 qp_id, ts_params->valid_devs[0]);
743 /* ***** Plaintext data for tests ***** */
745 const char catch_22_quote_1[] =
746 "There was only one catch and that was Catch-22, which "
747 "specified that a concern for one's safety in the face of "
748 "dangers that were real and immediate was the process of a "
749 "rational mind. Orr was crazy and could be grounded. All he "
750 "had to do was ask; and as soon as he did, he would no longer "
751 "be crazy and would have to fly more missions. Orr would be "
752 "crazy to fly more missions and sane if he didn't, but if he "
753 "was sane he had to fly them. If he flew them he was crazy "
754 "and didn't have to; but if he didn't want to he was sane and "
755 "had to. Yossarian was moved very deeply by the absolute "
756 "simplicity of this clause of Catch-22 and let out a "
757 "respectful whistle. \"That's some catch, that Catch-22\", he "
758 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
760 const char catch_22_quote[] =
761 "What a lousy earth! He wondered how many people were "
762 "destitute that same night even in his own prosperous country, "
763 "how many homes were shanties, how many husbands were drunk "
764 "and wives socked, and how many children were bullied, abused, "
765 "or abandoned. How many families hungered for food they could "
766 "not afford to buy? How many hearts were broken? How many "
767 "suicides would take place that same night, how many people "
768 "would go insane? How many cockroaches and landlords would "
769 "triumph? How many winners were losers, successes failures, "
770 "and rich men poor men? How many wise guys were stupid? How "
771 "many happy endings were unhappy endings? How many honest men "
772 "were liars, brave men cowards, loyal men traitors, how many "
773 "sainted men were corrupt, how many people in positions of "
774 "trust had sold their souls to bodyguards, how many had never "
775 "had souls? How many straight-and-narrow paths were crooked "
776 "paths? How many best families were worst families and how "
777 "many good people were bad people? When you added them all up "
778 "and then subtracted, you might be left with only the children, "
779 "and perhaps with Albert Einstein and an old violinist or "
780 "sculptor somewhere.";
782 #define QUOTE_480_BYTES (480)
783 #define QUOTE_512_BYTES (512)
784 #define QUOTE_768_BYTES (768)
785 #define QUOTE_1024_BYTES (1024)
789 /* ***** SHA1 Hash Tests ***** */
791 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
793 static uint8_t hmac_sha1_key[] = {
794 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
795 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
796 0xDE, 0xF4, 0xDE, 0xAD };
798 /* ***** SHA224 Hash Tests ***** */
800 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
803 /* ***** AES-CBC Cipher Tests ***** */
805 #define CIPHER_KEY_LENGTH_AES_CBC (16)
806 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
808 static uint8_t aes_cbc_key[] = {
809 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
810 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
812 static uint8_t aes_cbc_iv[] = {
813 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
814 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
817 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
819 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
820 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
821 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
822 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
823 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
824 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
825 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
826 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
827 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
828 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
829 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
830 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
831 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
832 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
833 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
834 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
835 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
836 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
837 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
838 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
839 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
840 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
841 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
842 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
843 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
844 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
845 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
846 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
847 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
848 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
849 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
850 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
851 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
852 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
853 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
854 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
855 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
856 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
857 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
858 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
859 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
860 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
861 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
862 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
863 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
864 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
865 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
866 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
867 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
868 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
869 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
870 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
871 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
872 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
873 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
874 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
875 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
876 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
877 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
878 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
879 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
880 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
881 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
882 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
883 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
886 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
887 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
888 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
889 0x18, 0x8c, 0x1d, 0x32
893 /* Multisession Vector context Test */
895 static uint8_t ms_aes_cbc_key0[] = {
896 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
897 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
900 static uint8_t ms_aes_cbc_iv0[] = {
901 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
902 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
905 static const uint8_t ms_aes_cbc_cipher0[] = {
906 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
907 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
908 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
909 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
910 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
911 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
912 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
913 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
914 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
915 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
916 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
917 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
918 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
919 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
920 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
921 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
922 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
923 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
924 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
925 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
926 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
927 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
928 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
929 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
930 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
931 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
932 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
933 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
934 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
935 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
936 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
937 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
938 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
939 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
940 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
941 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
942 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
943 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
944 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
945 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
946 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
947 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
948 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
949 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
950 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
951 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
952 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
953 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
954 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
955 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
956 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
957 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
958 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
959 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
960 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
961 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
962 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
963 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
964 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
965 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
966 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
967 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
968 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
969 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
973 static uint8_t ms_hmac_key0[] = {
974 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
975 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
976 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
977 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
978 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
979 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
980 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
981 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
984 static const uint8_t ms_hmac_digest0[] = {
985 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
986 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
987 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
988 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
989 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
990 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
991 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
992 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
996 /* Begin session 1 */
998 static uint8_t ms_aes_cbc_key1[] = {
999 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1000 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1003 static uint8_t ms_aes_cbc_iv1[] = {
1004 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1005 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1008 static const uint8_t ms_aes_cbc_cipher1[] = {
1009 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1010 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1011 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1012 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1013 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1014 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1015 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1016 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1017 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1018 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1019 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1020 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1021 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1022 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1023 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1024 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1025 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1026 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1027 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1028 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1029 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1030 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1031 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1032 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1033 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1034 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1035 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1036 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1037 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1038 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1039 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1040 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1041 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1042 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1043 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1044 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1045 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1046 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1047 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1048 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1049 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1050 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1051 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1052 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1053 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1054 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1055 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1056 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1057 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1058 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1059 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1060 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1061 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1062 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1063 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1064 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1065 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1066 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1067 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1068 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1069 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1070 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1071 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1072 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1076 static uint8_t ms_hmac_key1[] = {
1077 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1078 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1079 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1080 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1081 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1082 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1083 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1084 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1087 static const uint8_t ms_hmac_digest1[] = {
1088 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1089 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1090 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1091 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1092 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1093 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1094 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1095 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1098 /* Begin Session 2 */
1099 static uint8_t ms_aes_cbc_key2[] = {
1100 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1101 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1104 static uint8_t ms_aes_cbc_iv2[] = {
1105 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1106 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1109 static const uint8_t ms_aes_cbc_cipher2[] = {
1110 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1111 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1112 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1113 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1114 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1115 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1116 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1117 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1118 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1119 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1120 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1121 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1122 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1123 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1124 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1125 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1126 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1127 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1128 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1129 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1130 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1131 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1132 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1133 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1134 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1135 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1136 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1137 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1138 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1139 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1140 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1141 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1142 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1143 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1144 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1145 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1146 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1147 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1148 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1149 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1150 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1151 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1152 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1153 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1154 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1155 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1156 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1157 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1158 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1159 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1160 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1161 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1162 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1163 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1164 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1165 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1166 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1167 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1168 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1169 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1170 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1171 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1172 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1173 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1176 static uint8_t ms_hmac_key2[] = {
1177 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1178 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1179 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1180 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1181 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1182 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1183 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1184 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1187 static const uint8_t ms_hmac_digest2[] = {
1188 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1189 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1190 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1191 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1192 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1193 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1194 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1195 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1202 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1204 struct crypto_testsuite_params *ts_params = &testsuite_params;
1205 struct crypto_unittest_params *ut_params = &unittest_params;
1207 /* Generate test mbuf data and space for digest */
1208 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1209 catch_22_quote, QUOTE_512_BYTES, 0);
1211 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1212 DIGEST_BYTE_LENGTH_SHA1);
1213 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1215 /* Setup Cipher Parameters */
1216 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1217 ut_params->cipher_xform.next = &ut_params->auth_xform;
1219 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1220 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1221 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1222 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1224 /* Setup HMAC Parameters */
1225 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1227 ut_params->auth_xform.next = NULL;
1229 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1230 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1231 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1232 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1233 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1235 /* Create crypto session*/
1236 ut_params->sess = rte_cryptodev_sym_session_create(
1237 ts_params->valid_devs[0],
1238 &ut_params->cipher_xform);
1239 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1241 /* Generate crypto op data structure */
1242 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1243 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1244 TEST_ASSERT_NOT_NULL(ut_params->op,
1245 "Failed to allocate symmetric crypto operation struct");
1247 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1249 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1251 /* set crypto operation source mbuf */
1252 sym_op->m_src = ut_params->ibuf;
1254 /* Set crypto operation authentication parameters */
1255 sym_op->auth.digest.data = ut_params->digest;
1256 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1257 ut_params->ibuf, QUOTE_512_BYTES);
1258 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1260 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1261 sym_op->auth.data.length = QUOTE_512_BYTES;
1263 /* Set crypto operation cipher parameters */
1264 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1265 CIPHER_IV_LENGTH_AES_CBC);
1266 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1267 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1269 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1270 CIPHER_IV_LENGTH_AES_CBC);
1272 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1273 sym_op->cipher.data.length = QUOTE_512_BYTES;
1275 /* Process crypto operation */
1276 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1277 ut_params->op), "failed to process sym crypto op");
1279 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1280 "crypto op processing failed");
1283 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1284 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1286 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1287 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1289 "ciphertext data not as expected");
1291 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1293 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1294 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1295 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1296 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1297 DIGEST_BYTE_LENGTH_SHA1,
1298 "Generated digest data not as expected");
1300 return TEST_SUCCESS;
1303 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1305 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1307 static uint8_t hmac_sha512_key[] = {
1308 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1309 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1310 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1311 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1312 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1313 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1314 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1315 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1317 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1318 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1319 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1320 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1321 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1322 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1323 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1324 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1325 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1330 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1331 struct crypto_unittest_params *ut_params,
1332 uint8_t *cipher_key,
1336 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1337 struct crypto_unittest_params *ut_params,
1338 struct crypto_testsuite_params *ts_params,
1339 const uint8_t *cipher,
1340 const uint8_t *digest,
1345 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1346 struct crypto_unittest_params *ut_params,
1347 uint8_t *cipher_key,
1351 /* Setup Cipher Parameters */
1352 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1353 ut_params->cipher_xform.next = NULL;
1355 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1356 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1357 ut_params->cipher_xform.cipher.key.data = cipher_key;
1358 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1360 /* Setup HMAC Parameters */
1361 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1362 ut_params->auth_xform.next = &ut_params->cipher_xform;
1364 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1365 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1366 ut_params->auth_xform.auth.key.data = hmac_key;
1367 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1368 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1370 return TEST_SUCCESS;
1375 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1376 struct crypto_unittest_params *ut_params,
1377 struct crypto_testsuite_params *ts_params,
1378 const uint8_t *cipher,
1379 const uint8_t *digest,
1382 /* Generate test mbuf data and digest */
1383 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1386 QUOTE_512_BYTES, 0);
1388 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1389 DIGEST_BYTE_LENGTH_SHA512);
1390 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1392 rte_memcpy(ut_params->digest,
1394 DIGEST_BYTE_LENGTH_SHA512);
1396 /* Generate Crypto op data structure */
1397 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1398 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1399 TEST_ASSERT_NOT_NULL(ut_params->op,
1400 "Failed to allocate symmetric crypto operation struct");
1402 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1404 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1406 /* set crypto operation source mbuf */
1407 sym_op->m_src = ut_params->ibuf;
1409 sym_op->auth.digest.data = ut_params->digest;
1410 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1411 ut_params->ibuf, QUOTE_512_BYTES);
1412 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1414 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1415 sym_op->auth.data.length = QUOTE_512_BYTES;
1417 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1418 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1419 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1420 ut_params->ibuf, 0);
1421 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1423 rte_memcpy(sym_op->cipher.iv.data, iv,
1424 CIPHER_IV_LENGTH_AES_CBC);
1426 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1427 sym_op->cipher.data.length = QUOTE_512_BYTES;
1429 /* Process crypto operation */
1430 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1431 ut_params->op), "failed to process sym crypto op");
1433 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1434 "crypto op processing failed");
1436 ut_params->obuf = ut_params->op->sym->m_src;
1439 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1440 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1441 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1443 "Plaintext data not as expected");
1446 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1447 "Digest verification failed");
1449 return TEST_SUCCESS;
1453 test_AES_chain_mb_all(void)
1455 struct crypto_testsuite_params *ts_params = &testsuite_params;
1458 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1459 ts_params->op_mpool, ts_params->valid_devs[0],
1460 RTE_CRYPTODEV_AESNI_MB_PMD,
1461 BLKCIPHER_AES_CHAIN_TYPE);
1463 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1465 return TEST_SUCCESS;
1469 test_AES_chain_libcrypto_all(void)
1471 struct crypto_testsuite_params *ts_params = &testsuite_params;
1474 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1475 ts_params->op_mpool, ts_params->valid_devs[0],
1476 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1477 BLKCIPHER_AES_CHAIN_TYPE);
1479 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1481 return TEST_SUCCESS;
1485 test_AES_cipheronly_libcrypto_all(void)
1487 struct crypto_testsuite_params *ts_params = &testsuite_params;
1490 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1491 ts_params->op_mpool, ts_params->valid_devs[0],
1492 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1493 BLKCIPHER_AES_CIPHERONLY_TYPE);
1495 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1497 return TEST_SUCCESS;
1501 test_AES_chain_qat_all(void)
1503 struct crypto_testsuite_params *ts_params = &testsuite_params;
1506 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1507 ts_params->op_mpool, ts_params->valid_devs[0],
1508 RTE_CRYPTODEV_QAT_SYM_PMD,
1509 BLKCIPHER_AES_CHAIN_TYPE);
1511 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1513 return TEST_SUCCESS;
1517 test_authonly_libcrypto_all(void)
1519 struct crypto_testsuite_params *ts_params = &testsuite_params;
1522 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1523 ts_params->op_mpool, ts_params->valid_devs[0],
1524 RTE_CRYPTODEV_LIBCRYPTO_PMD,
1525 BLKCIPHER_AUTHONLY_TYPE);
1527 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1529 return TEST_SUCCESS;
1532 /* ***** SNOW 3G Tests ***** */
1534 create_wireless_algo_hash_session(uint8_t dev_id,
1535 const uint8_t *key, const uint8_t key_len,
1536 const uint8_t aad_len, const uint8_t auth_len,
1537 enum rte_crypto_auth_operation op,
1538 enum rte_crypto_auth_algorithm algo)
1540 uint8_t hash_key[key_len];
1542 struct crypto_unittest_params *ut_params = &unittest_params;
1544 memcpy(hash_key, key, key_len);
1546 TEST_HEXDUMP(stdout, "key:", key, key_len);
1548 /* Setup Authentication Parameters */
1549 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1550 ut_params->auth_xform.next = NULL;
1552 ut_params->auth_xform.auth.op = op;
1553 ut_params->auth_xform.auth.algo = algo;
1554 ut_params->auth_xform.auth.key.length = key_len;
1555 ut_params->auth_xform.auth.key.data = hash_key;
1556 ut_params->auth_xform.auth.digest_length = auth_len;
1557 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1558 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1559 &ut_params->auth_xform);
1560 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1565 create_wireless_algo_cipher_session(uint8_t dev_id,
1566 enum rte_crypto_cipher_operation op,
1567 enum rte_crypto_cipher_algorithm algo,
1568 const uint8_t *key, const uint8_t key_len)
1570 uint8_t cipher_key[key_len];
1572 struct crypto_unittest_params *ut_params = &unittest_params;
1574 memcpy(cipher_key, key, key_len);
1576 /* Setup Cipher Parameters */
1577 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1578 ut_params->cipher_xform.next = NULL;
1580 ut_params->cipher_xform.cipher.algo = algo;
1581 ut_params->cipher_xform.cipher.op = op;
1582 ut_params->cipher_xform.cipher.key.data = cipher_key;
1583 ut_params->cipher_xform.cipher.key.length = key_len;
1585 TEST_HEXDUMP(stdout, "key:", key, key_len);
1587 /* Create Crypto session */
1588 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1591 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1596 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1597 const unsigned cipher_len,
1598 const unsigned cipher_offset,
1599 enum rte_crypto_cipher_algorithm algo)
1601 struct crypto_testsuite_params *ts_params = &testsuite_params;
1602 struct crypto_unittest_params *ut_params = &unittest_params;
1603 unsigned iv_pad_len = 0;
1605 /* Generate Crypto op data structure */
1606 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1607 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1608 TEST_ASSERT_NOT_NULL(ut_params->op,
1609 "Failed to allocate pktmbuf offload");
1611 /* Set crypto operation data parameters */
1612 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1614 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1616 /* set crypto operation source mbuf */
1617 sym_op->m_src = ut_params->ibuf;
1620 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1621 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1623 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1625 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1628 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1630 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1631 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1632 sym_op->cipher.iv.length = iv_pad_len;
1634 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1635 sym_op->cipher.data.length = cipher_len;
1636 sym_op->cipher.data.offset = cipher_offset;
1641 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1642 const unsigned cipher_len,
1643 const unsigned cipher_offset,
1644 enum rte_crypto_cipher_algorithm algo)
1646 struct crypto_testsuite_params *ts_params = &testsuite_params;
1647 struct crypto_unittest_params *ut_params = &unittest_params;
1648 unsigned iv_pad_len = 0;
1650 /* Generate Crypto op data structure */
1651 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1652 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1653 TEST_ASSERT_NOT_NULL(ut_params->op,
1654 "Failed to allocate pktmbuf offload");
1656 /* Set crypto operation data parameters */
1657 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1659 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1661 /* set crypto operation source mbuf */
1662 sym_op->m_src = ut_params->ibuf;
1663 sym_op->m_dst = ut_params->obuf;
1666 if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1667 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1669 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1670 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1673 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1675 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1676 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1677 sym_op->cipher.iv.length = iv_pad_len;
1679 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1680 sym_op->cipher.data.length = cipher_len;
1681 sym_op->cipher.data.offset = cipher_offset;
1686 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1687 enum rte_crypto_cipher_operation cipher_op,
1688 enum rte_crypto_auth_operation auth_op,
1689 enum rte_crypto_auth_algorithm auth_algo,
1690 enum rte_crypto_cipher_algorithm cipher_algo,
1691 const uint8_t *key, const uint8_t key_len,
1692 const uint8_t aad_len, const uint8_t auth_len)
1695 uint8_t cipher_auth_key[key_len];
1697 struct crypto_unittest_params *ut_params = &unittest_params;
1699 memcpy(cipher_auth_key, key, key_len);
1701 /* Setup Authentication Parameters */
1702 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1703 ut_params->auth_xform.next = NULL;
1705 ut_params->auth_xform.auth.op = auth_op;
1706 ut_params->auth_xform.auth.algo = auth_algo;
1707 ut_params->auth_xform.auth.key.length = key_len;
1708 /* Hash key = cipher key */
1709 ut_params->auth_xform.auth.key.data = cipher_auth_key;
1710 ut_params->auth_xform.auth.digest_length = auth_len;
1711 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1713 /* Setup Cipher Parameters */
1714 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1715 ut_params->cipher_xform.next = &ut_params->auth_xform;
1717 ut_params->cipher_xform.cipher.algo = cipher_algo;
1718 ut_params->cipher_xform.cipher.op = cipher_op;
1719 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1720 ut_params->cipher_xform.cipher.key.length = key_len;
1722 TEST_HEXDUMP(stdout, "key:", key, key_len);
1724 /* Create Crypto session*/
1725 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1726 &ut_params->cipher_xform);
1728 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1733 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1734 enum rte_crypto_cipher_operation cipher_op,
1735 enum rte_crypto_auth_operation auth_op,
1736 enum rte_crypto_auth_algorithm auth_algo,
1737 enum rte_crypto_cipher_algorithm cipher_algo,
1738 const uint8_t *key, const uint8_t key_len,
1739 const uint8_t aad_len, const uint8_t auth_len)
1741 uint8_t auth_cipher_key[key_len];
1743 struct crypto_unittest_params *ut_params = &unittest_params;
1745 memcpy(auth_cipher_key, key, key_len);
1747 /* Setup Authentication Parameters */
1748 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1749 ut_params->auth_xform.auth.op = auth_op;
1750 ut_params->auth_xform.next = &ut_params->cipher_xform;
1751 ut_params->auth_xform.auth.algo = auth_algo;
1752 ut_params->auth_xform.auth.key.length = key_len;
1753 ut_params->auth_xform.auth.key.data = auth_cipher_key;
1754 ut_params->auth_xform.auth.digest_length = auth_len;
1755 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1757 /* Setup Cipher Parameters */
1758 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1759 ut_params->cipher_xform.next = NULL;
1760 ut_params->cipher_xform.cipher.algo = cipher_algo;
1761 ut_params->cipher_xform.cipher.op = cipher_op;
1762 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1763 ut_params->cipher_xform.cipher.key.length = key_len;
1765 TEST_HEXDUMP(stdout, "key:", key, key_len);
1767 /* Create Crypto session*/
1768 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1769 &ut_params->auth_xform);
1771 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1777 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1778 const unsigned auth_tag_len,
1779 const uint8_t *aad, const unsigned aad_len,
1780 unsigned data_pad_len,
1781 enum rte_crypto_auth_operation op,
1782 enum rte_crypto_auth_algorithm algo,
1783 const unsigned auth_len, const unsigned auth_offset)
1785 struct crypto_testsuite_params *ts_params = &testsuite_params;
1787 struct crypto_unittest_params *ut_params = &unittest_params;
1789 unsigned aad_buffer_len;
1791 /* Generate Crypto op data structure */
1792 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1793 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1794 TEST_ASSERT_NOT_NULL(ut_params->op,
1795 "Failed to allocate pktmbuf offload");
1797 /* Set crypto operation data parameters */
1798 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1800 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1802 /* set crypto operation source mbuf */
1803 sym_op->m_src = ut_params->ibuf;
1807 * Always allocate the aad up to the block size.
1808 * The cryptodev API calls out -
1809 * - the array must be big enough to hold the AAD, plus any
1810 * space to round this up to the nearest multiple of the
1811 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1813 if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1814 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1816 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1817 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1818 ut_params->ibuf, aad_buffer_len);
1819 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1820 "no room to prepend aad");
1821 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1823 sym_op->auth.aad.length = aad_len;
1825 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1826 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1828 TEST_HEXDUMP(stdout, "aad:",
1829 sym_op->auth.aad.data, aad_len);
1832 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1833 ut_params->ibuf, auth_tag_len);
1835 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1836 "no room to append auth tag");
1837 ut_params->digest = sym_op->auth.digest.data;
1838 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1839 ut_params->ibuf, data_pad_len + aad_len);
1840 sym_op->auth.digest.length = auth_tag_len;
1841 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1842 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1844 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1846 TEST_HEXDUMP(stdout, "digest:",
1847 sym_op->auth.digest.data,
1848 sym_op->auth.digest.length);
1850 sym_op->auth.data.length = auth_len;
1851 sym_op->auth.data.offset = auth_offset;
1857 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1858 const unsigned auth_tag_len,
1859 const uint8_t *aad, const uint8_t aad_len,
1860 unsigned data_pad_len,
1861 enum rte_crypto_auth_operation op,
1862 enum rte_crypto_auth_algorithm auth_algo,
1863 enum rte_crypto_cipher_algorithm cipher_algo,
1864 const uint8_t *iv, const uint8_t iv_len,
1865 const unsigned cipher_len, const unsigned cipher_offset,
1866 const unsigned auth_len, const unsigned auth_offset)
1868 struct crypto_testsuite_params *ts_params = &testsuite_params;
1869 struct crypto_unittest_params *ut_params = &unittest_params;
1871 unsigned iv_pad_len = 0;
1872 unsigned aad_buffer_len;
1874 /* Generate Crypto op data structure */
1875 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1876 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1877 TEST_ASSERT_NOT_NULL(ut_params->op,
1878 "Failed to allocate pktmbuf offload");
1879 /* Set crypto operation data parameters */
1880 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1882 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1884 /* set crypto operation source mbuf */
1885 sym_op->m_src = ut_params->ibuf;
1888 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1889 ut_params->ibuf, auth_tag_len);
1891 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1892 "no room to append auth tag");
1893 ut_params->digest = sym_op->auth.digest.data;
1894 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1895 ut_params->ibuf, data_pad_len);
1896 sym_op->auth.digest.length = auth_tag_len;
1897 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1898 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1900 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1902 TEST_HEXDUMP(stdout, "digest:",
1903 sym_op->auth.digest.data,
1904 sym_op->auth.digest.length);
1908 * Always allocate the aad up to the block size.
1909 * The cryptodev API calls out -
1910 * - the array must be big enough to hold the AAD, plus any
1911 * space to round this up to the nearest multiple of the
1912 * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1914 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1915 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1917 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1918 sym_op->auth.aad.data =
1919 (uint8_t *)rte_pktmbuf_prepend(
1920 ut_params->ibuf, aad_buffer_len);
1921 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1922 "no room to prepend aad");
1923 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1925 sym_op->auth.aad.length = aad_len;
1926 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1927 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1928 TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1931 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1932 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1934 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1935 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1936 ut_params->ibuf, iv_pad_len);
1938 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1939 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1940 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1941 sym_op->cipher.iv.length = iv_pad_len;
1942 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1943 sym_op->cipher.data.length = cipher_len;
1944 sym_op->cipher.data.offset = cipher_offset + auth_offset;
1945 sym_op->auth.data.length = auth_len;
1946 sym_op->auth.data.offset = auth_offset + cipher_offset;
1952 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
1953 const uint8_t *iv, const uint8_t iv_len,
1954 const uint8_t *aad, const uint8_t aad_len,
1955 unsigned data_pad_len,
1956 const unsigned cipher_len, const unsigned cipher_offset,
1957 const unsigned auth_len, const unsigned auth_offset,
1958 enum rte_crypto_auth_algorithm auth_algo,
1959 enum rte_crypto_cipher_algorithm cipher_algo)
1961 struct crypto_testsuite_params *ts_params = &testsuite_params;
1962 struct crypto_unittest_params *ut_params = &unittest_params;
1964 unsigned iv_pad_len = 0;
1965 unsigned aad_buffer_len = 0;
1967 /* Generate Crypto op data structure */
1968 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1969 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1970 TEST_ASSERT_NOT_NULL(ut_params->op,
1971 "Failed to allocate pktmbuf offload");
1973 /* Set crypto operation data parameters */
1974 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1976 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1978 /* set crypto operation source mbuf */
1979 sym_op->m_src = ut_params->ibuf;
1982 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1983 ut_params->ibuf, auth_tag_len);
1985 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1986 "no room to append auth tag");
1988 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1989 ut_params->ibuf, data_pad_len);
1990 sym_op->auth.digest.length = auth_tag_len;
1992 memset(sym_op->auth.digest.data, 0, auth_tag_len);
1994 TEST_HEXDUMP(stdout, "digest:",
1995 sym_op->auth.digest.data,
1996 sym_op->auth.digest.length);
2000 * Always allocate the aad up to the block size.
2001 * The cryptodev API calls out -
2002 * - the array must be big enough to hold the AAD, plus any
2003 * space to round this up to the nearest multiple of the
2004 * block size (8 bytes for KASUMI 16 bytes).
2006 if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2007 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2009 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2010 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2011 ut_params->ibuf, aad_buffer_len);
2012 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2013 "no room to prepend aad");
2014 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2016 sym_op->auth.aad.length = aad_len;
2017 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2018 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2019 TEST_HEXDUMP(stdout, "aad:",
2020 sym_op->auth.aad.data, aad_len);
2023 if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2024 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2026 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2028 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2029 ut_params->ibuf, iv_pad_len);
2030 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2032 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2033 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2034 sym_op->cipher.iv.length = iv_pad_len;
2036 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2038 sym_op->cipher.data.length = cipher_len;
2039 sym_op->cipher.data.offset = auth_offset + cipher_offset;
2041 sym_op->auth.data.length = auth_len;
2042 sym_op->auth.data.offset = auth_offset + cipher_offset;
2048 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2050 struct crypto_testsuite_params *ts_params = &testsuite_params;
2051 struct crypto_unittest_params *ut_params = &unittest_params;
2054 unsigned plaintext_pad_len;
2055 unsigned plaintext_len;
2058 /* Create SNOW 3G session */
2059 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2060 tdata->key.data, tdata->key.len,
2061 tdata->aad.len, tdata->digest.len,
2062 RTE_CRYPTO_AUTH_OP_GENERATE,
2063 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2067 /* alloc mbuf and set payload */
2068 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2070 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2071 rte_pktmbuf_tailroom(ut_params->ibuf));
2073 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2074 /* Append data which is padded to a multiple of */
2075 /* the algorithms block size */
2076 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2077 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2079 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2081 /* Create SNOW 3G operation */
2082 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2083 tdata->aad.data, tdata->aad.len,
2084 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2085 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2086 tdata->validAuthLenInBits.len,
2087 tdata->validAuthOffsetLenInBits.len);
2091 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2093 ut_params->obuf = ut_params->op->sym->m_src;
2094 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2095 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2096 + plaintext_pad_len + tdata->aad.len;
2099 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2102 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2103 "SNOW 3G Generated auth tag not as expected");
2109 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2111 struct crypto_testsuite_params *ts_params = &testsuite_params;
2112 struct crypto_unittest_params *ut_params = &unittest_params;
2115 unsigned plaintext_pad_len;
2116 unsigned plaintext_len;
2119 /* Create SNOW 3G session */
2120 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2121 tdata->key.data, tdata->key.len,
2122 tdata->aad.len, tdata->digest.len,
2123 RTE_CRYPTO_AUTH_OP_VERIFY,
2124 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2127 /* alloc mbuf and set payload */
2128 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2130 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2131 rte_pktmbuf_tailroom(ut_params->ibuf));
2133 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2134 /* Append data which is padded to a multiple of */
2135 /* the algorithms block size */
2136 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2137 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2139 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2141 /* Create SNOW 3G operation */
2142 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2144 tdata->aad.data, tdata->aad.len,
2146 RTE_CRYPTO_AUTH_OP_VERIFY,
2147 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2148 tdata->validAuthLenInBits.len,
2149 tdata->validAuthOffsetLenInBits.len);
2153 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2155 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2156 ut_params->obuf = ut_params->op->sym->m_src;
2157 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2158 + plaintext_pad_len + tdata->aad.len;
2161 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2170 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2172 struct crypto_testsuite_params *ts_params = &testsuite_params;
2173 struct crypto_unittest_params *ut_params = &unittest_params;
2176 unsigned plaintext_pad_len;
2177 unsigned plaintext_len;
2180 /* Create KASUMI session */
2181 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2182 tdata->key.data, tdata->key.len,
2183 tdata->aad.len, tdata->digest.len,
2184 RTE_CRYPTO_AUTH_OP_GENERATE,
2185 RTE_CRYPTO_AUTH_KASUMI_F9);
2189 /* alloc mbuf and set payload */
2190 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2192 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2193 rte_pktmbuf_tailroom(ut_params->ibuf));
2195 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2196 /* Append data which is padded to a multiple of */
2197 /* the algorithms block size */
2198 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2199 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2201 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2203 /* Create KASUMI operation */
2204 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2205 tdata->aad.data, tdata->aad.len,
2206 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2207 RTE_CRYPTO_AUTH_KASUMI_F9,
2208 tdata->validAuthLenInBits.len,
2209 tdata->validAuthOffsetLenInBits.len);
2213 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2215 ut_params->obuf = ut_params->op->sym->m_src;
2216 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2217 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2218 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2221 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2224 DIGEST_BYTE_LENGTH_KASUMI_F9,
2225 "KASUMI Generated auth tag not as expected");
2231 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2233 struct crypto_testsuite_params *ts_params = &testsuite_params;
2234 struct crypto_unittest_params *ut_params = &unittest_params;
2237 unsigned plaintext_pad_len;
2238 unsigned plaintext_len;
2241 /* Create KASUMI session */
2242 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2243 tdata->key.data, tdata->key.len,
2244 tdata->aad.len, tdata->digest.len,
2245 RTE_CRYPTO_AUTH_OP_VERIFY,
2246 RTE_CRYPTO_AUTH_KASUMI_F9);
2249 /* alloc mbuf and set payload */
2250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2252 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2253 rte_pktmbuf_tailroom(ut_params->ibuf));
2255 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2256 /* Append data which is padded to a multiple */
2257 /* of the algorithms block size */
2258 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2259 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2261 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2263 /* Create KASUMI operation */
2264 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2266 tdata->aad.data, tdata->aad.len,
2268 RTE_CRYPTO_AUTH_OP_VERIFY,
2269 RTE_CRYPTO_AUTH_KASUMI_F9,
2270 tdata->validAuthLenInBits.len,
2271 tdata->validAuthOffsetLenInBits.len);
2275 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2277 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2278 ut_params->obuf = ut_params->op->sym->m_src;
2279 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2280 + plaintext_pad_len + tdata->aad.len;
2283 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2292 test_snow3g_hash_generate_test_case_1(void)
2294 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2298 test_snow3g_hash_generate_test_case_2(void)
2300 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2304 test_snow3g_hash_generate_test_case_3(void)
2306 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2310 test_snow3g_hash_generate_test_case_4(void)
2312 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2316 test_snow3g_hash_generate_test_case_5(void)
2318 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2322 test_snow3g_hash_generate_test_case_6(void)
2324 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2328 test_snow3g_hash_verify_test_case_1(void)
2330 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2335 test_snow3g_hash_verify_test_case_2(void)
2337 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2341 test_snow3g_hash_verify_test_case_3(void)
2343 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2347 test_snow3g_hash_verify_test_case_4(void)
2349 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2353 test_snow3g_hash_verify_test_case_5(void)
2355 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2359 test_snow3g_hash_verify_test_case_6(void)
2361 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2365 test_kasumi_hash_generate_test_case_1(void)
2367 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2371 test_kasumi_hash_generate_test_case_2(void)
2373 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2377 test_kasumi_hash_generate_test_case_3(void)
2379 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2383 test_kasumi_hash_generate_test_case_4(void)
2385 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2389 test_kasumi_hash_generate_test_case_5(void)
2391 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2395 test_kasumi_hash_generate_test_case_6(void)
2397 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2401 test_kasumi_hash_verify_test_case_1(void)
2403 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2407 test_kasumi_hash_verify_test_case_2(void)
2409 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2413 test_kasumi_hash_verify_test_case_3(void)
2415 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2419 test_kasumi_hash_verify_test_case_4(void)
2421 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2425 test_kasumi_hash_verify_test_case_5(void)
2427 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2431 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2433 struct crypto_testsuite_params *ts_params = &testsuite_params;
2434 struct crypto_unittest_params *ut_params = &unittest_params;
2437 uint8_t *plaintext, *ciphertext;
2438 unsigned plaintext_pad_len;
2439 unsigned plaintext_len;
2441 /* Create KASUMI session */
2442 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2443 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2444 RTE_CRYPTO_CIPHER_KASUMI_F8,
2445 tdata->key.data, tdata->key.len);
2449 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2451 /* Clear mbuf payload */
2452 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2453 rte_pktmbuf_tailroom(ut_params->ibuf));
2455 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2456 /* Append data which is padded to a multiple */
2457 /* of the algorithms block size */
2458 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2459 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2461 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2463 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2465 /* Create KASUMI operation */
2466 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2467 tdata->plaintext.len,
2468 tdata->validCipherOffsetLenInBits.len,
2469 RTE_CRYPTO_CIPHER_KASUMI_F8);
2473 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2475 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2477 ut_params->obuf = ut_params->op->sym->m_dst;
2478 if (ut_params->obuf)
2479 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2482 ciphertext = plaintext;
2484 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2487 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2489 tdata->ciphertext.data,
2490 tdata->validCipherLenInBits.len,
2491 "KASUMI Ciphertext data not as expected");
2496 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2498 struct crypto_testsuite_params *ts_params = &testsuite_params;
2499 struct crypto_unittest_params *ut_params = &unittest_params;
2502 uint8_t *plaintext, *ciphertext;
2503 unsigned plaintext_pad_len;
2504 unsigned plaintext_len;
2506 /* Create KASUMI session */
2507 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2508 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2509 RTE_CRYPTO_CIPHER_KASUMI_F8,
2510 tdata->key.data, tdata->key.len);
2514 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2515 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2517 /* Clear mbuf payload */
2518 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2519 rte_pktmbuf_tailroom(ut_params->ibuf));
2521 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2522 /* Append data which is padded to a multiple */
2523 /* of the algorithms block size */
2524 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2525 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2527 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2528 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2530 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2532 /* Create KASUMI operation */
2533 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2535 tdata->plaintext.len,
2536 tdata->validCipherOffsetLenInBits.len,
2537 RTE_CRYPTO_CIPHER_KASUMI_F8);
2541 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2543 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2545 ut_params->obuf = ut_params->op->sym->m_dst;
2546 if (ut_params->obuf)
2547 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2550 ciphertext = plaintext;
2552 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2555 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2557 tdata->ciphertext.data,
2558 tdata->validCipherLenInBits.len,
2559 "KASUMI Ciphertext data not as expected");
2564 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2566 struct crypto_testsuite_params *ts_params = &testsuite_params;
2567 struct crypto_unittest_params *ut_params = &unittest_params;
2570 uint8_t *ciphertext, *plaintext;
2571 unsigned ciphertext_pad_len;
2572 unsigned ciphertext_len;
2574 /* Create KASUMI session */
2575 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2576 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2577 RTE_CRYPTO_CIPHER_KASUMI_F8,
2578 tdata->key.data, tdata->key.len);
2582 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2583 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2585 /* Clear mbuf payload */
2586 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2587 rte_pktmbuf_tailroom(ut_params->ibuf));
2589 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2590 /* Append data which is padded to a multiple */
2591 /* of the algorithms block size */
2592 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2593 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2594 ciphertext_pad_len);
2595 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2596 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2598 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2600 /* Create KASUMI operation */
2601 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2603 tdata->ciphertext.len,
2604 tdata->validCipherOffsetLenInBits.len,
2605 RTE_CRYPTO_CIPHER_KASUMI_F8);
2609 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2611 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2613 ut_params->obuf = ut_params->op->sym->m_dst;
2614 if (ut_params->obuf)
2615 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2618 plaintext = ciphertext;
2620 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2623 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2625 tdata->plaintext.data,
2626 tdata->validCipherLenInBits.len,
2627 "KASUMI Plaintext data not as expected");
2632 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2634 struct crypto_testsuite_params *ts_params = &testsuite_params;
2635 struct crypto_unittest_params *ut_params = &unittest_params;
2638 uint8_t *ciphertext, *plaintext;
2639 unsigned ciphertext_pad_len;
2640 unsigned ciphertext_len;
2642 /* Create KASUMI session */
2643 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2644 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2645 RTE_CRYPTO_CIPHER_KASUMI_F8,
2646 tdata->key.data, tdata->key.len);
2650 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2652 /* Clear mbuf payload */
2653 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2654 rte_pktmbuf_tailroom(ut_params->ibuf));
2656 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2657 /* Append data which is padded to a multiple */
2658 /* of the algorithms block size */
2659 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2660 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2661 ciphertext_pad_len);
2662 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2664 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2666 /* Create KASUMI operation */
2667 retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2669 tdata->ciphertext.len,
2670 tdata->validCipherOffsetLenInBits.len,
2671 RTE_CRYPTO_CIPHER_KASUMI_F8);
2675 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2677 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2679 ut_params->obuf = ut_params->op->sym->m_dst;
2680 if (ut_params->obuf)
2681 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2684 plaintext = ciphertext;
2686 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2689 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2691 tdata->plaintext.data,
2692 tdata->validCipherLenInBits.len,
2693 "KASUMI Plaintext data not as expected");
2698 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2700 struct crypto_testsuite_params *ts_params = &testsuite_params;
2701 struct crypto_unittest_params *ut_params = &unittest_params;
2704 uint8_t *plaintext, *ciphertext;
2705 unsigned plaintext_pad_len;
2706 unsigned plaintext_len;
2708 /* Create SNOW 3G session */
2709 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2710 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2711 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2712 tdata->key.data, tdata->key.len);
2716 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2718 /* Clear mbuf payload */
2719 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2720 rte_pktmbuf_tailroom(ut_params->ibuf));
2722 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2723 /* Append data which is padded to a multiple of */
2724 /* the algorithms block size */
2725 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2726 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2728 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2730 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2732 /* Create SNOW 3G operation */
2733 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2734 tdata->validCipherLenInBits.len,
2735 tdata->validCipherOffsetLenInBits.len,
2736 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2740 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2742 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2744 ut_params->obuf = ut_params->op->sym->m_dst;
2745 if (ut_params->obuf)
2746 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2749 ciphertext = plaintext;
2751 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2754 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2756 tdata->ciphertext.data,
2757 tdata->validDataLenInBits.len,
2758 "SNOW 3G Ciphertext data not as expected");
2764 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2766 struct crypto_testsuite_params *ts_params = &testsuite_params;
2767 struct crypto_unittest_params *ut_params = &unittest_params;
2768 uint8_t *plaintext, *ciphertext;
2771 unsigned plaintext_pad_len;
2772 unsigned plaintext_len;
2774 /* Create SNOW 3G session */
2775 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2776 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2777 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2778 tdata->key.data, tdata->key.len);
2782 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2783 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2785 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2786 "Failed to allocate input buffer in mempool");
2787 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2788 "Failed to allocate output buffer in mempool");
2790 /* Clear mbuf payload */
2791 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2792 rte_pktmbuf_tailroom(ut_params->ibuf));
2794 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2795 /* Append data which is padded to a multiple of */
2796 /* the algorithms block size */
2797 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2798 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2800 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2801 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2803 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2805 /* Create SNOW 3G operation */
2806 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2808 tdata->validCipherLenInBits.len,
2809 tdata->validCipherOffsetLenInBits.len,
2810 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2814 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2816 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2818 ut_params->obuf = ut_params->op->sym->m_dst;
2819 if (ut_params->obuf)
2820 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2823 ciphertext = plaintext;
2825 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2828 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2830 tdata->ciphertext.data,
2831 tdata->validDataLenInBits.len,
2832 "SNOW 3G Ciphertext data not as expected");
2836 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2838 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2840 uint8_t curr_byte, prev_byte;
2841 uint32_t length_in_bytes = ceil_byte_length(length + offset);
2842 uint8_t lower_byte_mask = (1 << offset) - 1;
2845 prev_byte = buffer[0];
2846 buffer[0] >>= offset;
2848 for (i = 1; i < length_in_bytes; i++) {
2849 curr_byte = buffer[i];
2850 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2851 (curr_byte >> offset);
2852 prev_byte = curr_byte;
2857 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2859 struct crypto_testsuite_params *ts_params = &testsuite_params;
2860 struct crypto_unittest_params *ut_params = &unittest_params;
2861 uint8_t *plaintext, *ciphertext;
2863 uint32_t plaintext_len;
2864 uint32_t plaintext_pad_len;
2865 uint8_t extra_offset = 4;
2866 uint8_t *expected_ciphertext_shifted;
2868 /* Create SNOW 3G session */
2869 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2870 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2871 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2872 tdata->key.data, tdata->key.len);
2876 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2877 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2879 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2880 "Failed to allocate input buffer in mempool");
2881 TEST_ASSERT_NOT_NULL(ut_params->obuf,
2882 "Failed to allocate output buffer in mempool");
2884 /* Clear mbuf payload */
2885 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2886 rte_pktmbuf_tailroom(ut_params->ibuf));
2888 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2890 * Append data which is padded to a
2891 * multiple of the algorithms block size
2893 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2895 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2898 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2900 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2901 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2903 #ifdef RTE_APP_TEST_DEBUG
2904 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2906 /* Create SNOW 3G operation */
2907 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2909 tdata->validCipherLenInBits.len,
2910 tdata->validCipherOffsetLenInBits.len +
2912 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2916 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2918 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2920 ut_params->obuf = ut_params->op->sym->m_dst;
2921 if (ut_params->obuf)
2922 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2925 ciphertext = plaintext;
2927 #ifdef RTE_APP_TEST_DEBUG
2928 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2931 expected_ciphertext_shifted = rte_malloc(NULL,
2932 ceil_byte_length(plaintext_len + extra_offset), 0);
2934 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2935 "failed to reserve memory for ciphertext shifted\n");
2937 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
2938 ceil_byte_length(tdata->ciphertext.len));
2939 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
2942 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
2944 expected_ciphertext_shifted,
2945 tdata->validDataLenInBits.len,
2947 "SNOW 3G Ciphertext data not as expected");
2951 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2953 struct crypto_testsuite_params *ts_params = &testsuite_params;
2954 struct crypto_unittest_params *ut_params = &unittest_params;
2958 uint8_t *plaintext, *ciphertext;
2959 unsigned ciphertext_pad_len;
2960 unsigned ciphertext_len;
2962 /* Create SNOW 3G session */
2963 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2964 RTE_CRYPTO_CIPHER_OP_DECRYPT,
2965 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2966 tdata->key.data, tdata->key.len);
2970 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2972 /* Clear mbuf payload */
2973 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2974 rte_pktmbuf_tailroom(ut_params->ibuf));
2976 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2977 /* Append data which is padded to a multiple of */
2978 /* the algorithms block size */
2979 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
2980 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2981 ciphertext_pad_len);
2982 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2984 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2986 /* Create SNOW 3G operation */
2987 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2988 tdata->validCipherLenInBits.len,
2989 tdata->validCipherOffsetLenInBits.len,
2990 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2994 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2996 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2997 ut_params->obuf = ut_params->op->sym->m_dst;
2998 if (ut_params->obuf)
2999 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3002 plaintext = ciphertext;
3004 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3007 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3008 tdata->plaintext.data,
3009 tdata->validDataLenInBits.len,
3010 "SNOW 3G Plaintext data not as expected");
3014 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3016 struct crypto_testsuite_params *ts_params = &testsuite_params;
3017 struct crypto_unittest_params *ut_params = &unittest_params;
3021 uint8_t *plaintext, *ciphertext;
3022 unsigned ciphertext_pad_len;
3023 unsigned ciphertext_len;
3025 /* Create SNOW 3G session */
3026 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3027 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3028 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3029 tdata->key.data, tdata->key.len);
3033 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3034 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3036 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3037 "Failed to allocate input buffer");
3038 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3039 "Failed to allocate output buffer");
3041 /* Clear mbuf payload */
3042 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3043 rte_pktmbuf_tailroom(ut_params->ibuf));
3045 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3046 rte_pktmbuf_tailroom(ut_params->obuf));
3048 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3049 /* Append data which is padded to a multiple of */
3050 /* the algorithms block size */
3051 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3052 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3053 ciphertext_pad_len);
3054 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3055 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3057 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3059 /* Create SNOW 3G operation */
3060 retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3062 tdata->validCipherLenInBits.len,
3063 tdata->validCipherOffsetLenInBits.len,
3064 RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3068 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3070 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3071 ut_params->obuf = ut_params->op->sym->m_dst;
3072 if (ut_params->obuf)
3073 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3076 plaintext = ciphertext;
3078 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3081 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3082 tdata->plaintext.data,
3083 tdata->validDataLenInBits.len,
3084 "SNOW 3G Plaintext data not as expected");
3089 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3091 struct crypto_testsuite_params *ts_params = &testsuite_params;
3092 struct crypto_unittest_params *ut_params = &unittest_params;
3096 uint8_t *plaintext, *ciphertext;
3097 unsigned plaintext_pad_len;
3098 unsigned plaintext_len;
3100 /* Create SNOW 3G session */
3101 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3102 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3103 RTE_CRYPTO_AUTH_OP_GENERATE,
3104 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3105 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3106 tdata->key.data, tdata->key.len,
3107 tdata->aad.len, tdata->digest.len);
3110 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3112 /* clear mbuf payload */
3113 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3114 rte_pktmbuf_tailroom(ut_params->ibuf));
3116 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3117 /* Append data which is padded to a multiple of */
3118 /* the algorithms block size */
3119 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3120 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3122 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3124 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3126 /* Create SNOW 3G operation */
3127 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3128 tdata->digest.len, tdata->aad.data,
3129 tdata->aad.len, /*tdata->plaintext.len,*/
3130 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3131 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3132 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3133 tdata->iv.data, tdata->iv.len,
3134 tdata->validCipherLenInBits.len,
3135 tdata->validCipherOffsetLenInBits.len,
3136 tdata->validAuthLenInBits.len,
3137 tdata->validAuthOffsetLenInBits.len
3142 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3144 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3145 ut_params->obuf = ut_params->op->sym->m_src;
3146 if (ut_params->obuf)
3147 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3148 + tdata->iv.len + tdata->aad.len;
3150 ciphertext = plaintext;
3152 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3154 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3156 tdata->ciphertext.data,
3157 tdata->validDataLenInBits.len,
3158 "SNOW 3G Ciphertext data not as expected");
3160 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3161 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3164 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3167 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3168 "SNOW 3G Generated auth tag not as expected");
3172 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3174 struct crypto_testsuite_params *ts_params = &testsuite_params;
3175 struct crypto_unittest_params *ut_params = &unittest_params;
3179 uint8_t *plaintext, *ciphertext;
3180 unsigned plaintext_pad_len;
3181 unsigned plaintext_len;
3183 /* Create SNOW 3G session */
3184 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3185 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3186 RTE_CRYPTO_AUTH_OP_GENERATE,
3187 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3188 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3189 tdata->key.data, tdata->key.len,
3190 tdata->aad.len, tdata->digest.len);
3194 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3196 /* clear mbuf payload */
3197 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3198 rte_pktmbuf_tailroom(ut_params->ibuf));
3200 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3201 /* Append data which is padded to a multiple of */
3202 /* the algorithms block size */
3203 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3204 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3206 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3208 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3210 /* Create SNOW 3G operation */
3211 retval = create_wireless_algo_auth_cipher_operation(
3213 tdata->iv.data, tdata->iv.len,
3214 tdata->aad.data, tdata->aad.len,
3216 tdata->validCipherLenInBits.len,
3217 tdata->validCipherOffsetLenInBits.len,
3218 tdata->validAuthLenInBits.len,
3219 tdata->validAuthOffsetLenInBits.len,
3220 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3221 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3227 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3229 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3230 ut_params->obuf = ut_params->op->sym->m_src;
3231 if (ut_params->obuf)
3232 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3233 + tdata->aad.len + tdata->iv.len;
3235 ciphertext = plaintext;
3237 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3238 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3239 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3242 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3244 tdata->ciphertext.data,
3245 tdata->validDataLenInBits.len,
3246 "SNOW 3G Ciphertext data not as expected");
3249 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3252 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3253 "SNOW 3G Generated auth tag not as expected");
3258 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3260 struct crypto_testsuite_params *ts_params = &testsuite_params;
3261 struct crypto_unittest_params *ut_params = &unittest_params;
3265 uint8_t *plaintext, *ciphertext;
3266 unsigned plaintext_pad_len;
3267 unsigned plaintext_len;
3269 /* Create KASUMI session */
3270 retval = create_wireless_algo_auth_cipher_session(
3271 ts_params->valid_devs[0],
3272 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3273 RTE_CRYPTO_AUTH_OP_GENERATE,
3274 RTE_CRYPTO_AUTH_KASUMI_F9,
3275 RTE_CRYPTO_CIPHER_KASUMI_F8,
3276 tdata->key.data, tdata->key.len,
3277 tdata->aad.len, tdata->digest.len);
3280 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3282 /* clear mbuf payload */
3283 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3284 rte_pktmbuf_tailroom(ut_params->ibuf));
3286 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3287 /* Append data which is padded to a multiple of */
3288 /* the algorithms block size */
3289 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3290 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3292 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3294 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3296 /* Create KASUMI operation */
3297 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3298 tdata->iv.data, tdata->iv.len,
3299 tdata->aad.data, tdata->aad.len,
3301 tdata->validCipherLenInBits.len,
3302 tdata->validCipherOffsetLenInBits.len,
3303 tdata->validAuthLenInBits.len,
3304 tdata->validAuthOffsetLenInBits.len,
3305 RTE_CRYPTO_AUTH_KASUMI_F9,
3306 RTE_CRYPTO_CIPHER_KASUMI_F8
3312 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3314 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3315 ut_params->obuf = ut_params->op->sym->m_src;
3316 if (ut_params->obuf)
3317 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3318 + tdata->iv.len + tdata->aad.len;
3320 ciphertext = plaintext;
3323 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3325 tdata->ciphertext.data,
3326 tdata->validCipherLenInBits.len,
3327 "KASUMI Ciphertext data not as expected");
3328 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3329 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3332 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3335 DIGEST_BYTE_LENGTH_KASUMI_F9,
3336 "KASUMI Generated auth tag not as expected");
3341 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3343 struct crypto_testsuite_params *ts_params = &testsuite_params;
3344 struct crypto_unittest_params *ut_params = &unittest_params;
3348 uint8_t *plaintext, *ciphertext;
3349 unsigned plaintext_pad_len;
3350 unsigned plaintext_len;
3352 /* Create KASUMI session */
3353 retval = create_wireless_algo_cipher_auth_session(
3354 ts_params->valid_devs[0],
3355 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3356 RTE_CRYPTO_AUTH_OP_GENERATE,
3357 RTE_CRYPTO_AUTH_KASUMI_F9,
3358 RTE_CRYPTO_CIPHER_KASUMI_F8,
3359 tdata->key.data, tdata->key.len,
3360 tdata->aad.len, tdata->digest.len);
3364 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3366 /* clear mbuf payload */
3367 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3368 rte_pktmbuf_tailroom(ut_params->ibuf));
3370 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3371 /* Append data which is padded to a multiple of */
3372 /* the algorithms block size */
3373 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3374 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3376 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3378 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3380 /* Create KASUMI operation */
3381 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3382 tdata->digest.len, tdata->aad.data,
3384 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3385 RTE_CRYPTO_AUTH_KASUMI_F9,
3386 RTE_CRYPTO_CIPHER_KASUMI_F8,
3387 tdata->iv.data, tdata->iv.len,
3388 tdata->validCipherLenInBits.len,
3389 tdata->validCipherOffsetLenInBits.len,
3390 tdata->validAuthLenInBits.len,
3391 tdata->validAuthOffsetLenInBits.len
3396 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3398 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3399 ut_params->obuf = ut_params->op->sym->m_src;
3400 if (ut_params->obuf)
3401 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3402 + tdata->aad.len + tdata->iv.len;
3404 ciphertext = plaintext;
3406 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3407 + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3410 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3412 tdata->ciphertext.data,
3413 tdata->validCipherLenInBits.len,
3414 "KASUMI Ciphertext data not as expected");
3417 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3420 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3421 "KASUMI Generated auth tag not as expected");
3426 test_zuc_encryption(const struct zuc_test_data *tdata)
3428 struct crypto_testsuite_params *ts_params = &testsuite_params;
3429 struct crypto_unittest_params *ut_params = &unittest_params;
3432 uint8_t *plaintext, *ciphertext;
3433 unsigned plaintext_pad_len;
3434 unsigned plaintext_len;
3436 /* Create ZUC session */
3437 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3438 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3439 RTE_CRYPTO_CIPHER_ZUC_EEA3,
3440 tdata->key.data, tdata->key.len);
3444 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3446 /* Clear mbuf payload */
3447 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3448 rte_pktmbuf_tailroom(ut_params->ibuf));
3450 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3451 /* Append data which is padded to a multiple */
3452 /* of the algorithms block size */
3453 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3454 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3456 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3458 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3460 /* Create ZUC operation */
3461 retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3462 tdata->plaintext.len,
3463 tdata->validCipherOffsetLenInBits.len,
3464 RTE_CRYPTO_CIPHER_ZUC_EEA3);
3468 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3470 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3472 ut_params->obuf = ut_params->op->sym->m_dst;
3473 if (ut_params->obuf)
3474 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3477 ciphertext = plaintext;
3479 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3482 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3484 tdata->ciphertext.data,
3485 tdata->validCipherLenInBits.len,
3486 "ZUC Ciphertext data not as expected");
3491 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3493 struct crypto_testsuite_params *ts_params = &testsuite_params;
3494 struct crypto_unittest_params *ut_params = &unittest_params;
3497 unsigned plaintext_pad_len;
3498 unsigned plaintext_len;
3501 /* Create ZUC session */
3502 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3503 tdata->key.data, tdata->key.len,
3504 tdata->aad.len, tdata->digest.len,
3505 RTE_CRYPTO_AUTH_OP_GENERATE,
3506 RTE_CRYPTO_AUTH_ZUC_EIA3);
3510 /* alloc mbuf and set payload */
3511 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3513 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3514 rte_pktmbuf_tailroom(ut_params->ibuf));
3516 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3517 /* Append data which is padded to a multiple of */
3518 /* the algorithms block size */
3519 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3520 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3522 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3524 /* Create ZUC operation */
3525 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3526 tdata->aad.data, tdata->aad.len,
3527 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3528 RTE_CRYPTO_AUTH_ZUC_EIA3,
3529 tdata->validAuthLenInBits.len,
3530 tdata->validAuthOffsetLenInBits.len);
3534 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3536 ut_params->obuf = ut_params->op->sym->m_src;
3537 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3538 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3539 + plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3542 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3545 DIGEST_BYTE_LENGTH_KASUMI_F9,
3546 "ZUC Generated auth tag not as expected");
3552 test_kasumi_encryption_test_case_1(void)
3554 return test_kasumi_encryption(&kasumi_test_case_1);
3558 test_kasumi_encryption_test_case_1_oop(void)
3560 return test_kasumi_encryption_oop(&kasumi_test_case_1);
3564 test_kasumi_encryption_test_case_2(void)
3566 return test_kasumi_encryption(&kasumi_test_case_2);
3570 test_kasumi_encryption_test_case_3(void)
3572 return test_kasumi_encryption(&kasumi_test_case_3);
3576 test_kasumi_encryption_test_case_4(void)
3578 return test_kasumi_encryption(&kasumi_test_case_4);
3582 test_kasumi_encryption_test_case_5(void)
3584 return test_kasumi_encryption(&kasumi_test_case_5);
3588 test_kasumi_decryption_test_case_1(void)
3590 return test_kasumi_decryption(&kasumi_test_case_1);
3594 test_kasumi_decryption_test_case_1_oop(void)
3596 return test_kasumi_decryption_oop(&kasumi_test_case_1);
3600 test_kasumi_decryption_test_case_2(void)
3602 return test_kasumi_decryption(&kasumi_test_case_2);
3606 test_kasumi_decryption_test_case_3(void)
3608 return test_kasumi_decryption(&kasumi_test_case_3);
3612 test_kasumi_decryption_test_case_4(void)
3614 return test_kasumi_decryption(&kasumi_test_case_4);
3618 test_kasumi_decryption_test_case_5(void)
3620 return test_kasumi_decryption(&kasumi_test_case_5);
3623 test_snow3g_encryption_test_case_1(void)
3625 return test_snow3g_encryption(&snow3g_test_case_1);
3629 test_snow3g_encryption_test_case_1_oop(void)
3631 return test_snow3g_encryption_oop(&snow3g_test_case_1);
3635 test_snow3g_encryption_test_case_1_offset_oop(void)
3637 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
3641 test_snow3g_encryption_test_case_2(void)
3643 return test_snow3g_encryption(&snow3g_test_case_2);
3647 test_snow3g_encryption_test_case_3(void)
3649 return test_snow3g_encryption(&snow3g_test_case_3);
3653 test_snow3g_encryption_test_case_4(void)
3655 return test_snow3g_encryption(&snow3g_test_case_4);
3659 test_snow3g_encryption_test_case_5(void)
3661 return test_snow3g_encryption(&snow3g_test_case_5);
3665 test_snow3g_decryption_test_case_1(void)
3667 return test_snow3g_decryption(&snow3g_test_case_1);
3671 test_snow3g_decryption_test_case_1_oop(void)
3673 return test_snow3g_decryption_oop(&snow3g_test_case_1);
3677 test_snow3g_decryption_test_case_2(void)
3679 return test_snow3g_decryption(&snow3g_test_case_2);
3683 test_snow3g_decryption_test_case_3(void)
3685 return test_snow3g_decryption(&snow3g_test_case_3);
3689 test_snow3g_decryption_test_case_4(void)
3691 return test_snow3g_decryption(&snow3g_test_case_4);
3695 test_snow3g_decryption_test_case_5(void)
3697 return test_snow3g_decryption(&snow3g_test_case_5);
3700 test_snow3g_cipher_auth_test_case_1(void)
3702 return test_snow3g_cipher_auth(&snow3g_test_case_3);
3706 test_snow3g_auth_cipher_test_case_1(void)
3708 return test_snow3g_auth_cipher(&snow3g_test_case_6);
3712 test_kasumi_auth_cipher_test_case_1(void)
3714 return test_kasumi_auth_cipher(&kasumi_test_case_3);
3718 test_kasumi_cipher_auth_test_case_1(void)
3720 return test_kasumi_cipher_auth(&kasumi_test_case_6);
3724 test_zuc_encryption_test_case_1(void)
3726 return test_zuc_encryption(&zuc_test_case_1);
3730 test_zuc_encryption_test_case_2(void)
3732 return test_zuc_encryption(&zuc_test_case_2);
3736 test_zuc_encryption_test_case_3(void)
3738 return test_zuc_encryption(&zuc_test_case_3);
3742 test_zuc_encryption_test_case_4(void)
3744 return test_zuc_encryption(&zuc_test_case_4);
3748 test_zuc_encryption_test_case_5(void)
3750 return test_zuc_encryption(&zuc_test_case_5);
3754 test_zuc_hash_generate_test_case_1(void)
3756 return test_zuc_authentication(&zuc_hash_test_case_1);
3760 test_zuc_hash_generate_test_case_2(void)
3762 return test_zuc_authentication(&zuc_hash_test_case_2);
3766 test_zuc_hash_generate_test_case_3(void)
3768 return test_zuc_authentication(&zuc_hash_test_case_3);
3772 test_zuc_hash_generate_test_case_4(void)
3774 return test_zuc_authentication(&zuc_hash_test_case_4);
3778 test_zuc_hash_generate_test_case_5(void)
3780 return test_zuc_authentication(&zuc_hash_test_case_5);
3784 test_3DES_chain_qat_all(void)
3786 struct crypto_testsuite_params *ts_params = &testsuite_params;
3789 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3790 ts_params->op_mpool, ts_params->valid_devs[0],
3791 RTE_CRYPTODEV_QAT_SYM_PMD,
3792 BLKCIPHER_3DES_CHAIN_TYPE);
3794 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3796 return TEST_SUCCESS;
3800 test_3DES_cipheronly_qat_all(void)
3802 struct crypto_testsuite_params *ts_params = &testsuite_params;
3805 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3806 ts_params->op_mpool, ts_params->valid_devs[0],
3807 RTE_CRYPTODEV_QAT_SYM_PMD,
3808 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3810 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3812 return TEST_SUCCESS;
3816 test_3DES_chain_libcrypto_all(void)
3818 struct crypto_testsuite_params *ts_params = &testsuite_params;
3821 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3822 ts_params->op_mpool, ts_params->valid_devs[0],
3823 RTE_CRYPTODEV_LIBCRYPTO_PMD,
3824 BLKCIPHER_3DES_CHAIN_TYPE);
3826 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3828 return TEST_SUCCESS;
3832 test_3DES_cipheronly_libcrypto_all(void)
3834 struct crypto_testsuite_params *ts_params = &testsuite_params;
3837 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3838 ts_params->op_mpool, ts_params->valid_devs[0],
3839 RTE_CRYPTODEV_LIBCRYPTO_PMD,
3840 BLKCIPHER_3DES_CIPHERONLY_TYPE);
3842 TEST_ASSERT_EQUAL(status, 0, "Test failed");
3844 return TEST_SUCCESS;
3847 /* ***** AES-GCM Tests ***** */
3850 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3851 const uint8_t *key, const uint8_t key_len,
3852 const uint8_t aad_len, const uint8_t auth_len,
3853 enum rte_crypto_auth_operation auth_op)
3855 uint8_t cipher_key[key_len];
3857 struct crypto_unittest_params *ut_params = &unittest_params;
3859 memcpy(cipher_key, key, key_len);
3861 /* Setup Cipher Parameters */
3862 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3863 ut_params->cipher_xform.next = NULL;
3865 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3866 ut_params->auth_xform.auth.op = auth_op;
3867 ut_params->cipher_xform.cipher.op = op;
3868 ut_params->cipher_xform.cipher.key.data = cipher_key;
3869 ut_params->cipher_xform.cipher.key.length = key_len;
3871 TEST_HEXDUMP(stdout, "key:", key, key_len);
3873 /* Setup Authentication Parameters */
3874 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3875 ut_params->auth_xform.next = NULL;
3877 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3879 ut_params->auth_xform.auth.digest_length = auth_len;
3880 ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3881 ut_params->auth_xform.auth.key.length = 0;
3882 ut_params->auth_xform.auth.key.data = NULL;
3884 if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3885 ut_params->cipher_xform.next = &ut_params->auth_xform;
3887 /* Create Crypto session*/
3888 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3889 &ut_params->cipher_xform);
3890 } else {/* Create Crypto session*/
3891 ut_params->auth_xform.next = &ut_params->cipher_xform;
3892 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3893 &ut_params->auth_xform);
3896 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3902 create_gcm_operation(enum rte_crypto_cipher_operation op,
3903 const uint8_t *auth_tag, const unsigned auth_tag_len,
3904 const uint8_t *iv, const unsigned iv_len,
3905 const uint8_t *aad, const unsigned aad_len,
3906 const unsigned data_len, unsigned data_pad_len)
3908 struct crypto_testsuite_params *ts_params = &testsuite_params;
3909 struct crypto_unittest_params *ut_params = &unittest_params;
3911 unsigned iv_pad_len = 0, aad_buffer_len;
3913 /* Generate Crypto op data structure */
3914 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3915 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3916 TEST_ASSERT_NOT_NULL(ut_params->op,
3917 "Failed to allocate symmetric crypto operation struct");
3919 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3921 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3922 ut_params->ibuf, auth_tag_len);
3923 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3924 "no room to append digest");
3925 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3926 ut_params->ibuf, data_pad_len);
3927 sym_op->auth.digest.length = auth_tag_len;
3929 if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3930 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3931 TEST_HEXDUMP(stdout, "digest:",
3932 sym_op->auth.digest.data,
3933 sym_op->auth.digest.length);
3937 iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3939 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3940 ut_params->ibuf, iv_pad_len);
3941 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3943 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3944 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3945 sym_op->cipher.iv.length = iv_len;
3947 rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3950 * Always allocate the aad up to the block size.
3951 * The cryptodev API calls out -
3952 * - the array must be big enough to hold the AAD, plus any
3953 * space to round this up to the nearest multiple of the
3954 * block size (16 bytes).
3956 aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
3958 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
3959 ut_params->ibuf, aad_buffer_len);
3960 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
3961 "no room to prepend aad");
3962 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
3964 sym_op->auth.aad.length = aad_len;
3966 memset(sym_op->auth.aad.data, 0, aad_buffer_len);
3967 rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
3969 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
3970 TEST_HEXDUMP(stdout, "aad:",
3971 sym_op->auth.aad.data, aad_len);
3973 sym_op->cipher.data.length = data_len;
3974 sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
3976 sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
3977 sym_op->auth.data.length = data_len;
3983 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
3985 struct crypto_testsuite_params *ts_params = &testsuite_params;
3986 struct crypto_unittest_params *ut_params = &unittest_params;
3990 uint8_t *plaintext, *ciphertext, *auth_tag;
3991 uint16_t plaintext_pad_len;
3993 /* Create GCM session */
3994 retval = create_gcm_session(ts_params->valid_devs[0],
3995 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3996 tdata->key.data, tdata->key.len,
3997 tdata->aad.len, tdata->auth_tag.len,
3998 RTE_CRYPTO_AUTH_OP_GENERATE);
4003 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4005 /* clear mbuf payload */
4006 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4007 rte_pktmbuf_tailroom(ut_params->ibuf));
4010 * Append data which is padded to a multiple
4011 * of the algorithms block size
4013 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4015 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4017 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4019 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4021 /* Create GCM opertaion */
4022 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4023 tdata->auth_tag.data, tdata->auth_tag.len,
4024 tdata->iv.data, tdata->iv.len,
4025 tdata->aad.data, tdata->aad.len,
4026 tdata->plaintext.len, plaintext_pad_len);
4030 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4032 ut_params->op->sym->m_src = ut_params->ibuf;
4034 /* Process crypto operation */
4035 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4036 ut_params->op), "failed to process sym crypto op");
4038 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4039 "crypto op processing failed");
4041 if (ut_params->op->sym->m_dst) {
4042 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4044 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4045 uint8_t *, plaintext_pad_len);
4047 ciphertext = plaintext;
4048 auth_tag = plaintext + plaintext_pad_len;
4051 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4052 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4055 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4057 tdata->ciphertext.data,
4058 tdata->ciphertext.len,
4059 "GCM Ciphertext data not as expected");
4061 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4063 tdata->auth_tag.data,
4064 tdata->auth_tag.len,
4065 "GCM Generated auth tag not as expected");
4072 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4074 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4078 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4080 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4084 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4086 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4090 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4092 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4096 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4098 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4102 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4104 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4108 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4110 return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4114 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4116 struct crypto_testsuite_params *ts_params = &testsuite_params;
4117 struct crypto_unittest_params *ut_params = &unittest_params;
4121 uint8_t *plaintext, *ciphertext;
4122 uint16_t ciphertext_pad_len;
4124 /* Create GCM session */
4125 retval = create_gcm_session(ts_params->valid_devs[0],
4126 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4127 tdata->key.data, tdata->key.len,
4128 tdata->aad.len, tdata->auth_tag.len,
4129 RTE_CRYPTO_AUTH_OP_VERIFY);
4134 /* alloc mbuf and set payload */
4135 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4137 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4138 rte_pktmbuf_tailroom(ut_params->ibuf));
4140 ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4142 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4143 ciphertext_pad_len);
4144 memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
4146 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4148 /* Create GCM opertaion */
4149 retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
4150 tdata->auth_tag.data, tdata->auth_tag.len,
4151 tdata->iv.data, tdata->iv.len,
4152 tdata->aad.data, tdata->aad.len,
4153 tdata->ciphertext.len, ciphertext_pad_len);
4158 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4160 ut_params->op->sym->m_src = ut_params->ibuf;
4162 /* Process crypto operation */
4163 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4164 ut_params->op), "failed to process sym crypto op");
4166 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4167 "crypto op processing failed");
4169 if (ut_params->op->sym->m_dst)
4170 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4173 plaintext = ciphertext;
4175 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4178 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4180 tdata->plaintext.data,
4181 tdata->plaintext.len,
4182 "GCM plaintext data not as expected");
4184 TEST_ASSERT_EQUAL(ut_params->op->status,
4185 RTE_CRYPTO_OP_STATUS_SUCCESS,
4186 "GCM authentication failed");
4191 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4193 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4197 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4199 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4203 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4205 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4209 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4211 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4215 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4217 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4221 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4223 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4227 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4229 return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4235 struct crypto_testsuite_params *ts_params = &testsuite_params;
4236 struct rte_cryptodev_stats stats;
4237 struct rte_cryptodev *dev;
4238 cryptodev_stats_get_t temp_pfn;
4240 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4241 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
4242 &stats) == -ENODEV),
4243 "rte_cryptodev_stats_get invalid dev failed");
4244 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
4245 "rte_cryptodev_stats_get invalid Param failed");
4246 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
4247 temp_pfn = dev->dev_ops->stats_get;
4248 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
4249 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
4251 "rte_cryptodev_stats_get invalid Param failed");
4252 dev->dev_ops->stats_get = temp_pfn;
4254 /* Test expected values */
4256 test_AES_CBC_HMAC_SHA1_encrypt_digest();
4258 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4260 "rte_cryptodev_stats_get failed");
4261 TEST_ASSERT((stats.enqueued_count == 1),
4262 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4263 TEST_ASSERT((stats.dequeued_count == 1),
4264 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4265 TEST_ASSERT((stats.enqueue_err_count == 0),
4266 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4267 TEST_ASSERT((stats.dequeue_err_count == 0),
4268 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4270 /* invalid device but should ignore and not reset device stats*/
4271 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
4272 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4274 "rte_cryptodev_stats_get failed");
4275 TEST_ASSERT((stats.enqueued_count == 1),
4276 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4278 /* check that a valid reset clears stats */
4279 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4280 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4282 "rte_cryptodev_stats_get failed");
4283 TEST_ASSERT((stats.enqueued_count == 0),
4284 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4285 TEST_ASSERT((stats.dequeued_count == 0),
4286 "rte_cryptodev_stats_get returned unexpected enqueued stat");
4288 return TEST_SUCCESS;
4291 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
4292 struct crypto_unittest_params *ut_params,
4293 enum rte_crypto_auth_operation op,
4294 const struct HMAC_MD5_vector *test_case)
4298 memcpy(key, test_case->key.data, test_case->key.len);
4300 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4301 ut_params->auth_xform.next = NULL;
4302 ut_params->auth_xform.auth.op = op;
4304 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
4306 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
4307 ut_params->auth_xform.auth.add_auth_data_length = 0;
4308 ut_params->auth_xform.auth.key.length = test_case->key.len;
4309 ut_params->auth_xform.auth.key.data = key;
4311 ut_params->sess = rte_cryptodev_sym_session_create(
4312 ts_params->valid_devs[0], &ut_params->auth_xform);
4314 if (ut_params->sess == NULL)
4317 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4319 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4320 rte_pktmbuf_tailroom(ut_params->ibuf));
4325 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
4326 const struct HMAC_MD5_vector *test_case,
4327 uint8_t **plaintext)
4329 uint16_t plaintext_pad_len;
4331 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4333 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4336 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4338 memcpy(*plaintext, test_case->plaintext.data,
4339 test_case->plaintext.len);
4341 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4342 ut_params->ibuf, MD5_DIGEST_LEN);
4343 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4344 "no room to append digest");
4345 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4346 ut_params->ibuf, plaintext_pad_len);
4347 sym_op->auth.digest.length = MD5_DIGEST_LEN;
4349 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
4350 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
4351 test_case->auth_tag.len);
4354 sym_op->auth.data.offset = 0;
4355 sym_op->auth.data.length = test_case->plaintext.len;
4357 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4358 ut_params->op->sym->m_src = ut_params->ibuf;
4364 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
4366 uint16_t plaintext_pad_len;
4367 uint8_t *plaintext, *auth_tag;
4369 struct crypto_testsuite_params *ts_params = &testsuite_params;
4370 struct crypto_unittest_params *ut_params = &unittest_params;
4372 if (MD5_HMAC_create_session(ts_params, ut_params,
4373 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
4376 /* Generate Crypto op data structure */
4377 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4378 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4379 TEST_ASSERT_NOT_NULL(ut_params->op,
4380 "Failed to allocate symmetric crypto operation struct");
4382 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4385 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4388 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4389 ut_params->op), "failed to process sym crypto op");
4391 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4392 "crypto op processing failed");
4394 if (ut_params->op->sym->m_dst) {
4395 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4396 uint8_t *, plaintext_pad_len);
4398 auth_tag = plaintext + plaintext_pad_len;
4401 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4403 test_case->auth_tag.data,
4404 test_case->auth_tag.len,
4405 "HMAC_MD5 generated tag not as expected");
4407 return TEST_SUCCESS;
4411 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
4415 struct crypto_testsuite_params *ts_params = &testsuite_params;
4416 struct crypto_unittest_params *ut_params = &unittest_params;
4418 if (MD5_HMAC_create_session(ts_params, ut_params,
4419 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
4423 /* Generate Crypto op data structure */
4424 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4425 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4426 TEST_ASSERT_NOT_NULL(ut_params->op,
4427 "Failed to allocate symmetric crypto operation struct");
4429 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4432 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4433 ut_params->op), "failed to process sym crypto op");
4435 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4436 "HMAC_MD5 crypto op processing failed");
4438 return TEST_SUCCESS;
4442 test_MD5_HMAC_generate_case_1(void)
4444 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
4448 test_MD5_HMAC_verify_case_1(void)
4450 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
4454 test_MD5_HMAC_generate_case_2(void)
4456 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
4460 test_MD5_HMAC_verify_case_2(void)
4462 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
4466 test_multi_session(void)
4468 struct crypto_testsuite_params *ts_params = &testsuite_params;
4469 struct crypto_unittest_params *ut_params = &unittest_params;
4471 struct rte_cryptodev_info dev_info;
4472 struct rte_cryptodev_sym_session **sessions;
4476 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
4477 aes_cbc_key, hmac_sha512_key);
4480 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4482 sessions = rte_malloc(NULL,
4483 (sizeof(struct rte_cryptodev_sym_session *) *
4484 dev_info.sym.max_nb_sessions) + 1, 0);
4486 /* Create multiple crypto sessions*/
4487 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
4488 sessions[i] = rte_cryptodev_sym_session_create(
4489 ts_params->valid_devs[0],
4490 &ut_params->auth_xform);
4491 TEST_ASSERT_NOT_NULL(sessions[i],
4492 "Session creation failed at session number %u",
4495 /* Attempt to send a request on each session */
4496 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
4500 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
4501 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
4503 "Failed to perform decrypt on request number %u.", i);
4504 /* free crypto operation structure */
4506 rte_crypto_op_free(ut_params->op);
4509 * free mbuf - both obuf and ibuf are usually the same,
4510 * so check if they point at the same address is necessary,
4511 * to avoid freeing the mbuf twice.
4513 if (ut_params->obuf) {
4514 rte_pktmbuf_free(ut_params->obuf);
4515 if (ut_params->ibuf == ut_params->obuf)
4516 ut_params->ibuf = 0;
4517 ut_params->obuf = 0;
4519 if (ut_params->ibuf) {
4520 rte_pktmbuf_free(ut_params->ibuf);
4521 ut_params->ibuf = 0;
4525 /* Next session create should fail */
4526 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
4527 &ut_params->auth_xform);
4528 TEST_ASSERT_NULL(sessions[i],
4529 "Session creation succeeded unexpectedly!");
4531 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
4532 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4537 return TEST_SUCCESS;
4540 struct multi_session_params {
4541 struct crypto_unittest_params ut_params;
4542 uint8_t *cipher_key;
4544 const uint8_t *cipher;
4545 const uint8_t *digest;
4549 #define MB_SESSION_NUMBER 3
4552 test_multi_session_random_usage(void)
4554 struct crypto_testsuite_params *ts_params = &testsuite_params;
4555 struct rte_cryptodev_info dev_info;
4556 struct rte_cryptodev_sym_session **sessions;
4558 struct multi_session_params ut_paramz[] = {
4561 .cipher_key = ms_aes_cbc_key0,
4562 .hmac_key = ms_hmac_key0,
4563 .cipher = ms_aes_cbc_cipher0,
4564 .digest = ms_hmac_digest0,
4565 .iv = ms_aes_cbc_iv0
4568 .cipher_key = ms_aes_cbc_key1,
4569 .hmac_key = ms_hmac_key1,
4570 .cipher = ms_aes_cbc_cipher1,
4571 .digest = ms_hmac_digest1,
4572 .iv = ms_aes_cbc_iv1
4575 .cipher_key = ms_aes_cbc_key2,
4576 .hmac_key = ms_hmac_key2,
4577 .cipher = ms_aes_cbc_cipher2,
4578 .digest = ms_hmac_digest2,
4579 .iv = ms_aes_cbc_iv2
4584 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4586 sessions = rte_malloc(NULL,
4587 (sizeof(struct rte_cryptodev_sym_session *)
4588 * dev_info.sym.max_nb_sessions) + 1, 0);
4590 for (i = 0; i < MB_SESSION_NUMBER; i++) {
4591 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
4592 sizeof(struct crypto_unittest_params));
4594 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
4595 &ut_paramz[i].ut_params,
4596 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
4598 /* Create multiple crypto sessions*/
4599 sessions[i] = rte_cryptodev_sym_session_create(
4600 ts_params->valid_devs[0],
4601 &ut_paramz[i].ut_params.auth_xform);
4603 TEST_ASSERT_NOT_NULL(sessions[i],
4604 "Session creation failed at session number %u",
4610 for (i = 0; i < 40000; i++) {
4612 j = rand() % MB_SESSION_NUMBER;
4614 TEST_ASSERT_SUCCESS(
4615 test_AES_CBC_HMAC_SHA512_decrypt_perform(
4617 &ut_paramz[j].ut_params,
4618 ts_params, ut_paramz[j].cipher,
4619 ut_paramz[j].digest,
4621 "Failed to perform decrypt on request number %u.", i);
4623 if (ut_paramz[j].ut_params.op)
4624 rte_crypto_op_free(ut_paramz[j].ut_params.op);
4627 * free mbuf - both obuf and ibuf are usually the same,
4628 * so check if they point at the same address is necessary,
4629 * to avoid freeing the mbuf twice.
4631 if (ut_paramz[j].ut_params.obuf) {
4632 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
4633 if (ut_paramz[j].ut_params.ibuf
4634 == ut_paramz[j].ut_params.obuf)
4635 ut_paramz[j].ut_params.ibuf = 0;
4636 ut_paramz[j].ut_params.obuf = 0;
4638 if (ut_paramz[j].ut_params.ibuf) {
4639 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
4640 ut_paramz[j].ut_params.ibuf = 0;
4644 for (i = 0; i < MB_SESSION_NUMBER; i++)
4645 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4650 return TEST_SUCCESS;
4654 test_null_cipher_only_operation(void)
4656 struct crypto_testsuite_params *ts_params = &testsuite_params;
4657 struct crypto_unittest_params *ut_params = &unittest_params;
4659 /* Generate test mbuf data and space for digest */
4660 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4661 catch_22_quote, QUOTE_512_BYTES, 0);
4663 /* Setup Cipher Parameters */
4664 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4665 ut_params->cipher_xform.next = NULL;
4667 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4668 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4670 /* Create Crypto session*/
4671 ut_params->sess = rte_cryptodev_sym_session_create(
4672 ts_params->valid_devs[0], &ut_params->cipher_xform);
4673 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4675 /* Generate Crypto op data structure */
4676 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4677 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4678 TEST_ASSERT_NOT_NULL(ut_params->op,
4679 "Failed to allocate symmetric crypto operation struct");
4681 /* Set crypto operation data parameters */
4682 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4684 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4686 /* set crypto operation source mbuf */
4687 sym_op->m_src = ut_params->ibuf;
4689 sym_op->cipher.data.offset = 0;
4690 sym_op->cipher.data.length = QUOTE_512_BYTES;
4692 /* Process crypto operation */
4693 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4695 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4697 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4698 "crypto operation processing failed");
4701 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4702 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4705 "Ciphertext data not as expected");
4707 return TEST_SUCCESS;
4711 test_null_auth_only_operation(void)
4713 struct crypto_testsuite_params *ts_params = &testsuite_params;
4714 struct crypto_unittest_params *ut_params = &unittest_params;
4716 /* Generate test mbuf data and space for digest */
4717 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4718 catch_22_quote, QUOTE_512_BYTES, 0);
4720 /* Setup HMAC Parameters */
4721 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4722 ut_params->auth_xform.next = NULL;
4724 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4725 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4727 /* Create Crypto session*/
4728 ut_params->sess = rte_cryptodev_sym_session_create(
4729 ts_params->valid_devs[0], &ut_params->auth_xform);
4730 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4732 /* Generate Crypto op data structure */
4733 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4734 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4735 TEST_ASSERT_NOT_NULL(ut_params->op,
4736 "Failed to allocate symmetric crypto operation struct");
4738 /* Set crypto operation data parameters */
4739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4741 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4743 sym_op->m_src = ut_params->ibuf;
4745 sym_op->auth.data.offset = 0;
4746 sym_op->auth.data.length = QUOTE_512_BYTES;
4748 /* Process crypto operation */
4749 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4751 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4753 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4754 "crypto operation processing failed");
4756 return TEST_SUCCESS;
4760 test_null_cipher_auth_operation(void)
4762 struct crypto_testsuite_params *ts_params = &testsuite_params;
4763 struct crypto_unittest_params *ut_params = &unittest_params;
4765 /* Generate test mbuf data and space for digest */
4766 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4767 catch_22_quote, QUOTE_512_BYTES, 0);
4769 /* Setup Cipher Parameters */
4770 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4771 ut_params->cipher_xform.next = &ut_params->auth_xform;
4773 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4774 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4776 /* Setup HMAC Parameters */
4777 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4778 ut_params->auth_xform.next = NULL;
4780 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4781 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4783 /* Create Crypto session*/
4784 ut_params->sess = rte_cryptodev_sym_session_create(
4785 ts_params->valid_devs[0], &ut_params->cipher_xform);
4786 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4788 /* Generate Crypto op data structure */
4789 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4790 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4791 TEST_ASSERT_NOT_NULL(ut_params->op,
4792 "Failed to allocate symmetric crypto operation struct");
4794 /* Set crypto operation data parameters */
4795 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4797 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4799 sym_op->m_src = ut_params->ibuf;
4801 sym_op->cipher.data.offset = 0;
4802 sym_op->cipher.data.length = QUOTE_512_BYTES;
4804 sym_op->auth.data.offset = 0;
4805 sym_op->auth.data.length = QUOTE_512_BYTES;
4807 /* Process crypto operation */
4808 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4810 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4812 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4813 "crypto operation processing failed");
4816 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4817 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4820 "Ciphertext data not as expected");
4822 return TEST_SUCCESS;
4826 test_null_auth_cipher_operation(void)
4828 struct crypto_testsuite_params *ts_params = &testsuite_params;
4829 struct crypto_unittest_params *ut_params = &unittest_params;
4831 /* Generate test mbuf data and space for digest */
4832 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4833 catch_22_quote, QUOTE_512_BYTES, 0);
4835 /* Setup Cipher Parameters */
4836 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4837 ut_params->cipher_xform.next = NULL;
4839 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4840 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4842 /* Setup HMAC Parameters */
4843 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4844 ut_params->auth_xform.next = &ut_params->cipher_xform;
4846 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4847 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4849 /* Create Crypto session*/
4850 ut_params->sess = rte_cryptodev_sym_session_create(
4851 ts_params->valid_devs[0], &ut_params->cipher_xform);
4852 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4854 /* Generate Crypto op data structure */
4855 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4856 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4857 TEST_ASSERT_NOT_NULL(ut_params->op,
4858 "Failed to allocate symmetric crypto operation struct");
4860 /* Set crypto operation data parameters */
4861 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4863 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4865 sym_op->m_src = ut_params->ibuf;
4867 sym_op->cipher.data.offset = 0;
4868 sym_op->cipher.data.length = QUOTE_512_BYTES;
4870 sym_op->auth.data.offset = 0;
4871 sym_op->auth.data.length = QUOTE_512_BYTES;
4873 /* Process crypto operation */
4874 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4876 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4878 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4879 "crypto operation processing failed");
4882 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4883 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4886 "Ciphertext data not as expected");
4888 return TEST_SUCCESS;
4893 test_null_invalid_operation(void)
4895 struct crypto_testsuite_params *ts_params = &testsuite_params;
4896 struct crypto_unittest_params *ut_params = &unittest_params;
4898 /* Setup Cipher Parameters */
4899 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4900 ut_params->cipher_xform.next = NULL;
4902 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
4903 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4905 /* Create Crypto session*/
4906 ut_params->sess = rte_cryptodev_sym_session_create(
4907 ts_params->valid_devs[0], &ut_params->cipher_xform);
4908 TEST_ASSERT_NULL(ut_params->sess,
4909 "Session creation succeeded unexpectedly");
4912 /* Setup HMAC Parameters */
4913 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4914 ut_params->auth_xform.next = NULL;
4916 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
4917 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4919 /* Create Crypto session*/
4920 ut_params->sess = rte_cryptodev_sym_session_create(
4921 ts_params->valid_devs[0], &ut_params->auth_xform);
4922 TEST_ASSERT_NULL(ut_params->sess,
4923 "Session creation succeeded unexpectedly");
4925 return TEST_SUCCESS;
4929 #define NULL_BURST_LENGTH (32)
4932 test_null_burst_operation(void)
4934 struct crypto_testsuite_params *ts_params = &testsuite_params;
4935 struct crypto_unittest_params *ut_params = &unittest_params;
4937 unsigned i, burst_len = NULL_BURST_LENGTH;
4939 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
4940 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
4942 /* Setup Cipher Parameters */
4943 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4944 ut_params->cipher_xform.next = &ut_params->auth_xform;
4946 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4947 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4949 /* Setup HMAC Parameters */
4950 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4951 ut_params->auth_xform.next = NULL;
4953 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4954 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4956 /* Create Crypto session*/
4957 ut_params->sess = rte_cryptodev_sym_session_create(
4958 ts_params->valid_devs[0], &ut_params->cipher_xform);
4959 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4961 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
4962 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
4963 burst_len, "failed to generate burst of crypto ops");
4965 /* Generate an operation for each mbuf in burst */
4966 for (i = 0; i < burst_len; i++) {
4967 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4969 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
4971 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
4975 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
4977 burst[i]->sym->m_src = m;
4980 /* Process crypto operation */
4981 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
4982 0, burst, burst_len),
4984 "Error enqueuing burst");
4986 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
4987 0, burst_dequeued, burst_len),
4989 "Error dequeuing burst");
4992 for (i = 0; i < burst_len; i++) {
4994 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
4995 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
4997 "data not as expected");
4999 rte_pktmbuf_free(burst[i]->sym->m_src);
5000 rte_crypto_op_free(burst[i]);
5003 return TEST_SUCCESS;
5007 generate_gmac_large_plaintext(uint8_t *data)
5011 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5012 memcpy(&data[i], &data[0], 32);
5016 create_gmac_operation(enum rte_crypto_auth_operation op,
5017 const struct gmac_test_data *tdata)
5019 struct crypto_testsuite_params *ts_params = &testsuite_params;
5020 struct crypto_unittest_params *ut_params = &unittest_params;
5021 struct rte_crypto_sym_op *sym_op;
5023 unsigned iv_pad_len;
5024 unsigned aad_pad_len;
5026 iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5027 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5030 * Runtime generate the large plain text instead of use hard code
5031 * plain text vector. It is done to avoid create huge source file
5032 * with the test vector.
5034 if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5035 generate_gmac_large_plaintext(tdata->aad.data);
5037 /* Generate Crypto op data structure */
5038 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5039 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5040 TEST_ASSERT_NOT_NULL(ut_params->op,
5041 "Failed to allocate symmetric crypto operation struct");
5043 sym_op = ut_params->op->sym;
5044 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5046 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5047 "no room to append aad");
5049 sym_op->auth.aad.length = tdata->aad.len;
5050 sym_op->auth.aad.phys_addr =
5051 rte_pktmbuf_mtophys(ut_params->ibuf);
5052 memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5054 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5055 ut_params->ibuf, tdata->gmac_tag.len);
5056 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5057 "no room to append digest");
5059 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5060 ut_params->ibuf, aad_pad_len);
5061 sym_op->auth.digest.length = tdata->gmac_tag.len;
5063 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5064 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
5065 tdata->gmac_tag.len);
5066 TEST_HEXDUMP(stdout, "digest:",
5067 sym_op->auth.digest.data,
5068 sym_op->auth.digest.length);
5071 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5072 ut_params->ibuf, iv_pad_len);
5073 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5075 memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5076 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5077 sym_op->cipher.iv.length = tdata->iv.len;
5079 rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
5081 TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
5083 sym_op->cipher.data.length = 0;
5084 sym_op->cipher.data.offset = 0;
5086 sym_op->auth.data.offset = 0;
5087 sym_op->auth.data.length = 0;
5092 static int create_gmac_session(uint8_t dev_id,
5093 enum rte_crypto_cipher_operation op,
5094 const struct gmac_test_data *tdata,
5095 enum rte_crypto_auth_operation auth_op)
5097 uint8_t cipher_key[tdata->key.len];
5099 struct crypto_unittest_params *ut_params = &unittest_params;
5101 memcpy(cipher_key, tdata->key.data, tdata->key.len);
5103 /* For GMAC we setup cipher parameters */
5104 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5105 ut_params->cipher_xform.next = NULL;
5106 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
5107 ut_params->cipher_xform.cipher.op = op;
5108 ut_params->cipher_xform.cipher.key.data = cipher_key;
5109 ut_params->cipher_xform.cipher.key.length = tdata->key.len;
5111 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5112 ut_params->auth_xform.next = NULL;
5114 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
5115 ut_params->auth_xform.auth.op = auth_op;
5116 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
5117 ut_params->auth_xform.auth.add_auth_data_length = 0;
5118 ut_params->auth_xform.auth.key.length = 0;
5119 ut_params->auth_xform.auth.key.data = NULL;
5121 ut_params->cipher_xform.next = &ut_params->auth_xform;
5123 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5124 &ut_params->cipher_xform);
5126 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5132 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
5134 struct crypto_testsuite_params *ts_params = &testsuite_params;
5135 struct crypto_unittest_params *ut_params = &unittest_params;
5139 uint8_t *auth_tag, *p;
5140 uint16_t aad_pad_len;
5142 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5143 "No GMAC length in the source data");
5145 retval = create_gmac_session(ts_params->valid_devs[0],
5146 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5147 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
5152 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5154 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5155 rte_pktmbuf_tailroom(ut_params->ibuf));
5157 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5159 p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
5161 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
5167 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5169 ut_params->op->sym->m_src = ut_params->ibuf;
5171 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5172 ut_params->op), "failed to process sym crypto op");
5174 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5175 "crypto op processing failed");
5177 if (ut_params->op->sym->m_dst) {
5178 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5179 uint8_t *, aad_pad_len);
5181 auth_tag = p + aad_pad_len;
5184 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
5186 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5188 tdata->gmac_tag.data,
5189 tdata->gmac_tag.len,
5190 "GMAC Generated auth tag not as expected");
5196 test_AES_GMAC_authentication_test_case_1(void)
5198 return test_AES_GMAC_authentication(&gmac_test_case_1);
5202 test_AES_GMAC_authentication_test_case_2(void)
5204 return test_AES_GMAC_authentication(&gmac_test_case_2);
5208 test_AES_GMAC_authentication_test_case_3(void)
5210 return test_AES_GMAC_authentication(&gmac_test_case_3);
5214 test_AES_GMAC_authentication_test_case_4(void)
5216 return test_AES_GMAC_authentication(&gmac_test_case_4);
5220 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
5222 struct crypto_testsuite_params *ts_params = &testsuite_params;
5223 struct crypto_unittest_params *ut_params = &unittest_params;
5226 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5227 "No GMAC length in the source data");
5229 retval = create_gmac_session(ts_params->valid_devs[0],
5230 RTE_CRYPTO_CIPHER_OP_DECRYPT,
5231 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
5236 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5238 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5239 rte_pktmbuf_tailroom(ut_params->ibuf));
5241 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
5247 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5249 ut_params->op->sym->m_src = ut_params->ibuf;
5251 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5252 ut_params->op), "failed to process sym crypto op");
5254 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5255 "crypto op processing failed");
5262 test_AES_GMAC_authentication_verify_test_case_1(void)
5264 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
5268 test_AES_GMAC_authentication_verify_test_case_2(void)
5270 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
5274 test_AES_GMAC_authentication_verify_test_case_3(void)
5276 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
5280 test_AES_GMAC_authentication_verify_test_case_4(void)
5282 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
5285 struct test_crypto_vector {
5286 enum rte_crypto_cipher_algorithm crypto_algo;
5299 const uint8_t *data;
5304 const uint8_t *data;
5308 enum rte_crypto_auth_algorithm auth_algo;
5316 const uint8_t *data;
5326 static const struct test_crypto_vector
5327 hmac_sha1_test_crypto_vector = {
5328 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5330 .data = plaintext_hash,
5335 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5336 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5337 0xDE, 0xF4, 0xDE, 0xAD
5343 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
5344 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
5345 0x3F, 0x91, 0x64, 0x59
5351 static const struct test_crypto_vector
5352 aes128_gmac_test_vector = {
5353 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
5354 .crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
5356 .data = plaintext_hash,
5361 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5362 0x08, 0x09, 0x0A, 0x0B
5368 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5369 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
5375 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
5376 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
5382 static const struct test_crypto_vector
5383 aes128cbc_hmac_sha1_test_vector = {
5384 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
5387 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
5388 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
5394 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5395 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
5400 .data = plaintext_hash,
5404 .data = ciphertext512_aes128cbc,
5407 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5410 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5411 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5412 0xDE, 0xF4, 0xDE, 0xAD
5418 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
5419 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5420 0x18, 0x8C, 0x1D, 0x32
5427 data_corruption(uint8_t *data)
5433 tag_corruption(uint8_t *data, unsigned int tag_offset)
5435 data[tag_offset] += 1;
5439 create_auth_session(struct crypto_unittest_params *ut_params,
5441 const struct test_crypto_vector *reference,
5442 enum rte_crypto_auth_operation auth_op)
5444 uint8_t auth_key[reference->auth_key.len + 1];
5446 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5448 /* Setup Authentication Parameters */
5449 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5450 ut_params->auth_xform.auth.op = auth_op;
5451 ut_params->auth_xform.next = NULL;
5452 ut_params->auth_xform.auth.algo = reference->auth_algo;
5453 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5454 ut_params->auth_xform.auth.key.data = auth_key;
5455 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5456 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5458 /* Create Crypto session*/
5459 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5460 &ut_params->auth_xform);
5462 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5468 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
5470 const struct test_crypto_vector *reference,
5471 enum rte_crypto_auth_operation auth_op,
5472 enum rte_crypto_cipher_operation cipher_op)
5474 uint8_t cipher_key[reference->cipher_key.len + 1];
5475 uint8_t auth_key[reference->auth_key.len + 1];
5477 memcpy(cipher_key, reference->cipher_key.data,
5478 reference->cipher_key.len);
5479 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5481 /* Setup Authentication Parameters */
5482 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5483 ut_params->auth_xform.auth.op = auth_op;
5484 ut_params->auth_xform.next = &ut_params->cipher_xform;
5485 ut_params->auth_xform.auth.algo = reference->auth_algo;
5486 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5487 ut_params->auth_xform.auth.key.data = auth_key;
5488 ut_params->auth_xform.auth.digest_length = reference->digest.len;
5489 ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5491 /* Setup Cipher Parameters */
5492 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5493 ut_params->cipher_xform.next = NULL;
5494 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
5495 ut_params->cipher_xform.cipher.op = cipher_op;
5496 ut_params->cipher_xform.cipher.key.data = cipher_key;
5497 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
5499 /* Create Crypto session*/
5500 ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5501 &ut_params->auth_xform);
5503 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5509 create_auth_operation(struct crypto_testsuite_params *ts_params,
5510 struct crypto_unittest_params *ut_params,
5511 const struct test_crypto_vector *reference,
5512 unsigned int auth_generate)
5514 /* Generate Crypto op data structure */
5515 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5516 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5517 TEST_ASSERT_NOT_NULL(ut_params->op,
5518 "Failed to allocate pktmbuf offload");
5520 /* Set crypto operation data parameters */
5521 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5523 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5525 /* set crypto operation source mbuf */
5526 sym_op->m_src = ut_params->ibuf;
5529 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5530 ut_params->ibuf, reference->digest.len);
5532 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5533 "no room to append auth tag");
5535 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5536 ut_params->ibuf, reference->plaintext.len);
5537 sym_op->auth.digest.length = reference->digest.len;
5540 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5542 memcpy(sym_op->auth.digest.data,
5543 reference->digest.data,
5544 reference->digest.len);
5546 TEST_HEXDUMP(stdout, "digest:",
5547 sym_op->auth.digest.data,
5548 sym_op->auth.digest.length);
5550 sym_op->auth.data.length = reference->plaintext.len;
5551 sym_op->auth.data.offset = 0;
5557 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
5558 struct crypto_unittest_params *ut_params,
5559 const struct test_crypto_vector *reference,
5560 unsigned int auth_generate)
5562 /* Generate Crypto op data structure */
5563 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5564 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5565 TEST_ASSERT_NOT_NULL(ut_params->op,
5566 "Failed to allocate pktmbuf offload");
5568 /* Set crypto operation data parameters */
5569 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5571 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5573 /* set crypto operation source mbuf */
5574 sym_op->m_src = ut_params->ibuf;
5577 sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5578 reference->aad.len);
5579 TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
5580 memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
5582 TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
5584 sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5585 sym_op->auth.aad.length = reference->aad.len;
5588 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5589 ut_params->ibuf, reference->digest.len);
5591 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5592 "no room to append auth tag");
5594 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5595 ut_params->ibuf, reference->ciphertext.len);
5596 sym_op->auth.digest.length = reference->digest.len;
5599 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5601 memcpy(sym_op->auth.digest.data,
5602 reference->digest.data,
5603 reference->digest.len);
5605 TEST_HEXDUMP(stdout, "digest:",
5606 sym_op->auth.digest.data,
5607 sym_op->auth.digest.length);
5609 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5610 ut_params->ibuf, reference->iv.len);
5611 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5613 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5614 sym_op->cipher.iv.length = reference->iv.len;
5616 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5618 sym_op->cipher.data.length = 0;
5619 sym_op->cipher.data.offset = 0;
5621 sym_op->auth.data.length = 0;
5622 sym_op->auth.data.offset = 0;
5628 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
5629 struct crypto_unittest_params *ut_params,
5630 const struct test_crypto_vector *reference,
5631 unsigned int auth_generate)
5633 /* Generate Crypto op data structure */
5634 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5635 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5636 TEST_ASSERT_NOT_NULL(ut_params->op,
5637 "Failed to allocate pktmbuf offload");
5639 /* Set crypto operation data parameters */
5640 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5642 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5644 /* set crypto operation source mbuf */
5645 sym_op->m_src = ut_params->ibuf;
5648 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5649 ut_params->ibuf, reference->digest.len);
5651 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5652 "no room to append auth tag");
5654 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5655 ut_params->ibuf, reference->ciphertext.len);
5656 sym_op->auth.digest.length = reference->digest.len;
5659 memset(sym_op->auth.digest.data, 0, reference->digest.len);
5661 memcpy(sym_op->auth.digest.data,
5662 reference->digest.data,
5663 reference->digest.len);
5665 TEST_HEXDUMP(stdout, "digest:",
5666 sym_op->auth.digest.data,
5667 sym_op->auth.digest.length);
5669 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5670 ut_params->ibuf, reference->iv.len);
5671 TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5673 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5674 sym_op->cipher.iv.length = reference->iv.len;
5676 memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5678 sym_op->cipher.data.length = reference->ciphertext.len;
5679 sym_op->cipher.data.offset = reference->iv.len;
5681 sym_op->auth.data.length = reference->ciphertext.len;
5682 sym_op->auth.data.offset = reference->iv.len;
5688 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5689 struct crypto_unittest_params *ut_params,
5690 const struct test_crypto_vector *reference)
5692 return create_auth_operation(ts_params, ut_params, reference, 0);
5696 create_auth_verify_GMAC_operation(
5697 struct crypto_testsuite_params *ts_params,
5698 struct crypto_unittest_params *ut_params,
5699 const struct test_crypto_vector *reference)
5701 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
5705 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5706 struct crypto_unittest_params *ut_params,
5707 const struct test_crypto_vector *reference)
5709 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
5713 test_authentication_verify_fail_when_data_corruption(
5714 struct crypto_testsuite_params *ts_params,
5715 struct crypto_unittest_params *ut_params,
5716 const struct test_crypto_vector *reference,
5717 unsigned int data_corrupted)
5723 /* Create session */
5724 retval = create_auth_session(ut_params,
5725 ts_params->valid_devs[0],
5727 RTE_CRYPTO_AUTH_OP_VERIFY);
5731 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5732 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5733 "Failed to allocate input buffer in mempool");
5735 /* clear mbuf payload */
5736 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5737 rte_pktmbuf_tailroom(ut_params->ibuf));
5739 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5740 reference->plaintext.len);
5741 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5742 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
5744 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
5746 /* Create operation */
5747 retval = create_auth_verify_operation(ts_params, ut_params, reference);
5753 data_corruption(plaintext);
5755 tag_corruption(plaintext, reference->plaintext.len);
5757 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5759 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5760 TEST_ASSERT_EQUAL(ut_params->op->status,
5761 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5762 "authentication not failed");
5764 ut_params->obuf = ut_params->op->sym->m_src;
5765 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5771 test_authentication_verify_GMAC_fail_when_corruption(
5772 struct crypto_testsuite_params *ts_params,
5773 struct crypto_unittest_params *ut_params,
5774 const struct test_crypto_vector *reference,
5775 unsigned int data_corrupted)
5779 /* Create session */
5780 retval = create_auth_cipher_session(ut_params,
5781 ts_params->valid_devs[0],
5783 RTE_CRYPTO_AUTH_OP_VERIFY,
5784 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5789 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5790 "Failed to allocate input buffer in mempool");
5792 /* clear mbuf payload */
5793 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5794 rte_pktmbuf_tailroom(ut_params->ibuf));
5796 /* Create operation */
5797 retval = create_auth_verify_GMAC_operation(ts_params,
5805 data_corruption(ut_params->op->sym->auth.aad.data);
5807 tag_corruption(ut_params->op->sym->auth.aad.data,
5808 reference->aad.len);
5810 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5812 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5813 TEST_ASSERT_EQUAL(ut_params->op->status,
5814 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5815 "authentication not failed");
5817 ut_params->obuf = ut_params->op->sym->m_src;
5818 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5824 test_authenticated_decryption_fail_when_corruption(
5825 struct crypto_testsuite_params *ts_params,
5826 struct crypto_unittest_params *ut_params,
5827 const struct test_crypto_vector *reference,
5828 unsigned int data_corrupted)
5832 uint8_t *ciphertext;
5834 /* Create session */
5835 retval = create_auth_cipher_session(ut_params,
5836 ts_params->valid_devs[0],
5838 RTE_CRYPTO_AUTH_OP_VERIFY,
5839 RTE_CRYPTO_CIPHER_OP_DECRYPT);
5843 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5844 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5845 "Failed to allocate input buffer in mempool");
5847 /* clear mbuf payload */
5848 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5849 rte_pktmbuf_tailroom(ut_params->ibuf));
5851 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5852 reference->ciphertext.len);
5853 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
5854 memcpy(ciphertext, reference->ciphertext.data,
5855 reference->ciphertext.len);
5857 /* Create operation */
5858 retval = create_cipher_auth_verify_operation(ts_params,
5866 data_corruption(ciphertext);
5868 tag_corruption(ciphertext, reference->ciphertext.len);
5870 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5873 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5874 TEST_ASSERT_EQUAL(ut_params->op->status,
5875 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5876 "authentication not failed");
5878 ut_params->obuf = ut_params->op->sym->m_src;
5879 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5885 test_authentication_verify_fail_when_data_corrupted(
5886 struct crypto_testsuite_params *ts_params,
5887 struct crypto_unittest_params *ut_params,
5888 const struct test_crypto_vector *reference)
5890 return test_authentication_verify_fail_when_data_corruption(
5891 ts_params, ut_params, reference, 1);
5895 test_authentication_verify_fail_when_tag_corrupted(
5896 struct crypto_testsuite_params *ts_params,
5897 struct crypto_unittest_params *ut_params,
5898 const struct test_crypto_vector *reference)
5900 return test_authentication_verify_fail_when_data_corruption(
5901 ts_params, ut_params, reference, 0);
5905 test_authentication_verify_GMAC_fail_when_data_corrupted(
5906 struct crypto_testsuite_params *ts_params,
5907 struct crypto_unittest_params *ut_params,
5908 const struct test_crypto_vector *reference)
5910 return test_authentication_verify_GMAC_fail_when_corruption(
5911 ts_params, ut_params, reference, 1);
5915 test_authentication_verify_GMAC_fail_when_tag_corrupted(
5916 struct crypto_testsuite_params *ts_params,
5917 struct crypto_unittest_params *ut_params,
5918 const struct test_crypto_vector *reference)
5920 return test_authentication_verify_GMAC_fail_when_corruption(
5921 ts_params, ut_params, reference, 0);
5925 test_authenticated_decryption_fail_when_data_corrupted(
5926 struct crypto_testsuite_params *ts_params,
5927 struct crypto_unittest_params *ut_params,
5928 const struct test_crypto_vector *reference)
5930 return test_authenticated_decryption_fail_when_corruption(
5931 ts_params, ut_params, reference, 1);
5935 test_authenticated_decryption_fail_when_tag_corrupted(
5936 struct crypto_testsuite_params *ts_params,
5937 struct crypto_unittest_params *ut_params,
5938 const struct test_crypto_vector *reference)
5940 return test_authenticated_decryption_fail_when_corruption(
5941 ts_params, ut_params, reference, 0);
5945 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
5947 return test_authentication_verify_fail_when_data_corrupted(
5948 &testsuite_params, &unittest_params,
5949 &hmac_sha1_test_crypto_vector);
5953 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
5955 return test_authentication_verify_fail_when_tag_corrupted(
5956 &testsuite_params, &unittest_params,
5957 &hmac_sha1_test_crypto_vector);
5961 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
5963 return test_authentication_verify_GMAC_fail_when_data_corrupted(
5964 &testsuite_params, &unittest_params,
5965 &aes128_gmac_test_vector);
5969 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
5971 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
5972 &testsuite_params, &unittest_params,
5973 &aes128_gmac_test_vector);
5977 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
5979 return test_authenticated_decryption_fail_when_data_corrupted(
5982 &aes128cbc_hmac_sha1_test_vector);
5986 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
5988 return test_authenticated_decryption_fail_when_tag_corrupted(
5991 &aes128cbc_hmac_sha1_test_vector);
5994 static struct unit_test_suite cryptodev_qat_testsuite = {
5995 .suite_name = "Crypto QAT Unit Test Suite",
5996 .setup = testsuite_setup,
5997 .teardown = testsuite_teardown,
5998 .unit_test_cases = {
5999 TEST_CASE_ST(ut_setup, ut_teardown,
6000 test_device_configure_invalid_dev_id),
6001 TEST_CASE_ST(ut_setup, ut_teardown,
6002 test_device_configure_invalid_queue_pair_ids),
6003 TEST_CASE_ST(ut_setup, ut_teardown,
6004 test_queue_pair_descriptor_setup),
6005 TEST_CASE_ST(ut_setup, ut_teardown,
6006 test_multi_session),
6008 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
6009 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
6010 TEST_CASE_ST(ut_setup, ut_teardown,
6011 test_3DES_cipheronly_qat_all),
6012 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
6014 /** AES GCM Authenticated Encryption */
6015 TEST_CASE_ST(ut_setup, ut_teardown,
6016 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6017 TEST_CASE_ST(ut_setup, ut_teardown,
6018 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6019 TEST_CASE_ST(ut_setup, ut_teardown,
6020 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6021 TEST_CASE_ST(ut_setup, ut_teardown,
6022 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6023 TEST_CASE_ST(ut_setup, ut_teardown,
6024 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6025 TEST_CASE_ST(ut_setup, ut_teardown,
6026 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6027 TEST_CASE_ST(ut_setup, ut_teardown,
6028 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6030 /** AES GCM Authenticated Decryption */
6031 TEST_CASE_ST(ut_setup, ut_teardown,
6032 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6033 TEST_CASE_ST(ut_setup, ut_teardown,
6034 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6035 TEST_CASE_ST(ut_setup, ut_teardown,
6036 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6037 TEST_CASE_ST(ut_setup, ut_teardown,
6038 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6039 TEST_CASE_ST(ut_setup, ut_teardown,
6040 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6041 TEST_CASE_ST(ut_setup, ut_teardown,
6042 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6043 TEST_CASE_ST(ut_setup, ut_teardown,
6044 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6046 /** AES GMAC Authentication */
6047 TEST_CASE_ST(ut_setup, ut_teardown,
6048 test_AES_GMAC_authentication_test_case_1),
6049 TEST_CASE_ST(ut_setup, ut_teardown,
6050 test_AES_GMAC_authentication_verify_test_case_1),
6051 TEST_CASE_ST(ut_setup, ut_teardown,
6052 test_AES_GMAC_authentication_test_case_2),
6053 TEST_CASE_ST(ut_setup, ut_teardown,
6054 test_AES_GMAC_authentication_verify_test_case_2),
6055 TEST_CASE_ST(ut_setup, ut_teardown,
6056 test_AES_GMAC_authentication_test_case_3),
6057 TEST_CASE_ST(ut_setup, ut_teardown,
6058 test_AES_GMAC_authentication_verify_test_case_3),
6060 /** SNOW 3G encrypt only (UEA2) */
6061 TEST_CASE_ST(ut_setup, ut_teardown,
6062 test_snow3g_encryption_test_case_1),
6063 TEST_CASE_ST(ut_setup, ut_teardown,
6064 test_snow3g_encryption_test_case_2),
6065 TEST_CASE_ST(ut_setup, ut_teardown,
6066 test_snow3g_encryption_test_case_3),
6067 TEST_CASE_ST(ut_setup, ut_teardown,
6068 test_snow3g_encryption_test_case_4),
6069 TEST_CASE_ST(ut_setup, ut_teardown,
6070 test_snow3g_encryption_test_case_5),
6072 TEST_CASE_ST(ut_setup, ut_teardown,
6073 test_snow3g_encryption_test_case_1_oop),
6074 TEST_CASE_ST(ut_setup, ut_teardown,
6075 test_snow3g_decryption_test_case_1_oop),
6077 /** SNOW 3G decrypt only (UEA2) */
6078 TEST_CASE_ST(ut_setup, ut_teardown,
6079 test_snow3g_decryption_test_case_1),
6080 TEST_CASE_ST(ut_setup, ut_teardown,
6081 test_snow3g_decryption_test_case_2),
6082 TEST_CASE_ST(ut_setup, ut_teardown,
6083 test_snow3g_decryption_test_case_3),
6084 TEST_CASE_ST(ut_setup, ut_teardown,
6085 test_snow3g_decryption_test_case_4),
6086 TEST_CASE_ST(ut_setup, ut_teardown,
6087 test_snow3g_decryption_test_case_5),
6088 TEST_CASE_ST(ut_setup, ut_teardown,
6089 test_snow3g_hash_generate_test_case_1),
6090 TEST_CASE_ST(ut_setup, ut_teardown,
6091 test_snow3g_hash_generate_test_case_2),
6092 TEST_CASE_ST(ut_setup, ut_teardown,
6093 test_snow3g_hash_generate_test_case_3),
6094 TEST_CASE_ST(ut_setup, ut_teardown,
6095 test_snow3g_hash_verify_test_case_1),
6096 TEST_CASE_ST(ut_setup, ut_teardown,
6097 test_snow3g_hash_verify_test_case_2),
6098 TEST_CASE_ST(ut_setup, ut_teardown,
6099 test_snow3g_hash_verify_test_case_3),
6100 TEST_CASE_ST(ut_setup, ut_teardown,
6101 test_snow3g_cipher_auth_test_case_1),
6102 TEST_CASE_ST(ut_setup, ut_teardown,
6103 test_snow3g_auth_cipher_test_case_1),
6105 /** HMAC_MD5 Authentication */
6106 TEST_CASE_ST(ut_setup, ut_teardown,
6107 test_MD5_HMAC_generate_case_1),
6108 TEST_CASE_ST(ut_setup, ut_teardown,
6109 test_MD5_HMAC_verify_case_1),
6110 TEST_CASE_ST(ut_setup, ut_teardown,
6111 test_MD5_HMAC_generate_case_2),
6112 TEST_CASE_ST(ut_setup, ut_teardown,
6113 test_MD5_HMAC_verify_case_2),
6116 TEST_CASE_ST(ut_setup, ut_teardown,
6117 test_null_auth_only_operation),
6118 TEST_CASE_ST(ut_setup, ut_teardown,
6119 test_null_cipher_only_operation),
6120 TEST_CASE_ST(ut_setup, ut_teardown,
6121 test_null_cipher_auth_operation),
6122 TEST_CASE_ST(ut_setup, ut_teardown,
6123 test_null_auth_cipher_operation),
6125 TEST_CASE_ST(ut_setup, ut_teardown,
6126 test_kasumi_hash_generate_test_case_6),
6129 TEST_CASE_ST(ut_setup, ut_teardown,
6130 test_kasumi_encryption_test_case_1),
6131 TEST_CASE_ST(ut_setup, ut_teardown,
6132 test_kasumi_encryption_test_case_3),
6133 TEST_CASE_ST(ut_setup, ut_teardown,
6134 test_kasumi_auth_cipher_test_case_1),
6135 TEST_CASE_ST(ut_setup, ut_teardown,
6136 test_kasumi_cipher_auth_test_case_1),
6138 TEST_CASES_END() /**< NULL terminate unit test array */
6142 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
6143 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
6144 .setup = testsuite_setup,
6145 .teardown = testsuite_teardown,
6146 .unit_test_cases = {
6147 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
6149 TEST_CASES_END() /**< NULL terminate unit test array */
6153 static struct unit_test_suite cryptodev_libcrypto_testsuite = {
6154 .suite_name = "Crypto Device LIBCRYPTO Unit Test Suite",
6155 .setup = testsuite_setup,
6156 .teardown = testsuite_teardown,
6157 .unit_test_cases = {
6158 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
6159 TEST_CASE_ST(ut_setup, ut_teardown,
6160 test_multi_session_random_usage),
6161 TEST_CASE_ST(ut_setup, ut_teardown,
6162 test_AES_chain_libcrypto_all),
6163 TEST_CASE_ST(ut_setup, ut_teardown,
6164 test_AES_cipheronly_libcrypto_all),
6165 TEST_CASE_ST(ut_setup, ut_teardown,
6166 test_3DES_chain_libcrypto_all),
6167 TEST_CASE_ST(ut_setup, ut_teardown,
6168 test_3DES_cipheronly_libcrypto_all),
6169 TEST_CASE_ST(ut_setup, ut_teardown,
6170 test_authonly_libcrypto_all),
6172 /** AES GCM Authenticated Encryption */
6173 TEST_CASE_ST(ut_setup, ut_teardown,
6174 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6175 TEST_CASE_ST(ut_setup, ut_teardown,
6176 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6177 TEST_CASE_ST(ut_setup, ut_teardown,
6178 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6179 TEST_CASE_ST(ut_setup, ut_teardown,
6180 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6181 TEST_CASE_ST(ut_setup, ut_teardown,
6182 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6183 TEST_CASE_ST(ut_setup, ut_teardown,
6184 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6185 TEST_CASE_ST(ut_setup, ut_teardown,
6186 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6188 /** AES GCM Authenticated Decryption */
6189 TEST_CASE_ST(ut_setup, ut_teardown,
6190 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6191 TEST_CASE_ST(ut_setup, ut_teardown,
6192 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6193 TEST_CASE_ST(ut_setup, ut_teardown,
6194 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6195 TEST_CASE_ST(ut_setup, ut_teardown,
6196 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6197 TEST_CASE_ST(ut_setup, ut_teardown,
6198 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6199 TEST_CASE_ST(ut_setup, ut_teardown,
6200 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6201 TEST_CASE_ST(ut_setup, ut_teardown,
6202 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6204 /** AES GMAC Authentication */
6205 TEST_CASE_ST(ut_setup, ut_teardown,
6206 test_AES_GMAC_authentication_test_case_1),
6207 TEST_CASE_ST(ut_setup, ut_teardown,
6208 test_AES_GMAC_authentication_verify_test_case_1),
6209 TEST_CASE_ST(ut_setup, ut_teardown,
6210 test_AES_GMAC_authentication_test_case_2),
6211 TEST_CASE_ST(ut_setup, ut_teardown,
6212 test_AES_GMAC_authentication_verify_test_case_2),
6213 TEST_CASE_ST(ut_setup, ut_teardown,
6214 test_AES_GMAC_authentication_test_case_3),
6215 TEST_CASE_ST(ut_setup, ut_teardown,
6216 test_AES_GMAC_authentication_verify_test_case_3),
6217 TEST_CASE_ST(ut_setup, ut_teardown,
6218 test_AES_GMAC_authentication_test_case_4),
6219 TEST_CASE_ST(ut_setup, ut_teardown,
6220 test_AES_GMAC_authentication_verify_test_case_4),
6222 /** Negative tests */
6223 TEST_CASE_ST(ut_setup, ut_teardown,
6224 authentication_verify_HMAC_SHA1_fail_data_corrupt),
6225 TEST_CASE_ST(ut_setup, ut_teardown,
6226 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6227 TEST_CASE_ST(ut_setup, ut_teardown,
6228 authentication_verify_AES128_GMAC_fail_data_corrupt),
6229 TEST_CASE_ST(ut_setup, ut_teardown,
6230 authentication_verify_AES128_GMAC_fail_tag_corrupt),
6231 TEST_CASE_ST(ut_setup, ut_teardown,
6232 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6233 TEST_CASE_ST(ut_setup, ut_teardown,
6234 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6236 TEST_CASES_END() /**< NULL terminate unit test array */
6240 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
6241 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
6242 .setup = testsuite_setup,
6243 .teardown = testsuite_teardown,
6244 .unit_test_cases = {
6245 /** AES GCM Authenticated Encryption */
6246 TEST_CASE_ST(ut_setup, ut_teardown,
6247 test_mb_AES_GCM_authenticated_encryption_test_case_1),
6248 TEST_CASE_ST(ut_setup, ut_teardown,
6249 test_mb_AES_GCM_authenticated_encryption_test_case_2),
6250 TEST_CASE_ST(ut_setup, ut_teardown,
6251 test_mb_AES_GCM_authenticated_encryption_test_case_3),
6252 TEST_CASE_ST(ut_setup, ut_teardown,
6253 test_mb_AES_GCM_authenticated_encryption_test_case_4),
6254 TEST_CASE_ST(ut_setup, ut_teardown,
6255 test_mb_AES_GCM_authenticated_encryption_test_case_5),
6256 TEST_CASE_ST(ut_setup, ut_teardown,
6257 test_mb_AES_GCM_authenticated_encryption_test_case_6),
6258 TEST_CASE_ST(ut_setup, ut_teardown,
6259 test_mb_AES_GCM_authenticated_encryption_test_case_7),
6261 /** AES GCM Authenticated Decryption */
6262 TEST_CASE_ST(ut_setup, ut_teardown,
6263 test_mb_AES_GCM_authenticated_decryption_test_case_1),
6264 TEST_CASE_ST(ut_setup, ut_teardown,
6265 test_mb_AES_GCM_authenticated_decryption_test_case_2),
6266 TEST_CASE_ST(ut_setup, ut_teardown,
6267 test_mb_AES_GCM_authenticated_decryption_test_case_3),
6268 TEST_CASE_ST(ut_setup, ut_teardown,
6269 test_mb_AES_GCM_authenticated_decryption_test_case_4),
6270 TEST_CASE_ST(ut_setup, ut_teardown,
6271 test_mb_AES_GCM_authenticated_decryption_test_case_5),
6272 TEST_CASE_ST(ut_setup, ut_teardown,
6273 test_mb_AES_GCM_authenticated_decryption_test_case_6),
6274 TEST_CASE_ST(ut_setup, ut_teardown,
6275 test_mb_AES_GCM_authenticated_decryption_test_case_7),
6277 TEST_CASES_END() /**< NULL terminate unit test array */
6281 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
6282 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
6283 .setup = testsuite_setup,
6284 .teardown = testsuite_teardown,
6285 .unit_test_cases = {
6286 /** KASUMI encrypt only (UEA1) */
6287 TEST_CASE_ST(ut_setup, ut_teardown,
6288 test_kasumi_encryption_test_case_1),
6289 TEST_CASE_ST(ut_setup, ut_teardown,
6290 test_kasumi_encryption_test_case_2),
6291 TEST_CASE_ST(ut_setup, ut_teardown,
6292 test_kasumi_encryption_test_case_3),
6293 TEST_CASE_ST(ut_setup, ut_teardown,
6294 test_kasumi_encryption_test_case_4),
6295 TEST_CASE_ST(ut_setup, ut_teardown,
6296 test_kasumi_encryption_test_case_5),
6297 /** KASUMI decrypt only (UEA1) */
6298 TEST_CASE_ST(ut_setup, ut_teardown,
6299 test_kasumi_decryption_test_case_1),
6300 TEST_CASE_ST(ut_setup, ut_teardown,
6301 test_kasumi_decryption_test_case_2),
6302 TEST_CASE_ST(ut_setup, ut_teardown,
6303 test_kasumi_decryption_test_case_3),
6304 TEST_CASE_ST(ut_setup, ut_teardown,
6305 test_kasumi_decryption_test_case_4),
6306 TEST_CASE_ST(ut_setup, ut_teardown,
6307 test_kasumi_decryption_test_case_5),
6309 TEST_CASE_ST(ut_setup, ut_teardown,
6310 test_kasumi_encryption_test_case_1_oop),
6311 TEST_CASE_ST(ut_setup, ut_teardown,
6312 test_kasumi_decryption_test_case_1_oop),
6314 /** KASUMI hash only (UIA1) */
6315 TEST_CASE_ST(ut_setup, ut_teardown,
6316 test_kasumi_hash_generate_test_case_1),
6317 TEST_CASE_ST(ut_setup, ut_teardown,
6318 test_kasumi_hash_generate_test_case_2),
6319 TEST_CASE_ST(ut_setup, ut_teardown,
6320 test_kasumi_hash_generate_test_case_3),
6321 TEST_CASE_ST(ut_setup, ut_teardown,
6322 test_kasumi_hash_generate_test_case_4),
6323 TEST_CASE_ST(ut_setup, ut_teardown,
6324 test_kasumi_hash_generate_test_case_5),
6325 TEST_CASE_ST(ut_setup, ut_teardown,
6326 test_kasumi_hash_generate_test_case_6),
6327 TEST_CASE_ST(ut_setup, ut_teardown,
6328 test_kasumi_hash_verify_test_case_1),
6329 TEST_CASE_ST(ut_setup, ut_teardown,
6330 test_kasumi_hash_verify_test_case_2),
6331 TEST_CASE_ST(ut_setup, ut_teardown,
6332 test_kasumi_hash_verify_test_case_3),
6333 TEST_CASE_ST(ut_setup, ut_teardown,
6334 test_kasumi_hash_verify_test_case_4),
6335 TEST_CASE_ST(ut_setup, ut_teardown,
6336 test_kasumi_hash_verify_test_case_5),
6337 TEST_CASE_ST(ut_setup, ut_teardown,
6338 test_kasumi_auth_cipher_test_case_1),
6339 TEST_CASE_ST(ut_setup, ut_teardown,
6340 test_kasumi_cipher_auth_test_case_1),
6341 TEST_CASES_END() /**< NULL terminate unit test array */
6344 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
6345 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
6346 .setup = testsuite_setup,
6347 .teardown = testsuite_teardown,
6348 .unit_test_cases = {
6349 /** SNOW 3G encrypt only (UEA2) */
6350 TEST_CASE_ST(ut_setup, ut_teardown,
6351 test_snow3g_encryption_test_case_1),
6352 TEST_CASE_ST(ut_setup, ut_teardown,
6353 test_snow3g_encryption_test_case_2),
6354 TEST_CASE_ST(ut_setup, ut_teardown,
6355 test_snow3g_encryption_test_case_3),
6356 TEST_CASE_ST(ut_setup, ut_teardown,
6357 test_snow3g_encryption_test_case_4),
6358 TEST_CASE_ST(ut_setup, ut_teardown,
6359 test_snow3g_encryption_test_case_5),
6361 TEST_CASE_ST(ut_setup, ut_teardown,
6362 test_snow3g_encryption_test_case_1_oop),
6363 TEST_CASE_ST(ut_setup, ut_teardown,
6364 test_snow3g_decryption_test_case_1_oop),
6366 TEST_CASE_ST(ut_setup, ut_teardown,
6367 test_snow3g_encryption_test_case_1_offset_oop),
6369 /** SNOW 3G decrypt only (UEA2) */
6370 TEST_CASE_ST(ut_setup, ut_teardown,
6371 test_snow3g_decryption_test_case_1),
6372 TEST_CASE_ST(ut_setup, ut_teardown,
6373 test_snow3g_decryption_test_case_2),
6374 TEST_CASE_ST(ut_setup, ut_teardown,
6375 test_snow3g_decryption_test_case_3),
6376 TEST_CASE_ST(ut_setup, ut_teardown,
6377 test_snow3g_decryption_test_case_4),
6378 TEST_CASE_ST(ut_setup, ut_teardown,
6379 test_snow3g_decryption_test_case_5),
6380 TEST_CASE_ST(ut_setup, ut_teardown,
6381 test_snow3g_hash_generate_test_case_1),
6382 TEST_CASE_ST(ut_setup, ut_teardown,
6383 test_snow3g_hash_generate_test_case_2),
6384 TEST_CASE_ST(ut_setup, ut_teardown,
6385 test_snow3g_hash_generate_test_case_3),
6386 /* Tests with buffers which length is not byte-aligned */
6387 TEST_CASE_ST(ut_setup, ut_teardown,
6388 test_snow3g_hash_generate_test_case_4),
6389 TEST_CASE_ST(ut_setup, ut_teardown,
6390 test_snow3g_hash_generate_test_case_5),
6391 TEST_CASE_ST(ut_setup, ut_teardown,
6392 test_snow3g_hash_generate_test_case_6),
6393 TEST_CASE_ST(ut_setup, ut_teardown,
6394 test_snow3g_hash_verify_test_case_1),
6395 TEST_CASE_ST(ut_setup, ut_teardown,
6396 test_snow3g_hash_verify_test_case_2),
6397 TEST_CASE_ST(ut_setup, ut_teardown,
6398 test_snow3g_hash_verify_test_case_3),
6399 /* Tests with buffers which length is not byte-aligned */
6400 TEST_CASE_ST(ut_setup, ut_teardown,
6401 test_snow3g_hash_verify_test_case_4),
6402 TEST_CASE_ST(ut_setup, ut_teardown,
6403 test_snow3g_hash_verify_test_case_5),
6404 TEST_CASE_ST(ut_setup, ut_teardown,
6405 test_snow3g_hash_verify_test_case_6),
6406 TEST_CASE_ST(ut_setup, ut_teardown,
6407 test_snow3g_cipher_auth_test_case_1),
6408 TEST_CASE_ST(ut_setup, ut_teardown,
6409 test_snow3g_auth_cipher_test_case_1),
6411 TEST_CASES_END() /**< NULL terminate unit test array */
6415 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
6416 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
6417 .setup = testsuite_setup,
6418 .teardown = testsuite_teardown,
6419 .unit_test_cases = {
6420 /** ZUC encrypt only (EEA3) */
6421 TEST_CASE_ST(ut_setup, ut_teardown,
6422 test_zuc_encryption_test_case_1),
6423 TEST_CASE_ST(ut_setup, ut_teardown,
6424 test_zuc_encryption_test_case_2),
6425 TEST_CASE_ST(ut_setup, ut_teardown,
6426 test_zuc_encryption_test_case_3),
6427 TEST_CASE_ST(ut_setup, ut_teardown,
6428 test_zuc_encryption_test_case_4),
6429 TEST_CASE_ST(ut_setup, ut_teardown,
6430 test_zuc_encryption_test_case_5),
6431 TEST_CASE_ST(ut_setup, ut_teardown,
6432 test_zuc_hash_generate_test_case_1),
6433 TEST_CASE_ST(ut_setup, ut_teardown,
6434 test_zuc_hash_generate_test_case_2),
6435 TEST_CASE_ST(ut_setup, ut_teardown,
6436 test_zuc_hash_generate_test_case_3),
6437 TEST_CASE_ST(ut_setup, ut_teardown,
6438 test_zuc_hash_generate_test_case_4),
6439 TEST_CASE_ST(ut_setup, ut_teardown,
6440 test_zuc_hash_generate_test_case_5),
6441 TEST_CASES_END() /**< NULL terminate unit test array */
6445 static struct unit_test_suite cryptodev_null_testsuite = {
6446 .suite_name = "Crypto Device NULL Unit Test Suite",
6447 .setup = testsuite_setup,
6448 .teardown = testsuite_teardown,
6449 .unit_test_cases = {
6450 TEST_CASE_ST(ut_setup, ut_teardown,
6451 test_null_auth_only_operation),
6452 TEST_CASE_ST(ut_setup, ut_teardown,
6453 test_null_cipher_only_operation),
6454 TEST_CASE_ST(ut_setup, ut_teardown,
6455 test_null_cipher_auth_operation),
6456 TEST_CASE_ST(ut_setup, ut_teardown,
6457 test_null_auth_cipher_operation),
6458 TEST_CASE_ST(ut_setup, ut_teardown,
6459 test_null_invalid_operation),
6460 TEST_CASE_ST(ut_setup, ut_teardown,
6461 test_null_burst_operation),
6463 TEST_CASES_END() /**< NULL terminate unit test array */
6468 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
6470 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
6471 return unit_test_suite_runner(&cryptodev_qat_testsuite);
6475 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
6477 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
6479 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
6483 test_cryptodev_libcrypto(void)
6485 gbl_cryptodev_type = RTE_CRYPTODEV_LIBCRYPTO_PMD;
6487 return unit_test_suite_runner(&cryptodev_libcrypto_testsuite);
6491 test_cryptodev_aesni_gcm(void)
6493 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
6495 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
6499 test_cryptodev_null(void)
6501 gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
6503 return unit_test_suite_runner(&cryptodev_null_testsuite);
6507 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
6509 gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
6511 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
6515 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
6517 gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
6519 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
6523 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
6525 gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
6527 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
6530 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
6531 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
6532 REGISTER_TEST_COMMAND(cryptodev_libcrypto_autotest, test_cryptodev_libcrypto);
6533 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
6534 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
6535 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
6536 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
6537 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);