From: Pierre Gondois <pierre.gond...@arm.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4151

The EFI_RNG_PROTOCOL can advertise multiple algorithms through
Guids. The PcdCpuRngSupportedAlgorithm contains a Guid that
can be configured. It represents the algorithm used in RngLib
and using CPU instructions.

When adding support for the Firmware Trng interface, it was made
available through in the RngDxe module. In RngDxe, the algorithm
associated with PcdCpuRngSupportedAlgorithm (implemented by the
RngLib) was always advertised by default.

It was assumed that support for RngLib and RNDR instructions
should be kept in ArmVirtPkg. However this support did not exist
as all ArmVirtPkg use the BaseRngLibTimerLib.inf implementation
of the RngLib.

Do not advertise the RngLib and PcdCpuRngSupportedAlgorithm
if PcdCpuRngSupportedAlgorithm is NULL.

Reported-by: Sami Mujawar <sami.muja...@arm.com>
Signed-off-by: Pierre Gondois <pierre.gond...@arm.com>
---
 .../RngDxe/AArch64/AArch64Algo.c                   | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c 
b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
index e8be217f8a8c..c98e09363e25 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/AArch64/AArch64Algo.c
@@ -39,23 +39,15 @@ GetAvailableAlgorithms (
   }
 
   // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm.
-  if (!EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand))) {
+  if (!IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm)) &&
+      !EFI_ERROR (RngGetBytes (sizeof (DummyRand), (UINT8 *)&DummyRand)))
+  {
     CopyMem (
       &mAvailableAlgoArray[mAvailableAlgoArrayCount],
       PcdGetPtr (PcdCpuRngSupportedAlgorithm),
       sizeof (EFI_RNG_ALGORITHM)
       );
     mAvailableAlgoArrayCount++;
-
-    DEBUG_CODE_BEGIN ();
-    if (IsZeroGuid (PcdGetPtr (PcdCpuRngSupportedAlgorithm))) {
-      DEBUG ((
-        DEBUG_WARN,
-        "PcdCpuRngSupportedAlgorithm should be a non-zero GUID\n"
-        ));
-    }
-
-    DEBUG_CODE_END ();
   }
 
   // Raw algorithm (Trng)
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#100808): https://edk2.groups.io/g/devel/message/100808
Mute This Topic: https://groups.io/mt/97454018/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to