From nobody Tue Feb 10 05:10:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+92360+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92360+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1660200858; cv=none; d=zohomail.com; s=zohoarc; b=UnB/vhXhJ8B57X84GsJ7Wj526rHSAbObSAHAsqEsrOlaLRDARZ+dHqG++iz0hEmnJVqwV92RAE4W1HTXNwfortjpH+gAz5fK557Yyauh/I6T83GJ1ODNnjWylGsGSZNMsdsv02r4NaW3hZhDMz7ZAdKyXHauHBj5OHMJTb9XDb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660200858; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Py5P6iRnT71KoOE0hhb/fqvw9COoDjYxypMlCVyVdMI=; b=hfv3j/a57sdI9egsxNQ7/XecW/ivJgRnuhxSZwKDBb43KkCnHJvtge2trDQTrwSppKg+jcCmscAycKy1nXj9RCl7uwvWZjfHhyUzikTZXv+xe/52wuzuWj8LNpzkKBgV4NGZLd5INh05T0grqGQEoMJAOKSiW/H2rhF4j8cj/9s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+92360+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1660200858830569.67102194496; Wed, 10 Aug 2022 23:54:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CEAfYY1788612xGKNtFiKGA1; Wed, 10 Aug 2022 23:54:18 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web08.3540.1660200857329267552 for ; Wed, 10 Aug 2022 23:54:17 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10435"; a="377565823" X-IronPort-AV: E=Sophos;i="5.93,228,1654585200"; d="scan'208";a="377565823" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2022 23:54:16 -0700 X-IronPort-AV: E=Sophos;i="5.93,228,1654585200"; d="scan'208";a="673586407" X-Received: from moisespe-mobl.amr.corp.intel.com (HELO jvang-mobl.amr.corp.intel.com) ([10.212.171.64]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2022 23:54:16 -0700 From: "Judah Vang" To: devel@edk2.groups.io Cc: Jian J Wang , Jiewen Yao , Nishant C Mistry Subject: [edk2-devel] [PATCH v4 16/28] SecurityPkg: Add VariableKey library function Date: Wed, 10 Aug 2022 23:53:25 -0700 Message-Id: <20220811065337.2068-17-judah.vang@intel.com> In-Reply-To: <20220811065337.2068-1-judah.vang@intel.com> References: <20220811065337.2068-1-judah.vang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,judah.vang@intel.com X-Gm-Message-State: BsZpc3zdMQnDtInRFABTgmpQx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1660200858; bh=w+sVBTnQYPKELgZ/i8Hdmis6MRIcH2KeEuy7oIQd1s4=; h=Cc:Date:From:Reply-To:Subject:To; b=gHDV2Qb7e4OrG2doNLb1Z9kqJ3FoPyQdsX1S3Vq/Gnb3rcLNXIfBXaGwFsAeNG4oRoE lVPP5XvgXuqGEaZwygTcthnjnyIG6EtHgoBV4ojPM7n7c1bIJT+dyVI4bgakwfjjZIF1S yd4bVroa5kNIObCjBAm9VNf3gy9NVpmy6L4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1660200859870100063 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2594 Provide function that retrieves the key for protected variables. Cc: Jian J Wang Cc: Jiewen Yao Cc: Nishant C Mistry Signed-off-by: Jian J Wang Signed-off-by: Nishant C Mistry Signed-off-by: Judah Vang --- SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf | 36 ++++++++++++ SecurityPkg/Library/VariableKeyLib/VariableKeyLib.c | 59 +++++++++++++++= +++++ 2 files changed, 95 insertions(+) diff --git a/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf b/Securi= tyPkg/Library/VariableKeyLib/VariableKeyLib.inf new file mode 100644 index 000000000000..f62c80ce9943 --- /dev/null +++ b/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf @@ -0,0 +1,36 @@ +## @file +# Provides default implementation of VariableKeyLib. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010029 + BASE_NAME =3D VariableKeyLib + FILE_GUID =3D 7DF5A0BA-1DBB-4E67-A9F7-9FCCB1F9D250 + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D VariableKeyLib + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 Arm AArch64 +# + +[Sources] + VariableKeyLib.c + +[Packages] + MdePkg/MdePkg.dec + SecurityPkg/SecurityPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + +[PpiS] + gKeyServicePpiGuid ## CONSUMES + diff --git a/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.c b/Security= Pkg/Library/VariableKeyLib/VariableKeyLib.c new file mode 100644 index 000000000000..31b22782cb0c --- /dev/null +++ b/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.c @@ -0,0 +1,59 @@ +/** @file + VariableKeyLib implementation. + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include + +#include + +#define VAR_KEY_SALT L"Key for RPMC Variable" +#define VAR_KEY_SALT_SIZE sizeof (VAR_KEY_SALT) + +/** + Retrieves the key for integrity and/or confidentiality of variables. + + @param[out] VariableKey A pointer to pointer for the variabl= e key buffer. + @param[in] VariableKeySize The size in bytes of the variable ke= y. + + @retval EFI_SUCCESS The variable key was returned. + @retval EFI_DEVICE_ERROR An error occurred while attempting= to get the variable key. + @retval EFI_ACCESS_DENIED The function was invoked after loc= king the key interface. + @retval EFI_UNSUPPORTED The variable key is not supported = in the current boot configuration. +**/ +EFI_STATUS +EFIAPI +GetVariableKey ( + OUT VOID *VariableKey, + IN UINTN VariableKeySize + ) +{ + EFI_STATUS Status; + KEY_SERVICE_PPI *KeyService; + + Status =3D PeiServicesLocatePpi ( + &gKeyServicePpiGuid, + 0, + NULL, + (void **)&KeyService + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + Status =3D KeyService->GenerateKey ( + (UINT8 *)VAR_KEY_SALT, + VAR_KEY_SALT_SIZE, + VariableKey, + VariableKeySize + ); + return Status; +} --=20 2.35.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#92360): https://edk2.groups.io/g/devel/message/92360 Mute This Topic: https://groups.io/mt/92953542/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-