From nobody Wed Apr 24 00:56:28 2024 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+89433+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+89433+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1651255523; cv=none; d=zohomail.com; s=zohoarc; b=AQ/QOljRD3iXPESZU0/fcNlZXdsJgM9sywbJu5qaFVhM8+FYWeIH79k1jyLfqDXn6u4ArZ2/IeGG9O4Jt2oHJsmCqLM7MSi9wIc0ds229C7GFDu96qtlIqahJ9N4/MBvloGkblgkam+2a0DA7xAn+o+dfax2qtZuRX6dnsLN/LY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651255523; 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=TEQf1NFisXPBXtk3Jx3wNPW9n01J7wM01x2gH5GjVxA=; b=UzLX+4yulpe6FbdayOibrsit9OukMyEeq1RP+wfRhcHUpSTZJmjr6OzGx3FRl4XddgS+1gCXSWApT5TTJUzqf+D4aiyuZZx4yxAKdKWbBkTHkRxRAIE7Igj/ZicJD6V95eec9T2xlKybPZyGlSmkvXnEbZt+xbL4miBdB83BIV4= 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+89433+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 1651255523574970.4798545988962; Fri, 29 Apr 2022 11:05:23 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OTrgYY1788612xDtbqwmJ0p4; Fri, 29 Apr 2022 11:05:23 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.13562.1651255521776053976 for ; Fri, 29 Apr 2022 11:05:21 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10332"; a="266550644" X-IronPort-AV: E=Sophos;i="5.91,186,1647327600"; d="scan'208";a="266550644" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 11:05:20 -0700 X-IronPort-AV: E=Sophos;i="5.91,186,1647327600"; d="scan'208";a="514955733" X-Received: from jvang-mobl.amr.corp.intel.com ([10.212.198.238]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 11:05:19 -0700 From: "Judah Vang" To: devel@edk2.groups.io Cc: Jian J Wang , Jiewen Yao , Nishant C Mistry Subject: [edk2-devel] [Patch v2 15/28] SecurityPkg: Add VariableKey library function Date: Fri, 29 Apr 2022 11:04:17 -0700 Message-Id: <20220429180430.3292-16-judah.vang@intel.com> In-Reply-To: <20220429180430.3292-1-judah.vang@intel.com> References: <20220429180430.3292-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: p2IlYmSbbPV54STEgiQHHJ1Jx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1651255523; bh=PGd188di8LGODHdcElbPtUT2G1JqEQBZnVn0GHPye6k=; h=Cc:Date:From:Reply-To:Subject:To; b=jr0jhF+01E5IXfq4uQHFwjgfM77nSiouNsGPOTkROS9xFdcL8WU/r7BiztGbl9JfkmM JOqnjizk+PgaNZHKlAK413jXBD3PW+Y9cogzeq3gz/1G5oK782ZBHRvfl8dVpKkFow6d6 WIV+MCi/bYOZEs20uce4O5pHoaSTV/W4k+I= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1651255524950100039 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 (#89433): https://edk2.groups.io/g/devel/message/89433 Mute This Topic: https://groups.io/mt/90781903/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-