MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_sm2_verify

Function test_sm2_verify

dpdk/app/test/test_cryptodev_asym.c:2754–2875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2752};
2753
2754static int
2755test_sm2_verify(void)
2756{
2757 struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
2758 struct crypto_testsuite_sm2_params input_params = sm2_param_fp256;
2759 const struct rte_cryptodev_asymmetric_xform_capability *capa;
2760 struct rte_mempool *sess_mpool = ts_params->session_mpool;
2761 struct rte_mempool *op_mpool = ts_params->op_mpool;
2762 struct rte_cryptodev_asym_capability_idx idx;
2763 uint8_t dev_id = ts_params->valid_devs[0];
2764 struct rte_crypto_op *result_op = NULL;
2765 struct rte_crypto_asym_xform xform;
2766 struct rte_crypto_asym_op *asym_op;
2767 struct rte_crypto_op *op = NULL;
2768 int ret, status = TEST_SUCCESS;
2769 void *sess = NULL;
2770
2771 /* Check SM2 capability */
2772 idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
2773 capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
2774 if (capa == NULL)
2775 return -ENOTSUP;
2776
2777 /* Setup crypto op data structure */
2778 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
2779 if (op == NULL) {
2780 RTE_LOG(ERR, USER1,
2781 "line %u FAILED: %s", __LINE__,
2782 "Failed to allocate asymmetric crypto "
2783 "operation struct\n");
2784 status = TEST_FAILED;
2785 goto exit;
2786 }
2787
2788 asym_op = op->asym;
2789
2790 /* Setup asym xform */
2791 xform.next = NULL;
2792 xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
2793 xform.ec.curve_id = input_params.curve;
2794 xform.ec.pkey.data = input_params.pkey.data;
2795 xform.ec.pkey.length = input_params.pkey.length;
2796 xform.ec.q.x.data = input_params.pubkey_qx.data;
2797 xform.ec.q.x.length = input_params.pubkey_qx.length;
2798 xform.ec.q.y.data = input_params.pubkey_qy.data;
2799 xform.ec.q.y.length = input_params.pubkey_qy.length;
2800
2801 ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
2802 if (ret < 0) {
2803 RTE_LOG(ERR, USER1,
2804 "line %u FAILED: %s", __LINE__,
2805 "Session creation failed\n");
2806 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
2807 goto exit;
2808 }
2809
2810 /* Attach asymmetric crypto session to crypto operations */
2811 rte_crypto_op_attach_asym_session(op, sess);

Callers

nothing calls this directly

Tested by

no test coverage detected