From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.105.1588002823053698429 for ; Mon, 27 Apr 2020 08:53:43 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: jian.j.wang@intel.com) IronPort-SDR: G/Bxhy17RSWkRnAL9qIsOlegVPRq2YoEI7U2l1lgUqhtJgtJe5cHrQpDAvSWW/R7tBru5o4Dar fw+kQ7j5EP6A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 08:53:42 -0700 IronPort-SDR: uS5zODIH2lRmVJCVCrqUxeEHCmhgOnAXCPPqVqEymB3/xXMur23t26AdW+tdFnEOso5e+FTO5w 28/HrvYTJ8xg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,324,1583222400"; d="scan'208";a="302411293" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 27 Apr 2020 08:53:42 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 27 Apr 2020 08:53:42 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 27 Apr 2020 08:53:41 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 27 Apr 2020 08:53:41 -0700 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.191]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.129]) with mapi id 14.03.0439.000; Mon, 27 Apr 2020 23:53:21 +0800 From: "Wang, Jian J" To: "devel@edk2.groups.io" , "Wang, Jian J" , "Jiang, Guomin" CC: "Lu, XiaoyuX" Subject: Re: [edk2-devel] [PATCH v4] CryptoPkg/Pkcs7: Extend support for other OID types Thread-Topic: [edk2-devel] [PATCH v4] CryptoPkg/Pkcs7: Extend support for other OID types Thread-Index: AQHWG40qz1J5lSuHWEWqmsjU26sMY6iMm9yggACDh2A= Date: Mon, 27 Apr 2020 15:53:20 +0000 Message-ID: References: <20200426054009.792-1-guomin.jiang@intel.com> <16099F3AD41E60C6.16806@groups.io> In-Reply-To: <16099F3AD41E60C6.16806@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: jian.j.wang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Guomin, One more comment. > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Wang, Jia= n > J > Sent: Monday, April 27, 2020 4:17 PM > To: Jiang, Guomin ; devel@edk2.groups.io > Cc: Lu, XiaoyuX > Subject: Re: [edk2-devel] [PATCH v4] CryptoPkg/Pkcs7: Extend support for= other > OID types >=20 > Guomin, >=20 > A few comments below. >=20 > > -----Original Message----- > > From: Jiang, Guomin > > Sent: Sunday, April 26, 2020 1:40 PM > > To: devel@edk2.groups.io > > Cc: Wang, Jian J ; Lu, XiaoyuX > > Subject: [PATCH v4] CryptoPkg/Pkcs7: Extend support for other OID type= s > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2539 > > > > Microsoft signtool supports creation of attached P7's with any OID pay= load > > via the "/p7co" parameter. It is necessary to check the data before ge= t > > the string. > > > > Cc: Jian J Wang > > Cc: Xiaoyu Lu > > Signed-off-by: Guomin Jiang > > --- > > .../BaseCryptLib/Pk/CryptPkcs7VerifyBase.c | 65 ++++++++++++++++++= - > > 1 file changed, 64 insertions(+), 1 deletion(-) > > > > diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c > > b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c > > index 313f459b11..70d9880897 100644 > > --- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c > > +++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c > > @@ -13,6 +13,65 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #include > > > > #include > > > > > > > > +/** > > > > + Check the contents of PKCS7 is not data. > > > > + > > > > + It is copied from PKCS7_type_is_other() in pk7_doit.c. > > > > + > > > > + @param P7 Pointer to the location which the PKCS7 is located at. > > > > + > > > > + @return UINT8 The content type. > > > > +**/ > > > > +static >=20 > Please use STATIC instead, according to ch5.6.1.2 of "EDK II Coding > Standards 2.1". >=20 > https://github.com/tianocore- > docs/Docs/raw/master/Specifications/CCS_2_1_Draft.pdf >=20 > > > > +UINT8 > > > > +Pkcs7TypeIsOther ( > > > > + PKCS7 *P7 >=20 > Missing IN/OUT modifier for parameter, according to ch5.7.1.11 of > "EDK II Coding Standards 2.1". Add in/out in function parameter > description comment as well. >=20 > https://github.com/tianocore- > docs/Docs/raw/master/Specifications/CCS_2_1_Draft.pdf >=20 > > > > + ) > > > > +{ > > > > + UINT8 Others =3D 1; > > > > + UINT8 Nid =3D (UINT8) OBJ_obj2nid (P7->type); > > The nid in source data structure is defined as 'int'. I think edk2 INTN is= the best shot for type of 'Others', 'Nid' and return value. Regards, Jian > > + > > > > + switch (Nid) { > > > > + case NID_pkcs7_data: > > > > + case NID_pkcs7_signed: > > > > + case NID_pkcs7_enveloped: > > > > + case NID_pkcs7_signedAndEnveloped: > > > > + case NID_pkcs7_encrypted: > > > > + Others =3D 0; > > > > + break; > > > > + default: > > > > + Others =3D 1; > > > > + } > > > > + > > > > + return Others; > > > > +} > > > > + > > > > +/** > > > > + Get the ASN.1 string for the PKCS7. > > > > + > > > > + It is copied from PKCS7_get_octet_string() in pk7_doit.c. > > > > + @param P7 Pointer to the location which the PKCS7 is located at. > > > > + > > > > + @return ASN1_OCTET_STRING ASN.1 string. > > > > +**/ > > > > +static >=20 > Same as above, use STATIC instead. >=20 > > > > +ASN1_OCTET_STRING* > > > > +Pkcs7GetOctetString ( > > > > + PKCS7 *P7 >=20 > Missing IN/OUT modifier for parameter, according to ch5.7.1.11 of > "EDK II Coding Standards 2.1". Add in/out in function parameter > description comment as well. >=20 > Regards, > Jian >=20 > > > > + ) > > > > +{ > > > > + if (PKCS7_type_is_data (P7)) { > > > > + return P7->d.data; > > > > + } > > > > + > > > > + if ((Pkcs7TypeIsOther(P7) =3D=3D 1) && P7->d.other && > > > > + (P7->d.other->type =3D=3D V_ASN1_OCTET_STRING)) { > > > > + return P7->d.other->value.octet_string; > > > > + } > > > > + > > > > + return NULL; > > > > +} > > > > + > > > > /** > > > > Extracts the attached content from a PKCS#7 signed data if existed.= The input > > signed > > > > data could be wrapped in a ContentInfo structure. > > > > @@ -98,7 +157,11 @@ Pkcs7GetAttachedContent ( > > // > > > > // Retrieve the attached content in PKCS7 signedData > > > > // > > > > - OctStr =3D Pkcs7->d.sign->contents->d.data; > > > > + OctStr =3D Pkcs7GetOctetString (Pkcs7->d.sign->contents); > > > > + if (OctStr =3D=3D NULL) { > > > > + goto _Exit; > > > > + } > > > > + > > > > if ((OctStr->length > 0) && (OctStr->data !=3D NULL)) { > > > > *ContentSize =3D OctStr->length; > > > > *Content =3D AllocatePool (*ContentSize); > > > > -- > > 2.25.1.windows.1 >=20 >=20 >=20