+(defun mml2015-epg-check-user-id (key recipient)
+ (let ((pointer (epg-key-user-id-list key))
+ result)
+ (while pointer
+ (if (and (equal (car (mail-header-parse-address
+ (epg-user-id-string (car pointer))))
+ (car (mail-header-parse-address
+ recipient)))
+ (not (memq (epg-user-id-validity (car pointer))
+ '(revoked expired))))
+ (setq result t
+ pointer nil)
+ (setq pointer (cdr pointer))))
+ result))
+
+(defun mml2015-epg-check-sub-key (key usage)
+ (let ((pointer (epg-key-sub-key-list key))
+ result)
+ ;; The primary key will be marked as disabled, when the entire
+ ;; key is disabled (see 12 Field, Format of colon listings, in
+ ;; gnupg/doc/DETAILS)
+ (unless (memq 'disabled (epg-sub-key-capability (car pointer)))
+ (while pointer
+ (if (and (memq usage (epg-sub-key-capability (car pointer)))
+ (not (memq (epg-sub-key-validity (car pointer))
+ '(revoked expired))))
+ (setq result t
+ pointer nil)
+ (setq pointer (cdr pointer)))))
+ result))
+
+(defun mml2015-epg-find-usable-key (context name usage
+ &optional name-is-key-id)
+ (let ((keys (epg-list-keys context name))
+ key)