From nobody Tue Feb 10 13:16:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90900+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90900+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1656530369; cv=none; d=zohomail.com; s=zohoarc; b=WwOwWgRiX18KBK2bjDIqT3QTJToHkGO8tYxXjDidxTTyDX0qKYuWmu1RnLiK4jDSE39kwW3SRIxZkNQPzWYHdiKpw9n9OBHueeKwEu6xHocoVoveJLEgrZgZLB4p6vQOzh2vqPwQVFgmxxckkHtadJoLKunTpGjtvEVAFFeGuiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656530369; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=uUDnbUJJHz6r6xaR9PjhhFjTT6DwV61OjxJTDb2Hw5g=; b=jnwLT7q0tjguX5yYFF1tRFeL5B1Y5N90e25J76uGalQfJPg4mh+VhuZCUKINHoJPp+FeSOSw3XN5lFrgcvN8t0sqpgHM43jcnatTH98tWX835LC2NdbsTDWpTzrnNDmZHY6WrcYc45vMMTA/NFPVPMkXSCbGOgfelJqrkETYUlQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90900+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1656530369789719.4780144849237; Wed, 29 Jun 2022 12:19:29 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iXFRYY1788612xrzWwZ73wlK; Wed, 29 Jun 2022 12:19:29 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.15930.1656530368715647399 for ; Wed, 29 Jun 2022 12:19:28 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9E335152B; Wed, 29 Jun 2022 12:19:28 -0700 (PDT) X-Received: from pierre123.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 549FA3F792; Wed, 29 Jun 2022 12:19:26 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH RESEND v1 2/9] MdePkg/DrbgLib: Add NULL instance of Drbg Library Date: Wed, 29 Jun 2022 21:18:39 +0200 Message-Id: <20220629191848.2619317-3-Pierre.Gondois@arm.com> In-Reply-To: <20220629191848.2619317-1-Pierre.Gondois@arm.com> References: <20220629191848.2619317-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,pierre.gondois@arm.com X-Gm-Message-State: hkCIHLMAgA18Nvh4jYbJuGtYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1656530369; bh=4lH8R1wjO8tRGkfuWpu1/PE4Z8jZM020K+gNHDtjebw=; h=Cc:Date:From:Reply-To:Subject:To; b=PUBHJZHDNxN1Ies64FIdG1H3PTQZERT7VreJVfXdzx2gTBp24fzMgKyjBgGuKP4TGth MKAQCEDa1YzE5kQx/QOaOP3dG2D8bNicRI09F3l7dscE0pB8Gqyn3/9mNhovhuX908EO7 YpmA0kFmGyIoSn5mmYi9QxTeFxtqgO5jdjw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1656530370158100005 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add a Null instance of the DrbgLib satisfy potential build dependencies issues. Signed-off-by: Pierre Gondois --- MdePkg/Library/DrbgLibNull/DrbgLib.c | 165 +++++++++++++++++++++ MdePkg/Library/DrbgLibNull/DrbgLibNull.inf | 21 +++ MdePkg/MdePkg.dsc | 1 + 3 files changed, 187 insertions(+) create mode 100644 MdePkg/Library/DrbgLibNull/DrbgLib.c create mode 100644 MdePkg/Library/DrbgLibNull/DrbgLibNull.inf diff --git a/MdePkg/Library/DrbgLibNull/DrbgLib.c b/MdePkg/Library/DrbgLibN= ull/DrbgLib.c new file mode 100644 index 000000000000..e366843b03f0 --- /dev/null +++ b/MdePkg/Library/DrbgLibNull/DrbgLib.c @@ -0,0 +1,165 @@ +/** @file + Drbg library. + Cf. [1] s9 DRBG Mechanism Functions + + Copyright (c) 2022, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Reference(s): + - [1] NIST Special Publication 800-90A Revision 1, June 2015, Recommenda= tion + for Random Number Generation Using Deterministic Random Bit Genera= tors. + (https://csrc.nist.gov/publications/detail/sp/800-90a/rev-1/final) + - [2] NIST Special Publication 800-90B, Recommendation for the Entropy + Sources Used for Random Bit Generation. + (https://csrc.nist.gov/publications/detail/sp/800-90b/final) + - [3] (Second Draft) NIST Special Publication 800-90C, Recommendation for + Random Bit Generator (RBG) Constructions. + (https://csrc.nist.gov/publications/detail/sp/800-90c/draft) + - [4] NIST Special Publication 800-57 Part 1 Revision 5, May 2020, + Recommendation for Key Management:Part 1 - General. + (https://csrc.nist.gov/publications/detail/sp/800-57-part-1/rev-5/= final) + - [5] Unified Extensible Firmware Interface (UEFI) Specification, + Version 2.8 Errata B, May 2020 + (https://www.uefi.org/specifications) + + @par Glossary: + - TRNG - True Random Number Generator + - Sec - Security + - DRBG - Deterministic Random Bits Generator + - CTR - Counter +**/ + +#include +#include +#include + +/** Reseed a DRBG instance. + + Implementation of Reseed_function. + Cf. [1] s9.2 'Reseeding a DRBG Instantiation' + + @param [in] PredResRequest Indicates whether prediction resistance + is to be provided during the request. + Might not be supported by all Drbgs. + @param [in] AddInput An optional additional input. + Might not be supported by all Drbgs. + @param [in] AddInputLen Additional input length (in bits). + Might not be supported by all Drbgs. + @param [in, out] Handle The Drbg handle. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Out of resources. +**/ +EFI_STATUS +EFIAPI +DrbgReseedFn ( + IN BOOLEAN PredResRequest, + IN CONST CHAR8 *AddInput, + IN UINTN AddInputLen, + IN OUT VOID *Handle + ) +{ + ASSERT (FALSE); + return EFI_UNSUPPORTED; +} + +/** Create a Drbg instance. + + Implementation of Instantiate_function. + Cf. [1] s9.1 Instantiating a DRBG + + @param [in] DrbgMechanism DRBG mechanism chosen. + @param [in] DrbgEntropySrc Entropy source chosen. + @param [in] ReqSecStrength Requested security strength (in bits). + The security strenght granted can be diffe= rent. + @param [in] PredRes Prediction resistance flag. + If relevant, instantiate a DRBG that suppo= rts + prediction resistance. + Might not be supported by all Drbgs. + @param [in] PersStr Personnalization string. + Might not be supported by all Drbgs. + @param [in] PersStrLen Personnalization string length (in bits). + Might not be supported by all Drbgs. + @param [out] HandlePtr Pointer containting the created Drbg handle. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Out of resources. +**/ +EFI_STATUS +EFIAPI +DrbgInstantiateFn ( + IN DRBG_MECHANISM DrbgMechanism, + IN DRBG_ENTROPY_SRC DrbgEntropySrc, + IN UINTN ReqSecStrength, + IN BOOLEAN PredRes, + IN CONST CHAR8 *PersStr, + IN UINTN PersStrLen, + OUT VOID **HandlePtr + ) +{ + ASSERT (FALSE); + return EFI_UNSUPPORTED; +} + +/** Generate a random number. + + Implementation of Generate_function. + Cf. [1] s9.3.1 The Generate Function + + @param [in] ReqSecStrength Requested security strength (in bits). + If the DrbgHandle cannot satisfy the reque= st, + an error is returned. + @param [in] PredResReq Request prediction resistance. + If the DrbgHandle cannot satisfy the reque= st, + an error is returned. + @param [in] AddInput Additional input. + Might not be supported by all Drbgs. + @param [in] AddInputLen Additional input length (in bits). + Might not be supported by all Drbgs. + @param [in] ReqNbBits Number of random bits requested. + @param [in, out] OutBuffer If success, contains the random bits. + The buffer must be at least ReqNbBits bits + long. + @param [in, out] Handle The Drbg handle. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Out of resources. +**/ +EFI_STATUS +EFIAPI +DrbgGenerateFn ( + IN UINTN ReqSecStrength, + IN BOOLEAN PredResReq, + IN CONST CHAR8 *AddInput, + IN UINTN AddInputLen, + IN UINTN ReqNbBits, + IN OUT UINT8 *OutBuffer, + IN OUT VOID *Handle + ) +{ + ASSERT (FALSE); + return EFI_UNSUPPORTED; +} + +/** Remove a DRBG instance. + + Implementation of Uninstantiate_function. + Cf. [1] s9.4 Removing a DRBG Instantiation + + @param [in, out] Handle The Drbg handle. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +DrbgUninstantiateFn ( + IN OUT VOID *Handle + ) +{ + ASSERT (FALSE); + return EFI_UNSUPPORTED; +} diff --git a/MdePkg/Library/DrbgLibNull/DrbgLibNull.inf b/MdePkg/Library/Dr= bgLibNull/DrbgLibNull.inf new file mode 100644 index 000000000000..6e17af4390fc --- /dev/null +++ b/MdePkg/Library/DrbgLibNull/DrbgLibNull.inf @@ -0,0 +1,21 @@ +## @file +# Drbg Null library +# +# Copyright (c) 2022, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D DrbgLib + FILE_GUID =3D B8A688E5-C31A-4CF8-9A76-B31211D292DE + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D DrbgLib + +[Sources] + DrbgLib.c + +[Packages] + MdePkg/MdePkg.dec diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index 726350c215e5..4820cecd0db8 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -69,6 +69,7 @@ [Components] MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf MdePkg/Library/BaseTrngLibNull/BaseTrngLibNull.inf MdePkg/Library/AesLibNull/AesLibNull.inf + MdePkg/Library/DrbgLibNull/DrbgLibNull.inf =20 MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf --=20 2.25.1 -=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 (#90900): https://edk2.groups.io/g/devel/message/90900 Mute This Topic: https://groups.io/mt/92072285/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-