Gnus development mailing list
 help / color / mirror / Atom feed
* mml-smime: mml-sime-encrypt-to-self
@ 2013-01-06 10:35 Uwe Brauer
  2013-01-08 11:14 ` Uwe Brauer
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2013-01-06 10:35 UTC (permalink / raw)
  To: ding

Hello

Mml2015 has the useful variable
mml2015-encrypt-to-self but mml-smime has no equivalent.

I had a look at the code and for me it is not obvious how include this
functionality.

Can somebody familiar with the code have a look please.

Thanks 

Uwe Brauer 





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

* Re: mml-smime: mml-sime-encrypt-to-self
  2013-01-06 10:35 mml-smime: mml-sime-encrypt-to-self Uwe Brauer
@ 2013-01-08 11:14 ` Uwe Brauer
  2013-01-10  9:08   ` Daiki Ueno
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2013-01-08 11:14 UTC (permalink / raw)
  To: ding

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

>> "Uwe" == Uwe Brauer <oub@mat.ucm.es> writes: 
 
   > Hello Mml2015 has the useful variable mml2015-encrypt-to-self 
   > but mml-smime has no equivalent. 
 
   > I had a look at the code and for me it is not obvious how 
   > include this functionality. 
 
   > Can somebody familiar with the code have a look please. 
 
I think I have implemented it. I attach a patch, since I am not 
familiar 

with bzr. 


Uwe Brauer 


[-- Attachment #2: mml-smime-diff --]
[-- Type: application/octet-stream, Size: 4594 bytes --]

diff -u /home/oub/xemacs/site-lisp/packages/gnus-git-28-9-2011/lisp/mml-smime-git.el /home/oub/xemacs/site-lisp/packages/gnus-git-28-9-2011/lisp/mml-smime.el
--- /home/oub/xemacs/site-lisp/packages/gnus-git-28-9-2011/lisp/mml-smime-git.el	2013-01-08 11:31:07.882405203 +0100
+++ /home/oub/xemacs/site-lisp/packages/gnus-git-28-9-2011/lisp/mml-smime.el	2013-01-08 11:31:07.890405032 +0100
@@ -79,6 +79,12 @@
   :group 'mime-security
   :type 'boolean)
 
+
+(defcustom mml-smime-encrypt-to-self nil
+  "If t, add your own key ID to recipient list when encryption."
+  :group 'mime-security
+  :type 'boolean)
+
 (defun mml-smime-sign (cont)
   (let ((func (nth 1 (assq mml-smime-use mml-smime-function-alist))))
     (if func
@@ -474,59 +480,68 @@
 
 (defun mml-smime-epg-encrypt (cont)
   (let ((inhibit-redisplay t)
-	(context (epg-make-context 'CMS))
-	(config (epg-configuration))
-	(recipients (message-options-get 'mml-smime-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key)
+		(context (epg-make-context 'CMS))
+		(config (epg-configuration))
+		(recipients (message-options-get 'mml-smime-epg-recipients))
+		cipher 
+		(sender (message-options-get 'message-sender))
+		(signer-names (or mml-smime-signers
+						  (if (and mml-smime-sign-with-sender sender)
+							  (list (concat "<" sender ">")))))
+		signers
+		(boundary (mml-compute-boundary cont))
+		recipient-key)
     (unless recipients
       (setq recipients
-	    (apply #'nconc
-		   (mapcar
-		    (lambda (recipient)
-		      (or (epg-expand-group config recipient)
-			  (list recipient)))
-		    (split-string
-		     (or (message-options-get 'message-recipients)
-			 (message-options-set 'message-recipients
-					      (read-string "Recipients: ")))
-		     "[ \f\t\n\r\v,]+"))))
+			(apply #'nconc
+				   (mapcar
+					(lambda (recipient)
+					  (or (epg-expand-group config recipient)
+						  (list recipient)))
+					(split-string
+					 (or (message-options-get 'message-recipients)
+						 (message-options-set 'message-recipients
+											  (read-string "Recipients: ")))
+					 "[ \f\t\n\r\v,]+"))))
+	  (when mml-smime-encrypt-to-self
+		(unless signer-names
+		  (error "Neither message sender nor mml-smime-signers are set"))
+		(setq recipients (nconc recipients signer-names)))
       (if (eq mm-encrypt-option 'guided)
-	  (setq recipients
-		(epa-select-keys context "\
+		  (setq recipients
+				(epa-select-keys context "\
 Select recipients for encryption.
 If no one is selected, symmetric encryption will be performed.  "
-				 recipients))
-	(setq recipients
-	      (mapcar
-	       (lambda (recipient)
-		 (setq recipient-key (mml-smime-epg-find-usable-key
-				      (epg-list-keys context 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))
-	(unless recipients
-	  (error "No recipient specified")))
+								 recipients))
+		(setq recipients
+			  (mapcar
+			   (lambda (recipient)
+				 (setq recipient-key (mml-smime-epg-find-usable-key
+									  (epg-list-keys context 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))
+		(unless recipients
+		  (error "No recipient specified")))
       (message-options-set 'mml-smime-epg-recipients recipients))
     (if mml-smime-cache-passphrase
-	(epg-context-set-passphrase-callback
-	 context
-	 #'mml-smime-epg-passphrase-callback))
+		(epg-context-set-passphrase-callback
+		 context
+		 #'mml-smime-epg-passphrase-callback))
     (condition-case error
-	(setq cipher
-	      (epg-encrypt-string context (buffer-string) recipients)
-	      mml-smime-epg-secret-key-id-list nil)
+		(setq cipher
+			  (epg-encrypt-string context (buffer-string) recipients)
+			  mml-smime-epg-secret-key-id-list nil)
       (error
        (while mml-smime-epg-secret-key-id-list
-	 (password-cache-remove (car mml-smime-epg-secret-key-id-list))
-	 (setq mml-smime-epg-secret-key-id-list
-	       (cdr mml-smime-epg-secret-key-id-list)))
+		 (password-cache-remove (car mml-smime-epg-secret-key-id-list))
+		 (setq mml-smime-epg-secret-key-id-list
+			   (cdr mml-smime-epg-secret-key-id-list)))
        (signal (car error) (cdr error))))
     (delete-region (point-min) (point-max))
     (goto-char (point-min))

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

* Re: mml-smime: mml-sime-encrypt-to-self
  2013-01-08 11:14 ` Uwe Brauer
