annotate lisp/pgg.el @ 76983:99a420a313c3

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