summaryrefslogtreecommitdiffstats
path: root/CryptoPkg
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2020-11-24 20:27:23 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-11-25 17:54:11 +0000
commit388f9a9355ae7ab95a34ac2e9a3c608caf11b74a (patch)
tree8f9aa566f74c4ffc85873e13684af3ad4c190492 /CryptoPkg
parent3ab9d60fcbe7d67e522aa25b88e1044be744167b (diff)
downloadedk2-388f9a9355ae7ab95a34ac2e9a3c608caf11b74a.tar.gz
edk2-388f9a9355ae7ab95a34ac2e9a3c608caf11b74a.tar.bz2
edk2-388f9a9355ae7ab95a34ac2e9a3c608caf11b74a.zip
CryptoPkg/Test/UnitTest/Library/BaseCryptLib: Fix MD5 Hash tests
Only include MD5 unit tests if ENABLE_MD5_DEPRECATED_INTERFACES is defined and define ENABLE_MD5_DEPRECATED_INTERFACES for host based unit tests so MD5 services are always tested. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Xiaoyu Lu <xiaoyux.lu@intel.com> Cc: Guomin Jiang <guomin.jiang@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Diffstat (limited to 'CryptoPkg')
-rw-r--r--CryptoPkg/Test/CryptoPkgHostUnitTest.dsc7
-rw-r--r--CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HashTests.c9
2 files changed, 14 insertions, 2 deletions
diff --git a/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc b/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc
index d8605176e6..ff0af36bcc 100644
--- a/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc
+++ b/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc
@@ -33,3 +33,10 @@
# Build HOST_APPLICATION that tests the SampleUnitTest
#
CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.inf
+
+[BuildOptions]
+ *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+ MSFT:*_*_*_CC_FLAGS = /D ENABLE_MD5_DEPRECATED_INTERFACES
+ INTEL:*_*_*_CC_FLAGS = /D ENABLE_MD5_DEPRECATED_INTERFACES
+ GCC:*_*_*_CC_FLAGS = -D ENABLE_MD5_DEPRECATED_INTERFACES
+ RVCT:*_*_*_CC_FLAGS = -DENABLE_MD5_DEPRECATED_INTERFACES
diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HashTests.c b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HashTests.c
index bc47c57362..aebba853e0 100644
--- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HashTests.c
+++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HashTests.c
@@ -1,7 +1,7 @@
/** @file
Application for Hash Primitives Validation.
-Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -21,10 +21,11 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 *HashData = "abc";
//
// Result for MD5("abc"). (From "A.5 Test suite" of IETF RFC1321)
//
+#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 Md5Digest[MD5_DIGEST_SIZE] = {
0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72
-
};
+#endif
//
// Result for SHA-1("abc"). (From "A.1 SHA-1 Example" of NIST FIPS 180-2)
@@ -107,7 +108,9 @@ typedef struct {
VOID *HashCtx;
} HASH_TEST_CONTEXT;
+#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
HASH_TEST_CONTEXT mMd5TestCtx = {MD5_DIGEST_SIZE, Md5GetContextSize, Md5Init, Md5Update, Md5Final, Md5HashAll, Md5Digest};
+#endif
HASH_TEST_CONTEXT mSha1TestCtx = {SHA1_DIGEST_SIZE, Sha1GetContextSize, Sha1Init, Sha1Update, Sha1Final, Sha1HashAll, Sha1Digest};
HASH_TEST_CONTEXT mSha256TestCtx = {SHA256_DIGEST_SIZE, Sha256GetContextSize, Sha256Init, Sha256Update, Sha256Final, Sha256HashAll, Sha256Digest};
HASH_TEST_CONTEXT mSha384TestCtx = {SHA384_DIGEST_SIZE, Sha384GetContextSize, Sha384Init, Sha384Update, Sha384Final, Sha384HashAll, Sha384Digest};
@@ -187,7 +190,9 @@ TEST_DESC mHashTest[] = {
//
// -----Description----------------Class---------------------Function---------------Pre------------------Post------------Context
//
+#ifdef ENABLE_MD5_DEPRECATED_INTERFACES
{"TestVerifyMd5()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mMd5TestCtx},
+#endif
{"TestVerifySha1()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha1TestCtx},
{"TestVerifySha256()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha256TestCtx},
{"TestVerifySha384()", "CryptoPkg.BaseCryptLib.Hash", TestVerifyHash, TestVerifyHashPreReq, TestVerifyHashCleanUp, &mSha384TestCtx},