CryptoPkg/BaseCryptLib: Make HMAC_CTX size backward compatible
authorXiaoyu Lu <xiaoyux.lu@intel.com>
Wed, 29 May 2019 18:40:38 +0000 (18:40 +0000)
committerJian J Wang <jian.j.wang@intel.com>
Mon, 3 Jun 2019 00:28:03 +0000 (08:28 +0800)
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=1089

OpenSSL internally redefines the size of HMAC_CTX at
crypto/hmac/hmac_lcl.h(OpenSSL commit e0810e35).
Ref: https://github.com/openssl/openssl/pull/4338

We should not use it directly and should remove relevant
functions(Hmac*GetContextSize).
Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=1792

But for compatiblility, temporarily change these definition
of HMAC_*_CTX_SIZE.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Ting Ye <ting.ye@intel.com>
Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Gary Lin <glin@suse.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c
CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c
CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c

index 3134806..19e9fbe 100644 (file)
@@ -9,8 +9,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "InternalCryptLib.h"\r
 #include <openssl/hmac.h>\r
 \r
-#define HMAC_MD5_CTX_SIZE    sizeof(void *) * 4 + sizeof(unsigned int) + \\r
-                             sizeof(unsigned char) * HMAC_MAX_MD_CBLOCK\r
+//\r
+// NOTE: OpenSSL redefines the size of HMAC_CTX at crypto/hmac/hmac_lcl.h\r
+//       #define HMAC_MAX_MD_CBLOCK_SIZE     144\r
+//\r
+#define HMAC_MD5_CTX_SIZE    (sizeof(void *) * 4 + sizeof(unsigned int) + \\r
+                             sizeof(unsigned char) * 144)\r
 \r
 /**\r
   Retrieves the size, in bytes, of the context buffer required for HMAC-MD5 operations.\r
index bbe3df4..7d7df96 100644 (file)
@@ -9,8 +9,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "InternalCryptLib.h"\r
 #include <openssl/hmac.h>\r
 \r
-#define HMAC_SHA1_CTX_SIZE   sizeof(void *) * 4 + sizeof(unsigned int) + \\r
-                             sizeof(unsigned char) * HMAC_MAX_MD_CBLOCK\r
+//\r
+// NOTE: OpenSSL redefines the size of HMAC_CTX at crypto/hmac/hmac_lcl.h\r
+//       #define HMAC_MAX_MD_CBLOCK_SIZE     144\r
+//\r
+//\r
+#define  HMAC_SHA1_CTX_SIZE   (sizeof(void *) * 4 + sizeof(unsigned int) + \\r
+                             sizeof(unsigned char) * 144)\r
 \r
 /**\r
   Retrieves the size, in bytes, of the context buffer required for HMAC-SHA1 operations.\r
index ac9084f..f24443e 100644 (file)
@@ -9,8 +9,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "InternalCryptLib.h"\r
 #include <openssl/hmac.h>\r
 \r
-#define HMAC_SHA256_CTX_SIZE   sizeof(void *) * 4 + sizeof(unsigned int) + \\r
-                               sizeof(unsigned char) * HMAC_MAX_MD_CBLOCK\r
+//\r
+// NOTE: OpenSSL redefines the size of HMAC_CTX at crypto/hmac/hmac_lcl.h\r
+//       #define HMAC_MAX_MD_CBLOCK_SIZE     144\r
+//\r
+#define HMAC_SHA256_CTX_SIZE    (sizeof(void *) * 4 + sizeof(unsigned int) + \\r
+                             sizeof(unsigned char) * 144)\r
 \r
 /**\r
   Retrieves the size, in bytes, of the context buffer required for HMAC-SHA256 operations.\r