From: ueno Date: Thu, 25 May 2006 05:50:28 +0000 (+0000) Subject: * epa.el (epa-verify-region): New command. X-Git-Tag: epg-0_0_2~38 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=2d3d6273c5f1646356f4dd08f428bb7dc67b92fa;p=elisp%2Fepg.git * epa.el (epa-verify-region): New command. --- diff --git a/ChangeLog b/ChangeLog index ad5496e..e0f1fce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * epa.el (epa-decrypt-file): Display verify result if the message is signed. (epa-decrypt-region): New command. + (epa-verify-region): New command. 2006-05-11 Daiki Ueno diff --git a/epa.el b/epa.el index b9524d7..6ebf0ac 100644 --- a/epa.el +++ b/epa.el @@ -625,7 +625,7 @@ If LOCAL is non-nil, the signature is marked as non exportable." (unless armor-end (error "No armor tail")) (goto-char armor-start) - (if (re-search-forward "^Charset: \\(.*\\)" nil t) + (if (re-search-forward "^Charset: \\(.*\\)" armor-end t) (setq charset (match-string 1))) (setq context (epg-make-context) plain (epg-decrypt-string @@ -644,6 +644,40 @@ If LOCAL is non-nil, the signature is marked as non exportable." (epg-verify-result-to-string (epg-context-result-for context 'verify))))))))) +;;;###autoload +(defun epa-verify-region (start end) + "Verify OpenPGP armors in the current region between START and END." + (interactive "r") + (save-excursion + (save-restriction + (narrow-to-region start end) + (goto-char start) + (let (armor-start armor-end context) + (while (re-search-forward "-----BEGIN PGP\\( SIGNED\\)? MESSAGE-----$" + nil t) + (setq armor-start (match-beginning 0)) + (if (match-beginning 1) ;cleartext signed message + (progn + (unless (re-search-forward "^-----BEGIN PGP SIGNATURE-----$" + nil t) + (error "Invalid cleartext signed message")) + (setq armor-end (re-search-forward + "^-----END PGP SIGNATURE-----$" + nil t))) + (setq armor-end (re-search-forward + "^-----END PGP MESSAGE-----$" + nil t))) + (unless armor-end + (error "No armor tail")) + (setq context (epg-make-context)) + (epg-verify-string context + (encode-coding-string + (buffer-substring armor-start armor-end) + coding-system-for-write)) + (message "%s" + (epg-verify-result-to-string + (epg-context-result-for context 'verify)))))))) + (provide 'epa) ;;; epa.el ends here