[v2,1/2] cryptodev: fix RSA xform for ASN.1 syntax

Message ID 20241004061107.584-2-gmuthukrishn@marvell.com (mailing list archive)
State Accepted
Delegated to: akhil goyal
Headers
Series cryptodev: fix RSA xform to support VirtIO standard |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gowrishankar Muthukrishnan Oct. 4, 2024, 6:11 a.m. UTC
As per ASN.1 syntax (RFC 3447 Appendix A.1.2), RSA private key
would need specification of quintuple along with private exponent.
It is up to the implementation to internally handle, but not at
RTE itself to make them exclusive each other. Removing union
on them allows asymmetric implementation in VirtIO to benefit from
the xform as per ASN.1 syntax.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 lib/cryptodev/rte_crypto_asym.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Kusztal, ArkadiuszX Oct. 7, 2024, 7:19 a.m. UTC | #1
Acked with a small comment.

> -----Original Message-----
> From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Sent: Friday, October 4, 2024 8:11 AM
> To: dev@dpdk.org; Akhil Goyal <gakhil@marvell.com>; Fan Zhang
> <fanzhang.oss@gmail.com>
> Cc: Anoob Joseph <anoobj@marvell.com>; Richardson, Bruce
> <bruce.richardson@intel.com>; jerinj@marvell.com; Kusztal, ArkadiuszX
> <arkadiuszx.kusztal@intel.com>; Ji, Kai <kai.ji@intel.com>; jack.bond-
> preston@foss.arm.com; Marchand, David <david.marchand@redhat.com>;
> hemant.agrawal@nxp.com; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Trahe, Fiona <fiona.trahe@intel.com>;
> Doherty, Declan <declan.doherty@intel.com>; matan@nvidia.com;
> ruifeng.wang@arm.com; Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>;
> maxime.coquelin@redhat.com; chenbox@nvidia.com;
> sunilprakashrao.uttarwar@amd.com; andrew.boyer@amd.com;
> ajit.khaparde@broadcom.com; raveendra.padasalagi@broadcom.com;
> vikas.gupta@broadcom.com; zhangfei.gao@linaro.org; g.singh@nxp.com;
> jianjay.zhou@huawei.com; Daly, Lee <lee.daly@intel.com>; Dooley, Brian
> <brian.dooley@intel.com>; Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com>
> Subject: [PATCH v2 1/2] cryptodev: fix RSA xform for ASN.1 syntax
> 
> As per ASN.1 syntax (RFC 3447 Appendix A.1.2), RSA private key would need
It could be RFC 8017 instead.
> specification of quintuple along with private exponent.
> It is up to the implementation to internally handle, but not at RTE itself to make
> them exclusive each other. Removing union on them allows asymmetric
> implementation in VirtIO to benefit from the xform as per ASN.1 syntax.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
>  lib/cryptodev/rte_crypto_asym.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
> index 39d3da3952..c33be3b155 100644
> --- a/lib/cryptodev/rte_crypto_asym.h
> +++ b/lib/cryptodev/rte_crypto_asym.h
> @@ -306,7 +306,7 @@ struct rte_crypto_rsa_xform {
> 
>  	enum rte_crypto_rsa_priv_key_type key_type;
> 
> -	union {
> +	struct {
>  		rte_crypto_uint d;
>  		/**< the RSA private exponent */
>  		struct rte_crypto_rsa_priv_key_qt qt;
> --
> 2.21.0

Acked-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
  
Kusztal, ArkadiuszX Oct. 7, 2024, 7:32 a.m. UTC | #2
> -----Original Message-----
> From: Kusztal, ArkadiuszX <arkadiuszx.kusztal@intel.com>
> Sent: Monday, October 7, 2024 9:20 AM
> To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>;
> dev@dpdk.org; Akhil Goyal <gakhil@marvell.com>; Fan Zhang
> <fanzhang.oss@gmail.com>
> Cc: Anoob Joseph <anoobj@marvell.com>; Richardson, Bruce
> <bruce.richardson@intel.com>; jerinj@marvell.com; Ji, Kai <kai.ji@intel.com>;
> jack.bond-preston@foss.arm.com; Marchand, David
> <david.marchand@redhat.com>; hemant.agrawal@nxp.com; De Lara Guarch,
> Pablo <pablo.de.lara.guarch@intel.com>; Trahe, Fiona
> <fiona.trahe@intel.com>; Doherty, Declan <declan.doherty@intel.com>;
> matan@nvidia.com; ruifeng.wang@arm.com; Gujjar, Abhinandan S
> <abhinandan.gujjar@intel.com>; maxime.coquelin@redhat.com;
> chenbox@nvidia.com; sunilprakashrao.uttarwar@amd.com;
> andrew.boyer@amd.com; ajit.khaparde@broadcom.com;
> raveendra.padasalagi@broadcom.com; vikas.gupta@broadcom.com;
> zhangfei.gao@linaro.org; g.singh@nxp.com; jianjay.zhou@huawei.com; Daly,
> Lee <lee.daly@intel.com>; Dooley, Brian <brian.dooley@intel.com>
> Subject: RE: [PATCH v2 1/2] cryptodev: fix RSA xform for ASN.1 syntax
> 
> Acked with a small comment.
> 
> > -----Original Message-----
> > From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > Sent: Friday, October 4, 2024 8:11 AM
> > To: dev@dpdk.org; Akhil Goyal <gakhil@marvell.com>; Fan Zhang
> > <fanzhang.oss@gmail.com>
> > Cc: Anoob Joseph <anoobj@marvell.com>; Richardson, Bruce
> > <bruce.richardson@intel.com>; jerinj@marvell.com; Kusztal, ArkadiuszX
> > <arkadiuszx.kusztal@intel.com>; Ji, Kai <kai.ji@intel.com>; jack.bond-
> > preston@foss.arm.com; Marchand, David <david.marchand@redhat.com>;
> > hemant.agrawal@nxp.com; De Lara Guarch, Pablo
> > <pablo.de.lara.guarch@intel.com>; Trahe, Fiona
> > <fiona.trahe@intel.com>; Doherty, Declan <declan.doherty@intel.com>;
> > matan@nvidia.com; ruifeng.wang@arm.com; Gujjar, Abhinandan S
> > <abhinandan.gujjar@intel.com>; maxime.coquelin@redhat.com;
> > chenbox@nvidia.com; sunilprakashrao.uttarwar@amd.com;
> > andrew.boyer@amd.com; ajit.khaparde@broadcom.com;
> > raveendra.padasalagi@broadcom.com;
> > vikas.gupta@broadcom.com; zhangfei.gao@linaro.org; g.singh@nxp.com;
> > jianjay.zhou@huawei.com; Daly, Lee <lee.daly@intel.com>; Dooley, Brian
> > <brian.dooley@intel.com>; Gowrishankar Muthukrishnan
> > <gmuthukrishn@marvell.com>
> > Subject: [PATCH v2 1/2] cryptodev: fix RSA xform for ASN.1 syntax
Additionally, it should not be a fix.
The RFC mandates usage of the ASN.1, but only in case sharing private key across the network.
How the Cryptodev should interpret it, is up to the implementation.
> >
> > As per ASN.1 syntax (RFC 3447 Appendix A.1.2), RSA private key would
> > need
> It could be RFC 8017 instead.
> > specification of quintuple along with private exponent.
> > It is up to the implementation to internally handle, but not at RTE
> > itself to make them exclusive each other. Removing union on them
> > allows asymmetric implementation in VirtIO to benefit from the xform as per
> ASN.1 syntax.
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > ---
> >  lib/cryptodev/rte_crypto_asym.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/cryptodev/rte_crypto_asym.h
> > b/lib/cryptodev/rte_crypto_asym.h index 39d3da3952..c33be3b155 100644
> > --- a/lib/cryptodev/rte_crypto_asym.h
> > +++ b/lib/cryptodev/rte_crypto_asym.h
> > @@ -306,7 +306,7 @@ struct rte_crypto_rsa_xform {
> >
> >  	enum rte_crypto_rsa_priv_key_type key_type;
> >
> > -	union {
> > +	struct {
> >  		rte_crypto_uint d;
> >  		/**< the RSA private exponent */
> >  		struct rte_crypto_rsa_priv_key_qt qt;
> > --
> > 2.21.0
> 
> Acked-by: Arkadiusz Kusztal <arkadiuszx.kusztal@intel.com>
  

Patch

diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
index 39d3da3952..c33be3b155 100644
--- a/lib/cryptodev/rte_crypto_asym.h
+++ b/lib/cryptodev/rte_crypto_asym.h
@@ -306,7 +306,7 @@  struct rte_crypto_rsa_xform {
 
 	enum rte_crypto_rsa_priv_key_type key_type;
 
-	union {
+	struct {
 		rte_crypto_uint d;
 		/**< the RSA private exponent */
 		struct rte_crypto_rsa_priv_key_qt qt;