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 C3E55A00C4; Mon, 30 May 2022 14:23:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3906142B75; Mon, 30 May 2022 14:23:54 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 2AD4342B75 for ; Mon, 30 May 2022 14:23:53 +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 24UCDgwn004646; Mon, 30 May 2022 05:23:52 -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=hm33x41NwoAhw1m+TkooAwyBG1HMFKvnLzJAUBCTTlE=; b=Rzv1/A95h5ZyK1DDljqC/mMFMHcFkOkzAMTl2pmSE3D+Kwd26rzvElwY7KVrJvOWzd4S U+RthD3bJPHr2VxarN3Q4NauJziPhfIeGr0GE41UxkEoaP+fDhRZXnYIr1him3FRQW3Q 8aE3/fLU/b5LvHvNf4JMeo94Qid06aHe5rFnVmgKTktEuNqL/mVhZb4o1vhqOaRv4ZPI QtRuWIA29yMreEltUbXsCtRThduXyoQmYOoCaXISnhmj61F1fjdr+9jBSDd/811GhzQ3 zAlsn18ZMlfUMdI/SfmSrOVV6ff/QKr6vLuRCmhzKF/hYajytOWhDU4MXrbed7oPfw/J 9w== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3gbk8n5c78-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 30 May 2022 05:23:52 -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; Mon, 30 May 2022 05:23:50 -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; Mon, 30 May 2022 05:23:50 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id B3B6C3F7081; Mon, 30 May 2022 05:23:47 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: Fan Zhang , Brian Dooley , , Anoob Joseph , Archana Muniganti , Jerin Jacob , Brandon Lo , "Gowrishankar Muthukrishnan" Subject: [v8, 02/10] examples/fips_validation: add json info to header Date: Mon, 30 May 2022 17:53:22 +0530 Message-ID: <8b41cb1b107180bae15fb86ab714cf76ed672919.1653913201.git.gmuthukrishn@marvell.com> 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: TuIXPu2cxhc1u_W3LBop_HwS38buqSI6 X-Proofpoint-GUID: TuIXPu2cxhc1u_W3LBop_HwS38buqSI6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-30_04,2022-05-30_01,2022-02-23_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 From: Brandon Lo Added json-specific functions and other information needed to test the new FIPS test vectors. Signed-off-by: Brandon Lo Signed-off-by: Gowrishankar Muthukrishnan --- v7: * fix switch clause for info.file_type. v5: * fix typo in macro name for prefixes. v2: * fix type of prefix to suffix --- examples/fips_validation/fips_validation.c | 6 +-- examples/fips_validation/fips_validation.h | 48 ++++++++++++++++++++-- examples/fips_validation/main.c | 2 + 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index 94253eaee8..38c99b291c 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -270,11 +270,11 @@ parse_file_type(const char *path) { const char *tmp = path + strlen(path) - 3; - if (strstr(tmp, REQ_FILE_PERFIX)) + if (strstr(tmp, REQ_FILE_PREFIX)) info.file_type = FIPS_TYPE_REQ; - else if (strstr(tmp, RSP_FILE_PERFIX)) + else if (strstr(tmp, RSP_FILE_PREFIX)) info.file_type = FIPS_TYPE_RSP; - else if (strstr(path, FAX_FILE_PERFIX)) + else if (strstr(path, FAX_FILE_PREFIX)) info.file_type = FIPS_TYPE_FAX; else return -EINVAL; diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h index aaadf01ba8..a1c83a9a6a 100644 --- a/examples/fips_validation/fips_validation.h +++ b/examples/fips_validation/fips_validation.h @@ -5,6 +5,10 @@ #ifndef _FIPS_VALIDATION_H_ #define _FIPS_VALIDATION_H_ +#ifdef RTE_HAS_JANSSON +#include +#endif /* RTE_HAS_JANSSON */ + #define FIPS_PARSE_ERR(fmt, args) \ RTE_LOG(ERR, USER1, "FIPS parse error" ## fmt ## "\n", ## args) @@ -21,9 +25,12 @@ #define POSITIVE_TEST 0 #define NEGATIVE_TEST -1 -#define REQ_FILE_PERFIX "req" -#define RSP_FILE_PERFIX "rsp" -#define FAX_FILE_PERFIX "fax" +#define REQ_FILE_PREFIX "req" +#define RSP_FILE_PREFIX "rsp" +#define FAX_FILE_PREFIX "fax" +#define JSON_FILE_PREFIX "json" + +#define ACVVERSION "1.0" enum fips_test_algorithms { FIPS_TEST_ALGO_AES = 0, @@ -40,7 +47,8 @@ enum fips_test_algorithms { enum file_types { FIPS_TYPE_REQ = 1, FIPS_TYPE_FAX, - FIPS_TYPE_RSP + FIPS_TYPE_RSP, + FIPS_TYPE_JSON, }; enum fips_test_op { @@ -161,6 +169,23 @@ struct gcm_interim_data { uint8_t gen_iv; }; +#ifdef RTE_HAS_JANSSON +struct fips_test_json_info { + /* Information used for reading from json */ + json_t *json_root; + json_t *json_vector_set; + json_t *json_test_group; + json_t *json_test_case; + /* Location of json write output */ + json_t *json_write_root; + json_t *json_write_group; + json_t *json_write_set; + json_t *json_write_case; + /* Other info */ + uint8_t is_sample; +}; +#endif /* RTE_HAS_JANSSON */ + struct fips_test_interim_info { FILE *fp_rd; FILE *fp_wr; @@ -196,6 +221,10 @@ struct fips_test_interim_info { extern struct fips_test_vector vec; extern struct fips_test_interim_info info; +#ifdef RTE_HAS_JANSSON +extern struct fips_test_json_info json_info; +#endif /* RTE_HAS_JANSSON */ + int fips_test_init(const char *req_file_path, const char *rsp_file_path, const char *device_name); @@ -212,6 +241,17 @@ fips_test_parse_one_case(void); void fips_test_write_one_case(void); +#ifdef RTE_HAS_JANSSON +int +fips_test_parse_one_json_vector_set(void); + +int +fips_test_parse_one_json_group(void); + +int +fips_test_parse_one_json_case(void); +#endif /* RTE_HAS_JANSSON */ + int parse_test_aes_init(void); diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c index e06ae37567..554d74cda0 100644 --- a/examples/fips_validation/main.c +++ b/examples/fips_validation/main.c @@ -1251,6 +1251,8 @@ fips_generic_test(void) if (ret < 0) return ret; break; + default: + break; } fprintf(info.fp_wr, "\n"); -- 2.25.1