From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web12.1435.1579201638889166706 for ; Thu, 16 Jan 2020 11:07:19 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=goNiyvpY; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579201638; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=78qQW1JIAk7dLUmHiSWjPfrZad1FGEvWvEM2xNX53Z8=; b=goNiyvpYYUfmjz0ilH0LLwFzSElIgbLMFc7kBC5q/exqbWN4QGXquvUm3UcqWRZcRQn4hq PoNkG3p6vbSIYb9Fb92S+RqPmel0ESkhzGslWfFWTuk1p6QRUBvmHB13E6S8iykaeW8w6F lhQRoLAsawFsPRWBKw97gBFzCLNf9Vg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-jG9zNqjRMkiwfDmBculgrg-1; Thu, 16 Jan 2020 14:07:14 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 536648017CC; Thu, 16 Jan 2020 19:07:13 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-120.ams2.redhat.com [10.36.116.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3497680890; Thu, 16 Jan 2020 19:07:12 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Chao Zhang , Jian J Wang , Jiewen Yao Subject: [PATCH 03/11] SecurityPkg/DxeImageVerificationHandler: keep PE/COFF info status internal Date: Thu, 16 Jan 2020 20:06:57 +0100 Message-Id: <20200116190705.18816-4-lersek@redhat.com> In-Reply-To: <20200116190705.18816-1-lersek@redhat.com> References: <20200116190705.18816-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: jG9zNqjRMkiwfDmBculgrg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: base64 VGhlIFBlQ29mZkxvYWRlckdldEltYWdlSW5mbygpIGZ1bmN0aW9uIG1heSByZXR1cm4gdmFyaW91 cyBlcnJvciBjb2RlcywKc3VjaCBhcyBSRVRVUk5fSU5WQUxJRF9QQVJBTUVURVIgYW5kIFJFVFVS Tl9VTlNVUFBPUlRFRC4KClN1Y2ggZXJyb3IgdmFsdWVzIHNob3VsZCBub3QgYmUgYXNzaWduZWQg dG8gb3VyICJTdGF0dXMiIHZhcmlhYmxlIGluIHRoZQpEeGVJbWFnZVZlcmlmaWNhdGlvbkhhbmRs ZXIoKSBmdW5jdGlvbiwgYmVjYXVzZSAiU3RhdHVzIiBnZW5lcmFsbHkgc3RhbmRzCmZvciB0aGUg bWFpbiBleGl0IHZhbHVlIG9mIHRoZSBmdW5jdGlvbi4gQW5kClNFQ1VSSVRZMl9GSUxFX0FVVEhF TlRJQ0FUSU9OX0hBTkRMRVIgZnVuY3Rpb25zIGFyZSBleHBlY3RlZCB0byByZXR1cm4gb25lCm9m IEVGSV9TVUNDRVNTLCBFRklfU0VDVVJJVFlfVklPTEFUSU9OLCBhbmQgRUZJX0FDQ0VTU19ERU5J RUQgb25seS4KCkludHJvZHVjZSB0aGUgIlBlQ29mZlN0YXR1cyIgaGVscGVyIHZhcmlhYmxlIGZv ciBrZWVwaW5nIHRoZSByZXR1cm4gdmFsdWUK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AqRmlsZUJ1ZmZlciwNCiAgIElOICBVSU5UTiAg ICAgICAgICAgICAgICAgICAgICAgICAgICBGaWxlU2l6ZSwNCiAgIElOICBCT09MRUFOICAgICAg ICAgICAgICAgICAgICAgICAgICBCb290UG9saWN5DQogICApDQogew0KICAgRUZJX1NUQVRVUyAg ICAgICAgICAgICAgICAgICAgICAgICAgIFN0YXR1czsNCiAgIEVGSV9JTUFHRV9ET1NfSEVBREVS ICAgICAgICAgICAgICAgICAqRG9zSGRyOw0KICAgQk9PTEVBTiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIElzVmVyaWZpZWQ7DQogICBFRklfU0lHTkFUVVJFX0xJU1QgICAgICAgICAgICAg ICAgICAgKlNpZ25hdHVyZUxpc3Q7DQogICBVSU5UTiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgU2lnbmF0dXJlTGlzdFNpemU7DQogICBFRklfU0lHTkFUVVJFX0RBVEEgICAgICAgICAg ICAgICAgICAgKlNpZ25hdHVyZTsNCiAgIEVGSV9JTUFHRV9FWEVDVVRJT05fQUNUSU9OICAgICAg ICAgICBBY3Rpb247DQogICBXSU5fQ0VSVElGSUNBVEUgICAgICAgICAgICAgICAgICAgICAgKldp bkNlcnRpZmljYXRlOw0KICAgVUlOVDMyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBv bGljeTsNCiAgIFVJTlQ4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqU2VjdXJlQm9v dDsNCiAgIFBFX0NPRkZfTE9BREVSX0lNQUdFX0NPTlRFWFQgICAgICAgICBJbWFnZUNvbnRleHQ7 DQogICBVSU5UMzIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTnVtYmVyT2ZSdmFBbmRT aXplczsNCiAgIFdJTl9DRVJUSUZJQ0FURV9FRklfUEtDUyAgICAgICAgICAgICAqUGtjc0NlcnRE YXRhOw0KICAgV0lOX0NFUlRJRklDQVRFX1VFRklfR1VJRCAgICAgICAgICAgICpXaW5DZXJ0VWVm aUd1aWQ7DQogICBVSU5UOCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKkF1dGhEYXRh Ow0KICAgVUlOVE4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEF1dGhEYXRhU2l6ZTsN CiAgIEVGSV9JTUFHRV9EQVRBX0RJUkVDVE9SWSAgICAgICAgICAgICAqU2VjRGF0YURpcjsNCiAg IFVJTlQzMiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPZmZTZXQ7DQogICBDSEFSMTYg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKk5hbWVTdHI7DQorICBSRVRVUk5fU1RBVFVT ICAgICAgICAgICAgICAgICAgICAgICAgUGVDb2ZmU3RhdHVzOw0KIA0KICAgU2lnbmF0dXJlTGlz dCAgICAgPSBOVUxMOw0KICAgU2lnbmF0dXJlTGlzdFNpemUgPSAwOw0KICAgV2luQ2VydGlmaWNh dGUgICAgPSBOVUxMOw0KICAgU2VjRGF0YURpciAgICAgICAgPSBOVUxMOw0KICAgUGtjc0NlcnRE YXRhICAgICAgPSBOVUxMOw0KICAgQWN0aW9uICAgICAgICAgICAgPSBFRklfSU1BR0VfRVhFQ1VU SU9OX0FVVEhfVU5URVNURUQ7DQogICBTdGF0dXMgICAgICAgICAgICA9IEVGSV9BQ0NFU1NfREVO SUVEOw0KICAgSXNWZXJpZmllZCAgICAgICAgPSBGQUxTRTsNCiANCiANCiAgIC8vDQogICAvLyBD aGVjayB0aGUgaW1hZ2UgdHlwZSBhbmQgZ2V0IHBvbGljeSBzZXR0aW5nLg0KICAgLy8NCiAgIHN3 aXRjaCAoR2V0SW1hZ2VUeXBlIChGaWxlKSkgew0KIA0KICAgY2FzZSBJTUFHRV9GUk9NX0ZWOg0K ICAgICBQb2xpY3kgPSBBTFdBWVNfRVhFQ1VURTsNCiAgICAgYnJlYWs7DQogDQogICBjYXNlIElN QUdFX0ZST01fT1BUSU9OX1JPTToNCiAgICAgUG9saWN5ID0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