diff options
author | Pierre Gondois <pierre.gondois@arm.com> | 2022-10-28 17:32:54 +0200 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-11-06 16:32:28 +0000 |
commit | 4b3e9d80bedf5909a4ec901425ed9c0a738fc76f (patch) | |
tree | d1de5753058b765d8a2b776c64882bbdfdc63dde /SecurityPkg/RandomNumberGenerator/RngDxe/Rand | |
parent | 199031b2b0233652ad5d5fdf73f0f44c0f264d55 (diff) | |
download | edk2-4b3e9d80bedf5909a4ec901425ed9c0a738fc76f.tar.gz edk2-4b3e9d80bedf5909a4ec901425ed9c0a738fc76f.tar.bz2 edk2-4b3e9d80bedf5909a4ec901425ed9c0a738fc76f.zip |
SecurityPkg/RngDxe: Check before advertising Cpu Rng algo
RngGetBytes() relies on the RngLib. The RngLib might use the RNDR
instruction if the FEAT_RNG feature is present. RngGetInfo and
RngGetRNG both must check that RngGetBytes() is working before
advertising/using it.
To do so, allocate an array storing the available algorithms.
The Rng algorithm at the lowest index will be the default Rng
algorithm. The array is shared between RngGetInfo and RngGetRNG.
This array is allocated when the driver is loaded, and freed
when unloaded.
This patch also prevents from having PcdCpuRngSupportedAlgorithm
let to a zero GUID, but let the possibility to have no valid Rng
algorithm in such case.
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'SecurityPkg/RandomNumberGenerator/RngDxe/Rand')
-rw-r--r-- | SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c index 8f5d8e740f..677600bed7 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c @@ -26,6 +26,32 @@ #include "RngDxeInternals.h"
+/** Allocate and initialize mAvailableAlgoArray with the available
+ Rng algorithms. Also update mAvailableAlgoArrayCount.
+
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_OUT_OF_RESOURCES Could not allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+GetAvailableAlgorithms (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+/** Free mAvailableAlgoArray.
+**/
+VOID
+EFIAPI
+FreeAvailableAlgorithms (
+ VOID
+ )
+{
+ return;
+}
+
/**
Produces and returns an RNG value using either the default or specified RNG algorithm.
|