From patchwork Thu May 11 12:35:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umesh Kartha X-Patchwork-Id: 24245 X-Patchwork-Delegate: pablo.de.lara.guarch@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B60F458D1; Thu, 11 May 2017 14:36:44 +0200 (CEST) Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0064.outbound.protection.outlook.com [104.47.34.64]) by dpdk.org (Postfix) with ESMTP id 0BFA7567F for ; Thu, 11 May 2017 14:36:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=C+oi4mfiFut3yHI21inANeoOks31IzbH/8SAMPcs/dE=; b=J8NdDXo5PgS3TaF1+vvuz3p6+ize4t1+Maftv4pcX74dE3NCurPoFfWhhjZTCNOXwXgKtz5QN7RipHcqiEi8TR3Ty3PMAhAqmgLi2CQUAjCA6fopJIb5GNiTH+QCnq8mTxis4XvqXYipyDYrNr3LWDtsh/TBg+hyPgA7h/oLFOg= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from ukw0rk.in.caveonetworks.com (14.140.2.178) by BN6PR07MB2755.namprd07.prod.outlook.com (10.173.27.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Thu, 11 May 2017 12:36:36 +0000 From: Umesh Kartha To: dev@dpdk.org Cc: Jerin Jacob , Balasubramanian Manoharan , Ram Kumar , Murthy Nidadavolu , declan.doherty@intel.com, pablo.de.lara.guarch@intel.com, Fiona Trahe Date: Thu, 11 May 2017 18:05:30 +0530 Message-Id: <1494506132-23107-2-git-send-email-Umesh.Kartha@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1494506132-23107-1-git-send-email-Umesh.Kartha@caviumnetworks.com> References: <1490177802-13398-1-git-send-email-Umesh.Kartha@caviumnetworks.com> <1494506132-23107-1-git-send-email-Umesh.Kartha@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: PN1PR01CA0092.INDPRD01.PROD.OUTLOOK.COM (10.174.144.160) To BN6PR07MB2755.namprd07.prod.outlook.com (10.173.27.141) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad9c3204-2b2e-419f-eb9f-08d4986a5f10 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:BN6PR07MB2755; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB2755; 3:UXQGPcICJ+e9Ryysuoj/I6YXQECOsAQKflFZf/apL0nCYhcKQqp83aPofOs1FOJmD0TZPDQBdwvjvlLnKcRtj+Aslhz2aJHB1TF54qnUm+oN8esHxdURT1uXZqSFiMRiObw/tEat6Xs7PorFTOH7HPKjuj5u4k8gCvBwuvbJBPwB2ot4/nsvl7j0kUIDEPC8lr6Ftf8Hb202OE4YEU0NobCe5/DJV7REddPHjmqWpp7OH8+X+WGK3pn06iOsLWFEl2B8qKj8U36sTcZEFlqlieTknT2x4IBQ2TMfAEYWkbnCoGjfTE+U/wRk1y8BkAnZpzhjlOnm4ytY8skNDwhV3w==; 25:+cyuCV75/UncTpfOAh1jX3hlwBzgdlbia/VQNqK00f0t4bZ03ScJJIE+JyFKpsVTOOQuJFp5ZfGasGFshsSCXczA/DQbd2k0YVhQ1UFpw/z+jLcBOn9tc5vXS/wLxE4kylTDOW29BCvTceiwXvG11rirBe2/n+ZqXAXnC0CvW1jOQhOG6cndo7rOVwGhW7Pl0isHhmKE7K7JQwwlxcr3pMwpl7PUNayhK36EAdNxBhfO6G5Xl2zgY3yvOdjOzgRstnSaCSNwEsQ4nCp/Pt4tn7LXQajtnQ/1moiYyR3/pWXq2c9nRO8kbHcHzyEWgYlmdK0gh+Chu9yDddYy7M50qRt9FxSKoD9bxR0qXi+DIwRYarRafeltbhMizuFehsWPv3LEnk1cKBNbbolocTrE8z9wWUTW6ddlmsdr0pXe+OMXNWsjsFYR1kS1xuObDoenAJv+ykZLBs3yPURnW95PJoqVxF6DJWteBSsWOB1Qcm0= X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB2755; 31:vArCCF0H0Bghyu2oRWERmMZdWYBkjD8Eapkq7UOBTGJ8aLz26mUkApmi/EEDnfgqz/fQD8IezUDs26xMwyhAT1IIsfbcDtX684MSAoD5r0rANxDvOEhrgCqxhvfLD15jdn2giUT4DkbNoEKzOSd3KEpD6mrht4Q5BBUcFxYx0FvyET7PiqTj8vbNqOstFpqF2Pojh5ErsfLp5I/SvPl0W9QnKQLvAPke4hnFtOJ+6Hw=; 20:BAItSleCyaCSFWPE2oN/7rQssYyrVYMD+ES7QI4sjx95g3FrrgoUbr2W13si21Eo6GBqY3X4dCtTIiJCj+VT60ZEGhepnv77/NTBFApQnmn4SsVRD2IydqJr8wRzrE7ha1hLZrETRzIuuvvvU+nz4EG72Ii7rxsljAQkpvpBegxgswNO4WJlMsoEH6sS/ohAeETIjckbELB9ks9kqw2ySNbP46Gs5rMt2ULCkdYVdWj7q0Mh9YL7GfqXny+gznYXw5UiiwcG5z1nhSj9/+y21iXjwJEOEHiVeNdAZyjsZxNbJ9s/grcj5vR+UqepsgCXFqkLZv+uZn7YwHVtO0mvJ/oVUi/gFMzJGpi1dpRqcn7g8Gnze0dXn4OocdYxnFzhfIN6ZWYWxX/mJUratOEYNeESyHxH9ldi98Gj026rrIX3S6jbYo+UpeFEM7N9SWdpDbPbPTctxO6QSVdy7FZei4YepU4N2vHwWOSL4INg0Bo5wjPyRRvPtct9n6SEQfJuTvjapnx9RrxK0+cDs5O5EFSLSwmHNhuBwViMCSHO6kmfbEN+UxrZdkSgCsyDd5MS894XipVXxJ4IZkY6KHKGetUO2wUVGCyuZLLuAi+j2og= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(6041248)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123560025)(6072148); SRVR:BN6PR07MB2755; BCL:0; PCL:0; RULEID:; SRVR:BN6PR07MB2755; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB2755; 4:dvsnvnIQiQ4K6UQg3kmjekFZrkyEqQotpAQH7ekBr0sBQxb6MIizuAs7VcBTybbB1r/FUVkpz4F+PC9/2VQrMvTsy6bsxhHZpElSNOlU9uVXlA1UBBVfCuWCD8X8vYF3CUDrMoUVsv60YwvuCWC2n8Nct6dIvbx26aLycfA+GzvImirk2A+0pjwtj3zaeg7k54NLvoUAY2o6+UAe+QlGEoU5+hUsY291iPLuh2p4r+ebkpGy6UeEnLir5QjA8thuw58ukvPYXVkFVTVHgnwx+iYsO4OSCsyPA4QSzfpGpD0GATSZr5uRqqRLGcbuSHNGkZwdqY2P3vfp0dlrPg/OcQ+eNc1yxTQdnKLcABoi74tax+5AexcmMvMKJrMi/WDh00l3yvc1wwWFE2l3JcrBXrndSgah+umuaP8ZnjgesovE045NwGLjUnWnP8fy9qhcKqK7Moo9HhVHZeATrQEG2JGJ3YsbttYtty8K3/9+pPO/ZQ1LMkDjULEJsoKiIdo2XjpKfZs/hK3ZsXjg2/887to76cyB/ZRhHqBt9KRXEoGKsICvu6zno6TzOdj2pIB6NLzSi1b6SKD7KDjFL/fuJg8bhIE3OZUSGslNtFLFyyPMV4ntUiOUvrfUPK7zoqHtG6kobEhXDLCpRYv8rewRODcOGYFwRqEebuABHq9siyvKO7GGzsLQB2sv3bPm6OeqCDvgMA+wxReFfPizFosBeiCd8v2LEGgqKtVkvb12oJz5JYv+EJKowi43ALaq94Eo3jvBGXRBEScCQvgWy3SX9w== X-Forefront-PRVS: 0304E36CA3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39400400002)(39410400002)(39450400003)(39840400002)(39850400002)(2351001)(305945005)(7736002)(189998001)(2906002)(4720700003)(478600001)(6916009)(6666003)(2950100002)(42882006)(25786009)(5890100001)(4326008)(2361001)(42186005)(72206003)(76176999)(5003940100001)(50986999)(5660300001)(81166006)(48376002)(54906002)(50226002)(6512007)(5009440100003)(66066001)(6486002)(53936002)(53946003)(6116002)(3846002)(8676002)(36756003)(47776003)(110136004)(38730400002)(6506006)(50466002)(110426004)(217873001)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB2755; H:ukw0rk.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR07MB2755; 23:PmbylWFpiJH3Lm0HQcBBelX6K9BnOT8YQiDSfdCqT?= LSM0OG+dCuluMr7PHPTtE1ebQKIvisUtOlxn99KxWClMxPvgKsR4i0kYMaTUX50qWFgE1zcIhlCkptYl1aLWeo2k6BuoK5QYKwYYzb/RqR/HzKeGEd74BLM/INIoK+EVXD2lUetklwpY0gJN+UAwxHGy4Um6a3ZWAdKazpzoRJcMSnM6kB6JnWrNpO3CsnL80hl12nUV3+y+DkxVfzoWCCbfLsL49OyamV8h9iJK4p+JJAMWF1ljxrP2pyfjFz/rkQFEOEDtazdu/xEsmi5Dd6gyhKC0bO0eWcY+2tt+X/mOIYdX7/cIzQ17bZB+bmiqYb/NYtXYmO/4rkhtZNuVxLLA6jvJdXKlVtscL9UxEPKfDlLAX44ItBOb4YaIJxwuqMElQr7bUhew6NLr96ONhviCGhxk5QqYgo4bUp6EC+KnKv+DGWwUHvxaE1/opcYnT1dnBFntzSwLqgMNTNDZnSEcisEMB6634Jgu9VG2RaAQRECG/7fKN3PrpgvkH6MvT7yyUW6dNCHD6unaFLVG4m/eu1bZpTq4AuIjhSJZVjmSSvwIrp4gtGjXfEBOyK5y4OHj/ZvYsyDexn/UP+wdtzIceny3SV/DeDVGidD88ZZ1ZV+TX0OLaurimQg92gOoCuw0jwMK2PeAouFm9nfQ10Yi7Dud3tNlmMLUH1SnOAwJB4VtgLiYqf8aJnPNgMkOnb8DZIJ4X1hbpj968bQLM4MAzYb6nmTyCwOkwKE8tHAY1ElBjBH92d1JB9sBm4NSti9OtI1GO1lrO781hOG80tH2awqS0tP73+Z/jx/fkndbzPWk8DloZ8q3/OnCoaQ3JbpFAH5lGrk44VmH1Nu1Fbo38ZK2zW/lAc9eWH9lqBk0gP7fAogTWeeE1xSrruYoCGL5PIfneS+DF0q7/EorLysta18gYIFX0QgtsQF5nUrW9Xi0gouLZEcyN/vVroltww378knrD5kXCpbMgXFmEpzN54dARVkS7Bs28gLDE4F73ocyUVOVa0G6pyRo2AaoC/z+b2+j/hWZ1QxVyjxy0b4PELmwNNSr4iFU+N7+50hKf+aKYH/XdosEfzUWnFqv56ubMwkJeN2MQTuBa0TFE19WkzX+gr77K5EOFSLOs1EldvEIvO+iEhwEh2iPy0Mq6g5fUWBa4tqmAfo7M3KKKqPYKXBSp0uP5aW6V98J4DjVNT/+VXR1okrnyDW2f2nrj7so/Yy/CvJoPMfpxXeF30C X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB2755; 6:zsTEJ/Hymwdb4N1g5VaetW/oByJ8nflnGp6wnjVJyGT5DFQpJav0efmtKkYgEt+JT3sNWR8yzcAyQmGI1L7MkHIdr+DK7o9ScqMX6Hhocgx+HhgOgDhhNpe0T9TDvqKPo6o8glIAgz5mxv0JVrwp9d4CzShrCwBl6ps5Wq/Iqewv3Ye/gDqaqoh90DzsHzkKO652doFC/qEDX3SFddToRr3qCO/4HGh1mKaVUeSXgwsN4WnOyVyWZGn6BAh1fDRbUlqqYGVgKcNJ5w8A+QcqVDHKEl4mWDWRBgYRQzFx1+0t+yYJjAp07IaWXTPqe4xT+PlMmsjUiYDSFvmdu9eJBA7yI8pNigYq6ipfowdNPSgngZAeeyEvfmNSFSH2+sTS0AdwSM/ikOOAyVW8bdaP+stocewZ16GJRpBA+oUzPjXG0K0OB4QvxaS6crhk80FqHg5KgYMCiw5mazNpzDToQkG7TEACTgARl0pE1AIUWZX1RWh7PIkMtdQ14EXBEGG/UDYR/jJy7wrKLgZNlRD+7Q==; 5:sQvnsXlhDz2Eb4PqyxZa/Y0R0rdYKPxmgjoRMJRqLWDv+Vg5zRsB2dYJQC7b38XI+Kzfz+d5CF+WwHcmNmpe5pElTmvIYY4k9d/vLucZbfmiUmYuYGiI/VlRBBZyNbkb1oDQDyCsWVEqwEBtQrcwGQ==; 24:JjDLbIH44S3pUlBegTDorSNI/phAcXQ0UtgOV6f/+94fibHHDOimBUbx2KgNHwJU58nsjgQa8pubP92RjGMubUiV15SNzzcwowUFkkgeW+0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB2755; 7:DqkL8AkEYg4ACrnBbKB3ukoHUjKqTI004UA7tyqXa8Wnfbwac2MM3zH6pKgbpnvm2BDXDqD5JBki8+za3HLR6NCcTHbdnpl+YDiMlRbcm75TFjZezjRx1mBuQ+DT2q0JJhxqLq0TdrzMN5/oNRrlRVi86sqo49yhNP7SAoyOKAdTUHG0Bq7woINu06j2Ct3gmKTBHilpZDZmvMV4LUlB6n1KuVM+vcun9CmOCHtQ4jXvn6+gDoaZA5d8yJV2rhQ63j5doy3MFBZwL+7k4CkIFZ+K3n9PzlipP4T466eX3Cy9GW0xKnwg1QO4SIF/aCxVOqOcw37vVinatOy6E+ID2g== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2017 12:36:36.9530 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB2755 Subject: [dpdk-dev] [RFC PATCH v2 1/3] cryptodev: added asymmetric algorithms X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added asymmetric xform structures, operation definitions, operation parameters. Added asymmetric algorithms RSA, DH, ECDH, DSA, ECDSA, MODEXP, FECC, MOD-INVERSE. Added curves (all curves supported by libcrypto as of now). Signed-off-by: Umesh Kartha --- lib/librte_cryptodev/rte_crypto_asym.h | 1124 ++++++++++++++++++++++++++++++++ 1 file changed, 1124 insertions(+) create mode 100644 lib/librte_cryptodev/rte_crypto_asym.h diff --git lib/librte_cryptodev/rte_crypto_asym.h lib/librte_cryptodev/rte_crypto_asym.h new file mode 100644 index 0000000..36a8b4f --- /dev/null +++ lib/librte_cryptodev/rte_crypto_asym.h @@ -0,0 +1,1124 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium networks Ltd. 2017. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium Networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _RTE_CRYPTO_ASYM_H_ +#define _RTE_CRYPTO_ASYM_H_ + +/** + * @file rte_crypto_asym.h + * + * RTE Definitions for Asymmetric Cryptography + * + * Defines asymmetric algorithms and modes, as well as supported + * asymmetric crypto operations. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include "rte_crypto_sym.h" + +typedef struct rte_crypto_xform_param_t { + uint8_t *data; + size_t length; +} rte_crypto_xform_param; + +typedef struct rte_crypto_op_param_t { + uint8_t *data; + phys_addr_t phys_addr; + size_t length; +} rte_crypto_op_param; + +/** Asymmetric crypto transformation types */ +enum rte_crypto_asym_xform_type { + RTE_CRYPTO_ASYM_XFORM_NOT_SPECIFIED = 0, + RTE_CRYPTO_ASYM_XFORM_RSA, + RTE_CRYPTO_ASYM_XFORM_MODEX, + RTE_CRYPTO_ASYM_XFORM_DH, + RTE_CRYPTO_ASYM_XFORM_ECDH, + RTE_CRYPTO_ASYM_XFORM_DSA, + RTE_CRYPTO_ASYM_XFORM_ECDSA, + RTE_CRYPTO_ASYM_XFORM_FECC, + RTE_CRYPTO_ASYM_XFORM_MODINV, + RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END +}; + +/** + * RSA operation type variants + */ +enum rte_crypto_rsa_optype { + RTE_CRYPTO_RSA_OP_NOT_SPECIFIED = 1, + /**< RSA operation unspecified */ + RTE_CRYPTO_RSA_OP_PUBLIC_ENCRYPT, + /**< RSA public encrypt operation */ + RTE_CRYPTO_RSA_OP_PRIVATE_DECRYPT, + /**< RSA private decrypt operation */ + RTE_CRYPTO_RSA_OP_SIGN, + /**< RSA private key signature operation */ + RTE_CRYPTO_RSA_OP_VERIFY, + /**< RSA public key verification operation */ + RTE_CRYPTO_RSA_OP_LIST_END +}; + +/** + * Padding types for RSA signature. + */ +enum rte_crypto_rsa_padding_type { + RTE_CRYPTO_RSA_PADDING_NOT_SPECIFIED = 1, + /**< RSA no padding scheme */ + RTE_CRYPTO_RSA_PADDING_BT1, + /**< RSA PKCS#1 padding BT1 scheme */ + RTE_CRYPTO_RSA_PADDING_BT2, + /**< RSA PKCS#1 padding BT2 scheme */ + RTE_CRYPTO_RSA_PADDING_OAEP, + /**< RSA PKCS#1 OAEP padding scheme */ + RTE_CRYPTO_RSA_PADDING_PSS, + /**< RSA PKCS#1 PSS padding scheme */ + RTE_CRYPTO_RSA_PADDING_TYPE_LIST_END +}; + +/** + * Modular exponentiaion operation type variants + */ +enum rte_crypto_modex_optype { + RTE_CRYPTO_MODEX_OP_NOT_SPECIFIED = 1, + /**< ModEx operation type unspecified */ + RTE_CRYPTO_MODEX_OP_MODEX, + /**< Modex operation modular exponentiation */ + RTE_CRYPTO_MODEX_OP_LIST_END +}; + +/** + * Modular Inverse operation type variants + */ +enum rte_crypto_modeinv_optype { + RTE_CRYPTO_MODINV_OP_NOT_SPECIFIED = 1, + /**< ModInv operation type unspecified */ + RTE_CRYPTO_MODINV_OP_MODINV, + /**< ModInv operation modular Inverse */ + RTE_CRYPTO_MODEX_OP_LIST_END +}; + +/** + * DSA operation type variants + */ +enum rte_crypto_dsa_optype { + RTE_CRYPTO_DSA_OP_NOT_SPECIFIED = 1, + /**< DSA operation unspecified */ + RTE_CRYPTO_DSA_OP_SIGN, + /**< DSA private key signature operation */ + RTE_CRYPTO_DSA_OP_VERIFY, + /**< DSA public key verification operation */ + RTE_CRYPTO_DSA_OP_LIST_END +}; + + +/** + * ECDSA operation type variants + */ +enum rte_crypto_ecdsa_optype { + RTE_CRYPTO_ECDSA_OP_NOT_SPECIFIED = 1, + /**< ECDSA operation unspecified */ + RTE_CRYPTO_ECDSA_OP_SIGN, + /**< ECDSA private key signature operation */ + RTE_CRYPTO_ECDSA_OP_VERIFY, + /**< ECDSA public key verification operation */ + RTE_CRYPTO_ECDSA_OP_LIST_END +}; + +/** + * Diffie Hellman Key operation variants + */ +enum rte_crypto_dh_optype { + RTE_CRYPTO_DH_OP_NOT_SPECIFIED = 1, + /**< DH operation unspecified */ + RTE_CRYPTO_DH_OP_KEY_GENERATION, + /**< DH private/public key generation operation */ + RTE_CRYPTO_DH_OP_KEY_COMPUTATION, + /**< DH private key computation operation */ + RTE_CRYPTO_DH_OP_LIST_END +}; + +/** + * Elliptic Curve Diffie Hellman Key operation variants + */ +enum rte_crypto_ecdh_optype { + RTE_CRYPTO_ECDH_OP_NOT_SPECIFIED = 1, + /**< ECDH operation unspecified */ + RTE_CRYPTO_ECDH_OP_KEY_GENERATION, + /**< ECDH private/public key generation operation */ + RTE_CRYPTO_ECDH_OP_KEY_CHECK, + /**< ECDH public key validity check operation */ + RTE_CRYPTO_ECDH_OP_KEY_COMPUTATION, + /**< ECDH private key computation operation */ + RTE_CRYPTO_ECDH_OP_LIST_END +}; + +/** + * Fundamental ECC operation type variants. + */ +enum rte_crypto_fecc_optype { + RTE_CRYPTO_FECC_OP_NOT_SPECIFIED = 1, + /**< FECC operation type unspecified */ + RTE_CRYPTO_FECC_OP_POINT_ADD, + /**< Fundamental ECC point addition operation */ + RTE_CRYPTO_FECC_OP_POINT_DBL, + /**< Fundamental ECC point doubling operation */ + RTE_CRYPTO_FECC_OP_POINT_MULTIPLY, + /**< Fundamental ECC point multiplication operation */ + RTE_CRYPTO_FECC_OP_LIST_END +}; + +/** + * ECC list of curves. + */ +enum rte_crypto_ec_prime_curve { + RTE_CRYPTO_EC_CURVE_NOT_SPECIFIED = -1, + /**< Unspecified or empty curve id */ + RTE_CRYPTO_EC_CURVE_secp112r1, + /**< SECG/WTLS curve over a 112 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp112r2, + /**< SECG curve over a 112 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp128r1, + /**< SECG curve over a 128 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp128r2, + /**< SECG curve over a 128 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp160k1, + /**< SECG curve over a 160 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp160r1, + /**< SECG curve over a 160 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp160r2, + /**< SECG/WTLS curve over a 160 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp192k1, + /**< SECG curve over a 192 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp224k1, + /**< SECG curve over a 224 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp224r1, + /**< NIST/SECG curve over a 224 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp256k1, + /**< SECG curve over a 256 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp384r1, + /**< NIST/SECG curve over a 384 bit prime field */ + RTE_CRYPTO_EC_CURVE_secp521r1, + /**< NIST/SECG curve over a 521 bit prime field */ + RTE_CRYPTO_EC_CURVE_prime192v1, + /**< NIST/X9.62/SECG curve over a 192 bit prime field */ + RTE_CRYPTO_EC_CURVE_prime192v2, + /**< X9.62 curve over a 192 bit prime field */ + RTE_CRYPTO_EC_CURVE_prime192v3, + /**< X9.62 curve over a 192 bit prime field */ + RTE_CRYPTO_EC_CURVE_prime239v1, + /**< X9.62 curve over a 239 bit prime field */ + RTE_CRYPTO_EC_CURVE_prime239v2, + /**< X9.62 curve over a 239 bit prime field */ + RTE_CRYPTO_EC_CURVE_prime239v3, + /**< X9.62 curve over a 239 bit prime field */ + RTE_CRYPTO_EC_CURVE_prime256v1, + /**< X9.62/SECG curve over a 256 bit prime field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls6, + /**< SECG/WTLS curve over a 112 bit prime field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls7, + /**< SECG/WTLS curve over a 160 bit prime field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls8, + /**< WTLS curve over a 112 bit prime field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls9, + /**< WTLS curve over a 160 bit prime field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls12, + /**< WTLS curve over a 224 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP160r1, + /**< RFC 5639 curve over a 160 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP160t1, + /**< RFC 5639 curve over a 160 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP192r1, + /**< RFC 5639 curve over a 192 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP192t1, + /**< RFC 5639 curve over a 192 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP224r1, + /**< RFC 5639 curve over a 224 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP224t1, + /**< RFC 5639 curve over a 224 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP256r1, + /**< RFC 5639 curve over a 256 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP256t1, + /**< RFC 5639 curve over a 256 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP320r1, + /**< RFC 5639 curve over a 320 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP320t1, + /**< RFC 5639 curve over a 320 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP384r1, + /**< RFC 5639 curve over a 384 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP384t1, + /**< RFC 5639 curve over a 384 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP512r1, + /**< RFC 5639 curve over a 512 bit prime field */ + RTE_CRYPTO_EC_CURVE_brainpoolP512t1, + /**< RFC 5639 curve over a 512 bit prime field */ + RTE_CRYPTO_EC_CURVE_x25519, + /**< Curve 25519 */ + RTE_CRYPTO_EC_CURVE_LIST_END +}; + +enum rte_crypto_ec_binary_curve { + RTE_CRYPTO_EC_CURVE_NOT_SPECIFIED = -1, + /**< Unspecified or empty curve id */ + RTE_CRYPTO_EC_CURVE_sect113r1, + /**< SECG curve over a 113 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect113r2, + /**< SECG curve over a 113 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect131r1, + /**< SECG/WTLS curve over a 131 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect131r2, + /**< SECG curve over a 131 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect163k1, + /**< NIST/SECG/WTLS curve over a 163 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect163r1, + /**< SECG curve over a 163 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect163r2, + /**< NIST/SECG curve over a 163 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect193r1, + /**< SECG curve over a 193 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect193r2, + /**< SECG curve over a 193 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect233k1, + /**< NIST/SECG/WTLS curve over a 233 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect233r1, + /**< NIST/SECG/WTLS curve over a 233 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect239k1, + /**< SECG curve over a 239 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect283k1, + /**< NIST/SECG curve over a 283 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect283r1, + /**< NIST/SECG curve over a 283 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect409k1, + /**< NIST/SECG curve over a 409 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect409r1, + /**< NIST/SECG curve over a 409 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect571k1, + /**< NIST/SECG curve over a 571 bit binary field */ + RTE_CRYPTO_EC_CURVE_sect571r1, + /**< NIST/SECG curve over a 571 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2pnb163v1, + /**< X9.62 curve over a 163 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2pnb163v2, + /**< X9.62 curve over a 163 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2pnb163v3, + /**< X9.62 curve over a 163 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2pnb176v1, + /**< X9.62 curve over a 176 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2tnb191v1, + /**< X9.62 curve over a 191 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2tnb191v2, + /**< X9.62 curve over a 191 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2tnb191v3, + /**< X9.62 curve over a 191 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2pnb208w1, + /**< X9.62 curve over a 208 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2tnb239v1, + /**< X9.62 curve over a 239 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2tnb239v2, + /**< X9.62 curve over a 239 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2tnb239v3, + /**< X9.62 curve over a 239 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2pnb272w1, + /**< X9.62 curve over a 272 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2pnb304w1, + /**< X9.62 curve over a 304 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2tnb359v1, + /**< X9.62 curve over a 359 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2pnb368w1, + /**< X9.62 curve over a 368 bit binary field */ + RTE_CRYPTO_EC_CURVE_c2tnb431r1, + /**< X9.62 curve over a 431 bit binary field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls1, + /**< WTLS curve over a 113 bit binary field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls3, + /**< NIST/SECG/WTLS curve over a 163 bit binary field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls4, + /**< SECG curve over a 113 bit binary field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls5, + /**< X9.62 curve over a 163 bit binary field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls10, + /**< NIST/SECG/WTLS curve over a 233 bit binary field */ + RTE_CRYPTO_EC_CURVE_wap_wsg_idm_ecid_wtls11, + /**< NIST/SECG/WTLS curve over a 233 bit binary field */ + RTE_CRYPTO_EC_CURVE_LIST_END +}; + +/** + * Elliptic curve point format + */ +struct rte_crypto_ec_point { + struct { + int length; + uint8_t *data; + phys_addr_t phys_addr; + /**< phys_addr is used only for points passed in the + * asym_op structure. + */ + } x; + /**< X co-ordinate */ + + struct { + int length; + uint8_t *data; + phys_addr_t phys_addr; + /**< phys_addr is used only for points passed in the + * operation structure + */ + } y; + /**< Y co-ordinate */ +}; + +/** + * Elliptic curve type + */ +enum rte_crypto_ec_curve_type { + RTE_CRYPTO_EC_CURVE_TYPE_UNDEFINED, + /**< Curve type undefined */ + RTE_CRYPTO_EC_CURVE_TYPE_PRIME_FIELD, + /**< EC curve defined over a prime field */ + RTE_CRYPTO_EC_CURVE_TYPE_BINARY_FIELD, + /**< EC curve defined over a binary field */ + RTE_CRYPTO_EC_CURVE_LIST_END +}; + +/** + * Elliptic curve id + */ +struct rte_crypto_ec_curve_id { + RTE_STD_C11 + union { + enum rte_crypto_ec_prime_curve pcurve; + enum rte_crypto_ec_binary_curve bcurve; + } +}; + +/** + * Asymmetric RSA transform data + * + * This structure contains data required to perform RSA crypto + * transform. If all CRT components are filled, RSA private key + * operations @ref RTE_CRYPTO_RSA_OP_SIGN and @ref + * RTE_CRYPTO_RSA_OP_PRIVATE_DECRYPT uses CRT method for crypto + * transform. + */ +struct rte_crypto_rsa_xform { + + rte_crypto_xform_param n; + /**< n - Prime modulus + * Prime modulus data of RSA operation in Octet-string network + * byte order format. + */ + + rte_crypto_xform_param e; + /**< e - Public key exponent + * Public key exponent used for RSA public key operations in Octet- + * string network byte order format. + */ + + rte_crypto_xform_param d; + /**< d - Private key exponent + * Private key exponent used for RSA private key operations in + * Octet-string network byte order format. + */ + + rte_crypto_xform_param p; + /**< p - Private key component P + * Private key component of RSA parameter required for CRT method + * of private key operations in Octet-string network byte order + * format. + */ + + rte_crypto_xform_param q; + /**< q - Private key component Q + * Private key component of RSA parameter required for CRT method + * of private key operations in Octet-string network byte order + * format. + */ + + rte_crypto_xform_param dP; + /**< dP - Private CRT component + * Private CRT component of RSA parameter required for CRT method + * RSA private key operations in Octet-string network byte order + * format. + * dP = d mod ( p - 1 ) + */ + + rte_crypto_xform_param dQ; + /**< dQ - Private CRT component + * Private CRT component of RSA parameter required for CRT method + * RSA private key operations in Octet-string network byte order + * format. + * dQ = d mod ( q - 1 ) + */ + + rte_crypto_xform_param qInv; + /**< qInv - Private CRT component + * Private CRT component of RSA parameter required for CRT method + * RSA private key operations in Octet-string network byte order + * format. + * qInv = inv q mod p + */ +}; + +/** Asymmetric Modular exponentiation transform data + * + * This structure contains data required to perform modular exponentation + * crypto transform. If all CRT components are valid, crypto transform + * operation follows CRT method. + */ +struct rte_crypto_modex_xform { + + rte_crypto_xform_param modulus; + /**< modulus + * Prime modulus of the modexp transform operation in Octet-string + * network byte order format. + */ + + rte_crypto_xform_param exponent; + /**< exponent + * Private exponent of the modexp transform operation in + * Octet-string network byte order format. + */ +}; + +/** Asymmetric DH transform data + * This structure contains data used to perform DH key + * computation + */ +struct rte_crypto_dh_xform { + rte_crypto_xform_param p; + /**< p : Prime modulus data + * DH prime modulous data in Octet-string network byte order format. + */ + + rte_crypto_xform_param g; + /**< g : Generator + * DH group generator data in Octet-string network byte order + * format. + */ + + rte_crypto_xform_param priv_key; + /**< priv_key + * DH private key data in Octet-string network byte order format. + */ + + rte_crypto_xform_param pub_key; + /**< pub_key + * DH public key data in Octet-string network byte order format. + */ +}; + +/**Asymmetric ECDH transform data + * This structure contains data required to perform ECDH crypto + * transform + */ +struct rte_crypto_ecdh_xform { + + enum rte_crypto_ec_curve_type curve_type; + /**< ECDH curve type: Prime vs Binary */ + + struct rte_crypto_ec_curve_id curve_id; + + rte_crypto_xform_param n; + /**< n : order + * ECDH curve order data in Octet-string network byte order format. + */ + + rte_crypto_xform_param p; + /**< p: + * If the curve_type is @ref RTE_CRYPTO_EC_CURVE_TYPE_PRIME_FIELD: + * p holds the prime modulus data in Octet string format. + * + * If the curve_type is @ref RTE_CRYPTO_EC_CURVE_TYPE_BINARY_FIELD: + * p holds reduction polynomial co-efficients and degree. + */ + + rte_crypto_xform_param a; + /**< Co-efficient 'a' of curve equation data in Octet-string network + * byte order format. + */ + + rte_crypto_xform_param b; + /**< Co-efficient 'b' of curve equation data in Octet-string network + * byte order format. + */ + + struct rte_crypto_ec_point G; + /**< G: EC curve generator + * EC curve generator point data in Octet-string network byte order + * format. + */ + + rte_crypto_xform_param pkey; + /**< pkey: Private key + * Private key data for ECDH operation in Octet-string network byte + * order format. + */ + + struct rte_crypto_ecpoint Q; + /**< Q: Public key point + * Public key point data of ECDH operation in Octet-string network + * byte order format. + */ + + int h; + /**< Co-factor of the curve */ +}; + +/** Asymmetric Digital Signature transform operation + * + * This structure contains data required to perform asymmetric + * digital signature crypto transform. + */ +struct rte_crypto_dsa_xform { + + rte_crypto_xform_param p; + /**< p - Prime modulus + * Prime modulus data for DSA operation in Octet-string network byte + * order format. + */ + + rte_crypto_xform_param q; + /**< q : Order of the subgroup + * Order of the subgroup data in Octet-string network byte order + * format. + * q % (p-1) = 0 + */ + + rte_crypto_xform_param g; + /**< g: Generator of the subgroup + * Generator data in Octet-string network byte order format. + */ + + rte_crypto_xform_param x; + /**< x: Private key of the signer + * Private key data in Octet-string network byte order format. + * Private key is valid only for signature generation operation. + */ + + rte_crypto_xform_param y; + /**< y : Public key of the signer. + * Public key data of the signer in Octet-string network byte order + * format. + * y = g^x mod p + */ +}; + +/** Asymmetric ECDSA transform data + * + * This structure contains data required to perform ECDSA crypto + * transform. + */ +struct rte_crypto_ecdsa_xform { + + enum rte_crypto_ec_curve_type curve_type; + /**< ECDSA curve type: Prime vs Binary */ + + struct rte_crypto_ec_curve_id curve_id; + /**< EC curve ID */ + + rte_crypto_xform_param n; + /**< n : order + * ECDH curve order data in Octet-string network byte order format. + */ + + rte_crypto_xform_param p; + /**< p: + * If the curve_type is @ref RTE_CRYPTO_EC_CURVE_TYPE_PRIME_FIELD: + * p holds the prime modulus data in Octet string format. + * + * If the curve_type is @ref RTE_CRYPTO_EC_CURVE_TYPE_BINARY_FIELD: + * p holds reduction polynomial co-efficients and degree. + */ + + rte_crypto_xform_param a; + /**< Co-efficient 'a' of curve equation data in Octet-string network + * byte order format. + */ + + rte_crypto_xform_param b; + /**< Co-efficient 'b' of curve equation data in Octet-string network + * byte order format. + */ + + struct rte_crypto_ecpoint G; + /**< G: EC curve generator + * EC curve generator point data in Octet-string network byte order + * format. + */ + + rte_crypto_xform_param pkey; + /**< pkey: Private key + * Private key data of the signer for ECDSA signature generation + * operation in Octet-string network byte format. Parameter is + * invalid or unsed for signature verification. + */ + + struct rte_crypto_ecpoint Q; + /**< Q: Public key point + * Public key point data of ECDSA operation in Octet-string network + * byte order format. + */ + + int h; + /**< Co-factor of the curve */ +}; + +/** Asymmetric modular inverse transform operation + * This structure contains data required to perform + * asymmetric modular inverse crypto transform + */ +struct rte_crypto_modinv_xform { +}; + +/** Asymmetric Fundamental ECC transform operation + * + * This structure contains data required to perform asymmetric + * fundamental ECC crypto transform. + */ +struct rte_crypto_fecc_xform { + + enum rte_crypto_ec_curve_type curve_type; + /**< FECC curve type: Prime vs Binary */ + + struct rte_crypto_ec_curve_id curve_id; + /**< EC curve ID */ + + rte_crypto_xform_param order; + /**< order : ECC curve order + * Curve order data in Octet-string network byte order format. + */ + + rte_crypto_xform_param prime; + /**< prime : Curve prime modulus data + * Prime modulus data in Octet-string network byte order format. + */ + + struct rte_crypto_ec_point G; + /**< G: curve generator point + * Curve generator point data in Octet-string network byte order + * format. + */ + + rte_crypto_xform_param a; + /**< Co-efficient 'a' of curve equation data in Octet-string network + * byte order format. + */ + + rte_crypto_xform_param b; + /**< Co-efficient 'a' of curve equation data in Octet-string network + * byte order format. + */ + + int h; + /**< Co-factor of the curve */ + +}; + +/** + * Asymmetric crypto transform data + * + * This structure contains the data required to perform the + * asymmetric crypto transformation operation. The field op + * determines the asymmetric algorithm for transformation. + */ +struct rte_crypto_asym_xform { + struct rte_crypto_asym_xform *next; + enum rte_crypto_asym_xform_type xform_type; + /**< Asymmetric algorithm for crypto transform */ + + RTE_STD_C11 + union { + struct rte_crypto_rsa_xform rsa; + struct rte_crypto_fecc_xform fecc; + struct rte_crypto_modex_xform modex; + struct rte_crypto_ecdsa_xform ecdsa; + struct rte_crypto_ecdh_xform ecdh; + struct rte_crypto_dsa_xform dsa; + }; +}; + +struct rte_cryptodev_asym_session; + +/** + * Crypto operation session type. This is used to specify whether a crypto + * operation has session structure attached for immutable parameters or if all + * operation information is included in the operation data structure. + */ +enum rte_crypto_asym_op_sess_type { + RTE_CRYPTO_ASYM_OP_WITH_SESSION, + /**< Session based crypto operation */ + RTE_CRYPTO_ASYM_OP_SESSIONLESS + /**< Session-less crypto operation */ +}; + +/** + * Asymmetric Cryptographic Operation. + * + * This structure contains data relating to performing asymmetric cryptographic + * operation. + * + */ +struct rte_crypto_asym_op { + + enum rte_crypto_asym_op_sess_type sess_type; + enum rte_crypto_asym_xform_type type; + + RTE_STD_C11 + union { + enum rte_crypto_rsa_optype rsa_op; + /**< Type of RSA operation for transform */; + enum rte_crypto_modex_optype modex_op; + /**< Type of modular exponentiation operation */ + enum rte_crypto_ecdsa_optype ecdsa_op; + /**< ECDSA crypto xform operation type */ + enum rte_crypto_fecc_optype fecc_op; + /**< ECDSA crypto xform operation type */ + enum rte_crypto_dsa_optype dsa_op; + /**< DSA crypto xform operation type */ + }; + + RTE_STD_C11 + union { + struct rte_cryptodev_asym_session *session; + /**< Handle for the initialised session context */ + struct rte_crypto_asym_xform *xform; + /**< Session-less API crypto operation parameters */ + }; + + RTE_STD_C11 + union { + + struct { + rte_crypto_op_param message; + /**< + * Pointer to data + * - to be encrypted for RSA public encrypt. + * - to be decrypted for RSA private decrypt. + * - to be signed for RSA sign generation. + * - to be authenticated for RSA sign verification. + */ + + rte_crypto_op_param sign; + /**< + * Pointer to RSA signature data. If operation is RSA + * sign @ref RTE_CRYPTO_RSA_OP_SIGN, buffer will be + * over-written with generated signature. + * + * Length of the signature data will be equal to the + * RSA prime modulus length. + */ + + enum rte_crypto_rsa_padding_type pad; + /**< RSA padding scheme to be used for transform */ + + enum rte_crypto_auth_algorithm md; + /**< Hash algorithm to be used for data hash if padding + * scheme is either OAEP or PSS. Valid hash algorithms + * are: + * MD5, SHA1, SHA224, SHA256, SHA384, SHA512 + */ + + enum rte_crypto_auth_algorithm mgf1md; + /**< + * Hash algorithm to be used for mask generation if + * padding scheme is either OAEP or PSS. If padding + * scheme is unspecified data hash algorithm is used + * for mask generation. Valid hash algorithms are: + * MD5, SHA1, SHA224, SHA256, SHA384, SHA512 + */ + } rsa; + + struct { + rte_crypto_op_param pub_key; + /**< + * If DH operation type is + * KEY_GENERATION: + * if priv_key and public key are provided, the keys + * are copied to DH xform structure, else key pair is + * generated and stored in DH xform structure. + * pub_key data should be in Octet-string network + * byte order format. + * + * KEY_COMPUTATION: + * pub_key holds the key shared by peer during DH + * key exchange. pub_key data is written as Octet- + * string network byte order format. + */ + RTE_STD_C11 + union { + rte_crypto_op_param priv_key; + /**< + * If DH operation type is KEY_GENERATION, and + * priv_key is provided, the key is copied to + * DH xform structure, else generated and stored + * in DH xform structure. priv_key data is in + * in Octet-string network byte order format. + */ + rte_crypto_op_param shared_key; + /* + * If DH operation type is KEY_COMPUTATION: + * shared_key holds the shared secret + * computed. shared_key is written as + * Octet-string network byte order format. + */ + }; + } dh; + + struct { + rte_crypto_op_param base; + /**< + * Pointer to base of modular exponentiation data in + * Octet-string network byte order format. + */ + } modex; + + struct { + rte_crypto_op_param priv_key; + /**< + * If ECDH operation type is KEY_GENERATION, and + * priv_key is provided, the key is copied to ECDH + * xform structure, else generated and stored in + * ECDH xform structure in Octet-string network byte + * order. + * If ECDH operation type is KEY_COMPUTATION: + * priv_key holds the 'X' co-ordinate of the shared + * secret EC point computed in Octet-string network + * byte order. + */ + + rte_crypto_ec_point pub_key; + /**< + * If ECDH operation type is + * KEY_GENERATION: + * if priv_key and public key are provided, the keys + * are copied ECDH xform structure, else key pair is + * generated and stored in ECDH xform structure. + * + * KEY_COMPUTATION: + * pub_key holds peer's public key during ECDH + * key exchange in Octet-string network byte order. + */ + } ecdh; + + struct { + rte_crypto_op_param message; + /**< + * Pointer to data + * - to be signed for ECDSA signature generation. + * - to be authenticated for ECDSA sign verification. + */ + + rte_crypto_op_param sign; + /**< + * Pointer to ECDSA signature. If operation type is + * @ref RTE_CRYPTO_ECDSA_OP_VERIFY this buffer will be + * over-written with the signature. + * + * Length of ECDSA signature will be less than twice the + * length of prime modulus length. + */ + + rte_crypto_op_param k; + /**< + * Pointer to random scalar to be used for generation + * of ECDSA signature @ref RTE_CRYPTO_ECDSA_OP_SIGN. + * It is invalid if operation is ECDSA verify. + * Scalar data is in Octet-string network byte order + * format. + * + * Length of scalar K should be less than the prime + * modulus of the curve + */ + } ecdsa; + + struct { + + rte_crypto_op_param message; + /**< + * Pointer to data + * - to be signed for DSA signature generation. + * - to be authenticated for DSA sign verification. + * + * Length of data to be signed, if is more than + * prime modulus length, is truncated to length of + * prime modulus. + */ + + rte_crypto_op_param k; + /**< + * Pointer to random scalar to be used for DSA + * signature generation. K should be a non-zero number + * less than q. k is in Octet-string network byte + * order format. + */ + + } dsa; + + struct { + struct rte_crypto_ec_point p; + /**< + * Pointer to primary curve point for fundamental + * ECC operation. Data is in Octet-string network + * byte order format. + * Length of data in bytes cannot exceed the prime + * modulus length of the curve. + */ + + struct rte_crypto_ec_point q; + /**< + * + * Pointer to secondary curve point for fundamental + * ECC operation. Data is in Octet-string network + * byte order format. + * + * Length of data in bytes cannot exceed the prime + * modulus length of the curve. This point is valid + * only for point addition optype + * RTE_CRYPTO_FECC_OP_POINT_ADD crypto transform. + */ + + rte_crypto_op_param k; + /**< + * Pointer to scalar data to be used only for point + * multiplication @ref RTE_CRYPTO_FECC_OP_POINT_MULTIPLY + * crypto transform. Data is in Octet-string network + * byte order format. + * + * Length of data in bytes cannot exceed the prime + * modulus length of the curve. + */ + + struct rte_crypto_ec_point r; + /**< + * Pointer to the resultant point on the curve after + * fundamental ECC crypto transform. Data is in + * Octet-string network byte order format. + * Length of data in bytes cannot exceed the prime + * modulus length of the curve. + */ + + } fecc; + + struct { + + rte_crypto_op_param prime; + /**< + * Pointer to the prime modulus data for modular + * inverse operation in Octet-string network byte + * order format. + */ + + rte_crypto_op_param base; + /**< + * Pointer to the base for the modular inverse + * operation in Octet-string network byte order + * format. + */ + } modinv; + }; + +} __rte_cache_aligned; + + + +/** + * Reset the fields of an asymmetric operation to their default values. + * + * @param op The crypto operation to be reset. + */ +static inline void +__rte_crypto_asym_op_reset(struct rte_crypto_asym_op *op) +{ + memset(op, 0, sizeof(*op)); + + op->sess_type = RTE_CRYPTO_ASYM_OP_SESSIONLESS; +} + + +/** + * Allocate space for asymmetric crypto xforms in the private data space of the + * crypto operation. This also defaults the crypto xform type to + * RTE_CRYPTO_ASYM_XFORM_NOT_SPECIFIED and configures the chaining of the xforms + * in the crypto operation + * + * @return + * - On success returns pointer to first crypto xform in crypto operations chain + * - On failure returns NULL + */ +static inline struct rte_crypto_asym_xform * +__rte_crypto_asym_op_asym_xforms_alloc(struct rte_crypto_asym_op *asym_op, + void *priv_data, uint8_t nb_xforms) +{ + struct rte_crypto_asym_xform *xform; + + asym_op->xform = xform = (struct rte_crypto_asym_xform *)priv_data; + + do { + xform->type = RTE_CRYPTO_ASYM_XFORM_NOT_SPECIFIED; + xform = xform->next = --nb_xforms > 0 ? xform + 1 : NULL; + } while (xform); + + return asym_op->xform; +} + + +/** + * Attach a session to an asymmetric crypto operation + * + * @param asym_op crypto operation + * @param sess cryptodev session + */ +static inline int +__rte_crypto_asym_op_attach_asym_session(struct rte_crypto_asym_op *asym_op, + struct rte_cryptodev_asym_session *sess) +{ + asym_op->session = sess; + asym_op->sess_type = RTE_CRYPTO_ASYM_OP_WITH_SESSION; + + return 0; +} + + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_CRYPTO_ASYM_H_ */