Gnus development mailing list
 help / color / mirror / Atom feed
From: Roy Hashimoto <roy.hashimoto@gmail.com>
To: ding@gnus.org
Subject: Re: magic numbers in mm-view.el
Date: Sun, 9 Jun 2013 17:37:15 +0000 (UTC)	[thread overview]
Message-ID: <loom.20130609T190948-715@post.gmane.org> (raw)
In-Reply-To: <mj7psuuay9t.fsf@mm117419-pc.MITRE.ORG>

David S. Goldberg <david.goldberg6 <at> verizon.net> writes:
> If I use the #secure tag to send an encrypted s/mime email to others
> and include a copy for myself, I am unable to read my copy in Gnus.  I
> am able to decrypt and verify it (assuming it's signed as well) by
> manually running Openssl on the message file and am also able to do so
> in Thunderbird.  Oddly enough, if I build a multipart structure for
> the message using #multipart instead of #secure I don't have this
> problem.  But because the structure of the message is apparently not a
> problem for OpenSSL or Thunderbird, I believe that the problem is that
> the mm-pkcs7-enveloped-magic variable is not sufficient to cover all
> cases.

This is a followup to an ancient thread but the bug is still present in the gnus
shipped with GNU Emacs 24.3.  To recap, sometimes valid S/MIME encrypted
messages will not be recognized with the error "Unknown or unimplemented
PKCS#7 type".  The cause was identified in the original message, which was
that the regular expression recognizing the binary PKCS7 envelope used a '.' 
to match any byte but that does not include 0x0a (\n).

Here's a patch that fixes that issue for both signed and encrypted messages
and makes the regexp a little easier to read:

Correct PKCS7 regexps to match messages with 0x0a bytes.

Signed-off-by: Roy Hashimoto <roy.hashimoto@gmail.com>
---

diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index ac6170a..b1cba27 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -660,14 +660,26 @@ If MODE is not set, try to find mode automatically."
 ;;      id-signedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
 ;;          us(840) rsadsi(113549) pkcs(1) pkcs7(7) 2 }
 (defvar mm-pkcs7-signed-magic
-  "\x30\x5c\x28\x80\x5c\x7c\x81\x2e\x5c\x7c\x82\x2e\x2e\x5c\x7c\x83\x2e\x2e\
-\x2e\x5c\x29\x06\x09\x5c\x2a\x86\x48\x86\xf7\x0d\x01\x07\x02")
+  (concat
+    "0"
+    "\\(\\(\x80\\)"
+    "\\|\\(\x81\\(.\\|\n\\)\\{1\\}\\)"
+    "\\|\\(\x82\\(.\\|\n\\)\\{2\\}\\)"
+    "\\|\\(\x83\\(.\\|\n\\)\\{3\\}\\)"
+    "\\)"
+    "\x06\x09\\*\x86H\x86\xf7\x0d\x01\x07\x02"))
 
 ;;      id-envelopedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
 ;;          us(840) rsadsi(113549) pkcs(1) pkcs7(7) 3 }
 (defvar mm-pkcs7-enveloped-magic
-  "\x30\x5c\x28\x80\x5c\x7c\x81\x2e\x5c\x7c\x82\x2e\x2e\x5c\x7c\x83\x2e\x2e\
-\x2e\x5c\x29\x06\x09\x5c\x2a\x86\x48\x86\xf7\x0d\x01\x07\x03")
+  (concat
+    "0"
+    "\\(\\(\x80\\)"
+    "\\|\\(\x81\\(.\\|\n\\)\\{1\\}\\)"
+    "\\|\\(\x82\\(.\\|\n\\)\\{2\\}\\)"
+    "\\|\\(\x83\\(.\\|\n\\)\\{3\\}\\)"
+    "\\)"
+    "\x06\x09\\*\x86H\x86\xf7\x0d\x01\x07\x03"))
 
 (defun mm-view-pkcs7-get-type (handle)
   (mm-with-unibyte-buffer
--

Roy




  parent reply	other threads:[~2013-06-09 17:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-10 17:59 David S. Goldberg
2005-06-10 20:31 ` Simon Josefsson
2005-06-13 14:48   ` David S. Goldberg
2005-06-10 21:02 ` Arne Jørgensen
2013-06-09 17:37 ` Roy Hashimoto [this message]
2013-06-10  4:57   ` Daiki Ueno

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=loom.20130609T190948-715@post.gmane.org \
    --to=roy.hashimoto@gmail.com \
    --cc=ding@gnus.org \
    /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;
as well as URLs for NNTP newsgroup(s).