From nobody Fri May 3 20:07:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64653+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64653+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598475308; cv=none; d=zohomail.com; s=zohoarc; b=He8nzGJMCX4xDTNMZrdkdK4A8En79sSBQ7p7FqAmJk86icInzKN4bE5gOT0ZLeXxxYLqi+DwvCZ1XsVqGmaMXkulwtxzW86IngIZhvxgUvCtJiDQsRZM6TxYwTbd79kAF+pY2pzJVkk+zqE7RbK6pzhDROVDOyn2CvizN66huKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598475308; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ja6m+yBiGd9Ruh7YNBzxMqIdEHAr8qEKy3R2JCH5QWw=; b=XZ8UjqPAw3cQ91hNhllvuHlFbPSTMM1az8MVRG9+rL9rgJb0W+tJxbVxrrjs664GEKrjQK1aZkxsVYHwyGgnQ8N9C6W9jbTCSLLo1i1jyWxixOWZmqijPSIE2qvjAIEYZ+WwHKO26b8Zc2+VQr7994LH7UOWZ8O5r2uum5TMViU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64653+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 1598475308688178.44276797687883; Wed, 26 Aug 2020 13:55:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ajaDYY1788612xvtJ1ukZsyG; Wed, 26 Aug 2020 13:55:08 -0700 X-Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mx.groups.io with SMTP id smtpd.web11.4534.1598475307513307688 for ; Wed, 26 Aug 2020 13:55:07 -0700 X-Received: by mail-pj1-f44.google.com with SMTP id s2so845203pjr.4 for ; Wed, 26 Aug 2020 13:55:07 -0700 (PDT) X-Gm-Message-State: b0rv4s9dJvrrjSFCoXI5CaD6x1787277AA= X-Google-Smtp-Source: ABdhPJxVh+ZSziXN+4r00zaEpfy9gxXR6ydMwtYpcAE2YVZrchlPA7NnG2F8hl8kfMZ/niVXBu8eVw== X-Received: by 2002:a17:90b:1004:: with SMTP id gm4mr7292722pjb.26.1598475306862; Wed, 26 Aug 2020 13:55:06 -0700 (PDT) X-Received: from tvis-name-05.localdomain ([50.34.40.129]) by smtp.gmail.com with ESMTPSA id s67sm68284pfs.117.2020.08.26.13.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 13:55:06 -0700 (PDT) From: "Matthew Carlson" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael D Kinney , Liming Gao , Zhiguang Liu , Matthew Carlson Subject: [edk2-devel] [PATCH v9 1/5] MdePkg: TimerRngLib: Added RngLib that uses TimerLib Date: Wed, 26 Aug 2020 13:54:57 -0700 Message-Id: <20200826205501.1124-2-matthewfcarlson@gmail.com> In-Reply-To: <20200826205501.1124-1-matthewfcarlson@gmail.com> References: <20200826205501.1124-1-matthewfcarlson@gmail.com> MIME-Version: 1.0 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,matthewfcarlson@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1598475308; bh=PF0ldLF4++M9YiMrN1gbED8slEz7yqDnDaTjW5VLKP8=; h=Cc:Date:From:Reply-To:Subject:To; b=CZt+cDIY3z8h2M6y1FpE5CEZjQCKCLgoaem8ksUx77M+J27zfYb+MPG/H3JuPxRBmX+ bhRcH6cprhMGiwYCAqlcEVSH+kZQ/p9P9qB2vi38gz3UvRrw/IkGomgGa9P8NGCcRa4TV QnbbuRF0b6Tkb8hfj4IeyodPtypRPOWvIwM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Matthew Carlson Added a new RngLib that provides random numbers from the TimerLib using the performance counter. This is meant to be used for OpenSSL to replicate past behavior. This should not be used in production as a real source of entropy. Ref: https://github.com/tianocore/edk2/pull/845 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 Cc: Ard Biesheuvel Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Matthew Carlson --- MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c | 187 +++++++++++= +++++++++ MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf | 36 ++++ MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni | 15 ++ MdePkg/MdePkg.dsc | 3 +- 4 files changed, 240 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c b/MdePkg/Libra= ry/BaseRngLibTimerLib/RngLibTimer.c new file mode 100644 index 000000000000..aecaa427bb3f --- /dev/null +++ b/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c @@ -0,0 +1,187 @@ +/** @file + BaseRng Library that uses the TimerLib to provide reasonably random numb= ers. + Do not use this on a production system. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include + +/** + Using the TimerLib GetPerformanceCounterProperties() we delay + for enough time for the PerformanceCounter to increment. + + If the return value from GetPerformanceCounterProperties (TimerLib) + is zero, this function will return 10 and attempt to assert. + **/ +STATIC +UINT32 +CalculateMinimumDecentDelayInMicroseconds ( + VOID + ) +{ + UINT64 CounterHz; + + // Get the counter properties + CounterHz =3D GetPerformanceCounterProperties (NULL, NULL); + // Make sure we won't divide by zero + if (CounterHz =3D=3D 0) { + ASSERT(CounterHz !=3D 0); // Assert so the developer knows something i= s wrong + return 10; // return 10 microseconds by default + } + // Calculate the minimum delay based on 1.5 microseconds divided by the = hertz. + // We calculate the length of a cycle (1/CounterHz) and multiply it by 1= .5 microseconds + // This ensures that the performance counter has increased by at least o= ne + return (UINT32)(MAX (DivU64x64Remainder (1500000,CounterHz, NULL), 1)); +} + + +/** + 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 + ) +{ + UINT32 Index; + UINT8 *RandPtr; + UINT32 DelayInMicroSeconds; + + ASSERT (Rand !=3D NULL); + + if (Rand =3D=3D NULL) { + return FALSE; + } + DelayInMicroSeconds =3D CalculateMinimumDecentDelayInMicroseconds (); + RandPtr =3D (UINT8*)Rand; + // Get 2 bytes of random ish data + for (Index =3D 0; Index < 2; Index ++) { + *RandPtr =3D (UINT8)(GetPerformanceCounter () & 0xFF); + // Delay to give the performance counter a chance to change + MicroSecondDelay (DelayInMicroSeconds); + RandPtr++; + } + return TRUE; +} + +/** + 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 + ) +{ + UINT32 Index; + UINT8 *RandPtr; + UINT32 DelayInMicroSeconds; + + ASSERT (Rand !=3D NULL); + + if (NULL =3D=3D Rand) { + return FALSE; + } + + RandPtr =3D (UINT8 *) Rand; + DelayInMicroSeconds =3D CalculateMinimumDecentDelayInMicroseconds (); + // Get 4 bytes of random ish data + for (Index =3D 0; Index < 4; Index ++) { + *RandPtr =3D (UINT8)(GetPerformanceCounter () & 0xFF); + // Delay to give the performance counter a chance to change + MicroSecondDelay (DelayInMicroSeconds); + RandPtr++; + } + return TRUE; +} + +/** + 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 + ) +{ + UINT32 Index; + UINT8 *RandPtr; + UINT32 DelayInMicroSeconds; + + ASSERT (Rand !=3D NULL); + + if (NULL =3D=3D Rand) { + return FALSE; + } + + RandPtr =3D (UINT8 *)Rand; + DelayInMicroSeconds =3D CalculateMinimumDecentDelayInMicroseconds (); + // Get 8 bytes of random ish data + for (Index =3D 0; Index < 8; Index ++) { + *RandPtr =3D (UINT8)(GetPerformanceCounter () & 0xFF); + // Delay to give the performance counter a chance to change + MicroSecondDelay (DelayInMicroSeconds); + RandPtr++; + } + + return TRUE; +} + +/** + 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 (Rand !=3D NULL); + // This should take around 80ms + + // Read first 64 bits + if (!GetRandomNumber64 (Rand)) { + return FALSE; + } + + // Read second 64 bits + return GetRandomNumber64 (++Rand); +} diff --git a/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf b/Mde= Pkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf new file mode 100644 index 000000000000..c499e5327351 --- /dev/null +++ b/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf @@ -0,0 +1,36 @@ +## @file +# Instance of RNG (Random Number Generator) Library. +# +# BaseRng Library that uses the TimerLib to provide reasonably random num= bers. +# Do NOT use this on a production system as this uses the system performa= nce +# counter rather than a true source of random in addition to having a weak +# random algorithm. This is provided primarily as a source of entropy for +# OpenSSL for platforms that do not have a good built in RngLib as this +# emulates what was done before (though it isn't perfect). +# +# Copyright (c) Microsoft Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D BaseRngLibTimerLib + MODULE_UNI_FILE =3D BaseRngLibTimerLib.uni + FILE_GUID =3D 74950C45-10FC-4AB5-B114-49C87C17409B + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RngLib + CONSTRUCTOR =3D BaseRngLibConstructor + +[Sources] + RngLibTimer.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib + TimerLib diff --git a/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni b/Mde= Pkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni new file mode 100644 index 000000000000..fde24b9f0107 --- /dev/null +++ b/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni @@ -0,0 +1,15 @@ +// @file +// Instance of RNG (Random Number Generator) Library. +// +// RngLib that uses TimerLib's performance counter to provide random numbe= rs. +// +// Copyright (c) Microsoft Corporation. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + + +#string STR_MODULE_ABSTRACT #language en-US "Instance of RNG Library" + +#string STR_MODULE_DESCRIPTION #language en-US "BaseRng Library that uses= the TimerLib to provide low-entropy random numbers" + diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index 472fa3777412..d7ba3a730909 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -62,6 +62,8 @@ MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf MdePkg/Library/BasePrintLib/BasePrintLib.inf MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.i= nf + MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf + MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf @@ -69,7 +71,6 @@ 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.28.0.windows.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 (#64653): https://edk2.groups.io/g/devel/message/64653 Mute This Topic: https://groups.io/mt/76437900/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- From nobody Fri May 3 20:07:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64654+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64654+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598475309; cv=none; d=zohomail.com; s=zohoarc; b=KtUNnULdZshwoVj7L9kk1cfMTasyBylc+/Rzd21DaFSWQfz0EfM9smcNInYK2nXh5RHOdjHYGauZ12crAiGTyCjrkMR62hmMqLadSYWOwzaKF/l6cZPOVPUYpmcS20mV2m7XZvussjTSMsoq+czqr8H+CmOvUTU3oJp4Q7gvsFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598475309; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=6Nk7URqC3sOBfAmmSeSUo5zGdK8FZPYjbwkTdNfWpFg=; b=ePMpQNO6HQ38Ryx2G8tW3C84O2OnO1HuKzP/947ccfy5QE423j2C7OOjzfkN6sd2oieMPq6Gg79jl4+CHsi2MMPDrQMe02VWOiit44fpbOwgCYRYGFMqMA+A4wLBYn7cGsk0MKBxFWcRBE3H9e57xPjGI/1T0jJ+4sAIYvQSVbI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64654+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 1598475309604517.9186190528502; Wed, 26 Aug 2020 13:55:09 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id UeZAYY1788612x3UALaqyFbt; Wed, 26 Aug 2020 13:55:09 -0700 X-Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mx.groups.io with SMTP id smtpd.web10.4549.1598475308665557739 for ; Wed, 26 Aug 2020 13:55:08 -0700 X-Received: by mail-pj1-f49.google.com with SMTP id s2so845228pjr.4 for ; Wed, 26 Aug 2020 13:55:08 -0700 (PDT) X-Gm-Message-State: kYgbsiCvHgMWQdmbPWVZ6dF7x1787277AA= X-Google-Smtp-Source: ABdhPJxsTSgYEV3Q4nfl9jDdDIscQOshQKmUyIwkOgL3NrqwoC4nDcymXQIeRK2U3Fpr+xQZefFymg== X-Received: by 2002:a17:90a:858a:: with SMTP id m10mr1627742pjn.185.1598475307676; Wed, 26 Aug 2020 13:55:07 -0700 (PDT) X-Received: from tvis-name-05.localdomain ([50.34.40.129]) by smtp.gmail.com with ESMTPSA id s67sm68284pfs.117.2020.08.26.13.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 13:55:07 -0700 (PDT) From: "Matthew Carlson" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael D Kinney , Liming Gao , Zhiguang Liu , Matthew Carlson Subject: [edk2-devel] [PATCH v9 2/5] MdePkg: BaseRngLibDxe: Add RngLib that uses RngDxe Date: Wed, 26 Aug 2020 13:54:58 -0700 Message-Id: <20200826205501.1124-3-matthewfcarlson@gmail.com> In-Reply-To: <20200826205501.1124-1-matthewfcarlson@gmail.com> References: <20200826205501.1124-1-matthewfcarlson@gmail.com> MIME-Version: 1.0 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,matthewfcarlson@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1598475309; bh=wyCX1BTNHXURGKJuEud3JKGiE8BBPj6VeLzoTuSgQQI=; h=Cc:Date:From:Reply-To:Subject:To; b=fAPG8UZIbtwXxt/dypFRNPcICh5pY2WNJjN3aBJdLtJbKv4/vcR/nu9yB7AT+k7SKnQ PNvYSrXnqQkwYcFpFEE/Xmfdmlzfyq230s1Yel0MDKXLpM9RoJ+rOi2RvRZZnenBX66zG 2WVJqIFbXyRWK7O4JcIxxezRnZCC9LOBXAc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Matthew Carlson This adds a RngLib that uses the RngProtocol to provide randomness. This means that the RngLib is meant to be used with DXE_DRIVERS. Ref: https://github.com/tianocore/edk2/pull/845 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 Cc: Ard Biesheuvel Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Matthew Carlson --- MdePkg/Library/DxeRngLib/DxeRngLib.c | 199 ++++++++++++++++++++ MdePkg/Library/DxeRngLib/DxeRngLib.inf | 38 ++++ MdePkg/Library/DxeRngLib/DxeRngLib.uni | 15 ++ MdePkg/MdePkg.dsc | 4 +- 4 files changed, 255 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLi= b/DxeRngLib.c new file mode 100644 index 000000000000..8d4e05e52d57 --- /dev/null +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c @@ -0,0 +1,199 @@ +/** @file + Provides an implementation of the library class RngLib that uses the Rng = protocol. + + Copyright (c) Microsoft Corporation. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ +#include +#include +#include +#include +#include + +/** + Routine Description: + + Generates a random number via the NIST + 800-9A algorithm. Refer to + http://csrc.nist.gov/groups/STM/cavp/documents/drbg/DRBGVS.pdf + for more information. + + @param[out] Buffer Buffer to receive the random number. + @param[in] BufferSize Number of bytes in Buffer. + + @retval EFI_SUCCESS or underlying failure code. +**/ +STATIC +EFI_STATUS +GenerateRandomNumberViaNist800Algorithm ( + OUT UINT8 *Buffer, + IN UINTN BufferSize + ) +{ + EFI_STATUS Status; + EFI_RNG_PROTOCOL *RngProtocol; + + RngProtocol =3D NULL; + + if (Buffer =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: Buffer =3D=3D NULL.\n", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + Status =3D gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&Rn= gProtocol); + if (EFI_ERROR (Status) || RngProtocol =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status =3D= %r\n", __FUNCTION__, Status)); + return Status; + } + + Status =3D RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr= 256Guid, BufferSize, Buffer); + DEBUG((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status =3D %r\n", __F= UNCTION__, Status)); + if (!EFI_ERROR (Status)) { + return Status; + } + + Status =3D RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hma= c256Guid, BufferSize, Buffer); + DEBUG((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status =3D %r\n", __= FUNCTION__, Status)); + if (!EFI_ERROR (Status)) { + return Status; + } + + Status =3D RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Has= h256Guid, BufferSize, Buffer); + DEBUG((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status =3D %r\n", __= FUNCTION__, Status)); + if (!EFI_ERROR (Status)) { + return Status; + } + // If all the other methods have failed, use the default method from the= RngProtocol + Status =3D RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer); + DEBUG((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status =3D %r\n", __= FUNCTION__, Status)); + if (!EFI_ERROR (Status)) { + return Status; + } + // If we get to this point, we have failed + DEBUG((DEBUG_ERROR, "%a: GetRNG() failed, staus =3D %r\n", __FUNCTION__,= Status)); + + return Status; +}// GenerateRandomNumberViaNist800Algorithm() + + +/** + Generates a 16-bit random number. + + if Rand is NULL, return FALSE. + + @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 + ) +{ + EFI_STATUS Status; + + if (Rand =3D=3D NULL) + { + return FALSE; + } + + Status =3D GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, 2); + if (EFI_ERROR (Status)) { + return FALSE; + } + return TRUE; +} + +/** + Generates a 32-bit random number. + + if Rand is NULL, return FALSE. + + @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 + ) +{ + EFI_STATUS Status; + + if (Rand =3D=3D NULL) { + return FALSE; + } + + Status =3D GenerateRandomNumberViaNist800Algorithm ((UINT8*)Rand, 4); + if (EFI_ERROR (Status)) { + return FALSE; + } + return TRUE; +} + +/** + Generates a 64-bit random number. + + if Rand is NULL, return FALSE. + + @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 + ) +{ + EFI_STATUS Status; + + if (Rand =3D=3D NULL) { + return FALSE; + } + + Status =3D GenerateRandomNumberViaNist800Algorithm ((UINT8*)Rand, 8); + if (EFI_ERROR (Status)) { + return FALSE; + } + return TRUE; +} + +/** + Generates a 128-bit random number. + + if Rand is NULL, return FALSE. + + @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 + ) +{ + EFI_STATUS Status; + + if (Rand =3D=3D NULL) { + return FALSE; + } + + Status =3D GenerateRandomNumberViaNist800Algorithm ((UINT8*)Rand, 16); + if (EFI_ERROR (Status)) { + return FALSE; + } + return TRUE; +} diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.inf b/MdePkg/Library/DxeRng= Lib/DxeRngLib.inf new file mode 100644 index 000000000000..68554ad21146 --- /dev/null +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.inf @@ -0,0 +1,38 @@ +# @file +# Provides implementation of the library class RngLib that uses the RngPro= tocol +# +# @copyright +# Copyright (c) Microsoft Corporation. All rights reserved. +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D DxeRngLib + MODULE_UNI_FILE =3D DxeRngLib.uni + FILE_GUID =3D FF9F84C5-A33E-44E3-9BB5-0D654B2D4149 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RngLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER + +[Packages] + MdePkg/MdePkg.dec + +[Sources] + DxeRngLib.c + +[LibraryClasses] + DebugLib + UefiBootServicesTableLib + +[Protocols] + gEfiRngProtocolGuid ## CONSUMES + +[Depex] + gEfiRngProtocolGuid + +[Guids] + gEfiRngAlgorithmSp80090Ctr256Guid + gEfiRngAlgorithmSp80090Hash256Guid + gEfiRngAlgorithmSp80090Hmac256Guid diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.uni b/MdePkg/Library/DxeRng= Lib/DxeRngLib.uni new file mode 100644 index 000000000000..c904e54b6fb0 --- /dev/null +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.uni @@ -0,0 +1,15 @@ +// @file +// Instance of RNG (Random Number Generator) Library. +// +// RngLib that uses the Rng Protocol to provide random numbers. +// +// Copyright (c) Microsoft Corporation. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + + +#string STR_MODULE_ABSTRACT #language en-US "Instance of RNG Library" + +#string STR_MODULE_DESCRIPTION #language en-US "BaseRng Library that uses= the Rng Protocol to provide random numbers" + diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index d7ba3a730909..2c3b7966b086 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -62,8 +62,10 @@ MdePkg/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf MdePkg/Library/BasePrintLib/BasePrintLib.inf MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.i= nf - MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf + MdePkg/Library/DxeRngLib/DxeRngLib.inf MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf + MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf + MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf --=20 2.28.0.windows.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 (#64654): https://edk2.groups.io/g/devel/message/64654 Mute This Topic: https://groups.io/mt/76437902/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- From nobody Fri May 3 20:07:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64655+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64655+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598475310; cv=none; d=zohomail.com; s=zohoarc; b=Hiv2CyqwgRSCFW4EUvASTOakfIBlXNidvlW9YVc6Otjmf3FXliygIrdvpNUjSlKuTyIvu2k4L36GOhDsV4iBrEYf7tqcZJ8TUUMpbMqDdkk/nf/Fxk0GHdO3b2jmdnXcLoe6zrbWCq50YAhSn2LFSyvphc0WklMAmDx2odiZ7Tg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598475310; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=8E58VE+b/BRp6W3EWmfWTLjnJ+DEdsJf5NxtfH6hsZ4=; b=RTby91KNv34yk4ciITF9m07CkBz+3h9yW5ZUYpAPKIejce0d8FGBKW7yjF05fPHBOEiz0FUJ2N4jMb/IKbaATjlIVEytlOXdQHw1vLD3t5uEYizZwDX4xNZgzhFVFlI5dJD/OKFf2DA1QHWF8CZYcVL245jxa27X/7B3jvO6Q2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64655+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 159847531076360.92717760714265; Wed, 26 Aug 2020 13:55:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id mG7wYY1788612x422gIJ3BzS; Wed, 26 Aug 2020 13:55:10 -0700 X-Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by mx.groups.io with SMTP id smtpd.web12.4530.1598475309612189352 for ; Wed, 26 Aug 2020 13:55:09 -0700 X-Received: by mail-pf1-f174.google.com with SMTP id k15so1689744pfc.12 for ; Wed, 26 Aug 2020 13:55:09 -0700 (PDT) X-Gm-Message-State: bEczkzDPAih3bgDyCTaTZgbdx1787277AA= X-Google-Smtp-Source: ABdhPJwzKhnDIrDG80NTcofnok33Tt8tw4+2C970zfNPgxxPjU4z5/hpOitGWc+h5DytfCBuwVu2NA== X-Received: by 2002:a62:78cb:: with SMTP id t194mr13468696pfc.171.1598475308860; Wed, 26 Aug 2020 13:55:08 -0700 (PDT) X-Received: from tvis-name-05.localdomain ([50.34.40.129]) by smtp.gmail.com with ESMTPSA id s67sm68284pfs.117.2020.08.26.13.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 13:55:08 -0700 (PDT) From: "Matthew Carlson" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Anthony Perard , Julien Grall , Matthew Carlson Subject: [edk2-devel] [PATCH v9 3/5] OvmfPkg: Add RngLib based on TimerLib for Crypto Date: Wed, 26 Aug 2020 13:54:59 -0700 Message-Id: <20200826205501.1124-4-matthewfcarlson@gmail.com> In-Reply-To: <20200826205501.1124-1-matthewfcarlson@gmail.com> References: <20200826205501.1124-1-matthewfcarlson@gmail.com> MIME-Version: 1.0 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,matthewfcarlson@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1598475310; bh=itNM7jmJqBStiV2dEDM6SBsrKvxVQ5BepibZaLVzhlQ=; h=Cc:Date:From:Reply-To:Subject:To; b=wSt68RHEvXbmwLWlvumCo4ZN4dILYEVXB2f1eNwr0kQ/QKpexA4Zlw03ekVJ5Yuy4U6 1jrT4fxjj6ag9/mMSimcEIn4Yw6mMW9u4CLztkO+Ygk4UXvgbPI/bEy7MJWP/dB4OZKvH Qt48LpJQuIu13twwwMOXHS9hGNrnI8vT30I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Matthew Carlson Updates the DSC's for Ovmf based platforms to add a RngLib that uses the TimerLib. This is due to a later change that adds TimerLib as a dependency for OpenSSL. The TimerLib based RngLib mimics the behavior of OpenSSL previously and it is recommended to switch to a better source of entropy than the system's performance counter. Ref: https://github.com/tianocore/edk2/pull/845 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall Reviewed-by: Laszlo Ersek Signed-off-by: Matthew Carlson --- OvmfPkg/Bhyve/BhyveX64.dsc | 1 + OvmfPkg/OvmfPkgIa32.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + OvmfPkg/OvmfXen.dsc | 1 + 5 files changed, 5 insertions(+) diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index d2e9edfaa6b8..16d2233d7788 100644 --- a/OvmfPkg/Bhyve/BhyveX64.dsc +++ b/OvmfPkg/Bhyve/BhyveX64.dsc @@ -185,6 +185,7 @@ !else OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf !endif + RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE PlatformSecureLib|OvmfPkg/Bhyve/Library/PlatformSecureLib/PlatformSecure= Lib.inf diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 133a9a93c071..fa18adeb5c5a 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -189,6 +189,7 @@ !else OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf !endif + RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 338c38db29b5..7456a154168d 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -193,6 +193,7 @@ !else OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf !endif + RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index b80710fbdca4..5bda143fd14d 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -193,6 +193,7 @@ !else OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf !endif + RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 37b63a874067..e562abd7175d 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -179,6 +179,7 @@ !else OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf !endif + RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLib= Null.inf VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf --=20 2.28.0.windows.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 (#64655): https://edk2.groups.io/g/devel/message/64655 Mute This Topic: https://groups.io/mt/76437903/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- From nobody Fri May 3 20:07:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64656+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64656+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598475311; cv=none; d=zohomail.com; s=zohoarc; b=YQuZ510lviu80Kec6nqSeuah4Dakag5dIfNs5+WkO7mTovEPRp4DKb+u2Ri/J2WbNfg8od3h8OsWsVkkFn3cEwgJHYJ2P+Qgexf3kxwT4l0MW7o1YkbNdDjN6kF77R53iqbbAr5YicYa+AvNBubN3y1MGTEnXqDDY6h4hefIVuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598475311; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=HRxAyuly89Nw9UHAxOMIzBqMAze265u3hdtW6I7hv+U=; b=TbJ0FAOJiGB0miU9EXxLu6tS4g+X2PfUfp7ttN8aZipGP0EQuaacOcRDmDwNfpvuP0ypNN1kbUxDV3pUROO6kAO6eL5PsbT350/uYLvgX9T9E6unoz1G+Q2gWCcaazf5nzplX664N1Ax9KpI3FSXG7BEgC0UivbIV2yz1d7e9Pk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64656+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 1598475311241752.5429301352192; Wed, 26 Aug 2020 13:55:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xEbIYY1788612xG9ZxOnTgKb; Wed, 26 Aug 2020 13:55:10 -0700 X-Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mx.groups.io with SMTP id smtpd.web12.4531.1598475310501889849 for ; Wed, 26 Aug 2020 13:55:10 -0700 X-Received: by mail-pg1-f172.google.com with SMTP id h12so1745158pgm.7 for ; Wed, 26 Aug 2020 13:55:10 -0700 (PDT) X-Gm-Message-State: 8QxMmFRxVPcliejFrjm92JUcx1787277AA= X-Google-Smtp-Source: ABdhPJxkLcVz1QFoBlGRh/iUhJIRGGcQKu+KCGl96Wvi1/0+W9ATmTKQJuhYGLOdLic1NZAqhoQ/8w== X-Received: by 2002:a62:6887:: with SMTP id d129mr13957016pfc.279.1598475309817; Wed, 26 Aug 2020 13:55:09 -0700 (PDT) X-Received: from tvis-name-05.localdomain ([50.34.40.129]) by smtp.gmail.com with ESMTPSA id s67sm68284pfs.117.2020.08.26.13.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 13:55:09 -0700 (PDT) From: "Matthew Carlson" To: devel@edk2.groups.io Cc: Laszlo Ersek , Ard Biesheuvel , Leif Lindholm , Matthew Carlson Subject: [edk2-devel] [PATCH v9 4/5] ArmVirtPkg: Add RngLib based on TimerLib for CryptoPkg Date: Wed, 26 Aug 2020 13:55:00 -0700 Message-Id: <20200826205501.1124-5-matthewfcarlson@gmail.com> In-Reply-To: <20200826205501.1124-1-matthewfcarlson@gmail.com> References: <20200826205501.1124-1-matthewfcarlson@gmail.com> MIME-Version: 1.0 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,matthewfcarlson@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1598475310; bh=DF8795O/PzYVl5+5ntZoevMasqK3eulpeOvPJUeF0IU=; h=Cc:Date:From:Reply-To:Subject:To; b=RUG/Q+Enr+5M9h0Rwh6q9aPuQi2lBRim9604s/25dIS+E9rbE0sBybWBQA4vGA/oIuP l7lQ1/RCkUmHA8t5EsUG/St6O5DN3evtxCwoL3oJmQZNTfFqq4v8z7VxE/D8mRKYVqgIU 57PKK2PD4jtbW9b5fzx0DHkofV6LPb+WuZw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Matthew Carlson Updates the DSC for the ArmVirtPkg platform to add a RngLib that uses the TimerLib. This is due to a later change that adds TimerLib as a dependency for OpenSSL. The TimerLib based RngLib mimics the behavior of OpenSSL previously and it is recommended to switch to a better source of entropy than the system's performance counter. Ref: https://github.com/tianocore/edk2/pull/845 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Leif Lindholm Reviewed-by: Laszlo Ersek Signed-off-by: Matthew Carlson --- ArmVirtPkg/ArmVirt.dsc.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index cf44fc73890b..cb3845d2bd37 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -160,6 +160,7 @@ OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf !endif BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf + RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 # # Secure Boot dependencies --=20 2.28.0.windows.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 (#64656): https://edk2.groups.io/g/devel/message/64656 Mute This Topic: https://groups.io/mt/76437904/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- From nobody Fri May 3 20:07:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+64657+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64657+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1598475313; cv=none; d=zohomail.com; s=zohoarc; b=HrmF7SiK/0B3g6sH98wG9cYqq9dssJV9BJclGqo1WYXlRnQDTU4ew9GWYST8sDJQbXjp6d0VVElmC33qrlIdXx1xD0BXkqWsghnH8n53vn4OO1zo+RFQXBeEWAMt6kqI41sUJQSj3AOWCM0v2Lz4R7mgEV/bYmI7b9CZyF5BiRw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598475313; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=SZnTDW/c+WRiEeGXckeIhxuw++uUloaT3TtrCMHF8ig=; b=fbNzQ2b8vj9DIEntE65lRJhVHMYEGsV54N01ppunv7mym0w1/yyvd0/OSTFKz/LB0f9N9M0zB52k/IIHvX810An3sGmAOgSaULohLGHMkRH2YxbS8LnN2A3DN0odi4EJ5OAtk3y6PO21fB/9NZNsBXT/8ByxH2CKt+EGCBcJl/k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+64657+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 1598475313146555.4809534257805; Wed, 26 Aug 2020 13:55:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id hqtnYY1788612xp0pMFDITt5; Wed, 26 Aug 2020 13:55:12 -0700 X-Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mx.groups.io with SMTP id smtpd.web12.4532.1598475311864200324 for ; Wed, 26 Aug 2020 13:55:11 -0700 X-Received: by mail-pj1-f47.google.com with SMTP id 2so1451173pjx.5 for ; Wed, 26 Aug 2020 13:55:11 -0700 (PDT) X-Gm-Message-State: 9eI0N5Vzq9YyRdOxI0gNsZwrx1787277AA= X-Google-Smtp-Source: ABdhPJyaUSlCqLnoHHl7gHXfZq1Fls+aHZtEXMVHPDpOBFW1wu0lMXL89SVWcNuZqmDjLinOHVmFcw== X-Received: by 2002:a17:90a:e513:: with SMTP id t19mr1249700pjy.125.1598475310775; Wed, 26 Aug 2020 13:55:10 -0700 (PDT) X-Received: from tvis-name-05.localdomain ([50.34.40.129]) by smtp.gmail.com with ESMTPSA id s67sm68284pfs.117.2020.08.26.13.55.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 13:55:10 -0700 (PDT) From: "Matthew Carlson" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jiewen Yao , Jian J Wang , Xiaoyu Lu , Jiewen Yao , Matthew Carlson Subject: [edk2-devel] [PATCH v9 5/5] CryptoPkg: OpensslLib: Use RngLib to generate entropy in rand_pool Date: Wed, 26 Aug 2020 13:55:01 -0700 Message-Id: <20200826205501.1124-6-matthewfcarlson@gmail.com> In-Reply-To: <20200826205501.1124-1-matthewfcarlson@gmail.com> References: <20200826205501.1124-1-matthewfcarlson@gmail.com> MIME-Version: 1.0 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,matthewfcarlson@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1598475312; bh=4xE9/MIW4c/ZftVdnOG+DAGTdI3txkijCGR5dmcHCOs=; h=Cc:Date:From:Reply-To:Subject:To; b=X+qmiFgqpkOAgQ18T+YG+GbdTWpat+ckCWShQrs5nfmLT70jDkTk4ntfQJG9UbUTYhU h7tDFXQuQRiVkHFh9ESepqZVV6/YiHCXcFV77fQEdK06YDkxaE3ATol2XQJUVEuMiG6S2 zu6zgZQ/giYLripkB1YMXhRYQmSjLszp9ao= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Matthew Carlson Ref: https://github.com/tianocore/edk2/pull/845 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 Changes OpenSSL to no longer depend on TimerLib and instead use RngLib. This allows platforms to decide for themsevles what sort of entropy source they provide to OpenSSL and TlsLib. Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jian J Wang Cc: Xiaoyu Lu Acked-by: Ard Biesheuvel Reviewed-by: Jiewen Yao Signed-off-by: Matthew Carlson --- CryptoPkg/Library/OpensslLib/rand_pool.c | 265 +++++------------= --- CryptoPkg/Library/OpensslLib/rand_pool_noise.c | 29 --- CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c | 43 ---- CryptoPkg/CryptoPkg.dsc | 1 + CryptoPkg/Library/OpensslLib/OpensslLib.inf | 15 +- CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf | 15 +- CryptoPkg/Library/OpensslLib/rand_pool_noise.h | 29 --- 7 files changed, 63 insertions(+), 334 deletions(-) diff --git a/CryptoPkg/Library/OpensslLib/rand_pool.c b/CryptoPkg/Library/O= pensslLib/rand_pool.c index 9e0179b03490..490b9e2f4692 100644 --- a/CryptoPkg/Library/OpensslLib/rand_pool.c +++ b/CryptoPkg/Library/OpensslLib/rand_pool.c @@ -2,8 +2,8 @@ OpenSSL_1_1_1b doesn't implement rand_pool_* functions for UEFI. The file implement these functions. =20 -Copyright (c) 2019, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent + Copyright (c) 2019, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 @@ -11,53 +11,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =20 #include -#include - -#include "rand_pool_noise.h" - -/** - Get some randomness from low-order bits of GetPerformanceCounter results. - And combine them to the 64-bit value - - @param[out] Rand Buffer pointer to store the 64-bit random value. - - @retval TRUE Random number generated successfully. - @retval FALSE Failed to generate. -**/ -STATIC -BOOLEAN -EFIAPI -GetRandNoise64FromPerformanceCounter( - OUT UINT64 *Rand - ) -{ - UINT32 Index; - UINT32 *RandPtr; - - if (NULL =3D=3D Rand) { - return FALSE; - } - - RandPtr =3D (UINT32 *) Rand; - - for (Index =3D 0; Index < 2; Index ++) { - *RandPtr =3D (UINT32) (GetPerformanceCounter () & 0xFF); - MicroSecondDelay (10); - RandPtr++; - } - - return TRUE; -} +#include =20 /** Calls RandomNumber64 to fill a buffer of arbitrary size with random bytes. + This is a shim layer to RngLib. =20 @param[in] Length Size of the buffer, in bytes, to fill with. @param[out] RandBuffer Pointer to the buffer to store the random res= ult. =20 - @retval EFI_SUCCESS Random bytes generation succeeded. - @retval EFI_NOT_READY Failed to request random bytes. + @retval TRUE Random bytes generation succeeded. + @retval FALSE Failed to request random bytes. =20 **/ STATIC @@ -65,7 +30,7 @@ BOOLEAN EFIAPI RandGetBytes ( IN UINTN Length, - OUT UINT8 *RandBuffer + OUT UINT8 *RandBuffer ) { BOOLEAN Ret; @@ -73,17 +38,17 @@ RandGetBytes ( =20 Ret =3D FALSE; =20 + if (RandBuffer =3D=3D NULL) { + DEBUG((DEBUG_ERROR, "[OPENSSL_RAND_POOL] NULL RandBuffer. No random nu= mbers are generated and your system is not secure\n")); + ASSERT (RandBuffer !=3D NULL); // Since we can't generate random numbe= rs, we should assert. Otherwise we will just blow up later. + return Ret; + } + + while (Length > 0) { - // - // Get random noise from platform. - // If it failed, fallback to PerformanceCounter - // If you really care about security, you must override - // GetRandomNoise64FromPlatform. - // - Ret =3D GetRandomNoise64 (&TempRand); - if (Ret =3D=3D FALSE) { - Ret =3D GetRandNoise64FromPerformanceCounter (&TempRand); - } + // Use RngLib to get random number + Ret =3D GetRandomNumber64 (&TempRand); + if (!Ret) { return Ret; } @@ -91,7 +56,8 @@ RandGetBytes ( *((UINT64*) RandBuffer) =3D TempRand; RandBuffer +=3D sizeof (UINT64); Length -=3D sizeof (TempRand); - } else { + } + else { CopyMem (RandBuffer, &TempRand, Length); Length =3D 0; } @@ -100,125 +66,6 @@ RandGetBytes ( return Ret; } =20 -/** - Creates a 128bit random value that is fully forward and backward predict= ion resistant, - suitable for seeding a NIST SP800-90 Compliant. - This function takes multiple random numbers from PerformanceCounter to e= nsure reseeding - and performs AES-CBC-MAC over the data to compute the seed value. - - @param[out] SeedBuffer Pointer to a 128bit buffer to store the rando= m seed. - - @retval TRUE Random seed generation succeeded. - @retval FALSE Failed to request random bytes. - -**/ -STATIC -BOOLEAN -EFIAPI -RandGetSeed128 ( - OUT UINT8 *SeedBuffer - ) -{ - BOOLEAN Ret; - UINT8 RandByte[16]; - UINT8 Key[16]; - UINT8 Ffv[16]; - UINT8 Xored[16]; - UINT32 Index; - UINT32 Index2; - AES_KEY AESKey; - - // - // Chose an arbitrary key and zero the feed_forward_value (FFV) - // - for (Index =3D 0; Index < 16; Index++) { - Key[Index] =3D (UINT8) Index; - Ffv[Index] =3D 0; - } - - AES_set_encrypt_key (Key, 16 * 8, &AESKey); - - // - // Perform CBC_MAC over 32 * 128 bit values, with 10us gaps between 128 = bit value - // The 10us gaps will ensure multiple reseeds within the system time wit= h a large - // design margin. - // - for (Index =3D 0; Index < 32; Index++) { - MicroSecondDelay (10); - Ret =3D RandGetBytes (16, RandByte); - if (!Ret) { - return Ret; - } - - // - // Perform XOR operations on two 128-bit value. - // - for (Index2 =3D 0; Index2 < 16; Index2++) { - Xored[Index2] =3D RandByte[Index2] ^ Ffv[Index2]; - } - - AES_encrypt (Xored, Ffv, &AESKey); - } - - for (Index =3D 0; Index < 16; Index++) { - SeedBuffer[Index] =3D Ffv[Index]; - } - - return Ret; -} - -/** - Generate high-quality entropy source. - - @param[in] Length Size of the buffer, in bytes, to fill with. - @param[out] Entropy Pointer to the buffer to store the entropy da= ta. - - @retval EFI_SUCCESS Entropy generation succeeded. - @retval EFI_NOT_READY Failed to request random data. - -**/ -STATIC -BOOLEAN -EFIAPI -RandGenerateEntropy ( - IN UINTN Length, - OUT UINT8 *Entropy - ) -{ - BOOLEAN Ret; - UINTN BlockCount; - UINT8 Seed[16]; - UINT8 *Ptr; - - BlockCount =3D Length / 16; - Ptr =3D (UINT8 *) Entropy; - - // - // Generate high-quality seed for DRBG Entropy - // - while (BlockCount > 0) { - Ret =3D RandGetSeed128 (Seed); - if (!Ret) { - return Ret; - } - CopyMem (Ptr, Seed, 16); - - BlockCount--; - Ptr =3D Ptr + 16; - } - - // - // Populate the remained data as request. - // - Ret =3D RandGetSeed128 (Seed); - if (!Ret) { - return Ret; - } - CopyMem (Ptr, Seed, (Length % 16)); - - return Ret; -} - /* * Add random bytes to the pool to acquire requested amount of entropy * @@ -227,27 +74,31 @@ RandGenerateEntropy ( * * This is OpenSSL required interface. */ -size_t rand_pool_acquire_entropy(RAND_POOL *pool) +size_t +rand_pool_acquire_entropy ( + RAND_POOL *pool + ) { - BOOLEAN Ret; - size_t bytes_needed; - unsigned char * buffer; + BOOLEAN Ret; + size_t bytes_needed; + unsigned char *buffer; =20 - bytes_needed =3D rand_pool_bytes_needed(pool, 1 /*entropy_factor*/); + bytes_needed =3D rand_pool_bytes_needed (pool, 1 /*entropy_factor*/); if (bytes_needed > 0) { - buffer =3D rand_pool_add_begin(pool, bytes_needed); + buffer =3D rand_pool_add_begin (pool, bytes_needed); =20 if (buffer !=3D NULL) { - Ret =3D RandGenerateEntropy(bytes_needed, buffer); + Ret =3D RandGetBytes (bytes_needed, buffer); if (FALSE =3D=3D Ret) { - rand_pool_add_end(pool, 0, 0); - } else { - rand_pool_add_end(pool, bytes_needed, 8 * bytes_needed); + rand_pool_add_end (pool, 0, 0); + } + else { + rand_pool_add_end (pool, bytes_needed, 8 * bytes_needed); } } } =20 - return rand_pool_entropy_available(pool); + return rand_pool_entropy_available (pool); } =20 /* @@ -255,17 +106,15 @@ size_t rand_pool_acquire_entropy(RAND_POOL *pool) * * This is OpenSSL required interface. */ -int rand_pool_add_nonce_data(RAND_POOL *pool) +int +rand_pool_add_nonce_data ( + RAND_POOL *pool + ) { - struct { - UINT64 Rand; - UINT64 TimerValue; - } data =3D { 0 }; + UINT8 data[16]; + RandGetBytes (sizeof(data), data); =20 - RandGetBytes(8, (UINT8 *)&(data.Rand)); - data.TimerValue =3D GetPerformanceCounter(); - - return rand_pool_add(pool, (unsigned char*)&data, sizeof(data), 0); + return rand_pool_add (pool, (unsigned char*)&data, sizeof(data), 0); } =20 /* @@ -273,17 +122,15 @@ int rand_pool_add_nonce_data(RAND_POOL *pool) * * This is OpenSSL required interface. */ -int rand_pool_add_additional_data(RAND_POOL *pool) +int +rand_pool_add_additional_data ( + RAND_POOL *pool + ) { - struct { - UINT64 Rand; - UINT64 TimerValue; - } data =3D { 0 }; - - RandGetBytes(8, (UINT8 *)&(data.Rand)); - data.TimerValue =3D GetPerformanceCounter(); + UINT8 data[16]; + RandGetBytes (sizeof(data), data); =20 - return rand_pool_add(pool, (unsigned char*)&data, sizeof(data), 0); + return rand_pool_add (pool, (unsigned char*)&data, sizeof(data), 0); } =20 /* @@ -291,7 +138,10 @@ int rand_pool_add_additional_data(RAND_POOL *pool) * * This is OpenSSL required interface. */ -int rand_pool_init(void) +int +rand_pool_init ( + VOID + ) { return 1; } @@ -301,7 +151,10 @@ int rand_pool_init(void) * * This is OpenSSL required interface. */ -void rand_pool_cleanup(void) +VOID +rand_pool_cleanup( + VOID + ) { } =20 @@ -310,7 +163,9 @@ void rand_pool_cleanup(void) * * This is OpenSSL required interface. */ -void rand_pool_keep_random_devices_open(int keep) +VOID +rand_pool_keep_random_devices_open ( + int keep + ) { } - diff --git a/CryptoPkg/Library/OpensslLib/rand_pool_noise.c b/CryptoPkg/Lib= rary/OpensslLib/rand_pool_noise.c deleted file mode 100644 index 212834e27acc..000000000000 --- a/CryptoPkg/Library/OpensslLib/rand_pool_noise.c +++ /dev/null @@ -1,29 +0,0 @@ -/** @file - Provide rand noise source. - -Copyright (c) 2019, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include - -/** - Get 64-bit noise source - - @param[out] Rand Buffer pointer to store 64-bit noise source - - @retval FALSE Failed to generate -**/ -BOOLEAN -EFIAPI -GetRandomNoise64 ( - OUT UINT64 *Rand - ) -{ - // - // Return FALSE will fallback to use PerformanceCounter to - // generate noise. - // - return FALSE; -} diff --git a/CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c b/CryptoPkg= /Library/OpensslLib/rand_pool_noise_tsc.c deleted file mode 100644 index 4158106231fd..000000000000 --- a/CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c +++ /dev/null @@ -1,43 +0,0 @@ -/** @file - Provide rand noise source. - -Copyright (c) 2019, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#include -#include -#include - -/** - Get 64-bit noise source - - @param[out] Rand Buffer pointer to store 64-bit noise source - - @retval TRUE Get randomness successfully. - @retval FALSE Failed to generate -**/ -BOOLEAN -EFIAPI -GetRandomNoise64 ( - OUT UINT64 *Rand - ) -{ - UINT32 Index; - UINT32 *RandPtr; - - if (NULL =3D=3D Rand) { - return FALSE; - } - - RandPtr =3D (UINT32 *)Rand; - - for (Index =3D 0; Index < 2; Index ++) { - *RandPtr =3D (UINT32) ((AsmReadTsc ()) & 0xFF); - RandPtr++; - MicroSecondDelay (10); - } - - return TRUE; -} diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc index 1af78468a19c..0490eeb7e22f 100644 --- a/CryptoPkg/CryptoPkg.dsc +++ b/CryptoPkg/CryptoPkg.dsc @@ -60,6 +60,7 @@ BaseCryptLib|CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf HashApiLib|CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.inf + RngLib|MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf =20 [LibraryClasses.ARM, LibraryClasses.AARCH64] # diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Librar= y/OpensslLib/OpensslLib.inf index cc27b8c57cb3..b00bb74ce67e 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf @@ -571,22 +571,9 @@ $(OPENSSL_PATH)/ssl/statem/statem_local.h # Autogenerated files list ends here buildinf.h - rand_pool_noise.h ossl_store.c rand_pool.c =20 -[Sources.Ia32] - rand_pool_noise_tsc.c - -[Sources.X64] - rand_pool_noise_tsc.c - -[Sources.ARM] - rand_pool_noise.c - -[Sources.AARCH64] - rand_pool_noise.c - [Packages] MdePkg/MdePkg.dec CryptoPkg/CryptoPkg.dec @@ -594,7 +581,7 @@ [LibraryClasses] BaseLib DebugLib - TimerLib + RngLib PrintLib =20 [LibraryClasses.ARM] diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf b/CryptoPkg/= Library/OpensslLib/OpensslLibCrypto.inf index 616ccd9f62d1..3557711bd85a 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf @@ -520,22 +520,9 @@ $(OPENSSL_PATH)/crypto/x509v3/v3_admis.h # Autogenerated files list ends here buildinf.h - rand_pool_noise.h ossl_store.c rand_pool.c =20 -[Sources.Ia32] - rand_pool_noise_tsc.c - -[Sources.X64] - rand_pool_noise_tsc.c - -[Sources.ARM] - rand_pool_noise.c - -[Sources.AARCH64] - rand_pool_noise.c - [Packages] MdePkg/MdePkg.dec CryptoPkg/CryptoPkg.dec @@ -543,7 +530,7 @@ [LibraryClasses] BaseLib DebugLib - TimerLib + RngLib PrintLib =20 [LibraryClasses.ARM] diff --git a/CryptoPkg/Library/OpensslLib/rand_pool_noise.h b/CryptoPkg/Lib= rary/OpensslLib/rand_pool_noise.h deleted file mode 100644 index 75acc686a9f1..000000000000 --- a/CryptoPkg/Library/OpensslLib/rand_pool_noise.h +++ /dev/null @@ -1,29 +0,0 @@ -/** @file - Provide rand noise source. - -Copyright (c) 2019, Intel Corporation. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent - -**/ - -#ifndef __RAND_POOL_NOISE_H__ -#define __RAND_POOL_NOISE_H__ - -#include - -/** - Get 64-bit noise source. - - @param[out] Rand Buffer pointer to store 64-bit noise source - - @retval TRUE Get randomness successfully. - @retval FALSE Failed to generate -**/ -BOOLEAN -EFIAPI -GetRandomNoise64 ( - OUT UINT64 *Rand - ); - - -#endif // __RAND_POOL_NOISE_H__ --=20 2.28.0.windows.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 (#64657): https://edk2.groups.io/g/devel/message/64657 Mute This Topic: https://groups.io/mt/76437905/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-