From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3DDBD81E87 for ; Mon, 7 Nov 2016 04:40:11 -0800 (PST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP; 07 Nov 2016 04:40:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,606,1473145200"; d="scan'208";a="28578711" Received: from jyao1-mobl.ccr.corp.intel.com ([10.254.208.25]) by orsmga004.jf.intel.com with ESMTP; 07 Nov 2016 04:40:12 -0800 From: Jiewen Yao To: edk2-devel@lists.01.org Cc: Feng Tian , Star Zeng , Michael D Kinney , Liming Gao , Chao Zhang Date: Mon, 7 Nov 2016 20:39:54 +0800 Message-Id: <1478522403-9300-4-git-send-email-jiewen.yao@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 In-Reply-To: <1478522403-9300-1-git-send-email-jiewen.yao@intel.com> References: <1478522403-9300-1-git-send-email-jiewen.yao@intel.com> Subject: [PATCH V9 03/12] SignedCapsulePkg/Include: Add EdkiiSystemCapsuleLib definition. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Nov 2016 12:40:11 -0000 This library is used to abstract the action for EDKII system FMP capsule, such as extracting a component from capsule, or authenticate the capsule. Cc: Feng Tian Cc: Star Zeng Cc: Michael D Kinney Cc: Liming Gao Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao Reviewed-by: Liming Gao --- SignedCapsulePkg/Include/Library/EdkiiSystemCapsuleLib.h | 154 ++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/SignedCapsulePkg/Include/Library/EdkiiSystemCapsuleLib.h b/SignedCapsulePkg/Include/Library/EdkiiSystemCapsuleLib.h new file mode 100644 index 0000000..11958e2 --- /dev/null +++ b/SignedCapsulePkg/Include/Library/EdkiiSystemCapsuleLib.h @@ -0,0 +1,154 @@ +/** @file + EDKII System Capsule library. + +Copyright (c) 2016, 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 +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + + +#ifndef __EDKII_SYSTEM_CAPSULE_LIB_H__ +#define __EDKII_SYSTEM_CAPSULE_LIB_H__ + +#include + +/** + Extract ImageFmpInfo from system firmware. + + @param[in] SystemFirmwareImage The System Firmware image. + @param[in] SystemFirmwareImageSize The size of the System Firmware image in bytes. + @param[out] ImageFmpInfo The ImageFmpInfo. + @param[out] ImageFmpInfoSize The size of the ImageFmpInfo in bytes. + + @retval TRUE The ImageFmpInfo is extracted. + @retval FALSE The ImageFmpInfo is not extracted. +**/ +BOOLEAN +EFIAPI +ExtractSystemFirmwareImageFmpInfo ( + IN VOID *SystemFirmwareImage, + IN UINTN SystemFirmwareImageSize, + OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **ImageFmpInfo, + OUT UINTN *ImageFmpInfoSize + ); + +/** + Extract the driver FV from an authenticated image. + + @param[in] AuthenticatedImage The authenticated capsule image. + @param[in] AuthenticatedImageSize The size of the authenticated capsule image in bytes. + @param[out] DriverFvImage The driver FV image. + @param[out] DriverFvImageSize The size of the driver FV image in bytes. + + @retval TRUE The driver Fv is extracted. + @retval FALSE The driver Fv is not extracted. +**/ +BOOLEAN +EFIAPI +ExtractDriverFvImage ( + IN VOID *AuthenticatedImage, + IN UINTN AuthenticatedImageSize, + OUT VOID **DriverFvImage, + OUT UINTN *DriverFvImageSize + ); + +/** + Extract the config image from an authenticated image. + + @param[in] AuthenticatedImage The authenticated capsule image. + @param[in] AuthenticatedImageSize The size of the authenticated capsule image in bytes. + @param[out] ConfigImage The config image. + @param[out] ConfigImageSize The size of the config image in bytes. + + @retval TRUE The config image is extracted. + @retval FALSE The config image is not extracted. +**/ +BOOLEAN +EFIAPI +ExtractConfigImage ( + IN VOID *AuthenticatedImage, + IN UINTN AuthenticatedImageSize, + OUT VOID **ConfigImage, + OUT UINTN *ConfigImageSize + ); + +/** + Extract the System Firmware image from an authenticated image. + + @param[in] AuthenticatedImage The authenticated capsule image. + @param[in] AuthenticatedImageSize The size of the authenticated capsule image in bytes. + @param[out] SystemFirmwareImage The System Firmware image. + @param[out] SystemFirmwareImageSize The size of the System Firmware image in bytes. + + @retval TRUE The System Firmware image is extracted. + @retval FALSE The System Firmware image is not extracted. +**/ +BOOLEAN +EFIAPI +ExtractSystemFirmwareImage ( + IN VOID *AuthenticatedImage, + IN UINTN AuthenticatedImageSize, + OUT VOID **SystemFirmwareImage, + OUT UINTN *SystemFirmwareImageSize + ); + +/** + Extract the authenticated image from an FMP capsule image. + + @param[in] Image The FMP capsule image, including EFI_FIRMWARE_IMAGE_AUTHENTICATION. + @param[in] ImageSize The size of FMP capsule image in bytes. + @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] AuthenticatedImage The authenticated capsule image, excluding EFI_FIRMWARE_IMAGE_AUTHENTICATION. + @param[out] AuthenticatedImageSize The size of the authenticated capsule image in bytes. + + @retval TRUE The authenticated image is extracted. + @retval FALSE The authenticated image is not extracted. +**/ +BOOLEAN +EFIAPI +ExtractAuthenticatedImage ( + IN VOID *Image, + IN UINTN ImageSize, + OUT UINT32 *LastAttemptStatus, + OUT VOID **AuthenticatedImage, + OUT UINTN *AuthenticatedImageSize + ); + +/** + Authenticated system firmware FMP capsule image. + + Caution: This function may receive untrusted input. + + @param[in] Image The FMP capsule image, including EFI_FIRMWARE_IMAGE_AUTHENTICATION. + @param[in] ImageSize The size of FMP capsule image in bytes. + @param[in] ForceVersionMatch TRUE: The version of capsule must be as same as the version of current image. + FALSE: The version of capsule must be as same as greater than the lowest + supported version of current image. + @param[out] LastAttemptVersion The last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] LastAttemptStatus The last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[out] AuthenticatedImage The authenticated capsule image, excluding EFI_FIRMWARE_IMAGE_AUTHENTICATION. + @param[out] AuthenticatedImageSize The size of the authenticated capsule image in bytes. + + @retval TRUE Authentication passes and the authenticated image is extracted. + @retval FALSE Authentication fails and the authenticated image is not extracted. +**/ +EFI_STATUS +EFIAPI +CapsuleAuthenticateSystemFirmware ( + IN VOID *Image, + IN UINTN ImageSize, + IN BOOLEAN ForceVersionMatch, + OUT UINT32 *LastAttemptVersion, + OUT UINT32 *LastAttemptStatus, + OUT VOID **AuthenticatedImage, + OUT UINTN *AuthenticatedImageSize + ); + +#endif + -- 2.7.4.windows.1