From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web09.1482.1666819453283539047 for ; Wed, 26 Oct 2022 14:24:13 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=XGXptxw7; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: erik.c.bjorge@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666819453; x=1698355453; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=iPH8y1WTcJn8orzs5XiVKzkrgGE6grymK0v8T1my8lk=; b=XGXptxw73aAXulbGjTr7bYOtoV2VLTNltiZC7P9dUr+J/uoKIRusCJYI LLzutmkqYOkxqJqMeJhGVyDQZo6se3JLMMiGXUEQFHiZoNkdUFHcpdWH4 GbrIxuMirrgBSpxUoMmaRv/UrvrjwHOAhz4jKBXEpJHHDSc4BTh5YWQTw UUA4NZoKFRiUdROxgQ7BBj/UXgBh95yvemf5d1toTYum3cY/vONjR4Hhe PSRAhys4p5KFZ0CFQcqaGCgfRGIYcFlmli9zXf+H4Z76ry2msDL+LyRCV ROS/sXFSO+txIJtOX+oQk8e9u0glIUogEh/sk0ioA45dTDmUCNmiz5Nw3 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="309757173" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="309757173" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 14:24:08 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="634651593" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="634651593" Received: from ecbjorge-mobl1.amr.corp.intel.com ([10.212.214.112]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 14:24:07 -0700 From: "Bjorge, Erik C" To: devel@edk2.groups.io Cc: Erik Bjorge , Jiewen Yao , Jian J Wang Subject: [PATCH V1] SecurityPkg: Fix return handling in RdRandGenerateEntropy Date: Wed, 26 Oct 2022 14:23:44 -0700 Message-Id: <91a69f0b059217210234eef8cac8ee37df7a152e.1666819264.git.erik.c.bjorge@intel.com> X-Mailer: git-send-email 2.36.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Jian J Wang Signed-off-by: Erik Bjorge --- .../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