]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Pei/Security/Security.c
Enable Nt32 platform boot to DXE phase.
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Security / Security.c
CommitLineData
192f6d4c 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//\r
23// Include common header file for this module.\r
24//\r
25#include "CommonHeader.h"\r
26\r
27#include <PeiMain.h>\r
28\r
29STATIC\r
30EFI_STATUS\r
31EFIAPI\r
32SecurityPpiNotifyCallback (\r
33 IN EFI_PEI_SERVICES **PeiServices,\r
34 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
35 IN VOID *Ppi\r
36 );\r
37\r
38static EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {\r
39 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
40 &gEfiPeiSecurityPpiGuid,\r
41 SecurityPpiNotifyCallback\r
42};\r
43\r
44VOID\r
45InitializeSecurityServices (\r
46 IN EFI_PEI_SERVICES **PeiServices,\r
47 IN PEI_CORE_INSTANCE *OldCoreData\r
48 )\r
49/*++\r
50\r
51Routine Description:\r
52\r
53 Initialize the security services.\r
54\r
55Arguments:\r
56\r
57 PeiServices - The PEI core services table.\r
58 OldCoreData - Pointer to the old core data.\r
59 NULL if being run in non-permament memory mode.\r
60Returns:\r
61\r
62 None\r
63\r
64--*/\r
65{\r
66 if (OldCoreData == NULL) {\r
67 PeiServicesNotifyPpi (&mNotifyList);\r
68 }\r
69 return;\r
70}\r
71\r
72STATIC\r
73EFI_STATUS\r
74EFIAPI\r
75SecurityPpiNotifyCallback (\r
76 IN EFI_PEI_SERVICES **PeiServices,\r
77 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r
78 IN VOID *Ppi\r
79 )\r
80/*++\r
81\r
82Routine Description:\r
83\r
84 Provide a callback for when the security PPI is installed.\r
85\r
86Arguments:\r
87\r
88 PeiServices - The PEI core services table.\r
89 NotifyDescriptor - The descriptor for the notification event.\r
90 Ppi - Pointer to the PPI in question.\r
91\r
92Returns:\r
93\r
94 EFI_SUCCESS - The function is successfully processed.\r
95\r
96--*/\r
97{\r
98 PEI_CORE_INSTANCE *PrivateData;\r
99\r
100 //\r
101 // Get PEI Core private data\r
102 //\r
103 PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
104 \r
105 //\r
106 // If there isn't a security PPI installed, use the one from notification\r
107 //\r
108 if (PrivateData->PrivateSecurityPpi == NULL) {\r
109 PrivateData->PrivateSecurityPpi = (EFI_PEI_SECURITY_PPI *)Ppi;\r
110 }\r
111 return EFI_SUCCESS;\r
112}\r
113\r
114EFI_STATUS\r
115VerifyPeim (\r
116 IN EFI_PEI_SERVICES **PeiServices,\r
117 IN EFI_FFS_FILE_HEADER *CurrentPeimAddress\r
118 )\r
119/*++\r
120\r
121Routine Description:\r
122\r
123 Provide a callout to the security verification service.\r
124\r
125Arguments:\r
126\r
127 PeiServices - The PEI core services table.\r
128 CurrentPeimAddress - Pointer to the Firmware File under investigation.\r
129\r
130Returns:\r
131\r
132 EFI_SUCCESS - Image is OK\r
133 EFI_SECURITY_VIOLATION - Image is illegal\r
134\r
135--*/\r
136{\r
137 PEI_CORE_INSTANCE *PrivateData;\r
138 EFI_STATUS Status;\r
139 UINT32 AuthenticationStatus;\r
140 BOOLEAN StartCrisisRecovery;\r
141\r
142 //\r
143 // Set a default authentication state\r
144 //\r
145 AuthenticationStatus = 0;\r
146\r
147 //\r
148 // get security PPI instance from PEI private data\r
149 //\r
150 PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);\r
151\r
152 if (PrivateData->PrivateSecurityPpi == NULL) {\r
153 Status = EFI_NOT_FOUND;\r
154 } else {\r
155 //\r
156 // Check to see if the image is OK\r
157 //\r
158 Status = PrivateData->PrivateSecurityPpi->AuthenticationState (\r
159 PeiServices,\r
160 PrivateData->PrivateSecurityPpi,\r
161 AuthenticationStatus,\r
162 CurrentPeimAddress,\r
163 &StartCrisisRecovery\r
164 );\r
165 if (StartCrisisRecovery) {\r
166 Status = EFI_SECURITY_VIOLATION;\r
167 }\r
168 }\r
169 return Status;\r
170}\r
171\r
172\r
173EFI_STATUS\r
174VerifyFv (\r
175 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
176 )\r
177/*++\r
178\r
179Routine Description:\r
180\r
181 Verify a Firmware volume\r
182\r
183Arguments:\r
184\r
185 CurrentFvAddress - Pointer to the current Firmware Volume under consideration\r
186\r
187Returns:\r
188\r
189 EFI_SUCCESS - Firmware Volume is legal\r
190 EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test\r
191\r
192--*/\r
193{\r
194 //\r
195 // Right now just pass the test. Future can authenticate and/or check the\r
196 // FV-header or other metric for goodness of binary.\r
197 //\r
198 return EFI_SUCCESS;\r
199}\r