Function: epg-start-encrypt

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

Signature

(epg-start-encrypt CONTEXT PLAIN RECIPIENTS &optional SIGN ALWAYS-TRUST)

Documentation

Initiate an encrypt operation on PLAIN.

PLAIN is a data object. If RECIPIENTS is nil, it performs symmetric encryption.

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-encrypt-file or epg-encrypt-string instead.

Source Code

;; Defined in /usr/src/emacs/lisp/epg.el.gz
(defun epg-start-encrypt (context plain recipients
				  &optional sign always-trust)
  "Initiate an encrypt operation on PLAIN.
PLAIN is a data object.
If RECIPIENTS is nil, it performs symmetric encryption.

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-encrypt-file' or `epg-encrypt-string' instead."
  (setf (epg-context-operation context) 'encrypt)
  (setf (epg-context-result context) nil)
  (epg--start context
	     (append (if always-trust '("--always-trust"))
		     (if recipients '("--encrypt") '("--symmetric"))
		     (if sign '("--sign"))
		     (if sign
			 (apply #'nconc
				(mapcar
				 (lambda (signer)
				   (list "-u"
					 (epg-sub-key-id
					  (car (epg-key-sub-key-list
						signer)))))
				 (epg-context-signers context))))
		     (if (and sign
                              (eql 'OpenPGP (epg-context-protocol context)))
                         (let ((sender (epg-context-sender context)))
                           (when (and (epg-required-version-p 'OpenPGP "2.1.15")
                                      (stringp sender))
                             (list "--sender" sender))))
                     (if sign
			 (epg--args-from-sig-notations
			  (epg-context-sig-notations context)))
		     (apply #'nconc
			    (mapcar
			     (lambda (recipient)
			       (list "-r"
				     (epg-sub-key-id
				      (car (epg-key-sub-key-list recipient)))))
			     recipients))
		     (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
                         (if sign '("BEGIN_SIGNING") '("BEGIN_ENCRYPTION"))))
  (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)))))