From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.8553.1573543869150939103 for ; Mon, 11 Nov 2019 23:31:09 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: jian.j.wang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Nov 2019 23:31:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,295,1569308400"; d="scan'208";a="404154830" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga005.fm.intel.com with ESMTP; 11 Nov 2019 23:31:07 -0800 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 Nov 2019 23:31:07 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 Nov 2019 23:31:07 -0800 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.63]) by shsmsx102.ccr.corp.intel.com ([169.254.2.108]) with mapi id 14.03.0439.000; Tue, 12 Nov 2019 15:31:05 +0800 From: "Wang, Jian J" To: "Ni, Ray" , "devel@edk2.groups.io" CC: "Yao, Jiewen" , "Zhang, Chao B" , "Kinney, Michael D" , "Gao, Liming" , Laszlo Ersek , "Ard Biesheuvel" Subject: Re: [PATCH] SecurityPkg/RngLibNull: add null version of RngLib Thread-Topic: [PATCH] SecurityPkg/RngLibNull: add null version of RngLib Thread-Index: AQHVmR3WthZ2MDZoDkW6mjLQqgQ8LqeHEmMAgAAGU/D//33/AIAAiBsw//98CACAAIZZgA== Date: Tue, 12 Nov 2019 07:31:04 +0000 Message-ID: References: <20191112055545.3948-1-jian.j.wang@intel.com> <734D49CCEBEEF84792F5B80ED585239D5C35A419@SHSMSX104.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5C35A524@SHSMSX104.ccr.corp.intel.com> <734D49CCEBEEF84792F5B80ED585239D5C35A54E@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5C35A54E@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMWJkNzAwMmItMTI2Ny00ZWNlLThhNzMtZTRiMWZiNDdiNzljIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibEVMbHV4bm5iWmltdXpLOHd6MEJqdHdmM2RlaW00bFYwT3NYcTJQT2lFcm9qR0dUMTFobFA3NFRaQmpKRlNDWiJ9 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 Yes, currently only those doing encryption/hash (like TLS, HddPassword) nee= ds random number explicitly. But sometimes it's hard to tell because random mi= ght be needed deeply inside other operations. The ASSERT will help to find out = that situation. Maybe I should use "link" instead of "use". Regards, Jian > -----Original Message----- > From: Ni, Ray > Sent: Tuesday, November 12, 2019 3:20 PM > To: Wang, Jian J ; devel@edk2.groups.io > Cc: Yao, Jiewen ; Zhang, Chao B > ; Kinney, Michael D ; > Gao, Liming ; Laszlo Ersek ; Ard > Biesheuvel > Subject: RE: [PATCH] SecurityPkg/RngLibNull: add null version of RngLib >=20 > Does a real platform that requires no random number exist? > If it doesn't, I agree with this implementation but please adjust the com= mit > message > to say it's just for pass build. >=20 > If it does, I prefer to remove the "ASSERT". >=20 > Either way, I just feel the commit message may mislead platforms to use > this instance but they will hit assertion. >=20 > Thanks, > Ray >=20 >=20 > > -----Original Message----- > > From: Wang, Jian J > > Sent: Tuesday, November 12, 2019 3:16 PM > > To: Ni, Ray ; devel@edk2.groups.io > > Cc: Yao, Jiewen ; Zhang, Chao B > > ; Kinney, Michael D > > ; Gao, Liming ; Laszl= o > > Ersek ; Ard Biesheuvel > > Subject: RE: [PATCH] SecurityPkg/RngLibNull: add null version of RngLib > > > > Since OpensslLib will depend on RngLib, we should give an instance of i= t > > anyway, even for those who don't need it. Otherwise the build will fail= . > > What's your suggestion for the message? > > > > Regards, > > Jian > > > > > -----Original Message----- > > > From: Ni, Ray > > > Sent: Tuesday, November 12, 2019 3:05 PM > > > To: Wang, Jian J ; devel@edk2.groups.io > > > Cc: Yao, Jiewen ; Zhang, Chao B > > > ; Kinney, Michael D > > > ; Gao, Liming ; > > > Laszlo Ersek ; Ard Biesheuvel > > > > > > Subject: RE: [PATCH] SecurityPkg/RngLibNull: add null version of > > > RngLib > > > > > > Jian, > > > But the commit message is: > > > "This is null version of RngLib which is used for those platforms or > > > components which don't need random number." > > > > > > Thanks, > > > Ray > > > > > > > -----Original Message----- > > > > From: Wang, Jian J > > > > Sent: Tuesday, November 12, 2019 2:58 PM > > > > To: Ni, Ray ; devel@edk2.groups.io > > > > Cc: Yao, Jiewen ; Zhang, Chao B > > > > ; Kinney, Michael D > > > > ; Gao, Liming ; > > > > Laszlo Ersek ; Ard Biesheuvel > > > > > > > > Subject: RE: [PATCH] SecurityPkg/RngLibNull: add null version of > > > > RngLib > > > > > > > > Ray, > > > > > > > > It's for build only but not supposed to be *used* in a platform. If > > > > a platform really wants a RngLib, the owners need to change the > > > > instance to a proper one. ASSERT will tell them that. Otherwise, th= e > > > > RngLib interface should not be called. > > > > > > > > Regards, > > > > Jian > > > > > > > > > -----Original Message----- > > > > > From: Ni, Ray > > > > > Sent: Tuesday, November 12, 2019 2:30 PM > > > > > To: Wang, Jian J ; devel@edk2.groups.io > > > > > Cc: Yao, Jiewen ; Zhang, Chao B > > > > > ; Kinney, Michael D > > > > > ; Gao, Liming ; > > > > > Laszlo Ersek ; Ard Biesheuvel > > > > > > > > > > Subject: RE: [PATCH] SecurityPkg/RngLibNull: add null version of > > > > > RngLib > > > > > > > > > > Jian, > > > > > If we expect platform to use this library, probably > > > > > "ASSERT(FALSE)" is not > > > > proper. > > > > > > > > > > > -----Original Message----- > > > > > > From: Wang, Jian J > > > > > > Sent: Tuesday, November 12, 2019 1:56 PM > > > > > > To: devel@edk2.groups.io > > > > > > Cc: Yao, Jiewen ; Zhang, Chao B > > > > > > ; Kinney, Michael D > > > > > > ; Gao, Liming > > > > > > ; Laszlo Ersek ; Ard > > > > > > Biesheuvel ; Ni, Ray > > > > > > > > > > > > Subject: [PATCH] SecurityPkg/RngLibNull: add null version of > > > > > > RngLib > > > > > > > > > > > > This is null version of RngLib which is used for those platform= s > > > > > > or components which don't need random number. > > > > > > > > > > > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 > > > > > > Cc: Jiewen Yao > > > > > > Cc: Chao Zhang > > > > > > Cc: Michael D Kinney > > > > > > Cc: Liming Gao > > > > > > Cc: Laszlo Ersek > > > > > > Cc: Ard Biesheuvel > > > > > > Cc: Ray Ni > > > > > > Signed-off-by: Jian J Wang > > > > > > --- > > > > > > .../RngLibNull/RngLibNull.c | 95 +++++++++++= ++++++++ > > > > > > .../RngLibNull/RngLibNull.inf | 31 ++++++ > > > > > > .../RngLibNull/RngLibNull.uni | 14 +++ > > > > > > 3 files changed, 140 insertions(+) create mode 100644 > > > > > > SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.c > > > > > > create mode 100644 > > > > > > SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.inf > > > > > > create mode 100644 > > > > > > SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.uni > > > > > > > > > > > > diff --git > > > > > > a/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.c > > > > > > b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.c > > > > > > new file mode 100644 > > > > > > index 0000000000..13677abc84 > > > > > > --- /dev/null > > > > > > +++ > > b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.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 rand= om > > 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 rand= om > > 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 rand= om > > 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 ran= dom > > 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/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.inf > > > > > > b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.inf > > > > > > new file mode 100644 > > > > > > index 0000000000..f6494cdb82 > > > > > > --- /dev/null > > > > > > +++ > > b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.in > > > > > > +++ f > > > > > > @@ -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 RngLibNull > > > > > > + MODULE_UNI_FILE =3D RngLibNull.uni > > > > > > + FILE_GUID =3D CD8991F8-2061-4084-8C9E-9= C6F352DC58D > > > > > > + MODULE_TYPE =3D BASE > > > > > > + VERSION_STRING =3D 1.0 > > > > > > + LIBRARY_CLASS =3D RngLib > > > > > > + > > > > > > +# > > > > > > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > > > > > > +# > > > > > > + > > > > > > +[Sources] > > > > > > + RngLibNull.c > > > > > > + > > > > > > +[Packages] > > > > > > + MdePkg/MdePkg.dec > > > > > > + > > > > > > +[LibraryClasses] > > > > > > + BaseLib > > > > > > + DebugLib > > > > > > diff --git > > > > > > a/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.uni > > > > > > b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.uni > > > > > > new file mode 100644 > > > > > > index 0000000000..40b2ec3fe1 > > > > > > --- /dev/null > > > > > > +++ > > b/SecurityPkg/RandomNumberGenerator/RngLibNull/RngLibNull.un > > > > > > +++ i > > > > > > @@ -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 "Cauti= on: > > > > This is > > > > > > a null version of RNG library and SHOULD NOT be used on any > > > > > > product > > > > ever." > > > > > > + > > > > > > -- > > > > > > 2.17.1.windows.2