From nobody Thu Mar 28 21:55:14 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+63086+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+63086+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595406082; cv=none; d=zohomail.com; s=zohoarc; b=ElPLF0ipwgpdQQYzRnUC9wvld3jBo4hpxz1amY9nBXBES7mg2l5VvG/YSXOO71rN8PFuuCMUqE76ybdAa8g0IqWsyrI36JsmblRsLtnXClfxq5kLiCSWQo3LkMH60iPuzzwu3nzmV9h0t/82rIkJYccMU8N24lwAq0uf0fYkca0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595406082; 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=Fg1JpDItQ9RCIAqHosKk7gVgpY+r+pMQvv7dPThgysA=; b=Xqu6nzCdCyFfbwhbZweC8lC7ykTkW4JuXLBNXwzPes3walNgS1ymt62nk4y2VxYzLHwcOqqQ9qyV7TIwsp0TS/9Oxxx2TM+FU7yGldrlOvh0yiBxl57T4kHtBjw6AdU8M7R/V+aT9RnE95Roj9e7pyJElsrckp807p4lcvFsuXg= 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+63086+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 1595406082162997.8252228873375; Wed, 22 Jul 2020 01:21:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 98tAYY1788612xESqEq07wsN; Wed, 22 Jul 2020 01:21:21 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web11.14228.1595406080183038905 for ; Wed, 22 Jul 2020 01:21:21 -0700 IronPort-SDR: y8oW4AM9c1Tvmmro+Wh4KvKyzWGWNMlwuI6CyrpcOz439Cuzpk/+k6JJ4T/dBCu9/zi25I/fVI wboE1iNmNSfA== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="129857634" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="129857634" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 01:21:20 -0700 IronPort-SDR: fa2Gi48JuW4/kPW5sq6pvh+9devsB5p63UDXDh+DjjskTGziviPCoTSGzW+QBJT6XwAUV4OA9m EfDAqSkf8xNg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="288209214" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga006.jf.intel.com with ESMTP; 22 Jul 2020 01:21:19 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang Subject: [edk2-devel] [PATCH v7 1/6] SecurityPkg/TcgPpi: Add TcgPpi header file. Date: Wed, 22 Jul 2020 16:21:02 +0800 Message-Id: <20200722082107.12601-2-qi1.zhang@intel.com> In-Reply-To: <20200722082107.12601-1-qi1.zhang@intel.com> References: <20200722082107.12601-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: 1IerE9Ihb2nrit5lTrBeaMP1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595406081; bh=hYvb9eTxd3YOKLHeHoiIngcNVYi8lGeTlfnonQw5tA8=; h=Cc:Date:From:Reply-To:Subject:To; b=ZLjd6lYOTPVynqEuFiMS2Bw//rR7Q4J/4sujx8ozHHesAEglyq60y1ubwo0Xk9n1j/7 o6fjGTTibM1ZIkcP4byRci8A3HrDw7lFS71ftkJjABh5SfA5s4+tRpmM5Q9lJ6T6P4YMy ZwReJVu2Jx6eZRY0rSToQdG8B5TXAesNXUk= 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 Reviewed-by: Jian J Wang --- 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 (#63086): https://edk2.groups.io/g/devel/message/63086 Mute This Topic: https://groups.io/mt/75720705/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 Thu Mar 28 21:55:14 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+63087+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+63087+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595406083; cv=none; d=zohomail.com; s=zohoarc; b=D58bbfLt7qPOVTLULR1Ryjsw8CjuDlpmFfFAJOk9vV2Z7I9X1PblhgEOSI8BQKE6HIGeENwjNTecB4DKZWMBIuJ6JO00/z+B2ACCKSbV8kPxRJq5thSAqO9Ix6MPzLMym5hb+/j7orIdmgUorOpSRhnFY2gPpH8wU59BvEZ0WSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595406083; 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=8xA1hQfj691CGL+u6UtLKbO5ecGE648y5qd56z5XbIg=; b=e8KbpIfRceHVKLMRiiyhKNayahN3apwfoXAmHbKHls3NgUYy/NsvQtRib5qzVH2xgzxZIjNUhiXznQxpL0BuhVFd/VMemnv0YSEf1lg+JoegvE882FjBpxl9iBMc+XGnVn4Q4g7iyOb3vhkLMFzT5AH88nkfZTh2N7xxfotqb48= 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+63087+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 1595406083296816.0926037141799; Wed, 22 Jul 2020 01:21:23 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id tklnYY1788612xr4R8oquneN; Wed, 22 Jul 2020 01:21:23 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web11.14228.1595406080183038905 for ; Wed, 22 Jul 2020 01:21:22 -0700 IronPort-SDR: WDDgY11/jSn+XMzVTKluzluNm4DSwqdwKMpM8ETc6nojmZt4Jh5+iV4p9XnCz8SgiGUBMxoLgH yqLHf06Y3KAg== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="129857652" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="129857652" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 01:21:22 -0700 IronPort-SDR: N3f/Mij1TledCz62YgxuPvXXybE+vtPRzBuKwheb2msQyFTNuad2c+qQUY0CjHNWMn96h6nRn+ 2ZEZ0JCI/TTw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="288209227" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga006.jf.intel.com with ESMTP; 22 Jul 2020 01:21:20 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang Subject: [edk2-devel] [PATCH v7 2/6] SecurityPkg/dec: Add TcgPpi. Date: Wed, 22 Jul 2020 16:21:03 +0800 Message-Id: <20200722082107.12601-3-qi1.zhang@intel.com> In-Reply-To: <20200722082107.12601-1-qi1.zhang@intel.com> References: <20200722082107.12601-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: ucgTSIu7HWPJUVX6dTTQy20Jx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595406083; bh=HKAk0McpeZ2hz0GFhK3rExZ/fzCpbLALs/u1uY8boXA=; h=Cc:Date:From:Reply-To:Subject:To; b=S6uqcZWBiAaQK86pmomM1B0ke8argb2tfyRSZwNRSpe9zYXhFZ8Z9GXP998RNVxS0we Qnamed+p+9ACE2btGoXqmGyez7uSFgOMzTqdGXnPNaxW6WXVgrq3hglHrEKQNeCBmO/b7 yHza6TXxDezRLw6jvnFe4g8sgpFnfmxRXaY= 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 Reviewed-by: Jian J Wang --- 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 (#63087): https://edk2.groups.io/g/devel/message/63087 Mute This Topic: https://groups.io/mt/75720707/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 Thu Mar 28 21:55:14 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+63088+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+63088+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595406086; cv=none; d=zohomail.com; s=zohoarc; b=dclvjOC6LI+WWjsTRxBqF7yYL4DKVmLUa47DucRd4riwoQ2IxTIpc7+DnDeo5+3NlkUbOtXI5V5x29bsyNcISSu03fOiqruaxeXlqJtzdHJV0zynp2mT4pRLwp1PfM40qkxBXUURtFvCdwo5f2qItB6LKhWRsb0pPNbVaSfMEbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595406086; 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=t+YUHMatLszqQ9rO8+VUUC+JgIfNo4D+7vZORz2gMuM=; b=dzMXf2Sunh2f8xVyOF/JAODua8A82AYMlXwnbkZRreYQsftrII5gEUynCe6JLNphFtQgjSW1V2wcTdoWq1O7IfhKEGkV1quRBdWaxvK6vorRIBrXtvSa611nDVCYZWWUE0U8B1lfjaIkfymMD7pZHMsXgBGqibvFsfMTzpuUibw= 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+63088+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 1595406086233553.1894554717219; Wed, 22 Jul 2020 01:21:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dx45YY1788612xADkeP0G5X2; Wed, 22 Jul 2020 01:21:25 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web11.14228.1595406080183038905 for ; Wed, 22 Jul 2020 01:21:24 -0700 IronPort-SDR: dUrtuKlTwzZIeQ3SJ5fNo6zkpRpaxrjg1fI9YTruq65uF+emwJX5hiVhmmqhDj88JjLlmm8xKD a1R015hSrQ2Q== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="129857679" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="129857679" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 01:21:23 -0700 IronPort-SDR: CgjuKoKlUhCprKg8DgS2Rg2MPFvpe4RbkxEBf7JejYgemYKiBrN3fpkGGOcLZfowUiQvGBRr1j tengwoyPfMuA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="288209239" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga006.jf.intel.com with ESMTP; 22 Jul 2020 01:21:22 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH v7 3/6] SecurityPkg/Tcg: Add TcgPpi Date: Wed, 22 Jul 2020 16:21:04 +0800 Message-Id: <20200722082107.12601-4-qi1.zhang@intel.com> In-Reply-To: <20200722082107.12601-1-qi1.zhang@intel.com> References: <20200722082107.12601-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: Z5g8MclwBSvZfJvvYHTLBNKsx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595406085; bh=iP58tOmZEBZzY4nYIuu5/q1MOD7Yh6mS3zaN0zPy+SU=; h=Cc:Date:From:Reply-To:Subject:To; b=k0qtGvUGzaWOzKYW6MDAZ+KiHYDovbYMiyLYCRC7p1eYa/f/HnLAtiXg0XVUEja23Kf Bho0pb0xT4s0PPz8vd90X1cvJIcRZY0BGWJ17hnJROXBzZryA2DnoMQL4DIiz4Eke1QAR BRc7gMNKS2gircfjTq9tRGrXfrg4Dr25/dk= 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 Reviewed-by: Jian J Wang --- 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 (#63088): https://edk2.groups.io/g/devel/message/63088 Mute This Topic: https://groups.io/mt/75720708/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 Thu Mar 28 21:55:14 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+63089+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+63089+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595406087; cv=none; d=zohomail.com; s=zohoarc; b=dAzJ4oYS1kPipOpcS7HUgUZ302QUbTHYZ1agqWOuS6Q2fzozncyc8GvHuk+b6vtPF46WIzpEex3WrD0vKibvKUAQcBz6DO3KtRVxX6JhSMTsjbPeoWmoElercDhxKjYoukxo/h9i2bhKCv6CQY+6EyuLRuef6aUOn7xGYO3qFpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595406087; 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=Mfw3cg+2zsW3nC1HoE8iBB6u2Xb7jE2zNw7Tg1PuTus=; b=O3Kw19AqJpZ//ngymzb7JyNlwAJe/8PW1m141P/bZA5osb0ARVW58uwWiW9zdImQ2q+pN/y/drU0Hsm51hAazk2Zvj0ntPwB3qIRzz5SeDjulYEn8e9IbH0nVTYaunG32zt5kZ4Ibw7nNdt1bHsW8zlzZKLScoN8p4Wb9LreAFU= 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+63089+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 1595406087859971.6571092528824; Wed, 22 Jul 2020 01:21:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8ldjYY1788612xBwvBb3pEQo; Wed, 22 Jul 2020 01:21:26 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web11.14228.1595406080183038905 for ; Wed, 22 Jul 2020 01:21:26 -0700 IronPort-SDR: CHU3/rCCHEULSLsDLQjWa8hCVzjBVtEEOIeSG/5RUbl+sXnXcr/Tg/qqsXvwRMV3+eInu9cR3+ Okw6++o9NViQ== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="129857693" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="129857693" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 01:21:25 -0700 IronPort-SDR: 1O4EFehGMpBX9yhBV6GJ1QQp6z+X1KFHFXi2yopSQ2J267y98BfZDZRHD/lDSFYYRpEan2wEq0 YJQA7cxUBP/A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="288209258" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga006.jf.intel.com with ESMTP; 22 Jul 2020 01:21:24 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang , Rahul Kumar Subject: [edk2-devel] [PATCH v7 4/6] SecurityPkg/Tcg2: Add TcgPpi Date: Wed, 22 Jul 2020 16:21:05 +0800 Message-Id: <20200722082107.12601-5-qi1.zhang@intel.com> In-Reply-To: <20200722082107.12601-1-qi1.zhang@intel.com> References: <20200722082107.12601-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: 5LlEQLaRJvA5wl2F4dMqzjcMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595406086; bh=40BfME7ez9xQ1qu7kzQ0Mp7iWyOx/5cgHNjnNf3mPhg=; h=Cc:Date:From:Reply-To:Subject:To; b=LwFTgMhpm66OBUPxtFWWQTHY3R7FRveaXO3FEr79ZgetMv6TQopbnlI6yUjndahjmPe TEQ+LsDIFVerFRxfVAL8LdQXLVW0N3GtcRCxBRdyaPzGOGexgcFsLE+Jf+/n4oMSWXBnj a5ncN3HCpnnzvinVBW4SIxw8t87z1mA1Ic4= 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 Reviewed-by: Jian J Wang --- 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..71695df3d8 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 (#63089): https://edk2.groups.io/g/devel/message/63089 Mute This Topic: https://groups.io/mt/75720709/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 Thu Mar 28 21:55:14 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+63090+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+63090+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595406088; cv=none; d=zohomail.com; s=zohoarc; b=EjWFSNTaVxvIHNnlJCDtUHS7meOvcV3LDWRAQyNxOHScRMcJimKvwbd+lSwa6t23ZOjTKUTFAqSpgRKgyi7LxEqWjOFU5mWtxkBtFAqGme+pudUZ/EPWwYfk0/DxWIqyu8TsRK2wGPtq8269uUFtnJLoa6ZYUWENyPUGrVWZ92w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595406088; 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=fKnZMQddq07EVcp9SiTV1zTt/ipDePs3AaBPzmO6mKw=; b=Scm3/qijPpKvN8w1M/jar6893nGbAHg/8vnUBr+93EAYoZTSurQLUBP3eQ+UfKFMTcXhFakF/PR80qtE4wImw1vdDkaZEsw7U/79Y0/dw0sMV9NeLkZYvBeej2IQJIPpIFgdXbbeIVPUWp+mSbjy3QS3S0z+PlRhbo9jSPaAxKM= 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+63090+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 1595406088443722.5246291577158; Wed, 22 Jul 2020 01:21:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8SqdYY1788612xoQik4CM6wE; Wed, 22 Jul 2020 01:21:28 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web11.14228.1595406080183038905 for ; Wed, 22 Jul 2020 01:21:27 -0700 IronPort-SDR: FNwO0G167alSYo9NWbY8uyIKpf5zpozrgDmEsYWdL3LXd0GjouwUMPC3ecsKjKescZxxlzgWqc IuA27mcm1n1w== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="129857710" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="129857710" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 01:21:27 -0700 IronPort-SDR: HBvhN0EJxS6nZfOxv8QAuchH/hbYSxNZ35/b2BtnUkqvK/kh1IZFFholO44oHf/GK4tUpQurOo 3dbfqO5gbX6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="288209275" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga006.jf.intel.com with ESMTP; 22 Jul 2020 01:21:25 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang Subject: [edk2-devel] [PATCH v7 5/6] SecurityPkg/PeiTpmMeasurementLib: Add PEI instance. Date: Wed, 22 Jul 2020 16:21:06 +0800 Message-Id: <20200722082107.12601-6-qi1.zhang@intel.com> In-Reply-To: <20200722082107.12601-1-qi1.zhang@intel.com> References: <20200722082107.12601-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: dS72ZL6JueZV09YrzNU681SAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595406088; bh=aJca+jYsAOirqdpp/xqYRRyBrliDpbTAMCthCQL+1sw=; h=Cc:Date:From:Reply-To:Subject:To; b=uIqWYZu9EAdLAP6nNTmA5HDvanEnTjvSr3/EqcqxYk8n4rqnxhNQlJpsA6VZMxcb+Zt ubyNIPa3Iyd7Iz6ileUoH62xI/ZD4mdXBdVsy/ZATL9lBUAruqzk1pIf9nabVT8qqFOeG E0Dj0HFcwTGG8gQPuceaLymGIJXpZl1Opuw= 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 Reviewed-by: Jian J Wang --- .../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..200e15a294 --- /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 (#63090): https://edk2.groups.io/g/devel/message/63090 Mute This Topic: https://groups.io/mt/75720710/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 Thu Mar 28 21:55:14 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+63091+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+63091+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1595406090; cv=none; d=zohomail.com; s=zohoarc; b=Lr5DTbymw6hZntWRyfMA4cUPNEMlker4zSUmF3sX6hILL6cHkI30sjCX+M2CRZ4qUbtH7nrge5dP3CF6lC/UwSNMmv2yahG+K9hlIdI0Y7avt8xL/h6Qp29KHhiq4kOW2sdIfNjmlW6jfexZj43x9pY2g+563uPP+Gc3fzdYXBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595406090; 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=hfn7YdVsoMPw7iz5iijdRJZQjdttUXdlaFrhbRNzhVs=; b=VzV501zRRQpmKrb+ClbfsY6FCGOB9ZpsN4ma+kSL2B6eSAIc73gjV+hOC6rdCU2ep07gSWynGOcR4Y9Qz4HNRkBxiC+mzAtoLJDog/rsEjRtp280JcwQyz2MVX0pSbbdjs/IuJJ8x4zsZWmZy9Dw4gGAb6eclILfEUJKt0uPHz4= 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+63091+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 1595406090014767.6268240266018; Wed, 22 Jul 2020 01:21:30 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id brYXYY1788612xOI87EpGtzg; Wed, 22 Jul 2020 01:21:29 -0700 X-Received: from mga12.intel.com (mga12.intel.com []) by mx.groups.io with SMTP id smtpd.web11.14228.1595406080183038905 for ; Wed, 22 Jul 2020 01:21:29 -0700 IronPort-SDR: cfP0d8iQDKjM3/udaTFH8RBIQZOx+hY9hm9N4wYGcsuJ1kaneMyW6uSH/fmeSuT94RYV0Dt3Ph KVotenvG6zIw== X-IronPort-AV: E=McAfee;i="6000,8403,9689"; a="129857725" X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="129857725" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 01:21:28 -0700 IronPort-SDR: g8Upnn+RuZ7sBjXru/YtzrJT/+xkyNmgFRtfK73hV0Sk10fcWgnd5nxDF1cjrmip7wVCBUzHWM XKZB4bXHeuMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,381,1589266800"; d="scan'208";a="288209291" X-Received: from shwdesssddpdqi.ccr.corp.intel.com ([10.239.9.10]) by orsmga006.jf.intel.com with ESMTP; 22 Jul 2020 01:21:27 -0700 From: "Qi Zhang" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Qi Zhang Subject: [edk2-devel] [PATCH v7 6/6] SecurityPkg/dsc: Add PeiTpmMeasurementLib. Date: Wed, 22 Jul 2020 16:21:07 +0800 Message-Id: <20200722082107.12601-7-qi1.zhang@intel.com> In-Reply-To: <20200722082107.12601-1-qi1.zhang@intel.com> References: <20200722082107.12601-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: t7gJUO9NfAuhXraVbfjWjS15x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1595406089; bh=416XCw66tYqnRKqGf0QtCxhb3jZVWdExcVpW8/0fpaU=; h=Cc:Date:From:Reply-To:Subject:To; b=PMUBVg6pXWZQOxiWCkXiuWlFoBROTUK5IZicWWRColWieYZXcZGc3ZVYD/9KlNaHiZ8 JL8QlLCSx9Dy+mVzRM797PzzI9maEi5wDuy++B4CO81/5R7tzeqPrQsSaz9UwDJvmY2Xc eNWRZPN2ufhdPRej6y/Zz+gLU9nf7KPS4Nc= 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 Reviewed-by: Jian J Wang --- 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 (#63091): https://edk2.groups.io/g/devel/message/63091 Mute This Topic: https://groups.io/mt/75720711/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-