diff mbox series

[06/40] cryptodev: separate key exchange operation enum

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

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kusztal, ArkadiuszX May 20, 2022, 5:54 a.m. UTC
- separated key exchange enum.
Key exchange and asymmetric crypto operations like signatures,
encryption/decryption should not share same operation enum as
its use cases are unrelated and mutually exclusive.
Therefore op_type was separate into:
1) operation type
2) key exchange operation type

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
 lib/cryptodev/rte_crypto_asym.h | 24 +++++++++++++++++-------
 lib/cryptodev/rte_cryptodev.c   | 14 ++++++++++----
 2 files changed, 27 insertions(+), 11 deletions(-)

Comments

Akhil Goyal May 24, 2022, 11:45 a.m. UTC | #1
> - separated key exchange enum.
> Key exchange and asymmetric crypto operations like signatures,
> encryption/decryption should not share same operation enum as
> its use cases are unrelated and mutually exclusive.
> Therefore op_type was separate into:
> 1) operation type
> 2) key exchange operation type
> 
> Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>

Please check if it need update in Documentation.

> ---
>  lib/cryptodev/rte_crypto_asym.h | 24 +++++++++++++++++-------
>  lib/cryptodev/rte_cryptodev.c   | 14 ++++++++++----
>  2 files changed, 27 insertions(+), 11 deletions(-)
> 
> diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
> index 0251e8caae..0fc9f49b87 100644
> --- a/lib/cryptodev/rte_crypto_asym.h
> +++ b/lib/cryptodev/rte_crypto_asym.h
> @@ -33,6 +33,10 @@ struct rte_cryptodev_asym_session;
>  extern const char *
>  rte_crypto_asym_xform_strings[];
> 
> +/** asym key exchange operation type name strings */
> +extern const char *
> +rte_crypto_asym_ke_strings[];
> +
>  /** asym operations type name strings */
>  extern const char *
>  rte_crypto_asym_op_strings[];
> @@ -94,12 +98,18 @@ enum rte_crypto_asym_op_type {
>  	/**< Signature Generation operation */
>  	RTE_CRYPTO_ASYM_OP_VERIFY,
>  	/**< Signature Verification operation */
> -	RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE,
> -	/**< DH Private Key generation operation */
> -	RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE,
> -	/**< DH Public Key generation operation */
> -	RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE
> -	/**< DH Shared Secret compute operation */
> +};
> +
> +/**
> + * Asymmetric crypto key exchange operation type
> + */
> +enum rte_crypto_asym_ke_type {
> +	RTE_CRYPTO_ASYM_KE_PRIVATE_KEY_GENERATE,
> +	/**< Private Key generation operation */
> +	RTE_CRYPTO_ASYM_KE_PUBLIC_KEY_GENERATE,
> +	/**< Public Key generation operation */
> +	RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE
> +	/**< Shared Secret compute operation */
>  };
> 
>  /**
> @@ -239,7 +249,7 @@ struct rte_crypto_modinv_xform {
>   *
>   */
>  struct rte_crypto_dh_xform {
> -	enum rte_crypto_asym_op_type type;
> +	enum rte_crypto_asym_ke_type type;
>  	/**< Setup xform for key generate or shared secret compute */
>  	rte_crypto_uint p;
>  	/**< Prime modulus data */
> diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
> index 691625bd04..af58f49d07 100644
> --- a/lib/cryptodev/rte_cryptodev.c
> +++ b/lib/cryptodev/rte_cryptodev.c
> @@ -176,10 +176,16 @@ const char *rte_crypto_asym_op_strings[] = {
>  	[RTE_CRYPTO_ASYM_OP_ENCRYPT]	= "encrypt",
>  	[RTE_CRYPTO_ASYM_OP_DECRYPT]	= "decrypt",
>  	[RTE_CRYPTO_ASYM_OP_SIGN]	= "sign",
> -	[RTE_CRYPTO_ASYM_OP_VERIFY]	= "verify",
> -	[RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE]	=
> "priv_key_generate",
> -	[RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE] =
> "pub_key_generate",
> -	[RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE] =
> "sharedsecret_compute",
> +	[RTE_CRYPTO_ASYM_OP_VERIFY]	= "verify"
> +};
> +
> +/**
> + * Asymmetric crypto key exchange operation strings identifiers.
> + */
> +const char *rte_crypto_asym_ke_strings[] = {
> +	[RTE_CRYPTO_ASYM_KE_PRIVATE_KEY_GENERATE] =
> "priv_key_generate",
> +	[RTE_CRYPTO_ASYM_KE_PUBLIC_KEY_GENERATE] =
> "pub_key_generate",
> +	[RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE] =
> "sharedsecret_compute"
>  };
> 
>  /**
> --
> 2.13.6
diff mbox series

Patch

diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
index 0251e8caae..0fc9f49b87 100644
--- a/lib/cryptodev/rte_crypto_asym.h
+++ b/lib/cryptodev/rte_crypto_asym.h
@@ -33,6 +33,10 @@  struct rte_cryptodev_asym_session;
 extern const char *
 rte_crypto_asym_xform_strings[];
 
+/** asym key exchange operation type name strings */
+extern const char *
+rte_crypto_asym_ke_strings[];
+
 /** asym operations type name strings */
 extern const char *
 rte_crypto_asym_op_strings[];
@@ -94,12 +98,18 @@  enum rte_crypto_asym_op_type {
 	/**< Signature Generation operation */
 	RTE_CRYPTO_ASYM_OP_VERIFY,
 	/**< Signature Verification operation */
-	RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE,
-	/**< DH Private Key generation operation */
-	RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE,
-	/**< DH Public Key generation operation */
-	RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE
-	/**< DH Shared Secret compute operation */
+};
+
+/**
+ * Asymmetric crypto key exchange operation type
+ */
+enum rte_crypto_asym_ke_type {
+	RTE_CRYPTO_ASYM_KE_PRIVATE_KEY_GENERATE,
+	/**< Private Key generation operation */
+	RTE_CRYPTO_ASYM_KE_PUBLIC_KEY_GENERATE,
+	/**< Public Key generation operation */
+	RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE
+	/**< Shared Secret compute operation */
 };
 
 /**
@@ -239,7 +249,7 @@  struct rte_crypto_modinv_xform {
  *
  */
 struct rte_crypto_dh_xform {
-	enum rte_crypto_asym_op_type type;
+	enum rte_crypto_asym_ke_type type;
 	/**< Setup xform for key generate or shared secret compute */
 	rte_crypto_uint p;
 	/**< Prime modulus data */
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 691625bd04..af58f49d07 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -176,10 +176,16 @@  const char *rte_crypto_asym_op_strings[] = {
 	[RTE_CRYPTO_ASYM_OP_ENCRYPT]	= "encrypt",
 	[RTE_CRYPTO_ASYM_OP_DECRYPT]	= "decrypt",
 	[RTE_CRYPTO_ASYM_OP_SIGN]	= "sign",
-	[RTE_CRYPTO_ASYM_OP_VERIFY]	= "verify",
-	[RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE]	= "priv_key_generate",
-	[RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE] = "pub_key_generate",
-	[RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE] = "sharedsecret_compute",
+	[RTE_CRYPTO_ASYM_OP_VERIFY]	= "verify"
+};
+
+/**
+ * Asymmetric crypto key exchange operation strings identifiers.
+ */
+const char *rte_crypto_asym_ke_strings[] = {
+	[RTE_CRYPTO_ASYM_KE_PRIVATE_KEY_GENERATE] = "priv_key_generate",
+	[RTE_CRYPTO_ASYM_KE_PUBLIC_KEY_GENERATE] = "pub_key_generate",
+	[RTE_CRYPTO_ASYM_KE_SHARED_SECRET_COMPUTE] = "sharedsecret_compute"
 };
 
 /**