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 243D345AE9; Tue, 8 Oct 2024 21:29:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DFAC40DD5; Tue, 8 Oct 2024 21:29:39 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mails.dpdk.org (Postfix) with ESMTP id 312F340DD5 for ; Tue, 8 Oct 2024 21:29:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728415777; x=1759951777; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=AS+wV+NnqP7/V0/J+vGhxPmsQZ6od3bTcjUz7TXb/LE=; b=NR1g7egeYwoYtfykU1nlUpss7tKK4H++NAhh5ZM6hIPjnyithKS8YVx9 aUTrcCVe88BSsrZXzBmOBW71cMzMLYtcvgfSrqnILlf/tY00QrHvqa+/v LTAo/DZvsI+oxGrgGhXs9s3gNHNnfOiOynWR9uPqfSLIPq9EoTNQUXA2h WY6f3YIJ061ComUsUK4JRPHiPnEFl8e+4GaZP7Zpx9SR11fklhx9BNpXg 7lY08ybLVlISrcI5gmPmYDpa9Af8/oeLfQ4cUeiTUIFPVB/KgxjesOKOg Cs1UrsOA8E4pgsBKSFly8EquyY4/tgwYtx+JFV2R+bjrJHI8KcUmbY7he w==; X-CSE-ConnectionGUID: 1QtjKf5FTkuzYNzdfIdsBw== X-CSE-MsgGUID: WrUiNYOJSZSgdXVGhk5zsg== X-IronPort-AV: E=McAfee;i="6700,10204,11219"; a="27808855" X-IronPort-AV: E=Sophos;i="6.11,187,1725346800"; d="scan'208";a="27808855" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2024 12:29:36 -0700 X-CSE-ConnectionGUID: jSabq8AKQr2Sso9aRfYyNQ== X-CSE-MsgGUID: P+dooLpQTiqgtH2tFK1lPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,187,1725346800"; d="scan'208";a="80540589" Received: from silpixa00399302.ir.intel.com ([10.237.214.22]) by fmviesa004.fm.intel.com with ESMTP; 08 Oct 2024 12:29:35 -0700 From: Arkadiusz Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, brian.dooley@intel.com, Arkadiusz Kusztal Subject: [PATCH v4 2/4] cryptodev: add ec points to sm2 op Date: Tue, 8 Oct 2024 19:14:31 +0100 Message-Id: <20241008181433.57591-3-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20241008181433.57591-1-arkadiuszx.kusztal@intel.com> References: <20241008062845.11071-1-arkadiuszx.kusztal@intel.com> <20241008181433.57591-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 | 57 +++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index 1b54774fee..4fb8ca813c 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -609,6 +609,12 @@ enum rte_crypto_sm2_op_capa { /**< Prehash message before crypto op. */ RTE_CRYPTO_SM2_PKE_KDF, /**< KDF support in SM2 public key encryption */ + RTE_CRYPTO_SM2_PARTIAL, + /**< + * PMD does not support the full process of the + * SM2 encryption/decryption, but the elliptic + * curve part only + */ }; /** @@ -636,20 +642,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. */ -- 2.13.6