]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/DxeImageAuthenticationStatusLib/DxeImageAuthenticationStatusLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / SecurityPkg / Library / DxeImageAuthenticationStatusLib / DxeImageAuthenticationStatusLib.c
1 /** @file
2 Implement image authentication status check in UEFI2.3.1.
3
4 Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <PiDxe.h>
10 #include <Library/SecurityManagementLib.h>
11
12 /**
13 Check image authentication status returned from Section Extraction Protocol
14
15 @param[in] AuthenticationStatus This is the authentication status returned from
16 the Section Extraction Protocol when reading the input file.
17 @param[in] File This is a pointer to the device path of the file that is
18 being dispatched. This will optionally be used for logging.
19 @param[in] FileBuffer File buffer matches the input file device path.
20 @param[in] FileSize Size of File buffer matches the input file device path.
21 @param[in] BootPolicy A boot policy that was used to call LoadImage() UEFI service.
22
23 @retval EFI_SUCCESS The input file specified by File did authenticate, and the
24 platform policy dictates that the DXE Core may use File.
25 @retval EFI_ACCESS_DENIED The file specified by File and FileBuffer did not
26 authenticate, and the platform policy dictates that the DXE
27 Foundation many not use File.
28
29 **/
30 EFI_STATUS
31 EFIAPI
32 DxeImageAuthenticationStatusHandler (
33 IN UINT32 AuthenticationStatus,
34 IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL,
35 IN VOID *FileBuffer,
36 IN UINTN FileSize,
37 IN BOOLEAN BootPolicy
38 )
39 {
40 if ((AuthenticationStatus & EFI_AUTH_STATUS_IMAGE_SIGNED) != 0) {
41 if ((AuthenticationStatus & (EFI_AUTH_STATUS_TEST_FAILED | EFI_AUTH_STATUS_NOT_TESTED)) != 0) {
42 return EFI_ACCESS_DENIED;
43 }
44 }
45
46 return EFI_SUCCESS;
47 }
48
49 /**
50 Register image authentication status check handler.
51
52 @param ImageHandle ImageHandle of the loaded driver.
53 @param SystemTable Pointer to the EFI System Table.
54
55 @retval EFI_SUCCESS The handlers were registered successfully.
56 **/
57 EFI_STATUS
58 EFIAPI
59 DxeImageAuthenticationStatusLibConstructor (
60 IN EFI_HANDLE ImageHandle,
61 IN EFI_SYSTEM_TABLE *SystemTable
62 )
63 {
64 return RegisterSecurity2Handler (
65 DxeImageAuthenticationStatusHandler,
66 EFI_AUTH_OPERATION_AUTHENTICATION_STATE
67 );
68 }