From patchwork Mon Jan 29 18:59:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 136201 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id 4DEF2439C7; Mon, 29 Jan 2024 20:00:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D36FE402C8; Mon, 29 Jan 2024 19:59:59 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mails.dpdk.org (Postfix) with ESMTP id 706BC4026F for ; Mon, 29 Jan 2024 19:59:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706554799; x=1738090799; h=from:to:cc:subject:date:message-id; bh=NUx5Qm4Q7ylP9hqKgUtMb9YIYxDVsSjM6o9a8LxwOeg=; b=PenHzU9g6N3FyRhg57nQhsdub3cojOBNlFjtXJd/ZweNlocS5lhcmiAP d408lwfsKvuTk/j5haHZ2whn5xDNiMKig/2SdHuo2UnNS5sOfqPi/coYl 6+c9PZdok5vQdcPnPYgRCt3JIWbo6+owqS1ZRx0tMw1ToXz7wHtTZxera J/PCpJTXxUohumxMUKfCR61GZGdGvywU7uu9LLPHM1ahaQDMTRBIYMiV7 qvtKeV1WWyv9xSVzv32yNC6idtH4KQiE+GWW9u9ev1yWnAbsRZaGbIopN JG/Qg4MBb+WClsTUHY7G+ZQD4q1iEZfrqhLBmJwfAr4MQOkegmPU7R/L6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="9696122" X-IronPort-AV: E=Sophos;i="6.05,227,1701158400"; d="scan'208";a="9696122" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2024 10:59:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,227,1701158400"; d="scan'208";a="29632903" Received: from silpixa00400308.ir.intel.com ([10.237.214.154]) by orviesa002.jf.intel.com with ESMTP; 29 Jan 2024 10:59:55 -0800 From: Arkadiusz Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, ciara.power@intel.com, Arkadiusz Kusztal Subject: [PATCH 1/3] cryptodev: add ec points to sm2 op Date: Mon, 29 Jan 2024 18:59:48 +0000 Message-Id: <20240129185950.14346-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 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 In the case when PMD cannot support full process of the SM2, but elliptic curve computation only, additional fields are needed to handle such a case. Points C1, kP therefore were added to the SM2 crypto operation struct. Signed-off-by: Arkadiusz Kusztal --- lib/cryptodev/rte_crypto_asym.h | 119 +++++++++++++++++++------------- 1 file changed, 71 insertions(+), 48 deletions(-) diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index 39d3da3952..55620d2d3a 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -599,40 +599,6 @@ struct rte_crypto_ecpm_op_param { /**< Scalar to multiply the input point */ }; -/** - * Asymmetric crypto transform data - * - * Structure describing asym xforms. - */ -struct rte_crypto_asym_xform { - struct rte_crypto_asym_xform *next; - /**< Pointer to next xform to set up xform chain.*/ - enum rte_crypto_asym_xform_type xform_type; - /**< Asymmetric crypto transform */ - - union { - struct rte_crypto_rsa_xform rsa; - /**< RSA xform parameters */ - - struct rte_crypto_modex_xform modex; - /**< Modular Exponentiation xform parameters */ - - struct rte_crypto_modinv_xform modinv; - /**< Modular Multiplicative Inverse xform parameters */ - - struct rte_crypto_dh_xform dh; - /**< DH xform parameters */ - - struct rte_crypto_dsa_xform dsa; - /**< DSA xform parameters */ - - struct rte_crypto_ec_xform ec; - /**< EC xform parameters, used by elliptic curve based - * operations. - */ - }; -}; - /** * SM2 operation params. */ @@ -658,20 +624,43 @@ struct rte_crypto_sm2_op_param { * will be overwritten by the PMD with the decrypted length. */ - rte_crypto_param cipher; - /**< - * Pointer to input data - * - to be decrypted for SM2 private decrypt. - * - * Pointer to output data - * - for SM2 public encrypt. - * In this case the underlying array should have been allocated - * with enough memory to hold ciphertext output (at least X bytes - * for prime field curve of N bytes and for message M bytes, - * where X = (C1 || C2 || C3) and computed based on SM2 RFC as - * C1 (1 + N + N), C2 = M, C3 = N. The cipher.length field will - * be overwritten by the PMD with the encrypted length. - */ + union { + rte_crypto_param cipher; + /**< + * Pointer to input data + * - to be decrypted for SM2 private decrypt. + * + * Pointer to output data + * - for SM2 public encrypt. + * In this case the underlying array should have been allocated + * with enough memory to hold ciphertext output (at least X bytes + * for prime field curve of N bytes and for message M bytes, + * where X = (C1 || C2 || C3) and computed based on SM2 RFC as + * C1 (1 + N + N), C2 = M, C3 = N. The cipher.length field will + * be overwritten by the PMD with the encrypted length. + */ + struct { + struct rte_crypto_ec_point C1; + /**< + * This field is used only when PMD does not support full + * process of the SM2 encryption/decryption, but elliptic + * curve part only. + * + * In the case of encryption, it is an output - point C1 = (x1,y1). + * In the case of decryption, if is an input - point C1 = (x1,y1) + * + */ + struct rte_crypto_ec_point kP; + /**< + * This field is used only when PMD does not support full + * process of the SM2 encryption/decryption, but elliptic + * curve part only. + * + * It is an output in the encryption case, it is a point + * [k]P = (x2,y2) + */ + }; + }; rte_crypto_uint id; /**< The SM2 id used by signer and verifier. */ @@ -697,6 +686,40 @@ struct rte_crypto_sm2_op_param { */ }; +/** + * Asymmetric crypto transform data + * + * Structure describing asym xforms. + */ +struct rte_crypto_asym_xform { + struct rte_crypto_asym_xform *next; + /**< Pointer to next xform to set up xform chain.*/ + enum rte_crypto_asym_xform_type xform_type; + /**< Asymmetric crypto transform */ + + union { + struct rte_crypto_rsa_xform rsa; + /**< RSA xform parameters */ + + struct rte_crypto_modex_xform modex; + /**< Modular Exponentiation xform parameters */ + + struct rte_crypto_modinv_xform modinv; + /**< Modular Multiplicative Inverse xform parameters */ + + struct rte_crypto_dh_xform dh; + /**< DH xform parameters */ + + struct rte_crypto_dsa_xform dsa; + /**< DSA xform parameters */ + + struct rte_crypto_ec_xform ec; + /**< EC xform parameters, used by elliptic curve based + * operations. + */ + }; +}; + /** * Asymmetric Cryptographic Operation. *