From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web12.1771.1573634635447112297 for ; Wed, 13 Nov 2019 00:43:55 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: jian.j.wang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 00:43:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="229682169" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga004.fm.intel.com with ESMTP; 13 Nov 2019 00:43:52 -0800 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 13 Nov 2019 00:43:52 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 13 Nov 2019 00:43:51 -0800 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.63]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.215]) with mapi id 14.03.0439.000; Wed, 13 Nov 2019 16:43:50 +0800 From: "Wang, Jian J" To: "devel@edk2.groups.io" , "Wang, Jian J" CC: "Kinney, Michael D" , "Gao, Liming" , Laszlo Ersek , Ard Biesheuvel , "Ni, Ray" Subject: Re: [edk2-devel] [PATCH v2] MdePkg: add null version of RngLib Thread-Topic: [edk2-devel] [PATCH v2] MdePkg: add null version of RngLib Thread-Index: AQHVmeQ8KkpGWwvnmEK0adxuC0rfU6eIvgug Date: Wed, 13 Nov 2019 08:43:50 +0000 Message-ID: References: <15D6A215430F1F2B.28343@groups.io> In-Reply-To: <15D6A215430F1F2B.28343@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTY2YTkzNzItNzNjNS00NzY1LWI2NGItMzhmNjE3NWY4OGRhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU1UzRHAxaHNrVU9KOVpSQ3VVYUJLc1JGTUVZWGZWVlp2OXZieXlaUEFBWElEbDVcL1ZudVZBZEF1c0JXbDVLXC9XIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: jian.j.wang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable As requested by Ray, I'd like to mention more usage about this library instance. To be more specific, if following components or functionalities are used i= n a platform, the BaseRngLibNull should *not* be used. Instead, a non-Null ver= sion of RngLib must be used (like BaseRngLib for IA32/X64, or coming RngDxeLib for all ARCHs). - SecurityPkg/HddPassword/HddPasswordDxe.c - AES, TLS (NetworkPkg/TlsDxe/TlsDxe.inf, CryptoPkg/Library/TlsLib/TlsLib.= inf) RSA_OAEP, RSA_PK1 - (If BaseRngLibNull interface ASSERTed at boot time) Regards, Jian > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Wang, Jia= n > J > Sent: Wednesday, November 13, 2019 1:35 PM > To: devel@edk2.groups.io > Cc: Kinney, Michael D ; Gao, Liming > ; Laszlo Ersek ; Ard Biesheuvel > ; Ni, Ray > Subject: [edk2-devel] [PATCH v2] MdePkg: add null version of RngLib >=20 > >v2: > > - Change the name from RngLibNull to BaseRngLibNull according to Lasz= lo's > > comments > > - Move the module from SecurityPkg to MdePkg according to Laszlo's > comments > > - Update commit message according to Laszlo and Ray's comments >=20 > This is null version of RngLib which should be used with modules that > inherit an (indirect) dependency on the RngLib class, but never actually > call RngLib APIs for consuming randomness. >=20 >=20 > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Ray Ni > Signed-off-by: Jian J Wang > --- > .../Library/BaseRngLibNull/BaseRngLibNull.c | 95 +++++++++++++++++++ > .../Library/BaseRngLibNull/BaseRngLibNull.inf | 31 ++++++ > .../Library/BaseRngLibNull/BaseRngLibNull.uni | 14 +++ > MdePkg/MdePkg.dsc | 1 + > 4 files changed, 141 insertions(+) > create mode 100644 MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c > create mode 100644 MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > create mode 100644 MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni >=20 > diff --git a/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c > b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c > new file mode 100644 > index 0000000000..13677abc84 > --- /dev/null > +++ b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c > @@ -0,0 +1,95 @@ > +/** @file > + Null version of Random number generator services. > + > +Copyright (c) 2019, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > + > +/** > + Generates a 16-bit random number. > + > + if Rand is NULL, then ASSERT(). > + > + @param[out] Rand Buffer pointer to store the 16-bit random value. > + > + @retval TRUE Random number generated successfully. > + @retval FALSE Failed to generate the random number. > + > +**/ > +BOOLEAN > +EFIAPI > +GetRandomNumber16 ( > + OUT UINT16 *Rand > + ) > +{ > + ASSERT (FALSE); > + return FALSE; > +} > + > +/** > + Generates a 32-bit random number. > + > + if Rand is NULL, then ASSERT(). > + > + @param[out] Rand Buffer pointer to store the 32-bit random value. > + > + @retval TRUE Random number generated successfully. > + @retval FALSE Failed to generate the random number. > + > +**/ > +BOOLEAN > +EFIAPI > +GetRandomNumber32 ( > + OUT UINT32 *Rand > + ) > +{ > + ASSERT (FALSE); > + return FALSE; > +} > + > +/** > + Generates a 64-bit random number. > + > + if Rand is NULL, then ASSERT(). > + > + @param[out] Rand Buffer pointer to store the 64-bit random value. > + > + @retval TRUE Random number generated successfully. > + @retval FALSE Failed to generate the random number. > + > +**/ > +BOOLEAN > +EFIAPI > +GetRandomNumber64 ( > + OUT UINT64 *Rand > + ) > +{ > + ASSERT (FALSE); > + return FALSE; > +} > + > +/** > + Generates a 128-bit random number. > + > + if Rand is NULL, then ASSERT(). > + > + @param[out] Rand Buffer pointer to store the 128-bit random value= . > + > + @retval TRUE Random number generated successfully. > + @retval FALSE Failed to generate the random number. > + > +**/ > +BOOLEAN > +EFIAPI > +GetRandomNumber128 ( > + OUT UINT64 *Rand > + ) > +{ > + ASSERT (FALSE); > + return FALSE; > +} > diff --git a/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > new file mode 100644 > index 0000000000..f456df1dae > --- /dev/null > +++ b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > @@ -0,0 +1,31 @@ > +## @file > +# Null instance of RNG (Random Number Generator) Library. > +# > +# Copyright (c) 2019, Intel Corporation. All rights reserved.
> +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D BaseRngLibNull > + MODULE_UNI_FILE =3D BaseRngLibNull.uni > + FILE_GUID =3D CD8991F8-2061-4084-8C9E-9C6F352DC5= 8D > + MODULE_TYPE =3D BASE > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D RngLib > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + BaseRngLibNull.c > + > +[Packages] > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + BaseLib > + DebugLib > diff --git a/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni > b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni > new file mode 100644 > index 0000000000..f32be6a617 > --- /dev/null > +++ b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni > @@ -0,0 +1,14 @@ > +// /** @file > +// Null Instance of RNG (Random Number Generator) Library. > +// > +// Copyright (c) 2019, Intel Corporation. All rights reserved.
> +// > +// SPDX-License-Identifier: BSD-2-Clause-Patent > +// > +// **/ > + > + > +#string STR_MODULE_ABSTRACT #language en-US "Null Instance = of > RNG Library" > + > +#string STR_MODULE_DESCRIPTION #language en-US "This library > instance should be used with modules that inherit an (indirect) dependen= cy on > the RngLib class, but never actually call RngLib APIs for consuming rand= omness." > + > diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc > index c1278e7907..0aeafaaacc 100644 > --- a/MdePkg/MdePkg.dsc > +++ b/MdePkg/MdePkg.dsc > @@ -61,6 +61,7 @@ >=20 > MdePkg/Library/BaseUefiDecompressLib/BaseUefiTianoCustomDecompressLib. > inf > MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf > MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf > + MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf >=20 > MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf > MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf > -- > 2.17.1.windows.2 >=20 >=20 >=20