From nobody Sun May 5 04:18:05 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+62749+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+62749+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1594979575; cv=none; d=zohomail.com; s=zohoarc; b=CapQdY4uUjInvpfM3O+T/DkTuMx9U+rzCi8yJGI7YbSHQx0TZLC2/HJ2L+VKtDFob5+ZPhtFyoXEXfudamfDDkcpj2EounMTik1sA+m0SUnGDWqZG66Adn3UBRYVUJc9rWlVCEmV74CL0oFrV5dlgFZiWxwi6P2WcNpVKYQg+y8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594979575; 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=CGnWjSYf/RiZWeXsfwCeOBkPj5L8uW0lGyWVxZPGfmM=; b=Fs/EW0rhk8UC90Qs9aP3GDBbYztzmRxBgC6aDFBnU44rjzvvLD4hcR5V6LQR5o4kU8GXooucWnAJ/BnAXzj7L2w4DBfjmP4TfN2bk9KL4yyyEuqIOzKh05mTc/roWwE+ZibBtA4t+x/JqVnnBBXPkzHSFCSgEVESedGhBCVCynk= 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+62749+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 1594979575883123.31176052424166; Fri, 17 Jul 2020 02:52:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RyGrYY1788612xV2vGZ35FKF; Fri, 17 Jul 2020 02:52:55 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web10.6793.1594971201528724190 for ; Fri, 17 Jul 2020 00:33:22 -0700 IronPort-SDR: QH4578YSqTyYynJC0fB5qYV9VnteohyXjM9H1Lt+VkIwO5KCYANlCOsQOFPspMvyGBRPbegeS6 8lZI/jQ+1kuQ== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129113484" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="129113484" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:33:22 -0700 IronPort-SDR: ysG+sRu+sOLqkwcIS/7Eu1+Fi15tYvT+D7XmvXtLK2FBrVoFiEsmO9lHTJt7StWRabjLMMb8t2 GC2An3kRS2kw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="361273517" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2020 00:33:19 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang Subject: [edk2-devel] [PATCH v3 1/6] SecurityPkg/TcgPpi: Add TcgPpi header file. Date: Fri, 17 Jul 2020 15:33:07 +0800 Message-Id: <20200717073312.10594-2-qi1.zhang@intel.com> In-Reply-To: <20200717073312.10594-1-qi1.zhang@intel.com> References: <20200717073312.10594-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: 9tGGSC2TQX4FPhCZW8d40z9ox1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594979575; bh=Zk6jbNVk85T//+nb/rgZZ8yGVwYdnvFqpXZ71vpYcyQ=; h=Cc:Date:From:Reply-To:Subject:To; b=S63y/nYKU8NJokMdBUm8VGRREO3kjqFD7TVhXDRcHdpGjV29GlaxniCwMPlL6SC5wiz WmOo21olros6QKlDyoOPRRzrurCPbXaSgpd6DlBwtOYpZEyG0yrdOqgO36foZG0xsRuG0 X9tkQQbE8gJXAyzi1UWWTf5jzrB0cct8LO4= 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: Chao Zhang Cc: Qi Zhang Signed-off-by: Jiewen Yao Reviewed-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..d86ff5961d --- /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 EFI_TCG2_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 (#62749): https://edk2.groups.io/g/devel/message/62749 Mute This Topic: https://groups.io/mt/75608824/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 Sun May 5 04:18:05 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+62750+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+62750+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1594979577; cv=none; d=zohomail.com; s=zohoarc; b=HjfuHNwzhnTcufEzcpZ/9iqSeVmf3GEC1rocLmL8GarXPOnPCeTcgxYVvGUTaP2I8YvBzEjDI0BNjspZVCVpbBAkqLl3iw2EY63F5PbZm/lBA5yRlMno2I1xIY4wMtJiDEdOdJPjYc3z9WHY4YsLL4Im3bLIqpYX6gyPeDW35nU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594979577; 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=0p2kqLR1J83h9M3ySCf+zaaHULyHLdduEyaMcOqOfrs=; b=OFLVVnrW7Jr+6/8hUghPH5170go8gie0ao2YoKX/b9KfOBjq52IKEigbTnx5LKqpM4rgQb/e1nqVGdUlJojXAVno4xRO3OIbMDnBDqZLLJkWiFmNjDhhLSQ3tYqXuWXYo6YJEgMcXTZJtIkxa5dr3OU6MIePeX+M5YzbJXorikA= 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+62750+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 1594979577056520.7555709660238; Fri, 17 Jul 2020 02:52:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4aQjYY1788612xOFoUzi2acI; Fri, 17 Jul 2020 02:52:56 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web10.6793.1594971201528724190 for ; Fri, 17 Jul 2020 00:33:23 -0700 IronPort-SDR: UHM1HLBlDweyxv3xfjUAP2LIxf5UmHvIElx07UWeWHqRZAz3bjyRYHD/NYGN4oU5wFaUN5TiyL fmPb3fEONgIA== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129113487" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="129113487" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:33:23 -0700 IronPort-SDR: G1wx7rjbz3FP0SJd64JwVoAr/IJMhGG7tP3L60tTqmh/sKBuzMj4lehzy87bnpiJ0xe67sGxoQ CXa1Suya9CjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="361273522" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2020 00:33:21 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang Subject: [edk2-devel] [PATCH v3 2/6] SecurityPkg/dec: Add TcgPpi. Date: Fri, 17 Jul 2020 15:33:08 +0800 Message-Id: <20200717073312.10594-3-qi1.zhang@intel.com> In-Reply-To: <20200717073312.10594-1-qi1.zhang@intel.com> References: <20200717073312.10594-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: h8YXX4TE2uFMVPbdwurxtIOGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594979576; bh=eEKcFgNGJlMq8hKAYglA9WwypzXU7397aknWgbwRTe4=; h=Cc:Date:From:Reply-To:Subject:To; b=RnyAoPqGpI3ztA9Fus1bBtA2wJRNSAplfy081AJ2HxL+SGazJ9YETbA6TMHvfkILqD9 /JfNzlSb4bIxWzaxmSBuPJxRW/Pq3CTPuDi/xiegzyuDD5Y5PhtHYO9UsaaLt32UFCLso vnSS6DzcmyTUs4XtQob+oGlZ/BarQVrMDv8= 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: Chao Zhang Cc: Qi Zhang Signed-off-by: Jiewen Yao Reviewed-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 (#62750): https://edk2.groups.io/g/devel/message/62750 Mute This Topic: https://groups.io/mt/75608825/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 Sun May 5 04:18:05 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+62751+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+62751+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1594979577; cv=none; d=zohomail.com; s=zohoarc; b=IwNb9rLXC0wiz2vX4dZOr/MAQt6A8L+k8rmmVkY7L5sYJXicgxKqJZrwvfQQWqOzLx/IAsvGW41TDxqehxoq4WMuX99he23ruIIawUjsnb2EXmvF4hcos7AOWgHo5cIieR2DcyBjVH4EuI5AbHViGKO94Yb07grCGNzbrB3SFis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594979577; 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=hrp8OdLU9GHzjB2ogTWFCM6nWUByOVhBfD9ExnocVCg=; b=Aky1Bra9CFra2WYqbsfugCdvdL3FV5OcjUerJ6JUC4Qjm9hx1slDcV/0N1dRit6Kd0fe+Lnjo/r2+mh2yVFKqS7PhSmZ6oeVNUeO52K/6ijM/vonMQmnKQVNUYFWGAkF18U7IqjBmGKXbv7hKLDimxpJ2jGHWHFeiox31ykYCTE= 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+62751+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 1594979577422251.60899181005414; Fri, 17 Jul 2020 02:52:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FpMUYY1788612xCi85Wqb37s; Fri, 17 Jul 2020 02:52:57 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web10.6793.1594971201528724190 for ; Fri, 17 Jul 2020 00:33:25 -0700 IronPort-SDR: aIP44kIe9UOjn2HyZwE2Q5O/VRG6ciWPasniwZ/ExOMuLout43u9BQs3nanRNDDFATk7Ydd5PH LgaaQwoebfiw== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129113491" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="129113491" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:33:25 -0700 IronPort-SDR: J8ovL6oyvBjnzTloSG7UoidqwbL8GB5rtvJHslv3jQ8UpabZTxoC1rZ/3zDxOmqz9B83Log2XF t0MDiug+UTGA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="361273529" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2020 00:33:23 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH v3 3/6] SecurityPkg/Tcg: Add TcgPpi Date: Fri, 17 Jul 2020 15:33:09 +0800 Message-Id: <20200717073312.10594-4-qi1.zhang@intel.com> In-Reply-To: <20200717073312.10594-1-qi1.zhang@intel.com> References: <20200717073312.10594-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: ZzyvTjxkNW9t9Kpn6g5sxxxlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594979577; bh=bwSKJxRRJsKAT1gQY9/kn1ixGWun+G9rIvvYwdH5Jj8=; h=Cc:Date:From:Reply-To:Subject:To; b=apt8t2XPRwBO8gTTkk1tDWowIPgoNDj6K//t0ey1mYh3l7kvNYlT/kN1nKtmGKslZH8 1FeHBF8heIkokPdbZ83h1izWGs3WPqfolSs6frn9DXc+H8PCJy6yuRDyve7nHgLw5uohe O6r3R1egs9gktU8nLpuVFkyVnx2VQAqGgCk= 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: Chao Zhang Cc: Qi Zhang Cc: Rahul Kumar Signed-off-by: Jiewen Yao Reviewed-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 (#62751): https://edk2.groups.io/g/devel/message/62751 Mute This Topic: https://groups.io/mt/75608827/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 Sun May 5 04:18:05 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+62752+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+62752+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1594979577; cv=none; d=zohomail.com; s=zohoarc; b=GyixifOBGc58M0TUJk1TRW/RSdFxOnwIdN8zxEaAbF7iyViiuHrcrFsuSRFEG39Mdk+YZBwu4fG92zdpDzWOpzeuDwoF0DOmGliau6KMvHXiQ6YVpSFDRtCtcnBkT2RdV4e+40lsL1DKB4h/fL/kt6FDSlOazhN/dPncjgDovTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594979577; 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=46VOkvznQGy2DtXBDm7aq41OWqhcYSMFXNWQDoS8gbQ=; b=eZhwUYH7T/19Zqo+7ToPhdZSQhLo1WI/lGstq/7IJvN14n5Z1IgGUoXR3Tiw6bedeD61XpcatBEbKGuiimsubbaVoSH9S3+hPTyIk4NIqCEiW2TkC9Y56AygaNg3njj4r0iTjncKuW8fc1RyBgKzJELyOPvA8gVNrhKLVgdiy1Q= 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+62752+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 1594979577871790.4882732540436; Fri, 17 Jul 2020 02:52:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 77X0YY1788612xr59eNpDY6f; Fri, 17 Jul 2020 02:52:57 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web10.6793.1594971201528724190 for ; Fri, 17 Jul 2020 00:33:27 -0700 IronPort-SDR: y5eE0G8/eyC2dc4cnCgQWyKjnjMgwyDmvHA84OZxnxh0EStEqVe/6YdmcMdWElwF8qtG9W7Psu otIY8H18fIsQ== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129113494" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="129113494" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:33:27 -0700 IronPort-SDR: ODHzjR1ioxPUpw693RvXq91BNL2S57T6hXH7vRWDmqbNtt26hSDNwldxEOeMAFLiGW5M6XhGoT 6Dmq0BcRflWw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="361273535" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2020 00:33:25 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH v3 4/6] SecurityPkg/Tcg2: Add TcgPpi Date: Fri, 17 Jul 2020 15:33:10 +0800 Message-Id: <20200717073312.10594-5-qi1.zhang@intel.com> In-Reply-To: <20200717073312.10594-1-qi1.zhang@intel.com> References: <20200717073312.10594-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: 6WAMzBtyURySOdeW9sbPxinRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594979577; bh=isKxZ2C78pOSYSVR3BKJicbFb5y+DJ3FjIdryDyx6WE=; h=Cc:Date:From:Reply-To:Subject:To; b=YhDXP+X8hMjcRwfOTtkykn/oVNJD4pYAsp6M3v5rPgoWT43QbC4yN/qkgZL+NVRJ+jf tZkh+hGE9iAMKGstt0HMu4s92pSmRxUCJNZxsXu/eSUK0+iB2wKwsIB0e4R+Vc42slMEN 6TyvicZcNHEVXK9SKVmIimqVdczPDT6In8c= 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: Chao Zhang Cc: Qi Zhang Cc: Rahul Kumar Signed-off-by: Jiewen Yao Reviewed-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..5344b7fd26 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 & EFI_TCG2_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, + EFI_TCG2_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 (#62752): https://edk2.groups.io/g/devel/message/62752 Mute This Topic: https://groups.io/mt/75608828/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 Sun May 5 04:18:05 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+62753+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+62753+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1594979578; cv=none; d=zohomail.com; s=zohoarc; b=e+mIrUQK7gRA0nggnd1cRIcZB9mg5mhwLZwHXzmQj/Czg1KMqELl1KTzNAJIUxsHR0hJqRokqiz9KY9MkGgJG7lg1jilI+CGA4OeqdnWdH7OzXgoYesbVg6G0/2RV0T3pziaSFRC4GueBBGAOmShi//IeEEOVvIMM+s1UEtp3CM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594979578; 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=6H/BpEU4OIvIzDmRyGLOYcvZE/qgh6JNoitiOEWgAJU=; b=J8ooThDlLe8nTdpxgvrIvJB9uo8pHOV6pwM1YWw5zuQ6cL2wab84x/2JqO4q2VXBsKiBvRCyB4p/qf40r7JfMcZ/p3aF/6DWc6rIxghrvICgCq2HM2ciDPiZ3J1BKZyPLVT0wxFhd6dnTOXF2oadzerBc7ElZbrx86fv3/HHb8s= 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+62753+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 1594979578501338.4223064351771; Fri, 17 Jul 2020 02:52:58 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id lGtgYY1788612xW3XtnWwphG; Fri, 17 Jul 2020 02:52:58 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web10.6793.1594971201528724190 for ; Fri, 17 Jul 2020 00:33:30 -0700 IronPort-SDR: HzXPc7kSfHkoVFQgeydtZ3CDnIWQz30TAKqfryuLzLAD7MZZ0UeYI8xi0C2ZJ3qgycCstmYIQI 9Hoz5H9r9H7Q== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129113501" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="129113501" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:33:29 -0700 IronPort-SDR: 8rtYzSO3xJ274QwaUA6xvCdTdzpdV3CfIZHpiN9q83vUq3MTG9XHR8MFmBXb3MHcaePBP2RLX7 Ecvih2z6fmqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="361273538" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2020 00:33:27 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang Subject: [edk2-devel] [PATCH v3 5/6] SecurityPkg/PeiTpmMeasurementLib: Add PEI instance. Date: Fri, 17 Jul 2020 15:33:11 +0800 Message-Id: <20200717073312.10594-6-qi1.zhang@intel.com> In-Reply-To: <20200717073312.10594-1-qi1.zhang@intel.com> References: <20200717073312.10594-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: bPeQj7DD8DujpKwBA4V5ZpMxx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594979578; bh=Zw7IfgBqHzh8pxhEUGiNwp1LTmrA+4pRHLycuG8p84M=; h=Cc:Date:From:Reply-To:Subject:To; b=Du+9BrhxOGMA+4gwRCVMqcxcVbpeLs/Um3l6RDqQXgrVE8ftYX7L2bQpO+3ubJDidXe LlPHqeMLFRnHDiknR/x0JjINJtQ6jXMzLGhr8LnIMsX/ymyIyeFfApD+BVYSrLogva3OX cIEAli7WoWaaPviU7FGY+KDxvQRnNo++IOc= 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: Chao Zhang Cc: Qi Zhang Signed-off-by: Jiewen Yao Reviewed-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 (#62753): https://edk2.groups.io/g/devel/message/62753 Mute This Topic: https://groups.io/mt/75608829/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 Sun May 5 04:18:05 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+62758+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+62758+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1594979581; cv=none; d=zohomail.com; s=zohoarc; b=hrd8cgAHIW3LRwXu1XrTnTS96b/SNYjojck4uL1Wz/5cRuYOV0kIfG6AP62fs36oS1cyzDpF9/lo39w6Tvr1wdBHUcZn92l3YN5t18R0EpIViuWry0RGHgNGd/eKnaRYsDUbTFKLynbIc412Gsl/YK5LPi8kLFr9UJUo13Pp97s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594979581; 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=BdBwy3dZlX8ldjDw7/agQwRlDIxSOoobwEP7w7u0VvE=; b=QcmiEnhd9Mzeeuxi/xhufvZIRPKJLY6qy2F5JKoNGqyVYCBmaUg+wEUpHpVFDXrfW3CYhH/1OT+igBKaWKUwTCHlKJZtqIJ3dTee4bR6CyhiH4dZhPECtw2kodyI5rOLvG0AynxRfxisKCPOnrz63OtzZgBwdEdfwEgshZMFBNs= 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+62758+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 1594979581278636.0146225367627; Fri, 17 Jul 2020 02:53:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JbDjYY1788612xUq3bLkhUBY; Fri, 17 Jul 2020 02:53:00 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web10.6793.1594971201528724190 for ; Fri, 17 Jul 2020 00:33:31 -0700 IronPort-SDR: W9+xS9ztz6b11PlPPH9pxfWKcVfsbT8zFjWQXBSeG5dPvoBWcq25pJhAdGk9aDb+Bypi0u9Ic4 OKl4cKupOEUA== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="129113503" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="129113503" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:33:31 -0700 IronPort-SDR: P4rMiDZDdkaLB/p6tYM4kXIoSozzzAbV82MKV9Ly/s/EH0yh/C28uKNeWHFQwkDDWEv15AgLFj nDZT97eIfpVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="361273544" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga001.jf.intel.com with ESMTP; 17 Jul 2020 00:33:29 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang , Qi Zhang Subject: [edk2-devel] [PATCH v3 6/6] SecurityPkg/dsc: Add PeiTpmMeasurementLib. Date: Fri, 17 Jul 2020 15:33:12 +0800 Message-Id: <20200717073312.10594-7-qi1.zhang@intel.com> In-Reply-To: <20200717073312.10594-1-qi1.zhang@intel.com> References: <20200717073312.10594-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: si5XO3eKDG9GEfwwlge1WeYWx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1594979580; bh=hC2KNurn8U6LxxYmpwm2LpfbClxxdRjZ+RudzQd8Vek=; h=Cc:Date:From:Reply-To:Subject:To; b=GCaEsLH3IBjrRmKYMjbSJD90kI2ORfNLtDB2kRCV/S6CdjxDAikXIkWIpN0vZDr/DKq 0qVWkxOLEJED9euhT6m8LI/DW4cvnevmXLjSQF33tchZHETiil1Cugog6gu0R+oWgx6mR Wsnx2j/GREsYZsgkP8LKvKxwQumodlQdWws= 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: Chao Zhang Cc: Qi Zhang Signed-off-by: Jiewen Yao Reviewed-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 (#62758): https://edk2.groups.io/g/devel/message/62758 Mute This Topic: https://groups.io/mt/75608834/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-