annotate lisp/pgg.el @ 110855:bec49af30c2f

Merge changes from emacs-23 branch.
author Juanma Barranquero <lekktu@gmail.com>
date Fri, 08 Oct 2010 12:14:47 +0200
parents 494ea2fb03d7
children 236342431786
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1 ;;; pgg.el --- glue for the various PGP implementations.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105372
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
5
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
6 ;; Author: Daiki Ueno <ueno@unixuser.org>
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
7 ;; Symmetric encryption added by: Sascha Wilde <wilde@sha-bang.de>
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8 ;; Created: 1999/10/28
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9 ;; Keywords: PGP
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
12
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; (at your option) any later version.
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
17
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
22
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27
100652
abcae147ec08 Add obsolescence info.
Daiki Ueno <ueno@unixuser.org>
parents: 94678
diff changeset
28 ;; This file is on its way to obsolescence, waiting for allout.el to
abcae147ec08 Add obsolescence info.
Daiki Ueno <ueno@unixuser.org>
parents: 94678
diff changeset
29 ;; switch to EPG.
abcae147ec08 Add obsolescence info.
Daiki Ueno <ueno@unixuser.org>
parents: 94678
diff changeset
30
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 ;;; Code:
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33 (require 'pgg-def)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 (require 'pgg-parse)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35 (autoload 'run-at-time "timer")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37 ;; Don't merge these two `eval-when-compile's.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38 (eval-when-compile
87209
bc4976b7380e Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 86496
diff changeset
39 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40 (require 'cl))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 ;;; @ utility functions
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43 ;;;
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
44
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
45 (eval-when-compile
110637
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
46 (when (featurep 'xemacs)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
47 (defmacro pgg-run-at-time-1 (time repeat function args)
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
48 (if (condition-case nil
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
49 (let ((delete-itimer 'delete-itimer)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
50 (itimer-driver-start 'itimer-driver-start)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
51 (itimer-value 'itimer-value)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
52 (start-itimer 'start-itimer))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
53 (unless (or (symbol-value 'itimer-process)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
54 (symbol-value 'itimer-timer))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
55 (funcall itimer-driver-start))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
56 ;; Check whether there is a bug to which the difference of
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
57 ;; the present time and the time when the itimer driver was
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
58 ;; woken up is subtracted from the initial itimer value.
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
59 (let* ((inhibit-quit t)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
60 (ctime (current-time))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
61 (itimer-timer-last-wakeup
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
62 (prog1
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
63 ctime
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
64 (setcar ctime (1- (car ctime)))))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
65 (itimer-list nil)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
66 (itimer (funcall start-itimer "pgg-run-at-time"
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
67 'ignore 5)))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
68 (sleep-for 0.1) ;; Accept the timeout interrupt.
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
69 (prog1
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
70 (> (funcall itimer-value itimer) 0)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
71 (funcall delete-itimer itimer))))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
72 (error nil))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
73 `(let ((time ,time))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
74 (apply #'start-itimer "pgg-run-at-time"
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
75 ,function (if time (max time 1e-9) 1e-9)
110637
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
76 ,repeat nil t ,args))
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
77 `(let ((time ,time)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
78 (itimers (list nil)))
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
79 (setcar
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
80 itimers
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
81 (apply #'start-itimer "pgg-run-at-time"
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
82 (lambda (itimers repeat function &rest args)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
83 (let ((itimer (car itimers)))
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
84 (if repeat
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
85 (progn
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
86 (set-itimer-function
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
87 itimer
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
88 (lambda (itimer repeat function &rest args)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
89 (set-itimer-restart itimer repeat)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
90 (set-itimer-function itimer function)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
91 (set-itimer-function-arguments itimer args)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
92 (apply function args)))
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
93 (set-itimer-function-arguments
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
94 itimer
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
95 (append (list itimer repeat function) args)))
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
96 (set-itimer-function
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
97 itimer
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
98 (lambda (itimer function &rest args)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
99 (delete-itimer itimer)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
100 (apply function args)))
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
101 (set-itimer-function-arguments
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
102 itimer
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
103 (append (list itimer function) args)))))
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
104 1e-9 (if time (max time 1e-9) 1e-9)
494ea2fb03d7 Remove Emacs 21 stuff.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
105 nil t itimers ,repeat ,function ,args)))))))
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
106
87300
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
107 (eval-and-compile
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
108 (if (featurep 'xemacs)
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
109 (progn
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
110 (defun pgg-run-at-time (time repeat function &rest args)
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
111 "Emulating function run as `run-at-time'.
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
112 TIME should be nil meaning now, or a number of seconds from now.
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
113 Return an itimer object which can be used in either `delete-itimer'
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
114 or `cancel-timer'."
87300
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
115 (pgg-run-at-time-1 time repeat function args))
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
116 (defun pgg-cancel-timer (timer)
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
117 "Emulate cancel-timer for xemacs."
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
118 (let ((delete-itimer 'delete-itimer))
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
119 (funcall delete-itimer timer))))
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
120 (defalias 'pgg-run-at-time 'run-at-time)
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
121 (defalias 'pgg-cancel-timer 'cancel-timer)))
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
122
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
123 (defun pgg-invoke (func scheme &rest args)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 (progn
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
125 (require (intern (format "pgg-%s" scheme)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 (apply 'funcall (intern (format "pgg-%s-%s" scheme func)) args)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128 (put 'pgg-save-coding-system 'lisp-indent-function 2)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
130 (defmacro pgg-save-coding-system (start end &rest body)
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
131 `(if (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 (let ((buffer (current-buffer)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 (let (buffer-undo-list)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 (insert-buffer-substring buffer ,start ,end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136 (encode-coding-region (point-min)(point-max)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 buffer-file-coding-system)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 (prog1 (save-excursion ,@body)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 (push nil buffer-undo-list)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 (ignore-errors (undo))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141 (save-restriction
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 (narrow-to-region ,start ,end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 ,@body)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145 (defun pgg-temp-buffer-show-function (buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 (let ((window (or (get-buffer-window buffer 'visible)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 (split-window-vertically))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148 (set-window-buffer window buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (shrink-window-if-larger-than-buffer window)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
151 ;; XXX `pgg-display-output-buffer' is a horrible name for this function.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
152 ;; It should be something like `pgg-situate-output-or-display-error'.
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153 (defun pgg-display-output-buffer (start end status)
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
154 "Situate en/decryption results or pop up an error buffer.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
155
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
156 Text from START to END is replaced by contents of output buffer if STATUS
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
157 is true, or else the output buffer is displayed."
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 (if status
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
159 (pgg-situate-output start end)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
160 (pgg-display-error-buffer)))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
161
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
162 (defun pgg-situate-output (start end)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
163 "Place en/decryption result in place of current text from START to END."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
164 (delete-region start end)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
165 (insert-buffer-substring pgg-output-buffer)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
166 (decode-coding-region start (point) buffer-file-coding-system))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
167
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
168 (defun pgg-display-error-buffer ()
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
169 "Pop up an error buffer indicating the reason for an en/decryption failure."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
170 (let ((temp-buffer-show-function
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
171 (function pgg-temp-buffer-show-function)))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
172 (with-output-to-temp-buffer pgg-echo-buffer
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
173 (set-buffer standard-output)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
174 (insert-buffer-substring pgg-errors-buffer))))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
175
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176 (defvar pgg-passphrase-cache (make-vector 7 0))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
178 (defvar pgg-pending-timers (make-vector 7 0)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
179 "Hash table for managing scheduled pgg cache management timers.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
180
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
181 We associate key and timer, so the timer can be cancelled if a new
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
182 timeout for the key is set while an old one is still pending.")
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
183
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
184 (defun pgg-read-passphrase (prompt &optional key notruncate)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
185 "Using PROMPT, obtain passphrase for KEY from cache or user.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
186
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
187 Truncate the key to 8 trailing characters unless NOTRUNCATE is true
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
188 \(default false).
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
189
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
190 Custom variables `pgg-cache-passphrase' and `pgg-passphrase-cache-expiry'
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
191 regulate cache behavior."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
192 (or (pgg-read-passphrase-from-cache key notruncate)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 (read-passwd prompt)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
195 (defun pgg-read-passphrase-from-cache (key &optional notruncate)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
196 "Obtain passphrase for KEY from time-limited passphrase cache.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
197
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
198 Truncate the key to 8 trailing characters unless NOTRUNCATE is true
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
199 \(default false).
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
200
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
201 Custom variables `pgg-cache-passphrase' and `pgg-passphrase-cache-expiry'
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
202 regulate cache behavior."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
203 (and pgg-cache-passphrase
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
204 key (or notruncate
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
205 (setq key (pgg-truncate-key-identifier key)))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
206 (symbol-value (intern-soft key pgg-passphrase-cache))))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
207
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
208 (defun pgg-add-passphrase-to-cache (key passphrase &optional notruncate)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
209 "Associate KEY with PASSPHRASE in time-limited passphrase cache.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
210
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
211 Truncate the key to 8 trailing characters unless NOTRUNCATE is true
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
212 \(default false).
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
213
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
214 Custom variables `pgg-cache-passphrase' and `pgg-passphrase-cache-expiry'
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
215 regulate cache behavior."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
216
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
217 (let* ((key (if notruncate key (pgg-truncate-key-identifier key)))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
218 (interned-timer-key (intern-soft key pgg-pending-timers))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
219 (old-timer (symbol-value interned-timer-key))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
220 new-timer)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
221 (when old-timer
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
222 (cancel-timer old-timer)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
223 (unintern interned-timer-key pgg-pending-timers))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
224 (set (intern key pgg-passphrase-cache)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
225 passphrase)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
226 (set (intern key pgg-pending-timers)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
227 (pgg-run-at-time pgg-passphrase-cache-expiry nil
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
228 #'pgg-remove-passphrase-from-cache
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
229 key notruncate))))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
230
72653
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
231 (if (fboundp 'clear-string)
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
232 (defalias 'pgg-clear-string 'clear-string)
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
233 (defun pgg-clear-string (string)
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
234 (fillarray string ?_)))
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
235
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
236 (declare-function pgg-clear-string "pgg" (string))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
237
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
238 (defun pgg-remove-passphrase-from-cache (key &optional notruncate)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
239 "Omit passphrase associated with KEY in time-limited passphrase cache.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
240
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
241 Truncate the key to 8 trailing characters unless NOTRUNCATE is true
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
242 \(default false).
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
243
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
244 This is a no-op if there is not entry for KEY (eg, it's already expired.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
245
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
246 The memory for the passphrase is filled with underscores to clear any
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
247 references to it.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
248
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
249 Custom variables `pgg-cache-passphrase' and `pgg-passphrase-cache-expiry'
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
250 regulate cache behavior."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
251 (let* ((passphrase (pgg-read-passphrase-from-cache key notruncate))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
252 (key (if notruncate key (pgg-truncate-key-identifier key)))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
253 (interned-timer-key (intern-soft key pgg-pending-timers))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
254 (old-timer (symbol-value interned-timer-key)))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
255 (when passphrase
72653
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
256 (pgg-clear-string passphrase)
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
257 (unintern key pgg-passphrase-cache))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
258 (when old-timer
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
259 (pgg-cancel-timer old-timer)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
260 (unintern interned-timer-key pgg-pending-timers))))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
261
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
262 (defmacro pgg-convert-lbt-region (start end lbt)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
263 `(let ((pgg-conversion-end (set-marker (make-marker) ,end)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
264 (goto-char ,start)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
265 (case ,lbt
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266 (CRLF
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
267 (while (progn
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
268 (end-of-line)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
269 (> (marker-position pgg-conversion-end) (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
270 (insert "\r")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
271 (forward-line 1)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
272 (LF
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273 (while (re-search-forward "\r$" pgg-conversion-end t)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 (replace-match ""))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
275
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
276 (put 'pgg-as-lbt 'lisp-indent-function 3)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
277
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
278 (defmacro pgg-as-lbt (start end lbt &rest body)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
279 `(let ((inhibit-read-only t)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
280 buffer-read-only
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
281 buffer-undo-list)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
282 (pgg-convert-lbt-region ,start ,end ,lbt)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
283 (let ((,end (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
284 ,@body)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
285 (push nil buffer-undo-list)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
286 (ignore-errors (undo))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
287
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
288 (put 'pgg-process-when-success 'lisp-indent-function 0)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
289
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
290 (defmacro pgg-process-when-success (&rest body)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
291 `(with-current-buffer pgg-output-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
292 (if (zerop (buffer-size)) nil ,@body t)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
294 (defalias 'pgg-make-temp-file
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
295 (if (fboundp 'make-temp-file)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
296 'make-temp-file
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
297 (lambda (prefix &optional dir-flag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
298 (let ((file (expand-file-name
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
299 (make-temp-name prefix)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
300 (if (fboundp 'temp-directory)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
301 (temp-directory)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
302 temporary-file-directory))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
303 (if dir-flag
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
304 (make-directory file))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
305 file))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
306
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
307 ;;; @ interface functions
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308 ;;;
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
309
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
310 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
311 (defun pgg-encrypt-region (start end rcpts &optional sign passphrase)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
312 "Encrypt the current region between START and END for RCPTS.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
313
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
314 If optional argument SIGN is non-nil, do a combined sign and encrypt.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
315
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
316 If optional PASSPHRASE is not specified, it will be obtained from the
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
317 passphrase cache or user."
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
318 (interactive
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
319 (list (region-beginning)(region-end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
320 (split-string (read-string "Recipients: ") "[ \t,]+")))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
321 (let ((status
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
322 (pgg-save-coding-system start end
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
323 (pgg-invoke "encrypt-region" (or pgg-scheme pgg-default-scheme)
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
324 (point-min) (point-max) rcpts sign passphrase))))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
325 (when (called-interactively-p 'interactive)
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
326 (pgg-display-output-buffer start end status))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
327 status))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
328
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
329 ;;;###autoload
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
330 (defun pgg-encrypt-symmetric-region (start end &optional passphrase)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
331 "Encrypt the current region between START and END symmetric with passphrase.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
332
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
333 If optional PASSPHRASE is not specified, it will be obtained from the
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
334 cache or user."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
335 (interactive "r")
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
336 (let ((status
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
337 (pgg-save-coding-system start end
77932
491c39d86dc0 (pgg-sign-region, pgg-sign): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 75347
diff changeset
338 (pgg-invoke "encrypt-symmetric-region"
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
339 (or pgg-scheme pgg-default-scheme)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
340 (point-min) (point-max) passphrase))))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
341 (when (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
342 (pgg-display-output-buffer start end status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
344
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
345 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
346 (defun pgg-encrypt-symmetric (&optional start end passphrase)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
347 "Encrypt the current buffer using a symmetric, rather than key-pair, cipher.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
348
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
349 If optional arguments START and END are specified, only encrypt within
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
350 the region.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
351
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
352 If optional PASSPHRASE is not specified, it will be obtained from the
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
353 passphrase cache or user."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
354 (interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
355 (let* ((start (or start (point-min)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
356 (end (or end (point-max)))
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
357 (status (pgg-encrypt-symmetric-region start end passphrase)))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
358 (when (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
359 (pgg-display-output-buffer start end status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
361
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
362 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
363 (defun pgg-encrypt (rcpts &optional sign start end passphrase)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
364 "Encrypt the current buffer for RCPTS.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
365
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
366 If optional argument SIGN is non-nil, do a combined sign and encrypt.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
367
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
368 If optional arguments START and END are specified, only encrypt within
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
369 the region.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
370
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
371 If optional PASSPHRASE is not specified, it will be obtained from the
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
372 passphrase cache or user."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
373 (interactive (list (split-string (read-string "Recipients: ") "[ \t,]+")))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
374 (let* ((start (or start (point-min)))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
375 (end (or end (point-max)))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
376 (status (pgg-encrypt-region start end rcpts sign passphrase)))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
377 (when (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
378 (pgg-display-output-buffer start end status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
379 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
380
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
382 (defun pgg-decrypt-region (start end &optional passphrase)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
383 "Decrypt the current region between START and END.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
384
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
385 If optional PASSPHRASE is not specified, it will be obtained from the
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
386 passphrase cache or user."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
387 (interactive "r")
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
388 (let* ((buf (current-buffer))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
389 (status
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
390 (pgg-save-coding-system start end
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
391 (pgg-invoke "decrypt-region" (or pgg-scheme pgg-default-scheme)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
392 (point-min) (point-max) passphrase))))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
393 (when (called-interactively-p 'interactive)
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
394 (pgg-display-output-buffer start end status))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
395 status))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
396
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
397 ;;;###autoload
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
398 (defun pgg-decrypt (&optional start end passphrase)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
399 "Decrypt the current buffer.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
400
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
401 If optional arguments START and END are specified, only decrypt within
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
402 the region.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
403
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
404 If optional PASSPHRASE is not specified, it will be obtained from the
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
405 passphrase cache or user."
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
406 (interactive "")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407 (let* ((start (or start (point-min)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
408 (end (or end (point-max)))
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
409 (status (pgg-decrypt-region start end passphrase)))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
410 (when (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411 (pgg-display-output-buffer start end status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
412 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
413
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
415 (defun pgg-sign-region (start end &optional cleartext passphrase)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
416 "Make the signature from text between START and END.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
417
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
418 If the optional 3rd argument CLEARTEXT is non-nil, it does not create
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
419 a detached signature.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
420
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
421 If this function is called interactively, CLEARTEXT is enabled
77932
491c39d86dc0 (pgg-sign-region, pgg-sign): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 75347
diff changeset
422 and the output is displayed.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
423
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
424 If optional PASSPHRASE is not specified, it will be obtained from the
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
425 passphrase cache or user."
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
426 (interactive "r")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
427 (let ((status (pgg-save-coding-system start end
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
428 (pgg-invoke "sign-region" (or pgg-scheme pgg-default-scheme)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
429 (point-min) (point-max)
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
430 (or (called-interactively-p 'interactive)
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
431 cleartext)
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
432 passphrase))))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
433 (when (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
434 (pgg-display-output-buffer start end status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
435 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
436
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
437 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
438 (defun pgg-sign (&optional cleartext start end passphrase)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
439 "Sign the current buffer.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
440
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
441 If the optional argument CLEARTEXT is non-nil, it does not create a
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
442 detached signature.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
443
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
444 If optional arguments START and END are specified, only sign data
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
445 within the region.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
446
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
447 If this function is called interactively, CLEARTEXT is enabled
77932
491c39d86dc0 (pgg-sign-region, pgg-sign): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 75347
diff changeset
448 and the output is displayed.
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
449
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
450 If optional PASSPHRASE is not specified, it will be obtained from the
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
451 passphrase cache or user."
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
452 (interactive "")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
453 (let* ((start (or start (point-min)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
454 (end (or end (point-max)))
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
455 (status (pgg-sign-region start end
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
456 (or (called-interactively-p 'interactive)
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
457 cleartext)
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
458 passphrase)))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
459 (when (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
460 (pgg-display-output-buffer start end status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
461 status))
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
462
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
463 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
464 (defun pgg-verify-region (start end &optional signature fetch)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
465 "Verify the current region between START and END.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
466 If the optional 3rd argument SIGNATURE is non-nil, it is treated as
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
467 the detached signature of the current region.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
468
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
469 If the optional 4th argument FETCH is non-nil, we attempt to fetch the
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
470 signer's public key from `pgg-default-keyserver-address'."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
471 (interactive "r")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
472 (let* ((packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
473 (if (null signature) nil
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
474 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
475 (buffer-disable-undo)
108287
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 106815
diff changeset
476 (unless (featurep 'xemacs)
c0d13767677a Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 106815
diff changeset
477 (set-buffer-multibyte nil))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
478 (insert-file-contents signature)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
479 (cdr (assq 2 (pgg-decode-armor-region
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
480 (point-min)(point-max)))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
481 (key (cdr (assq 'key-identifier packet)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
482 status keyserver)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
483 (and (stringp key)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
484 pgg-query-keyserver
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
485 (setq key (concat "0x" (pgg-truncate-key-identifier key)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
486 (null (pgg-lookup-key key))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
487 (or fetch (called-interactively-p 'interactive))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
488 (y-or-n-p (format "Key %s not found; attempt to fetch? " key))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
489 (setq keyserver
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
490 (or (cdr (assq 'preferred-key-server packet))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
491 pgg-default-keyserver-address))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
492 (pgg-fetch-key keyserver key))
77932
491c39d86dc0 (pgg-sign-region, pgg-sign): Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 75347
diff changeset
493 (setq status
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
494 (pgg-save-coding-system start end
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
495 (pgg-invoke "verify-region" (or pgg-scheme pgg-default-scheme)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
496 (point-min) (point-max) signature)))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
497 (when (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
498 (let ((temp-buffer-show-function
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
499 (function pgg-temp-buffer-show-function)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
500 (with-output-to-temp-buffer pgg-echo-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
501 (set-buffer standard-output)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
502 (insert-buffer-substring (if status pgg-output-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
503 pgg-errors-buffer)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
504 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
505
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
506 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
507 (defun pgg-verify (&optional signature fetch start end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
508 "Verify the current buffer.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
509 If the optional argument SIGNATURE is non-nil, it is treated as
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
510 the detached signature of the current region.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
511 If the optional argument FETCH is non-nil, we attempt to fetch the
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
512 signer's public key from `pgg-default-keyserver-address'.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
513 If optional arguments START and END are specified, only verify data
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
514 within the region."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
515 (interactive "")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
516 (let* ((start (or start (point-min)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
517 (end (or end (point-max)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
518 (status (pgg-verify-region start end signature fetch)))
105372
bd2966850aac Use `called-interactively-p' instead of `interactive-p'.
Juanma Barranquero <lekktu@gmail.com>
parents: 100908
diff changeset
519 (when (called-interactively-p 'interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
520 (let ((temp-buffer-show-function
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
521 (function pgg-temp-buffer-show-function)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
522 (with-output-to-temp-buffer pgg-echo-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
523 (set-buffer standard-output)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
524 (insert-buffer-substring (if status pgg-output-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
525 pgg-errors-buffer)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
526 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
527
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
528 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
529 (defun pgg-insert-key ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
530 "Insert the ASCII armored public key."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
531 (interactive)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
532 (pgg-invoke "insert-key" (or pgg-scheme pgg-default-scheme)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
533
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
534 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
535 (defun pgg-snarf-keys-region (start end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
536 "Import public keys in the current region between START and END."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
537 (interactive "r")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
538 (pgg-save-coding-system start end
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
539 (pgg-invoke "snarf-keys-region" (or pgg-scheme pgg-default-scheme)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
540 start end)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
541
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
542 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
543 (defun pgg-snarf-keys ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
544 "Import public keys in the current buffer."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
545 (interactive "")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
546 (pgg-snarf-keys-region (point-min) (point-max)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
547
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
548 (defun pgg-lookup-key (string &optional type)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
549 (pgg-invoke "lookup-key" (or pgg-scheme pgg-default-scheme) string type))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
550
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
551 (defvar pgg-insert-url-function (function pgg-insert-url-with-w3))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
552
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
553 (defun pgg-insert-url-with-w3 (url)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
554 (ignore-errors
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
555 (require 'url)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
556 (let (buffer-file-name)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
557 (url-insert-file-contents url))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
558
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
559 (defvar pgg-insert-url-extra-arguments nil)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
560 (defvar pgg-insert-url-program nil)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
561
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
562 (defun pgg-insert-url-with-program (url)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
563 (let ((args (copy-sequence pgg-insert-url-extra-arguments))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
564 process)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
565 (insert
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
566 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
567 (setq process
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
568 (apply #'start-process " *PGG url*" (current-buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
569 pgg-insert-url-program (nconc args (list url))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
570 (set-process-sentinel process #'ignore)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
571 (while (eq 'run (process-status process))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
572 (accept-process-output process 5))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
573 (delete-process process)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
574 (if (and process (eq 'run (process-status process)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
575 (interrupt-process process))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
576 (buffer-string)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
577
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
578 (defun pgg-fetch-key (keyserver key)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
579 "Attempt to fetch a KEY from KEYSERVER for addition to PGP or GnuPG keyring."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
580 (with-current-buffer (get-buffer-create pgg-output-buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
581 (buffer-disable-undo)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
582 (erase-buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
583 (let ((proto (if (string-match "^[a-zA-Z\\+\\.\\\\-]+:" keyserver)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
584 (substring keyserver 0 (1- (match-end 0))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
585 (save-excursion
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
586 (funcall pgg-insert-url-function
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
587 (if proto keyserver
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
588 (format "http://%s:11371/pks/lookup?op=get&search=%s"
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
589 keyserver key))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
590 (when (re-search-forward "^-+BEGIN" nil 'last)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
591 (delete-region (point-min) (match-beginning 0))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
592 (when (re-search-forward "^-+END" nil t)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
593 (delete-region (progn (end-of-line) (point))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
594 (point-max)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
595 (insert "\n")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
596 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
597 (insert-buffer-substring pgg-output-buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
598 (pgg-snarf-keys-region (point-min)(point-max)))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
599
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
600
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
601 (provide 'pgg)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
602
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
603 ;;; pgg.el ends here