summaryrefslogtreecommitdiffstats
path: root/SecurityPkg
diff options
context:
space:
mode:
authorPierre Gondois <pierre.gondois@arm.com>2022-11-24 17:17:54 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-07 15:34:23 +0000
commitbfb574db110899471fe09db819587b3151c7b7b5 (patch)
treefefab64b0f38c2398cb7e0b6aa47f464971cb9f3 /SecurityPkg
parentaa1cd447b346e8cc8141df2fe2d321b032c08acb (diff)
downloadedk2-bfb574db110899471fe09db819587b3151c7b7b5.tar.gz
edk2-bfb574db110899471fe09db819587b3151c7b7b5.tar.bz2
edk2-bfb574db110899471fe09db819587b3151c7b7b5.zip
SecurityPkg/RngDxe: Correctly update mAvailableAlgoArrayCount
mAvailableAlgoArrayCount holds the count of available RNG algorithms. In a following patch, its value will be used to prevent the EFI_RNG_PROTOCOL to be installed if no RNG algorithm is available. Correctly set/reset the value for all implementations. Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'SecurityPkg')
-rw-r--r--SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c1
-rw-r--r--SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c9
2 files changed, 9 insertions, 1 deletions
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
index 5ba319899c..ce49ff7ae6 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
@@ -40,6 +40,7 @@ FreeAvailableAlgorithms (
VOID
)
{
+ mAvailableAlgoArrayCount = 0;
FreePool (mAvailableAlgoArray);
return;
}
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
index 677600bed7..7e06e16e4b 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c
@@ -26,6 +26,11 @@
#include "RngDxeInternals.h"
+//
+// Count of Rng algorithms.
+//
+#define RNG_ALGORITHM_COUNT 2
+
/** Allocate and initialize mAvailableAlgoArray with the available
Rng algorithms. Also update mAvailableAlgoArrayCount.
@@ -38,6 +43,7 @@ GetAvailableAlgorithms (
VOID
)
{
+ mAvailableAlgoArrayCount = RNG_ALGORITHM_COUNT;
return EFI_SUCCESS;
}
@@ -49,6 +55,7 @@ FreeAvailableAlgorithms (
VOID
)
{
+ mAvailableAlgoArrayCount = 0;
return;
}
@@ -164,7 +171,7 @@ RngGetInfo (
return EFI_INVALID_PARAMETER;
}
- RequiredSize = 2 * sizeof (EFI_RNG_ALGORITHM);
+ RequiredSize = RNG_ALGORITHM_COUNT * sizeof (EFI_RNG_ALGORITHM);
if (*RNGAlgorithmListSize < RequiredSize) {
*RNGAlgorithmListSize = RequiredSize;