[v2,09/14] cryptodev: add asym op flags

Message ID 20220525155324.9288-10-arkadiuszx.kusztal@intel.com (mailing list archive)
State Superseded, 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 25, 2022, 3:53 p.m. UTC
  - Added flags to rte_crypto_asym_op struct.
It may be shared between different algorithms.
- Added Diffie-Hellman padding flags.
Diffie-Hellman padding is used in certain protocols,
in others, leading zero bytes need to be stripped.
Even same protocol may use a different approach - most
glaring example is TLS1.2 - TLS1.3.
For ease of use, and to avoid additional copy
on certain occasions, driver should be able to return both.

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

Comments

Akhil Goyal May 26, 2022, 11:46 a.m. UTC | #1
> - Added flags to rte_crypto_asym_op struct.
> It may be shared between different algorithms.
> - Added Diffie-Hellman padding flags.
> Diffie-Hellman padding is used in certain protocols,
> in others, leading zero bytes need to be stripped.
> Even same protocol may use a different approach - most
> glaring example is TLS1.2 - TLS1.3.
> For ease of use, and to avoid additional copy
> on certain occasions, driver should be able to return both.
> 
> Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
> ---
>  lib/cryptodev/rte_crypto_asym.h | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
> index 3eafaecbbe..1a57c0c532 100644
> --- a/lib/cryptodev/rte_crypto_asym.h
> +++ b/lib/cryptodev/rte_crypto_asym.h
> @@ -75,6 +75,19 @@ struct rte_crypto_ec_point {
>  	/**< Y coordinate */
>  };
> 
> +#define RTE_CRYPTO_ASYM_FLAG_PUB_KEY_NO_PADDING
> 	RTE_BIT32(0)
> +/**<
> + * If set to 1 - public key will be returned
> + * without leading zero bytes, otherwise it will be
> + * padded to the left with zero bytes (default)
> + */

I think this comment need to be re-written something like

/* Flag to denote public key will be returned without leading zero bytes
  * and if the flag is not set, public key will be padded to the left with zeros(default) */

> +#define RTE_CRYPTO_ASYM_FLAG_SHARED_KEY_NO_PADDING	RTE_BIT32(1)
> +/**<
> + * If set to 1 - shared key will be returned
> + * without leading zero bytes, otherwise it will be
> + * padded to the left with zero bytes (default)
> + */

Similar comment for this one also.

> +
>  /**
>   * List of elliptic curves. This enum aligns with
>   * TLS "Supported Groups" registry (previously known  as
> @@ -589,6 +602,8 @@ struct rte_crypto_asym_op {
>  		struct rte_crypto_ecdsa_op_param ecdsa;
>  		struct rte_crypto_ecpm_op_param ecpm;
>  	};
> +	uint16_t flags;
> +	/**< Asymmetric crypto operation flags */
Give reference to flags
RTE_CRYPTO_ASYM_FLAG_*

>  };
> 
>  #ifdef __cplusplus
> --
> 2.13.6
  

Patch

diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
index 3eafaecbbe..1a57c0c532 100644
--- a/lib/cryptodev/rte_crypto_asym.h
+++ b/lib/cryptodev/rte_crypto_asym.h
@@ -75,6 +75,19 @@  struct rte_crypto_ec_point {
 	/**< Y coordinate */
 };
 
+#define RTE_CRYPTO_ASYM_FLAG_PUB_KEY_NO_PADDING		RTE_BIT32(0)
+/**<
+ * If set to 1 - public key will be returned
+ * without leading zero bytes, otherwise it will be
+ * padded to the left with zero bytes (default)
+ */
+#define RTE_CRYPTO_ASYM_FLAG_SHARED_KEY_NO_PADDING	RTE_BIT32(1)
+/**<
+ * If set to 1 - shared key will be returned
+ * without leading zero bytes, otherwise it will be
+ * padded to the left with zero bytes (default)
+ */
+
 /**
  * List of elliptic curves. This enum aligns with
  * TLS "Supported Groups" registry (previously known  as
@@ -589,6 +602,8 @@  struct rte_crypto_asym_op {
 		struct rte_crypto_ecdsa_op_param ecdsa;
 		struct rte_crypto_ecpm_op_param ecpm;
 	};
+	uint16_t flags;
+	/**< Asymmetric crypto operation flags */
 };
 
 #ifdef __cplusplus