From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com []) by mx.groups.io with SMTP id smtpd.web10.14650.1596185716899366598 for ; Fri, 31 Jul 2020 01:55:17 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: qi1.zhang@intel.com) IronPort-SDR: n0KR/lhXs/pDatBVKzHw2bYXJE9ndR6pvRxEWH8CPODzkeoMyMZz9Gb8NSZCkFIdB1A6Yiba8O 7nfD3ze7TsIw== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="213281399" X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="213281399" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2020 01:55:05 -0700 IronPort-SDR: lIHoR2YUYOf/usEsRrU7ek/gPtB1zEKFa8WIVy5OroXWhATbrnzEW208xXyt0McsxLRrNYoakg 36Teh4W0WO6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,417,1589266800"; d="scan'208";a="490953616" Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by fmsmga006.fm.intel.com with ESMTP; 31 Jul 2020 01:55:04 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Qi Zhang , Jiewen Yao , Jian J Wang Subject: [PATCH 9/9] SecurityPkg/HashLib: add API HashFinal Date: Fri, 31 Jul 2020 16:54:37 +0800 Message-Id: <20200731085437.16070-10-qi1.zhang@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 In-Reply-To: <20200731085437.16070-1-qi1.zhang@intel.com> References: <20200731085437.16070-1-qi1.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2376 Cc: Jiewen Yao Cc: Jian J Wang Cc: Qi Zhang Signed-off-by: Qi Zhang --- SecurityPkg/Include/Library/HashLib.h | 15 ++++++ .../HashLibBaseCryptoRouterPei.c | 48 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/SecurityPkg/Include/Library/HashLib.h b/SecurityPkg/Include/Li= brary/HashLib.h index 6ad960ad70..e2d9a62a1d 100644 --- a/SecurityPkg/Include/Library/HashLib.h +++ b/SecurityPkg/Include/Library/HashLib.h @@ -47,6 +47,21 @@ HashUpdate ( IN UINTN DataToHashLen=0D );=0D =0D +/**=0D + Hash sequence complete and extend to PCR.=0D +=0D + @param HashHandle Hash handle.=0D + @param DigestList Digest list.=0D +=0D + @retval EFI_SUCCESS Hash sequence complete and DigestList is returne= d.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +HashFinal (=0D + IN HASH_HANDLE HashHandle,=0D + OUT TPML_DIGEST_VALUES *DigestList=0D + );=0D +=0D /**=0D Hash sequence complete and extend to PCR.=0D =0D diff --git a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoR= outerPei.c b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoR= outerPei.c index 42cb562f67..5b9719630d 100644 --- a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPe= i.c +++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPe= i.c @@ -208,6 +208,54 @@ HashUpdate ( return EFI_SUCCESS;=0D }=0D =0D +/**=0D + Hash sequence complete and extend to PCR.=0D +=0D + @param HashHandle Hash handle.=0D + @param DigestList Digest list.=0D +=0D + @retval EFI_SUCCESS Hash sequence complete and DigestList is returne= d.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +HashFinal (=0D + IN HASH_HANDLE HashHandle,=0D + OUT TPML_DIGEST_VALUES *DigestList=0D + )=0D +{=0D + TPML_DIGEST_VALUES Digest;=0D + HASH_INTERFACE_HOB *HashInterfaceHob;=0D + HASH_HANDLE *HashCtx;=0D + UINTN Index;=0D + UINT32 HashMask;=0D +=0D + HashInterfaceHob =3D InternalGetHashInterfaceHob (&gEfiCallerIdGuid);=0D + if (HashInterfaceHob =3D=3D NULL) {=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + if (HashInterfaceHob->HashInterfaceCount =3D=3D 0) {=0D + return EFI_UNSUPPORTED;=0D + }=0D +=0D + CheckSupportedHashMaskMismatch (HashInterfaceHob);=0D +=0D + HashCtx =3D (HASH_HANDLE *)HashHandle;=0D + ZeroMem (DigestList, sizeof(*DigestList));=0D +=0D + for (Index =3D 0; Index < HashInterfaceHob->HashInterfaceCount; Index++)= {=0D + HashMask =3D Tpm2GetHashMaskFromAlgo (&HashInterfaceHob->HashInterface= [Index].HashGuid);=0D + if ((HashMask & PcdGet32 (PcdTpm2HashMask)) !=3D 0) {=0D + HashInterfaceHob->HashInterface[Index].HashFinal (HashCtx[Index], &D= igest);=0D + Tpm2SetHashToDigestList (DigestList, &Digest);=0D + }=0D + }=0D +=0D + FreePool (HashCtx);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D /**=0D Hash sequence complete and extend to PCR.=0D =0D --=20 2.26.2.windows.1