[v1] examples/fips_validation: fix SHA MCT test from segfault
Dooley, Brian
brian.dooley at intel.com
Fri Sep 23 18:25:31 CEST 2022
> -----Original Message-----
> From: Gowrishankar Muthukrishnan <gmuthukrishn at marvell.com>
> Sent: Friday, September 16, 2022 3:02 PM
> To: dev at dpdk.org
> Cc: Anoob Joseph <anoobj at marvell.com>; Zhang, Roy Fan
> <roy.fan.zhang at intel.com>; Dooley, Brian <brian.dooley at intel.com>; Akhil
> Goyal <gakhil at marvell.com>; jerinj at marvell.com; Gowrishankar
> Muthukrishnan <gmuthukrishn at marvell.com>
> Subject: [v1] examples/fips_validation: fix SHA MCT test from segfault
>
> In case of FIPS 140-2 format of test vectors in MCT test, msg is not given in
> the test vector, hence pt will be NULL which test function has to handle
> correctly.
>
> Fixes: d5c247145c2c ("examples/fips_validation: add parsing for SHA")
>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn at marvell.com>
> ---
> examples/fips_validation/main.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/examples/fips_validation/main.c
> b/examples/fips_validation/main.c index 8bd5a66889..cab3dd22b9 100644
> --- a/examples/fips_validation/main.c
> +++ b/examples/fips_validation/main.c
> @@ -1696,13 +1696,14 @@ fips_mct_sha_test(void)
> /* val[0] is op result and other value is for parse_writeback callback
> */
> struct fips_val val[2] = {{NULL, 0},};
> struct fips_val md[SHA_MD_BLOCK], msg;
> - char temp[MAX_DIGEST_SIZE*2];
> int ret;
> uint32_t i, j;
>
> msg.len = SHA_MD_BLOCK * vec.cipher_auth.digest.len;
> msg.val = calloc(1, msg.len);
> - memcpy(vec.cipher_auth.digest.val, vec.pt.val,
> vec.cipher_auth.digest.len);
> + if (vec.pt.val)
> + memcpy(vec.cipher_auth.digest.val, vec.pt.val,
> +vec.cipher_auth.digest.len);
> +
> for (i = 0; i < SHA_MD_BLOCK; i++)
> md[i].val = rte_malloc(NULL, (MAX_DIGEST_SIZE*2), 0);
>
> @@ -1769,14 +1770,15 @@ fips_mct_sha_test(void)
> memcpy(vec.cipher_auth.digest.val, md[2].val, md[2].len);
> vec.cipher_auth.digest.len = md[2].len;
>
> - if (info.file_type != FIPS_TYPE_JSON) {
> + if (info.file_type != FIPS_TYPE_JSON)
> fprintf(info.fp_wr, "COUNT = %u\n", j);
> - writeback_hex_str("", temp,
> &vec.cipher_auth.digest);
> - fprintf(info.fp_wr, "MD = %s\n\n", temp);
> - }
> +
> val[1].val = msg.val;
> val[1].len = msg.len;
> info.parse_writeback(val);
> +
> + if (info.file_type != FIPS_TYPE_JSON)
> + fprintf(info.fp_wr, "\n");
> }
>
> for (i = 0; i < (SHA_MD_BLOCK); i++)
> --
> 2.25.1
LGTM
Tested-by: Brian Dooley <brian.dooley at intel.com>
More information about the dev
mailing list