From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.27852.1669306712167278600 for ; Thu, 24 Nov 2022 08:18:32 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 549D523A; Thu, 24 Nov 2022 08:18:38 -0800 (PST) Received: from pierre123.nice.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6129B3F587; Thu, 24 Nov 2022 08:18:30 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar , Jiewen Yao , Jian J Wang Subject: [PATCH v3 2/4] SecurityPkg/RngDxe: Correctly update mAvailableAlgoArrayCount Date: Thu, 24 Nov 2022 17:17:54 +0100 Message-Id: <20221124161756.216996-3-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221124161756.216996-1-Pierre.Gondois@arm.com> References: <20221124161756.216996-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pierre Gondois 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 --- 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/Secur= ityPkg/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 =3D 0; FreePool (mAvailableAlgoArray); return; } diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/Rand/RngDxe.c b/Sec= urityPkg/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 @@ =20 #include "RngDxeInternals.h" =20 +// +// Count of Rng algorithms. +// +#define RNG_ALGORITHM_COUNT 2 + /** Allocate and initialize mAvailableAlgoArray with the available Rng algorithms. Also update mAvailableAlgoArrayCount. =20 @@ -38,6 +43,7 @@ GetAvailableAlgorithms ( VOID ) { + mAvailableAlgoArrayCount =3D RNG_ALGORITHM_COUNT; return EFI_SUCCESS; } =20 @@ -49,6 +55,7 @@ FreeAvailableAlgorithms ( VOID ) { + mAvailableAlgoArrayCount =3D 0; return; } =20 @@ -164,7 +171,7 @@ RngGetInfo ( return EFI_INVALID_PARAMETER; } =20 - RequiredSize =3D 2 * sizeof (EFI_RNG_ALGORITHM); + RequiredSize =3D RNG_ALGORITHM_COUNT * sizeof (EFI_RNG_ALGORITHM); =20 if (*RNGAlgorithmListSize < RequiredSize) { *RNGAlgorithmListSize =3D RequiredSize; --=20 2.25.1