Function: epg-list-keys
epg-list-keys is a byte-compiled function defined in epg.el.gz.
Signature
(epg-list-keys CONTEXT &optional NAME MODE)
Documentation
Return a list of epg-key objects matched with NAME.
If MODE is nil or public, only public keyring should be searched.
If MODE is t or secret, only secret keyring should be searched.
Otherwise, only public keyring should be searched and the key
signatures should be included.
NAME is either a string or a list of strings.
Source Code
;; Defined in /usr/src/emacs/lisp/epg.el.gz
;;; Public Functions
(defun epg-list-keys (context &optional name mode)
"Return a list of epg-key objects matched with NAME.
If MODE is nil or `public', only public keyring should be searched.
If MODE is t or `secret', only secret keyring should be searched.
Otherwise, only public keyring should be searched and the key
signatures should be included.
NAME is either a string or a list of strings."
(let ((lines (epg--list-keys-1 context name mode))
keys cert pointer pointer-1 index string)
(while lines
(cond
((member (aref (car lines) 0) '("pub" "sec" "crt" "crs"))
(setq cert (member (aref (car lines) 0) '("crt" "crs"))
keys (cons (epg-make-key
(if (aref (car lines) 8)
(cdr (assq (string-to-char (aref (car lines) 8))
epg-key-validity-alist))))
keys))
(push (epg--make-sub-key-1 (car lines))
(epg-key-sub-key-list (car keys))))
((member (aref (car lines) 0) '("sub" "ssb"))
(push (epg--make-sub-key-1 (car lines))
(epg-key-sub-key-list (car keys))))
((equal (aref (car lines) 0) "uid")
;; Decode the UID name as a backslash escaped UTF-8 string,
;; generated by GnuPG/GpgSM.
(setq string (copy-sequence (aref (car lines) 9))
index 0)
(while (string-match "\"" string index)
(setq string (replace-match "\\\"" t t string)
index (1+ (match-end 0))))
(condition-case nil
(setq string (decode-coding-string
(car (read-from-string (concat "\"" string "\"")))
'utf-8))
(error
(setq string (aref (car lines) 9))))
(push (epg-make-user-id
(if (aref (car lines) 1)
(cdr (assq (string-to-char (aref (car lines) 1))
epg-key-validity-alist)))
(if cert
(condition-case nil
(epg-dn-from-string string)
(error string))
string))
(epg-key-user-id-list (car keys))))
((equal (aref (car lines) 0) "fpr")
(setf (epg-sub-key-fingerprint (car (epg-key-sub-key-list (car keys))))
(aref (car lines) 9)))
((equal (aref (car lines) 0) "sig")
(push
(epg-make-key-signature
(if (aref (car lines) 1)
(cdr (assq (string-to-char (aref (car lines) 1))
epg-key-validity-alist)))
(string-to-number (aref (car lines) 3))
(aref (car lines) 4)
(epg--time-from-seconds (aref (car lines) 5))
(epg--time-from-seconds (aref (car lines) 6))
(aref (car lines) 9)
(string-to-number (aref (car lines) 10) 16)
(eq (aref (aref (car lines) 10) 2) ?x))
(epg-user-id-signature-list
(car (epg-key-user-id-list (car keys)))))))
(setq lines (cdr lines)))
(setq keys (nreverse keys)
pointer keys)
(while pointer
(cl-callf nreverse (epg-key-sub-key-list (car pointer)))
(setq pointer-1 (cl-callf nreverse (epg-key-user-id-list (car pointer))))
(while pointer-1
(cl-callf nreverse (epg-user-id-signature-list (car pointer-1)))
(setq pointer-1 (cdr pointer-1)))
(setq pointer (cdr pointer)))
keys))