From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 762E5A00C2; Tue, 27 Sep 2022 09:26:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15B0242847; Tue, 27 Sep 2022 09:26:30 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 970824280D for ; Tue, 27 Sep 2022 09:26:28 +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 28R3hT9Z016181; Tue, 27 Sep 2022 00:26:27 -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=lEdefXPG7yiXc3U1cIyWm4bKStpSxg73Xg9lebu2OqQ=; b=DEErzZKu+tWiPInff5hAs8NlcHp1rPDE3gu26mdWREFdIqGU9PEKX6ViekGuDhHGHFT8 Cwk5frk+ZRlh/s/BqqNwBhmX9r/3t5sKFnyrSLuQlarytw0YZIRcxUUWZ5asQ1mrqzzt QjJ2O1KYgWvf4Ueoa7z5cr3BQgOueowid1rwmzsUANLZo90ltYVVITa9YxnnCjxwOeyd mcZx+6W+NlI++Cd839nb1XlkekDIswDQ9Np12wDY4C6QuI71OEZDQAj6O7hOLInZopTa xxGzuix9x3ZtmZAIm0DucIJ0iRCCszMvTsNBCAkPv8ExbDPWvV/SRJ8drVl3bN9w3FlV GA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3jt1dp8wpq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 27 Sep 2022 00:26:27 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 27 Sep 2022 00:26:25 -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; Tue, 27 Sep 2022 00:26:25 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 4802A3F707B; Tue, 27 Sep 2022 00:26:23 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Anoob Joseph , Fan Zhang , Brian Dooley , Akhil Goyal , , Gowrishankar Muthukrishnan Subject: [v2 3/7] examples/fips_validation: add function to calculate SHA hash size Date: Tue, 27 Sep 2022 12:56:08 +0530 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: VvMSQQPEXoz-4vLMH_S-6IXleUzIz8u6 X-Proofpoint-GUID: VvMSQQPEXoz-4vLMH_S-6IXleUzIz8u6 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-27_02,2022-09-22_02,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 Acked-by: Brian Dooley --- v2: - fixed include file --- examples/fips_validation/fips_validation.h | 1 + .../fips_validation/fips_validation_sha.c | 39 ++++++++++++------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h index a6288e17e5..6e5f2fce75 100644 --- a/examples/fips_validation/fips_validation.h +++ b/examples/fips_validation/fips_validation.h @@ -374,4 +374,5 @@ int prepare_gcm_xform(struct rte_crypto_sym_xform *xform); int prepare_gmac_xform(struct rte_crypto_sym_xform *xform); +int parse_test_sha_hash_size(enum rte_crypto_auth_algorithm algo); #endif 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; } -- 2.25.1