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 BC18B45A5F; Sun, 29 Sep 2024 20:44:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6A52140273; Sun, 29 Sep 2024 20:44:27 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id 9D2FE400D5 for ; Sun, 29 Sep 2024 20:44:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727635466; x=1759171466; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ZxamhaFCJ6Y4Z8VB7uZ5Iqodrbhb+CwTJ4LDj8kMLSo=; b=CE6Ajrrkj+wP/4HkcfIjsmbdrF+i5UqNzG+e00Jco06aOxJS/P2j/mSw h4GxsLCb9FcN7kayWRM6fmCrVqIXZ3SL6m2ZkTAXiSDkFdm21s6s1Bodg F7VN8yqzuCTVshP/jGUQx7qPxbJrHuRtbrRnjsA7BIRTncfwktDvu1IZm BVIryOWsuhJj5hw+nbCqCbqC8ToQ9XniYURSNK28B3srUKY1C0HgK5bMv 1/4jeNixDeFFdAHKctfC2hToSbB3YzW1D4nqs5qkoNuwYmNg3e42P3oJv JXHahP3sUzu+eEYN5Rr3sl3bqOFzxf8Z5VQ5iNvzncxGmHF/o1r9qsHkM w==; X-CSE-ConnectionGUID: CI6UHnmpS3ObZAMcjFHK3g== X-CSE-MsgGUID: D0ltbdMZRQiz1PNOQmekqA== X-IronPort-AV: E=McAfee;i="6700,10204,11210"; a="26228348" X-IronPort-AV: E=Sophos;i="6.11,163,1725346800"; d="scan'208";a="26228348" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Sep 2024 11:44:24 -0700 X-CSE-ConnectionGUID: i5ThNM7OTay/U2GkxMk4Xw== X-CSE-MsgGUID: HvdAVz9nTV+BYjvQ7n115Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,163,1725346800"; d="scan'208";a="72745793" Received: from silpixa00399302.ir.intel.com ([10.237.214.22]) by fmviesa007.fm.intel.com with ESMTP; 29 Sep 2024 11:44:23 -0700 From: Arkadiusz Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, brian.dooley@intel.com, Arkadiusz Kusztal Subject: [PATCH v2] cryptodev: add ec points to sm2 op Date: Sun, 29 Sep 2024 18:29:12 +0100 Message-Id: <20240929172912.87859-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20240129185950.14346-1-arkadiuszx.kusztal@intel.com> References: <20240129185950.14346-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 In the case when PMD cannot support the 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..f59759062f 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -600,40 +600,6 @@ struct rte_crypto_ecpm_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. - */ - }; -}; - -/** * SM2 operation params. */ struct rte_crypto_sm2_op_param { @@ -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 the full + * process of the SM2 encryption/decryption, but the 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 the full + * process of the SM2 encryption/decryption, but the 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. */ @@ -698,6 +687,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. * * Structure describing asymmetric crypto operation params. -- 2.13.6