From nobody Sun Apr 28 15:27:03 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+53300+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+53300+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1579155009; cv=none; d=zohomail.com; s=zohoarc; b=dM7E6ZWUBlG2m7tcnPKNbcM5LsPaEnICexij3dEh6WuydJqmemK174+7LRlMb0RXMzEnaBBclUrLzDoLUkkAOq55iHLkcw7YEyIj15tuyk1hKdLz7x3zRNDsylYFFzu8Fp6o0qHA3FG9LIlm2ZRK+7sFrFrrCVMs0WRly/P2sOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579155009; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=A0trV+k+U36PIln3Ilr4L/JZ5SyZTuE98nNSJR0tWXI=; b=McBYG4axeIzpRyfs0SDlCP9gEY91yNoawFGFQ2hrrg+7CegH7Yo55iwWIAQcgwy7rS0WqmMns1De3SifV+FH4Ftbfr7PFRt3Flod6cDJjGzfPUeT+TGVmw0ys42KSE7Q78fP7gKQFRHZofyFRy2bV4qTxVo87TziKRGwJacSvIA= 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+53300+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 1579155009061520.206432775275; Wed, 15 Jan 2020 22:10:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id gz6MYY1788612xONrYR3sk3r; Wed, 15 Jan 2020 22:10:08 -0800 X-Received: from mga02.intel.com (mga02.intel.com []) by mx.groups.io with SMTP id smtpd.web10.5215.1579155007460985160 for ; Wed, 15 Jan 2020 22:10:08 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2020 22:10:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,325,1574150400"; d="scan'208";a="219537660" X-Received: from unknown (HELO shwdeopensfp777.ccr.corp.intel.com) ([10.239.158.78]) by fmsmga007.fm.intel.com with ESMTP; 15 Jan 2020 22:10:05 -0800 From: "Wang, Jian J" To: devel@edk2.groups.io Cc: Xiaoyu Lu , Laszlo Ersek Subject: [edk2-devel] [PATCH v3 1/2] CryptoPkg/BaseCryptLib: replace HmacXxxInit API with HmacXxxSetKey Date: Thu, 16 Jan 2020 14:10:02 +0800 Message-Id: <20200116061004.636-2-jian.j.wang@intel.com> In-Reply-To: <20200116061004.636-1-jian.j.wang@intel.com> References: <20200116061004.636-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: Ocmhh9ZTe8igmXoO3y88rAUFx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579155008; bh=isD0qhg6C928tmtzN1WC037HsNCkJ0T+QMjLt0SF70Y=; h=Cc:Date:From:Reply-To:Subject:To; b=HVSPaRdL4csnYemsY79gxtpJIY14rzZp4Rbl3f4zm+C3CROmzpCn8v07p4lZx9dz5f/ LP/rkTiNK/faMUvhSzpEIAvOUcycpTB+nbitO286wwWx1dtoWTjRfIIcaGgjvFrgCrr+K i0uuVI/im32m1Gs2JkVzrEOIv5H8pPvMqHU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1792 HmacXxxInit() is supposed to be initialize user supplied buffer as HMAC context, as well as user supplied key. Currently it has no real use cases. Due to BZ1792, the user has no way to get correct size of context buffer after it's fixed, and then cannot make use of HmacXxxInit to initialize it. So it's decided to replace it with HmacXxxSetKey to keep the functionality of supplying a key to HMAC, but drop all other initialization works. The user can still get HMAC context via HmacXxxNew interface, which hides the details about the context. Cc: Xiaoyu Lu Cc: Laszlo Ersek Signed-off-by: Jian J Wang Reviewed-by: Laszlo Ersek --- CryptoPkg/Include/Library/BaseCryptLib.h | 94 ++++++------------- .../Library/BaseCryptLib/Hmac/CryptHmacMd5.c | 27 ++---- .../BaseCryptLib/Hmac/CryptHmacMd5Null.c | 8 +- .../Library/BaseCryptLib/Hmac/CryptHmacSha1.c | 27 ++---- .../BaseCryptLib/Hmac/CryptHmacSha1Null.c | 8 +- .../BaseCryptLib/Hmac/CryptHmacSha256.c | 27 ++---- .../BaseCryptLib/Hmac/CryptHmacSha256Null.c | 8 +- .../BaseCryptLibNull/Hmac/CryptHmacMd5Null.c | 8 +- .../BaseCryptLibNull/Hmac/CryptHmacSha1Null.c | 8 +- .../Hmac/CryptHmacSha256Null.c | 8 +- 10 files changed, 84 insertions(+), 139 deletions(-) diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h b/CryptoPkg/Include/L= ibrary/BaseCryptLib.h index 8fe303a0b3..c5803ea673 100644 --- a/CryptoPkg/Include/Library/BaseCryptLib.h +++ b/CryptoPkg/Include/Library/BaseCryptLib.h @@ -1073,24 +1073,24 @@ HmacMd5Free ( ); =20 /** - Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 c= ontext for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacMd5Update(). =20 If HmacMd5Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. =20 - @param[out] HmacMd5Context Pointer to HMAC-MD5 context being initializ= ed. + @param[out] HmacMd5Context Pointer to HMAC-MD5 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 - @retval TRUE HMAC-MD5 context initialization succeeded. - @retval FALSE HMAC-MD5 context initialization failed. + @retval TRUE Key is set successfully. + @retval FALSE Key is set unsuccessfully. @retval FALSE This interface is not supported. =20 **/ BOOLEAN EFIAPI -HmacMd5Init ( +HmacMd5SetKey ( OUT VOID *HmacMd5Context, IN CONST UINT8 *Key, IN UINTN KeySize @@ -1123,8 +1123,8 @@ HmacMd5Duplicate ( =20 This function performs HMAC-MD5 digest on a data buffer of the specified= size. It can be called multiple times to compute the digest of long or discont= inuous data streams. - HMAC-MD5 context should be already correctly initialized by HmacMd5Init(= ), and should not be - finalized by HmacMd5Final(). Behavior with invalid context is undefined. + HMAC-MD5 context should be initialized by HmacMd5New(), and should not b= e finalized by + HmacMd5Final(). Behavior with invalid context is undefined. =20 If HmacMd5Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. @@ -1152,8 +1152,8 @@ HmacMd5Update ( This function completes HMAC-MD5 hash computation and retrieves the dige= st value into the specified memory. After this function has been called, the HMAC-MD5 = context cannot be used again. - HMAC-MD5 context should be already correctly initialized by HmacMd5Init(= ), and should not be - finalized by HmacMd5Final(). Behavior with invalid HMAC-MD5 context is u= ndefined. + HMAC-MD5 context should be initialized by HmacMd5New(), and should not b= e finalized by + HmacMd5Final(). Behavior with invalid HMAC-MD5 context is undefined. =20 If HmacMd5Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. @@ -1175,23 +1175,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 @@ -1223,24 +1206,24 @@ HmacSha1Free ( ); =20 /** - Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1= context for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacSha1Update(). =20 If HmacSha1Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. =20 - @param[out] HmacSha1Context Pointer to HMAC-SHA1 context being initial= ized. + @param[out] HmacSha1Context Pointer to HMAC-SHA1 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 - @retval TRUE HMAC-SHA1 context initialization succeeded. - @retval FALSE HMAC-SHA1 context initialization failed. + @retval TRUE The Key is set successfully. + @retval FALSE The Key is set unsuccessfully. @retval FALSE This interface is not supported. =20 **/ BOOLEAN EFIAPI -HmacSha1Init ( +HmacSha1SetKey ( OUT VOID *HmacSha1Context, IN CONST UINT8 *Key, IN UINTN KeySize @@ -1273,8 +1256,8 @@ HmacSha1Duplicate ( =20 This function performs HMAC-SHA1 digest on a data buffer of the specifie= d size. It can be called multiple times to compute the digest of long or discont= inuous data streams. - HMAC-SHA1 context should be already correctly initialized by HmacSha1Ini= t(), and should not - be finalized by HmacSha1Final(). Behavior with invalid context is undefi= ned. + HMAC-SHA1 context should be initialized by HmacSha1New(), and should not= be finalized by + HmacSha1Final(). Behavior with invalid context is undefined. =20 If HmacSha1Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. @@ -1302,8 +1285,8 @@ HmacSha1Update ( This function completes HMAC-SHA1 hash computation and retrieves the dig= est value into the specified memory. After this function has been called, the HMAC-SHA1= context cannot be used again. - HMAC-SHA1 context should be already correctly initialized by HmacSha1Ini= t(), and should - not be finalized by HmacSha1Final(). Behavior with invalid HMAC-SHA1 con= text is undefined. + HMAC-SHA1 context should be initialized by HmacSha1New(), and should not= be finalized + by HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined. =20 If HmacSha1Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. @@ -1325,23 +1308,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 @@ -1368,24 +1334,24 @@ HmacSha256Free ( ); =20 /** - Initializes user-supplied memory pointed by HmacSha256Context as HMAC-SH= A256 context for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacSha256Update(). =20 If HmacSha256Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. =20 - @param[out] HmacSha256Context Pointer to HMAC-SHA256 context being ini= tialized. + @param[out] HmacSha256Context Pointer to HMAC-SHA256 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 - @retval TRUE HMAC-SHA256 context initialization succeeded. - @retval FALSE HMAC-SHA256 context initialization failed. + @retval TRUE The Key is set successfully. + @retval FALSE The Key is set unsuccessfully. @retval FALSE This interface is not supported. =20 **/ BOOLEAN EFIAPI -HmacSha256Init ( +HmacSha256SetKey ( OUT VOID *HmacSha256Context, IN CONST UINT8 *Key, IN UINTN KeySize @@ -1418,8 +1384,8 @@ HmacSha256Duplicate ( =20 This function performs HMAC-SHA256 digest on a data buffer of the specif= ied size. It can be called multiple times to compute the digest of long or discont= inuous data streams. - HMAC-SHA256 context should be already correctly initialized by HmacSha25= 6Init(), and should not - be finalized by HmacSha256Final(). Behavior with invalid context is unde= fined. + HMAC-SHA256 context should be initialized by HmacSha256New(), and should= not be finalized + by HmacSha256Final(). Behavior with invalid context is undefined. =20 If HmacSha256Context is NULL, then return FALSE. If this interface is not supported, then return FALSE. @@ -1447,8 +1413,8 @@ HmacSha256Update ( This function completes HMAC-SHA256 hash computation and retrieves the d= igest value into the specified memory. After this function has been called, the HMAC-SHA2= 56 context cannot be used again. - HMAC-SHA256 context should be already correctly initialized by HmacSha25= 6Init(), and should - not be finalized by HmacSha256Final(). Behavior with invalid HMAC-SHA256= context is undefined. + HMAC-SHA256 context should be initialized by HmacSha256New(), and should= not be finalized + by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undef= ined. =20 If HmacSha256Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c b/CryptoPkg= /Library/BaseCryptLib/Hmac/CryptHmacMd5.c index 19e9fbeae6..7d49dc2698 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c @@ -78,22 +78,22 @@ HmacMd5Free ( } =20 /** - Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 c= ontext for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacMd5Update(). =20 If HmacMd5Context is NULL, then return FALSE. =20 - @param[out] HmacMd5Context Pointer to HMAC-MD5 context being initializ= ed. + @param[out] HmacMd5Context Pointer to HMAC-MD5 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 - @retval TRUE HMAC-MD5 context initialization succeeded. - @retval FALSE HMAC-MD5 context initialization failed. + @retval TRUE Key is set successfully. + @retval FALSE Key is set unsuccessfully. =20 **/ BOOLEAN EFIAPI -HmacMd5Init ( +HmacMd5SetKey ( OUT VOID *HmacMd5Context, IN CONST UINT8 *Key, IN UINTN KeySize @@ -106,13 +106,6 @@ HmacMd5Init ( return FALSE; } =20 - // - // OpenSSL HMAC-MD5 Context Initialization - // - memset(HmacMd5Context, 0, HMAC_MD5_CTX_SIZE); - if (HMAC_CTX_reset ((HMAC_CTX *)HmacMd5Context) !=3D 1) { - return FALSE; - } if (HMAC_Init_ex ((HMAC_CTX *)HmacMd5Context, Key, (UINT32) KeySize, EVP= _md5(), NULL) !=3D 1) { return FALSE; } @@ -159,8 +152,8 @@ HmacMd5Duplicate ( =20 This function performs HMAC-MD5 digest on a data buffer of the specified= size. It can be called multiple times to compute the digest of long or discont= inuous data streams. - HMAC-MD5 context should be already correctly initialized by HmacMd5Init(= ), and should not be - finalized by HmacMd5Final(). Behavior with invalid context is undefined. + HMAC-MD5 context should be initialized by HmacMd5New(), and should not b= e finalized by + HmacMd5Final(). Behavior with invalid context is undefined. =20 If HmacMd5Context is NULL, then return FALSE. =20 @@ -210,8 +203,8 @@ HmacMd5Update ( This function completes HMAC-MD5 digest computation and retrieves the di= gest value into the specified memory. After this function has been called, the HMAC-MD5 = context cannot be used again. - HMAC-MD5 context should be already correctly initialized by HmacMd5Init(= ), and should not be - finalized by HmacMd5Final(). Behavior with invalid HMAC-MD5 context is u= ndefined. + HMAC-MD5 context should be initialized by HmacMd5New(), and should not b= e finalized by + HmacMd5Final(). Behavior with invalid HMAC-MD5 context is undefined. =20 If HmacMd5Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c b/Crypt= oPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c index 3aafed874b..b77a2266db 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c @@ -65,12 +65,12 @@ HmacMd5Free ( } =20 /** - Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 c= ontext for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacMd5Update(). =20 Return FALSE to indicate this interface is not supported. =20 - @param[out] HmacMd5Context Pointer to HMAC-MD5 context being initializ= ed. + @param[out] HmacMd5Context Pointer to HMAC-MD5 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 @@ -79,7 +79,7 @@ HmacMd5Free ( **/ BOOLEAN EFIAPI -HmacMd5Init ( +HmacMd5SetKey ( OUT VOID *HmacMd5Context, IN CONST UINT8 *Key, IN UINTN KeySize diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c b/CryptoPk= g/Library/BaseCryptLib/Hmac/CryptHmacSha1.c index 7d7df9640e..8126fb525f 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c @@ -79,22 +79,22 @@ HmacSha1Free ( } =20 /** - Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1= context for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacSha1Update(). =20 If HmacSha1Context is NULL, then return FALSE. =20 - @param[out] HmacSha1Context Pointer to HMAC-SHA1 context being initial= ized. + @param[out] HmacSha1Context Pointer to HMAC-SHA1 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 - @retval TRUE HMAC-SHA1 context initialization succeeded. - @retval FALSE HMAC-SHA1 context initialization failed. + @retval TRUE The Key is set successfully. + @retval FALSE The Key is set unsuccessfully. =20 **/ BOOLEAN EFIAPI -HmacSha1Init ( +HmacSha1SetKey ( OUT VOID *HmacSha1Context, IN CONST UINT8 *Key, IN UINTN KeySize @@ -107,13 +107,6 @@ HmacSha1Init ( return FALSE; } =20 - // - // OpenSSL HMAC-SHA1 Context Initialization - // - memset(HmacSha1Context, 0, HMAC_SHA1_CTX_SIZE); - if (HMAC_CTX_reset ((HMAC_CTX *)HmacSha1Context) !=3D 1) { - return FALSE; - } if (HMAC_Init_ex ((HMAC_CTX *)HmacSha1Context, Key, (UINT32) KeySize, EV= P_sha1(), NULL) !=3D 1) { return FALSE; } @@ -160,8 +153,8 @@ HmacSha1Duplicate ( =20 This function performs HMAC-SHA1 digest on a data buffer of the specifie= d size. It can be called multiple times to compute the digest of long or discont= inuous data streams. - HMAC-SHA1 context should be already correctly initialized by HmacSha1Ini= t(), and should not - be finalized by HmacSha1Final(). Behavior with invalid context is undefi= ned. + HMAC-SHA1 context should be initialized by HmacSha1New(), and should not= be finalized by + HmacSha1Final(). Behavior with invalid context is undefined. =20 If HmacSha1Context is NULL, then return FALSE. =20 @@ -211,8 +204,8 @@ HmacSha1Update ( This function completes HMAC-SHA1 digest computation and retrieves the d= igest value into the specified memory. After this function has been called, the HMAC-SHA1= context cannot be used again. - HMAC-SHA1 context should be already correctly initialized by HmacSha1Ini= t(), and should - not be finalized by HmacSha1Final(). Behavior with invalid HMAC-SHA1 con= text is undefined. + HMAC-SHA1 context should be initialized by HmacSha1New(), and should not= be finalized by + HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined. =20 If HmacSha1Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c b/Cryp= toPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c index 547aa484ea..84f204a542 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c @@ -65,12 +65,12 @@ HmacSha1Free ( } =20 /** - Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1= context for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacSha1Update(). =20 Return FALSE to indicate this interface is not supported. =20 - @param[out] HmacSha1Context Pointer to HMAC-SHA1 context being initial= ized. + @param[out] HmacSha1Context Pointer to HMAC-SHA1 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 @@ -79,7 +79,7 @@ HmacSha1Free ( **/ BOOLEAN EFIAPI -HmacSha1Init ( +HmacSha1SetKey ( OUT VOID *HmacSha1Context, IN CONST UINT8 *Key, IN UINTN KeySize diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c b/Crypto= Pkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c index f24443e745..f8fd0b172a 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256.c @@ -78,22 +78,22 @@ HmacSha256Free ( } =20 /** - Initializes user-supplied memory pointed by HmacSha256Context as HMAC-SH= A256 context for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacSha256Update(). =20 If HmacSha256Context is NULL, then return FALSE. =20 - @param[out] HmacSha256Context Pointer to HMAC-SHA256 context being ini= tialized. + @param[out] HmacSha256Context Pointer to HMAC-SHA256 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 - @retval TRUE HMAC-SHA256 context initialization succeeded. - @retval FALSE HMAC-SHA256 context initialization failed. + @retval TRUE The Key is set successfully. + @retval FALSE The Key is set unsuccessfully. =20 **/ BOOLEAN EFIAPI -HmacSha256Init ( +HmacSha256SetKey ( OUT VOID *HmacSha256Context, IN CONST UINT8 *Key, IN UINTN KeySize @@ -106,13 +106,6 @@ HmacSha256Init ( return FALSE; } =20 - // - // OpenSSL HMAC-SHA256 Context Initialization - // - memset(HmacSha256Context, 0, HMAC_SHA256_CTX_SIZE); - if (HMAC_CTX_reset ((HMAC_CTX *)HmacSha256Context) !=3D 1) { - return FALSE; - } if (HMAC_Init_ex ((HMAC_CTX *)HmacSha256Context, Key, (UINT32) KeySize, = EVP_sha256(), NULL) !=3D 1) { return FALSE; } @@ -159,8 +152,8 @@ HmacSha256Duplicate ( =20 This function performs HMAC-SHA256 digest on a data buffer of the specif= ied size. It can be called multiple times to compute the digest of long or discont= inuous data streams. - HMAC-SHA256 context should be already correctly initialized by HmacSha25= 6Init(), and should not - be finalized by HmacSha256Final(). Behavior with invalid context is unde= fined. + HMAC-SHA256 context should be initialized by HmacSha256New(), and should= not be finalized + by HmacSha256Final(). Behavior with invalid context is undefined. =20 If HmacSha256Context is NULL, then return FALSE. =20 @@ -210,8 +203,8 @@ HmacSha256Update ( This function completes HMAC-SHA256 hash computation and retrieves the d= igest value into the specified memory. After this function has been called, the HMAC-SHA2= 56 context cannot be used again. - HMAC-SHA256 context should be already correctly initialized by HmacSha25= 6Init(), and should - not be finalized by HmacSha256Final(). Behavior with invalid HMAC-SHA256= context is undefined. + HMAC-SHA256 context should be initialized by HmacSha256New(), and should= not be finalized + by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undef= ined. =20 If HmacSha256Context is NULL, then return FALSE. If HmacValue is NULL, then return FALSE. diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c b/Cr= yptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c index f0a4420e27..cededebaa0 100644 --- a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c +++ b/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c @@ -65,12 +65,12 @@ HmacSha256Free ( } =20 /** - Initializes user-supplied memory pointed by HmacSha256Context as HMAC-SH= A256 context for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacSha256Update(). =20 Return FALSE to indicate this interface is not supported. =20 - @param[out] HmacSha256Context Pointer to HMAC-SHA256 context being ini= tialized. + @param[out] HmacSha256Context Pointer to HMAC-SHA256 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 @@ -79,7 +79,7 @@ HmacSha256Free ( **/ BOOLEAN EFIAPI -HmacSha256Init ( +HmacSha256SetKey ( OUT VOID *HmacSha256Context, IN CONST UINT8 *Key, IN UINTN KeySize diff --git a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c b/C= ryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c index 3aafed874b..b77a2266db 100644 --- a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c +++ b/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c @@ -65,12 +65,12 @@ HmacMd5Free ( } =20 /** - Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 c= ontext for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacMd5Update(). =20 Return FALSE to indicate this interface is not supported. =20 - @param[out] HmacMd5Context Pointer to HMAC-MD5 context being initializ= ed. + @param[out] HmacMd5Context Pointer to HMAC-MD5 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 @@ -79,7 +79,7 @@ HmacMd5Free ( **/ BOOLEAN EFIAPI -HmacMd5Init ( +HmacMd5SetKey ( OUT VOID *HmacMd5Context, IN CONST UINT8 *Key, IN UINTN KeySize diff --git a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c b/= CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c index 547aa484ea..84f204a542 100644 --- a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c +++ b/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c @@ -65,12 +65,12 @@ HmacSha1Free ( } =20 /** - Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1= context for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacSha1Update(). =20 Return FALSE to indicate this interface is not supported. =20 - @param[out] HmacSha1Context Pointer to HMAC-SHA1 context being initial= ized. + @param[out] HmacSha1Context Pointer to HMAC-SHA1 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 @@ -79,7 +79,7 @@ HmacSha1Free ( **/ BOOLEAN EFIAPI -HmacSha1Init ( +HmacSha1SetKey ( OUT VOID *HmacSha1Context, IN CONST UINT8 *Key, IN UINTN KeySize diff --git a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c = b/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c index f0a4420e27..cededebaa0 100644 --- a/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c +++ b/CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha256Null.c @@ -65,12 +65,12 @@ HmacSha256Free ( } =20 /** - Initializes user-supplied memory pointed by HmacSha256Context as HMAC-SH= A256 context for - subsequent use. + Set user-supplied key for subsequent use. It must be done before any + calling to HmacSha256Update(). =20 Return FALSE to indicate this interface is not supported. =20 - @param[out] HmacSha256Context Pointer to HMAC-SHA256 context being ini= tialized. + @param[out] HmacSha256Context Pointer to HMAC-SHA256 context. @param[in] Key Pointer to the user-supplied key. @param[in] KeySize Key size in bytes. =20 @@ -79,7 +79,7 @@ HmacSha256Free ( **/ BOOLEAN EFIAPI -HmacSha256Init ( +HmacSha256SetKey ( OUT VOID *HmacSha256Context, IN CONST UINT8 *Key, IN UINTN KeySize --=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 (#53300): https://edk2.groups.io/g/devel/message/53300 Mute This Topic: https://groups.io/mt/69742159/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- From nobody Sun Apr 28 15:27:03 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+53301+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+53301+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1579155009; cv=none; d=zohomail.com; s=zohoarc; b=RxbF7RHaDeISFZH/p35vZFRtGWTDVekH3cNP7IYqPCb+8TVZIQXob9rd3PiewKB3xwJhcmeI3wY93iKIZk3fYpoME6wbe7nfGolMHTrhczu7GGwL0xTauDx1VjPM+dwBX4M6z8AYOa7pZV484CizFs/7hKZQSR12iywDzm+zszg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579155009; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=S8wDkWh2DkpE+gnkfomKntPHGI6lLvQNeJ96cgmTSTs=; b=ZbpRPnzF4EHL9XV8BCFVIZRzSPCN6tBxZQZPkH8kdcHT9NSBWZvp090PLThTrDbVvNoVGurdBxiXWmEFjqpEAFlMtLKM2l0QDMv0DhRTF132gXmsCpfdtx5ASOVfdkPp7PZOFoVghqgI0AwLRI5vms8EHAaX5fvUZw1j4KuIT6w= 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+53301+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 1579155009500175.8228539832404; Wed, 15 Jan 2020 22:10:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id RdthYY1788612x59NFV49G7S; Wed, 15 Jan 2020 22:10:09 -0800 X-Received: from mga02.intel.com (mga02.intel.com []) by mx.groups.io with SMTP id smtpd.web10.5215.1579155007460985160 for ; Wed, 15 Jan 2020 22:10:08 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2020 22:10:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,325,1574150400"; d="scan'208";a="219537663" X-Received: from unknown (HELO shwdeopensfp777.ccr.corp.intel.com) ([10.239.158.78]) by fmsmga007.fm.intel.com with ESMTP; 15 Jan 2020 22:10:06 -0800 From: "Wang, Jian J" To: devel@edk2.groups.io Cc: Xiaoyu Lu , Laszlo Ersek Subject: [edk2-devel] [PATCH v3 2/2] CryptoPkg/BaseCryptLib: remove HmacXxxGetContextSize interface Date: Thu, 16 Jan 2020 14:10:03 +0800 Message-Id: <20200116061004.636-3-jian.j.wang@intel.com> In-Reply-To: <20200116061004.636-1-jian.j.wang@intel.com> References: <20200116061004.636-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: FOFrAqV9FXVlHfF0kOYsUaNtx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1579155009; bh=CrAWrdbhe8eER7En4ydv+3y3vVtoiDW/2L9jH21NvoY=; h=Cc:Date:From:Reply-To:Subject:To; b=Ai+bafwFjl3STlEzXljqGtFlCy4EkYMzTH8o2QQ9RG/CiKNlUcaVXzsv4J3oDrvlgK1 h4/E/zCrs/6snJGHmZBVG1/XT2G5vD6dy0VlZPK0Q3ATrvT/94r25fQW//6nChzdanhei /KDteNkqUGkZaoM2M+SJ9+jAO8pQc8yF9bw= 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. Cc: Xiaoyu Lu Cc: Laszlo Ersek Signed-off-by: Jian J Wang Reviewed-by: Laszlo Ersek --- CryptoPkg/Include/Library/BaseCryptLib.h | 17 ---------- .../Library/BaseCryptLib/Hmac/CryptHmacMd5.c | 31 ------------------ .../BaseCryptLib/Hmac/CryptHmacMd5Null.c | 20 ------------ .../Library/BaseCryptLib/Hmac/CryptHmacSha1.c | 32 ------------------- .../BaseCryptLib/Hmac/CryptHmacSha1Null.c | 20 ------------ .../BaseCryptLib/Hmac/CryptHmacSha256.c | 31 ------------------ .../BaseCryptLib/Hmac/CryptHmacSha256Null.c | 20 ------------ .../BaseCryptLibNull/Hmac/CryptHmacMd5Null.c | 20 ------------ .../BaseCryptLibNull/Hmac/CryptHmacSha1Null.c | 20 ------------ .../Hmac/CryptHmacSha256Null.c | 20 ------------ 10 files changed, 231 deletions(-) diff --git a/CryptoPkg/Include/Library/BaseCryptLib.h b/CryptoPkg/Include/L= ibrary/BaseCryptLib.h index c5803ea673..09fed8b041 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 diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c b/CryptoPkg= /Library/BaseCryptLib/Hmac/CryptHmacMd5.c index 7d49dc2698..6775e93ca5 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 diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c b/Crypt= oPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c index b77a2266db..9da132eeee 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 8126fb525f..27d0004a3a 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 diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c b/Cryp= toPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c index 84f204a542..2c26e9d514 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 f8fd0b172a..4271eaa27e 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 diff --git a/CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c b/Cr= yptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha256Null.c index cededebaa0..1af625ec9f 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 b77a2266db..9da132eeee 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 84f204a542..2c26e9d514 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 cededebaa0..1af625ec9f 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 (#53301): https://edk2.groups.io/g/devel/message/53301 Mute This Topic: https://groups.io/mt/69742160/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-