Gnus development mailing list
 help / color / mirror / Atom feed
* gpg.el
@ 2002-04-26 12:08 Dmitry Bely
  2002-04-26 15:28 ` gpg.el Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Bely @ 2002-04-26 12:08 UTC (permalink / raw)


What is the preferable method to submit gpg.el bug reports? Should I post
them here or contact the authors directly?

Hope to hear from you soon,
Dmitry



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: gpg.el
  2002-04-26 12:08 gpg.el Dmitry Bely
@ 2002-04-26 15:28 ` Florian Weimer
  2002-04-26 16:02   ` gpg.el Dmitry Bely
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Weimer @ 2002-04-26 15:28 UTC (permalink / raw)


Dmitry Bely <dbely@mail.ru> writes:

> What is the preferable method to submit gpg.el bug reports? Should I post
> them here or contact the authors directly?

Better post them here, so others can help (I don't run XEmacs).



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: gpg.el
  2002-04-26 15:28 ` gpg.el Florian Weimer
@ 2002-04-26 16:02   ` Dmitry Bely
  2002-04-29 17:45     ` mml1991.el patch (was gpg.el) Dmitry Bely
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Bely @ 2002-04-26 16:02 UTC (permalink / raw)


Florian Weimer <fw@deneb.enyo.de> writes:

> Dmitry Bely <dbely@mail.ru> writes:
>
>> What is the preferable method to submit gpg.el bug reports? Should I post
>> them here or contact the authors directly?
>
> Better post them here, so others can help (I don't run XEmacs).

And neither you run Windows 2000 nor use a non-english charset :-)
Fortunately, the problem seems to have nothing to do with XEmacs. It
happens when I try to sign a message with an encoding different from
us-ascii (encryption is working fine as well as the us-ascii messages
signing). Here is an example:

(1) Non-signed message would be

Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 8bit

(koi8-r is Cyrillic 8-bit encoding like European cp1250. Everything else is
not interesting)

(2) Signed message created by gpg.el

[---cut---]
X-From-Line: nobody Fri Apr 26 13:34:15 2002
X-Draft-From: ("nnfolder+archive:archive" "")
To: dbely@mail.ru
Subject: signature test
From: Dmitry Bely <dbely@mail.ru>
Date: Fri, 26 Apr 2002 13:33:55 +0400
Message-ID: <d6wm248s.fsf@mail.ru>
User-Agent: Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.4 (Civil Service (Windows), i586-pc-win32)
MIME-Version: 1.0
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: base64
Lines: 13
Xref: BELY archive:1273
X-Gnus-Article-Number: 1273   Fri Apr 26 13:34:15 2002

=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
8M8t0tXT08vJDQoNCkhvcGUgdG8gaGVhciBmcm9tIHlvdSBzb29uLA0KRG1pdHJ5DQo
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6-2 (MingW32)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjzJHxYACgkQytFTynJIfm+LkgCg6Xa4XWbM24zBHl1WA/N8H/MU
x1YAoIxtzJL7u2C+OLwvd0Z/hpBlKQNh
=3Drc3D
=2D----END PGP SIGNATURE-----
[---cut---]

As you see, Content-Transfer-Encoding is incorrect: original koi8-r text is
really base64-encoded, but everything else is quoted-printable. So we have
the broken message...

Hope to hear from you soon,
Dmitry



^ permalink raw reply	[flat|nested] 6+ messages in thread

