DPDK patches and discussions
 help / color / mirror / Atom feed
From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
To: Shally Verma <shally.verma@caviumnetworks.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"pathreya@caviumnetworks.com" <pathreya@caviumnetworks.com>,
	Sunila Sahu <sunila.sahu@caviumnetworks.com>,
	Ashish Gupta <ashish.gupta@caviumnetworks.com>
Subject: Re: [dpdk-dev] [PATCH v4 1/2] test/crypto: add rsa and mod test application
Date: Mon, 9 Jul 2018 22:14:07 +0000	[thread overview]
Message-ID: <E115CCD9D858EF4F90C690B0DCB4D8977F8ED5A0@IRSMSX107.ger.corp.intel.com> (raw)
In-Reply-To: <1530806060-31227-2-git-send-email-shally.verma@caviumnetworks.com>



> -----Original Message-----
> From: Shally Verma [mailto:shally.verma@caviumnetworks.com]
> Sent: Thursday, July 5, 2018 4:54 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: dev@dpdk.org; pathreya@caviumnetworks.com; Sunila Sahu
> <sunila.sahu@caviumnetworks.com>; Ashish Gupta
> <ashish.gupta@caviumnetworks.com>
> Subject: [PATCH v4 1/2] test/crypto: add rsa and mod test application
> 
> From: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> 
> Test application include test case for :
> - RSA encrypt, decrypt, sign and verify
> - Modular Inversion and Exponentiation
> 
> Test cases uses predefined test vectors.
> 
> Signed-off-by: Sunila Sahu <sunila.sahu@caviumnetworks.com>
> Signed-off-by: Shally Verma <shally.verma@caviumnetworks.com>
> Signed-off-by: Ashish Gupta <ashish.gupta@caviumnetworks.com>
> ---
>  test/test/Makefile                          |   1 +
>  test/test/meson.build                       |   1 +
>  test/test/test_cryptodev_asym.c             | 836
> ++++++++++++++++++++++++++++
>  test/test/test_cryptodev_asym_util.h        |  45 ++
>  test/test/test_cryptodev_mod_test_vectors.h | 103 ++++
> test/test/test_cryptodev_rsa_test_vectors.h |  90 +++
>  6 files changed, 1076 insertions(+)
> 
> diff --git a/test/test/Makefile b/test/test/Makefile index eccc8ef..d6fb88f
> 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 diff --git
> a/test/test/meson.build b/test/test/meson.build index a907fd2..06cd6f7 100644
> --- a/test/test/meson.build
> +++ b/test/test/meson.build
> @@ -22,6 +22,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 0000000..9b6ffac
> --- /dev/null
> +++ b/test/test/test_cryptodev_asym.c
> @@ -0,0 +1,836 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(c) 2018 Cavium Networks
> + */
> +
> +#include <rte_bus_vdev.h>
> +#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_cryptodev.h>
> +#include <rte_cryptodev_pmd.h>
> +#include <rte_crypto.h>
> +
> +#include "test_cryptodev.h"
> +#include "test_cryptodev_mod_test_vectors.h"
> +#include "test_cryptodev_rsa_test_vectors.h"
> +#include "test_cryptodev_asym_util.h"
> +#include "test.h"
> +
> +#define TEST_NUM_BUFS 10
> +#define TEST_NUM_SESSIONS 4
> +#define ASYM_TEST_MSG_LEN	256
> +
> +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 };
> +
> +static int
> +test_rsa_sign_verify(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;
> +	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");

Shouldn't this be printf/RTE_LOG? Afaik, you are just printing into test_msg,
but not showing that in the screen.

> +		status = TEST_FAILED;
> +		goto error_exit;
> +	}

...

> +	}
> +
> +	/* print xfrm capability */

Use "xform".

...

> +++ b/test/test/test_cryptodev_asym_util.h

...

> +
> +static inline int verify_modexp(uint8_t *mod_exp,
> +		struct rte_crypto_op *result_op)
> +{
> +	int ret = 0;
> +	if (memcmp(mod_exp, result_op->asym->modex.base.data,
> +				result_op->asym->modex.base.length))
> +		ret = -1;
> +	return ret;

Ret variable is not required. Just return -1 inside if, and 0 outside.

...

> diff --git a/test/test/test_cryptodev_rsa_test_vectors.h
> b/test/test/test_cryptodev_rsa_test_vectors.h

...

> +		{
> +			.d = {
> +				.data = rsa_d,
> +				.length = sizeof(rsa_d)
> +			},
> +		}

These outer braces are not needed.

  parent reply	other threads:[~2018-07-09 22:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05 15:54 [dpdk-dev] [PATCH v4 0/2] test/crypto: add testcase for asym crypto Shally Verma
2018-07-05 15:54 ` [dpdk-dev] [PATCH v4 1/2] test/crypto: add rsa and mod test application Shally Verma
2018-07-09 18:16   ` De Lara Guarch, Pablo
2018-07-09 22:14   ` De Lara Guarch, Pablo [this message]
2018-07-05 15:54 ` [dpdk-dev] [PATCH v4 2/2] test/crypto: add dh and dsa " Shally Verma
2018-07-09 22:14   ` De Lara Guarch, Pablo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E115CCD9D858EF4F90C690B0DCB4D8977F8ED5A0@IRSMSX107.ger.corp.intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=ashish.gupta@caviumnetworks.com \
    --cc=dev@dpdk.org \
    --cc=pathreya@caviumnetworks.com \
    --cc=shally.verma@caviumnetworks.com \
    --cc=sunila.sahu@caviumnetworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).