From nobody Sat Apr 20 12:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63063+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63063+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595391134; cv=none; d=zohomail.com; s=zohoarc; b=RYSFJdbC+QWrjJX7fQ11WktLxK7BAWAnBgCssCfXv4CMdyhDs+6w++XbR4RFe/ttMRhSEIWQ8iHkVN1j/r6/aqjPQtt5+MAMwYMNR60n2b1TMC3mHDeo+ZID/SzXkML7O6z8Bvrf8qi6YQBrQklh+XwMiHUeAYSzSm6dkC6s7uw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595391134; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=iWnnJSJorNp5b1pTs8/FMQb4qY0zalhAtgdwmbmCV3Y=; b=QbRd4sblTVYl/iEBFBhfli+2/gu/GtxtdMkhT9iXf8SG5WwVRXr6nNivFNJtdLxpmwdmtUMtL+ZoyJCLTQN4F3UTsj1ZIQgGn3a2aI22aXQmt4Nqc7/bdNb+fh0TQsbfac/mtnuZZ4FR0s0ZnkutEicprlVBeLbljOkQsyV9EHg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63063+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595391134862433.3840394287813; Tue, 21 Jul 2020 21:12:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id GCWuYY1788612xaAbzXiCABV; Tue, 21 Jul 2020 21:12:14 -0700 X-Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web11.11889.1595391132846714831 for ; Tue, 21 Jul 2020 21:12:13 -0700 IronPort-SDR: 7sojs80ieYNM0fyzS0+s45TZzZxKQLEQfpMRh/HX5h59To+VdfvMTYSu567I8WS7H9ckNwCuaO EIMaX7bsxDag== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="168412575" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="168412575" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 21:12:13 -0700 IronPort-SDR: HlubdpsSxUBsJsuxuXUSviUswr5cgwis2XEudgq6yLSINOPrVMZ1uXcnY73Rw6i50Ma4xt1lbf /S2nFmRE/GYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="432240887" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga004.jf.intel.com with ESMTP; 21 Jul 2020 21:12:11 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang Subject: [edk2-devel] [PATCH v5 1/6] SecurityPkg/TcgPpi: Add TcgPpi header file. Date: Wed, 22 Jul 2020 12:12:01 +0800 Message-Id: <20200722041206.12199-2-qi1.zhang@intel.com> In-Reply-To: <20200722041206.12199-1-qi1.zhang@intel.com> References: <20200722041206.12199-1-qi1.zhang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,qi1.zhang@intel.com X-Gm-Message-State: zfKs4hHh62SxVNCzbELov4fox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595391134; bh=kYUDdggZIZQQagXvozThPK6FIU+xLdBJNx19YGN9E7Y=; h=Cc:Date:From:Reply-To:Subject:To; b=KZUQq5shTQdsl+BQUBgWHiSRJQpJc46DFSr13uUVy88ZCxpibzFQMyGHccaUlYQ/WTQ A+L/5XgZcnKrsuJ0+lCb4cwjt7UDf8d9nui7zvFAikt/UoLTFqqlUyKWVaOLYGFziQTTO UvGoPd62bZDHudXcXcq1TDgFJZJ7q970bEg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Jiewen Yao REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2841 Cc: Jiewen Yao Cc: Jian J Wang Cc: Qi Zhang Signed-off-by: Jiewen Yao --- SecurityPkg/Include/Ppi/Tcg.h | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 SecurityPkg/Include/Ppi/Tcg.h diff --git a/SecurityPkg/Include/Ppi/Tcg.h b/SecurityPkg/Include/Ppi/Tcg.h new file mode 100644 index 0000000000..0e943f2465 --- /dev/null +++ b/SecurityPkg/Include/Ppi/Tcg.h @@ -0,0 +1,60 @@ +/** @file + TCG PPI services. + +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _TCG_PPI_H_ +#define _TCG_PPI_H_ + +#include + +typedef struct _EDKII_TCG_PPI EDKII_TCG_PPI; + +// +// This bit is shall be set when HashData is the pre-hash digest. +// +#define EDKII_TCG_PRE_HASH 0x0000000000000001 + +/** + Tpm measure and log data, and extend the measurement result into a speci= fic PCR. + + @param[in] This Indicates the calling context + @param[in] Flags Bitmap providing additional information + @param[in] HashData If BIT0 of Flags is 0, it is physical addr= ess of the + start of the data buffer to be hashed, ext= ended, and logged. + If BIT0 of Flags is 1, it is physical addr= ess of the + start of the pre-hash data buffter to be e= xtended, and logged. + The pre-hash data format is TPML_DIGEST_VA= LUES. + @param[in] HashDataLen The length, in bytes, of the buffer refere= nced by HashData. + @param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data struct= ure. + @param[in] NewEventData Pointer to the new event data. + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_UNSUPPORTED TPM device not available. + @retval EFI_OUT_OF_RESOURCES Out of memory. + @retval EFI_DEVICE_ERROR The operation was unsuccessful. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_TCG_HASH_LOG_EXTEND_EVENT)( + IN EDKII_TCG_PPI *This, + IN UINT64 Flags, + IN UINT8 *HashData, + IN UINTN HashDataLen, + IN TCG_PCR_EVENT_HDR *NewEventHdr, + IN UINT8 *NewEventData + ); + +/// +/// The EFI_TCG Protocol abstracts TCG activity. +/// +struct _EDKII_TCG_PPI { + EDKII_TCG_HASH_LOG_EXTEND_EVENT HashLogExtendEvent; +}; + +extern EFI_GUID gEdkiiTcgPpiGuid; + +#endif --=20 2.26.2.windows.1 -=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 (#63063): https://edk2.groups.io/g/devel/message/63063 Mute This Topic: https://groups.io/mt/75718614/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- From nobody Sat Apr 20 12:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63064+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63064+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595391136; cv=none; d=zohomail.com; s=zohoarc; b=KY6ufUrWuuwLTfqME8LNLyzl8ANpNui9MiPmvmxXb9csyXRPHRkZ/tSCKRdpAZiYcac23GoBckPwqRCPJmlMBBXvqXoSDniEqD92gUKRiOSby/VAgd0M5E8/QjR+Wl3X4tMjbv5FJlBx06PyDFaWJHzxgB0W3K/yiuef3Kh0xJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595391136; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=7CZ3k6ra0dEDJjUlzMTbCvxOOqZRsaVuCRJyKDSK59U=; b=T5OPfObz59jXN5MIOa+nhy8KwTYeDFfy3XFwVekTRBI7rUCaoZBkffP077W49uC+54o1uXuqSXdv5Hm70IKzkLZ6vKQv+v7lSOCJjuz8vxu5o44CIHTH+8vmTItnD5cpCOQFI7wnM+9P+abzxKxBrdMbUET1om14x+6xRZOqPcM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63064+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595391136351179.438349151451; Tue, 21 Jul 2020 21:12:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vtsEYY1788612xoalUtusWhD; Tue, 21 Jul 2020 21:12:16 -0700 X-Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web11.11889.1595391132846714831 for ; Tue, 21 Jul 2020 21:12:15 -0700 IronPort-SDR: CVK8AGwDmmuNilFHxiX51xAuIfglrAL0uM5iaR4a48DsCySUdrRja3Ui6gO6bDnJnVny95fnjV haPzQH+eqL8g== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="168412594" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="168412594" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 21:12:15 -0700 IronPort-SDR: P6SFpxmyepJJPwkYlaevSklwEejz1QJrI1f77qk+d/9nj30Fp9ahvxs6rzIuJfcOC/p27VZKGQ 5LvV7DCr3rEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="432240902" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga004.jf.intel.com with ESMTP; 21 Jul 2020 21:12:13 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang Subject: [edk2-devel] [PATCH v5 2/6] SecurityPkg/dec: Add TcgPpi. Date: Wed, 22 Jul 2020 12:12:02 +0800 Message-Id: <20200722041206.12199-3-qi1.zhang@intel.com> In-Reply-To: <20200722041206.12199-1-qi1.zhang@intel.com> References: <20200722041206.12199-1-qi1.zhang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,qi1.zhang@intel.com X-Gm-Message-State: 2bTymzMkf4sWW5D3IZxEaibax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595391136; bh=wibMwtAt4BkigqU+U5V7x/XdqgUq1YUHag3gN4D+1C8=; h=Cc:Date:From:Reply-To:Subject:To; b=SF7nkAZT+u5FVj5AAEj66+doWPwDS/AgBLiCgiP3laOaU25wxx3culAdXeoqgviAvkc XHVaPcdX8drj02g9988fXyCapPS11n90Vp4JCQTj+nk1sN5S415tRHLO0WGlJ+vENW+gE /lfr4YI6XXtdWMPDVoOtqsGN05oi3cPTds0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Jiewen Yao REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2841 Cc: Jiewen Yao Cc: Jian J Wang Cc: Qi Zhang Signed-off-by: Jiewen Yao --- SecurityPkg/SecurityPkg.dec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec index 79d46308ad..42fc48cc1f 100644 --- a/SecurityPkg/SecurityPkg.dec +++ b/SecurityPkg/SecurityPkg.dec @@ -203,6 +203,9 @@ ## Include/Ppi/FirmwareVolumeInfoStoredHashFv.h gEdkiiPeiFirmwareVolumeInfoStoredHashFvPpiGuid =3D {0x7f5e4e31, 0x81b1, = 0x47e5, { 0x9e, 0x21, 0x1e, 0x4b, 0x5b, 0xc2, 0xf6, 0x1d } } =20 + ## Include/Ppi/Tcg.h + gEdkiiTcgPpiGuid =3D {0x57a13b87, 0x133d, 0x4bf3, { 0xbf, 0xf1, 0x1b, 0x= ca, 0xc7, 0x17, 0x6c, 0xf1 } } + # # [Error.gEfiSecurityPkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. --=20 2.26.2.windows.1 -=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 (#63064): https://edk2.groups.io/g/devel/message/63064 Mute This Topic: https://groups.io/mt/75718615/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- From nobody Sat Apr 20 12:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63065+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63065+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595391137; cv=none; d=zohomail.com; s=zohoarc; b=hnKSrLOLLWGUWSuBCQfp3BPDAxK7tgU6QAXu2ZN3WBaboTX3LHXGItH1H9XdSKBTud5ZAyhd+UwrcKtg0fcZ9TSxvl6Qrgn3jUEQaHYCcr8n89UA1SdykW/35xLr7fYUxNkd/lHiXY5nJhSJZAFFN9NYNh43u4b0v8qmnsHFp3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595391137; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=J9oMIi/TRQas/BfsgQcUgxwL78qEdpn09MOof9z+lQg=; b=UX+qJp8V8Gv2Mre+yZJJIXKZX9Yb6EDxxKT5kct5UH4Aq7MCzjFqtq5zIBx0q9u5IEVoBKxnatge2E88Q0j9Ja4Y+WoI0+Rir2D/ZlO6MTomgaerJPRguj1c+WpEMF2czq68KKXkJXu2kdIFPe0anrfPrc54qyXJLlFxP8hKGD0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63065+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595391137852272.5596720547061; Tue, 21 Jul 2020 21:12:17 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 45LMYY1788612xm2S3I0x0f6; Tue, 21 Jul 2020 21:12:17 -0700 X-Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web11.11889.1595391132846714831 for ; Tue, 21 Jul 2020 21:12:17 -0700 IronPort-SDR: OXDn3tzWNUHhRbVAsGi7Y4udhzBccV7jEIBFL9HUIuFh6fE205zGINAQbT5FetrUxPIzvEHZRZ t4N6yO5Ef9UA== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="168412613" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="168412613" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 21:12:16 -0700 IronPort-SDR: Kta9JerlydoYrqkSRlvi7L8nYsMjH3/fSIk9M7bKUAea/Xnq8lqGaG3kvwGA/nQx+92kecUvd4 kQ5ViHbi9dkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="432240920" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga004.jf.intel.com with ESMTP; 21 Jul 2020 21:12:15 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH v5 3/6] SecurityPkg/Tcg: Add TcgPpi Date: Wed, 22 Jul 2020 12:12:03 +0800 Message-Id: <20200722041206.12199-4-qi1.zhang@intel.com> In-Reply-To: <20200722041206.12199-1-qi1.zhang@intel.com> References: <20200722041206.12199-1-qi1.zhang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,qi1.zhang@intel.com X-Gm-Message-State: zYQw6kSgyPpFPs2TlDBuIE2Ex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595391137; bh=+GLhiKWS5nu2GPAIQM0Au/gfiiJxt3cZiCTIAPOvzzw=; h=Cc:Date:From:Reply-To:Subject:To; b=Vgd/rSk6MtnoMiqLdQPeDfs/sjUOdc/SizOl2bw4jIC1oGKzVLlxUT6uSeY7RprT5kC LshVyS2EfebZjFveKwev4elxIGv3kuSAq3K7qoUXt1nuW9nVF7OL8tjqGFKXRFt9dTKwt M162vOK1BTmx2Ky9JRg6OOUcrxyb8ZSj9o0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Jiewen Yao REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2841 Cc: Jiewen Yao Cc: Jian J Wang Cc: Qi Zhang Cc: Rahul Kumar Signed-off-by: Jiewen Yao --- SecurityPkg/Tcg/TcgPei/TcgPei.c | 61 ++++++++++++++++++++++++++++--- SecurityPkg/Tcg/TcgPei/TcgPei.inf | 3 +- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.c b/SecurityPkg/Tcg/TcgPei/TcgPe= i.c index a9a808c9ec..2533388849 100644 --- a/SecurityPkg/Tcg/TcgPei/TcgPei.c +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.c @@ -1,7 +1,7 @@ /** @file Initialize TPM device and measure FVs before handing off control to DXE. =20 -Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include #include @@ -51,6 +52,45 @@ EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = =3D { NULL }; =20 +/** + Do a hash operation on a data buffer, extend a specific TPM PCR with the= hash result, + and build a GUIDed HOB recording the event which will be passed to the D= XE phase and + added into the Event Log. + + @param[in] This Indicates the calling context + @param[in] Flags Bitmap providing additional information. + @param[in] HashData Physical address of the start of the data = buffer + to be hashed, extended, and logged. + @param[in] HashDataLen The length, in bytes, of the buffer refere= nced by HashData. + @param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data struct= ure. + @param[in] NewEventData Pointer to the new event data. + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event. + @retval EFI_DEVICE_ERROR The command was unsuccessful. + +**/ +EFI_STATUS +EFIAPI +HashLogExtendEvent ( + IN EDKII_TCG_PPI *This, + IN UINT64 Flags, + IN UINT8 *HashData, + IN UINTN HashDataLen, + IN TCG_PCR_EVENT_HDR *NewEventHdr, + IN UINT8 *NewEventData + ); + +EDKII_TCG_PPI mEdkiiTcgPpi =3D { + HashLogExtendEvent +}; + +EFI_PEI_PPI_DESCRIPTOR mTcgPpiList =3D { + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gEdkiiTcgPpiGuid, + &mEdkiiTcgPpi +}; + // // Number of firmware blobs to grow by each time we run out of room // @@ -243,7 +283,8 @@ TpmCommHashAll ( and build a GUIDed HOB recording the event which will be passed to the D= XE phase and added into the Event Log. =20 - @param[in] PeiServices Describes the list of possible PEI Service= s. + @param[in] This Indicates the calling context. + @param[in] Flags Bitmap providing additional information. @param[in] HashData Physical address of the start of the data = buffer to be hashed, extended, and logged. @param[in] HashDataLen The length, in bytes, of the buffer refere= nced by HashData. @@ -256,8 +297,10 @@ TpmCommHashAll ( =20 **/ EFI_STATUS +EFIAPI HashLogExtendEvent ( - IN EFI_PEI_SERVICES **PeiServices, + IN EDKII_TCG_PPI *This, + IN UINT64 Flags, IN UINT8 *HashData, IN UINTN HashDataLen, IN TCG_PCR_EVENT_HDR *NewEventHdr, @@ -346,7 +389,8 @@ MeasureCRTMVersion ( TcgEventHdr.EventSize =3D (UINT32) StrSize((CHAR16*)PcdGetPtr (PcdFirmwa= reVersionString)); =20 return HashLogExtendEvent ( - PeiServices, + &mEdkiiTcgPpi, + 0, (UINT8*)PcdGetPtr (PcdFirmwareVersionString), TcgEventHdr.EventSize, &TcgEventHdr, @@ -415,7 +459,8 @@ MeasureFvImage ( TcgEventHdr.EventSize =3D sizeof (FvBlob); =20 Status =3D HashLogExtendEvent ( - (EFI_PEI_SERVICES **) GetPeiServicesTablePointer(), + &mEdkiiTcgPpi, + 0, (UINT8*) (UINTN) FvBlob.BlobBase, (UINTN) FvBlob.BlobLength, &TcgEventHdr, @@ -744,6 +789,12 @@ PeimEntryMP ( Status =3D PeiServicesNotifyPpi (&mNotifyList[0]); ASSERT_EFI_ERROR (Status); =20 + // + // install Tcg Services + // + Status =3D PeiServicesInstallPpi (&mTcgPpiList); + ASSERT_EFI_ERROR (Status); + return Status; } =20 diff --git a/SecurityPkg/Tcg/TcgPei/TcgPei.inf b/SecurityPkg/Tcg/TcgPei/Tcg= Pei.inf index c0bff6e85e..4ab4edd657 100644 --- a/SecurityPkg/Tcg/TcgPei/TcgPei.inf +++ b/SecurityPkg/Tcg/TcgPei/TcgPei.inf @@ -4,7 +4,7 @@ # This module will initialize TPM device, measure reported FVs and BIOS v= ersion. # This module may also lock TPM physical presence and physicalPresenceLif= etimeLock. # -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -67,6 +67,7 @@ gPeiTpmInitializedPpiGuid ## S= OMETIMES_PRODUCES gPeiTpmInitializationDonePpiGuid ## P= RODUCES gEfiEndOfPeiSignalPpiGuid ## S= OMETIMES_CONSUMES ## NOTIFY + gEdkiiTcgPpiGuid ## P= RODUCES =20 [Pcd] gEfiSecurityPkgTokenSpaceGuid.PcdPhysicalPresenceLifetimeLock ## S= OMETIMES_CONSUMES --=20 2.26.2.windows.1 -=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 (#63065): https://edk2.groups.io/g/devel/message/63065 Mute This Topic: https://groups.io/mt/75718616/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- From nobody Sat Apr 20 12:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63066+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63066+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595391140; cv=none; d=zohomail.com; s=zohoarc; b=LWzrFHwszRP8vqOzii/fnKX9cHQ1hTF7fT7qgQjSMw6z5Ml8bczMgDGuOoLk1O0dsrFUoiRXHw1Pde9g8B+Ubltc6YIqlwDhe8vakKJHoyYYaD/bn4r5Z8kl+8lX8Stu3Z8ePX5B5dsAehrZKQLq+lSXNGkEQ3DstJ8N9kfc+Hs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595391140; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=xvLYrS+eaSEsoLApRRGpDL83hAjfc3g1NTPD/seB6Uk=; b=Wq+Xder49ntbv7ffgLG/VrpUtTgAujgbGQ8avUQEGBOP3ConLJPxxYDw/fR/Iveukf9pOJh/2cwOG1Vx1Z54xQJw/gHoYjENa2sfA55+TEgm9Y3Lqkh0ebXFmWcLonpL8U5QoRGtWli/O2T3DdK1E+qqtE7cm5HsW5fJWPR4pig= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63066+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595391140436214.17616176546187; Tue, 21 Jul 2020 21:12:20 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id fVPfYY1788612xitoeFGYLLc; Tue, 21 Jul 2020 21:12:20 -0700 X-Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web11.11889.1595391132846714831 for ; Tue, 21 Jul 2020 21:12:18 -0700 IronPort-SDR: raVTQzTWq3cxcloXZv/T1eFD09yd/ynNWKD7tiR+vRRJao6Y0lQppkTm731zjQV6mhhGDpqoNa Tiwql5Ghe7UQ== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="168412625" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="168412625" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 21:12:18 -0700 IronPort-SDR: KcvrIQaItFS1bXW9WAbKhgjKSl/FWpUu2Of0dCGIOWkLVNZPHFvI4BR3KjKR6EQETquH3HCpqc 5wSELbv5t8UA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="432240933" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga004.jf.intel.com with ESMTP; 21 Jul 2020 21:12:16 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH v5 4/6] SecurityPkg/Tcg2: Add TcgPpi Date: Wed, 22 Jul 2020 12:12:04 +0800 Message-Id: <20200722041206.12199-5-qi1.zhang@intel.com> In-Reply-To: <20200722041206.12199-1-qi1.zhang@intel.com> References: <20200722041206.12199-1-qi1.zhang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,qi1.zhang@intel.com X-Gm-Message-State: UQ3FsRwSnzsVxt64XWKYq02Qx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595391140; bh=dd6QM/vhlc2Q4rZAcez8J3/F2gTB2z4RjGJjHlVXPNg=; h=Cc:Date:From:Reply-To:Subject:To; b=cjysyi2E6xf5xPRs/EsyZ2VrS0tJ0a57pKEcEcPSGozdIwQck13DPOTvWuYW9Z+nEze 50XIN5/Wkf7ygeC0V5JFPFvypnAjPMVB381xaoJebfjIv4GHvDMZCBR2POILjxZfCPXXj Rg1fOsPLn/px2eGcZjGBGzyxJkiSj/UlnQI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Jiewen Yao And do some code clean with updated function REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2841 Cc: Jiewen Yao Cc: Jian J Wang Cc: Qi Zhang Cc: Rahul Kumar Signed-off-by: Jiewen Yao --- SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c | 110 +++++++++++++++++++++------- SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf | 3 +- 2 files changed, 86 insertions(+), 27 deletions(-) diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c b/SecurityPkg/Tcg/Tcg2Pei/Tc= g2Pei.c index 19b8e4b318..592f760057 100644 --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c @@ -1,7 +1,7 @@ /** @file Initialize TPM2 device and measure FVs before handing off control to DXE. =20 -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
Copyright (c) 2017, Microsoft Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include =20 #include #include @@ -66,6 +67,48 @@ EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = =3D { NULL }; =20 +/** + Do a hash operation on a data buffer, extend a specific TPM PCR with the= hash result, + and build a GUIDed HOB recording the event which will be passed to the D= XE phase and + added into the Event Log. + + @param[in] This Indicates the calling context + @param[in] Flags Bitmap providing additional information. + @param[in] HashData If BIT0 of Flags is 0, it is physical addr= ess of the + start of the data buffer to be hashed, ext= ended, and logged. + If BIT0 of Flags is 1, it is physical addr= ess of the + start of the pre-hash data buffter to be e= xtended, and logged. + The pre-hash data format is TPML_DIGEST_VA= LUES. + @param[in] HashDataLen The length, in bytes, of the buffer refere= nced by HashData. + @param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data struct= ure. + @param[in] NewEventData Pointer to the new event data. + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_OUT_OF_RESOURCES No enough memory to log the new event. + @retval EFI_DEVICE_ERROR The command was unsuccessful. + +**/ +EFI_STATUS +EFIAPI +HashLogExtendEvent ( + IN EDKII_TCG_PPI *This, + IN UINT64 Flags, + IN UINT8 *HashData, + IN UINTN HashDataLen, + IN TCG_PCR_EVENT_HDR *NewEventHdr, + IN UINT8 *NewEventData + ); + +EDKII_TCG_PPI mEdkiiTcgPpi =3D { + HashLogExtendEvent +}; + +EFI_PEI_PPI_DESCRIPTOR mTcgPpiList =3D { + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gEdkiiTcgPpiGuid, + &mEdkiiTcgPpi +}; + // // Number of firmware blobs to grow by each time we run out of room // @@ -375,9 +418,13 @@ LogHashEvent ( and build a GUIDed HOB recording the event which will be passed to the D= XE phase and added into the Event Log. =20 + @param[in] This Indicates the calling context @param[in] Flags Bitmap providing additional information. - @param[in] HashData Physical address of the start of the data = buffer - to be hashed, extended, and logged. + @param[in] HashData If BIT0 of Flags is 0, it is physical addr= ess of the + start of the data buffer to be hashed, ext= ended, and logged. + If BIT0 of Flags is 1, it is physical addr= ess of the + start of the pre-hash data buffter to be e= xtended, and logged. + The pre-hash data format is TPML_DIGEST_VA= LUES. @param[in] HashDataLen The length, in bytes, of the buffer refere= nced by HashData. @param[in] NewEventHdr Pointer to a TCG_PCR_EVENT_HDR data struct= ure. @param[in] NewEventData Pointer to the new event data. @@ -388,7 +435,9 @@ LogHashEvent ( =20 **/ EFI_STATUS +EFIAPI HashLogExtendEvent ( + IN EDKII_TCG_PPI *This, IN UINT64 Flags, IN UINT8 *HashData, IN UINTN HashDataLen, @@ -403,16 +452,23 @@ HashLogExtendEvent ( return EFI_DEVICE_ERROR; } =20 - Status =3D HashAndExtend ( - NewEventHdr->PCRIndex, - HashData, - HashDataLen, + if(Flags & EDKII_TCG_PRE_HASH) { + ZeroMem (&DigestList, sizeof(DigestList)); + CopyMem(&DigestList, HashData, sizeof(DigestList)); + Status =3D Tpm2PcrExtend( + 0, &DigestList ); + } else { + Status =3D HashAndExtend ( + NewEventHdr->PCRIndex, + HashData, + HashDataLen, + &DigestList + ); + } if (!EFI_ERROR (Status)) { - if ((Flags & EFI_TCG2_EXTEND_ONLY) =3D=3D 0) { - Status =3D LogHashEvent (&DigestList, NewEventHdr, NewEventData); - } + Status =3D LogHashEvent (&DigestList, NewEventHdr, NewEventData); } =20 if (Status =3D=3D EFI_DEVICE_ERROR) { @@ -452,6 +508,7 @@ MeasureCRTMVersion ( TcgEventHdr.EventSize =3D (UINT32) StrSize((CHAR16*)PcdGetPtr (PcdFirmwa= reVersionString)); =20 return HashLogExtendEvent ( + &mEdkiiTcgPpi, 0, (UINT8*)PcdGetPtr (PcdFirmwareVersionString), TcgEventHdr.EventSize, @@ -651,27 +708,22 @@ MeasureFvImage ( // FV pre-hash algos comply with current TPM hash requirement // Skip hashing step in measure, only extend DigestList to PCR and log= event // - Status =3D Tpm2PcrExtend( - 0, - &DigestList + Status =3D HashLogExtendEvent ( + &mEdkiiTcgPpi, + EDKII_TCG_PRE_HASH, + (UINT8*) &DigestList, // HashData + (UINTN) sizeof(DigestList), // HashDataLen + &TcgEventHdr, // EventHdr + EventData // EventData ); - - if (!EFI_ERROR(Status)) { - Status =3D LogHashEvent (&DigestList, &TcgEventHdr, EventData); - DEBUG ((DEBUG_INFO, "The pre-hashed FV which is extended & logged b= y Tcg2Pei starts at: 0x%x\n", FvBase)); - DEBUG ((DEBUG_INFO, "The pre-hashed FV which is extended & logged b= y Tcg2Pei has the size: 0x%x\n", FvLength)); - } else if (Status =3D=3D EFI_DEVICE_ERROR) { - BuildGuidHob (&gTpmErrorHobGuid,0); - REPORT_STATUS_CODE ( - EFI_ERROR_CODE | EFI_ERROR_MINOR, - (PcdGet32 (PcdStatusCodeSubClassTpmDevice) | EFI_P_EC_INTERFACE_ER= ROR) - ); - } + DEBUG ((DEBUG_INFO, "The pre-hashed FV which is extended & logged by T= cg2Pei starts at: 0x%x\n", FvBase)); + DEBUG ((DEBUG_INFO, "The pre-hashed FV which is extended & logged by T= cg2Pei has the size: 0x%x\n", FvLength)); } else { // // Hash the FV, extend digest to the TPM and log TCG event // Status =3D HashLogExtendEvent ( + &mEdkiiTcgPpi, 0, (UINT8*) (UINTN) FvBase, // HashData (UINTN) FvLength, // HashDataLen @@ -849,6 +901,12 @@ PeimEntryMP ( { EFI_STATUS Status; =20 + // + // install Tcg Services + // + Status =3D PeiServicesInstallPpi (&mTcgPpiList); + ASSERT_EFI_ERROR (Status); + if (PcdGet8 (PcdTpm2ScrtmPolicy) =3D=3D 1) { Status =3D MeasureCRTMVersion (); } @@ -893,7 +951,7 @@ MeasureSeparatorEventWithError ( TcgEvent.PCRIndex =3D PCRIndex; TcgEvent.EventType =3D EV_SEPARATOR; TcgEvent.EventSize =3D (UINT32)sizeof (EventData); - return HashLogExtendEvent(0,(UINT8 *)&EventData, TcgEvent.EventSize, &Tc= gEvent,(UINT8 *)&EventData); + return HashLogExtendEvent(&mEdkiiTcgPpi, 0, (UINT8 *)&EventData, TcgEven= t.EventSize, &TcgEvent,(UINT8 *)&EventData); } =20 /** diff --git a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf b/SecurityPkg/Tcg/Tcg2Pei/= Tcg2Pei.inf index 3d361e8859..f64b29f1ae 100644 --- a/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf +++ b/SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.inf @@ -8,7 +8,7 @@ # # This module will initialize TPM device, measure reported FVs and BIOS v= ersion. # -# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
# Copyright (c) 2017, Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -72,6 +72,7 @@ gPeiTpmInitializationDonePpiGuid ## = PRODUCES gEfiEndOfPeiSignalPpiGuid ## = SOMETIMES_CONSUMES ## NOTIFY gEdkiiPeiFirmwareVolumeInfoPrehashedFvPpiGuid ## = SOMETIMES_CONSUMES + gEdkiiTcgPpiGuid ## = PRODUCES =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString ## = SOMETIMES_CONSUMES --=20 2.26.2.windows.1 -=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 (#63066): https://edk2.groups.io/g/devel/message/63066 Mute This Topic: https://groups.io/mt/75718617/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- From nobody Sat Apr 20 12:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63067+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63067+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595391141; cv=none; d=zohomail.com; s=zohoarc; b=J7Gu9kNW2xj3A7GcuwJ7JO2IakuOcmdCD/C2fBm9+2sQ0iKi/n4Uib8J6lK9/9loYE1U/f18AWlPYBf4yfMOtl+sgHxbCDoU3SN1fog9WSlUXjyxrNR6PvE0tEqsoo4NPdlC5QIrVq3ohbFrxCqe9a0GDDa0kHcBL5pv8ycDXrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595391141; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=yjhhnexWlfyzcJ7PV63Rct+2ASsL1QBBYKs19efdiik=; b=aGgL54oSGtlYW6xmPuTmCZm37GKnB8qJ8e2y6kdvuRguD1hX0xhpxRXIjQDFMbbowt+IaF2UcE7PHkbEake82GBd+vI/aiITagQQjT+2Haj9pPOcMHljnj5Q1Ja99RgtDNKnJGxGS3neJJMLEDiDcqj+zXgkwlxAA40UqX6oMdY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63067+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595391141150902.7338624109957; Tue, 21 Jul 2020 21:12:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZMA1YY1788612xneKiXZPvx1; Tue, 21 Jul 2020 21:12:20 -0700 X-Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web11.11889.1595391132846714831 for ; Tue, 21 Jul 2020 21:12:20 -0700 IronPort-SDR: hk8y3sQy1cVKnLKC7nySVxN3WJs+0fSe4EorifTTBUn37f/EZZmxK4Z0L/vwtWnl7eSZwevZLc Sdb6KCkgbQgw== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="168412627" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="168412627" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 21:12:20 -0700 IronPort-SDR: l+1CuTpZNsEWUxsLiQbJlhPuXX+ZcmVQBj2RmNpGWX2u54gdpJJtT/mGf8Abo61Vf6sHbqUbbv j3aOGtis+YgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="432240938" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga004.jf.intel.com with ESMTP; 21 Jul 2020 21:12:18 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang Subject: [edk2-devel] [PATCH v5 5/6] SecurityPkg/PeiTpmMeasurementLib: Add PEI instance. Date: Wed, 22 Jul 2020 12:12:05 +0800 Message-Id: <20200722041206.12199-6-qi1.zhang@intel.com> In-Reply-To: <20200722041206.12199-1-qi1.zhang@intel.com> References: <20200722041206.12199-1-qi1.zhang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,qi1.zhang@intel.com X-Gm-Message-State: bVvxYyoW2JkpTdnDXpjECRoUx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595391140; bh=8QOuYSML7+4xc8k0w8pKdJg7CevRC/HsIPK8BH0CtsA=; h=Cc:Date:From:Reply-To:Subject:To; b=GAbG7rvEBHljcFsiSJJYGmdVoAvMureQi+9fkwcpyCozoRgGtxaEYL71z78RAdHvnsr 8A4vfhijX2Dt8yGrk2Gy27t+UeNnIWLfGjGaW/Hr+wY5yyGm2iYMnwNTHQmTmON5h8iec LtvAoF9qa4z7SafX5aNj7Trt2yQsmCgIyt8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Jiewen Yao REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2841 Cc: Jiewen Yao Cc: Jian J Wang Cc: Qi Zhang Signed-off-by: Jiewen Yao --- .../PeiTpmMeasurementLib.c | 74 +++++++++++++++++++ .../PeiTpmMeasurementLib.inf | 50 +++++++++++++ .../PeiTpmMeasurementLib.uni | 17 +++++ 3 files changed, 141 insertions(+) create mode 100644 SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurem= entLib.c create mode 100644 SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurem= entLib.inf create mode 100644 SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurem= entLib.uni diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.= c b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c new file mode 100644 index 0000000000..1a590e0c9e --- /dev/null +++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.c @@ -0,0 +1,74 @@ +/** @file + This library is used by other modules to measure data to TPM. + +Copyright (c) 2020, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +/** + Tpm measure and log data, and extend the measurement result into a speci= fic PCR. + + @param[in] PcrIndex PCR Index. + @param[in] EventType Event type. + @param[in] EventLog Measurement event log. + @param[in] LogLen Event log length in bytes. + @param[in] HashData The start of the data buffer to be hashed, = extended. + @param[in] HashDataLen The length, in bytes, of the buffer referen= ced by HashData + + @retval EFI_SUCCESS Operation completed successfully. + @retval EFI_UNSUPPORTED TPM device not available. + @retval EFI_OUT_OF_RESOURCES Out of memory. + @retval EFI_DEVICE_ERROR The operation was unsuccessful. +**/ +EFI_STATUS +EFIAPI +TpmMeasureAndLogData ( + IN UINT32 PcrIndex, + IN UINT32 EventType, + IN VOID *EventLog, + IN UINT32 LogLen, + IN VOID *HashData, + IN UINT64 HashDataLen + ) +{ + EFI_STATUS Status; + EDKII_TCG_PPI *TcgPpi; + TCG_PCR_EVENT_HDR TcgEventHdr; + + Status =3D PeiServicesLocatePpi( + &gEdkiiTcgPpiGuid, + 0, + NULL, + (VOID**)&TcgPpi + ); + if (EFI_ERROR(Status)) { + return Status; + } + + TcgEventHdr.PCRIndex =3D PcrIndex; + TcgEventHdr.EventType =3D EventType; + TcgEventHdr.EventSize =3D LogLen; + + Status =3D TcgPpi->HashLogExtendEvent ( + TcgPpi, + 0, + HashData, + (UINTN)HashDataLen, + &TcgEventHdr, + EventLog + ); + return Status; +} diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.= inf b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf new file mode 100644 index 0000000000..6625d0fd01 --- /dev/null +++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf @@ -0,0 +1,50 @@ +## @file +# Provides TPM measurement functions for TPM1.2 and TPM 2.0 +# +# This library provides TpmMeasureAndLogData() to measure and log data, a= nd +# extend the measurement result into a specific PCR. +# +# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiTpmMeasurementLib + FILE_GUID =3D 9A62C49D-C45A-4322-9F3C-45958DF0056B + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D TpmMeasurementLib|PEIM + MODULE_UNI_FILE =3D PeiTpmMeasurementLib.uni + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources] + PeiTpmMeasurementLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + SecurityPkg/SecurityPkg.dec + +[LibraryClasses] + BaseLib + BaseMemoryLib + HobLib + DebugLib + PcdLib + PrintLib + PeiServicesLib + PeiServicesTablePointerLib + +[Ppis] + gEdkiiTcgPpiGuid ## = CONSUMES + +[Depex] + gEfiPeiMasterBootModePpiGuid AND + gEfiTpmDeviceSelectedGuid diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.= uni b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni new file mode 100644 index 0000000000..7b4341b449 --- /dev/null +++ b/SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.uni @@ -0,0 +1,17 @@ +// /** @file +// Provides TPM measurement functions for TPM1.2 and TPM 2.0 +// +// This library provides TpmMeasureAndLogData() to to measure and log data= , and +// extend the measurement result into a specific PCR. +// +// Copyright (c) 2020, Intel Corporation. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "Provides TPM meas= urement functions for TPM1.2 and TPM 2.0" + +#string STR_MODULE_DESCRIPTION #language en-US "This library prov= ides TpmMeasureAndLogData() to to measure and log data, and extend the meas= urement result into a specific PCR." + --=20 2.26.2.windows.1 -=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 (#63067): https://edk2.groups.io/g/devel/message/63067 Mute This Topic: https://groups.io/mt/75718618/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- From nobody Sat Apr 20 12:36:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63068+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63068+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595391142; cv=none; d=zohomail.com; s=zohoarc; b=FOG3kX2Eh2bO37Kuf+xiBsRk+1mnb8jbZtZJHnEjfBfLuw9Jt9nZYpQEEBRXTjWPxt98glJBsMTTSt6g6fuGuaIqvRQHWmc/lOfR/fjolVZhLTZ7vSuJke8VqVtt/AyGArvFXB92Ovpt4OIlifyuzWF1rqLdFid3Xr6QGIApank= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595391142; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=cYmd1/fvK7pOdCutatMGFETT27+brfbFVvYthJDyfo0=; b=PspFr+w9abqKlEINBopcCwrxvRNRJb92i+kqkWvQVftNuFHiQrh8BPkT8UkuewPIR2JLJrXJ9JQaQM8yRXyKVFV5IAUQ8i7o/NP1chyCgKuHjMzxECvApWjcgE2RYodwhyBGjBIpL6xBwkUgx2NFlGAdt2lSihNbLqIXLzBPq/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63068+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1595391142560550.6217054952245; Tue, 21 Jul 2020 21:12:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iMC6YY1788612xtqMV55MiAG; Tue, 21 Jul 2020 21:12:22 -0700 X-Received: from mga01.intel.com (mga01.intel.com []) by mx.groups.io with SMTP id smtpd.web11.11889.1595391132846714831 for ; Tue, 21 Jul 2020 21:12:21 -0700 IronPort-SDR: KcNGQddugcHm3jW9qQ3LmT8w8q40wRVSPRUOYzdx7ZDCDhou0EMEBlGZXl4eU8JVxW+WVGKcLR Lw7XQjD0ooTw== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="168412636" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="168412636" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2020 21:12:21 -0700 IronPort-SDR: mweM1xXWSUJWQekccvOJLqo9+B7xRcBlD54LZzY21ysyNTRxW810SBTM8UAOt2fPEgklSWeXf8 GyRUE3rPvftg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="432240944" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga004.jf.intel.com with ESMTP; 21 Jul 2020 21:12:20 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang Subject: [edk2-devel] [PATCH v5 6/6] SecurityPkg/dsc: Add PeiTpmMeasurementLib. Date: Wed, 22 Jul 2020 12:12:06 +0800 Message-Id: <20200722041206.12199-7-qi1.zhang@intel.com> In-Reply-To: <20200722041206.12199-1-qi1.zhang@intel.com> References: <20200722041206.12199-1-qi1.zhang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,qi1.zhang@intel.com X-Gm-Message-State: 1w5OQWBml2nno8Xs3MFWjc2Ux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595391142; bh=D9pTpYNrI5wUlceSnme1d55hY92VeU34umSqMm6kvO4=; h=Cc:Date:From:Reply-To:Subject:To; b=kQ3tsljkCu5Xjt8nU10BskbHA0MOgWDYgMyg9OoVwG+fgZKNm15hJh+QgfpzPAIDni7 A23aof4/HXOY0hBOXAaBX/rhPPf4UqC8YpiOtgTtc/3qlgafr0/avUxfsmPiEeRtgGNj8 OkgemvogtVO2ESNcDGVFan1e3C6Tf3lkGE8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Jiewen Yao REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2841 Cc: Jiewen Yao Cc: Jian J Wang Cc: Qi Zhang Signed-off-by: Jiewen Yao --- SecurityPkg/SecurityPkg.dsc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index 53fce05353..28effe3eda 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -1,7 +1,7 @@ ## @file # Security Module Package for All Architectures. # -# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
# (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -96,6 +96,7 @@ Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLibDTpm= .inf Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf Tcg2PhysicalPresenceLib|SecurityPkg/Library/PeiTcg2PhysicalPresenceLib/P= eiTcg2PhysicalPresenceLib.inf + TpmMeasurementLib|SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasure= mentLib.inf RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf =20 [LibraryClasses.common.DXE_DRIVER] @@ -234,6 +235,7 @@ SecurityPkg/Library/FmpAuthenticationLibPkcs7/FmpAuthenticationLibPkcs7.= inf SecurityPkg/Library/FmpAuthenticationLibRsa2048Sha256/FmpAuthenticationL= ibRsa2048Sha256.inf =20 + SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf --=20 2.26.2.windows.1 -=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 (#63068): https://edk2.groups.io/g/devel/message/63068 Mute This Topic: https://groups.io/mt/75718620/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-