xref: /freebsd/sys/contrib/edk2/Include/Protocol/Security2.h (revision f439973d6726c3be929c8fb3b1545b8b1744abc3)
1*f439973dSWarner Losh /** @file
2*f439973dSWarner Losh   Security2 Architectural Protocol as defined in PI Specification1.2.1 VOLUME 2 DXE
3*f439973dSWarner Losh 
4*f439973dSWarner Losh   Abstracts security-specific functions from the DXE Foundation of UEFI Image Verification,
5*f439973dSWarner Losh   Trusted Computing Group (TCG) measured boot, and User Identity policy for image loading and
6*f439973dSWarner Losh   consoles. This protocol must be produced by a boot service or runtime DXE driver.
7*f439973dSWarner Losh 
8*f439973dSWarner Losh   This protocol is optional and must be published prior to the EFI_SECURITY_ARCH_PROTOCOL.
9*f439973dSWarner Losh   As a result, the same driver must publish both of these interfaces.
10*f439973dSWarner Losh 
11*f439973dSWarner Losh   When both Security and Security2 Architectural Protocols are published, LoadImage must use
12*f439973dSWarner Losh   them in accordance with the following rules:
13*f439973dSWarner Losh     The Security2 protocol must be used on every image being loaded.
14*f439973dSWarner Losh     The Security protocol must be used after the Securiy2 protocol and only on images that
15*f439973dSWarner Losh     have been read using Firmware Volume protocol.
16*f439973dSWarner Losh 
17*f439973dSWarner Losh   When only Security architectural protocol is published, LoadImage must use it on every image
18*f439973dSWarner Losh   being loaded.
19*f439973dSWarner Losh 
20*f439973dSWarner Losh   Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
21*f439973dSWarner Losh   SPDX-License-Identifier: BSD-2-Clause-Patent
22*f439973dSWarner Losh 
23*f439973dSWarner Losh **/
24*f439973dSWarner Losh 
25*f439973dSWarner Losh #ifndef __ARCH_PROTOCOL_SECURITY2_H__
26*f439973dSWarner Losh #define __ARCH_PROTOCOL_SECURITY2_H__
27*f439973dSWarner Losh 
28*f439973dSWarner Losh ///
29*f439973dSWarner Losh /// Global ID for the Security2 Code Architectural Protocol
30*f439973dSWarner Losh ///
31*f439973dSWarner Losh #define EFI_SECURITY2_ARCH_PROTOCOL_GUID \
32*f439973dSWarner Losh   { 0x94ab2f58, 0x1438, 0x4ef1, {0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68 } }
33*f439973dSWarner Losh 
34*f439973dSWarner Losh typedef struct _EFI_SECURITY2_ARCH_PROTOCOL EFI_SECURITY2_ARCH_PROTOCOL;
35*f439973dSWarner Losh 
36*f439973dSWarner Losh /**
37*f439973dSWarner Losh   The DXE Foundation uses this service to measure and/or verify a UEFI image.
38*f439973dSWarner Losh 
39*f439973dSWarner Losh   This service abstracts the invocation of Trusted Computing Group (TCG) measured boot, UEFI
40*f439973dSWarner Losh   Secure boot, and UEFI User Identity infrastructure. For the former two, the DXE Foundation
41*f439973dSWarner Losh   invokes the FileAuthentication() with a DevicePath and corresponding image in
42*f439973dSWarner Losh   FileBuffer memory. The TCG measurement code will record the FileBuffer contents into the
43*f439973dSWarner Losh   appropriate PCR. The image verification logic will confirm the integrity and provenance of the
44*f439973dSWarner Losh   image in FileBuffer of length FileSize . The origin of the image will be DevicePath in
45*f439973dSWarner Losh   these cases.
46*f439973dSWarner Losh   If the FileBuffer is NULL, the interface will determine if the DevicePath can be connected
47*f439973dSWarner Losh   in order to support the User Identification policy.
48*f439973dSWarner Losh 
49*f439973dSWarner Losh   @param  This             The EFI_SECURITY2_ARCH_PROTOCOL instance.
50*f439973dSWarner Losh   @param  File             A pointer to the device path of the file that is
51*f439973dSWarner Losh                            being dispatched. This will optionally be used for logging.
52*f439973dSWarner Losh   @param  FileBuffer       A pointer to the buffer with the UEFI file image.
53*f439973dSWarner Losh   @param  FileSize         The size of the file.
54*f439973dSWarner Losh   @param  BootPolicy       A boot policy that was used to call LoadImage() UEFI service. If
55*f439973dSWarner Losh                            FileAuthentication() is invoked not from the LoadImage(),
56*f439973dSWarner Losh                            BootPolicy must be set to FALSE.
57*f439973dSWarner Losh 
58*f439973dSWarner Losh   @retval EFI_SUCCESS             The file specified by DevicePath and non-NULL
59*f439973dSWarner Losh                                   FileBuffer did authenticate, and the platform policy dictates
60*f439973dSWarner Losh                                   that the DXE Foundation may use the file.
61*f439973dSWarner Losh   @retval EFI_SUCCESS             The device path specified by NULL device path DevicePath
62*f439973dSWarner Losh                                   and non-NULL FileBuffer did authenticate, and the platform
63*f439973dSWarner Losh                                   policy dictates that the DXE Foundation may execute the image in
64*f439973dSWarner Losh                                   FileBuffer.
65*f439973dSWarner Losh   @retval EFI_SUCCESS             FileBuffer is NULL and current user has permission to start
66*f439973dSWarner Losh                                   UEFI device drivers on the device path specified by DevicePath.
67*f439973dSWarner Losh   @retval EFI_SECURITY_VIOLATION  The file specified by DevicePath and FileBuffer did not
68*f439973dSWarner Losh                                   authenticate, and the platform policy dictates that the file should be
69*f439973dSWarner Losh                                   placed in the untrusted state. The image has been added to the file
70*f439973dSWarner Losh                                   execution table.
71*f439973dSWarner Losh   @retval EFI_ACCESS_DENIED       The file specified by File and FileBuffer did not
72*f439973dSWarner Losh                                   authenticate, and the platform policy dictates that the DXE
73*f439973dSWarner Losh                                   Foundation may not use File.
74*f439973dSWarner Losh   @retval EFI_SECURITY_VIOLATION  FileBuffer is NULL and the user has no
75*f439973dSWarner Losh                                   permission to start UEFI device drivers on the device path specified
76*f439973dSWarner Losh                                   by DevicePath.
77*f439973dSWarner Losh   @retval EFI_SECURITY_VIOLATION  FileBuffer is not NULL and the user has no permission to load
78*f439973dSWarner Losh                                   drivers from the device path specified by DevicePath. The
79*f439973dSWarner Losh                                   image has been added into the list of the deferred images.
80*f439973dSWarner Losh **/
81*f439973dSWarner Losh typedef EFI_STATUS (EFIAPI *EFI_SECURITY2_FILE_AUTHENTICATION)(
82*f439973dSWarner Losh   IN CONST EFI_SECURITY2_ARCH_PROTOCOL *This,
83*f439973dSWarner Losh   IN CONST EFI_DEVICE_PATH_PROTOCOL    *File  OPTIONAL,
84*f439973dSWarner Losh   IN VOID                              *FileBuffer,
85*f439973dSWarner Losh   IN UINTN                             FileSize,
86*f439973dSWarner Losh   IN BOOLEAN                           BootPolicy
87*f439973dSWarner Losh   );
88*f439973dSWarner Losh 
89*f439973dSWarner Losh ///
90*f439973dSWarner Losh /// The EFI_SECURITY2_ARCH_PROTOCOL is used to abstract platform-specific policy from the
91*f439973dSWarner Losh /// DXE Foundation. This includes measuring the PE/COFF image prior to invoking, comparing the
92*f439973dSWarner Losh /// image against a policy (whether a white-list/black-list of public image verification keys
93*f439973dSWarner Losh /// or registered hashes).
94*f439973dSWarner Losh ///
95*f439973dSWarner Losh struct _EFI_SECURITY2_ARCH_PROTOCOL {
96*f439973dSWarner Losh   EFI_SECURITY2_FILE_AUTHENTICATION    FileAuthentication;
97*f439973dSWarner Losh };
98*f439973dSWarner Losh 
99*f439973dSWarner Losh extern EFI_GUID  gEfiSecurity2ArchProtocolGuid;
100*f439973dSWarner Losh 
101*f439973dSWarner Losh #endif
102