public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Vinson Lee <vlee@twopensource.com>
Cc: dhowells@redhat.com, David Woodhouse <David.Woodhouse@intel.com>,
	"Luis R. Rodriguez" <mcgrof@suse.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Marcel Holtmann <marcel@holtmann.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: Linux 4.3-rc1 build error on CentOS 5.11 "scripts/sign-file.c:23:25: fatal error: openssl/cms.h: No such file or directory"
Date: Wed, 16 Sep 2015 23:45:15 +0100	[thread overview]
Message-ID: <15243.1442443515@warthog.procyon.org.uk> (raw)
In-Reply-To: <19089.1442357783@warthog.procyon.org.uk>

David Howells <dhowells@redhat.com> wrote:

> Hmmm...  Tricky.  I'll have to think about it.  I'm using PKCS7_NOCERTS with
> PKCS7_sign_add_signer() (or the CMS equivalents) to leave the cert list out of
> the message - but it's then necessary to manually specify the signers - at
> least so I recall.

It's worse than that.  The PKCS7_sign() function in pre-1.0.0 OpenSSL crypto
libs will only do SHA1.

Now, it will work, and SHA1 might be just about acceptable for something based
on that old an OpenSSL library.

With this in mind, does the attached additional patch (on top of the one I
gave you yesterday) work for you?  You need to set CONFIG_MODULE_SIG_SHA1=y in
your config.

David
---
diff --git a/scripts/sign-file.c b/scripts/sign-file.c
index 0765141c3150..f65120e2aa03 100755
--- a/scripts/sign-file.c
+++ b/scripts/sign-file.c
@@ -32,7 +32,14 @@
  * assume that it's not available and its header file is missing and that we
  * should use PKCS#7 instead.  Switching to the older PKCS#7 format restricts
  * the options we have on specifying the X.509 certificate we want.
+ *
+ * Further, older versions of OpenSSL don't support manually adding signers to
+ * the PKCS#7 message so have to accept that we get a certificate included in
+ * the signature message.  Nor do such older versions of OpenSSL support
+ * signing with anything other than SHA1 - so we're stuck with that if such is
+ * the case.
  */
+#define USE_PKCS7
 #if OPENSSL_VERSION_NUMBER < 0x10000000L
 #define USE_PKCS7
 #endif
@@ -184,6 +191,14 @@ int main(int argc, char **argv)
 		replace_orig = true;
 	}
 
+#ifdef USE_PKCS7
+	if (strcmp(hash_algo, "sha1") != 0) {
+		fprintf(stderr, "sign-file: %s only supports SHA1 signing\n",
+			OPENSSL_VERSION_TEXT);
+		exit(3);
+	}
+#endif
+
 	/* Read the private key and the X.509 cert the PKCS#7 message
 	 * will point to.
 	 */
@@ -240,8 +255,8 @@ int main(int argc, char **argv)
 	bm = BIO_new_file(module_name, "rb");
 	ERR(!bm, "%s", module_name);
 
-	/* Load the signature message from the digest buffer. */
 #ifndef USE_PKCS7
+	/* Load the signature message from the digest buffer. */
 	cms = CMS_sign(NULL, NULL, NULL, NULL,
 		       CMS_NOCERTS | CMS_PARTIAL | CMS_BINARY | CMS_DETACHED | CMS_STREAM);
 	ERR(!cms, "CMS_sign");
@@ -254,17 +269,10 @@ int main(int argc, char **argv)
 	    "CMS_final");
 
 #else
-	pkcs7 = PKCS7_sign(NULL, NULL, NULL, NULL,
-			   PKCS7_NOCERTS | PKCS7_PARTIAL | PKCS7_BINARY |
-			   PKCS7_DETACHED | PKCS7_STREAM);
+	pkcs7 = PKCS7_sign(x509, private_key, NULL, bm,
+			   PKCS7_NOCERTS | PKCS7_BINARY |
+			   PKCS7_DETACHED | PKCS7_STREAM | use_signed_attrs);
 	ERR(!pkcs7, "PKCS7_sign");
-
-	ERR(!PKCS7_sign_add_signer(pkcs7, x509, private_key, digest_algo,
-				   PKCS7_NOCERTS | PKCS7_BINARY | PKCS7_NOSMIMECAP |
-				   use_signed_attrs),
-	    "PKCS7_sign_add_signer");
-	ERR(PKCS7_final(pkcs7, bm, PKCS7_NOCERTS | PKCS7_BINARY) < 0,
-	    "PKCS7_final");
 #endif
 
 	if (save_sig) {

  reply	other threads:[~2015-09-16 22:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 22:41 Linux 4.3-rc1 build error on CentOS 5.11 "scripts/sign-file.c:23:25: fatal error: openssl/cms.h: No such file or directory" Vinson Lee
2015-09-11 23:22 ` Davidlohr Bueso
2015-09-12 21:40   ` Jim Davis
2015-09-14  2:14   ` Dongsheng Yang
2015-09-15 13:40 ` David Howells
2015-09-15 22:01   ` Vinson Lee
2015-09-15 22:56     ` David Howells
2015-09-16 22:45       ` David Howells [this message]
2015-09-18  6:48         ` Vinson Lee
2015-09-24 11:18           ` David Howells
2015-09-24 11:21             ` David Howells
2015-09-24 22:24               ` Vinson Lee
2015-09-25  6:16                 ` David Howells
2015-09-25 14:24                 ` David Howells
2015-09-26  1:43                   ` Vinson Lee

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-all 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=15243.1442443515@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=David.Woodhouse@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=mcgrof@suse.com \
    --cc=vlee@twopensource.com \
    --cc=zohar@linux.vnet.ibm.com \
    /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