summaryrefslogtreecommitdiff
path: root/SecurityPkg
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2024-05-31 09:49:13 +0200
committerArd Biesheuvel <workofard@gmail.com>2024-06-13 08:52:48 -0700
commita61bc0accb8a76edba4f073fdc7bafc908df045d (patch)
tree90e33f0afc58c8de56f43f0af6a64fa554fd5e5c /SecurityPkg
parentc3a8ca7b54a9fd17acdf16c6282a92cc989fa92a (diff)
downloadedk2-a61bc0accb8a76edba4f073fdc7bafc908df045d.zip
edk2-a61bc0accb8a76edba4f073fdc7bafc908df045d.tar.gz
edk2-a61bc0accb8a76edba4f073fdc7bafc908df045d.tar.bz2
SecurityPkg/RngDxe: add rng test
Check whenever RngLib actually returns random numbers, only return a non-zero number of Algorithms if that is the case. This has the effect that RndDxe loads and installs EFI_RNG_PROTOCOL only in case it can actually deliver random numbers. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
index 5723ed6..8b0742b 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
@@ -23,6 +23,7 @@
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/RngLib.h>
#include "RngDxeInternals.h"
@@ -43,7 +44,12 @@ GetAvailableAlgorithms (
VOID
)
{
- mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT;
+ UINT64 RngTest;
+
+ if (GetRandomNumber64 (&RngTest)) {
+ mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT;
+ }
+
return EFI_SUCCESS;
}