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>
38 #include <rte_mbuf_offload.h>
40 #include <rte_crypto.h>
41 #include <rte_cryptodev.h>
42 #include <rte_cryptodev_pmd.h>
45 #include "test_cryptodev.h"
47 static enum rte_cryptodev_type gbl_cryptodev_type;
49 struct crypto_testsuite_params {
50 struct rte_mempool *mbuf_pool;
51 struct rte_mempool *op_mpool;
52 struct rte_cryptodev_config conf;
53 struct rte_cryptodev_qp_conf qp_conf;
55 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
56 uint8_t valid_dev_count;
59 struct crypto_unittest_params {
60 struct rte_crypto_sym_xform cipher_xform;
61 struct rte_crypto_sym_xform auth_xform;
63 struct rte_cryptodev_sym_session *sess;
65 struct rte_crypto_op *op;
67 struct rte_mbuf *obuf, *ibuf;
73 * Forward declarations.
76 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
77 struct crypto_unittest_params *ut_params);
80 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
81 struct crypto_unittest_params *ut_params,
82 struct crypto_testsuite_params *ts_param);
84 static struct rte_mbuf *
85 setup_test_string(struct rte_mempool *mpool,
86 const char *string, size_t len, uint8_t blocksize)
88 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
89 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
91 memset(m->buf_addr, 0, m->buf_len);
93 char *dst = rte_pktmbuf_append(m, t_len);
100 rte_memcpy(dst, string, t_len);
108 hexdump_mbuf_data(FILE *f, const char *title, struct rte_mbuf *m)
110 rte_hexdump(f, title, rte_pktmbuf_mtod(m, const void *), m->data_len);
114 static struct rte_crypto_op *
115 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
118 hexdump_mbuf_data(stdout, "Enqueued Packet", ibuf);
121 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
122 printf("Error sending packet for encryption");
128 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
133 hexdump_mbuf_data(stdout, "Dequeued Packet", obuf);
139 static struct crypto_testsuite_params testsuite_params = { NULL };
140 static struct crypto_unittest_params unittest_params;
143 testsuite_setup(void)
145 struct crypto_testsuite_params *ts_params = &testsuite_params;
146 struct rte_cryptodev_info info;
147 unsigned i, nb_devs, dev_id;
151 memset(ts_params, 0, sizeof(*ts_params));
153 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
154 if (ts_params->mbuf_pool == NULL) {
155 /* Not already created so create */
156 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
158 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
160 if (ts_params->mbuf_pool == NULL) {
161 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
166 ts_params->op_mpool = rte_crypto_op_pool_create(
167 "MBUF_CRYPTO_SYM_OP_POOL",
168 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
169 NUM_MBUFS, MBUF_CACHE_SIZE,
171 sizeof(struct rte_crypto_sym_xform),
173 if (ts_params->op_mpool == NULL) {
174 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
178 /* Create 2 AESNI MB devices if required */
179 if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
180 nb_devs = rte_cryptodev_count_devtype(
181 RTE_CRYPTODEV_AESNI_MB_PMD);
183 for (i = nb_devs; i < 2; i++) {
184 ret = rte_eal_vdev_init(
185 CRYPTODEV_NAME_AESNI_MB_PMD, NULL);
187 TEST_ASSERT(ret == 0,
188 "Failed to create instance %u of"
190 i, CRYPTODEV_NAME_AESNI_MB_PMD);
195 nb_devs = rte_cryptodev_count();
197 RTE_LOG(ERR, USER1, "No crypto devices found?");
201 /* Create list of valid crypto devs */
202 for (i = 0; i < nb_devs; i++) {
203 rte_cryptodev_info_get(i, &info);
204 if (info.dev_type == gbl_cryptodev_type)
205 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
208 if (ts_params->valid_dev_count < 1)
211 /* Set up all the qps on the first of the valid devices found */
212 for (i = 0; i < 1; i++) {
213 dev_id = ts_params->valid_devs[i];
215 rte_cryptodev_info_get(dev_id, &info);
218 * Since we can't free and re-allocate queue memory always set
219 * the queues on this device up to max size first so enough
220 * memory is allocated for any later re-configures needed by
224 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
225 ts_params->conf.socket_id = SOCKET_ID_ANY;
226 ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
228 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
230 "Failed to configure cryptodev %u with %u qps",
231 dev_id, ts_params->conf.nb_queue_pairs);
233 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
235 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
236 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
237 dev_id, qp_id, &ts_params->qp_conf,
238 rte_cryptodev_socket_id(dev_id)),
239 "Failed to setup queue pair %u on "
249 testsuite_teardown(void)
251 struct crypto_testsuite_params *ts_params = &testsuite_params;
253 if (ts_params->mbuf_pool != NULL) {
254 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
255 rte_mempool_count(ts_params->mbuf_pool));
258 if (ts_params->op_mpool != NULL) {
259 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
260 rte_mempool_count(ts_params->op_mpool));
268 struct crypto_testsuite_params *ts_params = &testsuite_params;
269 struct crypto_unittest_params *ut_params = &unittest_params;
273 /* Clear unit test parameters before running test */
274 memset(ut_params, 0, sizeof(*ut_params));
276 /* Reconfigure device to default parameters */
277 ts_params->conf.nb_queue_pairs = DEFAULT_NUM_QPS_PER_QAT_DEVICE;
278 ts_params->conf.socket_id = SOCKET_ID_ANY;
279 ts_params->conf.session_mp.nb_objs =
280 (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) ?
281 DEFAULT_NUM_OPS_INFLIGHT :
282 DEFAULT_NUM_OPS_INFLIGHT;
284 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
286 "Failed to configure cryptodev %u",
287 ts_params->valid_devs[0]);
290 * Now reconfigure queues to size we actually want to use in this
293 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
295 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
296 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
297 ts_params->valid_devs[0], qp_id,
299 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
300 "Failed to setup queue pair %u on cryptodev %u",
301 qp_id, ts_params->valid_devs[0]);
305 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
307 /* Start the device */
308 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
309 "Failed to start cryptodev %u",
310 ts_params->valid_devs[0]);
318 struct crypto_testsuite_params *ts_params = &testsuite_params;
319 struct crypto_unittest_params *ut_params = &unittest_params;
320 struct rte_cryptodev_stats stats;
322 /* free crypto session structure */
323 if (ut_params->sess) {
324 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
326 ut_params->sess = NULL;
329 /* free crypto operation structure */
331 rte_crypto_op_free(ut_params->op);
334 * free mbuf - both obuf and ibuf are usually the same,
335 * but rte copes even if we call free twice
337 if (ut_params->obuf) {
338 rte_pktmbuf_free(ut_params->obuf);
341 if (ut_params->ibuf) {
342 rte_pktmbuf_free(ut_params->ibuf);
346 if (ts_params->mbuf_pool != NULL)
347 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
348 rte_mempool_count(ts_params->mbuf_pool));
350 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
352 /* Stop the device */
353 rte_cryptodev_stop(ts_params->valid_devs[0]);
357 test_device_configure_invalid_dev_id(void)
359 struct crypto_testsuite_params *ts_params = &testsuite_params;
360 uint16_t dev_id, num_devs = 0;
362 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
363 "Need at least %d devices for test", 1);
365 /* valid dev_id values */
366 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
368 /* Stop the device in case it's started so it can be configured */
369 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
371 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
372 "Failed test for rte_cryptodev_configure: "
373 "invalid dev_num %u", dev_id);
375 /* invalid dev_id values */
378 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
379 "Failed test for rte_cryptodev_configure: "
380 "invalid dev_num %u", dev_id);
384 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
385 "Failed test for rte_cryptodev_configure:"
386 "invalid dev_num %u", dev_id);
392 test_device_configure_invalid_queue_pair_ids(void)
394 struct crypto_testsuite_params *ts_params = &testsuite_params;
396 /* Stop the device in case it's started so it can be configured */
397 rte_cryptodev_stop(ts_params->valid_devs[0]);
399 /* valid - one queue pairs */
400 ts_params->conf.nb_queue_pairs = 1;
402 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
404 "Failed to configure cryptodev: dev_id %u, qp_id %u",
405 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
408 /* valid - max value queue pairs */
409 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
411 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
413 "Failed to configure cryptodev: dev_id %u, qp_id %u",
414 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
417 /* invalid - zero queue pairs */
418 ts_params->conf.nb_queue_pairs = 0;
420 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
422 "Failed test for rte_cryptodev_configure, dev_id %u,"
424 ts_params->valid_devs[0],
425 ts_params->conf.nb_queue_pairs);
428 /* invalid - max value supported by field queue pairs */
429 ts_params->conf.nb_queue_pairs = UINT16_MAX;
431 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
433 "Failed test for rte_cryptodev_configure, dev_id %u,"
435 ts_params->valid_devs[0],
436 ts_params->conf.nb_queue_pairs);
439 /* invalid - max value + 1 queue pairs */
440 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
442 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
444 "Failed test for rte_cryptodev_configure, dev_id %u,"
446 ts_params->valid_devs[0],
447 ts_params->conf.nb_queue_pairs);
453 test_queue_pair_descriptor_setup(void)
455 struct crypto_testsuite_params *ts_params = &testsuite_params;
456 struct rte_cryptodev_info dev_info;
457 struct rte_cryptodev_qp_conf qp_conf = {
458 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
463 /* Stop the device in case it's started so it can be configured */
464 rte_cryptodev_stop(ts_params->valid_devs[0]);
467 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
469 ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
471 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
472 &ts_params->conf), "Failed to configure cryptodev %u",
473 ts_params->valid_devs[0]);
477 * Test various ring sizes on this device. memzones can't be
478 * freed so are re-used if ring is released and re-created.
480 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
482 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
483 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
484 ts_params->valid_devs[0], qp_id, &qp_conf,
485 rte_cryptodev_socket_id(
486 ts_params->valid_devs[0])),
488 "rte_cryptodev_queue_pair_setup: num_inflights "
489 "%u on qp %u on cryptodev %u",
490 qp_conf.nb_descriptors, qp_id,
491 ts_params->valid_devs[0]);
494 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
496 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
497 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
498 ts_params->valid_devs[0], qp_id, &qp_conf,
499 rte_cryptodev_socket_id(
500 ts_params->valid_devs[0])),
502 " rte_cryptodev_queue_pair_setup: num_inflights"
503 " %u on qp %u on cryptodev %u",
504 qp_conf.nb_descriptors, qp_id,
505 ts_params->valid_devs[0]);
508 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
510 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
511 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
512 ts_params->valid_devs[0], qp_id, &qp_conf,
513 rte_cryptodev_socket_id(
514 ts_params->valid_devs[0])),
516 "rte_cryptodev_queue_pair_setup: num_inflights"
517 " %u on qp %u on cryptodev %u",
518 qp_conf.nb_descriptors, qp_id,
519 ts_params->valid_devs[0]);
522 /* invalid number of descriptors - max supported + 2 */
523 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
525 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
526 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
527 ts_params->valid_devs[0], qp_id, &qp_conf,
528 rte_cryptodev_socket_id(
529 ts_params->valid_devs[0])),
530 "Unexpectedly passed test for "
531 "rte_cryptodev_queue_pair_setup:"
532 "num_inflights %u on qp %u on cryptodev %u",
533 qp_conf.nb_descriptors, qp_id,
534 ts_params->valid_devs[0]);
537 /* invalid number of descriptors - max value of parameter */
538 qp_conf.nb_descriptors = UINT32_MAX-1;
540 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
541 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
542 ts_params->valid_devs[0], qp_id, &qp_conf,
543 rte_cryptodev_socket_id(
544 ts_params->valid_devs[0])),
545 "Unexpectedly passed test for "
546 "rte_cryptodev_queue_pair_setup:"
547 "num_inflights %u on qp %u on cryptodev %u",
548 qp_conf.nb_descriptors, qp_id,
549 ts_params->valid_devs[0]);
552 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
554 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
555 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
556 ts_params->valid_devs[0], qp_id, &qp_conf,
557 rte_cryptodev_socket_id(
558 ts_params->valid_devs[0])),
560 " rte_cryptodev_queue_pair_setup:"
561 "num_inflights %u on qp %u on cryptodev %u",
562 qp_conf.nb_descriptors, qp_id,
563 ts_params->valid_devs[0]);
566 /* invalid number of descriptors - max supported + 1 */
567 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
569 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
570 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
571 ts_params->valid_devs[0], qp_id, &qp_conf,
572 rte_cryptodev_socket_id(
573 ts_params->valid_devs[0])),
574 "Unexpectedly passed test for "
575 "rte_cryptodev_queue_pair_setup:"
576 "num_inflights %u on qp %u on cryptodev %u",
577 qp_conf.nb_descriptors, qp_id,
578 ts_params->valid_devs[0]);
581 /* test invalid queue pair id */
582 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
584 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
586 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
587 ts_params->valid_devs[0],
589 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
590 "Failed test for rte_cryptodev_queue_pair_setup:"
591 "invalid qp %u on cryptodev %u",
592 qp_id, ts_params->valid_devs[0]);
594 qp_id = 0xffff; /*invalid*/
596 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
597 ts_params->valid_devs[0],
599 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
600 "Failed test for rte_cryptodev_queue_pair_setup:"
601 "invalid qp %u on cryptodev %u",
602 qp_id, ts_params->valid_devs[0]);
607 /* ***** Plaintext data for tests ***** */
609 const char catch_22_quote_1[] =
610 "There was only one catch and that was Catch-22, which "
611 "specified that a concern for one's safety in the face of "
612 "dangers that were real and immediate was the process of a "
613 "rational mind. Orr was crazy and could be grounded. All he "
614 "had to do was ask; and as soon as he did, he would no longer "
615 "be crazy and would have to fly more missions. Orr would be "
616 "crazy to fly more missions and sane if he didn't, but if he "
617 "was sane he had to fly them. If he flew them he was crazy "
618 "and didn't have to; but if he didn't want to he was sane and "
619 "had to. Yossarian was moved very deeply by the absolute "
620 "simplicity of this clause of Catch-22 and let out a "
621 "respectful whistle. \"That's some catch, that Catch-22\", he "
622 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
624 const char catch_22_quote[] =
625 "What a lousy earth! He wondered how many people were "
626 "destitute that same night even in his own prosperous country, "
627 "how many homes were shanties, how many husbands were drunk "
628 "and wives socked, and how many children were bullied, abused, "
629 "or abandoned. How many families hungered for food they could "
630 "not afford to buy? How many hearts were broken? How many "
631 "suicides would take place that same night, how many people "
632 "would go insane? How many cockroaches and landlords would "
633 "triumph? How many winners were losers, successes failures, "
634 "and rich men poor men? How many wise guys were stupid? How "
635 "many happy endings were unhappy endings? How many honest men "
636 "were liars, brave men cowards, loyal men traitors, how many "
637 "sainted men were corrupt, how many people in positions of "
638 "trust had sold their souls to bodyguards, how many had never "
639 "had souls? How many straight-and-narrow paths were crooked "
640 "paths? How many best families were worst families and how "
641 "many good people were bad people? When you added them all up "
642 "and then subtracted, you might be left with only the children, "
643 "and perhaps with Albert Einstein and an old violinist or "
644 "sculptor somewhere.";
646 #define QUOTE_480_BYTES (480)
647 #define QUOTE_512_BYTES (512)
648 #define QUOTE_768_BYTES (768)
649 #define QUOTE_1024_BYTES (1024)
653 /* ***** SHA1 Hash Tests ***** */
655 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
657 static uint8_t hmac_sha1_key[] = {
658 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
659 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
660 0xDE, 0xF4, 0xDE, 0xAD };
662 /* ***** SHA224 Hash Tests ***** */
664 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
667 /* ***** AES-CBC Cipher Tests ***** */
669 #define CIPHER_KEY_LENGTH_AES_CBC (16)
670 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
672 static uint8_t aes_cbc_key[] = {
673 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
674 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
676 static uint8_t aes_cbc_iv[] = {
677 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
678 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
681 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
683 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
684 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
685 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
686 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
687 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
688 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
689 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
690 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
691 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
692 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
693 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
694 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
695 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
696 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
697 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
698 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
699 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
700 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
701 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
702 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
703 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
704 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
705 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
706 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
707 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
708 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
709 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
710 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
711 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
712 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
713 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
714 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
715 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
716 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
717 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
718 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
719 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
720 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
721 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
722 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
723 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
724 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
725 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
726 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
727 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
728 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
729 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
730 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
731 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
732 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
733 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
734 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
735 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
736 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
737 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
738 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
739 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
740 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
741 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
742 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
743 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
744 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
745 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
746 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
747 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
750 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
751 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
752 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
753 0x18, 0x8c, 0x1d, 0x32
758 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
760 struct crypto_testsuite_params *ts_params = &testsuite_params;
761 struct crypto_unittest_params *ut_params = &unittest_params;
763 /* Generate test mbuf data and space for digest */
764 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
765 catch_22_quote, QUOTE_512_BYTES, 0);
767 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
768 DIGEST_BYTE_LENGTH_SHA1);
769 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
771 /* Setup Cipher Parameters */
772 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
773 ut_params->cipher_xform.next = &ut_params->auth_xform;
775 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
776 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
777 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
778 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
780 /* Setup HMAC Parameters */
781 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
783 ut_params->auth_xform.next = NULL;
785 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
786 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
787 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
788 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
789 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
791 /* Create crypto session*/
792 ut_params->sess = rte_cryptodev_sym_session_create(
793 ts_params->valid_devs[0],
794 &ut_params->cipher_xform);
795 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
797 /* Generate crypto op data structure */
798 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
799 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
800 TEST_ASSERT_NOT_NULL(ut_params->op,
801 "Failed to allocate symmetric crypto operation struct");
803 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
805 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
807 /* set crypto operation source mbuf */
808 sym_op->m_src = ut_params->ibuf;
810 /* Set crypto operation authentication parameters */
811 sym_op->auth.digest.data = ut_params->digest;
812 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
813 ut_params->ibuf, QUOTE_512_BYTES);
814 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
816 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
817 sym_op->auth.data.length = QUOTE_512_BYTES;
819 /* Set crypto operation cipher parameters */
820 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
821 CIPHER_IV_LENGTH_AES_CBC);
822 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
823 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
825 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
826 CIPHER_IV_LENGTH_AES_CBC);
828 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
829 sym_op->cipher.data.length = QUOTE_512_BYTES;
831 /* Process crypto operation */
832 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
833 ut_params->op), "failed to process sym crypto op");
835 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
836 "crypto op processing failed");
839 uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
840 uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
842 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
843 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
845 "ciphertext data not as expected");
847 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
849 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
850 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
851 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
852 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
853 DIGEST_BYTE_LENGTH_SHA1,
854 "Generated digest data not as expected");
860 test_AES_CBC_HMAC_SHA1_encrypt_digest_sessionless(void)
862 struct crypto_testsuite_params *ts_params = &testsuite_params;
863 struct crypto_unittest_params *ut_params = &unittest_params;
865 /* Generate test mbuf data and space for digest */
866 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
867 catch_22_quote, QUOTE_512_BYTES, 0);
869 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
870 DIGEST_BYTE_LENGTH_SHA1);
871 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
873 /* Generate Crypto op data structure */
874 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
875 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
876 TEST_ASSERT_NOT_NULL(ut_params->op,
877 "Failed to allocate symmetric crypto operation struct");
879 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(ut_params->op, 2),
880 "failed to allocate space for crypto transforms");
882 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
884 /* set crypto operation source mbuf */
885 sym_op->m_src = ut_params->ibuf;
887 /* Set crypto operation data parameters */
888 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
890 /* cipher parameters */
891 sym_op->xform->cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
892 sym_op->xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
893 sym_op->xform->cipher.key.data = aes_cbc_key;
894 sym_op->xform->cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
896 /* hash parameters */
897 sym_op->xform->next->type = RTE_CRYPTO_SYM_XFORM_AUTH;
899 sym_op->xform->next->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
900 sym_op->xform->next->auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
901 sym_op->xform->next->auth.key.length = HMAC_KEY_LENGTH_SHA1;
902 sym_op->xform->next->auth.key.data = hmac_sha1_key;
903 sym_op->xform->next->auth.digest_length =
904 DIGEST_BYTE_LENGTH_SHA1;
906 sym_op->auth.digest.data = ut_params->digest;
907 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
908 ut_params->ibuf, QUOTE_512_BYTES);
909 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
912 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
913 sym_op->auth.data.length = QUOTE_512_BYTES;
915 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
916 CIPHER_IV_LENGTH_AES_CBC);
917 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
918 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
920 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
921 CIPHER_IV_LENGTH_AES_CBC);
923 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
924 sym_op->cipher.data.length = QUOTE_512_BYTES;
926 /* Process crypto operation */
927 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
928 ut_params->op), "failed to process sym crypto op");
930 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
931 "crypto op processing failed");
933 ut_params->obuf = ut_params->op->sym->m_src;
936 TEST_ASSERT_BUFFERS_ARE_EQUAL(
937 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
938 CIPHER_IV_LENGTH_AES_CBC,
939 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
941 "Ciphertext data not as expected");
943 TEST_ASSERT_BUFFERS_ARE_EQUAL(
944 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
945 CIPHER_IV_LENGTH_AES_CBC + QUOTE_512_BYTES,
946 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
947 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
948 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
949 DIGEST_BYTE_LENGTH_SHA1,
950 "Generated digest data not as expected");
957 test_AES_CBC_HMAC_SHA1_decrypt_digest_verify(void)
959 struct crypto_testsuite_params *ts_params = &testsuite_params;
960 struct crypto_unittest_params *ut_params = &unittest_params;
962 /* Generate test mbuf data and digest */
963 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
965 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
968 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
969 DIGEST_BYTE_LENGTH_SHA1);
970 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
972 rte_memcpy(ut_params->digest,
973 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
974 DIGEST_BYTE_LENGTH_SHA1);
976 /* Setup Cipher Parameters */
977 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
978 ut_params->cipher_xform.next = NULL;
980 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
981 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
982 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
983 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
985 /* Setup HMAC Parameters */
986 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
987 ut_params->auth_xform.next = &ut_params->cipher_xform;
989 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
990 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
991 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
992 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
993 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
995 /* Create Crypto session*/
997 rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
998 &ut_params->auth_xform);
999 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1001 /* Generate Crypto op data structure */
1002 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1003 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1004 TEST_ASSERT_NOT_NULL(ut_params->op,
1005 "Failed to allocate symmetric crypto operation struct");
1007 /* attach symmetric crypto session to crypto operations */
1008 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1010 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1012 /* set crypto operation source mbuf */
1013 sym_op->m_src = ut_params->ibuf;
1015 sym_op->auth.digest.data = ut_params->digest;
1016 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1017 ut_params->ibuf, QUOTE_512_BYTES);
1018 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1020 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1021 sym_op->auth.data.length = QUOTE_512_BYTES;
1023 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1024 CIPHER_IV_LENGTH_AES_CBC);
1025 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1026 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1028 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1029 CIPHER_IV_LENGTH_AES_CBC);
1031 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1032 sym_op->cipher.data.length = QUOTE_512_BYTES;
1035 /* Process crypto operation */
1036 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1037 ut_params->op), "failed to process sym crypto op");
1039 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1040 "crypto op processing failed");
1042 ut_params->obuf = ut_params->op->sym->m_src;
1046 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1047 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1048 CIPHER_IV_LENGTH_AES_CBC,
1051 "Ciphertext data not as expected");
1053 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1054 "Digest verification failed");
1057 return TEST_SUCCESS;
1061 /* ***** AES-CBC / HMAC-SHA256 Hash Tests ***** */
1063 #define HMAC_KEY_LENGTH_SHA256 (DIGEST_BYTE_LENGTH_SHA256)
1065 static uint8_t hmac_sha256_key[] = {
1066 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1067 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1068 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1069 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60 };
1071 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA256_digest[] = {
1072 0xc8, 0x57, 0x57, 0x31, 0x03, 0xe0, 0x03, 0x55,
1073 0x07, 0xc8, 0x9e, 0x7f, 0x48, 0x9a, 0x61, 0x9a,
1074 0x68, 0xee, 0x03, 0x0e, 0x71, 0x75, 0xc7, 0xf4,
1075 0x2e, 0x45, 0x26, 0x32, 0x7c, 0x12, 0x15, 0x15 };
1078 test_AES_CBC_HMAC_SHA256_encrypt_digest(void)
1080 struct crypto_testsuite_params *ts_params = &testsuite_params;
1081 struct crypto_unittest_params *ut_params = &unittest_params;
1083 /* Generate test mbuf data and space for digest */
1084 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1085 catch_22_quote, QUOTE_512_BYTES, 0);
1087 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1088 DIGEST_BYTE_LENGTH_SHA256);
1089 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1091 /* Setup Cipher Parameters */
1092 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1093 ut_params->cipher_xform.next = &ut_params->auth_xform;
1095 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1096 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1097 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1098 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1100 /* Setup HMAC Parameters */
1101 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1102 ut_params->auth_xform.next = NULL;
1104 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1105 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
1106 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA256;
1107 ut_params->auth_xform.auth.key.data = hmac_sha256_key;
1108 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA256;
1110 /* Create Crypto session*/
1111 ut_params->sess = rte_cryptodev_sym_session_create(
1112 ts_params->valid_devs[0],
1113 &ut_params->cipher_xform);
1114 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1116 /* Generate Crypto op data structure */
1117 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1118 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1119 TEST_ASSERT_NOT_NULL(ut_params->op,
1120 "Failed to allocate symmetric crypto operation struct");
1122 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1124 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1126 /* set crypto operation source mbuf */
1127 sym_op->m_src = ut_params->ibuf;
1129 sym_op->auth.digest.data = ut_params->digest;
1130 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1131 ut_params->ibuf, QUOTE_512_BYTES);
1132 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA256;
1134 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1135 sym_op->auth.data.length = QUOTE_512_BYTES;
1137 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1138 CIPHER_IV_LENGTH_AES_CBC);
1139 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1140 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1142 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1143 CIPHER_IV_LENGTH_AES_CBC);
1145 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1146 sym_op->cipher.data.length = QUOTE_512_BYTES;
1148 /* Process crypto operation */
1149 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1150 ut_params->op), "failed to process sym crypto op");
1152 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1153 "crypto op processing failed");
1155 ut_params->obuf = ut_params->op->sym->m_src;
1158 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1159 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1160 CIPHER_IV_LENGTH_AES_CBC,
1161 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1163 "Ciphertext data not as expected");
1165 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1166 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1167 CIPHER_IV_LENGTH_AES_CBC + QUOTE_512_BYTES,
1168 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA256_digest,
1169 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1170 TRUNCATED_DIGEST_BYTE_LENGTH_SHA256 :
1171 DIGEST_BYTE_LENGTH_SHA256,
1172 "Generated digest data not as expected");
1175 return TEST_SUCCESS;
1179 test_AES_CBC_HMAC_SHA256_decrypt_digest_verify(void)
1181 struct crypto_testsuite_params *ts_params = &testsuite_params;
1182 struct crypto_unittest_params *ut_params = &unittest_params;
1184 /* Generate test mbuf data and digest */
1185 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1187 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1188 QUOTE_512_BYTES, 0);
1190 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1191 DIGEST_BYTE_LENGTH_SHA256);
1192 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1194 rte_memcpy(ut_params->digest,
1195 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA256_digest,
1196 DIGEST_BYTE_LENGTH_SHA256);
1198 /* Setup Cipher Parameters */
1199 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1200 ut_params->cipher_xform.next = NULL;
1202 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1203 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1204 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1205 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1207 /* Setup HMAC Parameters */
1208 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1209 ut_params->auth_xform.next = &ut_params->cipher_xform;
1211 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1212 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
1213 ut_params->auth_xform.auth.key.data = hmac_sha256_key;
1214 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA256;
1215 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA256;
1217 /* Create Crypto session*/
1219 rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
1220 &ut_params->auth_xform);
1221 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1223 /* Generate Crypto op data structure */
1224 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1225 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1226 TEST_ASSERT_NOT_NULL(ut_params->op,
1227 "Failed to allocate symmetric crypto operation struct");
1230 /* Set crypto operation data parameters */
1231 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1233 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1235 /* set crypto operation source mbuf */
1236 sym_op->m_src = ut_params->ibuf;
1238 sym_op->auth.digest.data = ut_params->digest;
1239 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1240 ut_params->ibuf, QUOTE_512_BYTES);
1241 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA256;
1243 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1244 sym_op->auth.data.length = QUOTE_512_BYTES;
1246 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1247 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1248 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1249 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1251 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1252 CIPHER_IV_LENGTH_AES_CBC);
1254 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1255 sym_op->cipher.data.length = QUOTE_512_BYTES;
1257 /* Process crypto operation */
1258 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1259 ut_params->op), "failed to process sym crypto op");
1261 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1262 "crypto op processing failed");
1264 ut_params->obuf = ut_params->op->sym->m_src;
1267 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1268 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1269 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1271 "Plaintext data not as expected");
1273 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1274 "Digest verification failed");
1276 return TEST_SUCCESS;
1279 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1281 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1283 static uint8_t hmac_sha512_key[] = {
1284 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1285 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1286 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1287 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1288 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1289 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1290 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1291 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1293 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1294 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1295 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1296 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1297 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1298 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1299 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1300 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1301 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1304 test_AES_CBC_HMAC_SHA512_encrypt_digest(void)
1306 struct crypto_testsuite_params *ts_params = &testsuite_params;
1307 struct crypto_unittest_params *ut_params = &unittest_params;
1309 /* Generate test mbuf data and space for digest */
1310 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1311 catch_22_quote, QUOTE_512_BYTES, 0);
1313 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1314 DIGEST_BYTE_LENGTH_SHA512);
1315 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1317 /* Setup Cipher Parameters */
1318 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1319 ut_params->cipher_xform.next = &ut_params->auth_xform;
1321 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1322 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1323 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1324 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1326 /* Setup HMAC Parameters */
1327 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1328 ut_params->auth_xform.next = NULL;
1330 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1331 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1332 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1333 ut_params->auth_xform.auth.key.data = hmac_sha512_key;
1334 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1336 /* Create Crypto session*/
1338 rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
1339 &ut_params->cipher_xform);
1341 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1343 /* Generate Crypto op data structure */
1344 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1345 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1346 TEST_ASSERT_NOT_NULL(ut_params->op,
1347 "Failed to allocate symmetric crypto operation struct");
1349 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1351 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1353 /* set crypto operation source mbuf */
1354 sym_op->m_src = ut_params->ibuf;
1356 sym_op->auth.digest.data = ut_params->digest;
1357 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1358 ut_params->ibuf, QUOTE_512_BYTES);
1359 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1361 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1362 sym_op->auth.data.length = QUOTE_512_BYTES;
1364 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1365 CIPHER_IV_LENGTH_AES_CBC);
1366 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1367 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1369 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1370 CIPHER_IV_LENGTH_AES_CBC);
1372 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1373 sym_op->cipher.data.length = QUOTE_512_BYTES;
1375 /* Process crypto operation */
1376 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1377 ut_params->op), "failed to process sym crypto op");
1379 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1380 "crypto op processing failed");
1382 ut_params->obuf = ut_params->op->sym->m_src;
1385 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1386 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1387 CIPHER_IV_LENGTH_AES_CBC,
1388 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1390 "Ciphertext data not as expected");
1392 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1393 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1394 CIPHER_IV_LENGTH_AES_CBC + QUOTE_512_BYTES,
1395 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
1396 gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1397 TRUNCATED_DIGEST_BYTE_LENGTH_SHA512 :
1398 DIGEST_BYTE_LENGTH_SHA512,
1399 "Generated digest data not as expected");
1401 return TEST_SUCCESS;
1406 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1407 struct crypto_unittest_params *ut_params);
1410 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1411 struct crypto_unittest_params *ut_params,
1412 struct crypto_testsuite_params *ts_params);
1415 test_AES_CBC_HMAC_SHA512_decrypt_digest_verify(void)
1417 struct crypto_unittest_params *ut_params = &unittest_params;
1418 struct crypto_testsuite_params *ts_params = &testsuite_params;
1420 TEST_ASSERT(test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1421 ut_params) == TEST_SUCCESS,
1422 "Failed to create session params");
1424 /* Create Crypto session*/
1426 rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
1427 &ut_params->auth_xform);
1428 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1430 return test_AES_CBC_HMAC_SHA512_decrypt_perform(ut_params->sess,
1431 ut_params, ts_params);
1435 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1436 struct crypto_unittest_params *ut_params)
1439 /* Setup Cipher Parameters */
1440 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1441 ut_params->cipher_xform.next = NULL;
1443 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1444 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1445 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1446 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1448 /* Setup HMAC Parameters */
1449 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1450 ut_params->auth_xform.next = &ut_params->cipher_xform;
1452 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1453 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1454 ut_params->auth_xform.auth.key.data = hmac_sha512_key;
1455 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1456 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1458 return TEST_SUCCESS;
1463 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1464 struct crypto_unittest_params *ut_params,
1465 struct crypto_testsuite_params *ts_params)
1467 /* Generate test mbuf data and digest */
1468 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1470 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1471 QUOTE_512_BYTES, 0);
1473 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1474 DIGEST_BYTE_LENGTH_SHA512);
1475 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1477 rte_memcpy(ut_params->digest,
1478 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
1479 DIGEST_BYTE_LENGTH_SHA512);
1481 /* Generate Crypto op data structure */
1482 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1483 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1484 TEST_ASSERT_NOT_NULL(ut_params->op,
1485 "Failed to allocate symmetric crypto operation struct");
1487 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1489 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1491 /* set crypto operation source mbuf */
1492 sym_op->m_src = ut_params->ibuf;
1494 sym_op->auth.digest.data = ut_params->digest;
1495 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1496 ut_params->ibuf, QUOTE_512_BYTES);
1497 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1499 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1500 sym_op->auth.data.length = QUOTE_512_BYTES;
1502 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1503 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1504 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1505 ut_params->ibuf, 0);
1506 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1508 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1509 CIPHER_IV_LENGTH_AES_CBC);
1511 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1512 sym_op->cipher.data.length = QUOTE_512_BYTES;
1514 /* Process crypto operation */
1515 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1516 ut_params->op), "failed to process sym crypto op");
1518 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1519 "crypto op processing failed");
1521 ut_params->obuf = ut_params->op->sym->m_src;
1524 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1525 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1526 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1528 "Plaintext data not as expected");
1531 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1532 "Digest verification failed");
1534 return TEST_SUCCESS;
1537 /* ***** AES-CBC / HMAC-AES_XCBC Chain Tests ***** */
1539 static uint8_t aes_cbc_hmac_aes_xcbc_key[] = {
1540 0x87, 0x61, 0x54, 0x53, 0xC4, 0x6D, 0xDD, 0x51,
1541 0xE1, 0x9F, 0x86, 0x64, 0x39, 0x0A, 0xE6, 0x59
1544 static const uint8_t catch_22_quote_2_512_bytes_HMAC_AES_XCBC_digest[] = {
1545 0xE0, 0xAC, 0x9A, 0xC4, 0x22, 0x64, 0x35, 0x89,
1546 0x77, 0x1D, 0x8B, 0x75
1550 test_AES_CBC_HMAC_AES_XCBC_encrypt_digest(void)
1552 struct crypto_testsuite_params *ts_params = &testsuite_params;
1553 struct crypto_unittest_params *ut_params = &unittest_params;
1555 /* Generate test mbuf data and space for digest */
1556 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1557 catch_22_quote, QUOTE_512_BYTES, 0);
1559 /* Setup Cipher Parameters */
1560 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1561 ut_params->cipher_xform.next = &ut_params->auth_xform;
1563 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1564 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1565 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1566 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1568 /* Setup HMAC Parameters */
1569 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1570 ut_params->auth_xform.next = NULL;
1572 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1573 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_XCBC_MAC;
1574 ut_params->auth_xform.auth.key.length = AES_XCBC_MAC_KEY_SZ;
1575 ut_params->auth_xform.auth.key.data = aes_cbc_hmac_aes_xcbc_key;
1576 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_AES_XCBC;
1578 /* Create Crypto session*/
1579 ut_params->sess = rte_cryptodev_sym_session_create(
1580 ts_params->valid_devs[0],
1581 &ut_params->cipher_xform);
1582 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1584 /* Generate Crypto op data structure */
1585 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1586 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1587 TEST_ASSERT_NOT_NULL(ut_params->op,
1588 "Failed to allocate symmetric crypto operation struct");
1590 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1592 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1594 /* set crypto operation source mbuf */
1595 sym_op->m_src = ut_params->ibuf;
1597 /* Set operation cipher parameters */
1598 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1599 sym_op->m_src, CIPHER_IV_LENGTH_AES_CBC);
1600 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(sym_op->m_src);
1601 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1603 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1604 CIPHER_IV_LENGTH_AES_CBC);
1606 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1607 sym_op->cipher.data.length = QUOTE_512_BYTES;
1609 /* Set operation authentication parameters */
1610 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1611 sym_op->m_src, DIGEST_BYTE_LENGTH_AES_XCBC);
1612 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1614 CIPHER_IV_LENGTH_AES_CBC + QUOTE_512_BYTES);
1615 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_AES_XCBC;
1617 memset(sym_op->auth.digest.data, 0, DIGEST_BYTE_LENGTH_AES_XCBC);
1619 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1620 sym_op->auth.data.length = QUOTE_512_BYTES;
1623 /* Process crypto operation */
1624 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1626 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to process sym crypto op");
1628 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1629 "crypto op processing failed");
1632 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1633 rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1634 uint8_t *, CIPHER_IV_LENGTH_AES_CBC),
1635 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1637 "Ciphertext data not as expected");
1639 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1640 rte_pktmbuf_mtod_offset(
1641 ut_params->op->sym->m_src, uint8_t *,
1642 CIPHER_IV_LENGTH_AES_CBC +
1644 catch_22_quote_2_512_bytes_HMAC_AES_XCBC_digest,
1645 DIGEST_BYTE_LENGTH_AES_XCBC,
1646 "Generated digest data not as expected");
1648 return TEST_SUCCESS;
1652 test_AES_CBC_HMAC_AES_XCBC_decrypt_digest_verify(void)
1654 struct crypto_testsuite_params *ts_params = &testsuite_params;
1655 struct crypto_unittest_params *ut_params = &unittest_params;
1657 /* Generate test mbuf data and space for digest */
1658 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1659 (const char *)catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1660 QUOTE_512_BYTES, 0);
1662 /* Setup Cipher Parameters */
1663 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1664 ut_params->cipher_xform.next = NULL;
1666 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1667 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1668 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1669 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1671 /* Setup HMAC Parameters */
1672 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1673 ut_params->auth_xform.next = &ut_params->cipher_xform;
1675 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1676 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_XCBC_MAC;
1677 ut_params->auth_xform.auth.key.length = AES_XCBC_MAC_KEY_SZ;
1678 ut_params->auth_xform.auth.key.data = aes_cbc_hmac_aes_xcbc_key;
1679 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_AES_XCBC;
1681 /* Create Crypto session*/
1683 rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
1684 &ut_params->auth_xform);
1685 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1687 /* Generate Crypto op data structure */
1688 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1689 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1690 TEST_ASSERT_NOT_NULL(ut_params->op,
1691 "Failed to allocate symmetric crypto operation struct");
1693 /* Set crypto operation data parameters */
1694 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1696 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1698 /* set crypto operation source mbuf */
1699 sym_op->m_src = ut_params->ibuf;
1702 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1703 ut_params->ibuf, DIGEST_BYTE_LENGTH_AES_XCBC);
1704 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1705 "no room to append digest");
1707 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1708 ut_params->ibuf, QUOTE_512_BYTES);
1709 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_AES_XCBC;
1711 rte_memcpy(sym_op->auth.digest.data,
1712 catch_22_quote_2_512_bytes_HMAC_AES_XCBC_digest,
1713 DIGEST_BYTE_LENGTH_AES_XCBC);
1715 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1716 sym_op->auth.data.length = QUOTE_512_BYTES;
1718 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1719 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1720 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1721 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1723 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1724 CIPHER_IV_LENGTH_AES_CBC);
1726 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1727 sym_op->cipher.data.length = QUOTE_512_BYTES;
1729 /* Process crypto operation */
1730 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1731 ut_params->op), "failed to process sym crypto op");
1733 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1734 "crypto op processing failed");
1736 ut_params->obuf = ut_params->op->sym->m_src;
1739 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1740 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1741 CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1743 "Ciphertext data not as expected");
1745 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1746 "Digest verification failed");
1748 return TEST_SUCCESS;
1752 /* ***** AES-GCM Tests ***** */
1757 struct crypto_testsuite_params *ts_params = &testsuite_params;
1758 struct rte_cryptodev_stats stats;
1759 struct rte_cryptodev *dev;
1760 cryptodev_stats_get_t temp_pfn;
1762 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1763 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
1764 &stats) == -ENODEV),
1765 "rte_cryptodev_stats_get invalid dev failed");
1766 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
1767 "rte_cryptodev_stats_get invalid Param failed");
1768 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
1769 temp_pfn = dev->dev_ops->stats_get;
1770 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
1771 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
1773 "rte_cryptodev_stats_get invalid Param failed");
1774 dev->dev_ops->stats_get = temp_pfn;
1776 /* Test expected values */
1778 test_AES_CBC_HMAC_SHA1_encrypt_digest();
1780 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
1782 "rte_cryptodev_stats_get failed");
1783 TEST_ASSERT((stats.enqueued_count == 1),
1784 "rte_cryptodev_stats_get returned unexpected enqueued stat");
1785 TEST_ASSERT((stats.dequeued_count == 1),
1786 "rte_cryptodev_stats_get returned unexpected enqueued stat");
1787 TEST_ASSERT((stats.enqueue_err_count == 0),
1788 "rte_cryptodev_stats_get returned unexpected enqueued stat");
1789 TEST_ASSERT((stats.dequeue_err_count == 0),
1790 "rte_cryptodev_stats_get returned unexpected enqueued stat");
1792 /* invalid device but should ignore and not reset device stats*/
1793 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
1794 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
1796 "rte_cryptodev_stats_get failed");
1797 TEST_ASSERT((stats.enqueued_count == 1),
1798 "rte_cryptodev_stats_get returned unexpected enqueued stat");
1800 /* check that a valid reset clears stats */
1801 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1802 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
1804 "rte_cryptodev_stats_get failed");
1805 TEST_ASSERT((stats.enqueued_count == 0),
1806 "rte_cryptodev_stats_get returned unexpected enqueued stat");
1807 TEST_ASSERT((stats.dequeued_count == 0),
1808 "rte_cryptodev_stats_get returned unexpected enqueued stat");
1810 return TEST_SUCCESS;
1815 test_multi_session(void)
1817 struct crypto_testsuite_params *ts_params = &testsuite_params;
1818 struct crypto_unittest_params *ut_params = &unittest_params;
1820 struct rte_cryptodev_info dev_info;
1821 struct rte_cryptodev_sym_session **sessions;
1825 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params);
1828 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1830 sessions = rte_malloc(NULL,
1831 (sizeof(struct rte_cryptodev_sym_session *) *
1832 dev_info.sym.max_nb_sessions) + 1, 0);
1834 /* Create multiple crypto sessions*/
1835 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
1836 sessions[i] = rte_cryptodev_sym_session_create(
1837 ts_params->valid_devs[0],
1838 &ut_params->auth_xform);
1839 TEST_ASSERT_NOT_NULL(sessions[i],
1840 "Session creation failed at session number %u",
1843 /* Attempt to send a request on each session */
1844 TEST_ASSERT_SUCCESS(test_AES_CBC_HMAC_SHA512_decrypt_perform(
1845 sessions[i], ut_params, ts_params),
1846 "Failed to perform decrypt on request "
1850 /* Next session create should fail */
1851 sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
1852 &ut_params->auth_xform);
1853 TEST_ASSERT_NULL(sessions[i],
1854 "Session creation succeeded unexpectedly!");
1856 for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
1857 rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1862 return TEST_SUCCESS;
1866 test_not_in_place_crypto(void)
1868 struct crypto_testsuite_params *ts_params = &testsuite_params;
1869 struct crypto_unittest_params *ut_params = &unittest_params;
1870 struct rte_mbuf *dst_m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
1872 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params);
1874 /* Create multiple crypto sessions*/
1876 ut_params->sess = rte_cryptodev_sym_session_create(
1877 ts_params->valid_devs[0], &ut_params->auth_xform);
1879 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1882 /* Generate test mbuf data and digest */
1883 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1885 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1886 QUOTE_512_BYTES, 0);
1888 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1889 DIGEST_BYTE_LENGTH_SHA512);
1890 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1892 rte_memcpy(ut_params->digest,
1893 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
1894 DIGEST_BYTE_LENGTH_SHA512);
1896 /* Generate Crypto op data structure */
1897 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1898 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1899 TEST_ASSERT_NOT_NULL(ut_params->op,
1900 "Failed to allocate symmetric crypto operation struct");
1903 /* Set crypto operation data parameters */
1904 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1906 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1908 /* set crypto operation source mbuf */
1909 sym_op->m_src = ut_params->ibuf;
1910 sym_op->m_dst = dst_m;
1912 sym_op->auth.digest.data = ut_params->digest;
1913 sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1914 ut_params->ibuf, QUOTE_512_BYTES);
1915 sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1917 sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1918 sym_op->auth.data.length = QUOTE_512_BYTES;
1921 sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1922 ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1923 sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1924 ut_params->ibuf, 0);
1925 sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1927 rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1928 CIPHER_IV_LENGTH_AES_CBC);
1930 sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1931 sym_op->cipher.data.length = QUOTE_512_BYTES;
1933 /* Process crypto operation */
1934 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
1936 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
1938 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1939 "crypto operation processing failed");
1942 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1943 rte_pktmbuf_mtod(ut_params->op->sym->m_dst, char *),
1946 "Plaintext data not as expected");
1950 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1951 "Digest verification failed");
1953 return TEST_SUCCESS;
1957 static struct unit_test_suite cryptodev_qat_testsuite = {
1958 .suite_name = "Crypto QAT Unit Test Suite",
1959 .setup = testsuite_setup,
1960 .teardown = testsuite_teardown,
1961 .unit_test_cases = {
1962 TEST_CASE_ST(ut_setup, ut_teardown,
1963 test_device_configure_invalid_dev_id),
1964 TEST_CASE_ST(ut_setup, ut_teardown,
1965 test_device_configure_invalid_queue_pair_ids),
1966 TEST_CASE_ST(ut_setup, ut_teardown,
1967 test_queue_pair_descriptor_setup),
1968 TEST_CASE_ST(ut_setup, ut_teardown,
1969 test_multi_session),
1971 TEST_CASE_ST(ut_setup, ut_teardown,
1972 test_AES_CBC_HMAC_SHA1_encrypt_digest),
1973 TEST_CASE_ST(ut_setup, ut_teardown,
1974 test_AES_CBC_HMAC_SHA1_decrypt_digest_verify),
1976 TEST_CASE_ST(ut_setup, ut_teardown,
1977 test_AES_CBC_HMAC_SHA256_encrypt_digest),
1978 TEST_CASE_ST(ut_setup, ut_teardown,
1979 test_AES_CBC_HMAC_SHA256_decrypt_digest_verify),
1981 TEST_CASE_ST(ut_setup, ut_teardown,
1982 test_AES_CBC_HMAC_SHA512_encrypt_digest),
1983 TEST_CASE_ST(ut_setup, ut_teardown,
1984 test_AES_CBC_HMAC_SHA512_decrypt_digest_verify),
1986 TEST_CASE_ST(ut_setup, ut_teardown,
1987 test_AES_CBC_HMAC_AES_XCBC_encrypt_digest),
1988 TEST_CASE_ST(ut_setup, ut_teardown,
1989 test_AES_CBC_HMAC_AES_XCBC_decrypt_digest_verify),
1991 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
1993 TEST_CASES_END() /**< NULL terminate unit test array */
1997 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
1998 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
1999 .setup = testsuite_setup,
2000 .teardown = testsuite_teardown,
2001 .unit_test_cases = {
2002 TEST_CASE_ST(ut_setup, ut_teardown,
2003 test_AES_CBC_HMAC_SHA1_encrypt_digest),
2004 TEST_CASE_ST(ut_setup, ut_teardown,
2005 test_AES_CBC_HMAC_SHA1_decrypt_digest_verify),
2007 TEST_CASE_ST(ut_setup, ut_teardown,
2008 test_AES_CBC_HMAC_SHA256_encrypt_digest),
2009 TEST_CASE_ST(ut_setup, ut_teardown,
2010 test_AES_CBC_HMAC_SHA256_decrypt_digest_verify),
2012 TEST_CASE_ST(ut_setup, ut_teardown,
2013 test_AES_CBC_HMAC_SHA512_encrypt_digest),
2014 TEST_CASE_ST(ut_setup, ut_teardown,
2015 test_AES_CBC_HMAC_SHA512_decrypt_digest_verify),
2017 TEST_CASE_ST(ut_setup, ut_teardown,
2018 test_AES_CBC_HMAC_AES_XCBC_encrypt_digest),
2019 TEST_CASE_ST(ut_setup, ut_teardown,
2020 test_AES_CBC_HMAC_AES_XCBC_decrypt_digest_verify),
2022 TEST_CASE_ST(ut_setup, ut_teardown,
2023 test_AES_CBC_HMAC_SHA1_encrypt_digest_sessionless),
2025 TEST_CASE_ST(ut_setup, ut_teardown,
2026 test_not_in_place_crypto),
2028 TEST_CASES_END() /**< NULL terminate unit test array */
2033 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
2035 gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
2036 return unit_test_suite_runner(&cryptodev_qat_testsuite);
2038 static struct test_command cryptodev_qat_cmd = {
2039 .command = "cryptodev_qat_autotest",
2040 .callback = test_cryptodev_qat,
2044 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
2046 gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
2048 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
2051 static struct test_command cryptodev_aesni_mb_cmd = {
2052 .command = "cryptodev_aesni_mb_autotest",
2053 .callback = test_cryptodev_aesni_mb,
2056 REGISTER_TEST_COMMAND(cryptodev_qat_cmd);
2057 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_cmd);