From: ueno Date: Tue, 2 May 2006 02:04:50 +0000 (+0000) Subject: * epg.el (epg-make-key-signature): New object epg-key-signature. X-Git-Tag: epg-0_0_2~46 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=7f8578896d342f9a51ea38d5e89b6b744c5c06e3;p=elisp%2Fepg.git * epg.el (epg-make-key-signature): New object epg-key-signature. (epg-list-keys): Collect key signatures. --- diff --git a/ChangeLog b/ChangeLog index bbcdb7b..40deb56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-05-02 Daiki Ueno + + * epg.el (epg-make-key-signature): New object epg-key-signature. + (epg-list-keys): Collect key signatures. + 2006-05-01 Daiki Ueno * epg.el (epg-invalid-recipients-reason-alist): Renamed. diff --git a/epg.el b/epg.el index 2fc07de..cde76ad 100644 --- a/epg.el +++ b/epg.el @@ -652,6 +652,62 @@ This function is for internal use only." (signal 'wrong-type-argument (list 'epg-user-id-p user-id))) (aset (cdr user-id) 2 signature-list)) +(defun epg-make-key-signature (validity pubkey-algorithm key-id creation-time + expiration-time user-id class + exportable-p) + "Return a key signature object." + (cons 'epg-key-signature + (vector validity pubkey-algorithm key-id creation-time expiration-time + user-id class exportable-p))) + +(defun epg-key-signature-validity (key-signature) + "Return the validity of KEY-SIGNATURE." + (unless (eq (car key-signature) 'epg-key-signature) + (signal 'wrong-type-argument (list 'epg-key-signature-p key-signature))) + (aref (cdr key-signature) 0)) + +(defun epg-key-signature-pubkey-algorithm (key-signature) + "Return the public key algorithm of KEY-SIGNATURE." + (unless (eq (car key-signature) 'epg-key-signature) + (signal 'wrong-type-argument (list 'epg-key-signature-p key-signature))) + (aref (cdr key-signature) 1)) + +(defun epg-key-signature-key-id (key-signature) + "Return the key-id of KEY-SIGNATURE." + (unless (eq (car key-signature) 'epg-key-signature) + (signal 'wrong-type-argument (list 'epg-key-signature-p key-signature))) + (aref (cdr key-signature) 2)) + +(defun epg-key-signature-creation-time (key-signature) + "Return the creation time of KEY-SIGNATURE." + (unless (eq (car key-signature) 'epg-key-signature) + (signal 'wrong-type-argument (list 'epg-key-signature-p key-signature))) + (aref (cdr key-signature) 3)) + +(defun epg-key-signature-expiration-time (key-signature) + "Return the expiration time of KEY-SIGNATURE." + (unless (eq (car key-signature) 'epg-key-signature) + (signal 'wrong-type-argument (list 'epg-key-signature-p key-signature))) + (aref (cdr key-signature) 4)) + +(defun epg-key-signature-user-id (key-signature) + "Return the user-id of KEY-SIGNATURE." + (unless (eq (car key-signature) 'epg-key-signature) + (signal 'wrong-type-argument (list 'epg-key-signature-p key-signature))) + (aref (cdr key-signature) 5)) + +(defun epg-key-signature-class (key-signature) + "Return the class of KEY-SIGNATURE." + (unless (eq (car key-signature) 'epg-key-signature) + (signal 'wrong-type-argument (list 'epg-key-signature-p key-signature))) + (aref (cdr key-signature) 6)) + +(defun epg-key-signature-exportable-p (key-signature) + "Return t if KEY-SIGNATURE is exportable." + (unless (eq (car key-signature) 'epg-key-signature) + (signal 'wrong-type-argument (list 'epg-key-signature-p key-signature))) + (aref (cdr key-signature) 7)) + (defun epg-context-result-for (context name) "Return the result of CONTEXT associated with NAME." (cdr (assq name (epg-context-result context)))) @@ -1240,9 +1296,9 @@ This function is for internal use only." "--with-fingerprint" (if (memq mode '(t secret)) "--list-secret-keys" - (if mode - "--list-sigs" - "--list-keys"))) + (if (memq mode '(nil public)) + "--list-keys" + "--list-sigs"))) (unless (eq (epg-context-protocol context) 'CMS) '("--fixed-list-mode")) (if name (list name)))) @@ -1298,9 +1354,10 @@ This function is for internal use only." (setq epg-user-id-alist (cons (cons key-id user-id-string) epg-user-id-alist))))) +;;;###autoload (defun epg-list-keys (context &optional name mode) "Return a list of epg-key objects matched with NAME. -If MODE is nil, only public keyring should be searched. +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." @@ -1341,7 +1398,24 @@ signatures should be included." (epg-key-user-id-list (car keys))))) ((equal (aref (car lines) 0) "fpr") (epg-sub-key-set-fingerprint (car (epg-key-sub-key-list (car keys))) - (aref (car lines) 9)))) + (aref (car lines) 9))) + ((equal (aref (car lines) 0) "sig") + (epg-user-id-set-signature-list + (car (epg-key-user-id-list (car keys))) + (cons + (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) + (aref (car lines) 5) + (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))) (if (car keys) (epg-list-keys-postprocess-one-key (car keys)))