From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=qin.long@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CB98F203B9931 for ; Fri, 11 May 2018 01:25:59 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 May 2018 01:25:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,387,1520924400"; d="scan'208";a="38498299" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga007.fm.intel.com with ESMTP; 11 May 2018 01:25:59 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 11 May 2018 01:25:59 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 11 May 2018 01:25:58 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by shsmsx102.ccr.corp.intel.com ([169.254.2.79]) with mapi id 14.03.0319.002; Fri, 11 May 2018 16:25:57 +0800 From: "Long, Qin" To: Laszlo Ersek , James Bottomley , "edk2-devel@lists.01.org" CC: Zhang Lubo Thread-Topic: [edk2] [PATCH] SecurityPkg: fix sha256 signature check Thread-Index: AQHT5+JeXhxGUxfX10CsqEWg4igmNqQoYQUAgAHP3XA= Date: Fri, 11 May 2018 08:25:56 +0000 Message-ID: References: <1525903747.5882.11.camel@HansenPartnership.com> <1595cae2-f01d-57e2-6c2b-2cbb472d7a84@redhat.com> In-Reply-To: <1595cae2-f01d-57e2-6c2b-2cbb472d7a84@redhat.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] SecurityPkg: fix sha256 signature check X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 May 2018 08:26:00 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Laszlo Ersek > Sent: Thursday, May 10, 2018 8:36 PM > To: James Bottomley ; edk2- > devel@lists.01.org > Cc: Zhang Lubo > Subject: Re: [edk2] [PATCH] SecurityPkg: fix sha256 signature check >=20 > On 05/10/18 00:09, James Bottomley wrote: > > commit c035e37335ae43229d7e68de74a65f2c01ebc0af > > Author: Zhang Lubo > > Date: Thu Jan 5 14:58:05 2017 +0800 > > > > SecurityPkg: enhance secure boot Config Dxe & Time Based AuthVariab= le. > > > > Added a check for sha256 being the ownly allowed signature hash. > > Unfortuantely this commit assumed the form of the signature data was a > > raw SignedData sequence. Most tools actually generate a ContentInfo > > sequence instead which contains a header identifying the content as > > pkcs7-SignedData. Fix this check to allow either format to work. > > > > This fix is needed at least for efitools because we generate signed > > variable updates with the ContentInfo header. > > > > Signed-off-by: James Bottomley > > > --- > > CryptoPkg/Library/OpensslLib/openssl | 2 +- > > SecurityPkg/Library/AuthVariableLib/AuthService.c | 11 ++++++++++- > > 2 files changed, 11 insertions(+), 2 deletions(-) > > > > diff --git a/CryptoPkg/Library/OpensslLib/openssl > > b/CryptoPkg/Library/OpensslLib/openssl > > index b2758a2292..d4e4bd2a81 160000 > > --- a/CryptoPkg/Library/OpensslLib/openssl > > +++ b/CryptoPkg/Library/OpensslLib/openssl > > @@ -1 +1 @@ > > -Subproject commit b2758a2292aceda93e9f44c219b94fe21bb9a650 > > +Subproject commit d4e4bd2a8163f355fa8a3884077eaec7adc75ff7 >=20 > This hunk should not be necessary; please see edk2 commit b85b20fba42e > ("CryptoPkg/OpensslLib: Update OpenSSL version to 1.1.0h", 2018-04-15). >=20 > (I'll let the SecurityPkg maintainers review the rest.) >=20 > Thanks, > Laszlo [Long, Qin] I think so.=20 OpenSSL submodule was already upgraded to 1.1.0h (d4e4bd2a8...) >=20 > > diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c > > b/SecurityPkg/Library/AuthVariableLib/AuthService.c > > index 213a524f27..855ea3350a 100644 > > --- a/SecurityPkg/Library/AuthVariableLib/AuthService.c > > +++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c > > @@ -1908,10 +1908,19 @@ VerifyTimeBasedPayload ( > > // in VARIABLE_AUTHENTICATION_2 descriptor. > > // This field has the fixed offset (+13) and be calculated based = on two > bytes of length encoding. > > // > > + // However the data may also begin > > + // ContentInfo ::=3D SEQUENCE { > > + // contentType ContentType, > > + // content > > + // [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL } > > + // > > + // In which case the fixed offset is +32 // > > if ((Attributes & > EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) !=3D 0) { > > if (SigDataSize >=3D (13 + sizeof (mSha256OidValue))) { > > if (((*(SigData + 1) & TWO_BYTE_ENCODE) !=3D TWO_BYTE_ENCODE) || > > - (CompareMem (SigData + 13, &mSha256OidValue, sizeof > (mSha256OidValue)) !=3D 0)) { > > + (CompareMem (SigData + 13, &mSha256OidValue, sizeof > (mSha256OidValue)) !=3D 0 && > > + CompareMem (SigData + 32, &mSha256OidValue, sizeof > > +(mSha256OidValue)) !=3D 0)) { > > return EFI_SECURITY_VIOLATION; > > } > > } > > [Long, Qin] This part looks good to me.=20 I prefer to add this to make both formats (with or without contentType) to= work. >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel