From 270c7b132a6a417edff852229d05ca791ed46b7c Mon Sep 17 00:00:00 2001 From: Guo Mang Date: Mon, 8 May 2017 11:01:15 +0800 Subject: Upgrade core Upgrade core to UDK2017 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Guo Mang Reviewed-by: zwei4 --- .../CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf | 2 +- Platform/BroxtonPlatformPkg/BuildBios.bat | 2 +- .../Common/Library/ResetSystemLib/ResetSystemLib.c | 2 +- .../PlatformSettings/PlatformDxe/PlatformDxe.inf | 2 +- .../MdeModulePkg/Universal/PCD/Pei/Pcd.c | 4 +- .../MdeModulePkg/Universal/PCD/Pei/Service.h | 2 +- .../BroxtonPlatformPkg/PlatformDsc/Components.dsc | 12 +- .../PlatformDsc/LibraryClasses.DxeSmmDriver.dsc | 4 +- .../PlatformDsc/LibraryClasses.dsc | 3 + .../PlatformDsc/PcdsDynamicDefault.Default.dsc | 4 +- .../PlatformDsc/PcdsFeatureFlag.dsc | 4 +- Platform/BroxtonPlatformPkg/PlatformPkg.fdf | 7 +- .../Universal/Variable/RuntimeDxe/Variable.c | 5 +- .../ScPciExpressHelpersLibrary.h | 5 +- .../SouthCluster/ScInit/Smm/ScInitSmm.c | 14 +- .../SouthCluster/ScInit/Smm/ScInitSmm.h | 4 +- .../Txe/Library/HeciMsgLib/DxeSmmHeciMsgLib.c | 189 +-------------------- 17 files changed, 45 insertions(+), 220 deletions(-) diff --git a/Core/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf b/Core/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf index 5674714cea..b1ddc78b4f 100644 --- a/Core/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf +++ b/Core/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf @@ -46,7 +46,7 @@ Hash/CryptSha512Null.c Hmac/CryptHmacMd5Null.c Hmac/CryptHmacSha1Null.c - Hmac/CryptHmacSha256Null.c + Hmac/CryptHmacSha256.c Cipher/CryptAes.c Cipher/CryptTdesNull.c Cipher/CryptArc4Null.c diff --git a/Platform/BroxtonPlatformPkg/BuildBios.bat b/Platform/BroxtonPlatformPkg/BuildBios.bat index 0ebc5705a7..b57188d349 100644 --- a/Platform/BroxtonPlatformPkg/BuildBios.bat +++ b/Platform/BroxtonPlatformPkg/BuildBios.bat @@ -49,7 +49,7 @@ copy /y %WORKSPACE%\%PLATFORM_PATH%\DeviceCommonPkg\Override\BaseTools\Conf\tool :: Setup EDK environment. Edksetup puts new copies of target.txt, tools_def.txt, build_rule.txt in WorkSpace\Conf :: Also run edksetup as soon as possible to avoid it from changing environment variables we're overriding set "VCINSTALLDIR=" -set EDK_TOOLS_PATH=%CORE_PATH%\BaseTools +set EDK_TOOLS_PATH=%WORKSPACE%\BaseTools call edksetup.bat @echo off diff --git a/Platform/BroxtonPlatformPkg/Common/Library/ResetSystemLib/ResetSystemLib.c b/Platform/BroxtonPlatformPkg/Common/Library/ResetSystemLib/ResetSystemLib.c index 02b16e8928..1ef71cab8c 100644 --- a/Platform/BroxtonPlatformPkg/Common/Library/ResetSystemLib/ResetSystemLib.c +++ b/Platform/BroxtonPlatformPkg/Common/Library/ResetSystemLib/ResetSystemLib.c @@ -19,8 +19,8 @@ #include #include #include +#include -#include "ScRegs.h" #define RESET_GENERATOR_PORT 0xCF9 diff --git a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf index cf8ca08ccf..37eaf4623c 100644 --- a/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf +++ b/Platform/BroxtonPlatformPkg/Common/PlatformSettings/PlatformDxe/PlatformDxe.inf @@ -125,7 +125,7 @@ gEfiBxtTokenSpaceGuid.PcdPmcSsramBaseAddress0 gEfiBxtTokenSpaceGuid.PcdPmcGcrBaseAddress gPlatformModuleTokenSpaceGuid.PcdPBTNDisableInterval - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFastPS2Detection + gEfiMdeModulePkgTokenSpaceGuid.PcdFastPS2Detection gEfiBxtTokenSpaceGuid.PcdP2SBBaseAddress [Depex] diff --git a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/PCD/Pei/Pcd.c b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/PCD/Pei/Pcd.c index 107dd16a6a..dc396eb28b 100644 --- a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/PCD/Pei/Pcd.c +++ b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/PCD/Pei/Pcd.c @@ -1,7 +1,7 @@ /** @file All Pcd Ppi services are implemented here. - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -257,7 +257,7 @@ PeiGetPcdInfoGetSku ( VOID ) { - return GetPcdDatabase()->SystemSkuId; + return (UINTN) GetPcdDatabase()->SystemSkuId; } /** diff --git a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/PCD/Pei/Service.h b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/PCD/Pei/Service.h index e54c812e2a..b34fd02df0 100644 --- a/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/PCD/Pei/Service.h +++ b/Platform/BroxtonPlatformPkg/Common/SampleCode/MdeModulePkg/Universal/PCD/Pei/Service.h @@ -37,7 +37,7 @@ // Please make sure the PCD Serivce PEIM Version is consistent with // the version of the generated PEIM PCD Database by build tool. // -#define PCD_SERVICE_PEIM_VERSION 5 +#define PCD_SERVICE_PEIM_VERSION 6 // // PCD_PEI_SERVICE_DRIVER_VERSION is defined in Autogen.h. diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc index d39ec6d4bf..a58086138a 100644 --- a/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc +++ b/Platform/BroxtonPlatformPkg/PlatformDsc/Components.dsc @@ -72,6 +72,8 @@ $(PLATFORM_SI_PACKAGE)/SiInit/Dxe/SiInitDxe.inf MdeModulePkg/Universal/Metronome/Metronome.inf + MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf + IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.inf { gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0xF0000043 @@ -213,16 +215,6 @@ $(PLATFORM_PACKAGE_COMMON)/SampleCode/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.inf !endif - - PerformancePkg/Dp_App/Dp.inf { - - !if $(PERFORMANCE_ENABLE) == TRUE - PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf - TimerLib|$(PLATFORM_PACKAGE_COMMON)/Library/PlatformTscTimerLib/DxeTscTimerLib.inf - !endif - } - - !if $(TPM12_ENABLE) == TRUE SecurityPkg/Tcg/TcgDxe/TcgDxe.inf SecurityPkg/Tcg/TcgSmm/TcgSmm.inf diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeSmmDriver.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeSmmDriver.dsc index 8d3a5544b7..5a2feaaa38 100644 --- a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeSmmDriver.dsc +++ b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.DxeSmmDriver.dsc @@ -1,7 +1,7 @@ ## @file # Dxe Smm Driver Library Classes Description. # -# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -39,4 +39,4 @@ !endif SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf - + CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc index 971dc4a080..b3fb10a81f 100644 --- a/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc +++ b/Platform/BroxtonPlatformPkg/PlatformDsc/LibraryClasses.dsc @@ -98,6 +98,9 @@ S3BootScriptLib|MdePkg/Library/BaseS3BootScriptLibNull/BaseS3BootScriptLibNull.inf !endif + PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf + FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf + # # Generic Modules # diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsDynamicDefault.Default.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsDynamicDefault.Default.dsc index e2a84b617e..19c302db13 100644 --- a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsDynamicDefault.Default.dsc +++ b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsDynamicDefault.Default.dsc @@ -1,7 +1,7 @@ ## @file # Platform Dynamic Pcd Description. # -# Copyright (c) 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License @@ -53,5 +53,5 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0xfff60000 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0xfff9e000 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0xfffa0000 - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdFastPS2Detection|FALSE + gEfiMdeModulePkgTokenSpaceGuid.PcdFastPS2Detection|FALSE diff --git a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFeatureFlag.dsc b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFeatureFlag.dsc index 19e27ad1a9..ed00aac9e2 100644 --- a/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFeatureFlag.dsc +++ b/Platform/BroxtonPlatformPkg/PlatformDsc/PcdsFeatureFlag.dsc @@ -83,8 +83,8 @@ !endif # Optimize Driver init time in FastBoot Mode - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification|FALSE - gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdPs2MouseExtendedVerification|FALSE + gEfiMdeModulePkgTokenSpaceGuid.PcdPs2KbdExtendedVerification|FALSE + gEfiMdeModulePkgTokenSpaceGuid.PcdPs2MouseExtendedVerification|FALSE # Disable Deprecated Function # bugbug benben: set this to FALSE to allow PcdSetXXX() to work in SecurityPkg. Check diff --git a/Platform/BroxtonPlatformPkg/PlatformPkg.fdf b/Platform/BroxtonPlatformPkg/PlatformPkg.fdf index b98426e2ce..3b4d9e7801 100644 --- a/Platform/BroxtonPlatformPkg/PlatformPkg.fdf +++ b/Platform/BroxtonPlatformPkg/PlatformPkg.fdf @@ -37,12 +37,12 @@ DEFINE FLASH_AREA_SIZE = 0x00800000 DEFINE FLASH_REGION_FV_IBBR_OFFSET = 0x00000000 - DEFINE FLASH_REGION_FV_IBBR_SIZE = 0x00060000 + DEFINE FLASH_REGION_FV_IBBR_SIZE = 0x00050000 DEFINE FLASH_REGION_OBB_OFFSET = $(FLASH_REGION_FV_IBBR_OFFSET) + $(FLASH_REGION_FV_IBBR_SIZE) - DEFINE FLASH_REGION_OBB_SIZE = 0x0007B000 + DEFINE FLASH_REGION_OBB_SIZE = 0x00076000 DEFINE FLASH_REGION_OBBX_OFFSET = $(FLASH_REGION_OBB_OFFSET) + $(FLASH_REGION_OBB_SIZE) !if $(EXT_BIOS_ENABLE) == FALSE - DEFINE FLASH_REGION_OBBX_SIZE = 0x00165000 + DEFINE FLASH_REGION_OBBX_SIZE = 0x0017A000 !else DEFINE FLASH_REGION_OBBX_SIZE = 0x002EC000 !endif @@ -451,6 +451,7 @@ APRIORI DXE { INF $(PLATFORM_SI_PACKAGE)/SouthCluster/Sdio/Dxe/SD/SdControllerDxe/SdControllerDxe.inf INF $(PLATFORM_SI_PACKAGE)/SouthCluster/Sdio/Dxe/SD/SdMediaDeviceDxe/SdMediaDeviceDxe.inf + INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf INF IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.inf # diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SampleCode/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/Silicon/BroxtonSoC/BroxtonSiPkg/SampleCode/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 43687dafe8..9fcb55197d 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SampleCode/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SampleCode/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -16,7 +16,7 @@ VariableServiceSetVariable() should also check authenticate data to avoid buffer overflow, integer overflow. It should also check attribute to avoid authentication bypass. - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -3448,6 +3448,9 @@ VariableExistsInHob ( VARIABLE_POINTER_TRACK Variable; EFI_STATUS Status; + if (mVariableModuleGlobal->VariableGlobal.HobVariableBase == 0) { + return FALSE; + } Variable.CurrPtr = NULL; Variable.StartPtr = GetStartPointer ((VARIABLE_STORE_HEADER *) (UINTN) mVariableModuleGlobal->VariableGlobal.HobVariableBase); Variable.EndPtr = GetEndPointer ((VARIABLE_STORE_HEADER *) (UINTN) mVariableModuleGlobal->VariableGlobal.HobVariableBase); diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/Private/PeiDxeSmmScPciExpressHelpersLib/ScPciExpressHelpersLibrary.h b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/Private/PeiDxeSmmScPciExpressHelpersLib/ScPciExpressHelpersLibrary.h index 9d20fb6797..a651501a80 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/Private/PeiDxeSmmScPciExpressHelpersLib/ScPciExpressHelpersLibrary.h +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/Library/Private/PeiDxeSmmScPciExpressHelpersLib/ScPciExpressHelpersLibrary.h @@ -1,7 +1,7 @@ /** @file Header file for PCI Express helps library implementation. - Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2008 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -28,6 +28,9 @@ #include #include + +#define DEVICE_ID_NOCARE 0xFFFF + #define LTR_VALUE_MASK (BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7 + BIT8 + BIT9) #define LTR_SCALE_MASK (BIT10 + BIT11 + BIT12) diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Smm/ScInitSmm.c b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Smm/ScInitSmm.c index ed8a74b1ce..c3c1756494 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Smm/ScInitSmm.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Smm/ScInitSmm.c @@ -1,7 +1,7 @@ /** @file SC Init Smm module for SC specific SMI handlers. - Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -14,6 +14,7 @@ **/ #include "ScInitSmm.h" +#include GLOBAL_REMOVE_IF_UNREFERENCED EFI_SMM_SW_DISPATCH2_PROTOCOL *mSwDispatch; GLOBAL_REMOVE_IF_UNREFERENCED EFI_SMM_SX_DISPATCH2_PROTOCOL *mSxDispatch; @@ -144,6 +145,7 @@ ScInitSmmEntryPoint ( { EFI_STATUS Status; EFI_PEI_HOB_POINTERS HobPtr; + SC_PCIE_CONFIG *PcieRpConfig; DEBUG ((DEBUG_INFO, "ScInitSmmEntryPoint()\n")); @@ -171,13 +173,21 @@ ScInitSmmEntryPoint ( ASSERT (HobPtr.Guid != NULL); mScPolicy = (SC_POLICY_HOB *) GET_GUID_HOB_DATA (HobPtr.Guid); - Status = GetConfigBlock ((VOID *) mScPolicy, &gPcieRpConfigGuid, (VOID *) &mPcieRpConfig); + Status = GetConfigBlock ((VOID *) mScPolicy, &gPcieRpConfigGuid, (VOID *) &PcieRpConfig); ASSERT_EFI_ERROR (Status); + + mPcieRpConfig = AllocatePool(sizeof (SC_PCIE_CONFIG)); + if (mPcieRpConfig != NULL) { + CopyMem (mPcieRpConfig, PcieRpConfig, sizeof (SC_PCIE_CONFIG)); + } + InitializeSxHandler (ImageHandle); Status = InitializeScPcieSmm (ImageHandle, SystemTable); ASSERT_EFI_ERROR (Status); + FreePool (mPcieRpConfig); + return EFI_SUCCESS; } diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Smm/ScInitSmm.h b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Smm/ScInitSmm.h index 81748ba1f0..b2e7fb447c 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Smm/ScInitSmm.h +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/SouthCluster/ScInit/Smm/ScInitSmm.h @@ -1,7 +1,7 @@ /** @file Header file for SC Init SMM Handler - Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2012 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -59,8 +59,6 @@ extern UINTN mResvMmioSize; #define DeviceD0 0x00 #define DeviceD3 0x03 -#define ARRAY_SIZE (data) (sizeof (data) / sizeof (data[0])) - typedef enum { PciCfg, PciMmr diff --git a/Silicon/BroxtonSoC/BroxtonSiPkg/Txe/Library/HeciMsgLib/DxeSmmHeciMsgLib.c b/Silicon/BroxtonSoC/BroxtonSiPkg/Txe/Library/HeciMsgLib/DxeSmmHeciMsgLib.c index 61e41a6054..f64f50ad5d 100644 --- a/Silicon/BroxtonSoC/BroxtonSiPkg/Txe/Library/HeciMsgLib/DxeSmmHeciMsgLib.c +++ b/Silicon/BroxtonSoC/BroxtonSiPkg/Txe/Library/HeciMsgLib/DxeSmmHeciMsgLib.c @@ -1,7 +1,7 @@ /** @file Implementation file DXE/SMM specific HECI Message functionality. - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -32,197 +31,13 @@ #include #include #include +#include UINT8 Heci2DataBuffer[MAX (HECI2_BIOS_MAX_WRITE_MSG_SIZE, HECI2_BIOS_MAX_READ_MSG_SIZE)]; UINT32 mMonoCount = 0; UINT8 mHmacSha256Key[32] = {0}; -/** - Retrieves the size, in bytes, of the context buffer required for HMAC-SHA1 operations. - - @return The size, in bytes, of the context buffer required for HMAC-SHA1 operations. - -**/ -UINTN -EFIAPI -HmacSha256GetContextSize ( - VOID - ) -{ - // - // Retrieves the OpenSSL HMAC-SHA1 Context Size - // - return (UINTN) (sizeof (HMAC_CTX)); -} - - -/** - Initializes user-supplied memory pointed by HmacSha1Context as HMAC-SHA1 context for - subsequent use. - - If HmacSha1Context is NULL, then return FALSE. - - @param[out] HmacSha1Context Pointer to HMAC-SHA1 context being initialized. - @param[in] Key Pointer to the user-supplied key. - @param[in] KeySize Key size in bytes. - - @retval TRUE HMAC-SHA1 context initialization succeeded. - @retval FALSE HMAC-SHA1 context initialization failed. - -**/ -BOOLEAN -EFIAPI -HmacSha256Init ( - OUT VOID *HmacSha256Context, - IN CONST UINT8 *Key, - IN UINTN KeySize - ) -{ - // - // Check input parameters. - // - if (HmacSha256Context == NULL || KeySize > INT_MAX) { - return FALSE; - } - - // - // OpenSSL HMAC-SHA1 Context Initialization - // - HMAC_CTX_init (HmacSha256Context); - HMAC_Init_ex (HmacSha256Context, Key, (UINT32) KeySize, EVP_sha256(), NULL); - - return TRUE; -} - - -/** - Makes a copy of an existing HMAC-SHA1 context. - - If HmacSha1Context is NULL, then return FALSE. - If NewHmacSha1Context is NULL, then return FALSE. - - @param[in] HmacSha1Context Pointer to HMAC-SHA1 context being copied. - @param[out] NewHmacSha1Context Pointer to new HMAC-SHA1 context. - - @retval TRUE HMAC-SHA1 context copy succeeded. - @retval FALSE HMAC-SHA1 context copy failed. - -**/ -BOOLEAN -EFIAPI -HmacSha256Duplicate ( - IN CONST VOID *HmacSha256Context, - OUT VOID *NewHmacSha256Context - ) -{ - // - // Check input parameters. - // - if (HmacSha256Context == NULL || NewHmacSha256Context == NULL) { - return FALSE; - } - - CopyMem (NewHmacSha256Context, HmacSha256Context, sizeof (HMAC_CTX)); - - return TRUE; -} - - -/** - Digests the input data and updates HMAC-SHA1 context. - - This function performs HMAC-SHA1 digest on a data buffer of the specified size. - It can be called multiple times to compute the digest of long or discontinuous data streams. - HMAC-SHA1 context should be already correctly intialized by HmacSha1Init(), and should not - be finalized by HmacSha1Final(). Behavior with invalid context is undefined. - - If HmacSha1Context is NULL, then return FALSE. - - @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context. - @param[in] Data Pointer to the buffer containing the data to be digested. - @param[in] DataSize Size of Data buffer in bytes. - - @retval TRUE HMAC-SHA1 data digest succeeded. - @retval FALSE HMAC-SHA1 data digest failed. - -**/ -BOOLEAN -EFIAPI -HmacSha256Update ( - IN OUT VOID *HmacSha256Context, - IN CONST VOID *Data, - IN UINTN DataSize - ) -{ - // - // Check input parameters. - // - if (HmacSha256Context == NULL) { - return FALSE; - } - - // - // Check invalid parameters, in case that only DataLength was checked in OpenSSL - // - if (Data == NULL && DataSize != 0) { - return FALSE; - } - - // - // OpenSSL HMAC-SHA1 digest update - // - HMAC_Update (HmacSha256Context, Data, DataSize); - - return TRUE; -} - - -/** - Completes computation of the HMAC-SHA1 digest value. - - This function completes HMAC-SHA1 digest computation and retrieves the digest 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 intialized by HmacSha1Init(), and should - not be finalized by HmacSha1Final(). Behavior with invalid HMAC-SHA1 context is undefined. - - If HmacSha1Context is NULL, then return FALSE. - If HmacValue is NULL, then return FALSE. - - @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context. - @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA1 digest - value (20 bytes). - - @retval TRUE HMAC-SHA1 digest computation succeeded. - @retval FALSE HMAC-SHA1 digest computation failed. - -**/ -BOOLEAN -EFIAPI -HmacSha256Final ( - IN OUT VOID *HmacSha256Context, - OUT UINT8 *HmacValue - ) -{ - UINT32 Length; - - // - // Check input parameters. - // - if (HmacSha256Context == NULL || HmacValue == NULL) { - return FALSE; - } - - // - // OpenSSL HMAC-SHA1 digest finalization - // - HMAC_Final (HmacSha256Context, HmacValue, &Length); - HMAC_CTX_cleanup (HmacSha256Context); - - return TRUE; -} - EFI_STATUS ComputeHmacSha256Signature ( -- cgit v1.2.3