diff options
author | Amol N Sukerkar <amol.n.sukerkar@intel.com> | 2020-02-16 03:51:02 +0000 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-02-19 16:38:22 +0000 |
commit | c70bdf9d4a6a65b88970f31bc2cabd4d08b33885 (patch) | |
tree | bddc8e74b03f5303cdbe06e5033e63ffc13c9159 /CryptoPkg/Library/BaseHashApiLib | |
parent | 0997352ddb4761c49dfedf6fef46b4cd15f6c9bf (diff) | |
download | edk2-c70bdf9d4a6a65b88970f31bc2cabd4d08b33885.tar.gz edk2-c70bdf9d4a6a65b88970f31bc2cabd4d08b33885.tar.bz2 edk2-c70bdf9d4a6a65b88970f31bc2cabd4d08b33885.zip |
CryptoPkg/BaseHashApiLib: Align BaseHashApiLib with TPM 2.0 Implementation
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2511
This commit aligns the baseHashApiLib with TPM 2.0 Implementation
as follows:
- Remove reference to MD4 and MD5 algorithms as they are deprecated
- Align the enumerations for hashing algoerithms with the one used
in TPM 2.0 implementation defined in IndustryStandard/Tpm20.h.
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: Jian J Wang <jian.j.wang@intel.com>
Diffstat (limited to 'CryptoPkg/Library/BaseHashApiLib')
-rw-r--r-- | CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c | 121 |
1 files changed, 37 insertions, 84 deletions
diff --git a/CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c b/CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c index 277ef9f0b4..f9796b2158 100644 --- a/CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c +++ b/CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c @@ -12,6 +12,7 @@ **/
#include <Base.h>
+#include <IndustryStandard/Tpm20.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
@@ -31,32 +32,24 @@ HashApiGetContextSize ( VOID
)
{
- switch (PcdGet8 (PcdHashApiLibPolicy)) {
- case HASH_API_ALGO_MD4:
- return Md4GetContextSize ();
- break;
-
- case HASH_API_ALGO_MD5:
- return Md5GetContextSize ();
- break;
-
- case HASH_API_ALGO_SHA1:
+ switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ case HASH_ALG_SHA1:
return Sha1GetContextSize ();
break;
- case HASH_API_ALGO_SHA256:
+ case HASH_ALG_SHA256:
return Sha256GetContextSize ();
break;
- case HASH_API_ALGO_SHA384:
+ case HASH_ALG_SHA384:
return Sha384GetContextSize ();
break;
- case HASH_API_ALGO_SHA512:
+ case HASH_ALG_SHA512:
return Sha512GetContextSize ();
break;
- case HASH_API_ALGO_SM3_256:
+ case HASH_ALG_SM3_256:
return Sm3GetContextSize ();
break;
@@ -81,32 +74,24 @@ HashApiInit ( OUT HASH_API_CONTEXT HashContext
)
{
- switch (PcdGet8 (PcdHashApiLibPolicy)) {
- case HASH_API_ALGO_MD4:
- return Md4Init (HashContext);
- break;
-
- case HASH_API_ALGO_MD5:
- return Md5Init (HashContext);
- break;
-
- case HASH_API_ALGO_SHA1:
+ switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ case HASH_ALG_SHA1:
return Sha1Init (HashContext);
break;
- case HASH_API_ALGO_SHA256:
+ case HASH_ALG_SHA256:
return Sha256Init (HashContext);
break;
- case HASH_API_ALGO_SHA384:
+ case HASH_ALG_SHA384:
return Sha384Init (HashContext);
break;
- case HASH_API_ALGO_SHA512:
+ case HASH_ALG_SHA512:
return Sha512Init (HashContext);
break;
- case HASH_API_ALGO_SM3_256:
+ case HASH_ALG_SM3_256:
return Sm3Init (HashContext);
break;
@@ -133,32 +118,24 @@ HashApiDuplicate ( OUT HASH_API_CONTEXT NewHashContext
)
{
- switch (PcdGet8 (PcdHashApiLibPolicy)) {
- case HASH_API_ALGO_MD4:
- return Md4Duplicate (HashContext, NewHashContext);
- break;
-
- case HASH_API_ALGO_MD5:
- return Md5Duplicate (HashContext, NewHashContext);
- break;
-
- case HASH_API_ALGO_SHA1:
+ switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ case HASH_ALG_SHA1:
return Sha1Duplicate (HashContext, NewHashContext);
break;
- case HASH_API_ALGO_SHA256:
+ case HASH_ALG_SHA256:
return Sha256Duplicate (HashContext, NewHashContext);
break;
- case HASH_API_ALGO_SHA384:
+ case HASH_ALG_SHA384:
return Sha384Duplicate (HashContext, NewHashContext);
break;
- case HASH_API_ALGO_SHA512:
+ case HASH_ALG_SHA512:
return Sha512Duplicate (HashContext, NewHashContext);
break;
- case HASH_API_ALGO_SM3_256:
+ case HASH_ALG_SM3_256:
return Sm3Duplicate (HashContext, NewHashContext);
break;
@@ -187,32 +164,24 @@ HashApiUpdate ( IN UINTN DataToHashLen
)
{
- switch (PcdGet8 (PcdHashApiLibPolicy)) {
- case HASH_API_ALGO_MD4:
- return Md4Update (HashContext, DataToHash, DataToHashLen);
- break;
-
- case HASH_API_ALGO_MD5:
- return Md5Update (HashContext, DataToHash, DataToHashLen);
- break;
-
- case HASH_API_ALGO_SHA1:
+ switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ case HASH_ALG_SHA1:
return Sha1Update (HashContext, DataToHash, DataToHashLen);
break;
- case HASH_API_ALGO_SHA256:
+ case HASH_ALG_SHA256:
return Sha256Update (HashContext, DataToHash, DataToHashLen);
break;
- case HASH_API_ALGO_SHA384:
+ case HASH_ALG_SHA384:
return Sha384Update (HashContext, DataToHash, DataToHashLen);
break;
- case HASH_API_ALGO_SHA512:
+ case HASH_ALG_SHA512:
return Sha512Update (HashContext, DataToHash, DataToHashLen);
break;
- case HASH_API_ALGO_SM3_256:
+ case HASH_ALG_SM3_256:
return Sm3Update (HashContext, DataToHash, DataToHashLen);
break;
@@ -239,32 +208,24 @@ HashApiFinal ( OUT UINT8 *Digest
)
{
- switch (PcdGet8 (PcdHashApiLibPolicy)) {
- case HASH_API_ALGO_MD4:
- return Md4Final (HashContext, Digest);
- break;
-
- case HASH_API_ALGO_MD5:
- return Md5Final (HashContext, Digest);
- break;
-
- case HASH_API_ALGO_SHA1:
+ switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ case HASH_ALG_SHA1:
return Sha1Final (HashContext, Digest);
break;
- case HASH_API_ALGO_SHA256:
+ case HASH_ALG_SHA256:
return Sha256Final (HashContext, Digest);
break;
- case HASH_API_ALGO_SHA384:
+ case HASH_ALG_SHA384:
return Sha384Final (HashContext, Digest);
break;
- case HASH_API_ALGO_SHA512:
+ case HASH_ALG_SHA512:
return Sha512Final (HashContext, Digest);
break;
- case HASH_API_ALGO_SM3_256:
+ case HASH_ALG_SM3_256:
return Sm3Final (HashContext, Digest);
break;
@@ -293,32 +254,24 @@ HashApiHashAll ( OUT UINT8 *Digest
)
{
- switch (PcdGet8 (PcdHashApiLibPolicy)) {
- case HASH_API_ALGO_MD4:
- return Md4HashAll (DataToHash, DataToHashLen, Digest);
- break;
-
- case HASH_API_ALGO_MD5:
- return Md5HashAll (DataToHash, DataToHashLen, Digest);
- break;
-
- case HASH_API_ALGO_SHA1:
+ switch (PcdGet32 (PcdHashApiLibPolicy)) {
+ case HASH_ALG_SHA1:
return Sha1HashAll (DataToHash, DataToHashLen, Digest);
break;
- case HASH_API_ALGO_SHA256:
+ case HASH_ALG_SHA256:
return Sha256HashAll (DataToHash, DataToHashLen, Digest);
break;
- case HASH_API_ALGO_SHA384:
+ case HASH_ALG_SHA384:
return Sha384HashAll (DataToHash, DataToHashLen, Digest);
break;
- case HASH_API_ALGO_SHA512:
+ case HASH_ALG_SHA512:
return Sha512HashAll (DataToHash, DataToHashLen, Digest);
break;
- case HASH_API_ALGO_SM3_256:
+ case HASH_ALG_SM3_256:
return Sm3HashAll (DataToHash, DataToHashLen, Digest);
break;
|