From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web12.2119.1573637314485930131 for ; Wed, 13 Nov 2019 01:28:34 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CKjbiWiG; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573637313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nCoZHWiyOwRCedrJkLNwIWhzrY0CZv4YzZFFigEW48o=; b=CKjbiWiGADNW5omYaWqrQccb9jkFTrsX9qjyFNeVIuSz4HOpuPpv1QrMPjDOD4C5oQSdbl fzPC/zo1bE9UFK8QXl8KsECszMgcnDFtinJyyUKEn/43gM2Awnyk3I43uKqlsM9GcbiyAl c4QOds/7Gxbi5HrN3cVxeAjt+zpOZj8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-W_PIknskP7CSKt9OK7Tm1w-1; Wed, 13 Nov 2019 04:28:30 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4894B805DB5; Wed, 13 Nov 2019 09:28:29 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88BA763742; Wed, 13 Nov 2019 09:28:27 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2] MdePkg: add null version of RngLib To: "Wang, Jian J" , "devel@edk2.groups.io" Cc: "Kinney, Michael D" , "Gao, Liming" , Ard Biesheuvel , "Ni, Ray" References: <15D6A215430F1F2B.28343@groups.io> From: "Laszlo Ersek" Message-ID: Date: Wed, 13 Nov 2019 10:28:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: W_PIknskP7CSKt9OK7Tm1w-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable On 11/13/19 09:43, Wang, Jian J wrote: > As requested by Ray, I'd like to mention more usage about this library > instance. >=20 > To be more specific, if following components or functionalities are used= in a > platform, the BaseRngLibNull should *not* be used. Instead, a non-Null v= ersion > of RngLib must be used (like BaseRngLib for IA32/X64, or coming RngDxeLi= b > for all ARCHs). >=20 > - SecurityPkg/HddPassword/HddPasswordDxe.c > - AES, TLS (NetworkPkg/TlsDxe/TlsDxe.inf, CryptoPkg/Library/TlsLib/TlsLi= b.inf) > RSA_OAEP, RSA_PK1 > - (If BaseRngLibNull interface ASSERTed at boot time) Just a naming suggestion for "RngDxeLib": I think it should be called "DxeRngLibXxxx", where "Xxxx" should stand for the core idea in the implementation. For example, if the library is based on EFI_RNG_PROTOCOL, then it likely should be called DxeRngLibRngProtocol This scheme seems consistent with some other library instance names under MdePkg/Library: MdePkg/Library/UefiDebugLibDebugPortProtocol MdePkg/Library/UefiDevicePathLibDevicePathProtocol and maybe even with MdePkg/Library/SmmPciLibPciRootBridgeIo MdePkg/Library/UefiPciLibPciRootBridgeIo Thanks Laszlo >=20 > Regards, > Jian >=20 >> -----Original Message----- >> From: devel@edk2.groups.io On Behalf Of Wang, Ji= an >> J >> Sent: Wednesday, November 13, 2019 1:35 PM >> To: devel@edk2.groups.io >> Cc: Kinney, Michael D ; Gao, Liming >> ; Laszlo Ersek ; Ard Biesheuve= l >> ; Ni, Ray >> Subject: [edk2-devel] [PATCH v2] MdePkg: add null version of RngLib >> >>> 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 >> >> This is null version of RngLib which should be used with modules that >> inherit an (indirect) dependency on the RngLib class, but never actuall= y >> call RngLib APIs for consuming randomness. >> >> >> 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 >> >> 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 valu= e. >> + >> + @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-9C6F352DC= 58D >> + 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) depende= ncy on >> the RngLib class, but never actually call RngLib APIs for consuming ran= domness." >> + >> 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 @@ >> >> MdePkg/Library/BaseUefiDecompressLib/BaseUefiTianoCustomDecompressLib. >> inf >> MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf >> MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf >> + MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf >> >> MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf >> MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf >> -- >> 2.17.1.windows.2 >> >> >>=20 >=20