[gnus git] branch master updated: m0-5-243-gebd82a9 =1= mml-smime.el: Support signing by sender

Katsumi Yamaoka <[email protected]>
Newsgroups gmane.emacs.gnus.cvs
Message-ID <[email protected]>
       via  ebd82a9d41750b27e13af5064499dcc9f6dd34c0 (commit)
      from  14185e18386ebba04610ea66ebad153dc92d64e6 (commit)


- Log -----------------------------------------------------------------
commit ebd82a9d41750b27e13af5064499dcc9f6dd34c0
Author: Daiki Ueno <[email protected]>
Date:   Mon Jan 7 04:33:39 2013 +0000

    mml-smime.el: Support signing by sender

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a42cdf6..a506fa4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-07  Daiki Ueno  <[email protected]>
+
+	* mml-smime.el: Support signing by sender.
+	Requested by Uwe Brauer.
+	(mml-smime-sign-with-sender): New user option analogous
+	to mml2015-sign-with-sender.
+	(mml-smime-epg-sign): Respect mml-smime-sign-with-sender.
+	(mml-smime-epg-find-usable-secret-key): New helper function copied from
+	mml2015.el.
+
 2012-12-31  Lars Magne Ingebrigtsen  <[email protected]>
 
 	* gnus-msg.el (gnus-inews-insert-gcc): Don't insert Gcc headers if Gnus
diff --git a/lisp/mml-smime.el b/lisp/mml-smime.el
index 3e769d3..e7f9de7 100644
--- a/lisp/mml-smime.el
+++ b/lisp/mml-smime.el
@@ -74,6 +74,11 @@ Whether the passphrase is cached at all is controlled by
   :group 'mime-security
   :type '(repeat (string :tag "Key ID")))
 
+(defcustom mml-smime-sign-with-sender nil
+  "If t, use message sender so find a key to sign with."
+  :group 'mime-security
+  :type 'boolean)
+
 (defun mml-smime-sign (cont)
   (let ((func (nth 1 (assq mml-smime-use mml-smime-function-alist))))
     (if func
@@ -366,6 +371,24 @@ Whether the passphrase is cached at all is controlled by
 	  (setq pointer (cdr pointer))))
       (setq keys (cdr keys)))))
 
+;; XXX: since gpg --list-secret-keys does not return validity of each
+;; key, `mml-smime-epg-find-usable-key' defined above is not enough for
+;; secret keys.  The function `mml-smime-epg-find-usable-secret-key'
+;; below looks at appropriate public keys to check usability.
+(defun mml-smime-epg-find-usable-secret-key (context name usage)
+  (let ((secret-keys (epg-list-keys context name t))
+	secret-key)
+    (while (and (not secret-key) secret-keys)
+      (if (mml-smime-epg-find-usable-key
+	   (epg-list-keys context (epg-sub-key-fingerprint
+				   (car (epg-key-sub-key-list
+					 (car secret-keys)))))
+	   usage)
+	  (setq secret-key (car secret-keys)
+		secret-keys nil)
+	(setq secret-keys (cdr secret-keys))))
+    secret-key))
+
 (autoload 'mml-compute-boundary "mml")
 
 ;; We require mm-decode, which requires mm-bodies, which autoloads
@@ -376,6 +399,10 @@ Whether the passphrase is cached at all is controlled by
   (let* ((inhibit-redisplay t)
 	 (context (epg-make-context 'CMS))
 	 (boundary (mml-compute-boundary cont))
+	 (sender (message-options-get 'message-sender))
+	 (signer-names (or mml-smime-signers
+			   (if (and mml-smime-sign-with-sender sender)
+			       (list (concat "<" sender ">")))))
 	 signer-key
 	 (signers
 	  (or (message-options-get 'mml-smime-epg-signers)
@@ -385,20 +412,23 @@ Whether the passphrase is cached at all is controlled by
 		  (epa-select-keys context "\
 Select keys for signing.
 If no one is selected, default secret key is used.  "
-				   mml-smime-signers t)
-		(if mml-smime-signers
+				    signer-names
+				    t)
+		 (if (or sender mml-smime-signers)
+		     (delq nil
 		    (mapcar
 		     (lambda (signer)
-		       (setq signer-key (mml-smime-epg-find-usable-key
-					 (epg-list-keys context signer t)
-					 'sign))
+			      (setq signer-key
+				    (mml-smime-epg-find-usable-secret-key
+				     context signer 'sign))
 		       (unless (or signer-key
 				   (y-or-n-p
-				    (format "No secret key for %s; skip it? "
+					   (format
+					    "No secret key for %s; skip it? "
 					    signer)))
 			 (error "No secret key for %s" signer))
 		       signer-key)
-		     mml-smime-signers))))))
+			    signer-names)))))))
 	 signature micalg)
     (epg-context-set-signers context signers)
     (if mml-smime-cache-passphrase

-----------------------------------------------------------------------
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we listed those
revisions in full, above.

Summary of changes:
 lisp/ChangeLog    |   10 ++++++++
 lisp/mml-smime.el |   62 +++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 56 insertions(+), 16 deletions(-)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnus Project".

The branch, master has been updated


hooks/post-receive
-- 
Gnus Project
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.