From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.19023.1656548997164856148 for ; Wed, 29 Jun 2022 17:29:57 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=fpVTwQ5q; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: jiewen.yao@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656548997; x=1688084997; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=uWxKlZabtUnzK55nVKorXkLyGEJGQMijMSHIh3E7boc=; b=fpVTwQ5qJL0YC3Hgqe/lWZ8SYp1CGiIxZ5BPFb92sH/8hoY0oqspEWSb I+X/Pu4l37te4IzdeGrSWRhAR5If17pO0ZiKTFxR9F0/acCGKAW3ZOVH5 pQXsBfjlYlaesTmjJ/uf0iodSyg/Wel9HqGWjM/rlp3G4q/nar4EOf6iA C1MADcfgIEM1ysWIyWjJQoasUqBP65/AH3wRHWk3P2MdTt32QzuMSGZUl hkiCv7gfk5o/H1OManigjKMgbD9Tw1Gd7mbjxiet+2/5NvJFYAhN9uqUg aiB2yOy/cCSxhbYWqQ9A5hLcIpVVc7oXcWKiPkU+3A4KxWVQkWkgbnhp0 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10393"; a="265236912" X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="265236912" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 17:29:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="588540180" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga007.jf.intel.com with ESMTP; 29 Jun 2022 17:29:54 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 29 Jun 2022 17:29:54 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 29 Jun 2022 17:29:53 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Wed, 29 Jun 2022 17:29:53 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.103) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Wed, 29 Jun 2022 17:29:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ksou2sddTLcuRdPzyl4BYkYzbDjKExW3VkpZiBZuk6Ufo8FVvK5X8GTV8iGV6BD/XTQ02zCI42QG5f2pFIAmienW5XDfF8sLxEeZNGDzcSZk6e0lUNmF/WTuY66/QzLFSXx6yyAqhzJkluVVOo7f6k/AjZeowfPgFQIM0ldv+ILZm9olFkz8DARKlK+qKrbDfK8TTzKJUbccFQ7Ua/kUojfC2Rsv9pcnh6qa7vGGn5VWojPDbmtJWV0Sbg1B2L9+mO+eqvwA58XsMafXFgGmQlrHTDWDSp9dsGtx6IGEDYaIvE8PMoJEnL8KkGrs4G43b+qgZb5nkbx2DP3IbS9jbA== 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=rBZxLSu3xStMg/QyemWplElTU/zuHK6bKLt2wcRtTQk=; b=UlvDe/nWhDVfkypB+7uKbg1lLdDcy74UFpK4LMD4mAGTDLmX35Qcavf6XoyJ2CxR+uPXKLHFk7ppxcbDifwd/GQLg55rMHXxJVi7bM/7NdGi7BCtiRSRCX3P1YiC3pQszPXhclkVUHuiKqkUab1q0M60fIws2fKABQ/qcvaY4dSZm+C8qCXkz7T/XnxY1g3+E18neW4HliEPAY7xwKvW66b/Wn04w8vXnQaTBuSpMFJpqZZS+D15DeO76qAFLVf7H35XcJKtZ8EskEDiVg0/wjuG0oOmC+GoqS2067g/ODfLDraRK/FuioOKztSPeKitJ8ua9QXYWJNbS6hyAKSupw== 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 MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by DM6PR11MB3739.namprd11.prod.outlook.com (2603:10b6:5:13b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Thu, 30 Jun 2022 00:29:50 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::24ae:1cd3:3192:4c7e]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::24ae:1cd3:3192:4c7e%6]) with mapi id 15.20.5395.014; Thu, 30 Jun 2022 00:29:50 +0000 From: "Yao, Jiewen" To: "devel@edk2.groups.io" , "pierre.gondois@arm.com" CC: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , "Kinney, Michael D" , "Gao, Liming" , Edward Pickup Subject: Re: [edk2-devel] [PATCH RESEND v1 5/7] MdePkg/AesLib: Definition for AES library class interface Thread-Topic: [edk2-devel] [PATCH RESEND v1 5/7] MdePkg/AesLib: Definition for AES library class interface Thread-Index: AQHYi+/zPok8WzRfkECXVWfds1r+l61nF2PQ Date: Thu, 30 Jun 2022 00:29:50 +0000 Message-ID: References: <20220629191355.2618844-1-Pierre.Gondois@arm.com> <20220629191355.2618844-6-Pierre.Gondois@arm.com> In-Reply-To: <20220629191355.2618844-6-Pierre.Gondois@arm.com> Accept-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-office365-filtering-correlation-id: 0417f130-b28d-4cc8-a431-08da5a2fa53c x-ms-traffictypediagnostic: DM6PR11MB3739:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: doQyfBYb7n0gANOPNmR2kpbo8BLc9Pn4hsynbMCLUkAxlJ/wFVBQdjgz7BAnoihH+bOsaXWls+plc4bSQkcUrNkKGAGDUkiZxEAeTPuqLXqyePKiwUl6O2/mR9wzfTyB9tMQwW72bqjyHVKRjYSBX3H9evbbJbHk1YGs4mZJZbGRdFFUTdnEli9UppPREFDZBU+nLiVIKmqjpL5J56l/561K60FlRhHBSrH32dUdTEOqbmg7hCATpQyR1b5yV/lCGcgQrvxzsYbEMEQB4O7c4HXJSFVe7BwEc/NQZPfOzsmxcOiJKndTTVhj9cbToAtrPLIi/IWb1fPCrKIiwyOCb3G6Ff27yueNHvUlWjf6MQt2Xy+0puWL5VY7tI44CBUO/zWS29zqK7GLU6JO7dmMmqAlmXekor022fA9ua3+yV4xxNZGh//rvPKcAtr6w1LsFfx2Tl9BgOJ/gY0ou4UP/3apDvfe7x+VyQUF7Vyz3hRNm+W/IWC3aTA975+02WsY8FyZhsjlfLL+W+Vvh9ee4u0MPB5AViP8vwxQfmaI1aiB20AT7W18wJwaviCZRcsnOlN0iFWBgPFjhrRRdRzrBrFTa1wsQaqsF97yIg2QT3k/OPEkEPXXZ/WYVuPLYOGnRn+Rizizysg883CwKYNAdAJcYFjKIOBd5uGS9T+e4PV+teRdO14BIwAjQpla7yN+QO8Vnj+W2Sh1VZTsHj9llZ2QPR61XHTDHGJlBO+aeuXI5LfvwKFqsSdAsKTn3RHZttoUVoe0cSAOEkNTonm6touUr1BfHUFVvQFYnIiel+k04XxgY0LpZOtTYLtpQP9teH/ECL+qm2L1++4aptR2PdMfpgVfchSehGO2YhOLUy04Q9GY/tgVErkiJRx7kYuY x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR11MB5872.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(136003)(346002)(376002)(366004)(396003)(39860400002)(8936002)(4326008)(64756008)(66446008)(9686003)(54906003)(66476007)(26005)(7696005)(110136005)(76116006)(38070700005)(966005)(38100700002)(55016003)(316002)(71200400001)(52536014)(66946007)(66556008)(82960400001)(41300700001)(6506007)(478600001)(8676002)(53546011)(83380400001)(33656002)(86362001)(5660300002)(186003)(122000001)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?QjFTm9EMi0vMYM8XdV/38nHqLBDIQuIyP+R1AA3D03MVTHzuRHsICOmzAHkz?= =?us-ascii?Q?trf3TWrWLA0CdvRSdjcHdxxnSM6BQfIkCh81iBQ03EfACoRpcWhKzAO/ZHjJ?= =?us-ascii?Q?D7WRFatfhlYLNgv6MjMVg13aGSmSFsVE4x9unAIFREz7E0iBGWJkRgHceO3z?= =?us-ascii?Q?OWKx2eka1ASOzGwYCNrn5m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ascii?Q?6k6mNyeiqQZE643tod0agNMkXWTVQnAFID1TLtMYxW1dSxIW4e2tz2G3AhSr?= =?us-ascii?Q?cq6MvtyyQbB4/SlFbz+unzUrNBUDnYajMQIyBBturNyYml5Un370s1bv2kRe?= =?us-ascii?Q?9imRpJgBvJtyXX1Qv/YAyQyMhu1VbGOW+mOJgcL7I5lwY+/M7mlIOjUSpJpE?= =?us-ascii?Q?CNnit/+JFa4xK87MYOhAwTkR8OHZ11+9XhfGR8TOUnrufZp+9ej87q5kP4uy?= =?us-ascii?Q?b7jonZlhgMooUwKSEmhJRoSYNZ2DbrqHj88JRnYXVtKJog2rOXGO+gZSgXBl?= =?us-ascii?Q?bt7JemYQVmm+KOUozmWjOeAoJpX3xnPdQ8KFl6jl6yKF2AMf7ODDY67oMBkZ?= =?us-ascii?Q?BwzG8xSFxlPMTUK7eSloCmqbod23Rmw67RqUBt/fQkG3dT9nm+XhJOxZyW2b?= =?us-ascii?Q?WoUl3/McNJAcTc8ZPEAkWkwP30pc4S20HZKZ1Cu5mwXtJ8wJC8vPMMrbRFTr?= =?us-ascii?Q?d87LemWamaHu5AHd/H84NTkMkFf0P3QGgF+b2PQd?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0417f130-b28d-4cc8-a431-08da5a2fa53c X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jun 2022 00:29:50.8211 (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: iEygNQNdFig37WR61WMLlW04EQsJj7R70GhUVzj/m5zWoC1lAO9YOEEB4U4sZTJ/cywrS7biscLgLgkFFDc3ow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3739 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi 1) Would you please educate me, how this library be used in cryptolib? - ht= tps://github.com/tianocore/edk2/blob/master/CryptoPkg/Include/Library/BaseC= ryptLib.h#L1091 Currently, we have AES_CBC. We are going to add AES_GCM in near future. 2) For Intel AES_NI, we added support in OpensslLib directly - https://gith= ub.com/tianocore/edk2/tree/master/CryptoPkg/Library/OpensslLib/X64, can ARM= use the similar model? 3) Do you have chance to take a look if this interface is good enough to im= plement Intel AES_NI instruction? Thank you Yao Jiewen > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of > PierreGondois > Sent: Thursday, June 30, 2022 3:14 AM > To: devel@edk2.groups.io > Cc: Sami Mujawar ; Leif Lindholm > ; Ard Biesheuvel ; > Rebecca Cran ; Kinney, Michael D > ; Gao, Liming ; > Edward Pickup > Subject: [edk2-devel] [PATCH RESEND v1 5/7] MdePkg/AesLib: Definition for= AES > library class interface >=20 > From: Pierre Gondois >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3970 >=20 > The FIPS PUB 197: "Advanced Encryption Standard (AES)" > details the AES algorithm. Add a library to allow > different architecture specific implementations. >=20 > Signed-off-by: Pierre Gondois > --- > MdePkg/Include/Library/AesLib.h | 104 ++++++++++++++++++++++++++++++++ > MdePkg/MdePkg.dec | 4 ++ > 2 files changed, 108 insertions(+) > create mode 100644 MdePkg/Include/Library/AesLib.h >=20 > diff --git a/MdePkg/Include/Library/AesLib.h b/MdePkg/Include/Library/Aes= Lib.h > new file mode 100644 > index 000000000000..bc3408bb249b > --- /dev/null > +++ b/MdePkg/Include/Library/AesLib.h > @@ -0,0 +1,104 @@ > +/** @file > + AES library. > + > + Copyright (c) 2022, Arm Limited. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > + @par Reference(s): > + - FIPS 197 November 26, 2001: > + Specification for the ADVANCED ENCRYPTION STANDARD (AES) > +**/ > + > +#ifndef AES_LIB_H_ > +#define AES_LIB_H_ > + > +/// Key size in bytes. > +#define AES_KEY_SIZE_128 16 > +#define AES_KEY_SIZE_192 24 > +#define AES_KEY_SIZE_256 32 > +#define AES_BLOCK_SIZE 16 > + > +/* > + The Key Expansion generates a total of Nb (Nr + 1) words with: > + - Nb =3D 4: > + Number of columns (32-bit words) comprising the State > + - Nr =3D 10, 12, or 14: > + Number of rounds. > + */ > +#define AES_MAX_KEYLENGTH_U32 (4 * (14 + 1)) > + > +/** A context holding information to for AES encryption/decryption. > + */ > +typedef struct { > + /// Expanded encryption key. > + UINT32 ExpEncKey[AES_MAX_KEYLENGTH_U32]; > + /// Expanded decryption key. > + UINT32 ExpDecKey[AES_MAX_KEYLENGTH_U32]; > + /// Key size, in bytes. > + /// Must be one of 16|24|32. > + UINT32 KeySize; > +} AES_CTX; > + > +/** Encrypt an AES block. > + > + Buffers are little-endian. Overlapping is not checked. > + > + @param [in] AesCtx AES context. > + AesCtx is initialized with AesInitCtx (). > + @param [in] InBlock Input Block. The block to cipher. > + @param [out] OutBlock Output Block. The ciphered block. > + > + @retval RETURN_SUCCESS Success. > + @retval RETURN_INVALID_PARAMETER Invalid parameter. > + @retval RETURN_UNSUPPORTED Unsupported. > +**/ > +RETURN_STATUS > +EFIAPI > +AesEncrypt ( > + IN AES_CTX *AesCtx, > + IN UINT8 CONST *InBlock, > + OUT UINT8 *OutBlock > + ); > + > +/** Decrypt an AES block. > + > + Buffers are little-endian. Overlapping is not checked. > + > + @param [in] AesCtx AES context. > + AesCtx is initialized with AesInitCtx (). > + @param [in] InBlock Input Block. The block to de-cipher. > + @param [out] OutBlock Output Block. The de-ciphered block. > + > + @retval RETURN_SUCCESS Success. > + @retval RETURN_INVALID_PARAMETER Invalid parameter. > + @retval RETURN_UNSUPPORTED Unsupported. > +**/ > +RETURN_STATUS > +EFIAPI > +AesDecrypt ( > + IN AES_CTX *AesCtx, > + IN UINT8 CONST *InBlock, > + OUT UINT8 *OutBlock > + ); > + > +/** Initialize an AES_CTX structure. > + > + @param [in] Key AES key. Buffer of KeySize bytes. > + The buffer is little endian. > + @param [in] KeySize Size of the key. Must be one of 128|192|25= 6. > + @param [in, out] AesCtx AES context to initialize. > + > + @retval RETURN_SUCCESS Success. > + @retval RETURN_INVALID_PARAMETER Invalid parameter. > + @retval RETURN_UNSUPPORTED Unsupported. > +**/ > +RETURN_STATUS > +EFIAPI > +AesInitCtx ( > + IN UINT8 *Key, > + IN UINT32 KeySize, > + IN OUT AES_CTX *AesCtx > + ); > + > +#endif // AES_LIB_H_ > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec > index 7ff26e22f915..078ae9323ba6 100644 > --- a/MdePkg/MdePkg.dec > +++ b/MdePkg/MdePkg.dec > @@ -280,6 +280,10 @@ [LibraryClasses] > # > TrngLib|Include/Library/TrngLib.h >=20 > + ## @libraryclass Provides AES encryption/decryption services. > + # > + AesLib|Include/Library/AesLib.h > + > [LibraryClasses.IA32, LibraryClasses.X64, LibraryClasses.AARCH64] > ## @libraryclass Provides services to generate random number. > # > -- > 2.25.1 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#90895): https://edk2.groups.io/g/devel/message/90895 > Mute This Topic: https://groups.io/mt/92072168/1772286 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [jiewen.yao@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D >=20