1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Cavium Networks
3 * Copyright (c) 2019 Intel Corporation
6 #include <rte_bus_vdev.h>
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
14 #include <rte_cryptodev.h>
15 #include <rte_cryptodev_pmd.h>
16 #include <rte_crypto.h>
18 #include "test_cryptodev.h"
19 #include "test_cryptodev_dh_test_vectors.h"
20 #include "test_cryptodev_dsa_test_vectors.h"
21 #include "test_cryptodev_ecdsa_test_vectors.h"
22 #include "test_cryptodev_mod_test_vectors.h"
23 #include "test_cryptodev_rsa_test_vectors.h"
24 #include "test_cryptodev_asym_util.h"
27 #define TEST_NUM_BUFS 10
28 #define TEST_NUM_SESSIONS 4
30 #ifndef TEST_DATA_SIZE
31 #define TEST_DATA_SIZE 4096
33 #define ASYM_TEST_MSG_LEN 256
34 #define TEST_VECTOR_SIZE 256
36 static int gbl_driver_id;
37 struct crypto_testsuite_params {
38 struct rte_mempool *op_mpool;
39 struct rte_mempool *session_mpool;
40 struct rte_cryptodev_config conf;
41 struct rte_cryptodev_qp_conf qp_conf;
42 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
43 uint8_t valid_dev_count;
46 struct crypto_unittest_params {
47 struct rte_cryptodev_asym_session *sess;
48 struct rte_crypto_op *op;
51 union test_case_structure {
52 struct modex_test_data modex;
53 struct modinv_test_data modinv;
54 struct rsa_test_data_2 rsa_data;
57 struct test_cases_array {
59 const void *address[TEST_VECTOR_SIZE];
61 static struct test_cases_array test_vector = {0, { NULL } };
63 static uint32_t test_index;
65 static struct crypto_testsuite_params testsuite_params = { NULL };
68 queue_ops_rsa_sign_verify(struct rte_cryptodev_asym_session *sess)
70 struct crypto_testsuite_params *ts_params = &testsuite_params;
71 struct rte_mempool *op_mpool = ts_params->op_mpool;
72 uint8_t dev_id = ts_params->valid_devs[0];
73 struct rte_crypto_op *op, *result_op;
74 struct rte_crypto_asym_op *asym_op;
75 uint8_t output_buf[TEST_DATA_SIZE];
76 int status = TEST_SUCCESS;
78 /* Set up crypto op data structure */
79 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
81 RTE_LOG(ERR, USER1, "Failed to allocate asymmetric crypto "
82 "operation struct\n");
88 /* Compute sign on the test vector */
89 asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
91 asym_op->rsa.message.data = rsaplaintext.data;
92 asym_op->rsa.message.length = rsaplaintext.len;
93 asym_op->rsa.sign.length = 0;
94 asym_op->rsa.sign.data = output_buf;
95 asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
97 debug_hexdump(stdout, "message", asym_op->rsa.message.data,
98 asym_op->rsa.message.length);
100 /* Attach asymmetric crypto session to crypto operations */
101 rte_crypto_op_attach_asym_session(op, sess);
103 RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
105 /* Process crypto operation */
106 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
107 RTE_LOG(ERR, USER1, "Error sending packet for sign\n");
108 status = TEST_FAILED;
112 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
115 if (result_op == NULL) {
116 RTE_LOG(ERR, USER1, "Failed to process sign op\n");
117 status = TEST_FAILED;
121 debug_hexdump(stdout, "signed message", asym_op->rsa.sign.data,
122 asym_op->rsa.sign.length);
123 asym_op = result_op->asym;
126 asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
127 asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
129 /* Process crypto operation */
130 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
131 RTE_LOG(ERR, USER1, "Error sending packet for verify\n");
132 status = TEST_FAILED;
136 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
139 if (result_op == NULL) {
140 RTE_LOG(ERR, USER1, "Failed to process verify op\n");
141 status = TEST_FAILED;
145 status = TEST_SUCCESS;
146 if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
147 RTE_LOG(ERR, USER1, "Failed to process sign-verify op\n");
148 status = TEST_FAILED;
153 rte_crypto_op_free(op);
159 queue_ops_rsa_enc_dec(struct rte_cryptodev_asym_session *sess)
161 struct crypto_testsuite_params *ts_params = &testsuite_params;
162 struct rte_mempool *op_mpool = ts_params->op_mpool;
163 uint8_t dev_id = ts_params->valid_devs[0];
164 struct rte_crypto_op *op, *result_op;
165 struct rte_crypto_asym_op *asym_op;
166 uint8_t cipher_buf[TEST_DATA_SIZE] = {0};
167 int ret, status = TEST_SUCCESS;
169 /* Set up crypto op data structure */
170 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
172 RTE_LOG(ERR, USER1, "Failed to allocate asymmetric crypto "
173 "operation struct\n");
179 /* Compute encryption on the test vector */
180 asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
182 asym_op->rsa.message.data = rsaplaintext.data;
183 asym_op->rsa.cipher.data = cipher_buf;
184 asym_op->rsa.cipher.length = 0;
185 asym_op->rsa.message.length = rsaplaintext.len;
186 asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
188 debug_hexdump(stdout, "message", asym_op->rsa.message.data,
189 asym_op->rsa.message.length);
191 /* Attach asymmetric crypto session to crypto operations */
192 rte_crypto_op_attach_asym_session(op, sess);
194 RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
196 /* Process crypto operation */
197 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
198 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
199 status = TEST_FAILED;
203 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
206 if (result_op == NULL) {
207 RTE_LOG(ERR, USER1, "Failed to process encryption op\n");
208 status = TEST_FAILED;
211 debug_hexdump(stdout, "encrypted message", asym_op->rsa.message.data,
212 asym_op->rsa.message.length);
214 /* Use the resulted output as decryption Input vector*/
215 asym_op = result_op->asym;
216 asym_op->rsa.message.length = 0;
217 asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
218 asym_op->rsa.pad = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
220 /* Process crypto operation */
221 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
222 RTE_LOG(ERR, USER1, "Error sending packet for decryption\n");
223 status = TEST_FAILED;
227 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
230 if (result_op == NULL) {
231 RTE_LOG(ERR, USER1, "Failed to process decryption op\n");
232 status = TEST_FAILED;
235 status = TEST_SUCCESS;
236 ret = rsa_verify(&rsaplaintext, result_op);
238 status = TEST_FAILED;
242 rte_crypto_op_free(op);
247 test_cryptodev_asym_ver(struct rte_crypto_op *op,
248 struct rte_crypto_asym_xform *xform_tc,
249 union test_case_structure *data_tc,
250 struct rte_crypto_op *result_op)
252 int status = TEST_FAILED;
254 uint8_t *data_expected = NULL, *data_received = NULL;
255 size_t data_size = 0;
257 switch (data_tc->modex.xform_type) {
258 case RTE_CRYPTO_ASYM_XFORM_MODEX:
259 data_expected = data_tc->modex.reminder.data;
260 data_received = result_op->asym->modex.result.data;
261 data_size = result_op->asym->modex.result.length;
263 case RTE_CRYPTO_ASYM_XFORM_MODINV:
264 data_expected = data_tc->modinv.inverse.data;
265 data_received = result_op->asym->modinv.result.data;
266 data_size = result_op->asym->modinv.result.length;
268 case RTE_CRYPTO_ASYM_XFORM_RSA:
269 if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
270 data_size = xform_tc->rsa.n.length;
271 data_received = result_op->asym->rsa.cipher.data;
272 data_expected = data_tc->rsa_data.ct.data;
273 } else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
274 data_size = xform_tc->rsa.n.length;
275 data_expected = data_tc->rsa_data.pt.data;
276 data_received = result_op->asym->rsa.message.data;
277 } else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
278 data_size = xform_tc->rsa.n.length;
279 data_expected = data_tc->rsa_data.sign.data;
280 data_received = result_op->asym->rsa.sign.data;
281 } else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
282 data_size = xform_tc->rsa.n.length;
283 data_expected = data_tc->rsa_data.pt.data;
284 data_received = result_op->asym->rsa.cipher.data;
287 case RTE_CRYPTO_ASYM_XFORM_DH:
288 case RTE_CRYPTO_ASYM_XFORM_DSA:
289 case RTE_CRYPTO_ASYM_XFORM_NONE:
290 case RTE_CRYPTO_ASYM_XFORM_UNSPECIFIED:
294 ret = memcmp(data_expected, data_received, data_size);
295 if (!ret && data_size)
296 status = TEST_SUCCESS;
302 test_cryptodev_asym_op(struct crypto_testsuite_params *ts_params,
303 union test_case_structure *data_tc,
304 char *test_msg, int sessionless, enum rte_crypto_asym_op_type type,
305 enum rte_crypto_rsa_priv_key_type key_type)
307 struct rte_crypto_asym_op *asym_op = NULL;
308 struct rte_crypto_op *op = NULL;
309 struct rte_crypto_op *result_op = NULL;
310 struct rte_crypto_asym_xform xform_tc;
311 struct rte_cryptodev_asym_session *sess = NULL;
312 struct rte_cryptodev_asym_capability_idx cap_idx;
313 const struct rte_cryptodev_asymmetric_xform_capability *capability;
314 uint8_t dev_id = ts_params->valid_devs[0];
315 uint8_t input[TEST_DATA_SIZE] = {0};
316 uint8_t *result = NULL;
318 int status = TEST_SUCCESS;
320 xform_tc.next = NULL;
321 xform_tc.xform_type = data_tc->modex.xform_type;
323 cap_idx.type = xform_tc.xform_type;
324 capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
326 if (capability == NULL) {
328 "Device doesn't support MODEX. Test Skipped\n");
332 /* Generate crypto op data structure */
333 op = rte_crypto_op_alloc(ts_params->op_mpool,
334 RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
337 snprintf(test_msg, ASYM_TEST_MSG_LEN,
338 "line %u FAILED: %s",
339 __LINE__, "Failed to allocate asymmetric crypto "
341 status = TEST_FAILED;
347 switch (xform_tc.xform_type) {
348 case RTE_CRYPTO_ASYM_XFORM_MODEX:
349 result = rte_zmalloc(NULL, data_tc->modex.result_len, 0);
350 xform_tc.modex.modulus.data = data_tc->modex.modulus.data;
351 xform_tc.modex.modulus.length = data_tc->modex.modulus.len;
352 xform_tc.modex.exponent.data = data_tc->modex.exponent.data;
353 xform_tc.modex.exponent.length = data_tc->modex.exponent.len;
354 memcpy(input, data_tc->modex.base.data,
355 data_tc->modex.base.len);
356 asym_op->modex.base.data = input;
357 asym_op->modex.base.length = data_tc->modex.base.len;
358 asym_op->modex.result.data = result;
359 asym_op->modex.result.length = data_tc->modex.result_len;
360 if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
361 xform_tc.modex.modulus.length)) {
362 snprintf(test_msg, ASYM_TEST_MSG_LEN,
364 "FAILED: %s", __LINE__,
365 "Invalid MODULUS length specified");
366 status = TEST_FAILED;
370 case RTE_CRYPTO_ASYM_XFORM_MODINV:
371 result = rte_zmalloc(NULL, data_tc->modinv.result_len, 0);
372 xform_tc.modinv.modulus.data = data_tc->modinv.modulus.data;
373 xform_tc.modinv.modulus.length = data_tc->modinv.modulus.len;
374 memcpy(input, data_tc->modinv.base.data,
375 data_tc->modinv.base.len);
376 asym_op->modinv.base.data = input;
377 asym_op->modinv.base.length = data_tc->modinv.base.len;
378 asym_op->modinv.result.data = result;
379 asym_op->modinv.result.length = data_tc->modinv.result_len;
380 if (rte_cryptodev_asym_xform_capability_check_modlen(capability,
381 xform_tc.modinv.modulus.length)) {
382 snprintf(test_msg, ASYM_TEST_MSG_LEN,
384 "FAILED: %s", __LINE__,
385 "Invalid MODULUS length specified");
386 status = TEST_FAILED;
390 case RTE_CRYPTO_ASYM_XFORM_RSA:
391 result = rte_zmalloc(NULL, data_tc->rsa_data.n.len, 0);
392 op->asym->rsa.op_type = type;
393 xform_tc.rsa.e.data = data_tc->rsa_data.e.data;
394 xform_tc.rsa.e.length = data_tc->rsa_data.e.len;
395 xform_tc.rsa.n.data = data_tc->rsa_data.n.data;
396 xform_tc.rsa.n.length = data_tc->rsa_data.n.len;
398 if (key_type == RTE_RSA_KEY_TYPE_EXP) {
399 xform_tc.rsa.d.data = data_tc->rsa_data.d.data;
400 xform_tc.rsa.d.length = data_tc->rsa_data.d.len;
402 xform_tc.rsa.qt.p.data = data_tc->rsa_data.p.data;
403 xform_tc.rsa.qt.p.length = data_tc->rsa_data.p.len;
404 xform_tc.rsa.qt.q.data = data_tc->rsa_data.q.data;
405 xform_tc.rsa.qt.q.length = data_tc->rsa_data.q.len;
406 xform_tc.rsa.qt.dP.data = data_tc->rsa_data.dP.data;
407 xform_tc.rsa.qt.dP.length = data_tc->rsa_data.dP.len;
408 xform_tc.rsa.qt.dQ.data = data_tc->rsa_data.dQ.data;
409 xform_tc.rsa.qt.dQ.length = data_tc->rsa_data.dQ.len;
410 xform_tc.rsa.qt.qInv.data = data_tc->rsa_data.qInv.data;
411 xform_tc.rsa.qt.qInv.length = data_tc->rsa_data.qInv.len;
414 xform_tc.rsa.key_type = key_type;
415 op->asym->rsa.pad = data_tc->rsa_data.padding;
417 if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
418 asym_op->rsa.message.data = data_tc->rsa_data.pt.data;
419 asym_op->rsa.message.length = data_tc->rsa_data.pt.len;
420 asym_op->rsa.cipher.data = result;
421 asym_op->rsa.cipher.length = data_tc->rsa_data.n.len;
422 } else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
423 asym_op->rsa.message.data = result;
424 asym_op->rsa.message.length = data_tc->rsa_data.n.len;
425 asym_op->rsa.cipher.data = data_tc->rsa_data.ct.data;
426 asym_op->rsa.cipher.length = data_tc->rsa_data.ct.len;
427 } else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
428 asym_op->rsa.sign.data = result;
429 asym_op->rsa.sign.length = data_tc->rsa_data.n.len;
430 asym_op->rsa.message.data = data_tc->rsa_data.pt.data;
431 asym_op->rsa.message.length = data_tc->rsa_data.pt.len;
432 } else if (op->asym->rsa.op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
433 asym_op->rsa.cipher.data = result;
434 asym_op->rsa.cipher.length = data_tc->rsa_data.n.len;
435 asym_op->rsa.sign.data = data_tc->rsa_data.sign.data;
436 asym_op->rsa.sign.length = data_tc->rsa_data.sign.len;
439 case RTE_CRYPTO_ASYM_XFORM_DH:
440 case RTE_CRYPTO_ASYM_XFORM_DSA:
441 case RTE_CRYPTO_ASYM_XFORM_NONE:
442 case RTE_CRYPTO_ASYM_XFORM_UNSPECIFIED:
444 snprintf(test_msg, ASYM_TEST_MSG_LEN,
446 "FAILED: %s", __LINE__,
447 "Invalid ASYM algorithm specified");
448 status = TEST_FAILED;
453 sess = rte_cryptodev_asym_session_create(ts_params->session_mpool);
455 snprintf(test_msg, ASYM_TEST_MSG_LEN,
457 "FAILED: %s", __LINE__,
458 "Session creation failed");
459 status = TEST_FAILED;
463 if (rte_cryptodev_asym_session_init(dev_id, sess, &xform_tc,
464 ts_params->session_mpool) < 0) {
465 snprintf(test_msg, ASYM_TEST_MSG_LEN,
466 "line %u FAILED: %s",
467 __LINE__, "unabled to config sym session");
468 status = TEST_FAILED;
472 rte_crypto_op_attach_asym_session(op, sess);
474 asym_op->xform = &xform_tc;
475 op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
477 RTE_LOG(DEBUG, USER1, "Process ASYM operation");
479 /* Process crypto operation */
480 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
481 snprintf(test_msg, ASYM_TEST_MSG_LEN,
482 "line %u FAILED: %s",
483 __LINE__, "Error sending packet for operation");
484 status = TEST_FAILED;
488 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
491 if (result_op == NULL) {
492 snprintf(test_msg, ASYM_TEST_MSG_LEN,
493 "line %u FAILED: %s",
494 __LINE__, "Failed to process asym crypto op");
495 status = TEST_FAILED;
499 if (test_cryptodev_asym_ver(op, &xform_tc, data_tc, result_op) != TEST_SUCCESS) {
500 snprintf(test_msg, ASYM_TEST_MSG_LEN,
501 "line %u FAILED: %s",
502 __LINE__, "Verification failed ");
503 status = TEST_FAILED;
508 snprintf(test_msg, ASYM_TEST_MSG_LEN, "PASS");
510 snprintf(test_msg, ASYM_TEST_MSG_LEN, "SESSIONLESS PASS");
514 rte_cryptodev_asym_session_clear(dev_id, sess);
515 rte_cryptodev_asym_session_free(sess);
519 rte_crypto_op_free(op);
528 test_one_case(const void *test_case, int sessionless)
530 int status = TEST_SUCCESS, i = 0;
531 char test_msg[ASYM_TEST_MSG_LEN + 1];
533 /* Map the case to union */
534 union test_case_structure tc;
535 memcpy(&tc, test_case, sizeof(tc));
537 if (tc.modex.xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX
538 || tc.modex.xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) {
539 status = test_cryptodev_asym_op(&testsuite_params, &tc, test_msg,
541 printf(" %u) TestCase %s %s\n", test_index++,
542 tc.modex.description, test_msg);
544 for (i = 0; i < RTE_CRYPTO_ASYM_OP_LIST_END; i++) {
545 if (tc.modex.xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {
546 if (tc.rsa_data.op_type_flags & (1 << i)) {
547 if (tc.rsa_data.key_exp) {
548 status = test_cryptodev_asym_op(
549 &testsuite_params, &tc,
550 test_msg, sessionless, i,
551 RTE_RSA_KEY_TYPE_EXP);
555 if (tc.rsa_data.key_qt && (i ==
556 RTE_CRYPTO_ASYM_OP_DECRYPT ||
557 i == RTE_CRYPTO_ASYM_OP_SIGN)) {
558 status = test_cryptodev_asym_op(
560 &tc, test_msg, sessionless, i,
561 RTE_RSA_KET_TYPE_QT);
568 printf(" %u) TestCase %s %s\n", test_index++,
569 tc.modex.description, test_msg);
576 load_test_vectors(void)
578 uint32_t i = 0, v_size = 0;
579 /* Load MODEX vector*/
580 v_size = RTE_DIM(modex_test_case);
581 for (i = 0; i < v_size; i++) {
582 if (test_vector.size >= (TEST_VECTOR_SIZE)) {
583 RTE_LOG(DEBUG, USER1,
584 "TEST_VECTOR_SIZE too small\n");
587 test_vector.address[test_vector.size] = &modex_test_case[i];
590 /* Load MODINV vector*/
591 v_size = RTE_DIM(modinv_test_case);
592 for (i = 0; i < v_size; i++) {
593 if (test_vector.size >= (TEST_VECTOR_SIZE)) {
594 RTE_LOG(DEBUG, USER1,
595 "TEST_VECTOR_SIZE too small\n");
598 test_vector.address[test_vector.size] = &modinv_test_case[i];
602 v_size = RTE_DIM(rsa_test_case_list);
603 for (i = 0; i < v_size; i++) {
604 if (test_vector.size >= (TEST_VECTOR_SIZE)) {
605 RTE_LOG(DEBUG, USER1,
606 "TEST_VECTOR_SIZE too small\n");
609 test_vector.address[test_vector.size] = &rsa_test_case_list[i];
616 test_one_by_one(void)
618 int status = TEST_SUCCESS;
619 struct crypto_testsuite_params *ts_params = &testsuite_params;
621 uint8_t dev_id = ts_params->valid_devs[0];
622 struct rte_cryptodev_info dev_info;
625 rte_cryptodev_info_get(dev_id, &dev_info);
626 if ((dev_info.feature_flags &
627 RTE_CRYPTODEV_FF_ASYM_SESSIONLESS)) {
631 /* Go through all test cases */
633 for (i = 0; i < test_vector.size; i++) {
634 if (test_one_case(test_vector.address[i], 0) != TEST_SUCCESS)
635 status = TEST_FAILED;
638 for (i = 0; i < test_vector.size; i++) {
639 if (test_one_case(test_vector.address[i], 1)
641 status = TEST_FAILED;
645 TEST_ASSERT_EQUAL(status, 0, "Test failed");
650 test_rsa_sign_verify(void)
652 struct crypto_testsuite_params *ts_params = &testsuite_params;
653 struct rte_mempool *sess_mpool = ts_params->session_mpool;
654 uint8_t dev_id = ts_params->valid_devs[0];
655 struct rte_cryptodev_asym_session *sess;
656 struct rte_cryptodev_info dev_info;
657 int status = TEST_SUCCESS;
659 /* Test case supports op with exponent key only,
660 * Check in PMD feature flag for RSA exponent key type support.
662 rte_cryptodev_info_get(dev_id, &dev_info);
663 if (!(dev_info.feature_flags &
664 RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP)) {
665 RTE_LOG(INFO, USER1, "Device doesn't support sign op with "
666 "exponent key type. Test Skipped\n");
670 sess = rte_cryptodev_asym_session_create(sess_mpool);
673 RTE_LOG(ERR, USER1, "Session creation failed for "
678 if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
680 RTE_LOG(ERR, USER1, "Unable to config asym session for "
682 status = TEST_FAILED;
686 status = queue_ops_rsa_sign_verify(sess);
690 rte_cryptodev_asym_session_clear(dev_id, sess);
691 rte_cryptodev_asym_session_free(sess);
693 TEST_ASSERT_EQUAL(status, 0, "Test failed");
699 test_rsa_enc_dec(void)
701 struct crypto_testsuite_params *ts_params = &testsuite_params;
702 struct rte_mempool *sess_mpool = ts_params->session_mpool;
703 uint8_t dev_id = ts_params->valid_devs[0];
704 struct rte_cryptodev_asym_session *sess;
705 struct rte_cryptodev_info dev_info;
706 int status = TEST_SUCCESS;
708 /* Test case supports op with exponent key only,
709 * Check in PMD feature flag for RSA exponent key type support.
711 rte_cryptodev_info_get(dev_id, &dev_info);
712 if (!(dev_info.feature_flags &
713 RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_EXP)) {
714 RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with "
715 "exponent key type. Test skipped\n");
719 sess = rte_cryptodev_asym_session_create(sess_mpool);
722 RTE_LOG(ERR, USER1, "Session creation failed for enc_dec\n");
726 if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
728 RTE_LOG(ERR, USER1, "Unable to config asym session for "
730 status = TEST_FAILED;
734 status = queue_ops_rsa_enc_dec(sess);
738 rte_cryptodev_asym_session_clear(dev_id, sess);
739 rte_cryptodev_asym_session_free(sess);
741 TEST_ASSERT_EQUAL(status, 0, "Test failed");
747 test_rsa_sign_verify_crt(void)
749 struct crypto_testsuite_params *ts_params = &testsuite_params;
750 struct rte_mempool *sess_mpool = ts_params->session_mpool;
751 uint8_t dev_id = ts_params->valid_devs[0];
752 struct rte_cryptodev_asym_session *sess;
753 struct rte_cryptodev_info dev_info;
754 int status = TEST_SUCCESS;
756 /* Test case supports op with quintuple format key only,
757 * Check im PMD feature flag for RSA quintuple key type support.
759 rte_cryptodev_info_get(dev_id, &dev_info);
760 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
761 RTE_LOG(INFO, USER1, "Device doesn't support sign op with "
762 "quintuple key type. Test skipped\n");
766 sess = rte_cryptodev_asym_session_create(sess_mpool);
769 RTE_LOG(ERR, USER1, "Session creation failed for "
770 "sign_verify_crt\n");
771 status = TEST_FAILED;
775 if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
777 RTE_LOG(ERR, USER1, "Unable to config asym session for "
778 "sign_verify_crt\n");
779 status = TEST_FAILED;
782 status = queue_ops_rsa_sign_verify(sess);
786 rte_cryptodev_asym_session_clear(dev_id, sess);
787 rte_cryptodev_asym_session_free(sess);
789 TEST_ASSERT_EQUAL(status, 0, "Test failed");
795 test_rsa_enc_dec_crt(void)
797 struct crypto_testsuite_params *ts_params = &testsuite_params;
798 struct rte_mempool *sess_mpool = ts_params->session_mpool;
799 uint8_t dev_id = ts_params->valid_devs[0];
800 struct rte_cryptodev_asym_session *sess;
801 struct rte_cryptodev_info dev_info;
802 int status = TEST_SUCCESS;
804 /* Test case supports op with quintuple format key only,
805 * Check in PMD feature flag for RSA quintuple key type support.
807 rte_cryptodev_info_get(dev_id, &dev_info);
808 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_RSA_PRIV_OP_KEY_QT)) {
809 RTE_LOG(INFO, USER1, "Device doesn't support decrypt op with "
810 "quintuple key type. Test skipped\n");
814 sess = rte_cryptodev_asym_session_create(sess_mpool);
817 RTE_LOG(ERR, USER1, "Session creation failed for "
822 if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform_crt,
824 RTE_LOG(ERR, USER1, "Unable to config asym session for "
826 status = TEST_FAILED;
829 status = queue_ops_rsa_enc_dec(sess);
833 rte_cryptodev_asym_session_clear(dev_id, sess);
834 rte_cryptodev_asym_session_free(sess);
836 TEST_ASSERT_EQUAL(status, 0, "Test failed");
842 testsuite_setup(void)
844 struct crypto_testsuite_params *ts_params = &testsuite_params;
845 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
846 struct rte_cryptodev_info info;
847 int ret, dev_id = -1;
851 memset(ts_params, 0, sizeof(*ts_params));
853 test_vector.size = 0;
856 ts_params->op_mpool = rte_crypto_op_pool_create(
857 "CRYPTO_ASYM_OP_POOL",
858 RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
862 if (ts_params->op_mpool == NULL) {
863 RTE_LOG(ERR, USER1, "Can't create ASYM_CRYPTO_OP_POOL\n");
867 /* Create an OPENSSL device if required */
868 if (gbl_driver_id == rte_cryptodev_driver_id_get(
869 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
870 nb_devs = rte_cryptodev_device_count_by_driver(
871 rte_cryptodev_driver_id_get(
872 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
875 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
878 TEST_ASSERT(ret == 0, "Failed to create "
879 "instance of pmd : %s",
880 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
884 /* Get list of valid crypto devs */
885 nb_devs = rte_cryptodev_devices_get(
886 rte_cryptodev_driver_name_get(gbl_driver_id),
887 valid_devs, RTE_CRYPTO_MAX_DEVS);
889 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
894 * Get first valid asymmetric device found in test suite param and
897 for (i = 0; i < nb_devs ; i++) {
898 rte_cryptodev_info_get(valid_devs[i], &info);
899 if (info.feature_flags & RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) {
900 dev_id = ts_params->valid_devs[0] = valid_devs[i];
906 RTE_LOG(ERR, USER1, "Device doesn't support asymmetric. "
911 /* Set valid device count */
912 ts_params->valid_dev_count = nb_devs;
914 /* configure device with num qp */
915 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
916 ts_params->conf.socket_id = SOCKET_ID_ANY;
917 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY |
918 RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO;
919 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
921 "Failed to configure cryptodev %u with %u qps",
922 dev_id, ts_params->conf.nb_queue_pairs);
925 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
926 ts_params->qp_conf.mp_session = ts_params->session_mpool;
927 ts_params->qp_conf.mp_session_private = ts_params->session_mpool;
928 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
929 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
930 dev_id, qp_id, &ts_params->qp_conf,
931 rte_cryptodev_socket_id(dev_id)),
932 "Failed to setup queue pair %u on cryptodev %u ASYM",
936 /* setup asym session pool */
937 unsigned int session_size =
938 rte_cryptodev_asym_get_private_session_size(dev_id);
940 * Create mempool with TEST_NUM_SESSIONS * 2,
941 * to include the session headers
943 ts_params->session_mpool = rte_mempool_create(
945 TEST_NUM_SESSIONS * 2,
947 0, 0, NULL, NULL, NULL,
951 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
952 "session mempool allocation failed");
958 testsuite_teardown(void)
960 struct crypto_testsuite_params *ts_params = &testsuite_params;
962 if (ts_params->op_mpool != NULL) {
963 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
964 rte_mempool_avail_count(ts_params->op_mpool));
967 /* Free session mempools */
968 if (ts_params->session_mpool != NULL) {
969 rte_mempool_free(ts_params->session_mpool);
970 ts_params->session_mpool = NULL;
977 struct crypto_testsuite_params *ts_params = &testsuite_params;
981 /* Reconfigure device to default parameters */
982 ts_params->conf.socket_id = SOCKET_ID_ANY;
984 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
986 "Failed to configure cryptodev %u",
987 ts_params->valid_devs[0]);
989 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
990 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
991 ts_params->valid_devs[0], qp_id,
993 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
994 "Failed to setup queue pair %u on cryptodev %u",
995 qp_id, ts_params->valid_devs[0]);
998 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1000 /* Start the device */
1001 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1002 "Failed to start cryptodev %u",
1003 ts_params->valid_devs[0]);
1005 return TEST_SUCCESS;
1011 struct crypto_testsuite_params *ts_params = &testsuite_params;
1012 struct rte_cryptodev_stats stats;
1014 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1016 /* Stop the device */
1017 rte_cryptodev_stop(ts_params->valid_devs[0]);
1020 static inline void print_asym_capa(
1021 const struct rte_cryptodev_asymmetric_xform_capability *capa)
1025 printf("\nxform type: %s\n===================\n",
1026 rte_crypto_asym_xform_strings[capa->xform_type]);
1027 printf("operation supported -");
1029 for (i = 0; i < RTE_CRYPTO_ASYM_OP_LIST_END; i++) {
1030 /* check supported operations */
1031 if (rte_cryptodev_asym_xform_capability_check_optype(capa, i))
1033 rte_crypto_asym_op_strings[i]);
1035 switch (capa->xform_type) {
1036 case RTE_CRYPTO_ASYM_XFORM_RSA:
1037 case RTE_CRYPTO_ASYM_XFORM_MODINV:
1038 case RTE_CRYPTO_ASYM_XFORM_MODEX:
1039 case RTE_CRYPTO_ASYM_XFORM_DH:
1040 case RTE_CRYPTO_ASYM_XFORM_DSA:
1041 printf(" modlen: min %d max %d increment %d",
1044 capa->modlen.increment);
1046 case RTE_CRYPTO_ASYM_XFORM_ECDSA:
1054 test_capability(void)
1056 struct crypto_testsuite_params *ts_params = &testsuite_params;
1057 uint8_t dev_id = ts_params->valid_devs[0];
1058 struct rte_cryptodev_info dev_info;
1059 const struct rte_cryptodev_capabilities *dev_capa;
1061 struct rte_cryptodev_asym_capability_idx idx;
1062 const struct rte_cryptodev_asymmetric_xform_capability *capa;
1064 rte_cryptodev_info_get(dev_id, &dev_info);
1065 if (!(dev_info.feature_flags &
1066 RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)) {
1067 RTE_LOG(INFO, USER1,
1068 "Device doesn't support asymmetric. Test Skipped\n");
1069 return TEST_SUCCESS;
1072 /* print xform capability */
1074 dev_info.capabilities[i].op != RTE_CRYPTO_OP_TYPE_UNDEFINED;
1076 dev_capa = &(dev_info.capabilities[i]);
1077 if (dev_info.capabilities[i].op ==
1078 RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
1079 idx.type = dev_capa->asym.xform_capa.xform_type;
1081 capa = rte_cryptodev_asym_capability_get(dev_id,
1083 rte_cryptodev_asym_capability_idx *) &idx);
1084 print_asym_capa(capa);
1087 return TEST_SUCCESS;
1091 test_dh_gen_shared_sec(struct rte_crypto_asym_xform *xfrm)
1093 struct crypto_testsuite_params *ts_params = &testsuite_params;
1094 struct rte_mempool *op_mpool = ts_params->op_mpool;
1095 struct rte_mempool *sess_mpool = ts_params->session_mpool;
1096 uint8_t dev_id = ts_params->valid_devs[0];
1097 struct rte_crypto_asym_op *asym_op = NULL;
1098 struct rte_crypto_op *op = NULL, *result_op = NULL;
1099 struct rte_cryptodev_asym_session *sess = NULL;
1100 int status = TEST_SUCCESS;
1101 uint8_t output[TEST_DH_MOD_LEN];
1102 struct rte_crypto_asym_xform xform = *xfrm;
1103 uint8_t peer[] = "01234567890123456789012345678901234567890123456789";
1105 sess = rte_cryptodev_asym_session_create(sess_mpool);
1108 "line %u FAILED: %s", __LINE__,
1109 "Session creation failed");
1110 status = TEST_FAILED;
1113 /* set up crypto op data structure */
1114 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
1117 "line %u FAILED: %s",
1118 __LINE__, "Failed to allocate asymmetric crypto "
1119 "operation struct");
1120 status = TEST_FAILED;
1125 /* Setup a xform and op to generate private key only */
1126 xform.dh.type = RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE;
1128 asym_op->dh.priv_key.data = dh_test_params.priv_key.data;
1129 asym_op->dh.priv_key.length = dh_test_params.priv_key.length;
1130 asym_op->dh.pub_key.data = (uint8_t *)peer;
1131 asym_op->dh.pub_key.length = sizeof(peer);
1132 asym_op->dh.shared_secret.data = output;
1133 asym_op->dh.shared_secret.length = sizeof(output);
1135 if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
1138 "line %u FAILED: %s",
1139 __LINE__, "unabled to config sym session");
1140 status = TEST_FAILED;
1144 /* attach asymmetric crypto session to crypto operations */
1145 rte_crypto_op_attach_asym_session(op, sess);
1147 RTE_LOG(DEBUG, USER1, "Process ASYM operation");
1149 /* Process crypto operation */
1150 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
1152 "line %u FAILED: %s",
1153 __LINE__, "Error sending packet for operation");
1154 status = TEST_FAILED;
1158 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
1161 if (result_op == NULL) {
1163 "line %u FAILED: %s",
1164 __LINE__, "Failed to process asym crypto op");
1165 status = TEST_FAILED;
1169 debug_hexdump(stdout, "shared secret:",
1170 asym_op->dh.shared_secret.data,
1171 asym_op->dh.shared_secret.length);
1175 rte_cryptodev_asym_session_clear(dev_id, sess);
1176 rte_cryptodev_asym_session_free(sess);
1179 rte_crypto_op_free(op);
1184 test_dh_gen_priv_key(struct rte_crypto_asym_xform *xfrm)
1186 struct crypto_testsuite_params *ts_params = &testsuite_params;
1187 struct rte_mempool *op_mpool = ts_params->op_mpool;
1188 struct rte_mempool *sess_mpool = ts_params->session_mpool;
1189 uint8_t dev_id = ts_params->valid_devs[0];
1190 struct rte_crypto_asym_op *asym_op = NULL;
1191 struct rte_crypto_op *op = NULL, *result_op = NULL;
1192 struct rte_cryptodev_asym_session *sess = NULL;
1193 int status = TEST_SUCCESS;
1194 uint8_t output[TEST_DH_MOD_LEN];
1195 struct rte_crypto_asym_xform xform = *xfrm;
1197 sess = rte_cryptodev_asym_session_create(sess_mpool);
1200 "line %u FAILED: %s", __LINE__,
1201 "Session creation failed");
1202 status = TEST_FAILED;
1205 /* set up crypto op data structure */
1206 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
1209 "line %u FAILED: %s",
1210 __LINE__, "Failed to allocate asymmetric crypto "
1211 "operation struct");
1212 status = TEST_FAILED;
1217 /* Setup a xform and op to generate private key only */
1218 xform.dh.type = RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE;
1220 asym_op->dh.priv_key.data = output;
1221 asym_op->dh.priv_key.length = sizeof(output);
1223 if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
1226 "line %u FAILED: %s",
1227 __LINE__, "unabled to config sym session");
1228 status = TEST_FAILED;
1232 /* attach asymmetric crypto session to crypto operations */
1233 rte_crypto_op_attach_asym_session(op, sess);
1235 RTE_LOG(DEBUG, USER1, "Process ASYM operation");
1237 /* Process crypto operation */
1238 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
1240 "line %u FAILED: %s",
1241 __LINE__, "Error sending packet for operation");
1242 status = TEST_FAILED;
1246 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
1249 if (result_op == NULL) {
1251 "line %u FAILED: %s",
1252 __LINE__, "Failed to process asym crypto op");
1253 status = TEST_FAILED;
1257 debug_hexdump(stdout, "private key:",
1258 asym_op->dh.priv_key.data,
1259 asym_op->dh.priv_key.length);
1264 rte_cryptodev_asym_session_clear(dev_id, sess);
1265 rte_cryptodev_asym_session_free(sess);
1268 rte_crypto_op_free(op);
1275 test_dh_gen_pub_key(struct rte_crypto_asym_xform *xfrm)
1277 struct crypto_testsuite_params *ts_params = &testsuite_params;
1278 struct rte_mempool *op_mpool = ts_params->op_mpool;
1279 struct rte_mempool *sess_mpool = ts_params->session_mpool;
1280 uint8_t dev_id = ts_params->valid_devs[0];
1281 struct rte_crypto_asym_op *asym_op = NULL;
1282 struct rte_crypto_op *op = NULL, *result_op = NULL;
1283 struct rte_cryptodev_asym_session *sess = NULL;
1284 int status = TEST_SUCCESS;
1285 uint8_t output[TEST_DH_MOD_LEN];
1286 struct rte_crypto_asym_xform xform = *xfrm;
1288 sess = rte_cryptodev_asym_session_create(sess_mpool);
1291 "line %u FAILED: %s", __LINE__,
1292 "Session creation failed");
1293 status = TEST_FAILED;
1296 /* set up crypto op data structure */
1297 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
1300 "line %u FAILED: %s",
1301 __LINE__, "Failed to allocate asymmetric crypto "
1302 "operation struct");
1303 status = TEST_FAILED;
1307 /* Setup a xform chain to generate public key
1308 * using test private key
1311 xform.dh.type = RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE;
1314 asym_op->dh.pub_key.data = output;
1315 asym_op->dh.pub_key.length = sizeof(output);
1316 /* load pre-defined private key */
1317 asym_op->dh.priv_key.data = rte_malloc(NULL,
1318 dh_test_params.priv_key.length,
1320 asym_op->dh.priv_key = dh_test_params.priv_key;
1322 if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
1325 "line %u FAILED: %s",
1326 __LINE__, "unabled to config sym session");
1327 status = TEST_FAILED;
1331 /* attach asymmetric crypto session to crypto operations */
1332 rte_crypto_op_attach_asym_session(op, sess);
1334 RTE_LOG(DEBUG, USER1, "Process ASYM operation");
1336 /* Process crypto operation */
1337 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
1339 "line %u FAILED: %s",
1340 __LINE__, "Error sending packet for operation");
1341 status = TEST_FAILED;
1345 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
1348 if (result_op == NULL) {
1350 "line %u FAILED: %s",
1351 __LINE__, "Failed to process asym crypto op");
1352 status = TEST_FAILED;
1356 debug_hexdump(stdout, "pub key:",
1357 asym_op->dh.pub_key.data, asym_op->dh.pub_key.length);
1359 debug_hexdump(stdout, "priv key:",
1360 asym_op->dh.priv_key.data, asym_op->dh.priv_key.length);
1364 rte_cryptodev_asym_session_clear(dev_id, sess);
1365 rte_cryptodev_asym_session_free(sess);
1368 rte_crypto_op_free(op);
1374 test_dh_gen_kp(struct rte_crypto_asym_xform *xfrm)
1376 struct crypto_testsuite_params *ts_params = &testsuite_params;
1377 struct rte_mempool *op_mpool = ts_params->op_mpool;
1378 struct rte_mempool *sess_mpool = ts_params->session_mpool;
1379 uint8_t dev_id = ts_params->valid_devs[0];
1380 struct rte_crypto_asym_op *asym_op = NULL;
1381 struct rte_crypto_op *op = NULL, *result_op = NULL;
1382 struct rte_cryptodev_asym_session *sess = NULL;
1383 int status = TEST_SUCCESS;
1384 uint8_t out_pub_key[TEST_DH_MOD_LEN];
1385 uint8_t out_prv_key[TEST_DH_MOD_LEN];
1386 struct rte_crypto_asym_xform pub_key_xform;
1387 struct rte_crypto_asym_xform xform = *xfrm;
1389 sess = rte_cryptodev_asym_session_create(sess_mpool);
1392 "line %u FAILED: %s", __LINE__,
1393 "Session creation failed");
1394 status = TEST_FAILED;
1398 /* set up crypto op data structure */
1399 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
1402 "line %u FAILED: %s",
1403 __LINE__, "Failed to allocate asymmetric crypto "
1404 "operation struct");
1405 status = TEST_FAILED;
1409 /* Setup a xform chain to generate
1410 * private key first followed by
1412 */xform.dh.type = RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE;
1413 pub_key_xform.xform_type = RTE_CRYPTO_ASYM_XFORM_DH;
1414 pub_key_xform.dh.type = RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE;
1415 xform.next = &pub_key_xform;
1417 asym_op->dh.pub_key.data = out_pub_key;
1418 asym_op->dh.pub_key.length = sizeof(out_pub_key);
1419 asym_op->dh.priv_key.data = out_prv_key;
1420 asym_op->dh.priv_key.length = sizeof(out_prv_key);
1421 if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
1424 "line %u FAILED: %s",
1425 __LINE__, "unabled to config sym session");
1426 status = TEST_FAILED;
1430 /* attach asymmetric crypto session to crypto operations */
1431 rte_crypto_op_attach_asym_session(op, sess);
1433 RTE_LOG(DEBUG, USER1, "Process ASYM operation");
1435 /* Process crypto operation */
1436 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
1438 "line %u FAILED: %s",
1439 __LINE__, "Error sending packet for operation");
1440 status = TEST_FAILED;
1444 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
1447 if (result_op == NULL) {
1449 "line %u FAILED: %s",
1450 __LINE__, "Failed to process asym crypto op");
1451 status = TEST_FAILED;
1454 debug_hexdump(stdout, "priv key:",
1455 out_prv_key, asym_op->dh.priv_key.length);
1456 debug_hexdump(stdout, "pub key:",
1457 out_pub_key, asym_op->dh.pub_key.length);
1461 rte_cryptodev_asym_session_clear(dev_id, sess);
1462 rte_cryptodev_asym_session_free(sess);
1465 rte_crypto_op_free(op);
1473 struct crypto_testsuite_params *ts_params = &testsuite_params;
1474 struct rte_mempool *op_mpool = ts_params->op_mpool;
1475 struct rte_mempool *sess_mpool = ts_params->session_mpool;
1476 uint8_t dev_id = ts_params->valid_devs[0];
1477 struct rte_crypto_asym_op *asym_op = NULL;
1478 struct rte_crypto_op *op = NULL, *result_op = NULL;
1479 struct rte_cryptodev_asym_session *sess = NULL;
1480 int status = TEST_SUCCESS;
1481 struct rte_cryptodev_asym_capability_idx cap_idx;
1482 const struct rte_cryptodev_asymmetric_xform_capability *capability;
1483 uint8_t input[TEST_DATA_SIZE] = {0};
1485 uint8_t result[sizeof(mod_p)] = { 0 };
1487 if (rte_cryptodev_asym_get_xform_enum(
1488 &modinv_xform.xform_type, "modinv") < 0) {
1490 "Invalid ASYM algorithm specified\n");
1494 cap_idx.type = modinv_xform.xform_type;
1495 capability = rte_cryptodev_asym_capability_get(dev_id,
1498 if (capability == NULL) {
1499 RTE_LOG(INFO, USER1,
1500 "Device doesn't support MOD INV. Test Skipped\n");
1504 if (rte_cryptodev_asym_xform_capability_check_modlen(
1506 modinv_xform.modinv.modulus.length)) {
1508 "Invalid MODULUS length specified\n");
1512 sess = rte_cryptodev_asym_session_create(sess_mpool);
1514 RTE_LOG(ERR, USER1, "line %u "
1515 "FAILED: %s", __LINE__,
1516 "Session creation failed");
1517 status = TEST_FAILED;
1521 if (rte_cryptodev_asym_session_init(dev_id, sess, &modinv_xform,
1524 "line %u FAILED: %s",
1525 __LINE__, "unabled to config sym session");
1526 status = TEST_FAILED;
1530 /* generate crypto op data structure */
1531 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
1534 "line %u FAILED: %s",
1535 __LINE__, "Failed to allocate asymmetric crypto "
1536 "operation struct");
1537 status = TEST_FAILED;
1542 memcpy(input, base, sizeof(base));
1543 asym_op->modinv.base.data = input;
1544 asym_op->modinv.base.length = sizeof(base);
1545 asym_op->modinv.result.data = result;
1546 asym_op->modinv.result.length = sizeof(result);
1548 /* attach asymmetric crypto session to crypto operations */
1549 rte_crypto_op_attach_asym_session(op, sess);
1551 RTE_LOG(DEBUG, USER1, "Process ASYM operation");
1553 /* Process crypto operation */
1554 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
1556 "line %u FAILED: %s",
1557 __LINE__, "Error sending packet for operation");
1558 status = TEST_FAILED;
1562 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
1565 if (result_op == NULL) {
1567 "line %u FAILED: %s",
1568 __LINE__, "Failed to process asym crypto op");
1569 status = TEST_FAILED;
1573 ret = verify_modinv(mod_inv, result_op);
1576 "operation verification failed\n");
1577 status = TEST_FAILED;
1582 rte_cryptodev_asym_session_clear(dev_id, sess);
1583 rte_cryptodev_asym_session_free(sess);
1587 rte_crypto_op_free(op);
1589 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1597 struct crypto_testsuite_params *ts_params = &testsuite_params;
1598 struct rte_mempool *op_mpool = ts_params->op_mpool;
1599 struct rte_mempool *sess_mpool = ts_params->session_mpool;
1600 uint8_t dev_id = ts_params->valid_devs[0];
1601 struct rte_crypto_asym_op *asym_op = NULL;
1602 struct rte_crypto_op *op = NULL, *result_op = NULL;
1603 struct rte_cryptodev_asym_session *sess = NULL;
1604 int status = TEST_SUCCESS;
1605 struct rte_cryptodev_asym_capability_idx cap_idx;
1606 const struct rte_cryptodev_asymmetric_xform_capability *capability;
1607 uint8_t input[TEST_DATA_SIZE] = {0};
1609 uint8_t result[sizeof(mod_p)] = { 0 };
1611 if (rte_cryptodev_asym_get_xform_enum(&modex_xform.xform_type,
1615 "Invalid ASYM algorithm specified\n");
1619 /* check for modlen capability */
1620 cap_idx.type = modex_xform.xform_type;
1621 capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
1623 if (capability == NULL) {
1624 RTE_LOG(INFO, USER1,
1625 "Device doesn't support MOD EXP. Test Skipped\n");
1629 if (rte_cryptodev_asym_xform_capability_check_modlen(
1630 capability, modex_xform.modex.modulus.length)) {
1632 "Invalid MODULUS length specified\n");
1636 /* generate crypto op data structure */
1637 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
1640 "line %u FAILED: %s",
1641 __LINE__, "Failed to allocate asymmetric crypto "
1642 "operation struct");
1643 status = TEST_FAILED;
1647 sess = rte_cryptodev_asym_session_create(sess_mpool);
1651 "FAILED: %s", __LINE__,
1652 "Session creation failed");
1653 status = TEST_FAILED;
1657 if (rte_cryptodev_asym_session_init(dev_id, sess, &modex_xform,
1660 "line %u FAILED: %s",
1661 __LINE__, "unabled to config sym session");
1662 status = TEST_FAILED;
1667 memcpy(input, base, sizeof(base));
1668 asym_op->modex.base.data = input;
1669 asym_op->modex.base.length = sizeof(base);
1670 asym_op->modex.result.data = result;
1671 asym_op->modex.result.length = sizeof(result);
1672 /* attach asymmetric crypto session to crypto operations */
1673 rte_crypto_op_attach_asym_session(op, sess);
1675 RTE_LOG(DEBUG, USER1, "Process ASYM operation");
1676 /* Process crypto operation */
1677 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
1679 "line %u FAILED: %s",
1680 __LINE__, "Error sending packet for operation");
1681 status = TEST_FAILED;
1685 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
1688 if (result_op == NULL) {
1690 "line %u FAILED: %s",
1691 __LINE__, "Failed to process asym crypto op");
1692 status = TEST_FAILED;
1696 ret = verify_modexp(mod_exp, result_op);
1699 "operation verification failed\n");
1700 status = TEST_FAILED;
1705 rte_cryptodev_asym_session_clear(dev_id, sess);
1706 rte_cryptodev_asym_session_free(sess);
1710 rte_crypto_op_free(op);
1712 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1718 test_dh_keygenration(void)
1722 debug_hexdump(stdout, "p:", dh_xform.dh.p.data, dh_xform.dh.p.length);
1723 debug_hexdump(stdout, "g:", dh_xform.dh.g.data, dh_xform.dh.g.length);
1724 debug_hexdump(stdout, "priv_key:", dh_test_params.priv_key.data,
1725 dh_test_params.priv_key.length);
1727 RTE_LOG(INFO, USER1,
1728 "Test Public and Private key pair generation\n");
1730 status = test_dh_gen_kp(&dh_xform);
1731 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1733 RTE_LOG(INFO, USER1,
1734 "Test Public Key Generation using pre-defined priv key\n");
1736 status = test_dh_gen_pub_key(&dh_xform);
1737 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1739 RTE_LOG(INFO, USER1,
1740 "Test Private Key Generation only\n");
1742 status = test_dh_gen_priv_key(&dh_xform);
1743 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1745 RTE_LOG(INFO, USER1,
1746 "Test shared secret compute\n");
1748 status = test_dh_gen_shared_sec(&dh_xform);
1749 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1757 struct crypto_testsuite_params *ts_params = &testsuite_params;
1758 struct rte_mempool *op_mpool = ts_params->op_mpool;
1759 struct rte_mempool *sess_mpool = ts_params->session_mpool;
1760 uint8_t dev_id = ts_params->valid_devs[0];
1761 struct rte_crypto_asym_op *asym_op = NULL;
1762 struct rte_crypto_op *op = NULL, *result_op = NULL;
1763 struct rte_cryptodev_asym_session *sess = NULL;
1764 int status = TEST_SUCCESS;
1765 uint8_t r[TEST_DH_MOD_LEN];
1766 uint8_t s[TEST_DH_MOD_LEN];
1767 uint8_t dgst[] = "35d81554afaad2cf18f3a1770d5fedc4ea5be344";
1769 sess = rte_cryptodev_asym_session_create(sess_mpool);
1772 "line %u FAILED: %s", __LINE__,
1773 "Session creation failed");
1774 status = TEST_FAILED;
1777 /* set up crypto op data structure */
1778 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
1781 "line %u FAILED: %s",
1782 __LINE__, "Failed to allocate asymmetric crypto "
1783 "operation struct");
1784 status = TEST_FAILED;
1789 debug_hexdump(stdout, "p: ", dsa_xform.dsa.p.data,
1790 dsa_xform.dsa.p.length);
1791 debug_hexdump(stdout, "q: ", dsa_xform.dsa.q.data,
1792 dsa_xform.dsa.q.length);
1793 debug_hexdump(stdout, "g: ", dsa_xform.dsa.g.data,
1794 dsa_xform.dsa.g.length);
1795 debug_hexdump(stdout, "priv_key: ", dsa_xform.dsa.x.data,
1796 dsa_xform.dsa.x.length);
1798 if (rte_cryptodev_asym_session_init(dev_id, sess, &dsa_xform,
1801 "line %u FAILED: %s",
1802 __LINE__, "unabled to config sym session");
1803 status = TEST_FAILED;
1807 /* attach asymmetric crypto session to crypto operations */
1808 rte_crypto_op_attach_asym_session(op, sess);
1809 asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
1810 asym_op->dsa.message.data = dgst;
1811 asym_op->dsa.message.length = sizeof(dgst);
1812 asym_op->dsa.r.length = sizeof(r);
1813 asym_op->dsa.r.data = r;
1814 asym_op->dsa.s.length = sizeof(s);
1815 asym_op->dsa.s.data = s;
1817 RTE_LOG(DEBUG, USER1, "Process ASYM operation");
1819 /* Process crypto operation */
1820 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
1822 "line %u FAILED: %s",
1823 __LINE__, "Error sending packet for operation");
1824 status = TEST_FAILED;
1828 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
1831 if (result_op == NULL) {
1833 "line %u FAILED: %s",
1834 __LINE__, "Failed to process asym crypto op");
1835 status = TEST_FAILED;
1839 asym_op = result_op->asym;
1841 debug_hexdump(stdout, "r:",
1842 asym_op->dsa.r.data, asym_op->dsa.r.length);
1843 debug_hexdump(stdout, "s:",
1844 asym_op->dsa.s.data, asym_op->dsa.s.length);
1846 /* Test PMD DSA sign verification using signer public key */
1847 asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
1849 /* copy signer public key */
1850 asym_op->dsa.y.data = dsa_test_params.y.data;
1851 asym_op->dsa.y.length = dsa_test_params.y.length;
1853 /* Process crypto operation */
1854 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
1856 "line %u FAILED: %s",
1857 __LINE__, "Error sending packet for operation");
1858 status = TEST_FAILED;
1862 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
1865 if (result_op == NULL) {
1867 "line %u FAILED: %s",
1868 __LINE__, "Failed to process asym crypto op");
1869 status = TEST_FAILED;
1873 if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
1875 "line %u FAILED: %s",
1876 __LINE__, "Failed to process asym crypto op");
1877 status = TEST_FAILED;
1881 rte_cryptodev_asym_session_clear(dev_id, sess);
1882 rte_cryptodev_asym_session_free(sess);
1885 rte_crypto_op_free(op);
1893 status = test_dsa_sign();
1894 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1899 test_ecdsa_sign_verify(enum curve curve_id)
1901 struct crypto_testsuite_params *ts_params = &testsuite_params;
1902 struct rte_mempool *sess_mpool = ts_params->session_mpool;
1903 struct rte_mempool *op_mpool = ts_params->op_mpool;
1904 struct crypto_testsuite_ecdsa_params input_params;
1905 struct rte_cryptodev_asym_session *sess = NULL;
1906 uint8_t dev_id = ts_params->valid_devs[0];
1907 struct rte_crypto_op *result_op = NULL;
1908 uint8_t output_buf_r[TEST_DATA_SIZE];
1909 uint8_t output_buf_s[TEST_DATA_SIZE];
1910 struct rte_crypto_asym_xform xform;
1911 struct rte_crypto_asym_op *asym_op;
1912 struct rte_cryptodev_info dev_info;
1913 struct rte_crypto_op *op = NULL;
1914 int status = TEST_SUCCESS, ret;
1918 input_params = ecdsa_param_secp192r1;
1921 input_params = ecdsa_param_secp224r1;
1924 input_params = ecdsa_param_secp256r1;
1927 input_params = ecdsa_param_secp384r1;
1930 input_params = ecdsa_param_secp521r1;
1934 "line %u FAILED: %s", __LINE__,
1935 "Unsupported curve id\n");
1936 status = TEST_FAILED;
1940 rte_cryptodev_info_get(dev_id, &dev_info);
1942 sess = rte_cryptodev_asym_session_create(sess_mpool);
1945 "line %u FAILED: %s", __LINE__,
1946 "Session creation failed\n");
1947 status = TEST_FAILED;
1951 /* Setup crypto op data structure */
1952 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
1955 "line %u FAILED: %s", __LINE__,
1956 "Failed to allocate asymmetric crypto "
1957 "operation struct\n");
1958 status = TEST_FAILED;
1963 /* Setup asym xform */
1965 xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDSA;
1966 xform.ec.curve_id = input_params.curve;
1968 if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
1971 "line %u FAILED: %s", __LINE__,
1972 "Unable to config asym session\n");
1973 status = TEST_FAILED;
1977 /* Attach asymmetric crypto session to crypto operations */
1978 rte_crypto_op_attach_asym_session(op, sess);
1982 /* Populate op with operational details */
1983 op->asym->ecdsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
1984 op->asym->ecdsa.message.data = input_params.digest.data;
1985 op->asym->ecdsa.message.length = input_params.digest.length;
1986 op->asym->ecdsa.k.data = input_params.scalar.data;
1987 op->asym->ecdsa.k.length = input_params.scalar.length;
1988 op->asym->ecdsa.pkey.data = input_params.pkey.data;
1989 op->asym->ecdsa.pkey.length = input_params.pkey.length;
1992 op->asym->ecdsa.r.data = output_buf_r;
1993 op->asym->ecdsa.s.data = output_buf_s;
1995 RTE_LOG(DEBUG, USER1, "Process ASYM operation\n");
1997 /* Process crypto operation */
1998 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
2000 "line %u FAILED: %s", __LINE__,
2001 "Error sending packet for operation\n");
2002 status = TEST_FAILED;
2006 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
2009 if (result_op == NULL) {
2011 "line %u FAILED: %s", __LINE__,
2012 "Failed to process asym crypto op\n");
2013 status = TEST_FAILED;
2017 if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
2019 "line %u FAILED: %s", __LINE__,
2020 "Failed to process asym crypto op\n");
2021 status = TEST_FAILED;
2025 asym_op = result_op->asym;
2027 debug_hexdump(stdout, "r:",
2028 asym_op->ecdsa.r.data, asym_op->ecdsa.r.length);
2029 debug_hexdump(stdout, "s:",
2030 asym_op->ecdsa.s.data, asym_op->ecdsa.s.length);
2032 ret = verify_ecdsa_sign(input_params.sign_r.data,
2033 input_params.sign_s.data, result_op);
2035 status = TEST_FAILED;
2037 "line %u FAILED: %s", __LINE__,
2038 "ECDSA sign failed.\n");
2044 /* Populate op with operational details */
2045 op->asym->ecdsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
2046 op->asym->ecdsa.q.x.data = input_params.pubkey_qx.data;
2047 op->asym->ecdsa.q.x.length = input_params.pubkey_qx.length;
2048 op->asym->ecdsa.q.y.data = input_params.pubkey_qy.data;
2049 op->asym->ecdsa.q.y.length = input_params.pubkey_qx.length;
2050 op->asym->ecdsa.r.data = asym_op->ecdsa.r.data;
2051 op->asym->ecdsa.r.length = asym_op->ecdsa.r.length;
2052 op->asym->ecdsa.s.data = asym_op->ecdsa.s.data;
2053 op->asym->ecdsa.s.length = asym_op->ecdsa.s.length;
2055 /* Enqueue sign result for verify */
2056 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
2057 status = TEST_FAILED;
2059 "line %u FAILED: %s", __LINE__,
2060 "Error sending packet for operation\n");
2064 while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
2067 if (result_op == NULL) {
2068 status = TEST_FAILED;
2071 if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
2072 status = TEST_FAILED;
2074 "line %u FAILED: %s", __LINE__,
2075 "ECDSA verify failed.\n");
2081 rte_cryptodev_asym_session_clear(dev_id, sess);
2082 rte_cryptodev_asym_session_free(sess);
2085 rte_crypto_op_free(op);
2090 test_ecdsa_sign_verify_all_curve(void)
2092 int status, overall_status = TEST_SUCCESS;
2093 enum curve curve_id;
2097 for (curve_id = SECP192R1; curve_id < END_OF_CURVE_LIST; curve_id++) {
2098 status = test_ecdsa_sign_verify(curve_id);
2099 if (status == TEST_SUCCESS) {
2103 overall_status = status;
2105 printf(" %u) TestCase Sign/Veriy Curve %s %s\n",
2106 test_index ++, curve[curve_id], msg);
2108 return overall_status;
2111 static struct unit_test_suite cryptodev_openssl_asym_testsuite = {
2112 .suite_name = "Crypto Device OPENSSL ASYM Unit Test Suite",
2113 .setup = testsuite_setup,
2114 .teardown = testsuite_teardown,
2115 .unit_test_cases = {
2116 TEST_CASE_ST(ut_setup, ut_teardown, test_capability),
2117 TEST_CASE_ST(ut_setup, ut_teardown, test_dsa),
2118 TEST_CASE_ST(ut_setup, ut_teardown, test_dh_keygenration),
2119 TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec),
2120 TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify),
2121 TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec_crt),
2122 TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify_crt),
2123 TEST_CASE_ST(ut_setup, ut_teardown, test_mod_inv),
2124 TEST_CASE_ST(ut_setup, ut_teardown, test_mod_exp),
2125 TEST_CASE_ST(ut_setup, ut_teardown, test_one_by_one),
2126 TEST_CASES_END() /**< NULL terminate unit test array */
2130 static struct unit_test_suite cryptodev_qat_asym_testsuite = {
2131 .suite_name = "Crypto Device QAT ASYM Unit Test Suite",
2132 .setup = testsuite_setup,
2133 .teardown = testsuite_teardown,
2134 .unit_test_cases = {
2135 TEST_CASE_ST(ut_setup, ut_teardown, test_one_by_one),
2136 TEST_CASES_END() /**< NULL terminate unit test array */
2140 static struct unit_test_suite cryptodev_octeontx_asym_testsuite = {
2141 .suite_name = "Crypto Device OCTEONTX ASYM Unit Test Suite",
2142 .setup = testsuite_setup,
2143 .teardown = testsuite_teardown,
2144 .unit_test_cases = {
2145 TEST_CASE_ST(ut_setup, ut_teardown, test_capability),
2146 TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_enc_dec_crt),
2147 TEST_CASE_ST(ut_setup, ut_teardown, test_rsa_sign_verify_crt),
2148 TEST_CASE_ST(ut_setup, ut_teardown, test_mod_exp),
2149 TEST_CASE_ST(ut_setup, ut_teardown,
2150 test_ecdsa_sign_verify_all_curve),
2151 TEST_CASES_END() /**< NULL terminate unit test array */
2156 test_cryptodev_openssl_asym(void)
2158 gbl_driver_id = rte_cryptodev_driver_id_get(
2159 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
2161 if (gbl_driver_id == -1) {
2162 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
2163 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
2164 "in config file to run this testsuite.\n");
2168 return unit_test_suite_runner(&cryptodev_openssl_asym_testsuite);
2172 test_cryptodev_qat_asym(void)
2174 gbl_driver_id = rte_cryptodev_driver_id_get(
2175 RTE_STR(CRYPTODEV_NAME_QAT_ASYM_PMD));
2177 if (gbl_driver_id == -1) {
2178 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
2179 "CONFIG_RTE_LIBRTE_PMD_QAT_ASYM is enabled "
2180 "in config file to run this testsuite.\n");
2184 return unit_test_suite_runner(&cryptodev_qat_asym_testsuite);
2188 test_cryptodev_octeontx_asym(void)
2190 gbl_driver_id = rte_cryptodev_driver_id_get(
2191 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
2192 if (gbl_driver_id == -1) {
2193 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
2194 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
2195 "enabled in config file to run this "
2199 return unit_test_suite_runner(&cryptodev_octeontx_asym_testsuite);
2203 test_cryptodev_octeontx2_asym(void)
2205 gbl_driver_id = rte_cryptodev_driver_id_get(
2206 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
2207 if (gbl_driver_id == -1) {
2208 RTE_LOG(ERR, USER1, "OCTEONTX2 PMD must be loaded. Check if "
2209 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
2210 "enabled in config file to run this "
2215 /* Use test suite registered for crypto_octeontx PMD */
2216 return unit_test_suite_runner(&cryptodev_octeontx_asym_testsuite);
2219 REGISTER_TEST_COMMAND(cryptodev_openssl_asym_autotest,
2220 test_cryptodev_openssl_asym);
2222 REGISTER_TEST_COMMAND(cryptodev_qat_asym_autotest, test_cryptodev_qat_asym);
2224 REGISTER_TEST_COMMAND(cryptodev_octeontx_asym_autotest,
2225 test_cryptodev_octeontx_asym);
2227 REGISTER_TEST_COMMAND(cryptodev_octeontx2_asym_autotest,
2228 test_cryptodev_octeontx2_asym);