From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C5B6A0487 for ; Thu, 4 Jul 2019 14:44:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 63A001BE27; Thu, 4 Jul 2019 14:44:20 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 437451BDFA for ; Thu, 4 Jul 2019 14:44:18 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2019 05:44:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,451,1557212400"; d="scan'208";a="172420389" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 04 Jul 2019 05:44:15 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 4 Jul 2019 05:44:17 -0700 Received: from hasmsx114.ger.corp.intel.com (10.184.198.65) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 4 Jul 2019 05:44:16 -0700 Received: from HASMSX109.ger.corp.intel.com ([169.254.3.134]) by HASMSX114.ger.corp.intel.com ([169.254.14.198]) with mapi id 14.03.0439.000; Thu, 4 Jul 2019 15:44:14 +0300 From: "Kusztal, ArkadiuszX" To: "dev@dpdk.org" CC: "akhil.goyal@nxp.com" , "Trahe, Fiona" , "shally.verma@caviumnetworks.com" , Shally Verma Thread-Topic: [PATCH v2 2/3] crypto/openssl: rework openssl rsa implementation Thread-Index: AQHVMbWLmLjnskpgqEOOvAsY8LQPe6a6aLVg Date: Thu, 4 Jul 2019 12:44:13 +0000 Message-ID: <06EE24DD0B19E248B53F6DC8657831551B279317@hasmsx109.ger.corp.intel.com> References: <20190703153759.1508-1-arkadiuszx.kusztal@intel.com> <20190703153759.1508-3-arkadiuszx.kusztal@intel.com> In-Reply-To: <20190703153759.1508-3-arkadiuszx.kusztal@intel.com> Accept-Language: pl-PL, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.184.70.11] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 2/3] crypto/openssl: rework openssl rsa implementation 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" + Shally's Marvell address. Shally, Fiona can you take a look? > -----Original Message----- > From: Kusztal, ArkadiuszX > Sent: Wednesday, July 3, 2019 5:38 PM > To: dev@dpdk.org > Cc: akhil.goyal@nxp.com; Trahe, Fiona ; > shally.verma@caviumnetworks.com; Kusztal, ArkadiuszX > > Subject: [PATCH v2 2/3] crypto/openssl: rework openssl rsa implementation >=20 > This commit reworks implementation of RSA algorithm in OPENSSL PMD to > be conformant to API changes. >=20 > Signed-off-by: Arek Kusztal > --- > drivers/crypto/openssl/rte_openssl_pmd.c | 67 ++++++++++++++++++-------- > ------ > 1 file changed, 38 insertions(+), 29 deletions(-) >=20 > diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c > b/drivers/crypto/openssl/rte_openssl_pmd.c > index 7c8bf0d..642580b 100644 > --- a/drivers/crypto/openssl/rte_openssl_pmd.c > +++ b/drivers/crypto/openssl/rte_openssl_pmd.c > @@ -1842,15 +1842,13 @@ process_openssl_rsa_op(struct rte_crypto_op > *cop, > int ret =3D 0; > struct rte_crypto_asym_op *op =3D cop->asym; > RSA *rsa =3D sess->u.r.rsa; > - uint32_t pad =3D (op->rsa.pad); > + uint32_t pad =3D (op->rsa.padding); > uint8_t *tmp; >=20 > cop->status =3D RTE_CRYPTO_OP_STATUS_SUCCESS; >=20 > switch (pad) { > - case RTE_CRYPTO_RSA_PKCS1_V1_5_BT0: > - case RTE_CRYPTO_RSA_PKCS1_V1_5_BT1: > - case RTE_CRYPTO_RSA_PKCS1_V1_5_BT2: > + case RTE_CRYPTO_RSA_PADDING_PKCS1: > pad =3D RSA_PKCS1_PADDING; > break; > case RTE_CRYPTO_RSA_PADDING_NONE: > @@ -1867,19 +1865,19 @@ process_openssl_rsa_op(struct rte_crypto_op > *cop, > case RTE_CRYPTO_ASYM_OP_ENCRYPT: > ret =3D RSA_public_encrypt(op->rsa.message.length, > op->rsa.message.data, > - op->rsa.message.data, > + op->rsa.cipher.data, > rsa, > pad); >=20 > if (ret > 0) > - op->rsa.message.length =3D ret; > + op->rsa.cipher.length =3D ret; > OPENSSL_LOG(DEBUG, > "length of encrypted text %d\n", ret); > break; >=20 > case RTE_CRYPTO_ASYM_OP_DECRYPT: > - ret =3D RSA_private_decrypt(op->rsa.message.length, > - op->rsa.message.data, > + ret =3D RSA_private_decrypt(op->rsa.cipher.length, > + op->rsa.cipher.data, > op->rsa.message.data, > rsa, > pad); > @@ -1898,28 +1896,39 @@ process_openssl_rsa_op(struct rte_crypto_op > *cop, > break; >=20 > case RTE_CRYPTO_ASYM_OP_VERIFY: > - tmp =3D rte_malloc(NULL, op->rsa.sign.length, 0); > - if (tmp =3D=3D NULL) { > - OPENSSL_LOG(ERR, "Memory allocation failed"); > - cop->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > - break; > - } > - ret =3D RSA_public_decrypt(op->rsa.sign.length, > - op->rsa.sign.data, > - tmp, > - rsa, > - pad); > - > - OPENSSL_LOG(DEBUG, > - "Length of public_decrypt %d " > - "length of message %zd\n", > - ret, op->rsa.message.length); > - if ((ret <=3D 0) || (CRYPTO_memcmp(tmp, op- > >rsa.message.data, > - op->rsa.message.length))) { > - OPENSSL_LOG(ERR, "RSA sign Verification failed"); > - cop->status =3D RTE_CRYPTO_OP_STATUS_ERROR; > + if (pad =3D=3D RSA_NO_PADDING) { > + ret =3D RSA_public_decrypt(op->rsa.sign.length, > + op->rsa.sign.data, > + op->rsa.message_to_verify.data, > + rsa, > + pad); > + > + if (ret > 0) > + op->rsa.message_to_verify.length =3D ret; > + } else { > + tmp =3D rte_malloc(NULL, op->rsa.sign.length, 0); > + if (tmp =3D=3D NULL) { > + OPENSSL_LOG(ERR, "Memory allocation > failed"); > + cop->status =3D > RTE_CRYPTO_OP_STATUS_ERROR; > + break; > + } > + ret =3D RSA_public_decrypt(op->rsa.sign.length, > + op->rsa.sign.data, > + tmp, > + rsa, > + pad); > + > + OPENSSL_LOG(DEBUG, > + "Length of public_decrypt %d " > + "length of message %zd\n", > + ret, op->rsa.message.length); > + if ((ret <=3D 0) || (CRYPTO_memcmp(tmp, op- > >rsa.message.data, > + op->rsa.message.length))) { > + OPENSSL_LOG(ERR, "RSA sign Verification > failed"); > + cop->status =3D > RTE_CRYPTO_OP_STATUS_ERROR; > + } > + rte_free(tmp); > } > - rte_free(tmp); > break; >=20 > default: > -- > 2.1.0