public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Leif Lindholm <leif@nuviainc.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Jian J Wang <jian.j.wang@intel.com>
Subject: [PATCH v3 2/4] SecurityPkg/RngDxe: Correctly update mAvailableAlgoArrayCount
Date: Thu, 24 Nov 2022 17:17:54 +0100	[thread overview]
Message-ID: <20221124161756.216996-3-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20221124161756.216996-1-Pierre.Gondois@arm.com>

From: Pierre Gondois <pierre.gondois@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@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


  parent reply	other threads:[~2022-11-24 16:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 16:17 [PATCH v3 0/4] ArmPkg/SecurityPkg: Fixes for ArmTrngLib/RngDxe PierreGondois
2022-11-24 16:17 ` [PATCH v3 1/4] ArmPkg/ArmTrngLib: Remove ASSERTs in ArmTrngLibConstructor() PierreGondois
2022-11-24 16:17 ` PierreGondois [this message]
2022-11-24 16:17 ` [PATCH v3 3/4] SecurityPkg/RngDxe: Conditionally install EFI_RNG_PROTOCOL PierreGondois
2022-11-24 16:17 ` [PATCH v3 4/4] SecurityPkg/RngDxe: Fix Rng algo selection for Arm PierreGondois
2022-11-26 14:33 ` [PATCH v3 0/4] ArmPkg/SecurityPkg: Fixes for ArmTrngLib/RngDxe Ard Biesheuvel
2022-11-28 13:34   ` PierreGondois
2022-12-07  8:53   ` [edk2-devel] " Sami Mujawar
2022-12-07  9:04     ` Sami Mujawar
     [not found]   ` <172BC2FE233A5592.368@groups.io>
2023-01-09 12:26     ` PierreGondois
2023-02-10  9:26       ` PierreGondois
     [not found]       ` <17426C66FE22D73E.5513@groups.io>
2023-03-06 15:37         ` PierreGondois
2023-03-06 15:42           ` Yao, Jiewen
2023-03-06 16:22             ` Ard Biesheuvel
2023-03-06 17:09               ` PierreGondois
2023-03-06 17:36                 ` Ard Biesheuvel
2023-03-07  7:53               ` Yao, Jiewen
2023-03-07 15:38                 ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221124161756.216996-3-Pierre.Gondois@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox