public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH V1] SecurityPkg: Fix return handling in RdRandGenerateEntropy
@ 2022-10-26 21:23 Bjorge, Erik C
  0 siblings, 0 replies; only message in thread
From: Bjorge, Erik C @ 2022-10-26 21:23 UTC (permalink / raw)
  To: devel; +Cc: Erik Bjorge, Jiewen Yao, Jian J Wang

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4090

The function GetRandomNumber128 returns a BOOLEAN and not EFI_STATUS.
Update the code to correctly handle the BOOLEAN return type.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Erik Bjorge <erik.c.bjorge@intel.com>
---
 .../PeiDxeTpmPlatformHierarchyLib.c                | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c b/SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
index b8838766bc..8e3b7ce9fd 100644
--- a/SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
+++ b/SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLib/PeiDxeTpmPlatformHierarchyLib.c
@@ -46,12 +46,10 @@ RdRandGenerateEntropy (
   OUT UINT8  *Entropy
   )
 {
-  EFI_STATUS  Status;
   UINTN       BlockCount;
   UINT64      Seed[2];
   UINT8       *Ptr;
 
-  Status     = EFI_NOT_READY;
   BlockCount = Length / sizeof (Seed);
   Ptr        = (UINT8 *)Entropy;
 
@@ -59,9 +57,8 @@ RdRandGenerateEntropy (
   // Generate high-quality seed for DRBG Entropy
   //
   while (BlockCount > 0) {
-    Status = GetRandomNumber128 (Seed);
-    if (EFI_ERROR (Status)) {
-      return Status;
+    if (!GetRandomNumber128 (Seed)) {
+      return EFI_NOT_READY;
     }
 
     CopyMem (Ptr, Seed, sizeof (Seed));
@@ -73,14 +70,13 @@ RdRandGenerateEntropy (
   //
   // Populate the remained data as request.
   //
-  Status = GetRandomNumber128 (Seed);
-  if (EFI_ERROR (Status)) {
-    return Status;
+  if (!GetRandomNumber128 (Seed)) {
+    return EFI_NOT_READY;
   }
 
   CopyMem (Ptr, Seed, (Length % sizeof (Seed)));
 
-  return Status;
+  return EFI_SUCCESS;
 }
 
 /**
-- 
2.36.0.windows.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-26 21:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-26 21:23 [PATCH V1] SecurityPkg: Fix return handling in RdRandGenerateEntropy Bjorge, Erik C

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox