summaryrefslogtreecommitdiffstats
path: root/CryptoPkg
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2022-09-30 13:59:30 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-10-24 07:49:43 +0000
commit961fadf60c02d0e52c805508852949e25cea44f4 (patch)
treedce2e714e21cd30fceb577147ba98641c05cd94d /CryptoPkg
parent8f8372439d8ec5f565dbda1548c18deb068e0080 (diff)
downloadedk2-961fadf60c02d0e52c805508852949e25cea44f4.tar.gz
edk2-961fadf60c02d0e52c805508852949e25cea44f4.tar.bz2
edk2-961fadf60c02d0e52c805508852949e25cea44f4.zip
CryptoPkg/Test/UnitTest/Library/BaseCryptLib: Unit test fixes
* Update ImageTimeStampTest to return UNIT_TEST_PASSED instead of Status. On success Status is TRUE(1), which was returning a unit test status of UNIT_TEST_ERROR_PREREQUISITE_NOT_MET. * Update HmacTests to use the *Free() service from the HMAC family instead of FreePool(). Using FreePool() generates ASSERT() because the context being freed was not allocated using AllocatePool(). Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com> Cc: Guomin Jiang <guomin.jiang@intel.com> Cc: Christopher Zurcher <christopher.zurcher@microsoft.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'CryptoPkg')
-rw-r--r--CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c17
-rw-r--r--CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TSTests.c2
2 files changed, 13 insertions, 6 deletions
diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c
index 9c5b39410d..b347cb4cb4 100644
--- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c
+++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c
@@ -88,6 +88,12 @@ VOID *
);
typedef
+VOID
+(EFIAPI *EFI_HMAC_FREE)(
+ IN VOID *HashContext
+ );
+
+typedef
BOOLEAN
(EFIAPI *EFI_HMAC_INIT)(
IN OUT VOID *HashContext,
@@ -113,6 +119,7 @@ BOOLEAN
typedef struct {
UINT32 DigestSize;
EFI_HMAC_NEW HmacNew;
+ EFI_HMAC_FREE HmacFree;
EFI_HMAC_INIT HmacInit;
EFI_HMAC_UPDATE HmacUpdate;
EFI_HMAC_FINAL HmacFinal;
@@ -123,10 +130,10 @@ typedef struct {
} HMAC_TEST_CONTEXT;
// These functions have been deprecated but they've been left commented out for future reference
-// HMAC_TEST_CONTEXT mHmacMd5TestCtx = {MD5_DIGEST_SIZE, HmacMd5New, HmacMd5SetKey, HmacMd5Update, HmacMd5Final, HmacMd5Key, sizeof(HmacMd5Key), HmacMd5Digest};
-// HMAC_TEST_CONTEXT mHmacSha1TestCtx = {SHA1_DIGEST_SIZE, HmacSha1New, HmacSha1SetKey, HmacSha1Update, HmacSha1Final, HmacSha1Key, sizeof(HmacSha1Key), HmacSha1Digest};
-HMAC_TEST_CONTEXT mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, HmacSha256SetKey, HmacSha256Update, HmacSha256Final, HmacSha256Key, sizeof (HmacSha256Key), HmacSha256Digest };
-HMAC_TEST_CONTEXT mHmacSha384TestCtx = { SHA384_DIGEST_SIZE, HmacSha384New, HmacSha384SetKey, HmacSha384Update, HmacSha384Final, HmacSha384Key, sizeof (HmacSha384Key), HmacSha384Digest };
+// HMAC_TEST_CONTEXT mHmacMd5TestCtx = {MD5_DIGEST_SIZE, HmacMd5New, HmacMd5Free, HmacMd5SetKey, HmacMd5Update, HmacMd5Final, HmacMd5Key, sizeof(HmacMd5Key), HmacMd5Digest};
+// HMAC_TEST_CONTEXT mHmacSha1TestCtx = {SHA1_DIGEST_SIZE, HmacSha1New, HmacSha1Free, HmacSha1SetKey, HmacSha1Update, HmacSha1Final, HmacSha1Key, sizeof(HmacSha1Key), HmacSha1Digest};
+HMAC_TEST_CONTEXT mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, HmacSha256Free, HmacSha256SetKey, HmacSha256Update, HmacSha256Final, HmacSha256Key, sizeof (HmacSha256Key), HmacSha256Digest };
+HMAC_TEST_CONTEXT mHmacSha384TestCtx = { SHA384_DIGEST_SIZE, HmacSha384New, HmacSha384Free, HmacSha384SetKey, HmacSha384Update, HmacSha384Final, HmacSha384Key, sizeof (HmacSha384Key), HmacSha384Digest };
UNIT_TEST_STATUS
EFIAPI
@@ -155,7 +162,7 @@ TestVerifyHmacCleanUp (
HmacTestContext = Context;
if (HmacTestContext->HmacCtx != NULL) {
- FreePool (HmacTestContext->HmacCtx);
+ HmacTestContext->HmacFree (HmacTestContext->HmacCtx);
}
}
diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TSTests.c b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TSTests.c
index 225ec3e597..226e57e66f 100644
--- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TSTests.c
+++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TSTests.c
@@ -322,7 +322,7 @@ TestVerifyImageTimestampVerify (
UT_ASSERT_EQUAL (SigningTime.Minute, 50);
UT_ASSERT_EQUAL (SigningTime.Second, 3);
- return Status;
+ return UNIT_TEST_PASSED;
}
TEST_DESC mImageTimestampTest[] = {