From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web10.1468.1579201639097359964 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=JDe7knb+; spf=pass (domain: redhat.com, ip: 207.211.31.120, 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=6TwzKCf2hytdsmS1qLJKlz4yB6kLq3EkaSFLmkMiSt4=; b=JDe7knb+wx8UkCKxqGuRd44zs5BbyTbC6XSZMWQ2i5qciduqAYxAcJziyH64K89YNzVBW4 4WiUMvM5cExiVdUT3eD4L7ce0ZSeSV1Z8yODZ976fg/eWe+73PUeohf5SIw1VxOFKxk5iw khPqDgZtmpi6VBt71a4n1+RI4x0woa8= 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-25-VDGdJ2CNMwS-gC0getIQgg-1; Thu, 16 Jan 2020 14:07:11 -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 389DD800D50; Thu, 16 Jan 2020 19:07:10 +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 192F484333; Thu, 16 Jan 2020 19:07:08 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Chao Zhang , Jian J Wang , Jiewen Yao Subject: [PATCH 01/11] SecurityPkg/DxeImageVerificationHandler: simplify "VerifyStatus" Date: Thu, 16 Jan 2020 20:06:55 +0100 Message-Id: <20200116190705.18816-2-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: VDGdJ2CNMwS-gC0getIQgg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: base64 SW4gdGhlIER4ZUltYWdlVmVyaWZpY2F0aW9uSGFuZGxlcigpIGZ1bmN0aW9uLCB0aGUgIlZlcmlm eVN0YXR1cyIgdmFyaWFibGUKY2FuIG9ubHkgY29udGFpbiBvbmUgb2YgdHdvIHZhbHVlczogRUZJ X1NVQ0NFU1MgYW5kIEVGSV9BQ0NFU1NfREVOSUVELgpGdXJ0aGVybW9yZSwgdGhlIHZhcmlhYmxl IGlzIG9ubHkgY29uc3VtZWQgd2l0aCBFRklfRVJST1IoKS4KClRoZXJlZm9yZSwgdXNpbmcgdGhl IEVGSV9TVEFUVVMgdHlwZSBmb3IgdGhlIHZhcmlhYmxlIGlzIHVubmVjZXNzYXJ5LgpXb3JzZSwg Z2l2ZW4gdGhlIGNvbXBsZXggbWVhbmluZ3Mgb2YgdGhlIGZ1bmN0aW9uJ3MgcmV0dXJuIHZhbHVl cywgdXNpbmcKRUZJX1NUQVRVUyBmb3IgIlZlcmlmeVN0YXR1cyIgaXMgYWN0aXZlbHkgY29uZnVz aW5nLgoKUmVuYW1lIHRoZSB2YXJpYWJsZSB0byAiSXNWZXJpZmllZCIsIGFuZCBtYWtlIGl0IGEg c2ltcGxlIEJPT0xFQU4uCgpUaGlzIHBhdGNoIGlzIGEgbm8tb3AsIHJlZ2FyZGluZyBiZWhhdmlv ci4KCkNjOiBDaGFvIFpoYW5nIDx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iAgICAgICAgICAgICAgICAgICAgICAgICAgIEF1dGhlbnRpY2F0aW9uU3RhdHVzLA0K ICAgSU4gIENPTlNUIEVGSV9ERVZJQ0VfUEFUSF9QUk9UT0NPTCAgICpGaWxlLA0KICAgSU4gIFZP SUQgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpGaWxlQnVmZmVyLA0KICAgSU4gIFVJTlRO ICAgICAgICAgICAgICAgICAgICAgICAgICAgIEZpbGVTaXplLA0KICAgSU4gIEJPT0xFQU4gICAg ICAgICAgICAgICAgICAgICAgICAgIEJvb3RQb2xpY3kNCiAgICkNCiB7DQogICBFRklfU1RBVFVT ICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RhdHVzOw0KICAgRUZJX0lNQUdFX0RPU19IRUFE RVIgICAgICAgICAgICAgICAgICpEb3NIZHI7DQotICBFRklfU1RBVFVTICAgICAgICAgICAgICAg ICAgICAgICAgICAgVmVyaWZ5U3RhdHVzOw0KKyAgQk9PTEVBTiAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIElzVmVyaWZpZWQ7DQogICBFRklfU0lHTkFUVVJFX0xJU1QgICAgICAgICAgICAg ICAgICAgKlNpZ25hdHVyZUxpc3Q7DQogICBVSU5UTiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgU2lnbmF0dXJlTGlzdFNpemU7DQogICBFRklfU0lHTkFUVVJFX0RBVEEgICAgICAgICAg ICAgICAgICAgKlNpZ25hdHVyZTsNCiAgIEVGSV9JTUFHRV9FWEVDVVRJT05fQUNUSU9OICAgICAg ICAgICBBY3Rpb247DQogICBXSU5fQ0VSVElGSUNBVEUgICAgICAgICAgICAgICAgICAgICAgKldp bkNlcnRpZmljYXRlOw0KICAgVUlOVDMyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBv bGljeTsNCiAgIFVJTlQ4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAqU2VjdXJlQm9v dDsNCiAgIFBFX0NPRkZfTE9BREVSX0lNQUdFX0NPTlRFWFQgICAgICAgICBJbWFnZUNvbnRleHQ7 DQogICBVSU5UMzIgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgTnVtYmVyT2ZSdmFBbmRT aXplczsNCiAgIFdJTl9DRVJUSUZJQ0FURV9FRklfUEtDUyAgICAgICAgICAgICAqUGtjc0NlcnRE YXRhOw0KICAgV0lOX0NFUlRJRklDQVRFX1VFRklfR1VJRCAgICAgICAgICAgICpXaW5DZXJ0VWVm aUd1aWQ7DQogICBVSU5UOCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKkF1dGhEYXRh Ow0KICAgVUlOVE4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEF1dGhEYXRhU2l6ZTsN CiAgIEVGSV9JTUFHRV9EQVRBX0RJUkVDVE9SWSAgICAgICAgICAgICAqU2VjRGF0YURpcjsNCiAg IFVJTlQzMiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPZmZTZXQ7DQogICBDSEFSMTYg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKk5hbWVTdHI7DQogDQogICBTaWduYXR1cmVM aXN0ICAgICA9IE5VTEw7DQogICBTaWduYXR1cmVMaXN0U2l6ZSA9IDA7DQogICBXaW5DZXJ0aWZp Y2F0ZSAgICA9IE5VTEw7DQogICBTZWNEYXRhRGlyICAgICAgICA9IE5VTEw7DQogICBQa2NzQ2Vy dERhdGEgICAgICA9IE5VTEw7DQogICBBY3Rpb24gICAgICAgICAgICA9IEVGSV9JTUFHRV9FWEVD VVRJT05fQVVUSF9VTlRFU1RFRDsNCiAgIFN0YXR1cyAgICAgICAgICAgID0gRUZJX0FDQ0VTU19E RU5JRUQ7DQotICBWZXJpZnlTdGF0dXMgICAgICA9IEVGSV9BQ0NFU1NfREVOSUVEOw0KKyAgSXNW ZXJpZmllZCAgICAgICAgPSBGQUxTRTsNCiANCiANCiAgIC8vDQogICAvLyBDaGVjayB0aGUgaW1h Z2UgdHlwZSBhbmQgZ2V0IHB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