[Mew-dist 05734] decrypting non-pgp/mime pgp5.x messages

sen_ml at example.com sen_ml at example.com
1998年 7月 29日 (水) 19:56:54 JST


hello-

  i hope posting in english is ok -- please let me know if this is
a problem.

  i'd like to be able to decrypt pgp5 messages which are not sent as
pgp/mime, but i didn't find any functions to do so within mew -- i searched
the mailing list archives, which seemed to say that support may be added 
in the future.  is this correct?

  being impatient, i hacked up something that seems to work ok for
me.  there is almost no integration w/ mew yet -- though it depends
on mew.  this is only meant as a temporary measure so that at least
messages could be decrypted simply in emacs (i.e. not have to resort
to using a shell).  [note: this will work w/ pgp/mime messages as well]

  i copied and modified mew-pgp-decrypt (from mew-pgp.el) and made the
result into an interactive function w/ a different name.  to use it,
you invoke the function and specify a filename for decryption.  the
user is prompted for a passphrase, etc.  if decryption is successful,
a new frame w/ the decrypted message contents pops up.

  to use this, you need to create a directory named ~/.pgp/tmp/ (mode
should be something like 700 i think) -- decrypted files are placed
here -- i don't think placing decrypted files in /tmp is a good idea,
what do people think?

  all decrypted results end up in a buffer named "+decrypted" -- this
was intentional so that you only have to worry about getting rid of
one buffer if you need to "hide" your decrypted results in a hurry :-)
(i only did this because of the lack of integration w/ mew.)

  obvious points to improve on:

  -mew integration: 
     make usable from summary mode (so user doesn't have to specify
     a filename -- also, provide support for replying, etc.).
     some mailing list posts seemed to suggest that manual decryption
     is being planned, so i guess this should be coming :-)

  -remove dependency on frames:
     it might be better to use a window instead of a frame -- or better
     still, let the user choose.

  if someone has something similar already, please share :-)  if it
has already been posted, could someone tell me the subject line of
the relevant message?

  thanks for your attention...and thank you all authors of mew!

  (installation notes at end of message -- this has only been tested
for 1.93b49)

-sen

p.s. using mew and pgp5 w/ debian required that i put:

(setq mew-prog-pgp "pgp5")

in my .emacs file -- i believe this is because the pgp binary gets
installed as pgp5...is there some way to deal w/ this nicely within
mew? 

p.p.s. are there any plans for supporting mailing list commands w/in
mew?  in particular, i was thinking it would be nice to be able to
issue commands which automatically subsrcibe, unsubscribe, etc. for
different mailing list types (ezmlm, majordomo, etc.)

installation notes:

1) create ~/.pgp/tmp (mode 700)

2) put the following in your .emacs file.  optionally add a keymap
   entry for the function to extend the lives of your wrists :-)

; this is a modified mew-pgp-decrypt
; mew-pgp-decrypt from mew-pgp.el
(defun sen-mew-pgp-decrypt (file2)
  ;; file2 is an encrypted file with PGP.

  ; added this stuff -sln
  (interactive "f")
  (setq file2 (expand-file-name file2))
  (setq decrypted-file-name 
	(expand-file-name (make-temp-name "~/.pgp/tmp/")))

  ; old stuff starts here
  (message "PGP decrypting ... ")
  (setq mew-pgp-running 'decrypting)
  (setq mew-pgp-string nil)
  (setq mew-pgp-decrypt-msg nil)
  (setq mew-pgp-failure nil)
  (let ((process-connection-type mew-connection-type2)
	file3 process verify)
    
    ; don't want to use /tmp -- perhaps each user should
    ; have their own tmp directory?
    ;(setq file3 (mew-make-temp-name))

    ; only decrypt one at a time...
    (setq file3 decrypted-file-name)

    (setq process (start-process "PGP decrypt"
				 (current-buffer)
				 (mew-pgp-get mew-prog-pgpv)
				 "+language=en" "+batchmode=off"
				 "-o" file3 file2))
    (mew-set-process-cs process mew-cs-autoconv mew-cs-noconv)
    (set-process-filter process 'mew-pgp-process-filter1)
    (set-process-sentinel process 'mew-pgp-process-sentinel)
    ;; Wait for the termination of PGP.
    ;; Emacs doesn't provide synchronize mechanism with
    ;; an asynchronous process. So, take this way. 
    (while mew-pgp-running
	(if mew-xemacs-p
	    (accept-process-output)
	  (sit-for 1)
	  ;; accept-process-output or sleep-for is not enough
	  (discard-input))
	)
    (message "PGP decrypting ... done")
    (save-excursion
      (mew-set-buffer-tmp)
      (insert mew-pgp-string)
      (setq verify (mew-pgp-verify-check))
      )
    (if verify 
	(setq mew-pgp-decrypt-msg (concat mew-pgp-decrypt-msg "\n\t" verify)))
    (list file3 mew-pgp-decrypt-msg)

    ; added this stuff -sln
    ; pop up a new frame w/ decrypted contents
    (switch-to-buffer-other-frame "+decrypted")
    ; put the decrypted results in our new frame
    (insert-file file3)
    ; delete the decrypted file
    (delete-file file3)
    ; place extra results in buffer as well
    (insert mew-pgp-decrypt-msg)
    (insert "\n")
    ))



Mew-dist メーリングリストの案内