[3/3] test/crypto: check for rsa capa for op-type

Message ID 20190206111405.30860-4-ayverma@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series adding op-type crt sign and decrypt |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ayuj Verma Feb. 6, 2019, 11:16 a.m. UTC
  Add a rsa xform capability check in test functions,
to check for supported sign and decrypt op_types

Signed-off-by: Ayuj Verma <ayverma@marvell.com>
Signed-off-by: Shally Verma <shallyv@marvell.com>
---
 test/test/test_cryptodev_asym.c | 47 +++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
  

Patch

diff --git a/test/test/test_cryptodev_asym.c b/test/test/test_cryptodev_asym.c
index 0f6fc5767..ae1c76db7 100644
--- a/test/test/test_cryptodev_asym.c
+++ b/test/test/test_cryptodev_asym.c
@@ -52,10 +52,33 @@  test_rsa_sign_verify(void)
 	struct rte_crypto_asym_op *asym_op = NULL;
 	struct rte_crypto_op *op = NULL, *result_op = NULL;
 	struct rte_cryptodev_asym_session *sess = NULL;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
 	int status = TEST_SUCCESS;
 	uint8_t output_buf[TEST_DATA_SIZE] = {0};
 	uint8_t input_buf[TEST_DATA_SIZE] = {0};
 
+	/* check for RSA capability */
+	cap_idx.type = RTE_CRYPTO_ASYM_XFORM_RSA;
+	capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
+
+	if (!capability) {
+		RTE_LOG(ERR, USER1,
+				"RSA xform not supported\n");
+				return TEST_SKIPPED;
+	}
+
+	/* test case supports non-crt sign op only,
+	 * so check for it in capability
+	 */
+	if (!rte_cryptodev_asym_xform_capability_check_optype(
+		capability, RTE_CRYPTO_ASYM_OP_SIGN)) {
+		RTE_LOG(ERR, USER1,
+				"non-crt mode RTE_CRYPTO_ASYM_OP_SIGN "
+				"not supported\n");
+				return TEST_SKIPPED;
+		}
+
 	sess = rte_cryptodev_asym_session_create(sess_mpool);
 
 	if (!sess) {
@@ -186,9 +209,33 @@  test_rsa_enc_dec(void)
 	struct rte_crypto_asym_op *asym_op = NULL;
 	struct rte_crypto_op *op = NULL, *result_op = NULL;
 	struct rte_cryptodev_asym_session *sess = NULL;
+	struct rte_cryptodev_asym_capability_idx cap_idx;
+	const struct rte_cryptodev_asymmetric_xform_capability *capability;
 	int status = TEST_SUCCESS;
 	uint8_t input_buf[TEST_DATA_SIZE] = {0};
 
+	/* check for RSA capability */
+	cap_idx.type = RTE_CRYPTO_ASYM_XFORM_RSA;
+	capability = rte_cryptodev_asym_capability_get(dev_id, &cap_idx);
+
+	if (!capability) {
+		RTE_LOG(ERR, USER1,
+				"RSA xform not supported\n");
+				return TEST_SKIPPED;
+	}
+
+	/* test case supports non-crt decrypt op only,
+	 * so check for it in capability
+	 */
+	if (!rte_cryptodev_asym_xform_capability_check_optype(
+		capability, RTE_CRYPTO_ASYM_OP_DECRYPT)) {
+		RTE_LOG(ERR, USER1,
+				"non-crt mode RTE_CRYPTO_ASYM_OP_DECRYPT "
+				"not supported\n");
+				return TEST_SKIPPED;
+		}
+
+
 	sess = rte_cryptodev_asym_session_create(sess_mpool);
 
 	if (!sess) {