DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anoob Joseph <anoobj@marvell.com>
To: Akhil Goyal <akhil.goyal@nxp.com>,
	Pablo de Lara <pablo.de.lara.guarch@intel.com>
Cc: Sunila Sahu <ssahu@marvell.com>, Jerin Jacob <jerinj@marvell.com>,
	Narayana Prasad <pathreya@marvell.com>,
	Anoob Joseph <anoobj@marvell.com>,
	Fiona Trahe <fiona.trahe@intel.com>,
	Kanaka Durga Kotamarthy <kkotamarthy@marvell.com>,
	Shally Verma <shallyv@marvell.com>, <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 6/8] crypto/octeontx: add asymmetric op dequeue function
Date: Mon, 9 Sep 2019 18:58:05 +0530	[thread overview]
Message-ID: <1568035687-25492-7-git-send-email-anoobj@marvell.com> (raw)
In-Reply-To: <1568035687-25492-1-git-send-email-anoobj@marvell.com>

From: Sunila Sahu <ssahu@marvell.com>

Add asymmetric crypto op dequeue routine

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
Signed-off-by: Kanaka Durga Kotamarthy <kkotamarthy@marvell.com>
Signed-off-by: Sunila Sahu <ssahu@marvell.com>
---
 drivers/crypto/octeontx/otx_cryptodev_ops.c | 88 +++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c
index 1f42fe8..ab1ee7e 100644
--- a/drivers/crypto/octeontx/otx_cryptodev_ops.c
+++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c
@@ -591,6 +591,87 @@ otx_cpt_pkt_enqueue(void *qptr, struct rte_crypto_op **ops, uint16_t nb_ops)
 }
 
 static __rte_always_inline void
+otx_cpt_asym_rsa_op(struct rte_crypto_op *cop, struct cpt_request_info *req,
+		    struct rte_crypto_rsa_xform *rsa_ctx)
+
+{
+	struct rte_crypto_rsa_op_param *rsa = &cop->asym->rsa;
+
+	switch (rsa->op_type) {
+	case RTE_CRYPTO_ASYM_OP_ENCRYPT:
+		rsa->cipher.length = rsa_ctx->n.length;
+		memcpy(rsa->cipher.data, req->rptr, rsa->cipher.length);
+		break;
+	case RTE_CRYPTO_ASYM_OP_DECRYPT:
+		if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE)
+			rsa->message.length = rsa_ctx->n.length;
+		else {
+			/* Get length of decrypted output */
+			rsa->message.length = rte_cpu_to_be_16
+					(*((uint16_t *)req->rptr));
+
+			/* Offset data pointer by length fields */
+			req->rptr += 2;
+		}
+		memcpy(rsa->message.data, req->rptr, rsa->message.length);
+		break;
+	case RTE_CRYPTO_ASYM_OP_SIGN:
+		rsa->sign.length = rsa_ctx->n.length;
+		memcpy(rsa->sign.data, req->rptr, rsa->sign.length);
+		break;
+	case RTE_CRYPTO_ASYM_OP_VERIFY:
+		if (rsa->pad == RTE_CRYPTO_RSA_PADDING_NONE)
+			rsa->sign.length = rsa_ctx->n.length;
+		else {
+			/* Get length of decrypted output */
+			rsa->sign.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,
+			   rsa->message.length)) {
+			CPT_LOG_DP_ERR("RSA verification failed");
+			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		}
+		break;
+	default:
+		CPT_LOG_DP_DEBUG("Invalid RSA operation type");
+		cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		break;
+	}
+}
+
+static void
+otx_cpt_asym_post_process(struct rte_crypto_op *cop,
+			  struct cpt_request_info *req)
+{
+	struct rte_crypto_asym_op *op = cop->asym;
+	struct cpt_asym_sess_misc *sess;
+
+	sess = get_asym_session_private_data(op->session,
+					     otx_cryptodev_driver_id);
+
+	switch (sess->xfrm_type) {
+	case RTE_CRYPTO_ASYM_XFORM_RSA:
+		otx_cpt_asym_rsa_op(cop, req, &sess->rsa_ctx);
+		break;
+	case RTE_CRYPTO_ASYM_XFORM_MODEX:
+		op->modex.result.length = sess->mod_ctx.modulus.length;
+		memcpy(op->modex.result.data, req->rptr,
+		       op->modex.result.length);
+		break;
+	default:
+		CPT_LOG_DP_DEBUG("Invalid crypto xform type");
+		cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		break;
+	}
+}
+
+static __rte_always_inline void
 otx_cpt_dequeue_post_process(struct rte_crypto_op *cop, uintptr_t *rsp)
 {
 	/* H/w has returned success */
@@ -604,6 +685,13 @@ otx_cpt_dequeue_post_process(struct rte_crypto_op *cop, uintptr_t *rsp)
 			compl_auth_verify(cop, (uint8_t *)rsp[2], rsp[3]);
 		return;
 	}
