From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mx.groups.io with SMTP id smtpd.web09.5195.1625056470740325012 for ; Wed, 30 Jun 2021 05:34:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=yIRTytbi; spf=none, err=SPF record not found (domain: semihalf.com, ip: 209.85.167.53, mailfrom: gjb@semihalf.com) Received: by mail-lf1-f53.google.com with SMTP id a11so4747396lfg.11 for ; Wed, 30 Jun 2021 05:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UDCd230BH4VfXXkCXlIkcRL4rECT9g7fjkkDoXgyKbA=; b=yIRTytbiXhH/K3rmUWCK9oggP/0VKMoeXEROCP0lF7z3U0V/cCAVJa7a0HVyfNp8zV gNq7H8j64O+cPejtqpGEXN/BWafcJRjYyqItQq0YkU8721dhyOKGspa/L8NCTQxeVswV K+6z9DmcK8tUN32+ah7cFth5Z19OzE1UvUK35mu5kxFn+Uq3Rssqi4ipHtAqZd0Du3Iz FRpzuv5Cp/mLE2xlr9u/h5gpWtSSin7BFyRuBplRPB6IOWRNI0NV3nAz+3BBFIes0pfh 8ZULO4fR9+PnCsv4x5CnvIS94iqV/cDylH5X5rXSS9iKlLNbTlEnOoISmxRh05+J4Uxl 8f+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UDCd230BH4VfXXkCXlIkcRL4rECT9g7fjkkDoXgyKbA=; b=RsUvuRXzoRzNW0SF1CAG0yQNVCoMb5zJMba5Klb/ef8HxOwMxcNu3a3MWw03NbKYcd t9zQCFoj5eJf0yPYsNYrMN3WyTw80ulpILuAorDgpe6QsX4dePo1zpjb4COBIzSK00/F nnkXCYZiwpIXfM1VM+pWzCCErFwSOlKawro/oEYGJdWdgbq2zQcfr5bzH5zxJy4nWJeT ZLXtSkH4yH7yuC55agoqgdEv59b/2uEIMsALS9Ih8GQChPP9Tyx+u4vqCAtdAedxBNwI ks2vRO5S0RN2jlgj+sNKnV88Qn0BPe4HEeE3Soq1EGm3hJ8m4EexInAoRsDq25Klzgjr Qx8Q== X-Gm-Message-State: AOAM531b3uHI7JwhT8QrVEaOb4Gs+7OmUPH1ypYKDoA5BiXpH0TOa2yD FSfI5vPNev4siYfsecC+e0m2Ml1KBzuAUxgR X-Google-Smtp-Source: ABdhPJxOeKD/G0IhbtdHNhKlcHtnEbeDI3qZCRFvtzS3mRFXNoO1/bqlIRNOdRc9N2SF5G9M/88IuA== X-Received: by 2002:a05:6512:536:: with SMTP id o22mr23953517lfc.370.1625056468722; Wed, 30 Jun 2021 05:34:28 -0700 (PDT) Return-Path: Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id d29sm1285624lfv.20.2021.06.30.05.34.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 05:34:28 -0700 (PDT) From: "Grzegorz Bernacki" To: devel@edk2.groups.io Cc: leif@nuviainc.com, ardb+tianocore@kernel.org, Samer.El-Haj-Mahmoud@arm.com, sunny.Wang@arm.com, mw@semihalf.com, upstream@semihalf.com, jiewen.yao@intel.com, jian.j.wang@intel.com, min.m.xu@intel.com, lersek@redhat.com, sami.mujawar@arm.com, afish@apple.com, ray.ni@intel.com, jordan.l.justen@intel.com, rebecca@bsdio.com, grehan@freebsd.org, thomas.abraham@arm.com, chasel.chiu@intel.com, nathaniel.l.desimone@intel.com, gaoliming@byosoft.com.cn, eric.dong@intel.com, michael.d.kinney@intel.com, zailiang.sun@intel.com, yi.qian@intel.com, graeme@nuviainc.com, rad@semihalf.com, pete@akeo.ie, Grzegorz Bernacki Subject: [PATCH v4 0/12] Secure Boot default keys Date: Wed, 30 Jun 2021 14:34:00 +0200 Message-Id: <20210630123412.996158-1-gjb@semihalf.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patchset adds support for initialization of default Secure Boot variables based on keys content embedded in flash binary. This feature is active only if Secure Boot is enabled and DEFAULT_KEY is defined. The patchset consist also application to enroll keys from default variables and secure boot menu change to allow user to reset key content to default values. Discussion on design can be found at: https://edk2.groups.io/g/rfc/topic/82139806#600 I also added patch for RPi4 which enables this feature for that platform. Built with: GCC - RISC-V (U500, U540) [requires fixes in dsc to build] - Intel (Vlv2TbltDevicePkg (X64/IA32), Quark, MinPlatformPkg, EmulatorPkg (X64), Bhyve, OvmfPkg (X64/IA32)) - ARM (Sgi75,SbsaQemu,DeveloperBox, RPi3/RPi4) RISC-V, Quark, Vlv2TbltDevicePkg, Bhyve requires additional fixes to be built, will be post on edk2 maillist later VS2019 - Intel (OvmfPkgX64) Test with: GCC5/RPi4 VS2019/OvmfX64 (requires changes to enable feature) Tests: 1. Try to enroll key in incorrect format. 2. Enroll with only PKDefault keys specified. 3. Enroll with all keys specified. 4. Enroll when keys are enrolled. 5. Reset keys values. 6. Running signed & unsigned app after enrollment. Changes since v1: - change names: SecBootVariableLib => SecureBootVariableLib SecBootDefaultKeysDxe => SecureBootDefaultKeysDxe SecEnrollDefaultKeysApp => EnrollFromDefaultKeysApp - change name of function CheckSetupMode to GetSetupMode - remove ShellPkg dependecy from EnrollFromDefaultKeysApp - rebase to master Changes since v2: - fix coding style for functions headers in SecureBootVariableLib.h - add header to SecureBootDefaultKeys.fdf.inc - remove empty line spaces in SecureBootDefaultKeysDxe files - revert FAIL macro in EnrollFromDefaultKeysApp - remove functions duplicates and add SecureBootVariableLib to platforms which used it Changes since v3: - move SecureBootDefaultKeys.fdf.inc to ArmPlatformPkg - leave duplicate of CreateTimeBasedPayload in PlatformVarCleanupLib - fix typo in guid description Grzegorz Bernacki (12): [edk2] SecurityPkg: Create library for setting Secure Boot variables. ArmVirtPkg: add SecureBootVariableLib class resolution Intel Platforms: add SecureBootVariableLib class resolution ArmPlatformPkg: Create include file for default key content. SecurityPkg: Add SecureBootDefaultKeysDxe driver SecurityPkg: Add EnrollFromDefaultKeys application. SecurityPkg: Add new modules to Security package. SecurityPkg: Add option to reset secure boot keys. [edk2-platform] Intel Platforms: add SecureBootVariableLib class resolution ARM Silicon and Platforms: add SecureBootVariableLib class resolution RISC-V Platforms: add SecureBootVariableLib class resolution Platform/RaspberryPi: Enable default Secure Boot variables initialization SecurityPkg/SecurityPkg.dec | 14 + ArmVirtPkg/ArmVirt.dsc.inc | 1 + EmulatorPkg/EmulatorPkg.dsc | 1 + OvmfPkg/Bhyve/BhyveX64.dsc | 1 + OvmfPkg/OvmfPkgIa32.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 1 + OvmfPkg/OvmfPkgX64.dsc | 1 + SecurityPkg/SecurityPkg.dsc | 4 + SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.inf | 47 + SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf | 79 ++ SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf | 2 + SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.inf | 45 + SecurityPkg/Include/Library/SecureBootVariableLib.h | 251 +++++ SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigNvData.h | 2 + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfig.vfr | 6 + SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.c | 109 +++ SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.c | 980 ++++++++++++++++++++ SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigImpl.c | 343 ++++--- SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.c | 68 ++ ArmPlatformPkg/SecureBootDefaultKeys.fdf.inc | 70 ++ SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.uni | 16 + SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigStrings.uni | 4 + SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.uni | 16 + Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc | 1 + Platform/Intel/MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc | 1 + Platform/Intel/QuarkPlatformPkg/Quark.dsc | 1 + Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc | 1 + Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc | 3 ++- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 1 + Platform/RaspberryPi/RPi3/RPi3.dsc | 1 + Platform/RaspberryPi/RPi4/RPi4.dsc | 4 ++++ Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc | 1 + Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc | 1 + Platform/Socionext/DeveloperBox/DeveloperBox.dsc | 4 ++++ Platform/RaspberryPi/RPi4/RPi4.fdf 35 files changed, 1894 insertions(+), 189 deletions(-) create mode 100644 SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.inf create mode 100644 SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf create mode 100644 SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.inf create mode 100644 SecurityPkg/Include/Library/SecureBootVariableLib.h create mode 100644 SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.c create mode 100644 SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.c create mode 100644 SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.c create mode 100644 ArmPlatformPkg/SecureBootDefaultKeys.fdf.inc create mode 100644 SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.uni create mode 100644 SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.uni -- 2.25.1