cryptodev: add elliptic curve diffie hellman

Message ID 20220407074416.18565-1-arkadiuszx.kusztal@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series cryptodev: add elliptic curve diffie hellman |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation warning apply issues
ci/iol-testing warning apply patch failure

Commit Message

Arkadiusz Kusztal April 7, 2022, 7:44 a.m. UTC
  This commit adds Elliptic Curve Diffie-Hellman option to Cryptodev.
This could be achieved with EC point multiplication but:
1) Phase 1 of DH is used with EC generator, multiplication expect
setting generator manually.
2) It will unify usage of DH.
3) Can be extended easily to support X25519 and X448.

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
Depends-on: series-22398 ("cryptodev: move dh type from xform to dh op")

 lib/cryptodev/rte_crypto_asym.h | 41 +++++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 16 deletions(-)
  

Patch

diff --git a/lib/cryptodev/rte_crypto_asym.h b/lib/cryptodev/rte_crypto_asym.h
index 40c1d90604..e65222b802 100644
--- a/lib/cryptodev/rte_crypto_asym.h
+++ b/lib/cryptodev/rte_crypto_asym.h
@@ -91,6 +91,8 @@  enum rte_crypto_asym_xform_type {
 	/**< Elliptic Curve Digital Signature Algorithm
 	 * Perform Signature Generation and Verification.
 	 */
+	RTE_CRYPTO_ASYM_XFORM_ECDH,
+	/**< Elliptic Curve Diffie Hellman */
 	RTE_CRYPTO_ASYM_XFORM_ECPM,
 	/**< Elliptic Curve Point Multiplication */
 	RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END
@@ -385,34 +387,41 @@  struct rte_crypto_rsa_op_param {
 };
 
 /**
- * Diffie-Hellman Operations params.
+ * Diffie-Hellman/Elliptic Curve Diffie-Hellman operation.
  * @note:
  */
 struct rte_crypto_dh_op_param {
 	enum rte_crypto_asym_op_type op_type;
 	/**< Diffie-Hellman operation phase */
-	rte_crypto_uint pub_key;
+
+	rte_crypto_param priv_key;
 	/**<
-	 * Output generated public key when op_type is
-	 * DH PUB_KEY_GENERATION.
-	 * Input peer public key when op_type is DH
-	 * SHARED_SECRET_COMPUTATION
-	 *
+	 * Diffie-Hallman private part
+	 * For DH and ECDH it is big-endian integer.
+	 * Input for both phases of Diffie-Hellman
 	 */
 
-	rte_crypto_uint priv_key;
+	union {
+		rte_crypto_uint pub_key;
+		struct rte_crypto_ec_point pub_point;
+	};
 	/**<
-	 * Output generated private key if op_type is
-	 * DH PRIVATE_KEY_GENERATION
-	 * Input when op_type is DH SHARED_SECRET_COMPUTATION.
-	 *
+	 * Diffie-Hallman public part
+	 * For DH it is big-endian unsigned integer.
+	 * For ECDH it is a point on the curve.
+	 * Output for RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE
+	 * Input for RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE
 	 */
 
-	rte_crypto_uint shared_secret;
+	union {
+		rte_crypto_uint shared_secret;
+		struct rte_crypto_ec_point shared_point;
+	};
 	/**<
-	 * Output with calculated shared secret
-	 * when dh op_type = SHARED_SECRET_COMPUTATION.
-	 *
+	 * Diffie-Hallman shared secret
+	 * For DH it is big-endian unsigned integer.
+	 * For ECDH it is a point on the curve.
+	 * Output for RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE
 	 */
 };