[edk2-devel] [PATCH v5 07/10] SecurityPkg: Add SecureBootDefaultKeysDxe driver
Yao, Jiewen
jiewen.yao at intel.com
Tue Jul 6 11:53:43 UTC 2021
Reviewed-by: Jiewen Yao <Jiewen.yao at intel.com>
> -----Original Message-----
> From: Grzegorz Bernacki <gjb at semihalf.com>
> Sent: Thursday, July 1, 2021 5:18 PM
> To: devel at edk2.groups.io
> Cc: leif at nuviainc.com; ardb+tianocore at kernel.org; Samer.El-Haj-
> Mahmoud at arm.com; sunny.Wang at arm.com; mw at semihalf.com;
> upstream at semihalf.com; Yao, Jiewen <jiewen.yao at intel.com>; Wang, Jian J
> <jian.j.wang at intel.com>; Xu, Min M <min.m.xu at intel.com>;
> lersek at redhat.com; sami.mujawar at arm.com; afish at apple.com; Ni, Ray
> <ray.ni at intel.com>; Justen, Jordan L <jordan.l.justen at intel.com>;
> rebecca at bsdio.com; grehan at freebsd.org; thomas.abraham at arm.com; Chiu,
> Chasel <chasel.chiu at intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone at intel.com>; gaoliming at byosoft.com.cn; Dong, Eric
> <eric.dong at intel.com>; Kinney, Michael D <michael.d.kinney at intel.com>; Sun,
> Zailiang <zailiang.sun at intel.com>; Qian, Yi <yi.qian at intel.com>;
> graeme at nuviainc.com; rad at semihalf.com; pete at akeo.ie; Grzegorz Bernacki
> <gjb at semihalf.com>; Sunny Wang <sunny.wang at arm.com>
> Subject: [PATCH v5 07/10] SecurityPkg: Add SecureBootDefaultKeysDxe driver
>
> This driver initializes default Secure Boot keys and databases
> based on keys embedded in flash.
>
> Signed-off-by: Grzegorz Bernacki <gjb at semihalf.com>
> Reviewed-by: Sunny Wang <sunny.wang at arm.com>
> Reviewed-by: Pete Batard <pete at akeo.ie>
> Tested-by: Pete Batard <pete at akeo.ie> on Raspberry Pi
> ---
>
> SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefa
> ultKeysDxe.inf | 45 +++++++++++++
>
> SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefa
> ultKeysDxe.c | 68 ++++++++++++++++++++
>
> SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefa
> ultKeysDxe.uni | 16 +++++
> 3 files changed, 129 insertions(+)
> create mode 100644
> SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefa
> ultKeysDxe.inf
> create mode 100644
> SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefa
> ultKeysDxe.c
> create mode 100644
> SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefa
> ultKeysDxe.uni
>
> diff --git
> a/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.inf
> b/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.inf
> new file mode 100644
> index 0000000000..0af7563a3b
> --- /dev/null
> +++
> b/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.inf
> @@ -0,0 +1,45 @@
> +## @file
> +# Initializes Secure Boot default keys
> +#
> +# Copyright (c) 2021, ARM Ltd. All rights reserved.<BR>
> +# Copyright (c) 2021, Semihalf All rights reserved.<BR>
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +[Defines]
> + INF_VERSION = 0x00010005
> + BASE_NAME = SecureBootDefaultKeysDxe
> + FILE_GUID = C937FCB7-25AC-4376-89A2-4EA8B317DE83
> + MODULE_TYPE = DXE_DRIVER
> + ENTRY_POINT = SecureBootDefaultKeysEntryPoint
> +
> +#
> +# VALID_ARCHITECTURES = IA32 X64 AARCH64
> +#
> +[Sources]
> + SecureBootDefaultKeysDxe.c
> +
> +[Packages]
> + MdePkg/MdePkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + SecurityPkg/SecurityPkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + MemoryAllocationLib
> + UefiDriverEntryPoint
> + DebugLib
> + SecureBootVariableLib
> +
> +[Guids]
> + ## SOMETIMES_PRODUCES ## Variable:L"PKDefault"
> + ## SOMETIMES_PRODUCES ## Variable:L"KEKDefault"
> + ## SOMETIMES_PRODUCES ## Variable:L"dbDefault"
> + ## SOMETIMES_PRODUCES ## Variable:L"dbtDefault"
> + ## SOMETIMES_PRODUCES ## Variable:L"dbxDefault"
> + gEfiGlobalVariableGuid
> +
> +[Depex]
> + gEfiVariableArchProtocolGuid AND
> + gEfiVariableWriteArchProtocolGuid
> diff --git
> a/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.c
> b/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.c
> new file mode 100644
> index 0000000000..12a18dc352
> --- /dev/null
> +++
> b/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.c
> @@ -0,0 +1,68 @@
> +/** @file
> + This driver init default Secure Boot variables
> +
> +Copyright (c) 2021, ARM Ltd. All rights reserved.<BR>
> +Copyright (c) 2021, Semihalf All rights reserved.<BR>
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#include <Guid/AuthenticatedVariableFormat.h>
> +#include <Guid/ImageAuthentication.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Library/SecureBootVariableLib.h>
> +
> +/**
> + The entry point for SecureBootDefaultKeys driver.
> +
> + @param[in] ImageHandle The image handle of the driver.
> + @param[in] SystemTable The system table.
> +
> + @retval EFI_ALREADY_STARTED The driver already exists in system.
> + @retval EFI_OUT_OF_RESOURCES Fail to execute entry point due to lack of
> resources.
> + @retval EFI_SUCCESS All the related protocols are installed on the
> driver.
> + @retval Others Fail to get the SecureBootEnable variable.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SecureBootDefaultKeysEntryPoint (
> + IN EFI_HANDLE ImageHandle,
> + IN EFI_SYSTEM_TABLE *SystemTable
> + )
> +{
> + EFI_STATUS Status;
> +
> + Status = SecureBootInitPKDefault ();
> + if (EFI_ERROR (Status)) {
> + DEBUG((DEBUG_ERROR, "%a: Cannot initialize PKDefault: %r\n",
> __FUNCTION__, Status));
> + return Status;
> + }
> +
> + Status = SecureBootInitKEKDefault ();
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: Cannot initialize KEKDefault: %r\n",
> __FUNCTION__, Status));
> + return Status;
> + }
> + Status = SecureBootInitdbDefault ();
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_ERROR, "%a: Cannot initialize dbDefault: %r\n",
> __FUNCTION__, Status));
> + return Status;
> + }
> +
> + Status = SecureBootInitdbtDefault ();
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_INFO, "%a: dbtDefault not initialized\n", __FUNCTION__));
> + }
> +
> + Status = SecureBootInitdbxDefault ();
> + if (EFI_ERROR (Status)) {
> + DEBUG ((DEBUG_INFO, "%a: dbxDefault not initialized\n", __FUNCTION__));
> + }
> +
> + return Status;
> +}
> diff --git
> a/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.uni
> b/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.uni
> new file mode 100644
> index 0000000000..2b6cb7f950
> --- /dev/null
> +++
> b/SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootD
> efaultKeysDxe.uni
> @@ -0,0 +1,16 @@
> +// /** @file
> +// Provides the capability to intialize Secure Boot default variables
> +//
> +// Module which initializes Secure boot default variables.
> +//
> +// Copyright (c) 2021, ARM Ltd. All rights reserved.<BR>
> +// Copyright (c) 2021, Semihalf All rights reserved.<BR>
> +//
> +// SPDX-License-Identifier: BSD-2-Clause-Patent
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT #language en-US "Module which
> initializes Secure boot default variables"
> +
> +#string STR_MODULE_DESCRIPTION #language en-US "This module reads
> embedded keys and initializes Secure Boot default variables."
> --
> 2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#77523): https://edk2.groups.io/g/devel/message/77523
Mute This Topic: https://groups.io/mt/83912195/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list