[16/40] cryptodev: move dh type from xform to dh op

Message ID 20220520055445.40063-17-arkadiuszx.kusztal@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: akhil goyal
Headers
Series cryptodev: rsa, dh, ecdh changes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Arkadiusz Kusztal May 20, 2022, 5:54 a.m. UTC
  - Moved dh operation type to dh operation struct.
Operation type (PUBLIC_KEY_GENERATION, SHARED_SECRET) should
be free to choose for any operation. One xform/session should
be enough to perform both DH operations, if op_type would be xform
member, session would have to be to be created twice for the same
group. Similar problem would be observed in sessionless case.
Additionally, it will help extend DH to support Elliptic Curves.

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
 lib/cryptodev/rte_crypto_asym.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
  

Comments

Akhil Goyal May 24, 2022, 11:52 a.m. UTC | #1
> - Moved dh operation type to dh operation struct.
> Operation type (PUBLIC_KEY_GENERATION, SHARED_SECRET) should
> be free to choose for any operation. One xform/session should
> be enough to perform both DH operations, if op_type would be xform
> member, session would have to be to be created twice for the same
> group. Similar problem would be observed in sessionless case.
> Additionally, it will help extend DH to support Elliptic Curves.
> 
> Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
> ---
>  lib/cryptodev/rte_crypto_asym.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
> index b355cbe5fa..728a98f02e 100644
> --- a/lib/cryptodev/rte_crypto_asym.h
> +++ b/lib/cryptodev/rte_crypto_asym.h
> @@ -250,8 +250,6 @@ struct rte_crypto_modinv_xform {
>   *
>   */
>  struct rte_crypto_dh_xform {
> -	enum rte_crypto_asym_ke_type type;
> -	/**< Setup xform for key generate or shared secret compute */
>  	rte_crypto_uint p;
>  	/**< Prime modulus data */
>  	rte_crypto_uint g;
> @@ -379,27 +377,29 @@ struct rte_crypto_rsa_op_param {
>   * @note:
>   */
>  struct rte_crypto_dh_op_param {
> +	enum rte_crypto_asym_ke_type op_type;
> +	/**< Key exchange operation type */
>  	rte_crypto_uint pub_key;
>  	/**<
> -	 * Output generated public key when xform type is
> +	 * Output generated public key when op_type is
>  	 * DH PUB_KEY_GENERATION.
> -	 * Input peer public key when xform type is DH
> +	 * Input peer public key when op_type is DH
>  	 * SHARED_SECRET_COMPUTATION

Add reference with the actual enum field.

>  	 *
>  	 */
> 
>  	rte_crypto_uint priv_key;
>  	/**<
> -	 * Output generated private key if xform type is
> +	 * Output generated private key when op_type is
>  	 * DH PRIVATE_KEY_GENERATION
> -	 * Input when xform type is DH SHARED_SECRET_COMPUTATION.
> +	 * Input when op_type is DH SHARED_SECRET_COMPUTATION.
>  	 *
>  	 */
> 
>  	rte_crypto_uint shared_secret;
>  	/**<
>  	 * Output with calculated shared secret
> -	 * when dh xform set up with op type =
> SHARED_SECRET_COMPUTATION.
> +	 * when op type is SHARED_SECRET_COMPUTATION.
>  	 *
>  	 */
>  };
> --
> 2.13.6
  

Patch

diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
index b355cbe5fa..728a98f02e 100644
--- a/lib/cryptodev/rte_crypto_asym.h
+++ b/lib/cryptodev/rte_crypto_asym.h
@@ -250,8 +250,6 @@  struct rte_crypto_modinv_xform {
  *
  */
 struct rte_crypto_dh_xform {
-	enum rte_crypto_asym_ke_type type;
-	/**< Setup xform for key generate or shared secret compute */
 	rte_crypto_uint p;
 	/**< Prime modulus data */
 	rte_crypto_uint g;
@@ -379,27 +377,29 @@  struct rte_crypto_rsa_op_param {
  * @note:
  */
 struct rte_crypto_dh_op_param {
+	enum rte_crypto_asym_ke_type op_type;
+	/**< Key exchange operation type */
 	rte_crypto_uint pub_key;
 	/**<
-	 * Output generated public key when xform type is
+	 * Output generated public key when op_type is
 	 * DH PUB_KEY_GENERATION.
-	 * Input peer public key when xform type is DH
+	 * Input peer public key when op_type is DH
 	 * SHARED_SECRET_COMPUTATION
 	 *
 	 */
 
 	rte_crypto_uint priv_key;
 	/**<
-	 * Output generated private key if xform type is
+	 * Output generated private key when op_type is
 	 * DH PRIVATE_KEY_GENERATION
-	 * Input when xform type is DH SHARED_SECRET_COMPUTATION.
+	 * Input when op_type is DH SHARED_SECRET_COMPUTATION.
 	 *
 	 */
 
 	rte_crypto_uint shared_secret;
 	/**<
 	 * Output with calculated shared secret
-	 * when dh xform set up with op type = SHARED_SECRET_COMPUTATION.
+	 * when op type is SHARED_SECRET_COMPUTATION.
 	 *
 	 */
 };