]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg/Test/UnitTest/Library/BaseCryptLib: Unit test fixes
authorMichael D Kinney <michael.d.kinney@intel.com>
Fri, 30 Sep 2022 20:59:30 +0000 (13:59 -0700)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 24 Oct 2022 07:49:43 +0000 (07:49 +0000)
* 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>
CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c
CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TSTests.c

index 9c5b39410d0fe909bd6854ac0c4837b1400a74b3..b347cb4cb4f8e839623e686f343294f6f3ce8654 100644 (file)
@@ -87,6 +87,12 @@ VOID *
   VOID\r
   );\r
 \r
+typedef\r
+VOID\r
+(EFIAPI *EFI_HMAC_FREE)(\r
+  IN VOID  *HashContext\r
+  );\r
+\r
 typedef\r
 BOOLEAN\r
 (EFIAPI *EFI_HMAC_INIT)(\r
@@ -113,6 +119,7 @@ BOOLEAN
 typedef struct {\r
   UINT32             DigestSize;\r
   EFI_HMAC_NEW       HmacNew;\r
+  EFI_HMAC_FREE      HmacFree;\r
   EFI_HMAC_INIT      HmacInit;\r
   EFI_HMAC_UPDATE    HmacUpdate;\r
   EFI_HMAC_FINAL     HmacFinal;\r
@@ -123,10 +130,10 @@ typedef struct {
 } HMAC_TEST_CONTEXT;\r
 \r
 // These functions have been deprecated but they've been left commented out for future reference\r
-// HMAC_TEST_CONTEXT       mHmacMd5TestCtx    = {MD5_DIGEST_SIZE,    HmacMd5New,    HmacMd5SetKey,    HmacMd5Update,    HmacMd5Final,    HmacMd5Key,    sizeof(HmacMd5Key),    HmacMd5Digest};\r
-// HMAC_TEST_CONTEXT       mHmacSha1TestCtx   = {SHA1_DIGEST_SIZE,   HmacSha1New,   HmacSha1SetKey,   HmacSha1Update,   HmacSha1Final,   HmacSha1Key,   sizeof(HmacSha1Key),   HmacSha1Digest};\r
-HMAC_TEST_CONTEXT  mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, HmacSha256SetKey, HmacSha256Update, HmacSha256Final, HmacSha256Key, sizeof (HmacSha256Key), HmacSha256Digest };\r
-HMAC_TEST_CONTEXT  mHmacSha384TestCtx = { SHA384_DIGEST_SIZE, HmacSha384New, HmacSha384SetKey, HmacSha384Update, HmacSha384Final, HmacSha384Key, sizeof (HmacSha384Key), HmacSha384Digest };\r
+// HMAC_TEST_CONTEXT       mHmacMd5TestCtx    = {MD5_DIGEST_SIZE,    HmacMd5New,    HmacMd5Free,  HmacMd5SetKey,    HmacMd5Update,    HmacMd5Final,    HmacMd5Key,    sizeof(HmacMd5Key),    HmacMd5Digest};\r
+// HMAC_TEST_CONTEXT       mHmacSha1TestCtx   = {SHA1_DIGEST_SIZE,   HmacSha1New,   HmacSha1Free, HmacSha1SetKey,   HmacSha1Update,   HmacSha1Final,   HmacSha1Key,   sizeof(HmacSha1Key),   HmacSha1Digest};\r
+HMAC_TEST_CONTEXT  mHmacSha256TestCtx = { SHA256_DIGEST_SIZE, HmacSha256New, HmacSha256Free, HmacSha256SetKey, HmacSha256Update, HmacSha256Final, HmacSha256Key, sizeof (HmacSha256Key), HmacSha256Digest };\r
+HMAC_TEST_CONTEXT  mHmacSha384TestCtx = { SHA384_DIGEST_SIZE, HmacSha384New, HmacSha384Free, HmacSha384SetKey, HmacSha384Update, HmacSha384Final, HmacSha384Key, sizeof (HmacSha384Key), HmacSha384Digest };\r
 \r
 UNIT_TEST_STATUS\r
 EFIAPI\r
@@ -155,7 +162,7 @@ TestVerifyHmacCleanUp (
 \r
   HmacTestContext = Context;\r
   if (HmacTestContext->HmacCtx != NULL) {\r
-    FreePool (HmacTestContext->HmacCtx);\r
+    HmacTestContext->HmacFree (HmacTestContext->HmacCtx);\r
   }\r
 }\r
 \r
index 225ec3e59746c328d6c63bbdc9c54fd887ba3c8d..226e57e66f0447134dde336dff701fa8230e1990 100644 (file)
@@ -322,7 +322,7 @@ TestVerifyImageTimestampVerify (
   UT_ASSERT_EQUAL (SigningTime.Minute, 50);\r
   UT_ASSERT_EQUAL (SigningTime.Second, 3);\r
 \r
-  return Status;\r
+  return UNIT_TEST_PASSED;\r
 }\r
 \r
 TEST_DESC  mImageTimestampTest[] = {\r