* mime-pgp.el: Add autoload settings for `smime-decrypt-region' and
authorueno <ueno>
Wed, 8 Dec 1999 18:43:19 +0000 (18:43 +0000)
committerueno <ueno>
Wed, 8 Dec 1999 18:43:19 +0000 (18:43 +0000)
`smime-verify-region'.
(mime-verify-application/pkcs7-signature): New function.
(mime-decrypt-application/pkcs7-mime): New function.

mime-pgp.el

index dde2d68..4e1fac7 100644 (file)
@@ -1,4 +1,4 @@
-;;; mime-pgp.el --- mime-view internal methods for PGP.
+;;; mime-pgp.el --- mime-view internal methods foro PGP.
 
 ;; Copyright (C) 1995,1996,1997,1998,1999 MORIOKA Tomohiko
 
   "PGP verification of current region." t)
 (autoload 'pgg-snarf-keys-region "pgg"
   "Snarf PGP public keys in current region." t)
+(autoload 'smime-decrypt-region "smime"
+  "S/MIME decryption of current region." t)
+(autoload 'smime-verify-region "smime"
+  "S/MIME verification of current region." t)
 
 
 ;;; @ Internal method for multipart/signed
       )))
 
 
+;;; @ Internal method for application/pkcs7-signature
+;;;
+;;; It is based on RFC 2633 (S/MIME version 3).
+
+(defun mime-verify-application/pkcs7-signature (entity situation)
+  "Internal method to check S/MIME signature."
+  (let* ((entity-node-id (mime-entity-node-id entity))
+        (mother (mime-entity-parent entity))
+        (knum (car entity-node-id))
+        (onum (if (> knum 0)
+                  (1- knum)
+                (1+ knum)))
+        (orig-entity (nth onum (mime-entity-children mother)))
+        (basename (expand-file-name "tm" temporary-file-directory))
+        (sig-file (concat (make-temp-name basename) ".asc"))
+        status)
+    (save-excursion 
+      (mime-show-echo-buffer)
+      (set-buffer mime-echo-buffer-name)
+      (set-window-start 
+       (get-buffer-window mime-echo-buffer-name)
+       (point-max))
+      )
+    (mime-write-entity entity sig-file)
+    (unwind-protect
+       (with-temp-buffer
+         (mime-insert-entity orig-entity)
+         (goto-char (point-min))
+         (while (progn (end-of-line) (not (eobp)))
+           (insert "\r")
+           (forward-line 1))
+         (setq status (smime-verify-region (point-min)(point-max) 
+                                           sig-file))
+         (save-excursion 
+           (set-buffer mime-echo-buffer-name)
+           (insert-buffer-substring (if status smime-output-buffer
+                                      smime-errors-buffer))))
+      (delete-file sig-file))
+    ))
+
+
+;;; @ Internal method for application/pkcs7-mime
+;;;
+;;; It is based on RFC 2633 (S/MIME version 3).
+
+(defun mime-decrypt-application/pkcs7-mime (entity situation)
+  (let* ((p-win (or (get-buffer-window (current-buffer))
+                   (get-largest-window)))
+        (new-name
+         (format "%s-%s" (buffer-name) (mime-entity-number entity)))
+        (mother (current-buffer))
+        (preview-buffer (concat "*Preview-" (buffer-name) "*"))
+        representation-type)
+    (set-buffer (get-buffer-create new-name))
+    (erase-buffer)
+    (mime-insert-entity entity)
+    (smime-decrypt-region (point-min)(point-max))
+    (delete-region (point-min)(point-max))
+    (insert-buffer smime-output-buffer)
+    (setq major-mode 'mime-show-message-mode)
+    (save-window-excursion (mime-view-buffer nil preview-buffer mother
+                                            nil 'binary))
+    (set-window-buffer p-win preview-buffer)
+    ))
+
+
 ;;; @ end
 ;;;