From ce60785f8fddf91990da07513a2270fe6b34096d Mon Sep 17 00:00:00 2001 From: ueno Date: Thu, 20 Apr 2006 08:12:39 +0000 Subject: [PATCH] Fixed passphrase caching. --- pgg-epg.el | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/pgg-epg.el b/pgg-epg.el index a1705f5..39167da 100644 --- a/pgg-epg.el +++ b/pgg-epg.el @@ -32,21 +32,22 @@ (defun pgg-epg-passphrase-callback (key-id ignore) (if (eq key-id 'SYM) - (pgg-read-passphrase "GnuPG passphrase for symmetric encryption: ") - (let ((passphrase - (pgg-read-passphrase - (format "GnuPG passphrase for %s: " - (if entry - (cdr entry) - pgg-gpg-key-id)) - (if (eq pgg-gpg-key-id 'PIN) - "PIN" - pgg-gpg-key-id)))) + (epg-passphrase-callback-function key-id nil) + (let* ((entry (assoc key-id epg-user-id-alist)) + (passphrase + (pgg-read-passphrase + (format "GnuPG passphrase for %s: " + (if entry + (cdr entry) + key-id)) + (if (eq key-id 'PIN) + "PIN" + key-id)))) (when passphrase (pgg-add-passphrase-to-cache key-id passphrase) - (copy-sequence passphrase) (setq pgg-epg-secret-key-id-list - (cons key-id pgg-epg-secret-key-id-list)))))) + (cons key-id pgg-epg-secret-key-id-list)) + (copy-sequence passphrase))))) (defun pgg-epg-encrypt-region (start end recipients &optional sign passphrase) "This function is for internal use only. @@ -69,7 +70,8 @@ passphrase cache or user." (if pgg-encrypt-for-me (cons pgg-default-user-id recipients) recipients) - sign t)) + sign t) + pgg-epg-secret-key-id-list nil) (error (while pgg-epg-secret-key-id-list (pgg-remove-passphrase-from-cache (car pgg-epg-secret-key-id-list)) @@ -103,7 +105,8 @@ passphrase cache or user." (epg-context-set-textmode context pgg-text-mode) (epg-context-set-passphrase-callback context #'pgg-epg-passphrase-callback) (condition-case error - (setq plain (epg-decrypt-string context (buffer-substring start end))) + (setq plain (epg-decrypt-string context (buffer-substring start end)) + pgg-epg-secret-key-id-list nil) (error (while pgg-epg-secret-key-id-list (pgg-remove-passphrase-from-cache (car pgg-epg-secret-key-id-list)) @@ -133,7 +136,8 @@ passphrase cache or user." (buffer-substring start end) (if cleartext 'clearsign - 'detached))) + 'detached)) + pgg-epg-secret-key-id-list nil) (error (while pgg-epg-secret-key-id-list (pgg-remove-passphrase-from-cache (car pgg-epg-secret-key-id-list)) -- 1.7.10.4