DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v3 0/6] crypto: add asym crypto support
@ 2018-05-16  6:05 Shally Verma
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev Shally Verma
                   ` (5 more replies)
  0 siblings, 6 replies; 44+ messages in thread
From: Shally Verma @ 2018-05-16  6:05 UTC (permalink / raw)
  To: pablo.de.lara.guarch; +Cc: fiona.trahe, akhil.goyal, dev, pathreya

This patch series add support for asymmetric crypto in DPDK
librte_cryptodev framework along with unit test, PMD and
documentation updates

This patch series is divided in to following categories:
1. library patches with asymmetric API, xform and capability
   definitions
2. Unit test case addition
3. Openssl PMD changes with asymmetric crypto support
4. Programmer Guide updates with asymmetric description

changes in v3:
- correct rte_cryptodev_asym_session_create to pass void** to
  rte_mempool_get() and add support for private_data_size flag
- remove redundant xform_type from rte_cryptodev_asymmetric_capability
- added rte_cryptodev_asym_session_set/get_private_data for app to setup
  private data in a session as per latest dpdk-next-crypto spec
- rename few APIs to be consistent with other API names
- update test meson.build to include asym unit test file

changes in v2:
-addresses patch apply failure
raised on asym crypto v1 patch series:
https://dpdk.org/dev/patchwork/patch/36575/
https://dpdk.org/dev/patchwork/patch/36576/
https://dpdk.org/dev/patchwork/patch/36577/

And, unit test and PMD patch series:
https://dpdk.org/dev/patchwork/patch/36928/
https://dpdk.org/dev/patchwork/patch/36929/
https://dpdk.org/dev/patchwork/patch/36930/
-- resolve git apply patch error on patch id 36575
-- resolve git apply patch error on patch id 36929

Changes in v1:
- removal of dedicated sym and asym qp setup,
- remove asym qp count and attach/detach_session apis
- re-org xforms params for deffie-hellman to allow
  public key and optional private key generations
- move elliptic curve changes into another separate patch/patch series

TBD:
- add elliptic curve support
- rename of existing session_configure/clear APIs to
  sym_session_configure/clear/init APIs

It is based on review discussion on RFC v1 asym crypto patch
http://dpdk.org/patch/34308.

RFC v1 patch http://dpdk.org/patch/34308 is further a derivative of
earlier reviewed  RFC v2 patch series:
 http://dpdk.org/dev/patchwork/patch/24245/
 http://dpdk.org/dev/patchwork/patch/24246/
 http://dpdk.org/dev/patchwork/patch/24247/

Shally Verma (6):
  lib/cryptodev: add asymmetric algos in cryptodev
  lib/cryptodev: add asym op support in cryptodev
  lib/cryptodev: add asymmetric crypto capability in cryptodev
  test/crypto: add unit testcase for asym crypto
  crypto/openssl: add asym crypto support
  doc: add asym crypto in cryptodev programmer guide

 doc/guides/cryptodevs/features/openssl.ini       |   11 +
 doc/guides/cryptodevs/openssl.rst                |    1 +
 doc/guides/prog_guide/cryptodev_lib.rst          |  338 +++-
 drivers/crypto/openssl/rte_openssl_pmd.c         |  377 ++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c     |  395 ++++-
 drivers/crypto/openssl/rte_openssl_pmd_private.h |   29 +
 lib/librte_cryptodev/Makefile                    |    3 +-
 lib/librte_cryptodev/meson.build                 |    3 +-
 lib/librte_cryptodev/rte_crypto.h                |   37 +-
 lib/librte_cryptodev/rte_crypto_asym.h           |  519 +++++++
 lib/librte_cryptodev/rte_cryptodev.c             |  253 +++
 lib/librte_cryptodev/rte_cryptodev.h             |  217 ++-
 lib/librte_cryptodev/rte_cryptodev_pmd.h         |   58 +-
 lib/librte_cryptodev/rte_cryptodev_version.map   |   12 +
 test/test/Makefile                               |    3 +-
 test/test/meson.build                            |    1 +
 test/test/test_cryptodev_asym.c                  | 1787 ++++++++++++++++++++++
 17 files changed, 4015 insertions(+), 29 deletions(-)
 create mode 100644 lib/librte_cryptodev/rte_crypto_asym.h
 create mode 100644 test/test/test_cryptodev_asym.c

-- 
2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
  2018-05-16  6:05 [dpdk-dev] [PATCH v3 0/6] crypto: add asym crypto support Shally Verma
@ 2018-05-16  6:05 ` Shally Verma
  2018-06-15  8:40   ` De Lara Guarch, Pablo
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support " Shally Verma
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 44+ messages in thread
From: Shally Verma @ 2018-05-16  6:05 UTC (permalink / raw)
  To: pablo.de.lara.guarch
  Cc: fiona.trahe, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Add rte_crypto_asym.h with supported xfrms
and associated op structures and APIs

API currently supports:
- RSA Encrypt, Decrypt, Sign and Verify
- Modular Exponentiation and Inversion
- DSA Sign and Verify
- Deffie-hellman private key exchange
- Deffie-hellman public key exchange
- Deffie-hellman shared secret compute
- Deffie-hellman public/private key pair generation
using xform chain

Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
---
 lib/librte_cryptodev/Makefile          |   2 +-
 lib/librte_cryptodev/meson.build       |   3 +-
 lib/librte_cryptodev/rte_crypto_asym.h | 519 +++++++++++++++++++++++++++++++++
 3 files changed, 522 insertions(+), 2 deletions(-)

diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile
index bba8dee9f..138e627dc 100644
--- a/lib/librte_cryptodev/Makefile
+++ b/lib/librte_cryptodev/Makefile
@@ -23,7 +23,7 @@ SYMLINK-y-include += rte_crypto.h
 SYMLINK-y-include += rte_crypto_sym.h
 SYMLINK-y-include += rte_cryptodev.h
 SYMLINK-y-include += rte_cryptodev_pmd.h
-
+SYMLINK-y-include += rte_crypto_asym.h
 # versioning export map
 EXPORT_MAP := rte_cryptodev_version.map
 
diff --git a/lib/librte_cryptodev/meson.build b/lib/librte_cryptodev/meson.build
index bd5fed895..295f509ec 100644
--- a/lib/librte_cryptodev/meson.build
+++ b/lib/librte_cryptodev/meson.build
@@ -6,5 +6,6 @@ sources = files('rte_cryptodev.c', 'rte_cryptodev_pmd.c')
 headers = files('rte_cryptodev.h',
 	'rte_cryptodev_pmd.h',
 	'rte_crypto.h',
-	'rte_crypto_sym.h')
+	'rte_crypto_sym.h',
+	'rte_crypto_asym.h')
 deps += ['kvargs', 'mbuf']
diff --git a/lib/librte_cryptodev/rte_crypto_asym.h b/lib/librte_cryptodev/rte_crypto_asym.h
new file mode 100644
index 000000000..d0e2f1d40
--- /dev/null
+++ b/lib/librte_cryptodev/rte_crypto_asym.h
@@ -0,0 +1,519 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Cavium Networks
+ */
+
+#ifndef _RTE_CRYPTO_ASYM_H_
+#define _RTE_CRYPTO_ASYM_H_
+
+/**
+ * @file rte_crypto_asym.h
+ *
+ * RTE Definitions for Asymmetric Cryptography
+ *
+ * Defines asymmetric algorithms and modes, as well as supported
+ * asymmetric crypto operations.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <string.h>
+#include <stdint.h>
+#include <rte_memory.h>
+#include <rte_mempool.h>
+#include <rte_common.h>
+
+typedef struct rte_crypto_param_t {
+	uint8_t *data;
+	/**< pointer to buffer holding data */
+	rte_iova_t iova;
+	/**< IO address of data buffer */
+	size_t length;
+	/**< length of data in bytes */
+} rte_crypto_param;
+
+/** asym xform type name strings */
+extern const char *
+rte_crypto_asym_xform_strings[];
+
+/** asym operations type name strings */
+extern const char *
+rte_crypto_asym_op_strings[];
+
+/**
+ * Asymmetric crypto transformation types.
+ * Each xform type maps to one asymmetric algorithm
+ * performing specific operation
+ *
+ */
+enum rte_crypto_asym_xform_type {
+	RTE_CRYPTO_ASYM_XFORM_UNSPECIFIED = 0,
+	/**< Invalid xform. */
+	RTE_CRYPTO_ASYM_XFORM_NONE,
+	/**< Xform type None.
+	 * May be supported by PMD to support
+	 * passthrough op for debugging purpose.
+	 * if xform_type none , op_type is disregarded.
+	 */
+	RTE_CRYPTO_ASYM_XFORM_RSA,
+	/**< RSA. Performs Encrypt, Decrypt, Sign and Verify.
+	 * Refer to rte_crypto_asym_op_type
+	 */
+	RTE_CRYPTO_ASYM_XFORM_DH,
+	/**< Deffie-Hellman.
+	 * Performs Key Generate and Shared Secret Compute.
+	 * Refer to rte_crypto_asym_op_type
+	 */
+	RTE_CRYPTO_ASYM_XFORM_DSA,
+	/**< Digital Signature Algorithm
+	 * Performs Signature Generation and Verification.
+	 * Refer to rte_crypto_asym_op_type
+	 */
+	RTE_CRYPTO_ASYM_XFORM_MODINV,
+	/**< Modular Inverse
+	 * Perform Modulus inverse b^(-1) mod n
+	 */
+	RTE_CRYPTO_ASYM_XFORM_MODEX,
+	/**< Modular Exponentiation
+	 * Perform Modular Exponentiation b^e mod n
+	 */
+	RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END
+	/**< End of list */
+};
+
+/**
+ * Asymmetric crypto operation type variants
+ */
+enum rte_crypto_asym_op_type {
+	RTE_CRYPTO_ASYM_OP_ENCRYPT,
+	/**< Asymmetric Encrypt operation */
+	RTE_CRYPTO_ASYM_OP_DECRYPT,
+	/**< Asymmetric Decrypt operation */
+	RTE_CRYPTO_ASYM_OP_SIGN,
+	/**< 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 */
+	RTE_CRYPTO_ASYM_OP_LIST_END
+};
+
+/**
+ * Padding types for RSA signature.
+ */
+enum rte_crypto_rsa_padding_type {
+	RTE_CRYPTO_RSA_PADDING_NONE = 0,
+	/**< RSA no padding scheme */
+	RTE_CRYPTO_RSA_PKCS1_V1_5_BT0,
+	/**< RSA PKCS#1 V1.5 Block Type 0 padding scheme
+	 * as descibed in rfc2313
+	 */
+	RTE_CRYPTO_RSA_PKCS1_V1_5_BT1,
+	/**< RSA PKCS#1 V1.5 Block Type 01 padding scheme
+	 * as descibed in rfc2313
+	 */
+	RTE_CRYPTO_RSA_PKCS1_V1_5_BT2,
+	/**< RSA PKCS#1 V1.5 Block Type 02 padding scheme
+	 * as descibed in rfc2313
+	 */
+	RTE_CRYPTO_RSA_PADDING_OAEP,
+	/**< RSA PKCS#1 OAEP padding scheme */
+	RTE_CRYPTO_RSA_PADDING_PSS,
+	/**< RSA PKCS#1 PSS padding scheme */
+	RTE_CRYPTO_RSA_PADDING_TYPE_LIST_END
+};
+
+/**
+ * RSA private key type enumeration
+ *
+ * enumerates private key format required to perform RSA crypto
+ * transform.
+ *
+ */
+enum rte_crypto_rsa_priv_key_type {
+	RTE_RSA_KEY_TYPE_EXP,
+	/**< RSA private key is an exponent */
+	RTE_RSA_KET_TYPE_QT,
+	/**< RSA private key is in quintuple format
+	 * See rte_crypto_rsa_priv_key_qt
+	 */
+};
+
+/**
+ * Structure describing RSA private key in quintuple format.
+ * See PKCS V1.5 RSA Cryptography Standard.
+ */
+struct rte_crypto_rsa_priv_key_qt {
+	rte_crypto_param p;
+	/**< p - Private key component P
+	 * Private key component of RSA parameter  required for CRT method
+	 * of private key operations in Octet-string network byte order
+	 * format.
+	 */
+
+	rte_crypto_param q;
+	/**< q - Private key component Q
+	 * Private key component of RSA parameter  required for CRT method
+	 * of private key operations in Octet-string network byte order
+	 * format.
+	 */
+
+	rte_crypto_param dP;
+	/**< dP - Private CRT component
+	 * Private CRT component of RSA parameter  required for CRT method
+	 * RSA private key operations in Octet-string network byte order
+	 * format.
+	 * dP = d mod ( p - 1 )
+	 */
+
+	rte_crypto_param dQ;
+	/**< dQ - Private CRT component
+	 * Private CRT component of RSA parameter  required for CRT method
+	 * RSA private key operations in Octet-string network byte order
+	 * format.
+	 * dQ = d mod ( q - 1 )
+	 */
+
+	rte_crypto_param qInv;
+	/**< qInv - Private CRT component
+	 * Private CRT component of RSA parameter  required for CRT method
+	 * RSA private key operations in Octet-string network byte order
+	 * format.
+	 * qInv = inv q mod p
+	 */
+};
+
+/**
+ * Asymmetric RSA transform data
+ *
+ * Structure describing RSA xform params
+ *
+ */
+struct rte_crypto_rsa_xform {
+	rte_crypto_param n;
+	/**< n - Prime modulus
+	 * Prime modulus data of RSA operation in Octet-string network
+	 * byte order format.
+	 */
+
+	rte_crypto_param e;
+	/**< e - Public key exponent
+	 * Public key exponent used for RSA public key operations in Octet-
+	 * string network byte order format.
+	 */
+
+	enum rte_crypto_rsa_priv_key_type key_type;
+
+	union {
+			rte_crypto_param d;
+			/**< d - Private key exponent
+			 * Private key exponent used for RSA
+			 * private key operations in
+			 * Octet-string  network byte order format.
+			 */
+
+			struct rte_crypto_rsa_priv_key_qt qt;
+			/**< qt - Private key in quintuple format */
+	};
+};
+
+/**
+ * Asymmetric Modular exponentiation transform data
+ *
+ * Structure describing modular exponentation xform param
+ *
+ */
+struct rte_crypto_modex_xform {
+	rte_crypto_param modulus;
+	/**< modulus
+	 * Prime modulus of the modexp transform operation in octet-string
+	 * network byte order format.
+	 */
+
+	rte_crypto_param exponent;
+	/**< exponent
+	 * Private exponent of the modexp transform operation in
+	 * octet-string network byte order format.
+	 */
+};
+
+/**
+ * Asymmetric modular inverse transform operation
+ *
+ * Structure describing modulus inverse xform params
+ *
+ */
+struct rte_crypto_modinv_xform {
+	rte_crypto_param modulus;
+	/**<
+	 * Pointer to the prime modulus data for modular
+	 * inverse operation in octet-string network byte
+	 * order format.
+	 */
+};
+
+/**
+ * Asymmetric DH transform data
+ *
+ * Structure describing deffie-hellman xform params
+ *
+ */
+struct rte_crypto_dh_xform {
+	enum rte_crypto_asym_op_type type;
+	/**< Setup xform for key generate or shared secret compute */
+
+	rte_crypto_param p;
+	/**< p : Prime modulus data
+	 * DH prime modulous data in octet-string network byte order format.
+	 *
+	 */
+
+	rte_crypto_param g;
+	/**< g : Generator
+	 * DH group generator data in octet-string network byte order
+	 * format.
+	 *
+	 */
+};
+
+/**
+ * Asymmetric Digital Signature transform operation
+ *
+ * Structure describing DSA xform params
+ *
+ */
+struct rte_crypto_dsa_xform {
+	rte_crypto_param p;
+	/**< p - Prime modulus
+	 * Prime modulus data for DSA operation in Octet-string network byte
+	 * order format.
+	 */
+	rte_crypto_param q;
+	/**< q : Order of the subgroup.
+	 * Order of the subgroup data in Octet-string network byte order
+	 * format.
+	 * (p-1) % q = 0
+	 */
+	rte_crypto_param g;
+	/**< g: Generator of the subgroup
+	 * Generator  data in Octet-string network byte order format.
+	 */
+	rte_crypto_param x;
+	/**< x: Private key of the signer in octet-string network
+	 * byte order format.
+	 * Used when app has pre-defined private key.
+	 * Valid only when xform chain is DSA ONLY.
+	 * if xform chain is DH private key generate + DSA, then DSA sign
+	 * compute will use internally generated key.
+	 */
+};
+
+/**
+ * Operations params for modular operations:
+ * exponentiation and invert
+ *
+ */
+struct rte_crypto_mod_op_param {
+	rte_crypto_param base;
+	/**<
+	 * Pointer to base of modular exponentiation/inversion data in
+	 * Octet-string network byte order format.
+	 */
+};
+
+/**
+ * Asymmetric crypto transform data
+ *
+ * Structure describing asym xforms.
+ */
+struct rte_crypto_asym_xform {
+	struct rte_crypto_asym_xform *next;
+	/**< Pointer to next xform to set up xform chain.*/
+	enum rte_crypto_asym_xform_type xform_type;
+	/**< Asymmetric crypto transform */
+
+	__extension__
+	union {
+		struct rte_crypto_rsa_xform rsa;
+		/**< RSA xform parameters */
+
+		struct rte_crypto_modex_xform modex;
+		/**< Modular Exponentiation xform parameters */
+
+		struct rte_crypto_modinv_xform modinv;
+		/**< Modulus Inverse xform parameters */
+
+		struct rte_crypto_dh_xform dh;
+		/**< DH xform parameters */
+
+		struct rte_crypto_dsa_xform dsa;
+		/**< DSA xform parameters */
+	};
+};
+
+struct rte_cryptodev_asym_session;
+
+/**
+ * RSA operation params
+ *
+ */
+struct rte_crypto_rsa_op_param {
+	enum rte_crypto_asym_op_type op_type;
+	/**< Type of RSA operation for transform */;
+
+	rte_crypto_param message;
+	/**<
+	 * Pointer to data
+	 * - to be encrypted for RSA public encrypt.
+	 * - to be decrypted for RSA private decrypt.
+	 * - to be signed for RSA sign generation.
+	 * - to be authenticated for RSA sign verification.
+	 */
+
+	rte_crypto_param sign;
+	/**<
+	 * Pointer to RSA signature data. If operation is RSA
+	 * sign @ref RTE_CRYPTO_RSA_OP_SIGN, buffer will be
+	 * over-written with generated signature.
+	 *
+	 * Length of the signature data will be equal to the
+	 * RSA prime modulus length.
+	 */
+
+	enum rte_crypto_rsa_padding_type pad;
+	/**< RSA padding scheme to be used for transform */
+
+	enum rte_crypto_auth_algorithm md;
+	/**< Hash algorithm to be used for data hash if padding
+	 * scheme is either OAEP or PSS. Valid hash algorithms
+	 * are:
+	 * MD5, SHA1, SHA224, SHA256, SHA384, SHA512
+	 */
+
+	enum rte_crypto_auth_algorithm mgf1md;
+	/**<
+	 * Hash algorithm to be used for mask generation if
+	 * padding scheme is either OAEP or PSS. If padding
+	 * scheme is unspecified data hash algorithm is used
+	 * for mask generation. Valid hash algorithms are:
+	 * MD5, SHA1, SHA224, SHA256, SHA384, SHA512
+	 */
+};
+
+/**
+ * Deffie-Hellman Operations params.
+ * @note:
+ */
+struct rte_crypto_dh_op_param {
+	rte_crypto_param pub_key;
+	/**<
+	 * Output generated public key when xform type is
+	 * DH PUB_KEY_GENERATION.
+	 * Input peer public key when xform type is DH
+	 * SHARED_SECRET_COMPUTATION
+	 * pub_key is in octet-string network byte order format.
+	 *
+	 */
+
+	rte_crypto_param priv_key;
+	/**<
+	 * Output generated private key if xform type is
+	 * DH PRIVATE_KEY_GENERATION
+	 * Input when xform type is DH SHARED_SECRET_COMPUTATION.
+	 * priv_key is in octet-string network byte order format.
+	 *
+	 */
+
+	rte_crypto_param shared_secret;
+	/**<
+	 * Output with calculated shared secret
+	 * when dh xform set up with op type = SHARED_SECRET_COMPUTATION.
+	 * shared_secret is an octet-string network byte order format.
+	 *
+	 */
+};
+
+/**
+ * DSA Operations params
+ *
+ */
+struct rte_crypto_dsa_op_param {
+	enum rte_crypto_asym_op_type op_type;
+	/**< Signature Generation or Verification */
+	rte_crypto_param message;
+	/**< input message to be signed or verified */
+	rte_crypto_param r;
+	/**< dsa sign component 'r' value
+	 *
+	 * output if op_type = sign generate,
+	 * input if op_type = sign verify
+	 */
+	rte_crypto_param s;
+	/**< dsa sign component 's' value
+	 *
+	 * output if op_type = sign generate,
+	 * input if op_type = sign verify
+	 */
+	rte_crypto_param y;
+	/**< y : Public key of the signer.
+	 * Public key data of the signer in Octet-string network byte order
+	 * format.
+	 * y = g^x mod p
+	 */
+};
+
+/**
+ * Asymmetric Cryptographic Operation.
+ *
+ * Structure describing asymmetric crypto operation params.
+ *
+ */
+struct rte_crypto_asym_op {
+	struct rte_cryptodev_asym_session *session;
+	/**< Handle for the initialised session context */
+
+	__extension__
+	union {
+		struct rte_crypto_rsa_op_param rsa;
+		struct rte_crypto_mod_op_param modex;
+		struct rte_crypto_mod_op_param modinv;
+		struct rte_crypto_dh_op_param dh;
+		struct rte_crypto_dsa_op_param dsa;
+	};
+} __rte_cache_aligned;
+
+/**
+ * Reset the fields of an asymmetric operation to their default values.
+ *
+ * @param	op	The crypto operation to be reset.
+ */
+static inline void
+__rte_crypto_asym_op_reset(struct rte_crypto_asym_op *op)
+{
+	memset(op, 0, sizeof(*op));
+}
+
+/**
+ * Attach a session to an asymmetric crypto operation
+ *
+ * @param	asym_op	crypto operation
+ * @param	sess	cryptodev session
+ */
+static inline int
+__rte_crypto_op_attach_asym_session(struct rte_crypto_asym_op *asym_op,
+		struct rte_cryptodev_asym_session *sess)
+{
+	asym_op->session = sess;
+	return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_CRYPTO_ASYM_H_ */
-- 
2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev
  2018-05-16  6:05 [dpdk-dev] [PATCH v3 0/6] crypto: add asym crypto support Shally Verma
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev Shally Verma
@ 2018-05-16  6:05 ` Shally Verma
  2018-06-15  9:05   ` De Lara Guarch, Pablo
  2018-06-26  9:20   ` De Lara Guarch, Pablo
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability " Shally Verma
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 44+ messages in thread
From: Shally Verma @ 2018-05-16  6:05 UTC (permalink / raw)
  To: pablo.de.lara.guarch
  Cc: fiona.trahe, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Extend DPDK librte_cryptodev to:
- define asym op type in rte_crypto_op_type and associated
  op pool create/alloc APIs
- define asym session and associated session APIs

If PMD shows in its feature flag that it supports both sym and
asym then it must support those on all its qps.

Changes from v2:
- added rte_cryptodev_asym_session_set/get_private_data for app to
setup private data in a session as per latest dpdk-next-crypto spec
- rename rte_cryptodev_get_asym_session_private_size to be consistent
with other API names
- correct rte_cryptodev_asym_session_create to pass void** to
rte_mempool_get() and add for private_data_size flag

Changes from v1
    - resolve new line error in librte_cryptodev/rte_cryptodev_version.map

Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
---
 lib/librte_cryptodev/rte_crypto.h              |  37 ++++-
 lib/librte_cryptodev/rte_cryptodev.c           | 180 +++++++++++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h           | 114 +++++++++++++++-
 lib/librte_cryptodev/rte_cryptodev_pmd.h       |  58 +++++++-
 lib/librte_cryptodev/rte_cryptodev_version.map |   7 +
 5 files changed, 392 insertions(+), 4 deletions(-)

diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h
index 25404264b..ef9820e55 100644
--- a/lib/librte_cryptodev/rte_crypto.h
+++ b/lib/librte_cryptodev/rte_crypto.h
@@ -23,6 +23,7 @@ extern "C" {
 #include <rte_common.h>
 
 #include "rte_crypto_sym.h"
+#include "rte_crypto_asym.h"
 
 /** Crypto operation types */
 enum rte_crypto_op_type {
@@ -30,6 +31,8 @@ enum rte_crypto_op_type {
 	/**< Undefined operation type */
 	RTE_CRYPTO_OP_TYPE_SYMMETRIC,
 	/**< Symmetric operation */
+	RTE_CRYPTO_OP_TYPE_ASYMMETRIC
+	/**< Asymmetric operation */
 };
 
 /** Status of crypto operation */
@@ -103,6 +106,10 @@ struct rte_crypto_op {
 	union {
 		struct rte_crypto_sym_op sym[0];
 		/**< Symmetric operation parameters */
+
+		struct rte_crypto_asym_op asym[0];
+		/**< Asymmetric operation parameters */
+
 	}; /**< operation specific parameters */
 };
 
@@ -123,6 +130,9 @@ __rte_crypto_op_reset(struct rte_crypto_op *op, enum rte_crypto_op_type type)
 	case RTE_CRYPTO_OP_TYPE_SYMMETRIC:
 		__rte_crypto_sym_op_reset(op->sym);
 		break;
+	case RTE_CRYPTO_OP_TYPE_ASYMMETRIC:
+		__rte_crypto_asym_op_reset(op->asym);
+		break;
 	case RTE_CRYPTO_OP_TYPE_UNDEFINED:
 	default:
 		break;
@@ -289,9 +299,14 @@ __rte_crypto_op_get_priv_data(struct rte_crypto_op *op, uint32_t size)
 	if (likely(op->mempool != NULL)) {
 		priv_size = __rte_crypto_op_get_priv_data_size(op->mempool);
 
-		if (likely(priv_size >= size))
-			return (void *)((uint8_t *)(op + 1) +
+		if (likely(priv_size >= size)) {
+			if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
+				return (void *)((uint8_t *)(op + 1) +
 					sizeof(struct rte_crypto_sym_op));
+			if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC)
+				return (void *)((uint8_t *)(op+1) +
+					sizeof(struct rte_crypto_asym_op));
+		}
 	}
 
 	return NULL;
@@ -394,6 +409,24 @@ rte_crypto_op_attach_sym_session(struct rte_crypto_op *op,
 	return __rte_crypto_sym_op_attach_sym_session(op->sym, sess);
 }
 
+/**
+ * Attach a asymmetric session to a crypto operation
+ *
+ * @param	op	crypto operation, must be of type asymmetric
+ * @param	sess	cryptodev session
+ */
+static inline int
+rte_crypto_op_attach_asym_session(struct rte_crypto_op *op,
+		struct rte_cryptodev_asym_session *sess)
+{
+	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_ASYMMETRIC))
+		return -1;
+
+	op->sess_type = RTE_CRYPTO_OP_WITH_SESSION;
+
+	return __rte_crypto_op_attach_asym_session(op->asym, sess);
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 2a95a351f..4015872ed 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -166,6 +166,31 @@ rte_crypto_aead_operation_strings[] = {
 	[RTE_CRYPTO_AEAD_OP_DECRYPT]	= "decrypt"
 };
 
+/**
+ * Asymmetric crypto transform operation strings identifiers.
+ */
+const char *rte_crypto_asym_xform_strings[] = {
+	[RTE_CRYPTO_ASYM_XFORM_NONE]	= "none",
+	[RTE_CRYPTO_ASYM_XFORM_RSA]	= "rsa",
+	[RTE_CRYPTO_ASYM_XFORM_MODEX]	= "modexp",
+	[RTE_CRYPTO_ASYM_XFORM_MODINV]	= "modinv",
+	[RTE_CRYPTO_ASYM_XFORM_DH]	= "dh",
+	[RTE_CRYPTO_ASYM_XFORM_DSA]	= "dsa",
+};
+
+/**
+ * Asymmetric crypto operation strings identifiers.
+ */
+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",
+};
+
 int
 rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
 		const char *algo_string)
@@ -1088,6 +1113,38 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
 	return 0;
 }
 
+int __rte_experimental
+rte_cryptodev_asym_session_init(uint8_t dev_id,
+		struct rte_cryptodev_asym_session *sess,
+		struct rte_crypto_asym_xform *xforms,
+		struct rte_mempool *mp)
+{
+	struct rte_cryptodev *dev;
+	uint8_t index;
+	int ret;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+	if (sess == NULL || xforms == NULL || dev == NULL)
+		return -EINVAL;
+
+	index = dev->driver_id;
+
+	if (sess->sess_private_data[index] == NULL) {
+		ret = dev->dev_ops->asym_session_configure(dev,
+							xforms,
+							sess, mp);
+		if (ret < 0) {
+			CDEV_LOG_ERR(
+				"dev_id %d failed to configure session details",
+				dev_id);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
 struct rte_cryptodev_sym_session *
 rte_cryptodev_sym_session_create(struct rte_mempool *mp)
 {
@@ -1107,6 +1164,25 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mp)
 	return sess;
 }
 
+struct rte_cryptodev_asym_session * __rte_experimental
+rte_cryptodev_asym_session_create(struct rte_mempool *mp)
+{
+	struct rte_cryptodev_asym_session *sess;
+
+	/* Allocate a session structure from the session pool */
+	if (rte_mempool_get(mp, (void **)&sess)) {
+		CDEV_LOG_ERR("couldn't get object from session mempool");
+		return NULL;
+	}
+
+	/* Clear device session pointer.
+	 * Include the flag indicating presence of private data
+	 */
+	memset(sess, 0, (sizeof(void *) * nb_drivers) + sizeof(uint8_t));
+
+	return sess;
+}
+
 int
 rte_cryptodev_queue_pair_attach_sym_session(uint8_t dev_id, uint16_t qp_id,
 		struct rte_cryptodev_sym_session *sess)
@@ -1177,6 +1253,22 @@ rte_cryptodev_sym_session_clear(uint8_t dev_id,
 	return 0;
 }
 
+int __rte_experimental
+rte_cryptodev_asym_session_clear(uint8_t dev_id,
+		struct rte_cryptodev_asym_session *sess)
+{
+	struct rte_cryptodev *dev;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+	if (dev == NULL || sess == NULL)
+		return -EINVAL;
+
+	dev->dev_ops->asym_session_clear(dev, sess);
+
+	return 0;
+}
+
 int
 rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess)
 {
@@ -1201,6 +1293,31 @@ rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess)
 	return 0;
 }
 
+int __rte_experimental
+rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess)
+{
+	uint8_t i;
+	void *sess_priv;
+	struct rte_mempool *sess_mp;
+
+	if (sess == NULL)
+		return -EINVAL;
+
+	/* Check that all device private data has been freed */
+	for (i = 0; i < nb_drivers; i++) {
+		sess_priv = get_asym_session_private_data(sess, i);
+		if (sess_priv != NULL)
+			return -EBUSY;
+	}
+
+	/* Return session to mempool */
+	sess_mp = rte_mempool_from_obj(sess);
+	rte_mempool_put(sess_mp, sess);
+
+	return 0;
+}
+
+
 unsigned int
 rte_cryptodev_get_header_session_size(void)
 {
@@ -1241,6 +1358,29 @@ rte_cryptodev_get_private_session_size(uint8_t dev_id)
 
 }
 
