DPDK patches and discussions
 help / color / mirror / Atom feed
From: Akash Saxena <akash.saxena@caviumnetworks.com>
To: pablo.de.lara.guarch@intel.com
Cc: dev@dpdk.org, akhil.goyal@nxp.com,
	shally.verma@caviumnetworks.com, ayuj.verma@caviumnetworks.com,
	Akash Saxena <akash.saxena@caviumnetworks.com>
Subject: [dpdk-dev] [PATCH v1 1/2] crypto/openssl: changes for RSA verify operation
Date: Thu, 11 Oct 2018 19:13:10 +0530	[thread overview]
Message-ID: <1539265391-9606-2-git-send-email-akash.saxena@caviumnetworks.com> (raw)
In-Reply-To: <1539265391-9606-1-git-send-email-akash.saxena@caviumnetworks.com>

Add tmp buffer to pass to OpenSSL sign API and memcmp output with
original plain text to verify signature match.
Set op->status = RTE_CRYPO_OP_STATUS_ERROR on signature mismatch.

Signed-off-by: Ayuj Verma <ayuj.verma@caviumnetworks.com>
Signed-off-by: Akash Saxena <akash.saxena@caviumnetworks.com>
Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 003116d..cc33fca 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1843,6 +1843,9 @@ process_openssl_rsa_op(struct rte_crypto_op *cop,
 	struct rte_crypto_asym_op *op = cop->asym;
 	RSA *rsa = sess->u.r.rsa;
 	uint32_t pad = (op->rsa.pad);
+	uint8_t *tmp;
+
+	cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
 
 	switch (pad) {
 	case RTE_CRYPTO_RSA_PKCS1_V1_5_BT0:
@@ -1895,9 +1898,10 @@ 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);
 		ret = RSA_public_decrypt(op->rsa.sign.length,
 				op->rsa.sign.data,
-				op->rsa.sign.data,
+				tmp,
 				rsa,
 				pad);
 
@@ -1905,13 +1909,15 @@ process_openssl_rsa_op(struct rte_crypto_op *cop,
 				"Length of public_decrypt %d "
 				"length of message %zd\n",
 				ret, op->rsa.message.length);
-
-		if (memcmp(op->rsa.sign.data, op->rsa.message.data,
-					op->rsa.message.length)) {
-			OPENSSL_LOG(ERR,
-					"RSA sign Verification failed");
-			return -1;
+		if (ret > 0) {
+			if (memcmp(tmp, op->rsa.message.data,
+						op->rsa.message.length)) {
+				OPENSSL_LOG(ERR,
+						"RSA sign Verification failed");
+				cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+			}
 		}
+		rte_free(tmp);
 		break;
 
 	default:
-- 
2.7.4

  reply	other threads:[~2018-10-11 13:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-11 13:43 [dpdk-dev] [PATCH v1 0/2] Changes for RSA verify operation in OpenSSL PMD and unit tests Akash Saxena
2018-10-11 13:43 ` Akash Saxena [this message]
2018-10-16 13:15   ` [dpdk-dev] [PATCH v1 1/2] crypto/openssl: changes for RSA verify operation Akhil Goyal
2018-10-16 13:17   ` Akhil Goyal
2018-10-11 13:43 ` [dpdk-dev] [PATCH v1 2/2] test/crypto: remove data verification at rsa " Akash Saxena
2018-10-16 13:21   ` Akhil Goyal
2018-10-22 12:29     ` Verma, Shally
2018-10-24 13:09       ` 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=1539265391-9606-2-git-send-email-akash.saxena@caviumnetworks.com \
    --to=akash.saxena@caviumnetworks.com \
    --cc=akhil.goyal@nxp.com \
    --cc=ayuj.verma@caviumnetworks.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=shally.verma@caviumnetworks.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).