1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2015-2019 Intel Corporation 3 */ 4 5 #include <time.h> 6 7 #include <rte_common.h> 8 #include <rte_hexdump.h> 9 #include <rte_mbuf.h> 10 #include <rte_malloc.h> 11 #include <rte_memcpy.h> 12 #include <rte_pause.h> 13 #include <rte_bus_vdev.h> 14 15 #include <rte_crypto.h> 16 #include <rte_cryptodev.h> 17 #include <rte_cryptodev_pmd.h> 18 #include <rte_string_fns.h> 19 20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER 21 #include <rte_cryptodev_scheduler.h> 22 #include <rte_cryptodev_scheduler_operations.h> 23 #endif 24 25 #include <rte_lcore.h> 26 27 #include "test.h" 28 #include "test_cryptodev.h" 29 30 #include "test_cryptodev_blockcipher.h" 31 #include "test_cryptodev_aes_test_vectors.h" 32 #include "test_cryptodev_des_test_vectors.h" 33 #include "test_cryptodev_hash_test_vectors.h" 34 #include "test_cryptodev_kasumi_test_vectors.h" 35 #include "test_cryptodev_kasumi_hash_test_vectors.h" 36 #include "test_cryptodev_snow3g_test_vectors.h" 37 #include "test_cryptodev_snow3g_hash_test_vectors.h" 38 #include "test_cryptodev_zuc_test_vectors.h" 39 #include "test_cryptodev_aead_test_vectors.h" 40 #include "test_cryptodev_hmac_test_vectors.h" 41 #include "test_cryptodev_mixed_test_vectors.h" 42 #ifdef RTE_LIBRTE_SECURITY 43 #include "test_cryptodev_security_pdcp_test_vectors.h" 44 #include "test_cryptodev_security_pdcp_test_func.h" 45 #endif 46 47 #define VDEV_ARGS_SIZE 100 48 #define MAX_NB_SESSIONS 4 49 50 #define IN_PLACE 0 51 #define OUT_OF_PLACE 1 52 53 static int gbl_driver_id; 54 55 struct crypto_testsuite_params { 56 struct rte_mempool *mbuf_pool; 57 struct rte_mempool *large_mbuf_pool; 58 struct rte_mempool *op_mpool; 59 struct rte_mempool *session_mpool; 60 struct rte_mempool *session_priv_mpool; 61 struct rte_cryptodev_config conf; 62 struct rte_cryptodev_qp_conf qp_conf; 63 64 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS]; 65 uint8_t valid_dev_count; 66 }; 67 68 struct crypto_unittest_params { 69 struct rte_crypto_sym_xform cipher_xform; 70 struct rte_crypto_sym_xform auth_xform; 71 struct rte_crypto_sym_xform aead_xform; 72 73 union { 74 struct rte_cryptodev_sym_session *sess; 75 #ifdef RTE_LIBRTE_SECURITY 76 struct rte_security_session *sec_session; 77 #endif 78 }; 79 #ifdef RTE_LIBRTE_SECURITY 80 enum rte_security_session_action_type type; 81 #endif 82 struct rte_crypto_op *op; 83 84 struct rte_mbuf *obuf, *ibuf; 85 86 uint8_t *digest; 87 }; 88 89 #define ALIGN_POW2_ROUNDUP(num, align) \ 90 (((num) + (align) - 1) & ~((align) - 1)) 91 92 /* 93 * Forward declarations. 94 */ 95 static int 96 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( 97 struct crypto_unittest_params *ut_params, uint8_t *cipher_key, 98 uint8_t *hmac_key); 99 100 static int 101 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, 102 struct crypto_unittest_params *ut_params, 103 struct crypto_testsuite_params *ts_param, 104 const uint8_t *cipher, 105 const uint8_t *digest, 106 const uint8_t *iv); 107 108 static struct rte_mbuf * 109 setup_test_string(struct rte_mempool *mpool, 110 const char *string, size_t len, uint8_t blocksize) 111 { 112 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool); 113 size_t t_len = len - (blocksize ? (len % blocksize) : 0); 114 115 memset(m->buf_addr, 0, m->buf_len); 116 if (m) { 117 char *dst = rte_pktmbuf_append(m, t_len); 118 119 if (!dst) { 120 rte_pktmbuf_free(m); 121 return NULL; 122 } 123 if (string != NULL) 124 rte_memcpy(dst, string, t_len); 125 else 126 memset(dst, 0, t_len); 127 } 128 129 return m; 130 } 131 132 /* Get number of bytes in X bits (rounding up) */ 133 static uint32_t 134 ceil_byte_length(uint32_t num_bits) 135 { 136 if (num_bits % 8) 137 return ((num_bits >> 3) + 1); 138 else 139 return (num_bits >> 3); 140 } 141 142 static struct rte_crypto_op * 143 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op) 144 { 145 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) { 146 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n"); 147 return NULL; 148 } 149 150 op = NULL; 151 152 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0) 153 rte_pause(); 154 155 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) { 156 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status); 157 return NULL; 158 } 159 160 return op; 161 } 162 163 static struct crypto_testsuite_params testsuite_params = { NULL }; 164 static struct crypto_unittest_params unittest_params; 165 166 static int 167 testsuite_setup(void) 168 { 169 struct crypto_testsuite_params *ts_params = &testsuite_params; 170 struct rte_cryptodev_info info; 171 uint32_t i = 0, nb_devs, dev_id; 172 int ret; 173 uint16_t qp_id; 174 175 memset(ts_params, 0, sizeof(*ts_params)); 176 177 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL"); 178 if (ts_params->mbuf_pool == NULL) { 179 /* Not already created so create */ 180 ts_params->mbuf_pool = rte_pktmbuf_pool_create( 181 "CRYPTO_MBUFPOOL", 182 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE, 183 rte_socket_id()); 184 if (ts_params->mbuf_pool == NULL) { 185 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n"); 186 return TEST_FAILED; 187 } 188 } 189 190 ts_params->large_mbuf_pool = rte_mempool_lookup( 191 "CRYPTO_LARGE_MBUFPOOL"); 192 if (ts_params->large_mbuf_pool == NULL) { 193 /* Not already created so create */ 194 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create( 195 "CRYPTO_LARGE_MBUFPOOL", 196 1, 0, 0, UINT16_MAX, 197 rte_socket_id()); 198 if (ts_params->large_mbuf_pool == NULL) { 199 RTE_LOG(ERR, USER1, 200 "Can't create CRYPTO_LARGE_MBUFPOOL\n"); 201 return TEST_FAILED; 202 } 203 } 204 205 ts_params->op_mpool = rte_crypto_op_pool_create( 206 "MBUF_CRYPTO_SYM_OP_POOL", 207 RTE_CRYPTO_OP_TYPE_SYMMETRIC, 208 NUM_MBUFS, MBUF_CACHE_SIZE, 209 DEFAULT_NUM_XFORMS * 210 sizeof(struct rte_crypto_sym_xform) + 211 MAXIMUM_IV_LENGTH, 212 rte_socket_id()); 213 if (ts_params->op_mpool == NULL) { 214 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n"); 215 return TEST_FAILED; 216 } 217 218 /* Create an AESNI MB device if required */ 219 if (gbl_driver_id == rte_cryptodev_driver_id_get( 220 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) { 221 nb_devs = rte_cryptodev_device_count_by_driver( 222 rte_cryptodev_driver_id_get( 223 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))); 224 if (nb_devs < 1) { 225 ret = rte_vdev_init( 226 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL); 227 228 TEST_ASSERT(ret == 0, 229 "Failed to create instance of" 230 " pmd : %s", 231 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)); 232 } 233 } 234 235 /* Create an AESNI GCM device if required */ 236 if (gbl_driver_id == rte_cryptodev_driver_id_get( 237 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) { 238 nb_devs = rte_cryptodev_device_count_by_driver( 239 rte_cryptodev_driver_id_get( 240 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))); 241 if (nb_devs < 1) { 242 TEST_ASSERT_SUCCESS(rte_vdev_init( 243 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL), 244 "Failed to create instance of" 245 " pmd : %s", 246 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)); 247 } 248 } 249 250 /* Create a SNOW 3G device if required */ 251 if (gbl_driver_id == rte_cryptodev_driver_id_get( 252 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) { 253 nb_devs = rte_cryptodev_device_count_by_driver( 254 rte_cryptodev_driver_id_get( 255 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))); 256 if (nb_devs < 1) { 257 TEST_ASSERT_SUCCESS(rte_vdev_init( 258 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL), 259 "Failed to create instance of" 260 " pmd : %s", 261 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)); 262 } 263 } 264 265 /* Create a KASUMI device if required */ 266 if (gbl_driver_id == rte_cryptodev_driver_id_get( 267 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) { 268 nb_devs = rte_cryptodev_device_count_by_driver( 269 rte_cryptodev_driver_id_get( 270 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))); 271 if (nb_devs < 1) { 272 TEST_ASSERT_SUCCESS(rte_vdev_init( 273 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL), 274 "Failed to create instance of" 275 " pmd : %s", 276 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)); 277 } 278 } 279 280 /* Create a ZUC device if required */ 281 if (gbl_driver_id == rte_cryptodev_driver_id_get( 282 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) { 283 nb_devs = rte_cryptodev_device_count_by_driver( 284 rte_cryptodev_driver_id_get( 285 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))); 286 if (nb_devs < 1) { 287 TEST_ASSERT_SUCCESS(rte_vdev_init( 288 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL), 289 "Failed to create instance of" 290 " pmd : %s", 291 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)); 292 } 293 } 294 295 /* Create a NULL device if required */ 296 if (gbl_driver_id == rte_cryptodev_driver_id_get( 297 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) { 298 nb_devs = rte_cryptodev_device_count_by_driver( 299 rte_cryptodev_driver_id_get( 300 RTE_STR(CRYPTODEV_NAME_NULL_PMD))); 301 if (nb_devs < 1) { 302 ret = rte_vdev_init( 303 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL); 304 305 TEST_ASSERT(ret == 0, 306 "Failed to create instance of" 307 " pmd : %s", 308 RTE_STR(CRYPTODEV_NAME_NULL_PMD)); 309 } 310 } 311 312 /* Create an OPENSSL device if required */ 313 if (gbl_driver_id == rte_cryptodev_driver_id_get( 314 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) { 315 nb_devs = rte_cryptodev_device_count_by_driver( 316 rte_cryptodev_driver_id_get( 317 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))); 318 if (nb_devs < 1) { 319 ret = rte_vdev_init( 320 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), 321 NULL); 322 323 TEST_ASSERT(ret == 0, "Failed to create " 324 "instance of pmd : %s", 325 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)); 326 } 327 } 328 329 /* Create a ARMv8 device if required */ 330 if (gbl_driver_id == rte_cryptodev_driver_id_get( 331 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) { 332 nb_devs = rte_cryptodev_device_count_by_driver( 333 rte_cryptodev_driver_id_get( 334 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))); 335 if (nb_devs < 1) { 336 ret = rte_vdev_init( 337 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD), 338 NULL); 339 340 TEST_ASSERT(ret == 0, "Failed to create " 341 "instance of pmd : %s", 342 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)); 343 } 344 } 345 346 /* Create a MVSAM device if required */ 347 if (gbl_driver_id == rte_cryptodev_driver_id_get( 348 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) { 349 nb_devs = rte_cryptodev_device_count_by_driver( 350 rte_cryptodev_driver_id_get( 351 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))); 352 if (nb_devs < 1) { 353 ret = rte_vdev_init( 354 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD), 355 NULL); 356 357 TEST_ASSERT(ret == 0, "Failed to create " 358 "instance of pmd : %s", 359 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)); 360 } 361 } 362 363 /* Create an CCP device if required */ 364 if (gbl_driver_id == rte_cryptodev_driver_id_get( 365 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) { 366 nb_devs = rte_cryptodev_device_count_by_driver( 367 rte_cryptodev_driver_id_get( 368 RTE_STR(CRYPTODEV_NAME_CCP_PMD))); 369 if (nb_devs < 1) { 370 ret = rte_vdev_init( 371 RTE_STR(CRYPTODEV_NAME_CCP_PMD), 372 NULL); 373 374 TEST_ASSERT(ret == 0, "Failed to create " 375 "instance of pmd : %s", 376 RTE_STR(CRYPTODEV_NAME_CCP_PMD)); 377 } 378 } 379 380 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER 381 char vdev_args[VDEV_ARGS_SIZE] = {""}; 382 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core," 383 "ordering=enable,name=cryptodev_test_scheduler,corelist="}; 384 uint16_t slave_core_count = 0; 385 uint16_t socket_id = 0; 386 387 if (gbl_driver_id == rte_cryptodev_driver_id_get( 388 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) { 389 390 /* Identify the Slave Cores 391 * Use 2 slave cores for the device args 392 */ 393 RTE_LCORE_FOREACH_SLAVE(i) { 394 if (slave_core_count > 1) 395 break; 396 snprintf(vdev_args, sizeof(vdev_args), 397 "%s%d", temp_str, i); 398 strcpy(temp_str, vdev_args); 399 strlcat(temp_str, ";", sizeof(temp_str)); 400 slave_core_count++; 401 socket_id = rte_lcore_to_socket_id(i); 402 } 403 if (slave_core_count != 2) { 404 RTE_LOG(ERR, USER1, 405 "Cryptodev scheduler test require at least " 406 "two slave cores to run. " 407 "Please use the correct coremask.\n"); 408 return TEST_FAILED; 409 } 410 strcpy(temp_str, vdev_args); 411 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d", 412 temp_str, socket_id); 413 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args); 414 nb_devs = rte_cryptodev_device_count_by_driver( 415 rte_cryptodev_driver_id_get( 416 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))); 417 if (nb_devs < 1) { 418 ret = rte_vdev_init( 419 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD), 420 vdev_args); 421 TEST_ASSERT(ret == 0, 422 "Failed to create instance %u of" 423 " pmd : %s", 424 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)); 425 } 426 } 427 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */ 428 429 nb_devs = rte_cryptodev_count(); 430 if (nb_devs < 1) { 431 RTE_LOG(WARNING, USER1, "No crypto devices found?\n"); 432 return TEST_SKIPPED; 433 } 434 435 /* Create list of valid crypto devs */ 436 for (i = 0; i < nb_devs; i++) { 437 rte_cryptodev_info_get(i, &info); 438 if (info.driver_id == gbl_driver_id) 439 ts_params->valid_devs[ts_params->valid_dev_count++] = i; 440 } 441 442 if (ts_params->valid_dev_count < 1) 443 return TEST_FAILED; 444 445 /* Set up all the qps on the first of the valid devices found */ 446 447 dev_id = ts_params->valid_devs[0]; 448 449 rte_cryptodev_info_get(dev_id, &info); 450 451 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs; 452 ts_params->conf.socket_id = SOCKET_ID_ANY; 453 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY; 454 455 unsigned int session_size = 456 rte_cryptodev_sym_get_private_session_size(dev_id); 457 458 /* 459 * Create mempool with maximum number of sessions * 2, 460 * to include the session headers 461 */ 462 if (info.sym.max_nb_sessions != 0 && 463 info.sym.max_nb_sessions < MAX_NB_SESSIONS) { 464 RTE_LOG(ERR, USER1, "Device does not support " 465 "at least %u sessions\n", 466 MAX_NB_SESSIONS); 467 return TEST_FAILED; 468 } 469 470 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create( 471 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0, 472 SOCKET_ID_ANY); 473 TEST_ASSERT_NOT_NULL(ts_params->session_mpool, 474 "session mempool allocation failed"); 475 476 ts_params->session_priv_mpool = rte_mempool_create( 477 "test_sess_mp_priv", 478 MAX_NB_SESSIONS, 479 session_size, 480 0, 0, NULL, NULL, NULL, 481 NULL, SOCKET_ID_ANY, 482 0); 483 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool, 484 "session mempool allocation failed"); 485 486 487 488 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, 489 &ts_params->conf), 490 "Failed to configure cryptodev %u with %u qps", 491 dev_id, ts_params->conf.nb_queue_pairs); 492 493 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; 494 ts_params->qp_conf.mp_session = ts_params->session_mpool; 495 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool; 496 497 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) { 498 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( 499 dev_id, qp_id, &ts_params->qp_conf, 500 rte_cryptodev_socket_id(dev_id)), 501 "Failed to setup queue pair %u on cryptodev %u", 502 qp_id, dev_id); 503 } 504 505 return TEST_SUCCESS; 506 } 507 508 static void 509 testsuite_teardown(void) 510 { 511 struct crypto_testsuite_params *ts_params = &testsuite_params; 512 513 if (ts_params->mbuf_pool != NULL) { 514 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n", 515 rte_mempool_avail_count(ts_params->mbuf_pool)); 516 } 517 518 if (ts_params->op_mpool != NULL) { 519 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n", 520 rte_mempool_avail_count(ts_params->op_mpool)); 521 } 522 523 /* Free session mempools */ 524 if (ts_params->session_priv_mpool != NULL) { 525 rte_mempool_free(ts_params->session_priv_mpool); 526 ts_params->session_priv_mpool = NULL; 527 } 528 529 if (ts_params->session_mpool != NULL) { 530 rte_mempool_free(ts_params->session_mpool); 531 ts_params->session_mpool = NULL; 532 } 533 } 534 535 static int 536 ut_setup(void) 537 { 538 struct crypto_testsuite_params *ts_params = &testsuite_params; 539 struct crypto_unittest_params *ut_params = &unittest_params; 540 541 uint16_t qp_id; 542 543 /* Clear unit test parameters before running test */ 544 memset(ut_params, 0, sizeof(*ut_params)); 545 546 /* Reconfigure device to default parameters */ 547 ts_params->conf.socket_id = SOCKET_ID_ANY; 548 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY; 549 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; 550 ts_params->qp_conf.mp_session = ts_params->session_mpool; 551 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool; 552 553 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], 554 &ts_params->conf), 555 "Failed to configure cryptodev %u", 556 ts_params->valid_devs[0]); 557 558 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) { 559 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( 560 ts_params->valid_devs[0], qp_id, 561 &ts_params->qp_conf, 562 rte_cryptodev_socket_id(ts_params->valid_devs[0])), 563 "Failed to setup queue pair %u on cryptodev %u", 564 qp_id, ts_params->valid_devs[0]); 565 } 566 567 568 rte_cryptodev_stats_reset(ts_params->valid_devs[0]); 569 570 /* Start the device */ 571 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]), 572 "Failed to start cryptodev %u", 573 ts_params->valid_devs[0]); 574 575 return TEST_SUCCESS; 576 } 577 578 static void 579 ut_teardown(void) 580 { 581 struct crypto_testsuite_params *ts_params = &testsuite_params; 582 struct crypto_unittest_params *ut_params = &unittest_params; 583 struct rte_cryptodev_stats stats; 584 585 /* free crypto session structure */ 586 #ifdef RTE_LIBRTE_SECURITY 587 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) { 588 if (ut_params->sec_session) { 589 rte_security_session_destroy(rte_cryptodev_get_sec_ctx 590 (ts_params->valid_devs[0]), 591 ut_params->sec_session); 592 ut_params->sec_session = NULL; 593 } 594 } else 595 #endif 596 { 597 if (ut_params->sess) { 598 rte_cryptodev_sym_session_clear( 599 ts_params->valid_devs[0], 600 ut_params->sess); 601 rte_cryptodev_sym_session_free(ut_params->sess); 602 ut_params->sess = NULL; 603 } 604 } 605 606 /* free crypto operation structure */ 607 if (ut_params->op) 608 rte_crypto_op_free(ut_params->op); 609 610 /* 611 * free mbuf - both obuf and ibuf are usually the same, 612 * so check if they point at the same address is necessary, 613 * to avoid freeing the mbuf twice. 614 */ 615 if (ut_params->obuf) { 616 rte_pktmbuf_free(ut_params->obuf); 617 if (ut_params->ibuf == ut_params->obuf) 618 ut_params->ibuf = 0; 619 ut_params->obuf = 0; 620 } 621 if (ut_params->ibuf) { 622 rte_pktmbuf_free(ut_params->ibuf); 623 ut_params->ibuf = 0; 624 } 625 626 if (ts_params->mbuf_pool != NULL) 627 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n", 628 rte_mempool_avail_count(ts_params->mbuf_pool)); 629 630 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats); 631 632 /* Stop the device */ 633 rte_cryptodev_stop(ts_params->valid_devs[0]); 634 } 635 636 static int 637 test_device_configure_invalid_dev_id(void) 638 { 639 struct crypto_testsuite_params *ts_params = &testsuite_params; 640 uint16_t dev_id, num_devs = 0; 641 642 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1, 643 "Need at least %d devices for test", 1); 644 645 /* valid dev_id values */ 646 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1]; 647 648 /* Stop the device in case it's started so it can be configured */ 649 rte_cryptodev_stop(dev_id); 650 651 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf), 652 "Failed test for rte_cryptodev_configure: " 653 "invalid dev_num %u", dev_id); 654 655 /* invalid dev_id values */ 656 dev_id = num_devs; 657 658 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf), 659 "Failed test for rte_cryptodev_configure: " 660 "invalid dev_num %u", dev_id); 661 662 dev_id = 0xff; 663 664 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf), 665 "Failed test for rte_cryptodev_configure:" 666 "invalid dev_num %u", dev_id); 667 668 return TEST_SUCCESS; 669 } 670 671 static int 672 test_device_configure_invalid_queue_pair_ids(void) 673 { 674 struct crypto_testsuite_params *ts_params = &testsuite_params; 675 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs; 676 677 /* Stop the device in case it's started so it can be configured */ 678 rte_cryptodev_stop(ts_params->valid_devs[0]); 679 680 /* valid - one queue pairs */ 681 ts_params->conf.nb_queue_pairs = 1; 682 683 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], 684 &ts_params->conf), 685 "Failed to configure cryptodev: dev_id %u, qp_id %u", 686 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs); 687 688 689 /* valid - max value queue pairs */ 690 ts_params->conf.nb_queue_pairs = orig_nb_qps; 691 692 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], 693 &ts_params->conf), 694 "Failed to configure cryptodev: dev_id %u, qp_id %u", 695 ts_params->valid_devs[0], 696 ts_params->conf.nb_queue_pairs); 697 698 699 /* invalid - zero queue pairs */ 700 ts_params->conf.nb_queue_pairs = 0; 701 702 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0], 703 &ts_params->conf), 704 "Failed test for rte_cryptodev_configure, dev_id %u," 705 " invalid qps: %u", 706 ts_params->valid_devs[0], 707 ts_params->conf.nb_queue_pairs); 708 709 710 /* invalid - max value supported by field queue pairs */ 711 ts_params->conf.nb_queue_pairs = UINT16_MAX; 712 713 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0], 714 &ts_params->conf), 715 "Failed test for rte_cryptodev_configure, dev_id %u," 716 " invalid qps: %u", 717 ts_params->valid_devs[0], 718 ts_params->conf.nb_queue_pairs); 719 720 721 /* invalid - max value + 1 queue pairs */ 722 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1; 723 724 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0], 725 &ts_params->conf), 726 "Failed test for rte_cryptodev_configure, dev_id %u," 727 " invalid qps: %u", 728 ts_params->valid_devs[0], 729 ts_params->conf.nb_queue_pairs); 730 731 /* revert to original testsuite value */ 732 ts_params->conf.nb_queue_pairs = orig_nb_qps; 733 734 return TEST_SUCCESS; 735 } 736 737 static int 738 test_queue_pair_descriptor_setup(void) 739 { 740 struct crypto_testsuite_params *ts_params = &testsuite_params; 741 struct rte_cryptodev_info dev_info; 742 struct rte_cryptodev_qp_conf qp_conf = { 743 .nb_descriptors = MAX_NUM_OPS_INFLIGHT 744 }; 745 746 uint16_t qp_id; 747 748 /* Stop the device in case it's started so it can be configured */ 749 rte_cryptodev_stop(ts_params->valid_devs[0]); 750 751 752 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 753 754 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0], 755 &ts_params->conf), 756 "Failed to configure cryptodev %u", 757 ts_params->valid_devs[0]); 758 759 /* 760 * Test various ring sizes on this device. memzones can't be 761 * freed so are re-used if ring is released and re-created. 762 */ 763 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/ 764 qp_conf.mp_session = ts_params->session_mpool; 765 qp_conf.mp_session_private = ts_params->session_priv_mpool; 766 767 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) { 768 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( 769 ts_params->valid_devs[0], qp_id, &qp_conf, 770 rte_cryptodev_socket_id( 771 ts_params->valid_devs[0])), 772 "Failed test for " 773 "rte_cryptodev_queue_pair_setup: num_inflights " 774 "%u on qp %u on cryptodev %u", 775 qp_conf.nb_descriptors, qp_id, 776 ts_params->valid_devs[0]); 777 } 778 779 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2); 780 781 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) { 782 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( 783 ts_params->valid_devs[0], qp_id, &qp_conf, 784 rte_cryptodev_socket_id( 785 ts_params->valid_devs[0])), 786 "Failed test for" 787 " rte_cryptodev_queue_pair_setup: num_inflights" 788 " %u on qp %u on cryptodev %u", 789 qp_conf.nb_descriptors, qp_id, 790 ts_params->valid_devs[0]); 791 } 792 793 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */ 794 795 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) { 796 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( 797 ts_params->valid_devs[0], qp_id, &qp_conf, 798 rte_cryptodev_socket_id( 799 ts_params->valid_devs[0])), 800 "Failed test for " 801 "rte_cryptodev_queue_pair_setup: num_inflights" 802 " %u on qp %u on cryptodev %u", 803 qp_conf.nb_descriptors, qp_id, 804 ts_params->valid_devs[0]); 805 } 806 807 /* invalid number of descriptors - max supported + 2 */ 808 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2; 809 810 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) { 811 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( 812 ts_params->valid_devs[0], qp_id, &qp_conf, 813 rte_cryptodev_socket_id( 814 ts_params->valid_devs[0])), 815 "Unexpectedly passed test for " 816 "rte_cryptodev_queue_pair_setup:" 817 "num_inflights %u on qp %u on cryptodev %u", 818 qp_conf.nb_descriptors, qp_id, 819 ts_params->valid_devs[0]); 820 } 821 822 /* invalid number of descriptors - max value of parameter */ 823 qp_conf.nb_descriptors = UINT32_MAX-1; 824 825 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) { 826 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( 827 ts_params->valid_devs[0], qp_id, &qp_conf, 828 rte_cryptodev_socket_id( 829 ts_params->valid_devs[0])), 830 "Unexpectedly passed test for " 831 "rte_cryptodev_queue_pair_setup:" 832 "num_inflights %u on qp %u on cryptodev %u", 833 qp_conf.nb_descriptors, qp_id, 834 ts_params->valid_devs[0]); 835 } 836 837 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; 838 839 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) { 840 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup( 841 ts_params->valid_devs[0], qp_id, &qp_conf, 842 rte_cryptodev_socket_id( 843 ts_params->valid_devs[0])), 844 "Failed test for" 845 " rte_cryptodev_queue_pair_setup:" 846 "num_inflights %u on qp %u on cryptodev %u", 847 qp_conf.nb_descriptors, qp_id, 848 ts_params->valid_devs[0]); 849 } 850 851 /* invalid number of descriptors - max supported + 1 */ 852 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1; 853 854 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) { 855 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( 856 ts_params->valid_devs[0], qp_id, &qp_conf, 857 rte_cryptodev_socket_id( 858 ts_params->valid_devs[0])), 859 "Unexpectedly passed test for " 860 "rte_cryptodev_queue_pair_setup:" 861 "num_inflights %u on qp %u on cryptodev %u", 862 qp_conf.nb_descriptors, qp_id, 863 ts_params->valid_devs[0]); 864 } 865 866 /* test invalid queue pair id */ 867 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */ 868 869 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */ 870 871 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( 872 ts_params->valid_devs[0], 873 qp_id, &qp_conf, 874 rte_cryptodev_socket_id(ts_params->valid_devs[0])), 875 "Failed test for rte_cryptodev_queue_pair_setup:" 876 "invalid qp %u on cryptodev %u", 877 qp_id, ts_params->valid_devs[0]); 878 879 qp_id = 0xffff; /*invalid*/ 880 881 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup( 882 ts_params->valid_devs[0], 883 qp_id, &qp_conf, 884 rte_cryptodev_socket_id(ts_params->valid_devs[0])), 885 "Failed test for rte_cryptodev_queue_pair_setup:" 886 "invalid qp %u on cryptodev %u", 887 qp_id, ts_params->valid_devs[0]); 888 889 return TEST_SUCCESS; 890 } 891 892 /* ***** Plaintext data for tests ***** */ 893 894 const char catch_22_quote_1[] = 895 "There was only one catch and that was Catch-22, which " 896 "specified that a concern for one's safety in the face of " 897 "dangers that were real and immediate was the process of a " 898 "rational mind. Orr was crazy and could be grounded. All he " 899 "had to do was ask; and as soon as he did, he would no longer " 900 "be crazy and would have to fly more missions. Orr would be " 901 "crazy to fly more missions and sane if he didn't, but if he " 902 "was sane he had to fly them. If he flew them he was crazy " 903 "and didn't have to; but if he didn't want to he was sane and " 904 "had to. Yossarian was moved very deeply by the absolute " 905 "simplicity of this clause of Catch-22 and let out a " 906 "respectful whistle. \"That's some catch, that Catch-22\", he " 907 "observed. \"It's the best there is,\" Doc Daneeka agreed."; 908 909 const char catch_22_quote[] = 910 "What a lousy earth! He wondered how many people were " 911 "destitute that same night even in his own prosperous country, " 912 "how many homes were shanties, how many husbands were drunk " 913 "and wives socked, and how many children were bullied, abused, " 914 "or abandoned. How many families hungered for food they could " 915 "not afford to buy? How many hearts were broken? How many " 916 "suicides would take place that same night, how many people " 917 "would go insane? How many cockroaches and landlords would " 918 "triumph? How many winners were losers, successes failures, " 919 "and rich men poor men? How many wise guys were stupid? How " 920 "many happy endings were unhappy endings? How many honest men " 921 "were liars, brave men cowards, loyal men traitors, how many " 922 "sainted men were corrupt, how many people in positions of " 923 "trust had sold their souls to bodyguards, how many had never " 924 "had souls? How many straight-and-narrow paths were crooked " 925 "paths? How many best families were worst families and how " 926 "many good people were bad people? When you added them all up " 927 "and then subtracted, you might be left with only the children, " 928 "and perhaps with Albert Einstein and an old violinist or " 929 "sculptor somewhere."; 930 931 #define QUOTE_480_BYTES (480) 932 #define QUOTE_512_BYTES (512) 933 #define QUOTE_768_BYTES (768) 934 #define QUOTE_1024_BYTES (1024) 935 936 937 938 /* ***** SHA1 Hash Tests ***** */ 939 940 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1) 941 942 static uint8_t hmac_sha1_key[] = { 943 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 944 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 945 0xDE, 0xF4, 0xDE, 0xAD }; 946 947 /* ***** SHA224 Hash Tests ***** */ 948 949 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224) 950 951 952 /* ***** AES-CBC Cipher Tests ***** */ 953 954 #define CIPHER_KEY_LENGTH_AES_CBC (16) 955 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC) 956 957 static uint8_t aes_cbc_key[] = { 958 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2, 959 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A }; 960 961 static uint8_t aes_cbc_iv[] = { 962 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 963 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; 964 965 966 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */ 967 968 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = { 969 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31, 970 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76, 971 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E, 972 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A, 973 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E, 974 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08, 975 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0, 976 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01, 977 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57, 978 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE, 979 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9, 980 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9, 981 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D, 982 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3, 983 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46, 984 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3, 985 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80, 986 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92, 987 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5, 988 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5, 989 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2, 990 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5, 991 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA, 992 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76, 993 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4, 994 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62, 995 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4, 996 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4, 997 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54, 998 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61, 999 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91, 1000 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A, 1001 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF, 1002 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F, 1003 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28, 1004 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E, 1005 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7, 1006 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76, 1007 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6, 1008 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03, 1009 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C, 1010 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2, 1011 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6, 1012 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96, 1013 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6, 1014 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA, 1015 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87, 1016 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55, 1017 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B, 1018 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98, 1019 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53, 1020 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A, 1021 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26, 1022 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36, 1023 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36, 1024 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D, 1025 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E, 1026 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E, 1027 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A, 1028 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6, 1029 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4, 1030 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7, 1031 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1, 1032 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C 1033 }; 1034 1035 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = { 1036 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60, 1037 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1, 1038 0x18, 0x8c, 0x1d, 0x32 1039 }; 1040 1041 1042 /* Multisession Vector context Test */ 1043 /*Begin Session 0 */ 1044 static uint8_t ms_aes_cbc_key0[] = { 1045 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 1046 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 1047 }; 1048 1049 static uint8_t ms_aes_cbc_iv0[] = { 1050 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 1051 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 1052 }; 1053 1054 static const uint8_t ms_aes_cbc_cipher0[] = { 1055 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38, 1056 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC, 1057 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB, 1058 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9, 1059 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D, 1060 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4, 1061 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34, 1062 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F, 1063 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99, 1064 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED, 1065 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D, 1066 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24, 1067 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71, 1068 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72, 1069 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E, 1070 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD, 1071 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18, 1072 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6, 1073 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29, 1074 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C, 1075 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96, 1076 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26, 1077 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55, 1078 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46, 1079 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B, 1080 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4, 1081 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7, 1082 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5, 1083 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0, 1084 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E, 1085 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D, 1086 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44, 1087 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76, 1088 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3, 1089 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83, 1090 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85, 1091 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45, 1092 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25, 1093 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A, 1094 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1, 1095 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA, 1096 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3, 1097 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4, 1098 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60, 1099 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A, 1100 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A, 1101 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9, 1102 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55, 1103 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13, 1104 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B, 1105 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1, 1106 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0, 1107 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3, 1108 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23, 1109 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B, 1110 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07, 1111 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB, 1112 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1, 1113 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F, 1114 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F, 1115 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84, 1116 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B, 1117 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17, 1118 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF 1119 }; 1120 1121 1122 static uint8_t ms_hmac_key0[] = { 1123 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1, 1124 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA, 1125 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76, 1126 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60, 1127 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1, 1128 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0, 1129 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76, 1130 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60 1131 }; 1132 1133 static const uint8_t ms_hmac_digest0[] = { 1134 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51, 1135 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F, 1136 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C, 1137 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4, 1138 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56, 1139 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4, 1140 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23, 1141 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90 1142 }; 1143 1144 /* End Session 0 */ 1145 /* Begin session 1 */ 1146 1147 static uint8_t ms_aes_cbc_key1[] = { 1148 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 1149 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 1150 }; 1151 1152 static uint8_t ms_aes_cbc_iv1[] = { 1153 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 1154 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 1155 }; 1156 1157 static const uint8_t ms_aes_cbc_cipher1[] = { 1158 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71, 1159 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23, 1160 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09, 1161 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A, 1162 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C, 1163 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F, 1164 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9, 1165 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66, 1166 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43, 1167 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB, 1168 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23, 1169 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29, 1170 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26, 1171 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F, 1172 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68, 1173 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77, 1174 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8, 1175 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97, 1176 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3, 1177 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90, 1178 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5, 1179 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E, 1180 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45, 1181 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B, 1182 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5, 1183 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D, 1184 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E, 1185 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD, 1186 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE, 1187 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1, 1188 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F, 1189 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25, 1190 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1, 1191 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3, 1192 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE, 1193 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6, 1194 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52, 1195 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA, 1196 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63, 1197 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E, 1198 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA, 1199 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB, 1200 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71, 1201 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF, 1202 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A, 1203 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95, 1204 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73, 1205 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49, 1206 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB, 1207 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B, 1208 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC, 1209 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED, 1210 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02, 1211 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4, 1212 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF, 1213 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82, 1214 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D, 1215 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6, 1216 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9, 1217 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35, 1218 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0, 1219 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53, 1220 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5, 1221 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3 1222 1223 }; 1224 1225 static uint8_t ms_hmac_key1[] = { 1226 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1, 1227 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA, 1228 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76, 1229 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60, 1230 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1, 1231 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0, 1232 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76, 1233 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60 1234 }; 1235 1236 static const uint8_t ms_hmac_digest1[] = { 1237 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69, 1238 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50, 1239 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20, 1240 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD, 1241 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9, 1242 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4, 1243 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA, 1244 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F 1245 }; 1246 /* End Session 1 */ 1247 /* Begin Session 2 */ 1248 static uint8_t ms_aes_cbc_key2[] = { 1249 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 1250 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 1251 }; 1252 1253 static uint8_t ms_aes_cbc_iv2[] = { 1254 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 1255 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 1256 }; 1257 1258 static const uint8_t ms_aes_cbc_cipher2[] = { 1259 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91, 1260 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97, 1261 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8, 1262 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5, 1263 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98, 1264 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69, 1265 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09, 1266 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF, 1267 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44, 1268 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B, 1269 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9, 1270 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34, 1271 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99, 1272 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF, 1273 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC, 1274 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26, 1275 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3, 1276 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF, 1277 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3, 1278 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3, 1279 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA, 1280 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13, 1281 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38, 1282 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71, 1283 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC, 1284 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1, 1285 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E, 1286 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22, 1287 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62, 1288 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72, 1289 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6, 1290 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6, 1291 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44, 1292 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24, 1293 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5, 1294 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E, 1295 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17, 1296 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9, 1297 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D, 1298 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D, 1299 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22, 1300 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9, 1301 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49, 1302 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E, 1303 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B, 1304 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2, 1305 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95, 1306 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07, 1307 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3, 1308 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A, 1309 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57, 1310 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84, 1311 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61, 1312 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF, 1313 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17, 1314 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A, 1315 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1, 1316 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53, 1317 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7, 1318 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2, 1319 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A, 1320 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8, 1321 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70, 1322 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92 1323 }; 1324 1325 static uint8_t ms_hmac_key2[] = { 1326 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1, 1327 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA, 1328 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76, 1329 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60, 1330 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1, 1331 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0, 1332 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76, 1333 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60 1334 }; 1335 1336 static const uint8_t ms_hmac_digest2[] = { 1337 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF, 1338 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6, 1339 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77, 1340 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27, 1341 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82, 1342 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24, 1343 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E, 1344 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59 1345 }; 1346 1347 /* End Session 2 */ 1348 1349 1350 static int 1351 test_AES_CBC_HMAC_SHA1_encrypt_digest(void) 1352 { 1353 struct crypto_testsuite_params *ts_params = &testsuite_params; 1354 struct crypto_unittest_params *ut_params = &unittest_params; 1355 1356 /* Generate test mbuf data and space for digest */ 1357 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, 1358 catch_22_quote, QUOTE_512_BYTES, 0); 1359 1360 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 1361 DIGEST_BYTE_LENGTH_SHA1); 1362 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest"); 1363 1364 /* Setup Cipher Parameters */ 1365 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 1366 ut_params->cipher_xform.next = &ut_params->auth_xform; 1367 1368 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC; 1369 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; 1370 ut_params->cipher_xform.cipher.key.data = aes_cbc_key; 1371 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC; 1372 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 1373 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC; 1374 1375 /* Setup HMAC Parameters */ 1376 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 1377 1378 ut_params->auth_xform.next = NULL; 1379 1380 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; 1381 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC; 1382 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1; 1383 ut_params->auth_xform.auth.key.data = hmac_sha1_key; 1384 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1; 1385 1386 ut_params->sess = rte_cryptodev_sym_session_create( 1387 ts_params->session_mpool); 1388 1389 /* Create crypto session*/ 1390 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 1391 ut_params->sess, &ut_params->cipher_xform, 1392 ts_params->session_priv_mpool); 1393 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 1394 1395 /* Generate crypto op data structure */ 1396 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 1397 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 1398 TEST_ASSERT_NOT_NULL(ut_params->op, 1399 "Failed to allocate symmetric crypto operation struct"); 1400 1401 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 1402 1403 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 1404 1405 /* set crypto operation source mbuf */ 1406 sym_op->m_src = ut_params->ibuf; 1407 1408 /* Set crypto operation authentication parameters */ 1409 sym_op->auth.digest.data = ut_params->digest; 1410 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 1411 ut_params->ibuf, QUOTE_512_BYTES); 1412 1413 sym_op->auth.data.offset = 0; 1414 sym_op->auth.data.length = QUOTE_512_BYTES; 1415 1416 /* Copy IV at the end of the crypto operation */ 1417 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), 1418 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC); 1419 1420 /* Set crypto operation cipher parameters */ 1421 sym_op->cipher.data.offset = 0; 1422 sym_op->cipher.data.length = QUOTE_512_BYTES; 1423 1424 /* Process crypto operation */ 1425 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 1426 ut_params->op), "failed to process sym crypto op"); 1427 1428 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 1429 "crypto op processing failed"); 1430 1431 /* Validate obuf */ 1432 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src, 1433 uint8_t *); 1434 1435 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext, 1436 catch_22_quote_2_512_bytes_AES_CBC_ciphertext, 1437 QUOTE_512_BYTES, 1438 "ciphertext data not as expected"); 1439 1440 uint8_t *digest = ciphertext + QUOTE_512_BYTES; 1441 1442 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest, 1443 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest, 1444 gbl_driver_id == rte_cryptodev_driver_id_get( 1445 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ? 1446 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 : 1447 DIGEST_BYTE_LENGTH_SHA1, 1448 "Generated digest data not as expected"); 1449 1450 return TEST_SUCCESS; 1451 } 1452 1453 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */ 1454 1455 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512) 1456 1457 static uint8_t hmac_sha512_key[] = { 1458 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1, 1459 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA, 1460 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76, 1461 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60, 1462 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1, 1463 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0, 1464 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76, 1465 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 }; 1466 1467 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = { 1468 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8, 1469 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48, 1470 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8, 1471 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70, 1472 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8, 1473 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E, 1474 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D, 1475 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A }; 1476 1477 1478 1479 static int 1480 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( 1481 struct crypto_unittest_params *ut_params, 1482 uint8_t *cipher_key, 1483 uint8_t *hmac_key); 1484 1485 static int 1486 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, 1487 struct crypto_unittest_params *ut_params, 1488 struct crypto_testsuite_params *ts_params, 1489 const uint8_t *cipher, 1490 const uint8_t *digest, 1491 const uint8_t *iv); 1492 1493 1494 static int 1495 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( 1496 struct crypto_unittest_params *ut_params, 1497 uint8_t *cipher_key, 1498 uint8_t *hmac_key) 1499 { 1500 1501 /* Setup Cipher Parameters */ 1502 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 1503 ut_params->cipher_xform.next = NULL; 1504 1505 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC; 1506 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT; 1507 ut_params->cipher_xform.cipher.key.data = cipher_key; 1508 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC; 1509 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 1510 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC; 1511 1512 /* Setup HMAC Parameters */ 1513 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 1514 ut_params->auth_xform.next = &ut_params->cipher_xform; 1515 1516 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY; 1517 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC; 1518 ut_params->auth_xform.auth.key.data = hmac_key; 1519 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512; 1520 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512; 1521 1522 return TEST_SUCCESS; 1523 } 1524 1525 1526 static int 1527 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess, 1528 struct crypto_unittest_params *ut_params, 1529 struct crypto_testsuite_params *ts_params, 1530 const uint8_t *cipher, 1531 const uint8_t *digest, 1532 const uint8_t *iv) 1533 { 1534 /* Generate test mbuf data and digest */ 1535 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, 1536 (const char *) 1537 cipher, 1538 QUOTE_512_BYTES, 0); 1539 1540 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 1541 DIGEST_BYTE_LENGTH_SHA512); 1542 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest"); 1543 1544 rte_memcpy(ut_params->digest, 1545 digest, 1546 DIGEST_BYTE_LENGTH_SHA512); 1547 1548 /* Generate Crypto op data structure */ 1549 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 1550 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 1551 TEST_ASSERT_NOT_NULL(ut_params->op, 1552 "Failed to allocate symmetric crypto operation struct"); 1553 1554 rte_crypto_op_attach_sym_session(ut_params->op, sess); 1555 1556 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 1557 1558 /* set crypto operation source mbuf */ 1559 sym_op->m_src = ut_params->ibuf; 1560 1561 sym_op->auth.digest.data = ut_params->digest; 1562 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 1563 ut_params->ibuf, QUOTE_512_BYTES); 1564 1565 sym_op->auth.data.offset = 0; 1566 sym_op->auth.data.length = QUOTE_512_BYTES; 1567 1568 /* Copy IV at the end of the crypto operation */ 1569 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), 1570 iv, CIPHER_IV_LENGTH_AES_CBC); 1571 1572 sym_op->cipher.data.offset = 0; 1573 sym_op->cipher.data.length = QUOTE_512_BYTES; 1574 1575 /* Process crypto operation */ 1576 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 1577 ut_params->op), "failed to process sym crypto op"); 1578 1579 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 1580 "crypto op processing failed"); 1581 1582 ut_params->obuf = ut_params->op->sym->m_src; 1583 1584 /* Validate obuf */ 1585 TEST_ASSERT_BUFFERS_ARE_EQUAL( 1586 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 1587 catch_22_quote, 1588 QUOTE_512_BYTES, 1589 "Plaintext data not as expected"); 1590 1591 /* Validate obuf */ 1592 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 1593 "Digest verification failed"); 1594 1595 return TEST_SUCCESS; 1596 } 1597 1598 static int 1599 test_AES_cipheronly_mb_all(void) 1600 { 1601 struct crypto_testsuite_params *ts_params = &testsuite_params; 1602 int status; 1603 1604 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1605 ts_params->op_mpool, 1606 ts_params->session_mpool, ts_params->session_priv_mpool, 1607 ts_params->valid_devs[0], 1608 rte_cryptodev_driver_id_get( 1609 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), 1610 BLKCIPHER_AES_CIPHERONLY_TYPE); 1611 1612 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1613 1614 return TEST_SUCCESS; 1615 } 1616 1617 static int 1618 test_AES_docsis_mb_all(void) 1619 { 1620 struct crypto_testsuite_params *ts_params = &testsuite_params; 1621 int status; 1622 1623 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1624 ts_params->op_mpool, 1625 ts_params->session_mpool, ts_params->session_priv_mpool, 1626 ts_params->valid_devs[0], 1627 rte_cryptodev_driver_id_get( 1628 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), 1629 BLKCIPHER_AES_DOCSIS_TYPE); 1630 1631 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1632 1633 return TEST_SUCCESS; 1634 } 1635 1636 static int 1637 test_AES_docsis_qat_all(void) 1638 { 1639 struct crypto_testsuite_params *ts_params = &testsuite_params; 1640 int status; 1641 1642 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1643 ts_params->op_mpool, 1644 ts_params->session_mpool, ts_params->session_priv_mpool, 1645 ts_params->valid_devs[0], 1646 rte_cryptodev_driver_id_get( 1647 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), 1648 BLKCIPHER_AES_DOCSIS_TYPE); 1649 1650 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1651 1652 return TEST_SUCCESS; 1653 } 1654 1655 static int 1656 test_DES_docsis_qat_all(void) 1657 { 1658 struct crypto_testsuite_params *ts_params = &testsuite_params; 1659 int status; 1660 1661 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1662 ts_params->op_mpool, 1663 ts_params->session_mpool, ts_params->session_priv_mpool, 1664 ts_params->valid_devs[0], 1665 rte_cryptodev_driver_id_get( 1666 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), 1667 BLKCIPHER_DES_DOCSIS_TYPE); 1668 1669 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1670 1671 return TEST_SUCCESS; 1672 } 1673 1674 static int 1675 test_authonly_mb_all(void) 1676 { 1677 struct crypto_testsuite_params *ts_params = &testsuite_params; 1678 int status; 1679 1680 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1681 ts_params->op_mpool, 1682 ts_params->session_mpool, ts_params->session_priv_mpool, 1683 ts_params->valid_devs[0], 1684 rte_cryptodev_driver_id_get( 1685 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), 1686 BLKCIPHER_AUTHONLY_TYPE); 1687 1688 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1689 1690 return TEST_SUCCESS; 1691 } 1692 1693 static int 1694 test_authonly_qat_all(void) 1695 { 1696 struct crypto_testsuite_params *ts_params = &testsuite_params; 1697 int status; 1698 1699 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1700 ts_params->op_mpool, 1701 ts_params->session_mpool, ts_params->session_priv_mpool, 1702 ts_params->valid_devs[0], 1703 rte_cryptodev_driver_id_get( 1704 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), 1705 BLKCIPHER_AUTHONLY_TYPE); 1706 1707 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1708 1709 return TEST_SUCCESS; 1710 } 1711 1712 static int 1713 test_AES_chain_null_all(void) 1714 { 1715 struct crypto_testsuite_params *ts_params = &testsuite_params; 1716 int status; 1717 1718 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1719 ts_params->op_mpool, 1720 ts_params->session_mpool, ts_params->session_priv_mpool, 1721 ts_params->valid_devs[0], 1722 rte_cryptodev_driver_id_get( 1723 RTE_STR(CRYPTODEV_NAME_NULL_PMD)), 1724 BLKCIPHER_AES_CHAIN_TYPE); 1725 1726 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1727 1728 return TEST_SUCCESS; 1729 } 1730 1731 static int 1732 test_AES_cipheronly_null_all(void) 1733 { 1734 struct crypto_testsuite_params *ts_params = &testsuite_params; 1735 int status; 1736 1737 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1738 ts_params->op_mpool, 1739 ts_params->session_mpool, ts_params->session_priv_mpool, 1740 ts_params->valid_devs[0], 1741 rte_cryptodev_driver_id_get( 1742 RTE_STR(CRYPTODEV_NAME_NULL_PMD)), 1743 BLKCIPHER_AES_CIPHERONLY_TYPE); 1744 1745 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1746 1747 return TEST_SUCCESS; 1748 } 1749 1750 static int 1751 test_authonly_null_all(void) 1752 { 1753 struct crypto_testsuite_params *ts_params = &testsuite_params; 1754 int status; 1755 1756 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1757 ts_params->op_mpool, 1758 ts_params->session_mpool, ts_params->session_priv_mpool, 1759 ts_params->valid_devs[0], 1760 rte_cryptodev_driver_id_get( 1761 RTE_STR(CRYPTODEV_NAME_NULL_PMD)), 1762 BLKCIPHER_AUTHONLY_TYPE); 1763 1764 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1765 1766 return TEST_SUCCESS; 1767 } 1768 1769 static int 1770 test_AES_chain_mb_all(void) 1771 { 1772 struct crypto_testsuite_params *ts_params = &testsuite_params; 1773 int status; 1774 1775 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1776 ts_params->op_mpool, 1777 ts_params->session_mpool, ts_params->session_priv_mpool, 1778 ts_params->valid_devs[0], 1779 rte_cryptodev_driver_id_get( 1780 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), 1781 BLKCIPHER_AES_CHAIN_TYPE); 1782 1783 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1784 1785 return TEST_SUCCESS; 1786 } 1787 1788 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER 1789 1790 static int 1791 test_AES_cipheronly_scheduler_all(void) 1792 { 1793 struct crypto_testsuite_params *ts_params = &testsuite_params; 1794 int status; 1795 1796 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1797 ts_params->op_mpool, 1798 ts_params->session_mpool, ts_params->session_priv_mpool, 1799 ts_params->valid_devs[0], 1800 rte_cryptodev_driver_id_get( 1801 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)), 1802 BLKCIPHER_AES_CIPHERONLY_TYPE); 1803 1804 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1805 1806 return TEST_SUCCESS; 1807 } 1808 1809 static int 1810 test_AES_chain_scheduler_all(void) 1811 { 1812 struct crypto_testsuite_params *ts_params = &testsuite_params; 1813 int status; 1814 1815 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1816 ts_params->op_mpool, 1817 ts_params->session_mpool, ts_params->session_priv_mpool, 1818 ts_params->valid_devs[0], 1819 rte_cryptodev_driver_id_get( 1820 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)), 1821 BLKCIPHER_AES_CHAIN_TYPE); 1822 1823 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1824 1825 return TEST_SUCCESS; 1826 } 1827 1828 static int 1829 test_authonly_scheduler_all(void) 1830 { 1831 struct crypto_testsuite_params *ts_params = &testsuite_params; 1832 int status; 1833 1834 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1835 ts_params->op_mpool, 1836 ts_params->session_mpool, ts_params->session_priv_mpool, 1837 ts_params->valid_devs[0], 1838 rte_cryptodev_driver_id_get( 1839 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)), 1840 BLKCIPHER_AUTHONLY_TYPE); 1841 1842 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1843 1844 return TEST_SUCCESS; 1845 } 1846 1847 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */ 1848 1849 static int 1850 test_AES_chain_openssl_all(void) 1851 { 1852 struct crypto_testsuite_params *ts_params = &testsuite_params; 1853 int status; 1854 1855 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1856 ts_params->op_mpool, 1857 ts_params->session_mpool, ts_params->session_priv_mpool, 1858 ts_params->valid_devs[0], 1859 rte_cryptodev_driver_id_get( 1860 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)), 1861 BLKCIPHER_AES_CHAIN_TYPE); 1862 1863 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1864 1865 return TEST_SUCCESS; 1866 } 1867 1868 static int 1869 test_AES_cipheronly_openssl_all(void) 1870 { 1871 struct crypto_testsuite_params *ts_params = &testsuite_params; 1872 int status; 1873 1874 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1875 ts_params->op_mpool, 1876 ts_params->session_mpool, ts_params->session_priv_mpool, 1877 ts_params->valid_devs[0], 1878 rte_cryptodev_driver_id_get( 1879 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)), 1880 BLKCIPHER_AES_CIPHERONLY_TYPE); 1881 1882 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1883 1884 return TEST_SUCCESS; 1885 } 1886 1887 static int 1888 test_AES_chain_ccp_all(void) 1889 { 1890 struct crypto_testsuite_params *ts_params = &testsuite_params; 1891 int status; 1892 1893 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1894 ts_params->op_mpool, 1895 ts_params->session_mpool, ts_params->session_priv_mpool, 1896 ts_params->valid_devs[0], 1897 rte_cryptodev_driver_id_get( 1898 RTE_STR(CRYPTODEV_NAME_CCP_PMD)), 1899 BLKCIPHER_AES_CHAIN_TYPE); 1900 1901 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1902 1903 return TEST_SUCCESS; 1904 } 1905 1906 static int 1907 test_AES_cipheronly_ccp_all(void) 1908 { 1909 struct crypto_testsuite_params *ts_params = &testsuite_params; 1910 int status; 1911 1912 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1913 ts_params->op_mpool, 1914 ts_params->session_mpool, ts_params->session_priv_mpool, 1915 ts_params->valid_devs[0], 1916 rte_cryptodev_driver_id_get( 1917 RTE_STR(CRYPTODEV_NAME_CCP_PMD)), 1918 BLKCIPHER_AES_CIPHERONLY_TYPE); 1919 1920 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1921 1922 return TEST_SUCCESS; 1923 } 1924 1925 static int 1926 test_AES_chain_qat_all(void) 1927 { 1928 struct crypto_testsuite_params *ts_params = &testsuite_params; 1929 int status; 1930 1931 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1932 ts_params->op_mpool, 1933 ts_params->session_mpool, ts_params->session_priv_mpool, 1934 ts_params->valid_devs[0], 1935 rte_cryptodev_driver_id_get( 1936 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), 1937 BLKCIPHER_AES_CHAIN_TYPE); 1938 1939 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1940 1941 return TEST_SUCCESS; 1942 } 1943 1944 static int 1945 test_AES_cipheronly_qat_all(void) 1946 { 1947 struct crypto_testsuite_params *ts_params = &testsuite_params; 1948 int status; 1949 1950 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1951 ts_params->op_mpool, 1952 ts_params->session_mpool, ts_params->session_priv_mpool, 1953 ts_params->valid_devs[0], 1954 rte_cryptodev_driver_id_get( 1955 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), 1956 BLKCIPHER_AES_CIPHERONLY_TYPE); 1957 1958 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1959 1960 return TEST_SUCCESS; 1961 } 1962 1963 static int 1964 test_AES_cipheronly_virtio_all(void) 1965 { 1966 struct crypto_testsuite_params *ts_params = &testsuite_params; 1967 int status; 1968 1969 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1970 ts_params->op_mpool, 1971 ts_params->session_mpool, ts_params->session_priv_mpool, 1972 ts_params->valid_devs[0], 1973 rte_cryptodev_driver_id_get( 1974 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)), 1975 BLKCIPHER_AES_CIPHERONLY_TYPE); 1976 1977 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1978 1979 return TEST_SUCCESS; 1980 } 1981 1982 static int 1983 test_AES_chain_caam_jr_all(void) 1984 { 1985 struct crypto_testsuite_params *ts_params = &testsuite_params; 1986 int status; 1987 1988 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 1989 ts_params->op_mpool, 1990 ts_params->session_mpool, ts_params->session_priv_mpool, 1991 ts_params->valid_devs[0], 1992 rte_cryptodev_driver_id_get( 1993 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)), 1994 BLKCIPHER_AES_CHAIN_TYPE); 1995 1996 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 1997 1998 return TEST_SUCCESS; 1999 } 2000 2001 static int 2002 test_AES_cipheronly_caam_jr_all(void) 2003 { 2004 struct crypto_testsuite_params *ts_params = &testsuite_params; 2005 int status; 2006 2007 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2008 ts_params->op_mpool, 2009 ts_params->session_mpool, ts_params->session_priv_mpool, 2010 ts_params->valid_devs[0], 2011 rte_cryptodev_driver_id_get( 2012 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)), 2013 BLKCIPHER_AES_CIPHERONLY_TYPE); 2014 2015 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2016 2017 return TEST_SUCCESS; 2018 } 2019 2020 static int 2021 test_authonly_caam_jr_all(void) 2022 { 2023 struct crypto_testsuite_params *ts_params = &testsuite_params; 2024 int status; 2025 2026 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2027 ts_params->op_mpool, 2028 ts_params->session_mpool, ts_params->session_priv_mpool, 2029 ts_params->valid_devs[0], 2030 rte_cryptodev_driver_id_get( 2031 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)), 2032 BLKCIPHER_AUTHONLY_TYPE); 2033 2034 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2035 2036 return TEST_SUCCESS; 2037 } 2038 2039 2040 static int 2041 test_AES_chain_dpaa_sec_all(void) 2042 { 2043 struct crypto_testsuite_params *ts_params = &testsuite_params; 2044 int status; 2045 2046 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2047 ts_params->op_mpool, 2048 ts_params->session_mpool, ts_params->session_priv_mpool, 2049 ts_params->valid_devs[0], 2050 rte_cryptodev_driver_id_get( 2051 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)), 2052 BLKCIPHER_AES_CHAIN_TYPE); 2053 2054 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2055 2056 return TEST_SUCCESS; 2057 } 2058 2059 static int 2060 test_AES_cipheronly_dpaa_sec_all(void) 2061 { 2062 struct crypto_testsuite_params *ts_params = &testsuite_params; 2063 int status; 2064 2065 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2066 ts_params->op_mpool, 2067 ts_params->session_mpool, ts_params->session_priv_mpool, 2068 ts_params->valid_devs[0], 2069 rte_cryptodev_driver_id_get( 2070 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)), 2071 BLKCIPHER_AES_CIPHERONLY_TYPE); 2072 2073 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2074 2075 return TEST_SUCCESS; 2076 } 2077 2078 static int 2079 test_authonly_dpaa_sec_all(void) 2080 { 2081 struct crypto_testsuite_params *ts_params = &testsuite_params; 2082 int status; 2083 2084 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2085 ts_params->op_mpool, 2086 ts_params->session_mpool, ts_params->session_priv_mpool, 2087 ts_params->valid_devs[0], 2088 rte_cryptodev_driver_id_get( 2089 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)), 2090 BLKCIPHER_AUTHONLY_TYPE); 2091 2092 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2093 2094 return TEST_SUCCESS; 2095 } 2096 2097 static int 2098 test_AES_chain_dpaa2_sec_all(void) 2099 { 2100 struct crypto_testsuite_params *ts_params = &testsuite_params; 2101 int status; 2102 2103 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2104 ts_params->op_mpool, 2105 ts_params->session_mpool, ts_params->session_priv_mpool, 2106 ts_params->valid_devs[0], 2107 rte_cryptodev_driver_id_get( 2108 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)), 2109 BLKCIPHER_AES_CHAIN_TYPE); 2110 2111 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2112 2113 return TEST_SUCCESS; 2114 } 2115 2116 static int 2117 test_AES_cipheronly_dpaa2_sec_all(void) 2118 { 2119 struct crypto_testsuite_params *ts_params = &testsuite_params; 2120 int status; 2121 2122 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2123 ts_params->op_mpool, 2124 ts_params->session_mpool, ts_params->session_priv_mpool, 2125 ts_params->valid_devs[0], 2126 rte_cryptodev_driver_id_get( 2127 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)), 2128 BLKCIPHER_AES_CIPHERONLY_TYPE); 2129 2130 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2131 2132 return TEST_SUCCESS; 2133 } 2134 2135 static int 2136 test_authonly_dpaa2_sec_all(void) 2137 { 2138 struct crypto_testsuite_params *ts_params = &testsuite_params; 2139 int status; 2140 2141 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2142 ts_params->op_mpool, 2143 ts_params->session_mpool, ts_params->session_priv_mpool, 2144 ts_params->valid_devs[0], 2145 rte_cryptodev_driver_id_get( 2146 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)), 2147 BLKCIPHER_AUTHONLY_TYPE); 2148 2149 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2150 2151 return TEST_SUCCESS; 2152 } 2153 2154 static int 2155 test_authonly_openssl_all(void) 2156 { 2157 struct crypto_testsuite_params *ts_params = &testsuite_params; 2158 int status; 2159 2160 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2161 ts_params->op_mpool, 2162 ts_params->session_mpool, ts_params->session_priv_mpool, 2163 ts_params->valid_devs[0], 2164 rte_cryptodev_driver_id_get( 2165 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)), 2166 BLKCIPHER_AUTHONLY_TYPE); 2167 2168 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2169 2170 return TEST_SUCCESS; 2171 } 2172 2173 static int 2174 test_authonly_ccp_all(void) 2175 { 2176 struct crypto_testsuite_params *ts_params = &testsuite_params; 2177 int status; 2178 2179 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2180 ts_params->op_mpool, 2181 ts_params->session_mpool, ts_params->session_priv_mpool, 2182 ts_params->valid_devs[0], 2183 rte_cryptodev_driver_id_get( 2184 RTE_STR(CRYPTODEV_NAME_CCP_PMD)), 2185 BLKCIPHER_AUTHONLY_TYPE); 2186 2187 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2188 2189 return TEST_SUCCESS; 2190 } 2191 2192 static int 2193 test_AES_chain_armv8_all(void) 2194 { 2195 struct crypto_testsuite_params *ts_params = &testsuite_params; 2196 int status; 2197 2198 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2199 ts_params->op_mpool, 2200 ts_params->session_mpool, ts_params->session_priv_mpool, 2201 ts_params->valid_devs[0], 2202 rte_cryptodev_driver_id_get( 2203 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)), 2204 BLKCIPHER_AES_CHAIN_TYPE); 2205 2206 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2207 2208 return TEST_SUCCESS; 2209 } 2210 2211 static int 2212 test_AES_chain_mrvl_all(void) 2213 { 2214 struct crypto_testsuite_params *ts_params = &testsuite_params; 2215 int status; 2216 2217 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2218 ts_params->op_mpool, 2219 ts_params->session_mpool, ts_params->session_priv_mpool, 2220 ts_params->valid_devs[0], 2221 rte_cryptodev_driver_id_get( 2222 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), 2223 BLKCIPHER_AES_CHAIN_TYPE); 2224 2225 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2226 2227 return TEST_SUCCESS; 2228 } 2229 2230 static int 2231 test_AES_cipheronly_mrvl_all(void) 2232 { 2233 struct crypto_testsuite_params *ts_params = &testsuite_params; 2234 int status; 2235 2236 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2237 ts_params->op_mpool, 2238 ts_params->session_mpool, ts_params->session_priv_mpool, 2239 ts_params->valid_devs[0], 2240 rte_cryptodev_driver_id_get( 2241 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), 2242 BLKCIPHER_AES_CIPHERONLY_TYPE); 2243 2244 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2245 2246 return TEST_SUCCESS; 2247 } 2248 2249 static int 2250 test_authonly_mrvl_all(void) 2251 { 2252 struct crypto_testsuite_params *ts_params = &testsuite_params; 2253 int status; 2254 2255 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2256 ts_params->op_mpool, 2257 ts_params->session_mpool, ts_params->session_priv_mpool, 2258 ts_params->valid_devs[0], 2259 rte_cryptodev_driver_id_get( 2260 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), 2261 BLKCIPHER_AUTHONLY_TYPE); 2262 2263 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2264 2265 return TEST_SUCCESS; 2266 } 2267 2268 static int 2269 test_3DES_chain_mrvl_all(void) 2270 { 2271 struct crypto_testsuite_params *ts_params = &testsuite_params; 2272 int status; 2273 2274 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2275 ts_params->op_mpool, 2276 ts_params->session_mpool, ts_params->session_priv_mpool, 2277 ts_params->valid_devs[0], 2278 rte_cryptodev_driver_id_get( 2279 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), 2280 BLKCIPHER_3DES_CHAIN_TYPE); 2281 2282 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2283 2284 return TEST_SUCCESS; 2285 } 2286 2287 static int 2288 test_3DES_cipheronly_mrvl_all(void) 2289 { 2290 struct crypto_testsuite_params *ts_params = &testsuite_params; 2291 int status; 2292 2293 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2294 ts_params->op_mpool, 2295 ts_params->session_mpool, ts_params->session_priv_mpool, 2296 ts_params->valid_devs[0], 2297 rte_cryptodev_driver_id_get( 2298 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)), 2299 BLKCIPHER_3DES_CIPHERONLY_TYPE); 2300 2301 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2302 2303 return TEST_SUCCESS; 2304 } 2305 2306 static int 2307 test_AES_chain_octeontx_all(void) 2308 { 2309 struct crypto_testsuite_params *ts_params = &testsuite_params; 2310 int status; 2311 2312 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2313 ts_params->op_mpool, ts_params->session_mpool, 2314 ts_params->session_priv_mpool, 2315 ts_params->valid_devs[0], 2316 rte_cryptodev_driver_id_get( 2317 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)), 2318 BLKCIPHER_AES_CHAIN_TYPE); 2319 2320 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2321 2322 return TEST_SUCCESS; 2323 } 2324 2325 static int 2326 test_AES_cipheronly_octeontx_all(void) 2327 { 2328 struct crypto_testsuite_params *ts_params = &testsuite_params; 2329 int status; 2330 2331 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2332 ts_params->op_mpool, ts_params->session_mpool, 2333 ts_params->session_priv_mpool, 2334 ts_params->valid_devs[0], 2335 rte_cryptodev_driver_id_get( 2336 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)), 2337 BLKCIPHER_AES_CIPHERONLY_TYPE); 2338 2339 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2340 2341 return TEST_SUCCESS; 2342 } 2343 2344 static int 2345 test_3DES_chain_octeontx_all(void) 2346 { 2347 struct crypto_testsuite_params *ts_params = &testsuite_params; 2348 int status; 2349 2350 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2351 ts_params->op_mpool, ts_params->session_mpool, 2352 ts_params->session_priv_mpool, 2353 ts_params->valid_devs[0], 2354 rte_cryptodev_driver_id_get( 2355 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)), 2356 BLKCIPHER_3DES_CHAIN_TYPE); 2357 2358 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2359 2360 return TEST_SUCCESS; 2361 } 2362 2363 static int 2364 test_AES_chain_nitrox_all(void) 2365 { 2366 struct crypto_testsuite_params *ts_params = &testsuite_params; 2367 int status; 2368 2369 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2370 ts_params->op_mpool, 2371 ts_params->session_mpool, ts_params->session_priv_mpool, 2372 ts_params->valid_devs[0], 2373 rte_cryptodev_driver_id_get( 2374 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)), 2375 BLKCIPHER_AES_CHAIN_TYPE); 2376 2377 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2378 2379 return TEST_SUCCESS; 2380 } 2381 2382 static int 2383 test_3DES_cipheronly_octeontx_all(void) 2384 { 2385 struct crypto_testsuite_params *ts_params = &testsuite_params; 2386 int status; 2387 2388 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2389 ts_params->op_mpool, ts_params->session_mpool, 2390 ts_params->session_priv_mpool, 2391 ts_params->valid_devs[0], 2392 rte_cryptodev_driver_id_get( 2393 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)), 2394 BLKCIPHER_3DES_CIPHERONLY_TYPE); 2395 2396 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2397 2398 return TEST_SUCCESS; 2399 } 2400 2401 static int 2402 test_authonly_octeontx_all(void) 2403 { 2404 struct crypto_testsuite_params *ts_params = &testsuite_params; 2405 int status; 2406 2407 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2408 ts_params->op_mpool, ts_params->session_mpool, 2409 ts_params->session_priv_mpool, 2410 ts_params->valid_devs[0], 2411 rte_cryptodev_driver_id_get( 2412 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)), 2413 BLKCIPHER_AUTHONLY_TYPE); 2414 2415 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2416 2417 return TEST_SUCCESS; 2418 } 2419 2420 static int 2421 test_AES_chain_octeontx2_all(void) 2422 { 2423 struct crypto_testsuite_params *ts_params = &testsuite_params; 2424 int status; 2425 2426 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2427 ts_params->op_mpool, ts_params->session_mpool, 2428 ts_params->session_priv_mpool, 2429 ts_params->valid_devs[0], 2430 rte_cryptodev_driver_id_get( 2431 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)), 2432 BLKCIPHER_AES_CHAIN_TYPE); 2433 2434 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2435 2436 return TEST_SUCCESS; 2437 } 2438 2439 static int 2440 test_AES_cipheronly_octeontx2_all(void) 2441 { 2442 struct crypto_testsuite_params *ts_params = &testsuite_params; 2443 int status; 2444 2445 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2446 ts_params->op_mpool, ts_params->session_mpool, 2447 ts_params->session_priv_mpool, 2448 ts_params->valid_devs[0], 2449 rte_cryptodev_driver_id_get( 2450 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)), 2451 BLKCIPHER_AES_CIPHERONLY_TYPE); 2452 2453 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2454 2455 return TEST_SUCCESS; 2456 } 2457 2458 static int 2459 test_3DES_chain_octeontx2_all(void) 2460 { 2461 struct crypto_testsuite_params *ts_params = &testsuite_params; 2462 int status; 2463 2464 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2465 ts_params->op_mpool, ts_params->session_mpool, 2466 ts_params->session_priv_mpool, 2467 ts_params->valid_devs[0], 2468 rte_cryptodev_driver_id_get( 2469 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)), 2470 BLKCIPHER_3DES_CHAIN_TYPE); 2471 2472 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2473 2474 return TEST_SUCCESS; 2475 } 2476 2477 static int 2478 test_3DES_cipheronly_octeontx2_all(void) 2479 { 2480 struct crypto_testsuite_params *ts_params = &testsuite_params; 2481 int status; 2482 2483 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2484 ts_params->op_mpool, ts_params->session_mpool, 2485 ts_params->session_priv_mpool, 2486 ts_params->valid_devs[0], 2487 rte_cryptodev_driver_id_get( 2488 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)), 2489 BLKCIPHER_3DES_CIPHERONLY_TYPE); 2490 2491 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2492 2493 return TEST_SUCCESS; 2494 } 2495 2496 static int 2497 test_authonly_octeontx2_all(void) 2498 { 2499 struct crypto_testsuite_params *ts_params = &testsuite_params; 2500 int status; 2501 2502 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 2503 ts_params->op_mpool, ts_params->session_mpool, 2504 ts_params->session_priv_mpool, 2505 ts_params->valid_devs[0], 2506 rte_cryptodev_driver_id_get( 2507 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)), 2508 BLKCIPHER_AUTHONLY_TYPE); 2509 2510 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 2511 2512 return TEST_SUCCESS; 2513 } 2514 2515 /* ***** SNOW 3G Tests ***** */ 2516 static int 2517 create_wireless_algo_hash_session(uint8_t dev_id, 2518 const uint8_t *key, const uint8_t key_len, 2519 const uint8_t iv_len, const uint8_t auth_len, 2520 enum rte_crypto_auth_operation op, 2521 enum rte_crypto_auth_algorithm algo) 2522 { 2523 uint8_t hash_key[key_len]; 2524 int status; 2525 2526 struct crypto_testsuite_params *ts_params = &testsuite_params; 2527 struct crypto_unittest_params *ut_params = &unittest_params; 2528 2529 memcpy(hash_key, key, key_len); 2530 2531 debug_hexdump(stdout, "key:", key, key_len); 2532 2533 /* Setup Authentication Parameters */ 2534 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 2535 ut_params->auth_xform.next = NULL; 2536 2537 ut_params->auth_xform.auth.op = op; 2538 ut_params->auth_xform.auth.algo = algo; 2539 ut_params->auth_xform.auth.key.length = key_len; 2540 ut_params->auth_xform.auth.key.data = hash_key; 2541 ut_params->auth_xform.auth.digest_length = auth_len; 2542 ut_params->auth_xform.auth.iv.offset = IV_OFFSET; 2543 ut_params->auth_xform.auth.iv.length = iv_len; 2544 ut_params->sess = rte_cryptodev_sym_session_create( 2545 ts_params->session_mpool); 2546 2547 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 2548 &ut_params->auth_xform, 2549 ts_params->session_priv_mpool); 2550 TEST_ASSERT_EQUAL(status, 0, "session init failed"); 2551 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 2552 return 0; 2553 } 2554 2555 static int 2556 create_wireless_algo_cipher_session(uint8_t dev_id, 2557 enum rte_crypto_cipher_operation op, 2558 enum rte_crypto_cipher_algorithm algo, 2559 const uint8_t *key, const uint8_t key_len, 2560 uint8_t iv_len) 2561 { 2562 uint8_t cipher_key[key_len]; 2563 int status; 2564 struct crypto_testsuite_params *ts_params = &testsuite_params; 2565 struct crypto_unittest_params *ut_params = &unittest_params; 2566 2567 memcpy(cipher_key, key, key_len); 2568 2569 /* Setup Cipher Parameters */ 2570 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 2571 ut_params->cipher_xform.next = NULL; 2572 2573 ut_params->cipher_xform.cipher.algo = algo; 2574 ut_params->cipher_xform.cipher.op = op; 2575 ut_params->cipher_xform.cipher.key.data = cipher_key; 2576 ut_params->cipher_xform.cipher.key.length = key_len; 2577 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 2578 ut_params->cipher_xform.cipher.iv.length = iv_len; 2579 2580 debug_hexdump(stdout, "key:", key, key_len); 2581 2582 /* Create Crypto session */ 2583 ut_params->sess = rte_cryptodev_sym_session_create( 2584 ts_params->session_mpool); 2585 2586 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 2587 &ut_params->cipher_xform, 2588 ts_params->session_priv_mpool); 2589 TEST_ASSERT_EQUAL(status, 0, "session init failed"); 2590 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 2591 return 0; 2592 } 2593 2594 static int 2595 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len, 2596 unsigned int cipher_len, 2597 unsigned int cipher_offset) 2598 { 2599 struct crypto_testsuite_params *ts_params = &testsuite_params; 2600 struct crypto_unittest_params *ut_params = &unittest_params; 2601 2602 /* Generate Crypto op data structure */ 2603 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 2604 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 2605 TEST_ASSERT_NOT_NULL(ut_params->op, 2606 "Failed to allocate pktmbuf offload"); 2607 2608 /* Set crypto operation data parameters */ 2609 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 2610 2611 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 2612 2613 /* set crypto operation source mbuf */ 2614 sym_op->m_src = ut_params->ibuf; 2615 2616 /* iv */ 2617 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), 2618 iv, iv_len); 2619 sym_op->cipher.data.length = cipher_len; 2620 sym_op->cipher.data.offset = cipher_offset; 2621 return 0; 2622 } 2623 2624 static int 2625 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len, 2626 unsigned int cipher_len, 2627 unsigned int cipher_offset) 2628 { 2629 struct crypto_testsuite_params *ts_params = &testsuite_params; 2630 struct crypto_unittest_params *ut_params = &unittest_params; 2631 2632 /* Generate Crypto op data structure */ 2633 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 2634 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 2635 TEST_ASSERT_NOT_NULL(ut_params->op, 2636 "Failed to allocate pktmbuf offload"); 2637 2638 /* Set crypto operation data parameters */ 2639 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 2640 2641 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 2642 2643 /* set crypto operation source mbuf */ 2644 sym_op->m_src = ut_params->ibuf; 2645 sym_op->m_dst = ut_params->obuf; 2646 2647 /* iv */ 2648 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), 2649 iv, iv_len); 2650 sym_op->cipher.data.length = cipher_len; 2651 sym_op->cipher.data.offset = cipher_offset; 2652 return 0; 2653 } 2654 2655 static int 2656 create_wireless_algo_cipher_auth_session(uint8_t dev_id, 2657 enum rte_crypto_cipher_operation cipher_op, 2658 enum rte_crypto_auth_operation auth_op, 2659 enum rte_crypto_auth_algorithm auth_algo, 2660 enum rte_crypto_cipher_algorithm cipher_algo, 2661 const uint8_t *key, uint8_t key_len, 2662 uint8_t auth_iv_len, uint8_t auth_len, 2663 uint8_t cipher_iv_len) 2664 2665 { 2666 uint8_t cipher_auth_key[key_len]; 2667 int status; 2668 2669 struct crypto_testsuite_params *ts_params = &testsuite_params; 2670 struct crypto_unittest_params *ut_params = &unittest_params; 2671 2672 memcpy(cipher_auth_key, key, key_len); 2673 2674 /* Setup Authentication Parameters */ 2675 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 2676 ut_params->auth_xform.next = NULL; 2677 2678 ut_params->auth_xform.auth.op = auth_op; 2679 ut_params->auth_xform.auth.algo = auth_algo; 2680 ut_params->auth_xform.auth.key.length = key_len; 2681 /* Hash key = cipher key */ 2682 ut_params->auth_xform.auth.key.data = cipher_auth_key; 2683 ut_params->auth_xform.auth.digest_length = auth_len; 2684 /* Auth IV will be after cipher IV */ 2685 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len; 2686 ut_params->auth_xform.auth.iv.length = auth_iv_len; 2687 2688 /* Setup Cipher Parameters */ 2689 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 2690 ut_params->cipher_xform.next = &ut_params->auth_xform; 2691 2692 ut_params->cipher_xform.cipher.algo = cipher_algo; 2693 ut_params->cipher_xform.cipher.op = cipher_op; 2694 ut_params->cipher_xform.cipher.key.data = cipher_auth_key; 2695 ut_params->cipher_xform.cipher.key.length = key_len; 2696 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 2697 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len; 2698 2699 debug_hexdump(stdout, "key:", key, key_len); 2700 2701 /* Create Crypto session*/ 2702 ut_params->sess = rte_cryptodev_sym_session_create( 2703 ts_params->session_mpool); 2704 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 2705 2706 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 2707 &ut_params->cipher_xform, 2708 ts_params->session_priv_mpool); 2709 if (status == -ENOTSUP) 2710 return status; 2711 2712 TEST_ASSERT_EQUAL(status, 0, "session init failed"); 2713 return 0; 2714 } 2715 2716 static int 2717 create_wireless_cipher_auth_session(uint8_t dev_id, 2718 enum rte_crypto_cipher_operation cipher_op, 2719 enum rte_crypto_auth_operation auth_op, 2720 enum rte_crypto_auth_algorithm auth_algo, 2721 enum rte_crypto_cipher_algorithm cipher_algo, 2722 const struct wireless_test_data *tdata) 2723 { 2724 const uint8_t key_len = tdata->key.len; 2725 uint8_t cipher_auth_key[key_len]; 2726 int status; 2727 2728 struct crypto_testsuite_params *ts_params = &testsuite_params; 2729 struct crypto_unittest_params *ut_params = &unittest_params; 2730 const uint8_t *key = tdata->key.data; 2731 const uint8_t auth_len = tdata->digest.len; 2732 uint8_t cipher_iv_len = tdata->cipher_iv.len; 2733 uint8_t auth_iv_len = tdata->auth_iv.len; 2734 2735 memcpy(cipher_auth_key, key, key_len); 2736 2737 /* Setup Authentication Parameters */ 2738 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 2739 ut_params->auth_xform.next = NULL; 2740 2741 ut_params->auth_xform.auth.op = auth_op; 2742 ut_params->auth_xform.auth.algo = auth_algo; 2743 ut_params->auth_xform.auth.key.length = key_len; 2744 /* Hash key = cipher key */ 2745 ut_params->auth_xform.auth.key.data = cipher_auth_key; 2746 ut_params->auth_xform.auth.digest_length = auth_len; 2747 /* Auth IV will be after cipher IV */ 2748 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len; 2749 ut_params->auth_xform.auth.iv.length = auth_iv_len; 2750 2751 /* Setup Cipher Parameters */ 2752 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 2753 ut_params->cipher_xform.next = &ut_params->auth_xform; 2754 2755 ut_params->cipher_xform.cipher.algo = cipher_algo; 2756 ut_params->cipher_xform.cipher.op = cipher_op; 2757 ut_params->cipher_xform.cipher.key.data = cipher_auth_key; 2758 ut_params->cipher_xform.cipher.key.length = key_len; 2759 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 2760 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len; 2761 2762 2763 debug_hexdump(stdout, "key:", key, key_len); 2764 2765 /* Create Crypto session*/ 2766 ut_params->sess = rte_cryptodev_sym_session_create( 2767 ts_params->session_mpool); 2768 2769 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 2770 &ut_params->cipher_xform, 2771 ts_params->session_priv_mpool); 2772 2773 TEST_ASSERT_EQUAL(status, 0, "session init failed"); 2774 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 2775 return 0; 2776 } 2777 2778 static int 2779 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id, 2780 const struct wireless_test_data *tdata) 2781 { 2782 return create_wireless_cipher_auth_session(dev_id, 2783 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 2784 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3, 2785 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata); 2786 } 2787 2788 static int 2789 create_wireless_algo_auth_cipher_session(uint8_t dev_id, 2790 enum rte_crypto_cipher_operation cipher_op, 2791 enum rte_crypto_auth_operation auth_op, 2792 enum rte_crypto_auth_algorithm auth_algo, 2793 enum rte_crypto_cipher_algorithm cipher_algo, 2794 const uint8_t *key, const uint8_t key_len, 2795 uint8_t auth_iv_len, uint8_t auth_len, 2796 uint8_t cipher_iv_len) 2797 { 2798 uint8_t auth_cipher_key[key_len]; 2799 int status; 2800 struct crypto_testsuite_params *ts_params = &testsuite_params; 2801 struct crypto_unittest_params *ut_params = &unittest_params; 2802 2803 memcpy(auth_cipher_key, key, key_len); 2804 2805 /* Setup Authentication Parameters */ 2806 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 2807 ut_params->auth_xform.auth.op = auth_op; 2808 ut_params->auth_xform.next = &ut_params->cipher_xform; 2809 ut_params->auth_xform.auth.algo = auth_algo; 2810 ut_params->auth_xform.auth.key.length = key_len; 2811 ut_params->auth_xform.auth.key.data = auth_cipher_key; 2812 ut_params->auth_xform.auth.digest_length = auth_len; 2813 /* Auth IV will be after cipher IV */ 2814 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len; 2815 ut_params->auth_xform.auth.iv.length = auth_iv_len; 2816 2817 /* Setup Cipher Parameters */ 2818 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 2819 ut_params->cipher_xform.next = NULL; 2820 ut_params->cipher_xform.cipher.algo = cipher_algo; 2821 ut_params->cipher_xform.cipher.op = cipher_op; 2822 ut_params->cipher_xform.cipher.key.data = auth_cipher_key; 2823 ut_params->cipher_xform.cipher.key.length = key_len; 2824 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 2825 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len; 2826 2827 debug_hexdump(stdout, "key:", key, key_len); 2828 2829 /* Create Crypto session*/ 2830 ut_params->sess = rte_cryptodev_sym_session_create( 2831 ts_params->session_mpool); 2832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 2833 2834 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) { 2835 ut_params->auth_xform.next = NULL; 2836 ut_params->cipher_xform.next = &ut_params->auth_xform; 2837 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 2838 &ut_params->cipher_xform, 2839 ts_params->session_priv_mpool); 2840 2841 } else 2842 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 2843 &ut_params->auth_xform, 2844 ts_params->session_priv_mpool); 2845 2846 if (status == -ENOTSUP) 2847 return status; 2848 2849 TEST_ASSERT_EQUAL(status, 0, "session init failed"); 2850 2851 return 0; 2852 } 2853 2854 static int 2855 create_wireless_algo_hash_operation(const uint8_t *auth_tag, 2856 unsigned int auth_tag_len, 2857 const uint8_t *iv, unsigned int iv_len, 2858 unsigned int data_pad_len, 2859 enum rte_crypto_auth_operation op, 2860 unsigned int auth_len, unsigned int auth_offset) 2861 { 2862 struct crypto_testsuite_params *ts_params = &testsuite_params; 2863 2864 struct crypto_unittest_params *ut_params = &unittest_params; 2865 2866 /* Generate Crypto op data structure */ 2867 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 2868 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 2869 TEST_ASSERT_NOT_NULL(ut_params->op, 2870 "Failed to allocate pktmbuf offload"); 2871 2872 /* Set crypto operation data parameters */ 2873 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 2874 2875 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 2876 2877 /* set crypto operation source mbuf */ 2878 sym_op->m_src = ut_params->ibuf; 2879 2880 /* iv */ 2881 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), 2882 iv, iv_len); 2883 /* digest */ 2884 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( 2885 ut_params->ibuf, auth_tag_len); 2886 2887 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, 2888 "no room to append auth tag"); 2889 ut_params->digest = sym_op->auth.digest.data; 2890 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 2891 ut_params->ibuf, data_pad_len); 2892 if (op == RTE_CRYPTO_AUTH_OP_GENERATE) 2893 memset(sym_op->auth.digest.data, 0, auth_tag_len); 2894 else 2895 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len); 2896 2897 debug_hexdump(stdout, "digest:", 2898 sym_op->auth.digest.data, 2899 auth_tag_len); 2900 2901 sym_op->auth.data.length = auth_len; 2902 sym_op->auth.data.offset = auth_offset; 2903 2904 return 0; 2905 } 2906 2907 static int 2908 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata, 2909 enum rte_crypto_auth_operation op) 2910 { 2911 struct crypto_testsuite_params *ts_params = &testsuite_params; 2912 struct crypto_unittest_params *ut_params = &unittest_params; 2913 2914 const uint8_t *auth_tag = tdata->digest.data; 2915 const unsigned int auth_tag_len = tdata->digest.len; 2916 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len); 2917 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 2918 2919 const uint8_t *cipher_iv = tdata->cipher_iv.data; 2920 const uint8_t cipher_iv_len = tdata->cipher_iv.len; 2921 const uint8_t *auth_iv = tdata->auth_iv.data; 2922 const uint8_t auth_iv_len = tdata->auth_iv.len; 2923 const unsigned int cipher_len = tdata->validCipherLenInBits.len; 2924 const unsigned int auth_len = tdata->validAuthLenInBits.len; 2925 2926 /* Generate Crypto op data structure */ 2927 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 2928 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 2929 TEST_ASSERT_NOT_NULL(ut_params->op, 2930 "Failed to allocate pktmbuf offload"); 2931 /* Set crypto operation data parameters */ 2932 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 2933 2934 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 2935 2936 /* set crypto operation source mbuf */ 2937 sym_op->m_src = ut_params->ibuf; 2938 2939 /* digest */ 2940 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( 2941 ut_params->ibuf, auth_tag_len); 2942 2943 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, 2944 "no room to append auth tag"); 2945 ut_params->digest = sym_op->auth.digest.data; 2946 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 2947 ut_params->ibuf, data_pad_len); 2948 if (op == RTE_CRYPTO_AUTH_OP_GENERATE) 2949 memset(sym_op->auth.digest.data, 0, auth_tag_len); 2950 else 2951 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len); 2952 2953 debug_hexdump(stdout, "digest:", 2954 sym_op->auth.digest.data, 2955 auth_tag_len); 2956 2957 /* Copy cipher and auth IVs at the end of the crypto operation */ 2958 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, 2959 IV_OFFSET); 2960 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len); 2961 iv_ptr += cipher_iv_len; 2962 rte_memcpy(iv_ptr, auth_iv, auth_iv_len); 2963 2964 sym_op->cipher.data.length = cipher_len; 2965 sym_op->cipher.data.offset = 0; 2966 sym_op->auth.data.length = auth_len; 2967 sym_op->auth.data.offset = 0; 2968 2969 return 0; 2970 } 2971 2972 static int 2973 create_zuc_cipher_hash_generate_operation( 2974 const struct wireless_test_data *tdata) 2975 { 2976 return create_wireless_cipher_hash_operation(tdata, 2977 RTE_CRYPTO_AUTH_OP_GENERATE); 2978 } 2979 2980 static int 2981 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag, 2982 const unsigned auth_tag_len, 2983 const uint8_t *auth_iv, uint8_t auth_iv_len, 2984 unsigned data_pad_len, 2985 enum rte_crypto_auth_operation op, 2986 const uint8_t *cipher_iv, uint8_t cipher_iv_len, 2987 const unsigned cipher_len, const unsigned cipher_offset, 2988 const unsigned auth_len, const unsigned auth_offset) 2989 { 2990 struct crypto_testsuite_params *ts_params = &testsuite_params; 2991 struct crypto_unittest_params *ut_params = &unittest_params; 2992 2993 enum rte_crypto_cipher_algorithm cipher_algo = 2994 ut_params->cipher_xform.cipher.algo; 2995 enum rte_crypto_auth_algorithm auth_algo = 2996 ut_params->auth_xform.auth.algo; 2997 2998 /* Generate Crypto op data structure */ 2999 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 3000 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 3001 TEST_ASSERT_NOT_NULL(ut_params->op, 3002 "Failed to allocate pktmbuf offload"); 3003 /* Set crypto operation data parameters */ 3004 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 3005 3006 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 3007 3008 /* set crypto operation source mbuf */ 3009 sym_op->m_src = ut_params->ibuf; 3010 3011 /* digest */ 3012 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( 3013 ut_params->ibuf, auth_tag_len); 3014 3015 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, 3016 "no room to append auth tag"); 3017 ut_params->digest = sym_op->auth.digest.data; 3018 3019 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) { 3020 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 3021 ut_params->ibuf, data_pad_len); 3022 } else { 3023 struct rte_mbuf *m = ut_params->ibuf; 3024 unsigned int offset = data_pad_len; 3025 3026 while (offset > m->data_len && m->next != NULL) { 3027 offset -= m->data_len; 3028 m = m->next; 3029 } 3030 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 3031 m, offset); 3032 } 3033 3034 if (op == RTE_CRYPTO_AUTH_OP_GENERATE) 3035 memset(sym_op->auth.digest.data, 0, auth_tag_len); 3036 else 3037 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len); 3038 3039 debug_hexdump(stdout, "digest:", 3040 sym_op->auth.digest.data, 3041 auth_tag_len); 3042 3043 /* Copy cipher and auth IVs at the end of the crypto operation */ 3044 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, 3045 IV_OFFSET); 3046 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len); 3047 iv_ptr += cipher_iv_len; 3048 rte_memcpy(iv_ptr, auth_iv, auth_iv_len); 3049 3050 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 || 3051 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 || 3052 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) { 3053 sym_op->cipher.data.length = cipher_len; 3054 sym_op->cipher.data.offset = cipher_offset; 3055 } else { 3056 sym_op->cipher.data.length = cipher_len >> 3; 3057 sym_op->cipher.data.offset = cipher_offset >> 3; 3058 } 3059 3060 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 || 3061 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 || 3062 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) { 3063 sym_op->auth.data.length = auth_len; 3064 sym_op->auth.data.offset = auth_offset; 3065 } else { 3066 sym_op->auth.data.length = auth_len >> 3; 3067 sym_op->auth.data.offset = auth_offset >> 3; 3068 } 3069 3070 return 0; 3071 } 3072 3073 static int 3074 create_wireless_algo_auth_cipher_operation( 3075 const uint8_t *auth_tag, unsigned int auth_tag_len, 3076 const uint8_t *cipher_iv, uint8_t cipher_iv_len, 3077 const uint8_t *auth_iv, uint8_t auth_iv_len, 3078 unsigned int data_pad_len, 3079 unsigned int cipher_len, unsigned int cipher_offset, 3080 unsigned int auth_len, unsigned int auth_offset, 3081 uint8_t op_mode, uint8_t do_sgl, uint8_t verify) 3082 { 3083 struct crypto_testsuite_params *ts_params = &testsuite_params; 3084 struct crypto_unittest_params *ut_params = &unittest_params; 3085 3086 enum rte_crypto_cipher_algorithm cipher_algo = 3087 ut_params->cipher_xform.cipher.algo; 3088 enum rte_crypto_auth_algorithm auth_algo = 3089 ut_params->auth_xform.auth.algo; 3090 3091 /* Generate Crypto op data structure */ 3092 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 3093 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 3094 TEST_ASSERT_NOT_NULL(ut_params->op, 3095 "Failed to allocate pktmbuf offload"); 3096 3097 /* Set crypto operation data parameters */ 3098 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 3099 3100 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 3101 3102 /* set crypto operation mbufs */ 3103 sym_op->m_src = ut_params->ibuf; 3104 if (op_mode == OUT_OF_PLACE) 3105 sym_op->m_dst = ut_params->obuf; 3106 3107 /* digest */ 3108 if (!do_sgl) { 3109 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset( 3110 (op_mode == IN_PLACE ? 3111 ut_params->ibuf : ut_params->obuf), 3112 uint8_t *, data_pad_len); 3113 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 3114 (op_mode == IN_PLACE ? 3115 ut_params->ibuf : ut_params->obuf), 3116 data_pad_len); 3117 memset(sym_op->auth.digest.data, 0, auth_tag_len); 3118 } else { 3119 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3); 3120 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ? 3121 sym_op->m_src : sym_op->m_dst); 3122 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) { 3123 remaining_off -= rte_pktmbuf_data_len(sgl_buf); 3124 sgl_buf = sgl_buf->next; 3125 } 3126 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf, 3127 uint8_t *, remaining_off); 3128 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf, 3129 remaining_off); 3130 memset(sym_op->auth.digest.data, 0, remaining_off); 3131 while (sgl_buf->next != NULL) { 3132 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *), 3133 0, rte_pktmbuf_data_len(sgl_buf)); 3134 sgl_buf = sgl_buf->next; 3135 } 3136 } 3137 3138 /* Copy digest for the verification */ 3139 if (verify) 3140 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len); 3141 3142 /* Copy cipher and auth IVs at the end of the crypto operation */ 3143 uint8_t *iv_ptr = rte_crypto_op_ctod_offset( 3144 ut_params->op, uint8_t *, IV_OFFSET); 3145 3146 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len); 3147 iv_ptr += cipher_iv_len; 3148 rte_memcpy(iv_ptr, auth_iv, auth_iv_len); 3149 3150 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 || 3151 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 || 3152 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) { 3153 sym_op->cipher.data.length = cipher_len; 3154 sym_op->cipher.data.offset = cipher_offset; 3155 } else { 3156 sym_op->cipher.data.length = cipher_len >> 3; 3157 sym_op->cipher.data.offset = cipher_offset >> 3; 3158 } 3159 3160 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 || 3161 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 || 3162 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) { 3163 sym_op->auth.data.length = auth_len; 3164 sym_op->auth.data.offset = auth_offset; 3165 } else { 3166 sym_op->auth.data.length = auth_len >> 3; 3167 sym_op->auth.data.offset = auth_offset >> 3; 3168 } 3169 3170 return 0; 3171 } 3172 3173 static int 3174 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata) 3175 { 3176 struct crypto_testsuite_params *ts_params = &testsuite_params; 3177 struct crypto_unittest_params *ut_params = &unittest_params; 3178 3179 int retval; 3180 unsigned plaintext_pad_len; 3181 unsigned plaintext_len; 3182 uint8_t *plaintext; 3183 3184 /* Create SNOW 3G session */ 3185 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], 3186 tdata->key.data, tdata->key.len, 3187 tdata->auth_iv.len, tdata->digest.len, 3188 RTE_CRYPTO_AUTH_OP_GENERATE, 3189 RTE_CRYPTO_AUTH_SNOW3G_UIA2); 3190 if (retval < 0) 3191 return retval; 3192 3193 /* alloc mbuf and set payload */ 3194 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3195 3196 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 3197 rte_pktmbuf_tailroom(ut_params->ibuf)); 3198 3199 plaintext_len = ceil_byte_length(tdata->plaintext.len); 3200 /* Append data which is padded to a multiple of */ 3201 /* the algorithms block size */ 3202 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 3203 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 3204 plaintext_pad_len); 3205 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 3206 3207 /* Create SNOW 3G operation */ 3208 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len, 3209 tdata->auth_iv.data, tdata->auth_iv.len, 3210 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, 3211 tdata->validAuthLenInBits.len, 3212 0); 3213 if (retval < 0) 3214 return retval; 3215 3216 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3217 ut_params->op); 3218 ut_params->obuf = ut_params->op->sym->m_src; 3219 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3220 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 3221 + plaintext_pad_len; 3222 3223 /* Validate obuf */ 3224 TEST_ASSERT_BUFFERS_ARE_EQUAL( 3225 ut_params->digest, 3226 tdata->digest.data, 3227 DIGEST_BYTE_LENGTH_SNOW3G_UIA2, 3228 "SNOW 3G Generated auth tag not as expected"); 3229 3230 return 0; 3231 } 3232 3233 static int 3234 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata) 3235 { 3236 struct crypto_testsuite_params *ts_params = &testsuite_params; 3237 struct crypto_unittest_params *ut_params = &unittest_params; 3238 3239 int retval; 3240 unsigned plaintext_pad_len; 3241 unsigned plaintext_len; 3242 uint8_t *plaintext; 3243 3244 /* Create SNOW 3G session */ 3245 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], 3246 tdata->key.data, tdata->key.len, 3247 tdata->auth_iv.len, tdata->digest.len, 3248 RTE_CRYPTO_AUTH_OP_VERIFY, 3249 RTE_CRYPTO_AUTH_SNOW3G_UIA2); 3250 if (retval < 0) 3251 return retval; 3252 /* alloc mbuf and set payload */ 3253 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3254 3255 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 3256 rte_pktmbuf_tailroom(ut_params->ibuf)); 3257 3258 plaintext_len = ceil_byte_length(tdata->plaintext.len); 3259 /* Append data which is padded to a multiple of */ 3260 /* the algorithms block size */ 3261 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 3262 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 3263 plaintext_pad_len); 3264 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 3265 3266 /* Create SNOW 3G operation */ 3267 retval = create_wireless_algo_hash_operation(tdata->digest.data, 3268 tdata->digest.len, 3269 tdata->auth_iv.data, tdata->auth_iv.len, 3270 plaintext_pad_len, 3271 RTE_CRYPTO_AUTH_OP_VERIFY, 3272 tdata->validAuthLenInBits.len, 3273 0); 3274 if (retval < 0) 3275 return retval; 3276 3277 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3278 ut_params->op); 3279 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3280 ut_params->obuf = ut_params->op->sym->m_src; 3281 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 3282 + plaintext_pad_len; 3283 3284 /* Validate obuf */ 3285 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) 3286 return 0; 3287 else 3288 return -1; 3289 3290 return 0; 3291 } 3292 3293 static int 3294 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata) 3295 { 3296 struct crypto_testsuite_params *ts_params = &testsuite_params; 3297 struct crypto_unittest_params *ut_params = &unittest_params; 3298 3299 int retval; 3300 unsigned plaintext_pad_len; 3301 unsigned plaintext_len; 3302 uint8_t *plaintext; 3303 3304 /* Create KASUMI session */ 3305 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], 3306 tdata->key.data, tdata->key.len, 3307 0, tdata->digest.len, 3308 RTE_CRYPTO_AUTH_OP_GENERATE, 3309 RTE_CRYPTO_AUTH_KASUMI_F9); 3310 if (retval < 0) 3311 return retval; 3312 3313 /* alloc mbuf and set payload */ 3314 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3315 3316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 3317 rte_pktmbuf_tailroom(ut_params->ibuf)); 3318 3319 plaintext_len = ceil_byte_length(tdata->plaintext.len); 3320 /* Append data which is padded to a multiple of */ 3321 /* the algorithms block size */ 3322 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 3323 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 3324 plaintext_pad_len); 3325 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 3326 3327 /* Create KASUMI operation */ 3328 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len, 3329 NULL, 0, 3330 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, 3331 tdata->plaintext.len, 3332 0); 3333 if (retval < 0) 3334 return retval; 3335 3336 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3337 ut_params->op); 3338 ut_params->obuf = ut_params->op->sym->m_src; 3339 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3340 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 3341 + plaintext_pad_len; 3342 3343 /* Validate obuf */ 3344 TEST_ASSERT_BUFFERS_ARE_EQUAL( 3345 ut_params->digest, 3346 tdata->digest.data, 3347 DIGEST_BYTE_LENGTH_KASUMI_F9, 3348 "KASUMI Generated auth tag not as expected"); 3349 3350 return 0; 3351 } 3352 3353 static int 3354 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata) 3355 { 3356 struct crypto_testsuite_params *ts_params = &testsuite_params; 3357 struct crypto_unittest_params *ut_params = &unittest_params; 3358 3359 int retval; 3360 unsigned plaintext_pad_len; 3361 unsigned plaintext_len; 3362 uint8_t *plaintext; 3363 3364 /* Create KASUMI session */ 3365 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], 3366 tdata->key.data, tdata->key.len, 3367 0, tdata->digest.len, 3368 RTE_CRYPTO_AUTH_OP_VERIFY, 3369 RTE_CRYPTO_AUTH_KASUMI_F9); 3370 if (retval < 0) 3371 return retval; 3372 /* alloc mbuf and set payload */ 3373 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3374 3375 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 3376 rte_pktmbuf_tailroom(ut_params->ibuf)); 3377 3378 plaintext_len = ceil_byte_length(tdata->plaintext.len); 3379 /* Append data which is padded to a multiple */ 3380 /* of the algorithms block size */ 3381 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 3382 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 3383 plaintext_pad_len); 3384 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 3385 3386 /* Create KASUMI operation */ 3387 retval = create_wireless_algo_hash_operation(tdata->digest.data, 3388 tdata->digest.len, 3389 NULL, 0, 3390 plaintext_pad_len, 3391 RTE_CRYPTO_AUTH_OP_VERIFY, 3392 tdata->plaintext.len, 3393 0); 3394 if (retval < 0) 3395 return retval; 3396 3397 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3398 ut_params->op); 3399 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3400 ut_params->obuf = ut_params->op->sym->m_src; 3401 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 3402 + plaintext_pad_len; 3403 3404 /* Validate obuf */ 3405 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) 3406 return 0; 3407 else 3408 return -1; 3409 3410 return 0; 3411 } 3412 3413 static int 3414 test_snow3g_hash_generate_test_case_1(void) 3415 { 3416 return test_snow3g_authentication(&snow3g_hash_test_case_1); 3417 } 3418 3419 static int 3420 test_snow3g_hash_generate_test_case_2(void) 3421 { 3422 return test_snow3g_authentication(&snow3g_hash_test_case_2); 3423 } 3424 3425 static int 3426 test_snow3g_hash_generate_test_case_3(void) 3427 { 3428 return test_snow3g_authentication(&snow3g_hash_test_case_3); 3429 } 3430 3431 static int 3432 test_snow3g_hash_generate_test_case_4(void) 3433 { 3434 return test_snow3g_authentication(&snow3g_hash_test_case_4); 3435 } 3436 3437 static int 3438 test_snow3g_hash_generate_test_case_5(void) 3439 { 3440 return test_snow3g_authentication(&snow3g_hash_test_case_5); 3441 } 3442 3443 static int 3444 test_snow3g_hash_generate_test_case_6(void) 3445 { 3446 return test_snow3g_authentication(&snow3g_hash_test_case_6); 3447 } 3448 3449 static int 3450 test_snow3g_hash_verify_test_case_1(void) 3451 { 3452 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1); 3453 3454 } 3455 3456 static int 3457 test_snow3g_hash_verify_test_case_2(void) 3458 { 3459 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2); 3460 } 3461 3462 static int 3463 test_snow3g_hash_verify_test_case_3(void) 3464 { 3465 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3); 3466 } 3467 3468 static int 3469 test_snow3g_hash_verify_test_case_4(void) 3470 { 3471 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4); 3472 } 3473 3474 static int 3475 test_snow3g_hash_verify_test_case_5(void) 3476 { 3477 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5); 3478 } 3479 3480 static int 3481 test_snow3g_hash_verify_test_case_6(void) 3482 { 3483 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6); 3484 } 3485 3486 static int 3487 test_kasumi_hash_generate_test_case_1(void) 3488 { 3489 return test_kasumi_authentication(&kasumi_hash_test_case_1); 3490 } 3491 3492 static int 3493 test_kasumi_hash_generate_test_case_2(void) 3494 { 3495 return test_kasumi_authentication(&kasumi_hash_test_case_2); 3496 } 3497 3498 static int 3499 test_kasumi_hash_generate_test_case_3(void) 3500 { 3501 return test_kasumi_authentication(&kasumi_hash_test_case_3); 3502 } 3503 3504 static int 3505 test_kasumi_hash_generate_test_case_4(void) 3506 { 3507 return test_kasumi_authentication(&kasumi_hash_test_case_4); 3508 } 3509 3510 static int 3511 test_kasumi_hash_generate_test_case_5(void) 3512 { 3513 return test_kasumi_authentication(&kasumi_hash_test_case_5); 3514 } 3515 3516 static int 3517 test_kasumi_hash_generate_test_case_6(void) 3518 { 3519 return test_kasumi_authentication(&kasumi_hash_test_case_6); 3520 } 3521 3522 static int 3523 test_kasumi_hash_verify_test_case_1(void) 3524 { 3525 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1); 3526 } 3527 3528 static int 3529 test_kasumi_hash_verify_test_case_2(void) 3530 { 3531 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2); 3532 } 3533 3534 static int 3535 test_kasumi_hash_verify_test_case_3(void) 3536 { 3537 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3); 3538 } 3539 3540 static int 3541 test_kasumi_hash_verify_test_case_4(void) 3542 { 3543 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4); 3544 } 3545 3546 static int 3547 test_kasumi_hash_verify_test_case_5(void) 3548 { 3549 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5); 3550 } 3551 3552 static int 3553 test_kasumi_encryption(const struct kasumi_test_data *tdata) 3554 { 3555 struct crypto_testsuite_params *ts_params = &testsuite_params; 3556 struct crypto_unittest_params *ut_params = &unittest_params; 3557 3558 int retval; 3559 uint8_t *plaintext, *ciphertext; 3560 unsigned plaintext_pad_len; 3561 unsigned plaintext_len; 3562 3563 /* Create KASUMI session */ 3564 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 3565 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 3566 RTE_CRYPTO_CIPHER_KASUMI_F8, 3567 tdata->key.data, tdata->key.len, 3568 tdata->cipher_iv.len); 3569 if (retval < 0) 3570 return retval; 3571 3572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3573 3574 /* Clear mbuf payload */ 3575 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 3576 rte_pktmbuf_tailroom(ut_params->ibuf)); 3577 3578 plaintext_len = ceil_byte_length(tdata->plaintext.len); 3579 /* Append data which is padded to a multiple */ 3580 /* of the algorithms block size */ 3581 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 3582 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 3583 plaintext_pad_len); 3584 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 3585 3586 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 3587 3588 /* Create KASUMI operation */ 3589 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, 3590 tdata->cipher_iv.len, 3591 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), 3592 tdata->validCipherOffsetInBits.len); 3593 if (retval < 0) 3594 return retval; 3595 3596 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3597 ut_params->op); 3598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3599 3600 ut_params->obuf = ut_params->op->sym->m_dst; 3601 if (ut_params->obuf) 3602 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 3603 else 3604 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3); 3605 3606 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 3607 3608 const uint8_t *reference_ciphertext = tdata->ciphertext.data + 3609 (tdata->validCipherOffsetInBits.len >> 3); 3610 /* Validate obuf */ 3611 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 3612 ciphertext, 3613 reference_ciphertext, 3614 tdata->validCipherLenInBits.len, 3615 "KASUMI Ciphertext data not as expected"); 3616 return 0; 3617 } 3618 3619 static int 3620 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata) 3621 { 3622 struct crypto_testsuite_params *ts_params = &testsuite_params; 3623 struct crypto_unittest_params *ut_params = &unittest_params; 3624 3625 int retval; 3626 3627 unsigned int plaintext_pad_len; 3628 unsigned int plaintext_len; 3629 3630 uint8_t buffer[10000]; 3631 const uint8_t *ciphertext; 3632 3633 struct rte_cryptodev_info dev_info; 3634 3635 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 3636 3637 uint64_t feat_flags = dev_info.feature_flags; 3638 3639 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { 3640 printf("Device doesn't support in-place scatter-gather. " 3641 "Test Skipped.\n"); 3642 return -ENOTSUP; 3643 } 3644 3645 /* Create KASUMI session */ 3646 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 3647 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 3648 RTE_CRYPTO_CIPHER_KASUMI_F8, 3649 tdata->key.data, tdata->key.len, 3650 tdata->cipher_iv.len); 3651 if (retval < 0) 3652 return retval; 3653 3654 plaintext_len = ceil_byte_length(tdata->plaintext.len); 3655 3656 3657 /* Append data which is padded to a multiple */ 3658 /* of the algorithms block size */ 3659 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 3660 3661 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, 3662 plaintext_pad_len, 10, 0); 3663 3664 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data); 3665 3666 /* Create KASUMI operation */ 3667 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, 3668 tdata->cipher_iv.len, 3669 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), 3670 tdata->validCipherOffsetInBits.len); 3671 if (retval < 0) 3672 return retval; 3673 3674 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3675 ut_params->op); 3676 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3677 3678 ut_params->obuf = ut_params->op->sym->m_dst; 3679 3680 if (ut_params->obuf) 3681 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, 3682 plaintext_len, buffer); 3683 else 3684 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 3685 tdata->validCipherOffsetInBits.len >> 3, 3686 plaintext_len, buffer); 3687 3688 /* Validate obuf */ 3689 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 3690 3691 const uint8_t *reference_ciphertext = tdata->ciphertext.data + 3692 (tdata->validCipherOffsetInBits.len >> 3); 3693 /* Validate obuf */ 3694 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 3695 ciphertext, 3696 reference_ciphertext, 3697 tdata->validCipherLenInBits.len, 3698 "KASUMI Ciphertext data not as expected"); 3699 return 0; 3700 } 3701 3702 static int 3703 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata) 3704 { 3705 struct crypto_testsuite_params *ts_params = &testsuite_params; 3706 struct crypto_unittest_params *ut_params = &unittest_params; 3707 3708 int retval; 3709 uint8_t *plaintext, *ciphertext; 3710 unsigned plaintext_pad_len; 3711 unsigned plaintext_len; 3712 3713 /* Create KASUMI session */ 3714 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 3715 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 3716 RTE_CRYPTO_CIPHER_KASUMI_F8, 3717 tdata->key.data, tdata->key.len, 3718 tdata->cipher_iv.len); 3719 if (retval < 0) 3720 return retval; 3721 3722 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3723 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3724 3725 /* Clear mbuf payload */ 3726 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 3727 rte_pktmbuf_tailroom(ut_params->ibuf)); 3728 3729 plaintext_len = ceil_byte_length(tdata->plaintext.len); 3730 /* Append data which is padded to a multiple */ 3731 /* of the algorithms block size */ 3732 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 3733 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 3734 plaintext_pad_len); 3735 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); 3736 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 3737 3738 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 3739 3740 /* Create KASUMI operation */ 3741 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, 3742 tdata->cipher_iv.len, 3743 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), 3744 tdata->validCipherOffsetInBits.len); 3745 if (retval < 0) 3746 return retval; 3747 3748 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3749 ut_params->op); 3750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3751 3752 ut_params->obuf = ut_params->op->sym->m_dst; 3753 if (ut_params->obuf) 3754 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 3755 else 3756 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3); 3757 3758 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 3759 3760 const uint8_t *reference_ciphertext = tdata->ciphertext.data + 3761 (tdata->validCipherOffsetInBits.len >> 3); 3762 /* Validate obuf */ 3763 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 3764 ciphertext, 3765 reference_ciphertext, 3766 tdata->validCipherLenInBits.len, 3767 "KASUMI Ciphertext data not as expected"); 3768 return 0; 3769 } 3770 3771 static int 3772 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata) 3773 { 3774 struct crypto_testsuite_params *ts_params = &testsuite_params; 3775 struct crypto_unittest_params *ut_params = &unittest_params; 3776 3777 int retval; 3778 unsigned int plaintext_pad_len; 3779 unsigned int plaintext_len; 3780 3781 const uint8_t *ciphertext; 3782 uint8_t buffer[2048]; 3783 3784 struct rte_cryptodev_info dev_info; 3785 3786 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 3787 3788 uint64_t feat_flags = dev_info.feature_flags; 3789 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { 3790 printf("Device doesn't support out-of-place scatter-gather " 3791 "in both input and output mbufs. " 3792 "Test Skipped.\n"); 3793 return -ENOTSUP; 3794 } 3795 3796 /* Create KASUMI session */ 3797 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 3798 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 3799 RTE_CRYPTO_CIPHER_KASUMI_F8, 3800 tdata->key.data, tdata->key.len, 3801 tdata->cipher_iv.len); 3802 if (retval < 0) 3803 return retval; 3804 3805 plaintext_len = ceil_byte_length(tdata->plaintext.len); 3806 /* Append data which is padded to a multiple */ 3807 /* of the algorithms block size */ 3808 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 3809 3810 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, 3811 plaintext_pad_len, 10, 0); 3812 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool, 3813 plaintext_pad_len, 3, 0); 3814 3815 /* Append data which is padded to a multiple */ 3816 /* of the algorithms block size */ 3817 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data); 3818 3819 /* Create KASUMI operation */ 3820 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, 3821 tdata->cipher_iv.len, 3822 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), 3823 tdata->validCipherOffsetInBits.len); 3824 if (retval < 0) 3825 return retval; 3826 3827 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3828 ut_params->op); 3829 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3830 3831 ut_params->obuf = ut_params->op->sym->m_dst; 3832 if (ut_params->obuf) 3833 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, 3834 plaintext_pad_len, buffer); 3835 else 3836 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 3837 tdata->validCipherOffsetInBits.len >> 3, 3838 plaintext_pad_len, buffer); 3839 3840 const uint8_t *reference_ciphertext = tdata->ciphertext.data + 3841 (tdata->validCipherOffsetInBits.len >> 3); 3842 /* Validate obuf */ 3843 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 3844 ciphertext, 3845 reference_ciphertext, 3846 tdata->validCipherLenInBits.len, 3847 "KASUMI Ciphertext data not as expected"); 3848 return 0; 3849 } 3850 3851 3852 static int 3853 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata) 3854 { 3855 struct crypto_testsuite_params *ts_params = &testsuite_params; 3856 struct crypto_unittest_params *ut_params = &unittest_params; 3857 3858 int retval; 3859 uint8_t *ciphertext, *plaintext; 3860 unsigned ciphertext_pad_len; 3861 unsigned ciphertext_len; 3862 3863 /* Create KASUMI session */ 3864 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 3865 RTE_CRYPTO_CIPHER_OP_DECRYPT, 3866 RTE_CRYPTO_CIPHER_KASUMI_F8, 3867 tdata->key.data, tdata->key.len, 3868 tdata->cipher_iv.len); 3869 if (retval < 0) 3870 return retval; 3871 3872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3873 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3874 3875 /* Clear mbuf payload */ 3876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 3877 rte_pktmbuf_tailroom(ut_params->ibuf)); 3878 3879 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 3880 /* Append data which is padded to a multiple */ 3881 /* of the algorithms block size */ 3882 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8); 3883 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 3884 ciphertext_pad_len); 3885 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); 3886 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); 3887 3888 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); 3889 3890 /* Create KASUMI operation */ 3891 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, 3892 tdata->cipher_iv.len, 3893 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), 3894 tdata->validCipherOffsetInBits.len); 3895 if (retval < 0) 3896 return retval; 3897 3898 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3899 ut_params->op); 3900 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3901 3902 ut_params->obuf = ut_params->op->sym->m_dst; 3903 if (ut_params->obuf) 3904 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 3905 else 3906 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3); 3907 3908 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len); 3909 3910 const uint8_t *reference_plaintext = tdata->plaintext.data + 3911 (tdata->validCipherOffsetInBits.len >> 3); 3912 /* Validate obuf */ 3913 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 3914 plaintext, 3915 reference_plaintext, 3916 tdata->validCipherLenInBits.len, 3917 "KASUMI Plaintext data not as expected"); 3918 return 0; 3919 } 3920 3921 static int 3922 test_kasumi_decryption(const struct kasumi_test_data *tdata) 3923 { 3924 struct crypto_testsuite_params *ts_params = &testsuite_params; 3925 struct crypto_unittest_params *ut_params = &unittest_params; 3926 3927 int retval; 3928 uint8_t *ciphertext, *plaintext; 3929 unsigned ciphertext_pad_len; 3930 unsigned ciphertext_len; 3931 3932 /* Create KASUMI session */ 3933 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 3934 RTE_CRYPTO_CIPHER_OP_DECRYPT, 3935 RTE_CRYPTO_CIPHER_KASUMI_F8, 3936 tdata->key.data, tdata->key.len, 3937 tdata->cipher_iv.len); 3938 if (retval < 0) 3939 return retval; 3940 3941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 3942 3943 /* Clear mbuf payload */ 3944 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 3945 rte_pktmbuf_tailroom(ut_params->ibuf)); 3946 3947 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 3948 /* Append data which is padded to a multiple */ 3949 /* of the algorithms block size */ 3950 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8); 3951 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 3952 ciphertext_pad_len); 3953 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); 3954 3955 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); 3956 3957 /* Create KASUMI operation */ 3958 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, 3959 tdata->cipher_iv.len, 3960 tdata->ciphertext.len, 3961 tdata->validCipherOffsetInBits.len); 3962 if (retval < 0) 3963 return retval; 3964 3965 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 3966 ut_params->op); 3967 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 3968 3969 ut_params->obuf = ut_params->op->sym->m_dst; 3970 if (ut_params->obuf) 3971 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 3972 else 3973 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3); 3974 3975 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len); 3976 3977 const uint8_t *reference_plaintext = tdata->plaintext.data + 3978 (tdata->validCipherOffsetInBits.len >> 3); 3979 /* Validate obuf */ 3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 3981 plaintext, 3982 reference_plaintext, 3983 tdata->validCipherLenInBits.len, 3984 "KASUMI Plaintext data not as expected"); 3985 return 0; 3986 } 3987 3988 static int 3989 test_snow3g_encryption(const struct snow3g_test_data *tdata) 3990 { 3991 struct crypto_testsuite_params *ts_params = &testsuite_params; 3992 struct crypto_unittest_params *ut_params = &unittest_params; 3993 3994 int retval; 3995 uint8_t *plaintext, *ciphertext; 3996 unsigned plaintext_pad_len; 3997 unsigned plaintext_len; 3998 3999 /* Create SNOW 3G session */ 4000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 4001 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 4002 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4003 tdata->key.data, tdata->key.len, 4004 tdata->cipher_iv.len); 4005 if (retval < 0) 4006 return retval; 4007 4008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4009 4010 /* Clear mbuf payload */ 4011 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 4012 rte_pktmbuf_tailroom(ut_params->ibuf)); 4013 4014 plaintext_len = ceil_byte_length(tdata->plaintext.len); 4015 /* Append data which is padded to a multiple of */ 4016 /* the algorithms block size */ 4017 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 4018 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 4019 plaintext_pad_len); 4020 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 4021 4022 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 4023 4024 /* Create SNOW 3G operation */ 4025 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, 4026 tdata->cipher_iv.len, 4027 tdata->validCipherLenInBits.len, 4028 0); 4029 if (retval < 0) 4030 return retval; 4031 4032 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4033 ut_params->op); 4034 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4035 4036 ut_params->obuf = ut_params->op->sym->m_dst; 4037 if (ut_params->obuf) 4038 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 4039 else 4040 ciphertext = plaintext; 4041 4042 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 4043 4044 /* Validate obuf */ 4045 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4046 ciphertext, 4047 tdata->ciphertext.data, 4048 tdata->validDataLenInBits.len, 4049 "SNOW 3G Ciphertext data not as expected"); 4050 return 0; 4051 } 4052 4053 4054 static int 4055 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata) 4056 { 4057 struct crypto_testsuite_params *ts_params = &testsuite_params; 4058 struct crypto_unittest_params *ut_params = &unittest_params; 4059 uint8_t *plaintext, *ciphertext; 4060 4061 int retval; 4062 unsigned plaintext_pad_len; 4063 unsigned plaintext_len; 4064 4065 /* Create SNOW 3G session */ 4066 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 4067 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 4068 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4069 tdata->key.data, tdata->key.len, 4070 tdata->cipher_iv.len); 4071 if (retval < 0) 4072 return retval; 4073 4074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4075 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4076 4077 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 4078 "Failed to allocate input buffer in mempool"); 4079 TEST_ASSERT_NOT_NULL(ut_params->obuf, 4080 "Failed to allocate output buffer in mempool"); 4081 4082 /* Clear mbuf payload */ 4083 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 4084 rte_pktmbuf_tailroom(ut_params->ibuf)); 4085 4086 plaintext_len = ceil_byte_length(tdata->plaintext.len); 4087 /* Append data which is padded to a multiple of */ 4088 /* the algorithms block size */ 4089 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 4090 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 4091 plaintext_pad_len); 4092 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); 4093 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 4094 4095 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 4096 4097 /* Create SNOW 3G operation */ 4098 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, 4099 tdata->cipher_iv.len, 4100 tdata->validCipherLenInBits.len, 4101 0); 4102 if (retval < 0) 4103 return retval; 4104 4105 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4106 ut_params->op); 4107 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4108 4109 ut_params->obuf = ut_params->op->sym->m_dst; 4110 if (ut_params->obuf) 4111 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 4112 else 4113 ciphertext = plaintext; 4114 4115 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 4116 4117 /* Validate obuf */ 4118 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4119 ciphertext, 4120 tdata->ciphertext.data, 4121 tdata->validDataLenInBits.len, 4122 "SNOW 3G Ciphertext data not as expected"); 4123 return 0; 4124 } 4125 4126 static int 4127 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata) 4128 { 4129 struct crypto_testsuite_params *ts_params = &testsuite_params; 4130 struct crypto_unittest_params *ut_params = &unittest_params; 4131 4132 int retval; 4133 unsigned int plaintext_pad_len; 4134 unsigned int plaintext_len; 4135 uint8_t buffer[10000]; 4136 const uint8_t *ciphertext; 4137 4138 struct rte_cryptodev_info dev_info; 4139 4140 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 4141 4142 uint64_t feat_flags = dev_info.feature_flags; 4143 4144 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { 4145 printf("Device doesn't support out-of-place scatter-gather " 4146 "in both input and output mbufs. " 4147 "Test Skipped.\n"); 4148 return -ENOTSUP; 4149 } 4150 4151 /* Create SNOW 3G session */ 4152 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 4153 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 4154 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4155 tdata->key.data, tdata->key.len, 4156 tdata->cipher_iv.len); 4157 if (retval < 0) 4158 return retval; 4159 4160 plaintext_len = ceil_byte_length(tdata->plaintext.len); 4161 /* Append data which is padded to a multiple of */ 4162 /* the algorithms block size */ 4163 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 4164 4165 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, 4166 plaintext_pad_len, 10, 0); 4167 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool, 4168 plaintext_pad_len, 3, 0); 4169 4170 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 4171 "Failed to allocate input buffer in mempool"); 4172 TEST_ASSERT_NOT_NULL(ut_params->obuf, 4173 "Failed to allocate output buffer in mempool"); 4174 4175 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data); 4176 4177 /* Create SNOW 3G operation */ 4178 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, 4179 tdata->cipher_iv.len, 4180 tdata->validCipherLenInBits.len, 4181 0); 4182 if (retval < 0) 4183 return retval; 4184 4185 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4186 ut_params->op); 4187 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4188 4189 ut_params->obuf = ut_params->op->sym->m_dst; 4190 if (ut_params->obuf) 4191 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, 4192 plaintext_len, buffer); 4193 else 4194 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 4195 plaintext_len, buffer); 4196 4197 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 4198 4199 /* Validate obuf */ 4200 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4201 ciphertext, 4202 tdata->ciphertext.data, 4203 tdata->validDataLenInBits.len, 4204 "SNOW 3G Ciphertext data not as expected"); 4205 4206 return 0; 4207 } 4208 4209 /* Shift right a buffer by "offset" bits, "offset" < 8 */ 4210 static void 4211 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset) 4212 { 4213 uint8_t curr_byte, prev_byte; 4214 uint32_t length_in_bytes = ceil_byte_length(length + offset); 4215 uint8_t lower_byte_mask = (1 << offset) - 1; 4216 unsigned i; 4217 4218 prev_byte = buffer[0]; 4219 buffer[0] >>= offset; 4220 4221 for (i = 1; i < length_in_bytes; i++) { 4222 curr_byte = buffer[i]; 4223 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) | 4224 (curr_byte >> offset); 4225 prev_byte = curr_byte; 4226 } 4227 } 4228 4229 static int 4230 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata) 4231 { 4232 struct crypto_testsuite_params *ts_params = &testsuite_params; 4233 struct crypto_unittest_params *ut_params = &unittest_params; 4234 uint8_t *plaintext, *ciphertext; 4235 int retval; 4236 uint32_t plaintext_len; 4237 uint32_t plaintext_pad_len; 4238 uint8_t extra_offset = 4; 4239 uint8_t *expected_ciphertext_shifted; 4240 4241 /* Create SNOW 3G session */ 4242 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 4243 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 4244 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4245 tdata->key.data, tdata->key.len, 4246 tdata->cipher_iv.len); 4247 if (retval < 0) 4248 return retval; 4249 4250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4251 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4252 4253 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 4254 "Failed to allocate input buffer in mempool"); 4255 TEST_ASSERT_NOT_NULL(ut_params->obuf, 4256 "Failed to allocate output buffer in mempool"); 4257 4258 /* Clear mbuf payload */ 4259 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 4260 rte_pktmbuf_tailroom(ut_params->ibuf)); 4261 4262 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset); 4263 /* 4264 * Append data which is padded to a 4265 * multiple of the algorithms block size 4266 */ 4267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 4268 4269 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf, 4270 plaintext_pad_len); 4271 4272 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); 4273 4274 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3)); 4275 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset); 4276 4277 #ifdef RTE_APP_TEST_DEBUG 4278 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len); 4279 #endif 4280 /* Create SNOW 3G operation */ 4281 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, 4282 tdata->cipher_iv.len, 4283 tdata->validCipherLenInBits.len, 4284 extra_offset); 4285 if (retval < 0) 4286 return retval; 4287 4288 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4289 ut_params->op); 4290 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4291 4292 ut_params->obuf = ut_params->op->sym->m_dst; 4293 if (ut_params->obuf) 4294 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 4295 else 4296 ciphertext = plaintext; 4297 4298 #ifdef RTE_APP_TEST_DEBUG 4299 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 4300 #endif 4301 4302 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8); 4303 4304 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted, 4305 "failed to reserve memory for ciphertext shifted\n"); 4306 4307 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data, 4308 ceil_byte_length(tdata->ciphertext.len)); 4309 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len, 4310 extra_offset); 4311 /* Validate obuf */ 4312 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET( 4313 ciphertext, 4314 expected_ciphertext_shifted, 4315 tdata->validDataLenInBits.len, 4316 extra_offset, 4317 "SNOW 3G Ciphertext data not as expected"); 4318 return 0; 4319 } 4320 4321 static int test_snow3g_decryption(const struct snow3g_test_data *tdata) 4322 { 4323 struct crypto_testsuite_params *ts_params = &testsuite_params; 4324 struct crypto_unittest_params *ut_params = &unittest_params; 4325 4326 int retval; 4327 4328 uint8_t *plaintext, *ciphertext; 4329 unsigned ciphertext_pad_len; 4330 unsigned ciphertext_len; 4331 4332 /* Create SNOW 3G session */ 4333 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 4334 RTE_CRYPTO_CIPHER_OP_DECRYPT, 4335 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4336 tdata->key.data, tdata->key.len, 4337 tdata->cipher_iv.len); 4338 if (retval < 0) 4339 return retval; 4340 4341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4342 4343 /* Clear mbuf payload */ 4344 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 4345 rte_pktmbuf_tailroom(ut_params->ibuf)); 4346 4347 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 4348 /* Append data which is padded to a multiple of */ 4349 /* the algorithms block size */ 4350 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 4351 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 4352 ciphertext_pad_len); 4353 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); 4354 4355 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); 4356 4357 /* Create SNOW 3G operation */ 4358 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, 4359 tdata->cipher_iv.len, 4360 tdata->validCipherLenInBits.len, 4361 tdata->cipher.offset_bits); 4362 if (retval < 0) 4363 return retval; 4364 4365 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4366 ut_params->op); 4367 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4368 ut_params->obuf = ut_params->op->sym->m_dst; 4369 if (ut_params->obuf) 4370 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 4371 else 4372 plaintext = ciphertext; 4373 4374 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len); 4375 4376 /* Validate obuf */ 4377 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, 4378 tdata->plaintext.data, 4379 tdata->validDataLenInBits.len, 4380 "SNOW 3G Plaintext data not as expected"); 4381 return 0; 4382 } 4383 4384 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata) 4385 { 4386 struct crypto_testsuite_params *ts_params = &testsuite_params; 4387 struct crypto_unittest_params *ut_params = &unittest_params; 4388 4389 int retval; 4390 4391 uint8_t *plaintext, *ciphertext; 4392 unsigned ciphertext_pad_len; 4393 unsigned ciphertext_len; 4394 4395 /* Create SNOW 3G session */ 4396 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 4397 RTE_CRYPTO_CIPHER_OP_DECRYPT, 4398 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4399 tdata->key.data, tdata->key.len, 4400 tdata->cipher_iv.len); 4401 if (retval < 0) 4402 return retval; 4403 4404 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4405 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4406 4407 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 4408 "Failed to allocate input buffer"); 4409 TEST_ASSERT_NOT_NULL(ut_params->obuf, 4410 "Failed to allocate output buffer"); 4411 4412 /* Clear mbuf payload */ 4413 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 4414 rte_pktmbuf_tailroom(ut_params->ibuf)); 4415 4416 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, 4417 rte_pktmbuf_tailroom(ut_params->obuf)); 4418 4419 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 4420 /* Append data which is padded to a multiple of */ 4421 /* the algorithms block size */ 4422 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 4423 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 4424 ciphertext_pad_len); 4425 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); 4426 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); 4427 4428 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); 4429 4430 /* Create SNOW 3G operation */ 4431 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data, 4432 tdata->cipher_iv.len, 4433 tdata->validCipherLenInBits.len, 4434 0); 4435 if (retval < 0) 4436 return retval; 4437 4438 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4439 ut_params->op); 4440 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4441 ut_params->obuf = ut_params->op->sym->m_dst; 4442 if (ut_params->obuf) 4443 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 4444 else 4445 plaintext = ciphertext; 4446 4447 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len); 4448 4449 /* Validate obuf */ 4450 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext, 4451 tdata->plaintext.data, 4452 tdata->validDataLenInBits.len, 4453 "SNOW 3G Plaintext data not as expected"); 4454 return 0; 4455 } 4456 4457 static int 4458 test_zuc_cipher_auth(const struct wireless_test_data *tdata) 4459 { 4460 struct crypto_testsuite_params *ts_params = &testsuite_params; 4461 struct crypto_unittest_params *ut_params = &unittest_params; 4462 4463 int retval; 4464 4465 uint8_t *plaintext, *ciphertext; 4466 unsigned int plaintext_pad_len; 4467 unsigned int plaintext_len; 4468 4469 struct rte_cryptodev_sym_capability_idx cap_idx; 4470 4471 /* Check if device supports ZUC EEA3 */ 4472 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 4473 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3; 4474 4475 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], 4476 &cap_idx) == NULL) 4477 return -ENOTSUP; 4478 4479 /* Check if device supports ZUC EIA3 */ 4480 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; 4481 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3; 4482 4483 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], 4484 &cap_idx) == NULL) 4485 return -ENOTSUP; 4486 4487 /* Create ZUC session */ 4488 retval = create_zuc_cipher_auth_encrypt_generate_session( 4489 ts_params->valid_devs[0], 4490 tdata); 4491 if (retval < 0) 4492 return retval; 4493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4494 4495 /* clear mbuf payload */ 4496 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 4497 rte_pktmbuf_tailroom(ut_params->ibuf)); 4498 4499 plaintext_len = ceil_byte_length(tdata->plaintext.len); 4500 /* Append data which is padded to a multiple of */ 4501 /* the algorithms block size */ 4502 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 4503 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 4504 plaintext_pad_len); 4505 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 4506 4507 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 4508 4509 /* Create ZUC operation */ 4510 retval = create_zuc_cipher_hash_generate_operation(tdata); 4511 if (retval < 0) 4512 return retval; 4513 4514 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4515 ut_params->op); 4516 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4517 ut_params->obuf = ut_params->op->sym->m_src; 4518 if (ut_params->obuf) 4519 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 4520 else 4521 ciphertext = plaintext; 4522 4523 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 4524 /* Validate obuf */ 4525 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4526 ciphertext, 4527 tdata->ciphertext.data, 4528 tdata->validDataLenInBits.len, 4529 "ZUC Ciphertext data not as expected"); 4530 4531 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 4532 + plaintext_pad_len; 4533 4534 /* Validate obuf */ 4535 TEST_ASSERT_BUFFERS_ARE_EQUAL( 4536 ut_params->digest, 4537 tdata->digest.data, 4538 4, 4539 "ZUC Generated auth tag not as expected"); 4540 return 0; 4541 } 4542 4543 static int 4544 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata) 4545 { 4546 struct crypto_testsuite_params *ts_params = &testsuite_params; 4547 struct crypto_unittest_params *ut_params = &unittest_params; 4548 4549 int retval; 4550 4551 uint8_t *plaintext, *ciphertext; 4552 unsigned plaintext_pad_len; 4553 unsigned plaintext_len; 4554 4555 /* Create SNOW 3G session */ 4556 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0], 4557 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 4558 RTE_CRYPTO_AUTH_OP_GENERATE, 4559 RTE_CRYPTO_AUTH_SNOW3G_UIA2, 4560 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4561 tdata->key.data, tdata->key.len, 4562 tdata->auth_iv.len, tdata->digest.len, 4563 tdata->cipher_iv.len); 4564 if (retval < 0) 4565 return retval; 4566 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4567 4568 /* clear mbuf payload */ 4569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 4570 rte_pktmbuf_tailroom(ut_params->ibuf)); 4571 4572 plaintext_len = ceil_byte_length(tdata->plaintext.len); 4573 /* Append data which is padded to a multiple of */ 4574 /* the algorithms block size */ 4575 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 4576 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 4577 plaintext_pad_len); 4578 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 4579 4580 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 4581 4582 /* Create SNOW 3G operation */ 4583 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data, 4584 tdata->digest.len, tdata->auth_iv.data, 4585 tdata->auth_iv.len, 4586 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, 4587 tdata->cipher_iv.data, tdata->cipher_iv.len, 4588 tdata->validCipherLenInBits.len, 4589 0, 4590 tdata->validAuthLenInBits.len, 4591 0 4592 ); 4593 if (retval < 0) 4594 return retval; 4595 4596 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4597 ut_params->op); 4598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4599 ut_params->obuf = ut_params->op->sym->m_src; 4600 if (ut_params->obuf) 4601 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 4602 else 4603 ciphertext = plaintext; 4604 4605 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 4606 /* Validate obuf */ 4607 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4608 ciphertext, 4609 tdata->ciphertext.data, 4610 tdata->validDataLenInBits.len, 4611 "SNOW 3G Ciphertext data not as expected"); 4612 4613 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 4614 + plaintext_pad_len; 4615 4616 /* Validate obuf */ 4617 TEST_ASSERT_BUFFERS_ARE_EQUAL( 4618 ut_params->digest, 4619 tdata->digest.data, 4620 DIGEST_BYTE_LENGTH_SNOW3G_UIA2, 4621 "SNOW 3G Generated auth tag not as expected"); 4622 return 0; 4623 } 4624 4625 static int 4626 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata, 4627 uint8_t op_mode, uint8_t verify) 4628 { 4629 struct crypto_testsuite_params *ts_params = &testsuite_params; 4630 struct crypto_unittest_params *ut_params = &unittest_params; 4631 4632 int retval; 4633 4634 uint8_t *plaintext = NULL, *ciphertext = NULL; 4635 unsigned int plaintext_pad_len; 4636 unsigned int plaintext_len; 4637 unsigned int ciphertext_pad_len; 4638 unsigned int ciphertext_len; 4639 4640 struct rte_cryptodev_info dev_info; 4641 4642 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 4643 4644 uint64_t feat_flags = dev_info.feature_flags; 4645 4646 if (op_mode == OUT_OF_PLACE) { 4647 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { 4648 printf("Device doesn't support digest encrypted.\n"); 4649 return -ENOTSUP; 4650 } 4651 } 4652 4653 /* Create SNOW 3G session */ 4654 retval = create_wireless_algo_auth_cipher_session( 4655 ts_params->valid_devs[0], 4656 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT 4657 : RTE_CRYPTO_CIPHER_OP_ENCRYPT), 4658 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY 4659 : RTE_CRYPTO_AUTH_OP_GENERATE), 4660 RTE_CRYPTO_AUTH_SNOW3G_UIA2, 4661 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4662 tdata->key.data, tdata->key.len, 4663 tdata->auth_iv.len, tdata->digest.len, 4664 tdata->cipher_iv.len); 4665 4666 if (retval < 0) 4667 return retval; 4668 4669 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4670 if (op_mode == OUT_OF_PLACE) 4671 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 4672 4673 /* clear mbuf payload */ 4674 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 4675 rte_pktmbuf_tailroom(ut_params->ibuf)); 4676 if (op_mode == OUT_OF_PLACE) 4677 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, 4678 rte_pktmbuf_tailroom(ut_params->obuf)); 4679 4680 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 4681 plaintext_len = ceil_byte_length(tdata->plaintext.len); 4682 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 4683 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 4684 4685 if (verify) { 4686 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 4687 ciphertext_pad_len); 4688 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); 4689 if (op_mode == OUT_OF_PLACE) 4690 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); 4691 debug_hexdump(stdout, "ciphertext:", ciphertext, 4692 ciphertext_len); 4693 } else { 4694 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 4695 plaintext_pad_len); 4696 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 4697 if (op_mode == OUT_OF_PLACE) 4698 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); 4699 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 4700 } 4701 4702 /* Create SNOW 3G operation */ 4703 retval = create_wireless_algo_auth_cipher_operation( 4704 tdata->digest.data, tdata->digest.len, 4705 tdata->cipher_iv.data, tdata->cipher_iv.len, 4706 tdata->auth_iv.data, tdata->auth_iv.len, 4707 (tdata->digest.offset_bytes == 0 ? 4708 (verify ? ciphertext_pad_len : plaintext_pad_len) 4709 : tdata->digest.offset_bytes), 4710 tdata->validCipherLenInBits.len, 4711 tdata->cipher.offset_bits, 4712 tdata->validAuthLenInBits.len, 4713 tdata->auth.offset_bits, 4714 op_mode, 0, verify); 4715 4716 if (retval < 0) 4717 return retval; 4718 4719 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4720 ut_params->op); 4721 4722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4723 4724 ut_params->obuf = (op_mode == IN_PLACE ? 4725 ut_params->op->sym->m_src : ut_params->op->sym->m_dst); 4726 4727 if (verify) { 4728 if (ut_params->obuf) 4729 plaintext = rte_pktmbuf_mtod(ut_params->obuf, 4730 uint8_t *); 4731 else 4732 plaintext = ciphertext + 4733 (tdata->cipher.offset_bits >> 3); 4734 4735 debug_hexdump(stdout, "plaintext:", plaintext, 4736 (tdata->plaintext.len >> 3) - tdata->digest.len); 4737 debug_hexdump(stdout, "plaintext expected:", 4738 tdata->plaintext.data, 4739 (tdata->plaintext.len >> 3) - tdata->digest.len); 4740 } else { 4741 if (ut_params->obuf) 4742 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, 4743 uint8_t *); 4744 else 4745 ciphertext = plaintext; 4746 4747 debug_hexdump(stdout, "ciphertext:", ciphertext, 4748 ciphertext_len); 4749 debug_hexdump(stdout, "ciphertext expected:", 4750 tdata->ciphertext.data, tdata->ciphertext.len >> 3); 4751 4752 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 4753 + (tdata->digest.offset_bytes == 0 ? 4754 plaintext_pad_len : tdata->digest.offset_bytes); 4755 4756 debug_hexdump(stdout, "digest:", ut_params->digest, 4757 tdata->digest.len); 4758 debug_hexdump(stdout, "digest expected:", tdata->digest.data, 4759 tdata->digest.len); 4760 } 4761 4762 /* Validate obuf */ 4763 if (verify) { 4764 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4765 plaintext, 4766 tdata->plaintext.data, 4767 tdata->plaintext.len >> 3, 4768 "SNOW 3G Plaintext data not as expected"); 4769 } else { 4770 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4771 ciphertext, 4772 tdata->ciphertext.data, 4773 tdata->validDataLenInBits.len, 4774 "SNOW 3G Ciphertext data not as expected"); 4775 4776 TEST_ASSERT_BUFFERS_ARE_EQUAL( 4777 ut_params->digest, 4778 tdata->digest.data, 4779 DIGEST_BYTE_LENGTH_SNOW3G_UIA2, 4780 "SNOW 3G Generated auth tag not as expected"); 4781 } 4782 return 0; 4783 } 4784 4785 static int 4786 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata, 4787 uint8_t op_mode, uint8_t verify) 4788 { 4789 struct crypto_testsuite_params *ts_params = &testsuite_params; 4790 struct crypto_unittest_params *ut_params = &unittest_params; 4791 4792 int retval; 4793 4794 const uint8_t *plaintext = NULL; 4795 const uint8_t *ciphertext = NULL; 4796 const uint8_t *digest = NULL; 4797 unsigned int plaintext_pad_len; 4798 unsigned int plaintext_len; 4799 unsigned int ciphertext_pad_len; 4800 unsigned int ciphertext_len; 4801 uint8_t buffer[10000]; 4802 uint8_t digest_buffer[10000]; 4803 4804 struct rte_cryptodev_info dev_info; 4805 4806 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 4807 4808 uint64_t feat_flags = dev_info.feature_flags; 4809 4810 if (op_mode == IN_PLACE) { 4811 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { 4812 printf("Device doesn't support in-place scatter-gather " 4813 "in both input and output mbufs.\n"); 4814 return -ENOTSUP; 4815 } 4816 } else { 4817 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { 4818 printf("Device doesn't support out-of-place scatter-gather " 4819 "in both input and output mbufs.\n"); 4820 return -ENOTSUP; 4821 } 4822 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { 4823 printf("Device doesn't support digest encrypted.\n"); 4824 return -ENOTSUP; 4825 } 4826 } 4827 4828 /* Create SNOW 3G session */ 4829 retval = create_wireless_algo_auth_cipher_session( 4830 ts_params->valid_devs[0], 4831 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT 4832 : RTE_CRYPTO_CIPHER_OP_ENCRYPT), 4833 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY 4834 : RTE_CRYPTO_AUTH_OP_GENERATE), 4835 RTE_CRYPTO_AUTH_SNOW3G_UIA2, 4836 RTE_CRYPTO_CIPHER_SNOW3G_UEA2, 4837 tdata->key.data, tdata->key.len, 4838 tdata->auth_iv.len, tdata->digest.len, 4839 tdata->cipher_iv.len); 4840 4841 if (retval < 0) 4842 return retval; 4843 4844 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 4845 plaintext_len = ceil_byte_length(tdata->plaintext.len); 4846 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 4847 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 4848 4849 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, 4850 plaintext_pad_len, 15, 0); 4851 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 4852 "Failed to allocate input buffer in mempool"); 4853 4854 if (op_mode == OUT_OF_PLACE) { 4855 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool, 4856 plaintext_pad_len, 15, 0); 4857 TEST_ASSERT_NOT_NULL(ut_params->obuf, 4858 "Failed to allocate output buffer in mempool"); 4859 } 4860 4861 if (verify) { 4862 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, 4863 tdata->ciphertext.data); 4864 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 4865 ciphertext_len, buffer); 4866 debug_hexdump(stdout, "ciphertext:", ciphertext, 4867 ciphertext_len); 4868 } else { 4869 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, 4870 tdata->plaintext.data); 4871 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0, 4872 plaintext_len, buffer); 4873 debug_hexdump(stdout, "plaintext:", plaintext, 4874 plaintext_len); 4875 } 4876 memset(buffer, 0, sizeof(buffer)); 4877 4878 /* Create SNOW 3G operation */ 4879 retval = create_wireless_algo_auth_cipher_operation( 4880 tdata->digest.data, tdata->digest.len, 4881 tdata->cipher_iv.data, tdata->cipher_iv.len, 4882 tdata->auth_iv.data, tdata->auth_iv.len, 4883 (tdata->digest.offset_bytes == 0 ? 4884 (verify ? ciphertext_pad_len : plaintext_pad_len) 4885 : tdata->digest.offset_bytes), 4886 tdata->validCipherLenInBits.len, 4887 tdata->cipher.offset_bits, 4888 tdata->validAuthLenInBits.len, 4889 tdata->auth.offset_bits, 4890 op_mode, 1, verify); 4891 4892 if (retval < 0) 4893 return retval; 4894 4895 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 4896 ut_params->op); 4897 4898 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 4899 4900 ut_params->obuf = (op_mode == IN_PLACE ? 4901 ut_params->op->sym->m_src : ut_params->op->sym->m_dst); 4902 4903 if (verify) { 4904 if (ut_params->obuf) 4905 plaintext = rte_pktmbuf_read(ut_params->obuf, 0, 4906 plaintext_len, buffer); 4907 else 4908 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0, 4909 plaintext_len, buffer); 4910 4911 debug_hexdump(stdout, "plaintext:", plaintext, 4912 (tdata->plaintext.len >> 3) - tdata->digest.len); 4913 debug_hexdump(stdout, "plaintext expected:", 4914 tdata->plaintext.data, 4915 (tdata->plaintext.len >> 3) - tdata->digest.len); 4916 } else { 4917 if (ut_params->obuf) 4918 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, 4919 ciphertext_len, buffer); 4920 else 4921 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 4922 ciphertext_len, buffer); 4923 4924 debug_hexdump(stdout, "ciphertext:", ciphertext, 4925 ciphertext_len); 4926 debug_hexdump(stdout, "ciphertext expected:", 4927 tdata->ciphertext.data, tdata->ciphertext.len >> 3); 4928 4929 if (ut_params->obuf) 4930 digest = rte_pktmbuf_read(ut_params->obuf, 4931 (tdata->digest.offset_bytes == 0 ? 4932 plaintext_pad_len : tdata->digest.offset_bytes), 4933 tdata->digest.len, digest_buffer); 4934 else 4935 digest = rte_pktmbuf_read(ut_params->ibuf, 4936 (tdata->digest.offset_bytes == 0 ? 4937 plaintext_pad_len : tdata->digest.offset_bytes), 4938 tdata->digest.len, digest_buffer); 4939 4940 debug_hexdump(stdout, "digest:", digest, 4941 tdata->digest.len); 4942 debug_hexdump(stdout, "digest expected:", 4943 tdata->digest.data, tdata->digest.len); 4944 } 4945 4946 /* Validate obuf */ 4947 if (verify) { 4948 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4949 plaintext, 4950 tdata->plaintext.data, 4951 tdata->plaintext.len >> 3, 4952 "SNOW 3G Plaintext data not as expected"); 4953 } else { 4954 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 4955 ciphertext, 4956 tdata->ciphertext.data, 4957 tdata->validDataLenInBits.len, 4958 "SNOW 3G Ciphertext data not as expected"); 4959 4960 TEST_ASSERT_BUFFERS_ARE_EQUAL( 4961 digest, 4962 tdata->digest.data, 4963 DIGEST_BYTE_LENGTH_SNOW3G_UIA2, 4964 "SNOW 3G Generated auth tag not as expected"); 4965 } 4966 return 0; 4967 } 4968 4969 static int 4970 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata, 4971 uint8_t op_mode, uint8_t verify) 4972 { 4973 struct crypto_testsuite_params *ts_params = &testsuite_params; 4974 struct crypto_unittest_params *ut_params = &unittest_params; 4975 4976 int retval; 4977 4978 uint8_t *plaintext = NULL, *ciphertext = NULL; 4979 unsigned int plaintext_pad_len; 4980 unsigned int plaintext_len; 4981 unsigned int ciphertext_pad_len; 4982 unsigned int ciphertext_len; 4983 4984 struct rte_cryptodev_info dev_info; 4985 4986 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 4987 4988 uint64_t feat_flags = dev_info.feature_flags; 4989 4990 if (op_mode == OUT_OF_PLACE) { 4991 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { 4992 printf("Device doesn't support digest encrypted.\n"); 4993 return -ENOTSUP; 4994 } 4995 } 4996 4997 /* Create KASUMI session */ 4998 retval = create_wireless_algo_auth_cipher_session( 4999 ts_params->valid_devs[0], 5000 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT 5001 : RTE_CRYPTO_CIPHER_OP_ENCRYPT), 5002 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY 5003 : RTE_CRYPTO_AUTH_OP_GENERATE), 5004 RTE_CRYPTO_AUTH_KASUMI_F9, 5005 RTE_CRYPTO_CIPHER_KASUMI_F8, 5006 tdata->key.data, tdata->key.len, 5007 0, tdata->digest.len, 5008 tdata->cipher_iv.len); 5009 5010 if (retval < 0) 5011 return retval; 5012 5013 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 5014 if (op_mode == OUT_OF_PLACE) 5015 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 5016 5017 /* clear mbuf payload */ 5018 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 5019 rte_pktmbuf_tailroom(ut_params->ibuf)); 5020 if (op_mode == OUT_OF_PLACE) 5021 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, 5022 rte_pktmbuf_tailroom(ut_params->obuf)); 5023 5024 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 5025 plaintext_len = ceil_byte_length(tdata->plaintext.len); 5026 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 5027 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 5028 5029 if (verify) { 5030 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 5031 ciphertext_pad_len); 5032 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); 5033 if (op_mode == OUT_OF_PLACE) 5034 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); 5035 debug_hexdump(stdout, "ciphertext:", ciphertext, 5036 ciphertext_len); 5037 } else { 5038 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 5039 plaintext_pad_len); 5040 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 5041 if (op_mode == OUT_OF_PLACE) 5042 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); 5043 debug_hexdump(stdout, "plaintext:", plaintext, 5044 plaintext_len); 5045 } 5046 5047 /* Create KASUMI operation */ 5048 retval = create_wireless_algo_auth_cipher_operation( 5049 tdata->digest.data, tdata->digest.len, 5050 tdata->cipher_iv.data, tdata->cipher_iv.len, 5051 NULL, 0, 5052 (tdata->digest.offset_bytes == 0 ? 5053 (verify ? ciphertext_pad_len : plaintext_pad_len) 5054 : tdata->digest.offset_bytes), 5055 tdata->validCipherLenInBits.len, 5056 tdata->validCipherOffsetInBits.len, 5057 tdata->validAuthLenInBits.len, 5058 0, 5059 op_mode, 0, verify); 5060 5061 if (retval < 0) 5062 return retval; 5063 5064 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 5065 ut_params->op); 5066 5067 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 5068 5069 ut_params->obuf = (op_mode == IN_PLACE ? 5070 ut_params->op->sym->m_src : ut_params->op->sym->m_dst); 5071 5072 5073 if (verify) { 5074 if (ut_params->obuf) 5075 plaintext = rte_pktmbuf_mtod(ut_params->obuf, 5076 uint8_t *); 5077 else 5078 plaintext = ciphertext; 5079 5080 debug_hexdump(stdout, "plaintext:", plaintext, 5081 (tdata->plaintext.len >> 3) - tdata->digest.len); 5082 debug_hexdump(stdout, "plaintext expected:", 5083 tdata->plaintext.data, 5084 (tdata->plaintext.len >> 3) - tdata->digest.len); 5085 } else { 5086 if (ut_params->obuf) 5087 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, 5088 uint8_t *); 5089 else 5090 ciphertext = plaintext; 5091 5092 debug_hexdump(stdout, "ciphertext:", ciphertext, 5093 ciphertext_len); 5094 debug_hexdump(stdout, "ciphertext expected:", 5095 tdata->ciphertext.data, tdata->ciphertext.len >> 3); 5096 5097 ut_params->digest = rte_pktmbuf_mtod( 5098 ut_params->obuf, uint8_t *) + 5099 (tdata->digest.offset_bytes == 0 ? 5100 plaintext_pad_len : tdata->digest.offset_bytes); 5101 5102 debug_hexdump(stdout, "digest:", ut_params->digest, 5103 tdata->digest.len); 5104 debug_hexdump(stdout, "digest expected:", 5105 tdata->digest.data, tdata->digest.len); 5106 } 5107 5108 /* Validate obuf */ 5109 if (verify) { 5110 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5111 plaintext, 5112 tdata->plaintext.data, 5113 tdata->plaintext.len >> 3, 5114 "KASUMI Plaintext data not as expected"); 5115 } else { 5116 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5117 ciphertext, 5118 tdata->ciphertext.data, 5119 tdata->ciphertext.len >> 3, 5120 "KASUMI Ciphertext data not as expected"); 5121 5122 TEST_ASSERT_BUFFERS_ARE_EQUAL( 5123 ut_params->digest, 5124 tdata->digest.data, 5125 DIGEST_BYTE_LENGTH_KASUMI_F9, 5126 "KASUMI Generated auth tag not as expected"); 5127 } 5128 return 0; 5129 } 5130 5131 static int 5132 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata, 5133 uint8_t op_mode, uint8_t verify) 5134 { 5135 struct crypto_testsuite_params *ts_params = &testsuite_params; 5136 struct crypto_unittest_params *ut_params = &unittest_params; 5137 5138 int retval; 5139 5140 const uint8_t *plaintext = NULL; 5141 const uint8_t *ciphertext = NULL; 5142 const uint8_t *digest = NULL; 5143 unsigned int plaintext_pad_len; 5144 unsigned int plaintext_len; 5145 unsigned int ciphertext_pad_len; 5146 unsigned int ciphertext_len; 5147 uint8_t buffer[10000]; 5148 uint8_t digest_buffer[10000]; 5149 5150 struct rte_cryptodev_info dev_info; 5151 5152 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 5153 5154 uint64_t feat_flags = dev_info.feature_flags; 5155 5156 if (op_mode == IN_PLACE) { 5157 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { 5158 printf("Device doesn't support in-place scatter-gather " 5159 "in both input and output mbufs.\n"); 5160 return -ENOTSUP; 5161 } 5162 } else { 5163 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { 5164 printf("Device doesn't support out-of-place scatter-gather " 5165 "in both input and output mbufs.\n"); 5166 return -ENOTSUP; 5167 } 5168 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { 5169 printf("Device doesn't support digest encrypted.\n"); 5170 return -ENOTSUP; 5171 } 5172 } 5173 5174 /* Create KASUMI session */ 5175 retval = create_wireless_algo_auth_cipher_session( 5176 ts_params->valid_devs[0], 5177 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT 5178 : RTE_CRYPTO_CIPHER_OP_ENCRYPT), 5179 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY 5180 : RTE_CRYPTO_AUTH_OP_GENERATE), 5181 RTE_CRYPTO_AUTH_KASUMI_F9, 5182 RTE_CRYPTO_CIPHER_KASUMI_F8, 5183 tdata->key.data, tdata->key.len, 5184 0, tdata->digest.len, 5185 tdata->cipher_iv.len); 5186 5187 if (retval < 0) 5188 return retval; 5189 5190 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 5191 plaintext_len = ceil_byte_length(tdata->plaintext.len); 5192 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 5193 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 5194 5195 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, 5196 plaintext_pad_len, 15, 0); 5197 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 5198 "Failed to allocate input buffer in mempool"); 5199 5200 if (op_mode == OUT_OF_PLACE) { 5201 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool, 5202 plaintext_pad_len, 15, 0); 5203 TEST_ASSERT_NOT_NULL(ut_params->obuf, 5204 "Failed to allocate output buffer in mempool"); 5205 } 5206 5207 if (verify) { 5208 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, 5209 tdata->ciphertext.data); 5210 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 5211 ciphertext_len, buffer); 5212 debug_hexdump(stdout, "ciphertext:", ciphertext, 5213 ciphertext_len); 5214 } else { 5215 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, 5216 tdata->plaintext.data); 5217 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0, 5218 plaintext_len, buffer); 5219 debug_hexdump(stdout, "plaintext:", plaintext, 5220 plaintext_len); 5221 } 5222 memset(buffer, 0, sizeof(buffer)); 5223 5224 /* Create KASUMI operation */ 5225 retval = create_wireless_algo_auth_cipher_operation( 5226 tdata->digest.data, tdata->digest.len, 5227 tdata->cipher_iv.data, tdata->cipher_iv.len, 5228 NULL, 0, 5229 (tdata->digest.offset_bytes == 0 ? 5230 (verify ? ciphertext_pad_len : plaintext_pad_len) 5231 : tdata->digest.offset_bytes), 5232 tdata->validCipherLenInBits.len, 5233 tdata->validCipherOffsetInBits.len, 5234 tdata->validAuthLenInBits.len, 5235 0, 5236 op_mode, 1, verify); 5237 5238 if (retval < 0) 5239 return retval; 5240 5241 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 5242 ut_params->op); 5243 5244 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 5245 5246 ut_params->obuf = (op_mode == IN_PLACE ? 5247 ut_params->op->sym->m_src : ut_params->op->sym->m_dst); 5248 5249 if (verify) { 5250 if (ut_params->obuf) 5251 plaintext = rte_pktmbuf_read(ut_params->obuf, 0, 5252 plaintext_len, buffer); 5253 else 5254 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0, 5255 plaintext_len, buffer); 5256 5257 debug_hexdump(stdout, "plaintext:", plaintext, 5258 (tdata->plaintext.len >> 3) - tdata->digest.len); 5259 debug_hexdump(stdout, "plaintext expected:", 5260 tdata->plaintext.data, 5261 (tdata->plaintext.len >> 3) - tdata->digest.len); 5262 } else { 5263 if (ut_params->obuf) 5264 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, 5265 ciphertext_len, buffer); 5266 else 5267 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 5268 ciphertext_len, buffer); 5269 5270 debug_hexdump(stdout, "ciphertext:", ciphertext, 5271 ciphertext_len); 5272 debug_hexdump(stdout, "ciphertext expected:", 5273 tdata->ciphertext.data, tdata->ciphertext.len >> 3); 5274 5275 if (ut_params->obuf) 5276 digest = rte_pktmbuf_read(ut_params->obuf, 5277 (tdata->digest.offset_bytes == 0 ? 5278 plaintext_pad_len : tdata->digest.offset_bytes), 5279 tdata->digest.len, digest_buffer); 5280 else 5281 digest = rte_pktmbuf_read(ut_params->ibuf, 5282 (tdata->digest.offset_bytes == 0 ? 5283 plaintext_pad_len : tdata->digest.offset_bytes), 5284 tdata->digest.len, digest_buffer); 5285 5286 debug_hexdump(stdout, "digest:", digest, 5287 tdata->digest.len); 5288 debug_hexdump(stdout, "digest expected:", 5289 tdata->digest.data, tdata->digest.len); 5290 } 5291 5292 /* Validate obuf */ 5293 if (verify) { 5294 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5295 plaintext, 5296 tdata->plaintext.data, 5297 tdata->plaintext.len >> 3, 5298 "KASUMI Plaintext data not as expected"); 5299 } else { 5300 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5301 ciphertext, 5302 tdata->ciphertext.data, 5303 tdata->validDataLenInBits.len, 5304 "KASUMI Ciphertext data not as expected"); 5305 5306 TEST_ASSERT_BUFFERS_ARE_EQUAL( 5307 digest, 5308 tdata->digest.data, 5309 DIGEST_BYTE_LENGTH_KASUMI_F9, 5310 "KASUMI Generated auth tag not as expected"); 5311 } 5312 return 0; 5313 } 5314 5315 static int 5316 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata) 5317 { 5318 struct crypto_testsuite_params *ts_params = &testsuite_params; 5319 struct crypto_unittest_params *ut_params = &unittest_params; 5320 5321 int retval; 5322 5323 uint8_t *plaintext, *ciphertext; 5324 unsigned plaintext_pad_len; 5325 unsigned plaintext_len; 5326 5327 /* Create KASUMI session */ 5328 retval = create_wireless_algo_cipher_auth_session( 5329 ts_params->valid_devs[0], 5330 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 5331 RTE_CRYPTO_AUTH_OP_GENERATE, 5332 RTE_CRYPTO_AUTH_KASUMI_F9, 5333 RTE_CRYPTO_CIPHER_KASUMI_F8, 5334 tdata->key.data, tdata->key.len, 5335 0, tdata->digest.len, 5336 tdata->cipher_iv.len); 5337 if (retval < 0) 5338 return retval; 5339 5340 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 5341 5342 /* clear mbuf payload */ 5343 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 5344 rte_pktmbuf_tailroom(ut_params->ibuf)); 5345 5346 plaintext_len = ceil_byte_length(tdata->plaintext.len); 5347 /* Append data which is padded to a multiple of */ 5348 /* the algorithms block size */ 5349 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 5350 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 5351 plaintext_pad_len); 5352 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 5353 5354 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 5355 5356 /* Create KASUMI operation */ 5357 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data, 5358 tdata->digest.len, NULL, 0, 5359 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, 5360 tdata->cipher_iv.data, tdata->cipher_iv.len, 5361 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), 5362 tdata->validCipherOffsetInBits.len, 5363 tdata->validAuthLenInBits.len, 5364 0 5365 ); 5366 if (retval < 0) 5367 return retval; 5368 5369 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 5370 ut_params->op); 5371 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 5372 5373 if (ut_params->op->sym->m_dst) 5374 ut_params->obuf = ut_params->op->sym->m_dst; 5375 else 5376 ut_params->obuf = ut_params->op->sym->m_src; 5377 5378 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *, 5379 tdata->validCipherOffsetInBits.len >> 3); 5380 5381 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 5382 + plaintext_pad_len; 5383 5384 const uint8_t *reference_ciphertext = tdata->ciphertext.data + 5385 (tdata->validCipherOffsetInBits.len >> 3); 5386 /* Validate obuf */ 5387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5388 ciphertext, 5389 reference_ciphertext, 5390 tdata->validCipherLenInBits.len, 5391 "KASUMI Ciphertext data not as expected"); 5392 5393 /* Validate obuf */ 5394 TEST_ASSERT_BUFFERS_ARE_EQUAL( 5395 ut_params->digest, 5396 tdata->digest.data, 5397 DIGEST_BYTE_LENGTH_SNOW3G_UIA2, 5398 "KASUMI Generated auth tag not as expected"); 5399 return 0; 5400 } 5401 5402 static int 5403 test_zuc_encryption(const struct wireless_test_data *tdata) 5404 { 5405 struct crypto_testsuite_params *ts_params = &testsuite_params; 5406 struct crypto_unittest_params *ut_params = &unittest_params; 5407 5408 int retval; 5409 uint8_t *plaintext, *ciphertext; 5410 unsigned plaintext_pad_len; 5411 unsigned plaintext_len; 5412 5413 struct rte_cryptodev_sym_capability_idx cap_idx; 5414 5415 /* Check if device supports ZUC EEA3 */ 5416 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 5417 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3; 5418 5419 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], 5420 &cap_idx) == NULL) 5421 return -ENOTSUP; 5422 5423 /* Create ZUC session */ 5424 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 5425 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 5426 RTE_CRYPTO_CIPHER_ZUC_EEA3, 5427 tdata->key.data, tdata->key.len, 5428 tdata->cipher_iv.len); 5429 if (retval < 0) 5430 return retval; 5431 5432 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 5433 5434 /* Clear mbuf payload */ 5435 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 5436 rte_pktmbuf_tailroom(ut_params->ibuf)); 5437 5438 plaintext_len = ceil_byte_length(tdata->plaintext.len); 5439 /* Append data which is padded to a multiple */ 5440 /* of the algorithms block size */ 5441 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 5442 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 5443 plaintext_pad_len); 5444 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 5445 5446 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 5447 5448 /* Create ZUC operation */ 5449 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, 5450 tdata->cipher_iv.len, 5451 tdata->plaintext.len, 5452 0); 5453 if (retval < 0) 5454 return retval; 5455 5456 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 5457 ut_params->op); 5458 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 5459 5460 ut_params->obuf = ut_params->op->sym->m_dst; 5461 if (ut_params->obuf) 5462 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *); 5463 else 5464 ciphertext = plaintext; 5465 5466 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 5467 5468 /* Validate obuf */ 5469 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5470 ciphertext, 5471 tdata->ciphertext.data, 5472 tdata->validCipherLenInBits.len, 5473 "ZUC Ciphertext data not as expected"); 5474 return 0; 5475 } 5476 5477 static int 5478 test_zuc_encryption_sgl(const struct wireless_test_data *tdata) 5479 { 5480 struct crypto_testsuite_params *ts_params = &testsuite_params; 5481 struct crypto_unittest_params *ut_params = &unittest_params; 5482 5483 int retval; 5484 5485 unsigned int plaintext_pad_len; 5486 unsigned int plaintext_len; 5487 const uint8_t *ciphertext; 5488 uint8_t ciphertext_buffer[2048]; 5489 struct rte_cryptodev_info dev_info; 5490 5491 struct rte_cryptodev_sym_capability_idx cap_idx; 5492 5493 /* Check if device supports ZUC EEA3 */ 5494 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 5495 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3; 5496 5497 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], 5498 &cap_idx) == NULL) 5499 return -ENOTSUP; 5500 5501 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 5502 5503 uint64_t feat_flags = dev_info.feature_flags; 5504 5505 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { 5506 printf("Device doesn't support in-place scatter-gather. " 5507 "Test Skipped.\n"); 5508 return -ENOTSUP; 5509 } 5510 5511 plaintext_len = ceil_byte_length(tdata->plaintext.len); 5512 5513 /* Append data which is padded to a multiple */ 5514 /* of the algorithms block size */ 5515 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 5516 5517 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, 5518 plaintext_pad_len, 10, 0); 5519 5520 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, 5521 tdata->plaintext.data); 5522 5523 /* Create ZUC session */ 5524 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0], 5525 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 5526 RTE_CRYPTO_CIPHER_ZUC_EEA3, 5527 tdata->key.data, tdata->key.len, 5528 tdata->cipher_iv.len); 5529 if (retval < 0) 5530 return retval; 5531 5532 /* Clear mbuf payload */ 5533 5534 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data); 5535 5536 /* Create ZUC operation */ 5537 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, 5538 tdata->cipher_iv.len, tdata->plaintext.len, 5539 0); 5540 if (retval < 0) 5541 return retval; 5542 5543 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 5544 ut_params->op); 5545 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 5546 5547 ut_params->obuf = ut_params->op->sym->m_dst; 5548 if (ut_params->obuf) 5549 ciphertext = rte_pktmbuf_read(ut_params->obuf, 5550 0, plaintext_len, ciphertext_buffer); 5551 else 5552 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 5553 0, plaintext_len, ciphertext_buffer); 5554 5555 /* Validate obuf */ 5556 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); 5557 5558 /* Validate obuf */ 5559 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5560 ciphertext, 5561 tdata->ciphertext.data, 5562 tdata->validCipherLenInBits.len, 5563 "ZUC Ciphertext data not as expected"); 5564 5565 return 0; 5566 } 5567 5568 static int 5569 test_zuc_authentication(const struct wireless_test_data *tdata) 5570 { 5571 struct crypto_testsuite_params *ts_params = &testsuite_params; 5572 struct crypto_unittest_params *ut_params = &unittest_params; 5573 5574 int retval; 5575 unsigned plaintext_pad_len; 5576 unsigned plaintext_len; 5577 uint8_t *plaintext; 5578 5579 struct rte_cryptodev_sym_capability_idx cap_idx; 5580 5581 /* Check if device supports ZUC EIA3 */ 5582 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; 5583 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3; 5584 5585 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], 5586 &cap_idx) == NULL) 5587 return -ENOTSUP; 5588 5589 /* Create ZUC session */ 5590 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0], 5591 tdata->key.data, tdata->key.len, 5592 tdata->auth_iv.len, tdata->digest.len, 5593 RTE_CRYPTO_AUTH_OP_GENERATE, 5594 RTE_CRYPTO_AUTH_ZUC_EIA3); 5595 if (retval < 0) 5596 return retval; 5597 5598 /* alloc mbuf and set payload */ 5599 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 5600 5601 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 5602 rte_pktmbuf_tailroom(ut_params->ibuf)); 5603 5604 plaintext_len = ceil_byte_length(tdata->plaintext.len); 5605 /* Append data which is padded to a multiple of */ 5606 /* the algorithms block size */ 5607 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8); 5608 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 5609 plaintext_pad_len); 5610 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 5611 5612 /* Create ZUC operation */ 5613 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len, 5614 tdata->auth_iv.data, tdata->auth_iv.len, 5615 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE, 5616 tdata->validAuthLenInBits.len, 5617 0); 5618 if (retval < 0) 5619 return retval; 5620 5621 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 5622 ut_params->op); 5623 ut_params->obuf = ut_params->op->sym->m_src; 5624 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 5625 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 5626 + plaintext_pad_len; 5627 5628 /* Validate obuf */ 5629 TEST_ASSERT_BUFFERS_ARE_EQUAL( 5630 ut_params->digest, 5631 tdata->digest.data, 5632 DIGEST_BYTE_LENGTH_KASUMI_F9, 5633 "ZUC Generated auth tag not as expected"); 5634 5635 return 0; 5636 } 5637 5638 static int 5639 test_zuc_auth_cipher(const struct wireless_test_data *tdata, 5640 uint8_t op_mode, uint8_t verify) 5641 { 5642 struct crypto_testsuite_params *ts_params = &testsuite_params; 5643 struct crypto_unittest_params *ut_params = &unittest_params; 5644 5645 int retval; 5646 5647 uint8_t *plaintext = NULL, *ciphertext = NULL; 5648 unsigned int plaintext_pad_len; 5649 unsigned int plaintext_len; 5650 unsigned int ciphertext_pad_len; 5651 unsigned int ciphertext_len; 5652 5653 struct rte_cryptodev_info dev_info; 5654 struct rte_cryptodev_sym_capability_idx cap_idx; 5655 5656 /* Check if device supports ZUC EIA3 */ 5657 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; 5658 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3; 5659 5660 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], 5661 &cap_idx) == NULL) 5662 return -ENOTSUP; 5663 5664 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 5665 5666 uint64_t feat_flags = dev_info.feature_flags; 5667 5668 if (op_mode == OUT_OF_PLACE) { 5669 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { 5670 printf("Device doesn't support digest encrypted.\n"); 5671 return -ENOTSUP; 5672 } 5673 } 5674 5675 /* Create ZUC session */ 5676 retval = create_wireless_algo_auth_cipher_session( 5677 ts_params->valid_devs[0], 5678 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT 5679 : RTE_CRYPTO_CIPHER_OP_ENCRYPT), 5680 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY 5681 : RTE_CRYPTO_AUTH_OP_GENERATE), 5682 RTE_CRYPTO_AUTH_ZUC_EIA3, 5683 RTE_CRYPTO_CIPHER_ZUC_EEA3, 5684 tdata->key.data, tdata->key.len, 5685 tdata->auth_iv.len, tdata->digest.len, 5686 tdata->cipher_iv.len); 5687 5688 if (retval < 0) 5689 return retval; 5690 5691 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 5692 if (op_mode == OUT_OF_PLACE) 5693 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 5694 5695 /* clear mbuf payload */ 5696 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 5697 rte_pktmbuf_tailroom(ut_params->ibuf)); 5698 if (op_mode == OUT_OF_PLACE) 5699 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, 5700 rte_pktmbuf_tailroom(ut_params->obuf)); 5701 5702 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 5703 plaintext_len = ceil_byte_length(tdata->plaintext.len); 5704 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 5705 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 5706 5707 if (verify) { 5708 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 5709 ciphertext_pad_len); 5710 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); 5711 if (op_mode == OUT_OF_PLACE) 5712 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); 5713 debug_hexdump(stdout, "ciphertext:", ciphertext, 5714 ciphertext_len); 5715 } else { 5716 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 5717 plaintext_pad_len); 5718 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 5719 if (op_mode == OUT_OF_PLACE) 5720 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); 5721 debug_hexdump(stdout, "plaintext:", plaintext, 5722 plaintext_len); 5723 } 5724 5725 /* Create ZUC operation */ 5726 retval = create_wireless_algo_auth_cipher_operation( 5727 tdata->digest.data, tdata->digest.len, 5728 tdata->cipher_iv.data, tdata->cipher_iv.len, 5729 tdata->auth_iv.data, tdata->auth_iv.len, 5730 (tdata->digest.offset_bytes == 0 ? 5731 (verify ? ciphertext_pad_len : plaintext_pad_len) 5732 : tdata->digest.offset_bytes), 5733 tdata->validCipherLenInBits.len, 5734 tdata->validCipherOffsetInBits.len, 5735 tdata->validAuthLenInBits.len, 5736 0, 5737 op_mode, 0, verify); 5738 5739 if (retval < 0) 5740 return retval; 5741 5742 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 5743 ut_params->op); 5744 5745 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 5746 5747 ut_params->obuf = (op_mode == IN_PLACE ? 5748 ut_params->op->sym->m_src : ut_params->op->sym->m_dst); 5749 5750 5751 if (verify) { 5752 if (ut_params->obuf) 5753 plaintext = rte_pktmbuf_mtod(ut_params->obuf, 5754 uint8_t *); 5755 else 5756 plaintext = ciphertext; 5757 5758 debug_hexdump(stdout, "plaintext:", plaintext, 5759 (tdata->plaintext.len >> 3) - tdata->digest.len); 5760 debug_hexdump(stdout, "plaintext expected:", 5761 tdata->plaintext.data, 5762 (tdata->plaintext.len >> 3) - tdata->digest.len); 5763 } else { 5764 if (ut_params->obuf) 5765 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, 5766 uint8_t *); 5767 else 5768 ciphertext = plaintext; 5769 5770 debug_hexdump(stdout, "ciphertext:", ciphertext, 5771 ciphertext_len); 5772 debug_hexdump(stdout, "ciphertext expected:", 5773 tdata->ciphertext.data, tdata->ciphertext.len >> 3); 5774 5775 ut_params->digest = rte_pktmbuf_mtod( 5776 ut_params->obuf, uint8_t *) + 5777 (tdata->digest.offset_bytes == 0 ? 5778 plaintext_pad_len : tdata->digest.offset_bytes); 5779 5780 debug_hexdump(stdout, "digest:", ut_params->digest, 5781 tdata->digest.len); 5782 debug_hexdump(stdout, "digest expected:", 5783 tdata->digest.data, tdata->digest.len); 5784 } 5785 5786 /* Validate obuf */ 5787 if (verify) { 5788 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5789 plaintext, 5790 tdata->plaintext.data, 5791 tdata->plaintext.len >> 3, 5792 "ZUC Plaintext data not as expected"); 5793 } else { 5794 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5795 ciphertext, 5796 tdata->ciphertext.data, 5797 tdata->ciphertext.len >> 3, 5798 "ZUC Ciphertext data not as expected"); 5799 5800 TEST_ASSERT_BUFFERS_ARE_EQUAL( 5801 ut_params->digest, 5802 tdata->digest.data, 5803 DIGEST_BYTE_LENGTH_KASUMI_F9, 5804 "ZUC Generated auth tag not as expected"); 5805 } 5806 return 0; 5807 } 5808 5809 static int 5810 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata, 5811 uint8_t op_mode, uint8_t verify) 5812 { 5813 struct crypto_testsuite_params *ts_params = &testsuite_params; 5814 struct crypto_unittest_params *ut_params = &unittest_params; 5815 5816 int retval; 5817 5818 const uint8_t *plaintext = NULL; 5819 const uint8_t *ciphertext = NULL; 5820 const uint8_t *digest = NULL; 5821 unsigned int plaintext_pad_len; 5822 unsigned int plaintext_len; 5823 unsigned int ciphertext_pad_len; 5824 unsigned int ciphertext_len; 5825 uint8_t buffer[10000]; 5826 uint8_t digest_buffer[10000]; 5827 5828 struct rte_cryptodev_info dev_info; 5829 struct rte_cryptodev_sym_capability_idx cap_idx; 5830 5831 /* Check if device supports ZUC EIA3 */ 5832 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; 5833 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3; 5834 5835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], 5836 &cap_idx) == NULL) 5837 return -ENOTSUP; 5838 5839 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 5840 5841 uint64_t feat_flags = dev_info.feature_flags; 5842 5843 if (op_mode == IN_PLACE) { 5844 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { 5845 printf("Device doesn't support in-place scatter-gather " 5846 "in both input and output mbufs.\n"); 5847 return -ENOTSUP; 5848 } 5849 } else { 5850 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { 5851 printf("Device doesn't support out-of-place scatter-gather " 5852 "in both input and output mbufs.\n"); 5853 return -ENOTSUP; 5854 } 5855 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { 5856 printf("Device doesn't support digest encrypted.\n"); 5857 return -ENOTSUP; 5858 } 5859 } 5860 5861 /* Create ZUC session */ 5862 retval = create_wireless_algo_auth_cipher_session( 5863 ts_params->valid_devs[0], 5864 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT 5865 : RTE_CRYPTO_CIPHER_OP_ENCRYPT), 5866 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY 5867 : RTE_CRYPTO_AUTH_OP_GENERATE), 5868 RTE_CRYPTO_AUTH_ZUC_EIA3, 5869 RTE_CRYPTO_CIPHER_ZUC_EEA3, 5870 tdata->key.data, tdata->key.len, 5871 tdata->auth_iv.len, tdata->digest.len, 5872 tdata->cipher_iv.len); 5873 5874 if (retval < 0) 5875 return retval; 5876 5877 ciphertext_len = ceil_byte_length(tdata->ciphertext.len); 5878 plaintext_len = ceil_byte_length(tdata->plaintext.len); 5879 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 5880 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 5881 5882 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, 5883 plaintext_pad_len, 15, 0); 5884 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 5885 "Failed to allocate input buffer in mempool"); 5886 5887 if (op_mode == OUT_OF_PLACE) { 5888 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool, 5889 plaintext_pad_len, 15, 0); 5890 TEST_ASSERT_NOT_NULL(ut_params->obuf, 5891 "Failed to allocate output buffer in mempool"); 5892 } 5893 5894 if (verify) { 5895 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, 5896 tdata->ciphertext.data); 5897 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 5898 ciphertext_len, buffer); 5899 debug_hexdump(stdout, "ciphertext:", ciphertext, 5900 ciphertext_len); 5901 } else { 5902 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, 5903 tdata->plaintext.data); 5904 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0, 5905 plaintext_len, buffer); 5906 debug_hexdump(stdout, "plaintext:", plaintext, 5907 plaintext_len); 5908 } 5909 memset(buffer, 0, sizeof(buffer)); 5910 5911 /* Create ZUC operation */ 5912 retval = create_wireless_algo_auth_cipher_operation( 5913 tdata->digest.data, tdata->digest.len, 5914 tdata->cipher_iv.data, tdata->cipher_iv.len, 5915 NULL, 0, 5916 (tdata->digest.offset_bytes == 0 ? 5917 (verify ? ciphertext_pad_len : plaintext_pad_len) 5918 : tdata->digest.offset_bytes), 5919 tdata->validCipherLenInBits.len, 5920 tdata->validCipherOffsetInBits.len, 5921 tdata->validAuthLenInBits.len, 5922 0, 5923 op_mode, 1, verify); 5924 5925 if (retval < 0) 5926 return retval; 5927 5928 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 5929 ut_params->op); 5930 5931 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 5932 5933 ut_params->obuf = (op_mode == IN_PLACE ? 5934 ut_params->op->sym->m_src : ut_params->op->sym->m_dst); 5935 5936 if (verify) { 5937 if (ut_params->obuf) 5938 plaintext = rte_pktmbuf_read(ut_params->obuf, 0, 5939 plaintext_len, buffer); 5940 else 5941 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0, 5942 plaintext_len, buffer); 5943 5944 debug_hexdump(stdout, "plaintext:", plaintext, 5945 (tdata->plaintext.len >> 3) - tdata->digest.len); 5946 debug_hexdump(stdout, "plaintext expected:", 5947 tdata->plaintext.data, 5948 (tdata->plaintext.len >> 3) - tdata->digest.len); 5949 } else { 5950 if (ut_params->obuf) 5951 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, 5952 ciphertext_len, buffer); 5953 else 5954 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 5955 ciphertext_len, buffer); 5956 5957 debug_hexdump(stdout, "ciphertext:", ciphertext, 5958 ciphertext_len); 5959 debug_hexdump(stdout, "ciphertext expected:", 5960 tdata->ciphertext.data, tdata->ciphertext.len >> 3); 5961 5962 if (ut_params->obuf) 5963 digest = rte_pktmbuf_read(ut_params->obuf, 5964 (tdata->digest.offset_bytes == 0 ? 5965 plaintext_pad_len : tdata->digest.offset_bytes), 5966 tdata->digest.len, digest_buffer); 5967 else 5968 digest = rte_pktmbuf_read(ut_params->ibuf, 5969 (tdata->digest.offset_bytes == 0 ? 5970 plaintext_pad_len : tdata->digest.offset_bytes), 5971 tdata->digest.len, digest_buffer); 5972 5973 debug_hexdump(stdout, "digest:", digest, 5974 tdata->digest.len); 5975 debug_hexdump(stdout, "digest expected:", 5976 tdata->digest.data, tdata->digest.len); 5977 } 5978 5979 /* Validate obuf */ 5980 if (verify) { 5981 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5982 plaintext, 5983 tdata->plaintext.data, 5984 tdata->plaintext.len >> 3, 5985 "ZUC Plaintext data not as expected"); 5986 } else { 5987 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 5988 ciphertext, 5989 tdata->ciphertext.data, 5990 tdata->validDataLenInBits.len, 5991 "ZUC Ciphertext data not as expected"); 5992 5993 TEST_ASSERT_BUFFERS_ARE_EQUAL( 5994 digest, 5995 tdata->digest.data, 5996 DIGEST_BYTE_LENGTH_KASUMI_F9, 5997 "ZUC Generated auth tag not as expected"); 5998 } 5999 return 0; 6000 } 6001 6002 static int 6003 test_kasumi_encryption_test_case_1(void) 6004 { 6005 return test_kasumi_encryption(&kasumi_test_case_1); 6006 } 6007 6008 static int 6009 test_kasumi_encryption_test_case_1_sgl(void) 6010 { 6011 return test_kasumi_encryption_sgl(&kasumi_test_case_1); 6012 } 6013 6014 static int 6015 test_kasumi_encryption_test_case_1_oop(void) 6016 { 6017 return test_kasumi_encryption_oop(&kasumi_test_case_1); 6018 } 6019 6020 static int 6021 test_kasumi_encryption_test_case_1_oop_sgl(void) 6022 { 6023 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1); 6024 } 6025 6026 static int 6027 test_kasumi_encryption_test_case_2(void) 6028 { 6029 return test_kasumi_encryption(&kasumi_test_case_2); 6030 } 6031 6032 static int 6033 test_kasumi_encryption_test_case_3(void) 6034 { 6035 return test_kasumi_encryption(&kasumi_test_case_3); 6036 } 6037 6038 static int 6039 test_kasumi_encryption_test_case_4(void) 6040 { 6041 return test_kasumi_encryption(&kasumi_test_case_4); 6042 } 6043 6044 static int 6045 test_kasumi_encryption_test_case_5(void) 6046 { 6047 return test_kasumi_encryption(&kasumi_test_case_5); 6048 } 6049 6050 static int 6051 test_kasumi_decryption_test_case_1(void) 6052 { 6053 return test_kasumi_decryption(&kasumi_test_case_1); 6054 } 6055 6056 static int 6057 test_kasumi_decryption_test_case_1_oop(void) 6058 { 6059 return test_kasumi_decryption_oop(&kasumi_test_case_1); 6060 } 6061 6062 static int 6063 test_kasumi_decryption_test_case_2(void) 6064 { 6065 return test_kasumi_decryption(&kasumi_test_case_2); 6066 } 6067 6068 static int 6069 test_kasumi_decryption_test_case_3(void) 6070 { 6071 return test_kasumi_decryption(&kasumi_test_case_3); 6072 } 6073 6074 static int 6075 test_kasumi_decryption_test_case_4(void) 6076 { 6077 return test_kasumi_decryption(&kasumi_test_case_4); 6078 } 6079 6080 static int 6081 test_kasumi_decryption_test_case_5(void) 6082 { 6083 return test_kasumi_decryption(&kasumi_test_case_5); 6084 } 6085 static int 6086 test_snow3g_encryption_test_case_1(void) 6087 { 6088 return test_snow3g_encryption(&snow3g_test_case_1); 6089 } 6090 6091 static int 6092 test_snow3g_encryption_test_case_1_oop(void) 6093 { 6094 return test_snow3g_encryption_oop(&snow3g_test_case_1); 6095 } 6096 6097 static int 6098 test_snow3g_encryption_test_case_1_oop_sgl(void) 6099 { 6100 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1); 6101 } 6102 6103 6104 static int 6105 test_snow3g_encryption_test_case_1_offset_oop(void) 6106 { 6107 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1); 6108 } 6109 6110 static int 6111 test_snow3g_encryption_test_case_2(void) 6112 { 6113 return test_snow3g_encryption(&snow3g_test_case_2); 6114 } 6115 6116 static int 6117 test_snow3g_encryption_test_case_3(void) 6118 { 6119 return test_snow3g_encryption(&snow3g_test_case_3); 6120 } 6121 6122 static int 6123 test_snow3g_encryption_test_case_4(void) 6124 { 6125 return test_snow3g_encryption(&snow3g_test_case_4); 6126 } 6127 6128 static int 6129 test_snow3g_encryption_test_case_5(void) 6130 { 6131 return test_snow3g_encryption(&snow3g_test_case_5); 6132 } 6133 6134 static int 6135 test_snow3g_decryption_test_case_1(void) 6136 { 6137 return test_snow3g_decryption(&snow3g_test_case_1); 6138 } 6139 6140 static int 6141 test_snow3g_decryption_test_case_1_oop(void) 6142 { 6143 return test_snow3g_decryption_oop(&snow3g_test_case_1); 6144 } 6145 6146 static int 6147 test_snow3g_decryption_test_case_2(void) 6148 { 6149 return test_snow3g_decryption(&snow3g_test_case_2); 6150 } 6151 6152 static int 6153 test_snow3g_decryption_test_case_3(void) 6154 { 6155 return test_snow3g_decryption(&snow3g_test_case_3); 6156 } 6157 6158 static int 6159 test_snow3g_decryption_test_case_4(void) 6160 { 6161 return test_snow3g_decryption(&snow3g_test_case_4); 6162 } 6163 6164 static int 6165 test_snow3g_decryption_test_case_5(void) 6166 { 6167 return test_snow3g_decryption(&snow3g_test_case_5); 6168 } 6169 6170 /* 6171 * Function prepares snow3g_hash_test_data from snow3g_test_data. 6172 * Pattern digest from snow3g_test_data must be allocated as 6173 * 4 last bytes in plaintext. 6174 */ 6175 static void 6176 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern, 6177 struct snow3g_hash_test_data *output) 6178 { 6179 if ((pattern != NULL) && (output != NULL)) { 6180 output->key.len = pattern->key.len; 6181 6182 memcpy(output->key.data, 6183 pattern->key.data, pattern->key.len); 6184 6185 output->auth_iv.len = pattern->auth_iv.len; 6186 6187 memcpy(output->auth_iv.data, 6188 pattern->auth_iv.data, pattern->auth_iv.len); 6189 6190 output->plaintext.len = pattern->plaintext.len; 6191 6192 memcpy(output->plaintext.data, 6193 pattern->plaintext.data, pattern->plaintext.len >> 3); 6194 6195 output->digest.len = pattern->digest.len; 6196 6197 memcpy(output->digest.data, 6198 &pattern->plaintext.data[pattern->digest.offset_bytes], 6199 pattern->digest.len); 6200 6201 output->validAuthLenInBits.len = 6202 pattern->validAuthLenInBits.len; 6203 } 6204 } 6205 6206 /* 6207 * Test case verify computed cipher and digest from snow3g_test_case_7 data. 6208 */ 6209 static int 6210 test_snow3g_decryption_with_digest_test_case_1(void) 6211 { 6212 struct snow3g_hash_test_data snow3g_hash_data; 6213 6214 /* 6215 * Function prepare data for hash veryfication test case. 6216 * Digest is allocated in 4 last bytes in plaintext, pattern. 6217 */ 6218 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data); 6219 6220 return test_snow3g_decryption(&snow3g_test_case_7) & 6221 test_snow3g_authentication_verify(&snow3g_hash_data); 6222 } 6223 6224 static int 6225 test_snow3g_cipher_auth_test_case_1(void) 6226 { 6227 return test_snow3g_cipher_auth(&snow3g_test_case_3); 6228 } 6229 6230 static int 6231 test_snow3g_auth_cipher_test_case_1(void) 6232 { 6233 return test_snow3g_auth_cipher( 6234 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0); 6235 } 6236 6237 static int 6238 test_snow3g_auth_cipher_test_case_2(void) 6239 { 6240 return test_snow3g_auth_cipher( 6241 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0); 6242 } 6243 6244 static int 6245 test_snow3g_auth_cipher_test_case_2_oop(void) 6246 { 6247 return test_snow3g_auth_cipher( 6248 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0); 6249 } 6250 6251 static int 6252 test_snow3g_auth_cipher_part_digest_enc(void) 6253 { 6254 return test_snow3g_auth_cipher( 6255 &snow3g_auth_cipher_partial_digest_encryption, 6256 IN_PLACE, 0); 6257 } 6258 6259 static int 6260 test_snow3g_auth_cipher_part_digest_enc_oop(void) 6261 { 6262 return test_snow3g_auth_cipher( 6263 &snow3g_auth_cipher_partial_digest_encryption, 6264 OUT_OF_PLACE, 0); 6265 } 6266 6267 static int 6268 test_snow3g_auth_cipher_test_case_3_sgl(void) 6269 { 6270 return test_snow3g_auth_cipher_sgl( 6271 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0); 6272 } 6273 6274 static int 6275 test_snow3g_auth_cipher_test_case_3_oop_sgl(void) 6276 { 6277 return test_snow3g_auth_cipher_sgl( 6278 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0); 6279 } 6280 6281 static int 6282 test_snow3g_auth_cipher_part_digest_enc_sgl(void) 6283 { 6284 return test_snow3g_auth_cipher_sgl( 6285 &snow3g_auth_cipher_partial_digest_encryption, 6286 IN_PLACE, 0); 6287 } 6288 6289 static int 6290 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void) 6291 { 6292 return test_snow3g_auth_cipher_sgl( 6293 &snow3g_auth_cipher_partial_digest_encryption, 6294 OUT_OF_PLACE, 0); 6295 } 6296 6297 static int 6298 test_snow3g_auth_cipher_verify_test_case_1(void) 6299 { 6300 return test_snow3g_auth_cipher( 6301 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1); 6302 } 6303 6304 static int 6305 test_snow3g_auth_cipher_verify_test_case_2(void) 6306 { 6307 return test_snow3g_auth_cipher( 6308 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1); 6309 } 6310 6311 static int 6312 test_snow3g_auth_cipher_verify_test_case_2_oop(void) 6313 { 6314 return test_snow3g_auth_cipher( 6315 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1); 6316 } 6317 6318 static int 6319 test_snow3g_auth_cipher_verify_part_digest_enc(void) 6320 { 6321 return test_snow3g_auth_cipher( 6322 &snow3g_auth_cipher_partial_digest_encryption, 6323 IN_PLACE, 1); 6324 } 6325 6326 static int 6327 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void) 6328 { 6329 return test_snow3g_auth_cipher( 6330 &snow3g_auth_cipher_partial_digest_encryption, 6331 OUT_OF_PLACE, 1); 6332 } 6333 6334 static int 6335 test_snow3g_auth_cipher_verify_test_case_3_sgl(void) 6336 { 6337 return test_snow3g_auth_cipher_sgl( 6338 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1); 6339 } 6340 6341 static int 6342 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void) 6343 { 6344 return test_snow3g_auth_cipher_sgl( 6345 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1); 6346 } 6347 6348 static int 6349 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void) 6350 { 6351 return test_snow3g_auth_cipher_sgl( 6352 &snow3g_auth_cipher_partial_digest_encryption, 6353 IN_PLACE, 1); 6354 } 6355 6356 static int 6357 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void) 6358 { 6359 return test_snow3g_auth_cipher_sgl( 6360 &snow3g_auth_cipher_partial_digest_encryption, 6361 OUT_OF_PLACE, 1); 6362 } 6363 6364 static int 6365 test_snow3g_auth_cipher_with_digest_test_case_1(void) 6366 { 6367 return test_snow3g_auth_cipher( 6368 &snow3g_test_case_7, IN_PLACE, 0); 6369 } 6370 6371 static int 6372 test_kasumi_auth_cipher_test_case_1(void) 6373 { 6374 return test_kasumi_auth_cipher( 6375 &kasumi_test_case_3, IN_PLACE, 0); 6376 } 6377 6378 static int 6379 test_kasumi_auth_cipher_test_case_2(void) 6380 { 6381 return test_kasumi_auth_cipher( 6382 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0); 6383 } 6384 6385 static int 6386 test_kasumi_auth_cipher_test_case_2_oop(void) 6387 { 6388 return test_kasumi_auth_cipher( 6389 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0); 6390 } 6391 6392 static int 6393 test_kasumi_auth_cipher_test_case_2_sgl(void) 6394 { 6395 return test_kasumi_auth_cipher_sgl( 6396 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0); 6397 } 6398 6399 static int 6400 test_kasumi_auth_cipher_test_case_2_oop_sgl(void) 6401 { 6402 return test_kasumi_auth_cipher_sgl( 6403 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0); 6404 } 6405 6406 static int 6407 test_kasumi_auth_cipher_verify_test_case_1(void) 6408 { 6409 return test_kasumi_auth_cipher( 6410 &kasumi_test_case_3, IN_PLACE, 1); 6411 } 6412 6413 static int 6414 test_kasumi_auth_cipher_verify_test_case_2(void) 6415 { 6416 return test_kasumi_auth_cipher( 6417 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1); 6418 } 6419 6420 static int 6421 test_kasumi_auth_cipher_verify_test_case_2_oop(void) 6422 { 6423 return test_kasumi_auth_cipher( 6424 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1); 6425 } 6426 6427 static int 6428 test_kasumi_auth_cipher_verify_test_case_2_sgl(void) 6429 { 6430 return test_kasumi_auth_cipher_sgl( 6431 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1); 6432 } 6433 6434 static int 6435 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void) 6436 { 6437 return test_kasumi_auth_cipher_sgl( 6438 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1); 6439 } 6440 6441 static int 6442 test_kasumi_cipher_auth_test_case_1(void) 6443 { 6444 return test_kasumi_cipher_auth(&kasumi_test_case_6); 6445 } 6446 6447 static int 6448 test_zuc_encryption_test_case_1(void) 6449 { 6450 return test_zuc_encryption(&zuc_test_case_cipher_193b); 6451 } 6452 6453 static int 6454 test_zuc_encryption_test_case_2(void) 6455 { 6456 return test_zuc_encryption(&zuc_test_case_cipher_800b); 6457 } 6458 6459 static int 6460 test_zuc_encryption_test_case_3(void) 6461 { 6462 return test_zuc_encryption(&zuc_test_case_cipher_1570b); 6463 } 6464 6465 static int 6466 test_zuc_encryption_test_case_4(void) 6467 { 6468 return test_zuc_encryption(&zuc_test_case_cipher_2798b); 6469 } 6470 6471 static int 6472 test_zuc_encryption_test_case_5(void) 6473 { 6474 return test_zuc_encryption(&zuc_test_case_cipher_4019b); 6475 } 6476 6477 static int 6478 test_zuc_encryption_test_case_6_sgl(void) 6479 { 6480 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b); 6481 } 6482 6483 static int 6484 test_zuc_hash_generate_test_case_1(void) 6485 { 6486 return test_zuc_authentication(&zuc_test_case_auth_1b); 6487 } 6488 6489 static int 6490 test_zuc_hash_generate_test_case_2(void) 6491 { 6492 return test_zuc_authentication(&zuc_test_case_auth_90b); 6493 } 6494 6495 static int 6496 test_zuc_hash_generate_test_case_3(void) 6497 { 6498 return test_zuc_authentication(&zuc_test_case_auth_577b); 6499 } 6500 6501 static int 6502 test_zuc_hash_generate_test_case_4(void) 6503 { 6504 return test_zuc_authentication(&zuc_test_case_auth_2079b); 6505 } 6506 6507 static int 6508 test_zuc_hash_generate_test_case_5(void) 6509 { 6510 return test_zuc_authentication(&zuc_test_auth_5670b); 6511 } 6512 6513 static int 6514 test_zuc_hash_generate_test_case_6(void) 6515 { 6516 return test_zuc_authentication(&zuc_test_case_auth_128b); 6517 } 6518 6519 static int 6520 test_zuc_hash_generate_test_case_7(void) 6521 { 6522 return test_zuc_authentication(&zuc_test_case_auth_2080b); 6523 } 6524 6525 static int 6526 test_zuc_hash_generate_test_case_8(void) 6527 { 6528 return test_zuc_authentication(&zuc_test_case_auth_584b); 6529 } 6530 6531 static int 6532 test_zuc_cipher_auth_test_case_1(void) 6533 { 6534 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b); 6535 } 6536 6537 static int 6538 test_zuc_cipher_auth_test_case_2(void) 6539 { 6540 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b); 6541 } 6542 6543 static int 6544 test_zuc_auth_cipher_test_case_1(void) 6545 { 6546 return test_zuc_auth_cipher( 6547 &zuc_auth_cipher_test_case_1, IN_PLACE, 0); 6548 } 6549 6550 static int 6551 test_zuc_auth_cipher_test_case_1_oop(void) 6552 { 6553 return test_zuc_auth_cipher( 6554 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0); 6555 } 6556 6557 static int 6558 test_zuc_auth_cipher_test_case_1_sgl(void) 6559 { 6560 return test_zuc_auth_cipher_sgl( 6561 &zuc_auth_cipher_test_case_1, IN_PLACE, 0); 6562 } 6563 6564 static int 6565 test_zuc_auth_cipher_test_case_1_oop_sgl(void) 6566 { 6567 return test_zuc_auth_cipher_sgl( 6568 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0); 6569 } 6570 6571 static int 6572 test_zuc_auth_cipher_verify_test_case_1(void) 6573 { 6574 return test_zuc_auth_cipher( 6575 &zuc_auth_cipher_test_case_1, IN_PLACE, 1); 6576 } 6577 6578 static int 6579 test_zuc_auth_cipher_verify_test_case_1_oop(void) 6580 { 6581 return test_zuc_auth_cipher( 6582 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1); 6583 } 6584 6585 static int 6586 test_zuc_auth_cipher_verify_test_case_1_sgl(void) 6587 { 6588 return test_zuc_auth_cipher_sgl( 6589 &zuc_auth_cipher_test_case_1, IN_PLACE, 1); 6590 } 6591 6592 static int 6593 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void) 6594 { 6595 return test_zuc_auth_cipher_sgl( 6596 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1); 6597 } 6598 6599 static int 6600 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata) 6601 { 6602 uint8_t dev_id = testsuite_params.valid_devs[0]; 6603 6604 struct rte_cryptodev_sym_capability_idx cap_idx; 6605 6606 /* Check if device supports particular cipher algorithm */ 6607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 6608 cap_idx.algo.cipher = tdata->cipher_algo; 6609 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL) 6610 return -ENOTSUP; 6611 6612 /* Check if device supports particular hash algorithm */ 6613 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH; 6614 cap_idx.algo.auth = tdata->auth_algo; 6615 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL) 6616 return -ENOTSUP; 6617 6618 return 0; 6619 } 6620 6621 static int 6622 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata, 6623 uint8_t op_mode, uint8_t verify) 6624 { 6625 struct crypto_testsuite_params *ts_params = &testsuite_params; 6626 struct crypto_unittest_params *ut_params = &unittest_params; 6627 6628 int retval; 6629 6630 uint8_t *plaintext = NULL, *ciphertext = NULL; 6631 unsigned int plaintext_pad_len; 6632 unsigned int plaintext_len; 6633 unsigned int ciphertext_pad_len; 6634 unsigned int ciphertext_len; 6635 6636 struct rte_cryptodev_info dev_info; 6637 struct rte_crypto_op *op; 6638 6639 /* Check if device supports particular algorithms separately */ 6640 if (test_mixed_check_if_unsupported(tdata)) 6641 return -ENOTSUP; 6642 6643 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 6644 6645 uint64_t feat_flags = dev_info.feature_flags; 6646 6647 if (op_mode == OUT_OF_PLACE) { 6648 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { 6649 printf("Device doesn't support digest encrypted.\n"); 6650 return -ENOTSUP; 6651 } 6652 } 6653 6654 /* Create the session */ 6655 if (verify) 6656 retval = create_wireless_algo_cipher_auth_session( 6657 ts_params->valid_devs[0], 6658 RTE_CRYPTO_CIPHER_OP_DECRYPT, 6659 RTE_CRYPTO_AUTH_OP_VERIFY, 6660 tdata->auth_algo, 6661 tdata->cipher_algo, 6662 tdata->auth_key.data, tdata->auth_key.len, 6663 tdata->auth_iv.len, tdata->digest_enc.len, 6664 tdata->cipher_iv.len); 6665 else 6666 retval = create_wireless_algo_auth_cipher_session( 6667 ts_params->valid_devs[0], 6668 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 6669 RTE_CRYPTO_AUTH_OP_GENERATE, 6670 tdata->auth_algo, 6671 tdata->cipher_algo, 6672 tdata->auth_key.data, tdata->auth_key.len, 6673 tdata->auth_iv.len, tdata->digest_enc.len, 6674 tdata->cipher_iv.len); 6675 if (retval < 0) 6676 return retval; 6677 6678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 6679 if (op_mode == OUT_OF_PLACE) 6680 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 6681 6682 /* clear mbuf payload */ 6683 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 6684 rte_pktmbuf_tailroom(ut_params->ibuf)); 6685 if (op_mode == OUT_OF_PLACE) 6686 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, 6687 rte_pktmbuf_tailroom(ut_params->obuf)); 6688 6689 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits); 6690 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits); 6691 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 6692 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 6693 6694 if (verify) { 6695 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 6696 ciphertext_pad_len); 6697 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); 6698 if (op_mode == OUT_OF_PLACE) 6699 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); 6700 debug_hexdump(stdout, "ciphertext:", ciphertext, 6701 ciphertext_len); 6702 } else { 6703 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 6704 plaintext_pad_len); 6705 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 6706 if (op_mode == OUT_OF_PLACE) 6707 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); 6708 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); 6709 } 6710 6711 /* Create the operation */ 6712 retval = create_wireless_algo_auth_cipher_operation( 6713 tdata->digest_enc.data, tdata->digest_enc.len, 6714 tdata->cipher_iv.data, tdata->cipher_iv.len, 6715 tdata->auth_iv.data, tdata->auth_iv.len, 6716 (tdata->digest_enc.offset == 0 ? 6717 plaintext_pad_len 6718 : tdata->digest_enc.offset), 6719 tdata->validCipherLen.len_bits, 6720 tdata->cipher.offset_bits, 6721 tdata->validAuthLen.len_bits, 6722 tdata->auth.offset_bits, 6723 op_mode, 0, verify); 6724 6725 if (retval < 0) 6726 return retval; 6727 6728 op = process_crypto_request(ts_params->valid_devs[0], 6729 ut_params->op); 6730 6731 /* Check if the op failed because the device doesn't */ 6732 /* support this particular combination of algorithms */ 6733 if (op == NULL && ut_params->op->status == 6734 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) { 6735 printf("Device doesn't support this mixed combination. " 6736 "Test Skipped.\n"); 6737 return -ENOTSUP; 6738 } 6739 ut_params->op = op; 6740 6741 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 6742 6743 ut_params->obuf = (op_mode == IN_PLACE ? 6744 ut_params->op->sym->m_src : ut_params->op->sym->m_dst); 6745 6746 if (verify) { 6747 if (ut_params->obuf) 6748 plaintext = rte_pktmbuf_mtod(ut_params->obuf, 6749 uint8_t *); 6750 else 6751 plaintext = ciphertext + 6752 (tdata->cipher.offset_bits >> 3); 6753 6754 debug_hexdump(stdout, "plaintext:", plaintext, 6755 tdata->plaintext.len_bits >> 3); 6756 debug_hexdump(stdout, "plaintext expected:", 6757 tdata->plaintext.data, 6758 tdata->plaintext.len_bits >> 3); 6759 } else { 6760 if (ut_params->obuf) 6761 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, 6762 uint8_t *); 6763 else 6764 ciphertext = plaintext; 6765 6766 debug_hexdump(stdout, "ciphertext:", ciphertext, 6767 ciphertext_len); 6768 debug_hexdump(stdout, "ciphertext expected:", 6769 tdata->ciphertext.data, 6770 tdata->ciphertext.len_bits >> 3); 6771 6772 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) 6773 + (tdata->digest_enc.offset == 0 ? 6774 plaintext_pad_len : tdata->digest_enc.offset); 6775 6776 debug_hexdump(stdout, "digest:", ut_params->digest, 6777 tdata->digest_enc.len); 6778 debug_hexdump(stdout, "digest expected:", 6779 tdata->digest_enc.data, 6780 tdata->digest_enc.len); 6781 } 6782 6783 /* Validate obuf */ 6784 if (verify) { 6785 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 6786 plaintext, 6787 tdata->plaintext.data, 6788 tdata->plaintext.len_bits >> 3, 6789 "Plaintext data not as expected"); 6790 } else { 6791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 6792 ciphertext, 6793 tdata->ciphertext.data, 6794 tdata->validDataLen.len_bits, 6795 "Ciphertext data not as expected"); 6796 6797 TEST_ASSERT_BUFFERS_ARE_EQUAL( 6798 ut_params->digest, 6799 tdata->digest_enc.data, 6800 DIGEST_BYTE_LENGTH_SNOW3G_UIA2, 6801 "Generated auth tag not as expected"); 6802 } 6803 6804 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 6805 "crypto op processing failed"); 6806 6807 return 0; 6808 } 6809 6810 static int 6811 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata, 6812 uint8_t op_mode, uint8_t verify) 6813 { 6814 struct crypto_testsuite_params *ts_params = &testsuite_params; 6815 struct crypto_unittest_params *ut_params = &unittest_params; 6816 6817 int retval; 6818 6819 const uint8_t *plaintext = NULL; 6820 const uint8_t *ciphertext = NULL; 6821 const uint8_t *digest = NULL; 6822 unsigned int plaintext_pad_len; 6823 unsigned int plaintext_len; 6824 unsigned int ciphertext_pad_len; 6825 unsigned int ciphertext_len; 6826 uint8_t buffer[10000]; 6827 uint8_t digest_buffer[10000]; 6828 6829 struct rte_cryptodev_info dev_info; 6830 struct rte_crypto_op *op; 6831 6832 /* Check if device supports particular algorithms */ 6833 if (test_mixed_check_if_unsupported(tdata)) 6834 return -ENOTSUP; 6835 6836 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 6837 6838 uint64_t feat_flags = dev_info.feature_flags; 6839 6840 if (op_mode == IN_PLACE) { 6841 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { 6842 printf("Device doesn't support in-place scatter-gather " 6843 "in both input and output mbufs.\n"); 6844 return -ENOTSUP; 6845 } 6846 } else { 6847 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { 6848 printf("Device doesn't support out-of-place scatter-gather " 6849 "in both input and output mbufs.\n"); 6850 return -ENOTSUP; 6851 } 6852 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { 6853 printf("Device doesn't support digest encrypted.\n"); 6854 return -ENOTSUP; 6855 } 6856 } 6857 6858 /* Create the session */ 6859 if (verify) 6860 retval = create_wireless_algo_cipher_auth_session( 6861 ts_params->valid_devs[0], 6862 RTE_CRYPTO_CIPHER_OP_DECRYPT, 6863 RTE_CRYPTO_AUTH_OP_VERIFY, 6864 tdata->auth_algo, 6865 tdata->cipher_algo, 6866 tdata->auth_key.data, tdata->auth_key.len, 6867 tdata->auth_iv.len, tdata->digest_enc.len, 6868 tdata->cipher_iv.len); 6869 else 6870 retval = create_wireless_algo_auth_cipher_session( 6871 ts_params->valid_devs[0], 6872 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 6873 RTE_CRYPTO_AUTH_OP_GENERATE, 6874 tdata->auth_algo, 6875 tdata->cipher_algo, 6876 tdata->auth_key.data, tdata->auth_key.len, 6877 tdata->auth_iv.len, tdata->digest_enc.len, 6878 tdata->cipher_iv.len); 6879 if (retval < 0) 6880 return retval; 6881 6882 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits); 6883 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits); 6884 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); 6885 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); 6886 6887 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, 6888 ciphertext_pad_len, 15, 0); 6889 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 6890 "Failed to allocate input buffer in mempool"); 6891 6892 if (op_mode == OUT_OF_PLACE) { 6893 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool, 6894 plaintext_pad_len, 15, 0); 6895 TEST_ASSERT_NOT_NULL(ut_params->obuf, 6896 "Failed to allocate output buffer in mempool"); 6897 } 6898 6899 if (verify) { 6900 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, 6901 tdata->ciphertext.data); 6902 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 6903 ciphertext_len, buffer); 6904 debug_hexdump(stdout, "ciphertext:", ciphertext, 6905 ciphertext_len); 6906 } else { 6907 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, 6908 tdata->plaintext.data); 6909 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0, 6910 plaintext_len, buffer); 6911 debug_hexdump(stdout, "plaintext:", plaintext, 6912 plaintext_len); 6913 } 6914 memset(buffer, 0, sizeof(buffer)); 6915 6916 /* Create the operation */ 6917 retval = create_wireless_algo_auth_cipher_operation( 6918 tdata->digest_enc.data, tdata->digest_enc.len, 6919 tdata->cipher_iv.data, tdata->cipher_iv.len, 6920 tdata->auth_iv.data, tdata->auth_iv.len, 6921 (tdata->digest_enc.offset == 0 ? 6922 plaintext_pad_len 6923 : tdata->digest_enc.offset), 6924 tdata->validCipherLen.len_bits, 6925 tdata->cipher.offset_bits, 6926 tdata->validAuthLen.len_bits, 6927 tdata->auth.offset_bits, 6928 op_mode, 1, verify); 6929 6930 if (retval < 0) 6931 return retval; 6932 6933 op = process_crypto_request(ts_params->valid_devs[0], 6934 ut_params->op); 6935 6936 /* Check if the op failed because the device doesn't */ 6937 /* support this particular combination of algorithms */ 6938 if (op == NULL && ut_params->op->status == 6939 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) { 6940 printf("Device doesn't support this mixed combination. " 6941 "Test Skipped.\n"); 6942 return -ENOTSUP; 6943 } 6944 6945 ut_params->op = op; 6946 6947 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); 6948 6949 ut_params->obuf = (op_mode == IN_PLACE ? 6950 ut_params->op->sym->m_src : ut_params->op->sym->m_dst); 6951 6952 if (verify) { 6953 if (ut_params->obuf) 6954 plaintext = rte_pktmbuf_read(ut_params->obuf, 0, 6955 plaintext_len, buffer); 6956 else 6957 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0, 6958 plaintext_len, buffer); 6959 6960 debug_hexdump(stdout, "plaintext:", plaintext, 6961 (tdata->plaintext.len_bits >> 3) - 6962 tdata->digest_enc.len); 6963 debug_hexdump(stdout, "plaintext expected:", 6964 tdata->plaintext.data, 6965 (tdata->plaintext.len_bits >> 3) - 6966 tdata->digest_enc.len); 6967 } else { 6968 if (ut_params->obuf) 6969 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0, 6970 ciphertext_len, buffer); 6971 else 6972 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0, 6973 ciphertext_len, buffer); 6974 6975 debug_hexdump(stdout, "ciphertext:", ciphertext, 6976 ciphertext_len); 6977 debug_hexdump(stdout, "ciphertext expected:", 6978 tdata->ciphertext.data, 6979 tdata->ciphertext.len_bits >> 3); 6980 6981 if (ut_params->obuf) 6982 digest = rte_pktmbuf_read(ut_params->obuf, 6983 (tdata->digest_enc.offset == 0 ? 6984 plaintext_pad_len : 6985 tdata->digest_enc.offset), 6986 tdata->digest_enc.len, digest_buffer); 6987 else 6988 digest = rte_pktmbuf_read(ut_params->ibuf, 6989 (tdata->digest_enc.offset == 0 ? 6990 plaintext_pad_len : 6991 tdata->digest_enc.offset), 6992 tdata->digest_enc.len, digest_buffer); 6993 6994 debug_hexdump(stdout, "digest:", digest, 6995 tdata->digest_enc.len); 6996 debug_hexdump(stdout, "digest expected:", 6997 tdata->digest_enc.data, tdata->digest_enc.len); 6998 } 6999 7000 /* Validate obuf */ 7001 if (verify) { 7002 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 7003 plaintext, 7004 tdata->plaintext.data, 7005 tdata->plaintext.len_bits >> 3, 7006 "Plaintext data not as expected"); 7007 } else { 7008 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( 7009 ciphertext, 7010 tdata->ciphertext.data, 7011 tdata->validDataLen.len_bits, 7012 "Ciphertext data not as expected"); 7013 TEST_ASSERT_BUFFERS_ARE_EQUAL( 7014 digest, 7015 tdata->digest_enc.data, 7016 tdata->digest_enc.len, 7017 "Generated auth tag not as expected"); 7018 } 7019 7020 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 7021 "crypto op processing failed"); 7022 7023 return 0; 7024 } 7025 7026 /** AUTH AES CMAC + CIPHER AES CTR */ 7027 7028 static int 7029 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void) 7030 { 7031 return test_mixed_auth_cipher( 7032 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0); 7033 } 7034 7035 static int 7036 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void) 7037 { 7038 return test_mixed_auth_cipher( 7039 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0); 7040 } 7041 7042 static int 7043 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void) 7044 { 7045 return test_mixed_auth_cipher_sgl( 7046 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0); 7047 } 7048 7049 static int 7050 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void) 7051 { 7052 return test_mixed_auth_cipher_sgl( 7053 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0); 7054 } 7055 7056 static int 7057 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void) 7058 { 7059 return test_mixed_auth_cipher( 7060 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1); 7061 } 7062 7063 static int 7064 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void) 7065 { 7066 return test_mixed_auth_cipher( 7067 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1); 7068 } 7069 7070 static int 7071 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void) 7072 { 7073 return test_mixed_auth_cipher_sgl( 7074 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1); 7075 } 7076 7077 static int 7078 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void) 7079 { 7080 return test_mixed_auth_cipher_sgl( 7081 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1); 7082 } 7083 7084 /** MIXED AUTH + CIPHER */ 7085 7086 static int 7087 test_auth_zuc_cipher_snow_test_case_1(void) 7088 { 7089 return test_mixed_auth_cipher( 7090 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0); 7091 } 7092 7093 static int 7094 test_verify_auth_zuc_cipher_snow_test_case_1(void) 7095 { 7096 return test_mixed_auth_cipher( 7097 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1); 7098 } 7099 7100 static int 7101 test_auth_aes_cmac_cipher_snow_test_case_1(void) 7102 { 7103 return test_mixed_auth_cipher( 7104 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0); 7105 } 7106 7107 static int 7108 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void) 7109 { 7110 return test_mixed_auth_cipher( 7111 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1); 7112 } 7113 7114 static int 7115 test_auth_zuc_cipher_aes_ctr_test_case_1(void) 7116 { 7117 return test_mixed_auth_cipher( 7118 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0); 7119 } 7120 7121 static int 7122 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void) 7123 { 7124 return test_mixed_auth_cipher( 7125 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1); 7126 } 7127 7128 static int 7129 test_auth_snow_cipher_aes_ctr_test_case_1(void) 7130 { 7131 return test_mixed_auth_cipher( 7132 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0); 7133 } 7134 7135 static int 7136 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void) 7137 { 7138 return test_mixed_auth_cipher( 7139 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1); 7140 } 7141 7142 static int 7143 test_auth_snow_cipher_zuc_test_case_1(void) 7144 { 7145 return test_mixed_auth_cipher( 7146 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0); 7147 } 7148 7149 static int 7150 test_verify_auth_snow_cipher_zuc_test_case_1(void) 7151 { 7152 return test_mixed_auth_cipher( 7153 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1); 7154 } 7155 7156 static int 7157 test_auth_aes_cmac_cipher_zuc_test_case_1(void) 7158 { 7159 return test_mixed_auth_cipher( 7160 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0); 7161 } 7162 7163 static int 7164 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void) 7165 { 7166 return test_mixed_auth_cipher( 7167 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1); 7168 } 7169 7170 static int 7171 test_auth_null_cipher_snow_test_case_1(void) 7172 { 7173 return test_mixed_auth_cipher( 7174 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0); 7175 } 7176 7177 static int 7178 test_verify_auth_null_cipher_snow_test_case_1(void) 7179 { 7180 return test_mixed_auth_cipher( 7181 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1); 7182 } 7183 7184 static int 7185 test_auth_null_cipher_zuc_test_case_1(void) 7186 { 7187 return test_mixed_auth_cipher( 7188 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0); 7189 } 7190 7191 static int 7192 test_verify_auth_null_cipher_zuc_test_case_1(void) 7193 { 7194 return test_mixed_auth_cipher( 7195 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1); 7196 } 7197 7198 static int 7199 test_auth_snow_cipher_null_test_case_1(void) 7200 { 7201 return test_mixed_auth_cipher( 7202 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0); 7203 } 7204 7205 static int 7206 test_verify_auth_snow_cipher_null_test_case_1(void) 7207 { 7208 return test_mixed_auth_cipher( 7209 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1); 7210 } 7211 7212 static int 7213 test_auth_zuc_cipher_null_test_case_1(void) 7214 { 7215 return test_mixed_auth_cipher( 7216 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0); 7217 } 7218 7219 static int 7220 test_verify_auth_zuc_cipher_null_test_case_1(void) 7221 { 7222 return test_mixed_auth_cipher( 7223 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1); 7224 } 7225 7226 static int 7227 test_auth_null_cipher_aes_ctr_test_case_1(void) 7228 { 7229 return test_mixed_auth_cipher( 7230 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0); 7231 } 7232 7233 static int 7234 test_verify_auth_null_cipher_aes_ctr_test_case_1(void) 7235 { 7236 return test_mixed_auth_cipher( 7237 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1); 7238 } 7239 7240 static int 7241 test_auth_aes_cmac_cipher_null_test_case_1(void) 7242 { 7243 return test_mixed_auth_cipher( 7244 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0); 7245 } 7246 7247 static int 7248 test_verify_auth_aes_cmac_cipher_null_test_case_1(void) 7249 { 7250 return test_mixed_auth_cipher( 7251 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1); 7252 } 7253 7254 static int 7255 test_3DES_chain_qat_all(void) 7256 { 7257 struct crypto_testsuite_params *ts_params = &testsuite_params; 7258 int status; 7259 7260 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7261 ts_params->op_mpool, 7262 ts_params->session_mpool, ts_params->session_priv_mpool, 7263 ts_params->valid_devs[0], 7264 rte_cryptodev_driver_id_get( 7265 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), 7266 BLKCIPHER_3DES_CHAIN_TYPE); 7267 7268 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7269 7270 return TEST_SUCCESS; 7271 } 7272 7273 static int 7274 test_DES_cipheronly_qat_all(void) 7275 { 7276 struct crypto_testsuite_params *ts_params = &testsuite_params; 7277 int status; 7278 7279 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7280 ts_params->op_mpool, 7281 ts_params->session_mpool, ts_params->session_priv_mpool, 7282 ts_params->valid_devs[0], 7283 rte_cryptodev_driver_id_get( 7284 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), 7285 BLKCIPHER_DES_CIPHERONLY_TYPE); 7286 7287 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7288 7289 return TEST_SUCCESS; 7290 } 7291 7292 static int 7293 test_DES_cipheronly_openssl_all(void) 7294 { 7295 struct crypto_testsuite_params *ts_params = &testsuite_params; 7296 int status; 7297 7298 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7299 ts_params->op_mpool, 7300 ts_params->session_mpool, ts_params->session_priv_mpool, 7301 ts_params->valid_devs[0], 7302 rte_cryptodev_driver_id_get( 7303 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)), 7304 BLKCIPHER_DES_CIPHERONLY_TYPE); 7305 7306 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7307 7308 return TEST_SUCCESS; 7309 } 7310 7311 static int 7312 test_DES_docsis_openssl_all(void) 7313 { 7314 struct crypto_testsuite_params *ts_params = &testsuite_params; 7315 int status; 7316 7317 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7318 ts_params->op_mpool, 7319 ts_params->session_mpool, ts_params->session_priv_mpool, 7320 ts_params->valid_devs[0], 7321 rte_cryptodev_driver_id_get( 7322 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)), 7323 BLKCIPHER_DES_DOCSIS_TYPE); 7324 7325 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7326 7327 return TEST_SUCCESS; 7328 } 7329 7330 static int 7331 test_DES_cipheronly_mb_all(void) 7332 { 7333 struct crypto_testsuite_params *ts_params = &testsuite_params; 7334 int status; 7335 7336 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7337 ts_params->op_mpool, 7338 ts_params->session_mpool, ts_params->session_priv_mpool, 7339 ts_params->valid_devs[0], 7340 rte_cryptodev_driver_id_get( 7341 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), 7342 BLKCIPHER_DES_CIPHERONLY_TYPE); 7343 7344 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7345 7346 return TEST_SUCCESS; 7347 } 7348 static int 7349 test_3DES_cipheronly_mb_all(void) 7350 { 7351 struct crypto_testsuite_params *ts_params = &testsuite_params; 7352 int status; 7353 7354 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7355 ts_params->op_mpool, 7356 ts_params->session_mpool, ts_params->session_priv_mpool, 7357 ts_params->valid_devs[0], 7358 rte_cryptodev_driver_id_get( 7359 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), 7360 BLKCIPHER_3DES_CIPHERONLY_TYPE); 7361 7362 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7363 7364 return TEST_SUCCESS; 7365 } 7366 7367 static int 7368 test_DES_docsis_mb_all(void) 7369 { 7370 struct crypto_testsuite_params *ts_params = &testsuite_params; 7371 int status; 7372 7373 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7374 ts_params->op_mpool, 7375 ts_params->session_mpool, ts_params->session_priv_mpool, 7376 ts_params->valid_devs[0], 7377 rte_cryptodev_driver_id_get( 7378 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)), 7379 BLKCIPHER_DES_DOCSIS_TYPE); 7380 7381 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7382 7383 return TEST_SUCCESS; 7384 } 7385 7386 static int 7387 test_3DES_chain_caam_jr_all(void) 7388 { 7389 struct crypto_testsuite_params *ts_params = &testsuite_params; 7390 int status; 7391 7392 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7393 ts_params->op_mpool, 7394 ts_params->session_mpool, ts_params->session_priv_mpool, 7395 ts_params->valid_devs[0], 7396 rte_cryptodev_driver_id_get( 7397 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)), 7398 BLKCIPHER_3DES_CHAIN_TYPE); 7399 7400 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7401 7402 return TEST_SUCCESS; 7403 } 7404 7405 static int 7406 test_3DES_cipheronly_caam_jr_all(void) 7407 { 7408 struct crypto_testsuite_params *ts_params = &testsuite_params; 7409 int status; 7410 7411 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7412 ts_params->op_mpool, 7413 ts_params->session_mpool, ts_params->session_priv_mpool, 7414 ts_params->valid_devs[0], 7415 rte_cryptodev_driver_id_get( 7416 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)), 7417 BLKCIPHER_3DES_CIPHERONLY_TYPE); 7418 7419 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7420 7421 return TEST_SUCCESS; 7422 } 7423 7424 static int 7425 test_3DES_chain_dpaa_sec_all(void) 7426 { 7427 struct crypto_testsuite_params *ts_params = &testsuite_params; 7428 int status; 7429 7430 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7431 ts_params->op_mpool, 7432 ts_params->session_mpool, ts_params->session_priv_mpool, 7433 ts_params->valid_devs[0], 7434 rte_cryptodev_driver_id_get( 7435 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)), 7436 BLKCIPHER_3DES_CHAIN_TYPE); 7437 7438 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7439 7440 return TEST_SUCCESS; 7441 } 7442 7443 static int 7444 test_3DES_cipheronly_dpaa_sec_all(void) 7445 { 7446 struct crypto_testsuite_params *ts_params = &testsuite_params; 7447 int status; 7448 7449 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7450 ts_params->op_mpool, 7451 ts_params->session_mpool, ts_params->session_priv_mpool, 7452 ts_params->valid_devs[0], 7453 rte_cryptodev_driver_id_get( 7454 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)), 7455 BLKCIPHER_3DES_CIPHERONLY_TYPE); 7456 7457 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7458 7459 return TEST_SUCCESS; 7460 } 7461 7462 static int 7463 test_3DES_chain_dpaa2_sec_all(void) 7464 { 7465 struct crypto_testsuite_params *ts_params = &testsuite_params; 7466 int status; 7467 7468 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7469 ts_params->op_mpool, 7470 ts_params->session_mpool, ts_params->session_priv_mpool, 7471 ts_params->valid_devs[0], 7472 rte_cryptodev_driver_id_get( 7473 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)), 7474 BLKCIPHER_3DES_CHAIN_TYPE); 7475 7476 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7477 7478 return TEST_SUCCESS; 7479 } 7480 7481 static int 7482 test_3DES_cipheronly_dpaa2_sec_all(void) 7483 { 7484 struct crypto_testsuite_params *ts_params = &testsuite_params; 7485 int status; 7486 7487 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7488 ts_params->op_mpool, 7489 ts_params->session_mpool, ts_params->session_priv_mpool, 7490 ts_params->valid_devs[0], 7491 rte_cryptodev_driver_id_get( 7492 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)), 7493 BLKCIPHER_3DES_CIPHERONLY_TYPE); 7494 7495 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7496 7497 return TEST_SUCCESS; 7498 } 7499 7500 static int 7501 test_3DES_chain_ccp_all(void) 7502 { 7503 struct crypto_testsuite_params *ts_params = &testsuite_params; 7504 int status; 7505 7506 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7507 ts_params->op_mpool, 7508 ts_params->session_mpool, ts_params->session_priv_mpool, 7509 ts_params->valid_devs[0], 7510 rte_cryptodev_driver_id_get( 7511 RTE_STR(CRYPTODEV_NAME_CCP_PMD)), 7512 BLKCIPHER_3DES_CHAIN_TYPE); 7513 7514 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7515 7516 return TEST_SUCCESS; 7517 } 7518 7519 static int 7520 test_3DES_cipheronly_ccp_all(void) 7521 { 7522 struct crypto_testsuite_params *ts_params = &testsuite_params; 7523 int status; 7524 7525 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7526 ts_params->op_mpool, 7527 ts_params->session_mpool, ts_params->session_priv_mpool, 7528 ts_params->valid_devs[0], 7529 rte_cryptodev_driver_id_get( 7530 RTE_STR(CRYPTODEV_NAME_CCP_PMD)), 7531 BLKCIPHER_3DES_CIPHERONLY_TYPE); 7532 7533 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7534 7535 return TEST_SUCCESS; 7536 } 7537 7538 static int 7539 test_3DES_cipheronly_qat_all(void) 7540 { 7541 struct crypto_testsuite_params *ts_params = &testsuite_params; 7542 int status; 7543 7544 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7545 ts_params->op_mpool, 7546 ts_params->session_mpool, ts_params->session_priv_mpool, 7547 ts_params->valid_devs[0], 7548 rte_cryptodev_driver_id_get( 7549 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)), 7550 BLKCIPHER_3DES_CIPHERONLY_TYPE); 7551 7552 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7553 7554 return TEST_SUCCESS; 7555 } 7556 7557 static int 7558 test_3DES_chain_openssl_all(void) 7559 { 7560 struct crypto_testsuite_params *ts_params = &testsuite_params; 7561 int status; 7562 7563 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7564 ts_params->op_mpool, 7565 ts_params->session_mpool, ts_params->session_priv_mpool, 7566 ts_params->valid_devs[0], 7567 rte_cryptodev_driver_id_get( 7568 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)), 7569 BLKCIPHER_3DES_CHAIN_TYPE); 7570 7571 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7572 7573 return TEST_SUCCESS; 7574 } 7575 7576 static int 7577 test_3DES_cipheronly_openssl_all(void) 7578 { 7579 struct crypto_testsuite_params *ts_params = &testsuite_params; 7580 int status; 7581 7582 status = test_blockcipher_all_tests(ts_params->mbuf_pool, 7583 ts_params->op_mpool, 7584 ts_params->session_mpool, ts_params->session_priv_mpool, 7585 ts_params->valid_devs[0], 7586 rte_cryptodev_driver_id_get( 7587 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)), 7588 BLKCIPHER_3DES_CIPHERONLY_TYPE); 7589 7590 TEST_ASSERT_EQUAL(status, 0, "Test failed"); 7591 7592 return TEST_SUCCESS; 7593 } 7594 7595 /* ***** AEAD algorithm Tests ***** */ 7596 7597 static int 7598 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo, 7599 enum rte_crypto_aead_operation op, 7600 const uint8_t *key, const uint8_t key_len, 7601 const uint16_t aad_len, const uint8_t auth_len, 7602 uint8_t iv_len) 7603 { 7604 uint8_t aead_key[key_len]; 7605 7606 struct crypto_testsuite_params *ts_params = &testsuite_params; 7607 struct crypto_unittest_params *ut_params = &unittest_params; 7608 7609 memcpy(aead_key, key, key_len); 7610 7611 /* Setup AEAD Parameters */ 7612 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD; 7613 ut_params->aead_xform.next = NULL; 7614 ut_params->aead_xform.aead.algo = algo; 7615 ut_params->aead_xform.aead.op = op; 7616 ut_params->aead_xform.aead.key.data = aead_key; 7617 ut_params->aead_xform.aead.key.length = key_len; 7618 ut_params->aead_xform.aead.iv.offset = IV_OFFSET; 7619 ut_params->aead_xform.aead.iv.length = iv_len; 7620 ut_params->aead_xform.aead.digest_length = auth_len; 7621 ut_params->aead_xform.aead.aad_length = aad_len; 7622 7623 debug_hexdump(stdout, "key:", key, key_len); 7624 7625 /* Create Crypto session*/ 7626 ut_params->sess = rte_cryptodev_sym_session_create( 7627 ts_params->session_mpool); 7628 7629 rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 7630 &ut_params->aead_xform, 7631 ts_params->session_priv_mpool); 7632 7633 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 7634 7635 return 0; 7636 } 7637 7638 static int 7639 create_aead_xform(struct rte_crypto_op *op, 7640 enum rte_crypto_aead_algorithm algo, 7641 enum rte_crypto_aead_operation aead_op, 7642 uint8_t *key, const uint8_t key_len, 7643 const uint8_t aad_len, const uint8_t auth_len, 7644 uint8_t iv_len) 7645 { 7646 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1), 7647 "failed to allocate space for crypto transform"); 7648 7649 struct rte_crypto_sym_op *sym_op = op->sym; 7650 7651 /* Setup AEAD Parameters */ 7652 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD; 7653 sym_op->xform->next = NULL; 7654 sym_op->xform->aead.algo = algo; 7655 sym_op->xform->aead.op = aead_op; 7656 sym_op->xform->aead.key.data = key; 7657 sym_op->xform->aead.key.length = key_len; 7658 sym_op->xform->aead.iv.offset = IV_OFFSET; 7659 sym_op->xform->aead.iv.length = iv_len; 7660 sym_op->xform->aead.digest_length = auth_len; 7661 sym_op->xform->aead.aad_length = aad_len; 7662 7663 debug_hexdump(stdout, "key:", key, key_len); 7664 7665 return 0; 7666 } 7667 7668 static int 7669 create_aead_operation(enum rte_crypto_aead_operation op, 7670 const struct aead_test_data *tdata) 7671 { 7672 struct crypto_testsuite_params *ts_params = &testsuite_params; 7673 struct crypto_unittest_params *ut_params = &unittest_params; 7674 7675 uint8_t *plaintext, *ciphertext; 7676 unsigned int aad_pad_len, plaintext_pad_len; 7677 7678 /* Generate Crypto op data structure */ 7679 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 7680 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 7681 TEST_ASSERT_NOT_NULL(ut_params->op, 7682 "Failed to allocate symmetric crypto operation struct"); 7683 7684 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 7685 7686 /* Append aad data */ 7687 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) { 7688 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16); 7689 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 7690 aad_pad_len); 7691 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data, 7692 "no room to append aad"); 7693 7694 sym_op->aead.aad.phys_addr = 7695 rte_pktmbuf_iova(ut_params->ibuf); 7696 /* Copy AAD 18 bytes after the AAD pointer, according to the API */ 7697 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len); 7698 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data, 7699 tdata->aad.len); 7700 7701 /* Append IV at the end of the crypto operation*/ 7702 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, 7703 uint8_t *, IV_OFFSET); 7704 7705 /* Copy IV 1 byte after the IV pointer, according to the API */ 7706 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len); 7707 debug_hexdump(stdout, "iv:", iv_ptr, 7708 tdata->iv.len); 7709 } else { 7710 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16); 7711 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 7712 aad_pad_len); 7713 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data, 7714 "no room to append aad"); 7715 7716 sym_op->aead.aad.phys_addr = 7717 rte_pktmbuf_iova(ut_params->ibuf); 7718 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len); 7719 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data, 7720 tdata->aad.len); 7721 7722 /* Append IV at the end of the crypto operation*/ 7723 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, 7724 uint8_t *, IV_OFFSET); 7725 7726 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len); 7727 debug_hexdump(stdout, "iv:", iv_ptr, 7728 tdata->iv.len); 7729 } 7730 7731 /* Append plaintext/ciphertext */ 7732 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) { 7733 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16); 7734 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 7735 plaintext_pad_len); 7736 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); 7737 7738 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len); 7739 debug_hexdump(stdout, "plaintext:", plaintext, 7740 tdata->plaintext.len); 7741 7742 if (ut_params->obuf) { 7743 ciphertext = (uint8_t *)rte_pktmbuf_append( 7744 ut_params->obuf, 7745 plaintext_pad_len + aad_pad_len); 7746 TEST_ASSERT_NOT_NULL(ciphertext, 7747 "no room to append ciphertext"); 7748 7749 memset(ciphertext + aad_pad_len, 0, 7750 tdata->ciphertext.len); 7751 } 7752 } else { 7753 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16); 7754 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 7755 plaintext_pad_len); 7756 TEST_ASSERT_NOT_NULL(ciphertext, 7757 "no room to append ciphertext"); 7758 7759 memcpy(ciphertext, tdata->ciphertext.data, 7760 tdata->ciphertext.len); 7761 debug_hexdump(stdout, "ciphertext:", ciphertext, 7762 tdata->ciphertext.len); 7763 7764 if (ut_params->obuf) { 7765 plaintext = (uint8_t *)rte_pktmbuf_append( 7766 ut_params->obuf, 7767 plaintext_pad_len + aad_pad_len); 7768 TEST_ASSERT_NOT_NULL(plaintext, 7769 "no room to append plaintext"); 7770 7771 memset(plaintext + aad_pad_len, 0, 7772 tdata->plaintext.len); 7773 } 7774 } 7775 7776 /* Append digest data */ 7777 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) { 7778 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append( 7779 ut_params->obuf ? ut_params->obuf : 7780 ut_params->ibuf, 7781 tdata->auth_tag.len); 7782 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data, 7783 "no room to append digest"); 7784 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len); 7785 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset( 7786 ut_params->obuf ? ut_params->obuf : 7787 ut_params->ibuf, 7788 plaintext_pad_len + 7789 aad_pad_len); 7790 } else { 7791 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append( 7792 ut_params->ibuf, tdata->auth_tag.len); 7793 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data, 7794 "no room to append digest"); 7795 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset( 7796 ut_params->ibuf, 7797 plaintext_pad_len + aad_pad_len); 7798 7799 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data, 7800 tdata->auth_tag.len); 7801 debug_hexdump(stdout, "digest:", 7802 sym_op->aead.digest.data, 7803 tdata->auth_tag.len); 7804 } 7805 7806 sym_op->aead.data.length = tdata->plaintext.len; 7807 sym_op->aead.data.offset = aad_pad_len; 7808 7809 return 0; 7810 } 7811 7812 static int 7813 test_authenticated_encryption(const struct aead_test_data *tdata) 7814 { 7815 struct crypto_testsuite_params *ts_params = &testsuite_params; 7816 struct crypto_unittest_params *ut_params = &unittest_params; 7817 7818 int retval; 7819 uint8_t *ciphertext, *auth_tag; 7820 uint16_t plaintext_pad_len; 7821 uint32_t i; 7822 7823 /* Create AEAD session */ 7824 retval = create_aead_session(ts_params->valid_devs[0], 7825 tdata->algo, 7826 RTE_CRYPTO_AEAD_OP_ENCRYPT, 7827 tdata->key.data, tdata->key.len, 7828 tdata->aad.len, tdata->auth_tag.len, 7829 tdata->iv.len); 7830 if (retval < 0) 7831 return retval; 7832 7833 if (tdata->aad.len > MBUF_SIZE) { 7834 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); 7835 /* Populate full size of add data */ 7836 for (i = 32; i < MAX_AAD_LENGTH; i += 32) 7837 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32); 7838 } else 7839 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 7840 7841 /* clear mbuf payload */ 7842 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 7843 rte_pktmbuf_tailroom(ut_params->ibuf)); 7844 7845 /* Create AEAD operation */ 7846 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); 7847 if (retval < 0) 7848 return retval; 7849 7850 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 7851 7852 ut_params->op->sym->m_src = ut_params->ibuf; 7853 7854 /* Process crypto operation */ 7855 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 7856 ut_params->op), "failed to process sym crypto op"); 7857 7858 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 7859 "crypto op processing failed"); 7860 7861 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16); 7862 7863 if (ut_params->op->sym->m_dst) { 7864 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst, 7865 uint8_t *); 7866 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst, 7867 uint8_t *, plaintext_pad_len); 7868 } else { 7869 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src, 7870 uint8_t *, 7871 ut_params->op->sym->cipher.data.offset); 7872 auth_tag = ciphertext + plaintext_pad_len; 7873 } 7874 7875 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); 7876 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); 7877 7878 /* Validate obuf */ 7879 TEST_ASSERT_BUFFERS_ARE_EQUAL( 7880 ciphertext, 7881 tdata->ciphertext.data, 7882 tdata->ciphertext.len, 7883 "Ciphertext data not as expected"); 7884 7885 TEST_ASSERT_BUFFERS_ARE_EQUAL( 7886 auth_tag, 7887 tdata->auth_tag.data, 7888 tdata->auth_tag.len, 7889 "Generated auth tag not as expected"); 7890 7891 return 0; 7892 7893 } 7894 7895 #ifdef RTE_LIBRTE_SECURITY 7896 /* Basic algorithm run function for async inplace mode. 7897 * Creates a session from input parameters and runs one operation 7898 * on input_vec. Checks the output of the crypto operation against 7899 * output_vec. 7900 */ 7901 static int 7902 test_pdcp_proto(int i, int oop, 7903 enum rte_crypto_cipher_operation opc, 7904 enum rte_crypto_auth_operation opa, 7905 uint8_t *input_vec, 7906 unsigned int input_vec_len, 7907 uint8_t *output_vec, 7908 unsigned int output_vec_len) 7909 { 7910 struct crypto_testsuite_params *ts_params = &testsuite_params; 7911 struct crypto_unittest_params *ut_params = &unittest_params; 7912 uint8_t *plaintext; 7913 int ret = TEST_SUCCESS; 7914 7915 /* Generate test mbuf data */ 7916 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 7917 7918 /* clear mbuf payload */ 7919 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 7920 rte_pktmbuf_tailroom(ut_params->ibuf)); 7921 7922 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 7923 input_vec_len); 7924 memcpy(plaintext, input_vec, input_vec_len); 7925 7926 /* Out of place support */ 7927 if (oop) { 7928 /* 7929 * For out-op-place we need to alloc another mbuf 7930 */ 7931 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 7932 rte_pktmbuf_append(ut_params->obuf, output_vec_len); 7933 } 7934 7935 /* Set crypto type as IPSEC */ 7936 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL; 7937 7938 /* Setup Cipher Parameters */ 7939 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 7940 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg; 7941 ut_params->cipher_xform.cipher.op = opc; 7942 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i]; 7943 ut_params->cipher_xform.cipher.key.length = 7944 pdcp_test_params[i].cipher_key_len; 7945 ut_params->cipher_xform.cipher.iv.length = 0; 7946 7947 /* Setup HMAC Parameters if ICV header is required */ 7948 if (pdcp_test_params[i].auth_alg != 0) { 7949 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 7950 ut_params->auth_xform.next = NULL; 7951 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg; 7952 ut_params->auth_xform.auth.op = opa; 7953 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i]; 7954 ut_params->auth_xform.auth.key.length = 7955 pdcp_test_params[i].auth_key_len; 7956 7957 ut_params->cipher_xform.next = &ut_params->auth_xform; 7958 } else { 7959 ut_params->cipher_xform.next = NULL; 7960 } 7961 7962 struct rte_security_session_conf sess_conf = { 7963 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 7964 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 7965 {.pdcp = { 7966 .bearer = pdcp_test_bearer[i], 7967 .domain = pdcp_test_params[i].domain, 7968 .pkt_dir = pdcp_test_packet_direction[i], 7969 .sn_size = pdcp_test_data_sn_size[i], 7970 .hfn = pdcp_test_hfn[i], 7971 .hfn_threshold = pdcp_test_hfn_threshold[i], 7972 } }, 7973 .crypto_xform = &ut_params->cipher_xform 7974 }; 7975 7976 struct rte_security_ctx *ctx = (struct rte_security_ctx *) 7977 rte_cryptodev_get_sec_ctx( 7978 ts_params->valid_devs[0]); 7979 7980 /* Create security session */ 7981 ut_params->sec_session = rte_security_session_create(ctx, 7982 &sess_conf, ts_params->session_priv_mpool); 7983 7984 if (!ut_params->sec_session) { 7985 printf("TestCase %s()-%d line %d failed %s: ", 7986 __func__, i, __LINE__, "Failed to allocate session"); 7987 ret = TEST_FAILED; 7988 goto on_err; 7989 } 7990 7991 /* Generate crypto op data structure */ 7992 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 7993 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 7994 if (!ut_params->op) { 7995 printf("TestCase %s()-%d line %d failed %s: ", 7996 __func__, i, __LINE__, 7997 "Failed to allocate symmetric crypto operation struct"); 7998 ret = TEST_FAILED; 7999 goto on_err; 8000 } 8001 8002 rte_security_attach_session(ut_params->op, ut_params->sec_session); 8003 8004 /* set crypto operation source mbuf */ 8005 ut_params->op->sym->m_src = ut_params->ibuf; 8006 if (oop) 8007 ut_params->op->sym->m_dst = ut_params->obuf; 8008 8009 /* Process crypto operation */ 8010 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) 8011 == NULL) { 8012 printf("TestCase %s()-%d line %d failed %s: ", 8013 __func__, i, __LINE__, 8014 "failed to process sym crypto op"); 8015 ret = TEST_FAILED; 8016 goto on_err; 8017 } 8018 8019 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) { 8020 printf("TestCase %s()-%d line %d failed %s: ", 8021 __func__, i, __LINE__, "crypto op processing failed"); 8022 ret = TEST_FAILED; 8023 goto on_err; 8024 } 8025 8026 /* Validate obuf */ 8027 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src, 8028 uint8_t *); 8029 if (oop) { 8030 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst, 8031 uint8_t *); 8032 } 8033 8034 if (memcmp(ciphertext, output_vec, output_vec_len)) { 8035 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i); 8036 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len); 8037 rte_hexdump(stdout, "reference", output_vec, output_vec_len); 8038 ret = TEST_FAILED; 8039 goto on_err; 8040 } 8041 8042 on_err: 8043 rte_crypto_op_free(ut_params->op); 8044 ut_params->op = NULL; 8045 8046 if (ut_params->sec_session) 8047 rte_security_session_destroy(ctx, ut_params->sec_session); 8048 ut_params->sec_session = NULL; 8049 8050 rte_pktmbuf_free(ut_params->ibuf); 8051 ut_params->ibuf = NULL; 8052 if (oop) { 8053 rte_pktmbuf_free(ut_params->obuf); 8054 ut_params->obuf = NULL; 8055 } 8056 8057 return ret; 8058 } 8059 8060 static int 8061 test_pdcp_proto_SGL(int i, int oop, 8062 enum rte_crypto_cipher_operation opc, 8063 enum rte_crypto_auth_operation opa, 8064 uint8_t *input_vec, 8065 unsigned int input_vec_len, 8066 uint8_t *output_vec, 8067 unsigned int output_vec_len, 8068 uint32_t fragsz, 8069 uint32_t fragsz_oop) 8070 { 8071 struct crypto_testsuite_params *ts_params = &testsuite_params; 8072 struct crypto_unittest_params *ut_params = &unittest_params; 8073 uint8_t *plaintext; 8074 struct rte_mbuf *buf, *buf_oop = NULL; 8075 int ret = TEST_SUCCESS; 8076 int to_trn = 0; 8077 int to_trn_tbl[16]; 8078 int segs = 1; 8079 unsigned int trn_data = 0; 8080 8081 if (fragsz > input_vec_len) 8082 fragsz = input_vec_len; 8083 8084 uint16_t plaintext_len = fragsz; 8085 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz; 8086 8087 if (fragsz_oop > output_vec_len) 8088 frag_size_oop = output_vec_len; 8089 8090 int ecx = 0; 8091 if (input_vec_len % fragsz != 0) { 8092 if (input_vec_len / fragsz + 1 > 16) 8093 return 1; 8094 } else if (input_vec_len / fragsz > 16) 8095 return 1; 8096 8097 /* Out of place support */ 8098 if (oop) { 8099 /* 8100 * For out-op-place we need to alloc another mbuf 8101 */ 8102 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 8103 rte_pktmbuf_append(ut_params->obuf, frag_size_oop); 8104 buf_oop = ut_params->obuf; 8105 } 8106 8107 /* Generate test mbuf data */ 8108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 8109 8110 /* clear mbuf payload */ 8111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 8112 rte_pktmbuf_tailroom(ut_params->ibuf)); 8113 8114 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 8115 plaintext_len); 8116 memcpy(plaintext, input_vec, plaintext_len); 8117 trn_data += plaintext_len; 8118 8119 buf = ut_params->ibuf; 8120 8121 /* 8122 * Loop until no more fragments 8123 */ 8124 8125 while (trn_data < input_vec_len) { 8126 ++segs; 8127 to_trn = (input_vec_len - trn_data < fragsz) ? 8128 (input_vec_len - trn_data) : fragsz; 8129 8130 to_trn_tbl[ecx++] = to_trn; 8131 8132 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool); 8133 buf = buf->next; 8134 8135 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0, 8136 rte_pktmbuf_tailroom(buf)); 8137 8138 /* OOP */ 8139 if (oop && !fragsz_oop) { 8140 buf_oop->next = 8141 rte_pktmbuf_alloc(ts_params->mbuf_pool); 8142 buf_oop = buf_oop->next; 8143 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *), 8144 0, rte_pktmbuf_tailroom(buf_oop)); 8145 rte_pktmbuf_append(buf_oop, to_trn); 8146 } 8147 8148 plaintext = (uint8_t *)rte_pktmbuf_append(buf, 8149 to_trn); 8150 8151 memcpy(plaintext, input_vec + trn_data, to_trn); 8152 trn_data += to_trn; 8153 } 8154 8155 ut_params->ibuf->nb_segs = segs; 8156 8157 segs = 1; 8158 if (fragsz_oop && oop) { 8159 to_trn = 0; 8160 ecx = 0; 8161 8162 trn_data = frag_size_oop; 8163 while (trn_data < output_vec_len) { 8164 ++segs; 8165 to_trn = 8166 (output_vec_len - trn_data < 8167 frag_size_oop) ? 8168 (output_vec_len - trn_data) : 8169 frag_size_oop; 8170 8171 to_trn_tbl[ecx++] = to_trn; 8172 8173 buf_oop->next = 8174 rte_pktmbuf_alloc(ts_params->mbuf_pool); 8175 buf_oop = buf_oop->next; 8176 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *), 8177 0, rte_pktmbuf_tailroom(buf_oop)); 8178 rte_pktmbuf_append(buf_oop, to_trn); 8179 8180 trn_data += to_trn; 8181 } 8182 ut_params->obuf->nb_segs = segs; 8183 } 8184 8185 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL; 8186 8187 /* Setup Cipher Parameters */ 8188 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 8189 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg; 8190 ut_params->cipher_xform.cipher.op = opc; 8191 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i]; 8192 ut_params->cipher_xform.cipher.key.length = 8193 pdcp_test_params[i].cipher_key_len; 8194 ut_params->cipher_xform.cipher.iv.length = 0; 8195 8196 /* Setup HMAC Parameters if ICV header is required */ 8197 if (pdcp_test_params[i].auth_alg != 0) { 8198 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 8199 ut_params->auth_xform.next = NULL; 8200 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg; 8201 ut_params->auth_xform.auth.op = opa; 8202 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i]; 8203 ut_params->auth_xform.auth.key.length = 8204 pdcp_test_params[i].auth_key_len; 8205 8206 ut_params->cipher_xform.next = &ut_params->auth_xform; 8207 } else { 8208 ut_params->cipher_xform.next = NULL; 8209 } 8210 8211 struct rte_security_session_conf sess_conf = { 8212 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, 8213 .protocol = RTE_SECURITY_PROTOCOL_PDCP, 8214 {.pdcp = { 8215 .bearer = pdcp_test_bearer[i], 8216 .domain = pdcp_test_params[i].domain, 8217 .pkt_dir = pdcp_test_packet_direction[i], 8218 .sn_size = pdcp_test_data_sn_size[i], 8219 .hfn = pdcp_test_hfn[i], 8220 .hfn_threshold = pdcp_test_hfn_threshold[i], 8221 } }, 8222 .crypto_xform = &ut_params->cipher_xform 8223 }; 8224 8225 struct rte_security_ctx *ctx = (struct rte_security_ctx *) 8226 rte_cryptodev_get_sec_ctx( 8227 ts_params->valid_devs[0]); 8228 8229 /* Create security session */ 8230 ut_params->sec_session = rte_security_session_create(ctx, 8231 &sess_conf, ts_params->session_priv_mpool); 8232 8233 if (!ut_params->sec_session) { 8234 printf("TestCase %s()-%d line %d failed %s: ", 8235 __func__, i, __LINE__, "Failed to allocate session"); 8236 ret = TEST_FAILED; 8237 goto on_err; 8238 } 8239 8240 /* Generate crypto op data structure */ 8241 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 8242 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 8243 if (!ut_params->op) { 8244 printf("TestCase %s()-%d line %d failed %s: ", 8245 __func__, i, __LINE__, 8246 "Failed to allocate symmetric crypto operation struct"); 8247 ret = TEST_FAILED; 8248 goto on_err; 8249 } 8250 8251 rte_security_attach_session(ut_params->op, ut_params->sec_session); 8252 8253 /* set crypto operation source mbuf */ 8254 ut_params->op->sym->m_src = ut_params->ibuf; 8255 if (oop) 8256 ut_params->op->sym->m_dst = ut_params->obuf; 8257 8258 /* Process crypto operation */ 8259 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) 8260 == NULL) { 8261 printf("TestCase %s()-%d line %d failed %s: ", 8262 __func__, i, __LINE__, 8263 "failed to process sym crypto op"); 8264 ret = TEST_FAILED; 8265 goto on_err; 8266 } 8267 8268 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) { 8269 printf("TestCase %s()-%d line %d failed %s: ", 8270 __func__, i, __LINE__, "crypto op processing failed"); 8271 ret = TEST_FAILED; 8272 goto on_err; 8273 } 8274 8275 /* Validate obuf */ 8276 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src, 8277 uint8_t *); 8278 if (oop) { 8279 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst, 8280 uint8_t *); 8281 } 8282 if (fragsz_oop) 8283 fragsz = frag_size_oop; 8284 if (memcmp(ciphertext, output_vec, fragsz)) { 8285 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i); 8286 rte_hexdump(stdout, "encrypted", ciphertext, fragsz); 8287 rte_hexdump(stdout, "reference", output_vec, fragsz); 8288 ret = TEST_FAILED; 8289 goto on_err; 8290 } 8291 8292 buf = ut_params->op->sym->m_src->next; 8293 if (oop) 8294 buf = ut_params->op->sym->m_dst->next; 8295 8296 unsigned int off = fragsz; 8297 8298 ecx = 0; 8299 while (buf) { 8300 ciphertext = rte_pktmbuf_mtod(buf, 8301 uint8_t *); 8302 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) { 8303 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i); 8304 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]); 8305 rte_hexdump(stdout, "reference", output_vec + off, 8306 to_trn_tbl[ecx]); 8307 ret = TEST_FAILED; 8308 goto on_err; 8309 } 8310 off += to_trn_tbl[ecx++]; 8311 buf = buf->next; 8312 } 8313 on_err: 8314 rte_crypto_op_free(ut_params->op); 8315 ut_params->op = NULL; 8316 8317 if (ut_params->sec_session) 8318 rte_security_session_destroy(ctx, ut_params->sec_session); 8319 ut_params->sec_session = NULL; 8320 8321 rte_pktmbuf_free(ut_params->ibuf); 8322 ut_params->ibuf = NULL; 8323 if (oop) { 8324 rte_pktmbuf_free(ut_params->obuf); 8325 ut_params->obuf = NULL; 8326 } 8327 8328 return ret; 8329 } 8330 8331 int 8332 test_pdcp_proto_cplane_encap(int i) 8333 { 8334 return test_pdcp_proto(i, 0, 8335 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 8336 RTE_CRYPTO_AUTH_OP_GENERATE, 8337 pdcp_test_data_in[i], 8338 pdcp_test_data_in_len[i], 8339 pdcp_test_data_out[i], 8340 pdcp_test_data_in_len[i]+4); 8341 } 8342 8343 int 8344 test_pdcp_proto_uplane_encap(int i) 8345 { 8346 return test_pdcp_proto(i, 0, 8347 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 8348 RTE_CRYPTO_AUTH_OP_GENERATE, 8349 pdcp_test_data_in[i], 8350 pdcp_test_data_in_len[i], 8351 pdcp_test_data_out[i], 8352 pdcp_test_data_in_len[i]); 8353 8354 } 8355 8356 int 8357 test_pdcp_proto_uplane_encap_with_int(int i) 8358 { 8359 return test_pdcp_proto(i, 0, 8360 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 8361 RTE_CRYPTO_AUTH_OP_GENERATE, 8362 pdcp_test_data_in[i], 8363 pdcp_test_data_in_len[i], 8364 pdcp_test_data_out[i], 8365 pdcp_test_data_in_len[i] + 4); 8366 } 8367 8368 int 8369 test_pdcp_proto_cplane_decap(int i) 8370 { 8371 return test_pdcp_proto(i, 0, 8372 RTE_CRYPTO_CIPHER_OP_DECRYPT, 8373 RTE_CRYPTO_AUTH_OP_VERIFY, 8374 pdcp_test_data_out[i], 8375 pdcp_test_data_in_len[i] + 4, 8376 pdcp_test_data_in[i], 8377 pdcp_test_data_in_len[i]); 8378 } 8379 8380 int 8381 test_pdcp_proto_uplane_decap(int i) 8382 { 8383 return test_pdcp_proto(i, 0, 8384 RTE_CRYPTO_CIPHER_OP_DECRYPT, 8385 RTE_CRYPTO_AUTH_OP_VERIFY, 8386 pdcp_test_data_out[i], 8387 pdcp_test_data_in_len[i], 8388 pdcp_test_data_in[i], 8389 pdcp_test_data_in_len[i]); 8390 } 8391 8392 int 8393 test_pdcp_proto_uplane_decap_with_int(int i) 8394 { 8395 return test_pdcp_proto(i, 0, 8396 RTE_CRYPTO_CIPHER_OP_DECRYPT, 8397 RTE_CRYPTO_AUTH_OP_VERIFY, 8398 pdcp_test_data_out[i], 8399 pdcp_test_data_in_len[i] + 4, 8400 pdcp_test_data_in[i], 8401 pdcp_test_data_in_len[i]); 8402 } 8403 8404 static int 8405 test_PDCP_PROTO_SGL_in_place_32B(void) 8406 { 8407 /* i can be used for running any PDCP case 8408 * In this case it is uplane 12-bit AES-SNOW DL encap 8409 */ 8410 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK; 8411 return test_pdcp_proto_SGL(i, IN_PLACE, 8412 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 8413 RTE_CRYPTO_AUTH_OP_GENERATE, 8414 pdcp_test_data_in[i], 8415 pdcp_test_data_in_len[i], 8416 pdcp_test_data_out[i], 8417 pdcp_test_data_in_len[i]+4, 8418 32, 0); 8419 } 8420 static int 8421 test_PDCP_PROTO_SGL_oop_32B_128B(void) 8422 { 8423 /* i can be used for running any PDCP case 8424 * In this case it is uplane 18-bit NULL-NULL DL encap 8425 */ 8426 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK; 8427 return test_pdcp_proto_SGL(i, OUT_OF_PLACE, 8428 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 8429 RTE_CRYPTO_AUTH_OP_GENERATE, 8430 pdcp_test_data_in[i], 8431 pdcp_test_data_in_len[i], 8432 pdcp_test_data_out[i], 8433 pdcp_test_data_in_len[i]+4, 8434 32, 128); 8435 } 8436 static int 8437 test_PDCP_PROTO_SGL_oop_32B_40B(void) 8438 { 8439 /* i can be used for running any PDCP case 8440 * In this case it is uplane 18-bit AES DL encap 8441 */ 8442 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET 8443 + DOWNLINK; 8444 return test_pdcp_proto_SGL(i, OUT_OF_PLACE, 8445 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 8446 RTE_CRYPTO_AUTH_OP_GENERATE, 8447 pdcp_test_data_in[i], 8448 pdcp_test_data_in_len[i], 8449 pdcp_test_data_out[i], 8450 pdcp_test_data_in_len[i], 8451 32, 40); 8452 } 8453 static int 8454 test_PDCP_PROTO_SGL_oop_128B_32B(void) 8455 { 8456 /* i can be used for running any PDCP case 8457 * In this case it is cplane 12-bit AES-ZUC DL encap 8458 */ 8459 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK; 8460 return test_pdcp_proto_SGL(i, OUT_OF_PLACE, 8461 RTE_CRYPTO_CIPHER_OP_ENCRYPT, 8462 RTE_CRYPTO_AUTH_OP_GENERATE, 8463 pdcp_test_data_in[i], 8464 pdcp_test_data_in_len[i], 8465 pdcp_test_data_out[i], 8466 pdcp_test_data_in_len[i]+4, 8467 128, 32); 8468 } 8469 #endif 8470 8471 static int 8472 test_AES_GCM_authenticated_encryption_test_case_1(void) 8473 { 8474 return test_authenticated_encryption(&gcm_test_case_1); 8475 } 8476 8477 static int 8478 test_AES_GCM_authenticated_encryption_test_case_2(void) 8479 { 8480 return test_authenticated_encryption(&gcm_test_case_2); 8481 } 8482 8483 static int 8484 test_AES_GCM_authenticated_encryption_test_case_3(void) 8485 { 8486 return test_authenticated_encryption(&gcm_test_case_3); 8487 } 8488 8489 static int 8490 test_AES_GCM_authenticated_encryption_test_case_4(void) 8491 { 8492 return test_authenticated_encryption(&gcm_test_case_4); 8493 } 8494 8495 static int 8496 test_AES_GCM_authenticated_encryption_test_case_5(void) 8497 { 8498 return test_authenticated_encryption(&gcm_test_case_5); 8499 } 8500 8501 static int 8502 test_AES_GCM_authenticated_encryption_test_case_6(void) 8503 { 8504 return test_authenticated_encryption(&gcm_test_case_6); 8505 } 8506 8507 static int 8508 test_AES_GCM_authenticated_encryption_test_case_7(void) 8509 { 8510 return test_authenticated_encryption(&gcm_test_case_7); 8511 } 8512 8513 static int 8514 test_AES_GCM_authenticated_encryption_test_case_8(void) 8515 { 8516 return test_authenticated_encryption(&gcm_test_case_8); 8517 } 8518 8519 static int 8520 test_AES_GCM_auth_encryption_test_case_192_1(void) 8521 { 8522 return test_authenticated_encryption(&gcm_test_case_192_1); 8523 } 8524 8525 static int 8526 test_AES_GCM_auth_encryption_test_case_192_2(void) 8527 { 8528 return test_authenticated_encryption(&gcm_test_case_192_2); 8529 } 8530 8531 static int 8532 test_AES_GCM_auth_encryption_test_case_192_3(void) 8533 { 8534 return test_authenticated_encryption(&gcm_test_case_192_3); 8535 } 8536 8537 static int 8538 test_AES_GCM_auth_encryption_test_case_192_4(void) 8539 { 8540 return test_authenticated_encryption(&gcm_test_case_192_4); 8541 } 8542 8543 static int 8544 test_AES_GCM_auth_encryption_test_case_192_5(void) 8545 { 8546 return test_authenticated_encryption(&gcm_test_case_192_5); 8547 } 8548 8549 static int 8550 test_AES_GCM_auth_encryption_test_case_192_6(void) 8551 { 8552 return test_authenticated_encryption(&gcm_test_case_192_6); 8553 } 8554 8555 static int 8556 test_AES_GCM_auth_encryption_test_case_192_7(void) 8557 { 8558 return test_authenticated_encryption(&gcm_test_case_192_7); 8559 } 8560 8561 static int 8562 test_AES_GCM_auth_encryption_test_case_256_1(void) 8563 { 8564 return test_authenticated_encryption(&gcm_test_case_256_1); 8565 } 8566 8567 static int 8568 test_AES_GCM_auth_encryption_test_case_256_2(void) 8569 { 8570 return test_authenticated_encryption(&gcm_test_case_256_2); 8571 } 8572 8573 static int 8574 test_AES_GCM_auth_encryption_test_case_256_3(void) 8575 { 8576 return test_authenticated_encryption(&gcm_test_case_256_3); 8577 } 8578 8579 static int 8580 test_AES_GCM_auth_encryption_test_case_256_4(void) 8581 { 8582 return test_authenticated_encryption(&gcm_test_case_256_4); 8583 } 8584 8585 static int 8586 test_AES_GCM_auth_encryption_test_case_256_5(void) 8587 { 8588 return test_authenticated_encryption(&gcm_test_case_256_5); 8589 } 8590 8591 static int 8592 test_AES_GCM_auth_encryption_test_case_256_6(void) 8593 { 8594 return test_authenticated_encryption(&gcm_test_case_256_6); 8595 } 8596 8597 static int 8598 test_AES_GCM_auth_encryption_test_case_256_7(void) 8599 { 8600 return test_authenticated_encryption(&gcm_test_case_256_7); 8601 } 8602 8603 static int 8604 test_AES_GCM_auth_encryption_test_case_aad_1(void) 8605 { 8606 return test_authenticated_encryption(&gcm_test_case_aad_1); 8607 } 8608 8609 static int 8610 test_AES_GCM_auth_encryption_test_case_aad_2(void) 8611 { 8612 return test_authenticated_encryption(&gcm_test_case_aad_2); 8613 } 8614 8615 static int 8616 test_AES_GCM_auth_encryption_fail_iv_corrupt(void) 8617 { 8618 struct aead_test_data tdata; 8619 int res; 8620 8621 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); 8622 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8623 tdata.iv.data[0] += 1; 8624 res = test_authenticated_encryption(&tdata); 8625 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); 8626 return TEST_SUCCESS; 8627 } 8628 8629 static int 8630 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void) 8631 { 8632 struct aead_test_data tdata; 8633 int res; 8634 8635 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); 8636 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8637 tdata.plaintext.data[0] += 1; 8638 res = test_authenticated_encryption(&tdata); 8639 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); 8640 return TEST_SUCCESS; 8641 } 8642 8643 static int 8644 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void) 8645 { 8646 struct aead_test_data tdata; 8647 int res; 8648 8649 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); 8650 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8651 tdata.ciphertext.data[0] += 1; 8652 res = test_authenticated_encryption(&tdata); 8653 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); 8654 return TEST_SUCCESS; 8655 } 8656 8657 static int 8658 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void) 8659 { 8660 struct aead_test_data tdata; 8661 int res; 8662 8663 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); 8664 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8665 tdata.aad.len += 1; 8666 res = test_authenticated_encryption(&tdata); 8667 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); 8668 return TEST_SUCCESS; 8669 } 8670 8671 static int 8672 test_AES_GCM_auth_encryption_fail_aad_corrupt(void) 8673 { 8674 struct aead_test_data tdata; 8675 uint8_t aad[gcm_test_case_7.aad.len]; 8676 int res; 8677 8678 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); 8679 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8680 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len); 8681 aad[0] += 1; 8682 tdata.aad.data = aad; 8683 res = test_authenticated_encryption(&tdata); 8684 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); 8685 return TEST_SUCCESS; 8686 } 8687 8688 static int 8689 test_AES_GCM_auth_encryption_fail_tag_corrupt(void) 8690 { 8691 struct aead_test_data tdata; 8692 int res; 8693 8694 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); 8695 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8696 tdata.auth_tag.data[0] += 1; 8697 res = test_authenticated_encryption(&tdata); 8698 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed"); 8699 return TEST_SUCCESS; 8700 } 8701 8702 static int 8703 test_authenticated_decryption(const struct aead_test_data *tdata) 8704 { 8705 struct crypto_testsuite_params *ts_params = &testsuite_params; 8706 struct crypto_unittest_params *ut_params = &unittest_params; 8707 8708 int retval; 8709 uint8_t *plaintext; 8710 uint32_t i; 8711 8712 /* Create AEAD session */ 8713 retval = create_aead_session(ts_params->valid_devs[0], 8714 tdata->algo, 8715 RTE_CRYPTO_AEAD_OP_DECRYPT, 8716 tdata->key.data, tdata->key.len, 8717 tdata->aad.len, tdata->auth_tag.len, 8718 tdata->iv.len); 8719 if (retval < 0) 8720 return retval; 8721 8722 /* alloc mbuf and set payload */ 8723 if (tdata->aad.len > MBUF_SIZE) { 8724 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); 8725 /* Populate full size of add data */ 8726 for (i = 32; i < MAX_AAD_LENGTH; i += 32) 8727 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32); 8728 } else 8729 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 8730 8731 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 8732 rte_pktmbuf_tailroom(ut_params->ibuf)); 8733 8734 /* Create AEAD operation */ 8735 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); 8736 if (retval < 0) 8737 return retval; 8738 8739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 8740 8741 ut_params->op->sym->m_src = ut_params->ibuf; 8742 8743 /* Process crypto operation */ 8744 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 8745 ut_params->op), "failed to process sym crypto op"); 8746 8747 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 8748 "crypto op processing failed"); 8749 8750 if (ut_params->op->sym->m_dst) 8751 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst, 8752 uint8_t *); 8753 else 8754 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src, 8755 uint8_t *, 8756 ut_params->op->sym->cipher.data.offset); 8757 8758 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len); 8759 8760 /* Validate obuf */ 8761 TEST_ASSERT_BUFFERS_ARE_EQUAL( 8762 plaintext, 8763 tdata->plaintext.data, 8764 tdata->plaintext.len, 8765 "Plaintext data not as expected"); 8766 8767 TEST_ASSERT_EQUAL(ut_params->op->status, 8768 RTE_CRYPTO_OP_STATUS_SUCCESS, 8769 "Authentication failed"); 8770 8771 return 0; 8772 } 8773 8774 static int 8775 test_AES_GCM_authenticated_decryption_test_case_1(void) 8776 { 8777 return test_authenticated_decryption(&gcm_test_case_1); 8778 } 8779 8780 static int 8781 test_AES_GCM_authenticated_decryption_test_case_2(void) 8782 { 8783 return test_authenticated_decryption(&gcm_test_case_2); 8784 } 8785 8786 static int 8787 test_AES_GCM_authenticated_decryption_test_case_3(void) 8788 { 8789 return test_authenticated_decryption(&gcm_test_case_3); 8790 } 8791 8792 static int 8793 test_AES_GCM_authenticated_decryption_test_case_4(void) 8794 { 8795 return test_authenticated_decryption(&gcm_test_case_4); 8796 } 8797 8798 static int 8799 test_AES_GCM_authenticated_decryption_test_case_5(void) 8800 { 8801 return test_authenticated_decryption(&gcm_test_case_5); 8802 } 8803 8804 static int 8805 test_AES_GCM_authenticated_decryption_test_case_6(void) 8806 { 8807 return test_authenticated_decryption(&gcm_test_case_6); 8808 } 8809 8810 static int 8811 test_AES_GCM_authenticated_decryption_test_case_7(void) 8812 { 8813 return test_authenticated_decryption(&gcm_test_case_7); 8814 } 8815 8816 static int 8817 test_AES_GCM_authenticated_decryption_test_case_8(void) 8818 { 8819 return test_authenticated_decryption(&gcm_test_case_8); 8820 } 8821 8822 static int 8823 test_AES_GCM_auth_decryption_test_case_192_1(void) 8824 { 8825 return test_authenticated_decryption(&gcm_test_case_192_1); 8826 } 8827 8828 static int 8829 test_AES_GCM_auth_decryption_test_case_192_2(void) 8830 { 8831 return test_authenticated_decryption(&gcm_test_case_192_2); 8832 } 8833 8834 static int 8835 test_AES_GCM_auth_decryption_test_case_192_3(void) 8836 { 8837 return test_authenticated_decryption(&gcm_test_case_192_3); 8838 } 8839 8840 static int 8841 test_AES_GCM_auth_decryption_test_case_192_4(void) 8842 { 8843 return test_authenticated_decryption(&gcm_test_case_192_4); 8844 } 8845 8846 static int 8847 test_AES_GCM_auth_decryption_test_case_192_5(void) 8848 { 8849 return test_authenticated_decryption(&gcm_test_case_192_5); 8850 } 8851 8852 static int 8853 test_AES_GCM_auth_decryption_test_case_192_6(void) 8854 { 8855 return test_authenticated_decryption(&gcm_test_case_192_6); 8856 } 8857 8858 static int 8859 test_AES_GCM_auth_decryption_test_case_192_7(void) 8860 { 8861 return test_authenticated_decryption(&gcm_test_case_192_7); 8862 } 8863 8864 static int 8865 test_AES_GCM_auth_decryption_test_case_256_1(void) 8866 { 8867 return test_authenticated_decryption(&gcm_test_case_256_1); 8868 } 8869 8870 static int 8871 test_AES_GCM_auth_decryption_test_case_256_2(void) 8872 { 8873 return test_authenticated_decryption(&gcm_test_case_256_2); 8874 } 8875 8876 static int 8877 test_AES_GCM_auth_decryption_test_case_256_3(void) 8878 { 8879 return test_authenticated_decryption(&gcm_test_case_256_3); 8880 } 8881 8882 static int 8883 test_AES_GCM_auth_decryption_test_case_256_4(void) 8884 { 8885 return test_authenticated_decryption(&gcm_test_case_256_4); 8886 } 8887 8888 static int 8889 test_AES_GCM_auth_decryption_test_case_256_5(void) 8890 { 8891 return test_authenticated_decryption(&gcm_test_case_256_5); 8892 } 8893 8894 static int 8895 test_AES_GCM_auth_decryption_test_case_256_6(void) 8896 { 8897 return test_authenticated_decryption(&gcm_test_case_256_6); 8898 } 8899 8900 static int 8901 test_AES_GCM_auth_decryption_test_case_256_7(void) 8902 { 8903 return test_authenticated_decryption(&gcm_test_case_256_7); 8904 } 8905 8906 static int 8907 test_AES_GCM_auth_decryption_test_case_aad_1(void) 8908 { 8909 return test_authenticated_decryption(&gcm_test_case_aad_1); 8910 } 8911 8912 static int 8913 test_AES_GCM_auth_decryption_test_case_aad_2(void) 8914 { 8915 return test_authenticated_decryption(&gcm_test_case_aad_2); 8916 } 8917 8918 static int 8919 test_AES_GCM_auth_decryption_fail_iv_corrupt(void) 8920 { 8921 struct aead_test_data tdata; 8922 int res; 8923 8924 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8925 tdata.iv.data[0] += 1; 8926 res = test_authenticated_decryption(&tdata); 8927 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); 8928 return TEST_SUCCESS; 8929 } 8930 8931 static int 8932 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void) 8933 { 8934 struct aead_test_data tdata; 8935 int res; 8936 8937 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n"); 8938 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8939 tdata.plaintext.data[0] += 1; 8940 res = test_authenticated_decryption(&tdata); 8941 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); 8942 return TEST_SUCCESS; 8943 } 8944 8945 static int 8946 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void) 8947 { 8948 struct aead_test_data tdata; 8949 int res; 8950 8951 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8952 tdata.ciphertext.data[0] += 1; 8953 res = test_authenticated_decryption(&tdata); 8954 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); 8955 return TEST_SUCCESS; 8956 } 8957 8958 static int 8959 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void) 8960 { 8961 struct aead_test_data tdata; 8962 int res; 8963 8964 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8965 tdata.aad.len += 1; 8966 res = test_authenticated_decryption(&tdata); 8967 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); 8968 return TEST_SUCCESS; 8969 } 8970 8971 static int 8972 test_AES_GCM_auth_decryption_fail_aad_corrupt(void) 8973 { 8974 struct aead_test_data tdata; 8975 uint8_t aad[gcm_test_case_7.aad.len]; 8976 int res; 8977 8978 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8979 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len); 8980 aad[0] += 1; 8981 tdata.aad.data = aad; 8982 res = test_authenticated_decryption(&tdata); 8983 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed"); 8984 return TEST_SUCCESS; 8985 } 8986 8987 static int 8988 test_AES_GCM_auth_decryption_fail_tag_corrupt(void) 8989 { 8990 struct aead_test_data tdata; 8991 int res; 8992 8993 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data)); 8994 tdata.auth_tag.data[0] += 1; 8995 res = test_authenticated_decryption(&tdata); 8996 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed"); 8997 return TEST_SUCCESS; 8998 } 8999 9000 static int 9001 test_authenticated_encryption_oop(const struct aead_test_data *tdata) 9002 { 9003 struct crypto_testsuite_params *ts_params = &testsuite_params; 9004 struct crypto_unittest_params *ut_params = &unittest_params; 9005 9006 int retval; 9007 uint8_t *ciphertext, *auth_tag; 9008 uint16_t plaintext_pad_len; 9009 9010 /* Create AEAD session */ 9011 retval = create_aead_session(ts_params->valid_devs[0], 9012 tdata->algo, 9013 RTE_CRYPTO_AEAD_OP_ENCRYPT, 9014 tdata->key.data, tdata->key.len, 9015 tdata->aad.len, tdata->auth_tag.len, 9016 tdata->iv.len); 9017 if (retval < 0) 9018 return retval; 9019 9020 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 9021 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 9022 9023 /* clear mbuf payload */ 9024 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 9025 rte_pktmbuf_tailroom(ut_params->ibuf)); 9026 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, 9027 rte_pktmbuf_tailroom(ut_params->obuf)); 9028 9029 /* Create AEAD operation */ 9030 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); 9031 if (retval < 0) 9032 return retval; 9033 9034 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 9035 9036 ut_params->op->sym->m_src = ut_params->ibuf; 9037 ut_params->op->sym->m_dst = ut_params->obuf; 9038 9039 /* Process crypto operation */ 9040 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 9041 ut_params->op), "failed to process sym crypto op"); 9042 9043 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 9044 "crypto op processing failed"); 9045 9046 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16); 9047 9048 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *, 9049 ut_params->op->sym->cipher.data.offset); 9050 auth_tag = ciphertext + plaintext_pad_len; 9051 9052 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); 9053 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); 9054 9055 /* Validate obuf */ 9056 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9057 ciphertext, 9058 tdata->ciphertext.data, 9059 tdata->ciphertext.len, 9060 "Ciphertext data not as expected"); 9061 9062 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9063 auth_tag, 9064 tdata->auth_tag.data, 9065 tdata->auth_tag.len, 9066 "Generated auth tag not as expected"); 9067 9068 return 0; 9069 9070 } 9071 9072 static int 9073 test_AES_GCM_authenticated_encryption_oop_test_case_1(void) 9074 { 9075 return test_authenticated_encryption_oop(&gcm_test_case_5); 9076 } 9077 9078 static int 9079 test_authenticated_decryption_oop(const struct aead_test_data *tdata) 9080 { 9081 struct crypto_testsuite_params *ts_params = &testsuite_params; 9082 struct crypto_unittest_params *ut_params = &unittest_params; 9083 9084 int retval; 9085 uint8_t *plaintext; 9086 9087 /* Create AEAD session */ 9088 retval = create_aead_session(ts_params->valid_devs[0], 9089 tdata->algo, 9090 RTE_CRYPTO_AEAD_OP_DECRYPT, 9091 tdata->key.data, tdata->key.len, 9092 tdata->aad.len, tdata->auth_tag.len, 9093 tdata->iv.len); 9094 if (retval < 0) 9095 return retval; 9096 9097 /* alloc mbuf and set payload */ 9098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 9099 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 9100 9101 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 9102 rte_pktmbuf_tailroom(ut_params->ibuf)); 9103 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, 9104 rte_pktmbuf_tailroom(ut_params->obuf)); 9105 9106 /* Create AEAD operation */ 9107 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); 9108 if (retval < 0) 9109 return retval; 9110 9111 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 9112 9113 ut_params->op->sym->m_src = ut_params->ibuf; 9114 ut_params->op->sym->m_dst = ut_params->obuf; 9115 9116 /* Process crypto operation */ 9117 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 9118 ut_params->op), "failed to process sym crypto op"); 9119 9120 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 9121 "crypto op processing failed"); 9122 9123 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *, 9124 ut_params->op->sym->cipher.data.offset); 9125 9126 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len); 9127 9128 /* Validate obuf */ 9129 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9130 plaintext, 9131 tdata->plaintext.data, 9132 tdata->plaintext.len, 9133 "Plaintext data not as expected"); 9134 9135 TEST_ASSERT_EQUAL(ut_params->op->status, 9136 RTE_CRYPTO_OP_STATUS_SUCCESS, 9137 "Authentication failed"); 9138 return 0; 9139 } 9140 9141 static int 9142 test_AES_GCM_authenticated_decryption_oop_test_case_1(void) 9143 { 9144 return test_authenticated_decryption_oop(&gcm_test_case_5); 9145 } 9146 9147 static int 9148 test_authenticated_encryption_sessionless( 9149 const struct aead_test_data *tdata) 9150 { 9151 struct crypto_testsuite_params *ts_params = &testsuite_params; 9152 struct crypto_unittest_params *ut_params = &unittest_params; 9153 9154 int retval; 9155 uint8_t *ciphertext, *auth_tag; 9156 uint16_t plaintext_pad_len; 9157 uint8_t key[tdata->key.len + 1]; 9158 9159 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 9160 9161 /* clear mbuf payload */ 9162 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 9163 rte_pktmbuf_tailroom(ut_params->ibuf)); 9164 9165 /* Create AEAD operation */ 9166 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata); 9167 if (retval < 0) 9168 return retval; 9169 9170 /* Create GCM xform */ 9171 memcpy(key, tdata->key.data, tdata->key.len); 9172 retval = create_aead_xform(ut_params->op, 9173 tdata->algo, 9174 RTE_CRYPTO_AEAD_OP_ENCRYPT, 9175 key, tdata->key.len, 9176 tdata->aad.len, tdata->auth_tag.len, 9177 tdata->iv.len); 9178 if (retval < 0) 9179 return retval; 9180 9181 ut_params->op->sym->m_src = ut_params->ibuf; 9182 9183 TEST_ASSERT_EQUAL(ut_params->op->sess_type, 9184 RTE_CRYPTO_OP_SESSIONLESS, 9185 "crypto op session type not sessionless"); 9186 9187 /* Process crypto operation */ 9188 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 9189 ut_params->op), "failed to process sym crypto op"); 9190 9191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process"); 9192 9193 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 9194 "crypto op status not success"); 9195 9196 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16); 9197 9198 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, 9199 ut_params->op->sym->cipher.data.offset); 9200 auth_tag = ciphertext + plaintext_pad_len; 9201 9202 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len); 9203 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len); 9204 9205 /* Validate obuf */ 9206 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9207 ciphertext, 9208 tdata->ciphertext.data, 9209 tdata->ciphertext.len, 9210 "Ciphertext data not as expected"); 9211 9212 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9213 auth_tag, 9214 tdata->auth_tag.data, 9215 tdata->auth_tag.len, 9216 "Generated auth tag not as expected"); 9217 9218 return 0; 9219 9220 } 9221 9222 static int 9223 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void) 9224 { 9225 return test_authenticated_encryption_sessionless( 9226 &gcm_test_case_5); 9227 } 9228 9229 static int 9230 test_authenticated_decryption_sessionless( 9231 const struct aead_test_data *tdata) 9232 { 9233 struct crypto_testsuite_params *ts_params = &testsuite_params; 9234 struct crypto_unittest_params *ut_params = &unittest_params; 9235 9236 int retval; 9237 uint8_t *plaintext; 9238 uint8_t key[tdata->key.len + 1]; 9239 9240 /* alloc mbuf and set payload */ 9241 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 9242 9243 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 9244 rte_pktmbuf_tailroom(ut_params->ibuf)); 9245 9246 /* Create AEAD operation */ 9247 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata); 9248 if (retval < 0) 9249 return retval; 9250 9251 /* Create AEAD xform */ 9252 memcpy(key, tdata->key.data, tdata->key.len); 9253 retval = create_aead_xform(ut_params->op, 9254 tdata->algo, 9255 RTE_CRYPTO_AEAD_OP_DECRYPT, 9256 key, tdata->key.len, 9257 tdata->aad.len, tdata->auth_tag.len, 9258 tdata->iv.len); 9259 if (retval < 0) 9260 return retval; 9261 9262 ut_params->op->sym->m_src = ut_params->ibuf; 9263 9264 TEST_ASSERT_EQUAL(ut_params->op->sess_type, 9265 RTE_CRYPTO_OP_SESSIONLESS, 9266 "crypto op session type not sessionless"); 9267 9268 /* Process crypto operation */ 9269 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 9270 ut_params->op), "failed to process sym crypto op"); 9271 9272 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process"); 9273 9274 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 9275 "crypto op status not success"); 9276 9277 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, 9278 ut_params->op->sym->cipher.data.offset); 9279 9280 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len); 9281 9282 /* Validate obuf */ 9283 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9284 plaintext, 9285 tdata->plaintext.data, 9286 tdata->plaintext.len, 9287 "Plaintext data not as expected"); 9288 9289 TEST_ASSERT_EQUAL(ut_params->op->status, 9290 RTE_CRYPTO_OP_STATUS_SUCCESS, 9291 "Authentication failed"); 9292 return 0; 9293 } 9294 9295 static int 9296 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void) 9297 { 9298 return test_authenticated_decryption_sessionless( 9299 &gcm_test_case_5); 9300 } 9301 9302 static int 9303 test_AES_CCM_authenticated_encryption_test_case_128_1(void) 9304 { 9305 return test_authenticated_encryption(&ccm_test_case_128_1); 9306 } 9307 9308 static int 9309 test_AES_CCM_authenticated_encryption_test_case_128_2(void) 9310 { 9311 return test_authenticated_encryption(&ccm_test_case_128_2); 9312 } 9313 9314 static int 9315 test_AES_CCM_authenticated_encryption_test_case_128_3(void) 9316 { 9317 return test_authenticated_encryption(&ccm_test_case_128_3); 9318 } 9319 9320 static int 9321 test_AES_CCM_authenticated_decryption_test_case_128_1(void) 9322 { 9323 return test_authenticated_decryption(&ccm_test_case_128_1); 9324 } 9325 9326 static int 9327 test_AES_CCM_authenticated_decryption_test_case_128_2(void) 9328 { 9329 return test_authenticated_decryption(&ccm_test_case_128_2); 9330 } 9331 9332 static int 9333 test_AES_CCM_authenticated_decryption_test_case_128_3(void) 9334 { 9335 return test_authenticated_decryption(&ccm_test_case_128_3); 9336 } 9337 9338 static int 9339 test_AES_CCM_authenticated_encryption_test_case_192_1(void) 9340 { 9341 return test_authenticated_encryption(&ccm_test_case_192_1); 9342 } 9343 9344 static int 9345 test_AES_CCM_authenticated_encryption_test_case_192_2(void) 9346 { 9347 return test_authenticated_encryption(&ccm_test_case_192_2); 9348 } 9349 9350 static int 9351 test_AES_CCM_authenticated_encryption_test_case_192_3(void) 9352 { 9353 return test_authenticated_encryption(&ccm_test_case_192_3); 9354 } 9355 9356 static int 9357 test_AES_CCM_authenticated_decryption_test_case_192_1(void) 9358 { 9359 return test_authenticated_decryption(&ccm_test_case_192_1); 9360 } 9361 9362 static int 9363 test_AES_CCM_authenticated_decryption_test_case_192_2(void) 9364 { 9365 return test_authenticated_decryption(&ccm_test_case_192_2); 9366 } 9367 9368 static int 9369 test_AES_CCM_authenticated_decryption_test_case_192_3(void) 9370 { 9371 return test_authenticated_decryption(&ccm_test_case_192_3); 9372 } 9373 9374 static int 9375 test_AES_CCM_authenticated_encryption_test_case_256_1(void) 9376 { 9377 return test_authenticated_encryption(&ccm_test_case_256_1); 9378 } 9379 9380 static int 9381 test_AES_CCM_authenticated_encryption_test_case_256_2(void) 9382 { 9383 return test_authenticated_encryption(&ccm_test_case_256_2); 9384 } 9385 9386 static int 9387 test_AES_CCM_authenticated_encryption_test_case_256_3(void) 9388 { 9389 return test_authenticated_encryption(&ccm_test_case_256_3); 9390 } 9391 9392 static int 9393 test_AES_CCM_authenticated_decryption_test_case_256_1(void) 9394 { 9395 return test_authenticated_decryption(&ccm_test_case_256_1); 9396 } 9397 9398 static int 9399 test_AES_CCM_authenticated_decryption_test_case_256_2(void) 9400 { 9401 return test_authenticated_decryption(&ccm_test_case_256_2); 9402 } 9403 9404 static int 9405 test_AES_CCM_authenticated_decryption_test_case_256_3(void) 9406 { 9407 return test_authenticated_decryption(&ccm_test_case_256_3); 9408 } 9409 9410 static int 9411 test_stats(void) 9412 { 9413 struct crypto_testsuite_params *ts_params = &testsuite_params; 9414 struct rte_cryptodev_stats stats; 9415 struct rte_cryptodev *dev; 9416 cryptodev_stats_get_t temp_pfn; 9417 9418 rte_cryptodev_stats_reset(ts_params->valid_devs[0]); 9419 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600, 9420 &stats) == -ENODEV), 9421 "rte_cryptodev_stats_get invalid dev failed"); 9422 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0), 9423 "rte_cryptodev_stats_get invalid Param failed"); 9424 dev = &rte_cryptodevs[ts_params->valid_devs[0]]; 9425 temp_pfn = dev->dev_ops->stats_get; 9426 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0; 9427 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats) 9428 == -ENOTSUP), 9429 "rte_cryptodev_stats_get invalid Param failed"); 9430 dev->dev_ops->stats_get = temp_pfn; 9431 9432 /* Test expected values */ 9433 ut_setup(); 9434 test_AES_CBC_HMAC_SHA1_encrypt_digest(); 9435 ut_teardown(); 9436 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0], 9437 &stats), 9438 "rte_cryptodev_stats_get failed"); 9439 TEST_ASSERT((stats.enqueued_count == 1), 9440 "rte_cryptodev_stats_get returned unexpected enqueued stat"); 9441 TEST_ASSERT((stats.dequeued_count == 1), 9442 "rte_cryptodev_stats_get returned unexpected enqueued stat"); 9443 TEST_ASSERT((stats.enqueue_err_count == 0), 9444 "rte_cryptodev_stats_get returned unexpected enqueued stat"); 9445 TEST_ASSERT((stats.dequeue_err_count == 0), 9446 "rte_cryptodev_stats_get returned unexpected enqueued stat"); 9447 9448 /* invalid device but should ignore and not reset device stats*/ 9449 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300); 9450 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0], 9451 &stats), 9452 "rte_cryptodev_stats_get failed"); 9453 TEST_ASSERT((stats.enqueued_count == 1), 9454 "rte_cryptodev_stats_get returned unexpected enqueued stat"); 9455 9456 /* check that a valid reset clears stats */ 9457 rte_cryptodev_stats_reset(ts_params->valid_devs[0]); 9458 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0], 9459 &stats), 9460 "rte_cryptodev_stats_get failed"); 9461 TEST_ASSERT((stats.enqueued_count == 0), 9462 "rte_cryptodev_stats_get returned unexpected enqueued stat"); 9463 TEST_ASSERT((stats.dequeued_count == 0), 9464 "rte_cryptodev_stats_get returned unexpected enqueued stat"); 9465 9466 return TEST_SUCCESS; 9467 } 9468 9469 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params, 9470 struct crypto_unittest_params *ut_params, 9471 enum rte_crypto_auth_operation op, 9472 const struct HMAC_MD5_vector *test_case) 9473 { 9474 uint8_t key[64]; 9475 9476 memcpy(key, test_case->key.data, test_case->key.len); 9477 9478 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 9479 ut_params->auth_xform.next = NULL; 9480 ut_params->auth_xform.auth.op = op; 9481 9482 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC; 9483 9484 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN; 9485 ut_params->auth_xform.auth.key.length = test_case->key.len; 9486 ut_params->auth_xform.auth.key.data = key; 9487 9488 ut_params->sess = rte_cryptodev_sym_session_create( 9489 ts_params->session_mpool); 9490 9491 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 9492 ut_params->sess, &ut_params->auth_xform, 9493 ts_params->session_priv_mpool); 9494 9495 if (ut_params->sess == NULL) 9496 return TEST_FAILED; 9497 9498 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 9499 9500 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 9501 rte_pktmbuf_tailroom(ut_params->ibuf)); 9502 9503 return 0; 9504 } 9505 9506 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params, 9507 const struct HMAC_MD5_vector *test_case, 9508 uint8_t **plaintext) 9509 { 9510 uint16_t plaintext_pad_len; 9511 9512 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 9513 9514 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len, 9515 16); 9516 9517 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 9518 plaintext_pad_len); 9519 memcpy(*plaintext, test_case->plaintext.data, 9520 test_case->plaintext.len); 9521 9522 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( 9523 ut_params->ibuf, MD5_DIGEST_LEN); 9524 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, 9525 "no room to append digest"); 9526 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 9527 ut_params->ibuf, plaintext_pad_len); 9528 9529 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) { 9530 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data, 9531 test_case->auth_tag.len); 9532 } 9533 9534 sym_op->auth.data.offset = 0; 9535 sym_op->auth.data.length = test_case->plaintext.len; 9536 9537 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 9538 ut_params->op->sym->m_src = ut_params->ibuf; 9539 9540 return 0; 9541 } 9542 9543 static int 9544 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case) 9545 { 9546 uint16_t plaintext_pad_len; 9547 uint8_t *plaintext, *auth_tag; 9548 9549 struct crypto_testsuite_params *ts_params = &testsuite_params; 9550 struct crypto_unittest_params *ut_params = &unittest_params; 9551 9552 if (MD5_HMAC_create_session(ts_params, ut_params, 9553 RTE_CRYPTO_AUTH_OP_GENERATE, test_case)) 9554 return TEST_FAILED; 9555 9556 /* Generate Crypto op data structure */ 9557 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 9558 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 9559 TEST_ASSERT_NOT_NULL(ut_params->op, 9560 "Failed to allocate symmetric crypto operation struct"); 9561 9562 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len, 9563 16); 9564 9565 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext)) 9566 return TEST_FAILED; 9567 9568 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 9569 ut_params->op), "failed to process sym crypto op"); 9570 9571 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 9572 "crypto op processing failed"); 9573 9574 if (ut_params->op->sym->m_dst) { 9575 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst, 9576 uint8_t *, plaintext_pad_len); 9577 } else { 9578 auth_tag = plaintext + plaintext_pad_len; 9579 } 9580 9581 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9582 auth_tag, 9583 test_case->auth_tag.data, 9584 test_case->auth_tag.len, 9585 "HMAC_MD5 generated tag not as expected"); 9586 9587 return TEST_SUCCESS; 9588 } 9589 9590 static int 9591 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case) 9592 { 9593 uint8_t *plaintext; 9594 9595 struct crypto_testsuite_params *ts_params = &testsuite_params; 9596 struct crypto_unittest_params *ut_params = &unittest_params; 9597 9598 if (MD5_HMAC_create_session(ts_params, ut_params, 9599 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) { 9600 return TEST_FAILED; 9601 } 9602 9603 /* Generate Crypto op data structure */ 9604 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 9605 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 9606 TEST_ASSERT_NOT_NULL(ut_params->op, 9607 "Failed to allocate symmetric crypto operation struct"); 9608 9609 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext)) 9610 return TEST_FAILED; 9611 9612 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 9613 ut_params->op), "failed to process sym crypto op"); 9614 9615 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 9616 "HMAC_MD5 crypto op processing failed"); 9617 9618 return TEST_SUCCESS; 9619 } 9620 9621 static int 9622 test_MD5_HMAC_generate_case_1(void) 9623 { 9624 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1); 9625 } 9626 9627 static int 9628 test_MD5_HMAC_verify_case_1(void) 9629 { 9630 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1); 9631 } 9632 9633 static int 9634 test_MD5_HMAC_generate_case_2(void) 9635 { 9636 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2); 9637 } 9638 9639 static int 9640 test_MD5_HMAC_verify_case_2(void) 9641 { 9642 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2); 9643 } 9644 9645 static int 9646 test_multi_session(void) 9647 { 9648 struct crypto_testsuite_params *ts_params = &testsuite_params; 9649 struct crypto_unittest_params *ut_params = &unittest_params; 9650 9651 struct rte_cryptodev_info dev_info; 9652 struct rte_cryptodev_sym_session **sessions; 9653 9654 uint16_t i; 9655 9656 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params, 9657 aes_cbc_key, hmac_sha512_key); 9658 9659 9660 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 9661 9662 sessions = rte_malloc(NULL, 9663 (sizeof(struct rte_cryptodev_sym_session *) * 9664 MAX_NB_SESSIONS) + 1, 0); 9665 9666 /* Create multiple crypto sessions*/ 9667 for (i = 0; i < MAX_NB_SESSIONS; i++) { 9668 9669 sessions[i] = rte_cryptodev_sym_session_create( 9670 ts_params->session_mpool); 9671 9672 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 9673 sessions[i], &ut_params->auth_xform, 9674 ts_params->session_priv_mpool); 9675 TEST_ASSERT_NOT_NULL(sessions[i], 9676 "Session creation failed at session number %u", 9677 i); 9678 9679 /* Attempt to send a request on each session */ 9680 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform( 9681 sessions[i], 9682 ut_params, 9683 ts_params, 9684 catch_22_quote_2_512_bytes_AES_CBC_ciphertext, 9685 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest, 9686 aes_cbc_iv), 9687 "Failed to perform decrypt on request number %u.", i); 9688 /* free crypto operation structure */ 9689 if (ut_params->op) 9690 rte_crypto_op_free(ut_params->op); 9691 9692 /* 9693 * free mbuf - both obuf and ibuf are usually the same, 9694 * so check if they point at the same address is necessary, 9695 * to avoid freeing the mbuf twice. 9696 */ 9697 if (ut_params->obuf) { 9698 rte_pktmbuf_free(ut_params->obuf); 9699 if (ut_params->ibuf == ut_params->obuf) 9700 ut_params->ibuf = 0; 9701 ut_params->obuf = 0; 9702 } 9703 if (ut_params->ibuf) { 9704 rte_pktmbuf_free(ut_params->ibuf); 9705 ut_params->ibuf = 0; 9706 } 9707 } 9708 9709 /* Next session create should fail */ 9710 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 9711 sessions[i], &ut_params->auth_xform, 9712 ts_params->session_priv_mpool); 9713 TEST_ASSERT_NULL(sessions[i], 9714 "Session creation succeeded unexpectedly!"); 9715 9716 for (i = 0; i < MAX_NB_SESSIONS; i++) { 9717 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0], 9718 sessions[i]); 9719 rte_cryptodev_sym_session_free(sessions[i]); 9720 } 9721 9722 rte_free(sessions); 9723 9724 return TEST_SUCCESS; 9725 } 9726 9727 struct multi_session_params { 9728 struct crypto_unittest_params ut_params; 9729 uint8_t *cipher_key; 9730 uint8_t *hmac_key; 9731 const uint8_t *cipher; 9732 const uint8_t *digest; 9733 uint8_t *iv; 9734 }; 9735 9736 #define MB_SESSION_NUMBER 3 9737 9738 static int 9739 test_multi_session_random_usage(void) 9740 { 9741 struct crypto_testsuite_params *ts_params = &testsuite_params; 9742 struct rte_cryptodev_info dev_info; 9743 struct rte_cryptodev_sym_session **sessions; 9744 uint32_t i, j; 9745 struct multi_session_params ut_paramz[] = { 9746 9747 { 9748 .cipher_key = ms_aes_cbc_key0, 9749 .hmac_key = ms_hmac_key0, 9750 .cipher = ms_aes_cbc_cipher0, 9751 .digest = ms_hmac_digest0, 9752 .iv = ms_aes_cbc_iv0 9753 }, 9754 { 9755 .cipher_key = ms_aes_cbc_key1, 9756 .hmac_key = ms_hmac_key1, 9757 .cipher = ms_aes_cbc_cipher1, 9758 .digest = ms_hmac_digest1, 9759 .iv = ms_aes_cbc_iv1 9760 }, 9761 { 9762 .cipher_key = ms_aes_cbc_key2, 9763 .hmac_key = ms_hmac_key2, 9764 .cipher = ms_aes_cbc_cipher2, 9765 .digest = ms_hmac_digest2, 9766 .iv = ms_aes_cbc_iv2 9767 }, 9768 9769 }; 9770 9771 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); 9772 9773 sessions = rte_malloc(NULL, 9774 (sizeof(struct rte_cryptodev_sym_session *) 9775 * MAX_NB_SESSIONS) + 1, 0); 9776 9777 for (i = 0; i < MB_SESSION_NUMBER; i++) { 9778 sessions[i] = rte_cryptodev_sym_session_create( 9779 ts_params->session_mpool); 9780 9781 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params, 9782 sizeof(struct crypto_unittest_params)); 9783 9784 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params( 9785 &ut_paramz[i].ut_params, 9786 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key); 9787 9788 /* Create multiple crypto sessions*/ 9789 rte_cryptodev_sym_session_init( 9790 ts_params->valid_devs[0], 9791 sessions[i], 9792 &ut_paramz[i].ut_params.auth_xform, 9793 ts_params->session_priv_mpool); 9794 9795 TEST_ASSERT_NOT_NULL(sessions[i], 9796 "Session creation failed at session number %u", 9797 i); 9798 9799 } 9800 9801 srand(time(NULL)); 9802 for (i = 0; i < 40000; i++) { 9803 9804 j = rand() % MB_SESSION_NUMBER; 9805 9806 TEST_ASSERT_SUCCESS( 9807 test_AES_CBC_HMAC_SHA512_decrypt_perform( 9808 sessions[j], 9809 &ut_paramz[j].ut_params, 9810 ts_params, ut_paramz[j].cipher, 9811 ut_paramz[j].digest, 9812 ut_paramz[j].iv), 9813 "Failed to perform decrypt on request number %u.", i); 9814 9815 if (ut_paramz[j].ut_params.op) 9816 rte_crypto_op_free(ut_paramz[j].ut_params.op); 9817 9818 /* 9819 * free mbuf - both obuf and ibuf are usually the same, 9820 * so check if they point at the same address is necessary, 9821 * to avoid freeing the mbuf twice. 9822 */ 9823 if (ut_paramz[j].ut_params.obuf) { 9824 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf); 9825 if (ut_paramz[j].ut_params.ibuf 9826 == ut_paramz[j].ut_params.obuf) 9827 ut_paramz[j].ut_params.ibuf = 0; 9828 ut_paramz[j].ut_params.obuf = 0; 9829 } 9830 if (ut_paramz[j].ut_params.ibuf) { 9831 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf); 9832 ut_paramz[j].ut_params.ibuf = 0; 9833 } 9834 } 9835 9836 for (i = 0; i < MB_SESSION_NUMBER; i++) { 9837 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0], 9838 sessions[i]); 9839 rte_cryptodev_sym_session_free(sessions[i]); 9840 } 9841 9842 rte_free(sessions); 9843 9844 return TEST_SUCCESS; 9845 } 9846 9847 static int 9848 test_null_cipher_only_operation(void) 9849 { 9850 struct crypto_testsuite_params *ts_params = &testsuite_params; 9851 struct crypto_unittest_params *ut_params = &unittest_params; 9852 9853 /* Generate test mbuf data and space for digest */ 9854 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, 9855 catch_22_quote, QUOTE_512_BYTES, 0); 9856 9857 /* Setup Cipher Parameters */ 9858 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 9859 ut_params->cipher_xform.next = NULL; 9860 9861 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL; 9862 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; 9863 9864 ut_params->sess = rte_cryptodev_sym_session_create( 9865 ts_params->session_mpool); 9866 9867 /* Create Crypto session*/ 9868 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 9869 ut_params->sess, 9870 &ut_params->cipher_xform, 9871 ts_params->session_priv_mpool); 9872 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 9873 9874 /* Generate Crypto op data structure */ 9875 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 9876 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 9877 TEST_ASSERT_NOT_NULL(ut_params->op, 9878 "Failed to allocate symmetric crypto operation struct"); 9879 9880 /* Set crypto operation data parameters */ 9881 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 9882 9883 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 9884 9885 /* set crypto operation source mbuf */ 9886 sym_op->m_src = ut_params->ibuf; 9887 9888 sym_op->cipher.data.offset = 0; 9889 sym_op->cipher.data.length = QUOTE_512_BYTES; 9890 9891 /* Process crypto operation */ 9892 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 9893 ut_params->op); 9894 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned"); 9895 9896 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 9897 "crypto operation processing failed"); 9898 9899 /* Validate obuf */ 9900 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9901 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *), 9902 catch_22_quote, 9903 QUOTE_512_BYTES, 9904 "Ciphertext data not as expected"); 9905 9906 return TEST_SUCCESS; 9907 } 9908 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab, 9909 0xab, 0xab, 0xab, 0xab, 9910 0xab, 0xab, 0xab, 0xab, 9911 0xab, 0xab, 0xab, 0xab}; 9912 static int 9913 test_null_auth_only_operation(void) 9914 { 9915 struct crypto_testsuite_params *ts_params = &testsuite_params; 9916 struct crypto_unittest_params *ut_params = &unittest_params; 9917 uint8_t *digest; 9918 9919 /* Generate test mbuf data and space for digest */ 9920 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, 9921 catch_22_quote, QUOTE_512_BYTES, 0); 9922 9923 /* create a pointer for digest, but don't expect anything to be written 9924 * here in a NULL auth algo so no mbuf append done. 9925 */ 9926 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, 9927 QUOTE_512_BYTES); 9928 /* prefill the memory pointed to by digest */ 9929 memcpy(digest, orig_data, sizeof(orig_data)); 9930 9931 /* Setup HMAC Parameters */ 9932 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 9933 ut_params->auth_xform.next = NULL; 9934 9935 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL; 9936 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; 9937 9938 ut_params->sess = rte_cryptodev_sym_session_create( 9939 ts_params->session_mpool); 9940 9941 /* Create Crypto session*/ 9942 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 9943 ut_params->sess, &ut_params->auth_xform, 9944 ts_params->session_priv_mpool); 9945 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 9946 9947 /* Generate Crypto op data structure */ 9948 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 9949 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 9950 TEST_ASSERT_NOT_NULL(ut_params->op, 9951 "Failed to allocate symmetric crypto operation struct"); 9952 9953 /* Set crypto operation data parameters */ 9954 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 9955 9956 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 9957 9958 sym_op->m_src = ut_params->ibuf; 9959 9960 sym_op->auth.data.offset = 0; 9961 sym_op->auth.data.length = QUOTE_512_BYTES; 9962 sym_op->auth.digest.data = digest; 9963 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf, 9964 QUOTE_512_BYTES); 9965 9966 /* Process crypto operation */ 9967 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 9968 ut_params->op); 9969 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned"); 9970 9971 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 9972 "crypto operation processing failed"); 9973 /* Make sure memory pointed to by digest hasn't been overwritten */ 9974 TEST_ASSERT_BUFFERS_ARE_EQUAL( 9975 orig_data, 9976 digest, 9977 sizeof(orig_data), 9978 "Memory at digest ptr overwritten unexpectedly"); 9979 9980 return TEST_SUCCESS; 9981 } 9982 9983 9984 static int 9985 test_null_cipher_auth_operation(void) 9986 { 9987 struct crypto_testsuite_params *ts_params = &testsuite_params; 9988 struct crypto_unittest_params *ut_params = &unittest_params; 9989 uint8_t *digest; 9990 9991 /* Generate test mbuf data and space for digest */ 9992 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, 9993 catch_22_quote, QUOTE_512_BYTES, 0); 9994 9995 /* create a pointer for digest, but don't expect anything to be written 9996 * here in a NULL auth algo so no mbuf append done. 9997 */ 9998 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, 9999 QUOTE_512_BYTES); 10000 /* prefill the memory pointed to by digest */ 10001 memcpy(digest, orig_data, sizeof(orig_data)); 10002 10003 /* Setup Cipher Parameters */ 10004 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 10005 ut_params->cipher_xform.next = &ut_params->auth_xform; 10006 10007 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL; 10008 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; 10009 10010 /* Setup HMAC Parameters */ 10011 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 10012 ut_params->auth_xform.next = NULL; 10013 10014 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL; 10015 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; 10016 10017 ut_params->sess = rte_cryptodev_sym_session_create( 10018 ts_params->session_mpool); 10019 10020 /* Create Crypto session*/ 10021 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 10022 ut_params->sess, &ut_params->cipher_xform, 10023 ts_params->session_priv_mpool); 10024 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 10025 10026 /* Generate Crypto op data structure */ 10027 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 10028 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 10029 TEST_ASSERT_NOT_NULL(ut_params->op, 10030 "Failed to allocate symmetric crypto operation struct"); 10031 10032 /* Set crypto operation data parameters */ 10033 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 10034 10035 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 10036 10037 sym_op->m_src = ut_params->ibuf; 10038 10039 sym_op->cipher.data.offset = 0; 10040 sym_op->cipher.data.length = QUOTE_512_BYTES; 10041 10042 sym_op->auth.data.offset = 0; 10043 sym_op->auth.data.length = QUOTE_512_BYTES; 10044 sym_op->auth.digest.data = digest; 10045 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf, 10046 QUOTE_512_BYTES); 10047 10048 /* Process crypto operation */ 10049 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 10050 ut_params->op); 10051 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned"); 10052 10053 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 10054 "crypto operation processing failed"); 10055 10056 /* Validate obuf */ 10057 TEST_ASSERT_BUFFERS_ARE_EQUAL( 10058 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *), 10059 catch_22_quote, 10060 QUOTE_512_BYTES, 10061 "Ciphertext data not as expected"); 10062 /* Make sure memory pointed to by digest hasn't been overwritten */ 10063 TEST_ASSERT_BUFFERS_ARE_EQUAL( 10064 orig_data, 10065 digest, 10066 sizeof(orig_data), 10067 "Memory at digest ptr overwritten unexpectedly"); 10068 10069 return TEST_SUCCESS; 10070 } 10071 10072 static int 10073 test_null_auth_cipher_operation(void) 10074 { 10075 struct crypto_testsuite_params *ts_params = &testsuite_params; 10076 struct crypto_unittest_params *ut_params = &unittest_params; 10077 uint8_t *digest; 10078 10079 /* Generate test mbuf data */ 10080 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool, 10081 catch_22_quote, QUOTE_512_BYTES, 0); 10082 10083 /* create a pointer for digest, but don't expect anything to be written 10084 * here in a NULL auth algo so no mbuf append done. 10085 */ 10086 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, 10087 QUOTE_512_BYTES); 10088 /* prefill the memory pointed to by digest */ 10089 memcpy(digest, orig_data, sizeof(orig_data)); 10090 10091 /* Setup Cipher Parameters */ 10092 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 10093 ut_params->cipher_xform.next = NULL; 10094 10095 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL; 10096 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; 10097 10098 /* Setup HMAC Parameters */ 10099 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 10100 ut_params->auth_xform.next = &ut_params->cipher_xform; 10101 10102 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL; 10103 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; 10104 10105 ut_params->sess = rte_cryptodev_sym_session_create( 10106 ts_params->session_mpool); 10107 10108 /* Create Crypto session*/ 10109 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 10110 ut_params->sess, &ut_params->cipher_xform, 10111 ts_params->session_priv_mpool); 10112 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 10113 10114 /* Generate Crypto op data structure */ 10115 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 10116 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 10117 TEST_ASSERT_NOT_NULL(ut_params->op, 10118 "Failed to allocate symmetric crypto operation struct"); 10119 10120 /* Set crypto operation data parameters */ 10121 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 10122 10123 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 10124 10125 sym_op->m_src = ut_params->ibuf; 10126 10127 sym_op->cipher.data.offset = 0; 10128 sym_op->cipher.data.length = QUOTE_512_BYTES; 10129 10130 sym_op->auth.data.offset = 0; 10131 sym_op->auth.data.length = QUOTE_512_BYTES; 10132 sym_op->auth.digest.data = digest; 10133 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf, 10134 QUOTE_512_BYTES); 10135 10136 /* Process crypto operation */ 10137 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 10138 ut_params->op); 10139 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned"); 10140 10141 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 10142 "crypto operation processing failed"); 10143 10144 /* Validate obuf */ 10145 TEST_ASSERT_BUFFERS_ARE_EQUAL( 10146 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *), 10147 catch_22_quote, 10148 QUOTE_512_BYTES, 10149 "Ciphertext data not as expected"); 10150 /* Make sure memory pointed to by digest hasn't been overwritten */ 10151 TEST_ASSERT_BUFFERS_ARE_EQUAL( 10152 orig_data, 10153 digest, 10154 sizeof(orig_data), 10155 "Memory at digest ptr overwritten unexpectedly"); 10156 10157 return TEST_SUCCESS; 10158 } 10159 10160 10161 static int 10162 test_null_invalid_operation(void) 10163 { 10164 struct crypto_testsuite_params *ts_params = &testsuite_params; 10165 struct crypto_unittest_params *ut_params = &unittest_params; 10166 int ret; 10167 10168 /* Setup Cipher Parameters */ 10169 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 10170 ut_params->cipher_xform.next = NULL; 10171 10172 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC; 10173 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; 10174 10175 ut_params->sess = rte_cryptodev_sym_session_create( 10176 ts_params->session_mpool); 10177 10178 /* Create Crypto session*/ 10179 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 10180 ut_params->sess, &ut_params->cipher_xform, 10181 ts_params->session_priv_mpool); 10182 TEST_ASSERT(ret < 0, 10183 "Session creation succeeded unexpectedly"); 10184 10185 10186 /* Setup HMAC Parameters */ 10187 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 10188 ut_params->auth_xform.next = NULL; 10189 10190 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC; 10191 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; 10192 10193 ut_params->sess = rte_cryptodev_sym_session_create( 10194 ts_params->session_mpool); 10195 10196 /* Create Crypto session*/ 10197 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 10198 ut_params->sess, &ut_params->auth_xform, 10199 ts_params->session_priv_mpool); 10200 TEST_ASSERT(ret < 0, 10201 "Session creation succeeded unexpectedly"); 10202 10203 return TEST_SUCCESS; 10204 } 10205 10206 10207 #define NULL_BURST_LENGTH (32) 10208 10209 static int 10210 test_null_burst_operation(void) 10211 { 10212 struct crypto_testsuite_params *ts_params = &testsuite_params; 10213 struct crypto_unittest_params *ut_params = &unittest_params; 10214 10215 unsigned i, burst_len = NULL_BURST_LENGTH; 10216 10217 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL }; 10218 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL }; 10219 10220 /* Setup Cipher Parameters */ 10221 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 10222 ut_params->cipher_xform.next = &ut_params->auth_xform; 10223 10224 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL; 10225 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; 10226 10227 /* Setup HMAC Parameters */ 10228 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 10229 ut_params->auth_xform.next = NULL; 10230 10231 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL; 10232 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; 10233 10234 ut_params->sess = rte_cryptodev_sym_session_create( 10235 ts_params->session_mpool); 10236 10237 /* Create Crypto session*/ 10238 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 10239 ut_params->sess, &ut_params->cipher_xform, 10240 ts_params->session_priv_mpool); 10241 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 10242 10243 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool, 10244 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len), 10245 burst_len, "failed to generate burst of crypto ops"); 10246 10247 /* Generate an operation for each mbuf in burst */ 10248 for (i = 0; i < burst_len; i++) { 10249 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool); 10250 10251 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf"); 10252 10253 unsigned *data = (unsigned *)rte_pktmbuf_append(m, 10254 sizeof(unsigned)); 10255 *data = i; 10256 10257 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess); 10258 10259 burst[i]->sym->m_src = m; 10260 } 10261 10262 /* Process crypto operation */ 10263 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0], 10264 0, burst, burst_len), 10265 burst_len, 10266 "Error enqueuing burst"); 10267 10268 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0], 10269 0, burst_dequeued, burst_len), 10270 burst_len, 10271 "Error dequeuing burst"); 10272 10273 10274 for (i = 0; i < burst_len; i++) { 10275 TEST_ASSERT_EQUAL( 10276 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *), 10277 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src, 10278 uint32_t *), 10279 "data not as expected"); 10280 10281 rte_pktmbuf_free(burst[i]->sym->m_src); 10282 rte_crypto_op_free(burst[i]); 10283 } 10284 10285 return TEST_SUCCESS; 10286 } 10287 10288 static void 10289 generate_gmac_large_plaintext(uint8_t *data) 10290 { 10291 uint16_t i; 10292 10293 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32) 10294 memcpy(&data[i], &data[0], 32); 10295 } 10296 10297 static int 10298 create_gmac_operation(enum rte_crypto_auth_operation op, 10299 const struct gmac_test_data *tdata) 10300 { 10301 struct crypto_testsuite_params *ts_params = &testsuite_params; 10302 struct crypto_unittest_params *ut_params = &unittest_params; 10303 struct rte_crypto_sym_op *sym_op; 10304 10305 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16); 10306 10307 /* Generate Crypto op data structure */ 10308 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 10309 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 10310 TEST_ASSERT_NOT_NULL(ut_params->op, 10311 "Failed to allocate symmetric crypto operation struct"); 10312 10313 sym_op = ut_params->op->sym; 10314 10315 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( 10316 ut_params->ibuf, tdata->gmac_tag.len); 10317 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, 10318 "no room to append digest"); 10319 10320 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 10321 ut_params->ibuf, plaintext_pad_len); 10322 10323 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) { 10324 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data, 10325 tdata->gmac_tag.len); 10326 debug_hexdump(stdout, "digest:", 10327 sym_op->auth.digest.data, 10328 tdata->gmac_tag.len); 10329 } 10330 10331 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, 10332 uint8_t *, IV_OFFSET); 10333 10334 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len); 10335 10336 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len); 10337 10338 sym_op->cipher.data.length = 0; 10339 sym_op->cipher.data.offset = 0; 10340 10341 sym_op->auth.data.offset = 0; 10342 sym_op->auth.data.length = tdata->plaintext.len; 10343 10344 return 0; 10345 } 10346 10347 static int create_gmac_session(uint8_t dev_id, 10348 const struct gmac_test_data *tdata, 10349 enum rte_crypto_auth_operation auth_op) 10350 { 10351 uint8_t auth_key[tdata->key.len]; 10352 10353 struct crypto_testsuite_params *ts_params = &testsuite_params; 10354 struct crypto_unittest_params *ut_params = &unittest_params; 10355 10356 memcpy(auth_key, tdata->key.data, tdata->key.len); 10357 10358 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 10359 ut_params->auth_xform.next = NULL; 10360 10361 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC; 10362 ut_params->auth_xform.auth.op = auth_op; 10363 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len; 10364 ut_params->auth_xform.auth.key.length = tdata->key.len; 10365 ut_params->auth_xform.auth.key.data = auth_key; 10366 ut_params->auth_xform.auth.iv.offset = IV_OFFSET; 10367 ut_params->auth_xform.auth.iv.length = tdata->iv.len; 10368 10369 10370 ut_params->sess = rte_cryptodev_sym_session_create( 10371 ts_params->session_mpool); 10372 10373 rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 10374 &ut_params->auth_xform, 10375 ts_params->session_priv_mpool); 10376 10377 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 10378 10379 return 0; 10380 } 10381 10382 static int 10383 test_AES_GMAC_authentication(const struct gmac_test_data *tdata) 10384 { 10385 struct crypto_testsuite_params *ts_params = &testsuite_params; 10386 struct crypto_unittest_params *ut_params = &unittest_params; 10387 10388 int retval; 10389 10390 uint8_t *auth_tag, *plaintext; 10391 uint16_t plaintext_pad_len; 10392 10393 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0, 10394 "No GMAC length in the source data"); 10395 10396 retval = create_gmac_session(ts_params->valid_devs[0], 10397 tdata, RTE_CRYPTO_AUTH_OP_GENERATE); 10398 10399 if (retval < 0) 10400 return retval; 10401 10402 if (tdata->plaintext.len > MBUF_SIZE) 10403 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); 10404 else 10405 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 10406 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 10407 "Failed to allocate input buffer in mempool"); 10408 10409 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 10410 rte_pktmbuf_tailroom(ut_params->ibuf)); 10411 10412 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16); 10413 /* 10414 * Runtime generate the large plain text instead of use hard code 10415 * plain text vector. It is done to avoid create huge source file 10416 * with the test vector. 10417 */ 10418 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH) 10419 generate_gmac_large_plaintext(tdata->plaintext.data); 10420 10421 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 10422 plaintext_pad_len); 10423 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); 10424 10425 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len); 10426 debug_hexdump(stdout, "plaintext:", plaintext, 10427 tdata->plaintext.len); 10428 10429 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE, 10430 tdata); 10431 10432 if (retval < 0) 10433 return retval; 10434 10435 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 10436 10437 ut_params->op->sym->m_src = ut_params->ibuf; 10438 10439 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 10440 ut_params->op), "failed to process sym crypto op"); 10441 10442 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 10443 "crypto op processing failed"); 10444 10445 if (ut_params->op->sym->m_dst) { 10446 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst, 10447 uint8_t *, plaintext_pad_len); 10448 } else { 10449 auth_tag = plaintext + plaintext_pad_len; 10450 } 10451 10452 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len); 10453 10454 TEST_ASSERT_BUFFERS_ARE_EQUAL( 10455 auth_tag, 10456 tdata->gmac_tag.data, 10457 tdata->gmac_tag.len, 10458 "GMAC Generated auth tag not as expected"); 10459 10460 return 0; 10461 } 10462 10463 static int 10464 test_AES_GMAC_authentication_test_case_1(void) 10465 { 10466 return test_AES_GMAC_authentication(&gmac_test_case_1); 10467 } 10468 10469 static int 10470 test_AES_GMAC_authentication_test_case_2(void) 10471 { 10472 return test_AES_GMAC_authentication(&gmac_test_case_2); 10473 } 10474 10475 static int 10476 test_AES_GMAC_authentication_test_case_3(void) 10477 { 10478 return test_AES_GMAC_authentication(&gmac_test_case_3); 10479 } 10480 10481 static int 10482 test_AES_GMAC_authentication_test_case_4(void) 10483 { 10484 return test_AES_GMAC_authentication(&gmac_test_case_4); 10485 } 10486 10487 static int 10488 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata) 10489 { 10490 struct crypto_testsuite_params *ts_params = &testsuite_params; 10491 struct crypto_unittest_params *ut_params = &unittest_params; 10492 int retval; 10493 uint32_t plaintext_pad_len; 10494 uint8_t *plaintext; 10495 10496 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0, 10497 "No GMAC length in the source data"); 10498 10499 retval = create_gmac_session(ts_params->valid_devs[0], 10500 tdata, RTE_CRYPTO_AUTH_OP_VERIFY); 10501 10502 if (retval < 0) 10503 return retval; 10504 10505 if (tdata->plaintext.len > MBUF_SIZE) 10506 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool); 10507 else 10508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 10509 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 10510 "Failed to allocate input buffer in mempool"); 10511 10512 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 10513 rte_pktmbuf_tailroom(ut_params->ibuf)); 10514 10515 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16); 10516 10517 /* 10518 * Runtime generate the large plain text instead of use hard code 10519 * plain text vector. It is done to avoid create huge source file 10520 * with the test vector. 10521 */ 10522 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH) 10523 generate_gmac_large_plaintext(tdata->plaintext.data); 10524 10525 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 10526 plaintext_pad_len); 10527 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); 10528 10529 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len); 10530 debug_hexdump(stdout, "plaintext:", plaintext, 10531 tdata->plaintext.len); 10532 10533 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY, 10534 tdata); 10535 10536 if (retval < 0) 10537 return retval; 10538 10539 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 10540 10541 ut_params->op->sym->m_src = ut_params->ibuf; 10542 10543 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 10544 ut_params->op), "failed to process sym crypto op"); 10545 10546 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 10547 "crypto op processing failed"); 10548 10549 return 0; 10550 10551 } 10552 10553 static int 10554 test_AES_GMAC_authentication_verify_test_case_1(void) 10555 { 10556 return test_AES_GMAC_authentication_verify(&gmac_test_case_1); 10557 } 10558 10559 static int 10560 test_AES_GMAC_authentication_verify_test_case_2(void) 10561 { 10562 return test_AES_GMAC_authentication_verify(&gmac_test_case_2); 10563 } 10564 10565 static int 10566 test_AES_GMAC_authentication_verify_test_case_3(void) 10567 { 10568 return test_AES_GMAC_authentication_verify(&gmac_test_case_3); 10569 } 10570 10571 static int 10572 test_AES_GMAC_authentication_verify_test_case_4(void) 10573 { 10574 return test_AES_GMAC_authentication_verify(&gmac_test_case_4); 10575 } 10576 10577 struct test_crypto_vector { 10578 enum rte_crypto_cipher_algorithm crypto_algo; 10579 unsigned int cipher_offset; 10580 unsigned int cipher_len; 10581 10582 struct { 10583 uint8_t data[64]; 10584 unsigned int len; 10585 } cipher_key; 10586 10587 struct { 10588 uint8_t data[64]; 10589 unsigned int len; 10590 } iv; 10591 10592 struct { 10593 const uint8_t *data; 10594 unsigned int len; 10595 } plaintext; 10596 10597 struct { 10598 const uint8_t *data; 10599 unsigned int len; 10600 } ciphertext; 10601 10602 enum rte_crypto_auth_algorithm auth_algo; 10603 unsigned int auth_offset; 10604 10605 struct { 10606 uint8_t data[128]; 10607 unsigned int len; 10608 } auth_key; 10609 10610 struct { 10611 const uint8_t *data; 10612 unsigned int len; 10613 } aad; 10614 10615 struct { 10616 uint8_t data[128]; 10617 unsigned int len; 10618 } digest; 10619 }; 10620 10621 static const struct test_crypto_vector 10622 hmac_sha1_test_crypto_vector = { 10623 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC, 10624 .plaintext = { 10625 .data = plaintext_hash, 10626 .len = 512 10627 }, 10628 .auth_key = { 10629 .data = { 10630 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 10631 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 10632 0xDE, 0xF4, 0xDE, 0xAD 10633 }, 10634 .len = 20 10635 }, 10636 .digest = { 10637 .data = { 10638 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77, 10639 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17, 10640 0x3F, 0x91, 0x64, 0x59 10641 }, 10642 .len = 20 10643 } 10644 }; 10645 10646 static const struct test_crypto_vector 10647 aes128_gmac_test_vector = { 10648 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC, 10649 .plaintext = { 10650 .data = plaintext_hash, 10651 .len = 512 10652 }, 10653 .iv = { 10654 .data = { 10655 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 10656 0x08, 0x09, 0x0A, 0x0B 10657 }, 10658 .len = 12 10659 }, 10660 .auth_key = { 10661 .data = { 10662 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1, 10663 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA 10664 }, 10665 .len = 16 10666 }, 10667 .digest = { 10668 .data = { 10669 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56, 10670 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A 10671 }, 10672 .len = 16 10673 } 10674 }; 10675 10676 static const struct test_crypto_vector 10677 aes128cbc_hmac_sha1_test_vector = { 10678 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC, 10679 .cipher_offset = 0, 10680 .cipher_len = 512, 10681 .cipher_key = { 10682 .data = { 10683 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2, 10684 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A 10685 }, 10686 .len = 16 10687 }, 10688 .iv = { 10689 .data = { 10690 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 10691 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F 10692 }, 10693 .len = 16 10694 }, 10695 .plaintext = { 10696 .data = plaintext_hash, 10697 .len = 512 10698 }, 10699 .ciphertext = { 10700 .data = ciphertext512_aes128cbc, 10701 .len = 512 10702 }, 10703 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC, 10704 .auth_offset = 0, 10705 .auth_key = { 10706 .data = { 10707 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 10708 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 10709 0xDE, 0xF4, 0xDE, 0xAD 10710 }, 10711 .len = 20 10712 }, 10713 .digest = { 10714 .data = { 10715 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60, 10716 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1, 10717 0x18, 0x8C, 0x1D, 0x32 10718 }, 10719 .len = 20 10720 } 10721 }; 10722 10723 static const struct test_crypto_vector 10724 aes128cbc_hmac_sha1_aad_test_vector = { 10725 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC, 10726 .cipher_offset = 12, 10727 .cipher_len = 496, 10728 .cipher_key = { 10729 .data = { 10730 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2, 10731 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A 10732 }, 10733 .len = 16 10734 }, 10735 .iv = { 10736 .data = { 10737 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 10738 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F 10739 }, 10740 .len = 16 10741 }, 10742 .plaintext = { 10743 .data = plaintext_hash, 10744 .len = 512 10745 }, 10746 .ciphertext = { 10747 .data = ciphertext512_aes128cbc_aad, 10748 .len = 512 10749 }, 10750 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC, 10751 .auth_offset = 0, 10752 .auth_key = { 10753 .data = { 10754 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 10755 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 10756 0xDE, 0xF4, 0xDE, 0xAD 10757 }, 10758 .len = 20 10759 }, 10760 .digest = { 10761 .data = { 10762 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E, 10763 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08, 10764 0x62, 0x8D, 0x62, 0x65 10765 }, 10766 .len = 20 10767 } 10768 }; 10769 10770 static void 10771 data_corruption(uint8_t *data) 10772 { 10773 data[0] += 1; 10774 } 10775 10776 static void 10777 tag_corruption(uint8_t *data, unsigned int tag_offset) 10778 { 10779 data[tag_offset] += 1; 10780 } 10781 10782 static int 10783 create_auth_session(struct crypto_unittest_params *ut_params, 10784 uint8_t dev_id, 10785 const struct test_crypto_vector *reference, 10786 enum rte_crypto_auth_operation auth_op) 10787 { 10788 struct crypto_testsuite_params *ts_params = &testsuite_params; 10789 uint8_t auth_key[reference->auth_key.len + 1]; 10790 10791 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); 10792 10793 /* Setup Authentication Parameters */ 10794 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 10795 ut_params->auth_xform.auth.op = auth_op; 10796 ut_params->auth_xform.next = NULL; 10797 ut_params->auth_xform.auth.algo = reference->auth_algo; 10798 ut_params->auth_xform.auth.key.length = reference->auth_key.len; 10799 ut_params->auth_xform.auth.key.data = auth_key; 10800 ut_params->auth_xform.auth.digest_length = reference->digest.len; 10801 10802 /* Create Crypto session*/ 10803 ut_params->sess = rte_cryptodev_sym_session_create( 10804 ts_params->session_mpool); 10805 10806 rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 10807 &ut_params->auth_xform, 10808 ts_params->session_priv_mpool); 10809 10810 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 10811 10812 return 0; 10813 } 10814 10815 static int 10816 create_auth_cipher_session(struct crypto_unittest_params *ut_params, 10817 uint8_t dev_id, 10818 const struct test_crypto_vector *reference, 10819 enum rte_crypto_auth_operation auth_op, 10820 enum rte_crypto_cipher_operation cipher_op) 10821 { 10822 struct crypto_testsuite_params *ts_params = &testsuite_params; 10823 uint8_t cipher_key[reference->cipher_key.len + 1]; 10824 uint8_t auth_key[reference->auth_key.len + 1]; 10825 10826 memcpy(cipher_key, reference->cipher_key.data, 10827 reference->cipher_key.len); 10828 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); 10829 10830 /* Setup Authentication Parameters */ 10831 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 10832 ut_params->auth_xform.auth.op = auth_op; 10833 ut_params->auth_xform.auth.algo = reference->auth_algo; 10834 ut_params->auth_xform.auth.key.length = reference->auth_key.len; 10835 ut_params->auth_xform.auth.key.data = auth_key; 10836 ut_params->auth_xform.auth.digest_length = reference->digest.len; 10837 10838 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) { 10839 ut_params->auth_xform.auth.iv.offset = IV_OFFSET; 10840 ut_params->auth_xform.auth.iv.length = reference->iv.len; 10841 } else { 10842 ut_params->auth_xform.next = &ut_params->cipher_xform; 10843 10844 /* Setup Cipher Parameters */ 10845 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 10846 ut_params->cipher_xform.next = NULL; 10847 ut_params->cipher_xform.cipher.algo = reference->crypto_algo; 10848 ut_params->cipher_xform.cipher.op = cipher_op; 10849 ut_params->cipher_xform.cipher.key.data = cipher_key; 10850 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len; 10851 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 10852 ut_params->cipher_xform.cipher.iv.length = reference->iv.len; 10853 } 10854 10855 /* Create Crypto session*/ 10856 ut_params->sess = rte_cryptodev_sym_session_create( 10857 ts_params->session_mpool); 10858 10859 rte_cryptodev_sym_session_init(dev_id, ut_params->sess, 10860 &ut_params->auth_xform, 10861 ts_params->session_priv_mpool); 10862 10863 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 10864 10865 return 0; 10866 } 10867 10868 static int 10869 create_auth_operation(struct crypto_testsuite_params *ts_params, 10870 struct crypto_unittest_params *ut_params, 10871 const struct test_crypto_vector *reference, 10872 unsigned int auth_generate) 10873 { 10874 /* Generate Crypto op data structure */ 10875 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 10876 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 10877 TEST_ASSERT_NOT_NULL(ut_params->op, 10878 "Failed to allocate pktmbuf offload"); 10879 10880 /* Set crypto operation data parameters */ 10881 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 10882 10883 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 10884 10885 /* set crypto operation source mbuf */ 10886 sym_op->m_src = ut_params->ibuf; 10887 10888 /* digest */ 10889 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( 10890 ut_params->ibuf, reference->digest.len); 10891 10892 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, 10893 "no room to append auth tag"); 10894 10895 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 10896 ut_params->ibuf, reference->plaintext.len); 10897 10898 if (auth_generate) 10899 memset(sym_op->auth.digest.data, 0, reference->digest.len); 10900 else 10901 memcpy(sym_op->auth.digest.data, 10902 reference->digest.data, 10903 reference->digest.len); 10904 10905 debug_hexdump(stdout, "digest:", 10906 sym_op->auth.digest.data, 10907 reference->digest.len); 10908 10909 sym_op->auth.data.length = reference->plaintext.len; 10910 sym_op->auth.data.offset = 0; 10911 10912 return 0; 10913 } 10914 10915 static int 10916 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params, 10917 struct crypto_unittest_params *ut_params, 10918 const struct test_crypto_vector *reference, 10919 unsigned int auth_generate) 10920 { 10921 /* Generate Crypto op data structure */ 10922 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 10923 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 10924 TEST_ASSERT_NOT_NULL(ut_params->op, 10925 "Failed to allocate pktmbuf offload"); 10926 10927 /* Set crypto operation data parameters */ 10928 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 10929 10930 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 10931 10932 /* set crypto operation source mbuf */ 10933 sym_op->m_src = ut_params->ibuf; 10934 10935 /* digest */ 10936 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( 10937 ut_params->ibuf, reference->digest.len); 10938 10939 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, 10940 "no room to append auth tag"); 10941 10942 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 10943 ut_params->ibuf, reference->ciphertext.len); 10944 10945 if (auth_generate) 10946 memset(sym_op->auth.digest.data, 0, reference->digest.len); 10947 else 10948 memcpy(sym_op->auth.digest.data, 10949 reference->digest.data, 10950 reference->digest.len); 10951 10952 debug_hexdump(stdout, "digest:", 10953 sym_op->auth.digest.data, 10954 reference->digest.len); 10955 10956 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), 10957 reference->iv.data, reference->iv.len); 10958 10959 sym_op->cipher.data.length = 0; 10960 sym_op->cipher.data.offset = 0; 10961 10962 sym_op->auth.data.length = reference->plaintext.len; 10963 sym_op->auth.data.offset = 0; 10964 10965 return 0; 10966 } 10967 10968 static int 10969 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params, 10970 struct crypto_unittest_params *ut_params, 10971 const struct test_crypto_vector *reference, 10972 unsigned int auth_generate) 10973 { 10974 /* Generate Crypto op data structure */ 10975 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 10976 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 10977 TEST_ASSERT_NOT_NULL(ut_params->op, 10978 "Failed to allocate pktmbuf offload"); 10979 10980 /* Set crypto operation data parameters */ 10981 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 10982 10983 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 10984 10985 /* set crypto operation source mbuf */ 10986 sym_op->m_src = ut_params->ibuf; 10987 10988 /* digest */ 10989 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append( 10990 ut_params->ibuf, reference->digest.len); 10991 10992 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, 10993 "no room to append auth tag"); 10994 10995 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset( 10996 ut_params->ibuf, reference->ciphertext.len); 10997 10998 if (auth_generate) 10999 memset(sym_op->auth.digest.data, 0, reference->digest.len); 11000 else 11001 memcpy(sym_op->auth.digest.data, 11002 reference->digest.data, 11003 reference->digest.len); 11004 11005 debug_hexdump(stdout, "digest:", 11006 sym_op->auth.digest.data, 11007 reference->digest.len); 11008 11009 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET), 11010 reference->iv.data, reference->iv.len); 11011 11012 sym_op->cipher.data.length = reference->cipher_len; 11013 sym_op->cipher.data.offset = reference->cipher_offset; 11014 11015 sym_op->auth.data.length = reference->plaintext.len; 11016 sym_op->auth.data.offset = reference->auth_offset; 11017 11018 return 0; 11019 } 11020 11021 static int 11022 create_auth_verify_operation(struct crypto_testsuite_params *ts_params, 11023 struct crypto_unittest_params *ut_params, 11024 const struct test_crypto_vector *reference) 11025 { 11026 return create_auth_operation(ts_params, ut_params, reference, 0); 11027 } 11028 11029 static int 11030 create_auth_verify_GMAC_operation( 11031 struct crypto_testsuite_params *ts_params, 11032 struct crypto_unittest_params *ut_params, 11033 const struct test_crypto_vector *reference) 11034 { 11035 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0); 11036 } 11037 11038 static int 11039 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params, 11040 struct crypto_unittest_params *ut_params, 11041 const struct test_crypto_vector *reference) 11042 { 11043 return create_cipher_auth_operation(ts_params, ut_params, reference, 0); 11044 } 11045 11046 static int 11047 test_authentication_verify_fail_when_data_corruption( 11048 struct crypto_testsuite_params *ts_params, 11049 struct crypto_unittest_params *ut_params, 11050 const struct test_crypto_vector *reference, 11051 unsigned int data_corrupted) 11052 { 11053 int retval; 11054 11055 uint8_t *plaintext; 11056 11057 /* Create session */ 11058 retval = create_auth_session(ut_params, 11059 ts_params->valid_devs[0], 11060 reference, 11061 RTE_CRYPTO_AUTH_OP_VERIFY); 11062 if (retval < 0) 11063 return retval; 11064 11065 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 11066 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 11067 "Failed to allocate input buffer in mempool"); 11068 11069 /* clear mbuf payload */ 11070 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 11071 rte_pktmbuf_tailroom(ut_params->ibuf)); 11072 11073 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 11074 reference->plaintext.len); 11075 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); 11076 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len); 11077 11078 debug_hexdump(stdout, "plaintext:", plaintext, 11079 reference->plaintext.len); 11080 11081 /* Create operation */ 11082 retval = create_auth_verify_operation(ts_params, ut_params, reference); 11083 11084 if (retval < 0) 11085 return retval; 11086 11087 if (data_corrupted) 11088 data_corruption(plaintext); 11089 else 11090 tag_corruption(plaintext, reference->plaintext.len); 11091 11092 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 11093 ut_params->op); 11094 11095 TEST_ASSERT_NULL(ut_params->op, "authentication not failed"); 11096 11097 return 0; 11098 } 11099 11100 static int 11101 test_authentication_verify_GMAC_fail_when_corruption( 11102 struct crypto_testsuite_params *ts_params, 11103 struct crypto_unittest_params *ut_params, 11104 const struct test_crypto_vector *reference, 11105 unsigned int data_corrupted) 11106 { 11107 int retval; 11108 uint8_t *plaintext; 11109 11110 /* Create session */ 11111 retval = create_auth_cipher_session(ut_params, 11112 ts_params->valid_devs[0], 11113 reference, 11114 RTE_CRYPTO_AUTH_OP_VERIFY, 11115 RTE_CRYPTO_CIPHER_OP_DECRYPT); 11116 if (retval < 0) 11117 return retval; 11118 11119 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 11120 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 11121 "Failed to allocate input buffer in mempool"); 11122 11123 /* clear mbuf payload */ 11124 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 11125 rte_pktmbuf_tailroom(ut_params->ibuf)); 11126 11127 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 11128 reference->plaintext.len); 11129 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); 11130 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len); 11131 11132 debug_hexdump(stdout, "plaintext:", plaintext, 11133 reference->plaintext.len); 11134 11135 /* Create operation */ 11136 retval = create_auth_verify_GMAC_operation(ts_params, 11137 ut_params, 11138 reference); 11139 11140 if (retval < 0) 11141 return retval; 11142 11143 if (data_corrupted) 11144 data_corruption(plaintext); 11145 else 11146 tag_corruption(plaintext, reference->aad.len); 11147 11148 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 11149 ut_params->op); 11150 11151 TEST_ASSERT_NULL(ut_params->op, "authentication not failed"); 11152 11153 return 0; 11154 } 11155 11156 static int 11157 test_authenticated_decryption_fail_when_corruption( 11158 struct crypto_testsuite_params *ts_params, 11159 struct crypto_unittest_params *ut_params, 11160 const struct test_crypto_vector *reference, 11161 unsigned int data_corrupted) 11162 { 11163 int retval; 11164 11165 uint8_t *ciphertext; 11166 11167 /* Create session */ 11168 retval = create_auth_cipher_session(ut_params, 11169 ts_params->valid_devs[0], 11170 reference, 11171 RTE_CRYPTO_AUTH_OP_VERIFY, 11172 RTE_CRYPTO_CIPHER_OP_DECRYPT); 11173 if (retval < 0) 11174 return retval; 11175 11176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 11177 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 11178 "Failed to allocate input buffer in mempool"); 11179 11180 /* clear mbuf payload */ 11181 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 11182 rte_pktmbuf_tailroom(ut_params->ibuf)); 11183 11184 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 11185 reference->ciphertext.len); 11186 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext"); 11187 memcpy(ciphertext, reference->ciphertext.data, 11188 reference->ciphertext.len); 11189 11190 /* Create operation */ 11191 retval = create_cipher_auth_verify_operation(ts_params, 11192 ut_params, 11193 reference); 11194 11195 if (retval < 0) 11196 return retval; 11197 11198 if (data_corrupted) 11199 data_corruption(ciphertext); 11200 else 11201 tag_corruption(ciphertext, reference->ciphertext.len); 11202 11203 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 11204 ut_params->op); 11205 11206 TEST_ASSERT_NULL(ut_params->op, "authentication not failed"); 11207 11208 return 0; 11209 } 11210 11211 static int 11212 test_authenticated_encryt_with_esn( 11213 struct crypto_testsuite_params *ts_params, 11214 struct crypto_unittest_params *ut_params, 11215 const struct test_crypto_vector *reference) 11216 { 11217 int retval; 11218 11219 uint8_t *authciphertext, *plaintext, *auth_tag; 11220 uint16_t plaintext_pad_len; 11221 uint8_t cipher_key[reference->cipher_key.len + 1]; 11222 uint8_t auth_key[reference->auth_key.len + 1]; 11223 11224 /* Create session */ 11225 memcpy(cipher_key, reference->cipher_key.data, 11226 reference->cipher_key.len); 11227 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); 11228 11229 /* Setup Cipher Parameters */ 11230 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 11231 ut_params->cipher_xform.cipher.algo = reference->crypto_algo; 11232 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT; 11233 ut_params->cipher_xform.cipher.key.data = cipher_key; 11234 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len; 11235 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 11236 ut_params->cipher_xform.cipher.iv.length = reference->iv.len; 11237 11238 ut_params->cipher_xform.next = &ut_params->auth_xform; 11239 11240 /* Setup Authentication Parameters */ 11241 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 11242 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE; 11243 ut_params->auth_xform.auth.algo = reference->auth_algo; 11244 ut_params->auth_xform.auth.key.length = reference->auth_key.len; 11245 ut_params->auth_xform.auth.key.data = auth_key; 11246 ut_params->auth_xform.auth.digest_length = reference->digest.len; 11247 ut_params->auth_xform.next = NULL; 11248 11249 /* Create Crypto session*/ 11250 ut_params->sess = rte_cryptodev_sym_session_create( 11251 ts_params->session_mpool); 11252 11253 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 11254 ut_params->sess, 11255 &ut_params->cipher_xform, 11256 ts_params->session_priv_mpool); 11257 11258 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 11259 11260 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 11261 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 11262 "Failed to allocate input buffer in mempool"); 11263 11264 /* clear mbuf payload */ 11265 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 11266 rte_pktmbuf_tailroom(ut_params->ibuf)); 11267 11268 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 11269 reference->plaintext.len); 11270 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext"); 11271 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len); 11272 11273 /* Create operation */ 11274 retval = create_cipher_auth_operation(ts_params, 11275 ut_params, 11276 reference, 0); 11277 11278 if (retval < 0) 11279 return retval; 11280 11281 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 11282 ut_params->op); 11283 11284 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned"); 11285 11286 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 11287 "crypto op processing failed"); 11288 11289 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16); 11290 11291 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *, 11292 ut_params->op->sym->auth.data.offset); 11293 auth_tag = authciphertext + plaintext_pad_len; 11294 debug_hexdump(stdout, "ciphertext:", authciphertext, 11295 reference->ciphertext.len); 11296 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len); 11297 11298 /* Validate obuf */ 11299 TEST_ASSERT_BUFFERS_ARE_EQUAL( 11300 authciphertext, 11301 reference->ciphertext.data, 11302 reference->ciphertext.len, 11303 "Ciphertext data not as expected"); 11304 11305 TEST_ASSERT_BUFFERS_ARE_EQUAL( 11306 auth_tag, 11307 reference->digest.data, 11308 reference->digest.len, 11309 "Generated digest not as expected"); 11310 11311 return TEST_SUCCESS; 11312 11313 } 11314 11315 static int 11316 test_authenticated_decrypt_with_esn( 11317 struct crypto_testsuite_params *ts_params, 11318 struct crypto_unittest_params *ut_params, 11319 const struct test_crypto_vector *reference) 11320 { 11321 int retval; 11322 11323 uint8_t *ciphertext; 11324 uint8_t cipher_key[reference->cipher_key.len + 1]; 11325 uint8_t auth_key[reference->auth_key.len + 1]; 11326 11327 /* Create session */ 11328 memcpy(cipher_key, reference->cipher_key.data, 11329 reference->cipher_key.len); 11330 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len); 11331 11332 /* Setup Authentication Parameters */ 11333 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH; 11334 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY; 11335 ut_params->auth_xform.auth.algo = reference->auth_algo; 11336 ut_params->auth_xform.auth.key.length = reference->auth_key.len; 11337 ut_params->auth_xform.auth.key.data = auth_key; 11338 ut_params->auth_xform.auth.digest_length = reference->digest.len; 11339 ut_params->auth_xform.next = &ut_params->cipher_xform; 11340 11341 /* Setup Cipher Parameters */ 11342 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER; 11343 ut_params->cipher_xform.next = NULL; 11344 ut_params->cipher_xform.cipher.algo = reference->crypto_algo; 11345 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT; 11346 ut_params->cipher_xform.cipher.key.data = cipher_key; 11347 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len; 11348 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET; 11349 ut_params->cipher_xform.cipher.iv.length = reference->iv.len; 11350 11351 /* Create Crypto session*/ 11352 ut_params->sess = rte_cryptodev_sym_session_create( 11353 ts_params->session_mpool); 11354 11355 rte_cryptodev_sym_session_init(ts_params->valid_devs[0], 11356 ut_params->sess, 11357 &ut_params->auth_xform, 11358 ts_params->session_priv_mpool); 11359 11360 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed"); 11361 11362 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 11363 TEST_ASSERT_NOT_NULL(ut_params->ibuf, 11364 "Failed to allocate input buffer in mempool"); 11365 11366 /* clear mbuf payload */ 11367 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 11368 rte_pktmbuf_tailroom(ut_params->ibuf)); 11369 11370 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 11371 reference->ciphertext.len); 11372 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext"); 11373 memcpy(ciphertext, reference->ciphertext.data, 11374 reference->ciphertext.len); 11375 11376 /* Create operation */ 11377 retval = create_cipher_auth_verify_operation(ts_params, 11378 ut_params, 11379 reference); 11380 11381 if (retval < 0) 11382 return retval; 11383 11384 ut_params->op = process_crypto_request(ts_params->valid_devs[0], 11385 ut_params->op); 11386 11387 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process"); 11388 TEST_ASSERT_EQUAL(ut_params->op->status, 11389 RTE_CRYPTO_OP_STATUS_SUCCESS, 11390 "crypto op processing passed"); 11391 11392 ut_params->obuf = ut_params->op->sym->m_src; 11393 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf"); 11394 11395 return 0; 11396 } 11397 11398 static int 11399 create_aead_operation_SGL(enum rte_crypto_aead_operation op, 11400 const struct aead_test_data *tdata, 11401 void *digest_mem, uint64_t digest_phys) 11402 { 11403 struct crypto_testsuite_params *ts_params = &testsuite_params; 11404 struct crypto_unittest_params *ut_params = &unittest_params; 11405 11406 const unsigned int auth_tag_len = tdata->auth_tag.len; 11407 const unsigned int iv_len = tdata->iv.len; 11408 unsigned int aad_len = tdata->aad.len; 11409 unsigned int aad_len_pad = 0; 11410 11411 /* Generate Crypto op data structure */ 11412 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool, 11413 RTE_CRYPTO_OP_TYPE_SYMMETRIC); 11414 TEST_ASSERT_NOT_NULL(ut_params->op, 11415 "Failed to allocate symmetric crypto operation struct"); 11416 11417 struct rte_crypto_sym_op *sym_op = ut_params->op->sym; 11418 11419 sym_op->aead.digest.data = digest_mem; 11420 11421 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data, 11422 "no room to append digest"); 11423 11424 sym_op->aead.digest.phys_addr = digest_phys; 11425 11426 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) { 11427 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data, 11428 auth_tag_len); 11429 debug_hexdump(stdout, "digest:", 11430 sym_op->aead.digest.data, 11431 auth_tag_len); 11432 } 11433 11434 /* Append aad data */ 11435 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) { 11436 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, 11437 uint8_t *, IV_OFFSET); 11438 11439 /* Copy IV 1 byte after the IV pointer, according to the API */ 11440 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len); 11441 11442 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16); 11443 11444 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend( 11445 ut_params->ibuf, aad_len); 11446 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data, 11447 "no room to prepend aad"); 11448 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova( 11449 ut_params->ibuf); 11450 11451 memset(sym_op->aead.aad.data, 0, aad_len); 11452 /* Copy AAD 18 bytes after the AAD pointer, according to the API */ 11453 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len); 11454 11455 debug_hexdump(stdout, "iv:", iv_ptr, iv_len); 11456 debug_hexdump(stdout, "aad:", 11457 sym_op->aead.aad.data, aad_len); 11458 } else { 11459 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, 11460 uint8_t *, IV_OFFSET); 11461 11462 rte_memcpy(iv_ptr, tdata->iv.data, iv_len); 11463 11464 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16); 11465 11466 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend( 11467 ut_params->ibuf, aad_len_pad); 11468 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data, 11469 "no room to prepend aad"); 11470 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova( 11471 ut_params->ibuf); 11472 11473 memset(sym_op->aead.aad.data, 0, aad_len); 11474 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len); 11475 11476 debug_hexdump(stdout, "iv:", iv_ptr, iv_len); 11477 debug_hexdump(stdout, "aad:", 11478 sym_op->aead.aad.data, aad_len); 11479 } 11480 11481 sym_op->aead.data.length = tdata->plaintext.len; 11482 sym_op->aead.data.offset = aad_len_pad; 11483 11484 return 0; 11485 } 11486 11487 #define SGL_MAX_NO 16 11488 11489 static int 11490 test_authenticated_encryption_SGL(const struct aead_test_data *tdata, 11491 const int oop, uint32_t fragsz, uint32_t fragsz_oop) 11492 { 11493 struct crypto_testsuite_params *ts_params = &testsuite_params; 11494 struct crypto_unittest_params *ut_params = &unittest_params; 11495 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL; 11496 int retval; 11497 int to_trn = 0; 11498 int to_trn_tbl[SGL_MAX_NO]; 11499 int segs = 1; 11500 unsigned int trn_data = 0; 11501 uint8_t *plaintext, *ciphertext, *auth_tag; 11502 11503 if (fragsz > tdata->plaintext.len) 11504 fragsz = tdata->plaintext.len; 11505 11506 uint16_t plaintext_len = fragsz; 11507 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz; 11508 11509 if (fragsz_oop > tdata->plaintext.len) 11510 frag_size_oop = tdata->plaintext.len; 11511 11512 int ecx = 0; 11513 void *digest_mem = NULL; 11514 11515 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16); 11516 11517 if (tdata->plaintext.len % fragsz != 0) { 11518 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO) 11519 return 1; 11520 } else { 11521 if (tdata->plaintext.len / fragsz > SGL_MAX_NO) 11522 return 1; 11523 } 11524 11525 /* 11526 * For out-op-place we need to alloc another mbuf 11527 */ 11528 if (oop) { 11529 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 11530 rte_pktmbuf_append(ut_params->obuf, 11531 frag_size_oop + prepend_len); 11532 buf_oop = ut_params->obuf; 11533 } 11534 11535 /* Create AEAD session */ 11536 retval = create_aead_session(ts_params->valid_devs[0], 11537 tdata->algo, 11538 RTE_CRYPTO_AEAD_OP_ENCRYPT, 11539 tdata->key.data, tdata->key.len, 11540 tdata->aad.len, tdata->auth_tag.len, 11541 tdata->iv.len); 11542 if (retval < 0) 11543 return retval; 11544 11545 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool); 11546 11547 /* clear mbuf payload */ 11548 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, 11549 rte_pktmbuf_tailroom(ut_params->ibuf)); 11550 11551 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 11552 plaintext_len); 11553 11554 memcpy(plaintext, tdata->plaintext.data, plaintext_len); 11555 11556 trn_data += plaintext_len; 11557 11558 buf = ut_params->ibuf; 11559 11560 /* 11561 * Loop until no more fragments 11562 */ 11563 11564 while (trn_data < tdata->plaintext.len) { 11565 ++segs; 11566 to_trn = (tdata->plaintext.len - trn_data < fragsz) ? 11567 (tdata->plaintext.len - trn_data) : fragsz; 11568 11569 to_trn_tbl[ecx++] = to_trn; 11570 11571 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool); 11572 buf = buf->next; 11573 11574 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0, 11575 rte_pktmbuf_tailroom(buf)); 11576 11577 /* OOP */ 11578 if (oop && !fragsz_oop) { 11579 buf_last_oop = buf_oop->next = 11580 rte_pktmbuf_alloc(ts_params->mbuf_pool); 11581 buf_oop = buf_oop->next; 11582 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *), 11583 0, rte_pktmbuf_tailroom(buf_oop)); 11584 rte_pktmbuf_append(buf_oop, to_trn); 11585 } 11586 11587 plaintext = (uint8_t *)rte_pktmbuf_append(buf, 11588 to_trn); 11589 11590 memcpy(plaintext, tdata->plaintext.data + trn_data, 11591 to_trn); 11592 trn_data += to_trn; 11593 if (trn_data == tdata->plaintext.len) { 11594 if (oop) { 11595 if (!fragsz_oop) 11596 digest_mem = rte_pktmbuf_append(buf_oop, 11597 tdata->auth_tag.len); 11598 } else 11599 digest_mem = (uint8_t *)rte_pktmbuf_append(buf, 11600 tdata->auth_tag.len); 11601 } 11602 } 11603 11604 uint64_t digest_phys = 0; 11605 11606 ut_params->ibuf->nb_segs = segs; 11607 11608 segs = 1; 11609 if (fragsz_oop && oop) { 11610 to_trn = 0; 11611 ecx = 0; 11612 11613 if (frag_size_oop == tdata->plaintext.len) { 11614 digest_mem = rte_pktmbuf_append(ut_params->obuf, 11615 tdata->auth_tag.len); 11616 11617 digest_phys = rte_pktmbuf_iova_offset( 11618 ut_params->obuf, 11619 tdata->plaintext.len + prepend_len); 11620 } 11621 11622 trn_data = frag_size_oop; 11623 while (trn_data < tdata->plaintext.len) { 11624 ++segs; 11625 to_trn = 11626 (tdata->plaintext.len - trn_data < 11627 frag_size_oop) ? 11628 (tdata->plaintext.len - trn_data) : 11629 frag_size_oop; 11630 11631 to_trn_tbl[ecx++] = to_trn; 11632 11633 buf_last_oop = buf_oop->next = 11634 rte_pktmbuf_alloc(ts_params->mbuf_pool); 11635 buf_oop = buf_oop->next; 11636 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *), 11637 0, rte_pktmbuf_tailroom(buf_oop)); 11638 rte_pktmbuf_append(buf_oop, to_trn); 11639 11640 trn_data += to_trn; 11641 11642 if (trn_data == tdata->plaintext.len) { 11643 digest_mem = rte_pktmbuf_append(buf_oop, 11644 tdata->auth_tag.len); 11645 } 11646 } 11647 11648 ut_params->obuf->nb_segs = segs; 11649 } 11650 11651 /* 11652 * Place digest at the end of the last buffer 11653 */ 11654 if (!digest_phys) 11655 digest_phys = rte_pktmbuf_iova(buf) + to_trn; 11656 if (oop && buf_last_oop) 11657 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn; 11658 11659 if (!digest_mem && !oop) { 11660 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, 11661 + tdata->auth_tag.len); 11662 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf, 11663 tdata->plaintext.len); 11664 } 11665 11666 /* Create AEAD operation */ 11667 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT, 11668 tdata, digest_mem, digest_phys); 11669 11670 if (retval < 0) 11671 return retval; 11672 11673 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess); 11674 11675 ut_params->op->sym->m_src = ut_params->ibuf; 11676 if (oop) 11677 ut_params->op->sym->m_dst = ut_params->obuf; 11678 11679 /* Process crypto operation */ 11680 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0], 11681 ut_params->op), "failed to process sym crypto op"); 11682 11683 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS, 11684 "crypto op processing failed"); 11685 11686 11687 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src, 11688 uint8_t *, prepend_len); 11689 if (oop) { 11690 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst, 11691 uint8_t *, prepend_len); 11692 } 11693 11694 if (fragsz_oop) 11695 fragsz = fragsz_oop; 11696 11697 TEST_ASSERT_BUFFERS_ARE_EQUAL( 11698 ciphertext, 11699 tdata->ciphertext.data, 11700 fragsz, 11701 "Ciphertext data not as expected"); 11702 11703 buf = ut_params->op->sym->m_src->next; 11704 if (oop) 11705 buf = ut_params->op->sym->m_dst->next; 11706 11707 unsigned int off = fragsz; 11708 11709 ecx = 0; 11710 while (buf) { 11711 ciphertext = rte_pktmbuf_mtod(buf, 11712 uint8_t *); 11713 11714 TEST_ASSERT_BUFFERS_ARE_EQUAL( 11715 ciphertext, 11716 tdata->ciphertext.data + off, 11717 to_trn_tbl[ecx], 11718 "Ciphertext data not as expected"); 11719 11720 off += to_trn_tbl[ecx++]; 11721 buf = buf->next; 11722 } 11723 11724 auth_tag = digest_mem; 11725 TEST_ASSERT_BUFFERS_ARE_EQUAL( 11726 auth_tag, 11727 tdata->auth_tag.data, 11728 tdata->auth_tag.len, 11729 "Generated auth tag not as expected"); 11730 11731 return 0; 11732 } 11733 11734 static int 11735 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void) 11736 { 11737 return test_authenticated_encryption_SGL( 11738 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400); 11739 } 11740 11741 static int 11742 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void) 11743 { 11744 return test_authenticated_encryption_SGL( 11745 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000); 11746 } 11747 11748 static int 11749 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void) 11750 { 11751 return test_authenticated_encryption_SGL( 11752 &gcm_test_case_8, OUT_OF_PLACE, 400, 11753 gcm_test_case_8.plaintext.len); 11754 } 11755 11756 static int 11757 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void) 11758 { 11759 11760 return test_authenticated_encryption_SGL( 11761 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0); 11762 } 11763 11764 static int 11765 test_authentication_verify_fail_when_data_corrupted( 11766 struct crypto_testsuite_params *ts_params, 11767 struct crypto_unittest_params *ut_params, 11768 const struct test_crypto_vector *reference) 11769 { 11770 return test_authentication_verify_fail_when_data_corruption( 11771 ts_params, ut_params, reference, 1); 11772 } 11773 11774 static int 11775 test_authentication_verify_fail_when_tag_corrupted( 11776 struct crypto_testsuite_params *ts_params, 11777 struct crypto_unittest_params *ut_params, 11778 const struct test_crypto_vector *reference) 11779 { 11780 return test_authentication_verify_fail_when_data_corruption( 11781 ts_params, ut_params, reference, 0); 11782 } 11783 11784 static int 11785 test_authentication_verify_GMAC_fail_when_data_corrupted( 11786 struct crypto_testsuite_params *ts_params, 11787 struct crypto_unittest_params *ut_params, 11788 const struct test_crypto_vector *reference) 11789 { 11790 return test_authentication_verify_GMAC_fail_when_corruption( 11791 ts_params, ut_params, reference, 1); 11792 } 11793 11794 static int 11795 test_authentication_verify_GMAC_fail_when_tag_corrupted( 11796 struct crypto_testsuite_params *ts_params, 11797 struct crypto_unittest_params *ut_params, 11798 const struct test_crypto_vector *reference) 11799 { 11800 return test_authentication_verify_GMAC_fail_when_corruption( 11801 ts_params, ut_params, reference, 0); 11802 } 11803 11804 static int 11805 test_authenticated_decryption_fail_when_data_corrupted( 11806 struct crypto_testsuite_params *ts_params, 11807 struct crypto_unittest_params *ut_params, 11808 const struct test_crypto_vector *reference) 11809 { 11810 return test_authenticated_decryption_fail_when_corruption( 11811 ts_params, ut_params, reference, 1); 11812 } 11813 11814 static int 11815 test_authenticated_decryption_fail_when_tag_corrupted( 11816 struct crypto_testsuite_params *ts_params, 11817 struct crypto_unittest_params *ut_params, 11818 const struct test_crypto_vector *reference) 11819 { 11820 return test_authenticated_decryption_fail_when_corruption( 11821 ts_params, ut_params, reference, 0); 11822 } 11823 11824 static int 11825 authentication_verify_HMAC_SHA1_fail_data_corrupt(void) 11826 { 11827 return test_authentication_verify_fail_when_data_corrupted( 11828 &testsuite_params, &unittest_params, 11829 &hmac_sha1_test_crypto_vector); 11830 } 11831 11832 static int 11833 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void) 11834 { 11835 return test_authentication_verify_fail_when_tag_corrupted( 11836 &testsuite_params, &unittest_params, 11837 &hmac_sha1_test_crypto_vector); 11838 } 11839 11840 static int 11841 authentication_verify_AES128_GMAC_fail_data_corrupt(void) 11842 { 11843 return test_authentication_verify_GMAC_fail_when_data_corrupted( 11844 &testsuite_params, &unittest_params, 11845 &aes128_gmac_test_vector); 11846 } 11847 11848 static int 11849 authentication_verify_AES128_GMAC_fail_tag_corrupt(void) 11850 { 11851 return test_authentication_verify_GMAC_fail_when_tag_corrupted( 11852 &testsuite_params, &unittest_params, 11853 &aes128_gmac_test_vector); 11854 } 11855 11856 static int 11857 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void) 11858 { 11859 return test_authenticated_decryption_fail_when_data_corrupted( 11860 &testsuite_params, 11861 &unittest_params, 11862 &aes128cbc_hmac_sha1_test_vector); 11863 } 11864 11865 static int 11866 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void) 11867 { 11868 return test_authenticated_decryption_fail_when_tag_corrupted( 11869 &testsuite_params, 11870 &unittest_params, 11871 &aes128cbc_hmac_sha1_test_vector); 11872 } 11873 11874 static int 11875 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void) 11876 { 11877 return test_authenticated_encryt_with_esn( 11878 &testsuite_params, 11879 &unittest_params, 11880 &aes128cbc_hmac_sha1_aad_test_vector); 11881 } 11882 11883 static int 11884 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void) 11885 { 11886 return test_authenticated_decrypt_with_esn( 11887 &testsuite_params, 11888 &unittest_params, 11889 &aes128cbc_hmac_sha1_aad_test_vector); 11890 } 11891 11892 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER 11893 11894 /* global AESNI slave IDs for the scheduler test */ 11895 uint8_t aesni_ids[2]; 11896 11897 static int 11898 test_scheduler_attach_slave_op(void) 11899 { 11900 struct crypto_testsuite_params *ts_params = &testsuite_params; 11901 uint8_t sched_id = ts_params->valid_devs[0]; 11902 uint32_t nb_devs, i, nb_devs_attached = 0; 11903 int ret; 11904 char vdev_name[32]; 11905 11906 /* create 2 AESNI_MB if necessary */ 11907 nb_devs = rte_cryptodev_device_count_by_driver( 11908 rte_cryptodev_driver_id_get( 11909 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))); 11910 if (nb_devs < 2) { 11911 for (i = nb_devs; i < 2; i++) { 11912 snprintf(vdev_name, sizeof(vdev_name), "%s_%u", 11913 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), 11914 i); 11915 ret = rte_vdev_init(vdev_name, NULL); 11916 11917 TEST_ASSERT(ret == 0, 11918 "Failed to create instance %u of" 11919 " pmd : %s", 11920 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)); 11921 } 11922 } 11923 11924 /* attach 2 AESNI_MB cdevs */ 11925 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2; 11926 i++) { 11927 struct rte_cryptodev_info info; 11928 unsigned int session_size; 11929 11930 rte_cryptodev_info_get(i, &info); 11931 if (info.driver_id != rte_cryptodev_driver_id_get( 11932 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) 11933 continue; 11934 11935 session_size = rte_cryptodev_sym_get_private_session_size(i); 11936 /* 11937 * Create the session mempool again, since now there are new devices 11938 * to use the mempool. 11939 */ 11940 if (ts_params->session_mpool) { 11941 rte_mempool_free(ts_params->session_mpool); 11942 ts_params->session_mpool = NULL; 11943 } 11944 if (ts_params->session_priv_mpool) { 11945 rte_mempool_free(ts_params->session_priv_mpool); 11946 ts_params->session_priv_mpool = NULL; 11947 } 11948 11949 if (info.sym.max_nb_sessions != 0 && 11950 info.sym.max_nb_sessions < MAX_NB_SESSIONS) { 11951 RTE_LOG(ERR, USER1, 11952 "Device does not support " 11953 "at least %u sessions\n", 11954 MAX_NB_SESSIONS); 11955 return TEST_FAILED; 11956 } 11957 /* 11958 * Create mempool with maximum number of sessions, 11959 * to include the session headers 11960 */ 11961 if (ts_params->session_mpool == NULL) { 11962 ts_params->session_mpool = 11963 rte_cryptodev_sym_session_pool_create( 11964 "test_sess_mp", 11965 MAX_NB_SESSIONS, 0, 0, 0, 11966 SOCKET_ID_ANY); 11967 TEST_ASSERT_NOT_NULL(ts_params->session_mpool, 11968 "session mempool allocation failed"); 11969 } 11970 11971 /* 11972 * Create mempool with maximum number of sessions, 11973 * to include device specific session private data 11974 */ 11975 if (ts_params->session_priv_mpool == NULL) { 11976 ts_params->session_priv_mpool = rte_mempool_create( 11977 "test_sess_mp_priv", 11978 MAX_NB_SESSIONS, 11979 session_size, 11980 0, 0, NULL, NULL, NULL, 11981 NULL, SOCKET_ID_ANY, 11982 0); 11983 11984 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool, 11985 "session mempool allocation failed"); 11986 } 11987 11988 ts_params->qp_conf.mp_session = ts_params->session_mpool; 11989 ts_params->qp_conf.mp_session_private = 11990 ts_params->session_priv_mpool; 11991 11992 ret = rte_cryptodev_scheduler_slave_attach(sched_id, 11993 (uint8_t)i); 11994 11995 TEST_ASSERT(ret == 0, 11996 "Failed to attach device %u of pmd : %s", i, 11997 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)); 11998 11999 aesni_ids[nb_devs_attached] = (uint8_t)i; 12000 12001 nb_devs_attached++; 12002 } 12003 12004 return 0; 12005 } 12006 12007 static int 12008 test_scheduler_detach_slave_op(void) 12009 { 12010 struct crypto_testsuite_params *ts_params = &testsuite_params; 12011 uint8_t sched_id = ts_params->valid_devs[0]; 12012 uint32_t i; 12013 int ret; 12014 12015 for (i = 0; i < 2; i++) { 12016 ret = rte_cryptodev_scheduler_slave_detach(sched_id, 12017 aesni_ids[i]); 12018 TEST_ASSERT(ret == 0, 12019 "Failed to detach device %u", aesni_ids[i]); 12020 } 12021 12022 return 0; 12023 } 12024 12025 static int 12026 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode) 12027 { 12028 struct crypto_testsuite_params *ts_params = &testsuite_params; 12029 uint8_t sched_id = ts_params->valid_devs[0]; 12030 /* set mode */ 12031 return rte_cryptodev_scheduler_mode_set(sched_id, 12032 scheduler_mode); 12033 } 12034 12035 static int 12036 test_scheduler_mode_roundrobin_op(void) 12037 { 12038 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) == 12039 0, "Failed to set roundrobin mode"); 12040 return 0; 12041 12042 } 12043 12044 static int 12045 test_scheduler_mode_multicore_op(void) 12046 { 12047 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) == 12048 0, "Failed to set multicore mode"); 12049 12050 return 0; 12051 } 12052 12053 static int 12054 test_scheduler_mode_failover_op(void) 12055 { 12056 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) == 12057 0, "Failed to set failover mode"); 12058 12059 return 0; 12060 } 12061 12062 static int 12063 test_scheduler_mode_pkt_size_distr_op(void) 12064 { 12065 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) == 12066 0, "Failed to set pktsize mode"); 12067 12068 return 0; 12069 } 12070 12071 static struct unit_test_suite cryptodev_scheduler_testsuite = { 12072 .suite_name = "Crypto Device Scheduler Unit Test Suite", 12073 .setup = testsuite_setup, 12074 .teardown = testsuite_teardown, 12075 .unit_test_cases = { 12076 /* Multi Core */ 12077 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), 12078 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op), 12079 TEST_CASE_ST(ut_setup, ut_teardown, 12080 test_AES_chain_scheduler_all), 12081 TEST_CASE_ST(ut_setup, ut_teardown, 12082 test_AES_cipheronly_scheduler_all), 12083 TEST_CASE_ST(ut_setup, ut_teardown, 12084 test_authonly_scheduler_all), 12085 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), 12086 12087 /* Round Robin */ 12088 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), 12089 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op), 12090 TEST_CASE_ST(ut_setup, ut_teardown, 12091 test_AES_chain_scheduler_all), 12092 TEST_CASE_ST(ut_setup, ut_teardown, 12093 test_AES_cipheronly_scheduler_all), 12094 TEST_CASE_ST(ut_setup, ut_teardown, 12095 test_authonly_scheduler_all), 12096 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), 12097 12098 /* Fail over */ 12099 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), 12100 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op), 12101 TEST_CASE_ST(ut_setup, ut_teardown, 12102 test_AES_chain_scheduler_all), 12103 TEST_CASE_ST(ut_setup, ut_teardown, 12104 test_AES_cipheronly_scheduler_all), 12105 TEST_CASE_ST(ut_setup, ut_teardown, 12106 test_authonly_scheduler_all), 12107 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), 12108 12109 /* PKT SIZE */ 12110 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op), 12111 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op), 12112 TEST_CASE_ST(ut_setup, ut_teardown, 12113 test_AES_chain_scheduler_all), 12114 TEST_CASE_ST(ut_setup, ut_teardown, 12115 test_AES_cipheronly_scheduler_all), 12116 TEST_CASE_ST(ut_setup, ut_teardown, 12117 test_authonly_scheduler_all), 12118 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op), 12119 12120 TEST_CASES_END() /**< NULL terminate unit test array */ 12121 } 12122 }; 12123 12124 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */ 12125 12126 static struct unit_test_suite cryptodev_qat_testsuite = { 12127 .suite_name = "Crypto QAT Unit Test Suite", 12128 .setup = testsuite_setup, 12129 .teardown = testsuite_teardown, 12130 .unit_test_cases = { 12131 TEST_CASE_ST(ut_setup, ut_teardown, 12132 test_device_configure_invalid_dev_id), 12133 TEST_CASE_ST(ut_setup, ut_teardown, 12134 test_device_configure_invalid_queue_pair_ids), 12135 TEST_CASE_ST(ut_setup, ut_teardown, 12136 test_queue_pair_descriptor_setup), 12137 TEST_CASE_ST(ut_setup, ut_teardown, 12138 test_multi_session), 12139 12140 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all), 12141 TEST_CASE_ST(ut_setup, ut_teardown, 12142 test_AES_cipheronly_qat_all), 12143 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all), 12144 TEST_CASE_ST(ut_setup, ut_teardown, 12145 test_3DES_cipheronly_qat_all), 12146 TEST_CASE_ST(ut_setup, ut_teardown, 12147 test_DES_cipheronly_qat_all), 12148 TEST_CASE_ST(ut_setup, ut_teardown, 12149 test_AES_docsis_qat_all), 12150 TEST_CASE_ST(ut_setup, ut_teardown, 12151 test_DES_docsis_qat_all), 12152 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all), 12153 TEST_CASE_ST(ut_setup, ut_teardown, test_stats), 12154 12155 /** AES CCM Authenticated Encryption 128 bits key */ 12156 TEST_CASE_ST(ut_setup, ut_teardown, 12157 test_AES_CCM_authenticated_encryption_test_case_128_1), 12158 TEST_CASE_ST(ut_setup, ut_teardown, 12159 test_AES_CCM_authenticated_encryption_test_case_128_2), 12160 TEST_CASE_ST(ut_setup, ut_teardown, 12161 test_AES_CCM_authenticated_encryption_test_case_128_3), 12162 12163 /** AES CCM Authenticated Decryption 128 bits key*/ 12164 TEST_CASE_ST(ut_setup, ut_teardown, 12165 test_AES_CCM_authenticated_decryption_test_case_128_1), 12166 TEST_CASE_ST(ut_setup, ut_teardown, 12167 test_AES_CCM_authenticated_decryption_test_case_128_2), 12168 TEST_CASE_ST(ut_setup, ut_teardown, 12169 test_AES_CCM_authenticated_decryption_test_case_128_3), 12170 12171 /** AES GCM Authenticated Encryption */ 12172 TEST_CASE_ST(ut_setup, ut_teardown, 12173 test_AES_GCM_auth_encrypt_SGL_in_place_1500B), 12174 TEST_CASE_ST(ut_setup, ut_teardown, 12175 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B), 12176 TEST_CASE_ST(ut_setup, ut_teardown, 12177 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B), 12178 TEST_CASE_ST(ut_setup, ut_teardown, 12179 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg), 12180 TEST_CASE_ST(ut_setup, ut_teardown, 12181 test_AES_GCM_authenticated_encryption_test_case_1), 12182 TEST_CASE_ST(ut_setup, ut_teardown, 12183 test_AES_GCM_authenticated_encryption_test_case_2), 12184 TEST_CASE_ST(ut_setup, ut_teardown, 12185 test_AES_GCM_authenticated_encryption_test_case_3), 12186 TEST_CASE_ST(ut_setup, ut_teardown, 12187 test_AES_GCM_authenticated_encryption_test_case_4), 12188 TEST_CASE_ST(ut_setup, ut_teardown, 12189 test_AES_GCM_authenticated_encryption_test_case_5), 12190 TEST_CASE_ST(ut_setup, ut_teardown, 12191 test_AES_GCM_authenticated_encryption_test_case_6), 12192 TEST_CASE_ST(ut_setup, ut_teardown, 12193 test_AES_GCM_authenticated_encryption_test_case_7), 12194 TEST_CASE_ST(ut_setup, ut_teardown, 12195 test_AES_GCM_authenticated_encryption_test_case_8), 12196 12197 /** AES GCM Authenticated Decryption */ 12198 TEST_CASE_ST(ut_setup, ut_teardown, 12199 test_AES_GCM_authenticated_decryption_test_case_1), 12200 TEST_CASE_ST(ut_setup, ut_teardown, 12201 test_AES_GCM_authenticated_decryption_test_case_2), 12202 TEST_CASE_ST(ut_setup, ut_teardown, 12203 test_AES_GCM_authenticated_decryption_test_case_3), 12204 TEST_CASE_ST(ut_setup, ut_teardown, 12205 test_AES_GCM_authenticated_decryption_test_case_4), 12206 TEST_CASE_ST(ut_setup, ut_teardown, 12207 test_AES_GCM_authenticated_decryption_test_case_5), 12208 TEST_CASE_ST(ut_setup, ut_teardown, 12209 test_AES_GCM_authenticated_decryption_test_case_6), 12210 TEST_CASE_ST(ut_setup, ut_teardown, 12211 test_AES_GCM_authenticated_decryption_test_case_7), 12212 TEST_CASE_ST(ut_setup, ut_teardown, 12213 test_AES_GCM_authenticated_decryption_test_case_8), 12214 12215 /** AES GCM Authenticated Encryption 192 bits key */ 12216 TEST_CASE_ST(ut_setup, ut_teardown, 12217 test_AES_GCM_auth_encryption_test_case_192_1), 12218 TEST_CASE_ST(ut_setup, ut_teardown, 12219 test_AES_GCM_auth_encryption_test_case_192_2), 12220 TEST_CASE_ST(ut_setup, ut_teardown, 12221 test_AES_GCM_auth_encryption_test_case_192_3), 12222 TEST_CASE_ST(ut_setup, ut_teardown, 12223 test_AES_GCM_auth_encryption_test_case_192_4), 12224 TEST_CASE_ST(ut_setup, ut_teardown, 12225 test_AES_GCM_auth_encryption_test_case_192_5), 12226 TEST_CASE_ST(ut_setup, ut_teardown, 12227 test_AES_GCM_auth_encryption_test_case_192_6), 12228 TEST_CASE_ST(ut_setup, ut_teardown, 12229 test_AES_GCM_auth_encryption_test_case_192_7), 12230 12231 /** AES GCM Authenticated Decryption 192 bits key */ 12232 TEST_CASE_ST(ut_setup, ut_teardown, 12233 test_AES_GCM_auth_decryption_test_case_192_1), 12234 TEST_CASE_ST(ut_setup, ut_teardown, 12235 test_AES_GCM_auth_decryption_test_case_192_2), 12236 TEST_CASE_ST(ut_setup, ut_teardown, 12237 test_AES_GCM_auth_decryption_test_case_192_3), 12238 TEST_CASE_ST(ut_setup, ut_teardown, 12239 test_AES_GCM_auth_decryption_test_case_192_4), 12240 TEST_CASE_ST(ut_setup, ut_teardown, 12241 test_AES_GCM_auth_decryption_test_case_192_5), 12242 TEST_CASE_ST(ut_setup, ut_teardown, 12243 test_AES_GCM_auth_decryption_test_case_192_6), 12244 TEST_CASE_ST(ut_setup, ut_teardown, 12245 test_AES_GCM_auth_decryption_test_case_192_7), 12246 12247 /** AES GCM Authenticated Encryption 256 bits key */ 12248 TEST_CASE_ST(ut_setup, ut_teardown, 12249 test_AES_GCM_auth_encryption_test_case_256_1), 12250 TEST_CASE_ST(ut_setup, ut_teardown, 12251 test_AES_GCM_auth_encryption_test_case_256_2), 12252 TEST_CASE_ST(ut_setup, ut_teardown, 12253 test_AES_GCM_auth_encryption_test_case_256_3), 12254 TEST_CASE_ST(ut_setup, ut_teardown, 12255 test_AES_GCM_auth_encryption_test_case_256_4), 12256 TEST_CASE_ST(ut_setup, ut_teardown, 12257 test_AES_GCM_auth_encryption_test_case_256_5), 12258 TEST_CASE_ST(ut_setup, ut_teardown, 12259 test_AES_GCM_auth_encryption_test_case_256_6), 12260 TEST_CASE_ST(ut_setup, ut_teardown, 12261 test_AES_GCM_auth_encryption_test_case_256_7), 12262 12263 /** AES GCM Authenticated Decryption 256 bits key */ 12264 TEST_CASE_ST(ut_setup, ut_teardown, 12265 test_AES_GCM_auth_decryption_test_case_256_1), 12266 TEST_CASE_ST(ut_setup, ut_teardown, 12267 test_AES_GCM_auth_decryption_test_case_256_2), 12268 TEST_CASE_ST(ut_setup, ut_teardown, 12269 test_AES_GCM_auth_decryption_test_case_256_3), 12270 TEST_CASE_ST(ut_setup, ut_teardown, 12271 test_AES_GCM_auth_decryption_test_case_256_4), 12272 TEST_CASE_ST(ut_setup, ut_teardown, 12273 test_AES_GCM_auth_decryption_test_case_256_5), 12274 TEST_CASE_ST(ut_setup, ut_teardown, 12275 test_AES_GCM_auth_decryption_test_case_256_6), 12276 TEST_CASE_ST(ut_setup, ut_teardown, 12277 test_AES_GCM_auth_decryption_test_case_256_7), 12278 12279 /** AES GMAC Authentication */ 12280 TEST_CASE_ST(ut_setup, ut_teardown, 12281 test_AES_GMAC_authentication_test_case_1), 12282 TEST_CASE_ST(ut_setup, ut_teardown, 12283 test_AES_GMAC_authentication_verify_test_case_1), 12284 TEST_CASE_ST(ut_setup, ut_teardown, 12285 test_AES_GMAC_authentication_test_case_2), 12286 TEST_CASE_ST(ut_setup, ut_teardown, 12287 test_AES_GMAC_authentication_verify_test_case_2), 12288 TEST_CASE_ST(ut_setup, ut_teardown, 12289 test_AES_GMAC_authentication_test_case_3), 12290 TEST_CASE_ST(ut_setup, ut_teardown, 12291 test_AES_GMAC_authentication_verify_test_case_3), 12292 12293 /** SNOW 3G encrypt only (UEA2) */ 12294 TEST_CASE_ST(ut_setup, ut_teardown, 12295 test_snow3g_encryption_test_case_1), 12296 TEST_CASE_ST(ut_setup, ut_teardown, 12297 test_snow3g_encryption_test_case_2), 12298 TEST_CASE_ST(ut_setup, ut_teardown, 12299 test_snow3g_encryption_test_case_3), 12300 TEST_CASE_ST(ut_setup, ut_teardown, 12301 test_snow3g_encryption_test_case_4), 12302 TEST_CASE_ST(ut_setup, ut_teardown, 12303 test_snow3g_encryption_test_case_5), 12304 12305 TEST_CASE_ST(ut_setup, ut_teardown, 12306 test_snow3g_encryption_test_case_1_oop), 12307 TEST_CASE_ST(ut_setup, ut_teardown, 12308 test_snow3g_decryption_test_case_1_oop), 12309 12310 /** SNOW 3G generate auth, then encrypt (UEA2) */ 12311 TEST_CASE_ST(ut_setup, ut_teardown, 12312 test_snow3g_auth_cipher_test_case_1), 12313 TEST_CASE_ST(ut_setup, ut_teardown, 12314 test_snow3g_auth_cipher_test_case_2), 12315 TEST_CASE_ST(ut_setup, ut_teardown, 12316 test_snow3g_auth_cipher_test_case_2_oop), 12317 TEST_CASE_ST(ut_setup, ut_teardown, 12318 test_snow3g_auth_cipher_part_digest_enc), 12319 TEST_CASE_ST(ut_setup, ut_teardown, 12320 test_snow3g_auth_cipher_part_digest_enc_oop), 12321 TEST_CASE_ST(ut_setup, ut_teardown, 12322 test_snow3g_auth_cipher_test_case_3_sgl), 12323 TEST_CASE_ST(ut_setup, ut_teardown, 12324 test_snow3g_auth_cipher_test_case_3_oop_sgl), 12325 TEST_CASE_ST(ut_setup, ut_teardown, 12326 test_snow3g_auth_cipher_part_digest_enc_sgl), 12327 TEST_CASE_ST(ut_setup, ut_teardown, 12328 test_snow3g_auth_cipher_part_digest_enc_oop_sgl), 12329 12330 /** SNOW 3G decrypt (UEA2), then verify auth */ 12331 TEST_CASE_ST(ut_setup, ut_teardown, 12332 test_snow3g_auth_cipher_verify_test_case_1), 12333 TEST_CASE_ST(ut_setup, ut_teardown, 12334 test_snow3g_auth_cipher_verify_test_case_2), 12335 TEST_CASE_ST(ut_setup, ut_teardown, 12336 test_snow3g_auth_cipher_verify_test_case_2_oop), 12337 TEST_CASE_ST(ut_setup, ut_teardown, 12338 test_snow3g_auth_cipher_verify_part_digest_enc), 12339 TEST_CASE_ST(ut_setup, ut_teardown, 12340 test_snow3g_auth_cipher_verify_part_digest_enc_oop), 12341 TEST_CASE_ST(ut_setup, ut_teardown, 12342 test_snow3g_auth_cipher_verify_test_case_3_sgl), 12343 TEST_CASE_ST(ut_setup, ut_teardown, 12344 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl), 12345 TEST_CASE_ST(ut_setup, ut_teardown, 12346 test_snow3g_auth_cipher_verify_part_digest_enc_sgl), 12347 TEST_CASE_ST(ut_setup, ut_teardown, 12348 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl), 12349 12350 /** SNOW 3G decrypt only (UEA2) */ 12351 TEST_CASE_ST(ut_setup, ut_teardown, 12352 test_snow3g_decryption_test_case_1), 12353 TEST_CASE_ST(ut_setup, ut_teardown, 12354 test_snow3g_decryption_test_case_2), 12355 TEST_CASE_ST(ut_setup, ut_teardown, 12356 test_snow3g_decryption_test_case_3), 12357 TEST_CASE_ST(ut_setup, ut_teardown, 12358 test_snow3g_decryption_test_case_4), 12359 TEST_CASE_ST(ut_setup, ut_teardown, 12360 test_snow3g_decryption_test_case_5), 12361 TEST_CASE_ST(ut_setup, ut_teardown, 12362 test_snow3g_decryption_with_digest_test_case_1), 12363 TEST_CASE_ST(ut_setup, ut_teardown, 12364 test_snow3g_hash_generate_test_case_1), 12365 TEST_CASE_ST(ut_setup, ut_teardown, 12366 test_snow3g_hash_generate_test_case_2), 12367 TEST_CASE_ST(ut_setup, ut_teardown, 12368 test_snow3g_hash_generate_test_case_3), 12369 TEST_CASE_ST(ut_setup, ut_teardown, 12370 test_snow3g_hash_verify_test_case_1), 12371 TEST_CASE_ST(ut_setup, ut_teardown, 12372 test_snow3g_hash_verify_test_case_2), 12373 TEST_CASE_ST(ut_setup, ut_teardown, 12374 test_snow3g_hash_verify_test_case_3), 12375 TEST_CASE_ST(ut_setup, ut_teardown, 12376 test_snow3g_cipher_auth_test_case_1), 12377 TEST_CASE_ST(ut_setup, ut_teardown, 12378 test_snow3g_auth_cipher_with_digest_test_case_1), 12379 12380 /** ZUC encrypt only (EEA3) */ 12381 TEST_CASE_ST(ut_setup, ut_teardown, 12382 test_zuc_encryption_test_case_1), 12383 TEST_CASE_ST(ut_setup, ut_teardown, 12384 test_zuc_encryption_test_case_2), 12385 TEST_CASE_ST(ut_setup, ut_teardown, 12386 test_zuc_encryption_test_case_3), 12387 TEST_CASE_ST(ut_setup, ut_teardown, 12388 test_zuc_encryption_test_case_4), 12389 TEST_CASE_ST(ut_setup, ut_teardown, 12390 test_zuc_encryption_test_case_5), 12391 12392 /** ZUC authenticate (EIA3) */ 12393 TEST_CASE_ST(ut_setup, ut_teardown, 12394 test_zuc_hash_generate_test_case_6), 12395 TEST_CASE_ST(ut_setup, ut_teardown, 12396 test_zuc_hash_generate_test_case_7), 12397 TEST_CASE_ST(ut_setup, ut_teardown, 12398 test_zuc_hash_generate_test_case_8), 12399 12400 /** ZUC alg-chain (EEA3/EIA3) */ 12401 TEST_CASE_ST(ut_setup, ut_teardown, 12402 test_zuc_cipher_auth_test_case_1), 12403 TEST_CASE_ST(ut_setup, ut_teardown, 12404 test_zuc_cipher_auth_test_case_2), 12405 12406 /** ZUC generate auth, then encrypt (EEA3) */ 12407 TEST_CASE_ST(ut_setup, ut_teardown, 12408 test_zuc_auth_cipher_test_case_1), 12409 TEST_CASE_ST(ut_setup, ut_teardown, 12410 test_zuc_auth_cipher_test_case_1_oop), 12411 TEST_CASE_ST(ut_setup, ut_teardown, 12412 test_zuc_auth_cipher_test_case_1_sgl), 12413 TEST_CASE_ST(ut_setup, ut_teardown, 12414 test_zuc_auth_cipher_test_case_1_oop_sgl), 12415 12416 /** ZUC decrypt (EEA3), then verify auth */ 12417 TEST_CASE_ST(ut_setup, ut_teardown, 12418 test_zuc_auth_cipher_verify_test_case_1), 12419 TEST_CASE_ST(ut_setup, ut_teardown, 12420 test_zuc_auth_cipher_verify_test_case_1_oop), 12421 TEST_CASE_ST(ut_setup, ut_teardown, 12422 test_zuc_auth_cipher_verify_test_case_1_sgl), 12423 TEST_CASE_ST(ut_setup, ut_teardown, 12424 test_zuc_auth_cipher_verify_test_case_1_oop_sgl), 12425 12426 /** HMAC_MD5 Authentication */ 12427 TEST_CASE_ST(ut_setup, ut_teardown, 12428 test_MD5_HMAC_generate_case_1), 12429 TEST_CASE_ST(ut_setup, ut_teardown, 12430 test_MD5_HMAC_verify_case_1), 12431 TEST_CASE_ST(ut_setup, ut_teardown, 12432 test_MD5_HMAC_generate_case_2), 12433 TEST_CASE_ST(ut_setup, ut_teardown, 12434 test_MD5_HMAC_verify_case_2), 12435 12436 /** NULL algo tests done in chain_all, 12437 * cipheronly and authonly suites 12438 */ 12439 12440 /** KASUMI tests */ 12441 TEST_CASE_ST(ut_setup, ut_teardown, 12442 test_kasumi_hash_generate_test_case_1), 12443 TEST_CASE_ST(ut_setup, ut_teardown, 12444 test_kasumi_hash_generate_test_case_2), 12445 TEST_CASE_ST(ut_setup, ut_teardown, 12446 test_kasumi_hash_generate_test_case_3), 12447 TEST_CASE_ST(ut_setup, ut_teardown, 12448 test_kasumi_hash_generate_test_case_4), 12449 TEST_CASE_ST(ut_setup, ut_teardown, 12450 test_kasumi_hash_generate_test_case_5), 12451 TEST_CASE_ST(ut_setup, ut_teardown, 12452 test_kasumi_hash_generate_test_case_6), 12453 12454 TEST_CASE_ST(ut_setup, ut_teardown, 12455 test_kasumi_hash_verify_test_case_1), 12456 TEST_CASE_ST(ut_setup, ut_teardown, 12457 test_kasumi_hash_verify_test_case_2), 12458 TEST_CASE_ST(ut_setup, ut_teardown, 12459 test_kasumi_hash_verify_test_case_3), 12460 TEST_CASE_ST(ut_setup, ut_teardown, 12461 test_kasumi_hash_verify_test_case_4), 12462 TEST_CASE_ST(ut_setup, ut_teardown, 12463 test_kasumi_hash_verify_test_case_5), 12464 12465 TEST_CASE_ST(ut_setup, ut_teardown, 12466 test_kasumi_encryption_test_case_1), 12467 TEST_CASE_ST(ut_setup, ut_teardown, 12468 test_kasumi_encryption_test_case_3), 12469 TEST_CASE_ST(ut_setup, ut_teardown, 12470 test_kasumi_cipher_auth_test_case_1), 12471 12472 /** KASUMI generate auth, then encrypt (F8) */ 12473 TEST_CASE_ST(ut_setup, ut_teardown, 12474 test_kasumi_auth_cipher_test_case_1), 12475 TEST_CASE_ST(ut_setup, ut_teardown, 12476 test_kasumi_auth_cipher_test_case_2), 12477 TEST_CASE_ST(ut_setup, ut_teardown, 12478 test_kasumi_auth_cipher_test_case_2_oop), 12479 TEST_CASE_ST(ut_setup, ut_teardown, 12480 test_kasumi_auth_cipher_test_case_2_sgl), 12481 TEST_CASE_ST(ut_setup, ut_teardown, 12482 test_kasumi_auth_cipher_test_case_2_oop_sgl), 12483 12484 /** KASUMI decrypt (F8), then verify auth */ 12485 TEST_CASE_ST(ut_setup, ut_teardown, 12486 test_kasumi_auth_cipher_verify_test_case_1), 12487 TEST_CASE_ST(ut_setup, ut_teardown, 12488 test_kasumi_auth_cipher_verify_test_case_2), 12489 TEST_CASE_ST(ut_setup, ut_teardown, 12490 test_kasumi_auth_cipher_verify_test_case_2_oop), 12491 TEST_CASE_ST(ut_setup, ut_teardown, 12492 test_kasumi_auth_cipher_verify_test_case_2_sgl), 12493 TEST_CASE_ST(ut_setup, ut_teardown, 12494 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl), 12495 12496 /** Negative tests */ 12497 TEST_CASE_ST(ut_setup, ut_teardown, 12498 authentication_verify_HMAC_SHA1_fail_data_corrupt), 12499 TEST_CASE_ST(ut_setup, ut_teardown, 12500 authentication_verify_HMAC_SHA1_fail_tag_corrupt), 12501 TEST_CASE_ST(ut_setup, ut_teardown, 12502 test_AES_GCM_auth_encryption_fail_iv_corrupt), 12503 TEST_CASE_ST(ut_setup, ut_teardown, 12504 test_AES_GCM_auth_encryption_fail_in_data_corrupt), 12505 TEST_CASE_ST(ut_setup, ut_teardown, 12506 test_AES_GCM_auth_encryption_fail_out_data_corrupt), 12507 TEST_CASE_ST(ut_setup, ut_teardown, 12508 test_AES_GCM_auth_encryption_fail_aad_len_corrupt), 12509 TEST_CASE_ST(ut_setup, ut_teardown, 12510 test_AES_GCM_auth_encryption_fail_aad_corrupt), 12511 TEST_CASE_ST(ut_setup, ut_teardown, 12512 test_AES_GCM_auth_encryption_fail_tag_corrupt), 12513 TEST_CASE_ST(ut_setup, ut_teardown, 12514 test_AES_GCM_auth_decryption_fail_iv_corrupt), 12515 TEST_CASE_ST(ut_setup, ut_teardown, 12516 test_AES_GCM_auth_decryption_fail_in_data_corrupt), 12517 TEST_CASE_ST(ut_setup, ut_teardown, 12518 test_AES_GCM_auth_decryption_fail_out_data_corrupt), 12519 TEST_CASE_ST(ut_setup, ut_teardown, 12520 test_AES_GCM_auth_decryption_fail_aad_len_corrupt), 12521 TEST_CASE_ST(ut_setup, ut_teardown, 12522 test_AES_GCM_auth_decryption_fail_aad_corrupt), 12523 TEST_CASE_ST(ut_setup, ut_teardown, 12524 test_AES_GCM_auth_decryption_fail_tag_corrupt), 12525 TEST_CASE_ST(ut_setup, ut_teardown, 12526 authentication_verify_AES128_GMAC_fail_data_corrupt), 12527 TEST_CASE_ST(ut_setup, ut_teardown, 12528 authentication_verify_AES128_GMAC_fail_tag_corrupt), 12529 TEST_CASE_ST(ut_setup, ut_teardown, 12530 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 12531 TEST_CASE_ST(ut_setup, ut_teardown, 12532 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 12533 12534 /** Mixed CIPHER + HASH algorithms */ 12535 /** AUTH AES CMAC + CIPHER AES CTR */ 12536 TEST_CASE_ST(ut_setup, ut_teardown, 12537 test_aes_cmac_aes_ctr_digest_enc_test_case_1), 12538 TEST_CASE_ST(ut_setup, ut_teardown, 12539 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop), 12540 TEST_CASE_ST(ut_setup, ut_teardown, 12541 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl), 12542 TEST_CASE_ST(ut_setup, ut_teardown, 12543 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl), 12544 TEST_CASE_ST(ut_setup, ut_teardown, 12545 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1), 12546 TEST_CASE_ST(ut_setup, ut_teardown, 12547 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop), 12548 TEST_CASE_ST(ut_setup, ut_teardown, 12549 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl), 12550 TEST_CASE_ST(ut_setup, ut_teardown, 12551 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl), 12552 12553 /** AUTH ZUC + CIPHER SNOW3G */ 12554 TEST_CASE_ST(ut_setup, ut_teardown, 12555 test_auth_zuc_cipher_snow_test_case_1), 12556 TEST_CASE_ST(ut_setup, ut_teardown, 12557 test_verify_auth_zuc_cipher_snow_test_case_1), 12558 /** AUTH AES CMAC + CIPHER SNOW3G */ 12559 TEST_CASE_ST(ut_setup, ut_teardown, 12560 test_auth_aes_cmac_cipher_snow_test_case_1), 12561 TEST_CASE_ST(ut_setup, ut_teardown, 12562 test_verify_auth_aes_cmac_cipher_snow_test_case_1), 12563 /** AUTH ZUC + CIPHER AES CTR */ 12564 TEST_CASE_ST(ut_setup, ut_teardown, 12565 test_auth_zuc_cipher_aes_ctr_test_case_1), 12566 TEST_CASE_ST(ut_setup, ut_teardown, 12567 test_verify_auth_zuc_cipher_aes_ctr_test_case_1), 12568 /** AUTH SNOW3G + CIPHER AES CTR */ 12569 TEST_CASE_ST(ut_setup, ut_teardown, 12570 test_auth_snow_cipher_aes_ctr_test_case_1), 12571 TEST_CASE_ST(ut_setup, ut_teardown, 12572 test_verify_auth_snow_cipher_aes_ctr_test_case_1), 12573 /** AUTH SNOW3G + CIPHER ZUC */ 12574 TEST_CASE_ST(ut_setup, ut_teardown, 12575 test_auth_snow_cipher_zuc_test_case_1), 12576 TEST_CASE_ST(ut_setup, ut_teardown, 12577 test_verify_auth_snow_cipher_zuc_test_case_1), 12578 /** AUTH AES CMAC + CIPHER ZUC */ 12579 TEST_CASE_ST(ut_setup, ut_teardown, 12580 test_auth_aes_cmac_cipher_zuc_test_case_1), 12581 TEST_CASE_ST(ut_setup, ut_teardown, 12582 test_verify_auth_aes_cmac_cipher_zuc_test_case_1), 12583 12584 /** AUTH NULL + CIPHER SNOW3G */ 12585 TEST_CASE_ST(ut_setup, ut_teardown, 12586 test_auth_null_cipher_snow_test_case_1), 12587 TEST_CASE_ST(ut_setup, ut_teardown, 12588 test_verify_auth_null_cipher_snow_test_case_1), 12589 /** AUTH NULL + CIPHER ZUC */ 12590 TEST_CASE_ST(ut_setup, ut_teardown, 12591 test_auth_null_cipher_zuc_test_case_1), 12592 TEST_CASE_ST(ut_setup, ut_teardown, 12593 test_verify_auth_null_cipher_zuc_test_case_1), 12594 /** AUTH SNOW3G + CIPHER NULL */ 12595 TEST_CASE_ST(ut_setup, ut_teardown, 12596 test_auth_snow_cipher_null_test_case_1), 12597 TEST_CASE_ST(ut_setup, ut_teardown, 12598 test_verify_auth_snow_cipher_null_test_case_1), 12599 /** AUTH ZUC + CIPHER NULL */ 12600 TEST_CASE_ST(ut_setup, ut_teardown, 12601 test_auth_zuc_cipher_null_test_case_1), 12602 TEST_CASE_ST(ut_setup, ut_teardown, 12603 test_verify_auth_zuc_cipher_null_test_case_1), 12604 /** AUTH NULL + CIPHER AES CTR */ 12605 TEST_CASE_ST(ut_setup, ut_teardown, 12606 test_auth_null_cipher_aes_ctr_test_case_1), 12607 TEST_CASE_ST(ut_setup, ut_teardown, 12608 test_verify_auth_null_cipher_aes_ctr_test_case_1), 12609 /** AUTH AES CMAC + CIPHER NULL */ 12610 TEST_CASE_ST(ut_setup, ut_teardown, 12611 test_auth_aes_cmac_cipher_null_test_case_1), 12612 TEST_CASE_ST(ut_setup, ut_teardown, 12613 test_verify_auth_aes_cmac_cipher_null_test_case_1), 12614 12615 TEST_CASES_END() /**< NULL terminate unit test array */ 12616 } 12617 }; 12618 12619 static struct unit_test_suite cryptodev_virtio_testsuite = { 12620 .suite_name = "Crypto VIRTIO Unit Test Suite", 12621 .setup = testsuite_setup, 12622 .teardown = testsuite_teardown, 12623 .unit_test_cases = { 12624 TEST_CASE_ST(ut_setup, ut_teardown, 12625 test_AES_cipheronly_virtio_all), 12626 12627 TEST_CASES_END() /**< NULL terminate unit test array */ 12628 } 12629 }; 12630 12631 static struct unit_test_suite cryptodev_aesni_mb_testsuite = { 12632 .suite_name = "Crypto Device AESNI MB Unit Test Suite", 12633 .setup = testsuite_setup, 12634 .teardown = testsuite_teardown, 12635 .unit_test_cases = { 12636 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) 12637 TEST_CASE_ST(ut_setup, ut_teardown, 12638 test_AES_GCM_authenticated_encryption_test_case_1), 12639 TEST_CASE_ST(ut_setup, ut_teardown, 12640 test_AES_GCM_authenticated_encryption_test_case_2), 12641 TEST_CASE_ST(ut_setup, ut_teardown, 12642 test_AES_GCM_authenticated_encryption_test_case_3), 12643 TEST_CASE_ST(ut_setup, ut_teardown, 12644 test_AES_GCM_authenticated_encryption_test_case_4), 12645 TEST_CASE_ST(ut_setup, ut_teardown, 12646 test_AES_GCM_authenticated_encryption_test_case_5), 12647 TEST_CASE_ST(ut_setup, ut_teardown, 12648 test_AES_GCM_authenticated_encryption_test_case_6), 12649 TEST_CASE_ST(ut_setup, ut_teardown, 12650 test_AES_GCM_authenticated_encryption_test_case_7), 12651 12652 /** AES GCM Authenticated Decryption */ 12653 TEST_CASE_ST(ut_setup, ut_teardown, 12654 test_AES_GCM_authenticated_decryption_test_case_1), 12655 TEST_CASE_ST(ut_setup, ut_teardown, 12656 test_AES_GCM_authenticated_decryption_test_case_2), 12657 TEST_CASE_ST(ut_setup, ut_teardown, 12658 test_AES_GCM_authenticated_decryption_test_case_3), 12659 TEST_CASE_ST(ut_setup, ut_teardown, 12660 test_AES_GCM_authenticated_decryption_test_case_4), 12661 TEST_CASE_ST(ut_setup, ut_teardown, 12662 test_AES_GCM_authenticated_decryption_test_case_5), 12663 TEST_CASE_ST(ut_setup, ut_teardown, 12664 test_AES_GCM_authenticated_decryption_test_case_6), 12665 TEST_CASE_ST(ut_setup, ut_teardown, 12666 test_AES_GCM_authenticated_decryption_test_case_7), 12667 12668 /** AES GCM Authenticated Encryption 192 bits key */ 12669 TEST_CASE_ST(ut_setup, ut_teardown, 12670 test_AES_GCM_auth_encryption_test_case_192_1), 12671 TEST_CASE_ST(ut_setup, ut_teardown, 12672 test_AES_GCM_auth_encryption_test_case_192_2), 12673 TEST_CASE_ST(ut_setup, ut_teardown, 12674 test_AES_GCM_auth_encryption_test_case_192_3), 12675 TEST_CASE_ST(ut_setup, ut_teardown, 12676 test_AES_GCM_auth_encryption_test_case_192_4), 12677 TEST_CASE_ST(ut_setup, ut_teardown, 12678 test_AES_GCM_auth_encryption_test_case_192_5), 12679 TEST_CASE_ST(ut_setup, ut_teardown, 12680 test_AES_GCM_auth_encryption_test_case_192_6), 12681 TEST_CASE_ST(ut_setup, ut_teardown, 12682 test_AES_GCM_auth_encryption_test_case_192_7), 12683 12684 /** AES GCM Authenticated Decryption 192 bits key */ 12685 TEST_CASE_ST(ut_setup, ut_teardown, 12686 test_AES_GCM_auth_decryption_test_case_192_1), 12687 TEST_CASE_ST(ut_setup, ut_teardown, 12688 test_AES_GCM_auth_decryption_test_case_192_2), 12689 TEST_CASE_ST(ut_setup, ut_teardown, 12690 test_AES_GCM_auth_decryption_test_case_192_3), 12691 TEST_CASE_ST(ut_setup, ut_teardown, 12692 test_AES_GCM_auth_decryption_test_case_192_4), 12693 TEST_CASE_ST(ut_setup, ut_teardown, 12694 test_AES_GCM_auth_decryption_test_case_192_5), 12695 TEST_CASE_ST(ut_setup, ut_teardown, 12696 test_AES_GCM_auth_decryption_test_case_192_6), 12697 TEST_CASE_ST(ut_setup, ut_teardown, 12698 test_AES_GCM_auth_decryption_test_case_192_7), 12699 12700 /** AES GCM Authenticated Encryption 256 bits key */ 12701 TEST_CASE_ST(ut_setup, ut_teardown, 12702 test_AES_GCM_auth_encryption_test_case_256_1), 12703 TEST_CASE_ST(ut_setup, ut_teardown, 12704 test_AES_GCM_auth_encryption_test_case_256_2), 12705 TEST_CASE_ST(ut_setup, ut_teardown, 12706 test_AES_GCM_auth_encryption_test_case_256_3), 12707 TEST_CASE_ST(ut_setup, ut_teardown, 12708 test_AES_GCM_auth_encryption_test_case_256_4), 12709 TEST_CASE_ST(ut_setup, ut_teardown, 12710 test_AES_GCM_auth_encryption_test_case_256_5), 12711 TEST_CASE_ST(ut_setup, ut_teardown, 12712 test_AES_GCM_auth_encryption_test_case_256_6), 12713 TEST_CASE_ST(ut_setup, ut_teardown, 12714 test_AES_GCM_auth_encryption_test_case_256_7), 12715 12716 /** AES GCM Authenticated Decryption 256 bits key */ 12717 TEST_CASE_ST(ut_setup, ut_teardown, 12718 test_AES_GCM_auth_decryption_test_case_256_1), 12719 TEST_CASE_ST(ut_setup, ut_teardown, 12720 test_AES_GCM_auth_decryption_test_case_256_2), 12721 TEST_CASE_ST(ut_setup, ut_teardown, 12722 test_AES_GCM_auth_decryption_test_case_256_3), 12723 TEST_CASE_ST(ut_setup, ut_teardown, 12724 test_AES_GCM_auth_decryption_test_case_256_4), 12725 TEST_CASE_ST(ut_setup, ut_teardown, 12726 test_AES_GCM_auth_decryption_test_case_256_5), 12727 TEST_CASE_ST(ut_setup, ut_teardown, 12728 test_AES_GCM_auth_decryption_test_case_256_6), 12729 TEST_CASE_ST(ut_setup, ut_teardown, 12730 test_AES_GCM_auth_decryption_test_case_256_7), 12731 12732 /** AES GCM Authenticated Encryption big aad size */ 12733 TEST_CASE_ST(ut_setup, ut_teardown, 12734 test_AES_GCM_auth_encryption_test_case_aad_1), 12735 TEST_CASE_ST(ut_setup, ut_teardown, 12736 test_AES_GCM_auth_encryption_test_case_aad_2), 12737 12738 /** AES GCM Authenticated Decryption big aad size */ 12739 TEST_CASE_ST(ut_setup, ut_teardown, 12740 test_AES_GCM_auth_decryption_test_case_aad_1), 12741 TEST_CASE_ST(ut_setup, ut_teardown, 12742 test_AES_GCM_auth_decryption_test_case_aad_2), 12743 12744 /** Session-less tests */ 12745 TEST_CASE_ST(ut_setup, ut_teardown, 12746 test_AES_GCM_authenticated_encryption_sessionless_test_case_1), 12747 TEST_CASE_ST(ut_setup, ut_teardown, 12748 test_AES_GCM_authenticated_decryption_sessionless_test_case_1), 12749 12750 /** AES GMAC Authentication */ 12751 TEST_CASE_ST(ut_setup, ut_teardown, 12752 test_AES_GMAC_authentication_test_case_1), 12753 TEST_CASE_ST(ut_setup, ut_teardown, 12754 test_AES_GMAC_authentication_verify_test_case_1), 12755 TEST_CASE_ST(ut_setup, ut_teardown, 12756 test_AES_GMAC_authentication_test_case_2), 12757 TEST_CASE_ST(ut_setup, ut_teardown, 12758 test_AES_GMAC_authentication_verify_test_case_2), 12759 TEST_CASE_ST(ut_setup, ut_teardown, 12760 test_AES_GMAC_authentication_test_case_3), 12761 TEST_CASE_ST(ut_setup, ut_teardown, 12762 test_AES_GMAC_authentication_verify_test_case_3), 12763 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */ 12764 12765 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all), 12766 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all), 12767 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all), 12768 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all), 12769 TEST_CASE_ST(ut_setup, ut_teardown, 12770 test_DES_cipheronly_mb_all), 12771 TEST_CASE_ST(ut_setup, ut_teardown, 12772 test_DES_docsis_mb_all), 12773 TEST_CASE_ST(ut_setup, ut_teardown, 12774 test_3DES_cipheronly_mb_all), 12775 TEST_CASE_ST(ut_setup, ut_teardown, 12776 test_AES_CCM_authenticated_encryption_test_case_128_1), 12777 TEST_CASE_ST(ut_setup, ut_teardown, 12778 test_AES_CCM_authenticated_decryption_test_case_128_1), 12779 TEST_CASE_ST(ut_setup, ut_teardown, 12780 test_AES_CCM_authenticated_encryption_test_case_128_2), 12781 TEST_CASE_ST(ut_setup, ut_teardown, 12782 test_AES_CCM_authenticated_decryption_test_case_128_2), 12783 TEST_CASE_ST(ut_setup, ut_teardown, 12784 test_AES_CCM_authenticated_encryption_test_case_128_3), 12785 TEST_CASE_ST(ut_setup, ut_teardown, 12786 test_AES_CCM_authenticated_decryption_test_case_128_3), 12787 12788 TEST_CASES_END() /**< NULL terminate unit test array */ 12789 } 12790 }; 12791 12792 static struct unit_test_suite cryptodev_openssl_testsuite = { 12793 .suite_name = "Crypto Device OPENSSL Unit Test Suite", 12794 .setup = testsuite_setup, 12795 .teardown = testsuite_teardown, 12796 .unit_test_cases = { 12797 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session), 12798 TEST_CASE_ST(ut_setup, ut_teardown, 12799 test_multi_session_random_usage), 12800 TEST_CASE_ST(ut_setup, ut_teardown, 12801 test_AES_chain_openssl_all), 12802 TEST_CASE_ST(ut_setup, ut_teardown, 12803 test_AES_cipheronly_openssl_all), 12804 TEST_CASE_ST(ut_setup, ut_teardown, 12805 test_3DES_chain_openssl_all), 12806 TEST_CASE_ST(ut_setup, ut_teardown, 12807 test_3DES_cipheronly_openssl_all), 12808 TEST_CASE_ST(ut_setup, ut_teardown, 12809 test_DES_cipheronly_openssl_all), 12810 TEST_CASE_ST(ut_setup, ut_teardown, 12811 test_DES_docsis_openssl_all), 12812 TEST_CASE_ST(ut_setup, ut_teardown, 12813 test_authonly_openssl_all), 12814 12815 /** AES GCM Authenticated Encryption */ 12816 TEST_CASE_ST(ut_setup, ut_teardown, 12817 test_AES_GCM_authenticated_encryption_test_case_1), 12818 TEST_CASE_ST(ut_setup, ut_teardown, 12819 test_AES_GCM_authenticated_encryption_test_case_2), 12820 TEST_CASE_ST(ut_setup, ut_teardown, 12821 test_AES_GCM_authenticated_encryption_test_case_3), 12822 TEST_CASE_ST(ut_setup, ut_teardown, 12823 test_AES_GCM_authenticated_encryption_test_case_4), 12824 TEST_CASE_ST(ut_setup, ut_teardown, 12825 test_AES_GCM_authenticated_encryption_test_case_5), 12826 TEST_CASE_ST(ut_setup, ut_teardown, 12827 test_AES_GCM_authenticated_encryption_test_case_6), 12828 TEST_CASE_ST(ut_setup, ut_teardown, 12829 test_AES_GCM_authenticated_encryption_test_case_7), 12830 12831 /** AES GCM Authenticated Decryption */ 12832 TEST_CASE_ST(ut_setup, ut_teardown, 12833 test_AES_GCM_authenticated_decryption_test_case_1), 12834 TEST_CASE_ST(ut_setup, ut_teardown, 12835 test_AES_GCM_authenticated_decryption_test_case_2), 12836 TEST_CASE_ST(ut_setup, ut_teardown, 12837 test_AES_GCM_authenticated_decryption_test_case_3), 12838 TEST_CASE_ST(ut_setup, ut_teardown, 12839 test_AES_GCM_authenticated_decryption_test_case_4), 12840 TEST_CASE_ST(ut_setup, ut_teardown, 12841 test_AES_GCM_authenticated_decryption_test_case_5), 12842 TEST_CASE_ST(ut_setup, ut_teardown, 12843 test_AES_GCM_authenticated_decryption_test_case_6), 12844 TEST_CASE_ST(ut_setup, ut_teardown, 12845 test_AES_GCM_authenticated_decryption_test_case_7), 12846 12847 12848 /** AES GCM Authenticated Encryption 192 bits key */ 12849 TEST_CASE_ST(ut_setup, ut_teardown, 12850 test_AES_GCM_auth_encryption_test_case_192_1), 12851 TEST_CASE_ST(ut_setup, ut_teardown, 12852 test_AES_GCM_auth_encryption_test_case_192_2), 12853 TEST_CASE_ST(ut_setup, ut_teardown, 12854 test_AES_GCM_auth_encryption_test_case_192_3), 12855 TEST_CASE_ST(ut_setup, ut_teardown, 12856 test_AES_GCM_auth_encryption_test_case_192_4), 12857 TEST_CASE_ST(ut_setup, ut_teardown, 12858 test_AES_GCM_auth_encryption_test_case_192_5), 12859 TEST_CASE_ST(ut_setup, ut_teardown, 12860 test_AES_GCM_auth_encryption_test_case_192_6), 12861 TEST_CASE_ST(ut_setup, ut_teardown, 12862 test_AES_GCM_auth_encryption_test_case_192_7), 12863 12864 /** AES GCM Authenticated Decryption 192 bits key */ 12865 TEST_CASE_ST(ut_setup, ut_teardown, 12866 test_AES_GCM_auth_decryption_test_case_192_1), 12867 TEST_CASE_ST(ut_setup, ut_teardown, 12868 test_AES_GCM_auth_decryption_test_case_192_2), 12869 TEST_CASE_ST(ut_setup, ut_teardown, 12870 test_AES_GCM_auth_decryption_test_case_192_3), 12871 TEST_CASE_ST(ut_setup, ut_teardown, 12872 test_AES_GCM_auth_decryption_test_case_192_4), 12873 TEST_CASE_ST(ut_setup, ut_teardown, 12874 test_AES_GCM_auth_decryption_test_case_192_5), 12875 TEST_CASE_ST(ut_setup, ut_teardown, 12876 test_AES_GCM_auth_decryption_test_case_192_6), 12877 TEST_CASE_ST(ut_setup, ut_teardown, 12878 test_AES_GCM_auth_decryption_test_case_192_7), 12879 12880 /** AES GCM Authenticated Encryption 256 bits key */ 12881 TEST_CASE_ST(ut_setup, ut_teardown, 12882 test_AES_GCM_auth_encryption_test_case_256_1), 12883 TEST_CASE_ST(ut_setup, ut_teardown, 12884 test_AES_GCM_auth_encryption_test_case_256_2), 12885 TEST_CASE_ST(ut_setup, ut_teardown, 12886 test_AES_GCM_auth_encryption_test_case_256_3), 12887 TEST_CASE_ST(ut_setup, ut_teardown, 12888 test_AES_GCM_auth_encryption_test_case_256_4), 12889 TEST_CASE_ST(ut_setup, ut_teardown, 12890 test_AES_GCM_auth_encryption_test_case_256_5), 12891 TEST_CASE_ST(ut_setup, ut_teardown, 12892 test_AES_GCM_auth_encryption_test_case_256_6), 12893 TEST_CASE_ST(ut_setup, ut_teardown, 12894 test_AES_GCM_auth_encryption_test_case_256_7), 12895 12896 /** AES GCM Authenticated Decryption 256 bits key */ 12897 TEST_CASE_ST(ut_setup, ut_teardown, 12898 test_AES_GCM_auth_decryption_test_case_256_1), 12899 TEST_CASE_ST(ut_setup, ut_teardown, 12900 test_AES_GCM_auth_decryption_test_case_256_2), 12901 TEST_CASE_ST(ut_setup, ut_teardown, 12902 test_AES_GCM_auth_decryption_test_case_256_3), 12903 TEST_CASE_ST(ut_setup, ut_teardown, 12904 test_AES_GCM_auth_decryption_test_case_256_4), 12905 TEST_CASE_ST(ut_setup, ut_teardown, 12906 test_AES_GCM_auth_decryption_test_case_256_5), 12907 TEST_CASE_ST(ut_setup, ut_teardown, 12908 test_AES_GCM_auth_decryption_test_case_256_6), 12909 TEST_CASE_ST(ut_setup, ut_teardown, 12910 test_AES_GCM_auth_decryption_test_case_256_7), 12911 12912 /** AES GMAC Authentication */ 12913 TEST_CASE_ST(ut_setup, ut_teardown, 12914 test_AES_GMAC_authentication_test_case_1), 12915 TEST_CASE_ST(ut_setup, ut_teardown, 12916 test_AES_GMAC_authentication_verify_test_case_1), 12917 TEST_CASE_ST(ut_setup, ut_teardown, 12918 test_AES_GMAC_authentication_test_case_2), 12919 TEST_CASE_ST(ut_setup, ut_teardown, 12920 test_AES_GMAC_authentication_verify_test_case_2), 12921 TEST_CASE_ST(ut_setup, ut_teardown, 12922 test_AES_GMAC_authentication_test_case_3), 12923 TEST_CASE_ST(ut_setup, ut_teardown, 12924 test_AES_GMAC_authentication_verify_test_case_3), 12925 TEST_CASE_ST(ut_setup, ut_teardown, 12926 test_AES_GMAC_authentication_test_case_4), 12927 TEST_CASE_ST(ut_setup, ut_teardown, 12928 test_AES_GMAC_authentication_verify_test_case_4), 12929 12930 /** AES CCM Authenticated Encryption 128 bits key */ 12931 TEST_CASE_ST(ut_setup, ut_teardown, 12932 test_AES_CCM_authenticated_encryption_test_case_128_1), 12933 TEST_CASE_ST(ut_setup, ut_teardown, 12934 test_AES_CCM_authenticated_encryption_test_case_128_2), 12935 TEST_CASE_ST(ut_setup, ut_teardown, 12936 test_AES_CCM_authenticated_encryption_test_case_128_3), 12937 12938 /** AES CCM Authenticated Decryption 128 bits key*/ 12939 TEST_CASE_ST(ut_setup, ut_teardown, 12940 test_AES_CCM_authenticated_decryption_test_case_128_1), 12941 TEST_CASE_ST(ut_setup, ut_teardown, 12942 test_AES_CCM_authenticated_decryption_test_case_128_2), 12943 TEST_CASE_ST(ut_setup, ut_teardown, 12944 test_AES_CCM_authenticated_decryption_test_case_128_3), 12945 12946 /** AES CCM Authenticated Encryption 192 bits key */ 12947 TEST_CASE_ST(ut_setup, ut_teardown, 12948 test_AES_CCM_authenticated_encryption_test_case_192_1), 12949 TEST_CASE_ST(ut_setup, ut_teardown, 12950 test_AES_CCM_authenticated_encryption_test_case_192_2), 12951 TEST_CASE_ST(ut_setup, ut_teardown, 12952 test_AES_CCM_authenticated_encryption_test_case_192_3), 12953 12954 /** AES CCM Authenticated Decryption 192 bits key*/ 12955 TEST_CASE_ST(ut_setup, ut_teardown, 12956 test_AES_CCM_authenticated_decryption_test_case_192_1), 12957 TEST_CASE_ST(ut_setup, ut_teardown, 12958 test_AES_CCM_authenticated_decryption_test_case_192_2), 12959 TEST_CASE_ST(ut_setup, ut_teardown, 12960 test_AES_CCM_authenticated_decryption_test_case_192_3), 12961 12962 /** AES CCM Authenticated Encryption 256 bits key */ 12963 TEST_CASE_ST(ut_setup, ut_teardown, 12964 test_AES_CCM_authenticated_encryption_test_case_256_1), 12965 TEST_CASE_ST(ut_setup, ut_teardown, 12966 test_AES_CCM_authenticated_encryption_test_case_256_2), 12967 TEST_CASE_ST(ut_setup, ut_teardown, 12968 test_AES_CCM_authenticated_encryption_test_case_256_3), 12969 12970 /** AES CCM Authenticated Decryption 256 bits key*/ 12971 TEST_CASE_ST(ut_setup, ut_teardown, 12972 test_AES_CCM_authenticated_decryption_test_case_256_1), 12973 TEST_CASE_ST(ut_setup, ut_teardown, 12974 test_AES_CCM_authenticated_decryption_test_case_256_2), 12975 TEST_CASE_ST(ut_setup, ut_teardown, 12976 test_AES_CCM_authenticated_decryption_test_case_256_3), 12977 12978 /** Scatter-Gather */ 12979 TEST_CASE_ST(ut_setup, ut_teardown, 12980 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg), 12981 12982 /** Negative tests */ 12983 TEST_CASE_ST(ut_setup, ut_teardown, 12984 authentication_verify_HMAC_SHA1_fail_data_corrupt), 12985 TEST_CASE_ST(ut_setup, ut_teardown, 12986 authentication_verify_HMAC_SHA1_fail_tag_corrupt), 12987 TEST_CASE_ST(ut_setup, ut_teardown, 12988 authentication_verify_AES128_GMAC_fail_data_corrupt), 12989 TEST_CASE_ST(ut_setup, ut_teardown, 12990 authentication_verify_AES128_GMAC_fail_tag_corrupt), 12991 TEST_CASE_ST(ut_setup, ut_teardown, 12992 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 12993 TEST_CASE_ST(ut_setup, ut_teardown, 12994 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 12995 12996 /* ESN Testcase */ 12997 TEST_CASE_ST(ut_setup, ut_teardown, 12998 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check), 12999 13000 TEST_CASE_ST(ut_setup, ut_teardown, 13001 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check), 13002 13003 TEST_CASES_END() /**< NULL terminate unit test array */ 13004 } 13005 }; 13006 13007 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = { 13008 .suite_name = "Crypto Device AESNI GCM Unit Test Suite", 13009 .setup = testsuite_setup, 13010 .teardown = testsuite_teardown, 13011 .unit_test_cases = { 13012 /** AES GCM Authenticated Encryption */ 13013 TEST_CASE_ST(ut_setup, ut_teardown, 13014 test_AES_GCM_authenticated_encryption_test_case_1), 13015 TEST_CASE_ST(ut_setup, ut_teardown, 13016 test_AES_GCM_authenticated_encryption_test_case_2), 13017 TEST_CASE_ST(ut_setup, ut_teardown, 13018 test_AES_GCM_authenticated_encryption_test_case_3), 13019 TEST_CASE_ST(ut_setup, ut_teardown, 13020 test_AES_GCM_authenticated_encryption_test_case_4), 13021 TEST_CASE_ST(ut_setup, ut_teardown, 13022 test_AES_GCM_authenticated_encryption_test_case_5), 13023 TEST_CASE_ST(ut_setup, ut_teardown, 13024 test_AES_GCM_authenticated_encryption_test_case_6), 13025 TEST_CASE_ST(ut_setup, ut_teardown, 13026 test_AES_GCM_authenticated_encryption_test_case_7), 13027 13028 /** AES GCM Authenticated Decryption */ 13029 TEST_CASE_ST(ut_setup, ut_teardown, 13030 test_AES_GCM_authenticated_decryption_test_case_1), 13031 TEST_CASE_ST(ut_setup, ut_teardown, 13032 test_AES_GCM_authenticated_decryption_test_case_2), 13033 TEST_CASE_ST(ut_setup, ut_teardown, 13034 test_AES_GCM_authenticated_decryption_test_case_3), 13035 TEST_CASE_ST(ut_setup, ut_teardown, 13036 test_AES_GCM_authenticated_decryption_test_case_4), 13037 TEST_CASE_ST(ut_setup, ut_teardown, 13038 test_AES_GCM_authenticated_decryption_test_case_5), 13039 TEST_CASE_ST(ut_setup, ut_teardown, 13040 test_AES_GCM_authenticated_decryption_test_case_6), 13041 TEST_CASE_ST(ut_setup, ut_teardown, 13042 test_AES_GCM_authenticated_decryption_test_case_7), 13043 13044 /** AES GCM Authenticated Encryption 192 bits key */ 13045 TEST_CASE_ST(ut_setup, ut_teardown, 13046 test_AES_GCM_auth_encryption_test_case_192_1), 13047 TEST_CASE_ST(ut_setup, ut_teardown, 13048 test_AES_GCM_auth_encryption_test_case_192_2), 13049 TEST_CASE_ST(ut_setup, ut_teardown, 13050 test_AES_GCM_auth_encryption_test_case_192_3), 13051 TEST_CASE_ST(ut_setup, ut_teardown, 13052 test_AES_GCM_auth_encryption_test_case_192_4), 13053 TEST_CASE_ST(ut_setup, ut_teardown, 13054 test_AES_GCM_auth_encryption_test_case_192_5), 13055 TEST_CASE_ST(ut_setup, ut_teardown, 13056 test_AES_GCM_auth_encryption_test_case_192_6), 13057 TEST_CASE_ST(ut_setup, ut_teardown, 13058 test_AES_GCM_auth_encryption_test_case_192_7), 13059 13060 /** AES GCM Authenticated Decryption 192 bits key */ 13061 TEST_CASE_ST(ut_setup, ut_teardown, 13062 test_AES_GCM_auth_decryption_test_case_192_1), 13063 TEST_CASE_ST(ut_setup, ut_teardown, 13064 test_AES_GCM_auth_decryption_test_case_192_2), 13065 TEST_CASE_ST(ut_setup, ut_teardown, 13066 test_AES_GCM_auth_decryption_test_case_192_3), 13067 TEST_CASE_ST(ut_setup, ut_teardown, 13068 test_AES_GCM_auth_decryption_test_case_192_4), 13069 TEST_CASE_ST(ut_setup, ut_teardown, 13070 test_AES_GCM_auth_decryption_test_case_192_5), 13071 TEST_CASE_ST(ut_setup, ut_teardown, 13072 test_AES_GCM_auth_decryption_test_case_192_6), 13073 TEST_CASE_ST(ut_setup, ut_teardown, 13074 test_AES_GCM_auth_decryption_test_case_192_7), 13075 13076 /** AES GCM Authenticated Encryption 256 bits key */ 13077 TEST_CASE_ST(ut_setup, ut_teardown, 13078 test_AES_GCM_auth_encryption_test_case_256_1), 13079 TEST_CASE_ST(ut_setup, ut_teardown, 13080 test_AES_GCM_auth_encryption_test_case_256_2), 13081 TEST_CASE_ST(ut_setup, ut_teardown, 13082 test_AES_GCM_auth_encryption_test_case_256_3), 13083 TEST_CASE_ST(ut_setup, ut_teardown, 13084 test_AES_GCM_auth_encryption_test_case_256_4), 13085 TEST_CASE_ST(ut_setup, ut_teardown, 13086 test_AES_GCM_auth_encryption_test_case_256_5), 13087 TEST_CASE_ST(ut_setup, ut_teardown, 13088 test_AES_GCM_auth_encryption_test_case_256_6), 13089 TEST_CASE_ST(ut_setup, ut_teardown, 13090 test_AES_GCM_auth_encryption_test_case_256_7), 13091 13092 /** AES GCM Authenticated Decryption 256 bits key */ 13093 TEST_CASE_ST(ut_setup, ut_teardown, 13094 test_AES_GCM_auth_decryption_test_case_256_1), 13095 TEST_CASE_ST(ut_setup, ut_teardown, 13096 test_AES_GCM_auth_decryption_test_case_256_2), 13097 TEST_CASE_ST(ut_setup, ut_teardown, 13098 test_AES_GCM_auth_decryption_test_case_256_3), 13099 TEST_CASE_ST(ut_setup, ut_teardown, 13100 test_AES_GCM_auth_decryption_test_case_256_4), 13101 TEST_CASE_ST(ut_setup, ut_teardown, 13102 test_AES_GCM_auth_decryption_test_case_256_5), 13103 TEST_CASE_ST(ut_setup, ut_teardown, 13104 test_AES_GCM_auth_decryption_test_case_256_6), 13105 TEST_CASE_ST(ut_setup, ut_teardown, 13106 test_AES_GCM_auth_decryption_test_case_256_7), 13107 13108 /** AES GCM Authenticated Encryption big aad size */ 13109 TEST_CASE_ST(ut_setup, ut_teardown, 13110 test_AES_GCM_auth_encryption_test_case_aad_1), 13111 TEST_CASE_ST(ut_setup, ut_teardown, 13112 test_AES_GCM_auth_encryption_test_case_aad_2), 13113 13114 /** AES GCM Authenticated Decryption big aad size */ 13115 TEST_CASE_ST(ut_setup, ut_teardown, 13116 test_AES_GCM_auth_decryption_test_case_aad_1), 13117 TEST_CASE_ST(ut_setup, ut_teardown, 13118 test_AES_GCM_auth_decryption_test_case_aad_2), 13119 13120 /** AES GMAC Authentication */ 13121 TEST_CASE_ST(ut_setup, ut_teardown, 13122 test_AES_GMAC_authentication_test_case_1), 13123 TEST_CASE_ST(ut_setup, ut_teardown, 13124 test_AES_GMAC_authentication_verify_test_case_1), 13125 TEST_CASE_ST(ut_setup, ut_teardown, 13126 test_AES_GMAC_authentication_test_case_3), 13127 TEST_CASE_ST(ut_setup, ut_teardown, 13128 test_AES_GMAC_authentication_verify_test_case_3), 13129 TEST_CASE_ST(ut_setup, ut_teardown, 13130 test_AES_GMAC_authentication_test_case_4), 13131 TEST_CASE_ST(ut_setup, ut_teardown, 13132 test_AES_GMAC_authentication_verify_test_case_4), 13133 13134 /** Negative tests */ 13135 TEST_CASE_ST(ut_setup, ut_teardown, 13136 authentication_verify_AES128_GMAC_fail_data_corrupt), 13137 TEST_CASE_ST(ut_setup, ut_teardown, 13138 authentication_verify_AES128_GMAC_fail_tag_corrupt), 13139 13140 /** Out of place tests */ 13141 TEST_CASE_ST(ut_setup, ut_teardown, 13142 test_AES_GCM_authenticated_encryption_oop_test_case_1), 13143 TEST_CASE_ST(ut_setup, ut_teardown, 13144 test_AES_GCM_authenticated_decryption_oop_test_case_1), 13145 13146 /** Session-less tests */ 13147 TEST_CASE_ST(ut_setup, ut_teardown, 13148 test_AES_GCM_authenticated_encryption_sessionless_test_case_1), 13149 TEST_CASE_ST(ut_setup, ut_teardown, 13150 test_AES_GCM_authenticated_decryption_sessionless_test_case_1), 13151 13152 /** Scatter-Gather */ 13153 TEST_CASE_ST(ut_setup, ut_teardown, 13154 test_AES_GCM_auth_encrypt_SGL_in_place_1500B), 13155 TEST_CASE_ST(ut_setup, ut_teardown, 13156 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg), 13157 13158 TEST_CASES_END() /**< NULL terminate unit test array */ 13159 } 13160 }; 13161 13162 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = { 13163 .suite_name = "Crypto Device SW KASUMI Unit Test Suite", 13164 .setup = testsuite_setup, 13165 .teardown = testsuite_teardown, 13166 .unit_test_cases = { 13167 /** KASUMI encrypt only (UEA1) */ 13168 TEST_CASE_ST(ut_setup, ut_teardown, 13169 test_kasumi_encryption_test_case_1), 13170 TEST_CASE_ST(ut_setup, ut_teardown, 13171 test_kasumi_encryption_test_case_1_sgl), 13172 TEST_CASE_ST(ut_setup, ut_teardown, 13173 test_kasumi_encryption_test_case_2), 13174 TEST_CASE_ST(ut_setup, ut_teardown, 13175 test_kasumi_encryption_test_case_3), 13176 TEST_CASE_ST(ut_setup, ut_teardown, 13177 test_kasumi_encryption_test_case_4), 13178 TEST_CASE_ST(ut_setup, ut_teardown, 13179 test_kasumi_encryption_test_case_5), 13180 /** KASUMI decrypt only (UEA1) */ 13181 TEST_CASE_ST(ut_setup, ut_teardown, 13182 test_kasumi_decryption_test_case_1), 13183 TEST_CASE_ST(ut_setup, ut_teardown, 13184 test_kasumi_decryption_test_case_2), 13185 TEST_CASE_ST(ut_setup, ut_teardown, 13186 test_kasumi_decryption_test_case_3), 13187 TEST_CASE_ST(ut_setup, ut_teardown, 13188 test_kasumi_decryption_test_case_4), 13189 TEST_CASE_ST(ut_setup, ut_teardown, 13190 test_kasumi_decryption_test_case_5), 13191 13192 TEST_CASE_ST(ut_setup, ut_teardown, 13193 test_kasumi_encryption_test_case_1_oop), 13194 TEST_CASE_ST(ut_setup, ut_teardown, 13195 test_kasumi_encryption_test_case_1_oop_sgl), 13196 13197 13198 TEST_CASE_ST(ut_setup, ut_teardown, 13199 test_kasumi_decryption_test_case_1_oop), 13200 13201 /** KASUMI hash only (UIA1) */ 13202 TEST_CASE_ST(ut_setup, ut_teardown, 13203 test_kasumi_hash_generate_test_case_1), 13204 TEST_CASE_ST(ut_setup, ut_teardown, 13205 test_kasumi_hash_generate_test_case_2), 13206 TEST_CASE_ST(ut_setup, ut_teardown, 13207 test_kasumi_hash_generate_test_case_3), 13208 TEST_CASE_ST(ut_setup, ut_teardown, 13209 test_kasumi_hash_generate_test_case_4), 13210 TEST_CASE_ST(ut_setup, ut_teardown, 13211 test_kasumi_hash_generate_test_case_5), 13212 TEST_CASE_ST(ut_setup, ut_teardown, 13213 test_kasumi_hash_generate_test_case_6), 13214 TEST_CASE_ST(ut_setup, ut_teardown, 13215 test_kasumi_hash_verify_test_case_1), 13216 TEST_CASE_ST(ut_setup, ut_teardown, 13217 test_kasumi_hash_verify_test_case_2), 13218 TEST_CASE_ST(ut_setup, ut_teardown, 13219 test_kasumi_hash_verify_test_case_3), 13220 TEST_CASE_ST(ut_setup, ut_teardown, 13221 test_kasumi_hash_verify_test_case_4), 13222 TEST_CASE_ST(ut_setup, ut_teardown, 13223 test_kasumi_hash_verify_test_case_5), 13224 TEST_CASE_ST(ut_setup, ut_teardown, 13225 test_kasumi_cipher_auth_test_case_1), 13226 13227 /** KASUMI generate auth, then encrypt (F8) */ 13228 TEST_CASE_ST(ut_setup, ut_teardown, 13229 test_kasumi_auth_cipher_test_case_1), 13230 TEST_CASE_ST(ut_setup, ut_teardown, 13231 test_kasumi_auth_cipher_test_case_2), 13232 TEST_CASE_ST(ut_setup, ut_teardown, 13233 test_kasumi_auth_cipher_test_case_2_oop), 13234 TEST_CASE_ST(ut_setup, ut_teardown, 13235 test_kasumi_auth_cipher_test_case_2_sgl), 13236 TEST_CASE_ST(ut_setup, ut_teardown, 13237 test_kasumi_auth_cipher_test_case_2_oop_sgl), 13238 13239 /** KASUMI decrypt (F8), then verify auth */ 13240 TEST_CASE_ST(ut_setup, ut_teardown, 13241 test_kasumi_auth_cipher_verify_test_case_1), 13242 TEST_CASE_ST(ut_setup, ut_teardown, 13243 test_kasumi_auth_cipher_verify_test_case_2), 13244 TEST_CASE_ST(ut_setup, ut_teardown, 13245 test_kasumi_auth_cipher_verify_test_case_2_oop), 13246 TEST_CASE_ST(ut_setup, ut_teardown, 13247 test_kasumi_auth_cipher_verify_test_case_2_sgl), 13248 TEST_CASE_ST(ut_setup, ut_teardown, 13249 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl), 13250 TEST_CASES_END() /**< NULL terminate unit test array */ 13251 } 13252 }; 13253 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = { 13254 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite", 13255 .setup = testsuite_setup, 13256 .teardown = testsuite_teardown, 13257 .unit_test_cases = { 13258 /** SNOW 3G encrypt only (UEA2) */ 13259 TEST_CASE_ST(ut_setup, ut_teardown, 13260 test_snow3g_encryption_test_case_1), 13261 TEST_CASE_ST(ut_setup, ut_teardown, 13262 test_snow3g_encryption_test_case_2), 13263 TEST_CASE_ST(ut_setup, ut_teardown, 13264 test_snow3g_encryption_test_case_3), 13265 TEST_CASE_ST(ut_setup, ut_teardown, 13266 test_snow3g_encryption_test_case_4), 13267 TEST_CASE_ST(ut_setup, ut_teardown, 13268 test_snow3g_encryption_test_case_5), 13269 TEST_CASE_ST(ut_setup, ut_teardown, 13270 test_snow3g_auth_cipher_with_digest_test_case_1), 13271 13272 TEST_CASE_ST(ut_setup, ut_teardown, 13273 test_snow3g_encryption_test_case_1_oop), 13274 TEST_CASE_ST(ut_setup, ut_teardown, 13275 test_snow3g_encryption_test_case_1_oop_sgl), 13276 TEST_CASE_ST(ut_setup, ut_teardown, 13277 test_snow3g_decryption_test_case_1_oop), 13278 13279 TEST_CASE_ST(ut_setup, ut_teardown, 13280 test_snow3g_encryption_test_case_1_offset_oop), 13281 13282 /** SNOW 3G decrypt only (UEA2) */ 13283 TEST_CASE_ST(ut_setup, ut_teardown, 13284 test_snow3g_decryption_test_case_1), 13285 TEST_CASE_ST(ut_setup, ut_teardown, 13286 test_snow3g_decryption_test_case_2), 13287 TEST_CASE_ST(ut_setup, ut_teardown, 13288 test_snow3g_decryption_test_case_3), 13289 TEST_CASE_ST(ut_setup, ut_teardown, 13290 test_snow3g_decryption_test_case_4), 13291 TEST_CASE_ST(ut_setup, ut_teardown, 13292 test_snow3g_decryption_test_case_5), 13293 TEST_CASE_ST(ut_setup, ut_teardown, 13294 test_snow3g_decryption_with_digest_test_case_1), 13295 TEST_CASE_ST(ut_setup, ut_teardown, 13296 test_snow3g_hash_generate_test_case_1), 13297 TEST_CASE_ST(ut_setup, ut_teardown, 13298 test_snow3g_hash_generate_test_case_2), 13299 TEST_CASE_ST(ut_setup, ut_teardown, 13300 test_snow3g_hash_generate_test_case_3), 13301 /* Tests with buffers which length is not byte-aligned */ 13302 TEST_CASE_ST(ut_setup, ut_teardown, 13303 test_snow3g_hash_generate_test_case_4), 13304 TEST_CASE_ST(ut_setup, ut_teardown, 13305 test_snow3g_hash_generate_test_case_5), 13306 TEST_CASE_ST(ut_setup, ut_teardown, 13307 test_snow3g_hash_generate_test_case_6), 13308 TEST_CASE_ST(ut_setup, ut_teardown, 13309 test_snow3g_hash_verify_test_case_1), 13310 TEST_CASE_ST(ut_setup, ut_teardown, 13311 test_snow3g_hash_verify_test_case_2), 13312 TEST_CASE_ST(ut_setup, ut_teardown, 13313 test_snow3g_hash_verify_test_case_3), 13314 /* Tests with buffers which length is not byte-aligned */ 13315 TEST_CASE_ST(ut_setup, ut_teardown, 13316 test_snow3g_hash_verify_test_case_4), 13317 TEST_CASE_ST(ut_setup, ut_teardown, 13318 test_snow3g_hash_verify_test_case_5), 13319 TEST_CASE_ST(ut_setup, ut_teardown, 13320 test_snow3g_hash_verify_test_case_6), 13321 TEST_CASE_ST(ut_setup, ut_teardown, 13322 test_snow3g_cipher_auth_test_case_1), 13323 13324 /** SNOW 3G generate auth, then encrypt (UEA2) */ 13325 TEST_CASE_ST(ut_setup, ut_teardown, 13326 test_snow3g_auth_cipher_test_case_1), 13327 TEST_CASE_ST(ut_setup, ut_teardown, 13328 test_snow3g_auth_cipher_test_case_2), 13329 TEST_CASE_ST(ut_setup, ut_teardown, 13330 test_snow3g_auth_cipher_test_case_2_oop), 13331 TEST_CASE_ST(ut_setup, ut_teardown, 13332 test_snow3g_auth_cipher_part_digest_enc), 13333 TEST_CASE_ST(ut_setup, ut_teardown, 13334 test_snow3g_auth_cipher_part_digest_enc_oop), 13335 TEST_CASE_ST(ut_setup, ut_teardown, 13336 test_snow3g_auth_cipher_test_case_3_sgl), 13337 TEST_CASE_ST(ut_setup, ut_teardown, 13338 test_snow3g_auth_cipher_test_case_3_oop_sgl), 13339 TEST_CASE_ST(ut_setup, ut_teardown, 13340 test_snow3g_auth_cipher_part_digest_enc_sgl), 13341 TEST_CASE_ST(ut_setup, ut_teardown, 13342 test_snow3g_auth_cipher_part_digest_enc_oop_sgl), 13343 13344 /** SNOW 3G decrypt (UEA2), then verify auth */ 13345 TEST_CASE_ST(ut_setup, ut_teardown, 13346 test_snow3g_auth_cipher_verify_test_case_1), 13347 TEST_CASE_ST(ut_setup, ut_teardown, 13348 test_snow3g_auth_cipher_verify_test_case_2), 13349 TEST_CASE_ST(ut_setup, ut_teardown, 13350 test_snow3g_auth_cipher_verify_test_case_2_oop), 13351 TEST_CASE_ST(ut_setup, ut_teardown, 13352 test_snow3g_auth_cipher_verify_part_digest_enc), 13353 TEST_CASE_ST(ut_setup, ut_teardown, 13354 test_snow3g_auth_cipher_verify_part_digest_enc_oop), 13355 TEST_CASE_ST(ut_setup, ut_teardown, 13356 test_snow3g_auth_cipher_verify_test_case_3_sgl), 13357 TEST_CASE_ST(ut_setup, ut_teardown, 13358 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl), 13359 TEST_CASE_ST(ut_setup, ut_teardown, 13360 test_snow3g_auth_cipher_verify_part_digest_enc_sgl), 13361 TEST_CASE_ST(ut_setup, ut_teardown, 13362 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl), 13363 13364 TEST_CASES_END() /**< NULL terminate unit test array */ 13365 } 13366 }; 13367 13368 static struct unit_test_suite cryptodev_sw_zuc_testsuite = { 13369 .suite_name = "Crypto Device SW ZUC Unit Test Suite", 13370 .setup = testsuite_setup, 13371 .teardown = testsuite_teardown, 13372 .unit_test_cases = { 13373 /** ZUC encrypt only (EEA3) */ 13374 TEST_CASE_ST(ut_setup, ut_teardown, 13375 test_zuc_encryption_test_case_1), 13376 TEST_CASE_ST(ut_setup, ut_teardown, 13377 test_zuc_encryption_test_case_2), 13378 TEST_CASE_ST(ut_setup, ut_teardown, 13379 test_zuc_encryption_test_case_3), 13380 TEST_CASE_ST(ut_setup, ut_teardown, 13381 test_zuc_encryption_test_case_4), 13382 TEST_CASE_ST(ut_setup, ut_teardown, 13383 test_zuc_encryption_test_case_5), 13384 TEST_CASE_ST(ut_setup, ut_teardown, 13385 test_zuc_hash_generate_test_case_1), 13386 TEST_CASE_ST(ut_setup, ut_teardown, 13387 test_zuc_hash_generate_test_case_2), 13388 TEST_CASE_ST(ut_setup, ut_teardown, 13389 test_zuc_hash_generate_test_case_3), 13390 TEST_CASE_ST(ut_setup, ut_teardown, 13391 test_zuc_hash_generate_test_case_4), 13392 TEST_CASE_ST(ut_setup, ut_teardown, 13393 test_zuc_hash_generate_test_case_5), 13394 TEST_CASE_ST(ut_setup, ut_teardown, 13395 test_zuc_encryption_test_case_6_sgl), 13396 TEST_CASES_END() /**< NULL terminate unit test array */ 13397 } 13398 }; 13399 13400 static struct unit_test_suite cryptodev_caam_jr_testsuite = { 13401 .suite_name = "Crypto CAAM JR Unit Test Suite", 13402 .setup = testsuite_setup, 13403 .teardown = testsuite_teardown, 13404 .unit_test_cases = { 13405 TEST_CASE_ST(ut_setup, ut_teardown, 13406 test_device_configure_invalid_dev_id), 13407 TEST_CASE_ST(ut_setup, ut_teardown, 13408 test_multi_session), 13409 13410 TEST_CASE_ST(ut_setup, ut_teardown, 13411 test_AES_chain_caam_jr_all), 13412 TEST_CASE_ST(ut_setup, ut_teardown, 13413 test_3DES_chain_caam_jr_all), 13414 TEST_CASE_ST(ut_setup, ut_teardown, 13415 test_AES_cipheronly_caam_jr_all), 13416 TEST_CASE_ST(ut_setup, ut_teardown, 13417 test_3DES_cipheronly_caam_jr_all), 13418 TEST_CASE_ST(ut_setup, ut_teardown, 13419 test_authonly_caam_jr_all), 13420 13421 TEST_CASES_END() /**< NULL terminate unit test array */ 13422 } 13423 }; 13424 13425 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = { 13426 .suite_name = "Crypto DPAA_SEC Unit Test Suite", 13427 .setup = testsuite_setup, 13428 .teardown = testsuite_teardown, 13429 .unit_test_cases = { 13430 TEST_CASE_ST(ut_setup, ut_teardown, 13431 test_device_configure_invalid_dev_id), 13432 TEST_CASE_ST(ut_setup, ut_teardown, 13433 test_multi_session), 13434 13435 TEST_CASE_ST(ut_setup, ut_teardown, 13436 test_AES_chain_dpaa_sec_all), 13437 TEST_CASE_ST(ut_setup, ut_teardown, 13438 test_3DES_chain_dpaa_sec_all), 13439 TEST_CASE_ST(ut_setup, ut_teardown, 13440 test_AES_cipheronly_dpaa_sec_all), 13441 TEST_CASE_ST(ut_setup, ut_teardown, 13442 test_3DES_cipheronly_dpaa_sec_all), 13443 TEST_CASE_ST(ut_setup, ut_teardown, 13444 test_authonly_dpaa_sec_all), 13445 13446 #ifdef RTE_LIBRTE_SECURITY 13447 TEST_CASE_ST(ut_setup, ut_teardown, 13448 test_PDCP_PROTO_cplane_encap_all), 13449 13450 TEST_CASE_ST(ut_setup, ut_teardown, 13451 test_PDCP_PROTO_cplane_decap_all), 13452 13453 TEST_CASE_ST(ut_setup, ut_teardown, 13454 test_PDCP_PROTO_uplane_encap_all), 13455 13456 TEST_CASE_ST(ut_setup, ut_teardown, 13457 test_PDCP_PROTO_uplane_decap_all), 13458 13459 TEST_CASE_ST(ut_setup, ut_teardown, 13460 test_PDCP_PROTO_SGL_in_place_32B), 13461 TEST_CASE_ST(ut_setup, ut_teardown, 13462 test_PDCP_PROTO_SGL_oop_32B_128B), 13463 TEST_CASE_ST(ut_setup, ut_teardown, 13464 test_PDCP_PROTO_SGL_oop_32B_40B), 13465 TEST_CASE_ST(ut_setup, ut_teardown, 13466 test_PDCP_PROTO_SGL_oop_128B_32B), 13467 #endif 13468 /** AES GCM Authenticated Encryption */ 13469 TEST_CASE_ST(ut_setup, ut_teardown, 13470 test_AES_GCM_auth_encrypt_SGL_in_place_1500B), 13471 TEST_CASE_ST(ut_setup, ut_teardown, 13472 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B), 13473 TEST_CASE_ST(ut_setup, ut_teardown, 13474 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B), 13475 TEST_CASE_ST(ut_setup, ut_teardown, 13476 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg), 13477 TEST_CASE_ST(ut_setup, ut_teardown, 13478 test_AES_GCM_authenticated_encryption_test_case_1), 13479 TEST_CASE_ST(ut_setup, ut_teardown, 13480 test_AES_GCM_authenticated_encryption_test_case_2), 13481 TEST_CASE_ST(ut_setup, ut_teardown, 13482 test_AES_GCM_authenticated_encryption_test_case_3), 13483 TEST_CASE_ST(ut_setup, ut_teardown, 13484 test_AES_GCM_authenticated_encryption_test_case_4), 13485 TEST_CASE_ST(ut_setup, ut_teardown, 13486 test_AES_GCM_authenticated_encryption_test_case_5), 13487 TEST_CASE_ST(ut_setup, ut_teardown, 13488 test_AES_GCM_authenticated_encryption_test_case_6), 13489 TEST_CASE_ST(ut_setup, ut_teardown, 13490 test_AES_GCM_authenticated_encryption_test_case_7), 13491 TEST_CASE_ST(ut_setup, ut_teardown, 13492 test_AES_GCM_authenticated_encryption_test_case_8), 13493 13494 /** AES GCM Authenticated Decryption */ 13495 TEST_CASE_ST(ut_setup, ut_teardown, 13496 test_AES_GCM_authenticated_decryption_test_case_1), 13497 TEST_CASE_ST(ut_setup, ut_teardown, 13498 test_AES_GCM_authenticated_decryption_test_case_2), 13499 TEST_CASE_ST(ut_setup, ut_teardown, 13500 test_AES_GCM_authenticated_decryption_test_case_3), 13501 TEST_CASE_ST(ut_setup, ut_teardown, 13502 test_AES_GCM_authenticated_decryption_test_case_4), 13503 TEST_CASE_ST(ut_setup, ut_teardown, 13504 test_AES_GCM_authenticated_decryption_test_case_5), 13505 TEST_CASE_ST(ut_setup, ut_teardown, 13506 test_AES_GCM_authenticated_decryption_test_case_6), 13507 TEST_CASE_ST(ut_setup, ut_teardown, 13508 test_AES_GCM_authenticated_decryption_test_case_7), 13509 TEST_CASE_ST(ut_setup, ut_teardown, 13510 test_AES_GCM_authenticated_decryption_test_case_8), 13511 13512 /** AES GCM Authenticated Encryption 192 bits key */ 13513 TEST_CASE_ST(ut_setup, ut_teardown, 13514 test_AES_GCM_auth_encryption_test_case_192_1), 13515 TEST_CASE_ST(ut_setup, ut_teardown, 13516 test_AES_GCM_auth_encryption_test_case_192_2), 13517 TEST_CASE_ST(ut_setup, ut_teardown, 13518 test_AES_GCM_auth_encryption_test_case_192_3), 13519 TEST_CASE_ST(ut_setup, ut_teardown, 13520 test_AES_GCM_auth_encryption_test_case_192_4), 13521 TEST_CASE_ST(ut_setup, ut_teardown, 13522 test_AES_GCM_auth_encryption_test_case_192_5), 13523 TEST_CASE_ST(ut_setup, ut_teardown, 13524 test_AES_GCM_auth_encryption_test_case_192_6), 13525 TEST_CASE_ST(ut_setup, ut_teardown, 13526 test_AES_GCM_auth_encryption_test_case_192_7), 13527 13528 /** AES GCM Authenticated Decryption 192 bits key */ 13529 TEST_CASE_ST(ut_setup, ut_teardown, 13530 test_AES_GCM_auth_decryption_test_case_192_1), 13531 TEST_CASE_ST(ut_setup, ut_teardown, 13532 test_AES_GCM_auth_decryption_test_case_192_2), 13533 TEST_CASE_ST(ut_setup, ut_teardown, 13534 test_AES_GCM_auth_decryption_test_case_192_3), 13535 TEST_CASE_ST(ut_setup, ut_teardown, 13536 test_AES_GCM_auth_decryption_test_case_192_4), 13537 TEST_CASE_ST(ut_setup, ut_teardown, 13538 test_AES_GCM_auth_decryption_test_case_192_5), 13539 TEST_CASE_ST(ut_setup, ut_teardown, 13540 test_AES_GCM_auth_decryption_test_case_192_6), 13541 TEST_CASE_ST(ut_setup, ut_teardown, 13542 test_AES_GCM_auth_decryption_test_case_192_7), 13543 13544 /** AES GCM Authenticated Encryption 256 bits key */ 13545 TEST_CASE_ST(ut_setup, ut_teardown, 13546 test_AES_GCM_auth_encryption_test_case_256_1), 13547 TEST_CASE_ST(ut_setup, ut_teardown, 13548 test_AES_GCM_auth_encryption_test_case_256_2), 13549 TEST_CASE_ST(ut_setup, ut_teardown, 13550 test_AES_GCM_auth_encryption_test_case_256_3), 13551 TEST_CASE_ST(ut_setup, ut_teardown, 13552 test_AES_GCM_auth_encryption_test_case_256_4), 13553 TEST_CASE_ST(ut_setup, ut_teardown, 13554 test_AES_GCM_auth_encryption_test_case_256_5), 13555 TEST_CASE_ST(ut_setup, ut_teardown, 13556 test_AES_GCM_auth_encryption_test_case_256_6), 13557 TEST_CASE_ST(ut_setup, ut_teardown, 13558 test_AES_GCM_auth_encryption_test_case_256_7), 13559 13560 /** AES GCM Authenticated Decryption 256 bits key */ 13561 TEST_CASE_ST(ut_setup, ut_teardown, 13562 test_AES_GCM_auth_decryption_test_case_256_1), 13563 TEST_CASE_ST(ut_setup, ut_teardown, 13564 test_AES_GCM_auth_decryption_test_case_256_2), 13565 TEST_CASE_ST(ut_setup, ut_teardown, 13566 test_AES_GCM_auth_decryption_test_case_256_3), 13567 TEST_CASE_ST(ut_setup, ut_teardown, 13568 test_AES_GCM_auth_decryption_test_case_256_4), 13569 TEST_CASE_ST(ut_setup, ut_teardown, 13570 test_AES_GCM_auth_decryption_test_case_256_5), 13571 TEST_CASE_ST(ut_setup, ut_teardown, 13572 test_AES_GCM_auth_decryption_test_case_256_6), 13573 TEST_CASE_ST(ut_setup, ut_teardown, 13574 test_AES_GCM_auth_decryption_test_case_256_7), 13575 13576 /** Out of place tests */ 13577 TEST_CASE_ST(ut_setup, ut_teardown, 13578 test_AES_GCM_authenticated_encryption_oop_test_case_1), 13579 TEST_CASE_ST(ut_setup, ut_teardown, 13580 test_AES_GCM_authenticated_decryption_oop_test_case_1), 13581 13582 /** SNOW 3G encrypt only (UEA2) */ 13583 TEST_CASE_ST(ut_setup, ut_teardown, 13584 test_snow3g_encryption_test_case_1), 13585 TEST_CASE_ST(ut_setup, ut_teardown, 13586 test_snow3g_encryption_test_case_2), 13587 TEST_CASE_ST(ut_setup, ut_teardown, 13588 test_snow3g_encryption_test_case_3), 13589 TEST_CASE_ST(ut_setup, ut_teardown, 13590 test_snow3g_encryption_test_case_4), 13591 TEST_CASE_ST(ut_setup, ut_teardown, 13592 test_snow3g_encryption_test_case_5), 13593 13594 TEST_CASE_ST(ut_setup, ut_teardown, 13595 test_snow3g_encryption_test_case_1_oop), 13596 TEST_CASE_ST(ut_setup, ut_teardown, 13597 test_snow3g_encryption_test_case_1_oop_sgl), 13598 TEST_CASE_ST(ut_setup, ut_teardown, 13599 test_snow3g_decryption_test_case_1_oop), 13600 13601 /** SNOW 3G decrypt only (UEA2) */ 13602 TEST_CASE_ST(ut_setup, ut_teardown, 13603 test_snow3g_decryption_test_case_1), 13604 TEST_CASE_ST(ut_setup, ut_teardown, 13605 test_snow3g_decryption_test_case_2), 13606 TEST_CASE_ST(ut_setup, ut_teardown, 13607 test_snow3g_decryption_test_case_3), 13608 TEST_CASE_ST(ut_setup, ut_teardown, 13609 test_snow3g_decryption_test_case_4), 13610 TEST_CASE_ST(ut_setup, ut_teardown, 13611 test_snow3g_decryption_test_case_5), 13612 13613 TEST_CASE_ST(ut_setup, ut_teardown, 13614 test_snow3g_hash_generate_test_case_1), 13615 TEST_CASE_ST(ut_setup, ut_teardown, 13616 test_snow3g_hash_generate_test_case_2), 13617 TEST_CASE_ST(ut_setup, ut_teardown, 13618 test_snow3g_hash_generate_test_case_3), 13619 TEST_CASE_ST(ut_setup, ut_teardown, 13620 test_snow3g_hash_verify_test_case_1), 13621 TEST_CASE_ST(ut_setup, ut_teardown, 13622 test_snow3g_hash_verify_test_case_2), 13623 TEST_CASE_ST(ut_setup, ut_teardown, 13624 test_snow3g_hash_verify_test_case_3), 13625 13626 /** ZUC encrypt only (EEA3) */ 13627 TEST_CASE_ST(ut_setup, ut_teardown, 13628 test_zuc_encryption_test_case_1), 13629 TEST_CASE_ST(ut_setup, ut_teardown, 13630 test_zuc_encryption_test_case_2), 13631 TEST_CASE_ST(ut_setup, ut_teardown, 13632 test_zuc_encryption_test_case_3), 13633 TEST_CASE_ST(ut_setup, ut_teardown, 13634 test_zuc_encryption_test_case_4), 13635 TEST_CASE_ST(ut_setup, ut_teardown, 13636 test_zuc_encryption_test_case_5), 13637 13638 /** ZUC authenticate (EIA3) */ 13639 TEST_CASE_ST(ut_setup, ut_teardown, 13640 test_zuc_hash_generate_test_case_6), 13641 TEST_CASE_ST(ut_setup, ut_teardown, 13642 test_zuc_hash_generate_test_case_7), 13643 TEST_CASE_ST(ut_setup, ut_teardown, 13644 test_zuc_hash_generate_test_case_8), 13645 13646 /** Negative tests */ 13647 TEST_CASE_ST(ut_setup, ut_teardown, 13648 test_AES_GCM_auth_encryption_fail_iv_corrupt), 13649 TEST_CASE_ST(ut_setup, ut_teardown, 13650 test_AES_GCM_auth_encryption_fail_in_data_corrupt), 13651 TEST_CASE_ST(ut_setup, ut_teardown, 13652 test_AES_GCM_auth_encryption_fail_out_data_corrupt), 13653 TEST_CASE_ST(ut_setup, ut_teardown, 13654 test_AES_GCM_auth_encryption_fail_aad_len_corrupt), 13655 TEST_CASE_ST(ut_setup, ut_teardown, 13656 test_AES_GCM_auth_encryption_fail_aad_corrupt), 13657 TEST_CASE_ST(ut_setup, ut_teardown, 13658 test_AES_GCM_auth_encryption_fail_tag_corrupt), 13659 TEST_CASE_ST(ut_setup, ut_teardown, 13660 test_AES_GCM_auth_decryption_fail_iv_corrupt), 13661 TEST_CASE_ST(ut_setup, ut_teardown, 13662 test_AES_GCM_auth_decryption_fail_in_data_corrupt), 13663 TEST_CASE_ST(ut_setup, ut_teardown, 13664 test_AES_GCM_auth_decryption_fail_out_data_corrupt), 13665 TEST_CASE_ST(ut_setup, ut_teardown, 13666 test_AES_GCM_auth_decryption_fail_aad_len_corrupt), 13667 TEST_CASE_ST(ut_setup, ut_teardown, 13668 test_AES_GCM_auth_decryption_fail_aad_corrupt), 13669 TEST_CASE_ST(ut_setup, ut_teardown, 13670 test_AES_GCM_auth_decryption_fail_tag_corrupt), 13671 TEST_CASE_ST(ut_setup, ut_teardown, 13672 authentication_verify_HMAC_SHA1_fail_data_corrupt), 13673 TEST_CASE_ST(ut_setup, ut_teardown, 13674 authentication_verify_HMAC_SHA1_fail_tag_corrupt), 13675 TEST_CASE_ST(ut_setup, ut_teardown, 13676 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 13677 TEST_CASE_ST(ut_setup, ut_teardown, 13678 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 13679 13680 /* ESN Testcase */ 13681 TEST_CASE_ST(ut_setup, ut_teardown, 13682 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check), 13683 TEST_CASE_ST(ut_setup, ut_teardown, 13684 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check), 13685 13686 TEST_CASES_END() /**< NULL terminate unit test array */ 13687 } 13688 }; 13689 13690 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = { 13691 .suite_name = "Crypto DPAA2_SEC Unit Test Suite", 13692 .setup = testsuite_setup, 13693 .teardown = testsuite_teardown, 13694 .unit_test_cases = { 13695 TEST_CASE_ST(ut_setup, ut_teardown, 13696 test_device_configure_invalid_dev_id), 13697 TEST_CASE_ST(ut_setup, ut_teardown, 13698 test_multi_session), 13699 TEST_CASE_ST(ut_setup, ut_teardown, 13700 test_AES_chain_dpaa2_sec_all), 13701 TEST_CASE_ST(ut_setup, ut_teardown, 13702 test_3DES_chain_dpaa2_sec_all), 13703 TEST_CASE_ST(ut_setup, ut_teardown, 13704 test_AES_cipheronly_dpaa2_sec_all), 13705 TEST_CASE_ST(ut_setup, ut_teardown, 13706 test_3DES_cipheronly_dpaa2_sec_all), 13707 TEST_CASE_ST(ut_setup, ut_teardown, 13708 test_authonly_dpaa2_sec_all), 13709 13710 #ifdef RTE_LIBRTE_SECURITY 13711 TEST_CASE_ST(ut_setup, ut_teardown, 13712 test_PDCP_PROTO_cplane_encap_all), 13713 13714 TEST_CASE_ST(ut_setup, ut_teardown, 13715 test_PDCP_PROTO_cplane_decap_all), 13716 13717 TEST_CASE_ST(ut_setup, ut_teardown, 13718 test_PDCP_PROTO_uplane_encap_all), 13719 13720 TEST_CASE_ST(ut_setup, ut_teardown, 13721 test_PDCP_PROTO_uplane_decap_all), 13722 13723 TEST_CASE_ST(ut_setup, ut_teardown, 13724 test_PDCP_PROTO_SGL_in_place_32B), 13725 TEST_CASE_ST(ut_setup, ut_teardown, 13726 test_PDCP_PROTO_SGL_oop_32B_128B), 13727 TEST_CASE_ST(ut_setup, ut_teardown, 13728 test_PDCP_PROTO_SGL_oop_32B_40B), 13729 TEST_CASE_ST(ut_setup, ut_teardown, 13730 test_PDCP_PROTO_SGL_oop_128B_32B), 13731 #endif 13732 /** AES GCM Authenticated Encryption */ 13733 TEST_CASE_ST(ut_setup, ut_teardown, 13734 test_AES_GCM_auth_encrypt_SGL_in_place_1500B), 13735 TEST_CASE_ST(ut_setup, ut_teardown, 13736 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B), 13737 TEST_CASE_ST(ut_setup, ut_teardown, 13738 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B), 13739 TEST_CASE_ST(ut_setup, ut_teardown, 13740 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg), 13741 TEST_CASE_ST(ut_setup, ut_teardown, 13742 test_AES_GCM_authenticated_encryption_test_case_1), 13743 TEST_CASE_ST(ut_setup, ut_teardown, 13744 test_AES_GCM_authenticated_encryption_test_case_2), 13745 TEST_CASE_ST(ut_setup, ut_teardown, 13746 test_AES_GCM_authenticated_encryption_test_case_3), 13747 TEST_CASE_ST(ut_setup, ut_teardown, 13748 test_AES_GCM_authenticated_encryption_test_case_4), 13749 TEST_CASE_ST(ut_setup, ut_teardown, 13750 test_AES_GCM_authenticated_encryption_test_case_5), 13751 TEST_CASE_ST(ut_setup, ut_teardown, 13752 test_AES_GCM_authenticated_encryption_test_case_6), 13753 TEST_CASE_ST(ut_setup, ut_teardown, 13754 test_AES_GCM_authenticated_encryption_test_case_7), 13755 TEST_CASE_ST(ut_setup, ut_teardown, 13756 test_AES_GCM_authenticated_encryption_test_case_8), 13757 13758 /** AES GCM Authenticated Decryption */ 13759 TEST_CASE_ST(ut_setup, ut_teardown, 13760 test_AES_GCM_authenticated_decryption_test_case_1), 13761 TEST_CASE_ST(ut_setup, ut_teardown, 13762 test_AES_GCM_authenticated_decryption_test_case_2), 13763 TEST_CASE_ST(ut_setup, ut_teardown, 13764 test_AES_GCM_authenticated_decryption_test_case_3), 13765 TEST_CASE_ST(ut_setup, ut_teardown, 13766 test_AES_GCM_authenticated_decryption_test_case_4), 13767 TEST_CASE_ST(ut_setup, ut_teardown, 13768 test_AES_GCM_authenticated_decryption_test_case_5), 13769 TEST_CASE_ST(ut_setup, ut_teardown, 13770 test_AES_GCM_authenticated_decryption_test_case_6), 13771 TEST_CASE_ST(ut_setup, ut_teardown, 13772 test_AES_GCM_authenticated_decryption_test_case_7), 13773 TEST_CASE_ST(ut_setup, ut_teardown, 13774 test_AES_GCM_authenticated_decryption_test_case_8), 13775 13776 /** AES GCM Authenticated Encryption 192 bits key */ 13777 TEST_CASE_ST(ut_setup, ut_teardown, 13778 test_AES_GCM_auth_encryption_test_case_192_1), 13779 TEST_CASE_ST(ut_setup, ut_teardown, 13780 test_AES_GCM_auth_encryption_test_case_192_2), 13781 TEST_CASE_ST(ut_setup, ut_teardown, 13782 test_AES_GCM_auth_encryption_test_case_192_3), 13783 TEST_CASE_ST(ut_setup, ut_teardown, 13784 test_AES_GCM_auth_encryption_test_case_192_4), 13785 TEST_CASE_ST(ut_setup, ut_teardown, 13786 test_AES_GCM_auth_encryption_test_case_192_5), 13787 TEST_CASE_ST(ut_setup, ut_teardown, 13788 test_AES_GCM_auth_encryption_test_case_192_6), 13789 TEST_CASE_ST(ut_setup, ut_teardown, 13790 test_AES_GCM_auth_encryption_test_case_192_7), 13791 13792 /** AES GCM Authenticated Decryption 192 bits key */ 13793 TEST_CASE_ST(ut_setup, ut_teardown, 13794 test_AES_GCM_auth_decryption_test_case_192_1), 13795 TEST_CASE_ST(ut_setup, ut_teardown, 13796 test_AES_GCM_auth_decryption_test_case_192_2), 13797 TEST_CASE_ST(ut_setup, ut_teardown, 13798 test_AES_GCM_auth_decryption_test_case_192_3), 13799 TEST_CASE_ST(ut_setup, ut_teardown, 13800 test_AES_GCM_auth_decryption_test_case_192_4), 13801 TEST_CASE_ST(ut_setup, ut_teardown, 13802 test_AES_GCM_auth_decryption_test_case_192_5), 13803 TEST_CASE_ST(ut_setup, ut_teardown, 13804 test_AES_GCM_auth_decryption_test_case_192_6), 13805 TEST_CASE_ST(ut_setup, ut_teardown, 13806 test_AES_GCM_auth_decryption_test_case_192_7), 13807 13808 /** AES GCM Authenticated Encryption 256 bits key */ 13809 TEST_CASE_ST(ut_setup, ut_teardown, 13810 test_AES_GCM_auth_encryption_test_case_256_1), 13811 TEST_CASE_ST(ut_setup, ut_teardown, 13812 test_AES_GCM_auth_encryption_test_case_256_2), 13813 TEST_CASE_ST(ut_setup, ut_teardown, 13814 test_AES_GCM_auth_encryption_test_case_256_3), 13815 TEST_CASE_ST(ut_setup, ut_teardown, 13816 test_AES_GCM_auth_encryption_test_case_256_4), 13817 TEST_CASE_ST(ut_setup, ut_teardown, 13818 test_AES_GCM_auth_encryption_test_case_256_5), 13819 TEST_CASE_ST(ut_setup, ut_teardown, 13820 test_AES_GCM_auth_encryption_test_case_256_6), 13821 TEST_CASE_ST(ut_setup, ut_teardown, 13822 test_AES_GCM_auth_encryption_test_case_256_7), 13823 13824 /** AES GCM Authenticated Decryption 256 bits key */ 13825 TEST_CASE_ST(ut_setup, ut_teardown, 13826 test_AES_GCM_auth_decryption_test_case_256_1), 13827 TEST_CASE_ST(ut_setup, ut_teardown, 13828 test_AES_GCM_auth_decryption_test_case_256_2), 13829 TEST_CASE_ST(ut_setup, ut_teardown, 13830 test_AES_GCM_auth_decryption_test_case_256_3), 13831 TEST_CASE_ST(ut_setup, ut_teardown, 13832 test_AES_GCM_auth_decryption_test_case_256_4), 13833 TEST_CASE_ST(ut_setup, ut_teardown, 13834 test_AES_GCM_auth_decryption_test_case_256_5), 13835 TEST_CASE_ST(ut_setup, ut_teardown, 13836 test_AES_GCM_auth_decryption_test_case_256_6), 13837 TEST_CASE_ST(ut_setup, ut_teardown, 13838 test_AES_GCM_auth_decryption_test_case_256_7), 13839 13840 /** Out of place tests */ 13841 TEST_CASE_ST(ut_setup, ut_teardown, 13842 test_AES_GCM_authenticated_encryption_oop_test_case_1), 13843 TEST_CASE_ST(ut_setup, ut_teardown, 13844 test_AES_GCM_authenticated_decryption_oop_test_case_1), 13845 13846 /** SNOW 3G encrypt only (UEA2) */ 13847 TEST_CASE_ST(ut_setup, ut_teardown, 13848 test_snow3g_encryption_test_case_1), 13849 TEST_CASE_ST(ut_setup, ut_teardown, 13850 test_snow3g_encryption_test_case_2), 13851 TEST_CASE_ST(ut_setup, ut_teardown, 13852 test_snow3g_encryption_test_case_3), 13853 TEST_CASE_ST(ut_setup, ut_teardown, 13854 test_snow3g_encryption_test_case_4), 13855 TEST_CASE_ST(ut_setup, ut_teardown, 13856 test_snow3g_encryption_test_case_5), 13857 13858 TEST_CASE_ST(ut_setup, ut_teardown, 13859 test_snow3g_encryption_test_case_1_oop), 13860 TEST_CASE_ST(ut_setup, ut_teardown, 13861 test_snow3g_encryption_test_case_1_oop_sgl), 13862 TEST_CASE_ST(ut_setup, ut_teardown, 13863 test_snow3g_decryption_test_case_1_oop), 13864 13865 /** SNOW 3G decrypt only (UEA2) */ 13866 TEST_CASE_ST(ut_setup, ut_teardown, 13867 test_snow3g_decryption_test_case_1), 13868 TEST_CASE_ST(ut_setup, ut_teardown, 13869 test_snow3g_decryption_test_case_2), 13870 TEST_CASE_ST(ut_setup, ut_teardown, 13871 test_snow3g_decryption_test_case_3), 13872 TEST_CASE_ST(ut_setup, ut_teardown, 13873 test_snow3g_decryption_test_case_4), 13874 TEST_CASE_ST(ut_setup, ut_teardown, 13875 test_snow3g_decryption_test_case_5), 13876 13877 TEST_CASE_ST(ut_setup, ut_teardown, 13878 test_snow3g_hash_generate_test_case_1), 13879 TEST_CASE_ST(ut_setup, ut_teardown, 13880 test_snow3g_hash_generate_test_case_2), 13881 TEST_CASE_ST(ut_setup, ut_teardown, 13882 test_snow3g_hash_generate_test_case_3), 13883 TEST_CASE_ST(ut_setup, ut_teardown, 13884 test_snow3g_hash_verify_test_case_1), 13885 TEST_CASE_ST(ut_setup, ut_teardown, 13886 test_snow3g_hash_verify_test_case_2), 13887 TEST_CASE_ST(ut_setup, ut_teardown, 13888 test_snow3g_hash_verify_test_case_3), 13889 13890 /** ZUC encrypt only (EEA3) */ 13891 TEST_CASE_ST(ut_setup, ut_teardown, 13892 test_zuc_encryption_test_case_1), 13893 TEST_CASE_ST(ut_setup, ut_teardown, 13894 test_zuc_encryption_test_case_2), 13895 TEST_CASE_ST(ut_setup, ut_teardown, 13896 test_zuc_encryption_test_case_3), 13897 TEST_CASE_ST(ut_setup, ut_teardown, 13898 test_zuc_encryption_test_case_4), 13899 TEST_CASE_ST(ut_setup, ut_teardown, 13900 test_zuc_encryption_test_case_5), 13901 13902 /** ZUC authenticate (EIA3) */ 13903 TEST_CASE_ST(ut_setup, ut_teardown, 13904 test_zuc_hash_generate_test_case_6), 13905 TEST_CASE_ST(ut_setup, ut_teardown, 13906 test_zuc_hash_generate_test_case_7), 13907 TEST_CASE_ST(ut_setup, ut_teardown, 13908 test_zuc_hash_generate_test_case_8), 13909 13910 /** HMAC_MD5 Authentication */ 13911 TEST_CASE_ST(ut_setup, ut_teardown, 13912 test_MD5_HMAC_generate_case_1), 13913 TEST_CASE_ST(ut_setup, ut_teardown, 13914 test_MD5_HMAC_verify_case_1), 13915 TEST_CASE_ST(ut_setup, ut_teardown, 13916 test_MD5_HMAC_generate_case_2), 13917 TEST_CASE_ST(ut_setup, ut_teardown, 13918 test_MD5_HMAC_verify_case_2), 13919 13920 /** Negative tests */ 13921 TEST_CASE_ST(ut_setup, ut_teardown, 13922 test_AES_GCM_auth_encryption_fail_iv_corrupt), 13923 TEST_CASE_ST(ut_setup, ut_teardown, 13924 test_AES_GCM_auth_encryption_fail_in_data_corrupt), 13925 TEST_CASE_ST(ut_setup, ut_teardown, 13926 test_AES_GCM_auth_encryption_fail_out_data_corrupt), 13927 TEST_CASE_ST(ut_setup, ut_teardown, 13928 test_AES_GCM_auth_encryption_fail_aad_len_corrupt), 13929 TEST_CASE_ST(ut_setup, ut_teardown, 13930 test_AES_GCM_auth_encryption_fail_aad_corrupt), 13931 TEST_CASE_ST(ut_setup, ut_teardown, 13932 test_AES_GCM_auth_encryption_fail_tag_corrupt), 13933 TEST_CASE_ST(ut_setup, ut_teardown, 13934 test_AES_GCM_auth_decryption_fail_iv_corrupt), 13935 TEST_CASE_ST(ut_setup, ut_teardown, 13936 test_AES_GCM_auth_decryption_fail_in_data_corrupt), 13937 TEST_CASE_ST(ut_setup, ut_teardown, 13938 test_AES_GCM_auth_decryption_fail_out_data_corrupt), 13939 TEST_CASE_ST(ut_setup, ut_teardown, 13940 test_AES_GCM_auth_decryption_fail_aad_len_corrupt), 13941 TEST_CASE_ST(ut_setup, ut_teardown, 13942 test_AES_GCM_auth_decryption_fail_aad_corrupt), 13943 TEST_CASE_ST(ut_setup, ut_teardown, 13944 test_AES_GCM_auth_decryption_fail_tag_corrupt), 13945 TEST_CASE_ST(ut_setup, ut_teardown, 13946 authentication_verify_HMAC_SHA1_fail_data_corrupt), 13947 TEST_CASE_ST(ut_setup, ut_teardown, 13948 authentication_verify_HMAC_SHA1_fail_tag_corrupt), 13949 TEST_CASE_ST(ut_setup, ut_teardown, 13950 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 13951 TEST_CASE_ST(ut_setup, ut_teardown, 13952 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 13953 13954 /* ESN Testcase */ 13955 TEST_CASE_ST(ut_setup, ut_teardown, 13956 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check), 13957 13958 TEST_CASE_ST(ut_setup, ut_teardown, 13959 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check), 13960 13961 TEST_CASES_END() /**< NULL terminate unit test array */ 13962 } 13963 }; 13964 13965 static struct unit_test_suite cryptodev_null_testsuite = { 13966 .suite_name = "Crypto Device NULL Unit Test Suite", 13967 .setup = testsuite_setup, 13968 .teardown = testsuite_teardown, 13969 .unit_test_cases = { 13970 TEST_CASE_ST(ut_setup, ut_teardown, 13971 test_null_invalid_operation), 13972 TEST_CASE_ST(ut_setup, ut_teardown, 13973 test_null_burst_operation), 13974 TEST_CASE_ST(ut_setup, ut_teardown, 13975 test_AES_chain_null_all), 13976 TEST_CASE_ST(ut_setup, ut_teardown, 13977 test_AES_cipheronly_null_all), 13978 TEST_CASE_ST(ut_setup, ut_teardown, 13979 test_authonly_null_all), 13980 13981 TEST_CASES_END() /**< NULL terminate unit test array */ 13982 } 13983 }; 13984 13985 static struct unit_test_suite cryptodev_armv8_testsuite = { 13986 .suite_name = "Crypto Device ARMv8 Unit Test Suite", 13987 .setup = testsuite_setup, 13988 .teardown = testsuite_teardown, 13989 .unit_test_cases = { 13990 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all), 13991 13992 /** Negative tests */ 13993 TEST_CASE_ST(ut_setup, ut_teardown, 13994 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 13995 TEST_CASE_ST(ut_setup, ut_teardown, 13996 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 13997 13998 TEST_CASES_END() /**< NULL terminate unit test array */ 13999 } 14000 }; 14001 14002 static struct unit_test_suite cryptodev_mrvl_testsuite = { 14003 .suite_name = "Crypto Device Marvell Component Test Suite", 14004 .setup = testsuite_setup, 14005 .teardown = testsuite_teardown, 14006 .unit_test_cases = { 14007 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session), 14008 TEST_CASE_ST(ut_setup, ut_teardown, 14009 test_multi_session_random_usage), 14010 TEST_CASE_ST(ut_setup, ut_teardown, 14011 test_AES_chain_mrvl_all), 14012 TEST_CASE_ST(ut_setup, ut_teardown, 14013 test_AES_cipheronly_mrvl_all), 14014 TEST_CASE_ST(ut_setup, ut_teardown, 14015 test_authonly_mrvl_all), 14016 TEST_CASE_ST(ut_setup, ut_teardown, 14017 test_3DES_chain_mrvl_all), 14018 TEST_CASE_ST(ut_setup, ut_teardown, 14019 test_3DES_cipheronly_mrvl_all), 14020 14021 /** Negative tests */ 14022 TEST_CASE_ST(ut_setup, ut_teardown, 14023 authentication_verify_HMAC_SHA1_fail_data_corrupt), 14024 TEST_CASE_ST(ut_setup, ut_teardown, 14025 authentication_verify_HMAC_SHA1_fail_tag_corrupt), 14026 TEST_CASE_ST(ut_setup, ut_teardown, 14027 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 14028 TEST_CASE_ST(ut_setup, ut_teardown, 14029 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 14030 14031 TEST_CASES_END() /**< NULL terminate unit test array */ 14032 } 14033 }; 14034 14035 static struct unit_test_suite cryptodev_ccp_testsuite = { 14036 .suite_name = "Crypto Device CCP Unit Test Suite", 14037 .setup = testsuite_setup, 14038 .teardown = testsuite_teardown, 14039 .unit_test_cases = { 14040 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session), 14041 TEST_CASE_ST(ut_setup, ut_teardown, 14042 test_multi_session_random_usage), 14043 TEST_CASE_ST(ut_setup, ut_teardown, 14044 test_AES_chain_ccp_all), 14045 TEST_CASE_ST(ut_setup, ut_teardown, 14046 test_AES_cipheronly_ccp_all), 14047 TEST_CASE_ST(ut_setup, ut_teardown, 14048 test_3DES_chain_ccp_all), 14049 TEST_CASE_ST(ut_setup, ut_teardown, 14050 test_3DES_cipheronly_ccp_all), 14051 TEST_CASE_ST(ut_setup, ut_teardown, 14052 test_authonly_ccp_all), 14053 14054 /** Negative tests */ 14055 TEST_CASE_ST(ut_setup, ut_teardown, 14056 authentication_verify_HMAC_SHA1_fail_data_corrupt), 14057 TEST_CASE_ST(ut_setup, ut_teardown, 14058 authentication_verify_HMAC_SHA1_fail_tag_corrupt), 14059 TEST_CASE_ST(ut_setup, ut_teardown, 14060 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 14061 TEST_CASE_ST(ut_setup, ut_teardown, 14062 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 14063 14064 TEST_CASES_END() /**< NULL terminate unit test array */ 14065 } 14066 }; 14067 14068 static struct unit_test_suite cryptodev_octeontx_testsuite = { 14069 .suite_name = "Crypto Device OCTEONTX Unit Test Suite", 14070 .setup = testsuite_setup, 14071 .teardown = testsuite_teardown, 14072 .unit_test_cases = { 14073 TEST_CASE_ST(ut_setup, ut_teardown, 14074 test_AES_chain_octeontx_all), 14075 TEST_CASE_ST(ut_setup, ut_teardown, 14076 test_AES_cipheronly_octeontx_all), 14077 TEST_CASE_ST(ut_setup, ut_teardown, 14078 test_3DES_chain_octeontx_all), 14079 TEST_CASE_ST(ut_setup, ut_teardown, 14080 test_3DES_cipheronly_octeontx_all), 14081 TEST_CASE_ST(ut_setup, ut_teardown, 14082 test_authonly_octeontx_all), 14083 14084 /** AES GCM Authenticated Encryption */ 14085 TEST_CASE_ST(ut_setup, ut_teardown, 14086 test_AES_GCM_authenticated_encryption_test_case_1), 14087 TEST_CASE_ST(ut_setup, ut_teardown, 14088 test_AES_GCM_authenticated_encryption_test_case_2), 14089 TEST_CASE_ST(ut_setup, ut_teardown, 14090 test_AES_GCM_authenticated_encryption_test_case_3), 14091 TEST_CASE_ST(ut_setup, ut_teardown, 14092 test_AES_GCM_authenticated_encryption_test_case_4), 14093 TEST_CASE_ST(ut_setup, ut_teardown, 14094 test_AES_GCM_authenticated_encryption_test_case_5), 14095 TEST_CASE_ST(ut_setup, ut_teardown, 14096 test_AES_GCM_authenticated_encryption_test_case_6), 14097 TEST_CASE_ST(ut_setup, ut_teardown, 14098 test_AES_GCM_authenticated_encryption_test_case_7), 14099 14100 /** AES GCM Authenticated Decryption */ 14101 TEST_CASE_ST(ut_setup, ut_teardown, 14102 test_AES_GCM_authenticated_decryption_test_case_1), 14103 TEST_CASE_ST(ut_setup, ut_teardown, 14104 test_AES_GCM_authenticated_decryption_test_case_2), 14105 TEST_CASE_ST(ut_setup, ut_teardown, 14106 test_AES_GCM_authenticated_decryption_test_case_3), 14107 TEST_CASE_ST(ut_setup, ut_teardown, 14108 test_AES_GCM_authenticated_decryption_test_case_4), 14109 TEST_CASE_ST(ut_setup, ut_teardown, 14110 test_AES_GCM_authenticated_decryption_test_case_5), 14111 TEST_CASE_ST(ut_setup, ut_teardown, 14112 test_AES_GCM_authenticated_decryption_test_case_6), 14113 TEST_CASE_ST(ut_setup, ut_teardown, 14114 test_AES_GCM_authenticated_decryption_test_case_7), 14115 /** AES GMAC Authentication */ 14116 TEST_CASE_ST(ut_setup, ut_teardown, 14117 test_AES_GMAC_authentication_test_case_1), 14118 TEST_CASE_ST(ut_setup, ut_teardown, 14119 test_AES_GMAC_authentication_verify_test_case_1), 14120 TEST_CASE_ST(ut_setup, ut_teardown, 14121 test_AES_GMAC_authentication_test_case_2), 14122 TEST_CASE_ST(ut_setup, ut_teardown, 14123 test_AES_GMAC_authentication_verify_test_case_2), 14124 TEST_CASE_ST(ut_setup, ut_teardown, 14125 test_AES_GMAC_authentication_test_case_3), 14126 TEST_CASE_ST(ut_setup, ut_teardown, 14127 test_AES_GMAC_authentication_verify_test_case_3), 14128 14129 /** SNOW 3G encrypt only (UEA2) */ 14130 TEST_CASE_ST(ut_setup, ut_teardown, 14131 test_snow3g_encryption_test_case_1), 14132 TEST_CASE_ST(ut_setup, ut_teardown, 14133 test_snow3g_encryption_test_case_2), 14134 TEST_CASE_ST(ut_setup, ut_teardown, 14135 test_snow3g_encryption_test_case_3), 14136 TEST_CASE_ST(ut_setup, ut_teardown, 14137 test_snow3g_encryption_test_case_4), 14138 TEST_CASE_ST(ut_setup, ut_teardown, 14139 test_snow3g_encryption_test_case_5), 14140 14141 TEST_CASE_ST(ut_setup, ut_teardown, 14142 test_snow3g_encryption_test_case_1_oop), 14143 TEST_CASE_ST(ut_setup, ut_teardown, 14144 test_snow3g_decryption_test_case_1_oop), 14145 TEST_CASE_ST(ut_setup, ut_teardown, 14146 test_snow3g_encryption_test_case_1_oop_sgl), 14147 14148 /** SNOW 3G decrypt only (UEA2) */ 14149 TEST_CASE_ST(ut_setup, ut_teardown, 14150 test_snow3g_decryption_test_case_1), 14151 TEST_CASE_ST(ut_setup, ut_teardown, 14152 test_snow3g_decryption_test_case_2), 14153 TEST_CASE_ST(ut_setup, ut_teardown, 14154 test_snow3g_decryption_test_case_3), 14155 TEST_CASE_ST(ut_setup, ut_teardown, 14156 test_snow3g_decryption_test_case_4), 14157 TEST_CASE_ST(ut_setup, ut_teardown, 14158 test_snow3g_decryption_test_case_5), 14159 14160 TEST_CASE_ST(ut_setup, ut_teardown, 14161 test_snow3g_hash_generate_test_case_1), 14162 TEST_CASE_ST(ut_setup, ut_teardown, 14163 test_snow3g_hash_generate_test_case_2), 14164 TEST_CASE_ST(ut_setup, ut_teardown, 14165 test_snow3g_hash_generate_test_case_3), 14166 TEST_CASE_ST(ut_setup, ut_teardown, 14167 test_snow3g_hash_verify_test_case_1), 14168 TEST_CASE_ST(ut_setup, ut_teardown, 14169 test_snow3g_hash_verify_test_case_2), 14170 TEST_CASE_ST(ut_setup, ut_teardown, 14171 test_snow3g_hash_verify_test_case_3), 14172 14173 /** ZUC encrypt only (EEA3) */ 14174 TEST_CASE_ST(ut_setup, ut_teardown, 14175 test_zuc_encryption_test_case_1), 14176 TEST_CASE_ST(ut_setup, ut_teardown, 14177 test_zuc_encryption_test_case_2), 14178 TEST_CASE_ST(ut_setup, ut_teardown, 14179 test_zuc_encryption_test_case_3), 14180 TEST_CASE_ST(ut_setup, ut_teardown, 14181 test_zuc_encryption_test_case_4), 14182 TEST_CASE_ST(ut_setup, ut_teardown, 14183 test_zuc_encryption_test_case_5), 14184 TEST_CASE_ST(ut_setup, ut_teardown, 14185 test_zuc_hash_generate_test_case_1), 14186 TEST_CASE_ST(ut_setup, ut_teardown, 14187 test_zuc_hash_generate_test_case_2), 14188 TEST_CASE_ST(ut_setup, ut_teardown, 14189 test_zuc_hash_generate_test_case_3), 14190 TEST_CASE_ST(ut_setup, ut_teardown, 14191 test_zuc_hash_generate_test_case_4), 14192 TEST_CASE_ST(ut_setup, ut_teardown, 14193 test_zuc_hash_generate_test_case_5), 14194 TEST_CASE_ST(ut_setup, ut_teardown, 14195 test_zuc_encryption_test_case_6_sgl), 14196 14197 /** KASUMI encrypt only (UEA1) */ 14198 TEST_CASE_ST(ut_setup, ut_teardown, 14199 test_kasumi_encryption_test_case_1), 14200 TEST_CASE_ST(ut_setup, ut_teardown, 14201 test_kasumi_encryption_test_case_2), 14202 TEST_CASE_ST(ut_setup, ut_teardown, 14203 test_kasumi_encryption_test_case_3), 14204 TEST_CASE_ST(ut_setup, ut_teardown, 14205 test_kasumi_encryption_test_case_4), 14206 TEST_CASE_ST(ut_setup, ut_teardown, 14207 test_kasumi_encryption_test_case_5), 14208 TEST_CASE_ST(ut_setup, ut_teardown, 14209 test_kasumi_encryption_test_case_1_sgl), 14210 TEST_CASE_ST(ut_setup, ut_teardown, 14211 test_kasumi_encryption_test_case_1_oop_sgl), 14212 /** KASUMI decrypt only (UEA1) */ 14213 TEST_CASE_ST(ut_setup, ut_teardown, 14214 test_kasumi_decryption_test_case_1), 14215 TEST_CASE_ST(ut_setup, ut_teardown, 14216 test_kasumi_decryption_test_case_2), 14217 TEST_CASE_ST(ut_setup, ut_teardown, 14218 test_kasumi_decryption_test_case_3), 14219 TEST_CASE_ST(ut_setup, ut_teardown, 14220 test_kasumi_decryption_test_case_4), 14221 TEST_CASE_ST(ut_setup, ut_teardown, 14222 test_kasumi_decryption_test_case_5), 14223 14224 TEST_CASE_ST(ut_setup, ut_teardown, 14225 test_kasumi_encryption_test_case_1_oop), 14226 TEST_CASE_ST(ut_setup, ut_teardown, 14227 test_kasumi_decryption_test_case_1_oop), 14228 14229 /** KASUMI hash only (UIA1) */ 14230 TEST_CASE_ST(ut_setup, ut_teardown, 14231 test_kasumi_hash_generate_test_case_1), 14232 TEST_CASE_ST(ut_setup, ut_teardown, 14233 test_kasumi_hash_generate_test_case_2), 14234 TEST_CASE_ST(ut_setup, ut_teardown, 14235 test_kasumi_hash_generate_test_case_3), 14236 TEST_CASE_ST(ut_setup, ut_teardown, 14237 test_kasumi_hash_generate_test_case_4), 14238 TEST_CASE_ST(ut_setup, ut_teardown, 14239 test_kasumi_hash_generate_test_case_5), 14240 TEST_CASE_ST(ut_setup, ut_teardown, 14241 test_kasumi_hash_generate_test_case_6), 14242 TEST_CASE_ST(ut_setup, ut_teardown, 14243 test_kasumi_hash_verify_test_case_1), 14244 TEST_CASE_ST(ut_setup, ut_teardown, 14245 test_kasumi_hash_verify_test_case_2), 14246 TEST_CASE_ST(ut_setup, ut_teardown, 14247 test_kasumi_hash_verify_test_case_3), 14248 TEST_CASE_ST(ut_setup, ut_teardown, 14249 test_kasumi_hash_verify_test_case_4), 14250 TEST_CASE_ST(ut_setup, ut_teardown, 14251 test_kasumi_hash_verify_test_case_5), 14252 14253 /** NULL tests */ 14254 TEST_CASE_ST(ut_setup, ut_teardown, 14255 test_null_cipher_only_operation), 14256 TEST_CASE_ST(ut_setup, ut_teardown, 14257 test_null_auth_only_operation), 14258 TEST_CASE_ST(ut_setup, ut_teardown, 14259 test_null_cipher_auth_operation), 14260 TEST_CASE_ST(ut_setup, ut_teardown, 14261 test_null_auth_cipher_operation), 14262 14263 /** Negative tests */ 14264 TEST_CASE_ST(ut_setup, ut_teardown, 14265 authentication_verify_HMAC_SHA1_fail_data_corrupt), 14266 TEST_CASE_ST(ut_setup, ut_teardown, 14267 authentication_verify_HMAC_SHA1_fail_tag_corrupt), 14268 TEST_CASE_ST(ut_setup, ut_teardown, 14269 authentication_verify_AES128_GMAC_fail_data_corrupt), 14270 TEST_CASE_ST(ut_setup, ut_teardown, 14271 authentication_verify_AES128_GMAC_fail_tag_corrupt), 14272 TEST_CASE_ST(ut_setup, ut_teardown, 14273 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 14274 TEST_CASE_ST(ut_setup, ut_teardown, 14275 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 14276 TEST_CASES_END() /**< NULL terminate unit test array */ 14277 } 14278 }; 14279 14280 static struct unit_test_suite cryptodev_nitrox_testsuite = { 14281 .suite_name = "Crypto NITROX Unit Test Suite", 14282 .setup = testsuite_setup, 14283 .teardown = testsuite_teardown, 14284 .unit_test_cases = { 14285 TEST_CASE_ST(ut_setup, ut_teardown, 14286 test_device_configure_invalid_dev_id), 14287 TEST_CASE_ST(ut_setup, ut_teardown, 14288 test_device_configure_invalid_queue_pair_ids), 14289 TEST_CASE_ST(ut_setup, ut_teardown, 14290 test_AES_chain_nitrox_all), 14291 14292 TEST_CASES_END() /**< NULL terminate unit test array */ 14293 } 14294 }; 14295 14296 static struct unit_test_suite cryptodev_octeontx2_testsuite = { 14297 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite", 14298 .setup = testsuite_setup, 14299 .teardown = testsuite_teardown, 14300 .unit_test_cases = { 14301 TEST_CASE_ST(ut_setup, ut_teardown, 14302 test_AES_chain_octeontx2_all), 14303 TEST_CASE_ST(ut_setup, ut_teardown, 14304 test_AES_cipheronly_octeontx2_all), 14305 TEST_CASE_ST(ut_setup, ut_teardown, 14306 test_3DES_chain_octeontx2_all), 14307 TEST_CASE_ST(ut_setup, ut_teardown, 14308 test_3DES_cipheronly_octeontx2_all), 14309 TEST_CASE_ST(ut_setup, ut_teardown, 14310 test_authonly_octeontx2_all), 14311 14312 /** AES GCM Authenticated Encryption */ 14313 TEST_CASE_ST(ut_setup, ut_teardown, 14314 test_AES_GCM_authenticated_encryption_test_case_1), 14315 TEST_CASE_ST(ut_setup, ut_teardown, 14316 test_AES_GCM_authenticated_encryption_test_case_2), 14317 TEST_CASE_ST(ut_setup, ut_teardown, 14318 test_AES_GCM_authenticated_encryption_test_case_3), 14319 TEST_CASE_ST(ut_setup, ut_teardown, 14320 test_AES_GCM_authenticated_encryption_test_case_4), 14321 TEST_CASE_ST(ut_setup, ut_teardown, 14322 test_AES_GCM_authenticated_encryption_test_case_5), 14323 TEST_CASE_ST(ut_setup, ut_teardown, 14324 test_AES_GCM_authenticated_encryption_test_case_6), 14325 TEST_CASE_ST(ut_setup, ut_teardown, 14326 test_AES_GCM_authenticated_encryption_test_case_7), 14327 14328 /** AES GCM Authenticated Decryption */ 14329 TEST_CASE_ST(ut_setup, ut_teardown, 14330 test_AES_GCM_authenticated_decryption_test_case_1), 14331 TEST_CASE_ST(ut_setup, ut_teardown, 14332 test_AES_GCM_authenticated_decryption_test_case_2), 14333 TEST_CASE_ST(ut_setup, ut_teardown, 14334 test_AES_GCM_authenticated_decryption_test_case_3), 14335 TEST_CASE_ST(ut_setup, ut_teardown, 14336 test_AES_GCM_authenticated_decryption_test_case_4), 14337 TEST_CASE_ST(ut_setup, ut_teardown, 14338 test_AES_GCM_authenticated_decryption_test_case_5), 14339 TEST_CASE_ST(ut_setup, ut_teardown, 14340 test_AES_GCM_authenticated_decryption_test_case_6), 14341 TEST_CASE_ST(ut_setup, ut_teardown, 14342 test_AES_GCM_authenticated_decryption_test_case_7), 14343 /** AES GMAC Authentication */ 14344 TEST_CASE_ST(ut_setup, ut_teardown, 14345 test_AES_GMAC_authentication_test_case_1), 14346 TEST_CASE_ST(ut_setup, ut_teardown, 14347 test_AES_GMAC_authentication_verify_test_case_1), 14348 TEST_CASE_ST(ut_setup, ut_teardown, 14349 test_AES_GMAC_authentication_test_case_2), 14350 TEST_CASE_ST(ut_setup, ut_teardown, 14351 test_AES_GMAC_authentication_verify_test_case_2), 14352 TEST_CASE_ST(ut_setup, ut_teardown, 14353 test_AES_GMAC_authentication_test_case_3), 14354 TEST_CASE_ST(ut_setup, ut_teardown, 14355 test_AES_GMAC_authentication_verify_test_case_3), 14356 14357 /** SNOW 3G encrypt only (UEA2) */ 14358 TEST_CASE_ST(ut_setup, ut_teardown, 14359 test_snow3g_encryption_test_case_1), 14360 TEST_CASE_ST(ut_setup, ut_teardown, 14361 test_snow3g_encryption_test_case_2), 14362 TEST_CASE_ST(ut_setup, ut_teardown, 14363 test_snow3g_encryption_test_case_3), 14364 TEST_CASE_ST(ut_setup, ut_teardown, 14365 test_snow3g_encryption_test_case_4), 14366 TEST_CASE_ST(ut_setup, ut_teardown, 14367 test_snow3g_encryption_test_case_5), 14368 14369 TEST_CASE_ST(ut_setup, ut_teardown, 14370 test_snow3g_encryption_test_case_1_oop), 14371 TEST_CASE_ST(ut_setup, ut_teardown, 14372 test_snow3g_decryption_test_case_1_oop), 14373 TEST_CASE_ST(ut_setup, ut_teardown, 14374 test_snow3g_encryption_test_case_1_oop_sgl), 14375 14376 /** SNOW 3G decrypt only (UEA2) */ 14377 TEST_CASE_ST(ut_setup, ut_teardown, 14378 test_snow3g_decryption_test_case_1), 14379 TEST_CASE_ST(ut_setup, ut_teardown, 14380 test_snow3g_decryption_test_case_2), 14381 TEST_CASE_ST(ut_setup, ut_teardown, 14382 test_snow3g_decryption_test_case_3), 14383 TEST_CASE_ST(ut_setup, ut_teardown, 14384 test_snow3g_decryption_test_case_4), 14385 TEST_CASE_ST(ut_setup, ut_teardown, 14386 test_snow3g_decryption_test_case_5), 14387 14388 TEST_CASE_ST(ut_setup, ut_teardown, 14389 test_snow3g_hash_generate_test_case_1), 14390 TEST_CASE_ST(ut_setup, ut_teardown, 14391 test_snow3g_hash_generate_test_case_2), 14392 TEST_CASE_ST(ut_setup, ut_teardown, 14393 test_snow3g_hash_generate_test_case_3), 14394 TEST_CASE_ST(ut_setup, ut_teardown, 14395 test_snow3g_hash_verify_test_case_1), 14396 TEST_CASE_ST(ut_setup, ut_teardown, 14397 test_snow3g_hash_verify_test_case_2), 14398 TEST_CASE_ST(ut_setup, ut_teardown, 14399 test_snow3g_hash_verify_test_case_3), 14400 14401 /** ZUC encrypt only (EEA3) */ 14402 TEST_CASE_ST(ut_setup, ut_teardown, 14403 test_zuc_encryption_test_case_1), 14404 TEST_CASE_ST(ut_setup, ut_teardown, 14405 test_zuc_encryption_test_case_2), 14406 TEST_CASE_ST(ut_setup, ut_teardown, 14407 test_zuc_encryption_test_case_3), 14408 TEST_CASE_ST(ut_setup, ut_teardown, 14409 test_zuc_encryption_test_case_4), 14410 TEST_CASE_ST(ut_setup, ut_teardown, 14411 test_zuc_encryption_test_case_5), 14412 TEST_CASE_ST(ut_setup, ut_teardown, 14413 test_zuc_hash_generate_test_case_1), 14414 TEST_CASE_ST(ut_setup, ut_teardown, 14415 test_zuc_hash_generate_test_case_2), 14416 TEST_CASE_ST(ut_setup, ut_teardown, 14417 test_zuc_hash_generate_test_case_3), 14418 TEST_CASE_ST(ut_setup, ut_teardown, 14419 test_zuc_hash_generate_test_case_4), 14420 TEST_CASE_ST(ut_setup, ut_teardown, 14421 test_zuc_hash_generate_test_case_5), 14422 TEST_CASE_ST(ut_setup, ut_teardown, 14423 test_zuc_encryption_test_case_6_sgl), 14424 14425 /** KASUMI encrypt only (UEA1) */ 14426 TEST_CASE_ST(ut_setup, ut_teardown, 14427 test_kasumi_encryption_test_case_1), 14428 TEST_CASE_ST(ut_setup, ut_teardown, 14429 test_kasumi_encryption_test_case_2), 14430 TEST_CASE_ST(ut_setup, ut_teardown, 14431 test_kasumi_encryption_test_case_3), 14432 TEST_CASE_ST(ut_setup, ut_teardown, 14433 test_kasumi_encryption_test_case_4), 14434 TEST_CASE_ST(ut_setup, ut_teardown, 14435 test_kasumi_encryption_test_case_5), 14436 TEST_CASE_ST(ut_setup, ut_teardown, 14437 test_kasumi_encryption_test_case_1_sgl), 14438 TEST_CASE_ST(ut_setup, ut_teardown, 14439 test_kasumi_encryption_test_case_1_oop_sgl), 14440 /** KASUMI decrypt only (UEA1) */ 14441 TEST_CASE_ST(ut_setup, ut_teardown, 14442 test_kasumi_decryption_test_case_1), 14443 TEST_CASE_ST(ut_setup, ut_teardown, 14444 test_kasumi_decryption_test_case_2), 14445 TEST_CASE_ST(ut_setup, ut_teardown, 14446 test_kasumi_decryption_test_case_3), 14447 TEST_CASE_ST(ut_setup, ut_teardown, 14448 test_kasumi_decryption_test_case_4), 14449 TEST_CASE_ST(ut_setup, ut_teardown, 14450 test_kasumi_decryption_test_case_5), 14451 14452 TEST_CASE_ST(ut_setup, ut_teardown, 14453 test_kasumi_encryption_test_case_1_oop), 14454 TEST_CASE_ST(ut_setup, ut_teardown, 14455 test_kasumi_decryption_test_case_1_oop), 14456 14457 /** KASUMI hash only (UIA1) */ 14458 TEST_CASE_ST(ut_setup, ut_teardown, 14459 test_kasumi_hash_generate_test_case_1), 14460 TEST_CASE_ST(ut_setup, ut_teardown, 14461 test_kasumi_hash_generate_test_case_2), 14462 TEST_CASE_ST(ut_setup, ut_teardown, 14463 test_kasumi_hash_generate_test_case_3), 14464 TEST_CASE_ST(ut_setup, ut_teardown, 14465 test_kasumi_hash_generate_test_case_4), 14466 TEST_CASE_ST(ut_setup, ut_teardown, 14467 test_kasumi_hash_generate_test_case_5), 14468 TEST_CASE_ST(ut_setup, ut_teardown, 14469 test_kasumi_hash_generate_test_case_6), 14470 TEST_CASE_ST(ut_setup, ut_teardown, 14471 test_kasumi_hash_verify_test_case_1), 14472 TEST_CASE_ST(ut_setup, ut_teardown, 14473 test_kasumi_hash_verify_test_case_2), 14474 TEST_CASE_ST(ut_setup, ut_teardown, 14475 test_kasumi_hash_verify_test_case_3), 14476 TEST_CASE_ST(ut_setup, ut_teardown, 14477 test_kasumi_hash_verify_test_case_4), 14478 TEST_CASE_ST(ut_setup, ut_teardown, 14479 test_kasumi_hash_verify_test_case_5), 14480 14481 /** NULL tests */ 14482 TEST_CASE_ST(ut_setup, ut_teardown, 14483 test_null_cipher_only_operation), 14484 TEST_CASE_ST(ut_setup, ut_teardown, 14485 test_null_auth_only_operation), 14486 TEST_CASE_ST(ut_setup, ut_teardown, 14487 test_null_cipher_auth_operation), 14488 TEST_CASE_ST(ut_setup, ut_teardown, 14489 test_null_auth_cipher_operation), 14490 14491 /** Negative tests */ 14492 TEST_CASE_ST(ut_setup, ut_teardown, 14493 authentication_verify_HMAC_SHA1_fail_data_corrupt), 14494 TEST_CASE_ST(ut_setup, ut_teardown, 14495 authentication_verify_HMAC_SHA1_fail_tag_corrupt), 14496 TEST_CASE_ST(ut_setup, ut_teardown, 14497 authentication_verify_AES128_GMAC_fail_data_corrupt), 14498 TEST_CASE_ST(ut_setup, ut_teardown, 14499 authentication_verify_AES128_GMAC_fail_tag_corrupt), 14500 TEST_CASE_ST(ut_setup, ut_teardown, 14501 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt), 14502 TEST_CASE_ST(ut_setup, ut_teardown, 14503 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), 14504 TEST_CASES_END() /**< NULL terminate unit test array */ 14505 } 14506 }; 14507 14508 static int 14509 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/) 14510 { 14511 gbl_driver_id = rte_cryptodev_driver_id_get( 14512 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)); 14513 14514 if (gbl_driver_id == -1) { 14515 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both " 14516 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM " 14517 "are enabled in config file to run this testsuite.\n"); 14518 return TEST_SKIPPED; 14519 } 14520 14521 return unit_test_suite_runner(&cryptodev_qat_testsuite); 14522 } 14523 14524 static int 14525 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/) 14526 { 14527 gbl_driver_id = rte_cryptodev_driver_id_get( 14528 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)); 14529 14530 if (gbl_driver_id == -1) { 14531 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if " 14532 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled " 14533 "in config file to run this testsuite.\n"); 14534 return TEST_FAILED; 14535 } 14536 14537 return unit_test_suite_runner(&cryptodev_virtio_testsuite); 14538 } 14539 14540 static int 14541 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/) 14542 { 14543 gbl_driver_id = rte_cryptodev_driver_id_get( 14544 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)); 14545 14546 if (gbl_driver_id == -1) { 14547 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if " 14548 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled " 14549 "in config file to run this testsuite.\n"); 14550 return TEST_SKIPPED; 14551 } 14552 14553 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite); 14554 } 14555 14556 static int 14557 test_cryptodev_openssl(void) 14558 { 14559 gbl_driver_id = rte_cryptodev_driver_id_get( 14560 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)); 14561 14562 if (gbl_driver_id == -1) { 14563 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if " 14564 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled " 14565 "in config file to run this testsuite.\n"); 14566 return TEST_SKIPPED; 14567 } 14568 14569 return unit_test_suite_runner(&cryptodev_openssl_testsuite); 14570 } 14571 14572 static int 14573 test_cryptodev_aesni_gcm(void) 14574 { 14575 gbl_driver_id = rte_cryptodev_driver_id_get( 14576 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)); 14577 14578 if (gbl_driver_id == -1) { 14579 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if " 14580 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled " 14581 "in config file to run this testsuite.\n"); 14582 return TEST_SKIPPED; 14583 } 14584 14585 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite); 14586 } 14587 14588 static int 14589 test_cryptodev_null(void) 14590 { 14591 gbl_driver_id = rte_cryptodev_driver_id_get( 14592 RTE_STR(CRYPTODEV_NAME_NULL_PMD)); 14593 14594 if (gbl_driver_id == -1) { 14595 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if " 14596 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled " 14597 "in config file to run this testsuite.\n"); 14598 return TEST_SKIPPED; 14599 } 14600 14601 return unit_test_suite_runner(&cryptodev_null_testsuite); 14602 } 14603 14604 static int 14605 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/) 14606 { 14607 gbl_driver_id = rte_cryptodev_driver_id_get( 14608 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)); 14609 14610 if (gbl_driver_id == -1) { 14611 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if " 14612 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled " 14613 "in config file to run this testsuite.\n"); 14614 return TEST_SKIPPED; 14615 } 14616 14617 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite); 14618 } 14619 14620 static int 14621 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/) 14622 { 14623 gbl_driver_id = rte_cryptodev_driver_id_get( 14624 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)); 14625 14626 if (gbl_driver_id == -1) { 14627 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if " 14628 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled " 14629 "in config file to run this testsuite.\n"); 14630 return TEST_SKIPPED; 14631 } 14632 14633 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite); 14634 } 14635 14636 static int 14637 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/) 14638 { 14639 gbl_driver_id = rte_cryptodev_driver_id_get( 14640 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)); 14641 14642 if (gbl_driver_id == -1) { 14643 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if " 14644 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled " 14645 "in config file to run this testsuite.\n"); 14646 return TEST_SKIPPED; 14647 } 14648 14649 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite); 14650 } 14651 14652 static int 14653 test_cryptodev_armv8(void) 14654 { 14655 gbl_driver_id = rte_cryptodev_driver_id_get( 14656 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)); 14657 14658 if (gbl_driver_id == -1) { 14659 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if " 14660 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled " 14661 "in config file to run this testsuite.\n"); 14662 return TEST_SKIPPED; 14663 } 14664 14665 return unit_test_suite_runner(&cryptodev_armv8_testsuite); 14666 } 14667 14668 static int 14669 test_cryptodev_mrvl(void) 14670 { 14671 gbl_driver_id = rte_cryptodev_driver_id_get( 14672 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)); 14673 14674 if (gbl_driver_id == -1) { 14675 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if " 14676 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled " 14677 "in config file to run this testsuite.\n"); 14678 return TEST_SKIPPED; 14679 } 14680 14681 return unit_test_suite_runner(&cryptodev_mrvl_testsuite); 14682 } 14683 14684 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER 14685 14686 static int 14687 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/) 14688 { 14689 gbl_driver_id = rte_cryptodev_driver_id_get( 14690 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)); 14691 14692 if (gbl_driver_id == -1) { 14693 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if " 14694 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled " 14695 "in config file to run this testsuite.\n"); 14696 return TEST_SKIPPED; 14697 } 14698 14699 if (rte_cryptodev_driver_id_get( 14700 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) { 14701 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be" 14702 " enabled in config file to run this testsuite.\n"); 14703 return TEST_SKIPPED; 14704 } 14705 return unit_test_suite_runner(&cryptodev_scheduler_testsuite); 14706 } 14707 14708 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler); 14709 14710 #endif 14711 14712 static int 14713 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/) 14714 { 14715 gbl_driver_id = rte_cryptodev_driver_id_get( 14716 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)); 14717 14718 if (gbl_driver_id == -1) { 14719 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if " 14720 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled " 14721 "in config file to run this testsuite.\n"); 14722 return TEST_SKIPPED; 14723 } 14724 14725 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite); 14726 } 14727 14728 static int 14729 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/) 14730 { 14731 gbl_driver_id = rte_cryptodev_driver_id_get( 14732 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)); 14733 14734 if (gbl_driver_id == -1) { 14735 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if " 14736 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled " 14737 "in config file to run this testsuite.\n"); 14738 return TEST_SKIPPED; 14739 } 14740 14741 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite); 14742 } 14743 14744 static int 14745 test_cryptodev_ccp(void) 14746 { 14747 gbl_driver_id = rte_cryptodev_driver_id_get( 14748 RTE_STR(CRYPTODEV_NAME_CCP_PMD)); 14749 14750 if (gbl_driver_id == -1) { 14751 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if " 14752 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled " 14753 "in config file to run this testsuite.\n"); 14754 return TEST_FAILED; 14755 } 14756 14757 return unit_test_suite_runner(&cryptodev_ccp_testsuite); 14758 } 14759 14760 static int 14761 test_cryptodev_octeontx(void) 14762 { 14763 gbl_driver_id = rte_cryptodev_driver_id_get( 14764 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)); 14765 if (gbl_driver_id == -1) { 14766 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if " 14767 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is " 14768 "enabled in config file to run this " 14769 "testsuite.\n"); 14770 return TEST_FAILED; 14771 } 14772 return unit_test_suite_runner(&cryptodev_octeontx_testsuite); 14773 } 14774 14775 static int 14776 test_cryptodev_octeontx2(void) 14777 { 14778 gbl_driver_id = rte_cryptodev_driver_id_get( 14779 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)); 14780 if (gbl_driver_id == -1) { 14781 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if " 14782 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is " 14783 "enabled in config file to run this " 14784 "testsuite.\n"); 14785 return TEST_FAILED; 14786 } 14787 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite); 14788 } 14789 14790 static int 14791 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/) 14792 { 14793 gbl_driver_id = rte_cryptodev_driver_id_get( 14794 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)); 14795 14796 if (gbl_driver_id == -1) { 14797 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if " 14798 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled " 14799 "in config file to run this testsuite.\n"); 14800 return TEST_FAILED; 14801 } 14802 14803 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite); 14804 } 14805 14806 static int 14807 test_cryptodev_nitrox(void) 14808 { 14809 gbl_driver_id = rte_cryptodev_driver_id_get( 14810 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)); 14811 14812 if (gbl_driver_id == -1) { 14813 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if " 14814 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled " 14815 "in config file to run this testsuite.\n"); 14816 return TEST_FAILED; 14817 } 14818 14819 return unit_test_suite_runner(&cryptodev_nitrox_testsuite); 14820 } 14821 14822 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat); 14823 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb); 14824 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl); 14825 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm); 14826 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null); 14827 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g); 14828 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi); 14829 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc); 14830 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8); 14831 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl); 14832 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec); 14833 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec); 14834 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp); 14835 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio); 14836 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx); 14837 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2); 14838 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr); 14839 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox); 14840