+unsigned int __rte_experimental
+rte_cryptodev_asym_get_private_session_size(uint8_t dev_id)
+{
+	struct rte_cryptodev *dev;
+	unsigned int header_size = sizeof(void *) * nb_drivers;
+	unsigned int priv_sess_size;
+
+	if (!rte_cryptodev_pmd_is_valid_dev(dev_id))
+		return 0;
+
+	dev = rte_cryptodev_pmd_get_dev(dev_id);
+
+	if (*dev->dev_ops->asym_session_get_size == NULL)
+		return 0;
+
+	priv_sess_size = (*dev->dev_ops->asym_session_get_size)(dev);
+	if (priv_sess_size < header_size)
+		return header_size;
+
+	return priv_sess_size;
+
+}
+
 int __rte_experimental
 rte_cryptodev_sym_session_set_private_data(
 					struct rte_cryptodev_sym_session *sess,
@@ -1273,6 +1413,39 @@ rte_cryptodev_sym_session_get_private_data(
 	return (uint8_t *)sess + off_set;
 }
 
+
+int __rte_experimental
+rte_cryptodev_asym_session_set_private_data(
+					struct rte_cryptodev_asym_session *sess,
+					void *data,
+					uint16_t size)
+{
+	uint16_t off_set = sizeof(void *) * nb_drivers;
+	uint8_t *private_data_present = (uint8_t *)sess + off_set;
+
+	if (sess == NULL)
+		return -EINVAL;
+
+	*private_data_present = 1;
+	off_set += sizeof(uint8_t);
+	rte_memcpy((uint8_t *)sess + off_set, data, size);
+	return 0;
+}
+
+void * __rte_experimental
+rte_cryptodev_asym_session_get_private_data(
+				struct rte_cryptodev_asym_session *sess)
+{
+	uint16_t off_set = sizeof(void *) * nb_drivers;
+	uint8_t *private_data_present = (uint8_t *)sess + off_set;
+
+	if (sess == NULL || !*private_data_present)
+		return NULL;
+
+	off_set += sizeof(uint8_t);
+	return (uint8_t *)sess + off_set;
+}
+
 /** Initialise rte_crypto_op mempool element */
 static void
 rte_crypto_op_init(struct rte_mempool *mempool,
@@ -1303,6 +1476,13 @@ rte_crypto_op_pool_create(const char *name, enum rte_crypto_op_type type,
 			sizeof(struct rte_crypto_sym_op) +
 			priv_size;
 
+	if (type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+		/* override size by size of asym op */
+		elt_size = sizeof(struct rte_crypto_op) +
+			   sizeof(struct rte_crypto_asym_op) +
+			   priv_size;
+	}
+
 	/* lookup mempool in case already allocated */
 	struct rte_mempool *mp = rte_mempool_lookup(name);
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 261a359dc..623459a95 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -897,9 +897,14 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
  */
 struct rte_cryptodev_sym_session {
 	__extension__ void *sess_private_data[0];
-	/**< Private session material */
+	/**< Private symmetric session material */
 };
 
+/** Cryptodev asymmetric crypto session */
+struct rte_cryptodev_asym_session {
+	__extension__ void *sess_private_data[0];
+	/**< Private asymmetric session material */
+};
 
 /**
  * Create symmetric crypto session header (generic with no private data)
@@ -913,6 +918,18 @@ struct rte_cryptodev_sym_session {
 struct rte_cryptodev_sym_session *
 rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
 
+/**
+ * Create asymmetric crypto session header (generic with no private data)
+ *
+ * @param   mempool    mempool to allocate asymmetric session
+ *                     objects from
+ * @return
+ *  - On success return pointer to asym-session
+ *  - On failure returns NULL
+ */
+struct rte_cryptodev_asym_session * __rte_experimental
+rte_cryptodev_asym_session_create(struct rte_mempool *mempool);
+
 /**
  * Frees symmetric crypto session header, after checking that all
  * the device private data has been freed, returning it
@@ -928,6 +945,21 @@ rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
 int
 rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess);
 
+/**
+ * Frees asymmetric crypto session header, after checking that all
+ * the device private data has been freed, returning it
+ * to its original mempool.
+ *
+ * @param   sess     Session header to be freed.
+ *
+ * @return
+ *  - 0 if successful.
+ *  - -EINVAL if session is NULL.
+ *  - -EBUSY if not all device private data has been freed.
+ */
+int __rte_experimental
+rte_cryptodev_asym_session_free(struct rte_cryptodev_asym_session *sess);
+
 /**
  * Fill out private data for the device id, based on its device type.
  *
@@ -949,6 +981,27 @@ rte_cryptodev_sym_session_init(uint8_t dev_id,
 			struct rte_crypto_sym_xform *xforms,
 			struct rte_mempool *mempool);
 
+/**
+ * Initialize asymmetric session on a device with specific asymmetric xform
+ *
+ * @param   dev_id   ID of device that we want the session to be used on
+ * @param   sess     Session to be set up on a device
+ * @param   xforms   Asymmetric crypto transform operations to apply on flow
+ *                   processed with this session
+ * @param   mempool  Mempool to be used for internal allocation.
+ *
+ * @return
+ *  - On success, zero.
+ *  - -EINVAL if input parameters are invalid.
+ *  - -ENOTSUP if crypto device does not support the crypto transform.
+ *  - -ENOMEM if the private session could not be allocated.
+ */
+int __rte_experimental
+rte_cryptodev_asym_session_init(uint8_t dev_id,
+			struct rte_cryptodev_asym_session *sess,
+			struct rte_crypto_asym_xform *xforms,
+			struct rte_mempool *mempool);
+
 /**
  * Frees private data for the device id, based on its device type,
  * returning it to its mempool.
@@ -964,6 +1017,20 @@ int
 rte_cryptodev_sym_session_clear(uint8_t dev_id,
 			struct rte_cryptodev_sym_session *sess);
 
+/**
+ * Frees resources held by asymmetric session during rte_cryptodev_session_init
+ *
+ * @param   dev_id   ID of device that uses the asymmetric session.
+ * @param   sess     Asymmetric session setup on device using
+ *					 rte_cryptodev_session_init
+ * @return
+ *  - 0 if successful.
+ *  - -EINVAL if device is invalid or session is NULL.
+ */
+int __rte_experimental
+rte_cryptodev_asym_session_clear(uint8_t dev_id,
+			struct rte_cryptodev_asym_session *sess);
+
 /**
  * Get the size of the header session, for all registered drivers.
  *
@@ -984,6 +1051,18 @@ rte_cryptodev_get_header_session_size(void);
  */
 unsigned int
 rte_cryptodev_get_private_session_size(uint8_t dev_id);
+/**
+ * Get the size of the private data for asymmetric session
+ * on device
+ *
+ * @param	dev_id		The device identifier.
+ *
+ * @return
+ *   - Size of the asymmetric private data, if successful
+ *   - 0 if device is invalid or does not have private session
+ */
+unsigned int __rte_experimental
+rte_cryptodev_asym_get_private_session_size(uint8_t dev_id);
 
 /**
  * Attach queue pair with sym session.
@@ -1069,6 +1148,39 @@ void * __rte_experimental
 rte_cryptodev_sym_session_get_private_data(
 					struct rte_cryptodev_sym_session *sess);
 
+/**
+ * Set private data for a session.
+ *
+ * @param	sess		Session pointer allocated by
+ *				*rte_cryptodev_asym_session_create*.
+ * @param	data		Pointer to the private data.
+ * @param	size		Size of the private data.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+int __rte_experimental
+rte_cryptodev_asym_session_set_private_data(
+					struct rte_cryptodev_asym_session *sess,
+					void *data,
+					uint16_t size)
+
+/**
+ * Get private data of a session.
+ *
+ * @param	sess		Session pointer allocated by
+ *				*rte_cryptodev_asym_session_create*.
+ *
+ * @return
+ *  - On success return pointer to private data.
+ *  - On failure returns NULL.
+ */
+void * __rte_experimental
+rte_cryptodev_asym_session_get_private_data(
+				struct rte_cryptodev_asym_session *sess)
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h
index 69d776934..615a22586 100644
--- a/lib/librte_cryptodev/rte_cryptodev_pmd.h
+++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h
@@ -302,6 +302,17 @@ typedef int (*cryptodev_sym_create_session_pool_t)(
  */
 typedef unsigned (*cryptodev_sym_get_session_private_size_t)(
 		struct rte_cryptodev *dev);
+/**
+ * Get the size of a asymmetric cryptodev session
+ *
+ * @param	dev		Crypto device pointer
+ *
+ * @return
+ *  - On success returns the size of the session structure for device
+ *  - On failure returns 0
+ */
+typedef unsigned int (*cryptodev_asym_get_session_private_size_t)(
+		struct rte_cryptodev *dev);
 
 /**
  * Configure a Crypto session on a device.
@@ -321,7 +332,24 @@ typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
 		struct rte_crypto_sym_xform *xform,
 		struct rte_cryptodev_sym_session *session,
 		struct rte_mempool *mp);
-
+/**
+ * Configure a Crypto asymmetric session on a device.
+ *
+ * @param	dev		Crypto device pointer
+ * @param	xform		Single or chain of crypto xforms
+ * @param	priv_sess	Pointer to cryptodev's private session structure
+ * @param	mp		Mempool where the private session is allocated
+ *
+ * @return
+ *  - Returns 0 if private session structure have been created successfully.
+ *  - Returns -EINVAL if input parameters are invalid.
+ *  - Returns -ENOTSUP if crypto device does not support the crypto transform.
+ *  - Returns -ENOMEM if the private session could not be allocated.
+ */
+typedef int (*cryptodev_asym_configure_session_t)(struct rte_cryptodev *dev,
+		struct rte_crypto_asym_xform *xform,
+		struct rte_cryptodev_asym_session *session,
+		struct rte_mempool *mp);
 /**
  * Free driver private session data.
  *
@@ -331,6 +359,15 @@ typedef int (*cryptodev_sym_configure_session_t)(struct rte_cryptodev *dev,
 typedef void (*cryptodev_sym_free_session_t)(struct rte_cryptodev *dev,
 		struct rte_cryptodev_sym_session *sess);
 
+/**
+ * Free asymmetric session private data.
+ *
+ * @param	dev		Crypto device pointer
+ * @param	sess		Cryptodev session structure
+ */
+typedef void (*cryptodev_asym_free_session_t)(struct rte_cryptodev *dev,
+		struct rte_cryptodev_asym_session *sess);
+
 /**
  * Optional API for drivers to attach sessions with queue pair.
  * @param	dev		Crypto device pointer
@@ -384,10 +421,16 @@ struct rte_cryptodev_ops {
 
 	cryptodev_sym_get_session_private_size_t session_get_size;
 	/**< Return private session. */
+	cryptodev_asym_get_session_private_size_t asym_session_get_size;
+	/**< Return asym session private size. */
 	cryptodev_sym_configure_session_t session_configure;
 	/**< Configure a Crypto session. */
+	cryptodev_asym_configure_session_t asym_session_configure;
+	/**< Configure asymmetric Crypto session. */
 	cryptodev_sym_free_session_t session_clear;
 	/**< Clear a Crypto sessions private data. */
+	cryptodev_asym_free_session_t asym_session_clear;
+	/**< Clear a Crypto sessions private data. */
 	cryptodev_sym_queue_pair_attach_session_t qp_attach_session;
 	/**< Attach session to queue pair. */
 	cryptodev_sym_queue_pair_detach_session_t qp_detach_session;
@@ -535,6 +578,19 @@ set_session_private_data(struct rte_cryptodev_sym_session *sess,
 	sess->sess_private_data[driver_id] = private_data;
 }
 
+static inline void *
+get_asym_session_private_data(const struct rte_cryptodev_asym_session *sess,
+		uint8_t driver_id) {
+	return sess->sess_private_data[driver_id];
+}
+
+static inline void
+set_asym_session_private_data(struct rte_cryptodev_asym_session *sess,
+		uint8_t driver_id, void *private_data)
+{
+	sess->sess_private_data[driver_id] = private_data;
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 560e46411..62b782444 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -89,6 +89,13 @@ DPDK_17.11 {
 EXPERIMENTAL {
         global:
 
+	rte_cryptodev_asym_get_private_session_size
+	rte_cryptodev_asym_session_clear;
+	rte_cryptodev_asym_session_create;
+	rte_cryptodev_asym_session_free;
+	rte_cryptodev_asym_session_init;
+	rte_cryptodev_asym_session_get_private_data
+	rte_cryptodev_asym_session_set_private_data
 	rte_cryptodev_sym_session_get_private_data;
 	rte_cryptodev_sym_session_set_private_data;
 } DPDK_17.11;
-- 
2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability in cryptodev
  2018-05-16  6:05 [dpdk-dev] [PATCH v3 0/6] crypto: add asym crypto support Shally Verma
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev Shally Verma
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support " Shally Verma
@ 2018-05-16  6:05 ` Shally Verma
  2018-06-17 12:11   ` De Lara Guarch, Pablo
  2018-07-03 14:12   ` Trahe, Fiona
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto Shally Verma
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 44+ messages in thread
From: Shally Verma @ 2018-05-16  6:05 UTC (permalink / raw)
  To: pablo.de.lara.guarch
  Cc: fiona.trahe, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Extend cryptodev with asymmetric capability APIs and
definitions.

changes from v2:
- remove redundant xform_type from asym capability struct
- rename rte_cryptodev_get_asym_xform_enum to
be more consistent with other API names

Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>

---
User must apply patch
"lib/cryptodev: add asymmetric algos in cryptodev" before compilation
---
---
 lib/librte_cryptodev/Makefile                  |   1 +
 lib/librte_cryptodev/rte_cryptodev.c           |  73 +++++++++++++++++
 lib/librte_cryptodev/rte_cryptodev.h           | 107 ++++++++++++++++++++++++-
 lib/librte_cryptodev/rte_cryptodev_version.map |  11 ++-
 4 files changed, 186 insertions(+), 6 deletions(-)

diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile
index 138e627dc..93f9d2d45 100644
--- a/lib/librte_cryptodev/Makefile
+++ b/lib/librte_cryptodev/Makefile
@@ -12,6 +12,7 @@ LIBABIVER := 4
 # build flags
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 LDLIBS += -lrte_eal -lrte_mempool -lrte_ring -lrte_mbuf
 LDLIBS += -lrte_kvargs
 
diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rte_cryptodev.c
index 4015872ed..ee76cef07 100644
--- a/lib/librte_cryptodev/rte_cryptodev.c
+++ b/lib/librte_cryptodev/rte_cryptodev.c
@@ -242,6 +242,24 @@ rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum,
 	return -1;
 }
 
+int __rte_experimental
+rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum,
+		const char *xform_string)
+{
+	unsigned int i;
+
+	for (i = 1; i < RTE_DIM(rte_crypto_asym_xform_strings); i++) {
+		if (strcmp(xform_string,
+			   rte_crypto_asym_xform_strings[i]) == 0) {
+			*xform_enum = (enum rte_crypto_asym_xform_type) i;
+			return 0;
+		}
+	}
+
+	/* Invalid string */
+	return -1;
+}
+
 /**
  * The crypto auth operation strings identifiers.
  * It could be used in application command line.
@@ -287,6 +305,28 @@ rte_cryptodev_sym_capability_get(uint8_t dev_id,
 
 }
 
+const struct rte_cryptodev_asymmetric_xfrm_capability * __rte_experimental
+rte_cryptodev_asym_capability_get(uint8_t dev_id,
+		const struct rte_cryptodev_asym_capability_idx *idx)
+{
+	const struct rte_cryptodev_capabilities *capability;
+	struct rte_cryptodev_info dev_info;
+	unsigned int i = 0;
+
+	memset(&dev_info, 0, sizeof(struct rte_cryptodev_info));
+	rte_cryptodev_info_get(dev_id, &dev_info);
+
+	while ((capability = &dev_info.capabilities[i++])->op !=
+			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
+		if (capability->op != RTE_CRYPTO_OP_TYPE_ASYMMETRIC)
+			continue;
+
+		if (capability->asym.xfrm_capa.xform_type == idx->type)
+			return &capability->asym.xfrm_capa;
+	}
+	return NULL;
+};
+
 #define param_range_check(x, y) \
 	(((x < y.min) || (x > y.max)) || \
 	(y.increment != 0 && (x % y.increment) != 0))
@@ -342,6 +382,39 @@ rte_cryptodev_sym_capability_check_aead(
 
 	return 0;
 }
+int __rte_experimental
+rte_cryptodev_asym_xfrm_capability_check_optype(
+	const struct rte_cryptodev_asymmetric_xfrm_capability *capability,
+	enum rte_crypto_asym_op_type op_type)
+{
+	if (capability->op_types & (1 << op_type))
+		return 1;
+
+	return 0;
+}
+
+int __rte_experimental
+rte_cryptodev_asym_xfrm_capability_check_modlen(
+	const struct rte_cryptodev_asymmetric_xfrm_capability *capability,
+	uint16_t modlen)
+{
+	/* handle special case of 0 which means PMD doesn't define
+	 * any limit
+	 */
+	if ((capability->modlen.min != 0) &&
+		((modlen < capability->modlen.min) ||
+		(capability->modlen.increment != 0 &&
+		(modlen % (capability->modlen.increment)))))
+		return -1;
+	if ((capability->modlen.max != 0) &&
+		((modlen > capability->modlen.max) ||
+		(capability->modlen.increment != 0 &&
+		(modlen % (capability->modlen.increment)))))
+		return -1;
+
+	return 0;
+}
+
 
 const char *
 rte_cryptodev_get_feature_name(uint64_t flag)
diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
index 623459a95..6c13d23f8 100644
--- a/lib/librte_cryptodev/rte_cryptodev.h
+++ b/lib/librte_cryptodev/rte_cryptodev.h
@@ -178,6 +178,35 @@ struct rte_cryptodev_symmetric_capability {
 	};
 };
 
+/**
+ * Asymmetric Xform Crypto Capability
+ *
+ */
+struct rte_cryptodev_asymmetric_xfrm_capability {
+	enum rte_crypto_asym_xform_type xform_type;
+	/**< Transform type: RSA/MODEXP/DH/DSA/MODINV */
+
+	uint32_t op_types;
+	/**< bitmask for supported rte_crypto_asym_op_type */
+
+	__extension__
+	union {
+		struct rte_crypto_param_range modlen;
+		/**< Range of modulus length supported by modulus based xform.
+		 * Value 0 mean implementation default
+		 */
+	};
+};
+
+/**
+ * Asymmetric Crypto Capability
+ *
+ */
+struct rte_cryptodev_asymmetric_capability {
+	struct rte_cryptodev_asymmetric_xfrm_capability xfrm_capa;
+};
+
+
 /** Structure used to capture a capability of a crypto device */
 struct rte_cryptodev_capabilities {
 	enum rte_crypto_op_type op;
@@ -187,6 +216,8 @@ struct rte_cryptodev_capabilities {
 	union {
 		struct rte_cryptodev_symmetric_capability sym;
 		/**< Symmetric operation capability parameters */
+		struct rte_cryptodev_asymmetric_capability asym;
+		/**< Asymmetric operation capability parameters */
 	};
 };
 
@@ -201,7 +232,17 @@ struct rte_cryptodev_sym_capability_idx {
 };
 
 /**
- *  Provide capabilities available for defined device and algorithm
+ * Structure used to describe asymmetric crypto xforms
+ * Each xform maps to one asym algorithm.
+ *
+ */
+struct rte_cryptodev_asym_capability_idx {
+	enum rte_crypto_asym_xform_type type;
+	/**< Asymmetric xform (algo) type */
+};
+
+/**
+ * Provide capabilities available for defined device and algorithm
  *
  * @param	dev_id		The identifier of the device.
  * @param	idx		Description of crypto algorithms.
@@ -214,6 +255,20 @@ const struct rte_cryptodev_symmetric_capability *
 rte_cryptodev_sym_capability_get(uint8_t dev_id,
 		const struct rte_cryptodev_sym_capability_idx *idx);
 
+/**
+ *  Provide capabilities available for defined device and algorithm
+ *
+ * @param	dev_id		The identifier of the device.
+ * @param	algo		Description of crypto algorithms.
+ *
+ * @return
+ *   - Return description of the asymmetric crypto capability if exist.
+ *   - Return NULL if the capability not exist.
+ */
+const struct rte_cryptodev_asymmetric_xfrm_capability * __rte_experimental
+rte_cryptodev_asym_capability_get(uint8_t dev_id,
+		const struct rte_cryptodev_asym_capability_idx *idx);
+
 /**
  * Check if key size and initial vector are supported
  * in crypto cipher capability
@@ -269,6 +324,36 @@ rte_cryptodev_sym_capability_check_aead(
 		uint16_t key_size, uint16_t digest_size, uint16_t aad_size,
 		uint16_t iv_size);
 
+/**
+ * Check if op type is supported
+ *
+ * @param	capability	Description of the asymmetric crypto capability.
+ * @param	op_type		op type
+ *
+ * @return
+ *   - Return 1 if the op type is supported
+ *   - Return 0 if unsupported
+ */
+int __rte_experimental
+rte_cryptodev_asym_xfrm_capability_check_optype(
+	const struct rte_cryptodev_asymmetric_xfrm_capability *capability,
+		enum rte_crypto_asym_op_type op_type);
+
+/**
+ * Check if modulus length is in supported range
+ *
+ * @param	capability	Description of the asymmetric crypto capability.
+ * @param	modlen		modulus length.
+ *
+ * @return
+ *   - Return 0 if the parameters are in range of the capability.
+ *   - Return -1 if the parameters are out of range of the capability.
+ */
+int __rte_experimental
+rte_cryptodev_asym_xfrm_capability_check_modlen(
+	const struct rte_cryptodev_asymmetric_xfrm_capability *capability,
+		uint16_t modlen);
+
 /**
  * Provide the cipher algorithm enum, given an algorithm string
  *
@@ -314,6 +399,22 @@ int
 rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum,
 		const char *algo_string);
 
+/**
+ * Provide the Asymmetric xform enum, given an xform string
+ *
+ * @param	xform_enum	A pointer to the xform type
+ *				enum to be filled
+ * @param	xform_string	xform string
+ *
+ * @return
+ * - Return -1 if string is not valid
+ * - Return 0 if the string is valid
+ */
+int __rte_experimental
+rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum,
+		const char *xform_string);
+
+
 /** Macro used at end of crypto PMD list */
 #define RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() \
 	{ RTE_CRYPTO_OP_TYPE_UNDEFINED }
@@ -1164,7 +1265,7 @@ int __rte_experimental
 rte_cryptodev_asym_session_set_private_data(
 					struct rte_cryptodev_asym_session *sess,
 					void *data,
-					uint16_t size)
+					uint16_t size);
 
 /**
  * Get private data of a session.
@@ -1178,7 +1279,7 @@ rte_cryptodev_asym_session_set_private_data(
  */
 void * __rte_experimental
 rte_cryptodev_asym_session_get_private_data(
-				struct rte_cryptodev_asym_session *sess)
+				struct rte_cryptodev_asym_session *sess);
 
 
 #ifdef __cplusplus
diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map b/lib/librte_cryptodev/rte_cryptodev_version.map
index 62b782444..817cf9f70 100644
--- a/lib/librte_cryptodev/rte_cryptodev_version.map
+++ b/lib/librte_cryptodev/rte_cryptodev_version.map
@@ -89,13 +89,18 @@ DPDK_17.11 {
 EXPERIMENTAL {
         global:
 
-	rte_cryptodev_asym_get_private_session_size
+	rte_cryptodev_asym_capability_get;
+	rte_cryptodev_asym_get_private_session_size;
+	rte_cryptodev_asym_get_xform_enum;
+	rte_crypto_asym_op_strings;
 	rte_cryptodev_asym_session_clear;
 	rte_cryptodev_asym_session_create;
 	rte_cryptodev_asym_session_free;
 	rte_cryptodev_asym_session_init;
-	rte_cryptodev_asym_session_get_private_data
-	rte_cryptodev_asym_session_set_private_data
+	rte_cryptodev_asym_session_get_private_data;
+	rte_cryptodev_asym_session_set_private_data;
+	rte_cryptodev_asym_xfrm_capability_check_optype;
+	rte_crypto_asym_xform_strings;
 	rte_cryptodev_sym_session_get_private_data;
 	rte_cryptodev_sym_session_set_private_data;
 } DPDK_17.11;
-- 
2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-05-16  6:05 [dpdk-dev] [PATCH v3 0/6] crypto: add asym crypto support Shally Verma
                   ` (2 preceding siblings ...)
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability " Shally Verma
@ 2018-05-16  6:05 ` Shally Verma
  2018-06-17 12:52   ` De Lara Guarch, Pablo
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support Shally Verma
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide Shally Verma
  5 siblings, 1 reply; 44+ messages in thread
From: Shally Verma @ 2018-05-16  6:05 UTC (permalink / raw)
  To: pablo.de.lara.guarch
  Cc: fiona.trahe, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Add unit test case to test openssl PMD asym crypto
operations. Test case invoke asymmetric operation on DPDK
Openssl PMD and cross-verify results via Openssl SW library.
Tests have been verified with openssl 1.0.2m release.

Tested for:

* RSA Encrypt, Decrypt, Sign and Verify using pre-defined
  test vectors
* Modular Inversion and Exponentiation using pre-defined
  test vectors
* Deiffie-Hellman Public key generation using pre-defined
  private key and dynamically generated test vectors
* Deffie-hellman private key generation using dynamically
  generated test vectors
* Deffie-hellman private and public key pair generation
  using xform chain and using dynamically generated test
  vectors
* Deffie-hellman shared secret compute using dynamically
  generated test vectors
* DSA Sign and Verification

Deffie-hellman testcases use run-time generated test params,
thus may take some time for execution.

Changes from v2:
- Change test application to use the renamed APIs and
  to use xform type from capability structure

Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>

---
This patch dependent on asym crypto API patches.
Please apply them before compilation
---
---
 test/test/Makefile              |    3 +-
 test/test/meson.build           |    1 +
 test/test/test_cryptodev_asym.c | 1787 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 1790 insertions(+), 1 deletion(-)

diff --git a/test/test/Makefile b/test/test/Makefile
index d1a75fe92..9526b939d 100644
--- a/test/test/Makefile
+++ b/test/test/Makefile
@@ -179,6 +179,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) += test_pmd_ring_perf.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
 SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
+SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
 
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
@@ -205,7 +206,7 @@ CFLAGS += $(WERROR_FLAGS)
 
 CFLAGS += -D_GNU_SOURCE
 
-LDLIBS += -lm
+LDLIBS += -lm -lcrypto
 ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
 ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
 LDLIBS += -lz
diff --git a/test/test/meson.build b/test/test/meson.build
index 3c8edf521..85bb90a42 100644
--- a/test/test/meson.build
+++ b/test/test/meson.build
@@ -21,6 +21,7 @@ test_sources = files('commands.c',
 	'test_cpuflags.c',
 	'test_crc.c',
 	'test_cryptodev.c',
+	'test_cryptodev_asym.c',
 	'test_cryptodev_blockcipher.c',
 	'test_cycles.c',
 	'test_debug.c',
diff --git a/test/test/test_cryptodev_asym.c b/test/test/test_cryptodev_asym.c
new file mode 100644
index 000000000..a904c2785
--- /dev/null
+++ b/test/test/test_cryptodev_asym.c
@@ -0,0 +1,1787 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2017-2018 Cavium Networks
+ */
+
+#include <rte_common.h>
+#include <rte_hexdump.h>
+#include <rte_mbuf.h>
+#include <rte_malloc.h>
+#include <rte_memcpy.h>
+#include <rte_pause.h>
+#include <rte_bus_vdev.h>
+
+#include <rte_crypto.h>
+#include <rte_cryptodev.h>
+#include <rte_cryptodev_pmd.h>
+#include <openssl/ssl.h>
+
+#include "test.h"
+#include "test_cryptodev.h"
+
+#define TEST_DATA_SIZE 4096
+#define TEST_NUM_BUFS 10
+#define TEST_NUM_SESSIONS 4
+#define ASYM_TEST_MSG_LEN	256
+#define TEST_DH_MOD_LEN 1024
+
+static int gbl_driver_id;
+struct crypto_testsuite_params {
+	struct rte_mempool *op_mpool;
+	struct rte_mempool *session_mpool;
+	struct rte_cryptodev_config conf;
+	struct rte_cryptodev_qp_conf qp_conf;
+	uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
+	uint8_t valid_dev_count;
+};
+
+struct crypto_unittest_params {
+	struct rte_cryptodev_asym_session *sess;
+	struct rte_crypto_op *op;
+};
+
+static struct crypto_testsuite_params testsuite_params = { NULL };
+
+struct rsa_test_data {
+	enum rte_crypto_asym_op_type op_type;
+
+	struct {
+		uint8_t data[TEST_DATA_SIZE];
+		unsigned int len;
+	} plainText;
+	struct {
+		uint8_t data[TEST_DATA_SIZE];
+		unsigned int len;
+	} encryptedText;
+	struct {
+		uint8_t data[TEST_DATA_SIZE];
+		unsigned int len;
+	} signText;
+};
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+
+static unsigned char base[] = {	0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85,
+				0xAE, 0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD,
+				0xA8, 0xEB, 0x7E, 0x78, 0xA0, 0x50 };
+
+static struct rsa_test_data rsa_test_case = {
+	.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT,
+	.plainText = {
+		.data = {
+			0xF8, 0xBA, 0x1A, 0x55, 0xD0, 0x2F, 0x85, 0xAE,
+			0x96, 0x7B, 0xB6, 0x2F, 0xB6, 0xCD, 0xA8, 0xEB,
+			0x7E, 0x78, 0xA0, 0x50
+		},
+		.len = 20
+	},
+	.encryptedText = {
+		.data = {
+			0x4B, 0x22, 0x88, 0xF1, 0x91, 0x5A, 0x6A, 0xCC,
+			0x75, 0xD6, 0x40, 0xE3, 0x58, 0xCA, 0xC8, 0x70,
+			0x9B, 0x2B, 0xC7, 0x36, 0x1F, 0xAE, 0x38, 0xF3,
+			0x97, 0xA6, 0xEE, 0xA7, 0xDB, 0xFF, 0x9F, 0x09,
+			0x73, 0x1A, 0x2F, 0x01, 0xFA, 0xAF, 0x77, 0x09,
+			0xE1, 0x8D, 0x3E, 0x2D, 0x1D, 0x45, 0x15, 0x66,
+			0xE1, 0x79, 0xD7, 0xC6, 0x94, 0x1D, 0x54, 0xBF,
+			0xDD, 0xAB, 0x46, 0x34, 0xC7, 0x55, 0x62, 0x5B,
+			0x9D, 0xBD, 0x28, 0xDB, 0x46, 0x0D, 0x2D, 0x3D,
+			0x41, 0x46, 0xDA, 0x45, 0x31, 0x78, 0xD5, 0xE7,
+			0x2C, 0xA4, 0x1F, 0x73, 0xBE, 0x62, 0x41, 0x2C,
+			0x5C, 0x8D, 0x0D, 0xFA, 0xCC, 0x4C, 0xC1, 0x69,
+			0x90, 0xC9, 0x50, 0x21, 0x20, 0x90, 0x72, 0x70,
+			0x55, 0xA0, 0x25, 0x11, 0x5B, 0x96, 0x96, 0x07,
+			0x98, 0x90, 0x10, 0x81, 0x9E, 0x32, 0x16, 0x02,
+			0x6F, 0x52, 0xCF, 0xDB, 0x57, 0x9C, 0x57, 0xD2
+		},
+		.len = 128
+	},
+	.signText = {
+		.data = {
+			0x2F, 0x42, 0xB3, 0xB1, 0x7F, 0xA8, 0x66, 0x00,
+			0xC6, 0xB4, 0x7D, 0x12, 0x67, 0x5F, 0x94, 0xF7,
+			0x25, 0xD6, 0x7E, 0x14, 0xE4, 0xC2, 0x63, 0xB2,
+			0xDC, 0x1B, 0x13, 0xC0, 0xDA, 0xDA, 0x0D, 0x32,
+			0x9B, 0xF4, 0x8A, 0x62, 0x90, 0xE7, 0xB3, 0xF3,
+			0xBB, 0x5A, 0xAB, 0x5F, 0xF8, 0xAF, 0xF4, 0x19,
+			0x0D, 0xA5, 0x66, 0x25, 0x95, 0x69, 0x57, 0x43,
+			0x87, 0x44, 0xB0, 0x92, 0x1A, 0x39, 0xA6, 0x97,
+			0x06, 0xFD, 0xF3, 0x20, 0x72, 0xFB, 0xEA, 0xEF,
+			0xCF, 0xD1, 0x88, 0xCA, 0x23, 0x26, 0xA9, 0xA9,
+			0x22, 0xCD, 0xA0, 0x10, 0xF9, 0x14, 0x28, 0xC7,
+			0x0E, 0x82, 0xE1, 0xCD, 0xC3, 0x31, 0x0F, 0x75,
+			0x6D, 0x69, 0xCD, 0x55, 0x30, 0xA3, 0x26, 0xCB,
+			0xF8, 0xBC, 0xF3, 0xC5, 0xFA, 0xD7, 0x7E, 0x51,
+			0x81, 0xC9, 0x5C, 0x9F, 0x2A, 0x40, 0x40, 0x83,
+			0xB3, 0xBA, 0xDB, 0x94, 0x2D, 0x31, 0x1C, 0xF8
+
+		},
+		.len = 128
+	}
+};
+
+/** rsa xform using exponent key */
+struct rte_crypto_asym_xform rsa_xform = {
+	.next = NULL,
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
+	.rsa = {
+		.n = {
+		.data =
+		(uint8_t *)
+		("\x00\xb3\xa1\xaf\xb7\x13\x08\x00\x0a\x35\xdc\x2b\x20\x8d"
+		"\xa1\xb5\xce\x47\x8a\xc3\x80\xf4\x7d\x4a\xa2\x62\xfd\x61\x7f"
+		"\xb5\xa8\xde\x0a\x17\x97\xa0\xbf\xdf\x56\x5a\x3d\x51\x56\x4f"
+		"\x70\x70\x3f\x63\x6a\x44\x5b\xad\x84\x0d\x3f\x27\x6e\x3b\x34"
+		"\x91\x60\x14\xb9\xaa\x72\xfd\xa3\x64\xd2\x03\xa7\x53\x87\x9e"
+		"\x88\x0b\xc1\x14\x93\x1a\x62\xff\xb1\x5d\x74\xcd\x59\x63\x18"
+		"\x11\x3d\x4f\xba\x75\xd4\x33\x4e\x23\x6b\x7b\x57\x44\xe1\xd3"
+		"\x03\x13\xa6\xf0\x8b\x60\xb0\x9e\xee\x75\x08\x9d\x71\x63\x13"
+		"\xcb\xa6\x81\x92\x14\x03\x22\x2d\xde\x55"),
+		.length = 129
+		},
+		.e = {
+		.data = (uint8_t *)("\x01\x00\x01"),
+		.length = 3
+		},
+		.key_type = RTE_RSA_KEY_TYPE_EXP,
+		{
+		.d = {
+		.data =
+		(uint8_t *)
+		("\x24\xd7\xea\xf4\x7f\xe0\xca\x31\x4d\xee\xc4\xa1\xbe\xab\x06"
+		"\x61\x32\xe7\x51\x46\x27\xdf\x72\xe9\x6f\xa8\x4c\xd1\x26\xef"
+		"\x65\xeb\x67\xff\x5f\xa7\x3b\x25\xb9\x08\x8e\xa0\x47\x56\xe6"
+		"\x8e\xf9\xd3\x18\x06\x3d\xc6\xb1\xf8\xdc\x1b\x8d\xe5\x30\x54"
+		"\x26\xac\x16\x3b\x7b\xad\x46\x9e\x21\x6a\x57\xe6\x81\x56\x1d"
+		"\x2a\xc4\x39\x63\x67\x81\x2c\xca\xcc\xf8\x42\x04\xbe\xcf\x8f"
+		"\x6c\x5b\x81\x46\xb9\xc7\x62\x90\x87\x35\x03\x9b\x89\xcb\x37"
+		"\xbd\xf1\x1b\x99\xa1\x9a\x78\xd5\x4c\xdd\x3f\x41\x0c\xb7\x1a"
+		"\xd9\x7b\x87\x5f\xbe\xb1\x83\x41"),
+		.length = 128
+		},
+		}
+	}
+};
+
+struct rte_crypto_asym_xform modex_xform = {
+	.next = NULL,
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+	.modex = {
+		.modulus = {
+			.data =
+			(uint8_t *)
+			("\x00\xb3\xa1\xaf\xb7\x13\x08\x00\x0a\x35\xdc\x2b\x20\x8d"
+			"\xa1\xb5\xce\x47\x8a\xc3\x80\xf4\x7d\x4a\xa2\x62\xfd\x61\x7f"
+			"\xb5\xa8\xde\x0a\x17\x97\xa0\xbf\xdf\x56\x5a\x3d\x51\x56\x4f"
+			"\x70\x70\x3f\x63\x6a\x44\x5b\xad\x84\x0d\x3f\x27\x6e\x3b\x34"
+			"\x91\x60\x14\xb9\xaa\x72\xfd\xa3\x64\xd2\x03\xa7\x53\x87\x9e"
+			"\x88\x0b\xc1\x14\x93\x1a\x62\xff\xb1\x5d\x74\xcd\x59\x63\x18"
+			"\x11\x3d\x4f\xba\x75\xd4\x33\x4e\x23\x6b\x7b\x57\x44\xe1\xd3"
+			"\x03\x13\xa6\xf0\x8b\x60\xb0\x9e\xee\x75\x08\x9d\x71\x63\x13"
+			"\xcb\xa6\x81\x92\x14\x03\x22\x2d\xde\x55"),
+			.length = 129
+		},
+		.exponent = {
+			.data = (uint8_t *)("\x01\x00\x01"),
+			.length = 3
+		}
+	}
+};
+
+struct rte_crypto_asym_xform modinv_xform = {
+	.next = NULL,
+	.xform_type = RTE_CRYPTO_ASYM_XFORM_MODINV,
+	.modinv = {
+		.modulus = {
+			.data =
+			(uint8_t *)
+			("\x00\xb3\xa1\xaf\xb7\x13\x08\x00\x0a\x35\xdc\x2b\x20\x8d"
+			"\xa1\xb5\xce\x47\x8a\xc3\x80\xf4\x7d\x4a\xa2\x62\xfd\x61\x7f"
+			"\xb5\xa8\xde\x0a\x17\x97\xa0\xbf\xdf\x56\x5a\x3d\x51\x56\x4f"
+			"\x70\x70\x3f\x63\x6a\x44\x5b\xad\x84\x0d\x3f\x27\x6e\x3b\x34"
+			"\x91\x60\x14\xb9\xaa\x72\xfd\xa3\x64\xd2\x03\xa7\x53\x87\x9e"
+			"\x88\x0b\xc1\x14\x93\x1a\x62\xff\xb1\x5d\x74\xcd\x59\x63\x18"
+			"\x11\x3d\x4f\xba\x75\xd4\x33\x4e\x23\x6b\x7b\x57\x44\xe1\xd3"
+			"\x03\x13\xa6\xf0\x8b\x60\xb0\x9e\xee\x75\x08\x9d\x71\x63\x13"
+			"\xcb\xa6\x81\x92\x14\x03\x22\x2d\xde\x55"),
+			.length = 129
+		}
+	}
+};
+
+#pragma GCC diagnostic pop
+
+static int
+test_rsa(struct rsa_test_data *t)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_session *sess = NULL;
+	RSA *rsa = NULL;
+	int status = TEST_SUCCESS;
+	uint8_t tmp_buf[TEST_DATA_SIZE];
+	int tmp_len = 0;
+	uint8_t output_buf[TEST_DATA_SIZE] = {0};
+	uint8_t input_buf[TEST_DATA_SIZE] = {0};
+	char test_msg[ASYM_TEST_MSG_LEN + 1];
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+
+	if (!sess) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN, "line %u "
+				"FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &rsa_xform,
+			sess_mpool) < 0) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "unabled to config sym session");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	asym_op = op->asym;
+	asym_op->rsa.op_type = t->op_type;
+	asym_op->rsa.pad = RTE_CRYPTO_RSA_PKCS1_V1_5_BT1;
+
+	if (t->op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
+		memcpy(input_buf, t->plainText.data, t->plainText.len);
+		asym_op->rsa.message.data = input_buf;
+		asym_op->rsa.message.length = t->plainText.len;
+	} else if (t->op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
+		asym_op->rsa.message.data = t->plainText.data;
+		asym_op->rsa.message.length = t->plainText.len;
+		asym_op->rsa.sign.data = output_buf;
+	} else if (t->op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
+		memcpy(input_buf, t->encryptedText.data, t->encryptedText.len);
+		asym_op->rsa.message.data = input_buf;
+		asym_op->rsa.message.length = t->encryptedText.len;
+	} else if (t->op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
+		memcpy(input_buf, t->signText.data, t->signText.len);
+		asym_op->rsa.message.data = t->plainText.data;
+		asym_op->rsa.message.length = t->plainText.len;
+		asym_op->rsa.sign.data = input_buf;
+		asym_op->rsa.sign.length = t->signText.len;
+	}
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "Process ASYM operation");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	/* verify result using sw lib */
+	rsa = RSA_new();
+	if (rsa == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate sw RSA");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	rsa->n =
+		BN_bin2bn(
+			(const unsigned char *)rsa_xform.rsa.n.data,
+			rsa_xform.rsa.n.length,
+			rsa->n);
+	rsa->e = BN_bin2bn((const unsigned char *)rsa_xform.rsa.e.data,
+						rsa_xform.rsa.e.length,
+						rsa->e);
+	rsa->d = BN_bin2bn((const unsigned char *)rsa_xform.rsa.d.data,
+						rsa_xform.rsa.d.length,
+						rsa->d);
+
+	if (t->op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
+		debug_hexdump(stdout, "Encrypted output:",
+				asym_op->rsa.message.data,
+				asym_op->rsa.message.length);
+
+		/* decrypt using openssl lib */
+		tmp_len = RSA_private_decrypt(asym_op->rsa.message.length,
+						asym_op->rsa.message.data,
+						tmp_buf,
+						rsa,
+						RSA_PKCS1_PADDING);
+
+		if (memcmp(t->plainText.data, tmp_buf, tmp_len)) {
+			snprintf(test_msg,
+					 ASYM_TEST_MSG_LEN, "line %u "
+					"FAILED: %s", __LINE__,
+					"Crypto data not as expected");
+			status = TEST_FAILED;
+			goto error_exit;
+		}
+	} else if (t->op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
+		debug_hexdump(stdout, "RSA Sign output:",
+				asym_op->rsa.sign.data,
+				asym_op->rsa.sign.length);
+
+		/* verify generated sign using openssl lib */
+		tmp_len = RSA_public_decrypt(asym_op->rsa.sign.length,
+						asym_op->rsa.sign.data,
+						tmp_buf, rsa,
+						RSA_PKCS1_PADDING);
+
+		if (memcmp(asym_op->rsa.message.data, tmp_buf, tmp_len)) {
+			snprintf(test_msg, ASYM_TEST_MSG_LEN, "line %u "
+					"FAILED: %s", __LINE__,
+					"Crypto data not as expected");
+			status = TEST_FAILED;
+			goto error_exit;
+		}
+	} else if (t->op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
+		if (memcmp(asym_op->rsa.message.data,
+				t->plainText.data,
+				t->plainText.len)) {
+			snprintf(test_msg, ASYM_TEST_MSG_LEN, "line %u "
+					"FAILED: %s", __LINE__,
+					"Crypto data not as expected");
+			status = TEST_FAILED;
+			goto error_exit;
+		}
+	} else if (t->op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
+		/* compare verification output in sign to original message */
+		if (memcmp(asym_op->rsa.sign.data,
+				   asym_op->rsa.message.data,
+				   asym_op->rsa.message.length)) {
+			snprintf(test_msg, ASYM_TEST_MSG_LEN,
+					"line %u "
+					"FAILED: %s", __LINE__,
+					"Crypto data not as expected");
+			status = TEST_FAILED;
+			goto error_exit;
+		}
+	}
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "PASS");
+
+error_exit:
+	if (rsa)
+		RSA_free(rsa);
+	if (sess) {
+		rte_cryptodev_asym_session_clear(dev_id, sess);
+		rte_cryptodev_asym_session_free(sess);
+	}
+
+	if (op)
+		rte_crypto_op_free(op);
+
+	return status;
+}
+
+static int
+testsuite_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_cryptodev_info info;
+	uint32_t i = 0, nb_devs, dev_id;
+	int ret;
+	uint16_t qp_id;
+
+	memset(ts_params, 0, sizeof(*ts_params));
+
+	ts_params->op_mpool = rte_crypto_op_pool_create(
+			"CRYPTO_ASYM_OP_POOL",
+			RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+			TEST_NUM_BUFS, 0,
+			0,
+			rte_socket_id());
+	if (ts_params->op_mpool == NULL) {
+		RTE_LOG(ERR, USER1, "Can't create ASYM_CRYPTO_OP_POOL\n");
+		return TEST_FAILED;
+	}
+
+	/* Create an OPENSSL device if required */
+	if (gbl_driver_id == rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
+		nb_devs = rte_cryptodev_device_count_by_driver(
+				rte_cryptodev_driver_id_get(
+				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
+		if (nb_devs < 1) {
+			ret = rte_vdev_init(
+				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
+				NULL);
+
+			TEST_ASSERT(ret == 0, "Failed to create "
+				"instance of pmd : %s",
+				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
+		}
+	}
+
+	nb_devs = rte_cryptodev_count();
+	if (nb_devs < 1) {
+		RTE_LOG(ERR, USER1, "No crypto devices found?\n");
+		return TEST_FAILED;
+	}
+
+	/* Create list of valid crypto devs */
+	for (i = 0; i < nb_devs; i++) {
+		rte_cryptodev_info_get(i, &info);
+		if (info.driver_id == gbl_driver_id)
+			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
+	}
+
+	if (ts_params->valid_dev_count < 1)
+		return TEST_FAILED;
+
+	/* Set up all the qps on the first of the valid devices found */
+
+	dev_id = ts_params->valid_devs[0];
+
+	rte_cryptodev_info_get(dev_id, &info);
+
+	/* check if device support asymmetric , skip if not */
+	if (!(info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)) {
+		RTE_LOG(ERR, USER1, "Device doesn't support asymmetric. "
+				"Test Skipped.\n");
+		return TEST_FAILED;
+	}
+
+	/* configure device with num qp */
+	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
+	ts_params->conf.socket_id = SOCKET_ID_ANY;
+	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
+			&ts_params->conf),
+			"Failed to configure cryptodev %u with %u qps",
+			dev_id, ts_params->conf.nb_queue_pairs);
+
+	/* configure qp */
+	ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
+	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
+		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
+			dev_id, qp_id, &ts_params->qp_conf,
+			rte_cryptodev_socket_id(dev_id),
+			ts_params->session_mpool),
+			"Failed to setup queue pair %u on cryptodev %u ASYM",
+			qp_id, dev_id);
+	}
+
+	/* setup asym session pool */
+	unsigned int session_size =
+		rte_cryptodev_asym_get_private_session_size(dev_id);
+	/*
+	 * Create mempool with TEST_NUM_SESSIONS * 2,
+	 * to include the session headers
+	 */
+	ts_params->session_mpool = rte_mempool_create(
+				"test_asym_sess_mp",
+				TEST_NUM_SESSIONS * 2,
+				session_size,
+				0, 0, NULL, NULL, NULL,
+				NULL, SOCKET_ID_ANY,
+				0);
+
+	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
+			"session mempool allocation failed");
+
+	return TEST_SUCCESS;
+}
+
+static void
+testsuite_teardown(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+
+	if (ts_params->op_mpool != NULL) {
+		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
+		rte_mempool_avail_count(ts_params->op_mpool));
+	}
+
+	/* Free session mempools */
+	if (ts_params->session_mpool != NULL) {
+		rte_mempool_free(ts_params->session_mpool);
+		ts_params->session_mpool = NULL;
+	}
+}
+
+static int
+ut_setup(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+
+	uint16_t qp_id;
+
+	/* Reconfigure device to default parameters */
+	ts_params->conf.socket_id = SOCKET_ID_ANY;
+
+	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
+			&ts_params->conf),
+			"Failed to configure cryptodev %u",
+			ts_params->valid_devs[0]);
+
+	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
+		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
+			ts_params->valid_devs[0], qp_id,
+			&ts_params->qp_conf,
+			rte_cryptodev_socket_id(ts_params->valid_devs[0]),
+			ts_params->session_mpool),
+			"Failed to setup queue pair %u on cryptodev %u",
+			qp_id, ts_params->valid_devs[0]);
+	}
+
+	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
+
+	/* Start the device */
+	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
+						"Failed to start cryptodev %u",
+						ts_params->valid_devs[0]);
+
+	return TEST_SUCCESS;
+}
+
+static void
+ut_teardown(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_cryptodev_stats stats;
+
+	rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
+
+	/* Stop the device */
+	rte_cryptodev_stop(ts_params->valid_devs[0]);
+}
+
+static inline void print_asym_capa(
+		const struct rte_cryptodev_asymmetric_xfrm_capability	*capa)
+{
+	int i = 0;
+
+	printf("\nxform type: %s\n===================\n",
+			rte_crypto_asym_xform_strings[capa->xform_type]);
+	printf("operation supported -");
+
+	for (i = 0; i < RTE_CRYPTO_ASYM_OP_LIST_END; i++) {
+		/* check supported operations */
+		if (rte_cryptodev_asym_xfrm_capability_check_optype(capa, i))
+			printf(" %s",
+					rte_crypto_asym_op_strings[i]);
+		}
+		switch (capa->xform_type) {
+		case RTE_CRYPTO_ASYM_XFORM_RSA:
+		case RTE_CRYPTO_ASYM_XFORM_MODINV:
+		case RTE_CRYPTO_ASYM_XFORM_MODEX:
+		case RTE_CRYPTO_ASYM_XFORM_DH:
+		case RTE_CRYPTO_ASYM_XFORM_DSA:
+			printf(" modlen: min %d max %d increment %d\n",
+					capa->modlen.min,
+					capa->modlen.max,
+					capa->modlen.increment);
+		break;
+		default:
+			break;
+		}
+}
+
+/* ***** Plaintext data for tests ***** */
+static int
+test_capability(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_cryptodev_info dev_info;
+	const struct rte_cryptodev_capabilities *dev_capa;
+	int i = 0;
+	struct rte_cryptodev_asym_capability_idx idx;
+	const struct rte_cryptodev_asymmetric_xfrm_capability *capa;
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	if (!(dev_info.feature_flags &
+				RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO)) {
+	RTE_LOG(INFO, USER1,
+		"Device doesn't support asymmetric. Test Skipped\n");
+		return TEST_SUCCESS;
+	}
+
+	/* print xfrm capability */
+	for (i = 0;
+		dev_info.capabilities[i].op != RTE_CRYPTO_OP_TYPE_UNDEFINED;
+		i++) {
+		dev_capa = &(dev_info.capabilities[i]);
+		if (dev_info.capabilities[i].op ==
+				RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
+			idx.type = dev_capa->asym.xfrm_capa.xform_type;
+
+			capa = rte_cryptodev_asym_capability_get(dev_id,
+				(const struct
+				rte_cryptodev_asym_capability_idx *) &idx);
+			print_asym_capa(capa);
+			}
+	}
+	return TEST_SUCCESS;
+}
+
+static int
+test_dh_gen_shared_sec(DH *testkey, struct rte_crypto_asym_xform *xfrm)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_session *sess = NULL;
+	int status = TEST_SUCCESS;
+	char test_msg[ASYM_TEST_MSG_LEN + 1];
+	uint8_t output[TEST_DH_MOD_LEN];
+	struct rte_crypto_asym_xform xform = *xfrm;
+	uint8_t peer[] = "01234567890123456789012345678901234567890123456789";
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+	if (sess == NULL) {
+		snprintf(test_msg,
+				ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+
+	/* Setup a xform and op to generate private key only */
+	xform.dh.type = RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE;
+	xform.next = NULL;
+	asym_op->dh.priv_key.data = rte_malloc(NULL,
+					BN_num_bytes(testkey->priv_key),
+					0);
+	asym_op->dh.priv_key.length = BN_bn2bin(testkey->priv_key,
+					asym_op->dh.priv_key.data);
+	asym_op->dh.pub_key.data = (uint8_t *)peer;
+	asym_op->dh.pub_key.length = sizeof(peer);
+	asym_op->dh.shared_secret.data = output;
+	asym_op->dh.shared_secret.length = sizeof(output);
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
+			sess_mpool) < 0) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "unabled to config sym session");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "Process ASYM operation");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	debug_hexdump(stdout, "shared secret:",
+			asym_op->dh.shared_secret.data,
+			asym_op->dh.shared_secret.length);
+
+	/* compute shared secret using sw and compare */
+	BIGNUM *p = NULL;
+	p = BN_bin2bn(peer, sizeof(peer), p);
+	if (p != NULL) {
+		size_t test_len;
+		uint8_t *test_shared = rte_malloc(NULL, DH_size(testkey), 0);
+		test_len = DH_compute_key(test_shared, p, testkey);
+
+		debug_hexdump(stdout, "sw shared secret:",
+			test_shared,
+			test_len);
+
+		if ((test_len != asym_op->dh.shared_secret.length) ||
+		    (memcmp(test_shared,
+			asym_op->dh.shared_secret.data, test_len))) {
+			RTE_LOG(ERR, USER1,
+				"shared secret compute verification failed\n");
+			status = TEST_FAILED;
+		}
+		rte_free(test_shared);
+		BN_free(p);
+	}
+error_exit:
+	if (sess != NULL) {
+		rte_cryptodev_asym_session_clear(dev_id, sess);
+		rte_cryptodev_asym_session_free(sess);
+	}
+	if (op != NULL) {
+		if (asym_op->dh.priv_key.data != NULL)
+			rte_free(asym_op->dh.priv_key.data);
+		rte_crypto_op_free(op);
+	}
+	return status;
+}
+
+static int
+test_dh_gen_priv_key(DH *testkey __rte_unused,
+		     struct rte_crypto_asym_xform *xfrm)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_session *sess = NULL;
+	int status = TEST_SUCCESS;
+	char test_msg[ASYM_TEST_MSG_LEN + 1];
+	uint8_t output[TEST_DH_MOD_LEN];
+	struct rte_crypto_asym_xform xform = *xfrm;
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+	if (sess == NULL) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+
+	/* Setup a xform and op to generate private key only */
+	xform.dh.type = RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE;
+	xform.next = NULL;
+	asym_op->dh.priv_key.data = output;
+	asym_op->dh.priv_key.length = sizeof(output);
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
+			sess_mpool) < 0) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "unabled to config sym session");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "Process ASYM operation");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	debug_hexdump(stdout, "private key:",
+			asym_op->dh.priv_key.data,
+			asym_op->dh.priv_key.length);
+
+
+error_exit:
+	if (sess != NULL) {
+		rte_cryptodev_asym_session_clear(dev_id, sess);
+		rte_cryptodev_asym_session_free(sess);
+	}
+	if (op != NULL)
+		rte_crypto_op_free(op);
+
+	return status;
+}
+
+
+static int
+test_dh_gen_pub_key(DH *testkey,
+		    struct rte_crypto_asym_xform *xfrm)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_session *sess = NULL;
+	int status = TEST_SUCCESS;
+	char test_msg[ASYM_TEST_MSG_LEN + 1];
+	uint8_t output[TEST_DH_MOD_LEN];
+	struct rte_crypto_asym_xform xform = *xfrm;
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+	if (sess == NULL) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+	/* Setup a xform chain to generate public key
+	 * using test private key
+	 *
+	 */
+	xform.dh.type = RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE;
+	xform.next = NULL;
+
+	asym_op->dh.pub_key.data = output;
+	asym_op->dh.pub_key.length = sizeof(output);
+	/* load pre-defined private key */
+	asym_op->dh.priv_key.data = rte_malloc(NULL,
+					BN_num_bytes(testkey->priv_key),
+					0);
+	asym_op->dh.priv_key.length = BN_bn2bin(testkey->priv_key,
+					asym_op->dh.priv_key.data);
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
+			sess_mpool) < 0) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "unabled to config sym session");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "Process ASYM operation");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	debug_hexdump(stdout, "pub key:",
+			asym_op->dh.pub_key.data, asym_op->dh.pub_key.length);
+
+	BIGNUM *r = BN_new();
+	if (r != NULL) {
+		/* if priv key is same, then pub too should be same */
+		r = BN_bin2bn(asym_op->dh.pub_key.data,
+			      asym_op->dh.pub_key.length, r);
+		if (BN_cmp(testkey->pub_key, r))
+			status = TEST_FAILED;
+		BN_free(r);
+	}
+
+error_exit:
+	if (sess != NULL) {
+		rte_cryptodev_asym_session_clear(dev_id, sess);
+		rte_cryptodev_asym_session_free(sess);
+	}
+	if (op != NULL) {
+		if (asym_op->dh.priv_key.data != NULL)
+			rte_free(asym_op->dh.priv_key.data);
+		rte_crypto_op_free(op);
+
+	}
+	return status;
+}
+
+
+static int
+test_dh_gen_kp(DH *testkey, struct rte_crypto_asym_xform *xfrm)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_session *sess = NULL;
+	int status = TEST_SUCCESS;
+	char test_msg[ASYM_TEST_MSG_LEN + 1];
+	uint8_t out_pub_key[TEST_DH_MOD_LEN];
+	uint8_t out_prv_key[TEST_DH_MOD_LEN];
+	struct rte_crypto_asym_xform pub_key_xform;
+	struct rte_crypto_asym_xform xform = *xfrm;
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+	if (sess == NULL) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+	/* Setup a xform chain to generate
+	 * private key first followed by
+	 * public key
+	 */
+	xform.dh.type = RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE;
+	pub_key_xform.xform_type = RTE_CRYPTO_ASYM_XFORM_DH;
+	pub_key_xform.dh.type = RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE;
+	xform.next = &pub_key_xform;
+
+	asym_op->dh.pub_key.data = out_pub_key;
+	asym_op->dh.pub_key.length = sizeof(out_pub_key);
+	asym_op->dh.priv_key.data = out_prv_key;
+	asym_op->dh.priv_key.length = sizeof(out_prv_key);
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
+			sess_mpool) < 0) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "unabled to config sym session");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "Process ASYM operation");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	debug_hexdump(stdout, "priv key:",
+			out_prv_key, asym_op->dh.priv_key.length);
+	debug_hexdump(stdout, "pub key:",
+			out_pub_key, asym_op->dh.pub_key.length);
+
+	BIGNUM *r = BN_new();
+	if (r != NULL) {
+		r = BN_bin2bn(asym_op->dh.priv_key.data,
+				   asym_op->dh.priv_key.length, r);
+
+		/* if priv key is same, then pub too should be same */
+		if (!BN_cmp(testkey->priv_key, r)) {
+			r = BN_bin2bn(asym_op->dh.pub_key.data,
+				      asym_op->dh.pub_key.length, r);
+			if (BN_cmp(testkey->pub_key, r))
+				status = TEST_FAILED;
+		}
+		BN_free(r);
+	}
+
+error_exit:
+	if (sess != NULL) {
+		rte_cryptodev_asym_session_clear(dev_id, sess);
+		rte_cryptodev_asym_session_free(sess);
+	}
+	if (op != NULL)
+		rte_crypto_op_free(op);
+
+	return status;
+}
+
+static int
+test_RSA_encryption(void)
+{
+	rsa_test_case.op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
+	return test_rsa(&rsa_test_case);
+}
+
+static int
+test_RSA_decryption(void)
+{
+	rsa_test_case.op_type = RTE_CRYPTO_ASYM_OP_DECRYPT;
+	return test_rsa(&rsa_test_case);
+}
+
+static int
+test_RSA_sign(void)
+{
+	rsa_test_case.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
+	return test_rsa(&rsa_test_case);
+}
+
+static int
+test_RSA_verify(void)
+{
+	int status;
+	rsa_test_case.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
+	status = test_rsa(&rsa_test_case);
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+	return TEST_SUCCESS;
+}
+
+static int
+test_mod_inv(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_session *sess = NULL;
+	int status = TEST_SUCCESS;
+	char test_msg[ASYM_TEST_MSG_LEN + 1];
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	const struct rte_cryptodev_asymmetric_xfrm_capability *capability;
+	BN_CTX *ctx = NULL;
+	uint8_t input[TEST_DATA_SIZE] = {0}, sw_res[TEST_DATA_SIZE] = {0};
+	uint8_t sw_res_len = 0;
+
+	if (rte_cryptodev_asym_get_xform_enum(
+		&modinv_xform.xform_type, "modinv") < 0) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				 "Invalid ASYNC algorithm specified\n");
+		return -1;
+	}
+
+	cap_idx.type = modinv_xform.xform_type;
+	capability = rte_cryptodev_asym_capability_get(dev_id,
+					&cap_idx);
+
+	if (rte_cryptodev_asym_xfrm_capability_check_modlen(
+		capability,
+		modinv_xform.modinv.modulus.length)) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				 "Invalid MODULOUS length specified\n");
+				return -1;
+		}
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+	if (!sess) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN, "line %u "
+				"FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &modinv_xform,
+			sess_mpool) < 0) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "unabled to config sym session");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	/* generate crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		snprintf(test_msg,
+			ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+	memcpy(input, base, sizeof(base));
+	asym_op->modinv.base.data = input;
+	asym_op->modinv.base.length = sizeof(base);
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "Process ASYM operation");
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+	if (result_op == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	snprintf(test_msg,
+			ASYM_TEST_MSG_LEN,
+			"Modinv :%s length:%lu\n",
+			asym_op->modinv.base.data,
+			asym_op->modinv.base.length);
+
+	/* cross verify output using sw lib */
+	ctx = BN_CTX_new();
+	if (ctx == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Failed to allocate CTX");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	BN_CTX_start(ctx);
+	BIGNUM *x = BN_CTX_get(ctx);
+	BIGNUM *m = BN_CTX_get(ctx);
+	BIGNUM *r = BN_CTX_get(ctx);
+
+	if (!x || !m || !r) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Failed to allocate Bignum");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	m = BN_bin2bn(
+		(const unsigned char *)modinv_xform.modinv.modulus.data,
+		modinv_xform.modinv.modulus.length, m);
+	x = BN_bin2bn((const unsigned char *)base, sizeof(base), x);
+	if (!BN_mod_inverse(r, x, m, ctx)) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "SW Mod Inv failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	} else {
+		sw_res_len = BN_bn2bin(r, sw_res);
+		if (memcmp(sw_res, result_op->asym->modinv.base.data,
+					result_op->asym->modinv.base.length)) {
+			snprintf(test_msg, ASYM_TEST_MSG_LEN,
+					"resulted len[%lu]:expected len[%d]"
+					"FAILED: %s",
+					result_op->asym->modinv.base.length,
+					sw_res_len,
+					"SW validation fails");
+			status = TEST_FAILED;
+			goto error_exit;
+		}
+	}
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "PASS");
+
+error_exit:
+	if (ctx) {
+		BN_CTX_end(ctx);
+		BN_CTX_free(ctx);
+	}
+
+	if (sess) {
+		rte_cryptodev_asym_session_clear(dev_id, sess);
+		rte_cryptodev_asym_session_free(sess);
+	}
+
+	if (op)
+		rte_crypto_op_free(op);
+	return status;
+}
+
+static int
+test_mod_exp(void)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_session *sess = NULL;
+	int status = TEST_SUCCESS;
+	char test_msg[ASYM_TEST_MSG_LEN + 1];
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	const struct rte_cryptodev_asymmetric_xfrm_capability *capability;
+	BN_CTX *ctx = NULL;
+	uint8_t input[TEST_DATA_SIZE] = {0}, sw_res[TEST_DATA_SIZE] = {0};
+	uint8_t sw_res_len = 0;
+
+	if (rte_cryptodev_asym_get_xform_enum(&modex_xform.xform_type,
+		"modexp")
+		< 0) {
+		snprintf(test_msg,
+				ASYM_TEST_MSG_LEN,
+				"Invalid ASYNC algorithm specified\n");
+		return -1;
+	}
+
+	/* check for modlen capability */
+	cap_idx.type = modex_xform.xform_type;
+	capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
+
+	if (rte_cryptodev_asym_xfrm_capability_check_modlen(
+			capability, modex_xform.modex.modulus.length)) {
+		snprintf(test_msg,
+				ASYM_TEST_MSG_LEN,
+				"Invalid MODULOUS length specified\n");
+				return -1;
+		}
+
+	/* generate crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		snprintf(test_msg,
+			ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+	if (!sess) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				 "line %u "
+				"FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &modex_xform,
+			sess_mpool) < 0) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "unabled to config sym session");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	asym_op = op->asym;
+	memcpy(input, base, sizeof(base));
+	asym_op->modex.base.data = input;
+	asym_op->modex.base.length = sizeof(base);
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "Process ASYM operation");
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	/* cross verify output using sw lib */
+	ctx = BN_CTX_new();
+	if (ctx == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Failed to allocate CTX");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	BN_CTX_start(ctx);
+	BIGNUM *x = BN_CTX_get(ctx);
+	BIGNUM *m = BN_CTX_get(ctx);
+	BIGNUM *e = BN_CTX_get(ctx);
+	BIGNUM *r = BN_CTX_get(ctx);
+
+	if (!x || !m || !e || !r) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "Failed to allocate Bignum");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	m = BN_bin2bn(
+			(const unsigned char *)modex_xform.modex.modulus.data,
+			modex_xform.modex.modulus.length, m);
+	e = BN_bin2bn(
+			(const unsigned char *)modex_xform.modex.exponent.data,
+			modex_xform.modex.exponent.length, e);
+	x = BN_bin2bn((const unsigned char *)base, sizeof(base), x);
+	if (!BN_mod_exp(r, x, e, m, ctx)) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "SW Mod Exp failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	} else {
+		sw_res_len = BN_bn2bin(r, sw_res);
+		/* compare PMD result with sw result */
+		if (memcmp(sw_res,
+				result_op->asym->modex.base.data,
+				result_op->asym->modex.base.length)) {
+			snprintf(test_msg, ASYM_TEST_MSG_LEN,
+					"resulted len[%lu]:expected len[%d]"
+					" FAILED: %s",
+					result_op->asym->modinv.base.length,
+					sw_res_len,
+					"SW validation fails");
+			status = TEST_FAILED;
+			goto error_exit;
+		}
+	}
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "PASS");
+
+error_exit:
+	if (ctx != NULL) {
+		BN_CTX_end(ctx);
+		BN_CTX_free(ctx);
+	}
+
+	if (sess != NULL) {
+		rte_cryptodev_asym_session_clear(dev_id, sess);
+		rte_cryptodev_asym_session_free(sess);
+	}
+
+	if (op != NULL)
+		rte_crypto_op_free(op);
+
+	return status;
+}
+
+static int
+test_dh_keygenration(void)
+{
+	int status;
+	struct rte_crypto_asym_xform xform;
+	uint8_t p[TEST_DH_MOD_LEN];
+	uint8_t g[TEST_DH_MOD_LEN];
+
+	/* generate dh test params using openssl apis */
+	DH *key = NULL;
+	key = DH_new();
+	if (key == NULL ||
+	   (DH_generate_parameters_ex(key,
+					TEST_DH_MOD_LEN,
+					DH_GENERATOR_2, NULL) != 1)) {
+		RTE_LOG(ERR, USER1,
+			"Unable to generate test params\n");
+		status = TEST_FAILED;
+		return -1;
+	}
+
+	xform.dh.p.length = BN_bn2bin((const BIGNUM *)key->p, p);
+	xform.dh.g.length = BN_bn2bin((const BIGNUM *)key->g, g);
+
+	debug_hexdump(stdout, "p:", p, xform.dh.p.length);
+	debug_hexdump(stdout, "g:", g, xform.dh.g.length);
+
+	if (!DH_generate_key(key)) {
+		RTE_LOG(ERR, USER1,
+			"Unable to generate test params\n");
+		status = TEST_FAILED;
+		return -1;
+	}
+
+	/* load test params into dh xform */
+	xform.dh.p.data = p;
+	xform.dh.g.data = g;
+	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_DH;
+
+	RTE_LOG(INFO, USER1,
+		"Test Public and Private key pair generation\n");
+
+	status = test_dh_gen_kp(key, &xform);
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	RTE_LOG(INFO, USER1,
+		"Test Public Key Generation using pre-defined priv key\n");
+
+	status = test_dh_gen_pub_key(key, &xform);
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	RTE_LOG(INFO, USER1,
+		"Test Private Key Generation only\n");
+
+	status = test_dh_gen_priv_key(key, &xform);
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	RTE_LOG(INFO, USER1,
+		"Test shared secret compute\n");
+
+	status = test_dh_gen_shared_sec(key, &xform);
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	DH_free(key);
+	return status;
+}
+
+static int
+test_dsa_sign(DSA *testdsa, uint8_t *message, size_t msg_len)
+{
+	struct crypto_testsuite_params *ts_params = &testsuite_params;
+	struct rte_mempool *op_mpool = ts_params->op_mpool;
+	struct rte_mempool *sess_mpool = ts_params->session_mpool;
+	uint8_t dev_id = ts_params->valid_devs[0];
+	struct rte_crypto_asym_op *asym_op = NULL;
+	struct rte_crypto_op *op = NULL, *result_op = NULL;
+	struct rte_cryptodev_asym_session *sess = NULL;
+	int status = TEST_SUCCESS;
+	char test_msg[ASYM_TEST_MSG_LEN + 1];
+	uint8_t r[TEST_DH_MOD_LEN];
+	uint8_t s[TEST_DH_MOD_LEN];
+	struct rte_crypto_asym_xform xform;
+
+	sess = rte_cryptodev_asym_session_create(sess_mpool);
+	if (sess == NULL) {
+		snprintf(test_msg,
+				 ASYM_TEST_MSG_LEN,
+				 "line %u FAILED: %s", __LINE__,
+				"Session creation failed");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	/* set up crypto op data structure */
+	op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_ASYMMETRIC);
+	if (!op) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate asymmetric crypto "
+			"operation struct");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	asym_op = op->asym;
+
+	/* Setup a xform for DSA */
+	xform.xform_type = RTE_CRYPTO_ASYM_XFORM_DSA;
+	xform.next = NULL;
+	xform.dsa.x.data = rte_malloc(NULL,
+				      BN_num_bytes(testdsa->priv_key),
+				      0);
+	xform.dsa.p.data = rte_malloc(NULL,
+				      BN_num_bytes(testdsa->p),
+				      0);
+	xform.dsa.q.data = rte_malloc(NULL,
+				      BN_num_bytes(testdsa->q),
+				      0);
+	xform.dsa.g.data = rte_malloc(NULL,
+				      BN_num_bytes(testdsa->g),
+				      0);
+
+	/* copy test params to xform params */
+	xform.dsa.x.length = BN_bn2bin(testdsa->priv_key,
+				       xform.dsa.x.data);
+	xform.dsa.p.length = BN_bn2bin(testdsa->p,
+				       xform.dsa.p.data);
+	xform.dsa.q.length = BN_bn2bin(testdsa->q,
+				       xform.dsa.q.data);
+	xform.dsa.g.length = BN_bn2bin(testdsa->g,
+				       xform.dsa.g.data);
+
+	if (rte_cryptodev_asym_session_init(dev_id, sess, &xform,
+			sess_mpool) < 0) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+				"line %u FAILED: %s",
+				__LINE__, "unabled to config sym session");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	/* attach asymmetric crypto session to crypto operations */
+	rte_crypto_op_attach_asym_session(op, sess);
+	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_SIGN;
+	asym_op->dsa.message.data = message;
+	asym_op->dsa.message.length = msg_len;
+	asym_op->dsa.r.length = sizeof(r);
+	asym_op->dsa.r.data = r;
+	asym_op->dsa.s.length = sizeof(s);
+	asym_op->dsa.s.data = s;
+
+	snprintf(test_msg, ASYM_TEST_MSG_LEN, "Process ASYM operation");
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	asym_op = result_op->asym;
+
+	debug_hexdump(stdout, "r:",
+			asym_op->dsa.r.data, asym_op->dsa.r.length);
+	debug_hexdump(stdout, "s:",
+			asym_op->dsa.s.data, asym_op->dsa.s.length);
+
+	/* verify using sw */
+	DSA_SIG *sig = DSA_SIG_new();
+	if (!sig) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to allocate sw DSA sign");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+	sig->r = BN_bin2bn(asym_op->dsa.r.data, asym_op->dsa.r.length,
+			   sig->r);
+	sig->s = BN_bin2bn(asym_op->dsa.s.data, asym_op->dsa.s.length,
+			   sig->s);
+	if (!DSA_do_verify(message, msg_len, sig, testdsa)) {
+		status = TEST_FAILED;
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			" sign compute cross verification failed\n");
+		DSA_SIG_free(sig);
+		goto error_exit;
+	}
+	DSA_SIG_free(sig);
+
+	/* Test PMD DSA sign verification using signer public key */
+	asym_op->dsa.op_type = RTE_CRYPTO_ASYM_OP_VERIFY;
+
+	/* copy signer public key */
+	asym_op->dsa.y.data = rte_malloc(NULL,
+				      BN_num_bytes(testdsa->pub_key),
+				      0);
+	asym_op->dsa.y.length = BN_bn2bin(testdsa->pub_key,
+					  asym_op->dsa.y.data);
+
+	/* Process crypto operation */
+	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Error sending packet for operation");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	while (rte_cryptodev_dequeue_burst(dev_id, 0, &result_op, 1) == 0)
+		rte_pause();
+
+	if (result_op == NULL) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+		goto error_exit;
+	}
+
+	if (result_op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+		snprintf(test_msg, ASYM_TEST_MSG_LEN,
+			"line %u FAILED: %s",
+			__LINE__, "Failed to process asym crypto op");
+		status = TEST_FAILED;
+	}
+
+error_exit:
+	if (sess != NULL) {
+		rte_cryptodev_asym_session_clear(dev_id, sess);
+		rte_cryptodev_asym_session_free(sess);
+	}
+	if (op != NULL) {
+		if (xform.dsa.x.data)
+			rte_free(xform.dsa.x.data);
+		if (xform.dsa.p.data)
+			rte_free(xform.dsa.p.data);
+		if (xform.dsa.q.data)
+			rte_free(xform.dsa.q.data);
+		if (xform.dsa.g.data)
+			rte_free(xform.dsa.g.data);
+		rte_crypto_op_free(op);
+	}
+	return status;
+}
+
+static int
+test_dsa(void)
+{
+	int status;
+	DSA *dsa = DSA_new();
+	uint8_t dgst[] = "01234567890123456789";
+	/* generate test params */
+	if (dsa == NULL || !DSA_generate_parameters_ex(dsa, TEST_DH_MOD_LEN,
+		NULL, 0, NULL, NULL, NULL)) {
+		RTE_LOG(ERR, USER1,
+			" failed to generate test params\n");
+		return TEST_FAILED;
+	}
+	if (!DSA_generate_key(dsa)) {
+		RTE_LOG(ERR, USER1,
+			" failed to generate test params\n");
+		return TEST_FAILED;
+	}
+
+	/* test DSA sign using generated private key */
+	status = test_dsa_sign(dsa, dgst, sizeof(dgst));
+	TEST_ASSERT_EQUAL(status, 0, "Test failed");
+
+	DSA_free(dsa);
+	return status;
+}
+
+
+static struct unit_test_suite cryptodev_openssl_asym_testsuite  = {
+	.suite_name = "Crypto Device OPENSSL ASYM Unit Test Suite",
+	.setup = testsuite_setup,
+	.teardown = testsuite_teardown,
+	.unit_test_cases = {
+		TEST_CASE_ST(ut_setup, ut_teardown, test_capability),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_dsa),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_dh_keygenration),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_RSA_encryption),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_RSA_decryption),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_RSA_sign),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_RSA_verify),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_mod_inv),
+		TEST_CASE_ST(ut_setup, ut_teardown, test_mod_exp),
+		TEST_CASES_END() /**< NULL terminate unit test array */
+	}
+};
+
+static int
+test_cryptodev_openssl_asym(void)
+{
+	gbl_driver_id = rte_cryptodev_driver_id_get(
+			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
+
+	if (gbl_driver_id == -1) {
+		RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
+				"CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
+				"in config file to run this testsuite.\n");
+		return TEST_FAILED;
+	}
+
+	return unit_test_suite_runner(&cryptodev_openssl_asym_testsuite);
+}
+
+REGISTER_TEST_COMMAND(cryptodev_openssl_asym_autotest,
+					  test_cryptodev_openssl_asym);
-- 
2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-05-16  6:05 [dpdk-dev] [PATCH v3 0/6] crypto: add asym crypto support Shally Verma
                   ` (3 preceding siblings ...)
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto Shally Verma
@ 2018-05-16  6:05 ` Shally Verma
  2018-06-17 13:25   ` De Lara Guarch, Pablo
                     ` (2 more replies)
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide Shally Verma
  5 siblings, 3 replies; 44+ messages in thread
