From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0085.outbound.protection.outlook.com [104.47.36.85]) by dpdk.org (Postfix) with ESMTP id 29B851CAF9 for ; Thu, 5 Apr 2018 13:26:05 +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=Unbb7NCvi6A8vbZK8E6L6FYwu4V/gw70J1pBJLKztSI=; b=l0yDLGcQ/BX4dfu81esgl8Aqu+Q6KZfLOfn24aym+WJ1H02Xo+UdC4Zlyx89nj83yq1Q7l3C6UP0Me/AW1mM+No0P2WGpggLpQDSHXp1zhrz77PEgFknCxuUfFKlRW78XOxsY8zV8yzTsulL5dE512o28LOKASd+egF5jwkZGr0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by CY4PR0701MB3634.namprd07.prod.outlook.com (2603:10b6:910:92::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Thu, 5 Apr 2018 11:26:00 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: declan.doherty@intel.com, fiona.trahe@intel.com, pathreya@caviumnetworks.com, ssahu@caviumnetworks.com, agupta@caviumnetworks.com, dev@dpdk.org, Sunila Sahu , Ashish Gupta Date: Thu, 5 Apr 2018 16:54:44 +0530 Message-Id: <1522927489-23668-2-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522927489-23668-1-git-send-email-shally.verma@caviumnetworks.com> References: <1522927489-23668-1-git-send-email-shally.verma@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BM1PR0101CA0013.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::23) To CY4PR0701MB3634.namprd07.prod.outlook.com (2603:10b6:910:92::36) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1d1ec92-1f62-4cab-5ba5-08d59ae80408 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR0701MB3634; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3634; 3:DDl9g1bGhokXIfrhQkFuOVFtc7tUV50vCuL3h0SuPyIwK0ak7acFbRgx+O/PHs9RHcDcDrsbXQOnohjHwizBUwlL+gMRF37HOQ1FOJ9ui6HQCi63n8gg6OZ1TAKPe4X3n638X0KmMb6x7NP9MEoywZ4kxqsUoW4D7bt8bQMKyJyiCdNBpnEfO+LyOxPpEQG6AFJ2DG3QPrn3IVLt0yZe18FMlfBInh5lcdDzGlKSgSKNeD6lLogrOGq5u5qW/zDk; 25:5giA/iyiBqnIll+LYjgENSU0X+36id23fYdBYxrx+wG6cwy7YFBSk8qTK6RPgd18Buli/jrh4pW87/WdqIXYqT9WT3IkOtw1Nw/Jg9wuu0WUBc+UzZoWQ98D2ST4OiDm/ytgLO6NmpuhrgPPPy+aVcHtRVBqt/yO34WqJZYiZFBkHakszqdKftd2HIXFmeYwAN041grzyJaRk4LNgc8h4HPwQEJV4oSRg0McPtj1q5ugC+GZCMoSfkrp/cWXEkLnjOcf77dKn9yFdkfNiqabDl2lNr9HhaEs9bXT3FMMEont91VYatZyNaCS2VsDERdA3c9kbTqqRzKk9ukpaKItTw==; 31:ns6aYwmHgwziSGrgbW1yzKyUVF6bB1hvO3Fc1ZrG9fOwK3q+PEv63zff4YZBhtBTupa/own0tf2UFPFaedv0zyym4Vh+QsrMZVFIY5PWeknoy7EeCYzfgFYtqlQLTxrSnv+zCFfTamj1hDnINqwTXh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VS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231221)(944501327)(52105095)(93006095)(10201501046)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY4PR0701MB3634; BCL:0; PCL:0; RULEID:; SRVR:CY4PR0701MB3634; X-Forefront-PRVS: 06339BAE63 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39380400002)(366004)(376002)(396003)(39860400002)(199004)(189003)(72206003)(478600001)(59450400001)(106356001)(6116002)(47776003)(575784001)(7736002)(6486002)(55236004)(386003)(3846002)(4326008)(42882007)(66066001)(105586002)(486006)(2361001)(76176011)(6506007)(305945005)(25786009)(51416003)(16526019)(69596002)(5660300001)(186003)(2351001)(26005)(6916009)(36756003)(53416004)(6666003)(54906003)(48376002)(8936002)(52116002)(81156014)(476003)(8676002)(2616005)(956004)(11346002)(97736004)(446003)(68736007)(53936002)(6512007)(5890100001)(2906002)(316002)(107886003)(16586007)(50226002)(81166006)(50466002)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3634; H:hyd1sverma-dt.caveonetworks.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR0701MB3634; 23:5+0Dr3twk7AAGGLlVa6/hBzKAOb/K+m3NSZYjPK?= =?us-ascii?Q?eq5WL3MUKH/crXRx+0/tXs1/mNmD11/y7F7nyLK9uwy9dQqkmIvgJ6zPx9uH?= =?us-ascii?Q?F4ODbCgUyPefjr1QPqWCwNU4NkYZOAXUx5m1FDIZDHT4zey5gsmcppaJ3dmo?= =?us-ascii?Q?Bm/6o1JBw8JaoxQ4Szu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-ascii?Q?PSZYFbNTJ9ZL1j7oCzTiYIH0MLr6Ym81YCv5tSRgqHgCThYDsg1Xna/s/AVH?= =?us-ascii?Q?bNp/fyjSptBG9adttkodqkvM9Oz+txKn1rb5drtgwklYgXrZxjVCmAXWLoWi?= =?us-ascii?Q?xB8tJ74U1KVHlJBsw1G0J1XERv+3eExoYIOQ5RROHdRUlR05LAojzyEv3x6s?= =?us-ascii?Q?fVLTfbwg3L6R+yuTeLqOZFSmBunCwjvJm7HrAJvXkpqLMdErEsdyWIqUsnHm?= =?us-ascii?Q?Q7u6fYHF7msK60BzFwOSXXp/s2qIGKWRVDiTdDEoYrTCgANkj+lSupMCqH/y?= =?us-ascii?Q?IUPXkCUZ+T7281A+tdlKlX75Hn96UDR2B853/SagtdCO9hR/Xbh1uBXZewkq?= =?us-ascii?Q?yuOMF+CzPHM1BYJdorTjTUdBsEe1PEWU=3D?= X-Microsoft-Antispam-Message-Info: IygYDRTxcIcfQsrJ3373ttB7s8HtjlPVdEl/f7jV2Fb7Jv9n8vPgagGOUw2n/Ljo2Of3ULa3EuleVK88F++sxhwrf38u6+A6ErD4lasYHhpPBGKFRUeOhd7PnHd8i4CDRdOGU+liM36v57h9RASS7T2LIT1nvdU3Gx3JXvVVBQABUsG2isgh55jwspzMBFRD X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3634; 6:4RSsynWydoiCyJMd4UtWl222yxMDFmaE63zI6UkDcnh6T/IHRQvCHcl3QVckVseXhDMZpPjH89Qr6e21OFrWJLGuA+ATBYeXOUJf1C+VNc8C3OJIt67rTdUmQwNO1lhXLhZRpBY7z+QNcdVoZyrpk4rZIWRzsTf//qLpF1FNWACjtPnc+80CXWdgkhVHQabuWjL1ou1xvYp5DvSce6xUq7gXiQCLubi6ma6AnA/nHAfHPAm4vcW+m614mNgBEKCltPVPgVDTGT0JtcsRwfKd/Noj+bjHOvPKmk4ed2rbp9yV3+/0TUPEHR0aUTLRdXWqF2spM2oG2qtKWv+NxOil9ude/ztknsU1/1NKqZkspZvmr5pezBX+JBJBOjuY0MnpWx9/bFV85Vnj/QPJBGNQOx0T41QM6Gg4TxZ17c5UEyH7MVvDacwylCstTb4J4gWgXBupKN4M6oDefyoME6jccQ==; 5:uApGN9or7O64VtTWh+kDWgXZ9J1z4kwM5YwxkkncioJiafEmyp3QDuqhULS6gFDetq6IGMQ9JBvJaR4cVBsjin7Non8KzRlgwd5jByPHJW+W03uN3ksOifG3FpQJIerWUy1OE2UhIf3rfEEaoJhVqobDSUMxWpN9ddkICyDg7is=; 24:lY+gmiyxCWk4N4VXsbzmkScQ5Bx6XIDOEPT1vBDDjHihcfCm7bLDIsQV8Tb94L/WRd0HwoYZhpIsForwozM4hmzJzgBI0/lnAjkZS08YYbA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3634; 7:4ibu1H1OV76RxyfoYfI4FbCGtKjpWdzo7GvbGbuLaOs/gE9UViGUuYiFF8BbyPKxEe3GRGBL2O0jV2gVU7Sz5lU4N26qBwAANTv4g/nhhA4FBnF/p/2qquScf4Y2hcJn7C24gWNa9yRuHPax1KWXZXb5A5OF2/wGjRCH8BWLx8faCa3MIi/KzcNtQ9zic3zHlpk7xriUa50k1wGhCz4efiMgFkUI90uZ9ZoeWFBXT7uaV0zKoE1Vb8oA1IA/hsM6 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2018 11:26:00.5199 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1d1ec92-1f62-4cab-5ba5-08d59ae80408 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3634 Subject: [dpdk-dev] [PATCH v2 1/6] lib/cryptodev: add asymmetric algos in cryptodev 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: , X-List-Received-Date: Thu, 05 Apr 2018 11:26:06 -0000 Add rte_crypto_asym.h with supported xfrms and associated op structures and APIs API currently supports: - RSA Encrypt, Decrypt, Sign and Verify - Modular Exponentiation and Inversion - DSA Sign and Verify - Deffie-hellman private key exchange - Deffie-hellman public key exchange - Deffie-hellman shared secret compute - Deffie-hellman public/private key pair generation using xform chain Signed-off-by: Shally Verma Signed-off-by: Sunila Sahu Signed-off-by: Ashish Gupta --- lib/librte_cryptodev/Makefile | 3 +- lib/librte_cryptodev/rte_crypto_asym.h | 519 +++++++++++++++++++++++++++++++++ 2 files changed, 521 insertions(+), 1 deletion(-) diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile index bba8dee..93f9d2d 100644 --- a/lib/librte_cryptodev/Makefile +++ b/lib/librte_cryptodev/Makefile @@ -12,6 +12,7 @@ LIBABIVER := 4 # build flags CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -DALLOW_EXPERIMENTAL_API LDLIBS += -lrte_eal -lrte_mempool -lrte_ring -lrte_mbuf LDLIBS += -lrte_kvargs @@ -23,7 +24,7 @@ SYMLINK-y-include += rte_crypto.h SYMLINK-y-include += rte_crypto_sym.h SYMLINK-y-include += rte_cryptodev.h SYMLINK-y-include += rte_cryptodev_pmd.h - +SYMLINK-y-include += rte_crypto_asym.h # versioning export map EXPORT_MAP := rte_cryptodev_version.map diff --git a/lib/librte_cryptodev/rte_crypto_asym.h b/lib/librte_cryptodev/rte_crypto_asym.h new file mode 100644 index 0000000..d0e2f1d --- /dev/null +++ b/lib/librte_cryptodev/rte_crypto_asym.h @@ -0,0 +1,519 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017-2018 Cavium Networks + */ + +#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 + +typedef struct rte_crypto_param_t { + uint8_t *data; + /**< pointer to buffer holding data */ + rte_iova_t iova; + /**< IO address of data buffer */ + size_t length; + /**< length of data in bytes */ +} rte_crypto_param; + +/** asym xform type name strings */ +extern const char * +rte_crypto_asym_xform_strings[]; + +/** asym operations type name strings */ +extern const char * +rte_crypto_asym_op_strings[]; + +/** + * Asymmetric crypto transformation types. + * Each xform type maps to one asymmetric algorithm + * performing specific operation + * + */ +enum rte_crypto_asym_xform_type { + RTE_CRYPTO_ASYM_XFORM_UNSPECIFIED = 0, + /**< Invalid xform. */ + RTE_CRYPTO_ASYM_XFORM_NONE, + /**< Xform type None. + * May be supported by PMD to support + * passthrough op for debugging purpose. + * if xform_type none , op_type is disregarded. + */ + RTE_CRYPTO_ASYM_XFORM_RSA, + /**< RSA. Performs Encrypt, Decrypt, Sign and Verify. + * Refer to rte_crypto_asym_op_type + */ + RTE_CRYPTO_ASYM_XFORM_DH, + /**< Deffie-Hellman. + * Performs Key Generate and Shared Secret Compute. + * Refer to rte_crypto_asym_op_type + */ + RTE_CRYPTO_ASYM_XFORM_DSA, + /**< Digital Signature Algorithm + * Performs Signature Generation and Verification. + * Refer to rte_crypto_asym_op_type + */ + RTE_CRYPTO_ASYM_XFORM_MODINV, + /**< Modular Inverse + * Perform Modulus inverse b^(-1) mod n + */ + RTE_CRYPTO_ASYM_XFORM_MODEX, + /**< Modular Exponentiation + * Perform Modular Exponentiation b^e mod n + */ + RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END + /**< End of list */ +}; + +/** + * Asymmetric crypto operation type variants + */ +enum rte_crypto_asym_op_type { + RTE_CRYPTO_ASYM_OP_ENCRYPT, + /**< Asymmetric Encrypt operation */ + RTE_CRYPTO_ASYM_OP_DECRYPT, + /**< Asymmetric Decrypt operation */ + RTE_CRYPTO_ASYM_OP_SIGN, + /**< Signature Generation operation */ + RTE_CRYPTO_ASYM_OP_VERIFY, + /**< Signature Verification operation */ + RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE, + /**< DH Private Key generation operation */ + RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE, + /**< DH Public Key generation operation */ + RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE, + /**< DH Shared Secret compute operation */ + RTE_CRYPTO_ASYM_OP_LIST_END +}; + +/** + * Padding types for RSA signature. + */ +enum rte_crypto_rsa_padding_type { + RTE_CRYPTO_RSA_PADDING_NONE = 0, + /**< RSA no padding scheme */ + RTE_CRYPTO_RSA_PKCS1_V1_5_BT0, + /**< RSA PKCS#1 V1.5 Block Type 0 padding scheme + * as descibed in rfc2313 + */ + RTE_CRYPTO_RSA_PKCS1_V1_5_BT1, + /**< RSA PKCS#1 V1.5 Block Type 01 padding scheme + * as descibed in rfc2313 + */ + RTE_CRYPTO_RSA_PKCS1_V1_5_BT2, + /**< RSA PKCS#1 V1.5 Block Type 02 padding scheme + * as descibed in rfc2313 + */ + 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 +}; + +/** + * RSA private key type enumeration + * + * enumerates private key format required to perform RSA crypto + * transform. + * + */ +enum rte_crypto_rsa_priv_key_type { + RTE_RSA_KEY_TYPE_EXP, + /**< RSA private key is an exponent */ + RTE_RSA_KET_TYPE_QT, + /**< RSA private key is in quintuple format + * See rte_crypto_rsa_priv_key_qt + */ +}; + +/** + * Structure describing RSA private key in quintuple format. + * See PKCS V1.5 RSA Cryptography Standard. + */ +struct rte_crypto_rsa_priv_key_qt { + rte_crypto_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_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_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_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_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 RSA transform data + * + * Structure describing RSA xform params + * + */ +struct rte_crypto_rsa_xform { + rte_crypto_param n; + /**< n - Prime modulus + * Prime modulus data of RSA operation in Octet-string network + * byte order format. + */ + + rte_crypto_param e; + /**< e - Public key exponent + * Public key exponent used for RSA public key operations in Octet- + * string network byte order format. + */ + + enum rte_crypto_rsa_priv_key_type key_type; + + union { + rte_crypto_param d; + /**< d - Private key exponent + * Private key exponent used for RSA + * private key operations in + * Octet-string network byte order format. + */ + + struct rte_crypto_rsa_priv_key_qt qt; + /**< qt - Private key in quintuple format */ + }; +}; + +/** + * Asymmetric Modular exponentiation transform data + * + * Structure describing modular exponentation xform param + * + */ +struct rte_crypto_modex_xform { + rte_crypto_param modulus; + /**< modulus + * Prime modulus of the modexp transform operation in octet-string + * network byte order format. + */ + + rte_crypto_param exponent; + /**< exponent + * Private exponent of the modexp transform operation in + * octet-string network byte order format. + */ +}; + +/** + * Asymmetric modular inverse transform operation + * + * Structure describing modulus inverse xform params + * + */ +struct rte_crypto_modinv_xform { + rte_crypto_param modulus; + /**< + * Pointer to the prime modulus data for modular + * inverse operation in octet-string network byte + * order format. + */ +}; + +/** + * Asymmetric DH transform data + * + * Structure describing deffie-hellman xform params + * + */ +struct rte_crypto_dh_xform { + enum rte_crypto_asym_op_type type; + /**< Setup xform for key generate or shared secret compute */ + + rte_crypto_param p; + /**< p : Prime modulus data + * DH prime modulous data in octet-string network byte order format. + * + */ + + rte_crypto_param g; + /**< g : Generator + * DH group generator data in octet-string network byte order + * format. + * + */ +}; + +/** + * Asymmetric Digital Signature transform operation + * + * Structure describing DSA xform params + * + */ +struct rte_crypto_dsa_xform { + rte_crypto_param p; + /**< p - Prime modulus + * Prime modulus data for DSA operation in Octet-string network byte + * order format. + */ + rte_crypto_param q; + /**< q : Order of the subgroup. + * Order of the subgroup data in Octet-string network byte order + * format. + * (p-1) % q = 0 + */ + rte_crypto_param g; + /**< g: Generator of the subgroup + * Generator data in Octet-string network byte order format. + */ + rte_crypto_param x; + /**< x: Private key of the signer in octet-string network + * byte order format. + * Used when app has pre-defined private key. + * Valid only when xform chain is DSA ONLY. + * if xform chain is DH private key generate + DSA, then DSA sign + * compute will use internally generated key. + */ +}; + +/** + * Operations params for modular operations: + * exponentiation and invert + * + */ +struct rte_crypto_mod_op_param { + rte_crypto_param base; + /**< + * Pointer to base of modular exponentiation/inversion data in + * Octet-string network byte order format. + */ +}; + +/** + * Asymmetric crypto transform data + * + * Structure describing asym xforms. + */ +struct rte_crypto_asym_xform { + struct rte_crypto_asym_xform *next; + /**< Pointer to next xform to set up xform chain.*/ + enum rte_crypto_asym_xform_type xform_type; + /**< Asymmetric crypto transform */ + + __extension__ + union { + struct rte_crypto_rsa_xform rsa; + /**< RSA xform parameters */ + + struct rte_crypto_modex_xform modex; + /**< Modular Exponentiation xform parameters */ + + struct rte_crypto_modinv_xform modinv; + /**< Modulus Inverse xform parameters */ + + struct rte_crypto_dh_xform dh; + /**< DH xform parameters */ + + struct rte_crypto_dsa_xform dsa; + /**< DSA xform parameters */ + }; +}; + +struct rte_cryptodev_asym_session; + +/** + * RSA operation params + * + */ +struct rte_crypto_rsa_op_param { + enum rte_crypto_asym_op_type op_type; + /**< Type of RSA operation for transform */; + + rte_crypto_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_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 + */ +}; + +/** + * Deffie-Hellman Operations params. + * @note: + */ +struct rte_crypto_dh_op_param { + rte_crypto_param pub_key; + /**< + * Output generated public key when xform type is + * DH PUB_KEY_GENERATION. + * Input peer public key when xform type is DH + * SHARED_SECRET_COMPUTATION + * pub_key is in octet-string network byte order format. + * + */ + + rte_crypto_param priv_key; + /**< + * Output generated private key if xform type is + * DH PRIVATE_KEY_GENERATION + * Input when xform type is DH SHARED_SECRET_COMPUTATION. + * priv_key is in octet-string network byte order format. + * + */ + + rte_crypto_param shared_secret; + /**< + * Output with calculated shared secret + * when dh xform set up with op type = SHARED_SECRET_COMPUTATION. + * shared_secret is an octet-string network byte order format. + * + */ +}; + +/** + * DSA Operations params + * + */ +struct rte_crypto_dsa_op_param { + enum rte_crypto_asym_op_type op_type; + /**< Signature Generation or Verification */ + rte_crypto_param message; + /**< input message to be signed or verified */ + rte_crypto_param r; + /**< dsa sign component 'r' value + * + * output if op_type = sign generate, + * input if op_type = sign verify + */ + rte_crypto_param s; + /**< dsa sign component 's' value + * + * output if op_type = sign generate, + * input if op_type = sign verify + */ + rte_crypto_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 Cryptographic Operation. + * + * Structure describing asymmetric crypto operation params. + * + */ +struct rte_crypto_asym_op { + struct rte_cryptodev_asym_session *session; + /**< Handle for the initialised session context */ + + __extension__ + union { + struct rte_crypto_rsa_op_param rsa; + struct rte_crypto_mod_op_param modex; + struct rte_crypto_mod_op_param modinv; + struct rte_crypto_dh_op_param dh; + struct rte_crypto_dsa_op_param dsa; + }; +} __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)); +} + +/** + * Attach a session to an asymmetric crypto operation + * + * @param asym_op crypto operation + * @param sess cryptodev session + */ +static inline int +__rte_crypto_op_attach_asym_session(struct rte_crypto_asym_op *asym_op, + struct rte_cryptodev_asym_session *sess) +{ + asym_op->session = sess; + return 0; +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_CRYPTO_ASYM_H_ */ -- 1.9.1