From patchwork Tue Jul 3 15:24:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shally Verma X-Patchwork-Id: 42158 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 [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C7F8F1BF51; Tue, 3 Jul 2018 17:25:20 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0040.outbound.protection.outlook.com [104.47.36.40]) by dpdk.org (Postfix) with ESMTP id 254831BF4C for ; Tue, 3 Jul 2018 17:25:19 +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:X-MS-Exchange-SenderADCheck; bh=G1O6MRPBDcY1eCBuXiC7C0R8CBPI7AhaPFD5N8QCQYI=; b=eJevX0yrLv6/e84rq4q2rry4zNwRonjDGwyyfsFVzn3nh0AJftcuszePO8Bs4DlxGMqBaMi9891y11Xi9ro1IVGiS2mVgHp2H2H8FkSoJdLGrlvAKzG7VucWe7cS3XnBwDh2DaTsNL1wnEW5PsOB8oqsNQ+JvOBKDLofrA+oKAU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by DM5PR0701MB3640.namprd07.prod.outlook.com (2603:10b6:4:7e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.24; Tue, 3 Jul 2018 15:25:15 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, pathreya@caviumnetworks.com, nmurthy@caviumnetworks.com, Sunila Sahu , Ashish Gupta , Umesh Kartha Date: Tue, 3 Jul 2018 20:54:23 +0530 Message-Id: <1530631466-26427-2-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530631466-26427-1-git-send-email-shally.verma@caviumnetworks.com> References: <1530631466-26427-1-git-send-email-shally.verma@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: PN1PR0101CA0014.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:e::24) To DM5PR0701MB3640.namprd07.prod.outlook.com (2603:10b6:4:7e::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f33232fe-e36f-4265-1d95-08d5e0f92eb2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(2017052603328)(7153060)(7193020); SRVR:DM5PR0701MB3640; X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3640; 3:EEv/2GFygDwBe9B2J1EySzwlm/mYOWrkYi84haLfYYUHmapTjGb3WbdPwT8OHPcBWZt6AtSfHyUjMsSovjCUnIiLJPF4H4u779kDuBqGPEfmFpBSxGBY8ztWmSv6r8tgwTKrEEM/2FuQS521qA8Nduik8SFv26P29njLQH0sTN9PlqZgmNHeS841l+CDtKOGjtXV8nGgrfC/I35qzfnKRPjMHWcbnP/tiVw6cVa2D+HsZYRrd/nCUpU9oSsoX7h/; 25:jWtQgq0BOiygSnXzaDNOjmXtlW+B7KbbVJLH8XyUKqCCsKF71I8Vr/Br5zVbm/KlfddThroUkNlp0XVGaHv7ik/lEABXIvqkNZSYy7uPJJGleHXX5ZYmP3jBBzR1Kg4BDN+n2a9E7mZWJMFYM4UVsrtofmOS0A85gu220wNihXHVXNGz5/9sT8PFzgb8w6nT59i9mU+BieRFoS+VBaxxcwca3XPN6yHgmZrH08WawG4uDVJMlSQdVirA49kFK2LADoCGOtK5oJIlZOSiK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KjVfnbAMURibs8Hc0UHIrgOHJ8uKAip7ipyKyZMVQwPsLRdEavb6OGeBKV4WccJU1PNqnbuFojfcvQF2B9RTbxuvT1FHvkwaY32HSmQH9a2cj8w2HeWVE/2cVtp3PY5v6SvQw9v49ljdDS85i/otO8UjAj1eJHze2KLHRBifLvR4WtYepARYdtOQRjUYt+Z7+8BFNcrjQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(10201501046)(3231254)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:DM5PR0701MB3640; BCL:0; PCL:0; RULEID:; SRVR:DM5PR0701MB3640; X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(346002)(376002)(39860400002)(396003)(366004)(199004)(189003)(50226002)(53936002)(55236004)(316002)(6506007)(107886003)(54906003)(42882007)(305945005)(386003)(68736007)(51416003)(7736002)(4326008)(72206003)(8676002)(6486002)(478600001)(25786009)(81156014)(81166006)(76176011)(2361001)(6512007)(97736004)(69596002)(6116002)(16526019)(3846002)(186003)(2351001)(44832011)(5660300001)(6666003)(6916009)(53416004)(8936002)(66066001)(47776003)(476003)(106356001)(16586007)(956004)(2616005)(11346002)(105586002)(2906002)(52116002)(446003)(50466002)(14444005)(26005)(48376002)(36756003)(486006)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR0701MB3640; 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;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YA29+Mdi1SDOPddMuPyF7QdOzMrkRmJ35Q7YiPsLVukpR/oUTqLcAAFwES1DHIDv3h7qi38th5QNT+TuTZV6+DIWIAJcus93KutJGTNGxq5sNW9mzmERhpXu1CrOnX4YqvAaUtYqdd6eOQfv70ICXyFl14Mf/Z7knIA==; 5:dKPx+qCQYoFBjvrSFGZgeryr2A0OEsRaQyfem0KRBOSYH/KqorsSL27s+EbtlyyFo3ue+Hf1eWJ9zznTF9oRAkFFDZn0Hm7Z3Z9i0cP/LnFos0q2UUGYRZvTxuLl+pCtvsGAfmsTn1AXVSdzl3N/yNbDfU5/SMcZzgPWR5S25PE=; 24:1hLTnQIKljqRcZXUSyt7hJi0lctyKPmTXz3f190qnAvulhnKW2zIey1Mr/i+unLk5XUL6swT3E2nUo88V5omAr+FTL8vfshKy6B60i5WJrc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3640; 7:tOuXDeNLzKVeHr4QiYkZD32ImItnLh8r8/lhKSmnnXYZrXAwljUUl33ztBojZSwLwdBoUg1X3tkLeGJvl5HXkh5wLzX1vH81uIS1quq5narNu1Dn4LMO1WseTOtrCx+l/Q15riJavTEiL8+zhj+KOzrzTbSMqEts1Dn0TRN/G9wEzf/M900YMnhnZRflL6+irXWGJlAl1nfRY8R1tHsGyE2LoujjN8QjlQLRbbjyvQ+KQESYV29JSj3D8+BM42UW X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2018 15:25:15.3449 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f33232fe-e36f-4265-1d95-08d5e0f92eb2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0701MB3640 Subject: [dpdk-dev] [PATCH v4 1/4] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Signed-off-by: Umesh Kartha --- lib/librte_cryptodev/Makefile | 1 + lib/librte_cryptodev/meson.build | 3 +- lib/librte_cryptodev/rte_crypto_asym.h | 496 +++++++++++++++++++++++++++++++++ 3 files changed, 499 insertions(+), 1 deletion(-) diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile index bba8dee..c114888 100644 --- a/lib/librte_cryptodev/Makefile +++ b/lib/librte_cryptodev/Makefile @@ -23,6 +23,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/meson.build b/lib/librte_cryptodev/meson.build index bd5fed8..295f509 100644 --- a/lib/librte_cryptodev/meson.build +++ b/lib/librte_cryptodev/meson.build @@ -6,5 +6,6 @@ sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c') headers = files('rte_cryptodev.h', 'rte_cryptodev_pmd.h', 'rte_crypto.h', - 'rte_crypto_sym.h') + 'rte_crypto_sym.h', + 'rte_crypto_asym.h') deps += ['kvargs', 'mbuf'] diff --git a/lib/librte_cryptodev/rte_crypto_asym.h b/lib/librte_cryptodev/rte_crypto_asym.h new file mode 100644 index 0000000..7f88b57 --- /dev/null +++ b/lib/librte_cryptodev/rte_crypto_asym.h @@ -0,0 +1,496 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 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; + + __extension__ + 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; + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_CRYPTO_ASYM_H_ */ From patchwork Tue Jul 3 15:24:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shally Verma X-Patchwork-Id: 42159 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 [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9204B1BF4A; Tue, 3 Jul 2018 17:25:24 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0062.outbound.protection.outlook.com [104.47.36.62]) by dpdk.org (Postfix) with ESMTP id 6DC8F1BF59 for ; Tue, 3 Jul 2018 17:25:22 +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:X-MS-Exchange-SenderADCheck; bh=yCcaYBpKF2EBt9zPzlSFYf5pDnHg+nWJLsMwD32ffzc=; b=lrhnVbrhLOsHDFM2hkbdBGkS0v7IgNVr5yT1ON1HVovnBQzC7+8zj41t3lHklsszv+CYsmKCVVDh0bxe7vgT15QRsX1Cmmx7hm1fNeC5lx2hgt6X4N9SV8fFinlH4lN7IR6srAa6MDz531LSsR8L8zXRo8+5NT6eHd6yrmtPRB4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by DM5PR0701MB3640.namprd07.prod.outlook.com (2603:10b6:4:7e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.24; Tue, 3 Jul 2018 15:25:18 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, pathreya@caviumnetworks.com, nmurthy@caviumnetworks.com, Umesh Kartha , Sunila Sahu , Ashish Gupta Date: Tue, 3 Jul 2018 20:54:24 +0530 Message-Id: <1530631466-26427-3-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530631466-26427-1-git-send-email-shally.verma@caviumnetworks.com> References: <1530631466-26427-1-git-send-email-shally.verma@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: PN1PR0101CA0014.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:e::24) To DM5PR0701MB3640.namprd07.prod.outlook.com (2603:10b6:4:7e::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bff9de47-c88c-4dca-b560-08d5e0f9306b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(2017052603328)(7153060)(7193020); SRVR:DM5PR0701MB3640; X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3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T11G+2Tx589cbPB8aWLeT59inLH/cFrfbBkI74elbH0c7PXmQF+rTUEBBBY0rx43967wflS0cRoO7Navxa1c3dBMb72n15KhDtFPy1cvqfQbnVJRO/nLBIplMaodPCgsabRi3X0n8AsbAHyaWevIhM7t0GrlvRq+uV2HPWuhZEhsBg92wLNKAAJKyB26L18GrG9dkjyizMFwXxJ6iGZnMjjpl4Co2c+T67hFqlm+Kq6HCk+g5zUydAN8UZqnYFNMZxQLm+xUqgvw5NgwHkLT8F33SwJvvDCTyCLL9rYdwDWssGXFp920XDMC4aS4gMi3iFaAgduJxkD2wgfN1tp89hgq+0YhdqqE2AVzFOyUUJivvGLT2+clpZ3wUaGW8w9FN4Okq8AJRrCDoT4hAO1MnqMdu5aRWYMPnJ3ksf7rBRXUW6fuoYc3fXZj0gu+2hG6q8qjw82O1Fgu+gYK+0fhnXVy8U=; 4:47YEzHqmDoJHk0g7KyuhREOrxWNhMPSNL5RFPboEz3IZLsgXxECRRgE0wsaigAFAa9cHgyCp11u17hlUTo3htQAbRRnaq45kCTfvySOa9GEAQMwmAJkC7pZSqqor8IRNTytvuWbSuUlyEWlxar636RPhJpRY4snK43fnPUgDYhThQJMg35uAcM0UTLnp81JeBzxNDUJDnZ1DYcepK9cGmYXAGdaqa4cguZzghYDUgOwKR2+LMe1esmc49uT+R+a6r3AWQvmHmeFuX8jbIH0U9g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(10201501046)(3231254)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:DM5PR0701MB3640; BCL:0; PCL:0; RULEID:; SRVR:DM5PR0701MB3640; X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(346002)(376002)(39860400002)(396003)(366004)(199004)(189003)(50226002)(53936002)(55236004)(316002)(6506007)(107886003)(54906003)(42882007)(305945005)(386003)(68736007)(51416003)(575784001)(7736002)(4326008)(72206003)(8676002)(6486002)(478600001)(25786009)(81156014)(81166006)(76176011)(2361001)(6512007)(97736004)(69596002)(6116002)(16526019)(3846002)(186003)(2351001)(44832011)(5660300001)(6666003)(6916009)(53416004)(8936002)(66066001)(47776003)(476003)(106356001)(16586007)(956004)(2616005)(11346002)(105586002)(2906002)(52116002)(446003)(50466002)(5024004)(14444005)(26005)(48376002)(36756003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR0701MB3640; 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; DM5PR0701MB3640; 23:rMCpSncnbQDBE+8XlPib0Yy5BLUGKDBLW7jeBsI?= bGtuV+XRuRnrhlHDykUOTmLQRGyg34e6h+CvOZV0mSM/OVtcmIH4/Q1TdG2mgDkqjM1aeYT3hhYgR6LqVTygTNc+OyDiTq6Rb68u7vWitM/n9PI0V3tLb2DVawkJdNhapc8LRi6OmgzretfqU6PHob8+hHjTMrR8L2goQBAMlLWTe70P1Fp7Ref2uDh7ZbWsaryxPSalxvC+me+Fcc87zw5+ih6x7t47B8qa4X77F4Jkh50WGDsAWDI2UE6Oz56JJCsXmsBYls7zZxXx0hOY4+9ffLP/FZEKHvebYSgDI0/Y1PY98hC9jCfaJgvEM/fDChQ/WVU/vduaUKmNgg4+yyNFnuh3ZwCaerfDWDbu4+rjpqrnqNqALdEay4HrpDgzXC4lZLtDI4dP8nO0OLTQPOo1loeXxzO1n3LojB3ap0CVfvN47G0hCrvjfJN8obFaUGmiFc7kGV+igXNIHXZO+pyL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tgRl3bsAp96w7MtFY4ucKVlInN8B4hn4V5Mtr16WEzOiFsqFo4+cD1ODdjGs3ZrtI2Fbk1jsDnRUohpeySqQdGb4cZJXhvbAPFpFQA9KROTHHUess32mvotOQeDNW4m74t5bdg1zsomFhjk9wgDu02PWV+bADNWHKQOLME+cJyoL/PsvEsg7Xn+5vUe8q8dTIbHtv+g3stBSREEGELU1E48qQGaQQRWun8iiq2eym3W1s= X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3640; 6:TBmIfC7RiPSx2nFCvbKZjqEi4lH1gpIyDyBWpt/XWsEsg7cLAQfe17bA3r4Ayu3a6f+aZneu+/6CpgtEuVDxrm5mRXnllOiwXaimfkpUDSTd5++fPRGYiHn7oyAMyN+9lxVi2lXjsdspqoM8f+Ug2bsP1h/pl1aIAlI4L9d9rPU+luGslihhe4SPjZzsh+sGO6Vo9JKpOy3iAwWHdBO9QQxagotpzAfYAJyhkFdFX17wcE+D98lJxDY1FPFsxT+D8uXeDihedCmzlzjcivqI3wnB7GFNg8aOC3nKGybNUW4D3zjVPM91a/MknG21qimNiFWe+S3da5hKID4t6dnSB6RRSga5IH4b+xvm7It5lOUXn/99P1DNQAG4suMbOHYN+u6FTjPtsjR3Ro51TlotzrlOmcskugKbmhtwNi9P2iRPpcr2JMfdvTE0GV8nJ4u85Nm+91NpwVp5l/h6YBxA7A==; 5:UZa+hGpnm9qfAYq6Zw38jwNNciHBkVcLOpTeJY4dSc53qHoBikCUNWIjfayJqJcTUFW55QZ8g07GUJh8bkteKQzlPyPjKLNwfdtJd3oB6rdQ2j+pBX3oMFlwex8YatzbLG8o0DhTuhSplxjN1umcPVCyXuSkNC9fiahU+G3YJ7M=; 24:9lwKwY3te8eqCFrLdP98yrvukW9XWd3PTE5F1Grejrlb4zZKocTgd9EuRjmnzNkV+3LyDY1NnUv9jbgpQ6fhX8RmiUYEKPGULnAgMTZ2YFI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3640; 7:oxuBq21lq3IYmia9norMQjvnYvL1DsOqCwgk+iusKIyexDt18TcDucPMEkoH6UHk3JcPYqcK5lv3NNHxu4NSwqZ4W/cXZnpcgE+uv+1S//ENlCSFyWRprp5mCVvL60g6Jqhx3eNxtwONwGmOHBDgZNd3ZyttQ05I3K9XPyCGjRW76cNAYmPm1SpSgHzw7DIJIgkTSOjMvA52Zoq5OC9Sa3fp1ZPnamBeq9Jc+toxKltB0UsNCFDnW75XITnGV4l0 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2018 15:25:18.2570 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bff9de47-c88c-4dca-b560-08d5e0f9306b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0701MB3640 Subject: [dpdk-dev] [PATCH v4 2/4] cryptodev: support asymmetric operations 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" From: Umesh Kartha Extend DPDK librte_cryptodev to: - define asym op type in rte_crypto_op_type and associated op pool create/alloc APIs - define asym session and associated session APIs If PMD shows in its feature flag that it supports both sym and asym then it must support those on all its qps. Signed-off-by: Shally Verma Signed-off-by: Sunila Sahu Signed-off-by: Ashish Gupta Signed-off-by: Umesh Kartha --- lib/librte_cryptodev/rte_crypto.h | 37 ++++- lib/librte_cryptodev/rte_cryptodev.c | 201 ++++++++++++++++++++++++- lib/librte_cryptodev/rte_cryptodev.h | 124 ++++++++++++++- lib/librte_cryptodev/rte_cryptodev_pmd.h | 58 ++++++- lib/librte_cryptodev/rte_cryptodev_version.map | 10 +- 5 files changed, 423 insertions(+), 7 deletions(-) diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h index a16be65..fd5ef3a 100644 --- a/lib/librte_cryptodev/rte_crypto.h +++ b/lib/librte_cryptodev/rte_crypto.h @@ -23,6 +23,7 @@ extern "C" { #include #include "rte_crypto_sym.h" +#include "rte_crypto_asym.h" /** Crypto operation types */ enum rte_crypto_op_type { @@ -30,6 +31,8 @@ enum rte_crypto_op_type { /**< Undefined operation type */ RTE_CRYPTO_OP_TYPE_SYMMETRIC, /**< Symmetric operation */ + RTE_CRYPTO_OP_TYPE_ASYMMETRIC + /**< Asymmetric operation */ }; /** Status of crypto operation */ @@ -114,6 +117,10 @@ struct rte_crypto_op { union { struct rte_crypto_sym_op sym[0]; /**< Symmetric operation parameters */ + + struct rte_crypto_asym_op asym[0]; + /**< Asymmetric operation parameters */ + }; /**< operation specific parameters */ }; @@ -134,6 +141,9 @@ __rte_crypto_op_reset(struct rte_crypto_op *op, enum rte_crypto_op_type type) case RTE_CRYPTO_OP_TYPE_SYMMETRIC: __rte_crypto_sym_op_reset(op->sym); break; + case RTE_CRYPTO_OP_TYPE_ASYMMETRIC: + memset(op->asym, 0, sizeof(struct rte_crypto_asym_op)); + break; case RTE_CRYPTO_OP_TYPE_UNDEFINED: default: break; @@ -300,9 +310,14 @@ __rte_crypto_op_get_priv_data(struct rte_crypto_op *op, uint32_t size) if (likely(op->mempool != NULL)) { priv_size = __rte_crypto_op_get_priv_data_size(op->mempool); - if (likely(priv_size >= size)) - return (void *)((uint8_t *)(op + 1) + + if (likely(priv_size >= size)) { + if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) + return (void *)((uint8_t *)(op + 1) + sizeof(struct rte_crypto_sym_op)); + if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) + return (void *)((uint8_t *)(op + 1) + + sizeof(struct rte_crypto_asym_op)); + } } return NULL; @@ -405,6 +420,24 @@ rte_crypto_op_attach_sym_session(struct rte_crypto_op *op, return __rte_crypto_sym_op_attach_sym_session(op->sym, sess); } +/** + * Attach a asymmetric session to a crypto operation + * + * @param op crypto operation, must be of type asymmetric + * @param sess cryptodev session + */ +static inline int +rte_crypto_op_attach_asym_session(struct rte_crypto_op *op, + struct rte_cryptodev_asym_session *sess) +{ + if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_ASYMMETRIC)) + return -1; + + op->sess_type = RTE_CRYPTO_OP_WITH_SESSION; + op->asym->session = sess; + return 0; +} + #ifdef __cplusplus } #endif diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index 7e58212..47fc2e5 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -166,6 +166,31 @@ rte_crypto_aead_operation_strings[] = { [RTE_CRYPTO_AEAD_OP_DECRYPT] = "decrypt" }; +/** + * Asymmetric crypto transform operation strings identifiers. + */ +const char *rte_crypto_asym_xform_strings[] = { + [RTE_CRYPTO_ASYM_XFORM_NONE] = "none", + [RTE_CRYPTO_ASYM_XFORM_RSA] = "rsa", + [RTE_CRYPTO_ASYM_XFORM_MODEX] = "modexp", + [RTE_CRYPTO_ASYM_XFORM_MODINV] = "modinv", + [RTE_CRYPTO_ASYM_XFORM_DH] = "dh", + [RTE_CRYPTO_ASYM_XFORM_DSA] = "dsa", +}; + +/** + * Asymmetric crypto operation strings identifiers. + */ +const char *rte_crypto_asym_op_strings[] = { + [RTE_CRYPTO_ASYM_OP_ENCRYPT] = "encrypt", + [RTE_CRYPTO_ASYM_OP_DECRYPT] = "decrypt", + [RTE_CRYPTO_ASYM_OP_SIGN] = "sign", + [RTE_CRYPTO_ASYM_OP_VERIFY] = "verify", + [RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE] = "priv_key_generate", + [RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE] = "pub_key_generate", + [RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE] = "sharedsecret_compute", +}; + int rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum, const char *algo_string) @@ -1111,6 +1136,41 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, return 0; } +int __rte_experimental +rte_cryptodev_asym_session_init(uint8_t dev_id, + struct rte_cryptodev_asym_session *sess, + struct rte_crypto_asym_xform *xforms, + struct rte_mempool *mp) +{ + struct rte_cryptodev *dev; + uint8_t index; + int ret; + + dev = rte_cryptodev_pmd_get_dev(dev_id); + + if (sess == NULL || xforms == NULL || dev == NULL) + return -EINVAL; + + index = dev->driver_id; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_configure, + -ENOTSUP); + + if (sess->sess_private_data[index] == NULL) { + ret = dev->dev_ops->asym_session_configure(dev, + xforms, + sess, mp); + if (ret < 0) { + CDEV_LOG_ERR( + "dev_id %d failed to configure session details", + dev_id); + return ret; + } + } + + return 0; +} + struct rte_cryptodev_sym_session * rte_cryptodev_sym_session_create(struct rte_mempool *mp) { @@ -1130,6 +1190,25 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp) return sess; } +struct rte_cryptodev_asym_session * __rte_experimental +rte_cryptodev_asym_session_create(struct rte_mempool *mp) +{ + struct rte_cryptodev_asym_session *sess; + + /* Allocate a session structure from the session pool */ + if (rte_mempool_get(mp, (void **)&sess)) { + CDEV_LOG_ERR("couldn't get object from session mempool"); + return NULL; + } + + /* Clear device session pointer. + * Include the flag indicating presence of private data + */ + memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t)); + + return sess; +} + int rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id, struct rte_cryptodev_sym_session *sess) @@ -1200,6 +1279,24 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, return 0; } +int __rte_experimental +rte_cryptodev_asym_session_clear(uint8_t dev_id, + struct rte_cryptodev_asym_session *sess) +{ + struct rte_cryptodev *dev; + + dev = rte_cryptodev_pmd_get_dev(dev_id); + + if (dev == NULL || sess == NULL) + return -EINVAL; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_clear, -ENOTSUP); + + dev->dev_ops->asym_session_clear(dev, sess); + + return 0; +} + int rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) { @@ -1224,6 +1321,31 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess) return 0; } +int __rte_experimental +rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess) +{ + uint8_t i; + void *sess_priv; + struct rte_mempool *sess_mp; + + if (sess == NULL) + return -EINVAL; + + /* Check that all device private data has been freed */ + for (i = 0; i < nb_drivers; i++) { + sess_priv = get_asym_session_private_data(sess, i); + if (sess_priv != NULL) + return -EBUSY; + } + + /* Return session to mempool */ + sess_mp = rte_mempool_from_obj(sess); + rte_mempool_put(sess_mp, sess); + + return 0; +} + + unsigned int rte_cryptodev_get_header_session_size(void) { @@ -1241,6 +1363,17 @@ rte_cryptodev_sym_get_header_session_size(void) return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t)); } +unsigned int __rte_experimental +rte_cryptodev_asym_get_header_session_size(void) +{ + /* + * Header contains pointers to the private data + * of all registered drivers, and a flag which + * indicates presence of private data + */ + return ((sizeof(void *) * nb_drivers) + sizeof(uint8_t)); +} + unsigned int rte_cryptodev_get_private_session_size(uint8_t dev_id) { @@ -1276,6 +1409,29 @@ rte_cryptodev_sym_get_private_session_size(uint8_t dev_id) } +unsigned int __rte_experimental +rte_cryptodev_asym_get_private_session_size(uint8_t dev_id) +{ + struct rte_cryptodev *dev; + unsigned int header_size = sizeof(void *) * nb_drivers; + unsigned int priv_sess_size; + + if (!rte_cryptodev_pmd_is_valid_dev(dev_id)) + return 0; + + dev = rte_cryptodev_pmd_get_dev(dev_id); + + if (*dev->dev_ops->asym_session_get_size == NULL) + return 0; + + priv_sess_size = (*dev->dev_ops->asym_session_get_size)(dev); + if (priv_sess_size < header_size) + return header_size; + + return priv_sess_size; + +} + int __rte_experimental rte_cryptodev_sym_session_set_private_data( struct rte_cryptodev_sym_session *sess, @@ -1308,6 +1464,39 @@ rte_cryptodev_sym_session_get_private_data( return (uint8_t *)sess + off_set; } + +int __rte_experimental +rte_cryptodev_asym_session_set_private_data( + struct rte_cryptodev_asym_session *sess, + void *data, + uint16_t size) +{ + uint16_t off_set = sizeof(void *) * nb_drivers; + uint8_t *private_data_present = (uint8_t *)sess + off_set; + + if (sess == NULL) + return -EINVAL; + + *private_data_present = 1; + off_set += sizeof(uint8_t); + rte_memcpy((uint8_t *)sess + off_set, data, size); + return 0; +} + +void * __rte_experimental +rte_cryptodev_asym_session_get_app_private_data( + struct rte_cryptodev_asym_session *sess) +{ + uint16_t off_set = sizeof(void *) * nb_drivers; + uint8_t *private_data_present = (uint8_t *)sess + off_set; + + if (sess == NULL || !*private_data_present) + return NULL; + + off_set += sizeof(uint8_t); + return (uint8_t *)sess + off_set; +} + /** Initialise rte_crypto_op mempool element */ static void rte_crypto_op_init(struct rte_mempool *mempool, @@ -1335,8 +1524,16 @@ rte_crypto_op_pool_create(const char *name, enum rte_crypto_op_type type, struct rte_crypto_op_pool_private *priv; unsigned elt_size = sizeof(struct rte_crypto_op) + - sizeof(struct rte_crypto_sym_op) + - priv_size; + priv_size; + + if (type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) { + elt_size += sizeof(struct rte_crypto_sym_op); + } else if (type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) { + elt_size += sizeof(struct rte_crypto_asym_op); + } else { + CDEV_LOG_ERR("Invalid op_type\n"); + return NULL; + } /* lookup mempool in case already allocated */ struct rte_mempool *mp = rte_mempool_lookup(name); diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index ccc0f73..89dcd40 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -867,9 +867,14 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id, */ struct rte_cryptodev_sym_session { __extension__ void *sess_private_data[0]; - /**< Private session material */ + /**< Private symmetric session material */ }; +/** Cryptodev asymmetric crypto session */ +struct rte_cryptodev_asym_session { + __extension__ void *sess_private_data[0]; + /**< Private asymmetric session material */ +}; /** * Create symmetric crypto session header (generic with no private data) @@ -884,6 +889,18 @@ struct rte_cryptodev_sym_session * rte_cryptodev_sym_session_create(struct rte_mempool *mempool); /** + * Create asymmetric crypto session header (generic with no private data) + * + * @param mempool mempool to allocate asymmetric session + * objects from + * @return + * - On success return pointer to asym-session + * - On failure returns NULL + */ +struct rte_cryptodev_asym_session * __rte_experimental +rte_cryptodev_asym_session_create(struct rte_mempool *mempool); + +/** * Frees symmetric crypto session header, after checking that all * the device private data has been freed, returning it * to its original mempool. @@ -899,6 +916,21 @@ int rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess); /** + * Frees asymmetric crypto session header, after checking that all + * the device private data has been freed, returning it + * to its original mempool. + * + * @param sess Session header to be freed. + * + * @return + * - 0 if successful. + * - -EINVAL if session is NULL. + * - -EBUSY if not all device private data has been freed. + */ +int __rte_experimental +rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess); + +/** * Fill out private data for the device id, based on its device type. * * @param dev_id ID of device that we want the session to be used on @@ -920,6 +952,27 @@ rte_cryptodev_sym_session_init(uint8_t dev_id, struct rte_mempool *mempool); /** + * Initialize asymmetric session on a device with specific asymmetric xform + * + * @param dev_id ID of device that we want the session to be used on + * @param sess Session to be set up on a device + * @param xforms Asymmetric crypto transform operations to apply on flow + * processed with this session + * @param mempool Mempool to be used for internal allocation. + * + * @return + * - On success, zero. + * - -EINVAL if input parameters are invalid. + * - -ENOTSUP if crypto device does not support the crypto transform. + * - -ENOMEM if the private session could not be allocated. + */ +int __rte_experimental +rte_cryptodev_asym_session_init(uint8_t dev_id, + struct rte_cryptodev_asym_session *sess, + struct rte_crypto_asym_xform *xforms, + struct rte_mempool *mempool); + +/** * Frees private data for the device id, based on its device type, * returning it to its mempool. It is the application's responsibility * to ensure that private session data is not cleared while there are @@ -937,6 +990,20 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id, struct rte_cryptodev_sym_session *sess); /** + * Frees resources held by asymmetric session during rte_cryptodev_session_init + * + * @param dev_id ID of device that uses the asymmetric session. + * @param sess Asymmetric session setup on device using + * rte_cryptodev_session_init + * @return + * - 0 if successful. + * - -EINVAL if device is invalid or session is NULL. + */ +int __rte_experimental +rte_cryptodev_asym_session_clear(uint8_t dev_id, + struct rte_cryptodev_asym_session *sess); + +/** * @deprecated * Get the size of the header session, for all registered drivers. * @@ -971,6 +1038,15 @@ unsigned int rte_cryptodev_sym_get_header_session_size(void); /** + * Get the size of the asymmetric session header, for all registered drivers. + * + * @return + * Size of the asymmetric header session. + */ +unsigned int __rte_experimental +rte_cryptodev_asym_get_header_session_size(void); + +/** * Get the size of the private symmetric session data * for a device. * @@ -985,6 +1061,19 @@ unsigned int rte_cryptodev_sym_get_private_session_size(uint8_t dev_id); /** + * Get the size of the private data for asymmetric session + * on device + * + * @param dev_id The device identifier. + * + * @return + * - Size of the asymmetric private data, if successful + * - 0 if device is invalid or does not have private session + */ +unsigned int __rte_experimental +rte_cryptodev_asym_get_private_session_size(uint8_t dev_id); + +/** * @deprecated * Attach queue pair with sym session. * @@ -1072,6 +1161,39 @@ void * __rte_experimental rte_cryptodev_sym_session_get_private_data( struct rte_cryptodev_sym_session *sess); +/** + * Set private data for a session. + * + * @param sess Session pointer allocated by + * *rte_cryptodev_asym_session_create*. + * @param data Pointer to the private data. + * @param size Size of the private data. + * + * @return + * - On success, zero. + * - On failure, a negative value. + */ +int __rte_experimental +rte_cryptodev_asym_session_set_private_data( + struct rte_cryptodev_asym_session *sess, + void *data, + uint16_t size); + +/** + * Get private data of a session. + * + * @param sess Session pointer allocated by + * *rte_cryptodev_asym_session_create*. + * + * @return + * - On success return pointer to private data. + * - On failure returns NULL. + */ +void * __rte_experimental +rte_cryptodev_asym_session_get_app_private_data( + struct rte_cryptodev_asym_session *sess); + + #ifdef __cplusplus } #endif diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h index db8b976..b94e844 100644 --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h @@ -275,6 +275,17 @@ typedef int (*cryptodev_sym_create_session_pool_t)( */ typedef unsigned (*cryptodev_sym_get_session_private_size_t)( struct rte_cryptodev *dev); +/** + * Get the size of a asymmetric cryptodev session + * + * @param dev Crypto device pointer + * + * @return + * - On success returns the size of the session structure for device + * - On failure returns 0 + */ +typedef unsigned int (*cryptodev_asym_get_session_private_size_t)( + struct rte_cryptodev *dev); /** * Configure a Crypto session on a device. @@ -294,7 +305,24 @@ typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev, struct rte_crypto_sym_xform *xform, struct rte_cryptodev_sym_session *session, struct rte_mempool *mp); - +/** + * Configure a Crypto asymmetric session on a device. + * + * @param dev Crypto device pointer + * @param xform Single or chain of crypto xforms + * @param priv_sess Pointer to cryptodev's private session structure + * @param mp Mempool where the private session is allocated + * + * @return + * - Returns 0 if private session structure have been created successfully. + * - Returns -EINVAL if input parameters are invalid. + * - Returns -ENOTSUP if crypto device does not support the crypto transform. + * - Returns -ENOMEM if the private session could not be allocated. + */ +typedef int (*cryptodev_asym_configure_session_t)(struct rte_cryptodev *dev, + struct rte_crypto_asym_xform *xform, + struct rte_cryptodev_asym_session *session, + struct rte_mempool *mp); /** * Free driver private session data. * @@ -305,6 +333,15 @@ typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev, struct rte_cryptodev_sym_session *sess); /** + * Free asymmetric session private data. + * + * @param dev Crypto device pointer + * @param sess Cryptodev session structure + */ +typedef void (*cryptodev_asym_free_session_t)(struct rte_cryptodev *dev, + struct rte_cryptodev_asym_session *sess); + +/** * Optional API for drivers to attach sessions with queue pair. * @param dev Crypto device pointer * @param qp_id queue pair id for attaching session @@ -357,10 +394,16 @@ struct rte_cryptodev_ops { cryptodev_sym_get_session_private_size_t session_get_size; /**< Return private session. */ + cryptodev_asym_get_session_private_size_t asym_session_get_size; + /**< Return asym session private size. */ cryptodev_sym_configure_session_t session_configure; /**< Configure a Crypto session. */ + cryptodev_asym_configure_session_t asym_session_configure; + /**< Configure asymmetric Crypto session. */ cryptodev_sym_free_session_t session_clear; /**< Clear a Crypto sessions private data. */ + cryptodev_asym_free_session_t asym_session_clear; + /**< Clear a Crypto sessions private data. */ cryptodev_sym_queue_pair_attach_session_t qp_attach_session; /**< Attach session to queue pair. */ cryptodev_sym_queue_pair_detach_session_t qp_detach_session; @@ -508,6 +551,19 @@ set_session_private_data(struct rte_cryptodev_sym_session *sess, sess->sess_private_data[driver_id] = private_data; } +static inline void * +get_asym_session_private_data(const struct rte_cryptodev_asym_session *sess, + uint8_t driver_id) { + return sess->sess_private_data[driver_id]; +} + +static inline void +set_asym_session_private_data(struct rte_cryptodev_asym_session *sess, + uint8_t driver_id, void *private_data) +{ + sess->sess_private_data[driver_id] = private_data; +} + #ifdef __cplusplus } #endif diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map index be8f4c1..9cdc0ee 100644 --- a/lib/librte_cryptodev/rte_cryptodev_version.map +++ b/lib/librte_cryptodev/rte_cryptodev_version.map @@ -95,8 +95,16 @@ DPDK_18.05 { } DPDK_17.11; EXPERIMENTAL { - global: + global: + rte_cryptodev_asym_get_header_session_size; + rte_cryptodev_asym_get_private_session_size; + rte_cryptodev_asym_session_clear; + rte_cryptodev_asym_session_create; + rte_cryptodev_asym_session_free; + rte_cryptodev_asym_session_get_app_private_data; + rte_cryptodev_asym_session_init; + rte_cryptodev_asym_session_set_private_data; rte_cryptodev_sym_session_get_private_data; rte_cryptodev_sym_session_set_private_data; }; From patchwork Tue Jul 3 15:24:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shally Verma X-Patchwork-Id: 42160 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 [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 506B61BF60; Tue, 3 Jul 2018 17:25:27 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0077.outbound.protection.outlook.com [104.47.36.77]) by dpdk.org (Postfix) with ESMTP id 04A331BF5B for ; Tue, 3 Jul 2018 17:25:24 +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:X-MS-Exchange-SenderADCheck; bh=xKw+Z9TcD6OJLDsT6R4225IOk/z+nrfPAykknR+VYNQ=; b=endhRjKfW7SyvMLOKLSkV9/X0cCtoJlwKMvExyPenGcjchmg3p3zzCF2IdO8H+mSyjFmDVUKB2ZYCz2dNTsHJGEpIlrm3fCmPF3Imfpnbj55PhnJSKvqEMCarLUUx7CC/4P+/SoB0J/zwUTW0y1ba1PsmirRqjBoEPTbmAd9Ad8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by DM5PR0701MB3640.namprd07.prod.outlook.com (2603:10b6:4:7e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.24; Tue, 3 Jul 2018 15:25:21 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, pathreya@caviumnetworks.com, nmurthy@caviumnetworks.com, Ashish Gupta , Sunila Sahu , Umesh Kartha Date: Tue, 3 Jul 2018 20:54:25 +0530 Message-Id: <1530631466-26427-4-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530631466-26427-1-git-send-email-shally.verma@caviumnetworks.com> References: <1530631466-26427-1-git-send-email-shally.verma@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: PN1PR0101CA0014.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:e::24) To DM5PR0701MB3640.namprd07.prod.outlook.com (2603:10b6:4:7e::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff10f81a-d532-4fc6-e4ef-08d5e0f93246 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(2017052603328)(7153060)(7193020); SRVR:DM5PR0701MB3640; X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3640; 3:c2wmadbc0mdRKekLw+jUl7tzLoBph7IqS1Rr4JZFcFPbB29oxjb0yAYD9Fg2jOH1I6TEzzRIJy4yNWfB4sXY1atldu2xeakQEYjRHjGjVfSN2MKurnCpNc7QdK4YaQo/BxmnMo+hKSOcJARNj+WsHQZYxAozNMgbRZ0uLxFwFAQSW0Oz5tmZ7YkJ/mhRmDl+DVgaI0wVolv+0CwgCkzXDSrZKacKpAAEArTf7IqlVwdoQQFJonDsJUgLGx5e3Qqa; 25:aOP3k2GTMBrGaVY8PF9jHW43U8AZobpqQ62NGENj7+7C3TN2SDbFkkmoy3YWf+6U2bka+Vn7XkoGcjh5qNap2KvD4g8St06EAV0K/lQZRZzFYv3hBvRmAXgSvHIlTaWVS1RtsILcr6H22zFSFAmySv+Icnjni98PWNjROjIOlzi1j0pPhMZzXVcDXHpL7bhXgDYzXLrt8eV9JYUgyJbvbKx3p34iLOmcSH5np2LANOcM93LQptQYI55HIw1N3HWSyPQrWe7oZkUm/w1yA3rxgrXipexf9Yqy5hl0mC6TebxjxtJn2IxNbcb1TTderG7CA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dKJn7J71YEu18OTY4QwTsWNNA6BYw2KGxCYAOolnhJlpLBJgho2k9Ijq+MljAI40P9wVmsgIBSVoDyrj78h8HWl9lWRniETOcwL2o9OP1xkKOuHGgClE6lI7U6+un0FD1nZ+p9+6/YFzFzQ4fmJR55Uy6vEyOTL7aAbQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(10201501046)(3231254)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:DM5PR0701MB3640; BCL:0; PCL:0; RULEID:; SRVR:DM5PR0701MB3640; X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(346002)(376002)(39860400002)(396003)(366004)(199004)(189003)(50226002)(53936002)(55236004)(316002)(6506007)(107886003)(54906003)(42882007)(305945005)(386003)(68736007)(51416003)(575784001)(7736002)(4326008)(72206003)(8676002)(6486002)(478600001)(25786009)(81156014)(81166006)(76176011)(2361001)(6512007)(97736004)(69596002)(6116002)(16526019)(3846002)(186003)(2351001)(44832011)(5660300001)(6916009)(53416004)(8936002)(66066001)(47776003)(476003)(106356001)(16586007)(956004)(2616005)(11346002)(105586002)(2906002)(52116002)(446003)(50466002)(14444005)(26005)(48376002)(36756003)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR0701MB3640; 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; DM5PR0701MB3640; 23:MCtYL4W/sVMzlE1YPK+UatxfF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rVF3PqKcLjLFvJIWy5gUfbHaMfBDCsCLV/ex+8GG1rCup4DUUAj8Btrad4+J7BpcwDLAwomLm3fCr2s1MowVseh3zOSAZ/pe59A==; 5:fyiY9XWJfXNNqGsyoF4irMO0XBJC7v9QxOywmnBMoXVJvfjC8opsxjwDolS7FAXzTQvbOLQyrcEa9DClaHWskYHn2QhtFO7gqEc7Ae7UymHRGSeGJmuXl/oa7mLkrvjL+mT5HNgl8H7CJZmZn5QgVfLpfuYmL3kd57RhZyXiymE=; 24:VwSHAZsuX8NVii6PwlrK1viWuukwstf07B+3M0HYAEi/A75Ms7WnPLZtFY5MhTs81pNbCKAmzUszV3bYLngCt33BFX4DoRIE73BRYBV8Am8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3640; 7:xoo3j7LCjQCj7DIAm5IxFTApa62kq+KkI1alOrczUnVCg5PsTtGxblxjkumSRCi3YjmitCDz+scU7SBOlBYXCKYkbRXemN/KXEiDlaljuLQkqE+aaZAJ25BOv7BHxAhb+hdhmBD+zMHrP3qcVJno+gq+Z3rptV260K/BhmKT2vGetW6rpGcKJfabDqcvQ+JbLgMXPGPszJvtKFKtSBGrfZuKzXoTox3GS6z+au3NCKTp9i2uyJpDoACw39+exjKm X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2018 15:25:21.3921 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff10f81a-d532-4fc6-e4ef-08d5e0f93246 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0701MB3640 Subject: [dpdk-dev] [PATCH v4 3/4] lib/cryptodev: add asymmetric crypto capability 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ashish Gupta Extend cryptodev with asymmetric capability APIs and definitions. Signed-off-by: Shally Verma Signed-off-by: Sunila Sahu Signed-off-by: Ashish Gupta Signed-off-by: Umesh Kartha --- lib/librte_cryptodev/rte_cryptodev.c | 76 ++++++++++++++++++ lib/librte_cryptodev/rte_cryptodev.h | 103 ++++++++++++++++++++++++- lib/librte_cryptodev/rte_cryptodev_version.map | 5 ++ 3 files changed, 183 insertions(+), 1 deletion(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c index 47fc2e5..2e4b128 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -242,6 +242,24 @@ rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum, return -1; } +int __rte_experimental +rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum, + const char *xform_string) +{ + unsigned int i; + + for (i = 1; i < RTE_DIM(rte_crypto_asym_xform_strings); i++) { + if (strcmp(xform_string, + rte_crypto_asym_xform_strings[i]) == 0) { + *xform_enum = (enum rte_crypto_asym_xform_type) i; + return 0; + } + } + + /* Invalid string */ + return -1; +} + /** * The crypto auth operation strings identifiers. * It could be used in application command line. @@ -312,6 +330,28 @@ param_range_check(uint16_t size, const struct rte_crypto_param_range *range) return -1; } +const struct rte_cryptodev_asymmetric_xform_capability * __rte_experimental +rte_cryptodev_asym_capability_get(uint8_t dev_id, + const struct rte_cryptodev_asym_capability_idx *idx) +{ + const struct rte_cryptodev_capabilities *capability; + struct rte_cryptodev_info dev_info; + unsigned int i = 0; + + memset(&dev_info, 0, sizeof(struct rte_cryptodev_info)); + rte_cryptodev_info_get(dev_id, &dev_info); + + while ((capability = &dev_info.capabilities[i++])->op != + RTE_CRYPTO_OP_TYPE_UNDEFINED) { + if (capability->op != RTE_CRYPTO_OP_TYPE_ASYMMETRIC) + continue; + + if (capability->asym.xform_capa.xform_type == idx->type) + return &capability->asym.xform_capa; + } + return NULL; +}; + int rte_cryptodev_sym_capability_check_cipher( const struct rte_cryptodev_symmetric_capability *capability, @@ -363,6 +403,42 @@ rte_cryptodev_sym_capability_check_aead( return 0; } +int __rte_experimental +rte_cryptodev_asym_xform_capability_check_optype( + const struct rte_cryptodev_asymmetric_xform_capability *capability, + enum rte_crypto_asym_op_type op_type) +{ + if (capability->op_types & (1 << op_type)) + return 1; + + return 0; +} + +int __rte_experimental +rte_cryptodev_asym_xform_capability_check_modlen( + const struct rte_cryptodev_asymmetric_xform_capability *capability, + uint16_t modlen) +{ + /* no need to check for limits, if min or max = 0 */ + if (capability->modlen.min != 0) { + if (modlen < capability->modlen.min) + return -1; + } + + if (capability->modlen.max != 0) { + if (modlen > capability->modlen.max) + return -1; + } + + /* in any case, check if given modlen is module increment */ + if (capability->modlen.increment != 0) { + if (modlen % (capability->modlen.increment)) + return -1; + } + + return 0; +} + const char * rte_cryptodev_get_feature_name(uint64_t flag) diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index 89dcd40..ec87a77 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -143,6 +143,35 @@ struct rte_cryptodev_symmetric_capability { }; }; +/** + * Asymmetric Xform Crypto Capability + * + */ +struct rte_cryptodev_asymmetric_xform_capability { + enum rte_crypto_asym_xform_type xform_type; + /**< Transform type: RSA/MODEXP/DH/DSA/MODINV */ + + uint32_t op_types; + /**< bitmask for supported rte_crypto_asym_op_type */ + + __extension__ + union { + struct rte_crypto_param_range modlen; + /**< Range of modulus length supported by modulus based xform. + * Value 0 mean implementation default + */ + }; +}; + +/** + * Asymmetric Crypto Capability + * + */ +struct rte_cryptodev_asymmetric_capability { + struct rte_cryptodev_asymmetric_xform_capability xform_capa; +}; + + /** Structure used to capture a capability of a crypto device */ struct rte_cryptodev_capabilities { enum rte_crypto_op_type op; @@ -152,6 +181,8 @@ struct rte_cryptodev_capabilities { union { struct rte_cryptodev_symmetric_capability sym; /**< Symmetric operation capability parameters */ + struct rte_cryptodev_asymmetric_capability asym; + /**< Asymmetric operation capability parameters */ }; }; @@ -166,7 +197,17 @@ struct rte_cryptodev_sym_capability_idx { }; /** - * Provide capabilities available for defined device and algorithm + * Structure used to describe asymmetric crypto xforms + * Each xform maps to one asym algorithm. + * + */ +struct rte_cryptodev_asym_capability_idx { + enum rte_crypto_asym_xform_type type; + /**< Asymmetric xform (algo) type */ +}; + +/** + * Provide capabilities available for defined device and algorithm * * @param dev_id The identifier of the device. * @param idx Description of crypto algorithms. @@ -180,6 +221,20 @@ rte_cryptodev_sym_capability_get(uint8_t dev_id, const struct rte_cryptodev_sym_capability_idx *idx); /** + * Provide capabilities available for defined device and algorithm + * + * @param dev_id The identifier of the device. + * @param algo Description of crypto algorithms. + * + * @return + * - Return description of the asymmetric crypto capability if exist. + * - Return NULL if the capability not exist. + */ +const struct rte_cryptodev_asymmetric_xform_capability * __rte_experimental +rte_cryptodev_asym_capability_get(uint8_t dev_id, + const struct rte_cryptodev_asym_capability_idx *idx); + +/** * Check if key size and initial vector are supported * in crypto cipher capability * @@ -235,6 +290,36 @@ rte_cryptodev_sym_capability_check_aead( uint16_t iv_size); /** + * Check if op type is supported + * + * @param capability Description of the asymmetric crypto capability. + * @param op_type op type + * + * @return + * - Return 1 if the op type is supported + * - Return 0 if unsupported + */ +int __rte_experimental +rte_cryptodev_asym_xform_capability_check_optype( + const struct rte_cryptodev_asymmetric_xform_capability *capability, + enum rte_crypto_asym_op_type op_type); + +/** + * Check if modulus length is in supported range + * + * @param capability Description of the asymmetric crypto capability. + * @param modlen modulus length. + * + * @return + * - Return 0 if the parameters are in range of the capability. + * - Return -1 if the parameters are out of range of the capability. + */ +int __rte_experimental +rte_cryptodev_asym_xform_capability_check_modlen( + const struct rte_cryptodev_asymmetric_xform_capability *capability, + uint16_t modlen); + +/** * Provide the cipher algorithm enum, given an algorithm string * * @param algo_enum A pointer to the cipher algorithm @@ -279,6 +364,22 @@ int rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum, const char *algo_string); +/** + * Provide the Asymmetric xform enum, given an xform string + * + * @param xform_enum A pointer to the xform type + * enum to be filled + * @param xform_string xform string + * + * @return + * - Return -1 if string is not valid + * - Return 0 if the string is valid + */ +int __rte_experimental +rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum, + const char *xform_string); + + /** Macro used at end of crypto PMD list */ #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \ { RTE_CRYPTO_OP_TYPE_UNDEFINED } diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map index 9cdc0ee..aac1498 100644 --- a/lib/librte_cryptodev/rte_cryptodev_version.map +++ b/lib/librte_cryptodev/rte_cryptodev_version.map @@ -97,14 +97,19 @@ DPDK_18.05 { EXPERIMENTAL { global: + rte_cryptodev_asym_capability_get; rte_cryptodev_asym_get_header_session_size; rte_cryptodev_asym_get_private_session_size; + rte_cryptodev_asym_get_xform_enum; rte_cryptodev_asym_session_clear; rte_cryptodev_asym_session_create; rte_cryptodev_asym_session_free; rte_cryptodev_asym_session_get_app_private_data; rte_cryptodev_asym_session_init; rte_cryptodev_asym_session_set_private_data; + rte_cryptodev_asym_xform_capability_check_optype; rte_cryptodev_sym_session_get_private_data; rte_cryptodev_sym_session_set_private_data; + rte_crypto_asym_op_strings; + rte_crypto_asym_xform_strings; }; From patchwork Tue Jul 3 15:24:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shally Verma X-Patchwork-Id: 42161 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 [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 931AC1BF66; Tue, 3 Jul 2018 17:25:30 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0051.outbound.protection.outlook.com [104.47.36.51]) by dpdk.org (Postfix) with ESMTP id EC3F81BF64 for ; Tue, 3 Jul 2018 17:25:27 +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:X-MS-Exchange-SenderADCheck; bh=U3wgfoSe+GB6ISyHjvTVFWhq+HnrDaJkF11Dzp/+yTA=; b=kkV37fvSQQCKa6HzSfmzC3NcGdd5Ic/w05sue97ijf3zKdVUFJ7Bw4sUPYV1Bwm1Nw1EvL0ifhxDljFy5zzcaY/yDcMJwHlQzovjaJO7XZQnokdTs6/v92w7WGG4Y2mee4sdkBZXZneZTdsx1GIIZUELWWAyLpFN+fm6J/XAWc0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shally.Verma@cavium.com; Received: from hyd1sverma-dt.caveonetworks.com (115.113.156.2) by DM5PR0701MB3640.namprd07.prod.outlook.com (2603:10b6:4:7e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.24; Tue, 3 Jul 2018 15:25:24 +0000 From: Shally Verma To: pablo.de.lara.guarch@intel.com Cc: dev@dpdk.org, pathreya@caviumnetworks.com, nmurthy@caviumnetworks.com, Sunila Sahu , Ashish Gupta , Umesh Kartha Date: Tue, 3 Jul 2018 20:54:26 +0530 Message-Id: <1530631466-26427-5-git-send-email-shally.verma@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530631466-26427-1-git-send-email-shally.verma@caviumnetworks.com> References: <1530631466-26427-1-git-send-email-shally.verma@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: PN1PR0101CA0014.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:e::24) To DM5PR0701MB3640.namprd07.prod.outlook.com (2603:10b6:4:7e::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63d819b3-74a7-45fb-d66a-08d5e0f933fa X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(2017052603328)(7153060)(7193020); SRVR:DM5PR0701MB3640; X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3640; 3:O12E0g2Wa90GH3WI34gVKj8boCxC3y9bfvuvSuDLTqWTMYpgJ6v2Kr2dqfDKA5OVI8IaNI3F3hXEccAtGSgDF8e+ahJai4LNBFuWJlcvnbYVT5czIXKBQvp7xsbq84J17d2tDaHTxao473mg7L0wm6XmrGG0K2m1TrliBwyHvIQSMhNhV82kXL4xRLnV8VWJCov44xiAzzXgYFjCpsB+DIqGWH0M1pDHarRZCUgcx+Ze9JV8XXjd8B4bMkiinEvp; 25:ea7IwJiAVxEGHJnwpI43VuaQlfw4jzhqOvK9eQFY/YKX7V3Qe7QvdpUHENIKugCoNAkp/pDjCt/5XUsD4mW3l3WNAp3Egt+trGCZ8RQs7s+28ErdAFwwSIFqN72DTeevwgS/YoHtzR+/cJFuDj9Dcz8rLh/8LKkHjd2Fv00p500ecoEtZXK+ZIwh2sCWokCV/eohvqfRhYQbap5SCVI909QRdU2pRUPgyQ/B/ot22rU1Wnn7y4lnXuwPprOqPt5OwB//4yH5x8IfCpmKB1wjR7atc9Dkz9zrQZDgThr7KhjNoJzwnKIQvMsvJNmRj9haRa4y1Viz1UIf5A3EZguwFg==; 31:fGdgkCINnwUXTBsSONX/VW7K5VomEit7Id+t5hXvt7VNmDcbQHpqAgYdGD4q2lyiQjuViIMtLAjMfjct4fVOTrXfxsQkT5U4uIduKppe0v2ig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3fYVSiDJfv1BfNBSNt8R7wIIwVp09HZ9irdQqVjNuqwkeJM974q/E5Zhfgb5sCrFm2VbtR2Aq X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(10201501046)(3231254)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:DM5PR0701MB3640; BCL:0; PCL:0; RULEID:; SRVR:DM5PR0701MB3640; X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(346002)(376002)(39860400002)(396003)(366004)(199004)(189003)(50226002)(53936002)(55236004)(316002)(6506007)(107886003)(54906003)(53376002)(42882007)(305945005)(386003)(68736007)(51416003)(575784001)(7736002)(4326008)(72206003)(8676002)(6486002)(478600001)(6306002)(25786009)(81156014)(81166006)(76176011)(2361001)(6512007)(97736004)(69596002)(6116002)(16526019)(3846002)(186003)(2351001)(44832011)(5660300001)(6916009)(53416004)(8936002)(66066001)(47776003)(476003)(106356001)(16586007)(956004)(2616005)(11346002)(105586002)(2906002)(52116002)(446003)(50466002)(5024004)(14444005)(26005)(48376002)(36756003)(486006)(21314002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR0701MB3640; 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; DM5PR0701MB3640; 23:nAelsieaumcEqRVoww20YEtOzyDtg9qcl+OkEDE?= c5Rx9IJ241DXwPVBzq30DlCb0RhFWqXrfsmAg09AqA4pJxlLewM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DtrM46I1IytxO+pL5CPxXM1wZczBEUOR5LoI/iubG3BGG4IT7lbutyHcA+LkkpDnSo0jmrTlhFWKO0Jy5OylofcD0/9W6p6OalWzUq084N7L67dhuZytK7g+4x3/Sul5mQ==; 5:uKI1XzhNzjWShoFP2yiEucaPuq1v5+VGetP1go6Qp8iHefn+XYOmkr6Yzo+K/J+ddhX9o6HDA0SYPJxVvp6OOxbnlH268MRRGkwFDP2O0JEah5BG0JKtv0ywxkT8y3joHFeZXKR939AhCiyYuXHf0HBn7mzfp9SSDJVCTt3VAYM=; 24:fm7OHDZ37LQu4JBmZbmFhTTnOlipTh3Gy6RyASzzGFtiSvzmNta2ZfCKb9ItlTU8/RUmQleNXdGT8i543WDXodst2Kkq0lxFrgVzEAM66zc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM5PR0701MB3640; 7:M3bo/ecp7y+2k8w6g+FuHuZXxzrHFPwyfnN0J7mzSBVfnUf/y4yoq2Mj7K7OGvt8Dy5ES5XP2YRWdVkJKMmqcuLHOj9AOUBO0DSpOB9MlQAyhzlrfkYf/rB7pUvXKu0pLpPz+e3WqaKwlVKmIizGKImuY6maPO9QFHxjrvWNTn4wzINAzHjtF5nX4aewyAxgYyQCUhePtnEuYGIfkc3sGHkHCPdAwD1TfwORke0+rynYmqqXH82vLJfmEFQM9/wM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2018 15:25:24.2311 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63d819b3-74a7-45fb-d66a-08d5e0f933fa X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR0701MB3640 Subject: [dpdk-dev] [PATCH v4 4/4] doc: add asym crypto in cryptodev programmer guide 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" From: Sunila Sahu Update cryptodev programmer guide with description of asymmetric crypto framework in lib cryptodev. Signed-off-by: Shally Verma Signed-off-by: Sunila Sahu Signed-off-by: Ashish Gupta Signed-off-by: Umesh Kartha --- doc/guides/prog_guide/cryptodev_lib.rst | 290 ++++++++++++++++++++++++++++++-- 1 file changed, 279 insertions(+), 11 deletions(-) diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst index 30f0bcf..f6f0405 100644 --- a/doc/guides/prog_guide/cryptodev_lib.rst +++ b/doc/guides/prog_guide/cryptodev_lib.rst @@ -8,7 +8,7 @@ The cryptodev library provides a Crypto device framework for management and provisioning of hardware and software Crypto poll mode drivers, defining generic APIs which support a number of different Crypto operations. The framework currently only supports cipher, authentication, chained cipher/authentication -and AEAD symmetric Crypto operations. +and AEAD symmetric and asymmetric Crypto operations. Design Principles @@ -159,8 +159,8 @@ Device Features and Capabilities Crypto devices define their functionality through two mechanisms, global device features and algorithm capabilities. Global devices features identify device wide level features which are applicable to the whole device such as -the device having hardware acceleration or supporting symmetric Crypto -operations, +the device having hardware acceleration or supporting symmetric and/or asymmetric +Crypto operations, The capabilities mechanism defines the individual algorithms/functions which the device supports, such as a specific symmetric Crypto cipher, @@ -199,7 +199,7 @@ scope of the Crypto capability see the definition of the structure in the Each Crypto poll mode driver defines its own private array of capabilities for the operations it supports. Below is an example of the capabilities for a PMD which supports the authentication algorithm SHA1_HMAC and the cipher -algorithm AES_CBC. +algorithm AES_CBC and RSA operations. .. code-block:: c @@ -245,7 +245,29 @@ algorithm AES_CBC. } } } - } + }, + { /* RSA */ + .op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + {.asym = { + .xform_type = RTE_CRYPTO_ASYM_XFORM_RSA, + .xfrm_capa = { + .xform_type = RTE_CRYPTO_ASYM_XFORM_RSA, + .op_types = ((1 << RTE_CRYPTO_ASYM_OP_SIGN) | + (1 << RTE_CRYPTO_ASYM_OP_VERIFY) | + (1 << RTE_CRYPTO_ASYM_OP_ENCRYPT) | + (1 << RTE_CRYPTO_ASYM_OP_DECRYPT)), + { + .modlen = { + /* min length is based on openssl rsa keygen */ + .min = 30, + /* value 0 symbolizes no limit on max length */ + .max = 0, + .increment = 1 + }, } + } + }, + } + } } @@ -446,7 +468,7 @@ Crypto workloads. .. figure:: img/cryptodev_sym_sess.* -The Crypto device framework provides APIs to allocate and initizalize sessions +The Crypto device framework provides APIs to allocate and initialize sessions for crypto devices, where sessions are mempool objects. It is the application's responsibility to create and manage the session mempools. This approach allows for different scenarios such as having a single session @@ -788,14 +810,260 @@ using one of the crypto PMDs available in DPDK. num_dequeued_ops); } while (total_num_dequeued_ops < num_enqueued_ops); - Asymmetric Cryptography ----------------------- -Asymmetric functionality is currently not supported by the cryptodev API. +The cryptodev library currently provides support for the following asymmetric +Crypto operations; RSA, Modular exponentiation and inversion, Deffie-hellman +public and/or private key generation and shared secret compute, DSA Signature +generation and verification. + +Session and Session Management +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sessions are used in asymmetric cryptographic processing to store the immutable +data defined in asymmetric cryptographic transform which is further used in the +operation processing. Sessions typically stores information, such as, public +and private key information or domain params or prime modulus data i.e. immutable +across data sets. Crypto sessions cache this immutable data in a optimal way for the +underlying PMD and this allows further acceleration of the offload of Crypto workloads. + +Like symmetric, the Crypto device framework provides APIs to allocate and initialize +asymmetric sessions for crypto devices, where sessions are mempool objects. +It is the application's responsibility to create and manage the session mempools. +Application using both symmetric and asymmetric sessions should allocate and maintain +different sessions pools for each type. + +An application can use ``rte_cryptodev_get_asym_session_private_size()`` to +get the private size of asymmetric session on a given crypto device. This +function would allow an application to calculate the max device asymmetric +session size of all crypto devices to create a single session mempool. +If instead an application creates multiple asymmetric session mempools, +the Crypto device framework also provides ``rte_cryptodev_asym_get_header_session_size()`` to get +the size of an uninitialized session. + +Once the session mempools have been created, ``rte_cryptodev_asym_session_create()`` +is used to allocate an uninitialized asymmetric session from the given mempool. +The session then must be initialized using ``rte_cryptodev_asym_session_init()`` +for each of the required crypto devices. An asymmetric transform chain +is used to specify the operation and its parameters. See the section below for +details on transforms. + +When a session is no longer used, user must call ``rte_cryptodev_asym_session_clear()`` +for each of the crypto devices that are using the session, to free all driver +private asymmetric session data. Once this is done, session should be freed using +``rte_cryptodev_asym_session_free()`` which returns them to their mempool. + +Asymmetric Sessionless Support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Currently asymmetric crypto framework does not support sessionless. + +Transforms and Transform Chaining +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Asymmetric Crypto transforms (``rte_crypto_asym_xform``) are the mechanism used +to specify the details of the asymmetric Crypto operation. Next pointer within +xform allows transform to be chained together. Also it is important to note that +the order in which the transforms are passed indicates the order of the chaining. + +Not all asymmetric crypto xforms are supported for chaining. Currently supported +asymmetric crypto chaining is Deffie-hellman private key generation followed by +public generation. Also, currently API does not support chaining of symmetric and +asymmetric crypto xfroms. + +Each xform defines specific asymmetric crypto algo. Currently supported are: +* RSA +* Modular operations (Exponentiation and Inverse) +* Deffie-hellman +* DSA +* None - special case where PMD may support a passthrough mode. More for diagnostic purpose + +See *DPDK API Reference* for details on each rte_crypto_xxx_xform struct + +Asymmetric Operations +~~~~~~~~~~~~~~~~~~~~~ + +The asymmetric Crypto operation structure contains all the mutable data relating +to asymmetric cryptographic processing on an input data buffer. It uses either +RSA, Modular, Deffie-hellman or DSA operations depending upon session it is attached +to. + +Every operation must carry a valid session handle which further carries information +on xform or xform-chain to be performed on op. Every xform type defines its own set +of operational params in their respective rte_crypto_xxx_op_param struct. Depending +on xform information within session, PMD picks up and process respective op_param +struct. +Unlike symmetric, asymmetric operations do not use mbufs for input/output. +They operate on data buffer of type ``rte_crypto_param``. + +See *DPDK API Reference* for details on each rte_crypto_xxx_op_param struct + +Asymmetric crypto Sample code +----------------------------- + +There's a unit test application test_cryptodev_asym.c inside unit test framework that +show how to setup and process asymmetric operations using cryptodev library. + +The following sample code shows the basic steps to compute modular exponentiation +using 1024-bit modulus length using openssl PMD available in DPDK (performing other +crypto operations is similar except change to respective op and xform setup). + +.. code-block:: c + + /* + * Simple example to compute modular exponentiation with 1024-bit key + * + */ + #define MAX_ASYM_SESSIONS 10 + #define NUM_ASYM_BUFS 10 + + struct rte_mempool *crypto_op_pool, *asym_session_pool; + unsigned int asym_session_size; + int ret; + + /* Initialize EAL. */ + ret = rte_eal_init(argc, argv); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); + + uint8_t socket_id = rte_socket_id(); + + /* Create crypto operation pool. */ + crypto_op_pool = rte_crypto_op_pool_create( + "crypto_op_pool", + RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + NUM_ASYM_BUFS, 0, 0, + socket_id); + if (crypto_op_pool == NULL) + rte_exit(EXIT_FAILURE, "Cannot create crypto op pool\n"); + + /* Create the virtual crypto device. */ + char args[128]; + const char *crypto_name = "crypto_openssl"; + snprintf(args, sizeof(args), "socket_id=%d", socket_id); + ret = rte_vdev_init(crypto_name, args); + if (ret != 0) + rte_exit(EXIT_FAILURE, "Cannot create virtual device"); + + uint8_t cdev_id = rte_cryptodev_get_dev_id(crypto_name); + + /* Get private asym session data size. */ + asym_session_size = rte_cryptodev_get_asym_private_session_size(cdev_id); + + /* + * Create session mempool, with two objects per session, + * one for the session header and another one for the + * private asym session data for the crypto device. + */ + asym_session_pool = rte_mempool_create("asym_session_pool", + MAX_ASYM_SESSIONS * 2, + asym_session_size, + 0, + 0, NULL, NULL, NULL, + NULL, socket_id, + 0); + + /* Configure the crypto device. */ + struct rte_cryptodev_config conf = { + .nb_queue_pairs = 1, + .socket_id = socket_id + }; + struct rte_cryptodev_qp_conf qp_conf = { + .nb_descriptors = 2048 + }; + + if (rte_cryptodev_configure(cdev_id, &conf) < 0) + rte_exit(EXIT_FAILURE, "Failed to configure cryptodev %u", cdev_id); + + if (rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf, + socket_id, asym_session_pool) < 0) + rte_exit(EXIT_FAILURE, "Failed to setup queue pair\n"); + + if (rte_cryptodev_start(cdev_id) < 0) + rte_exit(EXIT_FAILURE, "Failed to start device\n"); + + /* Setup crypto xform to do modular exponentiation with 1024 bit + * length modulus + */ + struct rte_crypto_asym_xform modex_xform = { + .next = NULL, + .xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX, + .modex = { + .modulus = { + .data = + (uint8_t *) + ("\xb3\xa1\xaf\xb7\x13\x08\x00\x0a\x35\xdc\x2b\x20\x8d" + "\xa1\xb5\xce\x47\x8a\xc3\x80\xf4\x7d\x4a\xa2\x62\xfd\x61\x7f" + "\xb5\xa8\xde\x0a\x17\x97\xa0\xbf\xdf\x56\x5a\x3d\x51\x56\x4f" + "\x70\x70\x3f\x63\x6a\x44\x5b\xad\x84\x0d\x3f\x27\x6e\x3b\x34" + "\x91\x60\x14\xb9\xaa\x72\xfd\xa3\x64\xd2\x03\xa7\x53\x87\x9e" + "\x88\x0b\xc1\x14\x93\x1a\x62\xff\xb1\x5d\x74\xcd\x59\x63\x18" + "\x11\x3d\x4f\xba\x75\xd4\x33\x4e\x23\x6b\x7b\x57\x44\xe1\xd3" + "\x03\x13\xa6\xf0\x8b\x60\xb0\x9e\xee\x75\x08\x9d\x71\x63\x13" + "\xcb\xa6\x81\x92\x14\x03\x22\x2d\xde\x55"), + .length = 128 + }, + .exponent = { + .data = (uint8_t *)("\x01\x00\x01"), + .length = 3 + } + } + }; + /* Create asym crypto session and initialize it for the crypto device. */ + struct rte_cryptodev_asym_session *asym_session; + asym_session = rte_cryptodev_asym_session_create(asym_session_pool); + if (asym_session == NULL) + rte_exit(EXIT_FAILURE, "Session could not be created\n"); + + if (rte_cryptodev_asym_session_init(cdev_id, asym_session, + &modex_xform, asym_session_pool) < 0) + rte_exit(EXIT_FAILURE, "Session could not be initialized " + "for the crypto device\n"); + + /* Get a burst of crypto operations. */ + struct rte_crypto_op *crypto_ops[1]; + if (rte_crypto_op_bulk_alloc(crypto_op_pool, + RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + crypto_ops, 1) == 0) + rte_exit(EXIT_FAILURE, "Not enough crypto operations available\n"); + + /* Set up the crypto operations. */ + struct rte_crypto_asym_op *asym_op = crypto_ops[0]->asym; + + /* calculate mod exp of value 0xf8 */ + static unsigned char base[] = {0xF8}; + asym_op->modex.base.data = base; + asym_op->modex.base.length = sizeof(base); + asym_op->modex.base.iova = base; + + /* Attach the asym crypto session to the operation */ + rte_crypto_op_attach_asym_session(op, asym_session); + + /* Enqueue the crypto operations in the crypto device. */ + uint16_t num_enqueued_ops = rte_cryptodev_enqueue_burst(cdev_id, 0, + crypto_ops, 1); + + /* + * Dequeue the crypto operations until all the operations + * are processed in the crypto device. + */ + uint16_t num_dequeued_ops, total_num_dequeued_ops = 0; + do { + struct rte_crypto_op *dequeued_ops[1]; + num_dequeued_ops = rte_cryptodev_dequeue_burst(cdev_id, 0, + dequeued_ops, 1); + total_num_dequeued_ops += num_dequeued_ops; + /* Check if operation was processed successfully */ + if (dequeued_ops[0]->status != RTE_CRYPTO_OP_STATUS_SUCCESS) + rte_exit(EXIT_FAILURE, + "Some operations were not processed correctly"); -Crypto Device API -~~~~~~~~~~~~~~~~~ + } while (total_num_dequeued_ops < num_enqueued_ops); + + +Asymmetric Crypto Device API +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The cryptodev Library API is described in the *DPDK API Reference* document. +The cryptodev Library API is described in the +`DPDK API Reference `_