(mime-edit-decrypt-application/pgp-encrypted): New function.
authoryamaoka <yamaoka>
Wed, 12 May 1999 10:32:58 +0000 (10:32 +0000)
committeryamaoka <yamaoka>
Wed, 12 May 1999 10:32:58 +0000 (10:32 +0000)
(mime-pgp-detect-version): Allow some leading garbage lines.

mime-pgp.el

index f20408f..508f279 100644 (file)
@@ -300,11 +300,16 @@ or \"v\" for choosing a command of PGP 5.0i."
 
 (defun mime-pgp-detect-version ()
   "Detect PGP version in the buffer.  The buffer is expected to be narrowed
-to just an ascii armor."
+to just an ascii armor.  However, a few leading garbage lines are allowed."
   (let ((version (save-restriction
-                  (std11-narrow-to-header)
-                  (std11-fetch-field "Version")
-                  )))
+                  (goto-char (point-min))
+                  (if (re-search-forward "^-+BEGIN PGP " nil t)
+                      (progn
+                        (forward-line 1)
+                        (narrow-to-region (point) (point-max))
+                        (std11-narrow-to-header)
+                        (std11-fetch-field "Version")
+                        )))))
     (cond ((not version)
           pgp-version)
          ((string-match "GnuPG" version)
@@ -523,6 +528,15 @@ list of expected key-ID, start position and lines to be shown a result."
     (mime-view-application/pgp orig-entity situation)
     ))
 
+(defun mime-edit-decrypt-application/pgp-encrypted ()
+  "Decrypt the encrypted part for the function `mime-edit-again'."
+  (let ((pgp-version (mime-pgp-detect-version)))
+    ;; The following process should returns a pair (SUCCEEDED . VERIFIED)
+    ;; where SUCCEEDED is t if the decryption succeeded and VERIFIED is t
+    ;; if there was a valid signature.
+    (as-binary-process (funcall (pgp-function 'decrypt)))
+    ))
+
 
 ;;; @ Internal method for application/pgp-keys
 ;;;