From nobody Sun May 5 19:56:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+50562+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50562+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1573623332; cv=none; d=zoho.com; s=zohoarc; b=gN4YEgJtbTQZurLBo1912yLPoVeIgZLuVFWX32Y/sETMnQL8MfMm7I1YkRJdtWpKXmjGqfw3KYUTAwkj3Jd421CNePPwzMZreRrm/uUt7Tzt9oI6y1bTWnqdnmq4chKYgYBX5jy1BhSXZU2QtphD7BVSh1PnIPNl9Nxt5iAvHQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573623332; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=c2EMf05Tp+4xZ7EXnXNSzcE52FefhczAR4JyMEHT4XQ=; b=BUjRMf0SMBR/yO/W1ClErHCjOH1q1b2YafJcXLy85LAxetFZ+5G1A+CdBcIjnVcI2vX3uJwR9bmh3MHlW5sNq+nJPla0Fa6lAIrwpEqp1W2iebebZh5esJIZTdGPg9pEUT5QZwWB1MdN1VicTRf7DrumPui9PlOUsvtLYnL6YSw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+50562+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1573623332849379.6742159447939; Tue, 12 Nov 2019 21:35:32 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5JQiYY1788612x0LOqLyJ8Us; Tue, 12 Nov 2019 21:35:32 -0800 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web12.430.1573623331487752979 for ; Tue, 12 Nov 2019 21:35:31 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2019 21:35:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="202646301" X-Received: from shwdeopenpsi777.ccr.corp.intel.com ([10.239.158.59]) by fmsmga008.fm.intel.com with ESMTP; 12 Nov 2019 21:35:29 -0800 From: "Wang, Jian J" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Laszlo Ersek , Ard Biesheuvel , Ray Ni Subject: [edk2-devel] [PATCH v2] MdePkg: add null version of RngLib Date: Wed, 13 Nov 2019 13:35:29 +0800 Message-Id: <20191113053529.7768-1-jian.j.wang@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jian.j.wang@intel.com X-Gm-Message-State: 9vjkcH2vPKM0euY0cLSSOxNZx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1573623332; bh=4LNBZFKi5s2Tx8p59bk0Wr4Oozo2R4P0VgpQcmoqTuM=; h=Cc:Date:From:Reply-To:Subject:To; b=Dfntzyo5mk/K9eEd+Vy+aP8zOoQ+Zj/oTn1JWGpbqU/5KWS3aM7qsSPaDASh8q57SjK R6JBnE3cVLoneiw2vK167ezRu8qGPZiJEtp2+XmLAjKNfQR1daveRGWAyZdCDxJgcmv2L xEXxn6uXSGh/nrwTa1FCDPv754XYCpoFhAs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" >v2: > - Change the name from RngLibNull to BaseRngLibNull according to Laszlo's > comments > - Move the module from SecurityPkg to MdePkg according to Laszlo's comme= nts > - 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 actually 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 Reviewed-by: Laszlo Ersek --- .../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/Librar= y/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/Libr= ary/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-9C6F352DC58D + 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/Libr= ary/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 inst= ance should be used with modules that inherit an (indirect) dependency on t= he RngLib class, but never actually call RngLib APIs for consuming randomne= ss." + 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 =20 MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf --=20 2.17.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#50562): https://edk2.groups.io/g/devel/message/50562 Mute This Topic: https://groups.io/mt/55296935/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-