From nobody Tue Feb 10 15:29:43 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+95996+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+95996+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1667720149; cv=none; d=zohomail.com; s=zohoarc; b=doc6SPfE0PWjhoFOMGVcbvgYeQkbvJkbZNYJiDgbPZg/GdRFllEM6S3hT39eFoIr5B311N2OoIE8hjMqGtlN9qia7mm01oLMpB85lO9uU0tmFGg1aGu20uRQ/0m4uIcBpG7Z0sj5BI9iLdBg3Jwfow61P6wnNWtfwbhnJfAFD80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1667720149; 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=CGj9hC6bNckKaJFW1I34qqhvh4ustgJyOZjvB2s/D6w=; b=RyXL5wvYMnn9xoxCmOWovTv+VGUj9NESvQ2PsJ1VcMjieAJu6IM1BmCt0hQkMTYiPsRpjUouS7bbeZ9Wmjr1pqbARR7S4plpEauGeRbxlVC7+SimJIdUXuUDuXAPXnlCypQolCD4lsy5QtkaSyu1b+W0nGK1ML0qynW49JO7CdQ= 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+95996+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 1667720149450947.8848301132033; Sun, 6 Nov 2022 00:35:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iv1RYY1788612xtMrDm35jKr; Sun, 06 Nov 2022 00:35:48 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web10.14307.1667720143790244062 for ; Sun, 06 Nov 2022 00:35:44 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10522"; a="396534279" X-IronPort-AV: E=Sophos;i="5.96,142,1665471600"; d="scan'208";a="396534279" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2022 00:35:32 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10522"; a="810513483" X-IronPort-AV: E=Sophos;i="5.96,142,1665471600"; d="scan'208";a="810513483" X-Received: from jvang-mobl.amr.corp.intel.com ([10.209.139.244]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2022 00:35:31 -0700 From: "Judah Vang" To: devel@edk2.groups.io Cc: Jian J Wang , Jiewen Yao , Nishant C Mistry Subject: [edk2-devel] [PATCH v5 16/19] SecurityPkg: Add VariableKey library function Date: Sun, 6 Nov 2022 00:35:06 -0700 Message-Id: <20221106073509.3071-17-judah.vang@intel.com> In-Reply-To: <20221106073509.3071-1-judah.vang@intel.com> References: <20221106073509.3071-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: hRLlQnzpnRpWoXDQy33Zsa9Xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1667720148; bh=By/4itaLEZ3PBj+Rquv6mYDNF6b0hdcpSaEG+o5Yl3E=; h=Cc:Date:From:Reply-To:Subject:To; b=AgAaKPPkjKcAaO86ZpB5kvNGa15mPE/Zxs+iXZpL0/vfb8Qg73Huw0X6w2gIdvovVfA mQiLMJf6VLsLY3Y4kc/ecqn3sxZqPBiAnncncS0bm0W/uyQP3pS6Fjl45o0KVKAYEIwvU 3VPEr17nGb+poPzJM/7LauN8nvV4mssJziE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1667720150892100057 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2594 V5: Applied code review comments. Add PEIM to library class V1: 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..a9f7bb5afefd --- /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|PEIM + +# +# 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 (#95996): https://edk2.groups.io/g/devel/message/95996 Mute This Topic: https://groups.io/mt/94840832/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-