diff --git a/lisp/mm-view.el b/lisp/mm-view.el index 42e21ca..91fba5d 100644 --- a/lisp/mm-view.el +++ b/lisp/mm-view.el @@ -669,18 +669,24 @@ (defun mm-view-pkcs7-decrypt (handle) (insert-buffer-substring (mm-handle-buffer handle)) (goto-char (point-min)) - (insert "MIME-Version: 1.0\n") - (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m") - (smime-decrypt-region - (point-min) (point-max) - (if (= (length smime-keys) 1) - (cadar smime-keys) - (smime-get-key-by-email - (completing-read - (concat "Decipher using key" - (if smime-keys (concat "(default " (caar smime-keys) "): ") - ": ")) - smime-keys nil nil nil nil (car-safe (car-safe smime-keys)))))) + (if (eq mml-smime-use 'epg) + ;; Use EPG/gpgsm + (let ((part (base64-decode-string (buffer-string)))) + (erase-buffer) + (insert (epg-decrypt-string (epg-make-context 'CMS) part))) + ;; Use openssl + (insert "MIME-Version: 1.0\n") + (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m") + (smime-decrypt-region + (point-min) (point-max) + (if (= (length smime-keys) 1) + (cadar smime-keys) + (smime-get-key-by-email + (completing-read + (concat "Decipher using key" + (if smime-keys (concat "(default " (caar smime-keys) "): ") + ": ")) + smime-keys nil nil nil nil (car-safe (car-safe smime-keys))))))) (goto-char (point-min)) (while (search-forward "\r\n" nil t) (replace-match "\n"))