Function: epg-verify-string

epg-verify-string is a byte-compiled function defined in epg.el.gz.

Signature

(epg-verify-string CONTEXT SIGNATURE &optional SIGNED-TEXT)

Documentation

Verify a string SIGNATURE.

SIGNED-TEXT is a string if it is specified.

For a detached signature, both SIGNATURE and SIGNED-TEXT should be string. For a normal or a cleartext signature, SIGNED-TEXT should be nil. In the latter case, this function returns the plaintext after successful verification.

Note that this function does not return verification result as t or nil, nor signal error on failure. That's a design decision to handle the case where SIGNATURE has multiple signature.

To check the verification results, use epg-context-result-for as follows:

(epg-context-result-for context 'verify)

which will return a list of epg-signature object.

Source Code

;; Defined in /usr/src/emacs/lisp/epg.el.gz
(defun epg-verify-string (context signature &optional signed-text)
  "Verify a string SIGNATURE.
SIGNED-TEXT is a string if it is specified.

For a detached signature, both SIGNATURE and SIGNED-TEXT should be
string.  For a normal or a cleartext signature, SIGNED-TEXT should be
nil.  In the latter case, this function returns the plaintext after
successful verification.

Note that this function does not return verification result as t
or nil, nor signal error on failure.  That's a design decision to
handle the case where SIGNATURE has multiple signature.

To check the verification results, use `epg-context-result-for' as follows:

\(epg-context-result-for context \\='verify)

which will return a list of `epg-signature' object."
  (let ((coding-system-for-write 'binary)
	input-file)
    (unwind-protect
	(progn
	  (setf (epg-context-output-file context)
                (make-temp-file "epg-output"))
	  (if signed-text
	      (progn
		(setq input-file (make-temp-file "epg-signature"))
		(write-region signature nil input-file nil 'quiet)
		(epg-start-verify context
				  (epg-make-data-from-file input-file)
				  (epg-make-data-from-string signed-text)))
	    (epg-start-verify context (epg-make-data-from-string signature)))
	  (epg-wait-for-completion context)
	  (epg-read-output context))
      (epg-delete-output-file context)
      (if (and input-file
	       (file-exists-p input-file))
	  (delete-file input-file))
      (epg-reset context))))