On Thu, Oct 06, 2005 at 11:18:48AM +0900, Daiki Ueno wrote: > It might be better to split pgg-gpg-encrypt-symmetric-region from > pgg-gpg-encrypt-region rather than maintaining > pgg-symmetric-encryption-schemes.
Yes, I think you are right, after in all this would be a cleaner approach. (I had reasons for my original design, but reconsidering them, they didn't hold...) > And also, is it still necessary to give special meaning to the 1st > argument (recipients) of pgg-encrypt-region? I guess you mean pgg-gpg-encrypt-region? No, after moving symmetric encryption in a dedicated function the special meaning of recipients is no longer needed. > > ps. I have no write access to CVS, so if there are no objections, > > please commit. > > Currently, PGG in Emacs CVS is a part of Gnus. So I added > Simon Josefsson to the Cc: list. He is one of Gnus maintainers and he > has taken care of PGG in Gnus CVS. Thanks. Attached you'll find a revised version of the patch. cheers -- Sascha Wilde To become a Jedi, use Emacs you have to.
Index: man/pgg.texi
===================================================================
RCS file: /cvsroot/emacs/emacs/man/pgg.texi,v
retrieving revision 1.5
diff -u -r1.5 pgg.texi
--- man/pgg.texi 16 Sep 2005 22:11:00 -0000 1.5
+++ man/pgg.texi 6 Oct 2005 09:00:13 -0000
@@ -98,6 +98,8 @@
@lisp
(autoload 'pgg-encrypt-region "pgg"
"Encrypt the current region." t)
+(autoload 'pgg-encrypt-symmetric-region "pgg"
+ "Encrypt the current region with symmetric algorithm." t)
(autoload 'pgg-decrypt-region "pgg"
"Decrypt the current region." t)
(autoload 'pgg-sign-region "pgg"
@@ -140,6 +142,13 @@
with GnuPG.
@end deffn
[EMAIL PROTECTED] Command pgg-encrypt-symmetric-region start end
+Encrypt the current region between @var{start} and @var{end} using a
+symmetric cipher. After invocation you are asked for a passphrase.
+
+This is currently only implemented for GnuPG.
[EMAIL PROTECTED] deffn
+
@deffn Command pgg-decrypt-region start end
Decrypt the current region between @var{start} and @var{end}. If
decryption is successful, it replaces the current region contents (in
@@ -305,6 +314,13 @@
@var{recipients}. If @var{sign} is [EMAIL PROTECTED], do a combined sign
and encrypt. If encryption is successful, it returns @code{t},
otherwise @code{nil}.
[EMAIL PROTECTED] deffn
+
[EMAIL PROTECTED] Method pgg-scheme-encrypt-symmetric-region scheme start end
+Encrypt the current region between @var{start} and @var{end} using a
+symmetric cipher and a passphrases. If encryption is successful, it
+returns @code{t}, otherwise @code{nil}. This function is currently only
+implemented for GnuPG.
@end deffn
@deffn Method pgg-scheme-decrypt-region scheme start end
Index: man/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/man/ChangeLog,v
retrieving revision 1.681
diff -u -r1.681 ChangeLog
--- man/ChangeLog 4 Oct 2005 22:52:16 -0000 1.681
+++ man/ChangeLog 6 Oct 2005 09:00:16 -0000
@@ -1,3 +1,11 @@
+2005-10-06 Sascha Wilde <[EMAIL PROTECTED]>
+
+ * pgg.texi (How to use): Added autoload line for
+ `pgg-encrypt-symmetric-region'.
+ (User Commands): Description of `pgg-encrypt-symmetric-region'.
+ (Backend methods): Describe new funktion
+ `pgg-scheme-encrypt-symmetric-region'.
+
2005-10-05 Nick Roberts <[EMAIL PROTECTED]>
* speedbar.texi (GDB): Describe use of watch expressions.
Index: lisp/gnus/pgg.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/gnus/pgg.el,v
retrieving revision 1.8
diff -u -r1.8 pgg.el
--- lisp/gnus/pgg.el 26 Aug 2005 00:02:05 -0000 1.8
+++ lisp/gnus/pgg.el 6 Oct 2005 09:00:17 -0000
@@ -4,6 +4,7 @@
;; 2005 Free Software Foundation, Inc.
;; Author: Daiki Ueno <[EMAIL PROTECTED]>
+;; Symmetric encryption added by: Sascha Wilde <[EMAIL PROTECTED]>
;; Created: 1999/10/28
;; Keywords: PGP
@@ -232,6 +233,32 @@
(pgg-save-coding-system start end
(pgg-invoke "encrypt-region" (or pgg-scheme pgg-default-scheme)
(point-min) (point-max) rcpts sign))))
+ (when (interactive-p)
+ (pgg-display-output-buffer start end status))
+ status))
+
+;;;###autoload
+(defun pgg-encrypt-symmetric-region (start end)
+ "Encrypt the current region between START and END symmetric with passphrase."
+ (interactive "r")
+ (let ((status
+ (pgg-save-coding-system start end
+ (pgg-invoke "encrypt-symmetric-region"
+ (or pgg-scheme pgg-default-scheme)
+ (point-min) (point-max)))))
+ (when (interactive-p)
+ (pgg-display-output-buffer start end status))
+ status))
+
+;;;###autoload
+(defun pgg-encrypt-symmetric (&optional start end)
+ "Encrypt the current buffer symmetric with passphrase.
+If optional arguments START and END are specified, only encrypt within
+the region."
+ (interactive)
+ (let* ((start (or start (point-min)))
+ (end (or end (point-max)))
+ (status (pgg-encrypt-symmetric-region start end)))
(when (interactive-p)
(pgg-display-output-buffer start end status))
status))
Index: lisp/gnus/pgg-gpg.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/gnus/pgg-gpg.el,v
retrieving revision 1.6
diff -u -r1.6 pgg-gpg.el
--- lisp/gnus/pgg-gpg.el 6 Aug 2005 19:51:42 -0000 1.6
+++ lisp/gnus/pgg-gpg.el 6 Oct 2005 09:00:17 -0000
@@ -4,6 +4,7 @@
;; 2005 Free Software Foundation, Inc.
;; Author: Daiki Ueno <[EMAIL PROTECTED]>
+;; Symmetric encryption added by: Sascha Wilde <[EMAIL PROTECTED]>
;; Created: 1999/10/28
;; Keywords: PGP, OpenPGP, GnuPG
@@ -169,6 +170,16 @@
(pgg-gpg-possibly-cache-passphrase passphrase)))
(pgg-process-when-success)))
+(defun pgg-gpg-encrypt-symmetric-region (start end)
+ "Encrypt the current region between START and END with symmetric cipher."
+ (let* ((passphrase
+ (pgg-read-passphrase "GnuPG passphrase for symmetric encryption: "))
+ (args
+ (append (list "--batch" "--armor" "--symmetric" ))))
+ (pgg-as-lbt start end 'CRLF
+ (pgg-gpg-process-region start end passphrase pgg-gpg-program args))
+ (pgg-process-when-success)))
+
(defun pgg-gpg-decrypt-region (start end)
"Decrypt the current region between START and END."
(let* ((current-buffer (current-buffer))
@@ -180,7 +191,10 @@
(pgg-gpg-user-id (or key pgg-gpg-user-id pgg-default-user-id))
(passphrase
(pgg-read-passphrase
- (format "GnuPG passphrase for %s: " pgg-gpg-user-id)
+ (format (if (pgg-gpg-symmetric-key-p message-keys)
+ "Passphrase for symmetric dencryption: "
+ "GnuPG passphrase for %s: ")
+ pgg-gpg-user-id)
pgg-gpg-user-id))
(args '("--batch" "--decrypt")))
(pgg-gpg-process-region start end passphrase pgg-gpg-program args)
@@ -188,6 +202,13 @@
(pgg-gpg-possibly-cache-passphrase passphrase pgg-gpg-user-id)
(goto-char (point-min))
(re-search-forward "^\\[GNUPG:] DECRYPTION_OKAY\\>" nil t))))
+
+(defun pgg-gpg-symmetric-key-p (message-keys)
+ "Check if MESSAGE-KEYS contains a symmetric encryption indicator."
+ (dolist (key message-keys result)
+ (when (and (eq (car key) 3)
+ (member '(symmetric-key-algorithm) key))
+ (setq result key))))
(defun pgg-gpg-select-matching-key (message-keys secret-keys)
"Choose a key from MESSAGE-KEYS that matches one of the keys in SECRET-KEYS."
Index: lisp/gnus/ChangeLog
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/gnus/ChangeLog,v
retrieving revision 1.388
diff -u -r1.388 ChangeLog
--- lisp/gnus/ChangeLog 4 Oct 2005 22:51:06 -0000 1.388
+++ lisp/gnus/ChangeLog 6 Oct 2005 09:00:20 -0000
@@ -1,3 +1,15 @@
+2005-10-06 Sascha Wilde <[EMAIL PROTECTED]>
+
+ * pgg-gpg.el (pgg-gpg-encrypt-symmetric-region): New function for
+ symmetric encryption.
+ (pgg-gpg-symmetric-key-p): New function to check for an symmetric
+ encrypted session key.
+ (pgg-gpg-decrypt-region): When decrypting a symmetric encrypted
+ message ask for the passphrase in a proper way.
+
+ * pgg.el (pgg-encrypt-symmetric,pgg-encrypt-symmetric-region):
+ New user commands for symmetric encryption.
+
2005-10-04 Reiner Steib <[EMAIL PROTECTED]>
* mm-url.el (mm-url-predefined-programs): Add switches for curl.
pgpDVQPVxlasL.pgp
Description: PGP signature
_______________________________________________ Emacs-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/emacs-devel
