From patchwork Thu Apr 7 07:44:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 109409 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 81AF1A050B; Thu, 7 Apr 2022 09:44:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 194B540689; Thu, 7 Apr 2022 09:44:31 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 456154014F for ; Thu, 7 Apr 2022 09:44:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649317470; x=1680853470; h=from:to:cc:subject:date:message-id; bh=e4DImoVQPGhcPp2ZpEGt4EbM6urXjh+c5qzTkfnb5rU=; b=UqPcMOW1s+Cua/nZ1E+z+/hp3ioo4K1IRIu0D767auYS23gvrkmAKOTj Sw/9L0KHLZcGit7RY6i0pNjhdni0MM4tWBU7fIr5aj2x3iTGQAkg3BTIB rLx890AWRL8boWMX3DDvPgiLIGaBZKlBsP/nQB9CinDxlMUi5GVBsSWYR JkGLMLKSeh3KqJQObQvPj3iHnNrN5YMrZ7M/QUN9SC3KIUxe6uqkade0Y IP7C8/vEUcKPH8gZCksl9wmc15/84O4DCAshe8VtDon+QfKPO13jNq+ne h5vDQ0cRDimXpKU1ibBN43flJjvnm5ocLFpTXQ5osFMn/awyV60qMLeOQ g==; X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="241186022" X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="241186022" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2022 00:44:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="642384051" Received: from silpixa00400308.ir.intel.com ([10.237.214.95]) by FMSMGA003.fm.intel.com with ESMTP; 07 Apr 2022 00:44:28 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, roy.fan.zhang@intel.com, Arek Kusztal Subject: [PATCH] cryptodev: add elliptic curve diffie hellman Date: Thu, 7 Apr 2022 08:44:16 +0100 Message-Id: <20220407074416.18565-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 This commit adds Elliptic Curve Diffie-Hellman option to Cryptodev. This could be achieved with EC point multiplication but: 1) Phase 1 of DH is used with EC generator, multiplication expect setting generator manually. 2) It will unify usage of DH. 3) Can be extended easily to support X25519 and X448. Signed-off-by: Arek Kusztal --- Depends-on: series-22398 ("cryptodev: move dh type from xform to dh op") lib/cryptodev/rte_crypto_asym.h | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index 40c1d90604..e65222b802 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -91,6 +91,8 @@ enum rte_crypto_asym_xform_type { /**< Elliptic Curve Digital Signature Algorithm * Perform Signature Generation and Verification. */ + RTE_CRYPTO_ASYM_XFORM_ECDH, + /**< Elliptic Curve Diffie Hellman */ RTE_CRYPTO_ASYM_XFORM_ECPM, /**< Elliptic Curve Point Multiplication */ RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END @@ -385,34 +387,41 @@ struct rte_crypto_rsa_op_param { }; /** - * Diffie-Hellman Operations params. + * Diffie-Hellman/Elliptic Curve Diffie-Hellman operation. * @note: */ struct rte_crypto_dh_op_param { enum rte_crypto_asym_op_type op_type; /**< Diffie-Hellman operation phase */ - rte_crypto_uint pub_key; + + rte_crypto_param priv_key; /**< - * Output generated public key when op_type is - * DH PUB_KEY_GENERATION. - * Input peer public key when op_type is DH - * SHARED_SECRET_COMPUTATION - * + * Diffie-Hallman private part + * For DH and ECDH it is big-endian integer. + * Input for both phases of Diffie-Hellman */ - rte_crypto_uint priv_key; + union { + rte_crypto_uint pub_key; + struct rte_crypto_ec_point pub_point; + }; /**< - * Output generated private key if op_type is - * DH PRIVATE_KEY_GENERATION - * Input when op_type is DH SHARED_SECRET_COMPUTATION. - * + * Diffie-Hallman public part + * For DH it is big-endian unsigned integer. + * For ECDH it is a point on the curve. + * Output for RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE + * Input for RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE */ - rte_crypto_uint shared_secret; + union { + rte_crypto_uint shared_secret; + struct rte_crypto_ec_point shared_point; + }; /**< - * Output with calculated shared secret - * when dh op_type = SHARED_SECRET_COMPUTATION. - * + * Diffie-Hallman shared secret + * For DH it is big-endian unsigned integer. + * For ECDH it is a point on the curve. + * Output for RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE */ };