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 1006545C75; Mon, 4 Nov 2024 10:36:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C5ED40DD8; Mon, 4 Nov 2024 10:36:17 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by mails.dpdk.org (Postfix) with ESMTP id 42ED14021F for ; Mon, 4 Nov 2024 10:36:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730712975; x=1762248975; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=4cfROyQEI8tb0n7XMMrdKDTXa9oY+d9xIx0lB3Bxdxk=; b=dDT5CI3hOc5Mi3s7VU6PfytihoRXyXcdWc3L2PNK8BprdyD5AhGNFaxt e3tv3k1m8VWNTVLW8pczv1p4YrkP+2YC6DEgR++g7zWRmD09kUJSDm2BC jIQ7U67oa2AcpmAcO7Nhw9H/fb4v8vcMfN0x7BV/7FH4UjUWeAzU5iHos qS4q+0FjiotcM5bQt5ra3LRCdfzJr8a6kkhXbguNi6Ht9bb0cakM+LfSR Io2mh9Rtm6RkSv9bFgAsy8hr6e5PodcrtSKRFxgdBsWeQ+olHYWwP35bd 0ELVFQMzFGJdnb48ilMtlGVzQNS4MWTrZ0ykdpnY3g65e8SygnfM8i0Du A==; X-CSE-ConnectionGUID: mN5xEW5VQA6cL11OEdFMTw== X-CSE-MsgGUID: 0xnY5FBUSFCslqXlM2pYJA== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="29828801" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="29828801" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 01:36:15 -0800 X-CSE-ConnectionGUID: iV5z5q9TTki6oJp3psTHkA== X-CSE-MsgGUID: qHabc9k1Q8CxPKdnKXx05A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="106950436" Received: from silpixa00400308.ir.intel.com ([10.237.214.154]) by fmviesa002.fm.intel.com with ESMTP; 04 Nov 2024 01:36:14 -0800 From: Arkadiusz Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, brian.dooley@intel.com, Arkadiusz Kusztal Subject: [PATCH v8 1/3] cryptodev: add ec points to sm2 op Date: Mon, 4 Nov 2024 09:36:08 +0000 Message-Id: <20241104093610.20426-2-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20241104093610.20426-1-arkadiuszx.kusztal@intel.com> References: <20241104093610.20426-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 --- doc/guides/rel_notes/release_24_11.rst | 3 ++ lib/cryptodev/rte_crypto_asym.h | 56 +++++++++++++++++++------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index 53a5ffebe5..ee9e2cea3c 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -413,6 +413,9 @@ ABI Changes added new structure ``rte_node_xstats`` to ``rte_node_register`` and added ``xstat_off`` to ``rte_node``. +* cryptodev: The ``rte_crypto_sm2_op_param`` struct member to hold ciphertext + is changed to union data type. This change is to support partial SM2 calculation. + Known Issues ------------ diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index aeb46e688e..f095cebcd0 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -646,6 +646,8 @@ enum rte_crypto_sm2_op_capa { /**< Random number generator supported in SM2 ops. */ RTE_CRYPTO_SM2_PH, /**< Prehash message before crypto op. */ + RTE_CRYPTO_SM2_PARTIAL, + /**< Calculate elliptic curve points only. */ }; /** @@ -673,20 +675,46 @@ 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). + * + * Must be used along with the RTE_CRYPTO_SM2_PARTIAL flag. + */ + 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). + * + * Must be used along with the RTE_CRYPTO_SM2_PARTIAL flag. + */ + }; + }; rte_crypto_uint id; /**< The SM2 id used by signer and verifier. */ -- 2.34.1