summaryrefslogtreecommitdiff
path: root/CryptoPkg/Application
diff options
context:
space:
mode:
authorQin Long <qin.long@intel.com>2016-11-01 10:25:30 +0800
committerQin Long <qin.long@intel.com>2016-11-02 23:16:10 +0800
commitb7d1ba0a8ae9719689ad9725e02e4cb5d469a3ae (patch)
tree5e844e900a870b861a14c4ad826025c2dd4565e7 /CryptoPkg/Application
parent90a40219673303f97890d5ea2e367ee2dc04a0b3 (diff)
downloadedk2-platforms-b7d1ba0a8ae9719689ad9725e02e4cb5d469a3ae.tar.xz
CryptoPkg: Add xxxxHashAll APIs to facilitate the digest computation
Add new xxxxHashAll APIs to facilitate the digest computation of blob data. New APIs include: Md4HashAll(), Md5HashAll(), Sha1HashAll(), Sha256HashAll(), Sha384HashAll(), and Sha512HashAll(). The corresponding test cases were added in Cryptest utility. Cc: Ting Ye <ting.ye@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> Reviewed-by: Ting Ye <ting.ye@intel.com>
Diffstat (limited to 'CryptoPkg/Application')
-rw-r--r--CryptoPkg/Application/Cryptest/HashVerify.c76
1 files changed, 74 insertions, 2 deletions
diff --git a/CryptoPkg/Application/Cryptest/HashVerify.c b/CryptoPkg/Application/Cryptest/HashVerify.c
index ca64361c38..a35cad5b52 100644
--- a/CryptoPkg/Application/Cryptest/HashVerify.c
+++ b/CryptoPkg/Application/Cryptest/HashVerify.c
@@ -1,7 +1,7 @@
/** @file
Application for Hash Primitives Validation.
-Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -127,7 +127,19 @@ ValidateCryptDigest (
FreePool (HashCtx);
Print (L"Check Value... ");
- if (CompareMem (Digest, Md4Digest, MD5_DIGEST_SIZE) != 0) {
+ if (CompareMem (Digest, Md4Digest, MD4_DIGEST_SIZE) != 0) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+
+ Print (L"HashAll... ");
+ ZeroMem (Digest, MD5_DIGEST_SIZE);
+ Status = Md4HashAll (HashData, DataSize, Digest);
+ if (!Status) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+ if (CompareMem (Digest, Md4Digest, MD4_DIGEST_SIZE) != 0) {
Print (L"[Fail]");
return EFI_ABORTED;
}
@@ -172,6 +184,18 @@ ValidateCryptDigest (
return EFI_ABORTED;
}
+ Print (L"HashAll... ");
+ ZeroMem (Digest, MD5_DIGEST_SIZE);
+ Status = Md5HashAll (HashData, DataSize, Digest);
+ if (!Status) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+ if (CompareMem (Digest, Md5Digest, MD5_DIGEST_SIZE) != 0) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+
Print (L"[Pass]\n");
Print (L"- SHA1: ");
@@ -212,6 +236,18 @@ ValidateCryptDigest (
return EFI_ABORTED;
}
+ Print (L"HashAll... ");
+ ZeroMem (Digest, SHA1_DIGEST_SIZE);
+ Status = Sha1HashAll (HashData, DataSize, Digest);
+ if (!Status) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+ if (CompareMem (Digest, Sha1Digest, SHA1_DIGEST_SIZE) != 0) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+
Print (L"[Pass]\n");
Print (L"- SHA256: ");
@@ -252,6 +288,18 @@ ValidateCryptDigest (
return EFI_ABORTED;
}
+ Print (L"HashAll... ");
+ ZeroMem (Digest, SHA256_DIGEST_SIZE);
+ Status = Sha256HashAll (HashData, DataSize, Digest);
+ if (!Status) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+ if (CompareMem (Digest, Sha256Digest, SHA256_DIGEST_SIZE) != 0) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+
Print (L"[Pass]\n");
Print (L"- SHA384: ");
@@ -292,6 +340,18 @@ ValidateCryptDigest (
return EFI_ABORTED;
}
+ Print (L"HashAll... ");
+ ZeroMem (Digest, SHA384_DIGEST_SIZE);
+ Status = Sha384HashAll (HashData, DataSize, Digest);
+ if (!Status) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+ if (CompareMem (Digest, Sha384Digest, SHA384_DIGEST_SIZE) != 0) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+
Print (L"[Pass]\n");
Print (L"- SHA512: ");
@@ -332,6 +392,18 @@ ValidateCryptDigest (
return EFI_ABORTED;
}
+ Print (L"HashAll... ");
+ ZeroMem (Digest, SHA512_DIGEST_SIZE);
+ Status = Sha512HashAll (HashData, DataSize, Digest);
+ if (!Status) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+ if (CompareMem (Digest, Sha512Digest, SHA512_DIGEST_SIZE) != 0) {
+ Print (L"[Fail]");
+ return EFI_ABORTED;
+ }
+
Print (L"[Pass]\n");
return EFI_SUCCESS;