From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
To: <dev@dpdk.org>, <arkadiuszx.kusztal@intel.com>,
Akhil Goyal <gakhil@marvell.com>,
Fan Zhang <fanzhang.oss@gmail.com>
Cc: Anoob Joseph <anoobj@marvell.com>,
<FanZhangfanzhang.oss@gmail.com>, "Kai Ji" <kai.ji@intel.com>,
<jerinj@marvell.com>,
Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Subject: [PATCH v3 1/3] cryptodev: add asymmetric operational capability
Date: Wed, 9 Oct 2024 12:41:47 +0530 [thread overview]
Message-ID: <20241009071151.1106-1-gmuthukrishn@marvell.com> (raw)
In-Reply-To: <20241004181255.916-1-gmuthukrishn@marvell.com>
Asymmetric crypto algorithms such as SM2, EdDSA would need per op
capability and based on it, the input param to a crypto operation
is chosen wisely.
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v3:
- Removed unused rte_crypto_sm2_op_capa enum value RTE_CRYPTO_SM2_PKE_KDF.
HW that needs it can add this enum.
- Test and driver changes split from it and follows within same series.
---
lib/cryptodev/rte_crypto_asym.h | 10 ++++++++++
lib/cryptodev/rte_cryptodev.c | 16 ++++++++++++++++
lib/cryptodev/rte_cryptodev.h | 23 +++++++++++++++++++++++
lib/cryptodev/version.map | 3 +++
4 files changed, 52 insertions(+)
diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
index 39d3da3952..1adbe9c389 100644
--- a/lib/cryptodev/rte_crypto_asym.h
+++ b/lib/cryptodev/rte_crypto_asym.h
@@ -633,6 +633,16 @@ struct rte_crypto_asym_xform {
};
};
+/**
+ * SM2 operation capabilities
+ */
+enum rte_crypto_sm2_op_capa {
+ RTE_CRYPTO_SM2_RNG,
+ /**< Random number generator supported in SM2 ops. */
+ RTE_CRYPTO_SM2_PH,
+ /**< Prehash message before crypto op. */
+};
+
/**
* SM2 operation params.
*/
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index 682c9f49d0..d3d8e25b39 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -628,6 +628,22 @@ rte_cryptodev_asym_xform_capability_check_hash(
return ret;
}
+int
+rte_cryptodev_asym_xform_capability_check_opcap(
+ const struct rte_cryptodev_asymmetric_xform_capability *capability,
+ enum rte_crypto_asym_op_type op_type, uint8_t cap)
+{
+ int ret = 0;
+
+ if (!(capability->op_types & (1 << op_type)))
+ return ret;
+
+ if (capability->op_capa[op_type] & (1 << cap))
+ ret = 1;
+
+ return ret;
+}
+
/* spinlock for crypto device enq callbacks */
static rte_spinlock_t rte_cryptodev_callback_lock = RTE_SPINLOCK_INITIALIZER;
diff --git a/lib/cryptodev/rte_cryptodev.h b/lib/cryptodev/rte_cryptodev.h
index bec947f6d5..aa6ef3a94d 100644
--- a/lib/cryptodev/rte_cryptodev.h
+++ b/lib/cryptodev/rte_cryptodev.h
@@ -185,6 +185,9 @@ struct rte_cryptodev_asymmetric_xform_capability {
* Value 0 means unavailable, and application should pass the required
* random value. Otherwise, PMD would internally compute the random number.
*/
+
+ uint32_t op_capa[RTE_CRYPTO_ASYM_OP_LIST_END];
+ /**< Operation specific capabilities. */
};
uint64_t hash_algos;
@@ -359,6 +362,26 @@ rte_cryptodev_asym_xform_capability_check_hash(
const struct rte_cryptodev_asymmetric_xform_capability *capability,
enum rte_crypto_auth_algorithm hash);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Check if op capability is supported
+ *
+ * @param capability Description of the asymmetric crypto capability.
+ * @param op_type op type
+ * @param cap op capability
+ *
+ * @return
+ * - Return 1 if the op capability is supported
+ * - Return 0 if unsupported
+ */
+__rte_experimental
+int
+rte_cryptodev_asym_xform_capability_check_opcap(
+ const struct rte_cryptodev_asymmetric_xform_capability *capability,
+ enum rte_crypto_asym_op_type op_type, uint8_t cap);
+
/**
* Provide the cipher algorithm enum, given an algorithm string
*
diff --git a/lib/cryptodev/version.map b/lib/cryptodev/version.map
index 594c501855..5d40b7fed0 100644
--- a/lib/cryptodev/version.map
+++ b/lib/cryptodev/version.map
@@ -87,6 +87,9 @@ EXPERIMENTAL {
# added in 24.03
__rte_cryptodev_trace_qp_depth_used;
+
+ # added in 24.11
+ rte_cryptodev_asym_xform_capability_check_opcap;
};
INTERNAL {
--
2.21.0
next prev parent reply other threads:[~2024-10-09 7:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 18:17 [PATCH] " Gowrishankar Muthukrishnan
2024-10-04 18:12 ` [PATCH v2] " Gowrishankar Muthukrishnan
2024-10-08 17:06 ` Kusztal, ArkadiuszX
2024-10-09 3:38 ` Gowrishankar Muthukrishnan
2024-10-09 7:11 ` Gowrishankar Muthukrishnan [this message]
2024-10-09 7:11 ` [PATCH v3 2/3] test/crypto: check op capabilities in SM2 tests Gowrishankar Muthukrishnan
2024-10-09 7:11 ` [PATCH v3 3/3] crypto/openssl: include op capabilities for SM2 Gowrishankar Muthukrishnan
2024-10-09 20:29 ` [PATCH v3 1/3] cryptodev: add asymmetric operational capability Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241009071151.1106-1-gmuthukrishn@marvell.com \
--to=gmuthukrishn@marvell.com \
--cc=FanZhangfanzhang.oss@gmail.com \
--cc=anoobj@marvell.com \
--cc=arkadiuszx.kusztal@intel.com \
--cc=dev@dpdk.org \
--cc=fanzhang.oss@gmail.com \
--cc=gakhil@marvell.com \
--cc=jerinj@marvell.com \
--cc=kai.ji@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).