(vector (or protocol 'OpenPGP) armor textmode include-certs
cipher-algorithm digest-algorithm compress-algorithm
#'epg-passphrase-callback-function
- #'epg-progress-callback-function
+ nil
nil nil nil nil nil)))
(defun epg-context-protocol (context)
epg-gpg-program)))
(let* ((args (append (list "--no-tty"
"--status-fd" "1"
- "--yes"
- "--enable-progress-filter")
+ "--yes")
+ (if (epg-context-progress-callback context)
+ (list "--enable-progress-filter"))
(if epg-gpg-home-directory
(list "--homedir" epg-gpg-home-directory))
(unless (eq (epg-context-protocol context) 'CMS)
(setq epg-key-id 'PIN))
(defun epg--status-GET_HIDDEN (context string)
- (if (and epg-key-id
- (string-match "\\`passphrase\\." string))
- (let (inhibit-quit
- passphrase
- passphrase-with-new-line
- encoded-passphrase-with-new-line)
- (unwind-protect
- (condition-case nil
- (progn
- (setq passphrase
- (funcall
- (if (consp (epg-context-passphrase-callback context))
- (car (epg-context-passphrase-callback context))
- (epg-context-passphrase-callback context))
- context
- epg-key-id
- (if (consp (epg-context-passphrase-callback context))
- (cdr (epg-context-passphrase-callback context)))))
- (when passphrase
- (setq passphrase-with-new-line (concat passphrase "\n"))
- (epg--clear-string passphrase)
- (setq passphrase nil)
- (if epg-locale-coding-system
- (progn
- (setq encoded-passphrase-with-new-line
- (encode-coding-string
- passphrase-with-new-line
- epg-locale-coding-system))
- (epg--clear-string passphrase-with-new-line)
- (setq passphrase-with-new-line nil))
- (setq encoded-passphrase-with-new-line
- passphrase-with-new-line
- passphrase-with-new-line nil))
- (process-send-string (epg-context-process context)
- encoded-passphrase-with-new-line)))
- (quit
- (epg-context-set-result-for
- context 'error
- (cons '(quit)
- (epg-context-result-for context 'error)))
- (delete-process (epg-context-process context))))
- (if passphrase
- (epg--clear-string passphrase))
- (if passphrase-with-new-line
- (epg--clear-string passphrase-with-new-line))
- (if encoded-passphrase-with-new-line
- (epg--clear-string encoded-passphrase-with-new-line))))))
+ (when (and epg-key-id
+ (string-match "\\`passphrase\\." string))
+ (unless (epg-context-passphrase-callback context)
+ (error "passphrase-callback not set"))
+ (let (inhibit-quit
+ passphrase
+ passphrase-with-new-line
+ encoded-passphrase-with-new-line)
+ (unwind-protect
+ (condition-case nil
+ (progn
+ (setq passphrase
+ (funcall
+ (if (consp (epg-context-passphrase-callback context))
+ (car (epg-context-passphrase-callback context))
+ (epg-context-passphrase-callback context))
+ context
+ epg-key-id
+ (if (consp (epg-context-passphrase-callback context))
+ (cdr (epg-context-passphrase-callback context)))))
+ (when passphrase
+ (setq passphrase-with-new-line (concat passphrase "\n"))
+ (epg--clear-string passphrase)
+ (setq passphrase nil)
+ (if epg-passphrase-coding-system
+ (progn
+ (setq encoded-passphrase-with-new-line
+ (encode-coding-string
+ passphrase-with-new-line
+ epg-passphrase-coding-system))
+ (epg--clear-string passphrase-with-new-line)
+ (setq passphrase-with-new-line nil))
+ (setq encoded-passphrase-with-new-line
+ passphrase-with-new-line
+ passphrase-with-new-line nil))
+ (process-send-string (epg-context-process context)
+ encoded-passphrase-with-new-line)))
+ (quit
+ (epg-context-set-result-for
+ context 'error
+ (cons '(quit)
+ (epg-context-result-for context 'error)))
+ (delete-process (epg-context-process context))))
+ (if passphrase
+ (epg--clear-string passphrase))
+ (if passphrase-with-new-line
+ (epg--clear-string passphrase-with-new-line))
+ (if encoded-passphrase-with-new-line
+ (epg--clear-string encoded-passphrase-with-new-line))))))
(defun epg--status-GET_BOOL (context string)
(let ((entry (assoc string epg-prompt-alist))
(defun epg-progress-callback-function (context what char current total
handback)
- (message "%s: %d/%d" what current total))
+ (message "%s: %d%% (%d/%d)" what
+ (if (> total 0) (floor (* (/ current (float total)) 100)) 0)
+ current total))
(defun epg--list-keys-1 (context name mode)
(let ((args (append (if epg-gpg-home-directory
;;;###autoload
(defun epg-start-decrypt (context cipher)
"Initiate a decrypt operation on CIPHER.
-CIPHER is a data object.
+CIPHER must be a file data object.
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
(error "Not a file"))
(epg-context-set-operation context 'decrypt)
(epg-context-set-result context nil)
- (epg--start context (list "--decrypt" (epg-data-file cipher)))
+ (epg--start context (list "--decrypt" "--" (epg-data-file cipher)))
;; `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_DECRYPTION"))))
(if signed-text
;; Detached signature.
(if (epg-data-file signed-text)
- (epg--start context (list "--verify" (epg-data-file signature)
+ (epg--start context (list "--verify" "--" (epg-data-file signature)
(epg-data-file signed-text)))
- (epg--start context (list "--verify" (epg-data-file signature) "-"))
+ (epg--start context (list "--verify" "--" (epg-data-file signature)
+ "-"))
(if (eq (process-status (epg-context-process context)) 'run)
(process-send-string (epg-context-process context)
(epg-data-string signed-text)))
(process-send-eof (epg-context-process context))))
;; Normal (or cleartext) signature.
(if (epg-data-file signature)
- (epg--start context (list "--verify" (epg-data-file signature)))
+ (epg--start context (list "--verify" "--" (epg-data-file signature)))
(epg--start context (list "--verify"))
(if (eq (process-status (epg-context-process context)) 'run)
(process-send-string (epg-context-process context)
(car (epg-key-sub-key-list signer)))))
(epg-context-signers context)))
(if (epg-data-file plain)
- (list (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")))
(car (epg-key-sub-key-list recipient)))))
recipients))
(if (epg-data-file plain)
- (list (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)
(if sign
(epg-context-set-operation context 'import-keys)
(epg-context-set-result context nil)
(epg--start context (if (epg-data-file keys)
- (list "--import" (epg-data-file keys))
+ (list "--import" "--" (epg-data-file keys))
(list "--import")))
(when (epg-data-string keys)
(if (eq (process-status (epg-context-process context)) 'run)
(epg-context-set-operation context 'generate-key)
(epg-context-set-result context nil)
(if (epg-data-file parameters)
- (epg--start context (list "--batch" "--genkey"
+ (epg--start context (list "--batch" "--genkey" "--"
(epg-data-file parameters)))
(epg--start context '("--batch" "--genkey"))
(if (eq (process-status (epg-context-process context)) 'run)