get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/128026/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 128026,
    "url": "http://patchwork.dpdk.org/api/patches/128026/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/85371841f1285528d0f1c5952020d452243f8195.1685870993.git.gmuthukrishn@marvell.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<85371841f1285528d0f1c5952020d452243f8195.1685870993.git.gmuthukrishn@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/85371841f1285528d0f1c5952020d452243f8195.1685870993.git.gmuthukrishn@marvell.com",
    "date": "2023-06-04T09:42:45",
    "name": "[v3,2/3] test/crypto: add asymmetric SM2 test cases",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "452546406db6e58d5c1f94f29544a86831d04352",
    "submitter": {
        "id": 2301,
        "url": "http://patchwork.dpdk.org/api/people/2301/?format=api",
        "name": "Gowrishankar Muthukrishnan",
        "email": "gmuthukrishn@marvell.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patchwork.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/85371841f1285528d0f1c5952020d452243f8195.1685870993.git.gmuthukrishn@marvell.com/mbox/",
    "series": [
        {
            "id": 28335,
            "url": "http://patchwork.dpdk.org/api/series/28335/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=28335",
            "date": "2023-06-04T09:42:43",
            "name": "SM2 crypto algorithm support",
            "version": 3,
            "mbox": "http://patchwork.dpdk.org/series/28335/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/128026/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/128026/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id ED79442C26;\n\tSun,  4 Jun 2023 11:43:12 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 45DFE42D36;\n\tSun,  4 Jun 2023 11:43:03 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173])\n by mails.dpdk.org (Postfix) with ESMTP id E5F5B42D17\n for <dev@dpdk.org>; Sun,  4 Jun 2023 11:43:01 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 3548UJnt028683; Sun, 4 Jun 2023 02:43:01 -0700",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3r051k1vnh-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Sun, 04 Jun 2023 02:43:01 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Sun, 4 Jun 2023 02:42:59 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend\n Transport; Sun, 4 Jun 2023 02:42:59 -0700",
            "from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.175.191])\n by maili.marvell.com (Postfix) with ESMTP id 801413F70A5;\n Sun,  4 Jun 2023 02:42:56 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0220;\n bh=cyoGTaF/o2WCHENyuMY46QAHIV1JJnOEgMED2P492Ts=;\n b=VGQpLxKaHFkREu1EQ2RxPD+0TobJz5pDtXwN8JEOY/1lTp3VVMaD/1iyHSDVvSUtvrMh\n lCaXL7aLeS8re2aBPVaoMNjcO2ViwEXSFxEHUpxPpoWPbVAiXxR5reLbac46AiX/S1Os\n bQdUYlD/asURXMoU2St5lv8joQNXBYspsU9vduDyTIhIfXyv0ytOSSc+fVnAft6CvBJY\n u5A25e/mt3Vw2q/cMPD21xjBr1PmjaWgJYyG8sJ4C9x/mbyAnDpFr7JNfDRhlQsST12p\n xnWscq8wE0EqZh58pjcOdDP04FCgx3G2JWRWUlds4qkj/Es9S/4H5ZwLBf3K9dXPaFol bg==",
        "From": "Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<anoobj@marvell.com>, Akhil Goyal <gakhil@marvell.com>, Arkadiusz Kusztal\n <arkadiuszx.kusztal@intel.com>, Fan Zhang <fanzhang.oss@gmail.com>, Kai Ji\n <kai.ji@intel.com>, Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>",
        "Subject": "[PATCH v3 2/3] test/crypto: add asymmetric SM2 test cases",
        "Date": "Sun, 4 Jun 2023 15:12:45 +0530",
        "Message-ID": "\n <85371841f1285528d0f1c5952020d452243f8195.1685870993.git.gmuthukrishn@marvell.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<cover.1685870993.git.gmuthukrishn@marvell.com>",
        "References": "<cover.1685870993.git.gmuthukrishn@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "CN9wIfabgs0fy4x4yorVVRfLJ3JisoBG",
        "X-Proofpoint-ORIG-GUID": "CN9wIfabgs0fy4x4yorVVRfLJ3JisoBG",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26\n definitions=2023-06-03_08,2023-06-02_02,2023-05-22_02",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "Added test cases for asymmetric SM2 crypto validation.\nTest cases are added for sign/verify/encrypt/decrypt.\n\nSigned-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>\n---\n app/test/test_cryptodev_asym.c             | 581 +++++++++++++++++++++\n app/test/test_cryptodev_sm2_test_vectors.h | 129 +++++\n 2 files changed, 710 insertions(+)\n create mode 100644 app/test/test_cryptodev_sm2_test_vectors.h",
    "diff": "diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c\nindex 9236817650..baa8f89325 100644\n--- a/app/test/test_cryptodev_asym.c\n+++ b/app/test/test_cryptodev_asym.c\n@@ -21,6 +21,7 @@\n #include \"test_cryptodev_ecpm_test_vectors.h\"\n #include \"test_cryptodev_mod_test_vectors.h\"\n #include \"test_cryptodev_rsa_test_vectors.h\"\n+#include \"test_cryptodev_sm2_test_vectors.h\"\n #include \"test_cryptodev_asym_util.h\"\n #include \"test.h\"\n \n@@ -2196,6 +2197,582 @@ test_ecpm_all_curve(void)\n \treturn overall_status;\n }\n \n+static int\n+_test_sm2_sign(bool rnd_secret)\n+{\n+\tstruct crypto_testsuite_params_asym *ts_params = &testsuite_params;\n+\tstruct crypto_testsuite_sm2_params input_params = sm2_param_fp256;\n+\tstruct rte_mempool *sess_mpool = ts_params->session_mpool;\n+\tstruct rte_mempool *op_mpool = ts_params->op_mpool;\n+\tuint8_t dev_id = ts_params->valid_devs[0];\n+\tstruct rte_crypto_op *result_op = NULL;\n+\tuint8_t output_buf_r[TEST_DATA_SIZE];\n+\tuint8_t output_buf_s[TEST_DATA_SIZE];\n+\tstruct rte_crypto_asym_xform xform;\n+\tstruct rte_crypto_asym_op *asym_op;\n+\tstruct rte_crypto_op *op = NULL;\n+\tint ret, status = TEST_SUCCESS;\n+\tvoid *sess = NULL;\n+\n+\t/* Setup crypto op data structure */\n+\top = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);\n+\tif (op == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to allocate asymmetric crypto \"\n+\t\t\t\t\"operation struct\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tasym_op = op->asym;\n+\n+\t/* Setup asym xform */\n+\txform.next = NULL;\n+\txform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;\n+\txform.sm2.hash = RTE_CRYPTO_AUTH_SM3;\n+\n+\tret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Session creation failed\\n\");\n+\t\tstatus = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\t/* Attach asymmetric crypto session to crypto operations */\n+\trte_crypto_op_attach_asym_session(op, sess);\n+\n+\t/* Compute sign */\n+\n+\t/* Populate op with operational details */\n+\tasym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_SIGN;\n+\tasym_op->sm2.message.data = input_params.message.data;\n+\tasym_op->sm2.message.length = input_params.message.length;\n+\tasym_op->sm2.pkey.data = input_params.pkey.data;\n+\tasym_op->sm2.pkey.length = input_params.pkey.length;\n+\tasym_op->sm2.q.x.data = input_params.pubkey_qx.data;\n+\tasym_op->sm2.q.x.length = input_params.pubkey_qx.length;\n+\tasym_op->sm2.q.y.data = input_params.pubkey_qy.data;\n+\tasym_op->sm2.q.y.length = input_params.pubkey_qy.length;\n+\tasym_op->sm2.id.data = input_params.id.data;\n+\tasym_op->sm2.id.length = input_params.id.length;\n+\tif (rnd_secret) {\n+\t\tasym_op->sm2.k.data = NULL;\n+\t\tasym_op->sm2.k.length = 0;\n+\t} else {\n+\t\tasym_op->sm2.k.data = input_params.k.data;\n+\t\tasym_op->sm2.k.length = input_params.k.length;\n+\t}\n+\n+\t/* Init out buf */\n+\tasym_op->sm2.r.data = output_buf_r;\n+\tasym_op->sm2.s.data = output_buf_s;\n+\n+\tRTE_LOG(DEBUG, USER1, \"Process ASYM operation\\n\");\n+\n+\t/* Process crypto operation */\n+\tif (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Error sending packet for operation\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\twhile (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)\n+\t\trte_pause();\n+\n+\tif (result_op == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to process asym crypto op\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tif (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to process asym crypto op\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tasym_op = result_op->asym;\n+\n+\tdebug_hexdump(stdout, \"r:\",\n+\t\t\tasym_op->sm2.r.data, asym_op->sm2.r.length);\n+\tdebug_hexdump(stdout, \"s:\",\n+\t\t\tasym_op->sm2.s.data, asym_op->sm2.s.length);\n+\n+\tif (!rnd_secret) {\n+\t\t/* Verify sign (by comparison). */\n+\t\tif (memcmp(input_params.sign_r.data, asym_op->sm2.r.data,\n+\t\t\t\t   asym_op->sm2.r.length) != 0) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\t\"SM2 sign failed.\\n\");\n+\t\t\tgoto exit;\n+\t\t}\n+\t\tif (memcmp(input_params.sign_s.data, asym_op->sm2.s.data,\n+\t\t\t\t   asym_op->sm2.s.length) != 0) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\t\"SM2 sign failed.\\n\");\n+\t\t\tgoto exit;\n+\t\t}\n+\t} else {\n+\t\t/* Verify sign (in roundtrip).\n+\t\t * Due to random number used per message, sign op\n+\t\t * would produce different output for same message\n+\t\t * every time. Hence, we can't have expected output\n+\t\t * to match, instead reverse op to verify.\n+\t\t */\n+\n+\t\t/* Populate op with operational details */\n+\t\tasym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;\n+\n+\t\t/* Enqueue sign result for verify */\n+\t\tif (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\t\"Error sending packet for operation\\n\");\n+\t\t\tgoto exit;\n+\t\t}\n+\n+\t\twhile (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)\n+\t\t\trte_pause();\n+\n+\t\tif (result_op == NULL) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tgoto exit;\n+\t\t}\n+\t\tif (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\t\"SM2 verify failed.\\n\");\n+\t\t\tgoto exit;\n+\t\t}\n+\t}\n+\n+exit:\n+\tif (sess != NULL)\n+\t\trte_cryptodev_asym_session_free(dev_id, sess);\n+\trte_crypto_op_free(op);\n+\treturn status;\n+};\n+\n+static int\n+test_sm2_sign_rnd_secret(void)\n+{\n+\treturn _test_sm2_sign(true);\n+}\n+\n+__rte_used static int\n+test_sm2_sign_plain_secret(void)\n+{\n+\treturn _test_sm2_sign(false);\n+}\n+\n+static int\n+test_sm2_verify(void)\n+{\n+\tstruct crypto_testsuite_params_asym *ts_params = &testsuite_params;\n+\tstruct crypto_testsuite_sm2_params input_params = sm2_param_fp256;\n+\tstruct rte_mempool *sess_mpool = ts_params->session_mpool;\n+\tstruct rte_mempool *op_mpool = ts_params->op_mpool;\n+\tuint8_t dev_id = ts_params->valid_devs[0];\n+\tstruct rte_crypto_op *result_op = NULL;\n+\tstruct rte_crypto_asym_xform xform;\n+\tstruct rte_crypto_asym_op *asym_op;\n+\tstruct rte_crypto_op *op = NULL;\n+\tint ret, status = TEST_SUCCESS;\n+\tvoid *sess = NULL;\n+\n+\t/* Setup crypto op data structure */\n+\top = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);\n+\tif (op == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to allocate asymmetric crypto \"\n+\t\t\t\t\"operation struct\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tasym_op = op->asym;\n+\n+\t/* Setup asym xform */\n+\txform.next = NULL;\n+\txform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;\n+\txform.sm2.hash = RTE_CRYPTO_AUTH_SM3;\n+\n+\tret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Session creation failed\\n\");\n+\t\tstatus = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\t/* Attach asymmetric crypto session to crypto operations */\n+\trte_crypto_op_attach_asym_session(op, sess);\n+\n+\t/* Verify given sign */\n+\n+\t/* Populate op with operational details */\n+\tasym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;\n+\tasym_op->sm2.message.data = input_params.message.data;\n+\tasym_op->sm2.message.length = input_params.message.length;\n+\tasym_op->sm2.pkey.data = input_params.pkey.data;\n+\tasym_op->sm2.pkey.length = input_params.pkey.length;\n+\tasym_op->sm2.q.x.data = input_params.pubkey_qx.data;\n+\tasym_op->sm2.q.x.length = input_params.pubkey_qx.length;\n+\tasym_op->sm2.q.y.data = input_params.pubkey_qy.data;\n+\tasym_op->sm2.q.y.length = input_params.pubkey_qy.length;\n+\tasym_op->sm2.r.data = input_params.sign_r.data;\n+\tasym_op->sm2.r.length = input_params.sign_r.length;\n+\tasym_op->sm2.s.data = input_params.sign_s.data;\n+\tasym_op->sm2.s.length = input_params.sign_s.length;\n+\tasym_op->sm2.id.data = input_params.id.data;\n+\tasym_op->sm2.id.length = input_params.id.length;\n+\n+\tRTE_LOG(DEBUG, USER1, \"Process ASYM operation\\n\");\n+\n+\t/* Process crypto operation */\n+\tif (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Error sending packet for operation\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\twhile (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)\n+\t\trte_pause();\n+\n+\tif (result_op == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to process asym crypto op\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tif (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to process asym crypto op\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+exit:\n+\tif (sess != NULL)\n+\t\trte_cryptodev_asym_session_free(dev_id, sess);\n+\trte_crypto_op_free(op);\n+\treturn status;\n+};\n+\n+static int\n+_test_sm2_enc(bool rnd_secret)\n+{\n+\tstruct crypto_testsuite_params_asym *ts_params = &testsuite_params;\n+\tstruct crypto_testsuite_sm2_params input_params = sm2_param_fp256;\n+\tstruct rte_mempool *sess_mpool = ts_params->session_mpool;\n+\tstruct rte_mempool *op_mpool = ts_params->op_mpool;\n+\tuint8_t output_buf[TEST_DATA_SIZE], *pbuf = NULL;\n+\tuint8_t dev_id = ts_params->valid_devs[0];\n+\tstruct rte_crypto_op *result_op = NULL;\n+\tstruct rte_crypto_asym_xform xform;\n+\tstruct rte_crypto_asym_op *asym_op;\n+\tstruct rte_crypto_op *op = NULL;\n+\tint ret, status = TEST_SUCCESS;\n+\tvoid *sess = NULL;\n+\n+\t/* Setup crypto op data structure */\n+\top = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);\n+\tif (op == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to allocate asymmetric crypto \"\n+\t\t\t\t\"operation struct\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\tasym_op = op->asym;\n+\n+\t/* Setup asym xform */\n+\txform.next = NULL;\n+\txform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;\n+\txform.sm2.hash = RTE_CRYPTO_AUTH_SM3;\n+\n+\tret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Session creation failed\\n\");\n+\t\tstatus = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\t/* Attach asymmetric crypto session to crypto operations */\n+\trte_crypto_op_attach_asym_session(op, sess);\n+\n+\t/* Compute encrypt */\n+\n+\t/* Populate op with operational details */\n+\tasym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;\n+\tasym_op->sm2.message.data = input_params.message.data;\n+\tasym_op->sm2.message.length = input_params.message.length;\n+\tasym_op->sm2.pkey.data = input_params.pkey.data;\n+\tasym_op->sm2.pkey.length = input_params.pkey.length;\n+\tasym_op->sm2.q.x.data = input_params.pubkey_qx.data;\n+\tasym_op->sm2.q.x.length = input_params.pubkey_qx.length;\n+\tasym_op->sm2.q.y.data = input_params.pubkey_qy.data;\n+\tasym_op->sm2.q.y.length = input_params.pubkey_qy.length;\n+\tif (rnd_secret) {\n+\t\tasym_op->sm2.k.data = NULL;\n+\t\tasym_op->sm2.k.length = 0;\n+\t} else {\n+\t\tasym_op->sm2.k.data = input_params.k.data;\n+\t\tasym_op->sm2.k.length = input_params.k.length;\n+\t}\n+\n+\t/* Init out buf */\n+\tasym_op->sm2.cipher.data = output_buf;\n+\n+\tRTE_LOG(DEBUG, USER1, \"Process ASYM operation\\n\");\n+\n+\t/* Process crypto operation */\n+\tif (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Error sending packet for operation\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\twhile (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)\n+\t\trte_pause();\n+\n+\tif (result_op == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to process asym crypto op\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tif (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to process asym crypto op\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tasym_op = result_op->asym;\n+\n+\tdebug_hexdump(stdout, \"cipher:\",\n+\t\t\tasym_op->sm2.cipher.data, asym_op->sm2.cipher.length);\n+\n+\tif (!rnd_secret) {\n+\t\tif (memcmp(input_params.cipher.data, asym_op->sm2.cipher.data,\n+\t\t\t\t   asym_op->sm2.cipher.length) != 0) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tRTE_LOG(ERR, USER1, \"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\t\"SM2 encrypt failed.\\n\");\n+\t\t\tgoto exit;\n+\t\t}\n+\t} else {\n+\t\t/* Verify cipher (in roundtrip).\n+\t\t * Due to random number used per message, encrypt op\n+\t\t * would produce different output for same message\n+\t\t * every time. Hence, we can't have expected output\n+\t\t * to match, instead reverse op to decrypt.\n+\t\t */\n+\n+\t\t/* Populate op with operational details */\n+\t\top->asym->sm2.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;\n+\t\tpbuf = rte_malloc(NULL, TEST_DATA_SIZE, 0);\n+\t\top->asym->sm2.message.data = pbuf;\n+\t\top->asym->sm2.message.length = TEST_DATA_SIZE;\n+\n+\t\t/* Enqueue cipher result for decrypt */\n+\t\tif (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\t\"Error sending packet for operation\\n\");\n+\t\t\tgoto exit;\n+\t\t}\n+\n+\t\twhile (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)\n+\t\t\trte_pause();\n+\n+\t\tif (result_op == NULL) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tgoto exit;\n+\t\t}\n+\t\tif (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\t\"SM2 encrypt failed.\\n\");\n+\t\t\tgoto exit;\n+\t\t}\n+\n+\t\tasym_op = result_op->asym;\n+\t\tif (memcmp(input_params.message.data, asym_op->sm2.message.data,\n+\t\t\t       asym_op->sm2.message.length) != 0) {\n+\t\t\tstatus = TEST_FAILED;\n+\t\t\tRTE_LOG(ERR, USER1, \"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\t\"SM2 encrypt failed.\\n\");\n+\t\t\tgoto exit;\n+\t\t}\n+\t}\n+exit:\n+\tif (pbuf != NULL)\n+\t\trte_free(pbuf);\n+\n+\tif (sess != NULL)\n+\t\trte_cryptodev_asym_session_free(dev_id, sess);\n+\trte_crypto_op_free(op);\n+\treturn status;\n+};\n+\n+static int\n+test_sm2_enc_rnd_secret(void)\n+{\n+\treturn _test_sm2_enc(true);\n+}\n+\n+__rte_used static int\n+test_sm2_enc_plain_secret(void)\n+{\n+\treturn _test_sm2_enc(false);\n+}\n+\n+static int\n+test_sm2_dec(void)\n+{\n+\tstruct crypto_testsuite_params_asym *ts_params = &testsuite_params;\n+\tstruct crypto_testsuite_sm2_params input_params = sm2_param_fp256;\n+\tstruct rte_mempool *sess_mpool = ts_params->session_mpool;\n+\tstruct rte_mempool *op_mpool = ts_params->op_mpool;\n+\tuint8_t dev_id = ts_params->valid_devs[0];\n+\tstruct rte_crypto_op *result_op = NULL;\n+\tuint8_t output_buf_m[TEST_DATA_SIZE];\n+\tstruct rte_crypto_asym_xform xform;\n+\tstruct rte_crypto_asym_op *asym_op;\n+\tstruct rte_crypto_op *op = NULL;\n+\tint ret, status = TEST_SUCCESS;\n+\tvoid *sess = NULL;\n+\n+\t/* Setup crypto op data structure */\n+\top = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);\n+\tif (op == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to allocate asymmetric crypto \"\n+\t\t\t\t\"operation struct\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\tasym_op = op->asym;\n+\n+\t/* Setup asym xform */\n+\txform.next = NULL;\n+\txform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;\n+\txform.sm2.hash = RTE_CRYPTO_AUTH_SM3;\n+\n+\tret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mpool, &sess);\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Session creation failed\\n\");\n+\t\tstatus = (ret == -ENOTSUP) ? TEST_SKIPPED : TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\t/* Attach asymmetric crypto session to crypto operations */\n+\trte_crypto_op_attach_asym_session(op, sess);\n+\n+\t/* Compute decrypt */\n+\n+\t/* Populate op with operational details */\n+\tasym_op->sm2.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;\n+\tasym_op->sm2.cipher.data = input_params.cipher.data;\n+\tasym_op->sm2.cipher.length = input_params.cipher.length;\n+\tasym_op->sm2.pkey.data = input_params.pkey.data;\n+\tasym_op->sm2.pkey.length = input_params.pkey.length;\n+\tasym_op->sm2.q.x.data = input_params.pubkey_qx.data;\n+\tasym_op->sm2.q.x.length = input_params.pubkey_qx.length;\n+\tasym_op->sm2.q.y.data = input_params.pubkey_qy.data;\n+\tasym_op->sm2.q.y.length = input_params.pubkey_qy.length;\n+\n+\t/* Init out buf */\n+\tasym_op->sm2.message.data = output_buf_m;\n+\tasym_op->sm2.message.length = RTE_DIM(output_buf_m);\n+\n+\tRTE_LOG(DEBUG, USER1, \"Process ASYM operation\\n\");\n+\n+\t/* Process crypto operation */\n+\tif (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Error sending packet for operation\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\twhile (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)\n+\t\trte_pause();\n+\n+\tif (result_op == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to process asym crypto op\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tif (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"Failed to process asym crypto op\\n\");\n+\t\tstatus = TEST_FAILED;\n+\t\tgoto exit;\n+\t}\n+\n+\tasym_op = result_op->asym;\n+\n+\tdebug_hexdump(stdout, \"message:\",\n+\t\t\tasym_op->sm2.message.data, asym_op->sm2.message.length);\n+\n+\tif (memcmp(input_params.message.data, asym_op->sm2.message.data,\n+\t\t\top->asym->sm2.message.length)) {\n+\t\tstatus = TEST_FAILED;\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"line %u FAILED: %s\", __LINE__,\n+\t\t\t\t\"SM2 decrypt failed.\\n\");\n+\t\tgoto exit;\n+\t}\n+exit:\n+\tif (sess != NULL)\n+\t\trte_cryptodev_asym_session_free(dev_id, sess);\n+\trte_crypto_op_free(op);\n+\treturn status;\n+};\n+\n static struct unit_test_suite cryptodev_openssl_asym_testsuite  = {\n \t.suite_name = \"Crypto Device OPENSSL ASYM Unit Test Suite\",\n \t.setup = testsuite_setup,\n@@ -2205,6 +2782,10 @@ static struct unit_test_suite cryptodev_openssl_asym_testsuite  = {\n \t\tTEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_dsa),\n \t\tTEST_CASE_ST(ut_setup_asym, ut_teardown_asym,\n \t\t\t\ttest_dh_keygenration),\n+\t\tTEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_sm2_sign_rnd_secret),\n+\t\tTEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_sm2_verify),\n+\t\tTEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_sm2_enc_rnd_secret),\n+\t\tTEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_sm2_dec),\n \t\tTEST_CASE_ST(ut_setup_asym, ut_teardown_asym, test_rsa_enc_dec),\n \t\tTEST_CASE_ST(ut_setup_asym, ut_teardown_asym,\n \t\t\t\ttest_rsa_sign_verify),\ndiff --git a/app/test/test_cryptodev_sm2_test_vectors.h b/app/test/test_cryptodev_sm2_test_vectors.h\nnew file mode 100644\nindex 0000000000..7a4ce70c10\n--- /dev/null\n+++ b/app/test/test_cryptodev_sm2_test_vectors.h\n@@ -0,0 +1,129 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#ifndef __TEST_CRYPTODEV_SM2_TEST_VECTORS_H__\n+#define __TEST_CRYPTODEV_SM2_TEST_VECTORS_H__\n+\n+#include \"rte_crypto_asym.h\"\n+\n+struct crypto_testsuite_sm2_params {\n+\trte_crypto_param pubkey_qx;\n+\trte_crypto_param pubkey_qy;\n+\trte_crypto_param pkey;\n+\trte_crypto_param k;\n+\trte_crypto_param sign_r;\n+\trte_crypto_param sign_s;\n+\trte_crypto_param id;\n+\trte_crypto_param cipher;\n+\trte_crypto_param message;\n+};\n+\n+static uint8_t fp256_pkey[] = {\n+\t0x77, 0x84, 0x35, 0x65, 0x4c, 0x7a, 0x6d, 0xb1,\n+\t0x1e, 0x63, 0x0b, 0x41, 0x97, 0x36, 0x04, 0xf4,\n+\t0xec, 0x35, 0xee, 0x3b, 0x76, 0xc2, 0x34, 0x08,\n+\t0xd9, 0x4a, 0x22, 0x0d, 0x7f, 0xf6, 0xc6, 0x90\n+};\n+\n+static uint8_t fp256_qx[] = {\n+\t0x7b, 0x24, 0xa3, 0x03, 0xcf, 0xb2, 0x22, 0xfa,\n+\t0x4c, 0xb3, 0x88, 0x54, 0xf9, 0x30, 0xd1, 0x4d,\n+\t0xe3, 0x50, 0xda, 0xba, 0xe6, 0xa7, 0x0b, 0x91,\n+\t0x4c, 0x04, 0x0d, 0x5c, 0xe0, 0x8e, 0x86, 0xc5\n+};\n+\n+static uint8_t fp256_qy[] = {\n+\t0xbc, 0x39, 0xe3, 0x19, 0x4e, 0xd2, 0x29, 0x22,\n+\t0x5b, 0x37, 0x2d, 0xeb, 0xcc, 0x05, 0x52, 0x8d,\n+\t0xb9, 0x40, 0xa3, 0xab, 0x3c, 0xbe, 0x16, 0x30,\n+\t0x1c, 0xe4, 0xe8, 0x7f, 0xba, 0x6e, 0x0b, 0xae\n+};\n+\n+static uint8_t fp256_k[] = {\n+\t0x01, 0x04, 0x02, 0x05, 0x04, 0x06, 0x03, 0x07\n+};\n+\n+static uint8_t fp256_sign_r[] = {\n+\t0xf3, 0x26, 0x10, 0xde, 0xfb, 0xbf, 0x13, 0xd4,\n+\t0x73, 0xb1, 0xc2, 0x80, 0x51, 0x06, 0x29, 0xf9,\n+\t0xfb, 0xc8, 0x11, 0xa7, 0x8d, 0x2c, 0xcb, 0x09,\n+\t0x7c, 0xb2, 0xcf, 0x58, 0x0b, 0x5e, 0x25, 0xff\n+};\n+\n+static uint8_t fp256_sign_s[] = {\n+\t0x8d, 0x8d, 0xb5, 0x40, 0xe3, 0xfb, 0x98, 0xf9,\n+\t0x8c, 0xe4, 0x58, 0x60, 0xf2, 0x78, 0x8f, 0xd9,\n+\t0xbf, 0xb8, 0x47, 0x73, 0x88, 0xc1, 0xd1, 0xcd,\n+\t0x2d, 0xdb, 0xe3, 0xc1, 0x44, 0x30, 0x25, 0x86\n+};\n+\n+static uint8_t fp256_id[] = {\n+\t0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8\n+};\n+\n+static uint8_t fp256_message[] = {\n+\t0x6D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20,\n+\t0x64, 0x69, 0x67, 0x65, 0x73, 0x74\n+};\n+\n+static uint8_t fp256_cipher[] = {\n+\t0x30, 0x78, 0x02, 0x21, 0x00, 0xAB, 0xBD, 0xE8,\n+\t0xE8, 0x80, 0x93, 0x36, 0x77, 0xB6, 0x44, 0x47,\n+\t0x6D, 0x00, 0xF6, 0x51, 0xC8, 0x80, 0x9C, 0x9E,\n+\t0xD9, 0xEC, 0x36, 0x8A, 0x60, 0x8E, 0x26, 0x2D,\n+\t0x71, 0x31, 0xB7, 0xC1, 0x38, 0x02, 0x21, 0x00,\n+\t0xE1, 0xBF, 0x4C, 0x13, 0x7A, 0x87, 0x40, 0x32,\n+\t0xF5, 0xA1, 0xE2, 0xA1, 0x3B, 0x83, 0xBF, 0x6B,\n+\t0x3F, 0xFB, 0xC8, 0x13, 0x01, 0xDE, 0xCF, 0xC0,\n+\t0xF4, 0x24, 0x66, 0x52, 0x89, 0xDA, 0x6D, 0x7A,\n+\t0x04, 0x20, 0x8E, 0xFD, 0x52, 0x77, 0xC9, 0xE7,\n+\t0x90, 0xD1, 0x17, 0x75, 0xDE, 0xEE, 0xF3, 0xE5,\n+\t0x11, 0x0C, 0x5D, 0xE1, 0x3A, 0xB6, 0x2B, 0x72,\n+\t0x60, 0xE5, 0xD5, 0xF3, 0x0F, 0xE2, 0x44, 0xDB,\n+\t0xBC, 0x66, 0x04, 0x0E, 0x78, 0x2D, 0xC0, 0x3D,\n+\t0x38, 0xA2, 0x42, 0xA4, 0x8E, 0x8B, 0xF5, 0x06,\n+\t0x32, 0xFA\n+};\n+\n+/** SM2 Fp256 elliptic curve test params */\n+struct crypto_testsuite_sm2_params sm2_param_fp256 = {\n+\t.pubkey_qx = {\n+\t\t.data = fp256_qx,\n+\t\t.length = sizeof(fp256_qx),\n+\t},\n+\t.pubkey_qy = {\n+\t\t.data = fp256_qy,\n+\t\t.length = sizeof(fp256_qy),\n+\t},\n+\t.k = {\n+\t\t.data = fp256_k,\n+\t\t.length = sizeof(fp256_k),\n+\t},\n+\t.sign_r = {\n+\t\t.data = fp256_sign_r,\n+\t\t.length = sizeof(fp256_sign_r),\n+\t},\n+\t.sign_s = {\n+\t\t.data = fp256_sign_s,\n+\t\t.length = sizeof(fp256_sign_s),\n+\t},\n+\t.id = {\n+\t\t.data = fp256_id,\n+\t\t.length = sizeof(fp256_id),\n+\t},\n+\t.pkey = {\n+\t\t.data = fp256_pkey,\n+\t\t.length = sizeof(fp256_pkey),\n+\t},\n+\t.message = {\n+\t\t.data = fp256_message,\n+\t\t.length = sizeof(fp256_message),\n+\t},\n+\t.cipher = {\n+\t\t.data = fp256_cipher,\n+\t\t.length = sizeof(fp256_cipher),\n+\t}\n+};\n+\n+#endif /* __TEST_CRYPTODEV_SM2_TEST_VECTORS_H__ */\n",
    "prefixes": [
        "v3",
        "2/3"
    ]
}