From nobody Thu Apr 25 07:43:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+53004+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53004+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1578468413; cv=none; d=zohomail.com; s=zohoarc; b=CoMpd1VFZPgkQKLB30m39HZor3VeYHwf+rV0aRG6+/Q6hbHWkRiULBIuzP2ZrIvC9uOVnFLG8es1sh0lZGLAcyH6bmrJh2aIgPq9rVF0DTRl2h6+BRtaIKgfxgZTDckXHRvI2baND06F21rWn8wHbfVD86QCGmU5NeWDvoSKadY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578468413; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=mJwjk7ABGWyKHgv0t7P4PTL9pFM2bfTdIEUfACdcBb8=; b=Zb3MEzCD0GfcLoaRfL9XN9QmduriSehQNJYr3lexNq3hsGSYT0crIF0tqDK3iWjr0fDPWLbQxc2xYNO5x8F1ORYCSg342Fq0RdOcZ8GmjHT2oHnM0S5mzwvin1QxMritfNETr6zR7rAB28dLTIe172j/60z0vdvGYtXR86TUj5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+53004+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1578468413986392.18071625289895; Tue, 7 Jan 2020 23:26:53 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id tjSCYY1788612x2nTYL363Xj; Tue, 07 Jan 2020 23:26:53 -0800 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web12.4921.1578468412617761154 for ; Tue, 07 Jan 2020 23:26:52 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2020 23:26:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,409,1571727600"; d="scan'208";a="215870720" X-Received: from shwdeopensfp777.ccr.corp.intel.com ([10.239.158.78]) by orsmga008.jf.intel.com with ESMTP; 07 Jan 2020 23:26:50 -0800 From: "Wang, Jian J" To: devel@edk2.groups.io Cc: Xiaoyu Lu , Laszlo Ersek Subject: [edk2-devel] [PATCH] CryptoPkg/BaseCryptLib: deprecate HmacXxxGetContextSize interface Date: Wed, 8 Jan 2020 15:26:50 +0800 Message-Id: <20200108072650.1353-1-jian.j.wang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jian.j.wang@intel.com X-Gm-Message-State: cLWIIClTy2VtsMKuaneO5Wzlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1578468413; bh=WkURe3CSHInlq6d5qI9GDN3BCe0mHbK/ZfVO9Lywq+4=; h=Cc:Date:From:Reply-To:Subject:To; b=MJu9prnnyiwZjatyN3y2W8jqBiJptiBCCqEE0YnpzChzyQ5JmMZ0aQL+OMYk1iUDh2t EI97hsieWChUXXlbLC+bbrHeeko4ty+Nzd1gPc7CiSaMj5spjHn8melsb+qfXyCbCur7L 7Ayq4k09oP35UwF+DxgUEgLwgBAodV0w60w= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1792 Hmac(Md5|Sha1|Sha256)GetContextSize() use a deprecated macro HMAC_MAX_MD_CBLOCK defined in openssl. They should be dropped to avoid misuses in the future. For context allocation and release, use HmacXxxNew() and HmacXxxFree() instead. Since HmacXxxNew will zero allocated context buffer, the calling to memset() in HmacXxxInit is safe to be removed. Cc: Xiaoyu Lu Cc: Laszlo Ersek Signed-off-by: Jian J Wang --- CryptoPkg/Include/Library/BaseCryptLib.h | 51 ------------------- .../Library/BaseCryptLib/Hmac/CryptHmacMd5.c | 32 ------------ .../BaseCryptLib/Hmac/CryptHmacMd5Null.c | 20 -------- .../Library/BaseCryptLib/Hmac/CryptHmacSha1.c | 33 ------------ .../BaseCryptLib/Hmac/CryptHmacSha1Null.c | 20 -------- .../BaseCryptLib/Hmac/CryptHmacSha256.c | 32 ------------ .../BaseCryptLib/Hmac/CryptHmacSha256Null.c | 20 -------- .../BaseCryptLibNull/Hmac/CryptHmacMd5Null.c | 20 -------- .../BaseCryptLibNull/Hmac/CryptHmacSha1Null.c | 20 -------- .../Hmac/CryptHmacSha256Null.c | 20 -------- 10 files changed, 268 deletions(-) diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h b/CryptoPkg/Include/L= ibrary/BaseCryptLib.h index 8fe303a0b3..ffe606fa3f 100644 --- a/CryptoPkg/Include/Library/BaseCryptLib.h +++ b/CryptoPkg/Include/Library/BaseCryptLib.h @@ -1025,23 +1025,6 @@ Sm3HashAll ( // MAC (Message Authentication Code) Primitive //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-MD= 5 operations. - (NOTE: This API is deprecated. - Use HmacMd5New() / HmacMd5Free() for HMAC-MD5 Context operations.) - - If this interface is not supported, then return zero. - - @return The size, in bytes, of the context buffer required for HMAC-MD5= operations. - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacMd5GetContextSize ( - VOID - ); - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD5 u= se. =20 @@ -1175,23 +1158,6 @@ HmacMd5Final ( OUT UINT8 *HmacValue ); =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SH= A1 operations. - (NOTE: This API is deprecated. - Use HmacSha1New() / HmacSha1Free() for HMAC-SHA1 Context operatio= ns.) - - If this interface is not supported, then return zero. - - @return The size, in bytes, of the context buffer required for HMAC-SHA= 1 operations. - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacSha1GetContextSize ( - VOID - ); - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA1 = use. =20 @@ -1325,23 +1291,6 @@ HmacSha1Final ( OUT UINT8 *HmacValue ); =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SH= A256 operations. - (NOTE: This API is deprecated. - Use HmacSha256New() / HmacSha256Free() for HMAC-SHA256 Context op= erations.) - - If this interface is not supported, then return zero. - - @return The size, in bytes, of the context buffer required for HMAC-SHA= 256 operations. - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacSha256GetContextSize ( - VOID - ); - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA25= 6 use. =20 diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c b/CryptoPkg= /Library/BaseCryptLib/Hmac/CryptHmacMd5.c index 19e9fbeae6..819842392b 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c @@ -9,37 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalCryptLib.h" #include =20 -// -// NOTE: OpenSSL redefines the size of HMAC_CTX at crypto/hmac/hmac_lcl.h -// #define HMAC_MAX_MD_CBLOCK_SIZE 144 -// -#define HMAC_MD5_CTX_SIZE (sizeof(void *) * 4 + sizeof(unsigned int) + \ - sizeof(unsigned char) * 144) - -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-MD= 5 operations. - (NOTE: This API is deprecated. - Use HmacMd5New() / HmacMd5Free() for HMAC-MD5 Context operations.) - - @return The size, in bytes, of the context buffer required for HMAC-MD5= operations. - -**/ -UINTN -EFIAPI -HmacMd5GetContextSize ( - VOID - ) -{ - // - // Retrieves the OpenSSL HMAC-MD5 Context Size - // NOTE: HMAC_CTX object was made opaque in openssl-1.1.x, here we just = use the - // fixed size as a workaround to make this API work for compatibil= ity. - // We should retire HmacMd5GetContextSize() in future, and use Hma= cMd5New() - // and HmacMd5Free() for context allocation and release. - // - return (UINTN) HMAC_MD5_CTX_SIZE; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD5 u= se. =20 @@ -109,7 +78,6 @@ HmacMd5Init ( // // OpenSSL HMAC-MD5 Context Initialization // - memset(HmacMd5Context, 0, HMAC_MD5_CTX_SIZE); if (HMAC_CTX_reset ((HMAC_CTX *)HmacMd5Context) !=3D 1) { return FALSE; } diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c b/Crypt= oPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c index 3aafed874b..205dc9e474 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c @@ -8,26 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "InternalCryptLib.h" =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-MD= 5 operations. - (NOTE: This API is deprecated. - Use HmacMd5New() / HmacMd5Free() for HMAC-MD5 Context operations.) - - Return zero to indicate this interface is not supported. - - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacMd5GetContextSize ( - VOID - ) -{ - ASSERT (FALSE); - return 0; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD5 u= se. =20 diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c b/CryptoPk= g/Library/BaseCryptLib/Hmac/CryptHmacSha1.c index 7d7df9640e..f45ecebc6d 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c @@ -9,38 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalCryptLib.h" #include =20 -// -// NOTE: OpenSSL redefines the size of HMAC_CTX at crypto/hmac/hmac_lcl.h -// #define HMAC_MAX_MD_CBLOCK_SIZE 144 -// -// -#define HMAC_SHA1_CTX_SIZE (sizeof(void *) * 4 + sizeof(unsigned int) += \ - sizeof(unsigned char) * 144) - -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SH= A1 operations. - (NOTE: This API is deprecated. - Use HmacSha1New() / HmacSha1Free() for HMAC-SHA1 Context operatio= ns.) - - @return The size, in bytes, of the context buffer required for HMAC-SHA= 1 operations. - -**/ -UINTN -EFIAPI -HmacSha1GetContextSize ( - VOID - ) -{ - // - // Retrieves the OpenSSL HMAC-SHA1 Context Size - // NOTE: HMAC_CTX object was made opaque in openssl-1.1.x, here we just = use the - // fixed size as a workaround to make this API work for compatibil= ity. - // We should retire HmacSha15GetContextSize() in future, and use H= macSha1New() - // and HmacSha1Free() for context allocation and release. - // - return (UINTN) HMAC_SHA1_CTX_SIZE; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA1 = use. =20 @@ -110,7 +78,6 @@ HmacSha1Init ( // // OpenSSL HMAC-SHA1 Context Initialization // - memset(HmacSha1Context, 0, HMAC_SHA1_CTX_SIZE); if (HMAC_CTX_reset ((HMAC_CTX *)HmacSha1Context) !=3D 1) { return FALSE; } diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c b/Cryp= toPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c index 547aa484ea..542350f15a 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c @@ -8,26 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "InternalCryptLib.h" =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SH= A1 operations. - (NOTE: This API is deprecated. - Use HmacSha1New() / HmacSha1Free() for HMAC-SHA1 Context operatio= ns.) - - Return zero to indicate this interface is not supported. - - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacSha1GetContextSize ( - VOID - ) -{ - ASSERT (FALSE); - return 0; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA1 = use. =20 diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c b/Crypto= Pkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c index f24443e745..446d629d74 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c @@ -9,37 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include "InternalCryptLib.h" #include =20 -// -// NOTE: OpenSSL redefines the size of HMAC_CTX at crypto/hmac/hmac_lcl.h -// #define HMAC_MAX_MD_CBLOCK_SIZE 144 -// -#define HMAC_SHA256_CTX_SIZE (sizeof(void *) * 4 + sizeof(unsigned int)= + \ - sizeof(unsigned char) * 144) - -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SH= A256 operations. - (NOTE: This API is deprecated. - Use HmacSha256New() / HmacSha256Free() for HMAC-SHA256 Context op= erations.) - - @return The size, in bytes, of the context buffer required for HMAC-SHA= 256 operations. - -**/ -UINTN -EFIAPI -HmacSha256GetContextSize ( - VOID - ) -{ - // - // Retrieves the OpenSSL HMAC-SHA256 Context Size - // NOTE: HMAC_CTX object was made opaque in openssl-1.1.x, here we just = use the - // fixed size as a workaround to make this API work for compatibil= ity. - // We should retire HmacSha256GetContextSize() in future, and use = HmacSha256New() - // and HmacSha256Free() for context allocation and release. - // - return (UINTN)HMAC_SHA256_CTX_SIZE; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA25= 6 use. =20 @@ -109,7 +78,6 @@ HmacSha256Init ( // // OpenSSL HMAC-SHA256 Context Initialization // - memset(HmacSha256Context, 0, HMAC_SHA256_CTX_SIZE); if (HMAC_CTX_reset ((HMAC_CTX *)HmacSha256Context) !=3D 1) { return FALSE; } diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c b/Cr= yptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c index f0a4420e27..f8074cc617 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c @@ -8,26 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "InternalCryptLib.h" =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SH= A256 operations. - (NOTE: This API is deprecated. - Use HmacSha256New() / HmacSha256Free() for HMAC-SHA256 Context op= erations.) - - Return zero to indicate this interface is not supported. - - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacSha256GetContextSize ( - VOID - ) -{ - ASSERT (FALSE); - return 0; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA25= 6 use. =20 diff --git a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c b/C= ryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c index 3aafed874b..205dc9e474 100644 --- a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c +++ b/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c @@ -8,26 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "InternalCryptLib.h" =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-MD= 5 operations. - (NOTE: This API is deprecated. - Use HmacMd5New() / HmacMd5Free() for HMAC-MD5 Context operations.) - - Return zero to indicate this interface is not supported. - - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacMd5GetContextSize ( - VOID - ) -{ - ASSERT (FALSE); - return 0; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD5 u= se. =20 diff --git a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c b/= CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c index 547aa484ea..542350f15a 100644 --- a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c +++ b/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c @@ -8,26 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "InternalCryptLib.h" =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SH= A1 operations. - (NOTE: This API is deprecated. - Use HmacSha1New() / HmacSha1Free() for HMAC-SHA1 Context operatio= ns.) - - Return zero to indicate this interface is not supported. - - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacSha1GetContextSize ( - VOID - ) -{ - ASSERT (FALSE); - return 0; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA1 = use. =20 diff --git a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c = b/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c index f0a4420e27..f8074cc617 100644 --- a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c +++ b/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c @@ -8,26 +8,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include "InternalCryptLib.h" =20 -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SH= A256 operations. - (NOTE: This API is deprecated. - Use HmacSha256New() / HmacSha256Free() for HMAC-SHA256 Context op= erations.) - - Return zero to indicate this interface is not supported. - - @retval 0 This interface is not supported. - -**/ -UINTN -EFIAPI -HmacSha256GetContextSize ( - VOID - ) -{ - ASSERT (FALSE); - return 0; -} - /** Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA25= 6 use. =20 --=20 2.24.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#53004): https://edk2.groups.io/g/devel/message/53004 Mute This Topic: https://groups.io/mt/69523367/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-