X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FCore%2FPei%2FSecurity%2FSecurity.c;h=13c6368ffe23e9cea16ea5340614f5c6d6257ed0;hb=d1102dba7210b95e41d06c2338a22ba6af248645;hp=089995e5297be166318ba8ed9239779123bc24b5;hpb=859b72fa7e3ff1cf1d7476a3446af4ebbb5fe3e6;p=mirror_edk2.git
diff --git a/MdeModulePkg/Core/Pei/Security/Security.c b/MdeModulePkg/Core/Pei/Security/Security.c
index 089995e529..13c6368ffe 100644
--- a/MdeModulePkg/Core/Pei/Security/Security.c
+++ b/MdeModulePkg/Core/Pei/Security/Security.c
@@ -1,62 +1,39 @@
-/*++
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+/** @file
+ EFI PEI Core Security services
-Module Name:
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
- Security.c
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Abstract:
+**/
- EFI PEI Core Security services
+#include "PeiMain.h"
---*/
-#include
-
-STATIC
-EFI_STATUS
-EFIAPI
-SecurityPpiNotifyCallback (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
- IN VOID *Ppi
- );
-
-static EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
+EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
- &gEfiPeiSecurityPpiGuid,
+ &gEfiPeiSecurity2PpiGuid,
SecurityPpiNotifyCallback
};
+/**
+ Initialize the security services.
+
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param OldCoreData Pointer to the old core data.
+ NULL if being run in non-permament memory mode.
+
+**/
VOID
InitializeSecurityServices (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_CORE_INSTANCE *OldCoreData
)
-/*++
-
-Routine Description:
-
- Initialize the security services.
-
-Arguments:
-
- PeiServices - The PEI core services table.
- OldCoreData - Pointer to the old core data.
- NULL if being run in non-permament memory mode.
-Returns:
-
- None
-
---*/
{
if (OldCoreData == NULL) {
PeiServicesNotifyPpi (&mNotifyList);
@@ -64,7 +41,18 @@ Returns:
return;
}
-STATIC
+/**
+
+ Provide a callback for when the security PPI is installed.
+ This routine will cache installed security PPI into PeiCore's private data.
+
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
+ @param NotifyDescriptor The descriptor for the notification event.
+ @param Ppi Pointer to the PPI in question.
+
+ @return Always success
+
+**/
EFI_STATUS
EFIAPI
SecurityPpiNotifyCallback (
@@ -72,23 +60,6 @@ SecurityPpiNotifyCallback (
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
-/*++
-
-Routine Description:
-
- Provide a callback for when the security PPI is installed.
-
-Arguments:
-
- PeiServices - The PEI core services table.
- NotifyDescriptor - The descriptor for the notification event.
- Ppi - Pointer to the PPI in question.
-
-Returns:
-
- EFI_SUCCESS - The function is successfully processed.
-
---*/
{
PEI_CORE_INSTANCE *PrivateData;
@@ -96,68 +67,62 @@ Returns:
// Get PEI Core private data
//
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
-
+
//
// If there isn't a security PPI installed, use the one from notification
//
if (PrivateData->PrivateSecurityPpi == NULL) {
- PrivateData->PrivateSecurityPpi = (EFI_PEI_SECURITY_PPI *)Ppi;
+ PrivateData->PrivateSecurityPpi = (EFI_PEI_SECURITY2_PPI *)Ppi;
}
return EFI_SUCCESS;
}
-EFI_STATUS
-VerifyPeim (
- IN EFI_PEI_SERVICES **PeiServices,
- IN EFI_FFS_FILE_HEADER *CurrentPeimAddress
- )
-/*++
-
-Routine Description:
-
+/**
Provide a callout to the security verification service.
-Arguments:
-
- PeiServices - The PEI core services table.
- CurrentPeimAddress - Pointer to the Firmware File under investigation.
-
-Returns:
+ @param PrivateData PeiCore's private data structure
+ @param VolumeHandle Handle of FV
+ @param FileHandle Handle of PEIM's ffs
+ @param AuthenticationStatus Authentication status
- EFI_SUCCESS - Image is OK
- EFI_SECURITY_VIOLATION - Image is illegal
-
---*/
+ @retval EFI_SUCCESS Image is OK
+ @retval EFI_SECURITY_VIOLATION Image is illegal
+ @retval EFI_NOT_FOUND If security PPI is not installed.
+**/
+EFI_STATUS
+VerifyPeim (
+ IN PEI_CORE_INSTANCE *PrivateData,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN UINT32 AuthenticationStatus
+ )
{
- PEI_CORE_INSTANCE *PrivateData;
EFI_STATUS Status;
- UINT32 AuthenticationStatus;
- BOOLEAN StartCrisisRecovery;
-
- //
- // Set a default authentication state
- //
- AuthenticationStatus = 0;
-
- //
- // get security PPI instance from PEI private data
- //
- PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
+ BOOLEAN DeferExection;
+ Status = EFI_NOT_FOUND;
if (PrivateData->PrivateSecurityPpi == NULL) {
- Status = EFI_NOT_FOUND;
+ //
+ // Check AuthenticationStatus first.
+ //
+ if ((AuthenticationStatus & EFI_AUTH_STATUS_IMAGE_SIGNED) != 0) {
+ if ((AuthenticationStatus & (EFI_AUTH_STATUS_TEST_FAILED | EFI_AUTH_STATUS_NOT_TESTED)) != 0) {
+ Status = EFI_SECURITY_VIOLATION;
+ }
+ }
} else {
//
// Check to see if the image is OK
//
Status = PrivateData->PrivateSecurityPpi->AuthenticationState (
- PeiServices,
+ (CONST EFI_PEI_SERVICES **) &PrivateData->Ps,
PrivateData->PrivateSecurityPpi,
AuthenticationStatus,
- CurrentPeimAddress,
- &StartCrisisRecovery
+ VolumeHandle,
+ FileHandle,
+ &DeferExection
);
- if (StartCrisisRecovery) {
+ if (DeferExection) {
Status = EFI_SECURITY_VIOLATION;
}
}
@@ -165,26 +130,18 @@ Returns:
}
+/**
+ Verify a Firmware volume.
+
+ @param CurrentFvAddress Pointer to the current Firmware Volume under consideration
+
+ @retval EFI_SUCCESS Firmware Volume is legal
+
+**/
EFI_STATUS
VerifyFv (
IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
)
-/*++
-
-Routine Description:
-
- Verify a Firmware volume
-
-Arguments:
-
- CurrentFvAddress - Pointer to the current Firmware Volume under consideration
-
-Returns:
-
- EFI_SUCCESS - Firmware Volume is legal
- EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test
-
---*/
{
//
// Right now just pass the test. Future can authenticate and/or check the