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

Function test_sm2_dec

dpdk/app/test/test_cryptodev_asym.c:3058–3181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3056};
3057
3058static int
3059test_sm2_dec(void)
3060{
3061 struct crypto_testsuite_params_asym *ts_params = &testsuite_params;
3062 struct crypto_testsuite_sm2_params input_params = sm2_param_fp256;
3063 const struct rte_cryptodev_asymmetric_xform_capability *capa;
3064 struct rte_mempool *sess_mpool = ts_params->session_mpool;
3065 struct rte_mempool *op_mpool = ts_params->op_mpool;
3066 struct rte_cryptodev_asym_capability_idx idx;
3067 uint8_t dev_id = ts_params->valid_devs[0];
3068 struct rte_crypto_op *result_op = NULL;
3069 uint8_t output_buf_m[TEST_DATA_SIZE];
3070 struct rte_crypto_asym_xform xform;
3071 struct rte_crypto_asym_op *asym_op;
3072 struct rte_crypto_op *op = NULL;
3073 int ret, status = TEST_SUCCESS;
3074 void *sess = NULL;
3075
3076 /* Check SM2 capability */
3077 idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
3078 capa = rte_cryptodev_asym_capability_get(dev_id, &idx);
3079 if (capa == NULL)
3080 return -ENOTSUP;
3081
3082 /* Setup crypto op data structure */
3083 op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
3084 if (op == NULL) {
3085 RTE_LOG(ERR, USER1,
3086 "line %u FAILED: %s", __LINE__,
3087 "Failed to allocate asymmetric crypto "
3088 "operation struct\n");
3089 status = TEST_FAILED;
3090 goto exit;
3091 }
3092 asym_op = op->asym;
3093
3094 /* Setup asym xform */
3095 xform.next = NULL;
3096 xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
3097 xform.ec.curve_id = input_params.curve;
3098 xform.ec.pkey.data = input_params.pkey.data;
3099 xform.ec.pkey.length = input_params.pkey.length;
3100 xform.ec.q.x.data = input_params.pubkey_qx.data;
3101 xform.ec.q.x.length = input_params.pubkey_qx.length;
3102 xform.ec.q.y.data = input_params.pubkey_qy.data;
3103 xform.ec.q.y.length = input_params.pubkey_qy.length;
3104
3105 ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);
3106 if (ret < 0) {
3107 RTE_LOG(ERR, USER1,
3108 "line %u FAILED: %s", __LINE__,
3109 "Session creation failed\n");
3110 status = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;
3111 goto exit;
3112 }
3113
3114 /* Attach asymmetric crypto session to crypto operations */
3115 rte_crypto_op_attach_asym_session(op, sess);

Callers

nothing calls this directly

Tested by

no test coverage detected