X-Git-Url: http://cgit.sxemacs.org/?p=gnus;a=blobdiff_plain;f=lisp%2Fmml2015.el;h=5429a27a4e563cfbb6586e179778956481f0b2af;hp=babdab99fa616445eac7ebd4208309f27cc3f537;hb=733550914b151d9744ec45287b434af023f3e6d4;hpb=fddb800255b709964551ac2e54e6a6da9e667c3e diff --git a/lisp/mml2015.el b/lisp/mml2015.el index babdab99f..5429a27a4 100644 --- a/lisp/mml2015.el +++ b/lisp/mml2015.el @@ -39,6 +39,12 @@ (defvar mc-pgp-always-sign) (defvar mml2015-use (or + (condition-case nil + (progn + (require 'epg-config) + (epg-check-configuration (epg-configuration)) + 'epg) + (error)) (progn (ignore-errors ;; Avoid the "Recursive load suspected" error @@ -59,7 +65,7 @@ (fboundp 'mc-cleanup-recipient-headers) 'mailcrypt))) "The package used for PGP/MIME. -Valid packages include `pgg', `gpg' and `mailcrypt'.") +Valid packages include `epg', `pgg', `gpg' and `mailcrypt'.") ;; Something is not RFC2015. (defvar mml2015-function-alist @@ -125,11 +131,16 @@ Whether the passphrase is cached at all is controlled by :group 'mime-security :type '(repeat (string :tag "Key ID"))) -(defcustom mml2015-encrypt-to-self nil +(defcustom mml2015-encrypt-to-self t "If t, add your own key ID to recipient list when encryption." :group 'mime-security :type 'boolean) +(defcustom mml2015-always-trust t + "If t, GnuPG skip key validation on encryption." + :group 'mime-security + :type 'boolean) + ;;; mailcrypt wrapper (eval-and-compile @@ -945,16 +956,14 @@ Whether the passphrase is cached at all is controlled by (defun mml2015-epg-passphrase-callback (context key-id ignore) (if (eq key-id 'SYM) (epg-passphrase-callback-function context key-id nil) - (let* ((entry (assoc key-id epg-user-id-alist)) + (let* (entry (passphrase (password-read - (format "GnuPG passphrase for %s: " - (if entry - (cdr entry) - key-id)) (if (eq key-id 'PIN) - "PIN" - key-id)))) + "Passphrase for PIN: " + (if (setq entry (assoc key-id epg-user-id-alist)) + (format "Passphrase for %s %s: " key-id (cdr entry)) + (format "Passphrase for %s: " key-id)))))) (when passphrase (let ((password-cache-expiry mml2015-passphrase-cache-expiry)) (password-cache-add key-id passphrase)) @@ -1047,14 +1056,13 @@ Whether the passphrase is cached at all is controlled by (goto-char (point-min)) (while (search-forward "\r\n" nil t) (replace-match "\n" t t)) + (mm-set-handle-multipart-parameter + mm-security-handle 'gnus-info "OK") (if (epg-context-result-for context 'verify) (mm-set-handle-multipart-parameter - mm-security-handle 'gnus-info - (concat "OK\n" - (epg-verify-result-to-string - (epg-context-result-for context 'verify)))) - (mm-set-handle-multipart-parameter - mm-security-handle 'gnus-info "OK"))))) + mm-security-handle 'gnus-details + (epg-verify-result-to-string + (epg-context-result-for context 'verify))))))) (defun mml2015-epg-verify (handle ctl) (catch 'error @@ -1122,11 +1130,7 @@ If no one is selected, default secret key is used. " (if mml2015-signers (setq signers (mapcar (lambda (name) (car (epg-list-keys context name t))) - mml2015-signers)) - (setq signers (list (car (epg-list-keys - context - (message-options-get 'mml-sender) - t)))))) + mml2015-signers)))) (epg-context-set-armor context t) (epg-context-set-textmode context t) (epg-context-set-signers context signers) @@ -1167,25 +1171,20 @@ If no one is selected, default secret key is used. " (defun mml2015-epg-encrypt (cont &optional sign) (let ((inhibit-redisplay t) (context (epg-make-context)) - (recipients - (if (message-options-get 'message-recipients) - (split-string - (message-options-get 'message-recipients) - "[ \f\t\n\r\v,]+"))) - cipher signers config + (config (epg-configuration)) + (recipients (split-string + (or (message-options-get 'message-recipients) + (message-options-set 'message-recipients + (read-string "Recipients: "))) + "[ \f\t\n\r\v,]+")) + cipher signers (boundary (mml-compute-boundary cont))) - ;; We should remove this check if epg-0.0.6 is released. - (if (and (condition-case nil - (require 'epg-config) - (error)) - (functionp #'epg-expand-group)) - (setq config (epg-configuration) - recipients - (apply #'nconc - (mapcar (lambda (recipient) + (setq recipients (apply #'nconc + (mapcar + (lambda (recipient) (or (epg-expand-group config recipient) (list recipient))) - recipients)))) + recipients))) (if mml2015-verbose (setq recipients (epa-select-keys context "Select recipients for encryption. @@ -1202,9 +1201,7 @@ If no one is selected, symmetric encryption will be performed. " (mapcar (lambda (name) (car (epg-list-keys context name))) mml2015-signers))) - (setq recipients - (nconc recipients - (list (car (epg-list-keys context nil t))))))) + (error "mml2015-signers not set"))) (when sign (if mml2015-verbose (setq signers (epa-select-keys context "Select keys for signing. @@ -1213,11 +1210,7 @@ If no one is selected, default secret key is used. " (if mml2015-signers (setq signers (mapcar (lambda (name) (car (epg-list-keys context name t))) - mml2015-signers)) - (setq signers (list (car (epg-list-keys - context - (message-options-get 'mml-sender) - t)))))) + mml2015-signers)))) (epg-context-set-signers context signers)) (epg-context-set-armor context t) (epg-context-set-textmode context t) @@ -1227,7 +1220,8 @@ If no one is selected, default secret key is used. " #'mml2015-epg-passphrase-callback)) (condition-case error (setq cipher - (epg-encrypt-string context (buffer-string) recipients sign) + (epg-encrypt-string context (buffer-string) recipients sign + mml2015-always-trust) mml2015-epg-secret-key-id-list nil) (error (while mml2015-epg-secret-key-id-list