* mml1991.el patch (was gpg.el)
  2002-04-26 16:02   ` gpg.el Dmitry Bely
@ 2002-04-29 17:45     ` Dmitry Bely
  2002-05-01 10:37       ` Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Bely @ 2002-04-29 17:45 UTC (permalink / raw)
  Cc: Sascha LЭdecke, Florian Weimer

OK, that's not the gpg.el bug. The problem is that

(1) (mm-body-encoding) does not allow 8bit encodings for PGP-signed
    messages and returns base64 for some code pages (e.g. for Russian
    koi8r)
(2) (mml1991-gpg-sign) always assumes that it gets qp-encoded text, so it
    fails if base64-encoded one is supplied.

Here is the patch that fixes this issue (I am neither the very experienced
Lisp programmer nor Gnus hacker, so if you feel that I did something the
wrong, please correct me)

Index: mml1991.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml1991.el,v
retrieving revision 6.6
diff -u -r6.6 mml1991.el
--- mml1991.el	2002/02/20 00:15:32	6.6
+++ mml1991.el	2002/04/29 17:38:27
@@ -49,10 +49,19 @@
 (defun mml1991-mailcrypt-sign (cont)
   (let ((text (current-buffer))
 	headers signature
-	(result-buffer (get-buffer-create "*GPG Result*")))
+	(result-buffer (get-buffer-create "*GPG Result*"))
+	encode-function decode-function)
     ;; Save MIME Content[^ ]+: headers from signing
     (goto-char (point-min))
-    (while (looking-at "^Content[^ ]+:") (forward-line))
+    (while (looking-at "^Content[^ ]+:")
+      (progn
+	(if (looking-at "^Content-Transfer-Encoding:\\s-+\\(\\S-+\\)")
+	    (let ((encoding (downcase (match-string 1))))
+	      (setq encode-function
+		    (intern (concat encoding "-encode-region")))
+	      (setq decode-function
+		    (intern (concat encoding "-decode-region")))))
+	(forward-line)))
     (if (> (point) (point-min))
 	(progn
 	  (setq headers (buffer-substring (point-min) (point)))
@@ -60,7 +69,8 @@
     (goto-char (point-max))
     (unless (bolp)
       (insert "\n"))
-    (quoted-printable-decode-region (point-min) (point-max))
+    (if decode-function
+	(funcall decode-function (point-min) (point-max)))
     (with-temp-buffer
       (setq signature (current-buffer))
       (insert-buffer text)
@@ -72,7 +82,8 @@
       (goto-char (point-min))
       (while (re-search-forward "\r+$" nil t)
 	(replace-match "" t t))
-      (quoted-printable-encode-region (point-min) (point-max))
+      (if encode-function
+	  (funcall encode-function (point-min) (point-max)))
       (set-buffer text)
       (kill-region (point-min) (point-max))
       (if headers (insert headers))
@@ -125,10 +136,19 @@
 (defun mml1991-gpg-sign (cont)
   (let ((text (current-buffer))
 	headers signature
-	(result-buffer (get-buffer-create "*GPG Result*")))
+	(result-buffer (get-buffer-create "*GPG Result*"))
+	encode-function decode-function)
     ;; Save MIME Content[^ ]+: headers from signing
     (goto-char (point-min))
-    (while (looking-at "^Content[^ ]+:") (forward-line))
+    (while (looking-at "^Content[^ ]+:")
+      (progn
+	(if (looking-at "^Content-Transfer-Encoding:\\s-+\\(\\S-+\\)")
+	    (let ((encoding (downcase (match-string 1))))
+	      (setq encode-function
+		    (intern (concat encoding "-encode-region")))
+	      (setq decode-function
+		    (intern (concat encoding "-decode-region")))))
+	(forward-line)))
     (if (> (point) (point-min))
 	(progn
 	  (setq headers (buffer-substring (point-min) (point)))
@@ -136,7 +156,8 @@
     (goto-char (point-max))
     (unless (bolp)
       (insert "\n"))
-    (quoted-printable-decode-region (point-min) (point-max))
+    (if decode-function
+	(funcall decode-function (point-min) (point-max)))
     (with-temp-buffer
       (unless (gpg-sign-cleartext text (setq signature (current-buffer))
 				  result-buffer
@@ -148,7 +169,8 @@
       (goto-char (point-min))
       (while (re-search-forward "\r+$" nil t)
 	(replace-match "" t t))
-      (quoted-printable-encode-region (point-min) (point-max))
+      (if encode-function
+	  (funcall encode-function (point-min) (point-max)))
       (set-buffer text)
       (kill-region (point-min) (point-max))
       (if headers (insert headers))

Hope to hear from you soon,
Dmitry



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mml1991.el patch (was gpg.el)
  2002-04-29 17:45     ` mml1991.el patch (was gpg.el) Dmitry Bely
