mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-26 10:49:33 +00:00
EasyPG: Initial check-in.
This commit is contained in:
parent
1752e20580
commit
c154c0be04
@ -49,6 +49,7 @@ INFO_TARGETS = \
|
||||
$(infodir)/ebrowse \
|
||||
$(infodir)/ediff \
|
||||
$(infodir)/emacs-mime \
|
||||
$(infodir)/epa \
|
||||
$(infodir)/erc \
|
||||
$(infodir)/eshell \
|
||||
$(infodir)/eudc \
|
||||
@ -91,6 +92,7 @@ DVI_TARGETS = \
|
||||
ebrowse.dvi \
|
||||
ediff.dvi \
|
||||
emacs-mime.dvi \
|
||||
epa.dvi \
|
||||
erc.dvi \
|
||||
eshell.dvi \
|
||||
eudc.dvi \
|
||||
@ -207,6 +209,12 @@ $(infodir)/emacs-mime: emacs-mime.texi
|
||||
emacs-mime.dvi: emacs-mime.texi
|
||||
$(ENVADD) $(TEXI2DVI) ${srcdir}/emacs-mime.texi
|
||||
|
||||
epa : $(infodir)/epa
|
||||
$(infodir)/epa: epa.texi
|
||||
cd $(srcdir); $(MAKEINFO) epa.texi
|
||||
epa.dvi: epa.texi
|
||||
$(ENVADD) $(TEXI2DVI) ${srcdir}/epa.texi
|
||||
|
||||
erc : $(infodir)/erc
|
||||
$(infodir)/erc: erc.texi
|
||||
cd $(srcdir); $(MAKEINFO) erc.texi
|
||||
|
393
doc/misc/epa.texi
Normal file
393
doc/misc/epa.texi
Normal file
@ -0,0 +1,393 @@
|
||||
\input texinfo @c -*- mode: texinfo -*-
|
||||
@c %**start of header
|
||||
@setfilename ../../info/epa
|
||||
@settitle EasyPG Assistant User's Manual
|
||||
@c %**end of header
|
||||
|
||||
@set VERSION 1.0.0
|
||||
|
||||
@copying
|
||||
This file describes EasyPG Assistant.
|
||||
|
||||
Copyright @copyright{} 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
||||
Texts. A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
@end quotation
|
||||
@end copying
|
||||
|
||||
@dircategory Emacs
|
||||
@direntry
|
||||
* EasyPG Assistant: (epa). An Emacs user interface to GNU Privacy Guard.
|
||||
@end direntry
|
||||
|
||||
|
||||
@titlepage
|
||||
@title EasyPG Assistant
|
||||
|
||||
@author by Daiki Ueno
|
||||
@page
|
||||
|
||||
@vskip 0pt plus 1filll
|
||||
@insertcopying
|
||||
@end titlepage
|
||||
@page
|
||||
|
||||
@c @summarycontents
|
||||
@c @contents
|
||||
|
||||
@node Top
|
||||
@top EasyPG Assistant user's manual
|
||||
|
||||
EasyPG Assistant is an Emacs user interface to GNU Privacy Guard
|
||||
(GnuPG, @pxref{Top, , Top, gnupg, Using the GNU Privacy Guard}).
|
||||
|
||||
EasyPG Assistant is a part of the package called EasyPG, an all-in-one
|
||||
GnuPG interface for Emacs. EasyPG also contains the library interface
|
||||
called EasyPG Library.
|
||||
|
||||
@noindent
|
||||
This manual covers EasyPG version @value{VERSION}.
|
||||
|
||||
@menu
|
||||
* Overview::
|
||||
* Quick start::
|
||||
* Commands::
|
||||
@end menu
|
||||
|
||||
@node Overview
|
||||
@chapter Overview
|
||||
|
||||
EasyPG Assistant provides the following features.
|
||||
|
||||
@itemize @bullet
|
||||
@item Key manegement.
|
||||
@item Cryptographic operations on regions.
|
||||
@item Cryptographic operations on files.
|
||||
@item Dired integration.
|
||||
@item Mail-mode integration.
|
||||
@item Automatic encryption/decryption of *.gpg files.
|
||||
@end itemize
|
||||
|
||||
@node Quick start
|
||||
@chapter Quick start
|
||||
|
||||
To install, just follow the standard CMMI installation instructions.
|
||||
|
||||
@cartouche
|
||||
@example
|
||||
$ ./configure
|
||||
$ sudo make install
|
||||
@end example
|
||||
@end cartouche
|
||||
|
||||
@noindent
|
||||
Then, add the following line to your @file{~/.emacs}
|
||||
|
||||
@cartouche
|
||||
@lisp
|
||||
(require 'epa-setup)
|
||||
@end lisp
|
||||
@end cartouche
|
||||
|
||||
@noindent
|
||||
That's all. Restart emacs and type @kbd{M-x epa- @key{TAB}}, and you will see a
|
||||
lot of commands available. For example,
|
||||
|
||||
@itemize @bullet
|
||||
@item To browse your keyring, type @kbd{M-x epa-list-keys}
|
||||
|
||||
@item To create a cleartext signature of the region, type @kbd{M-x epa-sign-region}
|
||||
@end itemize
|
||||
|
||||
@node Commands
|
||||
@chapter Commands
|
||||
|
||||
This chapter introduces various commands for typical use cases.
|
||||
|
||||
@menu
|
||||
* Key management::
|
||||
* Cryptographic operations on regions::
|
||||
* Cryptographic operations on files::
|
||||
* Dired integration::
|
||||
* Mail-mode integration::
|
||||
* Encrypting/decrypting *.gpg files::
|
||||
@end menu
|
||||
|
||||
@node Key management
|
||||
@section Key management
|
||||
Probably the first step of using EasyPG Assistant is to browse your
|
||||
keyring. @kbd{M-x epa-list-keys} is corresponding to @samp{gpg
|
||||
--list-keys} from the command line.
|
||||
|
||||
@deffn Command epa-list-keys name mode
|
||||
Show all keys matched with @var{name} from the public keyring.
|
||||
@end deffn
|
||||
|
||||
@noindent
|
||||
The output looks as follows.
|
||||
|
||||
@example
|
||||
u A5B6B2D4B15813FE Daiki Ueno <ueno@@unixuser.org>
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
A character on the leftmost column indicates the trust level of the
|
||||
key. If it is @samp{u}, the key is marked as ultimately trusted. The
|
||||
second column is the key ID, and the rest is the user ID.
|
||||
|
||||
You can move over entries by @key{TAB}. If you type @key{RET} or
|
||||
click button1 on an entry, you will see more detailed information
|
||||
about the key you selected.
|
||||
|
||||
@example
|
||||
u Daiki Ueno <ueno@@unixuser.org>
|
||||
u A5B6B2D4B15813FE 1024bits DSA
|
||||
Created: 2001-10-09
|
||||
Expires: 2007-09-04
|
||||
Capabilities: sign certify
|
||||
Fingerprint: 8003 7CD0 0F1A 9400 03CA 50AA A5B6 B2D4 B158 13FE
|
||||
u 4447461B2A9BEA2D 2048bits ELGAMAL_E
|
||||
Created: 2001-10-09
|
||||
Expires: 2007-09-04
|
||||
Capabilities: encrypt
|
||||
Fingerprint: 9003 D76B 73B7 4A8A E588 10AF 4447 461B 2A9B EA2D
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
To browse your private keyring, use @kbd{M-x epa-list-secret-keys}.
|
||||
|
||||
@deffn Command epa-list-secret-keys name
|
||||
Show all keys matched with @var{name} from the private keyring.
|
||||
@end deffn
|
||||
|
||||
@noindent
|
||||
In @samp{*Keys*} buffer, several commands are available. The common
|
||||
use case is to export some keys to a file. To do that, type @kbd{m}
|
||||
to select keys, type @kbd{o}, and then supply the filename.
|
||||
|
||||
Below are other commands related to key management. Some of them take
|
||||
a file as input/output, and others take the current region.
|
||||
|
||||
@deffn Command epa-insert-keys keys
|
||||
Insert selected @var{keys} after the point. It will let you select
|
||||
keys before insertion. By default, it will encode keys in the OpenPGP
|
||||
armor format.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-import-keys file
|
||||
Import keys from @var{file} to your keyring.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-import-keys-region start end
|
||||
Import keys from the current region between @var{start} and @var{end}
|
||||
to your keyring.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-import-armor-in-region start end
|
||||
Import keys in the OpenPGP armor format in the current region between
|
||||
@var{start} and @var{end}. The difference from
|
||||
@code{epa-import-keys-region} is that
|
||||
@code{epa-import-armor-in-region} searches armors in the region and
|
||||
applies @code{epa-import-keys-region} to each of them.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-delete-keys allow-secret
|
||||
Delete selected keys. If @var{allow-secret} is non-@code{nil}, it
|
||||
also delete the secret keys.
|
||||
@end deffn
|
||||
|
||||
@node Cryptographic operations on regions
|
||||
@section Cryptographic operations on regions
|
||||
|
||||
@deffn Command epa-decrypt-region start end
|
||||
Decrypt the current region between @var{start} and @var{end}. It
|
||||
replaces the region with the decrypted text.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-decrypt-armor-in-region start end
|
||||
Decrypt OpenPGP armors in the current region between @var{start} and
|
||||
@var{end}. The difference from @code{epa-decrypt-region} is that
|
||||
@code{epa-decrypt-armor-in-region} searches armors in the region
|
||||
and applies @code{epa-decrypt-region} to each of them. That is, this
|
||||
command does not alter the original text around armors.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-verify-region start end
|
||||
Verify the current region between @var{start} and @var{end}. It sends
|
||||
the verification result to the minibuffer or a popup window. It
|
||||
replaces the region with the signed text.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-verify-cleartext-in-region
|
||||
Verify OpenPGP cleartext blocks in the current region between
|
||||
@var{start} and @var{end}. The difference from
|
||||
@code{epa-verify-region} is that @code{epa-verify-cleartext-in-region}
|
||||
searches OpenPGP cleartext blocks in the region and applies
|
||||
@code{epa-verify-region} to each of them. That is, this command does
|
||||
not alter the original text around OpenPGP cleartext blocks.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-sign-region start end signers type
|
||||
Sign the current region between @var{start} and @var{end}. By
|
||||
default, it creates a cleartext signature. If a prefix argument is
|
||||
given, it will let you select signing keys, and then a signature
|
||||
type.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-encrypt-region start end recipients sign signers
|
||||
Encrypt the current region between @var{start} and @var{end}. It will
|
||||
let you select recipients. If a prefix argument is given, it will
|
||||
also ask you whether or not to sign the text before encryption and if
|
||||
you answered yes, it will let you select the signing keys.
|
||||
@end deffn
|
||||
|
||||
@node Cryptographic operations on files
|
||||
@section Cryptographic operations on files
|
||||
|
||||
@deffn Command epa-decrypt-file file
|
||||
Decrypt @var{file}.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-verify-file file
|
||||
Verify @var{file}.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-sign-file file signers type
|
||||
Sign @var{file}. If a prefix argument is given, it will let you
|
||||
select signing keys, and then a signature type.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-encrypt-file file recipients
|
||||
Encrypt @var{file}. It will let you select recipients.
|
||||
@end deffn
|
||||
|
||||
@node Dired integration
|
||||
@section Dired integration
|
||||
|
||||
EasyPG Assistant extends Dired Mode for GNU Emacs to allow users to
|
||||
easily do cryptographic operations on files. For example,
|
||||
|
||||
@example
|
||||
M-x dired
|
||||
(mark some files)
|
||||
: e (or M-x epa-dired-do-encrypt)
|
||||
(select recipients by 'm' and click [OK])
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
The following keys are assigned.
|
||||
|
||||
@table @kbd
|
||||
@item : d
|
||||
@kindex @kbd{: d}
|
||||
@findex epa-dired-do-decrypt
|
||||
Decrypt marked files.
|
||||
|
||||
@item : v
|
||||
@kindex @kbd{: v}
|
||||
@findex epa-dired-do-verify
|
||||
Verify marked files.
|
||||
|
||||
@item : s
|
||||
@kindex @kbd{: s}
|
||||
@findex epa-dired-do-sign
|
||||
Sign marked files.
|
||||
|
||||
@item : e
|
||||
@kindex @kbd{: e}
|
||||
@findex epa-dired-do-encrypt
|
||||
Encrypt marked files.
|
||||
|
||||
@end table
|
||||
|
||||
@node Mail-mode integration
|
||||
@section Mail-mode integration
|
||||
|
||||
EasyPG Assistant provides a minor mode to help user compose inline PGP
|
||||
messages. Inline PGP is sending the OpenPGP blobs directly inside a
|
||||
mail message and it is not recommended and you should consider to use
|
||||
PGP/MIME. See
|
||||
@uref{http://josefsson.org/inline-openpgp-considered-harmful.html,
|
||||
Inline PGP in E-mail is bad, Mm'kay?}.
|
||||
|
||||
@noindent
|
||||
The following keys are assigned.
|
||||
|
||||
@table @kbd
|
||||
@item C-c C-e d
|
||||
@kindex @kbd{C-c C-e d}
|
||||
@findex epa-mail-decrypt
|
||||
Decrypt OpenPGP armors in the current buffer.
|
||||
|
||||
@item C-c C-e v
|
||||
@kindex @kbd{C-c C-e v}
|
||||
@findex epa-mail-verify
|
||||
Verify OpenPGP cleartext signed messages in the current buffer.
|
||||
|
||||
@item C-c C-e s
|
||||
@kindex @kbd{C-c C-e s}
|
||||
@findex epa-mail-sign
|
||||
Compose a signed message from the current buffer.
|
||||
|
||||
@item C-c C-e e
|
||||
@kindex @kbd{C-c C-e e}
|
||||
@findex epa-mail-encrypt
|
||||
Compose an encrypted message from the current buffer.
|
||||
|
||||
@end table
|
||||
|
||||
@node Encrypting/decrypting *.gpg files
|
||||
@section Encrypting/decrypting *.gpg files
|
||||
Once @code{epa-setup} is loaded, every file whose extension is
|
||||
@samp{.gpg} will be treated as encrypted. That is, when you attempt
|
||||
to open such a file which already exists, the decrypted text is
|
||||
inserted in the buffer rather than encrypted one. On the other hand,
|
||||
when you attempt to save the buffer to a file whose extension is
|
||||
@samp{.gpg}, encrypted data is written.
|
||||
|
||||
If you want to temporarily disable this behavior, use @kbd{M-x
|
||||
epa-file-disable}, and then to enable this behavior use @kbd{M-x
|
||||
epa-file-enable}.
|
||||
|
||||
@deffn Command epa-file-disable
|
||||
Disable automatic encryption/decryption of *.gpg files.
|
||||
@end deffn
|
||||
|
||||
@deffn Command epa-file-enable
|
||||
Enable automatic encryption/decryption of *.gpg files.
|
||||
@end deffn
|
||||
|
||||
@noindent
|
||||
@code{epa-file} will let you select recipients. If you want to
|
||||
suppress this question, it might be a good idea to put the following
|
||||
line on the first line of the text being encrypted.
|
||||
@vindex epa-file-encrypt-to
|
||||
|
||||
@cartouche
|
||||
@lisp
|
||||
;; -*- epa-file-encrypt-to: ("ueno@@unixuser.org") -*-
|
||||
@end lisp
|
||||
@end cartouche
|
||||
|
||||
Other variables which control the automatic encryption/decryption
|
||||
behavior are below.
|
||||
|
||||
@defvar epa-file-cache-passphrase-for-symmetric-encryption
|
||||
If non-@code{nil}, cache passphrase for symmetric encryption. The
|
||||
default value is @code{nil}.
|
||||
@end defvar
|
||||
|
||||
@defvar epa-file-inhibit-auto-save
|
||||
If non-@code{nil}, disable auto-saving when opening an encrypted file.
|
||||
The default value is @code{t}.
|
||||
@end defvar
|
||||
|
||||
@bye
|
||||
|
||||
@c End:
|
8
etc/NEWS
8
etc/NEWS
@ -229,6 +229,14 @@ consult the Remember Manual for usage details.
|
||||
dbus.el and by extensions to the C modules of Emacs. D-Bus is an
|
||||
inter-process communication mechanism for applications residing on the
|
||||
same host, based on messages. See the manual for further details.
|
||||
|
||||
** EasyPG is now part of the Emacs distribution.
|
||||
EasyPG is an all-in-one GnuPG interface for Emacs. It consists of two
|
||||
parts: EasyPG Assistant and EasyPG Library.
|
||||
|
||||
EasyPG Assistant is a set of convenient tools to use GnuPG from
|
||||
Emacs. EasyPG Library is a sort of an elisp port of GPGME, a wrapper
|
||||
library which provides API to access some of the GnuPG functions.
|
||||
|
||||
* Changes in Specialized Modes and Packages in Emacs 23.1
|
||||
|
||||
|
87
lisp/epa-dired.el
Normal file
87
lisp/epa-dired.el
Normal file
@ -0,0 +1,87 @@
|
||||
;;; epa-dired.el --- the EasyPG Assistant, dired extension
|
||||
;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Daiki Ueno <ueno@unixuser.org>
|
||||
;; Keywords: PGP, GnuPG
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; 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 2, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; 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
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; 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., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'epa)
|
||||
(require 'dired)
|
||||
|
||||
(defvar epa-dired-map
|
||||
(let ((keymap (make-sparse-keymap)))
|
||||
(define-key keymap "d" 'epa-dired-do-decrypt)
|
||||
(define-key keymap "v" 'epa-dired-do-verify)
|
||||
(define-key keymap "s" 'epa-dired-do-sign)
|
||||
(define-key keymap "e" 'epa-dired-do-encrypt)
|
||||
keymap))
|
||||
|
||||
(fset 'epa-dired-prefix epa-dired-map)
|
||||
|
||||
(defun epa-dired-mode-hook ()
|
||||
(define-key dired-mode-map ":" 'epa-dired-prefix))
|
||||
|
||||
(defun epa-dired-do-decrypt ()
|
||||
"Decrypt marked files."
|
||||
(interactive)
|
||||
(let ((file-list (dired-get-marked-files)))
|
||||
(while file-list
|
||||
(epa-decrypt-file (expand-file-name (car file-list)))
|
||||
(setq file-list (cdr file-list)))
|
||||
(revert-buffer)))
|
||||
|
||||
(defun epa-dired-do-verify ()
|
||||
"Verify marked files."
|
||||
(interactive)
|
||||
(let ((file-list (dired-get-marked-files)))
|
||||
(while file-list
|
||||
(epa-verify-file (expand-file-name (car file-list)))
|
||||
(setq file-list (cdr file-list)))))
|
||||
|
||||
(defun epa-dired-do-sign ()
|
||||
"Sign marked files."
|
||||
(interactive)
|
||||
(let ((file-list (dired-get-marked-files)))
|
||||
(while file-list
|
||||
(epa-sign-file
|
||||
(expand-file-name (car file-list))
|
||||
(epa-select-keys (epg-make-context) "Select keys for signing.
|
||||
If no one is selected, default secret key is used. "
|
||||
nil t)
|
||||
(y-or-n-p "Make a detached signature? "))
|
||||
(setq file-list (cdr file-list)))
|
||||
(revert-buffer)))
|
||||
|
||||
(defun epa-dired-do-encrypt ()
|
||||
"Encrypt marked files."
|
||||
(interactive)
|
||||
(let ((file-list (dired-get-marked-files)))
|
||||
(while file-list
|
||||
(epa-encrypt-file
|
||||
(expand-file-name (car file-list))
|
||||
(epa-select-keys (epg-make-context) "Select recipents for encryption.
|
||||
If no one is selected, symmetric encryption will be performed. "))
|
||||
(setq file-list (cdr file-list)))
|
||||
(revert-buffer)))
|
||||
|
||||
(provide 'epa-dired)
|
||||
|
||||
;;; epa-dired.el ends here
|
318
lisp/epa-file.el
Normal file
318
lisp/epa-file.el
Normal file
@ -0,0 +1,318 @@
|
||||
;;; epa-file.el --- the EasyPG Assistant, transparent file encryption
|
||||
;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Daiki Ueno <ueno@unixuser.org>
|
||||
;; Keywords: PGP, GnuPG
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; 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
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; 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., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'epa)
|
||||
|
||||
(defgroup epa-file nil
|
||||
"The EasyPG Assistant hooks for transparent file encryption"
|
||||
:group 'epa)
|
||||
|
||||
(defun epa-file--file-name-regexp-set (variable value)
|
||||
(set-default variable value)
|
||||
(if (fboundp 'epa-file-name-regexp-update)
|
||||
(epa-file-name-regexp-update)))
|
||||
|
||||
(defcustom epa-file-name-regexp "\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'"
|
||||
"Regexp which matches filenames to be encrypted with GnuPG.
|
||||
|
||||
If you set this outside Custom while epa-file is already enabled, you
|
||||
have to call `epa-file-name-regexp-update' after setting it to
|
||||
properly update file-name-handler-alist. Setting this through Custom
|
||||
does that automatically."
|
||||
:type 'regexp
|
||||
:group 'epa-file
|
||||
:set 'epa-file--file-name-regexp-set)
|
||||
|
||||
(defcustom epa-file-cache-passphrase-for-symmetric-encryption nil
|
||||
"If non-nil, cache passphrase for symmetric encryption."
|
||||
:type 'boolean
|
||||
:group 'epa-file)
|
||||
|
||||
(defcustom epa-file-inhibit-auto-save t
|
||||
"If non-nil, disable auto-saving when opening an encrypted file."
|
||||
:type 'boolean
|
||||
:group 'epa-file)
|
||||
|
||||
(defcustom epa-file-select-keys nil
|
||||
"If non-nil, always asks user to select recipients."
|
||||
:type 'boolean
|
||||
:group 'epa-file)
|
||||
|
||||
(defvar epa-file-encrypt-to nil
|
||||
"*Recipient(s) used for encrypting files.
|
||||
May either be a string or a list of strings.")
|
||||
|
||||
;;;###autoload
|
||||
(put 'epa-file-encrypt-to 'safe-local-variable
|
||||
(lambda (val)
|
||||
(or (stringp val)
|
||||
(and (listp val)
|
||||
(catch 'safe
|
||||
(mapc (lambda (elt)
|
||||
(unless (stringp elt)
|
||||
(throw 'safe nil)))
|
||||
val)
|
||||
t)))))
|
||||
|
||||
;;;###autoload
|
||||
(put 'epa-file-encrypt-to 'permanent-local t)
|
||||
|
||||
(defvar epa-file-handler
|
||||
(cons epa-file-name-regexp 'epa-file-handler))
|
||||
|
||||
(defvar epa-file-auto-mode-alist-entry
|
||||
(list epa-file-name-regexp nil 'epa-file))
|
||||
|
||||
(defvar epa-file-passphrase-alist nil)
|
||||
|
||||
(eval-and-compile
|
||||
(if (fboundp 'encode-coding-string)
|
||||
(defalias 'epa-file--encode-coding-string 'encode-coding-string)
|
||||
(defalias 'epa-file--encode-coding-string 'identity)))
|
||||
|
||||
(eval-and-compile
|
||||
(if (fboundp 'decode-coding-string)
|
||||
(defalias 'epa-file--decode-coding-string 'decode-coding-string)
|
||||
(defalias 'epa-file--decode-coding-string 'identity)))
|
||||
|
||||
(defun epa-file-name-regexp-update ()
|
||||
(interactive)
|
||||
(unless (equal (car epa-file-handler) epa-file-name-regexp)
|
||||
(setcar epa-file-handler epa-file-name-regexp)))
|
||||
|
||||
(defun epa-file-passphrase-callback-function (context key-id file)
|
||||
(if (and epa-file-cache-passphrase-for-symmetric-encryption
|
||||
(eq key-id 'SYM))
|
||||
(progn
|
||||
(setq file (file-truename file))
|
||||
(let ((entry (assoc file epa-file-passphrase-alist))
|
||||
passphrase)
|
||||
(or (copy-sequence (cdr entry))
|
||||
(progn
|
||||
(unless entry
|
||||
(setq entry (list file)
|
||||
epa-file-passphrase-alist
|
||||
(cons entry
|
||||
epa-file-passphrase-alist)))
|
||||
(setq passphrase (epa-passphrase-callback-function context
|
||||
key-id nil))
|
||||
(setcdr entry (copy-sequence passphrase))
|
||||
passphrase))))
|
||||
(epa-passphrase-callback-function context key-id nil)))
|
||||
|
||||
(defun epa-file-handler (operation &rest args)
|
||||
(save-match-data
|
||||
(let ((op (get operation 'epa-file)))
|
||||
(if op
|
||||
(apply op args)
|
||||
(epa-file-run-real-handler operation args)))))
|
||||
|
||||
(defun epa-file-run-real-handler (operation args)
|
||||
(let ((inhibit-file-name-handlers
|
||||
(cons 'epa-file-handler
|
||||
(and (eq inhibit-file-name-operation operation)
|
||||
inhibit-file-name-handlers)))
|
||||
(inhibit-file-name-operation operation))
|
||||
(apply operation args)))
|
||||
|
||||
(defun epa-file-decode-and-insert (string file visit beg end replace)
|
||||
(if (fboundp 'decode-coding-inserted-region)
|
||||
(save-restriction
|
||||
(narrow-to-region (point) (point))
|
||||
(let ((multibyte enable-multibyte-characters))
|
||||
(set-buffer-multibyte nil)
|
||||
(insert string)
|
||||
(set-buffer-multibyte multibyte)
|
||||
(decode-coding-inserted-region
|
||||
(point-min) (point-max)
|
||||
(substring file 0 (string-match epa-file-name-regexp file))
|
||||
visit beg end replace)))
|
||||
(insert (epa-file--decode-coding-string string (or coding-system-for-read
|
||||
'undecided)))))
|
||||
|
||||
(defvar last-coding-system-used)
|
||||
(defun epa-file-insert-file-contents (file &optional visit beg end replace)
|
||||
(barf-if-buffer-read-only)
|
||||
(if (and visit (or beg end))
|
||||
(error "Attempt to visit less than an entire file"))
|
||||
(setq file (expand-file-name file))
|
||||
(let* ((local-copy
|
||||
(condition-case inl
|
||||
(epa-file-run-real-handler #'file-local-copy (list file))
|
||||
(error)))
|
||||
(local-file (or local-copy file))
|
||||
(context (epg-make-context))
|
||||
string length entry)
|
||||
(if visit
|
||||
(setq buffer-file-name file))
|
||||
(epg-context-set-passphrase-callback
|
||||
context
|
||||
(cons #'epa-file-passphrase-callback-function
|
||||
local-file))
|
||||
(epg-context-set-progress-callback context
|
||||
#'epa-progress-callback-function)
|
||||
(unwind-protect
|
||||
(progn
|
||||
(if replace
|
||||
(goto-char (point-min)))
|
||||
(condition-case error
|
||||
(setq string (epg-decrypt-file context local-file nil))
|
||||
(error
|
||||
(if (setq entry (assoc file epa-file-passphrase-alist))
|
||||
(setcdr entry nil))
|
||||
(signal 'file-error
|
||||
(cons "Opening input file" (cdr error)))))
|
||||
(make-local-variable 'epa-file-encrypt-to)
|
||||
(setq epa-file-encrypt-to
|
||||
(mapcar #'car (epg-context-result-for context 'encrypted-to)))
|
||||
(if (or beg end)
|
||||
(setq string (substring string (or beg 0) end)))
|
||||
(save-excursion
|
||||
(save-restriction
|
||||
(narrow-to-region (point) (point))
|
||||
(epa-file-decode-and-insert string file visit beg end replace)
|
||||
(setq length (- (point-max) (point-min))))
|
||||
(if replace
|
||||
(delete-region (point) (point-max)))))
|
||||
(if (and local-copy
|
||||
(file-exists-p local-copy))
|
||||
(delete-file local-copy)))
|
||||
(list file length)))
|
||||
(put 'insert-file-contents 'epa-file 'epa-file-insert-file-contents)
|
||||
|
||||
(defun epa-file-write-region (start end file &optional append visit lockname
|
||||
mustbenew)
|
||||
(if append
|
||||
(error "Can't append to the file."))
|
||||
(setq file (expand-file-name file))
|
||||
(let* ((coding-system (or coding-system-for-write
|
||||
(if (fboundp 'select-safe-coding-system)
|
||||
;; This is needed since Emacs 22 has
|
||||
;; no-conversion setting for *.gpg in
|
||||
;; `auto-coding-alist'.
|
||||
(let ((buffer-file-name
|
||||
(file-name-sans-extension file)))
|
||||
(select-safe-coding-system
|
||||
(point-min) (point-max)))
|
||||
buffer-file-coding-system)))
|
||||
(context (epg-make-context))
|
||||
(coding-system-for-write 'binary)
|
||||
string entry
|
||||
(recipients
|
||||
(cond
|
||||
((listp epa-file-encrypt-to) epa-file-encrypt-to)
|
||||
((stringp epa-file-encrypt-to) (list epa-file-encrypt-to)))))
|
||||
(epg-context-set-passphrase-callback
|
||||
context
|
||||
(cons #'epa-file-passphrase-callback-function
|
||||
file))
|
||||
(epg-context-set-progress-callback context
|
||||
#'epa-progress-callback-function)
|
||||
(epg-context-set-armor context epa-armor)
|
||||
(condition-case error
|
||||
(setq string
|
||||
(epg-encrypt-string
|
||||
context
|
||||
(if (stringp start)
|
||||
(epa-file--encode-coding-string start coding-system)
|
||||
(epa-file--encode-coding-string (buffer-substring start end)
|
||||
coding-system))
|
||||
(if (or epa-file-select-keys
|
||||
(not (local-variable-p 'epa-file-encrypt-to
|
||||
(current-buffer))))
|
||||
(epa-select-keys
|
||||
context
|
||||
"Select recipents for encryption.
|
||||
If no one is selected, symmetric encryption will be performed. "
|
||||
recipients)
|
||||
(if epa-file-encrypt-to
|
||||
(epg-list-keys context recipients)))))
|
||||
(error
|
||||
(if (setq entry (assoc file epa-file-passphrase-alist))
|
||||
(setcdr entry nil))
|
||||
(signal 'file-error (cons "Opening output file" (cdr error)))))
|
||||
(epa-file-run-real-handler
|
||||
#'write-region
|
||||
(list string nil file append visit lockname mustbenew))
|
||||
(if (boundp 'last-coding-system-used)
|
||||
(setq last-coding-system-used coding-system))
|
||||
(if (eq visit t)
|
||||
(progn
|
||||
(setq buffer-file-name file)
|
||||
(set-visited-file-modtime))
|
||||
(if (stringp visit)
|
||||
(progn
|
||||
(set-visited-file-modtime)
|
||||
(setq buffer-file-name visit))))
|
||||
(if (or (eq visit t)
|
||||
(eq visit nil)
|
||||
(stringp visit))
|
||||
(message "Wrote %s" buffer-file-name))))
|
||||
(put 'write-region 'epa-file 'epa-file-write-region)
|
||||
|
||||
(defun epa-file-find-file-hook ()
|
||||
(if (and buffer-file-name
|
||||
(string-match epa-file-name-regexp buffer-file-name)
|
||||
epa-file-inhibit-auto-save)
|
||||
(auto-save-mode 0))
|
||||
(set-buffer-modified-p nil))
|
||||
|
||||
(defun epa-file-select-keys ()
|
||||
"Select recipients for encryption."
|
||||
(interactive)
|
||||
(make-local-variable 'epa-file-encrypt-to)
|
||||
(setq epa-file-encrypt-to
|
||||
(epa-select-keys
|
||||
(epg-make-context)
|
||||
"Select recipents for encryption.
|
||||
If no one is selected, symmetric encryption will be performed. ")))
|
||||
|
||||
;;;###autoload
|
||||
(defun epa-file-enable ()
|
||||
(interactive)
|
||||
(if (memq epa-file-handler file-name-handler-alist)
|
||||
(message "`epa-file' already enabled")
|
||||
(setq file-name-handler-alist
|
||||
(cons epa-file-handler file-name-handler-alist))
|
||||
(add-hook 'find-file-hooks 'epa-file-find-file-hook)
|
||||
(setq auto-mode-alist (cons epa-file-auto-mode-alist-entry auto-mode-alist))
|
||||
(message "`epa-file' enabled")))
|
||||
|
||||
;;;###autoload
|
||||
(defun epa-file-disable ()
|
||||
(interactive)
|
||||
(if (memq epa-file-handler file-name-handler-alist)
|
||||
(progn
|
||||
(setq file-name-handler-alist
|
||||
(delq epa-file-handler file-name-handler-alist))
|
||||
(remove-hook 'find-file-hooks 'epa-file-find-file-hook)
|
||||
(setq auto-mode-alist (delq epa-file-auto-mode-alist-entry
|
||||
auto-mode-alist))
|
||||
(message "`epa-file' disabled"))
|
||||
(message "`epa-file' already disabled")))
|
||||
|
||||
(provide 'epa-file)
|
||||
|
||||
;;; epa-file.el ends here
|
178
lisp/epa-mail.el
Normal file
178
lisp/epa-mail.el
Normal file
@ -0,0 +1,178 @@
|
||||
;;; epa-mail.el --- the EasyPG Assistant, minor-mode for mail composer
|
||||
;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Daiki Ueno <ueno@unixuser.org>
|
||||
;; Keywords: PGP, GnuPG, mail, message
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; 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
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; 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., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'epa)
|
||||
(require 'mail-utils)
|
||||
|
||||
(defvar epa-mail-mode-map
|
||||
(let ((keymap (make-sparse-keymap)))
|
||||
(define-key keymap "\C-c\C-ed" 'epa-mail-decrypt)
|
||||
(define-key keymap "\C-c\C-ev" 'epa-mail-verify)
|
||||
(define-key keymap "\C-c\C-es" 'epa-mail-sign)
|
||||
(define-key keymap "\C-c\C-ee" 'epa-mail-encrypt)
|
||||
(define-key keymap "\C-c\C-ei" 'epa-mail-import-keys)
|
||||
(define-key keymap "\C-c\C-eo" 'epa-insert-keys)
|
||||
keymap))
|
||||
|
||||
(defvar epa-mail-mode-hook nil)
|
||||
(defvar epa-mail-mode-on-hook nil)
|
||||
(defvar epa-mail-mode-off-hook nil)
|
||||
|
||||
(define-minor-mode epa-mail-mode
|
||||
"A minor-mode for composing encrypted/clearsigned mails."
|
||||
nil " epa-mail" epa-mail-mode-map)
|
||||
|
||||
(defun epa-mail--find-usable-key (keys usage)
|
||||
"Find a usable key from KEYS for USAGE."
|
||||
(catch 'found
|
||||
(while keys
|
||||
(let ((pointer (epg-key-sub-key-list (car keys))))
|
||||
(while pointer
|
||||
(if (and (memq usage (epg-sub-key-capability (car pointer)))
|
||||
(not (memq (epg-sub-key-validity (car pointer))
|
||||
'(revoked expired))))
|
||||
(throw 'found (car keys)))
|
||||
(setq pointer (cdr pointer))))
|
||||
(setq keys (cdr keys)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun epa-mail-decrypt ()
|
||||
"Decrypt OpenPGP armors in the current buffer.
|
||||
The buffer is expected to contain a mail message.
|
||||
|
||||
Don't use this command in Lisp programs!"
|
||||
(interactive)
|
||||
(epa-decrypt-armor-in-region (point-min) (point-max)))
|
||||
|
||||
;;;###autoload
|
||||
(defun epa-mail-verify ()
|
||||
"Verify OpenPGP cleartext signed messages in the current buffer.
|
||||
The buffer is expected to contain a mail message.
|
||||
|
||||
Don't use this command in Lisp programs!"
|
||||
(interactive)
|
||||
(epa-verify-cleartext-in-region (point-min) (point-max)))
|
||||
|
||||
;;;###autoload
|
||||
(defun epa-mail-sign (start end signers mode)
|
||||
"Sign the current buffer.
|
||||
The buffer is expected to contain a mail message.
|
||||
|
||||
Don't use this command in Lisp programs!"
|
||||
(interactive
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(if (search-forward mail-header-separator nil t)
|
||||
(forward-line))
|
||||
(setq epa-last-coding-system-specified
|
||||
(or coding-system-for-write
|
||||
(epa--select-safe-coding-system (point) (point-max))))
|
||||
(let ((verbose current-prefix-arg))
|
||||
(list (point) (point-max)
|
||||
(if verbose
|
||||
(epa-select-keys (epg-make-context epa-protocol)
|
||||
"Select keys for signing.
|
||||
If no one is selected, default secret key is used. "
|
||||
nil t))
|
||||
(if verbose
|
||||
(epa--read-signature-type)
|
||||
'clear)))))
|
||||
(epa-sign-region start end signers mode))
|
||||
|
||||
;;;###autoload
|
||||
(defun epa-mail-encrypt (start end recipients sign signers)
|
||||
"Encrypt the current buffer.
|
||||
The buffer is expected to contain a mail message.
|
||||
|
||||
Don't use this command in Lisp programs!"
|
||||
(interactive
|
||||
(save-excursion
|
||||
(let ((verbose current-prefix-arg)
|
||||
(context (epg-make-context epa-protocol))
|
||||
recipients recipient-key)
|
||||
(goto-char (point-min))
|
||||
(save-restriction
|
||||
(narrow-to-region (point)
|
||||
(if (search-forward mail-header-separator nil 0)
|
||||
(match-beginning 0)
|
||||
(point)))
|
||||
(setq recipients
|
||||
(mail-strip-quoted-names
|
||||
(mapconcat #'identity
|
||||
(nconc (mail-fetch-field "to" nil nil t)
|
||||
(mail-fetch-field "cc" nil nil t)
|
||||
(mail-fetch-field "bcc" nil nil t))
|
||||
","))))
|
||||
(if recipients
|
||||
(setq recipients (delete ""
|
||||
(split-string recipients "[ \t\n]+"))))
|
||||
(goto-char (point-min))
|
||||
(if (search-forward mail-header-separator nil t)
|
||||
(forward-line))
|
||||
(setq epa-last-coding-system-specified
|
||||
(or coding-system-for-write
|
||||
(epa--select-safe-coding-system (point) (point-max))))
|
||||
(list (point) (point-max)
|
||||
(if verbose
|
||||
(epa-select-keys
|
||||
context
|
||||
"Select recipients for encryption.
|
||||
If no one is selected, symmetric encryption will be performed. "
|
||||
recipients)
|
||||
(if recipients
|
||||
(mapcar
|
||||
(lambda (recipient)
|
||||
(setq recipient-key
|
||||
(epa-mail--find-usable-key
|
||||
(epg-list-keys
|
||||
(epg-make-context epa-protocol)
|
||||
(concat "<" recipient ">"))
|
||||
'encrypt))
|
||||
(unless (or recipient-key
|
||||
(y-or-n-p
|
||||
(format
|
||||
"No public key for %s; skip it? "
|
||||
recipient)))
|
||||
(error "No public key for %s" recipient))
|
||||
recipient-key)
|
||||
recipients)))
|
||||
(setq sign (if verbose (y-or-n-p "Sign? ")))
|
||||
(if sign
|
||||
(epa-select-keys context
|
||||
"Select keys for signing. "))))))
|
||||
(epa-encrypt-region start end recipients sign signers))
|
||||
|
||||
;;;###autoload
|
||||
(defun epa-mail-import-keys ()
|
||||
"Import keys in the OpenPGP armor format in the current buffer.
|
||||
The buffer is expected to contain a mail message.
|
||||
|
||||
Don't use this command in Lisp programs!"
|
||||
(interactive)
|
||||
(epa-import-armor-in-region (point-min) (point-max)))
|
||||
|
||||
(provide 'epa-mail)
|
||||
|
||||
;;; epa-mail.el ends here
|
39
lisp/epa-setup.el
Normal file
39
lisp/epa-setup.el
Normal file
@ -0,0 +1,39 @@
|
||||
;;; epa-setup.el --- setup routine for the EasyPG Assistant.
|
||||
;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Daiki Ueno <ueno@unixuser.org>
|
||||
;; Keywords: PGP, GnuPG
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; 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
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; 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., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(autoload 'epa-list-keys "epa")
|
||||
|
||||
(autoload 'epa-dired-mode-hook "epa-dired")
|
||||
(add-hook 'dired-mode-hook 'epa-dired-mode-hook)
|
||||
|
||||
(require 'epa-file)
|
||||
(epa-file-enable)
|
||||
|
||||
(autoload 'epa-mail-mode "epa-mail")
|
||||
(add-hook 'mail-mode-hook 'epa-mail-mode)
|
||||
|
||||
(provide 'epa-setup)
|
||||
|
||||
;;; epa-setup.el ends here
|
1176
lisp/epa.el
Normal file
1176
lisp/epa.el
Normal file
File diff suppressed because it is too large
Load Diff
140
lisp/epg-config.el
Normal file
140
lisp/epg-config.el
Normal file
@ -0,0 +1,140 @@
|
||||
;;; epg-config.el --- configuration of the EasyPG Library
|
||||
;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Daiki Ueno <ueno@unixuser.org>
|
||||
;; Keywords: PGP, GnuPG
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; 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
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; 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., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'epg-package-info)
|
||||
|
||||
(defgroup epg ()
|
||||
"The EasyPG Library"
|
||||
:group 'emacs)
|
||||
|
||||
(defcustom epg-gpg-program "gpg"
|
||||
"The `gpg' executable."
|
||||
:group 'epg
|
||||
:type 'string)
|
||||
|
||||
(defcustom epg-gpgsm-program "gpgsm"
|
||||
"The `gpgsm' executable."
|
||||
:group 'epg
|
||||
:type 'string)
|
||||
|
||||
(defcustom epg-gpg-home-directory nil
|
||||
"The directory which contains the configuration files of `epg-gpg-program'."
|
||||
:group 'epg
|
||||
:type '(choice (const :tag "Default" nil) directory))
|
||||
|
||||
(defcustom epg-passphrase-coding-system nil
|
||||
"Coding system to use with messages from `epg-gpg-program'."
|
||||
:group 'epg
|
||||
:type 'symbol)
|
||||
|
||||
(defcustom epg-debug nil
|
||||
"If non-nil, debug output goes to the \" *epg-debug*\" buffer.
|
||||
Note that the buffer name starts with a space."
|
||||
:group 'epg
|
||||
:type 'boolean)
|
||||
|
||||
(defconst epg-gpg-minimum-version "1.4.3")
|
||||
|
||||
;;;###autoload
|
||||
(defun epg-configuration ()
|
||||
"Return a list of internal configuration parameters of `epg-gpg-program'."
|
||||
(let (config groups type args)
|
||||
(with-temp-buffer
|
||||
(apply #'call-process epg-gpg-program nil (list t nil) nil
|
||||
(append (if epg-gpg-home-directory
|
||||
(list "--homedir" epg-gpg-home-directory))
|
||||
'("--with-colons" "--list-config")))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^cfg:\\([^:]+\\):\\(.*\\)" nil t)
|
||||
(setq type (intern (match-string 1))
|
||||
args (match-string 2))
|
||||
(cond
|
||||
((eq type 'group)
|
||||
(if (string-match "\\`\\([^:]+\\):" args)
|
||||
(setq groups
|
||||
(cons (cons (downcase (match-string 1 args))
|
||||
(delete "" (split-string
|
||||
(substring args
|
||||
(match-end 0))
|
||||
";")))
|
||||
groups))
|
||||
(if epg-debug
|
||||
(message "Invalid group configuration: %S" args))))
|
||||
((memq type '(pubkey cipher digest compress))
|
||||
(if (string-match "\\`\\([0-9]+\\)\\(;[0-9]+\\)*" args)
|
||||
(setq config
|
||||
(cons (cons type
|
||||
(mapcar #'string-to-number
|
||||
(delete "" (split-string args ";"))))
|
||||
config))
|
||||
(if epg-debug
|
||||
(message "Invalid %S algorithm configuration: %S"
|
||||
type args))))
|
||||
(t
|
||||
(setq config (cons (cons type args) config))))))
|
||||
(if groups
|
||||
(cons (cons 'groups groups) config)
|
||||
config)))
|
||||
|
||||
(defun epg-config--parse-version (string)
|
||||
(let ((index 0)
|
||||
version)
|
||||
(while (eq index (string-match "\\([0-9]+\\)\\.?" string index))
|
||||
(setq version (cons (string-to-number (match-string 1 string))
|
||||
version)
|
||||
index (match-end 0)))
|
||||
(nreverse version)))
|
||||
|
||||
(defun epg-config--compare-version (v1 v2)
|
||||
(while (and v1 v2 (= (car v1) (car v2)))
|
||||
(setq v1 (cdr v1) v2 (cdr v2)))
|
||||
(- (or (car v1) 0) (or (car v2) 0)))
|
||||
|
||||
;;;###autoload
|
||||
(defun epg-check-configuration (config &optional minimum-version)
|
||||
"Verify that a sufficient version of GnuPG is installed."
|
||||
(let ((entry (assq 'version config))
|
||||
version)
|
||||
(unless (and entry
|
||||
(stringp (cdr entry)))
|
||||
(error "Undetermined version: %S" entry))
|
||||
(setq version (epg-config--parse-version (cdr entry))
|
||||
minimum-version (epg-config--parse-version
|
||||
(or minimum-version
|
||||
epg-gpg-minimum-version)))
|
||||
(unless (>= (epg-config--compare-version version minimum-version) 0)
|
||||
(error "Unsupported version: %s" (cdr entry)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun epg-expand-group (config group)
|
||||
"Look at CONFIG and try to expand GROUP."
|
||||
(let ((entry (assq 'groups config)))
|
||||
(if (and entry
|
||||
(setq entry (assoc (downcase group) (cdr entry))))
|
||||
(cdr entry))))
|
||||
|
||||
(provide 'epg-config)
|
||||
|
||||
;;; epg-config.el ends here
|
37
lisp/epg-package-info.el
Normal file
37
lisp/epg-package-info.el
Normal file
@ -0,0 +1,37 @@
|
||||
;;; epg-package-info.el --- package information about EasyPG
|
||||
;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Daiki Ueno <ueno@unixuser.org>
|
||||
;; Keywords: PGP, GnuPG
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; 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, or (at your option)
|
||||
;; any later version.
|
||||
|
||||
;; 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
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; 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., 51 Franklin Street, Fifth Floor,
|
||||
;; Boston, MA 02110-1301, USA.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defconst epg-package-name "epg"
|
||||
"Name of this package.")
|
||||
|
||||
(defconst epg-version-number "1.0.0"
|
||||
"Version number of this package.")
|
||||
|
||||
(defconst epg-bug-report-address "ueno@unixuser.org"
|
||||
"Report bugs to this address.")
|
||||
|
||||
(provide 'epg-package-info)
|
||||
|
||||
;;; epg-package-info.el ends here
|
2654
lisp/epg.el
Normal file
2654
lisp/epg.el
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user