projects
/
gnus
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(gnus-html-schedule-image-fetching): Protect against invalid URLs.
[gnus]
/
lisp
/
pgg-pgp5.el
diff --git
a/lisp/pgg-pgp5.el
b/lisp/pgg-pgp5.el
index
fccd80b
..
4973119
100644
(file)
--- a/
lisp/pgg-pgp5.el
+++ b/
lisp/pgg-pgp5.el
@@
-1,34
+1,36
@@
;;; pgg-pgp5.el --- PGP 5.* support for PGG.
;;; pgg-pgp5.el --- PGP 5.* support for PGG.
-;; Copyright (C) 1999,2000 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
+;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
;; Author: Daiki Ueno <ueno@unixuser.org>
;; Created: 1999/11/02
;; Keywords: PGP, OpenPGP
;; Author: Daiki Ueno <ueno@unixuser.org>
;; Created: 1999/11/02
;; Keywords: PGP, OpenPGP
+;; Package: pgg
-;; This file is part of
SEMI (Secure Emacs MIME Interface)
.
+;; This file is part of
GNU Emacs
.
-;;
This program is free software; you can redistribute it and/or
-;;
modify it under the terms of the GNU General Public License as
-;;
published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
+;;
GNU Emacs is free software: you can redistribute it and/or modify
+;;
it under the terms of the GNU General Public License as published by
+;;
the Free Software Foundation, either version 3 of the License, or
+;;
(at
your option) any later version.
-;;
This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU
-;; General Public License for more details.
+;;
GNU Emacs is distributed in the hope that it will be useful,
+;;
but
WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; G
NU G
eneral Public License for more details.
;; You should have received a copy of the GNU General Public License
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
;;; Code:
-(eval-when-compile (require 'pgg))
+(eval-when-compile
+ (require 'cl) ; for pgg macros
+ (require 'pgg))
(defgroup pgg-pgp5 ()
(defgroup pgg-pgp5 ()
- "PGP 5.* interface"
+ "PGP 5.* interface
.
"
:group 'pgg)
(defcustom pgg-pgp5-pgpe-program "pgpe"
:group 'pgg)
(defcustom pgg-pgp5-pgpe-program "pgpe"
@@
-73,9
+75,7
@@
Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
"PGP 5.* ID of your default identity.")
(defun pgg-pgp5-process-region (start end passphrase program args)
"PGP 5.* ID of your default identity.")
(defun pgg-pgp5-process-region (start end passphrase program args)
- (let* ((errors-file-name
- (expand-file-name (make-temp-name "pgg-errors")
- pgg-temporary-file-directory))
+ (let* ((errors-file-name (pgg-make-temp-file "pgg-errors"))
(args
(append args
pgg-pgp5-extra-args
(args
(append args
pgg-pgp5-extra-args
@@
-142,41
+142,51
@@
Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
(buffer-substring (match-end 0)(progn (end-of-line)(point)))))
2)))))
(buffer-substring (match-end 0)(progn (end-of-line)(point)))))
2)))))
-(defun pgg-pgp5-encrypt-region (start end recipients)
+(defun pgg-pgp5-encrypt-region (start end recipients
&optional sign passphrase
)
"Encrypt the current region between START and END."
(let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
"Encrypt the current region between START and END."
(let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
+ (passphrase (or passphrase
+ (when sign
+ (pgg-read-passphrase
+ (format "PGP passphrase for %s: "
+ pgg-pgp5-user-id)
+ pgg-pgp5-user-id))))
(args
(args
- `("+NoBatchInvalidKeys=off" "-fat" "+batchmode=1"
- ,@(if recipients
- (apply #'append
- (mapcar (lambda (rcpt)
- (list "-r"
- (concat "\"" rcpt "\"")))
- (append recipients
- (if pgg-encrypt-for-me
- (list pgg-pgp5-user-id)))))))))
+ (append
+ `("+NoBatchInvalidKeys=off" "-fat" "+batchmode=1"
+ ,@(if (or recipients pgg-encrypt-for-me)
+ (apply #'append
+ (mapcar (lambda (rcpt)
+ (list "-r"
+ (concat "\"" rcpt "\"")))
+ (append recipients
+ (if pgg-encrypt-for-me
+ (list pgg-pgp5-user-id)))))))
+ (if sign '("-s" "-u" pgg-pgp5-user-id)))))
(pgg-pgp5-process-region start end nil pgg-pgp5-pgpe-program args)
(pgg-process-when-success nil)))
(pgg-pgp5-process-region start end nil pgg-pgp5-pgpe-program args)
(pgg-process-when-success nil)))
-(defun pgg-pgp5-decrypt-region (start end)
+(defun pgg-pgp5-decrypt-region (start end
&optional passphrase
)
"Decrypt the current region between START and END."
(let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
(passphrase
"Decrypt the current region between START and END."
(let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
(passphrase
- (pgg-read-passphrase
- (format "PGP passphrase for %s: " pgg-pgp5-user-id)
- (pgg-pgp5-lookup-key pgg-pgp5-user-id 'encrypt)))
+ (or passphrase
+ (pgg-read-passphrase
+ (format "PGP passphrase for %s: " pgg-pgp5-user-id)
+ (pgg-pgp5-lookup-key pgg-pgp5-user-id 'encrypt))))
(args
'("+verbose=1" "+batchmode=1" "+language=us" "-f")))
(pgg-pgp5-process-region start end passphrase pgg-pgp5-pgpv-program args)
(pgg-process-when-success nil)))
(args
'("+verbose=1" "+batchmode=1" "+language=us" "-f")))
(pgg-pgp5-process-region start end passphrase pgg-pgp5-pgpv-program args)
(pgg-process-when-success nil)))
-(defun pgg-pgp5-sign-region (start end &optional clearsign)
+(defun pgg-pgp5-sign-region (start end &optional clearsign
passphrase
)
"Make detached signature from text between START and END."
(let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
(passphrase
"Make detached signature from text between START and END."
(let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
(passphrase
- (pgg-read-passphrase
- (format "PGP passphrase for %s: " pgg-pgp5-user-id)
- (pgg-pgp5-lookup-key pgg-pgp5-user-id 'sign)))
+ (or passphrase
+ (pgg-read-passphrase
+ (format "PGP passphrase for %s: " pgg-pgp5-user-id)
+ (pgg-pgp5-lookup-key pgg-pgp5-user-id 'sign))))
(args
(list (if clearsign "-fat" "-fbat")
"+verbose=1" "+language=us" "+batchmode=1"
(args
(list (if clearsign "-fat" "-fbat")
"+verbose=1" "+language=us" "+batchmode=1"
@@
-190,16
+200,15
@@
Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
(point))
(point-max))))))
(if pgg-cache-passphrase
(point))
(point-max))))))
(if pgg-cache-passphrase
- (pgg-add-passphrase-cache
+ (pgg-add-passphrase-
to-
cache
(cdr (assq 'key-identifier packet))
passphrase)))))))
(defun pgg-pgp5-verify-region (start end &optional signature)
"Verify region between START and END as the detached signature SIGNATURE."
(cdr (assq 'key-identifier packet))
passphrase)))))))
(defun pgg-pgp5-verify-region (start end &optional signature)
"Verify region between START and END as the detached signature SIGNATURE."
- (let* ((basename (expand-file-name "pgg" pgg-temporary-file-directory))
- (orig-file (make-temp-name basename))
- (args '("+verbose=1" "+batchmode=1" "+language=us"))
- (orig-mode (default-file-modes)))
+ (let ((orig-file (pgg-make-temp-file "pgg"))
+ (args '("+verbose=1" "+batchmode=1" "+language=us"))
+ (orig-mode (default-file-modes)))
(unwind-protect
(progn
(set-default-file-modes 448)
(unwind-protect
(progn
(set-default-file-modes 448)
@@
-234,8
+243,7
@@
Bourne shell or its equivalent \(not tcsh) is needed for \"2>\"."
(defun pgg-pgp5-snarf-keys-region (start end)
"Add all public keys in region between START and END to the keyring."
(let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
(defun pgg-pgp5-snarf-keys-region (start end)
"Add all public keys in region between START and END to the keyring."
(let* ((pgg-pgp5-user-id (or pgg-pgp5-user-id pgg-default-user-id))
- (basename (expand-file-name "pgg" pgg-temporary-file-directory))
- (key-file (make-temp-name basename))
+ (key-file (pgg-make-temp-file "pgg"))
(args
(list "+verbose=1" "+batchmode=1" "+language=us" "-a"
key-file)))
(args
(list "+verbose=1" "+batchmode=1" "+language=us" "-a"
key-file)))