bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pgg feature for remaping email address for encryption purposes


From: Bradley M. Kuhn
Subject: pgg feature for remaping email address for encryption purposes
Date: Thu, 15 Mar 2007 18:53:43 -0400
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.91 (gnu/linux)

Attached please find a patch that adds a feature to Gnus' pgg.  The
feature is for situations where you have an address that you know isn't on
your keyring, but that should nevertheless be associated with some other
email address encryption key. (The common case for this is there's an
alias that reaches the party you're encrypting for, but that alias doesn't
appear on their key officially.)

The patch is cvs diff'ed against the CVS head.


It's been many many years since I gave a patch to Emacs, so I don't know
the proper procedure these days, I hope sending it to this address is
right.

BTW, I (obviously) quite familiar with FSF's copyright assignment process,
but I don't know the Emacs' team particular procedure for when they want
copyright assignments for a given patch.  I am of course willing to assign
past and future changes and to get an employer disclaimer.  Let me know if
I should contact <address@hidden> directly about that.

Finally, let me know if you like the patch or would like me to rewrite it
a bit differently!  One idea I had for a better way to do it would also be
allow an email address to expand to multiple ones, so that you can send to
an alias where you know the people who receive the mail and have it
encrypted for all of their keys, but that further feature could always be
added later.

Attachment: pgpN5Ex2aWHPp.pgp
Description: PGP signature

Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10808
diff -u -r1.10808 ChangeLog
--- lisp/ChangeLog      11 Mar 2007 23:53:38 -0000      1.10808
+++ lisp/ChangeLog      15 Mar 2007 21:55:09 -0000
@@ -1,3 +1,9 @@
+2007-03-16  Bradley M. Kuhn  <address@hidden>
+
+       * pgg.el (pgg-encryption-address-remap): New function.
+
+       * pgg-def.el (pgg-encryption-address-remap-alist): New variable.
+
 2007-03-11  Juri Linkov <address@hidden>
 
        * replace.el (match): Use yellow background on light-bg terminals.
Index: lisp/pgg-def.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/pgg-def.el,v
retrieving revision 1.7
diff -u -r1.7 pgg-def.el
--- lisp/pgg-def.el     21 Jan 2007 03:53:11 -0000      1.7
+++ lisp/pgg-def.el     15 Mar 2007 21:55:09 -0000
@@ -76,6 +76,17 @@
   :group 'pgg
   :type 'coding-system)
 
+(defcustom pgg-encryption-address-remap-alist
+  nil
+  "Alist of email addresses to remap to other addresses when
+doing lookup of encryption keys during encryption for the
+recepients of a message.  Typically, this is used for email
+aliases that eventually reach a particular user but those
+addresses are not actually listed on the key."
+  :type '(alist :key-type (string :tag "Email Address")
+               :value-type (string :tag "Email Address")))
+
+
 (defvar pgg-messages-coding-system nil
   "Coding system used when reading from a PGP external process.")
 
Index: lisp/pgg.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/pgg.el,v
retrieving revision 1.5
diff -u -r1.5 pgg.el
--- lisp/pgg.el 21 Jan 2007 03:53:11 -0000      1.5
+++ lisp/pgg.el 15 Mar 2007 21:55:09 -0000
@@ -301,6 +301,14 @@
            (make-directory file))
        file))))
 
+(defun pgg-encryption-address-remap (rcpts)
+  "Replace addresses based on entries in the
+`pgg-encryption-address-remap-alist' in rcpts, returning a new list of 
recipients"
+  (if (null rcpts) nil
+    (cons (let ( (val (assoc (car rcpts) pgg-encryption-address-remap-alist)) )
+            (if (null val) (car rcpts) (cdr val)))
+          (pgg-encryption-address-remap (cdr rcpts)))))
+
 ;;; @ interface functions
 ;;;
 
@@ -318,7 +326,8 @@
   (let ((status
         (pgg-save-coding-system start end
           (pgg-invoke "encrypt-region" (or pgg-scheme pgg-default-scheme)
-                      (point-min) (point-max) rcpts sign passphrase))))
+                      (point-min) (point-max) 
+                       (pgg-encryption-address-remap rcpts) sign passphrase))))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))
@@ -370,7 +379,8 @@
   (interactive (list (split-string (read-string "Recipients: ") "[ \t,]+")))
   (let* ((start (or start (point-min)))
         (end (or end (point-max)))
-        (status (pgg-encrypt-region start end rcpts sign passphrase)))
+        (status (pgg-encrypt-region start end
+                        (pgg-encryption-address-remap rcpts) sign passphrase)))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))
Index: man/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/man/ChangeLog,v
retrieving revision 1.1216
diff -u -r1.1216 ChangeLog
--- man/ChangeLog       6 Mar 2007 19:45:22 -0000       1.1216
+++ man/ChangeLog       15 Mar 2007 21:55:09 -0000
@@ -1,3 +1,8 @@
+2007-03-16  Bradley M. Kuhn  <address@hidden>
+
+       * pgg.texi (Other Configurable Variables): Added section and entry
+       about `pgg-encryption-address-remap-alist'.
+
 2007-03-06  Romain Francoise  <address@hidden>
 
        * faq.texi (New in Emacs 22): Don't say "now" too much.  Add MH-E to
Index: man/pgg.texi
===================================================================
RCS file: /sources/emacs/emacs/man/pgg.texi,v
retrieving revision 1.18
diff -u -r1.18 pgg.texi
--- man/pgg.texi        3 Mar 2007 22:04:37 -0000       1.18
+++ man/pgg.texi        15 Mar 2007 21:55:09 -0000
@@ -54,6 +54,25 @@
 * Parsing OpenPGP packets::     
 * Function Index::              
 * Variable Index::              
+
address@hidden
+ --- The Detailed Node Listing ---
+
+How to use
+
+* User Commands::               
+* Selecting an implementation::  
+* Caching passphrase::          
+* Default user identity::       
+* Other Configurable Variables::  
+
+Architecture
+
+* Initializing::                
+* Backend methods::             
+* Getting output::              
+
address@hidden detailmenu
 @end menu
 
 @node Overview
@@ -125,7 +144,8 @@
 * User Commands::               
 * Selecting an implementation::  
 * Caching passphrase::          
-* Default user identity::      
+* Default user identity::       
+* Other Configurable Variables::  
 @end menu
 
 @node User Commands
@@ -326,6 +346,24 @@
 variable.
 @end defvar
 
address@hidden Other Configurable Variables
address@hidden Other Configurable Variables
+
address@hidden pgg-encryption-address-remap-alist
+The alist for remapping some addresses to others for purposes of
+encryption.  It defaults to @samp{nil}.  Usually, this variable is used
+when there is a email address you send messages to that is actually an
+alias and will never appear as one of the addresses on the keyring
+itself.  For example, if you have an archive address like
address@hidden@@example.com}, but your keyring actually calls you
address@hidden@@example.com}, you could set this variable this way:
+
address@hidden
+(setq pgg-encryption-address-remap-alist
+      '("user-archive@@example.com" "user@@example.com"))
address@hidden lisp
address@hidden defvar
+
 @node Architecture
 @chapter Architecture
 
-- 

   -- bkuhn

reply via email to

[Prev in Thread] Current Thread [Next in Thread]