annotate lisp/pgg.el @ 92310:0801285155e7

(menu-bar-search-menu, menu-bar-replace-menu): Capitalize "Tagged Files". (minibuffer-local-map): Add menu items for next/previous history elements and isearch history forward/backward.
author Juri Linkov <juri@jurta.org>
date Thu, 28 Feb 2008 20:46:12 +0000
parents 107ccd98fa12
children 1e3a407766b9
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,
79721
73661ddc7ac7 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
4 ;; 2005, 2006, 2007, 2008 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
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
78236
9355f9b7bbff Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 77932
diff changeset
15 ;; the Free Software Foundation; either version 3, or (at your option)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
16 ;; any later version.
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
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
26 ;; Boston, MA 02110-1301, USA.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
29
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30 ;;; Code:
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32 (require 'pgg-def)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33 (require 'pgg-parse)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 (autoload 'run-at-time "timer")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36 ;; 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
37 (eval-when-compile
87209
bc4976b7380e Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 86496
diff changeset
38 (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
39 (require 'cl))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41 ;;; @ utility functions
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 ;;;
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
44 (eval-when-compile
87300
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
45 ;; Define it as a null macro for Emacs in order to suppress a byte
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
46 ;; compile warning that Emacs 21 issues.
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
47 (defmacro pgg-run-at-time-1 (time repeat function args)
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
48 (when (featurep 'xemacs)
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
49 (if (condition-case nil
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
50 (let ((delete-itimer 'delete-itimer)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
51 (itimer-driver-start 'itimer-driver-start)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
52 (itimer-value 'itimer-value)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
53 (start-itimer 'start-itimer))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
54 (unless (or (symbol-value 'itimer-process)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
55 (symbol-value 'itimer-timer))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
56 (funcall itimer-driver-start))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
57 ;; 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
58 ;; 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
59 ;; 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
60 (let* ((inhibit-quit t)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
61 (ctime (current-time))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
62 (itimer-timer-last-wakeup
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
63 (prog1
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
64 ctime
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
65 (setcar ctime (1- (car ctime)))))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
66 (itimer-list nil)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
67 (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
68 'ignore 5)))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
69 (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
70 (prog1
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
71 (> (funcall itimer-value itimer) 0)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
72 (funcall delete-itimer itimer))))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
73 (error nil))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
74 `(let ((time ,time))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
75 (apply #'start-itimer "pgg-run-at-time"
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
76 ,function (if time (max time 1e-9) 1e-9)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
77 ,repeat nil t ,args)))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
78 `(let ((time ,time)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
79 (itimers (list nil)))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
80 (setcar
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
81 itimers
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
82 (apply #'start-itimer "pgg-run-at-time"
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
83 (lambda (itimers repeat function &rest args)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
84 (let ((itimer (car itimers)))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
85 (if repeat
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
86 (progn
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
87 (set-itimer-function
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
88 itimer
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
89 (lambda (itimer repeat function &rest args)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
90 (set-itimer-restart itimer repeat)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
91 (set-itimer-function itimer function)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
92 (set-itimer-function-arguments itimer args)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
93 (apply function args)))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
94 (set-itimer-function-arguments
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
95 itimer
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
96 (append (list itimer repeat function) args)))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
97 (set-itimer-function
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
98 itimer
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
99 (lambda (itimer function &rest args)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
100 (delete-itimer itimer)
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
101 (apply function args)))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
102 (set-itimer-function-arguments
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
103 itimer
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
104 (append (list itimer function) args)))))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
105 1e-9 (if time (max time 1e-9) 1e-9)
87300
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
106 nil t itimers ,repeat ,function ,args))))))
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
107
87300
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
108 (eval-and-compile
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
109 (if (featurep 'xemacs)
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
110 (progn
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
111 (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
112 "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
113 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
114 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
115 or `cancel-timer'."
87300
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
116 (pgg-run-at-time-1 time repeat function args))
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
117 (defun pgg-cancel-timer (timer)
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
118 "Emulate cancel-timer for xemacs."
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
119 (let ((delete-itimer 'delete-itimer))
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
120 (funcall delete-itimer timer))))
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
121 (defalias 'pgg-run-at-time 'run-at-time)
b968c7f9a8b4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87209
diff changeset
122 (defalias 'pgg-cancel-timer 'cancel-timer)))
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
123
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 (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
125 (progn
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 (require (intern (format "pgg-%s" scheme)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127 (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
128
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 (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
130
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131 (defmacro pgg-save-coding-system (start end &rest body)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 `(if (interactive-p)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 (let ((buffer (current-buffer)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 (let (buffer-undo-list)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136 (insert-buffer-substring buffer ,start ,end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 (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
138 buffer-file-coding-system)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 (prog1 (save-excursion ,@body)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 (push nil buffer-undo-list)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141 (ignore-errors (undo))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 (save-restriction
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 (narrow-to-region ,start ,end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144 ,@body)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146 (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
147 (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
148 (split-window-vertically))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 (set-window-buffer window buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 (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
151
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
152 ;; 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
153 ;; 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
154 (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
155 "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
156
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
157 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
158 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
159 (if status
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
160 (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
161 (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
162
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
163 (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
164 "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
165 (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
166 (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
167 (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
168
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
169 (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
170 "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
171 (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
172 (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
173 (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
174 (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
175 (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
176
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 (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
178
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
179 (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
180 "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
181
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
182 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
183 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
184
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
185 (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
186 "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
187
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
188 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
189 \(default false).
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
190
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
191 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
192 regulate cache behavior."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
193 (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
194 (read-passwd prompt)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
195
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
196 (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
197 "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
198
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
199 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
200 \(default false).
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
201
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
202 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
203 regulate cache behavior."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
204 (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
205 key (or notruncate
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
206 (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
207 (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
208
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
209 (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
210 "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
211
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
212 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
213 \(default false).
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
214
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
215 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
216 regulate cache behavior."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
217
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
218 (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
219 (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
220 (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
221 new-timer)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
222 (when old-timer
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
223 (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
224 (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
225 (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
226 passphrase)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
227 (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
228 (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
229 #'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
230 key notruncate))))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
231
72653
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
232 (if (fboundp 'clear-string)
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
233 (defalias 'pgg-clear-string 'clear-string)
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
234 (defun pgg-clear-string (string)
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
235 (fillarray string ?_)))
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
236
86496
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
237 (declare-function pgg-clear-string "pgg" (string))
e793ef63bdb9 (pgg-clear-string): Declare as a function.
Glenn Morris <rgm@gnu.org>
parents: 82140
diff changeset
238
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
239 (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
240 "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
241
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
242 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
243 \(default false).
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
244
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
245 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
246
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
247 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
248 references to it.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
249
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
250 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
251 regulate cache behavior."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
252 (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
253 (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
254 (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
255 (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
256 (when passphrase
72653
87c011891481 Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 68651
diff changeset
257 (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
258 (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
259 (when old-timer
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
260 (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
261 (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
262
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
263 (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
264 `(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
265 (goto-char ,start)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266 (case ,lbt
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
267 (CRLF
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
268 (while (progn
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
269 (end-of-line)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
270 (> (marker-position pgg-conversion-end) (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
271 (insert "\r")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
272 (forward-line 1)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273 (LF
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 (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
275 (replace-match ""))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
276
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
277 (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
278
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
279 (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
280 `(let ((inhibit-read-only t)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
281 buffer-read-only
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
282 buffer-undo-list)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
283 (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
284 (let ((,end (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
285 ,@body)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
286 (push nil buffer-undo-list)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
287 (ignore-errors (undo))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
288
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
289 (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
290
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
291 (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
292 `(with-current-buffer pgg-output-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293 (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
294
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
295 (defalias 'pgg-make-temp-file
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
296 (if (fboundp 'make-temp-file)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
297 'make-temp-file
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
298 (lambda (prefix &optional dir-flag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
299 (let ((file (expand-file-name
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
300 (make-temp-name prefix)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
301 (if (fboundp 'temp-directory)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
302 (temp-directory)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
303 temporary-file-directory))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
304 (if dir-flag
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
305 (make-directory file))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
306 file))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
307
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308 ;;; @ interface functions
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
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
311 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
312 (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
313 "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
314
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
315 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
316
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
317 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
318 passphrase cache or user."
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
319 (interactive
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
320 (list (region-beginning)(region-end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
321 (split-string (read-string "Recipients: ") "[ \t,]+")))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
322 (let ((status
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
323 (pgg-save-coding-system start end
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
324 (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
325 (point-min) (point-max) rcpts sign passphrase))))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
326 (when (interactive-p)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
327 (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
328 status))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
329
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
330 ;;;###autoload
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
331 (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
332 "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
333
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
334 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
335 cache or user."
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
336 (interactive "r")
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
337 (let ((status
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
338 (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
339 (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
340 (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
341 (point-min) (point-max) passphrase))))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
342 (when (interactive-p)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 (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
344 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
345
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
346 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
347 (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
348 "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
349
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
350 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
351 the region.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
352
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
353 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
354 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
355 (interactive)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
356 (let* ((start (or start (point-min)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
357 (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
358 (status (pgg-encrypt-symmetric-region start end passphrase)))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
359 (when (interactive-p)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360 (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
361 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
362
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
363 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
364 (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
365 "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
366
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
367 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
368
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
369 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
370 the region.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
371
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
372 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
373 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
374 (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
375 (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
376 (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
377 (status (pgg-encrypt-region start end rcpts sign passphrase)))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
378 (when (interactive-p)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
379 (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
380 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
382 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
383 (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
384 "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
385
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
386 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
387 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
388 (interactive "r")
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
389 (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
390 (status
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
391 (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
392 (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
393 (point-min) (point-max) passphrase))))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
394 (when (interactive-p)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
395 (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
396 status))
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
397
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
398 ;;;###autoload
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
399 (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
400 "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
401
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
402 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
403 the region.
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
404
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
405 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
406 passphrase cache or user."
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407 (interactive "")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
408 (let* ((start (or start (point-min)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
409 (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
410 (status (pgg-decrypt-region start end passphrase)))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411 (when (interactive-p)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
412 (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
413 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
415 ;;;###autoload
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
416 (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
417 "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
418
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
419 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
420 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
421
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
422 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
423 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
424
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
425 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
426 passphrase cache or user."
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
427 (interactive "r")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
428 (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
429 (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
430 (point-min) (point-max)
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
431 (or (interactive-p) cleartext)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
432 passphrase))))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
433 (when (interactive-p)
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
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
456 (or (interactive-p) cleartext)
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
457 passphrase)))
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
458 (when (interactive-p)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
459 (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
460 status))
66519
20539524a670 (pgg-decrypt): Passing along 'passphrase' in call to pgg-decrypt-region.
Eli Zaretskii <eliz@gnu.org>
parents: 66383
diff changeset
461
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
462 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
463 (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
464 "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
465 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
466 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
467
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
468 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
469 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
470 (interactive "r")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
471 (let* ((packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
472 (if (null signature) nil
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
473 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
474 (buffer-disable-undo)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
475 (if (fboundp 'set-buffer-multibyte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
476 (set-buffer-multibyte nil))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
477 (insert-file-contents signature)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
478 (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
479 (point-min)(point-max)))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
480 (key (cdr (assq 'key-identifier packet)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
481 status keyserver)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
482 (and (stringp key)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
483 pgg-query-keyserver
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
484 (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
485 (null (pgg-lookup-key key))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
486 (or fetch (interactive-p))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
487 (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
488 (setq keyserver
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
489 (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
490 pgg-default-keyserver-address))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
491 (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
492 (setq status
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
493 (pgg-save-coding-system start end
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
494 (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
495 (point-min) (point-max) signature)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
496 (when (interactive-p)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
497 (let ((temp-buffer-show-function
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
498 (function pgg-temp-buffer-show-function)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
499 (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
500 (set-buffer standard-output)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
501 (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
502 pgg-errors-buffer)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
503 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
504
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
505 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
506 (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
507 "Verify the current buffer.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
508 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
509 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
510 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
511 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
512 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
513 within the region."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
514 (interactive "")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
515 (let* ((start (or start (point-min)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
516 (end (or end (point-max)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
517 (status (pgg-verify-region start end signature fetch)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
518 (when (interactive-p)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
519 (let ((temp-buffer-show-function
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
520 (function pgg-temp-buffer-show-function)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
521 (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
522 (set-buffer standard-output)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
523 (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
524 pgg-errors-buffer)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
525 status))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
526
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
527 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
528 (defun pgg-insert-key ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
529 "Insert the ASCII armored public key."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
530 (interactive)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
531 (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
532
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
533 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
534 (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
535 "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
536 (interactive "r")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
537 (pgg-save-coding-system start end
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
538 (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
539 start end)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
540
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
541 ;;;###autoload
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
542 (defun pgg-snarf-keys ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
543 "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
544 (interactive "")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
545 (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
546
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
547 (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
548 (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
549
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
550 (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
551
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
552 (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
553 (ignore-errors
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
554 (require 'url)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
555 (let (buffer-file-name)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
556 (url-insert-file-contents url))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
557
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
558 (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
559 (defvar pgg-insert-url-program nil)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
560
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
561 (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
562 (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
563 process)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
564 (insert
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
565 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
566 (setq process
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
567 (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
568 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
569 (set-process-sentinel process #'ignore)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
570 (while (eq 'run (process-status process))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
571 (accept-process-output process 5))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
572 (delete-process process)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
573 (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
574 (interrupt-process process))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
575 (buffer-string)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
576
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
577 (defun pgg-fetch-key (keyserver key)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
578 "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
579 (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
580 (buffer-disable-undo)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
581 (erase-buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
582 (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
583 (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
584 (save-excursion
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
585 (funcall pgg-insert-url-function
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
586 (if proto keyserver
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
587 (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
588 keyserver key))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
589 (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
590 (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
591 (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
592 (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
593 (point-max)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
594 (insert "\n")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
595 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
596 (insert-buffer-substring pgg-output-buffer)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
597 (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
598
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 (provide 'pgg)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
601
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
602 ;;; arch-tag: 9cc705dd-1e6a-4c90-8dce-c3561f9a2cf4
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
603 ;;; pgg.el ends here