@ 2013-01-10  9:08   ` Daiki Ueno
  2013-01-10 11:16     ` Uwe Brauer
  2013-01-11 17:36     ` Uwe Brauer
  0 siblings, 2 replies; 5+ messages in thread
From: Daiki Ueno @ 2013-01-10  9:08 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: ding

Uwe Brauer <oub@mat.ucm.es> writes:

> I think I have implemented it. I attach a patch, since I am not
> familiar with bzr. 

Thanks, looks almost good.  I'm going to push a slightly modified
version (attached).

By the way, could you please preserve indentation from the next time
when you send a patch?  Also good to use "git diff" or "git
format-patch" to generate diff.

Regards,
-- 
Daiki Ueno

From 0abd8b04f1c3e1cbe29de65bd6f2b8eac9204ab9 Mon Sep 17 00:00:00 2001
From: Uwe Brauer <oub@mat.ucm.es>
Date: Thu, 10 Jan 2013 18:00:56 +0900
Subject: [PATCH] Add mml-smime-encrypt-to-self.

* mml-smime.el (mml-smime-encrypt-to-self): New user option analogous
to mml2015-encrypt-to-self.
(mml-smime-epg-encrypt): Respect mml-smime-encrypt-to-self.
---
 lisp/ChangeLog    |  6 ++++++
 lisp/mml-smime.el | 28 +++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cd8ea7c..2ed5647 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2013-01-10  Uwe Brauer  <oub@mat.ucm.es>  (tiny change)
+
+	* mml-smime.el (mml-smime-encrypt-to-self): New user option analogous
+	to mml2015-encrypt-to-self.
+	(mml-smime-epg-encrypt): Respect mml-smime-encrypt-to-self.
+
 2013-01-09  Daiki Ueno  <ueno@gnu.org>
 
 	* mml-smime.el (epg-sub-key-fingerprint): Autoload for
diff --git a/lisp/mml-smime.el b/lisp/mml-smime.el
index e5e99de..6ea5537 100644
--- a/lisp/mml-smime.el
+++ b/lisp/mml-smime.el
@@ -80,6 +80,12 @@ Whether the passphrase is cached at all is controlled by
   :version "24.4"
   :type 'boolean)
 
+(defcustom mml-smime-encrypt-to-self nil
+  "If t, add your own key ID to recipient list when encryption."
+  :group 'mime-security
+  :version "24.4"
+  :type 'boolean)
+
 (defun mml-smime-sign (cont)
   (let ((func (nth 1 (assq mml-smime-use mml-smime-function-alist))))
     (if func
@@ -475,13 +481,17 @@ Content-Disposition: attachment; filename=smime.p7s
     (goto-char (point-max))))
 
 (defun mml-smime-epg-encrypt (cont)
-  (let ((inhibit-redisplay t)
-	(context (epg-make-context 'CMS))
-	(config (epg-configuration))
-	(recipients (message-options-get 'mml-smime-epg-recipients))
-	cipher signers
-	(boundary (mml-compute-boundary cont))
-	recipient-key)
+  (let* ((inhibit-redisplay t)
+	 (context (epg-make-context 'CMS))
+	 (config (epg-configuration))
+	 (recipients (message-options-get 'mml-smime-epg-recipients))
+	 cipher signers
+	 (sender (message-options-get 'message-sender))
+	 (signer-names (or mml-smime-signers
+			   (if (and mml-smime-sign-with-sender sender)
+			       (list (concat "<" sender ">")))))
+	 (boundary (mml-compute-boundary cont))
+	 recipient-key)
     (unless recipients
       (setq recipients
 	    (apply #'nconc
@@ -494,6 +504,10 @@ Content-Disposition: attachment; filename=smime.p7s
 			 (message-options-set 'message-recipients
 					      (read-string "Recipients: ")))
 		     "[ \f\t\n\r\v,]+"))))
+      (when mml-smime-encrypt-to-self
+	(unless signer-names
+	  (error "Neither message sender nor mml-smime-signers are set"))
+	(setq recipients (nconc recipients signer-names)))
       (if (eq mm-encrypt-option 'guided)
 	  (setq recipients
 		(epa-select-keys context "\
-- 
1.8.1





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

* Re: mml-smime: mml-sime-encrypt-to-self
  2013-01-10  9:08   ` Daiki Ueno