@ 2002-05-01 10:37       ` Florian Weimer
  2002-05-01 15:33         ` Dmitry Bely
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Weimer @ 2002-05-01 10:37 UTC (permalink / raw)


Dmitry Bely <dbely@mail.ru> writes:

> OK, that's not the gpg.el bug. The problem is that
>
> (1) (mm-body-encoding) does not allow 8bit encodings for PGP-signed
>     messages and returns base64 for some code pages (e.g. for Russian
>     koi8r)

For clearsigned messages (that's the stuff mml1991.el is for), or for
OpenPGP/MIME-signed messages?  It should be necessary only in the
latter case.

> (2) (mml1991-gpg-sign) always assumes that it gets qp-encoded text, so it
>     fails if base64-encoded one is supplied.
>
> Here is the patch that fixes this issue (I am neither the very experienced
> Lisp programmer nor Gnus hacker, so if you feel that I did something the
> wrong, please correct me)

IMHO, your change is wrong from an architectural point of
view. mml1991.el signatures should be applied *after* we have
generate the octet stream which is to be sent, but *before*
Content-Transfer-Encoding is applied.

But I'll check with OpenPGP WG to be sure that this is the right
approach to clearsigned messages and MIME.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: mml1991.el patch (was gpg.el)
  2002-05-01 10:37       ` Florian Weimer
@ 2002-05-01 15:33         ` Dmitry Bely
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Bely @ 2002-05-01 15:33 UTC (permalink / raw)


Florian Weimer <fw@deneb.enyo.de> writes:

>> OK, that's not the gpg.el bug. The problem is that
>>
>> (1) (mm-body-encoding) does not allow 8bit encodings for PGP-signed
>>     messages and returns base64 for some code pages (e.g. for Russian
>>     koi8r)
>
> For clearsigned messages (that's the stuff mml1991.el is for), or for
> OpenPGP/MIME-signed messages?  It should be necessary only in the
> latter case.

Of course, for clearsigned messages, i.e. messages with traditional PGP
signature (function "mml-secure-message-sign-pgp"). You may check this
yourself -- it requires quoted-printable even for us-ascii if message will
be later PGP-signed.

PGP/MIME is not broken and already works as expected.

>> (2) (mml1991-gpg-sign) always assumes that it gets qp-encoded text, so it
>>     fails if base64-encoded one is supplied.
>>
>> Here is the patch that fixes this issue (I am neither the very experienced
>> Lisp programmer nor Gnus hacker, so if you feel that I did something the
>> wrong, please correct me)
>
> IMHO, your change is wrong from an architectural point of
> view. mml1991.el signatures should be applied *after* we have
> generate the octet stream which is to be sent, but *before*
> Content-Transfer-Encoding is applied.

Exactly. But if you look into the sources, you will see that
(mml1991-gpg-sign) gets the message with Content-Transfer-Encoding already
applied. So (mml1991-gpg-sign) 1) unpacks the message, then 2) signs it
with PGP/GPG, then 3) packs it again. Yes, one pack/unpack sequence is
redundant (it would be better if (mml1991-gpg-sign) gets the original octet
stream), but Gnus is written this way, and I cannot easily change it. My
patch only corrects the wrong assumption, made in (mml1991-gpg-sign), that
its input stream is always quoted-printable encoded.

> But I'll check with OpenPGP WG to be sure that this is the right
> approach to clearsigned messages and MIME.

It works for me. Now I can sign and verify PGP messages without a problem.

Hope to hear from you soon,
Dmitry



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-05-01 15:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-26 12:08 gpg.el Dmitry Bely
2002-04-26 15:28 ` gpg.el Florian Weimer
2002-04-26 16:02   ` gpg.el Dmitry Bely
2002-04-29 17:45     ` mml1991.el patch (was gpg.el) Dmitry Bely
2002-05-01 10:37       ` Florian Weimer
2002-05-01 15:33         ` Dmitry Bely

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).