DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
To: Brandon Lo <blo@iol.unh.edu>,
	"roy.fan.zhang@intel.com" <roy.fan.zhang@intel.com>,
	"ciara.power@intel.com" <ciara.power@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, Akhil Goyal <gakhil@marvell.com>
Subject: RE: [EXT] [PATCH v4 6/8] examples/fips_validation: add json to hmac
Date: Wed, 18 May 2022 15:45:51 +0000	[thread overview]
Message-ID: <CO1PR18MB4714255838EE4A608382B113CBD19@CO1PR18MB4714.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20220429161559.415645-7-blo@iol.unh.edu>

Verified the functionality changes and looks good to me.

Acked-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Thanks.

> -----Original Message-----
> From: Brandon Lo <blo@iol.unh.edu>
> Sent: Friday, April 29, 2022 9:46 PM
> To: roy.fan.zhang@intel.com; ciara.power@intel.com
> Cc: dev@dpdk.org; Brandon Lo <blo@iol.unh.edu>
> Subject: [EXT] [PATCH v4 6/8] examples/fips_validation: add json to hmac
> 
> External Email
> 
> ----------------------------------------------------------------------
> Adds JSON support for the HMAC algorithm.
> 
> Signed-off-by: Brandon Lo <blo@iol.unh.edu>
> ---
>  examples/fips_validation/fips_validation.c    |  2 +
>  examples/fips_validation/fips_validation.h    |  6 ++
>  .../fips_validation/fips_validation_hmac.c    | 93 +++++++++++++++++++
>  examples/fips_validation/main.c               |  3 +
>  4 files changed, 104 insertions(+)
> 
> diff --git a/examples/fips_validation/fips_validation.c
> b/examples/fips_validation/fips_validation.c
> index d220dcab1f..04dfb85262 100644
> --- a/examples/fips_validation/fips_validation.c
> +++ b/examples/fips_validation/fips_validation.c
> @@ -458,6 +458,8 @@ fips_test_parse_one_json_vector_set(void)
>  	/* Vector sets contain the algorithm type, and nothing else we need.
> */
>  	if (strstr(algo_str, "AES-GCM"))
>  		info.algo = FIPS_TEST_ALGO_AES_GCM;
> +	if (strstr(algo_str, "HMAC"))
> +		info.algo = FIPS_TEST_ALGO_HMAC;
>  	else
>  		return -EINVAL;
> 
> diff --git a/examples/fips_validation/fips_validation.h
> b/examples/fips_validation/fips_validation.h
> index 8d7af99e04..2c65d838b0 100644
> --- a/examples/fips_validation/fips_validation.h
> +++ b/examples/fips_validation/fips_validation.h
> @@ -253,6 +253,12 @@ fips_test_parse_one_json_case(void);
> 
>  int
>  parse_test_gcm_json_init(void);
> +
> +int
> +parse_test_hmac_json_init(void);
> +
> +int
> +parse_test_hmac_json_algorithm(void);
>  #endif /* RTE_HAS_JANSSON */
> 
>  int
> diff --git a/examples/fips_validation/fips_validation_hmac.c
> b/examples/fips_validation/fips_validation_hmac.c
> index 1285c9d283..4cd1b1ac07 100644
> --- a/examples/fips_validation/fips_validation_hmac.c
> +++ b/examples/fips_validation/fips_validation_hmac.c
> @@ -19,6 +19,15 @@
>  #define PT_STR		"Msg = "
>  #define TAG_STR		"Mac = "
> 
> +#define ALGO_JSON_STR	"algorithm"
> +
> +#define KEYLEN_JSON_STR	"keyLen"
> +#define TAGLEN_JSON_STR	"macLen"
> +
> +#define KEY_JSON_STR	"key"
> +#define PT_JSON_STR		"msg"
> +#define TAG_JSON_STR	"mac"
> +
>  struct hash_size_conversion {
>  	const char *str;
>  	enum rte_crypto_auth_algorithm algo;
> @@ -65,6 +74,29 @@ struct fips_test_callback hmac_tests_interim_vectors[]
> = {
>  		{NULL, NULL, NULL} /**< end pointer */  };
> 
> +#ifdef RTE_HAS_JANSSON
> +struct hash_size_conversion json_algorithms[] = {
> +		{"HMAC-SHA-1", RTE_CRYPTO_AUTH_SHA1_HMAC},
> +		{"HMAC-SHA2-224", RTE_CRYPTO_AUTH_SHA224_HMAC},
> +		{"HMAC-SHA2-256", RTE_CRYPTO_AUTH_SHA256_HMAC},
> +		{"HMAC-SHA2-384", RTE_CRYPTO_AUTH_SHA384_HMAC},
> +		{"HMAC-SHA2-512", RTE_CRYPTO_AUTH_SHA512_HMAC}, };
> +
> +struct fips_test_callback hmac_tests_json_vectors[] = {
> +		{KEY_JSON_STR, parse_uint8_hex_str,
> &vec.cipher_auth.key},
> +		{PT_JSON_STR, parse_uint8_hex_str, &vec.pt},
> +		{TAG_JSON_STR, parse_uint8_hex_str,
> &vec.cipher_auth.digest},
> +		{NULL, NULL, NULL} /**< end pointer */ };
> +
> +struct fips_test_callback hmac_tests_interim_json_vectors[] = {
> +		{KEYLEN_JSON_STR, parser_read_uint32_val,
> &vec.cipher_auth.key},
> +		{TAGLEN_JSON_STR, parser_read_uint32_bit_val,
> &vec.cipher_auth.digest},
> +		{NULL, NULL, NULL} /**< end pointer */ }; #endif /*
> RTE_HAS_JANSSON
> +*/
> +
>  static int
>  parse_test_hmac_writeback(struct fips_val *val)  { @@ -103,3 +135,64 @@
> parse_test_hmac_init(void)
> 
>  	return 0;
>  }
> +
> +#ifdef RTE_HAS_JANSSON
> +static int
> +parse_test_hmac_json_writeback(struct fips_val *val) {
> +	struct fips_val val_local;
> +	json_t *tcId, *mac;
> +
> +	tcId = json_object_get(json_info.json_test_case, "tcId");
> +
> +	json_info.json_write_case = json_object();
> +	json_object_set(json_info.json_write_case, "tcId", tcId);
> +
> +
> +	val_local.val = val->val + vec.pt.len;
> +	val_local.len = vec.cipher_auth.digest.len;
> +
> +	writeback_hex_str("", info.one_line_text, &val_local);
> +
> +	mac = json_string(info.one_line_text);
> +	json_object_set_new(json_info.json_write_case, TAG_JSON_STR,
> mac);
> +
> +	return 0;
> +}
> +
> +int
> +parse_test_hmac_json_algorithm(void)
> +{
> +	json_t *algorithm_object;
> +	const char *algorithm_str;
> +	uint32_t i;
> +
> +	algorithm_object = json_object_get(json_info.json_vector_set,
> "algorithm");
> +	algorithm_str = json_string_value(algorithm_object);
> +
> +	for (i = 0; i < RTE_DIM(json_algorithms); i++) {
> +		if (strstr(algorithm_str, json_algorithms[i].str)) {
> +			info.interim_info.hmac_data.algo =
> json_algorithms[i].algo;
> +			return 0;
> +		}
> +	}
> +
> +	return -1;
> +}
> +
> +int
> +parse_test_hmac_json_init(void)
> +{
> +	info.op = FIPS_TEST_ENC_AUTH_GEN;
> +	info.parse_writeback = parse_test_hmac_json_writeback;
> +	info.callbacks = hmac_tests_json_vectors;
> +	info.writeback_callbacks = NULL;
> +	info.kat_check = rsp_test_hmac_check;
> +	info.interim_callbacks = hmac_tests_interim_json_vectors;
> +
> +	if (parse_test_hmac_json_algorithm() < 0)
> +		return -1;
> +
> +	return 0;
> +}
> +#endif /* RTE_HAS_JANSSON */
> diff --git a/examples/fips_validation/main.c
> b/examples/fips_validation/main.c index a1d8a1d758..de6dedaf75 100644
> --- a/examples/fips_validation/main.c
> +++ b/examples/fips_validation/main.c
> @@ -1943,6 +1943,9 @@ fips_test_one_test_group(void)
>  	case FIPS_TEST_ALGO_AES_GCM:
>  		ret = parse_test_gcm_json_init();
>  		break;
> +	case FIPS_TEST_ALGO_HMAC:
> +		ret = parse_test_hmac_json_init();
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> --
> 2.25.1


  reply	other threads:[~2022-05-18 15:46 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 14:51 [PATCH 0/5] Add JSON vector set support to fips validation Brandon Lo
2022-01-27 14:51 ` [PATCH 1/5] examples/fips_validation: add jansson dependency Brandon Lo
2022-01-27 14:51 ` [PATCH 2/5] examples/fips_validation: add json info to header Brandon Lo
2022-01-27 14:51 ` [PATCH 3/5] examples/fips_validation: add json parsing Brandon Lo
2022-01-27 14:51 ` [PATCH 4/5] examples/fips_validation: allow json file as input Brandon Lo
2022-01-27 14:51 ` [PATCH 5/5] examples/fips_validation: add json to gcm test Brandon Lo
2022-01-29 17:03 ` [PATCH v2 0/5] Add JSON vector set support to fips validation Brandon Lo
2022-01-29 17:03   ` [PATCH v2 1/5] examples/fips_validation: add jansson dependency Brandon Lo
2022-01-29 17:03   ` [PATCH v2 2/5] examples/fips_validation: add json info to header Brandon Lo
2022-01-29 17:03   ` [PATCH v2 3/5] examples/fips_validation: add json parsing Brandon Lo
2022-01-29 17:03   ` [PATCH v2 4/5] examples/fips_validation: allow json file as input Brandon Lo
2022-01-29 17:03   ` [PATCH v2 5/5] examples/fips_validation: add json to gcm test Brandon Lo
2022-01-29 17:55   ` [PATCH v3 0/5] Add JSON vector set support to fips validation Brandon Lo
2022-01-29 17:55     ` [PATCH v3 1/5] examples/fips_validation: add jansson dependency Brandon Lo
2022-01-29 17:55     ` [PATCH v3 2/5] examples/fips_validation: add json info to header Brandon Lo
2022-01-29 17:55     ` [PATCH v3 3/5] examples/fips_validation: add json parsing Brandon Lo
2022-01-29 17:55     ` [PATCH v3 4/5] examples/fips_validation: allow json file as input Brandon Lo
2022-01-29 17:55     ` [PATCH v3 5/5] examples/fips_validation: add json to gcm test Brandon Lo
2022-02-02 15:15     ` [PATCH v3 0/5] Add JSON vector set support to fips validation Brandon Lo
     [not found]       ` <MN2PR11MB382152E7C1DAFD68066264DEE62F9@MN2PR11MB3821.namprd11.prod.outlook.com>
     [not found]         ` <CAOeXdvZFkEUn-e2Reo3xg519qWpGq-UbYFhJqVeEMcXVxK7+YQ@mail.gmail.com>
     [not found]           ` <CAOeXdvZ4nBudX+bMdRASaLp=c955vUHi1Z-geUC6gFvE__2ozg@mail.gmail.com>
     [not found]             ` <CAOeXdvZbwW2tP-vyELRJza_imjjRm-JNYu+c4=-y2VtigqNg5A@mail.gmail.com>
2022-04-14 13:41               ` Brandon Lo
2022-04-21  8:02                 ` [EXT] " Gowrishankar Muthukrishnan
2022-04-26 14:30                   ` Brandon Lo
2022-02-08 21:48     ` [EXT] " Akhil Goyal
2022-04-29 16:15     ` [PATCH v4 0/8] " Brandon Lo
2022-04-29 16:15       ` [PATCH v4 1/8] examples/fips_validation: add jansson dependency Brandon Lo
2022-05-18 15:44         ` [EXT] " Gowrishankar Muthukrishnan
2022-04-29 16:15       ` [PATCH v4 2/8] examples/fips_validation: add json info to header Brandon Lo
2022-05-18 15:44         ` [EXT] " Gowrishankar Muthukrishnan
2022-04-29 16:15       ` [PATCH v4 3/8] examples/fips_validation: add json parsing Brandon Lo
2022-05-18 15:45         ` [EXT] " Gowrishankar Muthukrishnan
2022-04-29 16:15       ` [PATCH v4 4/8] examples/fips_validation: allow json file as input Brandon Lo
2022-05-18 15:45         ` [EXT] " Gowrishankar Muthukrishnan
2022-05-19  5:30         ` Gowrishankar Muthukrishnan
2022-05-19  9:12           ` Gowrishankar Muthukrishnan
2022-04-29 16:15       ` [PATCH v4 5/8] examples/fips_validation: add json to gcm test Brandon Lo
2022-05-18 15:45         ` [EXT] " Gowrishankar Muthukrishnan
2022-04-29 16:15       ` [PATCH v4 6/8] examples/fips_validation: add json to hmac Brandon Lo
2022-05-18 15:45         ` Gowrishankar Muthukrishnan [this message]
2022-04-29 16:15       ` [PATCH v4 7/8] examples/fips_validation: implement json cmac test Brandon Lo
2022-05-18 15:46         ` [EXT] " Gowrishankar Muthukrishnan
2022-04-29 16:15       ` [PATCH v4 8/8] examples/fips_validation: add parsing for cmac Brandon Lo
2022-05-18 15:46         ` [EXT] " Gowrishankar Muthukrishnan
2022-05-19  5:31         ` Gowrishankar Muthukrishnan
2022-05-19  9:11           ` Gowrishankar Muthukrishnan
2022-04-29 16:19       ` [PATCH v4 0/8] Add JSON vector set support to fips validation Brandon Lo
2022-05-25 15:45       ` [v5, 00/11] " Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 01/11] examples/fips_validation: add jansson dependency Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 02/11] examples/fips_validation: add json info to header Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 03/11] examples/fips_validation: add json parsing Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 04/11] examples/fips_validation: allow json file as input Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 05/11] examples/fips_validation: add json to gcm test Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 06/11] examples/fips_validation: add json to hmac Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 07/11] examples/fips_validation: implement json cmac test Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 08/11] examples/fips_validation: add parsing for cmac Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 09/11] examples/fips_validation: cleanup bypass tests in response file Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 10/11] examples/fips_validation: reset IV generation in every test group Gowrishankar Muthukrishnan
2022-05-25 15:45         ` [v5, 11/11] examples/fips_validation: add parsing for aes_cbc Gowrishankar Muthukrishnan
2022-05-25 17:08           ` [v5,11/11] " Gowrishankar Muthukrishnan
2022-05-25 17:13         ` [v6, 00/11] Add JSON vector set support to fips validation Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 01/11] examples/fips_validation: add jansson dependency Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 02/11] examples/fips_validation: add json info to header Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 03/11] examples/fips_validation: add json parsing Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 04/11] examples/fips_validation: allow json file as input Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 05/11] examples/fips_validation: add json to gcm test Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 06/11] examples/fips_validation: add json to hmac Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 07/11] examples/fips_validation: implement json cmac test Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 08/11] examples/fips_validation: add parsing for cmac Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 09/11] examples/fips_validation: cleanup bypass tests in response file Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 10/11] examples/fips_validation: reset IV generation in every test group Gowrishankar Muthukrishnan
2022-05-25 17:13           ` [v6, 11/11] examples/fips_validation: add parsing for aes_cbc Gowrishankar Muthukrishnan
2022-05-26  6:46           ` [EXT] [v6, 00/11] Add JSON vector set support to fips validation Akhil Goyal
2022-05-26  8:02           ` [v7, " Gowrishankar Muthukrishnan
2022-05-26  8:02             ` [v7, 01/11] examples/fips_validation: add jansson dependency Gowrishankar Muthukrishnan
2022-05-26  9:46               ` Zhang, Roy Fan
2022-05-26  8:02             ` [v7, 02/11] examples/fips_validation: add json info to header Gowrishankar Muthukrishnan
2022-05-26  9:46               ` Zhang, Roy Fan
2022-05-26  8:02             ` [v7, 03/11] examples/fips_validation: add json parsing Gowrishankar Muthukrishnan
2022-05-26  9:47               ` Zhang, Roy Fan
2022-05-26  8:02             ` [v7, 04/11] examples/fips_validation: allow json file as input Gowrishankar Muthukrishnan
2022-05-26  9:48               ` Zhang, Roy Fan
2022-05-26  8:02             ` [v7, 05/11] examples/fips_validation: add json to gcm test Gowrishankar Muthukrishnan
2022-05-26  9:49               ` Zhang, Roy Fan
2022-05-26  8:02             ` [v7, 06/11] examples/fips_validation: add json to hmac Gowrishankar Muthukrishnan
2022-05-26  9:49               ` Zhang, Roy Fan
2022-05-26  8:02             ` [v7, 07/11] examples/fips_validation: implement json cmac test Gowrishankar Muthukrishnan
2022-05-26  9:49               ` Zhang, Roy Fan
2022-05-26  8:02             ` [v7, 08/11] examples/fips_validation: add parsing for cmac Gowrishankar Muthukrishnan
2022-05-26  9:50               ` Zhang, Roy Fan
2022-05-26  8:02             ` [v7, 09/11] examples/fips_validation: cleanup bypass tests in response file Gowrishankar Muthukrishnan
2022-05-26  8:02             ` [v7, 10/11] examples/fips_validation: reset IV generation in every test group Gowrishankar Muthukrishnan
2022-05-26  8:02             ` [v7, 11/11] examples/fips_validation: add parsing for aes_cbc Gowrishankar Muthukrishnan
2022-05-30 12:23             ` [v8, 00/10] Add JSON vector set support to fips validation Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 01/10] examples/fips_validation: add jansson dependency Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 02/10] examples/fips_validation: add json info to header Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 03/10] examples/fips_validation: add json parsing Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 04/10] examples/fips_validation: allow json file as input Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 05/10] examples/fips_validation: add json to gcm test Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 06/10] examples/fips_validation: add json to hmac Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 07/10] examples/fips_validation: implement json cmac test Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 08/10] examples/fips_validation: add parsing for cmac Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 09/10] examples/fips_validation: add parsing for aes_cbc Gowrishankar Muthukrishnan
2022-05-30 12:23               ` [v8, 10/10] doc: add notes about acvp validation support Gowrishankar Muthukrishnan
2022-05-30 15:52               ` [v9, 00/10] Add JSON vector set support to fips validation Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 01/10] examples/fips_validation: add jansson dependency Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 02/10] examples/fips_validation: add json info to header Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 03/10] examples/fips_validation: add json parsing Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 04/10] examples/fips_validation: allow json file as input Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 05/10] examples/fips_validation: add json to gcm test Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 06/10] examples/fips_validation: add json to hmac Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 07/10] examples/fips_validation: implement json cmac test Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 08/10] examples/fips_validation: add parsing for cmac Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 09/10] examples/fips_validation: add parsing for aes_cbc Gowrishankar Muthukrishnan
2022-05-30 15:52                 ` [v9, 10/10] doc: add notes about acvp validation support Gowrishankar Muthukrishnan
2022-05-31 10:17                 ` [v9, 00/10] Add JSON vector set support to fips validation Poczatek, Jakub
2022-05-31 12:36                 ` Zhang, Roy Fan
2022-05-31 15:23                   ` Akhil Goyal
2022-06-07  9:48                     ` David Marchand
2022-06-13 11:58                       ` David Marchand
2022-06-21  7:28                         ` [EXT] " Gowrishankar Muthukrishnan
2022-06-21  7:36                           ` David Marchand
2022-06-21  7:40                             ` Akhil Goyal
2022-06-21  7:41                               ` David Marchand

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=CO1PR18MB4714255838EE4A608382B113CBD19@CO1PR18MB4714.namprd18.prod.outlook.com \
    --to=gmuthukrishn@marvell.com \
    --cc=blo@iol.unh.edu \
    --cc=ciara.power@intel.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=roy.fan.zhang@intel.com \
    /path/to/YOUR_REPLY

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

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