+2007-08-31 Daiki Ueno <ueno@unixuser.org>
+
+ * mml2015.el (mml2015-extract-cleartext-signature): New function.
+ (mml2015-mailcrypt-clear-verify): Use it.
+ (mml2015-gpg-clear-verify): Use it.
+ (mml2015-pgg-clear-verify): Use it.
+ (mml2015-epg-clear-verify): Replace the current part with the output
+ from GnuPG; don't extract the plaintext by itself.
+
+ * mm-uu.el (mm-uu-pgp-beginning-signature): Abolish.
+ (mm-uu-pgp-signed-extract-1): Bind coding-system-for-read when calling
+ mml2015-clear-verify-function; don't touch the armor headers or
+ dash-escaped text here.
+
2007-08-24 Katsumi Yamaoka <yamaoka@jpl.org>
* gnus-art.el (gnus-article-edit-part): Don't jump to nonexistent part.
(defvar mm-uu-yenc-decode-function 'yenc-decode-region)
-(defvar mm-uu-pgp-beginning-signature
- "^-----BEGIN PGP SIGNATURE-----")
-
(defvar mm-uu-beginning-regexp nil)
(defvar mm-dissect-disposition "inline"
(progn
(mml2015-clean-buffer)
(let ((coding-system-for-write (or gnus-newsgroup-charset
- 'iso-8859-1)))
+ 'iso-8859-1))
+ (coding-system-for-read (or gnus-newsgroup-charset
+ 'iso-8859-1)))
(funcall (mml2015-clear-verify-function))))
(when (and mml2015-use (null (mml2015-clear-verify-function)))
(mm-set-handle-multipart-parameter
mm-security-handle 'gnus-details
- (format "Clear verification not supported by `%s'.\n" mml2015-use))))
- (goto-char (point-min))
- (forward-line)
- ;; We need to be careful not to strip beyond the armor headers.
- ;; Previously, an attacker could replace the text inside our
- ;; markup with trailing garbage by injecting whitespace into the
- ;; message.
- (while (looking-at "Hash:") ; The only header allowed in cleartext
- (forward-line)) ; signatures according to RFC2440.
- (when (looking-at "[\t ]*$")
- (forward-line))
- (delete-region (point-min) (point))
- (if (re-search-forward mm-uu-pgp-beginning-signature nil t)
- (delete-region (match-beginning 0) (point-max)))
- (goto-char (point-min))
- (while (re-search-forward "^- " nil t)
- (replace-match "" t t)
- (forward-line 1)))
+ (format "Clear verification not supported by `%s'.\n" mml2015-use)))))
(list (mm-make-handle buf mm-uu-text-plain-type))))
(defun mm-uu-pgp-signed-extract ()
:group 'mime-security
:type 'boolean)
+;; Extract plaintext from cleartext signature. IMO, this kind of task
+;; should be done by GnuPG rather than Elisp, but older PGP backends
+;; (such as Mailcrypt, PGG, and gpg.el) discard the output from GnuPG.
+(defun mml2015-extract-cleartext-signature ()
+ (goto-char (point-min))
+ (forward-line)
+ ;; We need to be careful not to strip beyond the armor headers.
+ ;; Previously, an attacker could replace the text inside our
+ ;; markup with trailing garbage by injecting whitespace into the
+ ;; message.
+ (while (looking-at "Hash:") ; The only header allowed in cleartext
+ (forward-line)) ; signatures according to RFC2440.
+ (when (looking-at "[\t ]*$")
+ (forward-line))
+ (delete-region (point-min) (point))
+ (if (re-search-forward "^-----BEGIN PGP SIGNATURE-----" nil t)
+ (delete-region (match-beginning 0) (point-max)))
+ (goto-char (point-min))
+ (while (re-search-forward "^- " nil t)
+ (replace-match "" t t)
+ (forward-line 1)))
+
;;; mailcrypt wrapper
(eval-and-compile
(mm-set-handle-multipart-parameter
mm-security-handle 'gnus-info "OK")
(mm-set-handle-multipart-parameter
- mm-security-handle 'gnus-info "Failed"))))
+ mm-security-handle 'gnus-info "Failed")))
+ (mml2015-extract-cleartext-signature))
(defun mml2015-mailcrypt-sign (cont)
(mc-sign-generic (message-options-get 'message-sender)
(with-current-buffer mml2015-result-buffer
(mml2015-gpg-extract-signature-details)))
(mm-set-handle-multipart-parameter
- mm-security-handle 'gnus-info "Failed")))
+ mm-security-handle 'gnus-info "Failed"))
+ (mml2015-extract-cleartext-signature))
(defun mml2015-gpg-sign (cont)
(let ((boundary (mml-compute-boundary cont))
(with-current-buffer pgg-errors-buffer
(mml2015-gpg-extract-signature-details)))
(mm-set-handle-multipart-parameter
- mm-security-handle 'gnus-info "Failed"))))
+ mm-security-handle 'gnus-info "Failed")))
+ (mml2015-extract-cleartext-signature))
(defun mml2015-pgg-sign (cont)
(let ((pgg-errors-buffer mml2015-result-buffer)
(let ((inhibit-redisplay t)
(context (epg-make-context))
(signature (mm-encode-coding-string (buffer-string)
- buffer-file-coding-system))
+ coding-system-for-write))
plain)
(condition-case error
(setq plain (epg-verify-string context signature))
(mm-set-handle-multipart-parameter
mm-security-handle 'gnus-details (mml2015-format-error error)))))
(if plain
- (mm-set-handle-multipart-parameter
- mm-security-handle 'gnus-info
- (epg-verify-result-to-string
- (epg-context-result-for context 'verify))))))
+ (progn
+ (mm-set-handle-multipart-parameter
+ mm-security-handle 'gnus-info
+ (epg-verify-result-to-string
+ (epg-context-result-for context 'verify)))
+ (delete-region (point-min) (point-max))
+ (insert (mm-decode-coding-string plain coding-system-for-read)))
+ (mml2015-extract-cleartext-signature))))
(defun mml2015-epg-sign (cont)
(let* ((inhibit-redisplay t)