From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 9192B1B1FF for ; Mon, 15 Apr 2019 17:04:54 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Apr 2019 08:04:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,354,1549958400"; d="scan'208";a="140836565" Received: from silpixa00399502.ir.intel.com (HELO silpixa00399502.ger.corp.intel.com) ([10.237.222.111]) by fmsmga008.fm.intel.com with ESMTP; 15 Apr 2019 08:04:51 -0700 From: Marko Kovacevic To: dev@dpdk.org Cc: john.mcnamara@intel.com, xinfengx.zhao@intel.com, akhil.goyal@nxp.com, Marko Kovacevic , damianx.nowak@intel.com Date: Mon, 15 Apr 2019 16:04:47 +0100 Message-Id: <20190415150449.44799-1-marko.kovacevic@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190411141656.27720-1-marko.kovacevic@intel.com> References: <20190411141656.27720-1-marko.kovacevic@intel.com> Subject: [dpdk-dev] [PATCH v2 1/3] examples/fips: fix hmac test failure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Apr 2019 15:04:55 -0000 Application was failing as the HMAC and Plain SHA fips request files are similar in a way that they both have SHA- in the top section to determine the hash algo and hash sizes. And HMAC having the algo in the second line but the Plain SHA in the third meant that when the HMAC files was used once it parsed the third line Plain SHA was set as the algo and not HMAC. USER1: Failed to get capability for cdev 0 USER1: Error -22: test block [L=20 SHAAlg=SHA_2] USER1: Error -22: Failed test /root/FIPS/HMAC/req/HMAC.req Fixes: f4797bae0050 ("examples/fips_validation: support plain SHA") Cc: damianx.nowak@intel.com Signed-off-by: Marko Kovacevic --- v2: Fixed checkpatch warning --- examples/fips_validation/fips_validation.c | 80 +++++++++++++++++------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index 2f8314fcc..8d43b267e 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -98,6 +98,7 @@ fips_test_parse_header(void) uint32_t i; char *tmp; int ret; + int algo_parsed = 0; time_t t = time(NULL); struct tm *tm_now = localtime(&t); @@ -106,41 +107,50 @@ fips_test_parse_header(void) return ret; for (i = 0; i < info.nb_vec_lines; i++) { - if (strstr(info.vec[i], "AESVS")) { - info.algo = FIPS_TEST_ALGO_AES; - ret = parse_test_aes_init(); - if (ret < 0) - return ret; - } else if (strstr(info.vec[i], "GCM")) { - info.algo = FIPS_TEST_ALGO_AES_GCM; - ret = parse_test_gcm_init(); - if (ret < 0) - return ret; - } else if (strstr(info.vec[i], "CMAC")) { - info.algo = FIPS_TEST_ALGO_AES_CMAC; - ret = parse_test_cmac_init(); - if (ret < 0) - return 0; - } else if (strstr(info.vec[i], "CCM")) { - info.algo = FIPS_TEST_ALGO_AES_CCM; - ret = parse_test_ccm_init(); - if (ret < 0) - return 0; - } else if (strstr(info.vec[i], "HMAC")) { - info.algo = FIPS_TEST_ALGO_HMAC; - ret = parse_test_hmac_init(); - if (ret < 0) - return ret; - } else if (strstr(info.vec[i], "TDES")) { - info.algo = FIPS_TEST_ALGO_TDES; - ret = parse_test_tdes_init(); - if (ret < 0) - return 0; - } else if (strstr(info.vec[i], "SHA-")) { - info.algo = FIPS_TEST_ALGO_SHA; - ret = parse_test_sha_init(); - if (ret < 0) - return ret; + if (!algo_parsed) { + if (strstr(info.vec[i], "AESVS")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_AES; + ret = parse_test_aes_init(); + if (ret < 0) + return ret; + } else if (strstr(info.vec[i], "GCM")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_AES_GCM; + ret = parse_test_gcm_init(); + if (ret < 0) + return ret; + } else if (strstr(info.vec[i], "CMAC")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_AES_CMAC; + ret = parse_test_cmac_init(); + if (ret < 0) + return 0; + } else if (strstr(info.vec[i], "CCM")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_AES_CCM; + ret = parse_test_ccm_init(); + if (ret < 0) + return 0; + } else if (strstr(info.vec[i], "HMAC")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_HMAC; + ret = parse_test_hmac_init(); + if (ret < 0) + return ret; + } else if (strstr(info.vec[i], "TDES")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_TDES; + ret = parse_test_tdes_init(); + if (ret < 0) + return 0; + } else if (strstr(info.vec[i], "SHA-")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_SHA; + ret = parse_test_sha_init(); + if (ret < 0) + return ret; + } } tmp = strstr(info.vec[i], "# Config info for "); -- 2.13.6 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id C17A6A00E6 for ; Mon, 15 Apr 2019 17:04:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3CA981B20B; Mon, 15 Apr 2019 17:04:56 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 9192B1B1FF for ; Mon, 15 Apr 2019 17:04:54 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Apr 2019 08:04:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,354,1549958400"; d="scan'208";a="140836565" Received: from silpixa00399502.ir.intel.com (HELO silpixa00399502.ger.corp.intel.com) ([10.237.222.111]) by fmsmga008.fm.intel.com with ESMTP; 15 Apr 2019 08:04:51 -0700 From: Marko Kovacevic To: dev@dpdk.org Cc: john.mcnamara@intel.com, xinfengx.zhao@intel.com, akhil.goyal@nxp.com, Marko Kovacevic , damianx.nowak@intel.com Date: Mon, 15 Apr 2019 16:04:47 +0100 Message-Id: <20190415150449.44799-1-marko.kovacevic@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20190411141656.27720-1-marko.kovacevic@intel.com> References: <20190411141656.27720-1-marko.kovacevic@intel.com> Subject: [dpdk-dev] [PATCH v2 1/3] examples/fips: fix hmac test failure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190415150447.u80JYqepQNYV8BzLd88Te-DrbEh2tdgdf9R3I_3_3Zw@z> Application was failing as the HMAC and Plain SHA fips request files are similar in a way that they both have SHA- in the top section to determine the hash algo and hash sizes. And HMAC having the algo in the second line but the Plain SHA in the third meant that when the HMAC files was used once it parsed the third line Plain SHA was set as the algo and not HMAC. USER1: Failed to get capability for cdev 0 USER1: Error -22: test block [L=20 SHAAlg=SHA_2] USER1: Error -22: Failed test /root/FIPS/HMAC/req/HMAC.req Fixes: f4797bae0050 ("examples/fips_validation: support plain SHA") Cc: damianx.nowak@intel.com Signed-off-by: Marko Kovacevic --- v2: Fixed checkpatch warning --- examples/fips_validation/fips_validation.c | 80 +++++++++++++++++------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index 2f8314fcc..8d43b267e 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -98,6 +98,7 @@ fips_test_parse_header(void) uint32_t i; char *tmp; int ret; + int algo_parsed = 0; time_t t = time(NULL); struct tm *tm_now = localtime(&t); @@ -106,41 +107,50 @@ fips_test_parse_header(void) return ret; for (i = 0; i < info.nb_vec_lines; i++) { - if (strstr(info.vec[i], "AESVS")) { - info.algo = FIPS_TEST_ALGO_AES; - ret = parse_test_aes_init(); - if (ret < 0) - return ret; - } else if (strstr(info.vec[i], "GCM")) { - info.algo = FIPS_TEST_ALGO_AES_GCM; - ret = parse_test_gcm_init(); - if (ret < 0) - return ret; - } else if (strstr(info.vec[i], "CMAC")) { - info.algo = FIPS_TEST_ALGO_AES_CMAC; - ret = parse_test_cmac_init(); - if (ret < 0) - return 0; - } else if (strstr(info.vec[i], "CCM")) { - info.algo = FIPS_TEST_ALGO_AES_CCM; - ret = parse_test_ccm_init(); - if (ret < 0) - return 0; - } else if (strstr(info.vec[i], "HMAC")) { - info.algo = FIPS_TEST_ALGO_HMAC; - ret = parse_test_hmac_init(); - if (ret < 0) - return ret; - } else if (strstr(info.vec[i], "TDES")) { - info.algo = FIPS_TEST_ALGO_TDES; - ret = parse_test_tdes_init(); - if (ret < 0) - return 0; - } else if (strstr(info.vec[i], "SHA-")) { - info.algo = FIPS_TEST_ALGO_SHA; - ret = parse_test_sha_init(); - if (ret < 0) - return ret; + if (!algo_parsed) { + if (strstr(info.vec[i], "AESVS")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_AES; + ret = parse_test_aes_init(); + if (ret < 0) + return ret; + } else if (strstr(info.vec[i], "GCM")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_AES_GCM; + ret = parse_test_gcm_init(); + if (ret < 0) + return ret; + } else if (strstr(info.vec[i], "CMAC")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_AES_CMAC; + ret = parse_test_cmac_init(); + if (ret < 0) + return 0; + } else if (strstr(info.vec[i], "CCM")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_AES_CCM; + ret = parse_test_ccm_init(); + if (ret < 0) + return 0; + } else if (strstr(info.vec[i], "HMAC")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_HMAC; + ret = parse_test_hmac_init(); + if (ret < 0) + return ret; + } else if (strstr(info.vec[i], "TDES")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_TDES; + ret = parse_test_tdes_init(); + if (ret < 0) + return 0; + } else if (strstr(info.vec[i], "SHA-")) { + algo_parsed = 1; + info.algo = FIPS_TEST_ALGO_SHA; + ret = parse_test_sha_init(); + if (ret < 0) + return ret; + } } tmp = strstr(info.vec[i], "# Config info for "); -- 2.13.6