CryptoPkg/BaseHashApiLib: Implement Unified Hash Calculation API

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

This commit introduces a Unified Hash API to calculate hash using a
hashing algorithm specified by the PCD, PcdHashApiLibPolicy. This library
interfaces with the various hashing API, such as, MD4, MD5, SHA1, SHA256,
SHA512 and SM3_256 implemented in BaseCryptLib. The user can calculate
the desired hash by setting PcdHashApiLibPolicy to appropriate value.

This feature is documented in the Bugzilla,
https://bugzilla.tianocore.org/show_bug.cgi?id=2151.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Amol N Sukerkar <amol.n.sukerkar@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Amol N Sukerkar
2020-02-03 10:18:50 -08:00
committed by mergify[bot]
parent 2c061de063
commit 3feea54eae
7 changed files with 553 additions and 2 deletions

View File

@@ -33,9 +33,29 @@
##
TlsLib|Include/Library/TlsLib.h
## @libraryclass Provides Unified API for different hash implementations.
#
HashApiLib|Include/Library/HashApiLib.h
[Guids]
## Crypto package token space guid.
gEfiCryptoPkgTokenSpaceGuid = { 0x6bd7de60, 0x9ef7, 0x4899, { 0x97, 0xd0, 0xab, 0xff, 0xfd, 0xe9, 0x70, 0xf2 } }
[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
## This PCD indicates the HASH algorithm to calculate hash of data
# Based on the value set, the required algorithm is chosen to calculate
# the hash of data.<BR>
# The default hashing algorithm for BaseHashApiLib is set to SHA256.<BR>
# 0x00000001 - MD4.<BR>
# 0x00000002 - MD5.<BR>
# 0x00000003 - SHA1.<BR>
# 0x00000004 - SHA256.<BR>
# 0x00000005 - SHA384.<BR>
# 0x00000006 - SHA512.<BR>
# 0x00000007 - SM3_256.<BR>
# @Prompt Set policy for hashing unsigned image for Secure Boot.
# @ValidRange 0x80000001 | 0x00000001 - 0x00000007
gEfiCryptoPkgTokenSpaceGuid.PcdHashApiLibPolicy|0x04|UINT8|0x00000001
[UserExtensions.TianoCore."ExtraFiles"]
CryptoPkgExtra.uni