From patchwork Fri Sep 16 14:01:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 116397 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DC721A0032; Fri, 16 Sep 2022 16:01:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 86B724021D; Fri, 16 Sep 2022 16:01:40 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 3F0E840156 for ; Fri, 16 Sep 2022 16:01:39 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28GBS8R4032643; Fri, 16 Sep 2022 07:01:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=89LxpxQUkzXNV8ocPGWo5qRoH7Gc3psVSdM/y9/A9Lc=; b=X2KXnUKes27+z7HIe/bGS1bYOF7KhcggY2c3nzvn1G1AATgWgmEEpTchL+NGVP3kqErn dj5hsfA6kZ+XRtXBgvlY5BDNI0mTyMeuUtChsfthWGC7LtKLQpgHo+bdEmumf6kSk7wo 9UEedpyFuuLuQRvzGn5G5DJ1R2Pp9C/AvAdlReSRrgupXT+g+8r3nyBNarts531v7TMA 3RRqTIexIKlQMN6jT3i91xGgaz6yDIYzOp7iD9N13tITYXTUHCyyLpPZLdFduQSkHsOU Ve3AQ3vKYc4YkJLPGbi5AIwpRu4HY/IAJUjIESlkDsA5wlmnT00q6BO5kZW0tV7r+1rP 6w== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3jmra0rfnf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 16 Sep 2022 07:01:38 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 16 Sep 2022 07:01:36 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Fri, 16 Sep 2022 07:01:36 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 7A1143F70B1; Fri, 16 Sep 2022 07:01:34 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Anoob Joseph , Fan Zhang , Brian Dooley , Akhil Goyal , , Gowrishankar Muthukrishnan Subject: [v1] examples/fips_validation: fix SHA MCT test from segfault Date: Fri, 16 Sep 2022 19:31:31 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 7mYEu412smIO6wydJijZriJ5tg6H4Xj- X-Proofpoint-GUID: 7mYEu412smIO6wydJijZriJ5tg6H4Xj- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-16_08,2022-09-16_01,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Tested-by: Brian Dooley --- 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++)