]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/Security/Security.c
Fix function comment to follows doxygen format.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Security / Security.c
CommitLineData
615c6dd0 1/** @file\r
b1f6a7c6 2 EFI PEI Core Security services\r
3 \r
192f6d4c 4Copyright (c) 2006, Intel Corporation \r
5All rights reserved. This program and the accompanying materials \r
6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
b1f6a7c6 13**/\r
192f6d4c 14\r
b1f6a7c6 15#include <PeiMain.h>\r
192f6d4c 16\r
b1f6a7c6 17/**\r
192f6d4c 18\r
b1f6a7c6 19 Provide a callback for when the security PPI is installed.\r
192f6d4c 20\r
b1f6a7c6 21 @param PeiServices - The PEI core services table.\r
22 @param NotifyDescriptor - The descriptor for the notification event.\r
23 @param Ppi - Pointer to the PPI in question.\r
192f6d4c 24\r
b1f6a7c6 25 @return Always success\r
192f6d4c 26\r
b1f6a7c6 27**/\r
192f6d4c 28EFI_STATUS\r
29EFIAPI\r
30SecurityPpiNotifyCallback (\r
31 IN EFI_PEI_SERVICES **PeiServices,\r
32 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
33 IN VOID *Ppi\r
34 );\r
35\r
b1f6a7c6 36STATIC EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {\r
192f6d4c 37 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
b0d803fe 38 &gEfiPeiSecurity2PpiGuid,\r
192f6d4c 39 SecurityPpiNotifyCallback\r
40};\r
41\r
b1f6a7c6 42/**\r
192f6d4c 43\r
44 Initialize the security services.\r
45\r
192f6d4c 46\r
b1f6a7c6 47 @param PeiServices - The PEI core services table.\r
48 @param OldCoreData - Pointer to the old core data.\r
49 NULL if being run in non-permament memory mode.\r
192f6d4c 50\r
b1f6a7c6 51**/\r
52VOID\r
53InitializeSecurityServices (\r
54 IN EFI_PEI_SERVICES **PeiServices,\r
55 IN PEI_CORE_INSTANCE *OldCoreData\r
56 )\r
192f6d4c 57{\r
58 if (OldCoreData == NULL) {\r
59 PeiServicesNotifyPpi (&mNotifyList);\r
60 }\r
61 return;\r
62}\r
63\r
b1f6a7c6 64/**\r
65\r
66 Provide a callback for when the security PPI is installed.\r
67\r
68 @param PeiServices - The PEI core services table.\r
69 @param NotifyDescriptor - The descriptor for the notification event.\r
70 @param Ppi - Pointer to the PPI in question.\r
71\r
72 @return Always success\r
73\r
74**/\r
192f6d4c 75EFI_STATUS\r
76EFIAPI\r
77SecurityPpiNotifyCallback (\r
78 IN EFI_PEI_SERVICES **PeiServices,\r
79 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
80 IN VOID *Ppi\r
81 )\r
192f6d4c 82{\r
83 PEI_CORE_INSTANCE *PrivateData;\r
84\r
85 //\r
86 // Get PEI Core private data\r
87 //\r
88 PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
89 \r
90 //\r
91 // If there isn't a security PPI installed, use the one from notification\r
92 //\r
93 if (PrivateData->PrivateSecurityPpi == NULL) {\r
b0d803fe 94 PrivateData->PrivateSecurityPpi = (EFI_PEI_SECURITY2_PPI *)Ppi;\r
192f6d4c 95 }\r
96 return EFI_SUCCESS;\r
97}\r
98\r
b1f6a7c6 99/**\r
192f6d4c 100\r
101 Provide a callout to the security verification service.\r
102\r
192f6d4c 103\r
b1f6a7c6 104 @param PrivateData PeiCore's private data structure\r
105 @param VolumeHandle Handle of FV\r
106 @param FileHandle Handle of PEIM's ffs\r
192f6d4c 107\r
b1f6a7c6 108 @retval EFI_SUCCESS Image is OK\r
109 @retval EFI_SECURITY_VIOLATION Image is illegal\r
192f6d4c 110\r
b1f6a7c6 111**/\r
112EFI_STATUS\r
113VerifyPeim (\r
114 IN PEI_CORE_INSTANCE *PrivateData,\r
115 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
116 IN EFI_PEI_FILE_HANDLE FileHandle\r
117 )\r
192f6d4c 118{\r
192f6d4c 119 EFI_STATUS Status;\r
120 UINT32 AuthenticationStatus;\r
b0d803fe 121 BOOLEAN DeferExection;\r
192f6d4c 122\r
123 //\r
124 // Set a default authentication state\r
125 //\r
126 AuthenticationStatus = 0;\r
127\r
192f6d4c 128 if (PrivateData->PrivateSecurityPpi == NULL) {\r
129 Status = EFI_NOT_FOUND;\r
130 } else {\r
131 //\r
132 // Check to see if the image is OK\r
133 //\r
134 Status = PrivateData->PrivateSecurityPpi->AuthenticationState (\r
b0d803fe 135 (CONST EFI_PEI_SERVICES **) &PrivateData->PS,\r
192f6d4c 136 PrivateData->PrivateSecurityPpi,\r
137 AuthenticationStatus,\r
b0d803fe 138 VolumeHandle,\r
139 FileHandle,\r
140 &DeferExection\r
192f6d4c 141 );\r
b0d803fe 142 if (DeferExection) {\r
192f6d4c 143 Status = EFI_SECURITY_VIOLATION;\r
144 }\r
145 }\r
146 return Status;\r
147}\r
148\r
149\r
b1f6a7c6 150/**\r
151 Verify a Firmware volume.\r
152\r
153 @param CurrentFvAddress - Pointer to the current Firmware Volume under consideration\r
154\r
155 @retval EFI_SUCCESS - Firmware Volume is legal\r
156 @retval EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test\r
157\r
158**/\r
192f6d4c 159EFI_STATUS\r
160VerifyFv (\r
161 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
162 )\r
192f6d4c 163{\r
164 //\r
165 // Right now just pass the test. Future can authenticate and/or check the\r
166 // FV-header or other metric for goodness of binary.\r
167 //\r
168 return EFI_SUCCESS;\r
169}\r