From nobody Mon Feb 9 20:46:05 2026 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+52378+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+52378+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1576707399; cv=none; d=zohomail.com; s=zohoarc; b=DaMZoJNv+9wLZqiE7xqEeNyNdpb7NYKkF3pOaxV7UnxhDW2SpNx8OevDH+guqJZOxVfboCbyb+x6xSkQOmpGO5OD8z1pkPgusNxTJYe9N1mCMjtRvC6JT4A2gnYv4KYa3Q/WiOi1UPgD7+qBPobyV5AUc0O8N3s8MUs1kEWr5iA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576707399; 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=ETsZlSBhCTapY/vya9Y4nIhUNhlC1OS6VJVvQE+czK4=; b=NpvBVypBrrMoOzlIpQl//zWK4oeyVLkuOcsT7NRfsHZ/MkqV8uhTctGDSSCxa2Xn17RtAXZJFEMnhOkgb0Lv8ABQdR7RS7t4HPlBrzw/ks2hhISqikHhndJWxVi5pjFrvojCTLrWqniBqu8gO4TP4gQtlt7hjl+l0NMnxkmHgBA= 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+52378+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 1576707399839621.189396855977; Wed, 18 Dec 2019 14:16:39 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9fuuYY1788612xdsjbFJ0bjl; Wed, 18 Dec 2019 14:16:38 -0800 X-Received: from mga14.intel.com (mga14.intel.com []) by mx.groups.io with SMTP id smtpd.web10.1987.1576705847293132972 for ; Wed, 18 Dec 2019 13:50:48 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Dec 2019 13:50:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,330,1571727600"; d="scan'208";a="240930687" X-Received: from ansukerk-mobl.amr.corp.intel.com ([10.78.16.174]) by fmsmga004.fm.intel.com with ESMTP; 18 Dec 2019 13:50:47 -0800 From: "Sukerkar, Amol N" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, sachin.agrawal@intel.com, self Subject: [edk2-devel] [PATCH v1 4/6] SecurityPkg/HashApiInstanceSha384: Implement API registration mechanism for SHA384 Date: Wed, 18 Dec 2019 14:50:35 -0700 Message-Id: <20191218215037.1630-5-amol.n.sukerkar@intel.com> In-Reply-To: <20191218215037.1630-1-amol.n.sukerkar@intel.com> References: <20191218215037.1630-1-amol.n.sukerkar@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,amol.n.sukerkar@intel.com X-Gm-Message-State: xNb9E3zxDPmPajHwwg48S4H1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1576707398; bh=xH2o2ToTntHjAgNh4L/2sEf3rzVe/eJ6Qku+Px9sEEU=; h=Cc:Date:From:Reply-To:Subject:To; b=ey6fxuh1ofWW5Ggqk1VjkkNZ7KFJD4v8OG6IJr+96dj+elOLZ3BbeaEF9NzWUwKsNJ8 bVZ9+3moXixR8eHUFoCEafT5WWlG3PdDg9bMiJyWDBwsYiSjJaXOMczKl6Wkrp7+SPqh3 PYpCFRPPCUmIeWnAihfXQvVL5KBPpK8UZpY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This is the HashApiInstance implementation for SHA384 which registers the SHA384 hash library in CryptoPkg with BaseHashLib based on whether a platfo= rm supports SHA384 hash algorithm (provided by PcdTpm2HashMask). Signed-off-by: Sukerkar, Amol N --- SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.c | 128 = ++++++++++++++++++++ SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.inf | 40 = ++++++ SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.uni | 16 = +++ SecurityPkg/SecurityPkg.dsc | 1 + 4 files changed, 185 insertions(+) diff --git a/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha38= 4.c b/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.c new file mode 100644 index 000000000000..0d1b8f3e877a --- /dev/null +++ b/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.c @@ -0,0 +1,128 @@ +/** @file + This library is BaseCrypto SHA384 hash instance. + It can be registered to BaseCrypto router, to serve as hash engine. + +Copyright (c) 2013 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +/** + Start hash sequence. + + @param HashHandle Hash handle. + + @retval EFI_SUCCESS Hash sequence start and HandleHandle return= ed. + @retval EFI_OUT_OF_RESOURCES No enough resource to start hash. +**/ +EFI_STATUS +EFIAPI +Sha384_Init ( + OUT HASH_HANDLE *HashHandle + ) +{ + VOID *Sha384Ctx; + UINTN CtxSize; + + CtxSize =3D Sha384GetContextSize (); + Sha384Ctx =3D AllocatePool (CtxSize); + ASSERT (Sha384Ctx !=3D NULL); + + Sha384Init (Sha384Ctx); + + *HashHandle =3D (HASH_HANDLE)Sha384Ctx; + + return EFI_SUCCESS; +} + +/** + Update hash sequence data. + + @param HashHandle Hash handle. + @param DataToHash Data to be hashed. + @param DataToHashLen Data size. + + @retval EFI_SUCCESS Hash sequence updated. +**/ +EFI_STATUS +EFIAPI +Sha384_Update ( + IN HASH_HANDLE HashHandle, + IN VOID *DataToHash, + IN UINTN DataToHashLen + ) +{ + VOID *Sha384Ctx; + + Sha384Ctx =3D (VOID *)HashHandle; + Sha384Update (Sha384Ctx, DataToHash, DataToHashLen); + + return EFI_SUCCESS; +} + +/** + Complete hash sequence complete. + + @param HashHandle Hash handle. + @param DigestList Digest list. + + @retval EFI_SUCCESS Hash sequence complete and DigestList is returne= d. +**/ +EFI_STATUS +EFIAPI +Sha384_Final ( + IN HASH_HANDLE HashHandle, + OUT UINT8 **Digest + ) +{ + UINT8 Sha384Digest[SHA384_DIGEST_SIZE]; + VOID *Sha384Ctx; + + Sha384Ctx =3D (VOID *)HashHandle; + Sha384Final (Sha384Ctx, Sha384Digest); + + CopyMem (*Digest, Sha384Digest, SHA384_DIGEST_SIZE); + + FreePool (Sha384Ctx); + + return EFI_SUCCESS; +} + +HASH_INTERFACE_UNIFIED_API mSha384InternalHashApiInstance =3D { + HASH_ALGORITHM_SHA384_GUID, + Sha384_Init, + Sha384_Update, + Sha384_Final, +}; + +/** + The function register SHA384 instance. + + @retval EFI_SUCCESS SHA384 instance is registered, or system dose not = surpport registr SHA384 instance +**/ +EFI_STATUS +EFIAPI +HashApiInstanceSha384Constructor ( + VOID + ) +{ + EFI_STATUS Status; + + Status =3D RegisterHashApiLib (&mSha384InternalHashApiInstance); + if ((Status =3D=3D EFI_SUCCESS) || (Status =3D=3D EFI_UNSUPPORTED)) { + // + // Unsupported means platform policy does not need this instance enabl= ed. + // + DEBUG ((DEBUG_ERROR, "[ansukerk]: Hash Interface SHA384 is registered\= n")); + return EFI_SUCCESS; + } + return Status; +} diff --git a/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha38= 4.inf b/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.inf new file mode 100644 index 000000000000..ee36a926a8b8 --- /dev/null +++ b/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.inf @@ -0,0 +1,40 @@ +## @file +# Provides BaseCrypto SHA1 hash service +# +# This library can be registered to BaseCrypto router, to serve as hash e= ngine. +# +# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D HashApiInstanceSha384 + MODULE_UNI_FILE =3D HashApiInstanceSha384.uni + FILE_GUID =3D 9A7A6AB4-9DA6-4aa4-90CB-6D4B79EDA7B9 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D NULL + CONSTRUCTOR =3D HashApiInstanceSha384Constructor + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + HashApiInstanceSha384.c + +[Packages] + MdePkg/MdePkg.dec + SecurityPkg/SecurityPkg.dec + CryptoPkg/CryptoPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + MemoryAllocationLib + BaseCryptLib diff --git a/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha38= 4.uni b/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.uni new file mode 100644 index 000000000000..be41375bca7a --- /dev/null +++ b/SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.uni @@ -0,0 +1,16 @@ +// /** @file +// Provides BaseCrypto SHA384 hash service +// +// This library can be registered to BaseCrypto router, to serve as hash e= ngine. +// +// Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Provides BaseCryp= to SHA384 hash service API" + +#string STR_MODULE_DESCRIPTION #language en-US "This library can = be registered to Base Hash API, to serve as hash engine." + diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index 95a5710735e0..c03822872718 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -246,6 +246,7 @@ [Components.IA32, Components.X64] # SecurityPkg/Library/HashApiInstanceSha1/HashApiInstanceSha1.inf SecurityPkg/Library/HashApiInstanceSha256/HashApiInstanceSha256.inf + SecurityPkg/Library/HashApiInstanceSha384/HashApiInstanceSha384.inf =20 # # TPM --=20 2.16.2.windows.1 -=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 (#52378): https://edk2.groups.io/g/devel/message/52378 Mute This Topic: https://groups.io/mt/68808199/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-