]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Core/Pei/Security/Security.c
[Description]:
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Security / Security.c
... / ...
CommitLineData
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
24STATIC\r
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 &gEfiPeiSecurity2PpiGuid,\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
62 PeiServicesNotifyPpi (&mNotifyList);\r
63 }\r
64 return;\r
65}\r
66\r
67STATIC\r
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_SECURITY2_PPI *)Ppi;\r
105 }\r
106 return EFI_SUCCESS;\r
107}\r
108\r
109EFI_STATUS\r
110VerifyPeim (\r
111 IN PEI_CORE_INSTANCE *PrivateData,\r
112 IN EFI_PEI_FV_HANDLE VolumeHandle,\r
113 IN EFI_PEI_FILE_HANDLE FileHandle\r
114 )\r
115/*++\r
116\r
117Routine Description:\r
118\r
119 Provide a callout to the security verification service.\r
120\r
121Arguments:\r
122\r
123 PeiServices - The PEI core services table.\r
124 CurrentPeimAddress - Pointer to the Firmware File under investigation.\r
125\r
126Returns:\r
127\r
128 EFI_SUCCESS - Image is OK\r
129 EFI_SECURITY_VIOLATION - Image is illegal\r
130\r
131--*/\r
132{\r
133 EFI_STATUS Status;\r
134 UINT32 AuthenticationStatus;\r
135 BOOLEAN DeferExection;\r
136\r
137 //\r
138 // Set a default authentication state\r
139 //\r
140 AuthenticationStatus = 0;\r
141\r
142 if (PrivateData->PrivateSecurityPpi == NULL) {\r
143 Status = EFI_NOT_FOUND;\r
144 } else {\r
145 //\r
146 // Check to see if the image is OK\r
147 //\r
148 Status = PrivateData->PrivateSecurityPpi->AuthenticationState (\r
149 (CONST EFI_PEI_SERVICES **) &PrivateData->PS,\r
150 PrivateData->PrivateSecurityPpi,\r
151 AuthenticationStatus,\r
152 VolumeHandle,\r
153 FileHandle,\r
154 &DeferExection\r
155 );\r
156 if (DeferExection) {\r
157 Status = EFI_SECURITY_VIOLATION;\r
158 }\r
159 }\r
160 return Status;\r
161}\r
162\r
163\r
164EFI_STATUS\r
165VerifyFv (\r
166 IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress\r
167 )\r
168/*++\r
169\r
170Routine Description:\r
171\r
172 Verify a Firmware volume\r
173\r
174Arguments:\r
175\r
176 CurrentFvAddress - Pointer to the current Firmware Volume under consideration\r
177\r
178Returns:\r
179\r
180 EFI_SUCCESS - Firmware Volume is legal\r
181 EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test\r
182\r
183--*/\r
184{\r
185 //\r
186 // Right now just pass the test. Future can authenticate and/or check the\r
187 // FV-header or other metric for goodness of binary.\r
188 //\r
189 return EFI_SUCCESS;\r
190}\r