Commits

daiki  committed 8f4fe05

Synch easypg to upstream 0.0.16

  • Participants
  • Parent commits 1e6e7c0

Comments (0)

Files changed (11)

+2008-02-07  Daiki Ueno  <ueno@unixuser.org>
+
+	* EasyPG: Version 0.0.16 released.
+	* configure.ac: Bump up version.
+
+2008-02-06  Daiki Ueno  <ueno@unixuser.org>
+
+	* epa-file.el (epa-file-passphrase-callback-function): Use
+	canonical file names as keys for cache.
+
+2008-01-22  Daiki Ueno  <ueno@unixuser.org>
+
+	* epa-mail.el (epa-mail--find-usable-key): New function.
+	(epa-mail-encrypt): Use it.
+	Reported by intrigeri <intrigeri@boum.org>.
+
+2007-11-26  Daiki Ueno  <ueno@unixuser.org>
+
+	* epg-package-info.el.in (epg-bug-report-address): New constant.
+
+	* configure.ac: Use modern AC_INIT.
+
 2007-09-06  Norbert Koch  <viteno@xemacs.org>
 
 	* Makefile (VERSION): XEmacs package 1.01 released.
+* Major changes in 0.0.16
+
+** This will be the final version released under GPL2+.  Subsequent
+   versions will be released under GPL3+.
+
+** epa-mail-encrypt now skips unusable keys.
+
+** epa-file now uses canonical file names as keys for passphrase cache.
+
 * Major changes in 0.0.15
 
 ** Fixed a load-error of epa on XEmacs.

File configure.ac

-AC_INIT
+AC_PREREQ(2.61)
+AC_INIT([epg], [0.0.16], [ueno@unixuser.org])
 AC_CONFIG_SRCDIR([configure.ac])
-AC_PREREQ(2.59)
-AM_INIT_AUTOMAKE(epg, 0.0.15)
+AM_INIT_AUTOMAKE
 
 AC_CHECK_EMACS
 AC_PATH_LISPDIR

File epa-dired.el

 
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
 
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
 (defun epa-file-passphrase-callback-function (context key-id file)
   (if (and epa-file-cache-passphrase-for-symmetric-encryption
 	   (eq key-id 'SYM))
-      (let ((entry (assoc file epa-file-passphrase-alist))
-	    passphrase)
-	(or (copy-sequence (cdr entry))
-	    (progn
-	      (unless entry
-		(setq entry (list file)
-		      epa-file-passphrase-alist (cons entry
-						 epa-file-passphrase-alist)))
-	      (setq passphrase (epa-passphrase-callback-function context
-								 key-id nil))
-	      (setcdr entry (copy-sequence passphrase))
-	      passphrase)))
+      (progn
+	(setq file (file-truename file))
+	(let ((entry (assoc file epa-file-passphrase-alist))
+	      passphrase)
+	  (or (copy-sequence (cdr entry))
+	      (progn
+		(unless entry
+		  (setq entry (list file)
+			epa-file-passphrase-alist
+			(cons entry
+			      epa-file-passphrase-alist)))
+		(setq passphrase (epa-passphrase-callback-function context
+								   key-id nil))
+		(setcdr entry (copy-sequence passphrase))
+		passphrase))))
     (epa-passphrase-callback-function context key-id nil)))
 
 (defun epa-file-handler (operation &rest args)
 
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
   "A minor-mode for composing encrypted/clearsigned mails."
   nil " epa-mail" epa-mail-mode-map)
 
+(defun epa-mail--find-usable-key (keys usage)
+  "Find a usable key from KEYS for USAGE."
+  (catch 'found
+    (while keys
+      (let ((pointer (epg-key-sub-key-list (car keys))))
+	(while pointer
+	  (if (and (memq usage (epg-sub-key-capability (car pointer)))
+		   (not (memq (epg-sub-key-validity (car pointer))
+			      '(revoked expired))))
+	      (throw 'found (car keys)))
+	  (setq pointer (cdr pointer))))
+      (setq keys (cdr keys)))))
+
 ;;;###autoload
 (defun epa-mail-decrypt ()
   "Decrypt OpenPGP armors in the current buffer.
    (save-excursion
      (let ((verbose current-prefix-arg)
 	   (context (epg-make-context epa-protocol))
-	   recipients recipient-keys)
+	   recipients recipient-key)
        (goto-char (point-min))
        (save-restriction
 	 (narrow-to-region (point)
 If no one is selected, symmetric encryption will be performed.  "
 		  recipients)
 	       (if recipients
-		   (apply #'nconc
-			  (mapcar
-			   (lambda (recipient)
-			     (setq recipient-keys
-				   (epg-list-keys
-				    (epg-make-context epa-protocol)
-				    (concat "<" recipient ">")))
-			     (unless (or recipient-keys
-					 (y-or-n-p
-					  (format
-					   "No public key for %s; skip it? "
-					   recipient)))
-			       (error "No public key for %s" recipient))
-			     recipient-keys)
-			   recipients))))
+		   (mapcar
+		    (lambda (recipient)
+		      (setq recipient-key
+			    (epa-mail--find-usable-key
+			     (epg-list-keys
+			      (epg-make-context epa-protocol)
+			      (concat "<" recipient ">"))
+			     'encrypt))
+		      (unless (or recipient-key
+				  (y-or-n-p
+				   (format
+				    "No public key for %s; skip it? "
+				    recipient)))
+			(error "No public key for %s" recipient))
+		      recipient-key)
+		    recipients)))
 	     (setq sign (if verbose (y-or-n-p "Sign? ")))
 	     (if sign
 		 (epa-select-keys context

File epa-setup.el

+;;; epa-setup.el --- setup routine for the EasyPG Assistant.
+;; Copyright (C) 2006,2007,2008 Daiki Ueno
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Keywords: PGP, GnuPG
+
+;; This file is part of EasyPG.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Code:
+
 (autoload 'epa-list-keys "epa")
 
 (autoload 'epa-dired-mode-hook "epa-dired")
 
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License

File epg-config.el

 
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License

File epg-package-info.el.in

 
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
 (defconst epg-version-number "@VERSION@"
   "Version number of this package.")
 
+(defconst epg-bug-report-address "@PACKAGE_BUGREPORT@"
+  "Report bugs to this address.")
+
 (provide 'epg-package-info)
 
 ;;; epg-package-info.el ends here
 
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
 (defun epg-context-set-passphrase-callback (context passphrase-callback
 						    &optional handback)
   "Set the function used to query passphrase.
-If optional argument HANDBACK is specified, it is passed to CALLBACK."
+If optional argument HANDBACK is specified, it is passed to PASSPHRASE-CALLBACK."
   (unless (eq (car-safe context) 'epg-context)
     (signal 'wrong-type-argument (list 'epg-context-p context)))
   (aset (cdr context) 7 (if handback
 (defun epg-context-set-progress-callback (context progress-callback
 						  &optional handback)
   "Set the function which handles progress update.
-If optional argument HANDBACK is specified, it is passed to CALLBACK."
+If optional argument HANDBACK is specified, it is passed to PROGRESS-CALLBACK."
   (unless (eq (car-safe context) 'epg-context)
     (signal 'wrong-type-argument (list 'epg-context-p context)))
   (aset (cdr context) 8 (if handback
 
 ;;;###autoload
 (defun epg-start-sign-keys (context keys &optional local)
-  "Initiate an sign keys operation.
+  "Initiate a sign keys operation.
 
 If you use this function, you will need to wait for the completion of
 `epg-gpg-program' by using `epg-wait-for-completion' and call