Skip to content

Commit

Permalink
SecurityPkg/RngDxe: add rng test
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kraxel authored and ardbiesheuvel committed Jun 13, 2024
1 parent c3a8ca7 commit a61bc0a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/RngLib.h>

#include "RngDxeInternals.h"

Expand All @@ -43,7 +44,12 @@ GetAvailableAlgorithms (
VOID
)
{
mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT;
UINT64 RngTest;

if (GetRandomNumber64 (&RngTest)) {
mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT;
}

return EFI_SUCCESS;
}

Expand Down

0 comments on commit a61bc0a

Please sign in to comment.