X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=pgg-epg.el;h=bc093bbadcf048d8e32d9ff3d4062bb66cab32cf;hb=a2a5804f19009b4e01acfe3ca481feaa2266cb6d;hp=23aced95b32ab23fac6b5592649f495bfc3e7915;hpb=aadfc08d6febfbc9942e38fca8dc8d6608946a19;p=elisp%2Fepg.git diff --git a/pgg-epg.el b/pgg-epg.el index 23aced9..bc093bb 100644 --- a/pgg-epg.el +++ b/pgg-epg.el @@ -1,3 +1,30 @@ +;;; pgg-epg.el --- Gnus/PGG backend of EasyPG. +;; Copyright (C) 1999, 2000, 2002, 2003, 2004, +;; 2005, 2006 Free Software Foundation, Inc. +;; Copyright (C) 2006 Daiki Ueno + +;; Author: Daiki Ueno +;; Keywords: PGP, GnuPG + +;; This file is part of EasyPG. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 2, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Code: + (require 'epg) (eval-when-compile (require 'pgg)) @@ -65,41 +92,37 @@ passphrase cache or user." (epg-context-set-textmode context pgg-text-mode) (setq signature (epg-sign-string context (buffer-substring start end) (if cleartext - 'cleartext + 'clearsign 'detached))) (save-excursion (set-buffer (get-buffer-create pgg-output-buffer)) + (erase-buffer) (insert signature)) t)) -(defvar pgg-epg-signature nil) +(defvar pgg-epg-signatures nil) (defun pgg-epg-verify-region (start end &optional signature) "This function is for internal use only. Verify region between START and END as the detached signature SIGNATURE." - (let ((context (epg-make-context)) - pointer) + (let ((context (epg-make-context))) (epg-context-set-armor context t) (epg-context-set-textmode context pgg-text-mode) (if signature - (epg-verify-file context signature (buffer-substring start end)) + (epg-verify-string context + (with-temp-buffer + (insert-file-contents signature) + (buffer-string)) + (buffer-substring start end)) (epg-verify-string context (buffer-substring start end))) - (setq signature (reverse (epg-context-result-for context 'verify)) - pointer signature) (save-excursion (set-buffer (get-buffer-create pgg-errors-buffer)) - (make-local-variable 'pgg-epg-signature) - (setq pgg-epg-signature (car signature)) + (make-local-variable 'pgg-epg-signatures) + (setq pgg-epg-signatures (epg-context-result-for context 'verify)) (erase-buffer) - (while pointer - (insert (format "%s: %s %s %s\n" - (epg-signature-status (car pointer)) - (epg-signature-key-id (car pointer)) - (epg-signature-user-id (car pointer)) - (epg-signature-validity (car pointer)))) - (setq pointer (cdr pointer)))) - signature)) + (insert (epg-verify-result-to-string pgg-epg-signatures))) + t)) (defun pgg-epg-insert-key () "This function is for internal use only.