| 2875 | }; |
| 2876 | |
| 2877 | static int |
| 2878 | test_sm2_enc(void) |
| 2879 | { |
| 2880 | struct crypto_testsuite_params_asym *ts_params = &testsuite_params; |
| 2881 | struct crypto_testsuite_sm2_params input_params = sm2_param_fp256; |
| 2882 | const struct rte_cryptodev_asymmetric_xform_capability *capa; |
| 2883 | struct rte_mempool *sess_mpool = ts_params->session_mpool; |
| 2884 | struct rte_mempool *op_mpool = ts_params->op_mpool; |
| 2885 | uint8_t output_buf[TEST_DATA_SIZE], *pbuf = NULL; |
| 2886 | struct rte_cryptodev_asym_capability_idx idx; |
| 2887 | uint8_t dev_id = ts_params->valid_devs[0]; |
| 2888 | struct rte_crypto_op *result_op = NULL; |
| 2889 | struct rte_crypto_asym_xform xform; |
| 2890 | struct rte_crypto_asym_op *asym_op; |
| 2891 | struct rte_crypto_op *op = NULL; |
| 2892 | int ret, status = TEST_SUCCESS; |
| 2893 | void *sess = NULL; |
| 2894 | |
| 2895 | /* Check SM2 capability */ |
| 2896 | idx.type = RTE_CRYPTO_ASYM_XFORM_SM2; |
| 2897 | capa = rte_cryptodev_asym_capability_get(dev_id, &idx); |
| 2898 | if (capa == NULL) |
| 2899 | return -ENOTSUP; |
| 2900 | |
| 2901 | /* Setup crypto op data structure */ |
| 2902 | op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC); |
| 2903 | if (op == NULL) { |
| 2904 | RTE_LOG(ERR, USER1, |
| 2905 | "line %u FAILED: %s", __LINE__, |
| 2906 | "Failed to allocate asymmetric crypto " |
| 2907 | "operation struct\n"); |
| 2908 | status = TEST_FAILED; |
| 2909 | goto exit; |
| 2910 | } |
| 2911 | asym_op = op->asym; |
| 2912 | |
| 2913 | /* Setup asym xform */ |
| 2914 | xform.next = NULL; |
| 2915 | xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2; |
| 2916 | xform.ec.curve_id = input_params.curve; |
| 2917 | xform.ec.pkey.data = input_params.pkey.data; |
| 2918 | xform.ec.pkey.length = input_params.pkey.length; |
| 2919 | xform.ec.q.x.data = input_params.pubkey_qx.data; |
| 2920 | xform.ec.q.x.length = input_params.pubkey_qx.length; |
| 2921 | xform.ec.q.y.data = input_params.pubkey_qy.data; |
| 2922 | xform.ec.q.y.length = input_params.pubkey_qy.length; |
| 2923 | |
| 2924 | ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess); |
| 2925 | if (ret < 0) { |
| 2926 | RTE_LOG(ERR, USER1, |
| 2927 | "line %u FAILED: %s", __LINE__, |
| 2928 | "Session creation failed\n"); |
| 2929 | status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED; |
| 2930 | goto exit; |
| 2931 | } |
| 2932 | |
| 2933 | /* Attach asymmetric crypto session to crypto operations */ |
| 2934 | rte_crypto_op_attach_asym_session(op, sess); |
nothing calls this directly
no test coverage detected