From patchwork Fri Aug 12 11:57:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 114914 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 42D3BA0543; Fri, 12 Aug 2022 13:57:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B88A42C18; Fri, 12 Aug 2022 13:57:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id C009142C17 for ; Fri, 12 Aug 2022 13:57:37 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27C8KJGm007036; Fri, 12 Aug 2022 04:57:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=aPdazF9QDZPTOjlfr8KWS//TEVabMWlwKC5OpS+0SN4=; b=DK6fExJ/HiODINyTZ78TfYgQ7g+md/WXtL1bA1XykBO0pW9ZPmrTKpv0QLaEOkXY0PGp pNUvOZVbgzLQL6DFnhz1QHvGZqW6inFOVM9VvxvnebcSeWW02aur/fMy74Rx/3HrMzr0 0NEPlNNR874w5S6BEPdKKNZd/DmS/4H3GA/7sKgH2DPnF3YpjtBG9r6eHJ0eNrCbQkb6 Pr4PTHDVgvRQoR5yw1iO7yjMrSUCSf+Gps6UZdEoPEWSVTpKE9HPAkSEGGjhe9krcuBj 2dKyohAoQ3evHeAjA8DBSgqeeQ7XQwGXtnlY3H6V8wQf2CGqN+thhyMMuAyKECxnS1yV Vg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3hwk8wgkeg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 12 Aug 2022 04:57:37 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 12 Aug 2022 04:57:35 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 12 Aug 2022 04:57:35 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id AD69E5B6936; Fri, 12 Aug 2022 04:57:32 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Anoob Joseph , Fan Zhang , Brian Dooley , Akhil Goyal , , Gowrishankar Muthukrishnan Subject: [PATCH v1 3/5] examples/fips_validation: add function to calculate SHA hash size Date: Fri, 12 Aug 2022 17:27:18 +0530 Message-ID: <130d6af982dee864f507c228efc8f696453f2a07.1660304194.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-GUID: ZiSydoF12wW693782rfufRTOCtse8jtp X-Proofpoint-ORIG-GUID: ZiSydoF12wW693782rfufRTOCtse8jtp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-12_08,2022-08-11_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 Add function to calculate hash size for a given SHA hash algorithm. Fixes: d5c247145c2 ("examples/fips_validation: add parsing for SHA") Signed-off-by: Gowrishankar Muthukrishnan --- examples/fips_validation/fips_validation.h | 3 ++ .../fips_validation/fips_validation_sha.c | 39 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h index a6288e17e5..4732341dd3 100644 --- a/examples/fips_validation/fips_validation.h +++ b/examples/fips_validation/fips_validation.h @@ -293,6 +293,9 @@ parse_test_sha_json_algorithm(void); int parse_test_sha_json_test_type(void); +int +parse_test_sha_hash_size(enum rte_crypto_auth_algorithm algo); + int parse_test_tdes_json_init(void); #endif /* USE_JANSSON */ diff --git a/examples/fips_validation/fips_validation_sha.c b/examples/fips_validation/fips_validation_sha.c index 75b073c15d..cac2a25e6c 100644 --- a/examples/fips_validation/fips_validation_sha.c +++ b/examples/fips_validation/fips_validation_sha.c @@ -33,6 +33,22 @@ struct plain_hash_size_conversion { {"64", RTE_CRYPTO_AUTH_SHA512}, }; +int +parse_test_sha_hash_size(enum rte_crypto_auth_algorithm algo) +{ + int ret = -EINVAL; + uint8_t i; + + for (i = 0; i < RTE_DIM(phsc); i++) { + if (phsc[i].algo == algo) { + ret = atoi(phsc[i].str); + break; + } + } + + return ret; +} + static int parse_interim_algo(__rte_unused const char *key, char *text, @@ -212,6 +228,7 @@ parse_test_sha_json_algorithm(void) json_t *algorithm_object; const char *algorithm_str; uint32_t i; + int sz; algorithm_object = json_object_get(json_info.json_vector_set, "algorithm"); algorithm_str = json_string_value(algorithm_object); @@ -226,23 +243,15 @@ parse_test_sha_json_algorithm(void) if (i == RTE_DIM(json_algorithms)) return -1; - for (i = 0; i < RTE_DIM(phsc); i++) { - if (info.interim_info.sha_data.algo == phsc[i].algo) { - vec.cipher_auth.digest.len = atoi(phsc[i].str); - free(vec.cipher_auth.digest.val); - vec.cipher_auth.digest.val = calloc(1, vec.cipher_auth.digest.len); - if (vec.cipher_auth.digest.val == NULL) - return -1; - - break; - } - } + sz = parse_test_sha_hash_size(info.interim_info.sha_data.algo); + if (sz < 0) + return -1; - if (i == RTE_DIM(phsc)) { - free(vec.cipher_auth.digest.val); - vec.cipher_auth.digest.val = NULL; + free(vec.cipher_auth.digest.val); + vec.cipher_auth.digest.len = sz; + vec.cipher_auth.digest.val = calloc(1, sz); + if (vec.cipher_auth.digest.val == NULL) return -1; - } return 0; }