From: Shally Verma @ 2018-05-16  6:05 UTC (permalink / raw)
  To: pablo.de.lara.guarch
  Cc: fiona.trahe, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Add asymmetric crypto operation support in openssl PMD.
Current list of supported asym xforms:
* RSA
* DSA
* Deffie-hellman
* Modular Operations

changes from v2:
- Update the pmd capability as per new capability structure

changes from v1:
- resolve new line error in dod/guides/cryptodevs/openssl.rst

Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
---
 doc/guides/cryptodevs/features/openssl.ini       |  11 +
 doc/guides/cryptodevs/openssl.rst                |   1 +
 drivers/crypto/openssl/rte_openssl_pmd.c         | 377 ++++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_ops.c     | 395 ++++++++++++++++++++++-
 drivers/crypto/openssl/rte_openssl_pmd_private.h |  29 ++
 5 files changed, 801 insertions(+), 12 deletions(-)

diff --git a/doc/guides/cryptodevs/features/openssl.ini b/doc/guides/cryptodevs/features/openssl.ini
index 691565865..bef5c7f79 100644
--- a/doc/guides/cryptodevs/features/openssl.ini
+++ b/doc/guides/cryptodevs/features/openssl.ini
@@ -7,6 +7,7 @@
 Symmetric crypto       = Y
 Sym operation chaining = Y
 Mbuf scatter gather    = Y
