From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.devel Subject: Re: [feature request] epa-file-cache-passphrase-for-symmetric-encryption timeout. Date: Tue, 25 Nov 2008 14:56:23 -0600 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <86skpfbk3s.fsf@jumptrading.com> References: <87ej1522mb.fsf@sina.com> <861vx4x6rh.fsf@lifelogs.com> <87prkofxtf.fsf@sina.com> <867i6rd80c.fsf@lifelogs.com> <030e0451-0fd1-4e9d-a4a0-686d6798f9a3@broken.deisui.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1227646701 6307 80.91.229.12 (25 Nov 2008 20:58:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Nov 2008 20:58:21 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 25 21:59:24 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L54zh-00073z-CQ for ged-emacs-devel@m.gmane.org; Tue, 25 Nov 2008 21:58:49 +0100 Original-Received: from localhost ([127.0.0.1]:33825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L54yY-0006pX-0u for ged-emacs-devel@m.gmane.org; Tue, 25 Nov 2008 15:57:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L54yT-0006oF-7k for emacs-devel@gnu.org; Tue, 25 Nov 2008 15:57:33 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L54yS-0006nH-9s for emacs-devel@gnu.org; Tue, 25 Nov 2008 15:57:32 -0500 Original-Received: from [199.232.76.173] (port=38010 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L54yS-0006mu-3A for emacs-devel@gnu.org; Tue, 25 Nov 2008 15:57:32 -0500 Original-Received: from main.gmane.org ([80.91.229.2]:41140 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L54yR-0007KG-FG for emacs-devel@gnu.org; Tue, 25 Nov 2008 15:57:31 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1L54yN-0007jQ-T2 for emacs-devel@gnu.org; Tue, 25 Nov 2008 20:57:27 +0000 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 Nov 2008 20:57:27 +0000 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 Nov 2008 20:57:27 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 106 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6; d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:D0bGMXL4V+oVnGlmJ9PSfxwGCq4= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) 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:106168 Archived-At: On Wed, 26 Nov 2008 03:43:56 +0900 Daiki Ueno wrote: >>>>>> In <867i6rd80c.fsf@lifelogs.com> >>>>>> Ted Zlatanov wrote: >> On Sat, 22 Nov 2008 07:45:16 +0800 anhnmncb wrote: a> symmetric file encryption is enough for me :) >> ping... If Daiki Ueno is not interested I can implement this, but I >> wanted to give him a chance to do it since his coding style is pretty >> different from mine. DU> If you do want to implement this, you should consider: DU> - At the moment I'd rather recommend users to use public-key encryption DU> instead of symmetric encryption if they want passphrase caching, since DU> they will benefit from gpg-agent which utilizes secure memory. So it's DU> intensional that epa-file handles symmetric case specially. I see. DU> - As I said many times before (but you don't seem to understand), DU> epa-file.el is an application and epg.el is a library. Thank you for explaining again. My proposed patch follows. I've tested it. Ted Index: epa-file.el =================================================================== RCS file: /sources/emacs/emacs/lisp/epa-file.el,v retrieving revision 1.14 diff -c -r1.14 epa-file.el *** epa-file.el 30 Sep 2008 07:41:52 -0000 1.14 --- epa-file.el 25 Nov 2008 20:52:44 -0000 *************** *** 29,40 **** --- 29,46 ---- :type 'boolean :group 'epa-file) + (defcustom epa-file-cache-passphrase-for-symmetric-encryption-timeout nil + "If non-nil seconds, time out the passphrase cache for symmetric encryption." + :type 'integer + :group 'epa-file) + (defcustom epa-file-select-keys nil "If non-nil, always asks user to select recipients." :type 'boolean :group 'epa-file) (defvar epa-file-passphrase-alist nil) + (defvar epa-file-passphrase-timeout-alist nil) (eval-and-compile (if (fboundp 'encode-coding-string) *************** *** 51,58 **** (eq key-id 'SYM)) (progn (setq file (file-truename file)) ! (let ((entry (assoc file epa-file-passphrase-alist)) passphrase) (or (copy-sequence (cdr entry)) (progn (unless entry --- 57,81 ---- (eq key-id 'SYM)) (progn (setq file (file-truename file)) ! (let ((entry (assoc file epa-file-passphrase-alist)) passphrase) + ;; when we have an entry and we need to time out the passphrase, + ;; get the time of the passphrase entry for this file + ;; and if it's more than e-f-c-p-for-s-encryption-timeout seconds ago, + ;; set the entry's passphrase to nil so the user will have to re-enter + (when (and entry + epa-file-cache-passphrase-for-symmetric-encryption-timeout) + (let ((timeout-entry + (car-safe + (cdr (assoc file epa-file-passphrase-timeout-alist))))) + (when (and + timeout-entry + (< epa-file-cache-passphrase-for-symmetric-encryption-timeout + (time-to-seconds (time-since timeout-entry)))) + (setq epa-file-passphrase-timeout-alist + (delete file epa-file-passphrase-timeout-alist)) + (setcdr entry nil)))) + (or (copy-sequence (cdr entry)) (progn (unless entry *************** *** 63,68 **** --- 86,94 ---- (setq passphrase (epa-passphrase-callback-function context key-id nil)) (setcdr entry (copy-sequence passphrase)) + (setq epa-file-passphrase-timeout-alist + (cons (list file (current-time)) + epa-file-passphrase-timeout-alist)) passphrase)))) (epa-passphrase-callback-function context key-id nil)))