crypto/cnxk: fix ECDH pubkey verify

Message ID 20240615113434.2331-1-gmuthukrishn@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series crypto/cnxk: fix ECDH pubkey verify |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Gowrishankar Muthukrishnan June 15, 2024, 11:34 a.m. UTC
Fix dequeue operation for ECDH pubkey verify.

Fixes: baae0994fa96 ("crypto/cnxk: support ECDH")
Fixes: 5c9025583167 ("crypto/cnxk: fix CN9K ECDH public key verification")
Cc: stable@dpdk.org

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 23 ++++++++++++++---------
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 21 +++++++++++++--------
 2 files changed, 27 insertions(+), 17 deletions(-)
  

Comments

Anoob Joseph June 17, 2024, 6:40 a.m. UTC | #1
> 
> Fix dequeue operation for ECDH pubkey verify.
> 
> Fixes: baae0994fa96 ("crypto/cnxk: support ECDH")
> Fixes: 5c9025583167 ("crypto/cnxk: fix CN9K ECDH public key verification")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Acked-by: Anoob Joseph <anoobj@marvell.com>
  
Akhil Goyal June 26, 2024, 7:56 a.m. UTC | #2
> >
> > Fix dequeue operation for ECDH pubkey verify.
> >
> > Fixes: baae0994fa96 ("crypto/cnxk: support ECDH")
> > Fixes: 5c9025583167 ("crypto/cnxk: fix CN9K ECDH public key verification")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> 
> Acked-by: Anoob Joseph <anoobj@marvell.com>

Updated patch description

Applied to dpdk-next-crypto

Thanks
  

Patch

diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
index 720b756001..07bd13b16d 100644
--- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
@@ -1186,15 +1186,20 @@  cn10k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, struct rte_crypto_op *cop
 
 		return;
 	} else if (cop->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
-			   cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION &&
-			   cop->asym->ecdh.ke_type == RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY) {
-		if (likely(compcode == CPT_COMP_GOOD)) {
-			if (uc_compcode == ROC_AE_ERR_ECC_POINT_NOT_ON_CURVE) {
-				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
-				return;
-			} else if (uc_compcode == ROC_AE_ERR_ECC_PAI) {
-				cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
-				return;
+		   cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+		struct cnxk_ae_sess *sess;
+
+		sess = (struct cnxk_ae_sess *)cop->asym->session;
+		if (sess->xfrm_type == RTE_CRYPTO_ASYM_XFORM_ECDH &&
+		    cop->asym->ecdh.ke_type == RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY) {
+			if (likely(compcode == CPT_COMP_GOOD)) {
+				if (uc_compcode == ROC_AE_ERR_ECC_POINT_NOT_ON_CURVE) {
+					cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+					return;
+				} else if (uc_compcode == ROC_AE_ERR_ECC_PAI) {
+					cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+					return;
+				}
 			}
 		}
 	}
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 96a75a7797..f443cb9563 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -523,14 +523,19 @@  cn9k_cpt_dequeue_post_process(struct cnxk_cpt_qp *qp, struct rte_crypto_op *cop,
 			if (res->uc_compcode == ROC_SE_ERR_GC_ICV_MISCOMPARE)
 				cop->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
 			else if (cop->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC &&
-				 cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION &&
-				 cop->asym->ecdh.ke_type == RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY) {
-				if (res->uc_compcode == ROC_AE_ERR_ECC_POINT_NOT_ON_CURVE) {
-					cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
-					return;
-				} else if (res->uc_compcode == ROC_AE_ERR_ECC_PAI) {
-					cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
-					return;
+				 cop->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
+				struct cnxk_ae_sess *sess;
+
+				sess = (struct cnxk_ae_sess *)cop->asym->session;
+				if (sess->xfrm_type == RTE_CRYPTO_ASYM_XFORM_ECDH &&
+				    cop->asym->ecdh.ke_type == RTE_CRYPTO_ASYM_KE_PUB_KEY_VERIFY) {
+					if (res->uc_compcode == ROC_AE_ERR_ECC_POINT_NOT_ON_CURVE) {
+						cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+						return;
+					} else if (res->uc_compcode == ROC_AE_ERR_ECC_PAI) {
+						cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+						return;
+					}
 				}
 			} else
 				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;