+Asymmetric crypto	   = Y
 
 ;
 ; Supported crypto algorithms of the 'openssl' crypto driver.
@@ -49,3 +50,13 @@ AES GCM (256) = Y
 AES CCM (128) = Y
 AES CCM (192) = Y
 AES CCM (256) = Y
+
+;
+; Supported Asymmetric algorithms of the 'openssl' crypto driver.
+;
+[Asymmetric]
+RSA = Y
+DSA = Y
+Modular Exponentiation = Y
+Modular Inversion = Y
+Deffie-hellman = Y
diff --git a/doc/guides/cryptodevs/openssl.rst b/doc/guides/cryptodevs/openssl.rst
index 427fc807c..4f90be888 100644
--- a/doc/guides/cryptodevs/openssl.rst
+++ b/doc/guides/cryptodevs/openssl.rst
@@ -80,6 +80,7 @@ crypto processing.
 
 Test name is cryptodev_openssl_autotest.
 For performance test cryptodev_openssl_perftest can be used.
+For asymmetric crypto operations testing, run cryptodev_openssl_asym_autotest
 
 To verify real traffic l2fwd-crypto example can be used with this command:
 
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index f584d0d6f..527e42773 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -727,19 +727,35 @@ openssl_reset_session(struct openssl_session *sess)
 }
 
 /** Provide session for operation */
-static struct openssl_session *
+static void  *
 get_session(struct openssl_qp *qp, struct rte_crypto_op *op)
 {
 	struct openssl_session *sess = NULL;
+	struct openssl_asym_session *asym_sess = NULL;
 
 	if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
-		/* get existing session */
-		if (likely(op->sym->session != NULL))
-			sess = (struct openssl_session *)
-					get_session_private_data(
-					op->sym->session,
-					cryptodev_driver_id);
+		if (op->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC) {
+			/* get existing session */
+			if (likely(op->sym->session != NULL))
+				sess = (struct openssl_session *)
+						get_session_private_data(
+						op->sym->session,
+						cryptodev_driver_id);
+		} else {
+			if (likely(op->asym->session != NULL))
+				asym_sess = (struct openssl_asym_session *)
+						get_asym_session_private_data(
+						op->asym->session,
+						cryptodev_driver_id);
+			if (asym_sess == NULL)
+				op->status =
+					RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
+			return asym_sess;
+		}
 	} else {
+		if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC)
+			return NULL; /* sessionless asymmetric not supported */
+
 		/* provide internal session */
 		void *_sess = NULL;
 		void *_sess_private_data = NULL;
@@ -1525,6 +1541,341 @@ process_openssl_auth_op(struct openssl_qp *qp, struct rte_crypto_op *op,
 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
 }
 
+static int process_openssl_modinv_op(struct rte_crypto_op *cop,
+				  struct openssl_asym_session *sess)
+{
+	struct rte_crypto_asym_op *op = cop->asym;
+	BIGNUM *base = BN_CTX_get(sess->u.m.ctx);
+	BIGNUM *res = BN_CTX_get(sess->u.m.ctx);
+
+	if (unlikely(base == NULL || res == NULL)) {
+		if (base)
+			BN_free(base);
+		if (res)
+			BN_free(res);
+		cop->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+		return -1;
+	}
+
+	base = BN_bin2bn((const unsigned char *)op->modinv.base.data,
+					  op->modinv.base.length, base);
+
+	if (BN_mod_inverse(res, base, sess->u.m.modulus, sess->u.m.ctx)) {
+		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+		op->modinv.base.length = BN_bn2bin(res, op->modinv.base.data);
+	} else {
+		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+	}
+
+	return 0;
+}
+
+static int process_openssl_modexp_op(struct rte_crypto_op *cop,
+				  struct openssl_asym_session *sess)
+{
+	struct rte_crypto_asym_op *op = cop->asym;
+	BIGNUM *base = BN_CTX_get(sess->u.e.ctx);
+	BIGNUM *res = BN_CTX_get(sess->u.e.ctx);
+
+	if (unlikely(base == NULL || res == NULL)) {
+		if (base)
+			BN_free(base);
+		if (res)
+			BN_free(res);
+		cop->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+		return -1;
+	}
+
+	base = BN_bin2bn((const unsigned char *)op->modinv.base.data,
+					  op->modinv.base.length, base);
+
+	if (BN_mod_exp(res, base, sess->u.e.exp,
+				sess->u.e.mod, sess->u.e.ctx)) {
+		op->modinv.base.length = BN_bn2bin(res, op->modinv.base.data);
+		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+	} else {
+		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+	}
+
+	return 0;
+}
+
+/* process rsa operations */
+static int process_openssl_rsa_op(struct rte_crypto_op *cop,
+				  struct openssl_asym_session *sess)
+{
+	int ret = 0;
+	struct rte_crypto_asym_op *op = cop->asym;
+	RSA *rsa = sess->u.r.rsa;
+	uint32_t pad = (op->rsa.pad);
+
+	switch (pad) {
+	case RTE_CRYPTO_RSA_PKCS1_V1_5_BT1:
+	case RTE_CRYPTO_RSA_PKCS1_V1_5_BT2:
+		pad = RSA_PKCS1_PADDING;
+		break;
+	case RTE_CRYPTO_RSA_PADDING_PSS:
+		pad = RSA_PKCS1_PSS_PADDING;
+		/* fall through */
+	case RTE_CRYPTO_RSA_PADDING_OAEP:
+		pad = RSA_PKCS1_OAEP_PADDING;
+		/* fall through */
+	default:
+		pad = RSA_NO_PADDING;
+		break;
+	}
+
+	switch (op->rsa.op_type) {
+	case RTE_CRYPTO_ASYM_OP_ENCRYPT:
+		ret = RSA_public_encrypt(op->rsa.message.length,
+							op->rsa.message.data,
+							op->rsa.message.data,
+							rsa,
+							pad);
+
+		op->rsa.message.length = ret;
+		OPENSSL_LOG_DBG("length of encrypted text %d\n", ret);
+		break;
+
+	case RTE_CRYPTO_ASYM_OP_DECRYPT:
+		ret = RSA_private_decrypt(op->rsa.message.length,
+							op->rsa.message.data,
+							op->rsa.message.data,
+							rsa,
+							pad);
+		op->rsa.message.length = ret;
+		break;
+
+	case RTE_CRYPTO_ASYM_OP_SIGN:
+		ret = RSA_private_encrypt(op->rsa.message.length,
+							op->rsa.message.data,
+							op->rsa.sign.data,
+							rsa,
+							pad);
+		op->rsa.sign.length = ret;
+		break;
+
+	case RTE_CRYPTO_ASYM_OP_VERIFY:
+		ret = RSA_public_decrypt(op->rsa.sign.length,
+							op->rsa.sign.data,
+							op->rsa.sign.data,
+							rsa,
+							pad);
+
+		OPENSSL_LOG_DBG(
+			"Length of public_decrypt %d length of message %d\n",
+			ret, op->rsa.message.length);
+
+		if (memcmp(op->rsa.sign.data, op->rsa.message.data,
+					op->rsa.message.length)) {
+			OPENSSL_LOG_ERR("RSA sign Verification failed");
+			ret = -1;
+		}
+		break;
+	default:
+			/* allow ops with invalid args to be pushed to
+			 * completion queue
+			 */
+			cop->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		break;
+	}
+
+	if (ret < 0) {
+		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		ret = 0;
+	}
+
+	ret = 0;
+	return ret;
+}
+
+static int
+process_openssl_dh_op(struct rte_crypto_op *cop,
+		      struct openssl_asym_session *sess)
+{
+	struct rte_crypto_dh_op_param *op = &cop->asym->dh;
+	DH *dh_key = sess->u.dh.dh_key;
+
+	if (sess->u.dh.key_op &
+	   (1 << RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE)) {
+		BIGNUM *peer_key = NULL;
+
+		/* copy private key and peer key and compute shared secret */
+		peer_key = BN_bin2bn(op->pub_key.data,
+				     op->pub_key.length,
+				     peer_key);
+		if (peer_key == NULL) {
+			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+			return 0;
+		}
+		dh_key->priv_key = BN_bin2bn(op->priv_key.data,
+					     op->priv_key.length,
+					     dh_key->priv_key);
+		op->shared_secret.length = DH_compute_key(
+					op->shared_secret.data,
+					peer_key, dh_key);
+		if (!(op->shared_secret.length)) {
+			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+			BN_free(peer_key);
+			return 0;
+		}
+		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+		BN_free(peer_key);
+		return 0;
+	}
+
+	if ((sess->u.dh.key_op &
+	    (1 << RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE)) &&
+	    !(sess->u.dh.key_op &
+	    (1 << RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE))) {
+		/* generate public key using user-pass private key */
+		dh_key->priv_key = BN_bin2bn(op->priv_key.data,
+					     op->priv_key.length,
+					     dh_key->priv_key);
+		if (dh_key->priv_key == NULL) {
+			cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+			return 0;
+		}
+	}
+
+	/* generate public and private key pair */
+	if (!DH_generate_key(dh_key)) {
+		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		return 0;
+	}
+
+	if (sess->u.dh.key_op &
+	  (1 << RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE)) {
+		OPENSSL_LOG_DBG("%s:%d updated priv key\n",
+				__func__, __LINE__);
+
+		op->priv_key.length = BN_bn2bin(dh_key->priv_key,
+						op->priv_key.data);
+	}
+
+	if (sess->u.dh.key_op & (1 << RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE)) {
+		OPENSSL_LOG_DBG("%s:%d update public key\n",
+				__func__, __LINE__);
+
+		op->pub_key.length = BN_bn2bin(dh_key->pub_key,
+					       op->pub_key.data);
+	}
+	cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+
+	return 0;
+}
+
+static int
+process_openssl_dsa_sign_op(struct rte_crypto_op *cop,
+			     struct openssl_asym_session *sess)
+{
+	struct rte_crypto_dsa_op_param *op = &cop->asym->dsa;
+	DSA *dsa = sess->u.s.dsa;
+	DSA_SIG *sign;
+
+	sign = DSA_do_sign(op->message.data,
+			   op->message.length,
+			   dsa);
+
+	if (sign == NULL) {
+		OPENSSL_LOG_ERR("%s:%d\n", __func__, __LINE__);
+		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+	} else {
+		op->r.length = BN_bn2bin(sign->r, op->r.data);
+		op->s.length = BN_bn2bin(sign->s, op->s.data);
+		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+	}
+
+	DSA_SIG_free(sign);
+	return 0;
+}
+
+static int
+process_openssl_dsa_verify_op(struct rte_crypto_op *cop,
+			       struct openssl_asym_session *sess)
+{
+	struct rte_crypto_dsa_op_param *op = &cop->asym->dsa;
+	DSA *dsa = sess->u.s.dsa;
+	int ret;
+	DSA_SIG *sign = DSA_SIG_new();
+
+	if (sign == NULL) {
+		OPENSSL_LOG_ERR(" %s:%d\n", __func__, __LINE__);
+		return -1;
+	}
+
+	sign->r = BN_bin2bn(op->r.data,
+			    op->r.length,
+			    sign->r);
+	sign->s = BN_bin2bn(op->s.data,
+			    op->s.length,
+			    sign->s);
+
+	dsa->pub_key = BN_bin2bn(op->y.data,
+			    op->y.length,
+			    dsa->pub_key);
+
+	ret = DSA_do_verify(op->message.data,
+			    op->message.length,
+			    sign,
+			    dsa);
+
+	if (ret != 1)
+		cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
+	else
+		cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+
+	DSA_SIG_free(sign);
+
+	return 0;
+}
+
+
+static int
+process_asym_op(struct openssl_qp *qp, struct rte_crypto_op *op,
+		struct openssl_asym_session *sess)
+{
+	int retval = 0;
+
+	op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+
+	switch (sess->xfrm_type) {
+	case RTE_CRYPTO_ASYM_XFORM_RSA:
+		retval = process_openssl_rsa_op(op, sess);
+	break;
+	case RTE_CRYPTO_ASYM_XFORM_MODEX:
+		retval = process_openssl_modexp_op(op, sess);
+	break;
+	case RTE_CRYPTO_ASYM_XFORM_MODINV:
+		retval = process_openssl_modinv_op(op, sess);
+	break;
+	case RTE_CRYPTO_ASYM_XFORM_DH:
+		retval = process_openssl_dh_op(op, sess);
+	break;
+	case RTE_CRYPTO_ASYM_XFORM_DSA:
+		if (op->asym->dsa.op_type == RTE_CRYPTO_ASYM_OP_SIGN)
+			retval = process_openssl_dsa_sign_op(op, sess);
+		else if (op->asym->dsa.op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
+			retval = process_openssl_dsa_verify_op(op, sess);
+		else
+			op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+	break;
+	default:
+		op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
+		break;
+	}
+	if (!retval) {
+		/* op processed so push to completion queue as processed */
+		retval = rte_ring_enqueue(qp->processed_ops, (void *)op);
+		if (retval)
+			/* return error if failed to put in completion queue */
+			retval = -1;
+	}
+
+	return retval;
+}
+
+
 /** Process crypto operation for mbuf */
 static int
 process_op(struct openssl_qp *qp, struct rte_crypto_op *op,
@@ -1597,7 +1948,7 @@ static uint16_t
 openssl_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 		uint16_t nb_ops)
 {
-	struct openssl_session *sess;
+	void *sess;
 	struct openssl_qp *qp = queue_pair;
 	int i, retval;
 
@@ -1606,7 +1957,12 @@ openssl_pmd_enqueue_burst(void *queue_pair, struct rte_crypto_op **ops,
 		if (unlikely(sess == NULL))
 			goto enqueue_err;
 
-		retval = process_op(qp, ops[i], sess);
+		if (ops[i]->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
+			retval = process_op(qp, ops[i],
+					(struct openssl_session *) sess);
+		else
+			retval = process_asym_op(qp, ops[i],
+					(struct openssl_asym_session *) sess);
 		if (unlikely(retval < 0))
 			goto enqueue_err;
 	}
@@ -1660,7 +2016,8 @@ cryptodev_openssl_create(const char *name,
 	dev->feature_flags = RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO |
 			RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING |
 			RTE_CRYPTODEV_FF_CPU_AESNI |
-			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER;
+			RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER |
+			RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO;
 
 	/* Set vector instructions mode supported */
 	internals = dev->data->dev_private;
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 1cb87d59a..76f7410cb 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -469,6 +469,105 @@ static const struct rte_cryptodev_capabilities openssl_pmd_capabilities[] = {
 			}, }
 		}, }
 	},
+	{	/* RSA */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xfrm_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
+				.op_types = ((1 << RTE_CRYPTO_ASYM_OP_SIGN) |
+					(1 << RTE_CRYPTO_ASYM_OP_VERIFY) |
+					(1 << RTE_CRYPTO_ASYM_OP_ENCRYPT) |
+					(1 << RTE_CRYPTO_ASYM_OP_DECRYPT)),
+				{
+				.modlen = {
+				/* min length is based on openssl rsa keygen */
+				.min = 30,
+				/* value 0 symbolizes no limit on max length */
+				.max = 0,
+				.increment = 1
+				}, }
+			}
+		},
+		}
+	},
+	{	/* modexp */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xfrm_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+				.op_types = 0,
+				{
+				.modlen = {
+				/* min length is based on openssl rsa keygen */
+				.min = 0,
+				/* value 0 symbolizes no limit on max length */
+				.max = 0,
+				.increment = 1
+				}, }
+			}
+		},
+		}
+	},
+	{	/* modinv */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xfrm_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_MODINV,
+				.op_types = 0,
+				{
+				.modlen = {
+				/* min length is based on openssl rsa keygen */
+				.min = 0,
+				/* value 0 symbolizes no limit on max length */
+				.max = 0,
+				.increment = 1
+				}, }
+			}
+		},
+		}
+	},
+	{	/* dh */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xfrm_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_DH,
+				.op_types =
+				((1<<RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE) |
+				(1 << RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE |
+				(1 <<
+				RTE_CRYPTO_ASYM_OP_SHARED_SECRET_COMPUTE))),
+				{
+				.modlen = {
+				/* min length is based on openssl rsa keygen */
+				.min = 0,
+				/* value 0 symbolizes no limit on max length */
+				.max = 0,
+				.increment = 1
+				}, }
+			}
+		},
+		}
+	},
+	{	/* dsa */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xfrm_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_DSA,
+				.op_types =
+				((1<<RTE_CRYPTO_ASYM_OP_SIGN) |
+				(1 << RTE_CRYPTO_ASYM_OP_VERIFY)),
+				{
+				.modlen = {
+				/* min length is based on openssl rsa keygen */
+				.min = 0,
+				/* value 0 symbolizes no limit on max length */
+				.max = 0,
+				.increment = 1
+				}, }
+			}
+		},
+		}
+	},
 
 	RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST()
 };
@@ -670,13 +769,20 @@ openssl_pmd_qp_count(struct rte_cryptodev *dev)
 	return dev->data->nb_queue_pairs;
 }
 
-/** Returns the size of the session structure */
+/** Returns the size of symmetric session structure */
 static unsigned
 openssl_pmd_session_get_size(struct rte_cryptodev *dev __rte_unused)
 {
 	return sizeof(struct openssl_session);
 }
 
+/** Returns the size of the session structure */
+static unsigned
+openssl_pmd_asym_session_get_size(struct rte_cryptodev *dev __rte_unused)
+{
+	return sizeof(struct openssl_asym_session);
+}
+
 /** Configure the session from a crypto xform chain */
 static int
 openssl_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
@@ -713,6 +819,236 @@ openssl_pmd_session_configure(struct rte_cryptodev *dev __rte_unused,
 	return 0;
 }
 
+static int openssl_set_asym_session_parameters(
+				struct openssl_asym_session *asym_session,
+				struct rte_crypto_asym_xform *xform)
+{
+
+	if ((xform->xform_type != RTE_CRYPTO_ASYM_XFORM_DH) &&
+		(xform->next != NULL)) {
+		OPENSSL_LOG_ERR("chained xfrms are not supported on %s",
+			rte_crypto_asym_xform_strings[xform->xform_type]);
+		return -1;
+	}
+
+	switch (xform->xform_type) {
+	case RTE_CRYPTO_ASYM_XFORM_RSA:
+	{
+		struct rte_crypto_rsa_xform *xfrm = &(xform->rsa);
+		asym_session->xfrm_type = RTE_CRYPTO_ASYM_XFORM_RSA;
+
+		RSA *rsa = RSA_new();
+		if (rsa == NULL)
+			return -1;
+		/* copy xfrm data into rsa struct */
+		rsa->n = BN_bin2bn((const unsigned char *)xfrm->n.data,
+							xfrm->n.length, rsa->n);
+		rsa->e = BN_bin2bn((const unsigned char *)xfrm->e.data,
+							xfrm->e.length, rsa->e);
+		if (xfrm->key_type == RTE_RSA_KEY_TYPE_EXP) {
+			rsa->d = BN_bin2bn((const unsigned char *)xfrm->d.data,
+							xfrm->d.length,
+							rsa->d);
+		} else {
+			rsa->p = BN_bin2bn(
+					(const unsigned char *)xfrm->qt.p.data,
+							xfrm->qt.p.length,
+							rsa->p);
+			rsa->q = BN_bin2bn(
+					(const unsigned char *)xfrm->qt.q.data,
+							xfrm->qt.q.length,
+							rsa->q);
+			rsa->dmp1 = BN_bin2bn(
+					(const unsigned char *)xfrm->qt.dP.data,
+							xfrm->qt.dP.length,
+							rsa->dmp1);
+			rsa->dmq1 = BN_bin2bn(
+					(const unsigned char *)xfrm->qt.dQ.data,
+							xfrm->qt.dQ.length,
+							rsa->dmq1);
+			rsa->iqmp = BN_bin2bn(
+					(const unsigned char *)
+							xfrm->qt.qInv.data,
+							xfrm->qt.qInv.length,
+							rsa->iqmp);
+		}
+		asym_session->u.r.rsa = rsa;
+		break;
+	}
+	case RTE_CRYPTO_ASYM_XFORM_MODEX:
+	{
+		struct rte_crypto_modex_xform *xfrm = &(xform->modex);
+
+		asym_session->xfrm_type = RTE_CRYPTO_ASYM_XFORM_MODEX;
+
+		BN_CTX *ctx = BN_CTX_new();
+		if (ctx == NULL) {
+			OPENSSL_LOG_ERR(" failed to allocate resources\n");
+			return -1;
+		}
+		BN_CTX_start(ctx);
+		BIGNUM *mod = BN_CTX_get(ctx);
+		BIGNUM *exp = BN_CTX_get(ctx);
+		if (mod == NULL || exp == NULL) {
+			BN_CTX_end(ctx);
+			BN_CTX_free(ctx);
+			return -1;
+		}
+		mod = BN_bin2bn((const unsigned char *)xfrm->modulus.data,
+						 xfrm->modulus.length, mod);
+		exp = BN_bin2bn((const unsigned char *)xfrm->exponent.data,
+						 xfrm->exponent.length, exp);
+		asym_session->u.e.ctx = ctx;
+		asym_session->u.e.mod = mod;
+		asym_session->u.e.exp = exp;
+		break;
+	}
+	case RTE_CRYPTO_ASYM_XFORM_MODINV:
+	{
+		struct rte_crypto_modinv_xform *xfrm = &(xform->modinv);
+
+		asym_session->xfrm_type = RTE_CRYPTO_ASYM_XFORM_MODINV;
+
+		BN_CTX *ctx = BN_CTX_new();
+		if (ctx == NULL) {
+			OPENSSL_LOG_ERR(" failed to allocate resources\n");
+			return -1;
+		}
+		BN_CTX_start(ctx);
+		BIGNUM *mod = BN_CTX_get(ctx);
+		if (mod == NULL) {
+			BN_CTX_end(ctx);
+			BN_CTX_free(ctx);
+			return -1;
+		}
+
+		mod = BN_bin2bn((const unsigned char *)
+						 xfrm->modulus.data,
+						 xfrm->modulus.length,
+						 mod);
+		asym_session->u.m.ctx = ctx;
+		asym_session->u.m.modulus = mod;
+		break;
+	}
+	case RTE_CRYPTO_ASYM_XFORM_DH:
+	{
+		asym_session->xfrm_type = RTE_CRYPTO_ASYM_XFORM_DH;
+
+		asym_session->u.dh.dh_key = DH_new();
+		DH *dh = asym_session->u.dh.dh_key;
+		if (dh == NULL) {
+			OPENSSL_LOG_ERR(" failed to allocate resources\n");
+			return -1;
+		}
+
+		dh->p = BN_bin2bn((const unsigned char *)
+						 xform->dh.p.data,
+						 xform->dh.p.length,
+						 dh->p);
+
+		dh->g = BN_bin2bn((const unsigned char *)
+						 xform->dh.g.data,
+						 xform->dh.g.length,
+						 dh->g);
+
+		/* setup xfrom for
+		 * public key generate, or
+		 * DH Priv key generate, or both
+		 * public and private key generate
+		 */
+		asym_session->u.dh.key_op = (1 << xform->dh.type);
+
+		if (xform->dh.type == RTE_CRYPTO_ASYM_OP_PRIVATE_KEY_GENERATE) {
+			/* check if next is pubkey */
+			if ((xform->next != NULL) &&
+			   (xform->next->xform_type ==
+			   RTE_CRYPTO_ASYM_XFORM_DH) &&
+			   (xform->next->dh.type ==
+			   RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE)) {
+			    /* setup op as pub/priv key pair generation */
+				asym_session->u.dh.key_op |=
+				(1 << RTE_CRYPTO_ASYM_OP_PUBLIC_KEY_GENERATE);
+			}
+		}
+		break;
+	}
+	case RTE_CRYPTO_ASYM_XFORM_DSA:
+	{
+		asym_session->xfrm_type = RTE_CRYPTO_ASYM_XFORM_DSA;
+
+		asym_session->u.s.dsa = DSA_new();
+		DSA *dsa = asym_session->u.s.dsa;
+		if (dsa == NULL) {
+			OPENSSL_LOG_ERR(
+				" failed to allocate resources\n");
+			return -1;
+		}
+
+		dsa->p = BN_bin2bn((const unsigned char *)
+				    xform->dsa.p.data,
+				    xform->dsa.p.length,
+				    dsa->p);
+
+		dsa->g = BN_bin2bn((const unsigned char *)
+				    xform->dsa.g.data,
+				    xform->dsa.g.length,
+				    dsa->g);
+
+		dsa->q = BN_bin2bn((const unsigned char *)
+				    xform->dsa.q.data,
+				    xform->dsa.q.length,
+				    dsa->q);
+
+		dsa->priv_key = BN_bin2bn((const unsigned char *)
+				    xform->dsa.x.data,
+				    xform->dsa.x.length,
+				    dsa->priv_key);
+
+		break;
+	}
+	default:
+		return -1;
+	}
+
+	return 0;
+}
+
+/** Configure the session from a crypto xform chain */
+static int
+openssl_pmd_asym_session_configure(struct rte_cryptodev *dev __rte_unused,
+		struct rte_crypto_asym_xform *xform,
+		struct rte_cryptodev_asym_session *sess,
+		struct rte_mempool *mempool)
+{
+	void *asym_sess_private_data;
+	int ret;
+
+	if (unlikely(sess == NULL)) {
+		OPENSSL_LOG_ERR("invalid asymmetric session struct");
+		return -EINVAL;
+	}
+
+	if (rte_mempool_get(mempool, &asym_sess_private_data)) {
+		CDEV_LOG_ERR(
+			"Couldn't get object from session mempool");
+		return -ENOMEM;
+	}
+
+	ret = openssl_set_asym_session_parameters(asym_sess_private_data,
+									xform);
+	if (ret != 0) {
+		OPENSSL_LOG_ERR("failed configure session parameters");
+
+		/* Return session to mempool */
+		rte_mempool_put(mempool, asym_sess_private_data);
+		return ret;
+	}
+
+	set_asym_session_private_data(sess, dev->driver_id,
+			asym_sess_private_data);
+
+	return 0;
+}
 
 /** Clear the memory of session so it doesn't leave key material behind */
 static void
@@ -732,6 +1068,58 @@ openssl_pmd_session_clear(struct rte_cryptodev *dev,
 	}
 }
 
