args)))
       (set-default-file-modes orig-mode))
     (set-process-filter process #'epg--process-filter)
+    (set-process-sentinel process #'ignore)
     (epg-context-set-process context process)))
 
 (defun epg--process-filter (process input)
                             (string (match-string 2))
                             (symbol (intern-soft (concat "epg--status-"
                                                          status))))
+                       (forward-line)
+                       (setq epg-read-point (point))
                        (if (member status epg-pending-status-list)
                            (setq epg-pending-status-list nil))
                        (if (and symbol
                                 (fboundp symbol))
                            (funcall symbol epg-context string))
-                       (setq epg-last-status (cons status string))))
-                 (forward-line)
-                 (setq epg-read-point (point))))
+                       (goto-char epg-read-point)
+                       (setq epg-last-status (cons status string)))
+                   (forward-line)
+                   (setq epg-read-point (point)))))
            (setq epg-process-filter-running nil))))))
 
 (defun epg-read-output (context)
   (while (eq (process-status (epg-context-process context)) 'run)
     (accept-process-output (epg-context-process context) 1)))
 
+(defun epg-wait-for-plaintext (context length)
+  "Wait data from the `epg-gpg-program' process."
+  (while (and (eq (process-status (epg-context-process context)) 'run)
+             (< (- (point-max) epg-read-point) length))
+    (accept-process-output (epg-context-process context) 1)))
+
 (defun epg-reset (context)
   "Reset the CONTEXT."
   (if (and (epg-context-process context)
 (defun epg--status-DECRYPTION_OKAY (context string)
   (epg-context-set-result-for context 'decryption-okay t))
 
+(defun epg--status-PLAINTEXT_LENGTH (context string)
+  (when (string-match "\\`\\([0-9]+\\)" string)
+    (let ((length (string-to-number (match-string 1 string))))
+      (epg-wait-for-plaintext context length)
+      (epg-context-set-result-for
+       context 'plaintext
+       (buffer-substring epg-read-point
+                        (setq epg-read-point (+ epg-read-point length)))))))
+
 (defun epg--status-NODATA (context string)
   (epg-context-set-result-for
    context 'error
     (unwind-protect
        (progn
          (write-region cipher nil input-file nil 'quiet)
-         (epg-context-set-output-file context
-                                      (epg--make-temp-file "epg-output"))
          (epg-start-decrypt context (epg-make-data-from-file input-file))
          (epg-wait-for-completion context)
          (epg--check-error-for-decrypt context)
-         (epg-read-output context))
-      (epg-delete-output-file context)
+         (epg-context-result-for context 'plaintext))
       (if (file-exists-p input-file)
          (delete-file input-file))
       (epg-reset context))))