From: "Wang, Jian J" <jian.j.wang@intel.com>
To: guomin jiang <newexplorerj@gmail.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Lu, XiaoyuX" <xiaoyux.lu@intel.com>
Subject: Re: [edk2-devel] [PATCH] CryptoPkg: Check the type is data and Support other OID types.
Date: Thu, 26 Mar 2020 08:00:54 +0000 [thread overview]
Message-ID: <D827630B58408649ACB04F44C510003625A32069@SHSMSX107.ccr.corp.intel.com> (raw)
In-Reply-To: <l1h807sgmmky1d3bx2qietm2dhzy65-865uoz-9geyb0-jvs8yzunx1dg-x5pfpo-tkt3perpop4djdzo2y-szi5kyvuz2s7-ykmp9b-p1h6xf293stf-naxexk-cwy9ejgzeptlybws0e6u6b4q-r755mu.1585208813559@email.android.com>
[-- Attachment #1: Type: text/plain, Size: 3529 bytes --]
Guomin,
Please use edk2 coding style of symbol name and data type as possible as you can
in “our” code.
Regards,
Jian
From: guomin jiang <newexplorerj@gmail.com>
Sent: Thursday, March 26, 2020 3:47 PM
To: devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@intel.com>; Lu, XiaoyuX <xiaoyux.lu@intel.com>
Subject: Re:[edk2-devel] [PATCH] CryptoPkg: Check the type is data and Support other OID types.
Hi jian and xiaoyu,
could you please help review this change.
-------- Original message --------
From: "GuoMinJ via Groups.Io" <newexplorerj=gmail.com@groups.io<mailto:newexplorerj=gmail.com@groups.io>>
Date: Wed, Feb 26, 2020, 10:24 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: GuoMinJ <newexplorerj@gmail.com<mailto:newexplorerj@gmail.com>>
Subject: [edk2-devel] [PATCH] CryptoPkg: Check the type is data and Support other OID types.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2539
Microsoft signtool supports creation of attached P7's with any OID payload
via the "/p7co" parameter. It is necessary to check the data before get
the string.
Signed-off-by: GuoMinJ <newexplorerj@gmail.com<mailto:newexplorerj@gmail.com>>
---
.../BaseCryptLib/Pk/CryptPkcs7VerifyBase.c | 51 ++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c
index 313f459b11..d437e52e1f 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptPkcs7VerifyBase.c
@@ -13,6 +13,53 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <openssl/x509v3.h>
#include <openssl/pkcs7.h>
+/**
+ Check the contents of PKCS7 is not data.
+
+ @param p7 Pointer to the location which the PKCS7 is located at.
+
+ @return int The content type.
+**/
+static int PKCS7_type_is_other(PKCS7 *p7)
+{
+ int isOther = 1;
+
+ int nid = OBJ_obj2nid(p7->type);
+
+ switch (nid) {
+ case NID_pkcs7_data:
+ case NID_pkcs7_signed:
+ case NID_pkcs7_enveloped:
+ case NID_pkcs7_signedAndEnveloped:
+ case NID_pkcs7_digest:
+ case NID_pkcs7_encrypted:
+ isOther = 0;
+ break;
+ default:
+ isOther = 1;
+ }
+
+ return isOther;
+
+}
+
+/**
+ Get the ASN.1 string for the PKCS7.
+
+ @param p7 Pointer to the location which the PKCS7 is located at.
+
+ @return ASN1_OCTET_STRING ASN.1 string.
+**/
+static ASN1_OCTET_STRING *PKCS7_get_octet_string(PKCS7 *p7)
+{
+ if (PKCS7_type_is_data(p7))
+ return p7->d.data;
+ if (PKCS7_type_is_other(p7) && p7->d.other
+ && (p7->d.other->type == 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 +145,9 @@ Pkcs7GetAttachedContent (
//
// Retrieve the attached content in PKCS7 signedData
//
- OctStr = Pkcs7->d.sign->contents->d.data;
+ OctStr = PKCS7_get_octet_string(Pkcs7->d.sign->contents);
+ DEBUG ((DEBUG_INFO, "OctStr->Type: %x\n", OctStr->type));
+ DEBUG ((DEBUG_INFO, "OctStr->Length: %x\n", OctStr->length));
if ((OctStr->length > 0) && (OctStr->data != NULL)) {
*ContentSize = OctStr->length;
*Content = AllocatePool (*ContentSize);
--
2.17.1
[-- Attachment #2: Type: text/html, Size: 16057 bytes --]
prev parent reply other threads:[~2020-03-26 8:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <15F6D29A1A18DA67.19684@groups.io>
2020-03-26 7:46 ` [edk2-devel] [PATCH] CryptoPkg: Check the type is data and Support other OID types GuoMinJ
2020-03-26 8:00 ` Wang, Jian J [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D827630B58408649ACB04F44C510003625A32069@SHSMSX107.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox