From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
To: <dev@dpdk.org>
Cc: Anoob Joseph <anoobj@marvell.com>,
Fan Zhang <roy.fan.zhang@intel.com>,
Brian Dooley <brian.dooley@intel.com>,
Akhil Goyal <gakhil@marvell.com>, <jerinj@marvell.com>,
Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
Subject: [v1] examples/fips_validation: fix SHA MCT test from segfault
Date: Fri, 16 Sep 2022 19:31:31 +0530 [thread overview]
Message-ID: <cc33a1f1fa1da154bddd019ee5578af7f99df23d.1663336827.git.gmuthukrishn@marvell.com> (raw)
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@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
next reply other threads:[~2022-09-16 14:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 14:01 Gowrishankar Muthukrishnan [this message]
2022-09-23 16:25 ` Dooley, Brian
2022-10-07 9:53 ` Akhil Goyal
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=cc33a1f1fa1da154bddd019ee5578af7f99df23d.1663336827.git.gmuthukrishn@marvell.com \
--to=gmuthukrishn@marvell.com \
--cc=anoobj@marvell.com \
--cc=brian.dooley@intel.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=jerinj@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).