1 ;;; mml-gpg-old.el --- Old PGP message format (RFC 1991) support for MML
2 ;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
4 ;; Author: Sascha Lüdecke <sascha@meta-x.de>,
5 ;; Simon Josefsson <simon@josefsson.org> (Mailcrypt interface, Gnus glue)
8 ;; This file is (not yet) part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (defvar mml1991-use mml2015-use
30 "The package used for PGP.")
32 (defvar mml1991-function-alist
33 '((mailcrypt mml1991-mailcrypt-sign
34 mml1991-mailcrypt-encrypt)
37 "Alist of PGP/MIME functions.")
42 (autoload 'mc-sign-generic "mc-toplev"))
44 (defvar mml1991-decrypt-function 'mailcrypt-decrypt)
45 (defvar mml1991-verify-function 'mailcrypt-verify)
47 (defun mml1991-mailcrypt-sign (cont)
48 (let ((text (current-buffer))
50 (result-buffer (get-buffer-create "*GPG Result*")))
51 ;; Save MIME Content[^ ]+: headers from signing
52 (goto-char (point-min))
53 (while (looking-at "^Content[^ ]+:") (forward-line))
54 (if (> (point) (point-min))
56 (setq headers (buffer-substring (point-min) (point)))
57 (kill-region (point-min) (point))))
58 (goto-char (point-max))
61 (quoted-printable-decode-region (point-min) (point-max))
63 (setq signature (current-buffer))
65 (unless (mc-sign-generic (message-options-get 'message-sender)
67 (unless (> (point-max) (point-min))
68 (pop-to-buffer result-buffer)
69 (error "Sign error")))
70 (goto-char (point-min))
71 (while (re-search-forward "\r+$" nil t)
72 (replace-match "" t t))
73 (quoted-printable-encode-region (point-min) (point-max))
75 (kill-region (point-min) (point-max))
76 (if headers (insert headers))
78 (insert-buffer signature)
79 (goto-char (point-max)))))
81 (defun mml1991-mailcrypt-encrypt (cont)
82 (let ((text (current-buffer))
84 (result-buffer (get-buffer-create "*GPG Result*")))
85 ;; Strip MIME Content[^ ]: headers since it will be ASCII ARMOURED
86 (goto-char (point-min))
87 (while (looking-at "^Content[^ ]+:") (forward-line))
88 (if (> (point) (point-min))
90 (kill-region (point-min) (point))))
91 (mm-with-unibyte-current-buffer-mule4
93 (setq cipher (current-buffer))
95 (unless (mc-encrypt-generic
97 (message-options-get 'message-recipients)
98 (message-options-set 'message-recipients
99 (read-string "Recipients: ")))
101 (point-min) (point-max)
102 (message-options-get 'message-sender)
104 (unless (> (point-max) (point-min))
105 (pop-to-buffer result-buffer)
106 (error "Encrypt error")))
107 (goto-char (point-min))
108 (while (re-search-forward "\r+$" nil t)
109 (replace-match "" t t))
111 (kill-region (point-min) (point-max))
112 ;;(insert "Content-Type: application/pgp-encrypted\n\n")
113 ;;(insert "Version: 1\n\n")
115 (insert-buffer cipher)
116 (goto-char (point-max))))))
121 (autoload 'gpg-sign-cleartext "gpg"))
123 (defun mml1991-gpg-sign (cont)
124 (let ((text (current-buffer))
126 (result-buffer (get-buffer-create "*GPG Result*")))
127 ;; Save MIME Content[^ ]+: headers from signing
128 (goto-char (point-min))
129 (while (looking-at "^Content[^ ]+:") (forward-line))
130 (if (> (point) (point-min))
132 (setq headers (buffer-substring (point-min) (point)))
133 (kill-region (point-min) (point))))
134 (goto-char (point-max))
137 (quoted-printable-decode-region (point-min) (point-max))
139 (unless (gpg-sign-cleartext text (setq signature (current-buffer))
142 (message-options-get 'message-sender))
143 (unless (> (point-max) (point-min))
144 (pop-to-buffer result-buffer)
145 (error "Sign error")))
146 (goto-char (point-min))
147 (while (re-search-forward "\r+$" nil t)
148 (replace-match "" t t))
149 (quoted-printable-encode-region (point-min) (point-max))
151 (kill-region (point-min) (point-max))
152 (if headers (insert headers))
154 (insert-buffer signature)
155 (goto-char (point-max)))))
157 (defun mml1991-gpg-encrypt (cont)
158 (let ((text (current-buffer))
160 (result-buffer (get-buffer-create "*GPG Result*")))
161 ;; Strip MIME Content[^ ]: headers since it will be ASCII ARMOURED
162 (goto-char (point-min))
163 (while (looking-at "^Content[^ ]+:") (forward-line))
164 (if (> (point) (point-min))
166 (kill-region (point-min) (point))))
167 (mm-with-unibyte-current-buffer-mule4
169 (unless (gpg-sign-encrypt
170 text (setq cipher (current-buffer))
174 (message-options-get 'message-recipients)
175 (message-options-set 'message-recipients
176 (read-string "Recipients: ")))
179 (message-options-get 'message-sender)
180 t t) ; armor & textmode
181 (unless (> (point-max) (point-min))
182 (pop-to-buffer result-buffer)
183 (error "Encrypt error")))
184 (goto-char (point-min))
185 (while (re-search-forward "\r+$" nil t)
186 (replace-match "" t t))
188 (kill-region (point-min) (point-max))
189 ;;(insert "Content-Type: application/pgp-encrypted\n\n")
190 ;;(insert "Version: 1\n\n")
192 (insert-buffer cipher)
193 (goto-char (point-max))))))
196 (defun mml1991-encrypt (cont)
197 (let ((func (nth 2 (assq mml1991-use mml1991-function-alist))))
200 (error "Cannot find encrypt function"))))
203 (defun mml1991-sign (cont)
204 (let ((func (nth 1 (assq mml1991-use mml1991-function-alist))))
207 (error "Cannot find sign function"))))
212 ;; coding: iso-8859-1
215 ;;; mml1991.el ends here