DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] lib/cryptodev: set minimal output buffer size for RSA op
@ 2023-05-17 16:47 Gowrishankar Muthukrishnan
  2023-05-25  8:05 ` Akhil Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Gowrishankar Muthukrishnan @ 2023-05-17 16:47 UTC (permalink / raw)
  To: dev; +Cc: anoobj, Akhil Goyal, Fan Zhang, Gowrishankar Muthukrishnan

Depending on RSA op, the output buffer size could be set
minimal expected memory, rather than 0 as today. This will allow
PMD to do any validation on the size, in case an application
did not create enough memory or even in case of any memory
fault.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 app/test/test_cryptodev_asym.c  |  6 +++---
 lib/cryptodev/rte_crypto_asym.h | 15 ++++++++++-----
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 9236817650..bb4c70deba 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -90,7 +90,7 @@ queue_ops_rsa_sign_verify(void *sess)
 
 	asym_op->rsa.message.data = rsaplaintext.data;
 	asym_op->rsa.message.length = rsaplaintext.len;
-	asym_op->rsa.sign.length = 0;
+	asym_op->rsa.sign.length = RTE_DIM(rsa_n);
 	asym_op->rsa.sign.data = output_buf;
 	asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
@@ -181,7 +181,7 @@ queue_ops_rsa_enc_dec(void *sess)
 
 	asym_op->rsa.message.data = rsaplaintext.data;
 	asym_op->rsa.cipher.data = cipher_buf;
-	asym_op->rsa.cipher.length = 0;
+	asym_op->rsa.cipher.length = RTE_DIM(rsa_n);
 	asym_op->rsa.message.length = rsaplaintext.len;
 	asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
@@ -213,7 +213,7 @@ queue_ops_rsa_enc_dec(void *sess)
 
 	/* Use the resulted output as decryption Input vector*/
 	asym_op = result_op->asym;
-	asym_op->rsa.message.length = 0;
+	asym_op->rsa.message.length = RTE_DIM(rsa_n);
 	asym_op->rsa.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
 	asym_op->rsa.padding.type = RTE_CRYPTO_RSA_PADDING_PKCS1_5;
 
diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
index 989f38323f..bdf92d4358 100644
--- a/lib/cryptodev/rte_crypto_asym.h
+++ b/lib/cryptodev/rte_crypto_asym.h
@@ -414,7 +414,8 @@ struct rte_crypto_rsa_op_param {
 	 * In this case the underlying array should have been
 	 * allocated with enough memory to hold plaintext output
 	 * (i.e. must be at least RSA key size). The message.length
-	 * field should be 0 and will be overwritten by the PMD
+	 * field could be either 0 or minimal length expected from PMD.
+	 * This could be validated and overwritten by the PMD
 	 * with the decrypted length.
 	 */
 
@@ -427,8 +428,10 @@ struct rte_crypto_rsa_op_param {
 	 * - for RSA public encrypt.
 	 * In this case the underlying array should have been allocated
 	 * with enough memory to hold ciphertext 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.
+	 * at least RSA key size). The cipher.length field could be
+	 * either 0 or minimal length expected from PMD.
+	 * This could be validated and overwritten by the PMD
+	 * with the encrypted length.
 	 *
 	 * When RTE_CRYPTO_RSA_PADDING_NONE and RTE_CRYPTO_ASYM_OP_VERIFY
 	 * selected, this is an output of decrypted signature.
@@ -443,8 +446,10 @@ struct rte_crypto_rsa_op_param {
 	 * - for RSA private encrypt.
 	 * In this case the underlying array should have been allocated
 	 * with enough memory to hold signature output (i.e. must be
-	 * at least RSA key size). The sign.length field should
-	 * be 0 and will be overwritten by the PMD with the signature length.
+	 * at least RSA key size). The sign.length field could be
+	 * either 0 or minimal length expected from PMD.
+	 * This could be validated and overwritten by the PMD
+	 * with the signature length.
 	 */
 
 	struct rte_crypto_rsa_padding padding;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] lib/cryptodev: set minimal output buffer size for RSA op
  2023-05-17 16:47 [PATCH] lib/cryptodev: set minimal output buffer size for RSA op Gowrishankar Muthukrishnan
@ 2023-05-25  8:05 ` Akhil Goyal
  2023-05-30 14:41   ` Akhil Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Akhil Goyal @ 2023-05-25  8:05 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Anoob Joseph, Fan Zhang, Gowrishankar Muthukrishnan

> Subject: [PATCH] lib/cryptodev: set minimal output buffer size for RSA op
> 
> Depending on RSA op, the output buffer size could be set
> minimal expected memory, rather than 0 as today. This will allow
> PMD to do any validation on the size, in case an application
> did not create enough memory or even in case of any memory
> fault.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] lib/cryptodev: set minimal output buffer size for RSA op
  2023-05-25  8:05 ` Akhil Goyal
@ 2023-05-30 14:41   ` Akhil Goyal
  0 siblings, 0 replies; 3+ messages in thread
From: Akhil Goyal @ 2023-05-30 14:41 UTC (permalink / raw)
  To: Akhil Goyal, Gowrishankar Muthukrishnan, dev
  Cc: Anoob Joseph, Fan Zhang, Gowrishankar Muthukrishnan

> > Subject: [PATCH] lib/cryptodev: set minimal output buffer size for RSA op
> >
> > Depending on RSA op, the output buffer size could be set
> > minimal expected memory, rather than 0 as today. This will allow
> > PMD to do any validation on the size, in case an application
> > did not create enough memory or even in case of any memory
> > fault.
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Acked-by: Akhil Goyal <gakhil@marvell.com>
Applied to dpdk-next-crypto


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-30 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 16:47 [PATCH] lib/cryptodev: set minimal output buffer size for RSA op Gowrishankar Muthukrishnan
2023-05-25  8:05 ` Akhil Goyal
2023-05-30 14:41   ` Akhil Goyal

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).