From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sascha Wilde Newsgroups: gmane.emacs.devel Subject: Re: pgg symmetric encryption patch Date: Wed, 5 Oct 2005 18:19:05 +0200 Message-ID: <20051005161905.GA6208@kenny.sha-bang.local> References: <2cd46e7f0509301024r71462d81v81ebd8e858f06305@mail.gmail.com> <20050930210649.GA22126@kenny.sha-bang.local> <2cd46e7f0509301452l72c262d6l89efd6fb772f61b2@mail.gmail.com> <2cd46e7f0510010928v8244052k2a98375e38fdd2ed@mail.gmail.com> <20051002104823.GA31722@kenny.sha-bang.local> <20051003192503.GA15503@kenny.sha-bang.local> <2cd46e7f0510031250u66ea1349yb437d539ce4027ef@mail.gmail.com> <20051004105330.GA5288@kenny.sha-bang.local> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0349464045==" X-Trace: sea.gmane.org 1128529336 14360 80.91.229.2 (5 Oct 2005 16:22:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 5 Oct 2005 16:22:16 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 05 18:22:09 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ENBzR-00023G-Nw for ged-emacs-devel@m.gmane.org; Wed, 05 Oct 2005 18:19:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ENBzQ-0004rb-HH for ged-emacs-devel@m.gmane.org; Wed, 05 Oct 2005 12:19:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ENBzD-0004qD-7h for emacs-devel@gnu.org; Wed, 05 Oct 2005 12:19:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ENBzB-0004os-AG for emacs-devel@gnu.org; Wed, 05 Oct 2005 12:19:18 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ENBzB-0004oa-57 for emacs-devel@gnu.org; Wed, 05 Oct 2005 12:19:17 -0400 Original-Received: from [62.141.58.119] (helo=km1136.keymachine.de) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1ENBz8-0008Db-CD; Wed, 05 Oct 2005 12:19:15 -0400 Original-Received: from kenny.sha-bang.de (xdslq158.osnanet.de [82.149.188.158]) (authenticated bits=0) by km1136.keymachine.de (8.12.11/8.12.10) with ESMTP id j95GJ2c1023366; Wed, 5 Oct 2005 18:19:02 +0200 Original-Received: from wilde by kenny.sha-bang.de with local (Kenny MUA v.0409034.42) ID 1ENByz-0000qq-Kl; Wed, 05 Oct 2005 18:19:05 +0200 Original-To: Ken Manheimer , "Richard M. Stallman" , schwab@suse.de, emacs-devel@gnu.org, ueno@unixuser.org Mail-Followup-To: Ken Manheimer , "Richard M. Stallman" , schwab@suse.de, emacs-devel@gnu.org, ueno@unixuser.org In-Reply-To: <20051004105330.GA5288@kenny.sha-bang.local> User-Agent: Mutt/1.5.9i X-wieners-gbr-MailScanner-Information: MailScanner presented by www.wieners-gbr.de X-wieners-gbr-MailScanner: Nachricht wurde nicht auf Viren und Spam untersucht, sprechen Sie uns an: www.wieners-gbr.de. X-MailScanner-From: wilde@sha-bang.de X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:43576 Archived-At: --===============0349464045== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mxv5cy4qt+RJ9ypb" Content-Disposition: inline --mxv5cy4qt+RJ9ypb Content-Type: multipart/mixed; boundary="wRRV7LY7NUeQGEoC" Content-Disposition: inline --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 04, 2005 at 12:53:30PM +0200, Sascha Wilde wrote: > I'll try to find the time to make this a proper feature of pgg. (I > also added the original author to the cc, so he might add his > thoughts) I attached a more complete patch, including documentation and changelog entries. Any comments, bug-fixes, flames are highly appreciated. cheers sascha ps. I have no write access to CVS, so if there are no objections, please commit. --=20 Sascha Wilde "Liebet eure Feinde, vielleicht schadet das ihrem Ruf"=20 (Stanislaw Jerzy Lec) --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="emacs-pgg-symmetric.patch-02" Content-Transfer-Encoding: quoted-printable Index: man/pgg.texi =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 5 Oct 2005 16:09: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 =20 +@deffn 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. +@end 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,10 @@ @var{recipients}. If @var{sign} is non-@code{nil}, do a combined sign and encrypt. If encryption is successful, it returns @code{t}, otherwise @code{nil}. + +If @var{recipients} equals @code{:symmetric} a symmetric cipher together +with a passphrase is used and @var{sign} is ignored. This feature is +currently only implemented for GnuPG. @end deffn =20 @deffn Method pgg-scheme-decrypt-region scheme start end Index: man/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 5 Oct 2005 16:09:16 -0000 @@ -1,3 +1,11 @@ +2005-10-05 Sascha Wilde + + * 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 symmetric encryption feature in + `pgg-scheme-encrypt-region'. + 2005-10-05 Nick Roberts =20 * speedbar.texi (GDB): Describe use of watch expressions. Index: lisp/gnus/pgg.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 5 Oct 2005 16:09:17 -0000 @@ -4,6 +4,7 @@ ;; 2005 Free Software Foundation, Inc. =20 ;; Author: Daiki Ueno +;; Symmetric encryption added by: Sascha Wilde ;; Created: 1999/10/28 ;; Keywords: PGP =20 @@ -232,6 +233,34 @@ (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 passphr= ase." + (interactive "r") + (when (not (member (or pgg-scheme pgg-default-scheme) + pgg-symmetric-encryption-schemes)) + (error "Symmetric encryption is not implemented for selected scheme.")) + (let ((status + (pgg-save-coding-system start end + (pgg-invoke "encrypt-region" (or pgg-scheme pgg-default-scheme) + (point-min) (point-max) :symmetric)))) + (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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 5 Oct 2005 16:09:17 -0000 @@ -4,6 +4,7 @@ ;; 2005 Free Software Foundation, Inc. =20 ;; Author: Daiki Ueno +;; Symmetric encryption added by: Sascha Wilde ;; Created: 1999/10/28 ;; Keywords: PGP, OpenPGP, GnuPG =20 @@ -141,24 +142,32 @@ =20 (defun pgg-gpg-encrypt-region (start end recipients &optional sign) "Encrypt the current region between START and END. +If recipients is :symmetric do symmetric encryption If optional argument SIGN is non-nil, do a combined sign and encrypt." (let* ((pgg-gpg-user-id (or pgg-gpg-user-id pgg-default-user-id)) + (symmetric-encryption (eq recipients :symmetric)) (passphrase - (when sign - (pgg-read-passphrase - (format "GnuPG passphrase for %s: " pgg-gpg-user-id) - pgg-gpg-user-id))) + (if symmetric-encryption + (pgg-read-passphrase + "GnuPG passphrase for symmetric encryption: ") + (when sign + (pgg-read-passphrase + (format "GnuPG passphrase for %s: " pgg-gpg-user-id) + pgg-gpg-user-id)))) (args (append - (list "--batch" "--armor" "--always-trust" "--encrypt") + (list "--batch" "--armor" "--always-trust"=20 + (if symmetric-encryption "--symmetric" "--encrypt")) (if sign (list "--sign" "--local-user" pgg-gpg-user-id)) - (if recipients - (apply #'nconc - (mapcar (lambda (rcpt) - (list pgg-gpg-recipient-argument rcpt)) - (append recipients - (if pgg-encrypt-for-me - (list pgg-gpg-user-id))))))))) + (if symmetric-encryption + nil + (if recipients + (apply #'nconc + (mapcar (lambda (rcpt) + (list pgg-gpg-recipient-argument rcpt)) + (append recipients + (if pgg-encrypt-for-me + (list pgg-gpg-user-id)))))))))) (pgg-as-lbt start end 'CRLF (pgg-gpg-process-region start end passphrase pgg-gpg-program args)) (when sign @@ -180,7 +189,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 +200,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)))) =20 (defun pgg-gpg-select-matching-key (message-keys secret-keys) "Choose a key from MESSAGE-KEYS that matches one of the keys in SECRET-K= EYS." Index: lisp/gnus/pgg-def.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/emacs/emacs/lisp/gnus/pgg-def.el,v retrieving revision 1.7 diff -u -r1.7 pgg-def.el --- lisp/gnus/pgg-def.el 6 Aug 2005 19:51:42 -0000 1.7 +++ lisp/gnus/pgg-def.el 5 Oct 2005 16:09:17 -0000 @@ -3,6 +3,7 @@ ;; Copyright (C) 1999, 2002, 2003, 2004, 2005 Free Software Foundation, In= c. =20 ;; Author: Daiki Ueno +;; Symmetric encryption added by: Sascha Wilde ;; Created: 1999/11/02 ;; Keywords: PGP, OpenPGP, GnuPG =20 @@ -83,6 +84,9 @@ =20 (defvar pgg-scheme nil "Current scheme of PGP implementation.") + +(defconst pgg-symmetric-encryption-schemes '(gpg) + "Schemes of PGP implementation for which symmetric encrypt is implemente= d.") =20 (defmacro pgg-truncate-key-identifier (key) `(if (> (length ,key) 8) (substring ,key 8) ,key)) Index: lisp/gnus/ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 5 Oct 2005 16:09:19 -0000 @@ -1,3 +1,15 @@ +2005-10-05 Sascha Wilde + + * pgg-def.el (pgg-symmetric-encryption-schemes): List of schemes + with symmetric encryption support. + + * pgg-gpg.el (pgg-gpg-encrypt-region): Added symmetric encryption. + (pgg-gpg-symmetric-key-p): New function to check for an symmetric + encrypted session key. + + * pgg.el (pgg-encrypt-symmetric,pgg-encrypt-symmetric-region): + New user commands for symmetric encryption. + 2005-10-04 Reiner Steib =20 * mm-url.el (mm-url-predefined-programs): Add switches for curl. --wRRV7LY7NUeQGEoC-- --mxv5cy4qt+RJ9ypb Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFDQ/z5chutvmkRUCQRAtYpAJ4u+gOOf4qMKA2WF8gZr8FzGh+bzQCfe8t3 +2ZNa9gQcO1qn33P+WnITow= =w7I0 -----END PGP SIGNATURE----- --mxv5cy4qt+RJ9ypb-- --===============0349464045== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0349464045==--