From 45630ca6c839719dfc92583de5e606abba4b5718 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 9 Dec 2020 13:17:06 +0100 Subject: [PATCH] Filter revoked keys when saving files * lisp/epa-file.el (epa-file-write-region): Use it to select a non-revoked key (bug#22359). * lisp/epg.el (epg--filter-revoked-keys): New function. --- lisp/epa-file.el | 3 ++- lisp/epg.el | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 7fd41784746..21dc1ebaff0 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -309,7 +309,8 @@ encryption is used." If no one is selected, symmetric encryption will be performed. " recipients) (if epa-file-encrypt-to - (epg-list-keys context recipients))))) + (epg--filter-revoked-keys + (epg-list-keys context recipients)))))) (error (epa-display-error context) (if (setq entry (assoc file epa-file-passphrase-alist)) diff --git a/lisp/epg.el b/lisp/epg.el index 920b85398f3..b27e2c638c2 100644 --- a/lisp/epg.el +++ b/lisp/epg.el @@ -1382,6 +1382,13 @@ NAME is either a string or a list of strings." (setq pointer (cdr pointer))) keys)) +(defun epg--filter-revoked-keys (keys) + (seq-remove (lambda (key) + (seq-find (lambda (user) + (eq (epg-user-id-validity user) 'revoked)) + (epg-key-user-id-list key))) + keys)) + (defun epg--args-from-sig-notations (notations) (apply #'nconc (mapcar -- 2.39.2