(message "Verifying %s..." (file-name-nondirectory file))
(epg-verify-file context file plain)
(setq signature (reverse (epg-context-result-for context 'verify)))
- (with-output-to-temp-buffer "*epa-verify-file*"
- (set-buffer standard-output)
- (while signature
- (insert (format "%s: %s %s %s\n"
- (epg-signature-status (car signature))
- (epg-signature-key-id (car signature))
- (epg-signature-user-id (car signature))
- (epg-signature-validity (car signature))))
- (setq signature (cdr signature))))
- (shrink-window-if-larger-than-buffer
- (get-buffer-window "*epa-verify-file*"))
+ (while signature
+ (message "%s: %s %s %s\n"
+ (epg-signature-status (car signature))
+ (epg-signature-key-id (car signature))
+ (epg-signature-user-id (car signature))
+ (epg-signature-validity (car signature)))
+ (setq signature (cdr signature)))
(message "Verifying %s...done" (file-name-nondirectory file))))
(defun epa-sign-file (file detached)
(defvar epg-key-id nil)
(defvar epg-context nil)
(defvar epg-debug nil)
+(defvar epg-debug-buffer nil)
;; from gnupg/include/cipher.h
(defconst epg-cipher-algorithm-alist
process)
(if epg-debug
(save-excursion
- (set-buffer (get-buffer-create " *epg-debug*"))
+ (unless epg-debug-buffer
+ (setq epg-debug-buffer (generate-new-buffer " *epg-debug*")))
+ (set-buffer epg-debug-buffer)
(goto-char (point-max))
(insert (format "%s %s\n" epg-gpg-program
(mapconcat #'identity args " ")))))
(defun epg-process-filter (process input)
(if epg-debug
(save-excursion
- (set-buffer (get-buffer-create " *epg-debug*"))
+ (unless epg-debug-buffer
+ (setq epg-debug-buffer (generate-new-buffer " *epg-debug*")))
+ (set-buffer epg-debug-buffer)
(goto-char (point-max))
(insert input)))
(if (buffer-live-p (process-buffer process))
epg-pending-status-list)
(accept-process-output (epg-context-process context) 1))))
-(defun epg-wait-for-completion (context &optional no-eof)
- (if (and (not no-eof)
- (eq (process-status (epg-context-process context)) 'run))
- (process-send-eof (epg-context-process context)))
+(defun epg-wait-for-completion (context)
(while (eq (process-status (epg-context-process context)) 'run)
;; We can't use accept-process-output instead of sit-for here
;; because it may cause an interrupt during the sentinel execution.
(sit-for 0.1)))
+(defun epg-flush (context)
+ (if (eq (process-status (epg-context-process context)) 'run)
+ (process-send-eof (epg-context-process context))))
+
(defun epg-reset (context)
(if (and (epg-context-process context)
(buffer-live-p (process-buffer (epg-context-process context))))
(epg-context-set-output-file context
(epg-make-temp-file "epg-output")))
(epg-start-decrypt context (epg-make-data-from-file cipher))
- (epg-wait-for-completion context t)
+ (epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Decrypt failed: %S"
(epg-context-result-for context 'error)))
(epg-context-set-output-file context
(epg-make-temp-file "epg-output"))
(epg-start-decrypt context (epg-make-data-from-file input-file))
+ (epg-flush context)
(epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Decrypt failed: %S"
(epg-make-data-from-file signed-text))
(epg-start-verify context
(epg-make-data-from-file signature)))
- (epg-wait-for-completion context t)
+ (epg-wait-for-completion context)
(unless plain
(epg-read-output context)))
(unless plain
(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-flush context)
(epg-wait-for-completion context)
(epg-read-output context))
(epg-delete-output-file context)
(epg-context-set-output-file context
(epg-make-temp-file "epg-output")))
(epg-start-sign context (epg-make-data-from-file plain) mode)
- (epg-wait-for-completion context t)
+ (epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Sign failed: %S"
(epg-context-result-for context 'error)))
(epg-context-set-output-file context
(epg-make-temp-file "epg-output"))
(epg-start-sign context (epg-make-data-from-string plain) mode)
+ (epg-flush context)
(epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Sign failed: %S"
(epg-make-temp-file "epg-output")))
(epg-start-encrypt context (epg-make-data-from-file plain)
recipients sign always-trust)
- (epg-wait-for-completion context t)
+ (epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Encrypt failed: %S"
(epg-context-result-for context 'error)))
(epg-make-temp-file "epg-output"))
(epg-start-encrypt context (epg-make-data-from-string plain)
recipients sign always-trust)
+ (epg-flush context)
(epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Encrypt failed: %S"
(unwind-protect
(progn
(epg-start-import-keys context keys)
- (epg-wait-for-completion context (epg-data-file keys))
+ (if (epg-data-file keys)
+ (epg-flush context))
+ (epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Import keys failed"))
(epg-read-output context))
(unwind-protect
(progn
(epg-start-delete-keys context keys)
- (epg-wait-for-completion context t)
+ (epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Delete key failed")))
(epg-reset context)))