annotate lisp/tm/tm-pgp.el @ 80:1ce6082ce73f r20-0b90

Import from CVS: tag r20-0b90
author cvs
date Mon, 13 Aug 2007 09:06:37 +0200
parents c0c698873ce1
children 0d2f883870bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
1 ;;; tm-pgp.el --- tm-view internal methods for PGP.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
2
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
6 ;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
7 ;; Created: 1995/12/7
76
c0c698873ce1 Import from CVS: tag r20-0b33
cvs
parents: 70
diff changeset
8 ;; Version: $Id: tm-pgp.el,v 1.2 1996/12/28 21:03:15 steve Exp $
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
9 ;; Keywords: mail, news, MIME, multimedia, PGP, security
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
10
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
11 ;; This file is part of tm (Tools for MIME).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
12
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
13 ;; This program is free software; you can redistribute it and/or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
14 ;; modify it under the terms of the GNU General Public License as
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
15 ;; published by the Free Software Foundation; either version 2, or (at
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
16 ;; your option) any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
17
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
18 ;; This program is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
21 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
22
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
27
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
28 ;;; Commentary:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
29
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
30 ;; This module is based on 2 drafts about PGP MIME integration:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
31
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
32 ;; - draft-elkins-pem-pgp-04.txt
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
33 ;; ``MIME Security with Pretty Good Privacy (PGP)''
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
34 ;; by Michael Elkins <elkins@aero.org> (1996/6)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
35 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
36 ;; - draft-kazu-pgp-mime-00.txt
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
37 ;; ``PGP MIME Integration''
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
38 ;; by Kazuhiko Yamamoto <kazu@is.aist-nara.ac.jp> (1995/10)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
39 ;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
40 ;; These drafts may be contrary to each other. You should decide
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
41 ;; which you support.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
42
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
43 ;;; Code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
44
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
45 (require 'mailcrypt)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
46 (require 'tm-play)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
47
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
48
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
49 ;;; @ internal method for application/pgp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
50 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
51 ;;; It is based on draft-kazu-pgp-mime-00.txt
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
52
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
53 (defun mime-article/view-application/pgp (beg end cal)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
54 (let* ((cnum (mime-article/point-content-number beg))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
55 (cur-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
56 (new-name (format "%s-%s" (buffer-name) cnum))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
57 (mother mime::article/preview-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
58 (mode major-mode)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
59 code-converter str)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
60 (setq str (buffer-substring beg end))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
61 (switch-to-buffer new-name)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
62 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
63 (insert str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
64 (cond ((progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
65 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
66 (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE-+$" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
67 )
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
68 (mc-verify)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
69 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
70 (delete-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
71 (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
72 (and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
73 (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE-+\n\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
74 (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
75 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
76 (delete-region
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
77 (and (re-search-forward "^-+BEGIN PGP SIGNATURE-+")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
78 (match-beginning 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
79 (point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
80 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
81 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
82 (while (re-search-forward "^- -" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
83 (replace-match "-")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
84 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
85 (setq code-converter
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
86 (or
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
87 (cdr (assq mode mime-viewer/code-converter-alist))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
88 (function mime-viewer/default-code-convert-region)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
89 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
90 ((progn
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
91 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
92 (re-search-forward "^-+BEGIN PGP MESSAGE-+$" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
93 )
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
94 (as-binary-process (mc-decrypt))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
95 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
96 (delete-region (point-min)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
97 (and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
98 (search-forward "\n\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
99 (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
100 (setq code-converter (function mime-charset/decode-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
101 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
102 (setq major-mode 'mime/show-message-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
103 (setq mime::article/code-converter code-converter)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
104 (mime/viewer-mode mother)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
105 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
106
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
107 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
108 '((type . "application/pgp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
109 (method . mime-article/view-application/pgp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
110 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
111
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
112 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
113 '((type . "text/x-pgp")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
114 (method . mime-article/view-application/pgp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
115 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
116
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
117
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
118 ;;; @ Internal method for application/pgp-signature
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
119 ;;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
120 ;;; It is based on draft-elkins-pem-pgp-02.txt
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
121
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
122 (defvar tm-pgp::default-language 'en
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
123 "*Symbol of language for pgp.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
124 It should be ISO 639 2 letter language code such as en, ja, ...")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
125
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
126 (defvar tm-pgp::good-signature-regexp-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
127 '((en . "Good signature from user.*$"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
128 "Alist of language vs regexp to detect ``Good signature''.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
129
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
130 (defvar tm-pgp::key-expected-regexp-alist
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
131 '((en . "Key matching expected Key ID \\(\\S +\\) not found"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
132 "Alist of language vs regexp to detect ``Key expected''.")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
133
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
134 (defun mime::article/call-pgp-to-check-signature (output-buffer orig-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
135 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
136 (set-buffer output-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
137 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
138 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
139 (let* ((lang (or tm-pgp::default-language 'en))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
140 (status
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
141 (call-process-region (point-min)(point-max)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
142 "pgp" nil output-buffer nil orig-file
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
143 (format "+language=%s" lang)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
144 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
145 (regexp (cdr (assq lang tm-pgp::good-signature-regexp-alist)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
146 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
147 (if (= status 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
148 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
149 (set-buffer output-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
150 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
151 (message
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
152 (cond ((not (stringp regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
153 "Please specify right regexp for specified language")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
154 ((re-search-forward regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
155 (buffer-substring (match-beginning 0) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
156 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
157 (t
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
158 "Bad signature"
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
159 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
160 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
161
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
162 (defun mime-article/check-pgp-signature (beg end cal)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
163 (let* ((encoding (cdr (assq 'encoding cal)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
164 (cnum (mime-article/point-content-number beg))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
165 (rcnum (reverse cnum))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
166 (rmcnum (cdr rcnum))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
167 (knum (car rcnum))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
168 (onum (if (> knum 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
169 (1- knum)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
170 (1+ knum)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
171 (oinfo (mime-article/rcnum-to-cinfo (cons onum rmcnum)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
172 mime::article/content-info))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
173 status str kbuf
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
174 (basename (expand-file-name "tm" mime/tmp-dir))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
175 (orig-file (make-temp-name basename))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
176 (sig-file (concat orig-file ".sig"))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
177 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
178 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
179 (setq str (buffer-substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
180 (mime::content-info/point-min oinfo)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
181 (mime::content-info/point-max oinfo)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
182 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
183 (set-buffer (get-buffer-create mime/temp-buffer-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
184 (insert str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
185 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
186 (while (re-search-forward "\n" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
187 (replace-match "\r\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
188 )
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
189 (let ((mc-flag nil) ; for Mule
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
190 (file-coding-system *noconv*)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
191 kanji-flag ; for NEmacs
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
192 (emx-binary-mode t) ; for OS/2
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
193 jka-compr-compression-info-list ; for jka-compr
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
194 jam-zcat-filename-list ; for jam-zcat
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
195 require-final-newline)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
196 (write-file orig-file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
197 )
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
198 (kill-buffer (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
199 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
200 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
201 (mime-article/show-output-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
202 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
203 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
204 (setq str (buffer-substring
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
205 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
206 (goto-char beg)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
207 (and (search-forward "\n\n")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
208 (match-end 0)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
209 end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
210 (set-buffer (setq kbuf (get-buffer-create mime/temp-buffer-name)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
211 (insert str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
212 (mime-decode-region (point-min)(point-max) encoding)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
213 (let ((mc-flag nil) ; for Mule
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
214 (file-coding-system *noconv*)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
215 kanji-flag ; for NEmacs
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
216 (emx-binary-mode t) ; for OS/2
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
217 jka-compr-compression-info-list ; for jka-compr
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
218 jam-zcat-filename-list ; for jam-zcat
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
219 require-final-newline)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
220 (write-file sig-file)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
221 )
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
222 ;;(get-buffer-create mime/output-buffer-name)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
223 (or (mime::article/call-pgp-to-check-signature
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
224 mime/output-buffer-name orig-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
225 (let (pgp-id)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
226 (save-excursion
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
227 (set-buffer mime/output-buffer-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
228 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
229 (let ((regexp (cdr (assq (or tm-pgp::default-language 'en)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
230 tm-pgp::key-expected-regexp-alist))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
231 (cond ((not (stringp regexp))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
232 (message
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
233 "Please specify right regexp for specified language")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
234 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
235 ((re-search-forward regexp nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
236 (setq pgp-id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
237 (concat "0x" (buffer-substring-no-properties
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
238 (match-beginning 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
239 (match-end 1))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
240 ))))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
241 (if (and pgp-id
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
242 (y-or-n-p
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
243 (format "Key %s not found; attempt to fetch? " pgp-id))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
244 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
245 (progn
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
246 (mc-pgp-fetch-key (cons nil pgp-id))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
247 (mime::article/call-pgp-to-check-signature
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
248 mime/output-buffer-name orig-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
249 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
250 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
251 (let ((other-window-scroll-buffer mime/output-buffer-name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
252 (scroll-other-window 8)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
253 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
254 (kill-buffer kbuf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
255 (delete-file orig-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
256 (delete-file sig-file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
257 )))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
258
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
259 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
260 '((type . "application/pgp-signature")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
261 (method . mime-article/check-pgp-signature)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
262 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
263
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
264
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
265 ;;; @ Internal method for application/pgp-encrypted
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
266 ;;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
267 ;;; It is based on draft-elkins-pem-pgp-02.txt
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
268
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
269 (defun mime-article/decrypt-pgp (beg end cal)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
270 (let* ((cnum (mime-article/point-content-number beg))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
271 (rcnum (reverse cnum))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
272 (rmcnum (cdr rcnum))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
273 (knum (car rcnum))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
274 (onum (if (> knum 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
275 (1- knum)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
276 (1+ knum)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
277 (oinfo (mime-article/rcnum-to-cinfo (cons onum rmcnum)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
278 mime::article/content-info))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
279 (obeg (mime::content-info/point-min oinfo))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
280 (oend (mime::content-info/point-max oinfo))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
281 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
282 (mime-article/view-application/pgp obeg oend cal)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
283 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
284
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
285 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
286 '((type . "application/pgp-encrypted")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
287 (method . mime-article/decrypt-pgp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
288 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
289
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
290
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
291 ;;; @ Internal method for application/pgp-keys
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
292 ;;;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
293 ;;; It is based on draft-elkins-pem-pgp-02.txt
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
294
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
295 (autoload 'mc-snarf-keys "mc-toplev")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
296
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
297 (defun mime-article/add-pgp-keys (beg end cal)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
298 (let* ((cnum (mime-article/point-content-number beg))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
299 (cur-buf (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
300 (new-name (format "%s-%s" (buffer-name) cnum))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
301 (mother mime::article/preview-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
302 (charset (cdr (assoc "charset" cal)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
303 (encoding (cdr (assq 'encoding cal)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
304 (mode major-mode)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
305 str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
306 (setq str (buffer-substring beg end))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
307 (switch-to-buffer new-name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
308 (setq buffer-read-only nil)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
309 (erase-buffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
310 (insert str)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
311 (goto-char (point-min))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
312 (if (re-search-forward "^\n" nil t)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
313 (delete-region (point-min) (match-end 0))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
314 )
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
315 (mime-decode-region (point-min)(point-max) encoding)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 22
diff changeset
316 (mc-snarf-keys)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
317 (kill-buffer (current-buffer))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
318 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
319
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
320 (set-atype 'mime/content-decoding-condition
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
321 '((type . "application/pgp-keys")
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
322 (method . mime-article/add-pgp-keys)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
323 ))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
324
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
325
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
326 ;;; @ end
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
327 ;;;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
328
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
329 (provide 'tm-pgp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
330
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
331 (run-hooks 'tm-pgp-load-hook)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
332
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents:
diff changeset
333 ;;; tm-pgp.el ends here