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.
27 ;; RCS: $Id: mml1991.el,v 6.4 2001/12/18 06:26:40 zsh Exp $
31 (defvar mml1991-use mml2015-use
32 "The package used for PGP.")
34 (defvar mml1991-function-alist
35 '((mailcrypt mml1991-mailcrypt-sign
36 mml1991-mailcrypt-encrypt)
39 "Alist of PGP/MIME functions.")
44 (autoload 'mc-sign-generic "mc-toplev"))
46 (defvar mml1991-decrypt-function 'mailcrypt-decrypt)
47 (defvar mml1991-verify-function 'mailcrypt-verify)
49 (defun mml1991-mailcrypt-sign (cont)
50 (let ((text (current-buffer))
52 (result-buffer (get-buffer-create "*GPG Result*")))
53 ;; Save MIME Content[^ ]+: headers from signing
54 (goto-char (point-min))
55 (while (looking-at "^Content[^ ]+:") (forward-line))
56 (if (> (point) (point-min))
58 (setq headers (buffer-substring (point-min) (point)))
59 (kill-region (point-min) (point))))
60 (goto-char (point-max))
63 (quoted-printable-decode-region (point-min) (point-max))
65 (setq signature (current-buffer))
67 (unless (mc-sign-generic (message-options-get 'message-sender)
69 (unless (> (point-max) (point-min))
70 (pop-to-buffer result-buffer)
71 (error "Sign error")))
72 (goto-char (point-min))
73 (while (re-search-forward "\r+$" nil t)
74 (replace-match "" t t))
75 (quoted-printable-encode-region (point-min) (point-max))
77 (kill-region (point-min) (point-max))
78 (if headers (insert headers))
80 (insert-buffer signature)
81 (goto-char (point-max)))))
83 (defun mml1991-mailcrypt-encrypt (cont)
84 (let ((text (current-buffer))
86 (result-buffer (get-buffer-create "*GPG Result*")))
87 ;; Strip MIME Content[^ ]: headers since it will be ASCII ARMOURED
88 (goto-char (point-min))
89 (while (looking-at "^Content[^ ]+:") (forward-line))
90 (if (> (point) (point-min))
92 (kill-region (point-min) (point))))
93 (mm-with-unibyte-current-buffer-mule4
95 (setq cipher (current-buffer))
97 (unless (mc-encrypt-generic
99 (message-options-get 'message-recipients)
100 (message-options-set 'message-recipients
101 (read-string "Recipients: ")))
103 (point-min) (point-max)
104 (message-options-get 'message-sender)
106 (unless (> (point-max) (point-min))
107 (pop-to-buffer result-buffer)
108 (error "Encrypt error")))
109 (goto-char (point-min))
110 (while (re-search-forward "\r+$" nil t)
111 (replace-match "" t t))
113 (kill-region (point-min) (point-max))
114 ;;(insert "Content-Type: application/pgp-encrypted\n\n")
115 ;;(insert "Version: 1\n\n")
117 (insert-buffer cipher)
118 (goto-char (point-max))))))
123 (autoload 'gpg-sign-cleartext "gpg"))
125 (defun mml1991-gpg-sign (cont)
126 (let ((text (current-buffer))
128 (result-buffer (get-buffer-create "*GPG Result*")))
129 ;; Save MIME Content[^ ]+: headers from signing
130 (goto-char (point-min))
131 (while (looking-at "^Content[^ ]+:") (forward-line))
132 (if (> (point) (point-min))
134 (setq headers (buffer-substring (point-min) (point)))
135 (kill-region (point-min) (point))))
136 (goto-char (point-max))
139 (quoted-printable-decode-region (point-min) (point-max))
141 (unless (gpg-sign-cleartext text (setq signature (current-buffer))
144 (message-options-get 'message-sender))
145 (unless (> (point-max) (point-min))
146 (pop-to-buffer result-buffer)
147 (error "Sign error")))
148 (goto-char (point-min))
149 (while (re-search-forward "\r+$" nil t)
150 (replace-match "" t t))
151 (quoted-printable-encode-region (point-min) (point-max))
153 (kill-region (point-min) (point-max))
154 (if headers (insert headers))
156 (insert-buffer signature)
157 (goto-char (point-max)))))
159 (defun mml1991-gpg-encrypt (cont)
160 (let ((text (current-buffer))
162 (result-buffer (get-buffer-create "*GPG Result*")))
163 ;; Strip MIME Content[^ ]: headers since it will be ASCII ARMOURED
164 (goto-char (point-min))
165 (while (looking-at "^Content[^ ]+:") (forward-line))
166 (if (> (point) (point-min))
168 (kill-region (point-min) (point))))
169 (mm-with-unibyte-current-buffer-mule4
171 (unless (gpg-sign-encrypt
172 text (setq cipher (current-buffer))
176 (message-options-get 'message-recipients)
177 (message-options-set 'message-recipients
178 (read-string "Recipients: ")))
181 (message-options-get 'message-sender)
182 t t) ; armor & textmode
183 (unless (> (point-max) (point-min))
184 (pop-to-buffer result-buffer)
185 (error "Encrypt error")))
186 (goto-char (point-min))
187 (while (re-search-forward "\r+$" nil t)
188 (replace-match "" t t))
190 (kill-region (point-min) (point-max))
191 ;;(insert "Content-Type: application/pgp-encrypted\n\n")
192 ;;(insert "Version: 1\n\n")
194 (insert-buffer cipher)
195 (goto-char (point-max))))))
198 (defun mml1991-encrypt (cont)
199 (let ((func (nth 2 (assq mml1991-use mml1991-function-alist))))
202 (error "Cannot find encrypt function"))))
205 (defun mml1991-sign (cont)
206 (let ((func (nth 1 (assq mml1991-use mml1991-function-alist))))
209 (error "Cannot find sign function"))))
214 ;; coding: iso-8859-1
217 ;;; mml1991.el ends here