Function: epg-start-sign

epg-start-sign is a byte-compiled function defined in epg.el.gz.

Signature

(epg-start-sign CONTEXT PLAIN &optional MODE)

Documentation

Initiate a sign operation on PLAIN.

PLAIN is a data object.

If optional 3rd argument MODE is t or detached, it makes a detached signature. If it is nil or normal, it makes a normal signature. Otherwise, it makes a cleartext signature.

If you use this function, you will need to wait for the completion of epg-gpg-program by using epg-wait-for-completion and call epg-reset to clear a temporary output file. If you are unsure, use synchronous version of this function epg-sign-file or epg-sign-string instead.

Source Code

;; Defined in /usr/src/emacs/lisp/epg.el.gz
(defun epg-start-sign (context plain &optional mode)
  "Initiate a sign operation on PLAIN.
PLAIN is a data object.

If optional 3rd argument MODE is t or `detached', it makes a detached signature.
If it is nil or `normal', it makes a normal signature.
Otherwise, it makes a cleartext signature.

If you use this function, you will need to wait for the completion of
`epg-gpg-program' by using `epg-wait-for-completion' and call
`epg-reset' to clear a temporary output file.
If you are unsure, use synchronous version of this function
`epg-sign-file' or `epg-sign-string' instead."
  (setf (epg-context-operation context) 'sign)
  (setf (epg-context-result context) nil)
  (unless (memq mode '(t detached nil normal)) ;i.e. cleartext
    (setf (epg-context-armor context) nil)
    (setf (epg-context-textmode context) nil))
  (epg--start context
	     (append (list (if (memq mode '(t detached))
			       "--detach-sign"
			     (if (memq mode '(nil normal))
				 "--sign"
			       "--clearsign")))
		     (apply #'nconc
			    (mapcar
			     (lambda (signer)
			       (list "-u"
				     (epg-sub-key-id
				      (car (epg-key-sub-key-list signer)))))
			     (epg-context-signers context)))
                     (let ((sender (epg-context-sender context)))
                       (when (and (eql 'OpenPGP (epg-context-protocol context))
                                  (epg-required-version-p 'OpenPGP "2.1.15")
                                  (stringp sender))
                         (list "--sender" sender)))
		     (epg--args-from-sig-notations
		      (epg-context-sig-notations context))
		     (if (epg-data-file plain)
			 (list "--" (epg-data-file plain)))))
  ;; `gpgsm' does not read passphrase from stdin, so waiting is not needed.
  (unless (eq (epg-context-protocol context) 'CMS)
    (epg-wait-for-status context '("BEGIN_SIGNING")))
  (when (epg-data-string plain)
    (if (eq (process-status (epg-context-process context)) 'run)
	(process-send-string (epg-context-process context)
			     (epg-data-string plain)))
    (if (eq (process-status (epg-context-process context)) 'run)
	(process-send-eof (epg-context-process context)))))