Home | History | Annotate | Download | only in Library
      1 /** @file
      2   FMP capsule authenitcation Library.
      3 
      4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
      5 This program and the accompanying materials
      6 are licensed and made available under the terms and conditions of the BSD License
      7 which accompanies this distribution.  The full text of the license may be found at
      8 http://opensource.org/licenses/bsd-license.php
      9 
     10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13 **/
     14 
     15 
     16 #ifndef __FMP_AUTHENTICATION_LIB_H__
     17 #define __FMP_AUTHENTICATION_LIB_H__
     18 
     19 #include <Protocol/FirmwareManagement.h>
     20 
     21 /**
     22   The function is used to do the authentication for FMP capsule based upon
     23   EFI_FIRMWARE_IMAGE_AUTHENTICATION.
     24 
     25   The FMP capsule image should start with EFI_FIRMWARE_IMAGE_AUTHENTICATION,
     26   followed by the payload.
     27 
     28   If the return status is RETURN_SUCCESS, the caller may continue the rest
     29   FMP update process.
     30   If the return status is NOT RETURN_SUCCESS, the caller should stop the FMP
     31   update process and convert the return status to LastAttemptStatus
     32   to indicate that FMP update fails.
     33   The LastAttemptStatus can be got from ESRT table or via
     34   EFI_FIRMWARE_MANAGEMENT_PROTOCOL.GetImageInfo().
     35 
     36   Caution: This function may receive untrusted input.
     37 
     38   @param[in]  Image                   Points to an FMP authentication image, started from EFI_FIRMWARE_IMAGE_AUTHENTICATION.
     39   @param[in]  ImageSize               Size of the authentication image in bytes.
     40   @param[in]  PublicKeyData           The public key data used to validate the signature.
     41   @param[in]  PublicKeyDataLength     The length of the public key data.
     42 
     43   @retval RETURN_SUCCESS            Authentication pass.
     44                                     The LastAttemptStatus should be LAST_ATTEMPT_STATUS_SUCCESS.
     45   @retval RETURN_SECURITY_VIOLATION Authentication fail.
     46                                     The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR.
     47   @retval RETURN_INVALID_PARAMETER  The image is in an invalid format.
     48                                     The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT.
     49   @retval RETURN_UNSUPPORTED        No Authentication handler associated with CertType.
     50                                     The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT.
     51   @retval RETURN_UNSUPPORTED        Image or ImageSize is invalid.
     52                                     The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INVALID_FORMAT.
     53   @retval RETURN_OUT_OF_RESOURCES   No Authentication handler associated with CertType.
     54                                     The LastAttemptStatus should be LAST_ATTEMPT_STATUS_ERROR_INSUFFICIENT_RESOURCES.
     55 **/
     56 RETURN_STATUS
     57 EFIAPI
     58 AuthenticateFmpImage (
     59   IN EFI_FIRMWARE_IMAGE_AUTHENTICATION  *Image,
     60   IN UINTN                              ImageSize,
     61   IN CONST UINT8                        *PublicKeyData,
     62   IN UINTN                              PublicKeyDataLength
     63   );
     64 
     65 #endif
     66 
     67