[edk2-devel] [PATCH 9/9] SecurityPkg/HashLib: add API HashFinal
Yao, Jiewen
jiewen.yao at intel.com
Sun Aug 2 08:48:40 UTC 2020
If you want to add one API for a library class, we need add implementation for all library instances.
Here the DXE version should also be updated to add such capability.
> -----Original Message-----
> From: Zhang, Qi1 <qi1.zhang at intel.com>
> Sent: Friday, July 31, 2020 4:55 PM
> To: devel at edk2.groups.io
> Cc: Zhang, Qi1 <qi1.zhang at intel.com>; Yao, Jiewen <jiewen.yao at intel.com>;
> Wang, Jian J <jian.j.wang at intel.com>
> Subject: [PATCH 9/9] SecurityPkg/HashLib: add API HashFinal
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2376
>
> Cc: Jiewen Yao <jiewen.yao at intel.com>
> Cc: Jian J Wang <jian.j.wang at intel.com>
> Cc: Qi Zhang <qi1.zhang at intel.com>
> Signed-off-by: Qi Zhang <qi1.zhang at intel.com>
> ---
> 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/Library/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
>
> );
>
>
>
> +/**
>
> + Hash sequence complete and extend to PCR.
>
> +
>
> + @param HashHandle Hash handle.
>
> + @param DigestList Digest list.
>
> +
>
> + @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
>
> +**/
>
> +EFI_STATUS
>
> +EFIAPI
>
> +HashFinal (
>
> + IN HASH_HANDLE HashHandle,
>
> + OUT TPML_DIGEST_VALUES *DigestList
>
> + );
>
> +
>
> /**
>
> Hash sequence complete and extend to PCR.
>
>
>
> diff --git
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
> index 42cb562f67..5b9719630d 100644
> ---
> a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
> +++
> b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
> @@ -208,6 +208,54 @@ HashUpdate (
> return EFI_SUCCESS;
>
> }
>
>
>
> +/**
>
> + Hash sequence complete and extend to PCR.
>
> +
>
> + @param HashHandle Hash handle.
>
> + @param DigestList Digest list.
>
> +
>
> + @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
>
> +**/
>
> +EFI_STATUS
>
> +EFIAPI
>
> +HashFinal (
>
> + IN HASH_HANDLE HashHandle,
>
> + OUT TPML_DIGEST_VALUES *DigestList
>
> + )
>
> +{
>
> + TPML_DIGEST_VALUES Digest;
>
> + HASH_INTERFACE_HOB *HashInterfaceHob;
>
> + HASH_HANDLE *HashCtx;
>
> + UINTN Index;
>
> + UINT32 HashMask;
>
> +
>
> + HashInterfaceHob = InternalGetHashInterfaceHob (&gEfiCallerIdGuid);
>
> + if (HashInterfaceHob == NULL) {
>
> + return EFI_UNSUPPORTED;
>
> + }
>
> +
>
> + if (HashInterfaceHob->HashInterfaceCount == 0) {
>
> + return EFI_UNSUPPORTED;
>
> + }
>
> +
>
> + CheckSupportedHashMaskMismatch (HashInterfaceHob);
>
> +
>
> + HashCtx = (HASH_HANDLE *)HashHandle;
>
> + ZeroMem (DigestList, sizeof(*DigestList));
>
> +
>
> + for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {
>
> + HashMask = Tpm2GetHashMaskFromAlgo (&HashInterfaceHob-
> >HashInterface[Index].HashGuid);
>
> + if ((HashMask & PcdGet32 (PcdTpm2HashMask)) != 0) {
>
> + HashInterfaceHob->HashInterface[Index].HashFinal (HashCtx[Index],
> &Digest);
>
> + Tpm2SetHashToDigestList (DigestList, &Digest);
>
> + }
>
> + }
>
> +
>
> + FreePool (HashCtx);
>
> +
>
> + return EFI_SUCCESS;
>
> +}
>
> +
>
> /**
>
> Hash sequence complete and extend to PCR.
>
>
>
> --
> 2.26.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#63637): https://edk2.groups.io/g/devel/message/63637
Mute This Topic: https://groups.io/mt/75903688/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list