@ 2013-01-10 11:16     ` Uwe Brauer
  2013-01-11 17:36     ` Uwe Brauer
  1 sibling, 0 replies; 5+ messages in thread
From: Uwe Brauer @ 2013-01-10 11:16 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: Uwe Brauer, ding

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

>> "Daiki" == Daiki Ueno <ueno@gnu.org> writes:

   > Uwe Brauer <oub@mat.ucm.es> writes:
   >> I think I have implemented it. I attach a patch, since I am not
   >> familiar with bzr. 

   > Thanks, looks almost good.  I'm going to push a slightly modified
   > version (attached).

   > By the way, could you please preserve indentation from the next time
   > when you send a patch?  Also good to use "git diff" or "git
   > format-patch" to generate diff.


Oops, I swore I marked the function and run 
indent-region-or-balanced-expression!

I run diff -u, I thought that was the preferred way, I have not tried
git. I just did and I obtained 

Using git -diff
error: unable to find 7a7b3f6d82d0e18c71ed15b561f186c12dc0ec3d
git format-patch mml-smime.el mml-smime-old.el
fatal: bad object HEAD

I have never every really used git, I admit.

regards

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4488 bytes --]

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

* Re: mml-smime: mml-sime-encrypt-to-self
  2013-01-10  9:08   ` Daiki Ueno
  2013-01-10 11:16     ` Uwe Brauer
@ 2013-01-11 17:36     ` Uwe Brauer
  1 sibling, 0 replies; 5+ messages in thread
From: Uwe Brauer @ 2013-01-11 17:36 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: Uwe Brauer, ding

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

>> "Daiki" == Daiki Ueno <ueno@gnu.org> writes:

> Uwe Brauer <oub@mat.ucm.es> writes:
>> I think I have implemented it. I attach a patch, since I am not
>> familiar with bzr. 

> Thanks, looks almost good.  I'm going to push a slightly modified
> version (attached).

It seems that I cannot apply your patch. You did not commit it yet? I
just wanted to compare your patch with mine.

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 4474 bytes --]

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

end of thread, other threads:[~2013-01-11 17:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-06 10:35 mml-smime: mml-sime-encrypt-to-self Uwe Brauer
2013-01-08 11:14 ` Uwe Brauer
2013-01-10  9:08   ` Daiki Ueno
2013-01-10 11:16     ` Uwe Brauer
2013-01-11 17:36     ` Uwe Brauer

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