Gnus development mailing list
 help / color / mirror / Atom feed
* EasyPG support for mml2015.el
@ 2006-07-10  3:54 Daiki Ueno
  2006-07-10  9:04 ` Daiki Ueno
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Daiki Ueno @ 2006-07-10  3:54 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

Hi,

2 weeks ago, we had CodeFest Akihabara 2006 (a 24-hour hacking marathon
in Japan).  There I wrote a patch which allows to use EasyPG directly
from Gnus.

Can you install this patch into Gnus?  Though it has not yet been tested
thoroughly, it should not break existing mml2015.el feature.

To use: just set (setq mml2015-use 'epg)

Regards,
-- 
Daiki Ueno

[-- Attachment #2: mml2015.el.diff --]
[-- Type: application/octet-stream, Size: 12411 bytes --]

Index: lisp/mml2015.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml2015.el,v
retrieving revision 7.15
diff -u -r7.15 mml2015.el
--- lisp/mml2015.el	28 Apr 2006 05:17:40 -0000	7.15
+++ lisp/mml2015.el	10 Jul 2006 03:53:59 -0000
@@ -34,6 +34,7 @@
 (require 'mm-decode)
 (require 'mm-util)
 (require 'mml)
+(require 'password)
 
 (defvar mc-pgp-always-sign)
 
@@ -79,7 +80,13 @@
        mml2015-pgg-verify
        mml2015-pgg-decrypt
        mml2015-pgg-clear-verify
-       mml2015-pgg-clear-decrypt))
+       mml2015-pgg-clear-decrypt)
+  (epg mml2015-epg-sign
+       mml2015-epg-encrypt
+       mml2015-epg-verify
+       mml2015-epg-decrypt
+       mml2015-epg-clear-verify
+       mml2015-epg-clear-decrypt))
   "Alist of PGP/MIME functions.")
 
 (defvar mml2015-result-buffer nil)
@@ -96,6 +103,23 @@
   :type '(repeat (cons (regexp :tag "GnuPG output regexp")
 		       (boolean :tag "Trust key"))))
 
+(defcustom mml2015-verbose nil
+  "If non-nil, ask the user about the current operation more verbosely."
+  :group 'mime-security
+  :type 'boolean)
+
+(defcustom mml2015-cache-passphrase t
+  "If t, cache passphrase."
+  :group 'mime-security
+  :type 'boolean)
+
+(defcustom mml2015-passphrase-cache-expiry 16
+  "How many seconds the passphrase is cached.
+Whether the passphrase is cached at all is controlled by
+`mml2015-cache-passphrase'."
+  :group 'mime-security
+  :type 'integer)
+
 ;;; mailcrypt wrapper
 
 (eval-and-compile
@@ -871,6 +895,295 @@
     (insert (format "--%s\n" boundary))
     (insert "Content-Type: application/octet-stream\n\n")
     (insert-buffer-substring pgg-output-buffer)
+    (goto-char (point-max))
+    (insert (format "--%s--\n" boundary))
+    (goto-char (point-max))))
+
+;;; epg wrapper
+
+(eval-and-compile
+  (autoload 'epg-make-context "epg")
+  (autoload 'epa-select-keys "epa"))
+
+(eval-when-compile
+  (defvar epg-user-id-alist)
+  (defvar epg-digest-algorithm-alist)
+  (defvar inhibit-redisplay)
+  (autoload 'epg-context-set-armor "epg")
+  (autoload 'epg-context-set-textmode "epg")
+  (autoload 'epg-context-set-signers "epg")
+  (autoload 'epg-context-result-for "epg")
+  (autoload 'epg-new-signature-digest-algorithm "epg")
+  (autoload 'epg-verify-result-to-string "epg")
+  (autoload 'epg-list-keys "epg")
+  (autoload 'epg-decrypt-string "epg")
+  (autoload 'epg-verify-string "epg")
+  (autoload 'epg-sign-string "epg")
+  (autoload 'epg-encrypt-string "epg")
+  (autoload 'epg-passphrase-callback-function "epg")
+  (autoload 'epg-context-set-passphrase-callback "epg"))
+
+(defvar mml2015-epg-secret-key-id-list nil)
+
+(defun mml2015-epg-passphrase-callback (context key-id ignore)
+  (if (eq key-id 'SYM)
+      (epg-passphrase-callback-function context key-id nil)
+    (let* ((entry (assoc key-id epg-user-id-alist))
+	   (passphrase
+	    (password-read
+	     (format "GnuPG passphrase for %s: "
+		     (if entry
+			 (cdr entry)
+		       key-id))
+	     (if (eq key-id 'PIN)
+		 "PIN"
+	       key-id))))
+      (when passphrase
+	(let ((password-cache-expiry mml2015-passphrase-cache-expiry))
+	  (password-cache-add key-id passphrase))
+	(setq mml2015-epg-secret-key-id-list
+	      (cons key-id mml2015-epg-secret-key-id-list))
+	(copy-sequence passphrase)))))
+
+(defun mml2015-epg-decrypt (handle ctl)
+  (catch 'error
+    (let ((inhibit-redisplay t)
+	  context plain child handles result decrypt-status)
+      (unless (setq child (mm-find-part-by-type
+			   (cdr handle)
+			   "application/octet-stream" nil t))
+	(mm-set-handle-multipart-parameter
+	 mm-security-handle 'gnus-info "Corrupted")
+	(throw 'error handle))
+      (setq context (epg-make-context))
+      (epg-context-set-passphrase-callback
+       context
+       #'mml2015-epg-passphrase-callback)
+      (condition-case error
+	  (setq plain (epg-decrypt-string context (mm-get-part child))
+		mml2015-epg-secret-key-id-list nil)
+	(error
+	 (while mml2015-epg-secret-key-id-list
+	   (password-cache-remove (car mml2015-epg-secret-key-id-list))
+	   (setq mml2015-epg-secret-key-id-list
+		 (cdr mml2015-epg-secret-key-id-list)))
+	 (mm-set-handle-multipart-parameter
+	  mm-security-handle 'gnus-info "Failed")
+	 (if (eq (car error) 'quit)
+	     (mm-set-handle-multipart-parameter
+	      mm-security-handle 'gnus-details "Quit.")
+	   (mm-set-handle-multipart-parameter
+	    mm-security-handle 'gnus-details (mml2015-format-error error)))
+	 (throw 'error handle)))
+      (with-temp-buffer
+	(insert plain)
+	(goto-char (point-min))
+	(while (search-forward "\r\n" nil t)
+	  (replace-match "\n" t t))
+	(setq handles (mm-dissect-buffer t))
+	(mm-destroy-parts handle)
+	(if (epg-context-result-for context 'verify)
+	    (mm-set-handle-multipart-parameter
+	     mm-security-handle 'gnus-info
+	     (concat "OK\n"
+		     (epg-verify-result-to-string
+		      (epg-context-result-for context 'verify))))
+	  (mm-set-handle-multipart-parameter
+	   mm-security-handle 'gnus-info "OK"))
+	(if (stringp (car handles))
+	    (mm-set-handle-multipart-parameter
+	     mm-security-handle 'gnus-details
+	     (mm-handle-multipart-ctl-parameter handles 'gnus-details))))
+	(if (listp (car handles))
+	    handles
+	  (list handles)))))
+
+(defun mml2015-epg-clear-decrypt ()
+  (let ((inhibit-redisplay t)
+	(context (epg-make-context))
+	plain)
+    (epg-context-set-passphrase-callback
+     context
+     #'mml2015-epg-passphrase-callback)
+    (condition-case error
+	(setq plain (epg-decrypt-string context (buffer-string))
+	      mml2015-epg-secret-key-id-list nil)
+      (error
+       (while mml2015-epg-secret-key-id-list
+	 (password-cache-remove (car mml2015-epg-secret-key-id-list))
+	 (setq mml2015-epg-secret-key-id-list
+	       (cdr mml2015-epg-secret-key-id-list)))
+       (mm-set-handle-multipart-parameter
+	mm-security-handle 'gnus-info "Failed")
+       (if (eq (car error) 'quit)
+	   (mm-set-handle-multipart-parameter
+	    mm-security-handle 'gnus-details "Quit.")
+	 (mm-set-handle-multipart-parameter
+	  mm-security-handle 'gnus-details (mml2015-format-error error)))))
+    (when plain
+      (erase-buffer)
+      ;; Treat data which epg returns as a unibyte string.
+      (mm-disable-multibyte)
+      (insert plain)
+      (goto-char (point-min))
+      (while (search-forward "\r\n" nil t)
+	(replace-match "\n" t t))
+      (if (epg-context-result-for context 'verify)
+	  (mm-set-handle-multipart-parameter
+	   mm-security-handle 'gnus-info
+	   (concat "OK\n"
+		   (epg-verify-result-to-string
+		    (epg-context-result-for context 'verify))))
+	(mm-set-handle-multipart-parameter
+	 mm-security-handle 'gnus-info "OK")))))
+
+(defun mml2015-epg-verify (handle ctl)
+  (catch 'error
+    (let ((inhibit-redisplay t)
+	  context plain signature-file part signature)
+      (when (or (null (setq part (mm-find-raw-part-by-type
+				  ctl (or (mm-handle-multipart-ctl-parameter
+					   ctl 'protocol)
+					  "application/pgp-signature")
+				  t)))
+		(null (setq signature (mm-find-part-by-type
+				       (cdr handle) "application/pgp-signature"
+				       nil t))))
+	(mm-set-handle-multipart-parameter
+	 mm-security-handle 'gnus-info "Corrupted")
+	(throw 'error handle))
+      (setq context (epg-make-context))
+      (condition-case error
+	  (setq plain (epg-verify-string context (mm-get-part signature) part))
+	(error
+	 (mm-set-handle-multipart-parameter
+	  mm-security-handle 'gnus-info "Failed")
+	 (if (eq (car error) 'quit)
+	     (mm-set-handle-multipart-parameter
+	      mm-security-handle 'gnus-details "Quit.")
+	   (mm-set-handle-multipart-parameter
+	    mm-security-handle 'gnus-details (mml2015-format-error error)))
+	 (throw 'error handle)))
+      (mm-set-handle-multipart-parameter
+       mm-security-handle 'gnus-info
+       (epg-verify-result-to-string (epg-context-result-for context 'verify)))
+      handle)))
+
+(defun mml2015-epg-clear-verify ()
+  (let ((inhibit-redisplay t)
+	(context (epg-make-context))
+	(signature (encode-coding-string (buffer-string)
+					 buffer-file-coding-system))
+	plain)
+    (condition-case error
+	(setq plain (epg-verify-string context signature))
+      (error
+       (mm-set-handle-multipart-parameter
+	mm-security-handle 'gnus-info "Failed")
+       (if (eq (car error) 'quit)
+	   (mm-set-handle-multipart-parameter
+	    mm-security-handle 'gnus-details "Quit.")
+	 (mm-set-handle-multipart-parameter
+	  mm-security-handle 'gnus-details (mml2015-format-error error)))))
+    (if plain
+	(mm-set-handle-multipart-parameter
+	 mm-security-handle 'gnus-info
+	 (epg-verify-result-to-string
+	  (epg-context-result-for context 'verify))))))
+
+(defun mml2015-epg-sign (cont)
+  (let ((inhibit-redisplay t)
+	(context (epg-make-context))
+	(boundary (mml-compute-boundary cont))
+	signers	signature micalg)
+    (if mml2015-verbose
+	(setq signers (epa-select-keys context "Select keys for signing.
+If no one is selected, default secret key is used.  "
+				       nil t))
+      (setq signers (list (car (epg-list-keys
+				context
+				(message-options-get 'mml-sender) t)))))
+    (epg-context-set-armor context t)
+    (epg-context-set-textmode context t)
+    (epg-context-set-signers context signers)
+    (epg-context-set-passphrase-callback
+     context
+     #'mml2015-epg-passphrase-callback)
+    (condition-case error
+	(setq signature (epg-sign-string context (buffer-string) t)
+	      mml2015-epg-secret-key-id-list nil)
+      (error
+       (while mml2015-epg-secret-key-id-list
+	 (password-cache-remove (car mml2015-epg-secret-key-id-list))
+	 (setq mml2015-epg-secret-key-id-list
+	       (cdr mml2015-epg-secret-key-id-list)))
+       (signal (car error) (cdr error))))
+    (if (epg-context-result-for context 'sign)
+	(setq micalg (epg-new-signature-digest-algorithm
+		      (car (epg-context-result-for context 'sign)))))
+    (goto-char (point-min))
+    (insert (format "Content-Type: multipart/signed; boundary=\"%s\";\n"
+		    boundary))
+    (if micalg
+	(insert (format "\tmicalg=%s; "
+			(downcase
+			 (cdr (assq micalg
+				    epg-digest-algorithm-alist))))))
+    (insert "protocol=\"application/pgp-signature\"\n")
+    (insert (format "\n--%s\n" boundary))
+    (goto-char (point-max))
+    (insert (format "\n--%s\n" boundary))
+    (insert "Content-Type: application/pgp-signature\n\n")
+    (insert signature)
+    (goto-char (point-max))
+    (insert (format "--%s--\n" boundary))
+    (goto-char (point-max))))
+
+(defun mml2015-epg-encrypt (cont &optional sign)
+  (let ((inhibit-redisplay t)
+	(context (epg-make-context))
+	recipients cipher
+	(boundary (mml-compute-boundary cont)))
+    (if (or mml2015-verbose
+	    (null (message-options-get 'message-recipients)))
+	(setq recipients
+	      (epa-select-keys context "Select recipients for encryption.
+If no one is selected, symmetric encryption will be performed.  "
+			       (if (message-options-get 'message-recipients)
+				   (split-string
+				    (message-options-get 'message-recipients)
+				    "[ \f\t\n\r\v,]+"))))
+      (setq recipients
+	    (epg-list-keys context
+			   (split-string
+			    (message-options-get 'message-recipients)
+			    "[ \f\t\n\r\v,]+"))))
+    (epg-context-set-armor context t)
+    (epg-context-set-textmode context t)
+    (epg-context-set-passphrase-callback
+     context
+     #'mml2015-epg-passphrase-callback)
+    (condition-case error
+	(setq cipher
+	      (epg-encrypt-string context (buffer-string) recipients sign)
+	      mml2015-epg-secret-key-id-list nil)
+      (error
+       (while mml2015-epg-secret-key-id-list
+	 (password-cache-remove (car mml2015-epg-secret-key-id-list))
+	 (setq mml2015-epg-secret-key-id-list
+	       (cdr mml2015-epg-secret-key-id-list)))
+       (signal (car error) (cdr error))))
+    (delete-region (point-min) (point-max))
+    (goto-char (point-min))
+    (insert (format "Content-Type: multipart/encrypted; boundary=\"%s\";\n"
+		    boundary))
+    (insert "\tprotocol=\"application/pgp-encrypted\"\n\n")
+    (insert (format "--%s\n" boundary))
+    (insert "Content-Type: application/pgp-encrypted\n\n")
+    (insert "Version: 1\n\n")
+    (insert (format "--%s\n" boundary))
+    (insert "Content-Type: application/octet-stream\n\n")
+    (insert cipher)
     (goto-char (point-max))
     (insert (format "--%s--\n" boundary))
     (goto-char (point-max))))

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

* Re: EasyPG support for mml2015.el
  2006-07-10  3:54 EasyPG support for mml2015.el Daiki Ueno
@ 2006-07-10  9:04 ` Daiki Ueno
  2006-07-10 10:08   ` Simon Josefsson
  2006-07-10 10:03 ` Simon Josefsson
  2006-07-12  7:38 ` EasyPG hangs Max Froumentin
  2 siblings, 1 reply; 12+ messages in thread
From: Daiki Ueno @ 2006-07-10  9:04 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 326 bytes --]

>>>>> In <0a485279-4c9d-4249-bb88-c2fbf73c6171@well-done.deisui.org> 
>>>>>	Daiki Ueno <ueno@unixuser.org> wrote:
> 2 weeks ago, we had CodeFest Akihabara 2006 (a 24-hour hacking marathon
> in Japan).  There I wrote a patch which allows to use EasyPG directly
> from Gnus.

I just wrote a patch to mml1991.el attached below.


[-- Attachment #2: mml-epg.el.diff --]
[-- Type: application/octet-stream, Size: 18380 bytes --]

Index: lisp/mml1991.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml1991.el,v
retrieving revision 7.10
diff -u -r7.10 mml1991.el
--- lisp/mml1991.el	27 Apr 2006 07:00:49 -0000	7.10
+++ lisp/mml1991.el	10 Jul 2006 09:00:59 -0000
@@ -46,9 +46,22 @@
     (gpg mml1991-gpg-sign
 	 mml1991-gpg-encrypt)
     (pgg mml1991-pgg-sign
-	 mml1991-pgg-encrypt))
+	 mml1991-pgg-encrypt)
+    (epg mml1991-epg-sign
+	 mml1991-epg-encrypt))
   "Alist of PGP functions.")
 
+(defvar mml1991-verbose nil
+  "If non-nil, ask the user about the current operation more verbosely.")
+
+(defvar mml1991-cache-passphrase t
+  "If t, cache passphrase.")
+
+(defvar mml1991-passphrase-cache-expiry 16
+  "How many seconds the passphrase is cached.
+Whether the passphrase is cached at all is controlled by
+`mml1991-cache-passphrase'.")
+
 ;;; mailcrypt wrapper
 
 (eval-and-compile
@@ -288,6 +301,146 @@
   (delete-region (point-min) (point-max))
   (insert "\n")
   (insert-buffer-substring pgg-output-buffer)
+  t)
+
+;; epg wrapper
+
+(eval-and-compile
+  (autoload 'epg-make-context "epg"))
+
+(eval-when-compile
+  (defvar epg-user-id-alist)
+  (autoload 'epg-passphrase-callback-function "epg")
+  (autoload 'epa-select-keys "epa")
+  (autoload 'epg-list-keys "epg")
+
+  (autoload 'epg-context-set-armor "epg")
+  (autoload 'epg-context-set-textmode "epg")
+
+  (autoload 'epg-context-set-signers "epg")
+  (autoload 'epg-context-set-passphrase-callback "epg")
+
+  (autoload 'epg-sign-string "epg")
+  (autoload 'epg-encrypt-string "epg"))
+
+(defvar mml1991-epg-secret-key-id-list nil)
+
+(defun mml1991-epg-passphrase-callback (context key-id ignore)
+  (if (eq key-id 'SYM)
+      (epg-passphrase-callback-function context key-id nil)
+    (let* ((entry (assoc key-id epg-user-id-alist))
+	   (passphrase
+	    (password-read
+	     (format "GnuPG passphrase for %s: "
+		     (if entry
+			 (cdr entry)
+		       key-id))
+	     (if (eq key-id 'PIN)
+		 "PIN"
+	       key-id))))
+      (when passphrase
+	(let ((password-cache-expiry mml1991-passphrase-cache-expiry))
+	  (password-cache-add key-id passphrase))
+	(setq mml1991-epg-secret-key-id-list
+	      (cons key-id mml1991-epg-secret-key-id-list))
+	(copy-sequence passphrase)))))
+
+(defun mml1991-epg-sign (cont)
+  (let ((context (epg-make-context))
+	headers cte signers signature)
+    (if mml1991-verbose
+	(setq signers (epa-select-keys context "Select keys for signing.
+If no one is selected, default secret key is used.  "
+				       nil t))
+      (setq signers (list (car (epg-list-keys
+				context
+				(message-options-get 'mml-sender) t)))))
+    (epg-context-set-armor context t)
+    (epg-context-set-textmode context t)
+    (epg-context-set-signers context signers)
+    (epg-context-set-passphrase-callback
+     context
+     #'mml1991-epg-passphrase-callback)
+    ;; Don't sign headers.
+    (goto-char (point-min))
+    (when (re-search-forward "^$" nil t)
+      (setq headers (buffer-substring (point-min) (point)))
+      (save-restriction
+	(narrow-to-region (point-min) (point))
+	(setq cte (mail-fetch-field "content-transfer-encoding")))
+      (forward-line 1)
+      (delete-region (point-min) (point))
+      (when cte
+	(setq cte (intern (downcase cte)))
+	(mm-decode-content-transfer-encoding cte)))
+    (condition-case error
+	(setq signature (epg-sign-string context (buffer-string) 'clear)
+	      mml1991-epg-secret-key-id-list nil)
+      (error
+       (while mml1991-epg-secret-key-id-list
+	 (password-cache-remove (car mml1991-epg-secret-key-id-list))
+	 (setq mml1991-epg-secret-key-id-list
+	       (cdr mml1991-epg-secret-key-id-list)))
+       (signal (car error) (cdr error))))
+    (delete-region (point-min) (point-max))
+    (mm-with-unibyte-current-buffer
+      (insert signature)
+      (goto-char (point-min))
+      (while (re-search-forward "\r+$" nil t)
+	(replace-match "" t t))
+      (when cte
+	(mm-encode-content-transfer-encoding cte))
+      (goto-char (point-min))
+      (when headers
+	(insert headers))
+      (insert "\n"))
+    t))
+
+(defun mml1991-epg-encrypt (cont &optional sign)
+  (goto-char (point-min))
+  (when (re-search-forward "^$" nil t)
+    (let ((cte (save-restriction
+		 (narrow-to-region (point-min) (point))
+		 (mail-fetch-field "content-transfer-encoding"))))
+      ;; Strip MIME headers since it will be ASCII armoured.
+      (forward-line 1)
+      (delete-region (point-min) (point))
+      (when cte
+	(mm-decode-content-transfer-encoding (intern (downcase cte))))))
+  (let ((context (epg-make-context))
+	recipients cipher)
+    (if (or mml1991-verbose
+	    (null (message-options-get 'message-recipients)))
+	(setq recipients
+	      (epa-select-keys context "Select recipients for encryption.
+If no one is selected, symmetric encryption will be performed.  "
+			       (if (message-options-get 'message-recipients)
+				   (split-string
+				    (message-options-get 'message-recipients)
+				    "[ \f\t\n\r\v,]+"))))
+      (setq recipients
+	    (mapcar (lambda (name)
+		      (car (epg-list-keys context name)))
+		    (split-string
+		     (message-options-get 'message-recipients)
+		     "[ \f\t\n\r\v,]+"))))
+    (epg-context-set-armor context t)
+    (epg-context-set-textmode context t)
+    (epg-context-set-passphrase-callback
+     context
+     #'mml1991-epg-passphrase-callback)
+    (condition-case error
+	(setq cipher
+	      (epg-encrypt-string context (buffer-string) recipients sign)
+	      mml1991-epg-secret-key-id-list nil)
+      (error
+       (while mml1991-epg-secret-key-id-list
+	 (password-cache-remove (car mml1991-epg-secret-key-id-list))
+	 (setq mml1991-epg-secret-key-id-list
+	       (cdr mml1991-epg-secret-key-id-list)))
+       (signal (car error) (cdr error))))
+    (delete-region (point-min) (point-max))
+    (insert "\n" cipher))
   t)
 
 ;;;###autoload
Index: lisp/mml2015.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml2015.el,v
retrieving revision 7.15
diff -u -r7.15 mml2015.el
--- lisp/mml2015.el	28 Apr 2006 05:17:40 -0000	7.15
+++ lisp/mml2015.el	10 Jul 2006 09:01:00 -0000
@@ -34,6 +34,7 @@
 (require 'mm-decode)
 (require 'mm-util)
 (require 'mml)
+(require 'password)
 
 (defvar mc-pgp-always-sign)
 
@@ -79,7 +80,13 @@
        mml2015-pgg-verify
        mml2015-pgg-decrypt
        mml2015-pgg-clear-verify
-       mml2015-pgg-clear-decrypt))
+       mml2015-pgg-clear-decrypt)
+  (epg mml2015-epg-sign
+       mml2015-epg-encrypt
+       mml2015-epg-verify
+       mml2015-epg-decrypt
+       mml2015-epg-clear-verify
+       mml2015-epg-clear-decrypt))
   "Alist of PGP/MIME functions.")
 
 (defvar mml2015-result-buffer nil)
@@ -96,6 +103,23 @@
   :type '(repeat (cons (regexp :tag "GnuPG output regexp")
 		       (boolean :tag "Trust key"))))
 
+(defcustom mml2015-verbose nil
+  "If non-nil, ask the user about the current operation more verbosely."
+  :group 'mime-security
+  :type 'boolean)
+
+(defcustom mml2015-cache-passphrase t
+  "If t, cache passphrase."
+  :group 'mime-security
+  :type 'boolean)
+
+(defcustom mml2015-passphrase-cache-expiry 16
+  "How many seconds the passphrase is cached.
+Whether the passphrase is cached at all is controlled by
+`mml2015-cache-passphrase'."
+  :group 'mime-security
+  :type 'integer)
+
 ;;; mailcrypt wrapper
 
 (eval-and-compile
@@ -871,6 +895,296 @@
     (insert (format "--%s\n" boundary))
     (insert "Content-Type: application/octet-stream\n\n")
     (insert-buffer-substring pgg-output-buffer)
+    (goto-char (point-max))
+    (insert (format "--%s--\n" boundary))
+    (goto-char (point-max))))
+
+;;; epg wrapper
+
+(eval-and-compile
+  (autoload 'epg-make-context "epg"))
+
+(eval-when-compile
+  (defvar epg-user-id-alist)
+  (defvar epg-digest-algorithm-alist)
+  (defvar inhibit-redisplay)
+  (autoload 'epg-context-set-armor "epg")
+  (autoload 'epg-context-set-textmode "epg")
+  (autoload 'epg-context-set-signers "epg")
+  (autoload 'epg-context-result-for "epg")
+  (autoload 'epg-new-signature-digest-algorithm "epg")
+  (autoload 'epg-verify-result-to-string "epg")
+  (autoload 'epg-list-keys "epg")
+  (autoload 'epg-decrypt-string "epg")
+  (autoload 'epg-verify-string "epg")
+  (autoload 'epg-sign-string "epg")
+  (autoload 'epg-encrypt-string "epg")
+  (autoload 'epg-passphrase-callback-function "epg")
+  (autoload 'epg-context-set-passphrase-callback "epg")
+  (autoload 'epa-select-keys "epa"))
+
+(defvar mml2015-epg-secret-key-id-list nil)
+
+(defun mml2015-epg-passphrase-callback (context key-id ignore)
+  (if (eq key-id 'SYM)
+      (epg-passphrase-callback-function context key-id nil)
+    (let* ((entry (assoc key-id epg-user-id-alist))
+	   (passphrase
+	    (password-read
+	     (format "GnuPG passphrase for %s: "
+		     (if entry
+			 (cdr entry)
+		       key-id))
+	     (if (eq key-id 'PIN)
+		 "PIN"
+	       key-id))))
+      (when passphrase
+	(let ((password-cache-expiry mml2015-passphrase-cache-expiry))
+	  (password-cache-add key-id passphrase))
+	(setq mml2015-epg-secret-key-id-list
+	      (cons key-id mml2015-epg-secret-key-id-list))
+	(copy-sequence passphrase)))))
+
+(defun mml2015-epg-decrypt (handle ctl)
+  (catch 'error
+    (let ((inhibit-redisplay t)
+	  context plain child handles result decrypt-status)
+      (unless (setq child (mm-find-part-by-type
+			   (cdr handle)
+			   "application/octet-stream" nil t))
+	(mm-set-handle-multipart-parameter
+	 mm-security-handle 'gnus-info "Corrupted")
+	(throw 'error handle))
+      (setq context (epg-make-context))
+      (epg-context-set-passphrase-callback
+       context
+       #'mml2015-epg-passphrase-callback)
+      (condition-case error
+	  (setq plain (epg-decrypt-string context (mm-get-part child))
+		mml2015-epg-secret-key-id-list nil)
+	(error
+	 (while mml2015-epg-secret-key-id-list
+	   (password-cache-remove (car mml2015-epg-secret-key-id-list))
+	   (setq mml2015-epg-secret-key-id-list
+		 (cdr mml2015-epg-secret-key-id-list)))
+	 (mm-set-handle-multipart-parameter
+	  mm-security-handle 'gnus-info "Failed")
+	 (if (eq (car error) 'quit)
+	     (mm-set-handle-multipart-parameter
+	      mm-security-handle 'gnus-details "Quit.")
+	   (mm-set-handle-multipart-parameter
+	    mm-security-handle 'gnus-details (mml2015-format-error error)))
+	 (throw 'error handle)))
+      (with-temp-buffer
+	(insert plain)
+	(goto-char (point-min))
+	(while (search-forward "\r\n" nil t)
+	  (replace-match "\n" t t))
+	(setq handles (mm-dissect-buffer t))
+	(mm-destroy-parts handle)
+	(if (epg-context-result-for context 'verify)
+	    (mm-set-handle-multipart-parameter
+	     mm-security-handle 'gnus-info
+	     (concat "OK\n"
+		     (epg-verify-result-to-string
+		      (epg-context-result-for context 'verify))))
+	  (mm-set-handle-multipart-parameter
+	   mm-security-handle 'gnus-info "OK"))
+	(if (stringp (car handles))
+	    (mm-set-handle-multipart-parameter
+	     mm-security-handle 'gnus-details
+	     (mm-handle-multipart-ctl-parameter handles 'gnus-details))))
+	(if (listp (car handles))
+	    handles
+	  (list handles)))))
+
+(defun mml2015-epg-clear-decrypt ()
+  (let ((inhibit-redisplay t)
+	(context (epg-make-context))
+	plain)
+    (epg-context-set-passphrase-callback
+     context
+     #'mml2015-epg-passphrase-callback)
+    (condition-case error
+	(setq plain (epg-decrypt-string context (buffer-string))
+	      mml2015-epg-secret-key-id-list nil)
+      (error
+       (while mml2015-epg-secret-key-id-list
+	 (password-cache-remove (car mml2015-epg-secret-key-id-list))
+	 (setq mml2015-epg-secret-key-id-list
+	       (cdr mml2015-epg-secret-key-id-list)))
+       (mm-set-handle-multipart-parameter
+	mm-security-handle 'gnus-info "Failed")
+       (if (eq (car error) 'quit)
+	   (mm-set-handle-multipart-parameter
+	    mm-security-handle 'gnus-details "Quit.")
+	 (mm-set-handle-multipart-parameter
+	  mm-security-handle 'gnus-details (mml2015-format-error error)))))
+    (when plain
+      (erase-buffer)
+      ;; Treat data which epg returns as a unibyte string.
+      (mm-disable-multibyte)
+      (insert plain)
+      (goto-char (point-min))
+      (while (search-forward "\r\n" nil t)
+	(replace-match "\n" t t))
+      (if (epg-context-result-for context 'verify)
+	  (mm-set-handle-multipart-parameter
+	   mm-security-handle 'gnus-info
+	   (concat "OK\n"
+		   (epg-verify-result-to-string
+		    (epg-context-result-for context 'verify))))
+	(mm-set-handle-multipart-parameter
+	 mm-security-handle 'gnus-info "OK")))))
+
+(defun mml2015-epg-verify (handle ctl)
+  (catch 'error
+    (let ((inhibit-redisplay t)
+	  context plain signature-file part signature)
+      (when (or (null (setq part (mm-find-raw-part-by-type
+				  ctl (or (mm-handle-multipart-ctl-parameter
+					   ctl 'protocol)
+					  "application/pgp-signature")
+				  t)))
+		(null (setq signature (mm-find-part-by-type
+				       (cdr handle) "application/pgp-signature"
+				       nil t))))
+	(mm-set-handle-multipart-parameter
+	 mm-security-handle 'gnus-info "Corrupted")
+	(throw 'error handle))
+      (setq context (epg-make-context))
+      (condition-case error
+	  (setq plain (epg-verify-string context (mm-get-part signature) part))
+	(error
+	 (mm-set-handle-multipart-parameter
+	  mm-security-handle 'gnus-info "Failed")
+	 (if (eq (car error) 'quit)
+	     (mm-set-handle-multipart-parameter
+	      mm-security-handle 'gnus-details "Quit.")
+	   (mm-set-handle-multipart-parameter
+	    mm-security-handle 'gnus-details (mml2015-format-error error)))
+	 (throw 'error handle)))
+      (mm-set-handle-multipart-parameter
+       mm-security-handle 'gnus-info
+       (epg-verify-result-to-string (epg-context-result-for context 'verify)))
+      handle)))
+
+(defun mml2015-epg-clear-verify ()
+  (let ((inhibit-redisplay t)
+	(context (epg-make-context))
+	(signature (encode-coding-string (buffer-string)
+					 buffer-file-coding-system))
+	plain)
+    (condition-case error
+	(setq plain (epg-verify-string context signature))
+      (error
+       (mm-set-handle-multipart-parameter
+	mm-security-handle 'gnus-info "Failed")
+       (if (eq (car error) 'quit)
+	   (mm-set-handle-multipart-parameter
+	    mm-security-handle 'gnus-details "Quit.")
+	 (mm-set-handle-multipart-parameter
+	  mm-security-handle 'gnus-details (mml2015-format-error error)))))
+    (if plain
+	(mm-set-handle-multipart-parameter
+	 mm-security-handle 'gnus-info
+	 (epg-verify-result-to-string
+	  (epg-context-result-for context 'verify))))))
+
+(defun mml2015-epg-sign (cont)
+  (let ((inhibit-redisplay t)
+	(context (epg-make-context))
+	(boundary (mml-compute-boundary cont))
+	signers	signature micalg)
+    (if mml2015-verbose
+	(setq signers (epa-select-keys context "Select keys for signing.
+If no one is selected, default secret key is used.  "
+				       nil t))
+      (setq signers (list (car (epg-list-keys
+				context
+				(message-options-get 'mml-sender) t)))))
+    (epg-context-set-armor context t)
+    (epg-context-set-textmode context t)
+    (epg-context-set-signers context signers)
+    (epg-context-set-passphrase-callback
+     context
+     #'mml2015-epg-passphrase-callback)
+    (condition-case error
+	(setq signature (epg-sign-string context (buffer-string) t)
+	      mml2015-epg-secret-key-id-list nil)
+      (error
+       (while mml2015-epg-secret-key-id-list
+	 (password-cache-remove (car mml2015-epg-secret-key-id-list))
+	 (setq mml2015-epg-secret-key-id-list
+	       (cdr mml2015-epg-secret-key-id-list)))
+       (signal (car error) (cdr error))))
+    (if (epg-context-result-for context 'sign)
+	(setq micalg (epg-new-signature-digest-algorithm
+		      (car (epg-context-result-for context 'sign)))))
+    (goto-char (point-min))
+    (insert (format "Content-Type: multipart/signed; boundary=\"%s\";\n"
+		    boundary))
+    (if micalg
+	(insert (format "\tmicalg=%s; "
+			(downcase
+			 (cdr (assq micalg
+				    epg-digest-algorithm-alist))))))
+    (insert "protocol=\"application/pgp-signature\"\n")
+    (insert (format "\n--%s\n" boundary))
+    (goto-char (point-max))
+    (insert (format "\n--%s\n" boundary))
+    (insert "Content-Type: application/pgp-signature\n\n")
+    (insert signature)
+    (goto-char (point-max))
+    (insert (format "--%s--\n" boundary))
+    (goto-char (point-max))))
+
+(defun mml2015-epg-encrypt (cont &optional sign)
+  (let ((inhibit-redisplay t)
+	(context (epg-make-context))
+	recipients cipher
+	(boundary (mml-compute-boundary cont)))
+    (if (or mml2015-verbose
+	    (null (message-options-get 'message-recipients)))
+	(setq recipients
+	      (epa-select-keys context "Select recipients for encryption.
+If no one is selected, symmetric encryption will be performed.  "
+			       (if (message-options-get 'message-recipients)
+				   (split-string
+				    (message-options-get 'message-recipients)
+				    "[ \f\t\n\r\v,]+"))))
+      (setq recipients
+	    (mapcar (lambda (name)
+		      (car (epg-list-keys context name)))
+		    (split-string
+		     (message-options-get 'message-recipients)
+		     "[ \f\t\n\r\v,]+"))))
+    (epg-context-set-armor context t)
+    (epg-context-set-textmode context t)
+    (epg-context-set-passphrase-callback
+     context
+     #'mml2015-epg-passphrase-callback)
+    (condition-case error
+	(setq cipher
+	      (epg-encrypt-string context (buffer-string) recipients sign)
+	      mml2015-epg-secret-key-id-list nil)
+      (error
+       (while mml2015-epg-secret-key-id-list
+	 (password-cache-remove (car mml2015-epg-secret-key-id-list))
+	 (setq mml2015-epg-secret-key-id-list
+	       (cdr mml2015-epg-secret-key-id-list)))
+       (signal (car error) (cdr error))))
+    (delete-region (point-min) (point-max))
+    (goto-char (point-min))
+    (insert (format "Content-Type: multipart/encrypted; boundary=\"%s\";\n"
+		    boundary))
+    (insert "\tprotocol=\"application/pgp-encrypted\"\n\n")
+    (insert (format "--%s\n" boundary))
+    (insert "Content-Type: application/pgp-encrypted\n\n")
+    (insert "Version: 1\n\n")
+    (insert (format "--%s\n" boundary))
+    (insert "Content-Type: application/octet-stream\n\n")
+    (insert cipher)
     (goto-char (point-max))
     (insert (format "--%s--\n" boundary))
     (goto-char (point-max))))

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Regards,
-- 
Daiki Ueno

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

* Re: EasyPG support for mml2015.el
  2006-07-10  3:54 EasyPG support for mml2015.el Daiki Ueno
  2006-07-10  9:04 ` Daiki Ueno
@ 2006-07-10 10:03 ` Simon Josefsson
  2006-07-12  7:38 ` EasyPG hangs Max Froumentin
  2 siblings, 0 replies; 12+ messages in thread
From: Simon Josefsson @ 2006-07-10 10:03 UTC (permalink / raw)
  Cc: ding

Daiki Ueno <ueno@unixuser.org> writes:

> Hi,
>
> 2 weeks ago, we had CodeFest Akihabara 2006 (a 24-hour hacking marathon
> in Japan).  There I wrote a patch which allows to use EasyPG directly
> from Gnus.
>
> Can you install this patch into Gnus?  Though it has not yet been tested
> thoroughly, it should not break existing mml2015.el feature.
>
> To use: just set (setq mml2015-use 'epg)

Hi!  Looks good, I've installed this.  One minor thing though:

> +(defcustom mml2015-cache-passphrase t
> +  "If t, cache passphrase."
> +  :group 'mime-security
> +  :type 'boolean)

This variable doesn't seem to be used by your new code?

Thanks,
Simon



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

* Re: EasyPG support for mml2015.el
  2006-07-10  9:04 ` Daiki Ueno
@ 2006-07-10 10:08   ` Simon Josefsson
  2006-07-10 10:36     ` Daiki Ueno
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Josefsson @ 2006-07-10 10:08 UTC (permalink / raw)
  Cc: ding

Daiki Ueno <ueno@unixuser.org> writes:

>>>>>> In <0a485279-4c9d-4249-bb88-c2fbf73c6171@well-done.deisui.org> 
>>>>>>	Daiki Ueno <ueno@unixuser.org> wrote:
>> 2 weeks ago, we had CodeFest Akihabara 2006 (a 24-hour hacking marathon
>> in Japan).  There I wrote a patch which allows to use EasyPG directly
>> from Gnus.
>
> I just wrote a patch to mml1991.el attached below.

I installed the patch against mml1991.el.  There was a patch against
mml2015.el there too, slightly different than your last patch, but I
couldn't apply it on top of the old patch.  Any problem here?

One minor issue here too:

> +(defvar mml1991-cache-passphrase t
> +  "If t, cache passphrase.")

This variable isn't used.

And maybe there shouldn't be this many variables that control password
caching -- now there is at least in mml1991, mml2015 and in pgg, if I
recall correctly.

Btw, I think you should have CVS commit access, to maintain the PGG
files and install patches like this, are you interested in this?  Lars
has to decide, of course.

/Simon



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

* Re: EasyPG support for mml2015.el
  2006-07-10 10:08   ` Simon Josefsson
@ 2006-07-10 10:36     ` Daiki Ueno
  2006-07-10 10:53       ` Simon Josefsson
  0 siblings, 1 reply; 12+ messages in thread
From: Daiki Ueno @ 2006-07-10 10:36 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

>>>>> In <8764i5ydq0.fsf@latte.josefsson.org> 
>>>>>	Simon Josefsson <jas@extundo.com> wrote:
> > I just wrote a patch to mml1991.el attached below.

> I installed the patch against mml1991.el.  There was a patch against
> mml2015.el there too, slightly different than your last patch, but I
> couldn't apply it on top of the old patch.  Any problem here?

Sorry, this is because I created the diff from my up-to-date working copy.

> One minor issue here too:

> > +(defvar mml1991-cache-passphrase t
> > +  "If t, cache passphrase.")

> This variable isn't used.

Fixed in the attached patch.

> And maybe there shouldn't be this many variables that control password
> caching -- now there is at least in mml1991, mml2015 and in pgg, if I
> recall correctly.

Should these functions be unified in in mml-sec.el?


[-- Attachment #2: mml-epg.el.diff --]
[-- Type: application/octet-stream, Size: 4200 bytes --]

Index: lisp/mml1991.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml1991.el,v
retrieving revision 7.11
diff -u -r7.11 mml1991.el
--- lisp/mml1991.el	10 Jul 2006 10:05:00 -0000	7.11
+++ lisp/mml1991.el	10 Jul 2006 10:35:34 -0000
@@ -32,6 +32,8 @@
   (require 'cl)
   (require 'mm-util))
 
+(require 'password)
+
 (defvar mc-pgp-always-sign)
 
 (autoload 'quoted-printable-decode-region "qp")
@@ -358,9 +360,10 @@
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
     (epg-context-set-signers context signers)
-    (epg-context-set-passphrase-callback
-     context
-     #'mml1991-epg-passphrase-callback)
+    (if mml1991-cache-passphrase
+	(epg-context-set-passphrase-callback
+	 context
+	 #'mml1991-epg-passphrase-callback))
     ;; Don't sign headers.
     (goto-char (point-min))
     (when (re-search-forward "^$" nil t)
@@ -426,9 +429,10 @@
 		     "[ \f\t\n\r\v,]+"))))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
-    (epg-context-set-passphrase-callback
-     context
-     #'mml1991-epg-passphrase-callback)
+    (if mml1991-cache-passphrase
+	(epg-context-set-passphrase-callback
+	 context
+	 #'mml1991-epg-passphrase-callback))
     (condition-case error
 	(setq cipher
 	      (epg-encrypt-string context (buffer-string) recipients sign)
Index: lisp/mml2015.el
===================================================================
RCS file: /usr/local/cvsroot/gnus/lisp/mml2015.el,v
retrieving revision 7.16
diff -u -r7.16 mml2015.el
--- lisp/mml2015.el	10 Jul 2006 10:03:11 -0000	7.16
+++ lisp/mml2015.el	10 Jul 2006 10:35:35 -0000
@@ -902,8 +902,7 @@
 ;;; epg wrapper
 
 (eval-and-compile
-  (autoload 'epg-make-context "epg")
-  (autoload 'epa-select-keys "epa"))
+  (autoload 'epg-make-context "epg"))
 
 (eval-when-compile
   (defvar epg-user-id-alist)
@@ -956,9 +955,10 @@
 	 mm-security-handle 'gnus-info "Corrupted")
 	(throw 'error handle))
       (setq context (epg-make-context))
-      (epg-context-set-passphrase-callback
-       context
-       #'mml2015-epg-passphrase-callback)
+      (if mml2015-cache-passphrase
+	  (epg-context-set-passphrase-callback
+	   context
+	   #'mml2015-epg-passphrase-callback))
       (condition-case error
 	  (setq plain (epg-decrypt-string context (mm-get-part child))
 		mml2015-epg-secret-key-id-list nil)
@@ -1002,9 +1002,10 @@
   (let ((inhibit-redisplay t)
 	(context (epg-make-context))
 	plain)
-    (epg-context-set-passphrase-callback
-     context
-     #'mml2015-epg-passphrase-callback)
+    (if mml2015-cache-passphrase
+	(epg-context-set-passphrase-callback
+	 context
+	 #'mml2015-epg-passphrase-callback))
     (condition-case error
 	(setq plain (epg-decrypt-string context (buffer-string))
 	      mml2015-epg-secret-key-id-list nil)
@@ -1106,9 +1107,10 @@
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
     (epg-context-set-signers context signers)
-    (epg-context-set-passphrase-callback
-     context
-     #'mml2015-epg-passphrase-callback)
+    (if mml2015-cache-passphrase
+	(epg-context-set-passphrase-callback
+	 context
+	 #'mml2015-epg-passphrase-callback))
     (condition-case error
 	(setq signature (epg-sign-string context (buffer-string) t)
 	      mml2015-epg-secret-key-id-list nil)
@@ -1154,15 +1156,17 @@
 				    (message-options-get 'message-recipients)
 				    "[ \f\t\n\r\v,]+"))))
       (setq recipients
-	    (epg-list-keys context
-			   (split-string
-			    (message-options-get 'message-recipients)
-			    "[ \f\t\n\r\v,]+"))))
+	    (mapcar (lambda (name)
+		      (car (epg-list-keys context name)))
+		    (split-string
+		     (message-options-get 'message-recipients)
+		     "[ \f\t\n\r\v,]+"))))
     (epg-context-set-armor context t)
     (epg-context-set-textmode context t)
-    (epg-context-set-passphrase-callback
-     context
-     #'mml2015-epg-passphrase-callback)
+    (if mml2015-cache-passphrase
+	(epg-context-set-passphrase-callback
+	 context
+	 #'mml2015-epg-passphrase-callback))
     (condition-case error
 	(setq cipher
 	      (epg-encrypt-string context (buffer-string) recipients sign)

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Regards,
-- 
Daiki Ueno

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

* Re: EasyPG support for mml2015.el
  2006-07-10 10:36     ` Daiki Ueno
@ 2006-07-10 10:53       ` Simon Josefsson
  2006-07-11  8:28         ` Daiki Ueno
  0 siblings, 1 reply; 12+ messages in thread
From: Simon Josefsson @ 2006-07-10 10:53 UTC (permalink / raw)
  Cc: ding

Daiki Ueno <ueno@unixuser.org> writes:

>> One minor issue here too:
>
>> > +(defvar mml1991-cache-passphrase t
>> > +  "If t, cache passphrase.")
>
>> This variable isn't used.
>
> Fixed in the attached patch.

Applied, thanks.

>> And maybe there shouldn't be this many variables that control password
>> caching -- now there is at least in mml1991, mml2015 and in pgg, if I
>> recall correctly.
>
> Should these functions be unified in in mml-sec.el?

Yes, that seems like a good idea, at least for mml1991/mml2015.  Maybe
it isn't a good idea for PGG to depend on mml-sec variables though?

Hm.  Actually, I think it may be better to use password-cache and
password-cache-expiry from password.el instead.  What do you think?

Or better, we put the variables in mml-sec, but the defaults are to
use the values from password.el.  Some users may want different
password caching policy for mml-sec than for other passwords, but if a
user changes the password.el values, the defaults change everywhere
else too.  I think that causes the least surprises.

I'm not sure..

/Simon



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

* Re: EasyPG support for mml2015.el
  2006-07-10 10:53       ` Simon Josefsson
@ 2006-07-11  8:28         ` Daiki Ueno
  2006-07-25  5:23           ` Daiki Ueno
  0 siblings, 1 reply; 12+ messages in thread
From: Daiki Ueno @ 2006-07-11  8:28 UTC (permalink / raw)


>>>>> In <87wtalwx2q.fsf@latte.josefsson.org> 
>>>>>	Simon Josefsson <jas@extundo.com> wrote:
> >> And maybe there shouldn't be this many variables that control password
> >> caching -- now there is at least in mml1991, mml2015 and in pgg, if I
> >> recall correctly.
> >
> > Should these functions be unified in in mml-sec.el?

> Yes, that seems like a good idea, at least for mml1991/mml2015.  Maybe
> it isn't a good idea for PGG to depend on mml-sec variables though?

Exactly.  This is because PGG does not provide callback mechanism and is
tightly coupled with password.el already.  Once I thought that I could
remove these crappy stuff from PGG, however, there was an elisp which calls
pgg-add-passphrase-to-cache, etc.  Sigh.

> Hm.  Actually, I think it may be better to use password-cache and
> password-cache-expiry from password.el instead.  What do you think?

> Or better, we put the variables in mml-sec, but the defaults are to
> use the values from password.el.  Some users may want different
> password caching policy for mml-sec than for other passwords, but if a
> user changes the password.el values, the defaults change everywhere
> else too.  I think that causes the least surprises.

That sounds good.

Regards,
-- 
Daiki Ueno



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

* EasyPG hangs
  2006-07-10  3:54 EasyPG support for mml2015.el Daiki Ueno
  2006-07-10  9:04 ` Daiki Ueno
  2006-07-10 10:03 ` Simon Josefsson
@ 2006-07-12  7:38 ` Max Froumentin
  2006-07-12  8:16   ` Daiki Ueno
  2 siblings, 1 reply; 12+ messages in thread
From: Max Froumentin @ 2006-07-12  7:38 UTC (permalink / raw)


Emacs/cvs latest, epg-0.0.3

Emacs hangs when sending message signed with PGP/Mime, just after
asking for the passphrase. Process table indicate emacs is waiting for:

gpg --no-tty --status-fd 1 --yes --command-fd 0 --armor --textmode
--output /tmp/epg-output29013GRK --detach-sign -u C3CEE40BCDC1E89

Trace on quit included below.

Sorry not to investigate this further for now, hopefully this description
is good enough for Daiki-san to fix the bug.

Max.

Debugger entered--Lisp error: (quit)
  accept-process-output(#<process epg> 1)
  epg-wait-for-status((epg-context . [OpenPGP t t nil nil nil nil mml2015-epg-passphrase-callback epg-progress-callback-function (...) #<process epg> "/tmp/epg-output29013GRK" nil sign]) ("BEGIN_SIGNING"))
  epg-start-sign((epg-context . [OpenPGP t t nil nil nil nil mml2015-epg-passphrase-callback epg-progress-callback-function (...) #<process epg> "/tmp/epg-output29013GRK" nil sign]) (epg-data . [nil "\ntest pgp\n\nMax.\n"]) t)
  epg-sign-string((epg-context . [OpenPGP t t nil nil nil nil mml2015-epg-passphrase-callback epg-progress-callback-function (...) #<process epg> "/tmp/epg-output29013GRK" nil sign]) "\ntest pgp\n\nMax.\n" t)
  byte-code("Ã\bÄ Å#ÆÆ" [context signature mml2015-epg-secret-key-id-list epg-sign-string buffer-string t nil] 4)
  mml2015-epg-sign((part (sign . "pgpmime") (tag-location . 329) (contents . "test pgp\n\nMax.\n")))
  mml2015-sign((part (sign . "pgpmime") (tag-location . 329) (contents . "test pgp\n\nMax.\n")))
  mml-pgpmime-sign-buffer((part (sign . "pgpmime") (tag-location . 329) (contents . "test pgp\n\nMax.\n")))
  mml-generate-mime-1((part (sign . "pgpmime") (tag-location . 329) (contents . "test pgp\n\nMax.\n")))
  mml-generate-mime()
  message-encode-message-body()
  message-send-mail(nil)
  message-send-via-mail(nil)
  message-send(nil)
  message-send-and-exit(nil)
* call-interactively(message-send-and-exit)




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

* Re: EasyPG hangs
  2006-07-12  7:38 ` EasyPG hangs Max Froumentin
@ 2006-07-12  8:16   ` Daiki Ueno
  2006-07-12  9:16     ` Max Froumentin
  0 siblings, 1 reply; 12+ messages in thread
From: Daiki Ueno @ 2006-07-12  8:16 UTC (permalink / raw)
  Cc: ding

>>>>> In <874pxnp927.fsf@lapin-bleu.net> 
>>>>>	Max Froumentin <max@lapin-bleu.net> wrote:
> Emacs hangs when sending message signed with PGP/Mime, just after
> asking for the passphrase. Process table indicate emacs is waiting for:

I bet you are using earlier GnuPG version than 1.4.3, which is not
supported by EasyPG.

Regards,
-- 
Daiki Ueno



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

* Re: EasyPG hangs
  2006-07-12  8:16   ` Daiki Ueno
@ 2006-07-12  9:16     ` Max Froumentin
  2006-07-13  4:02       ` Daiki Ueno
  0 siblings, 1 reply; 12+ messages in thread
From: Max Froumentin @ 2006-07-12  9:16 UTC (permalink / raw)
  Cc: ueno

Daiki Ueno <ueno@unixuser.org> writes:

> I bet you are using earlier GnuPG version than 1.4.3, which is not
> supported by EasyPG.

Thanks, you're right. Sorry for not having checked in the README file
(but perhaps you'd like to add something to autoconf to check). It's
working now.

Max.




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

* Re: EasyPG hangs
  2006-07-12  9:16     ` Max Froumentin
@ 2006-07-13  4:02       ` Daiki Ueno
  0 siblings, 0 replies; 12+ messages in thread
From: Daiki Ueno @ 2006-07-13  4:02 UTC (permalink / raw)
  Cc: ding

>>>>> In <87r70r5gk3.fsf@lapin-bleu.net> 
>>>>>	Max Froumentin <max@lapin-bleu.net> wrote:
> > I bet you are using earlier GnuPG version than 1.4.3, which is not
> > supported by EasyPG.

> (but perhaps you'd like to add something to autoconf to check).

Thanks, that's a good idea.  I've installed this in CVS.

Regards,
-- 
Daiki Ueno



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

* Re: EasyPG support for mml2015.el
  2006-07-11  8:28         ` Daiki Ueno
@ 2006-07-25  5:23           ` Daiki Ueno
  0 siblings, 0 replies; 12+ messages in thread
From: Daiki Ueno @ 2006-07-25  5:23 UTC (permalink / raw)


>>>>> In <f139e7db-ad97-45f0-81c9-acac6c35f328@well-done.deisui.org> 
>>>>>	Daiki Ueno <ueno@unixuser.org> wrote:
> > Or better, we put the variables in mml-sec, but the defaults are to
> > use the values from password.el.  Some users may want different
> > password caching policy for mml-sec than for other passwords, but if a
> > user changes the password.el values, the defaults change everywhere
> > else too.  I think that causes the least surprises.

> That sounds good.

I just installed this change in the trunk.

Regards,
-- 
Daiki Ueno



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

end of thread, other threads:[~2006-07-25  5:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-10  3:54 EasyPG support for mml2015.el Daiki Ueno
2006-07-10  9:04 ` Daiki Ueno
2006-07-10 10:08   ` Simon Josefsson
2006-07-10 10:36     ` Daiki Ueno
2006-07-10 10:53       ` Simon Josefsson
2006-07-11  8:28         ` Daiki Ueno
2006-07-25  5:23           ` Daiki Ueno
2006-07-10 10:03 ` Simon Josefsson
2006-07-12  7:38 ` EasyPG hangs Max Froumentin
2006-07-12  8:16   ` Daiki Ueno
2006-07-12  9:16     ` Max Froumentin
2006-07-13  4:02       ` Daiki Ueno

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