[37/40] cryptodev: add asym op flags
Checks
Commit Message
- 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 | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
Comments
> - 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 | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
> index 37dd3b9d86..01b1fdd074 100644
> --- a/lib/cryptodev/rte_crypto_asym.h
> +++ b/lib/cryptodev/rte_crypto_asym.h
> @@ -41,6 +41,26 @@ rte_crypto_asym_ke_strings[];
> extern const char *
> rte_crypto_asym_op_strings[];
>
> +#define RTE_CRYPTO_ASYM_FLAG_PUB_KEY_NO_PADDING 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 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)
> + */
> +
> +#define RTE_CRYPTO_ASYM_FLAG_SET(op, flag) \
> + (op->flags |= (1ULL << flag))
> +#define RTE_CRYPTO_ASYM_FLAG_UNSET(op, flag) \
> + (op->flags &= (~(1ULL << flag)))
> +#define RTE_CRYPTO_ASYM_FLAG_GET(op, flag) \
> + (!!(op->flags &= (1ULL << flag)))
> +
Why are these SET/GET macros needed?
Is the following not sufficient
#define RTE_CRYPTO_ASYM_FLAG_PUB_KEY_NO_PADDING RTE_BIT32(0)
#define RTE_CRYPTO_ASYM_FLAG_SHARED_KEY_NO_PADDING RTE_BIT32(1)
op->flags |= RTE_CRYPTO_ASYM_FLAG_PUB_KEY_NO_PADDING;
> /**
> * List of elliptic curves. This enum aligns with
> * TLS "Supported Groups" registry (previously known as
> @@ -607,6 +627,11 @@ struct rte_crypto_asym_op {
> struct rte_crypto_ecdsa_op_param ecdsa;
> struct rte_crypto_ecpm_op_param ecpm;
> };
> + uint16_t flags;
> + /**< Asymmetric crypto flags, every flag starts with
> + * RTE_CRYPTO_ASYM_FLAG_*. Flags are set/unset with
> + * RTE_CRYPTO_ASYM_SET_FLAGS, RTE_CRYPTO_ASYM_GET_FLAGS
> + */
> };
>
> #ifdef __cplusplus
> --
> 2.13.6
@@ -41,6 +41,26 @@ rte_crypto_asym_ke_strings[];
extern const char *
rte_crypto_asym_op_strings[];
+#define RTE_CRYPTO_ASYM_FLAG_PUB_KEY_NO_PADDING 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 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)
+ */
+
+#define RTE_CRYPTO_ASYM_FLAG_SET(op, flag) \
+ (op->flags |= (1ULL << flag))
+#define RTE_CRYPTO_ASYM_FLAG_UNSET(op, flag) \
+ (op->flags &= (~(1ULL << flag)))
+#define RTE_CRYPTO_ASYM_FLAG_GET(op, flag) \
+ (!!(op->flags &= (1ULL << flag)))
+
/**
* List of elliptic curves. This enum aligns with
* TLS "Supported Groups" registry (previously known as
@@ -607,6 +627,11 @@ struct rte_crypto_asym_op {
struct rte_crypto_ecdsa_op_param ecdsa;
struct rte_crypto_ecpm_op_param ecpm;
};
+ uint16_t flags;
+ /**< Asymmetric crypto flags, every flag starts with
+ * RTE_CRYPTO_ASYM_FLAG_*. Flags are set/unset with
+ * RTE_CRYPTO_ASYM_SET_FLAGS, RTE_CRYPTO_ASYM_GET_FLAGS
+ */
};
#ifdef __cplusplus