From: ueno Date: Wed, 12 Apr 2006 09:26:23 +0000 (+0000) Subject: * pgg-epg.el (mml2015-gpg-extract-signature-details): New function. X-Git-Tag: epgsm-branchpoint~110 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=aadfc08d6febfbc9942e38fca8dc8d6608946a19;p=elisp%2Fepg.git * pgg-epg.el (mml2015-gpg-extract-signature-details): New function. * epg.el (epg-signature-fingerprint): New function. (epg-signature-set-fingerprint): New function. (epg-status-VALIDSIG): New function. --- diff --git a/epg.el b/epg.el index 662ffe9..aee0542 100644 --- a/epg.el +++ b/epg.el @@ -153,7 +153,7 @@ This function is for internal use only." (defun epg-make-signature (status key-id user-id) "Return a signature object." - (vector status key-id user-id nil)) + (vector status key-id user-id nil nil)) (defun epg-signature-status (signature) "Return the status code of SIGNATURE." @@ -171,6 +171,10 @@ This function is for internal use only." "Return the validity of SIGNATURE." (aref signature 3)) +(defun epg-signature-fingerprint (signature) + "Return the fingerprint of SIGNATURE." + (aref signature 4)) + (defun epg-signature-set-status (signature status) "Set the status code of SIGNATURE." (aset signature 0 status)) @@ -187,6 +191,10 @@ This function is for internal use only." "Set the validity of SIGNATURE." (aset signature 3 validity)) +(defun epg-signature-set-fingerprint (signature fingerprint) + "Set the fingerprint of SIGNATURE." + (aset signature 4 fingerprint)) + (defun epg-context-result-for (context name) (cdr (assq name (epg-context-result context)))) @@ -378,11 +386,18 @@ This function is for internal use only." (match-string 2 string)) (epg-context-result-for epg-context 'verify))))) +(defun epg-status-VALIDSIG (process string) + (let ((signature (car (epg-context-result-for epg-context 'verify)))) + (if (and signature + (eq (epg-signature-status signature) 'good) + (string-match "\\`\\([^ ]+\\) " string)) + (epg-signature-set-fingerprint signature (match-string 1 string))))) + (defun epg-status-TRUST_UNDEFINED (process string) (let ((signature (car (epg-context-result-for epg-context 'verify)))) (if (and signature (eq (epg-signature-status signature) 'good)) - (epg-signature-set-validity signature 'unknown)))) + (epg-signature-set-validity signature 'undefined)))) (defun epg-status-TRUST_NEVER (process string) (let ((signature (car (epg-context-result-for epg-context 'verify)))) @@ -400,13 +415,13 @@ This function is for internal use only." (let ((signature (car (epg-context-result-for epg-context 'verify)))) (if (and signature (eq (epg-signature-status signature) 'good)) - (epg-signature-set-validity signature 'full)))) + (epg-signature-set-validity signature 'fully)))) (defun epg-status-TRUST_ULTIMATE (process string) (let ((signature (car (epg-context-result-for epg-context 'verify)))) (if (and signature (eq (epg-signature-status signature) 'good)) - (epg-signature-set-validity signature 'full)))) + (epg-signature-set-validity signature 'ultimate)))) (defun epg-status-PROGRESS (process string) (if (string-match "\\`\\([^ ]+\\) \\([^ ]\\) \\([0-9]+\\) \\([0-9]+\\)" diff --git a/pgg-epg.el b/pgg-epg.el index 0b12bec..23aced9 100644 --- a/pgg-epg.el +++ b/pgg-epg.el @@ -72,6 +72,8 @@ passphrase cache or user." (insert signature)) t)) +(defvar pgg-epg-signature nil) + (defun pgg-epg-verify-region (start end &optional signature) "This function is for internal use only. @@ -87,6 +89,8 @@ Verify region between START and END as the detached signature SIGNATURE." pointer signature) (save-excursion (set-buffer (get-buffer-create pgg-errors-buffer)) + (make-local-variable 'pgg-epg-signature) + (setq pgg-epg-signature (car signature)) (erase-buffer) (while pointer (insert (format "%s: %s %s %s\n" @@ -117,6 +121,28 @@ Add all public keys in region between START and END to the keyring." (epg-context-set-textmode context pgg-text-mode) (epg-import-keys context (buffer-substring start end)))) +(defun mml2015-gpg-extract-signature-details () + (if pgg-epg-signature + (let* ((expired (eq (epg-signature-status pgg-epg-signature) + 'key-expired)) + (signer (cons (epg-signature-key-id pgg-epg-signature) + (epg-signature-user-id pgg-epg-signature))) + (fprint (epg-signature-fingerprint pgg-epg-signature)) + (trust-good-enough-p + (memq (epg-signature-validity pgg-epg-signature) + '(marginal fully ultimate)))) + (cond ((and signer fprint) + (concat (cdr signer) + (unless trust-good-enough-p + (concat "\nUntrusted, Fingerprint: " + (mml2015-gpg-pretty-print-fpr fprint))) + (when expired + (format "\nWARNING: Signature from expired key (%s)" + (car signer))))) + (t + "From unknown user"))) + "From unknown user")) + (provide 'pgg-epg) ;;; pgg-epg.el ends here