From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id DE2DE740057 for ; Thu, 28 Sep 2023 15:34:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=CLmz+KElIrzVqza4Ge6fcW61+j1oNc/vM1a1mXtcX+U=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1695915270; v=1; b=uP4AaRJYPjge7K1jI3sVpuSZhwlUwPQn5fWmMX6hrDL7oz4qawMVU7DISrT7EhhxBkzWmh+I RPu0b+RQS+y+lApoRXG5LCejhOoN8T5wqaETV2DOcQTVBQMcvdpWOLBOqRkiT/WV7z99dmr2jRw OBPbU8dOlqf/ZskuCWl+nvkc= X-Received: by 127.0.0.2 with SMTP id qyuaYY7687511xA6uKFEkaQA; Thu, 28 Sep 2023 08:34:30 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web10.16607.1695915264250602914 for ; Thu, 28 Sep 2023 08:34:30 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="703970" X-IronPort-AV: E=Sophos;i="6.03,184,1694761200"; d="scan'208";a="703970" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2023 08:34:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10847"; a="778943240" X-IronPort-AV: E=Sophos;i="6.03,184,1694761200"; d="scan'208";a="778943240" X-Received: from shwdejointd777.ccr.corp.intel.com ([10.239.58.116]) by orsmga008.jf.intel.com with ESMTP; 28 Sep 2023 08:34:28 -0700 From: "Wenxing Hou" To: devel@edk2.groups.io Cc: Jiewen Yao , Yi Li , Xiaoyu Lu , Guomin Jiang Subject: [edk2-devel] [PATCH v3 03/11] CryptoPkg: Add HMAC functions based on Mbedtls Date: Thu, 28 Sep 2023 23:34:08 +0800 Message-Id: <20230928153416.537-4-wenxing.hou@intel.com> In-Reply-To: <20230928153416.537-1-wenxing.hou@intel.com> References: <20230928153416.537-1-wenxing.hou@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: 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,wenxing.hou@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: N4uDaOL4kwnI4Ho32oWX15a8x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=uP4AaRJY; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Add HMAC APIS. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4177 Cc: Jiewen Yao Cc: Yi Li Cc: Xiaoyu Lu Cc: Guomin Jiang Signed-off-by: Wenxing Hou --- .../BaseCryptLibMbedTls/Hmac/CryptHmac.c | 678 ++++++++++++++++++ .../BaseCryptLibMbedTls/Hmac/CryptHmacNull.c | 359 ++++++++++ .../UnitTest/Library/BaseCryptLib/HmacTests.c | 60 +- 3 files changed, 1084 insertions(+), 13 deletions(-) create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmac.c create mode 100644 CryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmacNul= l.c diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmac.c b/Crypt= oPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmac.c new file mode 100644 index 0000000000..c4cda57b4d --- /dev/null +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmac.c @@ -0,0 +1,678 @@ +/** @file=0D + HMAC-SHA256 Wrapper Implementation over MbedTLS.=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include "InternalCryptLib.h"=0D +#include =0D +=0D +/**=0D + Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD us= e.=0D +=0D + @return Pointer to the HMAC_CTX context that has been initialized.=0D + If the allocations fails, HmacShaMdNew() returns NULL.=0D +=0D +**/=0D +STATIC=0D +VOID *=0D +HmacMdNew (=0D + VOID=0D + )=0D +{=0D + VOID *HmacMdCtx;=0D +=0D + HmacMdCtx =3D AllocateZeroPool (sizeof (mbedtls_md_context_t));=0D + if (HmacMdCtx =3D=3D NULL) {=0D + return NULL;=0D + }=0D +=0D + return HmacMdCtx;=0D +}=0D +=0D +/**=0D + Release the specified HMAC_CTX context.=0D +=0D + @param[in] HmacMdCtx Pointer to the HMAC_CTX context to be released.=0D +=0D +**/=0D +VOID=0D +HmacMdFree (=0D + IN VOID *HmacMdCtx=0D + )=0D +{=0D + mbedtls_md_free (HmacMdCtx);=0D + if (HmacMdCtx !=3D NULL) {=0D + FreePool (HmacMdCtx);=0D + }=0D +}=0D +=0D +/**=0D + Set user-supplied key for subsequent use. It must be done before any=0D + calling to HmacMdUpdate().=0D +=0D + If HmacMdContext is NULL, then return FALSE.=0D +=0D + @param[in] MdType Message Digest Type.=0D + @param[out] HmacMdContext Pointer to HMAC-MD context.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D +=0D + @retval TRUE The Key is set successfully.=0D + @retval FALSE The Key is set unsuccessfully.=0D +=0D +**/=0D +STATIC=0D +BOOLEAN=0D +HmacMdSetKey (=0D + IN mbedtls_md_type_t MdType,=0D + OUT VOID *HmacMdContext,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize=0D + )=0D +{=0D + const mbedtls_md_info_t *md_info;=0D + INT32 Ret;=0D +=0D + if ((HmacMdContext =3D=3D NULL) || (KeySize > INT_MAX)) {=0D + return FALSE;=0D + }=0D +=0D + ZeroMem (HmacMdContext, sizeof (mbedtls_md_context_t));=0D + mbedtls_md_init (HmacMdContext);=0D +=0D + md_info =3D mbedtls_md_info_from_type (MdType);=0D + ASSERT (md_info !=3D NULL);=0D +=0D + Ret =3D mbedtls_md_setup (HmacMdContext, md_info, 1);=0D + if (Ret !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + Ret =3D mbedtls_md_hmac_starts (HmacMdContext, Key, KeySize);=0D + if (Ret !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + return TRUE;=0D +}=0D +=0D +/**=0D + Return block size in md_type.=0D +=0D + @param[in] MdType message digest Type.=0D +=0D + @retval blocksize in md_type.=0D +=0D +**/=0D +int=0D +HmacMdGetBlockSize (=0D + mbedtls_md_type_t MdType=0D + )=0D +{=0D + switch (MdType) {=0D + case MBEDTLS_MD_SHA256:=0D + return 64;=0D + case MBEDTLS_MD_SHA384:=0D + return 128;=0D + default:=0D + ASSERT (FALSE);=0D + return 0;=0D + }=0D +}=0D +=0D +/**=0D + Makes a copy of an existing HMAC-MD context.=0D +=0D + If HmacMdContext is NULL, then return FALSE.=0D + If NewHmacMdContext is NULL, then return FALSE.=0D +=0D + @param[in] MdType message digest Type.=0D + @param[in] HmacMdContext Pointer to HMAC-MD context being copied.=0D + @param[out] NewHmacMdContext Pointer to new HMAC-MD context.=0D +=0D + @retval TRUE HMAC-MD context copy succeeded.=0D + @retval FALSE HMAC-MD context copy failed.=0D +=0D +**/=0D +STATIC=0D +BOOLEAN=0D +HmacMdDuplicate (=0D + IN CONST mbedtls_md_type_t MdType,=0D + IN CONST VOID *HmacMdContext,=0D + OUT VOID *NewHmacMdContext=0D + )=0D +{=0D + INT32 Ret;=0D + CONST mbedtls_md_info_t *md_info;=0D + mbedtls_md_context_t *MdContext;=0D +=0D + if ((HmacMdContext =3D=3D NULL) || (NewHmacMdContext =3D=3D NULL)) {=0D + return FALSE;=0D + }=0D +=0D + ZeroMem (NewHmacMdContext, sizeof (mbedtls_md_context_t));=0D + mbedtls_md_init (NewHmacMdContext);=0D + md_info =3D mbedtls_md_info_from_type (MdType);=0D + ASSERT (md_info !=3D NULL);=0D +=0D + Ret =3D mbedtls_md_setup (NewHmacMdContext, md_info, 1);=0D + if (Ret !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + MdContext =3D (mbedtls_md_context_t *)NewHmacMdContext;=0D +=0D + Ret =3D mbedtls_md_clone (NewHmacMdContext, HmacMdContext);=0D + if (Ret !=3D 0) {=0D + if (MdContext->md_ctx !=3D NULL) {=0D + mbedtls_free (MdContext->md_ctx);=0D + }=0D +=0D + if (MdContext->hmac_ctx !=3D NULL) {=0D + mbedtls_free (MdContext->hmac_ctx);=0D + }=0D +=0D + return FALSE;=0D + }=0D +=0D + CopyMem (=0D + ((mbedtls_md_context_t *)NewHmacMdContext)->hmac_ctx,=0D + ((CONST mbedtls_md_context_t *)HmacMdContext)->hmac_ctx,=0D + HmacMdGetBlockSize (MdType) * 2=0D + );=0D +=0D + return TRUE;=0D +}=0D +=0D +/**=0D + Digests the input data and updates HMAC-MD context.=0D +=0D + This function performs HMAC-MD digest on a data buffer of the specified = size.=0D + It can be called multiple times to compute the digest of long or discont= inuous data streams.=0D + HMAC-MD context should be initialized by HmacMdNew(), and should not be = finalized=0D + by HmacMdFinal(). Behavior with invalid context is undefined.=0D +=0D + If HmacMdContext is NULL, then return FALSE.=0D +=0D + @param[in, out] HmacMdContext Pointer to the HMAC-MD context.=0D + @param[in] Data Pointer to the buffer containing the = data to be digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D +=0D + @retval TRUE HMAC-MD data digest succeeded.=0D + @retval FALSE HMAC-MD data digest failed.=0D +=0D +**/=0D +STATIC=0D +BOOLEAN=0D +HmacMdUpdate (=0D + IN OUT VOID *HmacMdContext,=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize=0D + )=0D +{=0D + INT32 Ret;=0D +=0D + if (HmacMdContext =3D=3D NULL) {=0D + return FALSE;=0D + }=0D +=0D + if ((Data =3D=3D NULL) && (DataSize !=3D 0)) {=0D + return FALSE;=0D + }=0D +=0D + if (DataSize > INT_MAX) {=0D + return FALSE;=0D + }=0D +=0D + Ret =3D mbedtls_md_hmac_update (HmacMdContext, Data, DataSize);=0D + if (Ret !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + return TRUE;=0D +}=0D +=0D +/**=0D + Completes computation of the HMAC-MD digest value.=0D +=0D + This function completes HMAC-MD hash computation and retrieves the diges= t value into=0D + the specified memory. After this function has been called, the HMAC-MD c= ontext cannot=0D + be used again.=0D + HMAC-MD context should be initialized by HmacMdNew(), and should not be = finalized=0D + by HmacMdFinal(). Behavior with invalid HMAC-MD context is undefined.=0D +=0D + If HmacMdContext is NULL, then return FALSE.=0D + If HmacValue is NULL, then return FALSE.=0D +=0D + @param[in, out] HmacMdContext Pointer to the HMAC-MD context.=0D + @param[out] HmacValue Pointer to a buffer that receives th= e HMAC-MD digest=0D + value.=0D +=0D + @retval TRUE HMAC-MD digest computation succeeded.=0D + @retval FALSE HMAC-MD digest computation failed.=0D +=0D +**/=0D +STATIC=0D +BOOLEAN=0D +HmacMdFinal (=0D + IN OUT VOID *HmacMdContext,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + INT32 Ret;=0D +=0D + if ((HmacMdContext =3D=3D NULL) || (HmacValue =3D=3D NULL)) {=0D + return FALSE;=0D + }=0D +=0D + Ret =3D mbedtls_md_hmac_finish (HmacMdContext, HmacValue);=0D + if (Ret !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + Ret =3D mbedtls_md_hmac_reset (HmacMdContext);=0D + if (Ret !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + return TRUE;=0D +}=0D +=0D +/**=0D + Computes the HMAC-MD digest of a input data buffer.=0D +=0D + This function performs the HMAC-MD digest of a given data buffer, and pl= aces=0D + the digest value into the specified memory.=0D +=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in] MdType Message Digest Type.=0D + @param[in] Data Pointer to the buffer containing the data to be= digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D + @param[out] HmacValue Pointer to a buffer that receives the HMAC-MD d= igest=0D + value.=0D +=0D + @retval TRUE HMAC-MD digest computation succeeded.=0D + @retval FALSE HMAC-MD digest computation failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +STATIC=0D +BOOLEAN=0D +HmacMdAll (=0D + IN mbedtls_md_type_t MdType,=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + const mbedtls_md_info_t *md_info;=0D + INT32 Ret;=0D +=0D + md_info =3D mbedtls_md_info_from_type (MdType);=0D + ASSERT (md_info !=3D NULL);=0D +=0D + Ret =3D mbedtls_md_hmac (md_info, Key, KeySize, Data, DataSize, HmacValu= e);=0D + if (Ret !=3D 0) {=0D + return FALSE;=0D + }=0D +=0D + return TRUE;=0D +}=0D +=0D +/**=0D + Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA25= 6 use.=0D +=0D + @return Pointer to the HMAC_CTX context that has been initialized.=0D + If the allocations fails, HmacSha256New() returns NULL.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +HmacSha256New (=0D + VOID=0D + )=0D +{=0D + return HmacMdNew ();=0D +}=0D +=0D +/**=0D + Release the specified HMAC_CTX context.=0D +=0D + @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be release= d.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +HmacSha256Free (=0D + IN VOID *HmacSha256Ctx=0D + )=0D +{=0D + HmacMdFree (HmacSha256Ctx);=0D +}=0D +=0D +/**=0D + Set user-supplied key for subsequent use. It must be done before any=0D + calling to HmacSha256Update().=0D +=0D + If HmacSha256Context is NULL, then return FALSE.=0D +=0D + @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D +=0D + @retval TRUE The Key is set successfully.=0D + @retval FALSE The Key is set unsuccessfully.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256SetKey (=0D + OUT VOID *HmacSha256Context,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize=0D + )=0D +{=0D + return HmacMdSetKey (MBEDTLS_MD_SHA256, HmacSha256Context, Key, KeySize)= ;=0D +}=0D +=0D +/**=0D + Makes a copy of an existing HMAC-SHA256 context.=0D +=0D + If HmacSha256Context is NULL, then return FALSE.=0D + If NewHmacSha256Context is NULL, then return FALSE.=0D +=0D + @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being c= opied.=0D + @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.=0D +=0D + @retval TRUE HMAC-SHA256 context copy succeeded.=0D + @retval FALSE HMAC-SHA256 context copy failed.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256Duplicate (=0D + IN CONST VOID *HmacSha256Context,=0D + OUT VOID *NewHmacSha256Context=0D + )=0D +{=0D + return HmacMdDuplicate (MBEDTLS_MD_SHA256, HmacSha256Context, NewHmacSha= 256Context);=0D +}=0D +=0D +/**=0D + Digests the input data and updates HMAC-SHA256 context.=0D +=0D + This function performs HMAC-SHA256 digest on a data buffer of the specif= ied size.=0D + It can be called multiple times to compute the digest of long or discont= inuous data streams.=0D + HMAC-SHA256 context should be initialized by HmacSha256New(), and should= not be finalized=0D + by HmacSha256Final(). Behavior with invalid context is undefined.=0D +=0D + If HmacSha256Context is NULL, then return FALSE.=0D +=0D + @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.=0D + @param[in] Data Pointer to the buffer containing the = data to be digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D +=0D + @retval TRUE HMAC-SHA256 data digest succeeded.=0D + @retval FALSE HMAC-SHA256 data digest failed.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256Update (=0D + IN OUT VOID *HmacSha256Context,=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize=0D + )=0D +{=0D + return HmacMdUpdate (HmacSha256Context, Data, DataSize);=0D +}=0D +=0D +/**=0D + Completes computation of the HMAC-SHA256 digest value.=0D +=0D + This function completes HMAC-SHA256 hash computation and retrieves the d= igest value into=0D + the specified memory. After this function has been called, the HMAC-SHA2= 56 context cannot=0D + be used again.=0D + HMAC-SHA256 context should be initialized by HmacSha256New(), and should= not be finalized=0D + by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undef= ined.=0D +=0D + If HmacSha256Context is NULL, then return FALSE.=0D + If HmacValue is NULL, then return FALSE.=0D +=0D + @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.= =0D + @param[out] HmacValue Pointer to a buffer that receives th= e HMAC-SHA256 digest=0D + value (32 bytes).=0D +=0D + @retval TRUE HMAC-SHA256 digest computation succeeded.=0D + @retval FALSE HMAC-SHA256 digest computation failed.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256Final (=0D + IN OUT VOID *HmacSha256Context,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + return HmacMdFinal (HmacSha256Context, HmacValue);=0D +}=0D +=0D +/**=0D + Computes the HMAC-SHA256 digest of a input data buffer.=0D +=0D + This function performs the HMAC-SHA256 digest of a given data buffer, an= d places=0D + the digest value into the specified memory.=0D +=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in] Data Pointer to the buffer containing the data to be= digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D + @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA2= 56 digest=0D + value (32 bytes).=0D +=0D + @retval TRUE HMAC-SHA256 digest computation succeeded.=0D + @retval FALSE HMAC-SHA256 digest computation failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256All (=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + return HmacMdAll (MBEDTLS_MD_SHA256, Data, DataSize, Key, KeySize, HmacV= alue);=0D +}=0D +=0D +/**=0D + Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA38= 4 use.=0D +=0D + @return Pointer to the HMAC_CTX context that has been initialized.=0D + If the allocations fails, HmacSha384New() returns NULL.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +HmacSha384New (=0D + VOID=0D + )=0D +{=0D + return HmacMdNew ();=0D +}=0D +=0D +/**=0D + Release the specified HMAC_CTX context.=0D +=0D + @param[in] HmacSha384Ctx Pointer to the HMAC_CTX context to be release= d.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +HmacSha384Free (=0D + IN VOID *HmacSha384Ctx=0D + )=0D +{=0D + HmacMdFree (HmacSha384Ctx);=0D +}=0D +=0D +/**=0D + Set user-supplied key for subsequent use. It must be done before any=0D + calling to HmacSha384Update().=0D +=0D + If HmacSha384Context is NULL, then return FALSE.=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[out] HmacSha384Context Pointer to HMAC-SHA384 context.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D +=0D + @retval TRUE The Key is set successfully.=0D + @retval FALSE The Key is set unsuccessfully.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384SetKey (=0D + OUT VOID *HmacSha384Context,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize=0D + )=0D +{=0D + return HmacMdSetKey (MBEDTLS_MD_SHA384, HmacSha384Context, Key, KeySize)= ;=0D +}=0D +=0D +/**=0D + Makes a copy of an existing HMAC-SHA384 context.=0D +=0D + If HmacSha384Context is NULL, then return FALSE.=0D + If NewHmacSha384Context is NULL, then return FALSE.=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in] HmacSha384Context Pointer to HMAC-SHA384 context being c= opied.=0D + @param[out] NewHmacSha384Context Pointer to new HMAC-SHA384 context.=0D +=0D + @retval TRUE HMAC-SHA384 context copy succeeded.=0D + @retval FALSE HMAC-SHA384 context copy failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384Duplicate (=0D + IN CONST VOID *HmacSha384Context,=0D + OUT VOID *NewHmacSha384Context=0D + )=0D +{=0D + return HmacMdDuplicate (MBEDTLS_MD_SHA384, HmacSha384Context, NewHmacSha= 384Context);=0D +}=0D +=0D +/**=0D + Digests the input data and updates HMAC-SHA384 context.=0D +=0D + This function performs HMAC-SHA384 digest on a data buffer of the specif= ied size.=0D + It can be called multiple times to compute the digest of long or discont= inuous data streams.=0D + HMAC-SHA384 context should be initialized by HmacSha384New(), and should= not be finalized=0D + by HmacSha384Final(). Behavior with invalid context is undefined.=0D +=0D + If HmacSha384Context is NULL, then return FALSE.=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.=0D + @param[in] Data Pointer to the buffer containing the = data to be digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D +=0D + @retval TRUE HMAC-SHA384 data digest succeeded.=0D + @retval FALSE HMAC-SHA384 data digest failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384Update (=0D + IN OUT VOID *HmacSha384Context,=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize=0D + )=0D +{=0D + return HmacMdUpdate (HmacSha384Context, Data, DataSize);=0D +}=0D +=0D +/**=0D + Completes computation of the HMAC-SHA384 digest value.=0D +=0D + This function completes HMAC-SHA384 hash computation and retrieves the d= igest value into=0D + the specified memory. After this function has been called, the HMAC-SHA3= 84 context cannot=0D + be used again.=0D + HMAC-SHA384 context should be initialized by HmacSha384New(), and should= not be finalized=0D + by HmacSha384Final(). Behavior with invalid HMAC-SHA384 context is undef= ined.=0D +=0D + If HmacSha384Context is NULL, then return FALSE.=0D + If HmacValue is NULL, then return FALSE.=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.= =0D + @param[out] HmacValue Pointer to a buffer that receives th= e HMAC-SHA384 digest=0D + value (48 bytes).=0D +=0D + @retval TRUE HMAC-SHA384 digest computation succeeded.=0D + @retval FALSE HMAC-SHA384 digest computation failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384Final (=0D + IN OUT VOID *HmacSha384Context,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + return HmacMdFinal (HmacSha384Context, HmacValue);=0D +}=0D +=0D +/**=0D + Computes the HMAC-SHA384 digest of a input data buffer.=0D +=0D + This function performs the HMAC-SHA384 digest of a given data buffer, an= d places=0D + the digest value into the specified memory.=0D +=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in] Data Pointer to the buffer containing the data to be= digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D + @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA3= 84 digest=0D + value (48 bytes).=0D +=0D + @retval TRUE HMAC-SHA384 digest computation succeeded.=0D + @retval FALSE HMAC-SHA384 digest computation failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384All (=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + return HmacMdAll (MBEDTLS_MD_SHA384, Data, DataSize, Key, KeySize, HmacV= alue);=0D +}=0D diff --git a/CryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmacNull.c b/C= ryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmacNull.c new file mode 100644 index 0000000000..37bf3ea486 --- /dev/null +++ b/CryptoPkg/Library/BaseCryptLibMbedTls/Hmac/CryptHmacNull.c @@ -0,0 +1,359 @@ +/** @file=0D + HMAC-SHA256/SHA384 Wrapper Implementation which does not provide real ca= pabilities.=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include "InternalCryptLib.h"=0D +=0D +/**=0D + Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA25= 6 use.=0D +=0D + Return NULL to indicate this interface is not supported.=0D +=0D + @return NULL This interface is not supported..=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +HmacSha256New (=0D + VOID=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return NULL;=0D +}=0D +=0D +/**=0D + Release the specified HMAC_CTX context.=0D +=0D + This function will do nothing.=0D +=0D + @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be release= d.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +HmacSha256Free (=0D + IN VOID *HmacSha256Ctx=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return;=0D +}=0D +=0D +/**=0D + Set user-supplied key for subsequent use. It must be done before any=0D + calling to HmacSha256Update().=0D +=0D + Return FALSE to indicate this interface is not supported.=0D +=0D + @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D +=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256SetKey (=0D + OUT VOID *HmacSha256Context,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Makes a copy of an existing HMAC-SHA256 context.=0D +=0D + Return FALSE to indicate this interface is not supported.=0D +=0D + @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being c= opied.=0D + @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.=0D +=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256Duplicate (=0D + IN CONST VOID *HmacSha256Context,=0D + OUT VOID *NewHmacSha256Context=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Digests the input data and updates HMAC-SHA256 context.=0D +=0D + Return FALSE to indicate this interface is not supported.=0D +=0D + @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.=0D + @param[in] Data Pointer to the buffer containing the = data to be digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D +=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256Update (=0D + IN OUT VOID *HmacSha256Context,=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Completes computation of the HMAC-SHA256 digest value.=0D +=0D + Return FALSE to indicate this interface is not supported.=0D +=0D + @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.= =0D + @param[out] HmacValue Pointer to a buffer that receives th= e HMAC-SHA256 digest=0D + value (32 bytes).=0D +=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256Final (=0D + IN OUT VOID *HmacSha256Context,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Computes the HMAC-SHA256 digest of a input data buffer.=0D +=0D + This function performs the HMAC-SHA256 digest of a given data buffer, an= d places=0D + the digest value into the specified memory.=0D +=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in] Data Pointer to the buffer containing the data to be= digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D + @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA2= 56 digest=0D + value (32 bytes).=0D +=0D + @retval TRUE HMAC-SHA256 digest computation succeeded.=0D + @retval FALSE HMAC-SHA256 digest computation failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha256All (=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA38= 4 use.=0D +=0D + @return Pointer to the HMAC_CTX context that has been initialized.=0D + If the allocations fails, HmacSha384New() returns NULL.=0D +=0D +**/=0D +VOID *=0D +EFIAPI=0D +HmacSha384New (=0D + VOID=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return NULL;=0D +}=0D +=0D +/**=0D + Release the specified HMAC_CTX context.=0D +=0D + @param[in] HmacSha384Ctx Pointer to the HMAC_CTX context to be release= d.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +HmacSha384Free (=0D + IN VOID *HmacSha384Ctx=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return;=0D +}=0D +=0D +/**=0D + Set user-supplied key for subsequent use. It must be done before any=0D + calling to HmacSha384Update().=0D +=0D + If HmacSha384Context is NULL, then return FALSE.=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[out] HmacSha384Context Pointer to HMAC-SHA384 context.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D +=0D + @retval TRUE The Key is set successfully.=0D + @retval FALSE The Key is set unsuccessfully.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384SetKey (=0D + OUT VOID *HmacSha384Context,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Makes a copy of an existing HMAC-SHA384 context.=0D +=0D + If HmacSha384Context is NULL, then return FALSE.=0D + If NewHmacSha384Context is NULL, then return FALSE.=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in] HmacSha384Context Pointer to HMAC-SHA384 context being c= opied.=0D + @param[out] NewHmacSha384Context Pointer to new HMAC-SHA384 context.=0D +=0D + @retval TRUE HMAC-SHA384 context copy succeeded.=0D + @retval FALSE HMAC-SHA384 context copy failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384Duplicate (=0D + IN CONST VOID *HmacSha384Context,=0D + OUT VOID *NewHmacSha384Context=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Digests the input data and updates HMAC-SHA384 context.=0D +=0D + This function performs HMAC-SHA384 digest on a data buffer of the specif= ied size.=0D + It can be called multiple times to compute the digest of long or discont= inuous data streams.=0D + HMAC-SHA384 context should be initialized by HmacSha384New(), and should= not be finalized=0D + by HmacSha384Final(). Behavior with invalid context is undefined.=0D +=0D + If HmacSha384Context is NULL, then return FALSE.=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.=0D + @param[in] Data Pointer to the buffer containing the = data to be digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D +=0D + @retval TRUE HMAC-SHA384 data digest succeeded.=0D + @retval FALSE HMAC-SHA384 data digest failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384Update (=0D + IN OUT VOID *HmacSha384Context,=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Completes computation of the HMAC-SHA384 digest value.=0D +=0D + This function completes HMAC-SHA384 hash computation and retrieves the d= igest value into=0D + the specified memory. After this function has been called, the HMAC-SHA3= 84 context cannot=0D + be used again.=0D + HMAC-SHA384 context should be initialized by HmacSha384New(), and should= not be finalized=0D + by HmacSha384Final(). Behavior with invalid HMAC-SHA384 context is undef= ined.=0D +=0D + If HmacSha384Context is NULL, then return FALSE.=0D + If HmacValue is NULL, then return FALSE.=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.= =0D + @param[out] HmacValue Pointer to a buffer that receives th= e HMAC-SHA384 digest=0D + value (48 bytes).=0D +=0D + @retval TRUE HMAC-SHA384 digest computation succeeded.=0D + @retval FALSE HMAC-SHA384 digest computation failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384Final (=0D + IN OUT VOID *HmacSha384Context,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Computes the HMAC-SHA384 digest of a input data buffer.=0D +=0D + This function performs the HMAC-SHA384 digest of a given data buffer, an= d places=0D + the digest value into the specified memory.=0D +=0D + If this interface is not supported, then return FALSE.=0D +=0D + @param[in] Data Pointer to the buffer containing the data to be= digested.=0D + @param[in] DataSize Size of Data buffer in bytes.=0D + @param[in] Key Pointer to the user-supplied key.=0D + @param[in] KeySize Key size in bytes.=0D + @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA3= 84 digest=0D + value (48 bytes).=0D +=0D + @retval TRUE HMAC-SHA384 digest computation succeeded.=0D + @retval FALSE HMAC-SHA384 digest computation failed.=0D + @retval FALSE This interface is not supported.=0D +=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +HmacSha384All (=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize,=0D + OUT UINT8 *HmacValue=0D + )=0D +{=0D + ASSERT (FALSE);=0D + return FALSE;=0D +}=0D diff --git a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c b/Cry= ptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c index b347cb4cb4..c0d15b34ff 100644 --- a/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c +++ b/CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c @@ -82,19 +82,19 @@ GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 HmacSha384Di= gest[] =3D { };=0D =0D typedef=0D -VOID *=0D + VOID *=0D (EFIAPI *EFI_HMAC_NEW)(=0D VOID=0D );=0D =0D typedef=0D -VOID=0D + VOID=0D (EFIAPI *EFI_HMAC_FREE)(=0D IN VOID *HashContext=0D );=0D =0D typedef=0D -BOOLEAN=0D + BOOLEAN=0D (EFIAPI *EFI_HMAC_INIT)(=0D IN OUT VOID *HashContext,=0D IN CONST UINT8 *Key,=0D @@ -102,7 +102,14 @@ BOOLEAN );=0D =0D typedef=0D -BOOLEAN=0D + BOOLEAN=0D +(EFIAPI *EFI_HMAC_DUP)(=0D + IN CONST VOID *HashContext,=0D + OUT VOID *NewHashContext=0D + );=0D +=0D +typedef=0D + BOOLEAN=0D (EFIAPI *EFI_HMAC_UPDATE)(=0D IN OUT VOID *HashContext,=0D IN CONST VOID *Data,=0D @@ -110,30 +117,39 @@ BOOLEAN );=0D =0D typedef=0D -BOOLEAN=0D + BOOLEAN=0D (EFIAPI *EFI_HMAC_FINAL)(=0D IN OUT VOID *HashContext,=0D OUT UINT8 *HashValue=0D );=0D =0D +typedef=0D + BOOLEAN=0D +(EFIAPI *EFI_HMAC_ALL)(=0D + IN CONST VOID *Data,=0D + IN UINTN DataSize,=0D + IN CONST UINT8 *Key,=0D + IN UINTN KeySize,=0D + OUT UINT8 *HashValue=0D + );=0D +=0D typedef struct {=0D UINT32 DigestSize;=0D EFI_HMAC_NEW HmacNew;=0D EFI_HMAC_FREE HmacFree;=0D EFI_HMAC_INIT HmacInit;=0D + EFI_HMAC_DUP HmacDup;=0D EFI_HMAC_UPDATE HmacUpdate;=0D EFI_HMAC_FINAL HmacFinal;=0D + EFI_HMAC_ALL HmacAll;=0D CONST UINT8 *Key;=0D UINTN KeySize;=0D CONST UINT8 *Digest;=0D VOID *HmacCtx;=0D } HMAC_TEST_CONTEXT;=0D =0D -// These functions have been deprecated but they've been left commented ou= t for future reference=0D -// HMAC_TEST_CONTEXT mHmacMd5TestCtx =3D {MD5_DIGEST_SIZE, Hma= cMd5New, HmacMd5Free, HmacMd5SetKey, HmacMd5Update, HmacMd5Final,= HmacMd5Key, sizeof(HmacMd5Key), HmacMd5Digest};=0D -// HMAC_TEST_CONTEXT mHmacSha1TestCtx =3D {SHA1_DIGEST_SIZE, Hma= cSha1New, HmacSha1Free, HmacSha1SetKey, HmacSha1Update, HmacSha1Final= , HmacSha1Key, sizeof(HmacSha1Key), HmacSha1Digest};=0D -HMAC_TEST_CONTEXT mHmacSha256TestCtx =3D { SHA256_DIGEST_SIZE, HmacSha256= New, HmacSha256Free, HmacSha256SetKey, HmacSha256Update, HmacSha256Final, H= macSha256Key, sizeof (HmacSha256Key), HmacSha256Digest };=0D -HMAC_TEST_CONTEXT mHmacSha384TestCtx =3D { SHA384_DIGEST_SIZE, HmacSha384= New, HmacSha384Free, HmacSha384SetKey, HmacSha384Update, HmacSha384Final, H= macSha384Key, sizeof (HmacSha384Key), HmacSha384Digest };=0D +HMAC_TEST_CONTEXT mHmacSha256TestCtx =3D { SHA256_DIGEST_SIZE, HmacSha256= New, HmacSha256Free, HmacSha256SetKey, HmacSha256Duplicate, HmacSha256Updat= e, HmacSha256Final, HmacSha256All, HmacSha256Key, sizeof (HmacSha256Key), H= macSha256Digest };=0D +HMAC_TEST_CONTEXT mHmacSha384TestCtx =3D { SHA384_DIGEST_SIZE, HmacSha384= New, HmacSha384Free, HmacSha384SetKey, HmacSha384Duplicate, HmacSha384Updat= e, HmacSha384Final, HmacSha384All, HmacSha384Key, sizeof (HmacSha384Key), H= macSha384Digest };=0D =0D UNIT_TEST_STATUS=0D EFIAPI=0D @@ -173,23 +189,44 @@ TestVerifyHmac ( )=0D {=0D UINT8 Digest[MAX_DIGEST_SIZE];=0D + UINT8 DigestCopy[MAX_DIGEST_SIZE];=0D + UINT8 DigestByAll[MAX_DIGEST_SIZE];=0D + VOID *HmacCopyContext;=0D BOOLEAN Status;=0D HMAC_TEST_CONTEXT *HmacTestContext;=0D =0D HmacTestContext =3D Context;=0D =0D ZeroMem (Digest, MAX_DIGEST_SIZE);=0D + ZeroMem (DigestCopy, MAX_DIGEST_SIZE);=0D + ZeroMem (DigestByAll, MAX_DIGEST_SIZE);=0D +=0D + HmacCopyContext =3D HmacTestContext->HmacNew ();=0D =0D Status =3D HmacTestContext->HmacInit (HmacTestContext->HmacCtx, HmacTest= Context->Key, HmacTestContext->KeySize);=0D UT_ASSERT_TRUE (Status);=0D =0D + Status =3D HmacTestContext->HmacInit (HmacCopyContext, HmacTestContext->= Key, HmacTestContext->KeySize);=0D + UT_ASSERT_TRUE (Status);=0D +=0D Status =3D HmacTestContext->HmacUpdate (HmacTestContext->HmacCtx, HmacDa= ta, 8);=0D UT_ASSERT_TRUE (Status);=0D =0D + Status =3D HmacTestContext->HmacDup (HmacTestContext->HmacCtx, HmacCopyC= ontext);=0D + UT_ASSERT_TRUE (Status);=0D +=0D Status =3D HmacTestContext->HmacFinal (HmacTestContext->HmacCtx, Digest)= ;=0D UT_ASSERT_TRUE (Status);=0D =0D + Status =3D HmacTestContext->HmacFinal (HmacCopyContext, DigestCopy);=0D + UT_ASSERT_TRUE (Status);=0D +=0D + Status =3D HmacTestContext->HmacAll (HmacData, 8, HmacTestContext->Key, = HmacTestContext->KeySize, DigestByAll);=0D + UT_ASSERT_TRUE (Status);=0D +=0D UT_ASSERT_MEM_EQUAL (Digest, HmacTestContext->Digest, HmacTestContext->D= igestSize);=0D + UT_ASSERT_MEM_EQUAL (Digest, DigestCopy, HmacTestContext->DigestSize);=0D + UT_ASSERT_MEM_EQUAL (Digest, DigestByAll, HmacTestContext->DigestSize);= =0D =0D return UNIT_TEST_PASSED;=0D }=0D @@ -200,9 +237,6 @@ TEST_DESC mHmacTest[] =3D { //=0D { "TestVerifyHmacSha256()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHma= c, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha256TestCtx },=0D { "TestVerifyHmacSha384()", "CryptoPkg.BaseCryptLib.Hmac", TestVerifyHma= c, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha384TestCtx },=0D - // These functions have been deprecated but they've been left commented = out for future reference=0D - // {"TestVerifyHmacMd5()", "CryptoPkg.BaseCryptLib.Hmac", TestVerif= yHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacMd5TestCtx},=0D - // {"TestVerifyHmacSha1()", "CryptoPkg.BaseCryptLib.Hmac", TestVerif= yHmac, TestVerifyHmacPreReq, TestVerifyHmacCleanUp, &mHmacSha1TestCtx},=0D };=0D =0D UINTN mHmacTestNum =3D ARRAY_SIZE (mHmacTest);=0D --=20 2.26.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#109155): https://edk2.groups.io/g/devel/message/109155 Mute This Topic: https://groups.io/mt/101639976/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-