From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4DE70A04A5; Wed, 9 Feb 2022 15:01:09 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D54BD41C2E; Wed, 9 Feb 2022 15:00:55 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 8D6E8411E6 for ; Wed, 9 Feb 2022 15:00:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644415253; x=1675951253; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=mEPTSYXnRGKX3ZOkJzHTRnQTZIR9cgVOj8F0VUTC6P4=; b=E63a7X7gX5t/3dSOnOsaX1B9dOOWUe+NSAWiNYi2/aaT73P4UHe7l7dX krRopceASyOrzS0XHiPAf5r1RxDW0uCJW5+bBUYuDr6W5kurbWY9yskJ1 ninhsV1PByruPia3Hl7FEuVB6BAm+LPIUo8jgGdRz0dIw0VR6Mxoqfkrw DPOdhqjDIfsfIs9jI+PMenGWrOAy7McU3xlr+z9KadEorpHKj5XycLtmV 0SnuJ70FANQLXQa15VAeXIcmBCNPxUnsdisF8+PJxHo0dvb1vYQryUNM3 74GUaL6CEFjnrqf8/KqCIAbgOqSf+yDWGQF2Z247UQIm7IPjxTEv/z0qD w==; X-IronPort-AV: E=McAfee;i="6200,9189,10252"; a="249157374" X-IronPort-AV: E=Sophos;i="5.88,355,1635231600"; d="scan'208";a="249157374" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 06:00:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,355,1635231600"; d="scan'208";a="525996070" Received: from silpixa00400308.ir.intel.com ([10.237.214.95]) by orsmga007.jf.intel.com with ESMTP; 09 Feb 2022 06:00:49 -0800 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, roy.fan.zhang@intel.com, Arek Kusztal Subject: [PATCH v2 4/5] crypto/qat: add ecpm algorithm Date: Wed, 9 Feb 2022 14:00:19 +0000 Message-Id: <20220209140020.19365-5-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209140020.19365-1-arkadiuszx.kusztal@intel.com> References: <20220209140020.19365-1-arkadiuszx.kusztal@intel.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch adds Elliptic Curve Multiplication algorithm to Intel QuickAssist Technology PMD. Signed-off-by: Arek Kusztal --- doc/guides/cryptodevs/qat.rst | 1 + doc/guides/rel_notes/release_22_03.rst | 5 ++ drivers/common/qat/qat_adf/qat_pke.h | 20 ++++++++ drivers/crypto/qat/qat_asym.c | 85 +++++++++++++++++++++++++++++++++- drivers/crypto/qat/qat_asym.h | 2 + 5 files changed, 112 insertions(+), 1 deletion(-) diff --git a/doc/guides/cryptodevs/qat.rst b/doc/guides/cryptodevs/qat.rst index 0f8fecf4df..c93606afea 100644 --- a/doc/guides/cryptodevs/qat.rst +++ b/doc/guides/cryptodevs/qat.rst @@ -176,6 +176,7 @@ The QAT ASYM PMD has support for: * ``RTE_CRYPTO_ASYM_XFORM_MODINV`` * ``RTE_CRYPTO_ASYM_XFORM_RSA`` * ``RTE_CRYPTO_ASYM_XFORM_ECDSA`` +* ``RTE_CRYPTO_ASYM_XFORM_ECPM`` Limitations ~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_22_03.rst b/doc/guides/rel_notes/release_22_03.rst index 1d7e0c1425..a1d0769320 100644 --- a/doc/guides/rel_notes/release_22_03.rst +++ b/doc/guides/rel_notes/release_22_03.rst @@ -78,6 +78,11 @@ New Features * ECDSA algorithm is now supported by Intel QuickAssist Technology asymmetric crypto PMD. +* **Updated Intel QuickAssist Technology asymmetric crypto PMD.** + + * ECPM algorithm is now supported by Intel QuickAssist + Technology asymmetric crypto PMD. + Removed Items ------------- diff --git a/drivers/common/qat/qat_adf/qat_pke.h b/drivers/common/qat/qat_adf/qat_pke.h index 1fe5f6bd8e..092fc373de 100644 --- a/drivers/common/qat/qat_adf/qat_pke.h +++ b/drivers/common/qat/qat_adf/qat_pke.h @@ -252,4 +252,24 @@ get_ecdsa_function(struct rte_crypto_asym_xform *xform) return qat_function; } +static struct qat_asym_function +get_ecpm_function(struct rte_crypto_asym_xform *xform) +{ + struct qat_asym_function qat_function; + + switch (xform->ec.curve_id) { + case RTE_CRYPTO_EC_GROUP_SECP256R1: + qat_function.func_id = MATHS_POINT_MULTIPLICATION_GFP_L256; + qat_function.bytesize = 32; + break; + case RTE_CRYPTO_EC_GROUP_SECP521R1: + qat_function.func_id = MATHS_POINT_MULTIPLICATION_GFP_521; + qat_function.bytesize = 66; + break; + default: + qat_function.func_id = 0; + } + return qat_function; +} + #endif diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c index 59e7c5140c..444c702572 100644 --- a/drivers/crypto/qat/qat_asym.c +++ b/drivers/crypto/qat/qat_asym.c @@ -62,7 +62,7 @@ what.length) #define SET_PKE_LN_EC(where, what, how, idx) \ - rte_memcpy(&where[idx * RTE_ALIGN_CEIL(how, 8)] + \ + rte_memcpy(where[idx] + \ RTE_ALIGN_CEIL(how, 8) - \ how, \ what.data, \ @@ -668,6 +668,84 @@ ecdsa_collect(struct rte_crypto_asym_op *asym_op, } static int +ecpm_set_input(struct rte_crypto_asym_op *asym_op, + struct icp_qat_fw_pke_request *qat_req, + struct qat_asym_op_cookie *cookie, + struct rte_crypto_asym_xform *xform) +{ + struct qat_asym_function qat_function; + uint32_t alg_bytesize, __rte_unused qat_alg_bytesize, func_id; + int curve_id; + + curve_id = pick_curve(xform); + if (curve_id < 0) { + QAT_LOG(ERR, "Incorrect elliptic curve"); + return -EINVAL; + } + + qat_function = get_ecpm_function(xform); + func_id = qat_function.func_id; + if (func_id == 0) { + QAT_LOG(ERR, "Cannot obtain functionality id"); + return -EINVAL; + } + alg_bytesize = qat_function.bytesize; + qat_alg_bytesize = RTE_ALIGN_CEIL(alg_bytesize, 8); + + SET_PKE_LN(cookie->input_array, asym_op->ecpm.scalar, + alg_bytesize, 0); + SET_PKE_LN(cookie->input_array, asym_op->ecpm.p.x, + alg_bytesize, 1); + SET_PKE_LN(cookie->input_array, asym_op->ecpm.p.y, + alg_bytesize, 2); + SET_PKE_LN_EC(cookie->input_array, curve[SECP256R1].a, + alg_bytesize, 3); + SET_PKE_LN_EC(cookie->input_array, curve[SECP256R1].b, + alg_bytesize, 4); + SET_PKE_LN_EC(cookie->input_array, curve[SECP256R1].p, + alg_bytesize, 5); + SET_PKE_LN_EC(cookie->input_array, curve[SECP256R1].h, + alg_bytesize, 6); + + cookie->alg_bytesize = alg_bytesize; + qat_req->pke_hdr.cd_pars.func_id = func_id; + qat_req->input_param_count = + QAT_ASYM_ECPM_IN_PARAMS; + qat_req->output_param_count = + QAT_ASYM_ECPM_OUT_PARAMS; + + HEXDUMP("k", cookie->input_array[0], qat_alg_bytesize); + HEXDUMP("xG", cookie->input_array[1], qat_alg_bytesize); + HEXDUMP("yG", cookie->input_array[2], qat_alg_bytesize); + HEXDUMP("a", cookie->input_array[3], qat_alg_bytesize); + HEXDUMP("b", cookie->input_array[4], qat_alg_bytesize); + HEXDUMP("q", cookie->input_array[5], qat_alg_bytesize); + HEXDUMP("h", cookie->input_array[6], qat_alg_bytesize); + + return 0; +} + +static uint8_t +ecpm_collect(struct rte_crypto_asym_op *asym_op, + struct qat_asym_op_cookie *cookie) +{ + uint8_t *r = asym_op->ecpm.r.x.data; + uint8_t *s = asym_op->ecpm.r.y.data; + uint32_t alg_bytesize = cookie->alg_bytesize; + + asym_op->ecpm.r.x.length = alg_bytesize; + asym_op->ecpm.r.y.length = alg_bytesize; + rte_memcpy(r, cookie->output_array[0], alg_bytesize); + rte_memcpy(s, cookie->output_array[1], alg_bytesize); + + HEXDUMP("rX", cookie->output_array[0], + alg_bytesize); + HEXDUMP("rY", cookie->output_array[1], + alg_bytesize); + return RTE_CRYPTO_OP_STATUS_SUCCESS; +} + +static int asym_set_input(struct rte_crypto_asym_op *asym_op, struct icp_qat_fw_pke_request *qat_req, struct qat_asym_op_cookie *cookie, @@ -686,6 +764,9 @@ asym_set_input(struct rte_crypto_asym_op *asym_op, case RTE_CRYPTO_ASYM_XFORM_ECDSA: return ecdsa_set_input(asym_op, qat_req, cookie, xform); + case RTE_CRYPTO_ASYM_XFORM_ECPM: + return ecpm_set_input(asym_op, qat_req, + cookie, xform); default: QAT_LOG(ERR, "Invalid/unsupported asymmetric crypto xform"); return -EINVAL; @@ -761,6 +842,8 @@ qat_asym_collect_response(struct rte_crypto_op *rx_op, return rsa_collect(asym_op, cookie); case RTE_CRYPTO_ASYM_XFORM_ECDSA: return ecdsa_collect(asym_op, cookie); + case RTE_CRYPTO_ASYM_XFORM_ECPM: + return ecpm_collect(asym_op, cookie); default: QAT_LOG(ERR, "Not supported xform type"); return RTE_CRYPTO_OP_STATUS_ERROR; diff --git a/drivers/crypto/qat/qat_asym.h b/drivers/crypto/qat/qat_asym.h index 9344e48eb4..e05ed7fc86 100644 --- a/drivers/crypto/qat/qat_asym.h +++ b/drivers/crypto/qat/qat_asym.h @@ -29,6 +29,8 @@ typedef uint64_t large_int_ptr; #define QAT_ASYM_ECDSA_RS_SIGN_OUT_PARAMS 2 #define QAT_ASYM_ECDSA_RS_VERIFY_IN_PARAMS 1 #define QAT_ASYM_ECDSA_RS_VERIFY_OUT_PARAMS 0 +#define QAT_ASYM_ECPM_IN_PARAMS 7 +#define QAT_ASYM_ECPM_OUT_PARAMS 2 struct qat_asym_op_cookie { size_t alg_bytesize; -- 2.13.6