From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 46A991A1DEF for ; Mon, 22 Aug 2016 01:47:59 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP; 22 Aug 2016 01:47:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,559,1464678000"; d="scan'208";a="438947" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga005.fm.intel.com with ESMTP; 22 Aug 2016 01:47:58 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 22 Aug 2016 01:47:58 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.248.2; Mon, 22 Aug 2016 01:47:58 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.147]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.8]) with mapi id 14.03.0248.002; Mon, 22 Aug 2016 16:47:56 +0800 From: "Gao, Liming" To: "Zhu, Yonghong" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] BaseTools: add capsule image header for auth FMP capsule file Thread-Index: AQHR/EYjd/oMQHTlc0WeEHgcqgQR06BUqzBw Date: Mon, 22 Aug 2016 08:47:56 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A1155ED831@shsmsx102.ccr.corp.intel.com> References: <1471850613-93368-1-git-send-email-yonghong.zhu@intel.com> In-Reply-To: <1471850613-93368-1-git-send-email-yonghong.zhu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] BaseTools: add capsule image header for auth FMP capsule file X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Aug 2016 08:47:59 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Zhu, Yonghong > Sent: Monday, August 22, 2016 3:24 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [Patch] BaseTools: add capsule image header for auth FMP capsule > file >=20 > in last commit 91ae29, it missed to add the > EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER for the auth > FMP capsule. >=20 > Cc: Liming Gao > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Yonghong Zhu > --- > BaseTools/Source/Python/GenFds/Capsule.py | 15 +++++++++++---- > BaseTools/Source/Python/GenFds/CapsuleData.py | 10 ---------- > 2 files changed, 11 insertions(+), 14 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/GenFds/Capsule.py > b/BaseTools/Source/Python/GenFds/Capsule.py > index f8af12a..93ecee1 100644 > --- a/BaseTools/Source/Python/GenFds/Capsule.py > +++ b/BaseTools/Source/Python/GenFds/Capsule.py > @@ -139,10 +139,11 @@ class Capsule (CapsuleClassObject) : > PreSize +=3D os.path.getsize(FileName) > File =3D open(FileName, 'rb') > Content.write(File.read()) > File.close() > for fmp in self.FmpPayloadList: > + Buffer =3D fmp.GenCapsuleSubItem() > if fmp.Certificate_Guid: > ExternalTool, ExternalOption =3D FindExtendTool([], > GenFdsGlobalVariable.ArchList, fmp.Certificate_Guid) > CmdOption =3D '' > CapInputFile =3D fmp.ImageFile > if not os.path.isabs(fmp.ImageFile): > @@ -159,11 +160,11 @@ class Capsule (CapsuleClassObject) : > GenFdsGlobalVariable.CallExternalTool(CmdList, "Failed t= o generate > FMP auth capsule") > if uuid.UUID(fmp.Certificate_Guid) =3D=3D EFI_CERT_TYPE_= PKCS7_GUID: > dwLength =3D 4 + 2 + 2 + 16 + os.path.getsize(CapOut= putTmp) - > os.path.getsize(CapInputFile) > else: > dwLength =3D 4 + 2 + 2 + 16 + 16 + 256 + 256 > - Buffer =3D pack('Q', fmp.MonotonicCount) > + Buffer +=3D pack('Q', fmp.MonotonicCount) > Buffer +=3D pack('I', dwLength) > Buffer +=3D pack('H', WIN_CERT_REVISION) > Buffer +=3D pack('H', WIN_CERT_TYPE_EFI_GUID) > Buffer +=3D uuid.UUID(fmp.Certificate_Guid).get_bytes_le= () > if os.path.exists(CapOutputTmp): > @@ -176,14 +177,20 @@ class Capsule (CapsuleClassObject) : > VendorFile.close() > FwMgrHdr.write(pack('=3DQ', PreSize)) > PreSize +=3D len(Buffer) > Content.write(Buffer) > else: > - payload =3D fmp.GenCapsuleSubItem() > + ImageFile =3D open(fmp.ImageFile, 'rb') > + Buffer +=3D ImageFile.read() > + ImageFile.close() > + if fmp.VendorCodeFile: > + VendorFile =3D open(fmp.VendorCodeFile, 'rb') > + Buffer +=3D VendorFile.read() > + VendorFile.close() > FwMgrHdr.write(pack('=3DQ', PreSize)) > - PreSize +=3D len(payload) > - Content.write(payload) > + PreSize +=3D len(Buffer) > + Content.write(Buffer) > BodySize =3D len(FwMgrHdr.getvalue()) + len(Content.getvalue()) > Header.write(pack('=3DI', HdrSize + BodySize)) > # > # The real capsule header structure is 28 bytes > # > diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py > b/BaseTools/Source/Python/GenFds/CapsuleData.py > index 2a5c454..5d5a1e4 100644 > --- a/BaseTools/Source/Python/GenFds/CapsuleData.py > +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py > @@ -214,16 +214,6 @@ class CapsulePayload(CapsuleData): > 0, > ImageFileSize, > VendorFileSize, > int(self.HardwareInstance, 16) > ) > - # > - # Append file content to the structure > - # > - ImageFile =3D open(self.ImageFile, 'rb') > - Buffer +=3D ImageFile.read() > - ImageFile.close() > - if self.VendorCodeFile: > - VendorFile =3D open(self.VendorCodeFile, 'rb') > - Buffer +=3D VendorFile.read() > - VendorFile.close() > return Buffer > -- > 2.6.1.windows.1