+
+	if (cop->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		rsp = RTE_PTR_ADD(rsp, 4 * sizeof(uintptr_t));
+		otx_cpt_asym_post_process(cop, (struct cpt_request_info *)rsp);
+	}
+
+	return;
 }
 
 static uint16_t
-- 
2.7.4


  parent reply	other threads:[~2019-09-09 13:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09 13:27 [dpdk-dev] [PATCH 0/8] add asym support in crypto_octeontx PMD Anoob Joseph
2019-09-09 13:28 ` [dpdk-dev] [PATCH 1/8] crypto/octeontx: add device type mailbox routine Anoob Joseph
2019-09-09 13:28 ` [dpdk-dev] [PATCH 2/8] crypto/octeontx: add RSA and modexp asym capabilities Anoob Joseph
2019-10-01 12:38   ` Akhil Goyal
2019-10-02 10:48     ` Anoob Joseph
2019-10-03  8:03       ` Akhil Goyal
2019-09-09 13:28 ` [dpdk-dev] [PATCH 3/8] crypto/octeontx: add asymmetric session operations Anoob Joseph
2019-10-01 12:57   ` Akhil Goyal
2019-10-02 11:18     ` Anoob Joseph
2019-09-09 13:28 ` [dpdk-dev] [PATCH 4/8] common/cpt: add helper functions for asymmetric crypto Anoob Joseph
2019-10-01 13:04   ` Akhil Goyal
2019-10-02 11:13     ` Anoob Joseph
2019-10-04  7:32       ` Anoob Joseph
2019-09-09 13:28 ` [dpdk-dev] [PATCH 5/8] crypto/octeontx: add asymmetric op enqueue function Anoob Joseph
2019-09-09 13:28 ` Anoob Joseph [this message]
2019-09-09 13:28 ` [dpdk-dev] [PATCH 7/8] app/test: register octeontx PMD to asym testsuite Anoob Joseph
2019-09-09 13:28 ` [dpdk-dev] [PATCH 8/8] doc: update octeontx asymmetric features Anoob Joseph
2019-10-01 13:27   ` Akhil Goyal
2019-10-02 11:04     ` Anoob Joseph
2019-10-03  8:01       ` Akhil Goyal
2019-09-09 15:51 ` [dpdk-dev] [PATCH 0/8] add asym support in crypto_octeontx PMD Shally Verma
2019-10-11 13:01 ` [dpdk-dev] [PATCH v2 0/5] " Anoob Joseph
2019-10-11 13:01   ` [dpdk-dev] [PATCH v2 1/5] crypto/octeontx: add device type mailbox routine Anoob Joseph
2019-10-11 13:01   ` [dpdk-dev] [PATCH v2 2/5] crypto/octeontx: add asymmetric session operations Anoob Joseph
2019-10-11 13:01   ` [dpdk-dev] [PATCH v2 3/5] common/cpt: add helper functions for asymmetric crypto Anoob Joseph
2019-10-11 13:01   ` [dpdk-dev] [PATCH v2 4/5] crypto/octeontx: add asymmetric enqueue/dequeue ops Anoob Joseph
2019-10-11 13:01   ` [dpdk-dev] [PATCH v2 5/5] app/test: register octeontx PMD to asym testsuite Anoob Joseph
2019-10-15 12:46   ` [dpdk-dev] [PATCH v2 0/5] add asym support in crypto_octeontx PMD Akhil Goyal
2019-10-15 13:31     ` Akhil Goyal
2019-10-16  4:57     ` Anoob Joseph
2019-10-16  5:57       ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1568035687-25492-7-git-send-email-anoobj@marvell.com \
    --to=anoobj@marvell.com \
    --cc=akhil.goyal@nxp.com \
    --cc=dev@dpdk.org \
    --cc=fiona.trahe@intel.com \
    --cc=jerinj@marvell.com \
    --cc=kkotamarthy@marvell.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=pathreya@marvell.com \
    --cc=shallyv@marvell.com \
    --cc=ssahu@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).