* mime-pgp.el (mime-verify-application/*-signature): New function.
authorueno <ueno>
Sun, 23 Apr 2006 02:21:39 +0000 (02:21 +0000)
committerueno <ueno>
Sun, 23 Apr 2006 02:21:39 +0000 (02:21 +0000)
(mime-verify-application/pgp-signature): Abolished.
(mime-verify-application/pkcs7-signature): Abolished.

mime-edit.el
mime-pgp.el
semi-setup.el

index 70cfbed..d810941 100644 (file)
@@ -1873,8 +1873,7 @@ If no one is selected, symmetric encryption will be performed.  "
          )))))
 
 (defun mime-edit-convert-lbt-string (string)
-  (let ((index 0)
-       (length (length string)))
+  (let ((index 0))
     (while (setq index (string-match "\n" string index))
       (setq string (replace-match "\r\n" nil nil string)
            index (+ index 2)))         ;(length "\r\n")
@@ -2377,7 +2376,7 @@ and insert data encoded as ENCODING."
   (mime-edit-insert-tag "application" "pgp-keys")
   (mime-edit-define-encoding "7bit")
   (let ((context (epg-make-context)))
-    (epg-context-set-armor t)
+    (epg-context-set-armor context t)
     (epg-export-keys-to-string context
                               (epa-select-keys context
                                                "Select keys for export.  ")))
index bbaea2c..5709244 100644 (file)
     (set-window-buffer p-win preview-buffer)))
 
 
-;;; @ Internal method for application/pgp-signature
-;;;
-;;; It is based on RFC 2015 (PGP/MIME) and
-;;; draft-ietf-openpgp-mime-02.txt (OpenPGP/MIME).
-
-(defun mime-verify-application/pgp-signature (entity situation)
-  "Internal method to check PGP/MIME signature."
+(defun mime-verify-application/*-signature (entity situation)
   (let* ((entity-node-id (mime-entity-node-id entity))
         (mother (mime-entity-parent entity))
         (knum (car entity-node-id))
                   (1- knum)
                 (1+ knum)))
         (orig-entity (nth onum (mime-entity-children mother)))
-        (context (epg-make-context)))
+        (protocol (cdr (assoc "protocol" (mime-entity-parameters mother))))
+        (context (epg-make-context
+                  (if (equal protocol "application/pgp-signature")
+                      'OpenPGP
+                    (if (string-match
+                         "\\`application/\\(x-\\)?pkcs7-signature\\'"
+                         protocol)
+                      'CMS
+                      (error "Unknown protocol: %s" protocol)))))
+        verify-result)
     (epg-verify-string context
                       (mime-entity-content entity)
                       (with-temp-buffer
                         (while (search-forward "\n" nil t)
                           (replace-match "\r\n"))
                         (buffer-substring)))
+    (setq verify-result
+         (mapcar (lambda (signature)
+                   (unless (stringp (epg-signature-user-id signature))
+                     (setq signature (copy-sequence signature))
+                     (epg-signature-set-user-id
+                      signature
+                      (epg-decode-dn (epg-signature-user-id signature))))
+                   signature)
+                 (epg-context-result-for context 'verify)))
     (message "%s"
-            (epg-verify-result-to-string
-             (epg-context-result-for context 'verify)))))
+            (epg-verify-result-to-string verify-result))))
 
 
 ;;; @ Internal method for application/pgp-encrypted
     (epa-list-keys)))
 
 
-;;; @ Internal method for application/pkcs7-signature
-;;;
-;;; It is based on the S/MIME user interface in Gnus.
-
-(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)))
-        (context (epg-make-context 'CMS))
-        verify-result)
-    (epg-verify-string context
-                      (mime-entity-content entity)
-                      (with-temp-buffer
-                        (if (fboundp 'set-buffer-multibyte)
-                            (set-buffer-multibyte nil))
-                        (mime-insert-entity orig-entity)
-                        (goto-char (point-min))
-                        (while (search-forward "\n" nil t)
-                          (replace-match "\r\n"))
-                        (buffer-substring)))
-    (setq verify-result
-         (mapcar (lambda (signature)
-                   (unless (stringp (epg-signature-user-id signature))
-                     (setq signature (copy-sequence signature))
-                     (epg-signature-set-user-id
-                      signature
-                      (epg-decode-dn (epg-signature-user-id signature))))
-                   signature)
-                 (epg-context-result-for context 'verify)))
-    (message "%s"
-            (epg-verify-result-to-string verify-result))))
-
-
 ;;; @ Internal method for application/pkcs7-mime
 ;;;
 ;;; It is based on RFC 2633 (S/MIME version 3).
index 7a3aa11..ada262c 100644 (file)
@@ -98,7 +98,7 @@
      (mime-add-condition
       'action
       '((type . application)(subtype . pgp-signature)
-       (method . mime-verify-application/pgp-signature))
+       (method . mime-verify-application/*-signature))
       'strict "mime-pgp")
         
      (mime-add-condition
      (mime-add-condition
       'action
       '((type . application)(subtype . pkcs7-signature)
-       (method . mime-verify-application/pkcs7-signature))
+       (method . mime-verify-application/*-signature))
       'strict "mime-pgp")
 
      (mime-add-condition
       'action
       '((type . application)(subtype . x-pkcs7-signature)
-       (method . mime-verify-application/pkcs7-signature))
+       (method . mime-verify-application/*-signature))
       'strict "mime-pgp")
 
      (mime-add-condition