From 584b246e8857c577e2243152b30a82a9fa8388fc Mon Sep 17 00:00:00 2001 From: Michael D Kinney Date: Mon, 3 Oct 2022 16:27:26 -0700 Subject: [PATCH] CryptoPkg: Fixed host-based unit tests * Build host-based tests using OpensslLib instance with all services enabled. * Build host-based tests using performance optimized OpensslLib instance with all services enabled. * Remove unused PCD gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled * Remove redundant and unnecessary [BuildOptions] * Limit host-based unit tests to only IA32/X64 Cc: Jiewen Yao Cc: Jian J Wang Cc: Xiaoyu Lu Cc: Guomin Jiang Cc: Christopher Zurcher Signed-off-by: Michael D Kinney Reviewed-by: Jiewen Yao --- .../BaseCryptLib/UnitTestHostBaseCryptLib.inf | 22 ++------ CryptoPkg/Test/CryptoPkgHostUnitTest.dsc | 17 ++---- .../TestBaseCryptLibHostAccel.inf | 56 +++++++++++++++++++ 3 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHostAccel.inf diff --git a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf index 168e24e4c0..8026179447 100644 --- a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf @@ -18,7 +18,7 @@ # # The following information is for reference only and not required by the build tools. # -# VALID_ARCHITECTURES = IA32 X64 ARM AARCH64 +# VALID_ARCHITECTURES = IA32 X64 # [Sources] @@ -28,6 +28,7 @@ Hash/CryptSha256.c Hash/CryptSha512.c Hash/CryptSm3.c + Hash/CryptParallelHashNull.c Hmac/CryptHmac.c Kdf/CryptHkdf.c Cipher/CryptAes.c @@ -48,8 +49,7 @@ Pk/CryptRsaPss.c Pk/CryptRsaPssSign.c Bn/CryptBn.c - Pk/CryptEcNull.c |*|*|*|!gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled - Pk/CryptEc.c |*|*|*|gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled + Pk/CryptEc.c SysCall/UnitTestHostCrtWrapper.c @@ -59,12 +59,6 @@ [Sources.X64] Rand/CryptRandTsc.c -[Sources.ARM] - Rand/CryptRand.c - -[Sources.AARCH64] - Rand/CryptRand.c - [Packages] MdePkg/MdePkg.dec CryptoPkg/CryptoPkg.dec @@ -75,9 +69,7 @@ MemoryAllocationLib DebugLib OpensslLib - -[FixedPcd] - gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled + PrintLib # # Remove these [BuildOptions] after this library is cleaned up @@ -85,11 +77,9 @@ [BuildOptions] # # suppress the following warnings so we do not break the build with warnings-as-errors: - # C4090: 'function' : different 'const' qualifiers - # C4018: '>': signed/unsigned mismatch - MSFT:*_*_*_CC_FLAGS = /wd4090 /wd4018 - + # GCC:*_CLANG35_*_CC_FLAGS = -std=c99 GCC:*_CLANG38_*_CC_FLAGS = -std=c99 + GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types XCODE:*_*_*_CC_FLAGS = -std=c99 diff --git a/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc b/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc index b6e1a66198..369a1cb699 100644 --- a/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc +++ b/CryptoPkg/Test/CryptoPkgHostUnitTest.dsc @@ -19,19 +19,13 @@ !include UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc -[PcdsFixedAtBuild] - gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled|TRUE - [LibraryClasses] - OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibFull.inf BaseCryptLib|CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf -[LibraryClasses.AARCH64, LibraryClasses.ARM] - RngLib|MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf - [LibraryClasses.X64, LibraryClasses.IA32] RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf @@ -40,9 +34,10 @@ # Build HOST_APPLICATION that tests the SampleUnitTest # CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.inf + CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHostAccel.inf { + + OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.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 + *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHostAccel.inf b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHostAccel.inf new file mode 100644 index 0000000000..9d0fcfd357 --- /dev/null +++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHostAccel.inf @@ -0,0 +1,56 @@ +## @file +# Host-based UnitTest for BaseCryptLib +# +# Copyright (c) Microsoft Corporation.
+# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = BaseCryptLibUnitTestHostAccel + FILE_GUID = B1AED64E-B53A-4D69-B0BA-60EEDAC47A6B + MODULE_TYPE = HOST_APPLICATION + VERSION_STRING = 1.0 + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 +# + +[Sources] + UnitTestMain.c + BaseCryptLibUnitTests.c + TestBaseCryptLib.h + HashTests.c + HmacTests.c + BlockCipherTests.c + RsaTests.c + RsaPkcs7Tests.c + Pkcs5Pbkdf2Tests.c + AuthenticodeTests.c + TSTests.c + DhTests.c + RandTests.c + Pkcs7EkuTests.c + OaepEncryptTests.c + RsaPssTests.c + ParallelhashTests.c + HkdfTests.c + AeadAesGcmTests.c + BnTests.c + EcTests.c + X509Tests.c + +[Packages] + MdePkg/MdePkg.dec + CryptoPkg/CryptoPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + BaseCryptLib + UnitTestLib + MmServicesTableLib + SynchronizationLib