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 1A118A054D; Fri, 23 Sep 2022 18:30:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C06EF42BC1; Fri, 23 Sep 2022 18:30:14 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id AFA6D40156 for ; Fri, 23 Sep 2022 18:30:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663950613; x=1695486613; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=+lGd8bD+5nuosFgjz4RdR1qOCQleC4tCk4mkDT9ZEsc=; b=VFY0L9q8+jm+XSOk9H/NNRI1unsNI0OS7ed9RNdltSLQgQerQLUHSfNJ dI+Wtkp791AZGuLcF92BcY3ZXmAIHibZT5UlYi1pCfTiWdtI+rT/Q0cUC AROesclxu1bEVXcPya6CnNtNdWvYEOhG8BHYk6s5VU4baabT52FUmBdTJ Eb7+5kY6ngAu1+zpWnzKyBLhz7yl4HbxgFH8Cb4885J7YnvfvnUDv1XpY x7w/4KbgpgXVVuebshVLeG5tIz95uk/s2Q88ElQ4h9L1s/YU9ANKXpZdB kG8JRkwRfloPvZe9Jz4VNmt2FplRgGLAJBPNGHB0gOM80TpuO6Xsj+PYb Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10479"; a="280992932" X-IronPort-AV: E=Sophos;i="5.93,339,1654585200"; d="scan'208";a="280992932" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2022 09:30:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,339,1654585200"; d="scan'208";a="688769351" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmsmga004.fm.intel.com with ESMTP; 23 Sep 2022 09:30:07 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 23 Sep 2022 09:30:06 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 23 Sep 2022 09:30:05 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Fri, 23 Sep 2022 09:30:05 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Fri, 23 Sep 2022 09:30:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EvItrhHnUtOjWE/dGOGs6Z1dDGpNOtIeNWyiIQRYkuqCnqEleOgK4HeyFm4ul6GoAuokw1NzfFcpvlbHZ+6Cgrgqu5rf8YCZNRy/wkeFGzuR+NPrQ+qkMC3fiVdKr5kcH7QfT2tUfec1dcw3tAbXA18TrHPD/ygxZ+0GoDlgIUZ1Fs9on2UNIi0MnGthfWOn73bhnVhRh1WLoutvBESDCLTEJn1mEhe1CxRcw9PGP1jkfinFAWKYSGx9Km3hn2XHcWwtihlSP24y4kBwxHUDqjGa7ZgA/07zOI2E2lYYPkIwOSdzcZjS3M0j7a17P2/FgC6IleBJ7oBvXYc0EVZo1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lp93x2aaEzh9mE9PACa320b1iKRJMMjNER2eQRwTRz0=; b=Kkh1paTcKmKVbTFr94vS27NM3xRvsGPdXfyzG4iAtbU2WJ/9+TFb9pDA8EZr5z5u3WYntK21SQpzJLoCmrWS2dKydxa034VkTTpCKq+hqykSgi0jHFsHOxk00GE73LF8/jXweZ41Sm9ByhrUrgvwYDWSL+MCrVjSJaJvzbTe8+HXhoxzvzI8bZEzsze40QoydrYrESaKK24KWn2bSH4WPiJAX+Gf2uwAWf96Lg26sGNnGFv65BSbIJG2BZsgWG8ub40bOC7y2JILmBoO+qmZh24sCaUImxbCIXV5nRwwu4Fxf/8w6A5AGnBewKOO0tRK/ZYOBtmFXEPqyxZ3FqpBaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from CY4PR11MB1848.namprd11.prod.outlook.com (2603:10b6:903:123::22) by BN9PR11MB5257.namprd11.prod.outlook.com (2603:10b6:408:132::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Fri, 23 Sep 2022 16:30:02 +0000 Received: from CY4PR11MB1848.namprd11.prod.outlook.com ([fe80::917f:87a9:4204:a8d1]) by CY4PR11MB1848.namprd11.prod.outlook.com ([fe80::917f:87a9:4204:a8d1%6]) with mapi id 15.20.5654.020; Fri, 23 Sep 2022 16:30:02 +0000 From: "Dooley, Brian" To: Gowrishankar Muthukrishnan , "dev@dpdk.org" CC: Anoob Joseph , "Zhang, Roy Fan" , Akhil Goyal , "jerinj@marvell.com" Subject: RE: [PATCH v2 2/2] examples/fips_validation: add parsing for TDES Thread-Topic: [PATCH v2 2/2] examples/fips_validation: add parsing for TDES Thread-Index: AQHYrkH7xfCWyZReFkOokiwmBj+DAK3tdXAg Date: Fri, 23 Sep 2022 16:30:02 +0000 Message-ID: References: <73d188a54d126678538a1a2b7d8b9aae95e4e6d8.1657694117.git.gmuthukrishn@marvell.com> <20220812115201.1032352-1-gmuthukrishn@marvell.com> <20220812115201.1032352-2-gmuthukrishn@marvell.com> In-Reply-To: <20220812115201.1032352-2-gmuthukrishn@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.500.17 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CY4PR11MB1848:EE_|BN9PR11MB5257:EE_ x-ms-office365-filtering-correlation-id: 9f035bcd-dc5d-4723-10ed-08da9d80ddb7 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rCNpGBLBAZV9sDwAniFTMeoRpLkuYbKWFteTiB7KrA2l1pqQK37GlWNmjCNLv439WUrvcrHPkbVDRILqBBUUihFyf9Aw04AinaGHFeN1NGDdhKUwxCIhMmFYSX7fiuSJ/Wa0d7FXOlMbb1AO7yUNjWWufW8c0Qb8OBUMzxdFHij+1c/du82mS7fZmD4t8cAzrZegCfRR093JrRzXeh5u15Dk5/9sQ0EUhjlrhpP1E+kqgsX806iZoR4N+bQ0QgLFfVFbm8rTCiD3OtFGvt8H8+lImb7A75t/wlzrea0pJU/DaV2M2OryEq/tZewJEGWE2sa58kgWHj7kIyY1xQNwp2rGfouFhqDZjM6BQmztOfXkBDxCE38is9QFRfKLQfm256Iv0fv7LjOHYLeaE7xWQr6tgOLl1sxu/zMfKT4ZAFueZ6q/ldcjhk0quLWgzFJebvPAorHnEPuoPYU/jiPmeH+aVDBQDQASAI+odMdu2X28+akk3io9DV3fv94VVKbh35Wf/WkSzmtBA9Bn+pzVE9OxIpKRbSleTXBNM2o7aSEq/WjldrgmrcD+SmkPavT/24pkpRwNhbfJjxelebklwszqd/tca+qcgA4RV20sanC5cDuW22I+oHiw8weqhy180fAGHQMNfs2ZUGlL3Pei0SvFI+aIbD+yAGp6tPMCg4i938Ul7xDGU4lBuT5vdWNz2QhCMAGyqH1O+PUyu/kTn2UDhor+WTfYV2rZquQg+5oLUpMfJnEe2LEPkb57j9C5ZSdUurgDA08a/BOOxZRIWg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY4PR11MB1848.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(366004)(39860400002)(136003)(396003)(376002)(346002)(451199015)(30864003)(478600001)(53546011)(2906002)(26005)(9686003)(7696005)(6506007)(38100700002)(122000001)(41300700001)(76116006)(64756008)(4326008)(66556008)(66476007)(66446008)(38070700005)(316002)(55016003)(54906003)(8676002)(52536014)(33656002)(5660300002)(66946007)(110136005)(8936002)(71200400001)(86362001)(186003)(83380400001)(82960400001)(579004)(559001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?x+KlqpRhQeXI6B2HPWO/nRv168j+MWGOkeOeCgFhGo2RRYjfAA8MHOdqF0D0?= =?us-ascii?Q?x9anrD/sNpc7QVu2ZI4fmB5onsh1BW6cPdMmIXpq2QtW5TanCdyFiLJ66AVI?= =?us-ascii?Q?T1HkeeTwTGZxZNC+Rg0KngqdkDN7Vx4uHfLJR644biHEXs9YZN/CviBGTr5s?= =?us-ascii?Q?OI9te3960AQuOYIqHXSjU002ZQQW3BFKmMJVkSInuN73JL+UXc/tKjHU7khK?= =?us-ascii?Q?L1PT0gWhijDpca8mMv9baQaQ9nx1YGoMUHBeJvRuz5rdpTh1g5xq4gvFVJHW?= =?us-ascii?Q?wfEMpjU2EEs8bwdbjuSOxdqEAvUBRXBImDptHMJJZaE82l7ytRxLXsR5+u02?= =?us-ascii?Q?sAYPeeHAlOlO8G1Psq3hgkYqCgfvzoDPd4UFhHAGWVFwsC6njSBkDxYooKeG?= =?us-ascii?Q?Qr6JLkbBOQFRSM0++Ou782rXBBj1/MA3BoBsvS7e5qZu++NCQcLQr3EkP5Im?= =?us-ascii?Q?8aTPXfqZAwtEJNO7ux4KZ924f755+/wZJkm8hDcAeCDuODjqNGSbAh7SXf6f?= =?us-ascii?Q?vSfct2VxWCZWUBoOL/SXG8Z8RHg6J9DEG6bIBeR2YP9OAHXbQqXnTaWYk2ER?= =?us-ascii?Q?JSLW6Ksx6hrabqFHdA7ydvTYoh1mlQZzGcPVwC2QF8xQcn78ko0BKQoIu3Hd?= =?us-ascii?Q?3FQT1Dvby5rhbCskTOvhKbsIH09mD9JMQuaMW893NtPFZ6BHyRl3Z5u4jTBP?= =?us-ascii?Q?WjXpISyDW1kNaWzMkaz0EqLVuqV9pTrODQizMpJpQ0fxZPA6W3WhWI4HIfzI?= =?us-ascii?Q?wWtgvHZ/RV5C0fKqI1K4fbTZdCJQZNNNddX02VcUM+OajYfO1tOd7xj0mjh6?= =?us-ascii?Q?+CmifkmLYMJJ5E+DC5Fz4vf+00i5yRMUpgPufQawzfKqNZ1JIX9Evnn9rJz/?= =?us-ascii?Q?jnGZJKY+FuKsSQTyZwfZKMKkbo9CUCK0yR9dS71h6A6VIFA36TJP3ghIlv7Y?= =?us-ascii?Q?NylU+AbMloEWtHHdo3a2hXC/95nQ203o45NQ3BNFYL1FErZowiuNW+fB4xnq?= =?us-ascii?Q?NaDPBin05eM2cpMs1728z+aQDa2j3mE9G2cVYSStY2u1nwpeD3iKmBCPzX69?= =?us-ascii?Q?X6uYzFFYSVpay55Wehq/b3P0/HtlM2akD938vxr9cOKhBpdyZgeCwtzfbTtk?= =?us-ascii?Q?MzWRACk4mDQN1HaE/5SCGlD81RP5Sh/bCiurOUOe9KdceZfFpBrsAZ30WQz5?= =?us-ascii?Q?EicIm2GKS3qHCsQD6AMCJqwjT6oHMtNSHIFSpdN1VIPZ6rKs3JL8LEmgCBrV?= =?us-ascii?Q?DPyLlya41pZm8f42lTw/u8wCdQB9oBLC/YADrrKcXbLp/8CKK9dAPs1gR6fT?= =?us-ascii?Q?J/2FL1Fo80+MezWWuXf4ZxHBcyjkYnhUcrI5PuApc/3zEH8SABmR93T5bKUr?= =?us-ascii?Q?EZMpb2z/KYugU6BASbU6GApR6x/7Ae48yteXIFn2fdOc+RNGWXk6ex3JsPPx?= =?us-ascii?Q?oJUN2EwOF9dHtVz9712lN7GX3bffNkbaJEDDvmxwb2/zS3Zs+BZyYZXRD55L?= =?us-ascii?Q?6MUp7SPfb2k/BWi1fSYHeYMAdfIkyG4NKNQxot8WB+9oH9Im5LiFhxdc35ta?= =?us-ascii?Q?u45akms7uS5H79T3jvujrJ+cm3/d7g0lLHBHD+Zt?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1848.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f035bcd-dc5d-4723-10ed-08da9d80ddb7 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Sep 2022 16:30:02.7327 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mLAdZExCAFOYVkllKP8RaC+VVtOWgvlwWFYkBFbehK7kNn2tLE9eeGiMXTt74VSfmUNPRvyt5PnE71UteWWTVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5257 X-OriginatorOrg: intel.com 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 > -----Original Message----- > From: Gowrishankar Muthukrishnan > Sent: Friday, August 12, 2022 12:52 PM > To: dev@dpdk.org > Cc: Anoob Joseph ; Zhang, Roy Fan > ; Dooley, Brian ; Akhil > Goyal ; jerinj@marvell.com; Gowrishankar > Muthukrishnan > Subject: [PATCH v2 2/2] examples/fips_validation: add parsing for TDES >=20 > Added function to parse algorithm for TDES CBC and ECB tests in json. >=20 > Signed-off-by: Gowrishankar Muthukrishnan > --- > doc/guides/sample_app_ug/fips_validation.rst | 2 + > examples/fips_validation/fips_validation.c | 3 + > examples/fips_validation/fips_validation.h | 4 + > .../fips_validation/fips_validation_tdes.c | 335 ++++++++++++++++++ > examples/fips_validation/main.c | 94 +++-- > 5 files changed, 404 insertions(+), 34 deletions(-) >=20 > diff --git a/doc/guides/sample_app_ug/fips_validation.rst > b/doc/guides/sample_app_ug/fips_validation.rst > index 6f4bd34726..33a8c97575 100644 > --- a/doc/guides/sample_app_ug/fips_validation.rst > +++ b/doc/guides/sample_app_ug/fips_validation.rst > @@ -64,6 +64,8 @@ ACVP > * AES-XTS (128,256) - AFT > * HMAC (SHA1, SHA224, SHA256, SHA384, SHA512) > * SHA (1, 256, 384, 512) - AFT, MCT > + * TDES-CBC - AFT, MCT > + * TDES-ECB - AFT, MCT >=20 >=20 > Application Information > diff --git a/examples/fips_validation/fips_validation.c > b/examples/fips_validation/fips_validation.c > index 9678aa2161..6c9f5e42a4 100644 > --- a/examples/fips_validation/fips_validation.c > +++ b/examples/fips_validation/fips_validation.c > @@ -468,6 +468,9 @@ fips_test_parse_one_json_vector_set(void) > info.algo =3D FIPS_TEST_ALGO_AES_XTS; > else if (strstr(algo_str, "SHA")) > info.algo =3D FIPS_TEST_ALGO_SHA; > + else if (strstr(algo_str, "TDES-CBC") || > + strstr(algo_str, "TDES-ECB")) > + info.algo =3D FIPS_TEST_ALGO_TDES; > else > return -EINVAL; >=20 > diff --git a/examples/fips_validation/fips_validation.h > b/examples/fips_validation/fips_validation.h > index 5c1abcbd91..f42040f460 100644 > --- a/examples/fips_validation/fips_validation.h > +++ b/examples/fips_validation/fips_validation.h > @@ -114,6 +114,7 @@ enum fips_tdes_test_types { > TDES_VARIABLE_KEY, > TDES_VARIABLE_TEXT, > TDES_KAT, > + TDES_AFT, /* Functional Test */ > TDES_MCT, /* Monte Carlo (Modes) Test */ > TDES_MMT /* Multi block Message Test */ }; @@ -290,6 +291,9 @@ > parse_test_sha_json_algorithm(void); >=20 > int > parse_test_sha_json_test_type(void); > + > +int > +parse_test_tdes_json_init(void); > #endif /* USE_JANSSON */ >=20 > int > diff --git a/examples/fips_validation/fips_validation_tdes.c > b/examples/fips_validation/fips_validation_tdes.c > index a1ddd57cfd..10f13e6b0b 100644 > --- a/examples/fips_validation/fips_validation_tdes.c > +++ b/examples/fips_validation/fips_validation_tdes.c > @@ -38,6 +38,21 @@ >=20 > #define DEVICE_STR "# Config Info for : " >=20 > +#define ALGO_JSON_STR "algorithm" > +#define TESTTYPE_JSON_STR "testType" > +#define DIR_JSON_STR "direction" > +#define KEYOPT_JSON_STR "keyingOption" > + > +#define PT_JSON_STR "pt" > +#define CT_JSON_STR "ct" > +#define IV_JSON_STR "iv" > +#define KEY1_JSON_STR "key1" > +#define KEY2_JSON_STR "key2" > +#define KEY3_JSON_STR "key3" > + > +#define OP_ENC_JSON_STR "encrypt" > +#define OP_DEC_JSON_STR "decrypt" > + > struct { > uint32_t type; > const char *desc; > @@ -48,6 +63,7 @@ struct { > {TDES_VARIABLE_KEY, "VARIABLE KEY"}, > {TDES_VARIABLE_TEXT, "VARIABLE > PLAINTEXT/CIPHERTEXT"}, > {TDES_VARIABLE_TEXT, "KAT"}, > + {TDES_AFT, "Functional Test"}, > {TDES_MCT, "Monte Carlo (Modes) Test"}, > {TDES_MMT, "Multi block Message Test"}, }; @@ -92,6 > +108,325 @@ struct fips_test_callback tdes_writeback_callbacks[] =3D { > {NULL, NULL, NULL} /**< end pointer */ }; >=20 > +#ifdef USE_JANSSON > +static struct { > + enum fips_tdes_test_types type; > + const char *desc; > +} const tdes_test_types[] =3D { > + {TDES_AFT, "AFT"}, > + {TDES_MCT, "MCT"}, > +}; > + > +static struct { > + enum fips_tdes_test_mode mode; > + const char *desc; > +} const tdes_test_modes[] =3D { > + {TDES_MODE_CBC, "CBC"}, > + {TDES_MODE_ECB, "ECB"}, > +}; > + > +#define TDES_KEYS_TUPLE_LEN 24 > + > +static int > +parser_tdes_read_key(const char *key, char *src, struct fips_val *val) > +{ > + uint8_t tmp_key[TDES_KEYS_TUPLE_LEN] =3D {0}; > + uint32_t len, i; > + > + len =3D strlen(src) / 2; > + > + if (val->val) { > + memcpy(tmp_key, val->val, val->len); > + rte_free(val->val); > + } > + > + val->val =3D rte_zmalloc(NULL, TDES_KEYS_TUPLE_LEN, 0); > + if (!val->val) > + return -1; > + > + memcpy(val->val, tmp_key, TDES_KEYS_TUPLE_LEN); > + > + if (strstr(key, KEY1_JSON_STR)) { > + for (i =3D 0; i < len; i++) { > + char byte[3] =3D {src[i * 2], src[i * 2 + 1], '\0'}; > + > + if (parser_read_uint8_hex(&val->val[i], byte) < 0) > + goto error_exit; > + } > + > + if (info.interim_info.tdes_data.nb_keys =3D=3D 2) > + memcpy(val->val + 16, val->val, 8); > + > + } else if (strstr(key, KEY2_JSON_STR)) { > + for (i =3D 0; i < len; i++) { > + char byte[3] =3D {src[i * 2], src[i * 2 + 1], '\0'}; > + > + if (parser_read_uint8_hex(&val->val[i + 8], byte) < 0) > + goto error_exit; > + } > + > + } else if (strstr(key, KEY3_JSON_STR)) { > + for (i =3D 0; i < len; i++) { > + char byte[3] =3D {src[i * 2], src[i * 2 + 1], '\0'}; > + > + if (parser_read_uint8_hex(&val->val[i + 16], byte) < > 0) > + goto error_exit; > + } > + } else > + return -EINVAL; > + > + val->len =3D TDES_KEYS_TUPLE_LEN; > + > + return 0; > + > +error_exit: > + rte_free(val->val); > + memset(val, 0, sizeof(*val)); > + return -EINVAL; > +} > + > +struct fips_test_callback tdes_dec_json_vectors[] =3D { > + {KEY1_JSON_STR, parser_tdes_read_key, &vec.cipher_auth.key}, > + {KEY2_JSON_STR, parser_tdes_read_key, &vec.cipher_auth.key}, > + {KEY3_JSON_STR, parser_tdes_read_key, &vec.cipher_auth.key}, > + {IV_JSON_STR, parse_uint8_hex_str, &vec.iv}, > + {CT_JSON_STR, parse_uint8_hex_str, &vec.ct}, > + {NULL, NULL, NULL} /**< end pointer */ }; > + > +struct fips_test_callback tdes_enc_json_vectors[] =3D { > + {KEY1_JSON_STR, parser_tdes_read_key, &vec.cipher_auth.key}, > + {KEY2_JSON_STR, parser_tdes_read_key, &vec.cipher_auth.key}, > + {KEY3_JSON_STR, parser_tdes_read_key, &vec.cipher_auth.key}, > + {IV_JSON_STR, parse_uint8_hex_str, &vec.iv}, > + {PT_JSON_STR, parse_uint8_hex_str, &vec.pt}, > + {NULL, NULL, NULL} /**< end pointer */ }; > + > +static int > +parse_test_tdes_json_writeback(struct fips_val *val) { > + struct fips_val tmp_val; > + json_t *tcId; > + > + tcId =3D json_object_get(json_info.json_test_case, "tcId"); > + > + json_info.json_write_case =3D json_object(); > + json_object_set(json_info.json_write_case, "tcId", tcId); > + > + if (info.op =3D=3D FIPS_TEST_ENC_AUTH_GEN) { > + json_t *ct; > + > + tmp_val.val =3D val->val; > + tmp_val.len =3D vec.pt.len; > + > + writeback_hex_str("", info.one_line_text, &tmp_val); > + ct =3D json_string(info.one_line_text); > + json_object_set_new(json_info.json_write_case, > CT_JSON_STR, ct); > + > + tmp_val.val =3D val->val + vec.pt.len; > + tmp_val.len =3D val->len - vec.pt.len; > + > + writeback_hex_str("", info.one_line_text, &tmp_val); > + } else { > + if (vec.status =3D=3D RTE_CRYPTO_OP_STATUS_SUCCESS) { > + tmp_val.val =3D val->val; > + tmp_val.len =3D vec.ct.len; > + > + writeback_hex_str("", info.one_line_text, > &tmp_val); > + json_object_set_new(json_info.json_write_case, > PT_JSON_STR, > + > json_string(info.one_line_text)); > + } else { > + json_object_set_new(json_info.json_write_case, > "testPassed", json_false()); > + } > + } > + > + return 0; > +} > + > +static int > +parse_test_tdes_mct_json_writeback(struct fips_val *val) { > + json_t *tcId, *resArr, *res, *ct, *pt, *key, *iv; > + struct fips_val tmp_val; > + > + tcId =3D json_object_get(json_info.json_test_case, "tcId"); > + if (json_info.json_write_case) { > + json_t *wcId; > + > + wcId =3D json_object_get(json_info.json_write_case, "tcId"); > + if (!json_equal(tcId, wcId)) { > + json_info.json_write_case =3D json_object(); > + json_object_set(json_info.json_write_case, "tcId", > tcId); > + json_object_set(json_info.json_write_case, > "resultsArray", json_array()); > + } > + } else { > + json_info.json_write_case =3D json_object(); > + json_object_set(json_info.json_write_case, "tcId", tcId); > + json_object_set(json_info.json_write_case, "resultsArray", > json_array()); > + } > + > + resArr =3D json_object_get(json_info.json_write_case, > "resultsArray"); > + if (!json_is_array(resArr)) > + return -EINVAL; > + > + res =3D json_object(); > + if (info .op =3D=3D FIPS_TEST_ENC_AUTH_GEN) { > + tmp_val.len =3D 8; > + tmp_val.val =3D vec.cipher_auth.key.val; > + writeback_hex_str("", info.one_line_text, &tmp_val); > + key =3D json_string(info.one_line_text); > + json_object_set_new(res, KEY1_JSON_STR, key); > + > + tmp_val.val =3D vec.cipher_auth.key.val + 8; > + writeback_hex_str("", info.one_line_text, &tmp_val); > + key =3D json_string(info.one_line_text); > + json_object_set_new(res, KEY2_JSON_STR, key); > + > + tmp_val.val =3D vec.cipher_auth.key.val + 16; > + writeback_hex_str("", info.one_line_text, &tmp_val); > + key =3D json_string(info.one_line_text); > + json_object_set_new(res, KEY3_JSON_STR, key); > + > + if (info.interim_info.tdes_data.test_mode =3D=3D > TDES_MODE_CBC) { > + writeback_hex_str("", info.one_line_text, &val[2]); > + iv =3D json_string(info.one_line_text); > + json_object_set_new(res, IV_JSON_STR, iv); > + } > + > + writeback_hex_str("", info.one_line_text, &val[1]); > + pt =3D json_string(info.one_line_text); > + json_object_set_new(res, PT_JSON_STR, pt); > + > + tmp_val.val =3D val->val; > + tmp_val.len =3D vec.pt.len; > + > + writeback_hex_str("", info.one_line_text, &tmp_val); > + ct =3D json_string(info.one_line_text); > + json_object_set_new(res, CT_JSON_STR, ct); > + > + tmp_val.val =3D val->val + vec.pt.len; > + tmp_val.len =3D val->len - vec.pt.len; > + > + writeback_hex_str("", info.one_line_text, &tmp_val); > + } else { > + if (vec.status =3D=3D RTE_CRYPTO_OP_STATUS_SUCCESS) { > + tmp_val.len =3D 8; > + tmp_val.val =3D vec.cipher_auth.key.val; > + writeback_hex_str("", info.one_line_text, > &tmp_val); > + key =3D json_string(info.one_line_text); > + json_object_set_new(res, KEY1_JSON_STR, key); > + > + tmp_val.val =3D vec.cipher_auth.key.val + 8; > + writeback_hex_str("", info.one_line_text, > &tmp_val); > + key =3D json_string(info.one_line_text); > + json_object_set_new(res, KEY2_JSON_STR, key); > + > + tmp_val.val =3D vec.cipher_auth.key.val + 16; > + writeback_hex_str("", info.one_line_text, > &tmp_val); > + key =3D json_string(info.one_line_text); > + json_object_set_new(res, KEY3_JSON_STR, key); > + > + if (info.interim_info.tdes_data.test_mode =3D=3D > TDES_MODE_CBC) { > + writeback_hex_str("", info.one_line_text, > &val[2]); > + iv =3D json_string(info.one_line_text); > + json_object_set_new(res, IV_JSON_STR, iv); > + } > + > + tmp_val.val =3D val->val; > + tmp_val.len =3D vec.ct.len; > + > + writeback_hex_str("", info.one_line_text, > &tmp_val); > + pt =3D json_string(info.one_line_text); > + json_object_set_new(res, PT_JSON_STR, pt); > + > + writeback_hex_str("", info.one_line_text, &val[1]); > + ct =3D json_string(info.one_line_text); > + json_object_set_new(res, CT_JSON_STR, ct); > + } else { > + json_object_set_new(json_info.json_write_case, > "testPassed", json_false()); > + } > + } > + > + json_array_append_new(resArr, res); > + > + return 0; > +} > + > +int parse_test_tdes_json_init(void) > +{ > + json_t *type_obj =3D json_object_get(json_info.json_test_group, > TESTTYPE_JSON_STR); > + json_t *algo_obj =3D json_object_get(json_info.json_vector_set, > ALGO_JSON_STR); > + const char *type_str =3D json_string_value(type_obj); > + const char *algo_str =3D json_string_value(algo_obj); > + uint32_t i; > + > + if (json_info.json_test_group) { > + json_t *direction_obj, *opt_obj; > + const char *direction_str; > + int opt_val; > + > + direction_obj =3D json_object_get(json_info.json_test_group, > DIR_JSON_STR); > + direction_str =3D json_string_value(direction_obj); > + > + if (strcmp(direction_str, OP_ENC_JSON_STR) =3D=3D 0) { > + info.op =3D FIPS_TEST_ENC_AUTH_GEN; > + info.callbacks =3D tdes_enc_json_vectors; > + } else if (strcmp(direction_str, OP_DEC_JSON_STR) =3D=3D 0) { > + info.op =3D FIPS_TEST_DEC_AUTH_VERIF; > + info.callbacks =3D tdes_dec_json_vectors; > + } else { > + return -EINVAL; > + } > + > + opt_obj =3D json_object_get(json_info.json_test_group, > KEYOPT_JSON_STR); > + opt_val =3D json_integer_value(opt_obj); > + if (opt_val =3D=3D 2) > + info.interim_info.tdes_data.nb_keys =3D 2; > + else > + info.interim_info.tdes_data.nb_keys =3D 3; > + > + info.interim_callbacks =3D NULL; > + } > + > + for (i =3D 0; i < RTE_DIM(tdes_test_types); i++) > + if (strstr(type_str, tdes_test_types[i].desc)) { > + info.interim_info.tdes_data.test_type =3D > + tdes_test_types[i].type; > + break; > + } > + > + if (i >=3D RTE_DIM(tdes_test_types)) > + return -EINVAL; > + > + for (i =3D 0; RTE_DIM(tdes_test_modes); i++) > + if (strstr(algo_str, tdes_test_modes[i].desc)) { > + info.interim_info.tdes_data.test_mode =3D > + tdes_test_modes[i].mode; > + break; > + } > + > + if (i >=3D RTE_DIM(tdes_test_modes)) > + return -EINVAL; > + > + switch (info.interim_info.tdes_data.test_type) { > + case TDES_AFT: > + info.parse_writeback =3D parse_test_tdes_json_writeback; > + break; > + case TDES_MCT: > + info.parse_writeback =3D > parse_test_tdes_mct_json_writeback; > + break; > + default: > + info.parse_writeback =3D NULL; > + }; > + > + if (info.parse_writeback =3D=3D NULL) > + return -EINVAL; > + > + return 0; > +} > +#endif /* USE_JANSSON */ > + > static int > parse_tdes_interim(const char *key, char *text, > __rte_unused struct fips_val *val) > diff --git a/examples/fips_validation/main.c > b/examples/fips_validation/main.c index 5c3f79a91c..8babbb3298 100644 > --- a/examples/fips_validation/main.c > +++ b/examples/fips_validation/main.c > @@ -1303,7 +1303,7 @@ fips_mct_tdes_test(void) > #define TDES_BLOCK_SIZE 8 > #define TDES_EXTERN_ITER 400 > #define TDES_INTERN_ITER 10000 > - struct fips_val val =3D {NULL, 0}, val_key; > + struct fips_val val[3] =3D {{NULL, 0},}, val_key, pt, ct, iv; > uint8_t prev_out[TDES_BLOCK_SIZE] =3D {0}; > uint8_t prev_prev_out[TDES_BLOCK_SIZE] =3D {0}; > uint8_t prev_in[TDES_BLOCK_SIZE] =3D {0}; @@ -1311,16 +1311,25 @@ > fips_mct_tdes_test(void) > int ret; > int test_mode =3D info.interim_info.tdes_data.test_mode; >=20 > + pt.len =3D vec.pt.len; > + pt.val =3D calloc(1, pt.len); > + ct.len =3D vec.ct.len; > + ct.val =3D calloc(1, ct.len); > + iv.len =3D vec.iv.len; > + iv.val =3D calloc(1, iv.len); > + > for (i =3D 0; i < TDES_EXTERN_ITER; i++) { > - if ((i =3D=3D 0) && (info.version =3D=3D 21.4f)) { > - if (!(strstr(info.vec[0], "COUNT"))) > - fprintf(info.fp_wr, "%s%u\n", "COUNT =3D ", > 0); > - } > + if (info.file_type !=3D FIPS_TYPE_JSON) { > + if ((i =3D=3D 0) && (info.version =3D=3D 21.4f)) { > + if (!(strstr(info.vec[0], "COUNT"))) > + fprintf(info.fp_wr, "%s%u\n", > "COUNT =3D ", 0); > + } >=20 > - if (i !=3D 0) > - update_info_vec(i); > + if (i !=3D 0) > + update_info_vec(i); >=20 > - fips_test_write_one_case(); > + fips_test_write_one_case(); > + } >=20 > for (j =3D 0; j < TDES_INTERN_ITER; j++) { > ret =3D fips_run_test(); > @@ -1335,7 +1344,7 @@ fips_mct_tdes_test(void) > return ret; > } >=20 > - ret =3D get_writeback_data(&val); > + ret =3D get_writeback_data(&val[0]); > if (ret < 0) > return ret; >=20 > @@ -1343,51 +1352,61 @@ fips_mct_tdes_test(void) > memcpy(prev_in, vec.ct.val, > TDES_BLOCK_SIZE); >=20 > if (j =3D=3D 0) { > - memcpy(prev_out, val.val, > TDES_BLOCK_SIZE); > + memcpy(prev_out, val[0].val, > TDES_BLOCK_SIZE); > + memcpy(pt.val, vec.pt.val, pt.len); > + memcpy(ct.val, vec.ct.val, ct.len); > + memcpy(iv.val, vec.iv.val, iv.len); >=20 > if (info.op =3D=3D FIPS_TEST_ENC_AUTH_GEN) { > if (test_mode =3D=3D TDES_MODE_ECB) { > - memcpy(vec.pt.val, val.val, > + memcpy(vec.pt.val, > val[0].val, > TDES_BLOCK_SIZE); > } else { > memcpy(vec.pt.val, > vec.iv.val, > TDES_BLOCK_SIZE); > - memcpy(vec.iv.val, val.val, > + memcpy(vec.iv.val, val[0].val, > TDES_BLOCK_SIZE); > } > - > + val[1].val =3D pt.val; > + val[1].len =3D pt.len; > + val[2].val =3D iv.val; > + val[2].len =3D iv.len; > } else { > if (test_mode =3D=3D TDES_MODE_ECB) { > - memcpy(vec.ct.val, val.val, > + memcpy(vec.ct.val, val[0].val, > TDES_BLOCK_SIZE); > } else { > memcpy(vec.iv.val, vec.ct.val, > TDES_BLOCK_SIZE); > - memcpy(vec.ct.val, val.val, > + memcpy(vec.ct.val, val[0].val, > TDES_BLOCK_SIZE); > } > + val[1].val =3D ct.val; > + val[1].len =3D ct.len; > + val[2].val =3D iv.val; > + val[2].len =3D iv.len; > } > continue; > } >=20 > if (info.op =3D=3D FIPS_TEST_ENC_AUTH_GEN) { > if (test_mode =3D=3D TDES_MODE_ECB) { > - memcpy(vec.pt.val, val.val, > + memcpy(vec.pt.val, val[0].val, > TDES_BLOCK_SIZE); > } else { > - memcpy(vec.iv.val, val.val, > + memcpy(vec.iv.val, val[0].val, > TDES_BLOCK_SIZE); > memcpy(vec.pt.val, prev_out, > TDES_BLOCK_SIZE); > } > } else { > if (test_mode =3D=3D TDES_MODE_ECB) { > - memcpy(vec.ct.val, val.val, > + memcpy(vec.ct.val, val[0].val, > TDES_BLOCK_SIZE); > } else { > memcpy(vec.iv.val, vec.ct.val, > TDES_BLOCK_SIZE); > - memcpy(vec.ct.val, val.val, > + memcpy(vec.ct.val, val[0].val, > TDES_BLOCK_SIZE); > } > } > @@ -1395,14 +1414,15 @@ fips_mct_tdes_test(void) > if (j =3D=3D TDES_INTERN_ITER - 1) > continue; >=20 > - memcpy(prev_out, val.val, TDES_BLOCK_SIZE); > + memcpy(prev_out, val[0].val, TDES_BLOCK_SIZE); >=20 > if (j =3D=3D TDES_INTERN_ITER - 3) > - memcpy(prev_prev_out, val.val, > TDES_BLOCK_SIZE); > + memcpy(prev_prev_out, val[0].val, > TDES_BLOCK_SIZE); > } >=20 > - info.parse_writeback(&val); > - fprintf(info.fp_wr, "\n"); > + info.parse_writeback(val); > + if (info.file_type !=3D FIPS_TYPE_JSON) > + fprintf(info.fp_wr, "\n"); >=20 > if (i =3D=3D TDES_EXTERN_ITER - 1) > continue; > @@ -1424,19 +1444,19 @@ fips_mct_tdes_test(void) >=20 > switch (info.interim_info.tdes_data.nb_keys) { > case 3: > - val_key.val[k] ^=3D val.val[k]; > + val_key.val[k] ^=3D val[0].val[k]; > val_key.val[k + 8] ^=3D prev_out[k]; > val_key.val[k + 16] ^=3D prev_prev_out[k]; > break; > case 2: > - val_key.val[k] ^=3D val.val[k]; > + val_key.val[k] ^=3D val[0].val[k]; > val_key.val[k + 8] ^=3D prev_out[k]; > - val_key.val[k + 16] ^=3D val.val[k]; > + val_key.val[k + 16] ^=3D val[0].val[k]; > break; > default: /* case 1 */ > - val_key.val[k] ^=3D val.val[k]; > - val_key.val[k + 8] ^=3D val.val[k]; > - val_key.val[k + 16] ^=3D val.val[k]; > + val_key.val[k] ^=3D val[0].val[k]; > + val_key.val[k + 8] ^=3D val[0].val[k]; > + val_key.val[k + 16] ^=3D val[0].val[k]; > break; > } >=20 > @@ -1449,22 +1469,25 @@ fips_mct_tdes_test(void) >=20 > if (info.op =3D=3D FIPS_TEST_ENC_AUTH_GEN) { > if (test_mode =3D=3D TDES_MODE_ECB) { > - memcpy(vec.pt.val, val.val, > TDES_BLOCK_SIZE); > + memcpy(vec.pt.val, val[0].val, > TDES_BLOCK_SIZE); > } else { > - memcpy(vec.iv.val, val.val, > TDES_BLOCK_SIZE); > + memcpy(vec.iv.val, val[0].val, > TDES_BLOCK_SIZE); > memcpy(vec.pt.val, prev_out, > TDES_BLOCK_SIZE); > } > } else { > if (test_mode =3D=3D TDES_MODE_ECB) { > - memcpy(vec.ct.val, val.val, > TDES_BLOCK_SIZE); > + memcpy(vec.ct.val, val[0].val, > TDES_BLOCK_SIZE); > } else { > memcpy(vec.iv.val, prev_out, > TDES_BLOCK_SIZE); > - memcpy(vec.ct.val, val.val, > TDES_BLOCK_SIZE); > + memcpy(vec.ct.val, val[0].val, > TDES_BLOCK_SIZE); > } > } > } >=20 > - free(val.val); > + free(val[0].val); > + free(pt.val); > + free(ct.val); > + free(iv.val); >=20 > return 0; > } > @@ -2007,6 +2030,9 @@ fips_test_one_test_group(void) > case FIPS_TEST_ALGO_SHA: > ret =3D parse_test_sha_json_init(); > break; > + case FIPS_TEST_ALGO_TDES: > + ret =3D parse_test_tdes_json_init(); > + break; > default: > return -EINVAL; > } > -- > 2.25.1 Acked-by: Brian Dooley