From patchwork Mon Nov 29 09:51:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramkumar Balu X-Patchwork-Id: 104740 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E4EB4A0C5A; Mon, 29 Nov 2021 11:41:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 30A91410EA; Mon, 29 Nov 2021 11:41:10 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id EE90E40689; Mon, 29 Nov 2021 10:53:08 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1ASM0qvI030797; Mon, 29 Nov 2021 01:53:08 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=+wDGjS97/OEoiHz7/agVelTdOltH7RfBmA6SnuDXJZo=; b=DYVQjjObSaKw+LdUrwVIaUNmJ9azg3IGgdYZ24eE54OqpzUtX2Tnjqi5+gfoYEwbN5hm x34281qA0xP/8jTcI8IykCu3BPq+GeWzs4gotIM7vvgJ5DJ8+hiaCnz+/61mO5pbqZdx HcL5qFlZniSyKXoS8Sz0CApE3fTuRTpS3WUpD3biOLPKU04I88Ky2gL9e/IKiudPCxoa AhoV7E9z5e1jwFskqwg+zRBcjoIcoz2XQAMn3OMw8DbPjTJnAWqWnw+b3F9JTVsxvscW yxMqNkxOsjnYn63RW+OvMgI+7t58aiOOlLhOjW/sdLwuM6OlC/VkK4ZmJee32EyFwQI/ +g== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3cmgkpsuh8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 29 Nov 2021 01:53:07 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 29 Nov 2021 01:53:06 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 29 Nov 2021 01:53:06 -0800 Received: from rbalu.marvell.com (unknown [10.29.53.29]) by maili.marvell.com (Postfix) with ESMTP id 94E023F7082; Mon, 29 Nov 2021 01:53:03 -0800 (PST) From: Ramkumar Balu To: Akhil Goyal , Anoob Joseph , Declan Doherty , Fan Zhang , Ankur Dwivedi , "Tejasree Kondoj" CC: , , Ramkumar Subject: [PATCH 1/5] cryptodev: fix RSA op cipher field description Date: Mon, 29 Nov 2021 09:51:55 +0000 Message-ID: <20211129095159.16376-2-rbalu@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211129095159.16376-1-rbalu@marvell.com> References: <20211129095159.16376-1-rbalu@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 57EPZTvaUkqRxiSLA5dWZVwD4oUDz3cw X-Proofpoint-GUID: 57EPZTvaUkqRxiSLA5dWZVwD4oUDz3cw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-29_07,2021-11-28_01,2020-04-07_01 X-Mailman-Approved-At: Mon, 29 Nov 2021 11:41:08 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ramkumar The description for 'struct rte_crypto_rsa_op_param' failed to specify a field for returning the plaintext from RSA public key decryption. This patch fixes the rte_crypto_rsa_op_param description to specify 'cipher' field to be used for returning plaintext during RSA op_type == RTE_CRYPTO_ASYM_OP_VERIFY. Fixes: 501ed9c6611f ("cryptodev: add cipher field to RSA op") Cc: stable@dpdk.org Signed-off-by: Ramkumar --- lib/cryptodev/rte_crypto_asym.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h index 9c866f553f..b99cf6843c 100644 --- a/lib/cryptodev/rte_crypto_asym.h +++ b/lib/cryptodev/rte_crypto_asym.h @@ -461,11 +461,12 @@ struct rte_crypto_rsa_op_param { * - to be decrypted for RSA private decrypt. * * Pointer to output data - * - for RSA public encrypt. + * - for RSA public encrypt/decrypt. * In this case the underlying array should have been allocated - * with enough memory to hold ciphertext output (i.e. must be + * with enough memory to hold ciphertext/plaintext output (i.e. must be * at least RSA key size). The cipher.length field should - * be 0 and will be overwritten by the PMD with the encrypted length. + * be 0 and will be overwritten by the PMD with the encrypted/decrypted + * length. * * All data is in Octet-string network byte order format. */ From patchwork Mon Nov 29 09:51:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramkumar Balu X-Patchwork-Id: 104741 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 60C7DA0C5A; Mon, 29 Nov 2021 11:41:20 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 10AFB41147; Mon, 29 Nov 2021 11:41:11 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id EAAB540689; Mon, 29 Nov 2021 10:53:18 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1ASLrU0T017558; Mon, 29 Nov 2021 01:53:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=gfmG/K17S1B8BgwswZveGnpZ8uta98xGz6hunFg/hbo=; b=UN5mOJZHmDvXVphFfaFfLVHjDyFCyohNeNT+9ktzhEM0g0Wb52KShlVEEUM9gE/iA5Gc YWWLwdwHEJRi1IVlqqPC3XU4ZFAfJnTAUTZf2QpE3gAVoT2SZT5DSpL+zR2kV/ho5ZvG Q0RjjjKTmvJFiBjJN+kzCmECZ41nwbArP2I18if2KjsFspkC5U8yqwPbvtL2Oyw/cpnf zLHJZ30EPxAWKNDumjURXkFBu6roCJj7BEpDLXWmhiJqKXUUEBePuZ3QSM+U+Gbt1rie 9b/YNsOSSmsBdVuaGx2cUovHJU8yyejtFqHWBEMEBpHmPL9yf2nQioXUgGTmL0YAQEL9 AQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3cmgkpsuht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 29 Nov 2021 01:53:17 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 29 Nov 2021 01:53:16 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 29 Nov 2021 01:53:16 -0800 Received: from rbalu.marvell.com (unknown [10.29.53.29]) by maili.marvell.com (Postfix) with ESMTP id DC42C3F7079; Mon, 29 Nov 2021 01:53:12 -0800 (PST) From: Ramkumar Balu To: Akhil Goyal , Anoob Joseph , Declan Doherty , Fan Zhang , Ankur Dwivedi , "Tejasree Kondoj" CC: , , Ramkumar Subject: [PATCH 2/5] crypto/openssl: fix output of RSA verify op Date: Mon, 29 Nov 2021 09:51:56 +0000 Message-ID: <20211129095159.16376-3-rbalu@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211129095159.16376-1-rbalu@marvell.com> References: <20211129095159.16376-1-rbalu@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: r2s8pKg1049fSOrbP6KjbPPatOebb0DK X-Proofpoint-GUID: r2s8pKg1049fSOrbP6KjbPPatOebb0DK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-29_07,2021-11-28_01,2020-04-07_01 X-Mailman-Approved-At: Mon, 29 Nov 2021 11:41:08 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ramkumar During RSA verify, the OpenSSL PMD fails to return the plaintext after public key decryption. This patch fixes the OpenSSL PMD to return the decrypted plaintext in cipher.data / cipher.length fields Fixes: 3e9d6bd447fb ("crypto/openssl: add RSA and mod asym operations") Fixes: fe1606e0138c ("crypto/openssl: fix RSA verify operation") Cc: stable@dpdk.org Signed-off-by: Ramkumar --- drivers/crypto/openssl/rte_openssl_pmd.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c index 5794ed8159..3ab2c3b5c1 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -1953,12 +1953,16 @@ process_openssl_rsa_op(struct rte_crypto_op *cop, break; case RTE_CRYPTO_ASYM_OP_VERIFY: - tmp = rte_malloc(NULL, op->rsa.sign.length, 0); + tmp = op->rsa.cipher.data; if (tmp == NULL) { - OPENSSL_LOG(ERR, "Memory allocation failed"); - cop->status = RTE_CRYPTO_OP_STATUS_ERROR; - break; + tmp = rte_malloc(NULL, op->rsa.sign.length, 0); + if (tmp == NULL) { + OPENSSL_LOG(ERR, "Memory allocation failed"); + cop->status = RTE_CRYPTO_OP_STATUS_ERROR; + break; + } } + ret = RSA_public_decrypt(op->rsa.sign.length, op->rsa.sign.data, tmp, @@ -1974,7 +1978,9 @@ process_openssl_rsa_op(struct rte_crypto_op *cop, OPENSSL_LOG(ERR, "RSA sign Verification failed"); cop->status = RTE_CRYPTO_OP_STATUS_ERROR; } - rte_free(tmp); + op->rsa.cipher.length = ret; + if (tmp != op->rsa.cipher.data) + rte_free(tmp); break; default: From patchwork Mon Nov 29 09:51:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramkumar Balu X-Patchwork-Id: 104742 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BB2D3A0C5A; Mon, 29 Nov 2021 11:41:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 19AB74117D; Mon, 29 Nov 2021 11:41:12 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id EFFE440689; Mon, 29 Nov 2021 10:53:32 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AT7ZQb6009078; Mon, 29 Nov 2021 01:53:32 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=aM7L54Q0UxlEYe1FN3RYsSbSbKOvA0VFdU6xDg11Ero=; b=A1YMCKlvkCTHxa7tlROmKV8dS3QMvts43v8dey6Ebd6a5b6BAGwVo6fO8gbz9usa/JUr hZdEO7QgSS8u7GyBAdSZjnZ+NX6hEL0UzXPx+AUCT/UGviTZfDoO5YNZXK0RKUkYyTr2 mTrhQcYTxYfiwbngeWAVmrlLNgOfg8ioZZtWX2PJL0Qfe6ILdC66FwgZY8wHrSeUWHq9 2UNYWzBT3vnmgA18nReQKrwEoGNGaBepJhO4d7Lz4bsCy87l41XGe66+PWwG/tsGQQmv L+RqHXcGmfSLCg+0YqoVC2KdRu1r24d7KbHhmZSr04gQLDvO8rMZ2jkGiogLF2xGk0oZ IA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3cmtkpgdb8-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 29 Nov 2021 01:53:32 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 29 Nov 2021 01:53:30 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 29 Nov 2021 01:53:30 -0800 Received: from rbalu.marvell.com (unknown [10.29.53.29]) by maili.marvell.com (Postfix) with ESMTP id 176263F7079; Mon, 29 Nov 2021 01:53:24 -0800 (PST) From: Ramkumar Balu To: Akhil Goyal , Anoob Joseph , Declan Doherty , Fan Zhang , Ankur Dwivedi , "Tejasree Kondoj" CC: , , Ramkumar Subject: [PATCH 3/5] crypto/octeontx: fix output field for RSA verify Date: Mon, 29 Nov 2021 09:51:57 +0000 Message-ID: <20211129095159.16376-4-rbalu@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211129095159.16376-1-rbalu@marvell.com> References: <20211129095159.16376-1-rbalu@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: opOL3KN6cOIvL_a4rVeMTPk3XMQPeiNu X-Proofpoint-ORIG-GUID: opOL3KN6cOIvL_a4rVeMTPk3XMQPeiNu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-29_07,2021-11-28_01,2020-04-07_01 X-Mailman-Approved-At: Mon, 29 Nov 2021 11:41:08 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ramkumar During RSA sign verification, the OCTEONTX PMD returns the decrypted plaintext in 'sign' field of rte_crypto_rsa_op_param. The 'sign' field is actually used to pass input to the operation. This PMD overwrites the 'sign' field buffer. This is non-compliance to lib cryptodev. This patch fixes the PMD to use 'cipher' field to return the decrypted plaintext during RSA verify operation. Fixes: e9a356e2fc71 ("crypto/octeontx: add asymmetric enqueue/dequeue ops") Cc: stable@dpdk.org Signed-off-by: Ramkumar --- drivers/crypto/octeontx/otx_cryptodev_ops.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c index 9e8fd495cf..07ce079d87 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c @@ -788,18 +788,20 @@ otx_cpt_asym_rsa_op(struct rte_crypto_op *cop, struct cpt_request_info *req, break; case RTE_CRYPTO_ASYM_OP_VERIFY: if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE) - rsa->sign.length = rsa_ctx->n.length; + rsa->cipher.length = rsa_ctx->n.length; else { /* Get length of decrypted output */ - rsa->sign.length = rte_cpu_to_be_16 + rsa->cipher.length = rte_cpu_to_be_16 (*((uint16_t *)req->rptr)); /* Offset data pointer by length fields */ req->rptr += 2; } - memcpy(rsa->sign.data, req->rptr, rsa->sign.length); - if (memcmp(rsa->sign.data, rsa->message.data, + if (rsa->cipher.data != NULL) + memcpy(rsa->cipher.data, req->rptr, rsa->cipher.length); + + if (memcmp(req->rptr, rsa->message.data, rsa->message.length)) { CPT_LOG_DP_ERR("RSA verification failed"); cop->status = RTE_CRYPTO_OP_STATUS_ERROR; From patchwork Mon Nov 29 09:51:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramkumar Balu X-Patchwork-Id: 104743 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F1EB2A0C5A; Mon, 29 Nov 2021 11:41:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 10F1642765; Mon, 29 Nov 2021 11:41:13 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 2E10040689; Mon, 29 Nov 2021 10:53:46 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1AT7ZQbC009078; Mon, 29 Nov 2021 01:53:45 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=owL+yEvx51IDYyVIvVBL3b77DK9AOZ8ahfxiHWcTZpU=; b=L2XsoQZcmAv5h2MjgoPXYmsLGtUybdQS2/cAgbmCow3tiRd0U1d59fHKyK8Z5uooLpoa ET+otuAbgATLBnslKA10kn3GB3OhiduXVcdjtndrXPnOoS9a3dck1T77D4QDz1mqnZ/E KrtVYxEIDTQbBT6dZ78ATVpSdnrZGBrvNPUJj7f3zDcOHtXaDX1GfyClIKUC1oAFNNfC oEWTWc2d6yzcL5/d0PV5sHQm5w+ELSCD/nDAbC3ohjGDKsLRO3rnIvAApFjhCpvdfGy/ mQVqB8S46dKEQrBOOtlkmibQtkKed/ndFWTdo6nYE45+w7dEXgXRWfbWzuzxs3peH0O2 nQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3cmtkpgdcx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 29 Nov 2021 01:53:45 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 29 Nov 2021 01:53:43 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 29 Nov 2021 01:53:43 -0800 Received: from rbalu.marvell.com (unknown [10.29.53.29]) by maili.marvell.com (Postfix) with ESMTP id 96E163F7090; Mon, 29 Nov 2021 01:53:38 -0800 (PST) From: Ramkumar Balu To: Akhil Goyal , Anoob Joseph , Declan Doherty , Fan Zhang , Ankur Dwivedi , "Tejasree Kondoj" CC: , , Ramkumar Subject: [PATCH 4/5] crypto/octeontx2: fix output field for RSA verify Date: Mon, 29 Nov 2021 09:51:58 +0000 Message-ID: <20211129095159.16376-5-rbalu@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211129095159.16376-1-rbalu@marvell.com> References: <20211129095159.16376-1-rbalu@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 3eyfa1uWCsgCQNHauh7yVSnzb7T61Nj0 X-Proofpoint-ORIG-GUID: 3eyfa1uWCsgCQNHauh7yVSnzb7T61Nj0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-29_07,2021-11-28_01,2020-04-07_01 X-Mailman-Approved-At: Mon, 29 Nov 2021 11:41:08 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ramkumar During RSA sign verification, the OCTEONTX2 PMD returns the decrypted plaintext in 'sign' field of rte_crypto_rsa_op_param. The 'sign' field is actually used to pass input to the operation. This PMD overwrites the 'sign' field buffer. This is non-compliance to lib cryptodev. This patch fixes the PMD to use 'cipher' field to return the decrypted plaintext during RSA verify operation. Fixes: 04227377c81b ("crypto/octeontx2: support asymmetric in enqueue/dequeue") Cc: stable@dpdk.org Signed-off-by: Ramkumar --- drivers/crypto/octeontx2/otx2_cryptodev_ops.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c index 339b82f33e..fb38e309aa 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_ops.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_ops.c @@ -876,20 +876,22 @@ otx2_cpt_asym_rsa_op(struct rte_crypto_op *cop, struct cpt_request_info *req, break; case RTE_CRYPTO_ASYM_OP_VERIFY: if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE) { - rsa->sign.length = rsa_ctx->n.length; - memcpy(rsa->sign.data, req->rptr, rsa->sign.length); + rsa->cipher.length = rsa_ctx->n.length; } else { /* Get length of signed output */ - rsa->sign.length = rte_cpu_to_be_16 + rsa->cipher.length = rte_cpu_to_be_16 (*((uint16_t *)req->rptr)); /* * Offset output data pointer by length field - * (2 bytes) and copy signed data. + * (2 bytes). */ - memcpy(rsa->sign.data, req->rptr + 2, - rsa->sign.length); + req->rptr += 2; } - if (memcmp(rsa->sign.data, rsa->message.data, + + if (rsa->cipher.data != NULL) + memcpy(rsa->cipher.data, req->rptr, rsa->cipher.length); + + if (memcmp(req->rptr, rsa->message.data, rsa->message.length)) { CPT_LOG_DP_ERR("RSA verification failed"); cop->status = RTE_CRYPTO_OP_STATUS_ERROR; From patchwork Mon Nov 29 09:51:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramkumar Balu X-Patchwork-Id: 104744 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1D570A0C5A; Mon, 29 Nov 2021 11:41:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1885A4276F; Mon, 29 Nov 2021 11:41:14 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id EAF7E40689; Mon, 29 Nov 2021 10:53:54 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1ASNMELR003048; Mon, 29 Nov 2021 01:53:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=StPUS0yw/3b3gzBjvTh64tEZYrUs4sHF+7m0mhXxD68=; b=X+EJAtFPE0B8U+AAExMcS9fPCb0NmdYr4eJn1pTX2p3eOSMZ6+J1xKLvowkuXdeXcLQG t0T/ge60c/2F4/hPU46sVbpxlGpCPAn4cP6WK3mTxrsmqFvrw827cfiqvoBCYhwRa4oX jRiePlwxoItd+hQ+TyUWbD369qTGhgONeA4as+uJQKLBQ0HPLBgT8LIRiiLA0LjbvUEo SizZ/DGV1T3/CktSHtnOAAxq3FXP5aTfrxWC2ghxwnH3XU9uAkNoQM598Fp/n6Zigc+H X6BV+2hOnq/7D5DA8ask3vyZt4DKqmFeeE3xm8MeALw0Mi20YLr4EaGcRfHzPObl5Q7r bw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3cmgkpsukv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 29 Nov 2021 01:53:53 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 29 Nov 2021 01:53:52 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Mon, 29 Nov 2021 01:53:52 -0800 Received: from rbalu.marvell.com (unknown [10.29.53.29]) by maili.marvell.com (Postfix) with ESMTP id D41E63F7079; Mon, 29 Nov 2021 01:53:46 -0800 (PST) From: Ramkumar Balu To: Akhil Goyal , Anoob Joseph , Declan Doherty , Fan Zhang , Ankur Dwivedi , "Tejasree Kondoj" CC: , , Ramkumar Subject: [PATCH 5/5] crypto/cnxk: fix output field for RSA verify Date: Mon, 29 Nov 2021 09:51:59 +0000 Message-ID: <20211129095159.16376-6-rbalu@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211129095159.16376-1-rbalu@marvell.com> References: <20211129095159.16376-1-rbalu@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Vmx8QBnoUD8gMCzJVuGaAE-p6JO6e0o4 X-Proofpoint-GUID: Vmx8QBnoUD8gMCzJVuGaAE-p6JO6e0o4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-29_07,2021-11-28_01,2020-04-07_01 X-Mailman-Approved-At: Mon, 29 Nov 2021 11:41:08 +0100 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ramkumar During RSA sign verification, this PMD returns the decrypted plaintext in 'sign' field of rte_crypto_rsa_op_param. The 'sign' field is actually used to pass input to the operation. This PMD overwrites the 'sign' field buffer. This is non-compliance to lib cryptodev. This patch fixes the PMD to use 'cipher' field to return the decrypted plaintext during RSA verify operation. Fixes: 6661bedf1605 ("crypto/cnxk: add asymmetric datapath") Cc: stable@dpdk.org Signed-off-by: Ramkumar --- drivers/crypto/cnxk/cnxk_ae.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h index 6222171fe6..f4c6c92880 100644 --- a/drivers/crypto/cnxk/cnxk_ae.h +++ b/drivers/crypto/cnxk/cnxk_ae.h @@ -696,19 +696,22 @@ cnxk_ae_dequeue_rsa_op(struct rte_crypto_op *cop, uint8_t *rptr, break; case RTE_CRYPTO_ASYM_OP_VERIFY: if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE) { - rsa->sign.length = rsa_ctx->n.length; - memcpy(rsa->sign.data, rptr, rsa->sign.length); + rsa->cipher.length = rsa_ctx->n.length; } else { /* Get length of signed output */ - rsa->sign.length = + rsa->cipher.length = rte_cpu_to_be_16(*((uint16_t *)rptr)); /* * Offset output data pointer by length field - * (2 bytes) and copy signed data. + * (2 bytes). */ - memcpy(rsa->sign.data, rptr + 2, rsa->sign.length); + rptr += 2; } - if (memcmp(rsa->sign.data, rsa->message.data, + + if (rsa->cipher.data != NULL) + memcpy(rsa->cipher.data, rptr, rsa->cipher.length); + + if (memcmp(rptr, rsa->message.data, rsa->message.length)) { cop->status = RTE_CRYPTO_OP_STATUS_ERROR; }