+static void openssl_reset_asym_session(struct openssl_asym_session *sess)
+{
+	switch (sess->xfrm_type) {
+	case RTE_CRYPTO_ASYM_XFORM_RSA:
+		if (sess->u.r.rsa)
+			RSA_free(sess->u.r.rsa);
+		break;
+	case RTE_CRYPTO_ASYM_XFORM_MODEX:
+		if (sess->u.e.ctx) {
+			BN_CTX_end(sess->u.e.ctx);
+			BN_CTX_free(sess->u.e.ctx);
+		}
+		break;
+	case RTE_CRYPTO_ASYM_XFORM_MODINV:
+		if (sess->u.m.ctx) {
+			BN_CTX_end(sess->u.m.ctx);
+			BN_CTX_free(sess->u.m.ctx);
+		}
+		break;
+	case RTE_CRYPTO_ASYM_XFORM_DH:
+		if (sess->u.dh.dh_key)
+			DH_free(sess->u.dh.dh_key);
+		break;
+	case RTE_CRYPTO_ASYM_XFORM_DSA:
+		if (sess->u.s.dsa)
+			DSA_free(sess->u.s.dsa);
+		break;
+	default:
+		break;
+	}
+}
+
+/** Clear the memory of asymmetric session
+ * so it doesn't leave key material behind
+ */
+static void
+openssl_pmd_asym_session_clear(struct rte_cryptodev *dev,
+		struct rte_cryptodev_asym_session *sess)
+{
+	uint8_t index = dev->driver_id;
+	void *sess_priv = get_asym_session_private_data(sess, index);
+
+	/* Zero out the whole structure */
+	if (sess_priv) {
+		openssl_reset_asym_session(sess_priv);
+		memset(sess_priv, 0, sizeof(struct openssl_asym_session));
+		struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
+		set_asym_session_private_data(sess, index, NULL);
+		rte_mempool_put(sess_mp, sess_priv);
+	}
+}
+
 struct rte_cryptodev_ops openssl_pmd_ops = {
 		.dev_configure		= openssl_pmd_config,
 		.dev_start		= openssl_pmd_start,
@@ -750,8 +1138,11 @@ struct rte_cryptodev_ops openssl_pmd_ops = {
 		.queue_pair_count	= openssl_pmd_qp_count,
 
 		.session_get_size	= openssl_pmd_session_get_size,
+		.asym_session_get_size	= openssl_pmd_asym_session_get_size,
 		.session_configure	= openssl_pmd_session_configure,
-		.session_clear		= openssl_pmd_session_clear
+		.asym_session_configure	= openssl_pmd_asym_session_configure,
+		.session_clear		= openssl_pmd_session_clear,
+		.asym_session_clear	= openssl_pmd_asym_session_clear
 };
 
 struct rte_cryptodev_ops *rte_openssl_pmd_ops = &openssl_pmd_ops;
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_private.h b/drivers/crypto/openssl/rte_openssl_pmd_private.h
index bc8dc7cdc..ebc9dee53 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_private.h
+++ b/drivers/crypto/openssl/rte_openssl_pmd_private.h
@@ -8,6 +8,10 @@
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
 #include <openssl/des.h>
+#include <openssl/rsa.h>
+#include <openssl/dh.h>
+#include <openssl/dsa.h>
+
 
 #define CRYPTODEV_NAME_OPENSSL_PMD	crypto_openssl
 /**< Open SSL Crypto PMD device name */
@@ -157,6 +161,31 @@ struct openssl_session {
 
 } __rte_cache_aligned;
 
+/** OPENSSL crypto private asymmetric session structure */
+struct openssl_asym_session {
+	enum rte_crypto_asym_xform_type xfrm_type;
+	union {
+		struct rsa {
+			RSA *rsa;
+		} r;
+		struct exp {
+			BIGNUM *exp;
+			BIGNUM *mod;
+			BN_CTX *ctx;
+		} e;
+		struct mod {
+			BIGNUM *modulus;
+			BN_CTX *ctx;
+		} m;
+		struct dh {
+			DH *dh_key;
+			uint32_t key_op;
+		} dh;
+		struct {
+			DSA *dsa;
+		} s;
+	} u;
+} __rte_cache_aligned;
 /** Set and validate OPENSSL crypto session parameters */
 extern int
 openssl_set_session_parameters(struct openssl_session *sess,
-- 
2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
  2018-05-16  6:05 [dpdk-dev] [PATCH v3 0/6] crypto: add asym crypto support Shally Verma
                   ` (4 preceding siblings ...)
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support Shally Verma
@ 2018-05-16  6:05 ` Shally Verma
  2018-06-14 10:43   ` Kovacevic, Marko
  2018-06-17 13:33   ` De Lara Guarch, Pablo
  5 siblings, 2 replies; 44+ messages in thread
From: Shally Verma @ 2018-05-16  6:05 UTC (permalink / raw)
  To: pablo.de.lara.guarch
  Cc: fiona.trahe, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Update cryptodev programmer guide with description of
asymmetric crypto framework in lib cryptodev.

Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
---
 doc/guides/prog_guide/cryptodev_lib.rst | 338 +++++++++++++++++++++++++++++++-
 1 file changed, 329 insertions(+), 9 deletions(-)

diff --git a/doc/guides/prog_guide/cryptodev_lib.rst b/doc/guides/prog_guide/cryptodev_lib.rst
index b279a20e5..9244a0684 100644
--- a/doc/guides/prog_guide/cryptodev_lib.rst
+++ b/doc/guides/prog_guide/cryptodev_lib.rst
@@ -8,7 +8,7 @@ The cryptodev library provides a Crypto device framework for management and
 provisioning of hardware and software Crypto poll mode drivers, defining generic
 APIs which support a number of different Crypto operations. The framework
 currently only supports cipher, authentication, chained cipher/authentication
-and AEAD symmetric Crypto operations.
+and AEAD symmetric and asymmetric Crypto operations.
 
 
 Design Principles
@@ -159,8 +159,8 @@ Device Features and Capabilities
 Crypto devices define their functionality through two mechanisms, global device
 features and algorithm capabilities. Global devices features identify device
 wide level features which are applicable to the whole device such as
-the device having hardware acceleration or supporting symmetric Crypto
-operations,
+the device having hardware acceleration or supporting symmetric and/or asymmetric
+Crypto operations,
 
 The capabilities mechanism defines the individual algorithms/functions which
 the device supports, such as a specific symmetric Crypto cipher,
@@ -199,7 +199,7 @@ scope of the Crypto capability see the definition of the structure in the
 Each Crypto poll mode driver defines its own private array of capabilities
 for the operations it supports. Below is an example of the capabilities for a
 PMD which supports the authentication algorithm SHA1_HMAC and the cipher
-algorithm AES_CBC.
+algorithm AES_CBC and RSA operations.
 
 .. code-block:: c
 
@@ -245,7 +245,29 @@ algorithm AES_CBC.
                     }
                 }
             }
-        }
+        },
+		{	/* RSA */
+		.op = RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+		{.asym = {
+			.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
+			.xfrm_capa = {
+				.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
+				.op_types = ((1 << RTE_CRYPTO_ASYM_OP_SIGN) |
+					(1 << RTE_CRYPTO_ASYM_OP_VERIFY) |
+					(1 << RTE_CRYPTO_ASYM_OP_ENCRYPT) |
+					(1 << RTE_CRYPTO_ASYM_OP_DECRYPT)),
+				{
+				.modlen = {
+				/* min length is based on openssl rsa keygen */
+				.min = 30,
+				/* value 0 symbolizes no limit on max length */
+				.max = 0,
+				.increment = 1
+				}, }
+			}
+		},
+		}
+	}
     }
 
 
@@ -788,14 +810,312 @@ using one of the crypto PMDs available in DPDK.
                                             num_dequeued_ops);
     } while (total_num_dequeued_ops < num_enqueued_ops);
 
-
 Asymmetric Cryptography
 -----------------------
 
-Asymmetric functionality is currently not supported by the cryptodev API.
+The cryptodev library currently provides support for the following asymmetric
+Crypto operations; RSA, Modular exponentiation and inversion, Deffie-hellman
+public and/or private key generation and shared secret compute, DSA Signature
+generation and verification.
+
+Session and Session Management
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Sessions are used in asymmetric cryptographic processing to store the immutable
+data defined in asymmetric cryptographic transform which is further used in the
+operation processing. Sessions typically stores information, such as, public
+and private key information or domain params or prime modulus data i.e. immutable
+across data sets. Crypto sessions cache this immutable data in a optimal way for the
+underlying PMD and this allows further acceleration of the offload of Crypto workloads.
+
+Like symmetric, the Crypto device framework provides APIs to allocate and initizalize
+asymmetric sessions for crypto devices, where sessions are mempool objects.
+It is the application's responsibility to create and manage the session mempools.
+Application using both symmetric and asymmetric sessions should allocate and maintain
+different sessions pools for each type.
+
+An application can use ``rte_cryptodev_get_asym_session_private_size()`` to
+get the private size of asymmetric session on a given crypto device. This
+function would allow an application to calculate the max device asymmetric
+session size of all crypto devices to create a single session mempool.
+If instead an application creates multiple asymmetric session mempools,
+the Crypto device framework also provides ``rte_cryptodev_get_header_session_size()`` to get
+the size of an uninitialized session.
+
+Once the session mempools have been created, ``rte_cryptodev_asym_session_create()``
+is used to allocate an uninitialized asymmetric session from the given mempool.
+The session then must be initialized using ``rte_cryptodev_asym_session_init()``
+for each of the required crypto devices. An asymmetric transform chain
+is used to specify the operation and its parameters. See the section below for
+details on transforms.
+
+When a session is no longer used, user must call ``rte_cryptodev_asym_session_clear()``
+for each of the crypto devices that are using the session, to free all driver
+private asymmetric session data. Once this is done, session should be freed using
+``rte_cryptodev_asym_session_free()`` which returns them to their mempool.
+
+Asymmetric Sessionless Support
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Currently asymmetric crypto framework does not support sessionless.
+
+Transforms and Transform Chaining
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Asymmetric Crypto transforms (``rte_crypto_asym_xform``) are the mechanism used
+to specify the details of the asymmetric Crypto operation. Next pointer within
+xform allows transform to be chained together. Also it is important to note that
+the order in which the transforms are passed indicates the order of the chaining.
+
+Not all asymmetric crypto xforms are supported for chaining. Currently supported
+asymmetric crypto chaining is Deffie-hellman private key generation followed by
+public generation. Also, currently API does not support chaining of symmetric and
+asymmetric crypto xfroms.
+
+Each xform defines specific asymmetric crypto algo. Currently supported are:
+* RSA
+* Modular operations (Exponentiation and Inverse)
+* Deffie-hellman
+* DSA
+* None - special case where PMD may support a passthrough mode. More for diagonistic purpose
+
+.. code-block:: c
+
+    struct rte_crypto_asym_xform {
+		struct rte_crypto_asym_xform *next;
+		/**< Pointer to next xform to set up xform chain.*/
+		enum rte_crypto_asym_xform_type xform_type;
+		/**< Asymmetric crypto transform */
+
+		__extension__
+		union {
+			struct rte_crypto_rsa_xform rsa;
+			/**< RSA xform parameters */
+
+			struct rte_crypto_modex_xform modex;
+			/**< Modular Exponentiation xform parameters */
+
+			struct rte_crypto_modinv_xform modinv;
+			/**< Modulus Inverse xform parameters */
+
+			struct rte_crypto_dh_xform dh;
+			/**< DH xform parameters */
+
+			struct rte_crypto_dsa_xform dsa;
+			/**< DSA xform parameters */
+		};
+	};
+
+Asymmetric Operations
+~~~~~~~~~~~~~~~~~~~~~
+
+The asymmetric Crypto operation structure contains all the mutable data relating
+to asymmetric cryptographic processing on an input data buffer. It uses either
+RSA, Modular, Deffie-hellman or DSA operations depending upon session it is attached
+to.
+
+Every operation must carry a valid session handle which further carries information
+on xform or xform-chain to be performed on op. Every xform type defines its own set
+of opertational params in their respective rte_crypto_xxx_op_param struct. Depending
+on xform information within session, PMD picks up and process respective op_param
+struct.
+Unlike symmetric, asymmetric operations do not use mbufs for input/output.
+They operate on data buffer of type ``rte_crypto_param``.
+
+.. code-block:: c
+
+    typedef struct rte_crypto_param_t {
+            uint8_t *data;
+            /**< pointer to buffer holding data */
+            rte_iova_t iova;
+            /**< IO address of data buffer */
+            size_t length;
+            /**< length of data in bytes */
+    } rte_crypto_param;
+
+See *DPDK API Reference* for details on each rte_crypto_xxx_op_param struct
+
+.. code-block:: c
+
+    struct rte_crypto_asym_op {
+		struct rte_cryptodev_asym_session *session;
+		/**< Handle for the initialised session context */
+
+		__extension__
+		union {
+			struct rte_crypto_rsa_op_param rsa;
+			struct rte_crypto_mod_op_param modex;
+			struct rte_crypto_mod_op_param modinv;
+			struct rte_crypto_dh_op_param dh;
+			struct rte_crypto_dsa_op_param dsa;
+		};
+	} __rte_cache_aligned;
+
+
+Asymmetric crypto Sample code
+-----------------------------
+
+There's a unit test application test_cryptodev_asym.c inside unit test framework that
+show how to setup and process asymmetric operations using cryptodev library.
+
+The following sample code shows the basic steps to compute modular exponentiation
+using 1024-bit modulus length using openssl PMD available in DPDK (performing other
+crypto operations is similar except change to respective op and xform setup).
+
+.. code-block:: c
+
+    /*
+     * Simple example to compute modular exponentiation with 1024-bit key
+     *
+     */
+    #define MAX_ASYM_SESSIONS	10
+    #define NUM_ASYM_BUFS	10
+
+    struct rte_mempool *crypto_op_pool, *asym_session_pool;
+    unsigned int asym_session_size;
+    int ret;
+
+    /* Initialize EAL. */
+    ret = rte_eal_init(argc, argv);
+    if (ret < 0)
+        rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n");
+
+    uint8_t socket_id = rte_socket_id();
+
+    /* Create crypto operation pool. */
+    crypto_op_pool = rte_crypto_op_pool_create(
+                                    "crypto_op_pool",
+                                    RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+                                    NUM_ASYM_BUFS, 0, 0,
+                                    socket_id);
+    if (crypto_op_pool == NULL)
+        rte_exit(EXIT_FAILURE, "Cannot create crypto op pool\n");
+
+    /* Create the virtual crypto device. */
+    char args[128];
+    const char *crypto_name = "crypto_openssl";
+    snprintf(args, sizeof(args), "socket_id=%d", socket_id);
+    ret = rte_vdev_init(crypto_name, args);
+    if (ret != 0)
+        rte_exit(EXIT_FAILURE, "Cannot create virtual device");
+
+    uint8_t cdev_id = rte_cryptodev_get_dev_id(crypto_name);
+
+    /* Get private asym session data size. */
+    asym_session_size = rte_cryptodev_get_asym_private_session_size(cdev_id);
+
+    /*
+     * Create session mempool, with two objects per session,
+     * one for the session header and another one for the
+     * private asym session data for the crypto device.
+     */
+    asym_session_pool = rte_mempool_create("asym_session_pool",
+                                    MAX_ASYM_SESSIONS * 2,
+                                    asym_session_size,
+                                    0,
+                                    0, NULL, NULL, NULL,
+                                    NULL, socket_id,
+                                    0);
+
+    /* Configure the crypto device. */
+    struct rte_cryptodev_config conf = {
+        .nb_queue_pairs = 1,
+        .socket_id = socket_id
+    };
+    struct rte_cryptodev_qp_conf qp_conf = {
+        .nb_descriptors = 2048
+    };
+
+    if (rte_cryptodev_configure(cdev_id, &conf) < 0)
+        rte_exit(EXIT_FAILURE, "Failed to configure cryptodev %u", cdev_id);
+
+    if (rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
+                            socket_id, asym_session_pool) < 0)
+        rte_exit(EXIT_FAILURE, "Failed to setup queue pair\n");
+
+    if (rte_cryptodev_start(cdev_id) < 0)
+        rte_exit(EXIT_FAILURE, "Failed to start device\n");
+
+    /* Setup crypto xform to do modular exponentiation with 1024 bit
+	 * length modulus
+	 */
+    struct rte_crypto_asym_xform modex_xform = {
+		.next = NULL,
+		.xform_type = RTE_CRYPTO_ASYM_XFORM_MODEX,
+		.modex = {
+			.modulus = {
+				.data =
+				(uint8_t *)
+				("\xb3\xa1\xaf\xb7\x13\x08\x00\x0a\x35\xdc\x2b\x20\x8d"
+				"\xa1\xb5\xce\x47\x8a\xc3\x80\xf4\x7d\x4a\xa2\x62\xfd\x61\x7f"
+				"\xb5\xa8\xde\x0a\x17\x97\xa0\xbf\xdf\x56\x5a\x3d\x51\x56\x4f"
+				"\x70\x70\x3f\x63\x6a\x44\x5b\xad\x84\x0d\x3f\x27\x6e\x3b\x34"
+				"\x91\x60\x14\xb9\xaa\x72\xfd\xa3\x64\xd2\x03\xa7\x53\x87\x9e"
+				"\x88\x0b\xc1\x14\x93\x1a\x62\xff\xb1\x5d\x74\xcd\x59\x63\x18"
+				"\x11\x3d\x4f\xba\x75\xd4\x33\x4e\x23\x6b\x7b\x57\x44\xe1\xd3"
+				"\x03\x13\xa6\xf0\x8b\x60\xb0\x9e\xee\x75\x08\x9d\x71\x63\x13"
+				"\xcb\xa6\x81\x92\x14\x03\x22\x2d\xde\x55"),
+				.length = 128
+			},
+			.exponent = {
+				.data = (uint8_t *)("\x01\x00\x01"),
+				.length = 3
+			}
+		}
+    };
+    /* Create asym crypto session and initialize it for the crypto device. */
+    struct rte_cryptodev_asym_session *asym_session;
+    asym_session = rte_cryptodev_asym_session_create(asym_session_pool);
+    if (asym_session == NULL)
+        rte_exit(EXIT_FAILURE, "Session could not be created\n");
+
+    if (rte_cryptodev_asym_session_init(cdev_id, asym_session,
+                    &modex_xform, asym_session_pool) < 0)
+        rte_exit(EXIT_FAILURE, "Session could not be initialized "
+                    "for the crypto device\n");
+
+    /* Get a burst of crypto operations. */
+    struct rte_crypto_op *crypto_ops[1];
+    if (rte_crypto_op_bulk_alloc(crypto_op_pool,
+                            RTE_CRYPTO_OP_TYPE_ASYMMETRIC,
+                            crypto_ops, 1) == 0)
+        rte_exit(EXIT_FAILURE, "Not enough crypto operations available\n");
+
+    /* Set up the crypto operations. */
+    struct rte_crypto_asym_op *asym_op = crypto_ops[0]->asym;
+
+	/* calculate mod exp of value 0xf8 */
+    static unsigned char base[] = {0xF8};
+    asym_op->modex.base.data = base;
+    asym_op->modex.base.length = sizeof(base);
+	asym_op->modex.base.iova = base;
+
+    /* Attach the asym crypto session to the operation */
+    rte_crypto_op_attach_asym_session(op, asym_session);
+
+    /* Enqueue the crypto operations in the crypto device. */
+    uint16_t num_enqueued_ops = rte_cryptodev_enqueue_burst(cdev_id, 0,
+                                            crypto_ops, 1);
+
+    /*
+     * Dequeue the crypto operations until all the operations
+     * are proccessed in the crypto device.
+     */
+    uint16_t num_dequeued_ops, total_num_dequeued_ops = 0;
+    do {
+        struct rte_crypto_op *dequeued_ops[1];
+        num_dequeued_ops = rte_cryptodev_dequeue_burst(cdev_id, 0,
+                                        dequeued_ops, 1);
+        total_num_dequeued_ops += num_dequeued_ops;
+
+        /* Check if operation was processed successfully */
+        if (dequeued_ops[0]->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
+                rte_exit(EXIT_FAILURE,
+                        "Some operations were not processed correctly");
+
+    } while (total_num_dequeued_ops < num_enqueued_ops);
 
 
-Crypto Device API
-~~~~~~~~~~~~~~~~~
+Asymmetric Crypto Device API
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The cryptodev Library API is described in the *DPDK API Reference* document.
-- 
2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide Shally Verma
@ 2018-06-14 10:43   ` Kovacevic, Marko
  2018-06-15  8:06     ` Verma, Shally
  2018-06-17 13:33   ` De Lara Guarch, Pablo
  1 sibling, 1 reply; 44+ messages in thread
From: Kovacevic, Marko @ 2018-06-14 10:43 UTC (permalink / raw)
  To: Shally Verma, De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

<...>

> +params or prime modulus data i.e. immutable across data sets. Crypto
> +sessions cache this immutable data in a optimal way for the underlying PMD
> and this allows further acceleration of the offload of Crypto workloads.
> +
> +Like symmetric, the Crypto device framework provides APIs to allocate
> +and initizalize asymmetric sessions for crypto devices, where sessions are

Spelling initizalize/ initialize 


> mempool objects.
> +It is the application's responsibility to create and manage the session
> mempools.
> +Application using both symmetric and asymmetric sessions should
> +allocate and maintain different sessions pools for each type.
> +

<...>

> +Every operation must carry a valid session handle which further carries
> +information on xform or xform-chain to be performed on op. Every xform
> +type defines its own set of opertational params in their respective

Spelling opertational/ operational 

<...>

> +
> +    /*
> +     * Dequeue the crypto operations until all the operations
> +     * are proccessed in the crypto device.
> +     */

Spelling proccessed/  processed


<...>

> 
> -Crypto Device API
> -~~~~~~~~~~~~~~~~~
> +Asymmetric Crypto Device API
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
>  The cryptodev Library API is described in the *DPDK API Reference*
> document.

Maybe try and have the DPDK API Reference as a clickable link so someone can just 
be brought straight to it. Maybe something like this 

`DPDK API Reference <http://dpdk.org/doc/api/>`_

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
  2018-06-14 10:43   ` Kovacevic, Marko
@ 2018-06-15  8:06     ` Verma, Shally
  0 siblings, 0 replies; 44+ messages in thread
From: Verma, Shally @ 2018-06-15  8:06 UTC (permalink / raw)
  To: Kovacevic, Marko, De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Thanks for reviewing. Acked to all feedback

Thanks
Shally
>-----Original Message-----
>From: Kovacevic, Marko [mailto:marko.kovacevic@intel.com]
>Sent: 14 June 2018 16:13
>To: Verma, Shally <Shally.Verma@cavium.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
>
>External Email
>
><...>
>
>> +params or prime modulus data i.e. immutable across data sets. Crypto
>> +sessions cache this immutable data in a optimal way for the underlying PMD
>> and this allows further acceleration of the offload of Crypto workloads.
>> +
>> +Like symmetric, the Crypto device framework provides APIs to allocate
>> +and initizalize asymmetric sessions for crypto devices, where sessions are
>
>Spelling initizalize/ initialize
>
>
>> mempool objects.
>> +It is the application's responsibility to create and manage the session
>> mempools.
>> +Application using both symmetric and asymmetric sessions should
>> +allocate and maintain different sessions pools for each type.
>> +
>
><...>
>
>> +Every operation must carry a valid session handle which further carries
>> +information on xform or xform-chain to be performed on op. Every xform
>> +type defines its own set of opertational params in their respective
>
>Spelling opertational/ operational
>
><...>
>
>> +
>> +    /*
>> +     * Dequeue the crypto operations until all the operations
>> +     * are proccessed in the crypto device.
>> +     */
>
>Spelling proccessed/  processed
>
>
><...>
>
>>
>> -Crypto Device API
>> -~~~~~~~~~~~~~~~~~
>> +Asymmetric Crypto Device API
>> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>  The cryptodev Library API is described in the *DPDK API Reference*
>> document.
>
>Maybe try and have the DPDK API Reference as a clickable link so someone can just
>be brought straight to it. Maybe something like this
>
>`DPDK API Reference <http://dpdk.org/doc/api/>`_
>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev Shally Verma
@ 2018-06-15  8:40   ` De Lara Guarch, Pablo
  2018-06-22 15:38     ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-15  8:40 UTC (permalink / raw)
  To: Shally Verma
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Hi Shally,

> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
> 
> Add rte_crypto_asym.h with supported xfrms and associated op structures and
> APIs
> 
> API currently supports:
> - RSA Encrypt, Decrypt, Sign and Verify
> - Modular Exponentiation and Inversion
> - DSA Sign and Verify
> - Deffie-hellman private key exchange
> - Deffie-hellman public key exchange
> - Deffie-hellman shared secret compute
> - Deffie-hellman public/private key pair generation using xform chain
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>

I have some comments below, but apart from those, could you send a rebased version of this API?

Thanks,
Pablo

> ---
>  lib/librte_cryptodev/Makefile          |   2 +-
>  lib/librte_cryptodev/meson.build       |   3 +-
>  lib/librte_cryptodev/rte_crypto_asym.h | 519
> +++++++++++++++++++++++++++++++++
>  3 files changed, 522 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile index
> bba8dee9f..138e627dc 100644
> --- a/lib/librte_cryptodev/Makefile
> +++ b/lib/librte_cryptodev/Makefile
> @@ -23,7 +23,7 @@ SYMLINK-y-include += rte_crypto.h  SYMLINK-y-include +=
> rte_crypto_sym.h  SYMLINK-y-include += rte_cryptodev.h  SYMLINK-y-include +=
> rte_cryptodev_pmd.h
> -
> +SYMLINK-y-include += rte_crypto_asym.h

Leave the blank space that was present before.

>  # versioning export map
>  EXPORT_MAP := rte_cryptodev_version.map
> 

...

> --- /dev/null
> +++ b/lib/librte_cryptodev/rte_crypto_asym.h

...

> +
> +#include <string.h>
> +#include <stdint.h>

Leave a blank space between non-DPDK and DPDK libraries.

> +#include <rte_memory.h>
> +#include <rte_mempool.h>
> +#include <rte_common.h>
> +

...

> +struct rte_crypto_rsa_xform {
> +	rte_crypto_param n;
> +	/**< n - Prime modulus
> +	 * Prime modulus data of RSA operation in Octet-string network
> +	 * byte order format.
> +	 */
> +
> +	rte_crypto_param e;
> +	/**< e - Public key exponent
> +	 * Public key exponent used for RSA public key operations in Octet-
> +	 * string network byte order format.
> +	 */
> +
> +	enum rte_crypto_rsa_priv_key_type key_type;
> +

Needs RTE_STD_C11/extension, before the union.

> +	union {
> +			rte_crypto_param d;
> +			/**< d - Private key exponent
> +			 * Private key exponent used for RSA
> +			 * private key operations in
> +			 * Octet-string  network byte order format.
> +			 */
> +
> +			struct rte_crypto_rsa_priv_key_qt qt;
> +			/**< qt - Private key in quintuple format */
> +	};
> +};

...

> +/**
> + * Asymmetric Cryptographic Operation.
> + *
> + * Structure describing asymmetric crypto operation params.
> + *
> + */
> +struct rte_crypto_asym_op {
> +	struct rte_cryptodev_asym_session *session;
> +	/**< Handle for the initialised session context */
> +

Looking at the xform structure, it looks like a chain of xforms is possible.
Looking at this union, this case wouldn't be possible, as only one item from the union can be set.

> +	__extension__
> +	union {
> +		struct rte_crypto_rsa_op_param rsa;
> +		struct rte_crypto_mod_op_param modex;
> +		struct rte_crypto_mod_op_param modinv;
> +		struct rte_crypto_dh_op_param dh;
> +		struct rte_crypto_dsa_op_param dsa;
> +	};
> +} __rte_cache_aligned;
> +
> +/**
> + * Reset the fields of an asymmetric operation to their default values.
> + *
> + * @param	op	The crypto operation to be reset.
> + */
> +static inline void
> +__rte_crypto_asym_op_reset(struct rte_crypto_asym_op *op) {
> +	memset(op, 0, sizeof(*op));
> +}
> +
> +/**
> + * Attach a session to an asymmetric crypto operation
> + *
> + * @param	asym_op	crypto operation
> + * @param	sess	cryptodev session
> + */
> +static inline int
> +__rte_crypto_op_attach_asym_session(struct rte_crypto_asym_op *asym_op,
> +		struct rte_cryptodev_asym_session *sess) {
> +	asym_op->session = sess;
> +	return 0;
> +}

I think we should get rid of these two functions, as they are just one line, used just once in the code.
I know it is also done in symmetric, I think it can be removed from there too.


> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* _RTE_CRYPTO_ASYM_H_ */
> --
> 2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support " Shally Verma
@ 2018-06-15  9:05   ` De Lara Guarch, Pablo
  2018-06-26  9:20   ` De Lara Guarch, Pablo
  1 sibling, 0 replies; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-15  9:05 UTC (permalink / raw)
  To: Shally Verma
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta



> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev

Change title to "cryptodev: support asymmetric operations".

> 
> Extend DPDK librte_cryptodev to:
> - define asym op type in rte_crypto_op_type and associated
>   op pool create/alloc APIs
> - define asym session and associated session APIs
> 
> If PMD shows in its feature flag that it supports both sym and asym then it must
> support those on all its qps.
> 
> Changes from v2:
> - added rte_cryptodev_asym_session_set/get_private_data for app to setup
> private data in a session as per latest dpdk-next-crypto spec
> - rename rte_cryptodev_get_asym_session_private_size to be consistent with
> other API names
> - correct rte_cryptodev_asym_session_create to pass void** to
> rte_mempool_get() and add for private_data_size flag
> 
> Changes from v1
>     - resolve new line error in librte_cryptodev/rte_cryptodev_version.map

These changes should go after the three dashes after the "Signed-off-by" lines.

> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> ---
>  lib/librte_cryptodev/rte_crypto.h              |  37 ++++-
>  lib/librte_cryptodev/rte_cryptodev.c           | 180 +++++++++++++++++++++++++
>  lib/librte_cryptodev/rte_cryptodev.h           | 114 +++++++++++++++-
>  lib/librte_cryptodev/rte_cryptodev_pmd.h       |  58 +++++++-
>  lib/librte_cryptodev/rte_cryptodev_version.map |   7 +
>  5 files changed, 392 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/librte_cryptodev/rte_crypto.h b/lib/librte_cryptodev/rte_crypto.h
> index 25404264b..ef9820e55 100644
> --- a/lib/librte_cryptodev/rte_crypto.h
> +++ b/lib/librte_cryptodev/rte_crypto.h

...

> +			if (op->type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC)
> +				return (void *)((uint8_t *)(op+1) +

For consistency, use (op + 1).

...

> --- a/lib/librte_cryptodev/rte_cryptodev.c
> +++ b/lib/librte_cryptodev/rte_cryptodev.c

...

>  /** Initialise rte_crypto_op mempool element */  static void
> rte_crypto_op_init(struct rte_mempool *mempool, @@ -1303,6 +1476,13 @@
> rte_crypto_op_pool_create(const char *name, enum rte_crypto_op_type type,
>  			sizeof(struct rte_crypto_sym_op) +
>  			priv_size;
> 

I would check for type == SYMMETRIC in the previous code,
else if type == ASYMMETRIC with this code, else log error and return NULL
(or use a switch, whatever you prefer).


> +	if (type == RTE_CRYPTO_OP_TYPE_ASYMMETRIC) {
> +		/* override size by size of asym op */
> +		elt_size = sizeof(struct rte_crypto_op) +
> +			   sizeof(struct rte_crypto_asym_op) +
> +			   priv_size;
> +	}
> +
>  	/* lookup mempool in case already allocated */
>  	struct rte_mempool *mp = rte_mempool_lookup(name);
> 
> diff --git a/lib/librte_cryptodev/rte_cryptodev.h
> b/lib/librte_cryptodev/rte_cryptodev.h
> index 261a359dc..623459a95 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.h
> +++ b/lib/librte_cryptodev/rte_cryptodev.h

...

> + */
> +int __rte_experimental
> +rte_cryptodev_asym_session_set_private_data(
> +					struct rte_cryptodev_asym_session
> *sess,
> +					void *data,
> +					uint16_t size)

Missing ";" here.

> +
> +/**
> + * Get private data of a session.
> + *
> + * @param	sess		Session pointer allocated by
> + *				*rte_cryptodev_asym_session_create*.
> + *
> + * @return
> + *  - On success return pointer to private data.
> + *  - On failure returns NULL.
> + */
> +void * __rte_experimental
> +rte_cryptodev_asym_session_get_private_data(
> +				struct rte_cryptodev_asym_session *sess)

Missing ";" here.

> +
> +
>  #ifdef __cplusplus
>  }
>  #endif

> diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map
> b/lib/librte_cryptodev/rte_cryptodev_version.map
> index 560e46411..62b782444 100644
> --- a/lib/librte_cryptodev/rte_cryptodev_version.map
> +++ b/lib/librte_cryptodev/rte_cryptodev_version.map
> @@ -89,6 +89,13 @@ DPDK_17.11 {
>  EXPERIMENTAL {
>          global:
> 
> +	rte_cryptodev_asym_get_private_session_size

I see that there is not rte_cryptodev_asym_get_header_session_size.
rte_cryptodev_get_header_session_size is deprecated, so you won't be able to use this API.


> +	rte_cryptodev_asym_session_clear;
> +	rte_cryptodev_asym_session_create;
> +	rte_cryptodev_asym_session_free;
> +	rte_cryptodev_asym_session_init;
> +	rte_cryptodev_asym_session_get_private_data
> +	rte_cryptodev_asym_session_set_private_data

Missing ";" at the end of these two functions.
Also, "asym_session_get_private_data" should be placed after "asym_session_free".

>  	rte_cryptodev_sym_session_get_private_data;
>  	rte_cryptodev_sym_session_set_private_data;
>  } DPDK_17.11;
> --
> 2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability in cryptodev
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability " Shally Verma
@ 2018-06-17 12:11   ` De Lara Guarch, Pablo
  2018-07-03 14:12   ` Trahe, Fiona
  1 sibling, 0 replies; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-17 12:11 UTC (permalink / raw)
  To: Shally Verma
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta



> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability in
> cryptodev
> 
> Extend cryptodev with asymmetric capability APIs and definitions.
> 
> changes from v2:
> - remove redundant xform_type from asym capability struct
> - rename rte_cryptodev_get_asym_xform_enum to be more consistent with
> other API names
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> 
> ---
> User must apply patch
> "lib/cryptodev: add asymmetric algos in cryptodev" before compilation
> ---
> ---
>  lib/librte_cryptodev/Makefile                  |   1 +
>  lib/librte_cryptodev/rte_cryptodev.c           |  73 +++++++++++++++++
>  lib/librte_cryptodev/rte_cryptodev.h           | 107 ++++++++++++++++++++++++-
>  lib/librte_cryptodev/rte_cryptodev_version.map |  11 ++-
>  4 files changed, 186 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/librte_cryptodev/Makefile b/lib/librte_cryptodev/Makefile index
> 138e627dc..93f9d2d45 100644
> --- a/lib/librte_cryptodev/Makefile
> +++ b/lib/librte_cryptodev/Makefile
> @@ -12,6 +12,7 @@ LIBABIVER := 4
>  # build flags
>  CFLAGS += -O3
>  CFLAGS += $(WERROR_FLAGS)
> +CFLAGS += -DALLOW_EXPERIMENTAL_API

I don't think this flag is needed. You are exporting experimental API, but not using inside the library
(apps/drivers will need to use this flag, though).

>  LDLIBS += -lrte_eal -lrte_mempool -lrte_ring -lrte_mbuf  LDLIBS += -lrte_kvargs
> 
> diff --git a/lib/librte_cryptodev/rte_cryptodev.c
> b/lib/librte_cryptodev/rte_cryptodev.c
> index 4015872ed..ee76cef07 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.c

...

> +const struct rte_cryptodev_asymmetric_xfrm_capability *

s/xfrm/xform/. Same for the rest of the code.

...

> +int __rte_experimental
> +rte_cryptodev_asym_xfrm_capability_check_modlen(
> +	const struct rte_cryptodev_asymmetric_xfrm_capability *capability,
> +	uint16_t modlen)
> +{
> +	/* handle special case of 0 which means PMD doesn't define
> +	 * any limit
> +	 */
> +	if ((capability->modlen.min != 0) &&
> +		((modlen < capability->modlen.min) ||
> +		(capability->modlen.increment != 0 &&
> +		(modlen % (capability->modlen.increment)))))
> +		return -1;

It is a bit difficult to read this. I think it would be better to separate this if into multiple ones,
making it easier to review. Same with the following one.

> +	if ((capability->modlen.max != 0) &&
> +		((modlen > capability->modlen.max) ||
> +		(capability->modlen.increment != 0 &&
> +		(modlen % (capability->modlen.increment)))))
> +		return -1;
> +
> +	return 0;
> +}
> +
> 
>  const char *
>  rte_cryptodev_get_feature_name(uint64_t flag) diff --git
> a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
> index 623459a95..6c13d23f8 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.h
> +++ b/lib/librte_cryptodev/rte_cryptodev.h

...

> @@ -1164,7 +1265,7 @@ int __rte_experimental
> rte_cryptodev_asym_session_set_private_data(
>  					struct rte_cryptodev_asym_session
> *sess,
>  					void *data,
> -					uint16_t size)
> +					uint16_t size);

Fix this in previous patch.

> 
>  /**
>   * Get private data of a session.
> @@ -1178,7 +1279,7 @@ rte_cryptodev_asym_session_set_private_data(
>   */
>  void * __rte_experimental
>  rte_cryptodev_asym_session_get_private_data(
> -				struct rte_cryptodev_asym_session *sess)
> +				struct rte_cryptodev_asym_session *sess);
> 
> 
>  #ifdef __cplusplus
> diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map
> b/lib/librte_cryptodev/rte_cryptodev_version.map
> index 62b782444..817cf9f70 100644
> --- a/lib/librte_cryptodev/rte_cryptodev_version.map
> +++ b/lib/librte_cryptodev/rte_cryptodev_version.map
> @@ -89,13 +89,18 @@ DPDK_17.11 {
>  EXPERIMENTAL {
>          global:
> 
> -	rte_cryptodev_asym_get_private_session_size
> +	rte_cryptodev_asym_capability_get;
> +	rte_cryptodev_asym_get_private_session_size;
> +	rte_cryptodev_asym_get_xform_enum;
> +	rte_crypto_asym_op_strings;
>  	rte_cryptodev_asym_session_clear;
>  	rte_cryptodev_asym_session_create;
>  	rte_cryptodev_asym_session_free;
>  	rte_cryptodev_asym_session_init;
> -	rte_cryptodev_asym_session_get_private_data
> -	rte_cryptodev_asym_session_set_private_data
> +	rte_cryptodev_asym_session_get_private_data;
> +	rte_cryptodev_asym_session_set_private_data;
> +	rte_cryptodev_asym_xfrm_capability_check_optype;
> +	rte_crypto_asym_xform_strings;

Make sure that list is sorted alphabetically (rte_crypto_* should go at the end).

>  	rte_cryptodev_sym_session_get_private_data;
>  	rte_cryptodev_sym_session_set_private_data;
>  } DPDK_17.11;
> --
> 2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto Shally Verma
@ 2018-06-17 12:52   ` De Lara Guarch, Pablo
  2018-06-17 15:01     ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-17 12:52 UTC (permalink / raw)
  To: Shally Verma
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Hi Shally,

> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
> 
> Add unit test case to test openssl PMD asym crypto
> operations. Test case invoke asymmetric operation on DPDK
> Openssl PMD and cross-verify results via Openssl SW library.
> Tests have been verified with openssl 1.0.2m release.

Is it possible to run these tests without using an external library to verify the results,
like what we do with symmetric crypto? Having known answers in the test vectors?
I am not familiar with asymmetric, that's why I am asking.

Also, you are adding asymmetric support for OpenSSL PMD in the 5th patch,
So this test won't work until then.
I think it is better to change the other between patch 4 and 5.

> 
> Tested for:
> 
> * RSA Encrypt, Decrypt, Sign and Verify using pre-defined
>   test vectors
> * Modular Inversion and Exponentiation using pre-defined
>   test vectors
> * Deiffie-Hellman Public key generation using pre-defined
>   private key and dynamically generated test vectors
> * Deffie-hellman private key generation using dynamically
>   generated test vectors
> * Deffie-hellman private and public key pair generation
>   using xform chain and using dynamically generated test
>   vectors
> * Deffie-hellman shared secret compute using dynamically
>   generated test vectors
> * DSA Sign and Verification
> 
> Deffie-hellman testcases use run-time generated test params,
> thus may take some time for execution.
> 
> Changes from v2:
> - Change test application to use the renamed APIs and
>   to use xform type from capability structure
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> 
> ---
> This patch dependent on asym crypto API patches.
> Please apply them before compilation
> ---
> ---
>  test/test/Makefile              |    3 +-
>  test/test/meson.build           |    1 +
>  test/test/test_cryptodev_asym.c | 1787
> +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 1790 insertions(+), 1 deletion(-)
> 
> diff --git a/test/test/Makefile b/test/test/Makefile
> index d1a75fe92..9526b939d 100644
> --- a/test/test/Makefile
> +++ b/test/test/Makefile
> @@ -179,6 +179,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_RING) +=
> test_pmd_ring_perf.c
> 
>  SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_blockcipher.c
>  SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev.c
> +SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += test_cryptodev_asym.c
> 
>  ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
>  SRCS-$(CONFIG_RTE_LIBRTE_COMPRESSDEV) += test_compressdev.c
> @@ -205,7 +206,7 @@ CFLAGS += $(WERROR_FLAGS)
> 
>  CFLAGS += -D_GNU_SOURCE
> 
> -LDLIBS += -lm
> +LDLIBS += -lm -lcrypto

