[edk2-devel] [PATCH v3 2/4] SecurityPkg/RngDxe: Correctly update mAvailableAlgoArrayCount
PierreGondois
pierre.gondois at arm.com
Thu Nov 24 16:17:54 UTC 2022
From: Pierre Gondois <pierre.gondois at arm.com>
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 at arm.com>
---
SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c | 1 +
SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
index 5ba319899ce9..ce49ff7ae661 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 677600bed7ab..7e06e16e4be5 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;
--
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96619): https://edk2.groups.io/g/devel/message/96619
Mute This Topic: https://groups.io/mt/95240505/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list