2000-11-16 Simon Josefsson <sj@extundo.com>
authorSimon Josefsson <jas@extundo.com>
Sat, 18 Nov 2000 20:57:13 +0000 (20:57 +0000)
committerSimon Josefsson <jas@extundo.com>
Sat, 18 Nov 2000 20:57:13 +0000 (20:57 +0000)
* gpg.el (gpg-command-verify-cleartext): New variable.
(gpg-verify-cleartext): New function.

contrib/ChangeLog [new file with mode: 0644]
contrib/gpg.el

diff --git a/contrib/ChangeLog b/contrib/ChangeLog
new file mode 100644 (file)
index 0000000..b5b3458
--- /dev/null
@@ -0,0 +1,4 @@
+2000-11-16  Simon Josefsson  <sj@extundo.com>
+
+       * gpg.el (gpg-command-verify-cleartext): New variable.
+       (gpg-verify-cleartext): New function.
index c7b5763..8f55f32 100644 (file)
@@ -7,7 +7,7 @@
 ;; Keywords: crypto
 ;; Created: 2000-04-15
 
-;; $Id: gpg.el,v 6.2 2000/10/31 22:16:42 zsh Exp $
+;; $Id: gpg.el,v 1.1 2000/11/04 12:22:17 zsh Exp $
 
 ;; This file is NOT (yet?) part of GNU Emacs.
 
@@ -304,6 +304,25 @@ charsets or line endings; the input data shall be treated as binary."
            (string :format "%v"))))
   :group 'gpg-commands)
 
+(defcustom gpg-command-verify-cleartext
+  '(gpg . ("--batch" "--verbose" "--verify" message-file))
+  "Command to verify a message.
+The invoked program has to read the signed message from the given
+file.  It should write human-readable information to standard output
+and/or standard error.  The program shall not convert charsets or line
+endings; the input data shall be treated as binary."
+  :tag "Cleartext Verify Command"
+  :type '(cons 
+         gpg-command-program
+         (repeat 
+          :tag "Arguments"
+          (choice 
+           :format "%[Type%] %v"
+           (const :tag "Insert name of file containing the message here." 
+                  :value message-file)
+           (string :format "%v"))))
+  :group 'gpg-commands)
+
 (defcustom gpg-command-decrypt
   '(gpg . ("--decrypt" "--batch" "--passphrase-fd=0"))
   "Command to decrypt a message.
@@ -821,6 +840,39 @@ buffer RESULT for details."
            nil)
        t))))
 
+;;;###autoload
+(defun gpg-verify-cleartext (message result)
+  "Verify message in buffer MESSAGE.
+Returns t if everything worked out well, nil otherwise.  Consult
+buffer RESULT for details.
+
+NOTE: Use of this function is deprecated."
+  (interactive "bBuffer containing message: \nbBuffor for result: ")
+  (gpg-with-temp-files 1
+    (let* ((msg-file    (nth 0 gpg-temp-files))
+          (cmd (gpg-exec-path gpg-command-verify-cleartext))
+          (args (gpg-build-arg-list (cdr gpg-command-verify-cleartext)
+                                    `((message-file . ,msg-file))))
+          res)
+      (with-temp-file msg-file 
+       (buffer-disable-undo)
+       (apply 'insert-buffer-substring (if (listp message)
+                                           message
+                                         (list message))))
+      (setq res (apply 'call-process-region
+                      (point-min) (point-min) ; no data
+                      cmd
+                      nil              ; don't delete
+                      result
+                      nil              ; don't display
+                      args))
+      (if (or (stringp res) (> res 0))
+         ;; Signal or abnormal exit.
+         (with-current-buffer result
+           (insert (format "\nCommand exit status: %s\n" res))
+           nil)
+       t))))
+
 ;;;###autoload
 (defun gpg-decrypt (ciphertext plaintext result &optional passphrase)
   "Decrypt buffer CIPHERTEXT to buffer PLAINTEXT.