If openssl libcrypto is actually required, I would add a check similar to
the one just below, with compressdev, to add "-lcrypto", so
users can run the test app without this, if they don't want to test asymmetric.

>  ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
>  ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
>  LDLIBS += -lz

..

> +++ b/test/test/test_cryptodev_asym.c
> @@ -0,0 +1,1787 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2017-2018 Cavium Networks
> + */
> +
> +#include <rte_common.h>
> +#include <rte_hexdump.h>
> +#include <rte_mbuf.h>
> +#include <rte_malloc.h>
> +#include <rte_memcpy.h>
> +#include <rte_pause.h>
> +#include <rte_bus_vdev.h>
> +
> +#include <rte_crypto.h>
> +#include <rte_cryptodev.h>
> +#include <rte_cryptodev_pmd.h>
> +#include <openssl/ssl.h>

Move this to the top of the file (as it is an external library to DPDK).

> +
> +#include "test.h"
> +#include "test_cryptodev.h"

...

> +/** rsa xform using exponent key */
> +struct rte_crypto_asym_xform rsa_xform = {
> +	.next = NULL,
> +	.xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
> +	.rsa = {
> +		.n = {
> +		.data =
> +		(uint8_t *)
> +

For better consistency, could you use the format used above (0x00, 0xB3, 0xA1...)?

> 	("\x00\xb3\xa1\xaf\xb7\x13\x08\x00\x0a\x35\xdc\x2b\x20\x8d"

...

> +#pragma GCC diagnostic pop
> +
> +static int
> +test_rsa(struct rsa_test_data *t)

...

> +	rsa->n =
> +		BN_bin2bn(
> +			(const unsigned char *)rsa_xform.rsa.n.data,
> +			rsa_xform.rsa.n.length,
> +			rsa->n);

I am getting a compilation error:

/test/test/test_cryptodev_asym.c:322:5: error:
dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
  rsa->n =
     ^~

My OpenSSL version is 1.1.0h.

Thanks,
Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support Shally Verma
@ 2018-06-17 13:25   ` De Lara Guarch, Pablo
  2018-06-17 15:48     ` Verma, Shally
  2018-06-26  9:23   ` De Lara Guarch, Pablo
  2018-07-03 14:50   ` Trahe, Fiona
  2 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-17 13:25 UTC (permalink / raw)
  To: Shally Verma
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta



> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> 
> Add asymmetric crypto operation support in openssl PMD.
> Current list of supported asym xforms:
> * RSA
> * DSA
> * Deffie-hellman
> * Modular Operations
> 
> changes from v2:
> - Update the pmd capability as per new capability structure
> 
> changes from v1:
> - resolve new line error in dod/guides/cryptodevs/openssl.rst
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> ---
>  doc/guides/cryptodevs/features/openssl.ini       |  11 +
>  doc/guides/cryptodevs/openssl.rst                |   1 +
>  drivers/crypto/openssl/rte_openssl_pmd.c         | 377 ++++++++++++++++++++-
>  drivers/crypto/openssl/rte_openssl_pmd_ops.c     | 395
> ++++++++++++++++++++++-
>  drivers/crypto/openssl/rte_openssl_pmd_private.h |  29 ++
>  5 files changed, 801 insertions(+), 12 deletions(-)
> 
> diff --git a/doc/guides/cryptodevs/features/openssl.ini
> b/doc/guides/cryptodevs/features/openssl.ini
> index 691565865..bef5c7f79 100644
> --- a/doc/guides/cryptodevs/features/openssl.ini
> +++ b/doc/guides/cryptodevs/features/openssl.ini
> @@ -7,6 +7,7 @@
>  Symmetric crypto       = Y
>  Sym operation chaining = Y
>  Mbuf scatter gather    = Y
> +Asymmetric crypto	   = Y
> 
>  ;
>  ; Supported crypto algorithms of the 'openssl' crypto driver.
> @@ -49,3 +50,13 @@ AES GCM (256) = Y
>  AES CCM (128) = Y
>  AES CCM (192) = Y
>  AES CCM (256) = Y
> +
> +;
> +; Supported Asymmetric algorithms of the 'openssl' crypto driver.
> +;
> +[Asymmetric]
> +RSA = Y
> +DSA = Y
> +Modular Exponentiation = Y
> +Modular Inversion = Y
> +Deffie-hellman = Y

You need to add these parameters in default.ini file,
otherwise they are not shown when building the documentation.

> diff --git a/doc/guides/cryptodevs/openssl.rst
> b/doc/guides/cryptodevs/openssl.rst
> index 427fc807c..4f90be888 100644
> --- a/doc/guides/cryptodevs/openssl.rst
> +++ b/doc/guides/cryptodevs/openssl.rst
> @@ -80,6 +80,7 @@ crypto processing.
> 
>  Test name is cryptodev_openssl_autotest.
>  For performance test cryptodev_openssl_perftest can be used.
> +For asymmetric crypto operations testing, run
> +cryptodev_openssl_asym_autotest
> 
>  To verify real traffic l2fwd-crypto example can be used with this command:
> 
> diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c
> b/drivers/crypto/openssl/rte_openssl_pmd.c
> index f584d0d6f..527e42773 100644
> --- a/drivers/crypto/openssl/rte_openssl_pmd.c
> +++ b/drivers/crypto/openssl/rte_openssl_pmd.c

...

> +		}
> +		dh_key->priv_key = BN_bin2bn(op->priv_key.data,
> +					     op->priv_key.length,
> +					     dh_key->priv_key);

As on the previous patch, I am getting a compilation issue:

drivers/crypto/openssl/rte_openssl_pmd.c:1711:9: error:
dereferencing pointer to incomplete type 'DH {aka struct dh_st}'
   dh_key->priv_key = BN_bin2bn(op->priv_key.data,

...

> diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
> b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
> index 1cb87d59a..76f7410cb 100644
> --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
> +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c

...

>  struct rte_cryptodev_ops openssl_pmd_ops = {
>  		.dev_configure		= openssl_pmd_config,
>  		.dev_start		= openssl_pmd_start,
> @@ -750,8 +1138,11 @@ struct rte_cryptodev_ops openssl_pmd_ops = {
>  		.queue_pair_count	= openssl_pmd_qp_count,
> 
>  		.session_get_size	= openssl_pmd_session_get_size,
> +		.asym_session_get_size	=
> openssl_pmd_asym_session_get_size,
>  		.session_configure	= openssl_pmd_session_configure,
> -		.session_clear		= openssl_pmd_session_clear
> +		.asym_session_configure	=
> openssl_pmd_asym_session_configure,
> +		.session_clear		= openssl_pmd_session_clear,
> +		.asym_session_clear	= openssl_pmd_asym_session_clear
>  };

I think session_get_size, session_configure and session_clear should be renamed
to sym_session_*, to avoid confusion. Could you add another patch renaming these?

Thanks,
Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide Shally Verma
  2018-06-14 10:43   ` Kovacevic, Marko
@ 2018-06-17 13:33   ` De Lara Guarch, Pablo
  2018-06-17 16:59     ` Verma, Shally
  1 sibling, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-17 13:33 UTC (permalink / raw)
  To: Shally Verma
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Hi Shally,

> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
> 
> Update cryptodev programmer guide with description of asymmetric crypto
> framework in lib cryptodev.
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> ---
>  doc/guides/prog_guide/cryptodev_lib.rst | 338

...

> +
> +
> +Asymmetric crypto Sample code
> +-----------------------------

Could you change the previous section "crypto sample code" to 
"Symmetric crypto sample code", for more clarification?

...

> -Crypto Device API
> -~~~~~~~~~~~~~~~~~
> +Asymmetric Crypto Device API
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is not specific to Asymmetric, so the name should remained "Crypto Device API",
In a different section (so change "~" to "-").

> 
>  The cryptodev Library API is described in the *DPDK API Reference* document.
> --
> 2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-06-17 12:52   ` De Lara Guarch, Pablo
@ 2018-06-17 15:01     ` Verma, Shally
  2018-06-17 19:31       ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-06-17 15:01 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Hi Pablo

>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 17 June 2018 18:23
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
>
>External Email
>
>Hi Shally,
>
>> -----Original Message-----
>> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
>> Sent: Wednesday, May 16, 2018 7:05 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
>> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
>> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
>> <ashish.gupta@caviumnetworks.com>
>> Subject: [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
>>
>> Add unit test case to test openssl PMD asym crypto
>> operations. Test case invoke asymmetric operation on DPDK
>> Openssl PMD and cross-verify results via Openssl SW library.
>> Tests have been verified with openssl 1.0.2m release.
>
>Is it possible to run these tests without using an external library to verify the results,
>like what we do with symmetric crypto? Having known answers in the test vectors?
>I am not familiar with asymmetric, that's why I am asking.
>
[Shally] I prefer to have it cross verified using an independent library module, that's the reason I kept design that way.

>Also, you are adding asymmetric support for OpenSSL PMD in the 5th patch,
>So this test won't work until then.
>I think it is better to change the other between patch 4 and 5.
[Shally] Ok

>
>>

//snip

>>
>> -LDLIBS += -lm
>> +LDLIBS += -lm -lcrypto
>
>If openssl libcrypto is actually required, I would add a check similar to
>the one just below, with compressdev, to add "-lcrypto", so
>users can run the test app without this, if they don't want to test asymmetric.
>
>>  ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
>>  ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
>>  LDLIBS += -lz
>
[Shally] You mean add another config option for Asymmetric test?

>..
>

//snip

>> +#include <rte_crypto.h>
>> +#include <rte_cryptodev.h>
>> +#include <rte_cryptodev_pmd.h>
>> +#include <openssl/ssl.h>
>
>Move this to the top of the file (as it is an external library to DPDK).
>
[Shally] Ok

>> +
>> +#include "test.h"
>> +#include "test_cryptodev.h"
>
>...
>
>> +/** rsa xform using exponent key */
>> +struct rte_crypto_asym_xform rsa_xform = {
>> +     .next = NULL,
>> +     .xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
>> +     .rsa = {
>> +             .n = {
>> +             .data =
>> +             (uint8_t *)
>> +
>
>For better consistency, could you use the format used above (0x00, 0xB3, 0xA1...)?
>
>>       ("\x00\xb3\xa1\xaf\xb7\x13\x08\x00\x0a\x35\xdc\x2b\x20\x8d"
[Shally] Ok. 

>
>...
>
>> +#pragma GCC diagnostic pop
>> +
>> +static int
>> +test_rsa(struct rsa_test_data *t)
>
>...
>
>> +     rsa->n =
>> +             BN_bin2bn(
>> +                     (const unsigned char *)rsa_xform.rsa.n.data,
>> +                     rsa_xform.rsa.n.length,
>> +                     rsa->n);
>
>I am getting a compilation error:
>
>/test/test/test_cryptodev_asym.c:322:5: error:
>dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
>  rsa->n =
>     ^~
>
>My OpenSSL version is 1.1.0h.
>
[Shally] This library is tested with version 1.0.2m (mentioned above) and also one supported by openssl PMD . So, you need to take similar version.

Thanks for review.
Shally

>Thanks,
>Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-06-17 13:25   ` De Lara Guarch, Pablo
@ 2018-06-17 15:48     ` Verma, Shally
  2018-06-17 19:38       ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-06-17 15:48 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Hi Pablo

>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 17 June 2018 18:55
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
>
>External Email
>
>> -----Original Message-----
>> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
>> Sent: Wednesday, May 16, 2018 7:05 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
>> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
>> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
>> <ashish.gupta@caviumnetworks.com>
>> Subject: [PATCH v3 5/6] crypto/openssl: add asym crypto support
>>
>> Add asymmetric crypto operation support in openssl PMD.
>> Current list of supported asym xforms:
>> * RSA
>> * DSA
>> * Deffie-hellman
>> * Modular Operations
>>
>> changes from v2:
>> - Update the pmd capability as per new capability structure
>>
>> changes from v1:
>> - resolve new line error in dod/guides/cryptodevs/openssl.rst
>>
>> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
>> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
>> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
>> ---
.. [snip] ..

>> +;
>> +; Supported Asymmetric algorithms of the 'openssl' crypto driver.
>> +;
>> +[Asymmetric]
>> +RSA = Y
>> +DSA = Y
>> +Modular Exponentiation = Y
>> +Modular Inversion = Y
>> +Deffie-hellman = Y
>
>You need to add these parameters in default.ini file,
>otherwise they are not shown when building the documentation.
>
[Shally] Ok

..[snip]..

>>
>> diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c
>> b/drivers/crypto/openssl/rte_openssl_pmd.c
>> index f584d0d6f..527e42773 100644
>> --- a/drivers/crypto/openssl/rte_openssl_pmd.c
>> +++ b/drivers/crypto/openssl/rte_openssl_pmd.c
>
>...
>
>> +             }
>> +             dh_key->priv_key = BN_bin2bn(op->priv_key.data,
>> +                                          op->priv_key.length,
>> +                                          dh_key->priv_key);
>
>As on the previous patch, I am getting a compilation issue:
>
>drivers/crypto/openssl/rte_openssl_pmd.c:1711:9: error:
>dereferencing pointer to incomplete type 'DH {aka struct dh_st}'
>   dh_key->priv_key = BN_bin2bn(op->priv_key.data,
>
[Shally] as  I mentioned before Openssl PMD support 1.0.2 version series(http://doc.dpdk.org/guides/cryptodevs/openssl.html) and thus the error 

>...
>
>> diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
>> b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
>> index 1cb87d59a..76f7410cb 100644
>> --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
>> +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
>
>...
>
>>  struct rte_cryptodev_ops openssl_pmd_ops = {
>>               .dev_configure          = openssl_pmd_config,
>>               .dev_start              = openssl_pmd_start,
>> @@ -750,8 +1138,11 @@ struct rte_cryptodev_ops openssl_pmd_ops = {
>>               .queue_pair_count       = openssl_pmd_qp_count,
>>
>>               .session_get_size       = openssl_pmd_session_get_size,
>> +             .asym_session_get_size  =
>> openssl_pmd_asym_session_get_size,
>>               .session_configure      = openssl_pmd_session_configure,
>> -             .session_clear          = openssl_pmd_session_clear
>> +             .asym_session_configure =
>> openssl_pmd_asym_session_configure,
>> +             .session_clear          = openssl_pmd_session_clear,
>> +             .asym_session_clear     = openssl_pmd_asym_session_clear
>>  };
>
>I think session_get_size, session_configure and session_clear should be renamed
>to sym_session_*, to avoid confusion. Could you add another patch renaming these?
>
[Shally] I see in latest cryptodev these typedefs are already named to 
cryptodev_sym_configure_session_t, _sym_get_session_private_size_t and _sym_free_.. so these changes would come while rebase.
or you are referring to change openssl_pmd_session_configure to openssl_pmd_sym_session_configure and so others?

Thanks for review.

>Thanks,
>Pablo
>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
  2018-06-17 13:33   ` De Lara Guarch, Pablo
@ 2018-06-17 16:59     ` Verma, Shally
  0 siblings, 0 replies; 44+ messages in thread
From: Verma, Shally @ 2018-06-17 16:59 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

HI Pablo

>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 17 June 2018 19:03
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
>
>External Email
>
>Hi Shally,
>
>> -----Original Message-----
>> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
>> Sent: Wednesday, May 16, 2018 7:05 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
>> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
>> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
>> <ashish.gupta@caviumnetworks.com>
>> Subject: [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide
>>

//snip 

>>  doc/guides/prog_guide/cryptodev_lib.rst | 338
>
>...
>
>> +
>> +
>> +Asymmetric crypto Sample code
>> +-----------------------------
>
>Could you change the previous section "crypto sample code" to
>"Symmetric crypto sample code", for more clarification?
>
[Shally] Will do.

>...
>
>> -Crypto Device API
>> -~~~~~~~~~~~~~~~~~
>> +Asymmetric Crypto Device API
>> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>This is not specific to Asymmetric, so the name should remained "Crypto Device API",
>In a different section (so change "~" to "-").
>
[Shally] Wil do.

Thanks for review.
Shally

>>
>>  The cryptodev Library API is described in the *DPDK API Reference* document.
>> --
>> 2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-06-17 15:01     ` Verma, Shally
@ 2018-06-17 19:31       ` De Lara Guarch, Pablo
  2018-06-18  5:40         ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-17 19:31 UTC (permalink / raw)
  To: Verma, Shally
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish



> -----Original Message-----
> From: Verma, Shally [mailto:Shally.Verma@cavium.com]
> Sent: Sunday, June 17, 2018 4:01 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; Athreya, Narayana Prasad
> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> Subject: RE: [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
> 
> Hi Pablo
> 
> >-----Original Message-----
> >From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
> >Sent: 17 June 2018 18:23
> >To: Verma, Shally <Shally.Verma@cavium.com>
> >Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> >dev@dpdk.org; Athreya, Narayana Prasad
> ><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> ><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> >Subject: RE: [PATCH v3 4/6] test/crypto: add unit testcase for asym
> >crypto
> >
> >External Email
> >
> >Hi Shally,
> >
> >> -----Original Message-----
> >> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> >> Sent: Wednesday, May 16, 2018 7:05 AM
> >> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> >> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> >> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> >> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> >> <ashish.gupta@caviumnetworks.com>
> >> Subject: [PATCH v3 4/6] test/crypto: add unit testcase for asym
> >> crypto
> >>
> >> Add unit test case to test openssl PMD asym crypto operations. Test
> >> case invoke asymmetric operation on DPDK Openssl PMD and cross-verify
> >> results via Openssl SW library.
> >> Tests have been verified with openssl 1.0.2m release.
> >
> >Is it possible to run these tests without using an external library to
> >verify the results, like what we do with symmetric crypto? Having known
> answers in the test vectors?
> >I am not familiar with asymmetric, that's why I am asking.
> >
> [Shally] I prefer to have it cross verified using an independent library module,
> that's the reason I kept design that way.
> 
> >Also, you are adding asymmetric support for OpenSSL PMD in the 5th
> >patch, So this test won't work until then.
> >I think it is better to change the other between patch 4 and 5.
> [Shally] Ok
> 
> >
> >>
> 
> //snip
> 
> >>
> >> -LDLIBS += -lm
> >> +LDLIBS += -lm -lcrypto
> >
> >If openssl libcrypto is actually required, I would add a check similar
> >to the one just below, with compressdev, to add "-lcrypto", so users
> >can run the test app without this, if they don't want to test asymmetric.
> >
> >>  ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
> >>  ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
> >>  LDLIBS += -lz
> >
> [Shally] You mean add another config option for Asymmetric test?

At least check for CRYPTODEV, but since this is enabled by default,
I think we need an RTE_CRYPTODEV_ASYM_TEST flag.

> 
> >..
> >
> 
> //snip
> 
> >> +#include <rte_crypto.h>
> >> +#include <rte_cryptodev.h>
> >> +#include <rte_cryptodev_pmd.h>
> >> +#include <openssl/ssl.h>
> >
> >Move this to the top of the file (as it is an external library to DPDK).
> >
> [Shally] Ok
> 
> >> +
> >> +#include "test.h"
> >> +#include "test_cryptodev.h"
> >
> >...
> >
> >> +/** rsa xform using exponent key */
> >> +struct rte_crypto_asym_xform rsa_xform = {
> >> +     .next = NULL,
> >> +     .xform_type = RTE_CRYPTO_ASYM_XFORM_RSA,
> >> +     .rsa = {
> >> +             .n = {
> >> +             .data =
> >> +             (uint8_t *)
> >> +
> >
> >For better consistency, could you use the format used above (0x00, 0xB3,
> 0xA1...)?
> >
> >>       ("\x00\xb3\xa1\xaf\xb7\x13\x08\x00\x0a\x35\xdc\x2b\x20\x8d"
> [Shally] Ok.
> 
> >
> >...
> >
> >> +#pragma GCC diagnostic pop
> >> +
> >> +static int
> >> +test_rsa(struct rsa_test_data *t)
> >
> >...
> >
> >> +     rsa->n =
> >> +             BN_bin2bn(
> >> +                     (const unsigned char *)rsa_xform.rsa.n.data,
> >> +                     rsa_xform.rsa.n.length,
> >> +                     rsa->n);
> >
> >I am getting a compilation error:
> >
> >/test/test/test_cryptodev_asym.c:322:5: error:
> >dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
> >  rsa->n =
> >     ^~
> >
> >My OpenSSL version is 1.1.0h.
> >
> [Shally] This library is tested with version 1.0.2m (mentioned above) and also
> one supported by openssl PMD . So, you need to take similar version.

I'd say we should support the latest stable version of OpenSSL.
Could you get the latest 1.1.0?

Thanks,
Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-06-17 15:48     ` Verma, Shally
@ 2018-06-17 19:38       ` De Lara Guarch, Pablo
  2018-06-18  5:30         ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-17 19:38 UTC (permalink / raw)
  To: Verma, Shally
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish



> -----Original Message-----
> From: Verma, Shally [mailto:Shally.Verma@cavium.com]
> Sent: Sunday, June 17, 2018 4:48 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; Athreya, Narayana Prasad
> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> 
> Hi Pablo
> 
> >-----Original Message-----
> >From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
> >Sent: 17 June 2018 18:55
> >To: Verma, Shally <Shally.Verma@cavium.com>
> >Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> >dev@dpdk.org; Athreya, Narayana Prasad
> ><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> ><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> >Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> >
> >External Email
> >
> >> -----Original Message-----
> >> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> >> Sent: Wednesday, May 16, 2018 7:05 AM
> >> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> >> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> >> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> >> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> >> <ashish.gupta@caviumnetworks.com>
> >> Subject: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> >>
> >> Add asymmetric crypto operation support in openssl PMD.
> >> Current list of supported asym xforms:
> >> * RSA
> >> * DSA
> >> * Deffie-hellman
> >> * Modular Operations
> >>
> >> changes from v2:
> >> - Update the pmd capability as per new capability structure
> >>
> >> changes from v1:
> >> - resolve new line error in dod/guides/cryptodevs/openssl.rst
> >>
> >> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> >> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> >> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> >> ---
> .. [snip] ..
> 
> >> +;
> >> +; Supported Asymmetric algorithms of the 'openssl' crypto driver.
> >> +;
> >> +[Asymmetric]
> >> +RSA = Y
> >> +DSA = Y
> >> +Modular Exponentiation = Y
> >> +Modular Inversion = Y
> >> +Deffie-hellman = Y
> >
> >You need to add these parameters in default.ini file, otherwise they
> >are not shown when building the documentation.
> >
> [Shally] Ok
> 
> ..[snip]..
> 
> >>
> >> diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c
> >> b/drivers/crypto/openssl/rte_openssl_pmd.c
> >> index f584d0d6f..527e42773 100644
> >> --- a/drivers/crypto/openssl/rte_openssl_pmd.c
> >> +++ b/drivers/crypto/openssl/rte_openssl_pmd.c
> >
> >...
> >
> >> +             }
> >> +             dh_key->priv_key = BN_bin2bn(op->priv_key.data,
> >> +                                          op->priv_key.length,
> >> +                                          dh_key->priv_key);
> >
> >As on the previous patch, I am getting a compilation issue:
> >
> >drivers/crypto/openssl/rte_openssl_pmd.c:1711:9: error:
> >dereferencing pointer to incomplete type 'DH {aka struct dh_st}'
> >   dh_key->priv_key = BN_bin2bn(op->priv_key.data,
> >
> [Shally] as  I mentioned before Openssl PMD support 1.0.2 version
> series(http://doc.dpdk.org/guides/cryptodevs/openssl.html) and thus the error
> 
> >...
> >
> >> diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
> >> b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
> >> index 1cb87d59a..76f7410cb 100644
> >> --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
> >> +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
> >
> >...
> >
> >>  struct rte_cryptodev_ops openssl_pmd_ops = {
> >>               .dev_configure          = openssl_pmd_config,
> >>               .dev_start              = openssl_pmd_start,
> >> @@ -750,8 +1138,11 @@ struct rte_cryptodev_ops openssl_pmd_ops = {
> >>               .queue_pair_count       = openssl_pmd_qp_count,
> >>
> >>               .session_get_size       = openssl_pmd_session_get_size,
> >> +             .asym_session_get_size  =
> >> openssl_pmd_asym_session_get_size,
> >>               .session_configure      = openssl_pmd_session_configure,
> >> -             .session_clear          = openssl_pmd_session_clear
> >> +             .asym_session_configure =
> >> openssl_pmd_asym_session_configure,
> >> +             .session_clear          = openssl_pmd_session_clear,
> >> +             .asym_session_clear     = openssl_pmd_asym_session_clear
> >>  };
> >
> >I think session_get_size, session_configure and session_clear should be
> >renamed to sym_session_*, to avoid confusion. Could you add another patch
> renaming these?
> >
> [Shally] I see in latest cryptodev these typedefs are already named to
> cryptodev_sym_configure_session_t, _sym_get_session_private_size_t and
> _sym_free_.. so these changes would come while rebase.
> or you are referring to change openssl_pmd_session_configure to
> openssl_pmd_sym_session_configure and so others?

Yes, but the name is still session_configure/clear, not sym_session_configure/clear, right?
And also, I think we should rename the OpenSSL functions, openssl_pmd_session_*,
to openssl_pmd_sym_session_*.

Pablo

> 
> Thanks for review.
> 
> >Thanks,
> >Pablo
> >

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-06-17 19:38       ` De Lara Guarch, Pablo
@ 2018-06-18  5:30         ` Verma, Shally
  2018-06-23 12:41           ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-06-18  5:30 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Hi Pablo

>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 18 June 2018 01:09
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
>
>External Email
>

//snip

>> >>  struct rte_cryptodev_ops openssl_pmd_ops = {
>> >>               .dev_configure          = openssl_pmd_config,
>> >>               .dev_start              = openssl_pmd_start,
>> >> @@ -750,8 +1138,11 @@ struct rte_cryptodev_ops openssl_pmd_ops = {
>> >>               .queue_pair_count       = openssl_pmd_qp_count,
>> >>
>> >>               .session_get_size       = openssl_pmd_session_get_size,
>> >> +             .asym_session_get_size  =
>> >> openssl_pmd_asym_session_get_size,
>> >>               .session_configure      = openssl_pmd_session_configure,
>> >> -             .session_clear          = openssl_pmd_session_clear
>> >> +             .asym_session_configure =
>> >> openssl_pmd_asym_session_configure,
>> >> +             .session_clear          = openssl_pmd_session_clear,
>> >> +             .asym_session_clear     = openssl_pmd_asym_session_clear
>> >>  };
>> >
>> >I think session_get_size, session_configure and session_clear should be
>> >renamed to sym_session_*, to avoid confusion. Could you add another patch
>> renaming these?
>> >
>> [Shally] I see in latest cryptodev these typedefs are already named to
>> cryptodev_sym_configure_session_t, _sym_get_session_private_size_t and
>> _sym_free_.. so these changes would come while rebase.
>> or you are referring to change openssl_pmd_session_configure to
>> openssl_pmd_sym_session_configure and so others?
>
>Yes, but the name is still session_configure/clear, not sym_session_configure/clear, right?
>And also, I think we should rename the OpenSSL functions, openssl_pmd_session_*,
>to openssl_pmd_sym_session_*.
>
[Shally] Ok. I will look into this.

Thanks
Shally

>Pablo
>
>>
>> Thanks for review.
>>
>> >Thanks,
>> >Pablo
>> >

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-06-17 19:31       ` De Lara Guarch, Pablo
@ 2018-06-18  5:40         ` Verma, Shally
  2018-06-18  6:39           ` Akhil Goyal
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-06-18  5:40 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Hi Pablo

>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 18 June 2018 01:01
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
>
>External Email
>
//snip 

>> >>  ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
>> >>  ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
>> >>  LDLIBS += -lz
>> >
>> [Shally] You mean add another config option for Asymmetric test?
>
>At least check for CRYPTODEV, but since this is enabled by default,
>I think we need an RTE_CRYPTODEV_ASYM_TEST flag.

[Shally] OK. Will look into this.

>
>>
>> >..

//snip

>> >> +#pragma GCC diagnostic pop
>> >> +
>> >> +static int
>> >> +test_rsa(struct rsa_test_data *t)
>> >
>> >...
>> >
>> >> +     rsa->n =
>> >> +             BN_bin2bn(
>> >> +                     (const unsigned char *)rsa_xform.rsa.n.data,
>> >> +                     rsa_xform.rsa.n.length,
>> >> +                     rsa->n);
>> >
>> >I am getting a compilation error:
>> >
>> >/test/test/test_cryptodev_asym.c:322:5: error:
>> >dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
>> >  rsa->n =
>> >     ^~
>> >
>> >My OpenSSL version is 1.1.0h.
>> >
>> [Shally] This library is tested with version 1.0.2m (mentioned above) and also
>> one supported by openssl PMD . So, you need to take similar version.
>
>I'd say we should support the latest stable version of OpenSSL.
>Could you get the latest 1.1.0?
[Shally] Openssl PMD uses 1.0.2h. If we move test to 1.1.0 then dpdk would need to be set
to link to two different version of libcrypto whenever openssl PMD is enabled which seems like a cumbersome process for users.
So I recommend for now to stick to one version.

Thanks
Shally

>
>Thanks,
>Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-06-18  5:40         ` Verma, Shally
@ 2018-06-18  6:39           ` Akhil Goyal
  2018-06-18  6:48             ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: Akhil Goyal @ 2018-06-18  6:39 UTC (permalink / raw)
  To: Verma, Shally, De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Hi Shally,
On 6/18/2018 11:10 AM, Verma, Shally wrote:
> Hi Pablo
>
>> -----Original Message-----
>> From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>> Sent: 18 June 2018 01:01
>> To: Verma, Shally <Shally.Verma@cavium.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
>> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>> Subject: RE: [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
>>
>> External Email
>>
> //snip
>
>>>>>  ifeq ($(CONFIG_RTE_COMPRESSDEV_TEST),y)
>>>>>  ifeq ($(CONFIG_RTE_LIBRTE_COMPRESSDEV),y)
>>>>>  LDLIBS += -lz
>>>>
>>> [Shally] You mean add another config option for Asymmetric test?
>>
>> At least check for CRYPTODEV, but since this is enabled by default,
>> I think we need an RTE_CRYPTODEV_ASYM_TEST flag.
>
> [Shally] OK. Will look into this.
>
>>
>>>
>>>> ..
>
> //snip
>
>>>>> +#pragma GCC diagnostic pop
>>>>> +
>>>>> +static int
>>>>> +test_rsa(struct rsa_test_data *t)
>>>>
>>>> ...
>>>>
>>>>> +     rsa->n =
>>>>> +             BN_bin2bn(
>>>>> +                     (const unsigned char *)rsa_xform.rsa.n.data,
>>>>> +                     rsa_xform.rsa.n.length,
>>>>> +                     rsa->n);
>>>>
>>>> I am getting a compilation error:
>>>>
>>>> /test/test/test_cryptodev_asym.c:322:5: error:
>>>> dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
>>>>  rsa->n =
>>>>     ^~
>>>>
>>>> My OpenSSL version is 1.1.0h.
>>>>
>>> [Shally] This library is tested with version 1.0.2m (mentioned above) and also
>>> one supported by openssl PMD . So, you need to take similar version.
>>
>> I'd say we should support the latest stable version of OpenSSL.
>> Could you get the latest 1.1.0?
> [Shally] Openssl PMD uses 1.0.2h. If we move test to 1.1.0 then dpdk would need to be set
> to link to two different version of libcrypto whenever openssl PMD is enabled which seems like a cumbersome process for users.
> So I recommend for now to stick to one version.
>

OpenSSL PMD can get compiled/linked with any of the versions 1.0.2 or 
1.1. We cannot control the above applications which version it is using. 
So we should not add limitation for openssl version. Please check below 
snippet in the PMD if this is suitable in your case.

+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
+static HMAC_CTX *HMAC_CTX_new(void)
+{
+       HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
+
+       if (ctx != NULL)
+               HMAC_CTX_init(ctx);
+       return ctx;
+}
+
+static void HMAC_CTX_free(HMAC_CTX *ctx)
+{
+       if (ctx != NULL) {
+               HMAC_CTX_cleanup(ctx);
+               OPENSSL_free(ctx);
+       }
+}
+#endif


> Thanks
> Shally
>
>>
>> Thanks,
>> Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-06-18  6:39           ` Akhil Goyal
@ 2018-06-18  6:48             ` Verma, Shally
  2018-06-18  7:34               ` Akhil Goyal
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-06-18  6:48 UTC (permalink / raw)
  To: Akhil Goyal, De Lara Guarch, Pablo
  Cc: Trahe, Fiona, dev, Athreya, Narayana Prasad, Sahu, Sunila, Gupta, Ashish

Hi

>-----Original Message-----
>From: Akhil Goyal [mailto:akhil.goyal@nxp.com]
>Sent: 18 June 2018 12:10
>To: Verma, Shally <Shally.Verma@cavium.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
>

//snip

>>>>>> +static int
>>>>>> +test_rsa(struct rsa_test_data *t)
>>>>>
>>>>> ...
>>>>>
>>>>>> +     rsa->n =
>>>>>> +             BN_bin2bn(
>>>>>> +                     (const unsigned char *)rsa_xform.rsa.n.data,
>>>>>> +                     rsa_xform.rsa.n.length,
>>>>>> +                     rsa->n);
>>>>>
>>>>> I am getting a compilation error:
>>>>>
>>>>> /test/test/test_cryptodev_asym.c:322:5: error:
>>>>> dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
>>>>>  rsa->n =
>>>>>     ^~
>>>>>
>>>>> My OpenSSL version is 1.1.0h.
>>>>>
>>>> [Shally] This library is tested with version 1.0.2m (mentioned above) and also
>>>> one supported by openssl PMD . So, you need to take similar version.
>>>
>>> I'd say we should support the latest stable version of OpenSSL.
>>> Could you get the latest 1.1.0?
>> [Shally] Openssl PMD uses 1.0.2h. If we move test to 1.1.0 then dpdk would need to be set
>> to link to two different version of libcrypto whenever openssl PMD is enabled which seems like a cumbersome process for users.
>> So I recommend for now to stick to one version.
>>
>
>OpenSSL PMD can get compiled/linked with any of the versions 1.0.2 or
>1.1. We cannot control the above applications which version it is using.
>So we should not add limitation for openssl version. Please check below
>snippet in the PMD if this is suitable in your case.
>
>+#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
>+static HMAC_CTX *HMAC_CTX_new(void)
>+{
>+       HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
>+
>+       if (ctx != NULL)
>+               HMAC_CTX_init(ctx);
>+       return ctx;
>+}
>+
>+static void HMAC_CTX_free(HMAC_CTX *ctx)
>+{
>+       if (ctx != NULL) {
>+               HMAC_CTX_cleanup(ctx);
>+               OPENSSL_free(ctx);
>+       }
>+}
>+#endif
>
[Shally] Are we just planning to make PMD/test compatible for all lib versions? Won't it then be too many version compatibility checks in PMD/test and a maintainability issue than having implementation mentioned to be compatible with specific version?

>
>> Thanks
>> Shally
>>
>>>
>>> Thanks,
>>> Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-06-18  6:48             ` Verma, Shally
@ 2018-06-18  7:34               ` Akhil Goyal
  2018-06-18  8:38                 ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 44+ messages in thread
From: Akhil Goyal @ 2018-06-18  7:34 UTC (permalink / raw)
  To: Verma, Shally, Akhil Goyal, De Lara Guarch, Pablo
  Cc: Trahe, Fiona, dev, Athreya, Narayana Prasad, Sahu, Sunila, Gupta, Ashish

Hi Shally,
On 6/18/2018 12:18 PM, Verma, Shally wrote:
> Hi
>
>> -----Original Message-----
>> From: Akhil Goyal [mailto:akhil.goyal@nxp.com]
>> Sent: 18 June 2018 12:10
>> To: Verma, Shally <Shally.Verma@cavium.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
>> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>> Subject: Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
>>
>
> //snip
>
>>>>>>> +static int
>>>>>>> +test_rsa(struct rsa_test_data *t)
>>>>>>
>>>>>> ...
>>>>>>
>>>>>>> +     rsa->n =
>>>>>>> +             BN_bin2bn(
>>>>>>> +                     (const unsigned char *)rsa_xform.rsa.n.data,
>>>>>>> +                     rsa_xform.rsa.n.length,
>>>>>>> +                     rsa->n);
>>>>>>
>>>>>> I am getting a compilation error:
>>>>>>
>>>>>> /test/test/test_cryptodev_asym.c:322:5: error:
>>>>>> dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
>>>>>>  rsa->n =
>>>>>>     ^~
>>>>>>
>>>>>> My OpenSSL version is 1.1.0h.
>>>>>>
>>>>> [Shally] This library is tested with version 1.0.2m (mentioned above) and also
>>>>> one supported by openssl PMD . So, you need to take similar version.
>>>>
>>>> I'd say we should support the latest stable version of OpenSSL.
>>>> Could you get the latest 1.1.0?
>>> [Shally] Openssl PMD uses 1.0.2h. If we move test to 1.1.0 then dpdk would need to be set
>>> to link to two different version of libcrypto whenever openssl PMD is enabled which seems like a cumbersome process for users.
>>> So I recommend for now to stick to one version.
>>>
>>
>> OpenSSL PMD can get compiled/linked with any of the versions 1.0.2 or
>> 1.1. We cannot control the above applications which version it is using.
>> So we should not add limitation for openssl version. Please check below
>> snippet in the PMD if this is suitable in your case.
>>
>> +#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
>> +static HMAC_CTX *HMAC_CTX_new(void)
>> +{
>> +       HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
>> +
>> +       if (ctx != NULL)
>> +               HMAC_CTX_init(ctx);
>> +       return ctx;
>> +}
>> +
>> +static void HMAC_CTX_free(HMAC_CTX *ctx)
>> +{
>> +       if (ctx != NULL) {
>> +               HMAC_CTX_cleanup(ctx);
>> +               OPENSSL_free(ctx);
>> +       }
>> +}
>> +#endif
>>
> [Shally] Are we just planning to make PMD/test compatible for all lib versions? Won't it then be too many version compatibility checks in PMD/test and a maintainability issue than having implementation mentioned to be compatible with specific version?
>

I think we should at least support the latest stable version. As per the 
openssl website "The latest stable version is the 1.1.0 series. The 
1.0.2 series is our Long Term Support (LTS) release, supported until 
31st December 2019". I think Pablo also suggested to support openssl 1.1.

Thanks,
Akhil
>>
>>> Thanks
>>> Shally
>>>
>>>>
>>>> Thanks,
>>>> Pablo
>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-06-18  7:34               ` Akhil Goyal
@ 2018-06-18  8:38                 ` De Lara Guarch, Pablo
  2018-06-18 16:22                   ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-18  8:38 UTC (permalink / raw)
  To: Akhil Goyal, Verma, Shally
  Cc: Trahe, Fiona, dev, Athreya, Narayana Prasad, Sahu, Sunila, Gupta, Ashish

Hi,

> -----Original Message-----
> From: Akhil Goyal [mailto:akhil.goyal@nxp.com]
> Sent: Monday, June 18, 2018 8:35 AM
> To: Verma, Shally <Shally.Verma@cavium.com>; Akhil Goyal
> <akhil.goyal@nxp.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; dev@dpdk.org; Athreya, Narayana
> Prasad <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> Subject: Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym
> crypto
> 
> Hi Shally,
> On 6/18/2018 12:18 PM, Verma, Shally wrote:
> > Hi
> >
> >> -----Original Message-----
> >> From: Akhil Goyal [mailto:akhil.goyal@nxp.com]
> >> Sent: 18 June 2018 12:10
> >> To: Verma, Shally <Shally.Verma@cavium.com>; De Lara Guarch, Pablo
> >> <pablo.de.lara.guarch@intel.com>
> >> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> >> dev@dpdk.org; Athreya, Narayana Prasad
> >> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> >> <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> >> Subject: Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase
> >> for asym crypto
> >>
> >
> > //snip
> >
> >>>>>>> +static int
> >>>>>>> +test_rsa(struct rsa_test_data *t)
> >>>>>>
> >>>>>> ...
> >>>>>>
> >>>>>>> +     rsa->n =
> >>>>>>> +             BN_bin2bn(
> >>>>>>> +                     (const unsigned char *)rsa_xform.rsa.n.data,
> >>>>>>> +                     rsa_xform.rsa.n.length,
> >>>>>>> +                     rsa->n);
> >>>>>>
> >>>>>> I am getting a compilation error:
> >>>>>>
> >>>>>> /test/test/test_cryptodev_asym.c:322:5: error:
> >>>>>> dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
> >>>>>>  rsa->n =
> >>>>>>     ^~
> >>>>>>
> >>>>>> My OpenSSL version is 1.1.0h.
> >>>>>>
> >>>>> [Shally] This library is tested with version 1.0.2m (mentioned
> >>>>> above) and also one supported by openssl PMD . So, you need to take
> similar version.
> >>>>
> >>>> I'd say we should support the latest stable version of OpenSSL.
> >>>> Could you get the latest 1.1.0?
> >>> [Shally] Openssl PMD uses 1.0.2h. If we move test to 1.1.0 then dpdk
> >>> would need to be set to link to two different version of libcrypto whenever
> openssl PMD is enabled which seems like a cumbersome process for users.
> >>> So I recommend for now to stick to one version.
> >>>
> >>
> >> OpenSSL PMD can get compiled/linked with any of the versions 1.0.2 or
> >> 1.1. We cannot control the above applications which version it is using.
> >> So we should not add limitation for openssl version. Please check
> >> below snippet in the PMD if this is suitable in your case.
> >>
> >> +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) static HMAC_CTX
> >> +*HMAC_CTX_new(void) {
> >> +       HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
> >> +
> >> +       if (ctx != NULL)
> >> +               HMAC_CTX_init(ctx);
> >> +       return ctx;
> >> +}
> >> +
> >> +static void HMAC_CTX_free(HMAC_CTX *ctx) {
> >> +       if (ctx != NULL) {
> >> +               HMAC_CTX_cleanup(ctx);
> >> +               OPENSSL_free(ctx);
> >> +       }
> >> +}
> >> +#endif
> >>
> > [Shally] Are we just planning to make PMD/test compatible for all lib versions?
> Won't it then be too many version compatibility checks in PMD/test and a
> maintainability issue than having implementation mentioned to be compatible
> with specific version?
> >
> 
> I think we should at least support the latest stable version. As per the openssl
> website "The latest stable version is the 1.1.0 series. The
> 1.0.2 series is our Long Term Support (LTS) release, supported until 31st
> December 2019". I think Pablo also suggested to support openssl 1.1.

I think we should keep supporting OpenSSL 1.1, even though our documentation
says that we support up to 1.0.2 (which we should fix!).
Knowing that Ubuntu and Fedora have 1.1 version in their latest versions,
I think it is a good idea to keep supporting this,
As many users will be using this version and we would be breaking their code if he change this.

Thanks,
Pablo

> 
> Thanks,
> Akhil
> >>
> >>> Thanks
> >>> Shally
> >>>
> >>>>
> >>>> Thanks,
> >>>> Pablo
> >

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
  2018-06-18  8:38                 ` De Lara Guarch, Pablo
@ 2018-06-18 16:22                   ` Verma, Shally
  0 siblings, 0 replies; 44+ messages in thread
From: Verma, Shally @ 2018-06-18 16:22 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, Akhil Goyal
  Cc: Trahe, Fiona, dev, Athreya, Narayana Prasad, Sahu, Sunila, Gupta, Ashish



>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 18 June 2018 14:09
>To: Akhil Goyal <akhil.goyal@nxp.com>; Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; dev@dpdk.org; Athreya, Narayana Prasad <NarayanaPrasad.Athreya@cavium.com>; Sahu,
>Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto
>
//snip

>> >>>>>>> +static int
>> >>>>>>> +test_rsa(struct rsa_test_data *t)
>> >>>>>>
>> >>>>>> ...
>> >>>>>>
>> >>>>>>> +     rsa->n =
>> >>>>>>> +             BN_bin2bn(
>> >>>>>>> +                     (const unsigned char *)rsa_xform.rsa.n.data,
>> >>>>>>> +                     rsa_xform.rsa.n.length,
>> >>>>>>> +                     rsa->n);
>> >>>>>>
>> >>>>>> I am getting a compilation error:
>> >>>>>>
>> >>>>>> /test/test/test_cryptodev_asym.c:322:5: error:
>> >>>>>> dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}'
>> >>>>>>  rsa->n =
>> >>>>>>     ^~
>> >>>>>>
>> >>>>>> My OpenSSL version is 1.1.0h.
>> >>>>>>
>> >>>>> [Shally] This library is tested with version 1.0.2m (mentioned
>> >>>>> above) and also one supported by openssl PMD . So, you need to take
>> similar version.
>> >>>>
>> >>>> I'd say we should support the latest stable version of OpenSSL.
>> >>>> Could you get the latest 1.1.0?
>> >>> [Shally] Openssl PMD uses 1.0.2h. If we move test to 1.1.0 then dpdk
>> >>> would need to be set to link to two different version of libcrypto whenever
>> openssl PMD is enabled which seems like a cumbersome process for users.
>> >>> So I recommend for now to stick to one version.
>> >>>
>> >>
>> >> OpenSSL PMD can get compiled/linked with any of the versions 1.0.2 or
>> >> 1.1. We cannot control the above applications which version it is using.
>> >> So we should not add limitation for openssl version. Please check
>> >> below snippet in the PMD if this is suitable in your case.
>> >>
>> >> +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) static HMAC_CTX
>> >> +*HMAC_CTX_new(void) {
>> >> +       HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
>> >> +
>> >> +       if (ctx != NULL)
>> >> +               HMAC_CTX_init(ctx);
>> >> +       return ctx;
>> >> +}
>> >> +
>> >> +static void HMAC_CTX_free(HMAC_CTX *ctx) {
>> >> +       if (ctx != NULL) {
>> >> +               HMAC_CTX_cleanup(ctx);
>> >> +               OPENSSL_free(ctx);
>> >> +       }
>> >> +}
>> >> +#endif
>> >>
>> > [Shally] Are we just planning to make PMD/test compatible for all lib versions?
>> Won't it then be too many version compatibility checks in PMD/test and a
>> maintainability issue than having implementation mentioned to be compatible
>> with specific version?
>> >
>>
>> I think we should at least support the latest stable version. As per the openssl
>> website "The latest stable version is the 1.1.0 series. The
>> 1.0.2 series is our Long Term Support (LTS) release, supported until 31st
>> December 2019". I think Pablo also suggested to support openssl 1.1.
>
>I think we should keep supporting OpenSSL 1.1, even though our documentation
>says that we support up to 1.0.2 (which we should fix!).
>Knowing that Ubuntu and Fedora have 1.1 version in their latest versions,
>I think it is a good idea to keep supporting this,
>As many users will be using this version and we would be breaking their code if he change this.

[Shally] Will look into this .

>
>Thanks,
>Pablo
>
>>
>> Thanks,
>> Akhil
>> >>
>> >>> Thanks
>> >>> Shally
>> >>>
>> >>>>
>> >>>> Thanks,
>> >>>> Pablo
>> >

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
  2018-06-15  8:40   ` De Lara Guarch, Pablo
@ 2018-06-22 15:38     ` Verma, Shally
  2018-06-25 21:34       ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-06-22 15:38 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Hi Pablo

>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 15 June 2018 14:10
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
>
//snip 

>
>...
>
>> +/**
>> + * Asymmetric Cryptographic Operation.
>> + *
>> + * Structure describing asymmetric crypto operation params.
>> + *
>> + */
>> +struct rte_crypto_asym_op {
>> +     struct rte_cryptodev_asym_session *session;
>> +     /**< Handle for the initialised session context */
>> +
>
>Looking at the xform structure, it looks like a chain of xforms is possible.
>Looking at this union, this case wouldn't be possible, as only one item from the union can be set.

[Shally] xforms, which support chaining, would need to have op_type in their respective xform struct.
Example  struct rte_crypto_dh_xform,  where app can chain Deffie-hellman public and/or shared secret compute and DSA sign compute.

+struct rte_crypto_dh_xform {
+	enum rte_crypto_asym_op_type type;
+	/**< Setup xform for key generate or shared secret compute */ and DSA xforms struct

test_cryptodev_asym illustrates how to setup chained dh+dsa ops.

Thanks
Shally


>
//snip

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-06-18  5:30         ` Verma, Shally
@ 2018-06-23 12:41           ` Verma, Shally
  2018-06-23 18:16             ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-06-23 12:41 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Hi Pablo

>-----Original Message-----
>From: Verma, Shally
>Sent: 18 June 2018 11:00
>To: 'De Lara Guarch, Pablo' <pablo.de.lara.guarch@intel.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
>
//snip

>>> >>
>>> >>               .session_get_size       = openssl_pmd_session_get_size,
>>> >> +             .asym_session_get_size  =
>>> >> openssl_pmd_asym_session_get_size,
>>> >>               .session_configure      = openssl_pmd_session_configure,
>>> >> -             .session_clear          = openssl_pmd_session_clear
>>> >> +             .asym_session_configure =
>>> >> openssl_pmd_asym_session_configure,
>>> >> +             .session_clear          = openssl_pmd_session_clear,
>>> >> +             .asym_session_clear     = openssl_pmd_asym_session_clear
>>> >>  };
>>> >
>>> >I think session_get_size, session_configure and session_clear should be
>>> >renamed to sym_session_*, to avoid confusion. Could you add another patch
>>> renaming these?
>>> >
>>> [Shally] I see in latest cryptodev these typedefs are already named to
>>> cryptodev_sym_configure_session_t, _sym_get_session_private_size_t and
>>> _sym_free_.. so these changes would come while rebase.
>>> or you are referring to change openssl_pmd_session_configure to
>>> openssl_pmd_sym_session_configure and so others?
>>
>>Yes, but the name is still session_configure/clear, not sym_session_configure/clear, right?
>>And also, I think we should rename the OpenSSL functions, openssl_pmd_session_*,
>>to openssl_pmd_sym_session_*.
>>
>[Shally] Ok. I will look into this.
>
[Shally] if I change these names in struct rte_cryptodev_ops, then we will need to change all drivers. I think that should be done in a separate patch series specific to rename these. For now, I will rename only openssl pmd APIs to use _sym version for this patch series.

>Thanks
>Shally
>
>>Pablo
>>
>>>
>>> Thanks for review.
>>>
>>> >Thanks,
>>> >Pablo
>>> >

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-06-23 12:41           ` Verma, Shally
@ 2018-06-23 18:16             ` De Lara Guarch, Pablo
  2018-06-23 18:26               ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-23 18:16 UTC (permalink / raw)
  To: Verma, Shally
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish



> -----Original Message-----
> From: Verma, Shally [mailto:Shally.Verma@cavium.com]
> Sent: Saturday, June 23, 2018 1:42 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; Athreya, Narayana Prasad
> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> 
> Hi Pablo
> 
> >-----Original Message-----
> >From: Verma, Shally
> >Sent: 18 June 2018 11:00
> >To: 'De Lara Guarch, Pablo' <pablo.de.lara.guarch@intel.com>
> >Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> >dev@dpdk.org; Athreya, Narayana Prasad
> ><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> ><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> >Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> >
> //snip
> 
> >>> >>
> >>> >>               .session_get_size       = openssl_pmd_session_get_size,
> >>> >> +             .asym_session_get_size  =
> >>> >> openssl_pmd_asym_session_get_size,
> >>> >>               .session_configure      = openssl_pmd_session_configure,
> >>> >> -             .session_clear          = openssl_pmd_session_clear
> >>> >> +             .asym_session_configure =
> >>> >> openssl_pmd_asym_session_configure,
> >>> >> +             .session_clear          = openssl_pmd_session_clear,
> >>> >> +             .asym_session_clear     = openssl_pmd_asym_session_clear
> >>> >>  };
> >>> >
> >>> >I think session_get_size, session_configure and session_clear
> >>> >should be renamed to sym_session_*, to avoid confusion. Could you
> >>> >add another patch
> >>> renaming these?
> >>> >
> >>> [Shally] I see in latest cryptodev these typedefs are already named
> >>> to cryptodev_sym_configure_session_t,
> >>> _sym_get_session_private_size_t and _sym_free_.. so these changes would
> come while rebase.
> >>> or you are referring to change openssl_pmd_session_configure to
> >>> openssl_pmd_sym_session_configure and so others?
> >>
> >>Yes, but the name is still session_configure/clear, not
> sym_session_configure/clear, right?
> >>And also, I think we should rename the OpenSSL functions,
> >>openssl_pmd_session_*, to openssl_pmd_sym_session_*.
> >>
> >[Shally] Ok. I will look into this.
> >
> [Shally] if I change these names in struct rte_cryptodev_ops, then we will need
> to change all drivers. I think that should be done in a separate patch series
> specific to rename these. For now, I will rename only openssl pmd APIs to use
> _sym version for this patch series.

Right. I think a separate patch is a good idea, but it has to be done in one patch,
to avoid breaking the compilation. Could you send this patch soon?

Thanks,
Pablo

> 
> >Thanks
> >Shally
> >
> >>Pablo
> >>
> >>>
> >>> Thanks for review.
> >>>
> >>> >Thanks,
> >>> >Pablo
> >>> >

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-06-23 18:16             ` De Lara Guarch, Pablo
@ 2018-06-23 18:26               ` Verma, Shally
  2018-06-25 16:35                 ` De Lara Guarch, Pablo
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-06-23 18:26 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish



>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 23 June 2018 23:47
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
>
>External Email
// snip

>> >>Yes, but the name is still session_configure/clear, not
>> sym_session_configure/clear, right?
>> >>And also, I think we should rename the OpenSSL functions,
>> >>openssl_pmd_session_*, to openssl_pmd_sym_session_*.
>> >>
>> >[Shally] Ok. I will look into this.
>> >
>> [Shally] if I change these names in struct rte_cryptodev_ops, then we will need
>> to change all drivers. I think that should be done in a separate patch series
>> specific to rename these. For now, I will rename only openssl pmd APIs to use
>> _sym version for this patch series.
>
>Right. I think a separate patch is a good idea, but it has to be done in one patch,
>to avoid breaking the compilation. Could you send this patch soon?
>
I can send openssl asym related patch soon. Can't commit on right now for sym_ session name  in pmd ops changes.
Sorry about that.

Thanks
Shally

>Thanks,
>Pablo
>
>>
>> >Thanks
>> >Shally
>> >
>> >>Pablo
>> >>
>> >>>
>> >>> Thanks for review.
>> >>>
>> >>> >Thanks,
>> >>> >Pablo
>> >>> >

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-06-23 18:26               ` Verma, Shally
@ 2018-06-25 16:35                 ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-25 16:35 UTC (permalink / raw)
  To: Verma, Shally
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish



> -----Original Message-----
> From: Verma, Shally [mailto:Shally.Verma@cavium.com]
> Sent: Saturday, June 23, 2018 7:26 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; Athreya, Narayana Prasad
> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> 
> 
> 
> >-----Original Message-----
> >From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
> >Sent: 23 June 2018 23:47
> >To: Verma, Shally <Shally.Verma@cavium.com>
> >Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> >dev@dpdk.org; Athreya, Narayana Prasad
> ><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> ><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> >Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> >
> >External Email
> // snip
> 
> >> >>Yes, but the name is still session_configure/clear, not
> >> sym_session_configure/clear, right?
> >> >>And also, I think we should rename the OpenSSL functions,
> >> >>openssl_pmd_session_*, to openssl_pmd_sym_session_*.
> >> >>
> >> >[Shally] Ok. I will look into this.
> >> >
> >> [Shally] if I change these names in struct rte_cryptodev_ops, then we
> >> will need to change all drivers. I think that should be done in a
> >> separate patch series specific to rename these. For now, I will
> >> rename only openssl pmd APIs to use _sym version for this patch series.
> >
> >Right. I think a separate patch is a good idea, but it has to be done
> >in one patch, to avoid breaking the compilation. Could you send this patch
> soon?
> >
> I can send openssl asym related patch soon. Can't commit on right now for sym_
> session name  in pmd ops changes.
> Sorry about that.

I will send a patch renaming these functions as part of cryptodev API changes
http://patches.dpdk.org/cover/40958/

Thanks,
Pablo

> 
> Thanks
> Shally
> 
> >Thanks,
> >Pablo
> >
> >>
> >> >Thanks
> >> >Shally
> >> >
> >> >>Pablo
> >> >>
> >> >>>
> >> >>> Thanks for review.
> >> >>>
> >> >>> >Thanks,
> >> >>> >Pablo
> >> >>> >

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
  2018-06-22 15:38     ` Verma, Shally
@ 2018-06-25 21:34       ` De Lara Guarch, Pablo
  2018-06-26 11:54         ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-25 21:34 UTC (permalink / raw)
  To: Verma, Shally
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Hi Shally,

> -----Original Message-----
> From: Verma, Shally [mailto:Shally.Verma@cavium.com]
> Sent: Friday, June 22, 2018 4:39 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; Athreya, Narayana Prasad
> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> Subject: RE: [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
> 
> Hi Pablo
> 
> >-----Original Message-----
> >From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
> >Sent: 15 June 2018 14:10
> >To: Verma, Shally <Shally.Verma@cavium.com>
> >Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> >dev@dpdk.org; Athreya, Narayana Prasad
> ><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> ><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> >Subject: RE: [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in
> >cryptodev
> >
> //snip
> 
> >
> >...
> >
> >> +/**
> >> + * Asymmetric Cryptographic Operation.
> >> + *
> >> + * Structure describing asymmetric crypto operation params.
> >> + *
> >> + */
> >> +struct rte_crypto_asym_op {
> >> +     struct rte_cryptodev_asym_session *session;
> >> +     /**< Handle for the initialised session context */
> >> +
> >
> >Looking at the xform structure, it looks like a chain of xforms is possible.
> >Looking at this union, this case wouldn't be possible, as only one item from the
> union can be set.
> 
> [Shally] xforms, which support chaining, would need to have op_type in their
> respective xform struct.
> Example  struct rte_crypto_dh_xform,  where app can chain Deffie-hellman
> public and/or shared secret compute and DSA sign compute.
> 
> +struct rte_crypto_dh_xform {
> +	enum rte_crypto_asym_op_type type;
> +	/**< Setup xform for key generate or shared secret compute */ and DSA
> +xforms struct
> 
> test_cryptodev_asym illustrates how to setup chained dh+dsa ops.

Are you talking about test_dh_gen_kp? Because this is the only function
where I see that there is a chain of xforms.
In this case, both xforms are the same type (RTE_CRYPTO_ASYM_XFORM_DH),
and the operation only sets parameters for rte_crypto_dh_op_param.
I would expect that dh_op_param and dsa_op_param would need to be set, which couldn't be done.

Thanks,
Pablo

> 
> Thanks
> Shally
> 
> 
> >
> //snip

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support " Shally Verma
  2018-06-15  9:05   ` De Lara Guarch, Pablo
@ 2018-06-26  9:20   ` De Lara Guarch, Pablo
  2018-06-26 11:21     ` Verma, Shally
  1 sibling, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-26  9:20 UTC (permalink / raw)
  To: Shally Verma
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta

Hi Shally,

> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev
> 
> Extend DPDK librte_cryptodev to:
> - define asym op type in rte_crypto_op_type and associated
>   op pool create/alloc APIs
> - define asym session and associated session APIs
> 
> If PMD shows in its feature flag that it supports both sym and asym then it must
> support those on all its qps.
> 
> Changes from v2:
> - added rte_cryptodev_asym_session_set/get_private_data for app to setup
> private data in a session as per latest dpdk-next-crypto spec
> - rename rte_cryptodev_get_asym_session_private_size to be consistent with
> other API names
> - correct rte_cryptodev_asym_session_create to pass void** to
> rte_mempool_get() and add for private_data_size flag
> 
> Changes from v1
>     - resolve new line error in librte_cryptodev/rte_cryptodev_version.map
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>

...

> +int __rte_experimental
> +rte_cryptodev_asym_session_init(uint8_t dev_id,
> +		struct rte_cryptodev_asym_session *sess,
> +		struct rte_crypto_asym_xform *xforms,
> +		struct rte_mempool *mp)
> +{
> +	struct rte_cryptodev *dev;
> +	uint8_t index;
> +	int ret;
> +
> +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> +
> +	if (sess == NULL || xforms == NULL || dev == NULL)
> +		return -EINVAL;
> +
> +	index = dev->driver_id;
> +

Check if asym_session_configure is implemented in the device, like this:

RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_configure, -ENOTSUP);

This way, there won't be a segmentation fault when using a device that
does not support asymmetric operations.

> +	if (sess->sess_private_data[index] == NULL) {
> +		ret = dev->dev_ops->asym_session_configure(dev,
> +							xforms,
> +							sess, mp);
> +		if (ret < 0) {
> +			CDEV_LOG_ERR(
> +				"dev_id %d failed to configure session details",
> +				dev_id);
> +			return ret;

...

> +int __rte_experimental
> +rte_cryptodev_asym_session_clear(uint8_t dev_id,
> +		struct rte_cryptodev_asym_session *sess) {
> +	struct rte_cryptodev *dev;
> +
> +	dev = rte_cryptodev_pmd_get_dev(dev_id);
> +
> +	if (dev == NULL || sess == NULL)
> +		return -EINVAL;
> +

Same as above, add the following.

RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_clear, -ENOTSUP);

> +	dev->dev_ops->asym_session_clear(dev, sess);
> +
> +	return 0;
> +}

I will send a patch doing the same for symmetric.

Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support Shally Verma
  2018-06-17 13:25   ` De Lara Guarch, Pablo
@ 2018-06-26  9:23   ` De Lara Guarch, Pablo
  2018-06-26 11:22     ` Verma, Shally
  2018-07-03 14:50   ` Trahe, Fiona
  2 siblings, 1 reply; 44+ messages in thread
From: De Lara Guarch, Pablo @ 2018-06-26  9:23 UTC (permalink / raw)
  To: Shally Verma
  Cc: Trahe, Fiona, akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta



> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> 
> Add asymmetric crypto operation support in openssl PMD.
> Current list of supported asym xforms:
> * RSA
> * DSA
> * Deffie-hellman
> * Modular Operations
> 
> changes from v2:
> - Update the pmd capability as per new capability structure
> 
> changes from v1:
> - resolve new line error in dod/guides/cryptodevs/openssl.rst
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> ---
>  doc/guides/cryptodevs/features/openssl.ini       |  11 +
>  doc/guides/cryptodevs/openssl.rst                |   1 +
>  drivers/crypto/openssl/rte_openssl_pmd.c         | 377 ++++++++++++++++++++-
>  drivers/crypto/openssl/rte_openssl_pmd_ops.c     | 395
> ++++++++++++++++++++++-
>  drivers/crypto/openssl/rte_openssl_pmd_private.h |  29 ++
>  5 files changed, 801 insertions(+), 12 deletions(-)

...

> @@ -1606,7 +1957,12 @@ openssl_pmd_enqueue_burst(void *queue_pair,
> struct rte_crypto_op **ops,
>  		if (unlikely(sess == NULL))
>  			goto enqueue_err;
> 
> -		retval = process_op(qp, ops[i], sess);
> +		if (ops[i]->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
> +			retval = process_op(qp, ops[i],
> +					(struct openssl_session *) sess);

Could you rename process_op to process_sym_op?

Also, I think we need this check for the other PMDs.
I will send a patch to check if op type is equal to symmetric.

Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev
  2018-06-26  9:20   ` De Lara Guarch, Pablo
@ 2018-06-26 11:21     ` Verma, Shally
  0 siblings, 0 replies; 44+ messages in thread
From: Verma, Shally @ 2018-06-26 11:21 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish

Ack.
Thanks
Shally

>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 26 June 2018 14:50
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev
>
>External Email
>
>Hi Shally,
>
>> -----Original Message-----
>> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
>> Sent: Wednesday, May 16, 2018 7:05 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
>> dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
>> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
>> <ashish.gupta@caviumnetworks.com>
>> Subject: [PATCH v3 2/6] lib/cryptodev: add asym op support in cryptodev
>>
>> Extend DPDK librte_cryptodev to:
>> - define asym op type in rte_crypto_op_type and associated
>>   op pool create/alloc APIs
>> - define asym session and associated session APIs
>>
>> If PMD shows in its feature flag that it supports both sym and asym then it must
>> support those on all its qps.
>>
>> Changes from v2:
>> - added rte_cryptodev_asym_session_set/get_private_data for app to setup
>> private data in a session as per latest dpdk-next-crypto spec
>> - rename rte_cryptodev_get_asym_session_private_size to be consistent with
>> other API names
>> - correct rte_cryptodev_asym_session_create to pass void** to
>> rte_mempool_get() and add for private_data_size flag
>>
>> Changes from v1
>>     - resolve new line error in librte_cryptodev/rte_cryptodev_version.map
>>
>> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
>> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
>> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
>
>...
>
>> +int __rte_experimental
>> +rte_cryptodev_asym_session_init(uint8_t dev_id,
>> +             struct rte_cryptodev_asym_session *sess,
>> +             struct rte_crypto_asym_xform *xforms,
>> +             struct rte_mempool *mp)
>> +{
>> +     struct rte_cryptodev *dev;
>> +     uint8_t index;
>> +     int ret;
>> +
>> +     dev = rte_cryptodev_pmd_get_dev(dev_id);
>> +
>> +     if (sess == NULL || xforms == NULL || dev == NULL)
>> +             return -EINVAL;
>> +
>> +     index = dev->driver_id;
>> +
>
>Check if asym_session_configure is implemented in the device, like this:
>
>RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_configure, -ENOTSUP);
>
>This way, there won't be a segmentation fault when using a device that
>does not support asymmetric operations.
>
>> +     if (sess->sess_private_data[index] == NULL) {
>> +             ret = dev->dev_ops->asym_session_configure(dev,
>> +                                                     xforms,
>> +                                                     sess, mp);
>> +             if (ret < 0) {
>> +                     CDEV_LOG_ERR(
>> +                             "dev_id %d failed to configure session details",
>> +                             dev_id);
>> +                     return ret;
>
>...
>
>> +int __rte_experimental
>> +rte_cryptodev_asym_session_clear(uint8_t dev_id,
>> +             struct rte_cryptodev_asym_session *sess) {
>> +     struct rte_cryptodev *dev;
>> +
>> +     dev = rte_cryptodev_pmd_get_dev(dev_id);
>> +
>> +     if (dev == NULL || sess == NULL)
>> +             return -EINVAL;
>> +
>
>Same as above, add the following.
>
>RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->asym_session_clear, -ENOTSUP);
>
>> +     dev->dev_ops->asym_session_clear(dev, sess);
>> +
>> +     return 0;
>> +}
>
>I will send a patch doing the same for symmetric.
>
>Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-06-26  9:23   ` De Lara Guarch, Pablo
@ 2018-06-26 11:22     ` Verma, Shally
  0 siblings, 0 replies; 44+ messages in thread
From: Verma, Shally @ 2018-06-26 11:22 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish



>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 26 June 2018 14:53
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support

//snip

>> -             retval = process_op(qp, ops[i], sess);
>> +             if (ops[i]->type == RTE_CRYPTO_OP_TYPE_SYMMETRIC)
>> +                     retval = process_op(qp, ops[i],
>> +                                     (struct openssl_session *) sess);
>
>Could you rename process_op to process_sym_op?
>
[Shally] Will do.

>Also, I think we need this check for the other PMDs.
>I will send a patch to check if op type is equal to symmetric.
>
>Pablo

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
  2018-06-25 21:34       ` De Lara Guarch, Pablo
@ 2018-06-26 11:54         ` Verma, Shally
  0 siblings, 0 replies; 44+ messages in thread
From: Verma, Shally @ 2018-06-26 11:54 UTC (permalink / raw)
  To: De Lara Guarch, Pablo
  Cc: Trahe, Fiona, akhil.goyal, dev, Athreya, Narayana Prasad, Sahu,
	Sunila, Gupta, Ashish



>-----Original Message-----
>From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>Sent: 26 June 2018 03:04
>To: Verma, Shally <Shally.Verma@cavium.com>
>Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
>
>External Email
>
>Hi Shally,
>
>> -----Original Message-----
>> From: Verma, Shally [mailto:Shally.Verma@cavium.com]
>> Sent: Friday, June 22, 2018 4:39 PM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
>> dev@dpdk.org; Athreya, Narayana Prasad
>> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
>> <Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>> Subject: RE: [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev
>>
>> Hi Pablo
>>
>> >-----Original Message-----
>> >From: De Lara Guarch, Pablo [mailto:pablo.de.lara.guarch@intel.com]
>> >Sent: 15 June 2018 14:10
>> >To: Verma, Shally <Shally.Verma@cavium.com>
>> >Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com;
>> >dev@dpdk.org; Athreya, Narayana Prasad
>> ><NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
>> ><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>> >Subject: RE: [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in
>> >cryptodev
>> >
>> //snip
>>
>> >
>> >...
>> >
>> >> +/**
>> >> + * Asymmetric Cryptographic Operation.
>> >> + *
>> >> + * Structure describing asymmetric crypto operation params.
>> >> + *
>> >> + */
>> >> +struct rte_crypto_asym_op {
>> >> +     struct rte_cryptodev_asym_session *session;
>> >> +     /**< Handle for the initialised session context */
>> >> +
>> >
>> >Looking at the xform structure, it looks like a chain of xforms is possible.
>> >Looking at this union, this case wouldn't be possible, as only one item from the
>> union can be set.
>>
>> [Shally] xforms, which support chaining, would need to have op_type in their
>> respective xform struct.
>> Example  struct rte_crypto_dh_xform,  where app can chain Deffie-hellman
>> public and/or shared secret compute and DSA sign compute.
>>
>> +struct rte_crypto_dh_xform {
>> +     enum rte_crypto_asym_op_type type;
>> +     /**< Setup xform for key generate or shared secret compute */ and DSA
>> +xforms struct
>>
>> test_cryptodev_asym illustrates how to setup chained dh+dsa ops.
>
>Are you talking about test_dh_gen_kp? Because this is the only function
>where I see that there is a chain of xforms.
>In this case, both xforms are the same type (RTE_CRYPTO_ASYM_XFORM_DH),
>and the operation only sets parameters for rte_crypto_dh_op_param.

[Shally] Ya you right. Testapp illustrates chaining for dh public and private key pair generation. Not DH followed by DSA.
Currently, DH key pair generation was only identified requirement for chaining, so only that is illustrated. If other xforms are to be extended for chaining,
then respective struct might need modification based on exact requirement.

>I would expect that dh_op_param and dsa_op_param would need to be set, which couldn't be done.
[Shally] No change would be required in either. if app want to DSA sign data using internally generated DH private key, then PMD input DH params and setup DSA to use key generated by DH. In such case, since end operation is DSA_SIGN, so app will enqueue only DSA op with op_type = DSA_SIGN and respective dsa_op_param for processing.

>
>Thanks,
>Pablo
>
>>
>> Thanks
>> Shally
>>
>>
>> >
>> //snip

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability in cryptodev
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability " Shally Verma
  2018-06-17 12:11   ` De Lara Guarch, Pablo
@ 2018-07-03 14:12   ` Trahe, Fiona
  2018-07-03 14:47     ` Verma, Shally
  1 sibling, 1 reply; 44+ messages in thread
From: Trahe, Fiona @ 2018-07-03 14:12 UTC (permalink / raw)
  To: Shally Verma, De Lara Guarch, Pablo
  Cc: akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta, Trahe, Fiona

Hi Shally,

> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org;
> pathreya@caviumnetworks.com; Sunila Sahu <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability in cryptodev
> 
> Extend cryptodev with asymmetric capability APIs and
> definitions.
> 
> changes from v2:
> - remove redundant xform_type from asym capability struct
> - rename rte_cryptodev_get_asym_xform_enum to
> be more consistent with other API names
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> 
> ---
//snip//

> diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
> index 623459a95..6c13d23f8 100644
> --- a/lib/librte_cryptodev/rte_cryptodev.h
> +++ b/lib/librte_cryptodev/rte_cryptodev.h
> @@ -178,6 +178,35 @@ struct rte_cryptodev_symmetric_capability {
>  	};
>  };
> 
> +/**
> + * Asymmetric Xform Crypto Capability
> + *
> + */
> +struct rte_cryptodev_asymmetric_xfrm_capability {
> +	enum rte_crypto_asym_xform_type xform_type;
> +	/**< Transform type: RSA/MODEXP/DH/DSA/MODINV */
> +
> +	uint32_t op_types;
> +	/**< bitmask for supported rte_crypto_asym_op_type */
> +
> +	__extension__
> +	union {
> +		struct rte_crypto_param_range modlen;
> +		/**< Range of modulus length supported by modulus based xform.
> +		 * Value 0 mean implementation default
> +		 */
[Fiona] Some other fields may be necessary here, e.g.
 - A bitmask for supported RSA padding types
 - Whether RSA private-key in quintuple format is supported
 - Which hash-algorithms are supported if RSA padding = OAEP or PSS
 - whether xform chaining is supported for DH keypair gen
These are not blockers for the first release, but are likely to be 
needed before the experimental label is removed.

> +	};
> +};
> +
> +/**
> + * Asymmetric Crypto Capability
> + *
> + */
> +struct rte_cryptodev_asymmetric_capability {
> +	struct rte_cryptodev_asymmetric_xfrm_capability xfrm_capa;
> +};
[Fiona] Why the  extra indirection?
Couldn't this be removed and the previous structure be 
renamed rte_cryptodev_asymmetric_capability?

//snip//
> @@ -1164,7 +1265,7 @@ int __rte_experimental
>  rte_cryptodev_asym_session_set_private_data(
[Fiona] I'd prefer to call this appl_data or appl_priv_data, I think the term private_data is 
over-used, sometimes means PMD data and sometimes means appl data.
Btw- same is true of sym private_data - but changing that is out of scope for this patch

  
>  					struct rte_cryptodev_asym_session *sess,
>  					void *data,
> -					uint16_t size)
> +					uint16_t size);
> 
>  /**
>   * Get private data of a session.
> @@ -1178,7 +1279,7 @@ rte_cryptodev_asym_session_set_private_data(
>   */
>  void * __rte_experimental
>  rte_cryptodev_asym_session_get_private_data(
> -				struct rte_cryptodev_asym_session *sess)
> +				struct rte_cryptodev_asym_session *sess);
> 
> 
>  #ifdef __cplusplus
> diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map
> b/lib/librte_cryptodev/rte_cryptodev_version.map
> index 62b782444..817cf9f70 100644
> --- a/lib/librte_cryptodev/rte_cryptodev_version.map
> +++ b/lib/librte_cryptodev/rte_cryptodev_version.map
> @@ -89,13 +89,18 @@ DPDK_17.11 {
>  EXPERIMENTAL {
>          global:
> 
> -	rte_cryptodev_asym_get_private_session_size
> +	rte_cryptodev_asym_capability_get;
> +	rte_cryptodev_asym_get_private_session_size;
> +	rte_cryptodev_asym_get_xform_enum;
> +	rte_crypto_asym_op_strings;
>  	rte_cryptodev_asym_session_clear;
>  	rte_cryptodev_asym_session_create;
>  	rte_cryptodev_asym_session_free;
>  	rte_cryptodev_asym_session_init;
> -	rte_cryptodev_asym_session_get_private_data
> -	rte_cryptodev_asym_session_set_private_data
> +	rte_cryptodev_asym_session_get_private_data;
> +	rte_cryptodev_asym_session_set_private_data;
> +	rte_cryptodev_asym_xfrm_capability_check_optype;
> +	rte_crypto_asym_xform_strings;
>  	rte_cryptodev_sym_session_get_private_data;
>  	rte_cryptodev_sym_session_set_private_data;
>  } DPDK_17.11;
> --
> 2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability in cryptodev
  2018-07-03 14:12   ` Trahe, Fiona
@ 2018-07-03 14:47     ` Verma, Shally
  0 siblings, 0 replies; 44+ messages in thread
From: Verma, Shally @ 2018-07-03 14:47 UTC (permalink / raw)
  To: Trahe, Fiona, De Lara Guarch, Pablo
  Cc: akhil.goyal, dev, Athreya, Narayana Prasad, Sahu, Sunila, Gupta, Ashish

HI Fiona

Thanks for review. I was just about to send lib patch v4. So for now, I couldn't  consider all input but some of them.
But , in any case, this version is experimental so it is open for further feedback after 1st version go in.

Rest, please see my feedback inline.

>-----Original Message-----
>From: Trahe, Fiona [mailto:fiona.trahe@intel.com]
>Sent: 03 July 2018 19:42
>To: Verma, Shally <Shally.Verma@cavium.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>Cc: akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>; Trahe, Fiona <fiona.trahe@intel.com>
>Subject: RE: [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability in cryptodev
>
>External Email
>
>Hi Shally,
>
>> -----Original Message-----
>> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
>> Sent: Wednesday, May 16, 2018 7:05 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org;
>> pathreya@caviumnetworks.com; Sunila Sahu <sunila.sahu@caviumnetworks.com>; Ashish Gupta
>> <ashish.gupta@caviumnetworks.com>
>> Subject: [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability in cryptodev
>>
>> Extend cryptodev with asymmetric capability APIs and
>> definitions.
>>
>> changes from v2:
>> - remove redundant xform_type from asym capability struct
>> - rename rte_cryptodev_get_asym_xform_enum to
>> be more consistent with other API names
>>
>> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
>> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
>> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
>>
>> ---
>//snip//
>
>> diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h
>> index 623459a95..6c13d23f8 100644
>> --- a/lib/librte_cryptodev/rte_cryptodev.h
>> +++ b/lib/librte_cryptodev/rte_cryptodev.h
>> @@ -178,6 +178,35 @@ struct rte_cryptodev_symmetric_capability {
>>       };
>>  };
>>
>> +/**
>> + * Asymmetric Xform Crypto Capability
>> + *
>> + */
>> +struct rte_cryptodev_asymmetric_xfrm_capability {
>> +     enum rte_crypto_asym_xform_type xform_type;
>> +     /**< Transform type: RSA/MODEXP/DH/DSA/MODINV */
>> +
>> +     uint32_t op_types;
>> +     /**< bitmask for supported rte_crypto_asym_op_type */
>> +
>> +     __extension__
>> +     union {
>> +             struct rte_crypto_param_range modlen;
>> +             /**< Range of modulus length supported by modulus based xform.
>> +              * Value 0 mean implementation default
>> +              */
>[Fiona] Some other fields may be necessary here, e.g.
> - A bitmask for supported RSA padding types
> - Whether RSA private-key in quintuple format is supported
> - Which hash-algorithms are supported if RSA padding = OAEP or PSS
> - whether xform chaining is supported for DH keypair gen
>These are not blockers for the first release, but are likely to be
>needed before the experimental label is removed.
>
[Shally] Agree. Part of these capabilities might need to there as per xform capability. 
But  as you indicated, in any case, they are experimental right now, so let's have them added on a requirement basis once current is accepted.

>> +     };
>> +};
>> +
>> +/**
>> + * Asymmetric Crypto Capability
>> + *
>> + */
>> +struct rte_cryptodev_asymmetric_capability {
>> +     struct rte_cryptodev_asymmetric_xfrm_capability xfrm_capa;
>> +};
>[Fiona] Why the  extra indirection?
>Couldn't this be removed and the previous structure be
>renamed rte_cryptodev_asymmetric_capability?
[Shally] it is to keep consistency in rte_cryptodev_capability which uses name asymmetric_capability on the similar line as symmetric.
But again, change is trivial, so if intended will do in subsequent versions.
>
>//snip//
>> @@ -1164,7 +1265,7 @@ int __rte_experimental
>>  rte_cryptodev_asym_session_set_private_data(
>[Fiona] I'd prefer to call this appl_data or appl_priv_data, I think the term private_data is
>over-used, sometimes means PMD data and sometimes means appl data.
>Btw- same is true of sym private_data - but changing that is out of scope for this patch
>
[Shally] ok. I can change it to get_app_priv_data and set_app_priv_data

Thanks
Shally

>
>>                                       struct rte_cryptodev_asym_session *sess,
>>                                       void *data,
>> -                                     uint16_t size)
>> +                                     uint16_t size);
>>
>>  /**
>>   * Get private data of a session.
>> @@ -1178,7 +1279,7 @@ rte_cryptodev_asym_session_set_private_data(
>>   */
>>  void * __rte_experimental
>>  rte_cryptodev_asym_session_get_private_data(
>> -                             struct rte_cryptodev_asym_session *sess)
>> +                             struct rte_cryptodev_asym_session *sess);
>>
>>
>>  #ifdef __cplusplus
>> diff --git a/lib/librte_cryptodev/rte_cryptodev_version.map
>> b/lib/librte_cryptodev/rte_cryptodev_version.map
>> index 62b782444..817cf9f70 100644
>> --- a/lib/librte_cryptodev/rte_cryptodev_version.map
>> +++ b/lib/librte_cryptodev/rte_cryptodev_version.map
>> @@ -89,13 +89,18 @@ DPDK_17.11 {
>>  EXPERIMENTAL {
>>          global:
>>
>> -     rte_cryptodev_asym_get_private_session_size
>> +     rte_cryptodev_asym_capability_get;
>> +     rte_cryptodev_asym_get_private_session_size;
>> +     rte_cryptodev_asym_get_xform_enum;
>> +     rte_crypto_asym_op_strings;
>>       rte_cryptodev_asym_session_clear;
>>       rte_cryptodev_asym_session_create;
>>       rte_cryptodev_asym_session_free;
>>       rte_cryptodev_asym_session_init;
>> -     rte_cryptodev_asym_session_get_private_data
>> -     rte_cryptodev_asym_session_set_private_data
>> +     rte_cryptodev_asym_session_get_private_data;
>> +     rte_cryptodev_asym_session_set_private_data;
>> +     rte_cryptodev_asym_xfrm_capability_check_optype;
>> +     rte_crypto_asym_xform_strings;
>>       rte_cryptodev_sym_session_get_private_data;
>>       rte_cryptodev_sym_session_set_private_data;
>>  } DPDK_17.11;
>> --
>> 2.14.3

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support Shally Verma
  2018-06-17 13:25   ` De Lara Guarch, Pablo
  2018-06-26  9:23   ` De Lara Guarch, Pablo
@ 2018-07-03 14:50   ` Trahe, Fiona
  2018-07-03 14:59     ` Verma, Shally
  2 siblings, 1 reply; 44+ messages in thread
From: Trahe, Fiona @ 2018-07-03 14:50 UTC (permalink / raw)
  To: Shally Verma, De Lara Guarch, Pablo
  Cc: akhil.goyal, dev, pathreya, Sunila Sahu, Ashish Gupta, Trahe, Fiona

Hi Shally,

> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Wednesday, May 16, 2018 7:05 AM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org;
> pathreya@caviumnetworks.com; Sunila Sahu <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> 
> Add asymmetric crypto operation support in openssl PMD.
> Current list of supported asym xforms:
> * RSA
> * DSA
> * Deffie-hellman
> * Modular Operations
> 
> changes from v2:
> - Update the pmd capability as per new capability structure
> 
> changes from v1:
> - resolve new line error in dod/guides/cryptodevs/openssl.rst
> 
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>


//snip//
> +/* process rsa operations */
> +static int process_openssl_rsa_op(struct rte_crypto_op *cop,
> +				  struct openssl_asym_session *sess)
> +{
> +	int ret = 0;
> +	struct rte_crypto_asym_op *op = cop->asym;
> +	RSA *rsa = sess->u.r.rsa;
> +	uint32_t pad = (op->rsa.pad);
> +
> +	switch (pad) {
> +	case RTE_CRYPTO_RSA_PKCS1_V1_5_BT1:
> +	case RTE_CRYPTO_RSA_PKCS1_V1_5_BT2:
> +		pad = RSA_PKCS1_PADDING;
> +		break;
> +	case RTE_CRYPTO_RSA_PADDING_PSS:
> +		pad = RSA_PKCS1_PSS_PADDING;
> +		/* fall through */
> +	case RTE_CRYPTO_RSA_PADDING_OAEP:
> +		pad = RSA_PKCS1_OAEP_PADDING;
> +		/* fall through */
> +	default:
> +		pad = RSA_NO_PADDING;
> +		break;
[Fiona] Maybe I'm missing something, but won't this fall through to RSA_NO_PADDING for OAEP and PSS cases?
 
//snip//

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-07-03 14:50   ` Trahe, Fiona
@ 2018-07-03 14:59     ` Verma, Shally
  2018-07-03 15:11       ` Trahe, Fiona
  0 siblings, 1 reply; 44+ messages in thread
From: Verma, Shally @ 2018-07-03 14:59 UTC (permalink / raw)
  To: Trahe, Fiona, De Lara Guarch, Pablo
  Cc: akhil.goyal, dev, Athreya, Narayana Prasad, Sahu, Sunila, Gupta, Ashish



>-----Original Message-----
>From: Trahe, Fiona [mailto:fiona.trahe@intel.com]
>Sent: 03 July 2018 20:21
>To: Verma, Shally <Shally.Verma@cavium.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>Cc: akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>; Trahe, Fiona <fiona.trahe@intel.com>
>Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
>
>External Email
>
>Hi Shally,
>
>> -----Original Message-----
>> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
>> Sent: Wednesday, May 16, 2018 7:05 AM
>> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org;
>> pathreya@caviumnetworks.com; Sunila Sahu <sunila.sahu@caviumnetworks.com>; Ashish Gupta
>> <ashish.gupta@caviumnetworks.com>
>> Subject: [PATCH v3 5/6] crypto/openssl: add asym crypto support
>>
>> Add asymmetric crypto operation support in openssl PMD.
>> Current list of supported asym xforms:
>> * RSA
>> * DSA
>> * Deffie-hellman
>> * Modular Operations
>>
>> changes from v2:
>> - Update the pmd capability as per new capability structure
>>
>> changes from v1:
>> - resolve new line error in dod/guides/cryptodevs/openssl.rst
>>
>> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
>> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
>> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
>
>
>//snip//
>> +/* process rsa operations */
>> +static int process_openssl_rsa_op(struct rte_crypto_op *cop,
>> +                               struct openssl_asym_session *sess)
>> +{
>> +     int ret = 0;
>> +     struct rte_crypto_asym_op *op = cop->asym;
>> +     RSA *rsa = sess->u.r.rsa;
>> +     uint32_t pad = (op->rsa.pad);
>> +
>> +     switch (pad) {
>> +     case RTE_CRYPTO_RSA_PKCS1_V1_5_BT1:
>> +     case RTE_CRYPTO_RSA_PKCS1_V1_5_BT2:
>> +             pad = RSA_PKCS1_PADDING;
>> +             break;
>> +     case RTE_CRYPTO_RSA_PADDING_PSS:
>> +             pad = RSA_PKCS1_PSS_PADDING;
>> +             /* fall through */
>> +     case RTE_CRYPTO_RSA_PADDING_OAEP:
>> +             pad = RSA_PKCS1_OAEP_PADDING;
>> +             /* fall through */
>> +     default:
>> +             pad = RSA_NO_PADDING;
>> +             break;
>[Fiona] Maybe I'm missing something, but won't this fall through to RSA_NO_PADDING for OAEP and PSS cases?
>
>//snip//
Yes. It will because we were not claiming OAEP/PSS support in 1st cut. Also, So, made them switched to no-padding. 
However, openssl PMD asym changes , as such, is on hold until it is moved that to 1.1.0. So, we will submit  PMD and testapp as a separate patches from 
Lib patch series.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-07-03 14:59     ` Verma, Shally
@ 2018-07-03 15:11       ` Trahe, Fiona
  2018-07-03 15:14         ` Verma, Shally
  0 siblings, 1 reply; 44+ messages in thread
From: Trahe, Fiona @ 2018-07-03 15:11 UTC (permalink / raw)
  To: Verma, Shally, De Lara Guarch, Pablo
  Cc: akhil.goyal, dev, Athreya, Narayana Prasad, Sahu, Sunila, Gupta, Ashish



> -----Original Message-----
> From: Verma, Shally [mailto:Shally.Verma@cavium.com]
> Sent: Tuesday, July 3, 2018 4:00 PM
> To: Trahe, Fiona <fiona.trahe@intel.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila <Sunila.Sahu@cavium.com>; Gupta, Ashish
> <Ashish.Gupta@cavium.com>
> Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> 
> 
> 
> >-----Original Message-----
> >From: Trahe, Fiona [mailto:fiona.trahe@intel.com]
> >Sent: 03 July 2018 20:21
> >To: Verma, Shally <Shally.Verma@cavium.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> >Cc: akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad
> <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
> ><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>; Trahe, Fiona
> <fiona.trahe@intel.com>
> >Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> >
> >External Email
> >
> >Hi Shally,
> >
> >> -----Original Message-----
> >> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> >> Sent: Wednesday, May 16, 2018 7:05 AM
> >> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> >> Cc: Trahe, Fiona <fiona.trahe@intel.com>; akhil.goyal@nxp.com; dev@dpdk.org;
> >> pathreya@caviumnetworks.com; Sunila Sahu <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> >> <ashish.gupta@caviumnetworks.com>
> >> Subject: [PATCH v3 5/6] crypto/openssl: add asym crypto support
> >>
> >> Add asymmetric crypto operation support in openssl PMD.
> >> Current list of supported asym xforms:
> >> * RSA
> >> * DSA
> >> * Deffie-hellman
> >> * Modular Operations
> >>
> >> changes from v2:
> >> - Update the pmd capability as per new capability structure
> >>
> >> changes from v1:
> >> - resolve new line error in dod/guides/cryptodevs/openssl.rst
> >>
> >> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> >> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> >> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> >
> >
> >//snip//
> >> +/* process rsa operations */
> >> +static int process_openssl_rsa_op(struct rte_crypto_op *cop,
> >> +                               struct openssl_asym_session *sess)
> >> +{
> >> +     int ret = 0;
> >> +     struct rte_crypto_asym_op *op = cop->asym;
> >> +     RSA *rsa = sess->u.r.rsa;
> >> +     uint32_t pad = (op->rsa.pad);
> >> +
> >> +     switch (pad) {
> >> +     case RTE_CRYPTO_RSA_PKCS1_V1_5_BT1:
> >> +     case RTE_CRYPTO_RSA_PKCS1_V1_5_BT2:
> >> +             pad = RSA_PKCS1_PADDING;
> >> +             break;
> >> +     case RTE_CRYPTO_RSA_PADDING_PSS:
> >> +             pad = RSA_PKCS1_PSS_PADDING;
> >> +             /* fall through */
> >> +     case RTE_CRYPTO_RSA_PADDING_OAEP:
> >> +             pad = RSA_PKCS1_OAEP_PADDING;
> >> +             /* fall through */
> >> +     default:
> >> +             pad = RSA_NO_PADDING;
> >> +             break;
> >[Fiona] Maybe I'm missing something, but won't this fall through to RSA_NO_PADDING for OAEP and
> PSS cases?
> >
> >//snip//
> Yes. It will because we were not claiming OAEP/PSS support in 1st cut. Also, So, made them switched to
> no-padding.
> However, openssl PMD asym changes , as such, is on hold until it is moved that to 1.1.0. So, we will
> submit  PMD and testapp as a separate patches from
> Lib patch series.
> 
[Fiona] ok. I'd suggest leaving out the "pad = " in the 2 fall-through cases. And expanding comment to 
"Not supported yet, so fall-through" for more clarity.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support
  2018-07-03 15:11       ` Trahe, Fiona
@ 2018-07-03 15:14         ` Verma, Shally
  0 siblings, 0 replies; 44+ messages in thread
From: Verma, Shally @ 2018-07-03 15:14 UTC (permalink / raw)
  To: Trahe, Fiona, De Lara Guarch, Pablo
  Cc: akhil.goyal, dev, Athreya, Narayana Prasad, Sahu, Sunila, Gupta, Ashish



>-----Original Message-----
>From: Trahe, Fiona [mailto:fiona.trahe@intel.com]
>Sent: 03 July 2018 20:41
>To: Verma, Shally <Shally.Verma@cavium.com>; De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
>Cc: akhil.goyal@nxp.com; dev@dpdk.org; Athreya, Narayana Prasad <NarayanaPrasad.Athreya@cavium.com>; Sahu, Sunila
><Sunila.Sahu@cavium.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
>Subject: RE: [PATCH v3 5/6] crypto/openssl: add asym crypto support
>
>External Email
>
//snip

>> >> +/* process rsa operations */
>> >> +static int process_openssl_rsa_op(struct rte_crypto_op *cop,
>> >> +                               struct openssl_asym_session *sess)
>> >> +{
>> >> +     int ret = 0;
>> >> +     struct rte_crypto_asym_op *op = cop->asym;
>> >> +     RSA *rsa = sess->u.r.rsa;
>> >> +     uint32_t pad = (op->rsa.pad);
>> >> +
>> >> +     switch (pad) {
>> >> +     case RTE_CRYPTO_RSA_PKCS1_V1_5_BT1:
>> >> +     case RTE_CRYPTO_RSA_PKCS1_V1_5_BT2:
>> >> +             pad = RSA_PKCS1_PADDING;
>> >> +             break;
>> >> +     case RTE_CRYPTO_RSA_PADDING_PSS:
>> >> +             pad = RSA_PKCS1_PSS_PADDING;
>> >> +             /* fall through */
>> >> +     case RTE_CRYPTO_RSA_PADDING_OAEP:
>> >> +             pad = RSA_PKCS1_OAEP_PADDING;
>> >> +             /* fall through */
>> >> +     default:
>> >> +             pad = RSA_NO_PADDING;
>> >> +             break;
>> >[Fiona] Maybe I'm missing something, but won't this fall through to RSA_NO_PADDING for OAEP and
>> PSS cases?
>> >
>> >//snip//
>> Yes. It will because we were not claiming OAEP/PSS support in 1st cut. Also, So, made them switched to
>> no-padding.
>> However, openssl PMD asym changes , as such, is on hold until it is moved that to 1.1.0. So, we will
>> submit  PMD and testapp as a separate patches from
>> Lib patch series.
>>
>[Fiona] ok. I'd suggest leaving out the "pad = " in the 2 fall-through cases. And expanding comment to
>"Not supported yet, so fall-through" for more clarity.
All right. noted.

Thanks
Shally

^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2018-07-03 15:14 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-16  6:05 [dpdk-dev] [PATCH v3 0/6] crypto: add asym crypto support Shally Verma
2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 1/6] lib/cryptodev: add asymmetric algos in cryptodev Shally Verma
2018-06-15  8:40   ` De Lara Guarch, Pablo
2018-06-22 15:38     ` Verma, Shally
2018-06-25 21:34       ` De Lara Guarch, Pablo
2018-06-26 11:54         ` Verma, Shally
2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 2/6] lib/cryptodev: add asym op support " Shally Verma
2018-06-15  9:05   ` De Lara Guarch, Pablo
2018-06-26  9:20   ` De Lara Guarch, Pablo
2018-06-26 11:21     ` Verma, Shally
2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 3/6] lib/cryptodev: add asymmetric crypto capability " Shally Verma
2018-06-17 12:11   ` De Lara Guarch, Pablo
2018-07-03 14:12   ` Trahe, Fiona
2018-07-03 14:47     ` Verma, Shally
2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 4/6] test/crypto: add unit testcase for asym crypto Shally Verma
2018-06-17 12:52   ` De Lara Guarch, Pablo
2018-06-17 15:01     ` Verma, Shally
2018-06-17 19:31       ` De Lara Guarch, Pablo
2018-06-18  5:40         ` Verma, Shally
2018-06-18  6:39           ` Akhil Goyal
2018-06-18  6:48             ` Verma, Shally
2018-06-18  7:34               ` Akhil Goyal
2018-06-18  8:38                 ` De Lara Guarch, Pablo
2018-06-18 16:22                   ` Verma, Shally
2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 5/6] crypto/openssl: add asym crypto support Shally Verma
2018-06-17 13:25   ` De Lara Guarch, Pablo
2018-06-17 15:48     ` Verma, Shally
2018-06-17 19:38       ` De Lara Guarch, Pablo
2018-06-18  5:30         ` Verma, Shally
2018-06-23 12:41           ` Verma, Shally
2018-06-23 18:16             ` De Lara Guarch, Pablo
2018-06-23 18:26               ` Verma, Shally
2018-06-25 16:35                 ` De Lara Guarch, Pablo
2018-06-26  9:23   ` De Lara Guarch, Pablo
2018-06-26 11:22     ` Verma, Shally
2018-07-03 14:50   ` Trahe, Fiona
2018-07-03 14:59     ` Verma, Shally
2018-07-03 15:11       ` Trahe, Fiona
2018-07-03 15:14         ` Verma, Shally
2018-05-16  6:05 ` [dpdk-dev] [PATCH v3 6/6] doc: add asym crypto in cryptodev programmer guide Shally Verma
2018-06-14 10:43   ` Kovacevic, Marko
2018-06-15  8:06     ` Verma, Shally
2018-06-17 13:33   ` De Lara Guarch, Pablo
2018-06-17 16:59     ` Verma, Shally

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).