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