From patchwork Wed Nov 29 16:10:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 134697 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 5098F43402; Wed, 29 Nov 2023 17:10:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3813F42E30; Wed, 29 Nov 2023 17:10:46 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 420F5409FA for ; Wed, 29 Nov 2023 17:10:45 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3ATFAIkW011841; Wed, 29 Nov 2023 08:10:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=qD8UJGINbESaA6OFYEyxhtQ6uaJJwyn+wLa2PFtYBQg=; b=F8oCL7wi5pPn+CmJX1juESZ2YAu1r9C1/zSuWhRUkFnON6ei18j0JM0nfjohjljpLIAd NAHQ1WdPkxX4+wXw1E7YOsLBiCGdLiMJIC6mGFnn2NI1qeiqicj+J1AKtZQxC9rXff/o Fe3yV2fUelPVUx9PNe3qzZl2tdCYCS7CjnwTwpuccEU/9JXMIWoMMNUpKXSk1P2gCnZO i3G7PmKBHdMQQFQ6xjrvh+x3QJHoWutVMjnQk+0Q8kgavKo9Pl4SCPTWjT9T6XdnYc/t BhjWqCJSnMZ/55wVm0SJ+twgAkGyseXd19jfa7eUue4FsT0ly7R3rFZbX5EhYgXMPcUC FA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3up4x199b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 29 Nov 2023 08:10:44 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 29 Nov 2023 08:10:42 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 29 Nov 2023 08:10:42 -0800 Received: from BG-LT91401.marvell.com (BG-LT91401.marvell.com [10.28.168.34]) by maili.marvell.com (Postfix) with ESMTP id 050FA3F7041; Wed, 29 Nov 2023 08:10:39 -0800 (PST) From: Gowrishankar Muthukrishnan To: CC: , Akhil Goyal , Fan Zhang , Kai Ji , "Gowrishankar Muthukrishnan" Subject: [PATCH v1 1/3] cryptodev: add EDDSA asymmetric crypto algorithm Date: Wed, 29 Nov 2023 21:40:34 +0530 Message-ID: <0ae6a1afadac64050d80b0fd7712c4a6a8599e2c.1701273963.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Proofpoint-GUID: jsMfJva6QIynejfHBfSfQ2Ywp_D3tMDu X-Proofpoint-ORIG-GUID: jsMfJva6QIynejfHBfSfQ2Ywp_D3tMDu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-29_14,2023-11-29_01,2023-05-22_02 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 Add support for asymmetric EDDSA in cryptodev, as referenced in RFC: https://datatracker.ietf.org/doc/html/rfc8032 Signed-off-by: Gowrishankar Muthukrishnan --- doc/guides/cryptodevs/features/default.ini | 1 + doc/guides/prog_guide/cryptodev_lib.rst | 2 +- lib/cryptodev/rte_crypto_asym.h | 51 +++++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/doc/guides/cryptodevs/features/default.ini b/doc/guides/cryptodevs/features/default.ini index f411d4bab7..3073753911 100644 --- a/doc/guides/cryptodevs/features/default.ini +++ b/doc/guides/cryptodevs/features/default.ini @@ -130,6 +130,7 @@ ECDSA = ECPM = ECDH = SM2 = +EDDSA = ; ; Supported Operating systems of a default crypto driver. diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst index 2b513bbf82..dd636ba5ef 100644 --- a/doc/guides/prog_guide/cryptodev_lib.rst +++ b/doc/guides/prog_guide/cryptodev_lib.rst @@ -927,7 +927,7 @@ Asymmetric Cryptography The cryptodev library currently provides support for the following asymmetric Crypto operations; RSA, Modular exponentiation and inversion, Diffie-Hellman and Elliptic Curve Diffie-Hellman public and/or private key generation and shared -secret compute, DSA Signature generation and verification. +secret compute, DSA and EdDSA Signature generation and verification. Session and Session Management ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index 39d3da3952..7813d28b7a 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -65,9 +65,22 @@ enum rte_crypto_curve_id { RTE_CRYPTO_EC_GROUP_SECP256R1 = 23, RTE_CRYPTO_EC_GROUP_SECP384R1 = 24, RTE_CRYPTO_EC_GROUP_SECP521R1 = 25, + RTE_CRYPTO_EC_GROUP_ED25519 = 29, + RTE_CRYPTO_EC_GROUP_ED448 = 30, RTE_CRYPTO_EC_GROUP_SM2 = 41, }; +/** + * List of Edwards curve instances as per RFC 8032 (Section 5). + */ +enum rte_crypto_edward_instance { + RTE_CRYPTO_EDCURVE_25519, + RTE_CRYPTO_EDCURVE_25519CTX, + RTE_CRYPTO_EDCURVE_25519PH, + RTE_CRYPTO_EDCURVE_448, + RTE_CRYPTO_EDCURVE_448PH +}; + /** * Asymmetric crypto transformation types. * Each xform type maps to one asymmetric algorithm @@ -108,6 +121,10 @@ enum rte_crypto_asym_xform_type { /**< Elliptic Curve Digital Signature Algorithm * Perform Signature Generation and Verification. */ + RTE_CRYPTO_ASYM_XFORM_EDDSA, + /**< Edwards Curve Digital Signature Algorithm + * Perform Signature Generation and Verification. + */ RTE_CRYPTO_ASYM_XFORM_ECDH, /**< Elliptic Curve Diffie Hellman */ RTE_CRYPTO_ASYM_XFORM_ECPM, @@ -376,7 +393,13 @@ struct rte_crypto_ec_xform { rte_crypto_uint pkey; /**< Private key */ - struct rte_crypto_ec_point q; + union { + struct rte_crypto_ec_point q; + /**< Elliptic curve point */ + + rte_crypto_uint qcomp; + /**< Elliptic curve point compressed */ + }; /**< Public key */ }; @@ -585,6 +608,31 @@ struct rte_crypto_ecdsa_op_param { */ }; +/** + * EDDSA operation params + */ +struct rte_crypto_eddsa_op_param { + enum rte_crypto_asym_op_type op_type; + /**< Signature generation or verification */ + + rte_crypto_param message; + /**< Input message digest to be signed or verified */ + + rte_crypto_param context; + /**< Context value for the sign op. + * Must not be empty for Ed25519ctx instance. + */ + + enum rte_crypto_edward_instance instance; + /**< Type of Edwards curve. */ + + rte_crypto_uint sign; + /**< Edward curve signature + * output : for signature generation + * input : for signature verification + */ +}; + /** * Structure for EC point multiplication operation param */ @@ -718,6 +766,7 @@ struct rte_crypto_asym_op { struct rte_crypto_ecdh_op_param ecdh; struct rte_crypto_dsa_op_param dsa; struct rte_crypto_ecdsa_op_param ecdsa; + struct rte_crypto_eddsa_op_param eddsa; struct rte_crypto_ecpm_op_param ecpm; struct rte_crypto_sm2_op_param sm2; };