+;;; epa.el --- EasyPG Assistant, GUI of EasyPG
+;; Copyright (C) 2006 Daiki Ueno
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Keywords: PGP, GnuPG
+
+;; This file is part of EasyPG.
+
+;; 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.
+
+;; 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.
+
+;; 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)
(require 'font-lock)
(defgroup epa nil
- "EasyPG Assistant, GUI for EasyPG."
+ "EasyPG Assistant, GUI of EasyPG."
:group 'epg)
(defgroup epa-faces nil
(defvar epa-buffer nil)
-(defface epa-trust-full-face
+(defface epa-validity-full-face
'((((class color) (background dark))
(:foreground "PaleTurquoise" :bold t))
(t
(:bold t)))
- "Face used for displaying the trust-full addon."
+ "Face used for displaying the validity-full addon."
:group 'epa-faces)
-(defvar epa-trust-full-face 'epa-trust-full-face)
+(defvar epa-validity-full-face 'epa-validity-full-face)
-(defface epa-trust-disabled-face
+(defface epa-validity-disabled-face
'((((class color) (background dark))
(:foreground "PaleTurquoise" :italic t))
(t
()))
- "Face used for displaying the disabled trust."
+ "Face used for displaying the disabled validity."
:group 'epa-faces)
-(defvar epa-trust-disabled-face 'epa-trust-disabled-face)
+(defvar epa-validity-disabled-face 'epa-validity-disabled-face)
-(defface epa-trust-unknown-face
+(defface epa-validity-unknown-face
'((t
(:italic t)))
- "Face used for displaying the trust-unknown addon."
+ "Face used for displaying the validity-unknown addon."
:group 'epa-faces)
-(defvar epa-trust-unknown-face 'epa-trust-unknown-face)
+(defvar epa-validity-unknown-face 'epa-validity-unknown-face)
-(defface epa-trust-marginal-face
+(defface epa-validity-marginal-face
'((t
(:italic t :inverse-video t)))
- "Face used for displaying the trust-marginal addon."
+ "Face used for displaying the validity-marginal addon."
:group 'epa-faces)
-(defvar epa-trust-marginal-face 'epa-trust-marginal-face)
+(defvar epa-validity-marginal-face 'epa-validity-marginal-face)
(defface epa-user-id-face
'((((class color)
(defvar epa-user-id-face 'epa-user-id-face)
(defcustom epa-validity-face-alist
- '((?o . epa-trust-unknown-face)
- (?i . epa-trust-disabled-face)
- (?d . epa-trust-disabled-face)
- (?r . epa-trust-disabled-face)
- (?e . epa-trust-disabled-face)
- (?- . epa-trust-unknown-face)
- (?q . epa-trust-unknown-face)
- (?n . epa-trust-disabled-face)
- (?m . epa-trust-marginal-face)
- (?f . epa-trust-full-face)
- (?u . epa-trust-full-face)
- (? . epa-trust-full-face))
+ '((?o . epa-validity-unknown-face)
+ (?i . epa-validity-disabled-face)
+ (?d . epa-validity-disabled-face)
+ (?r . epa-validity-disabled-face)
+ (?e . epa-validity-disabled-face)
+ (?- . epa-validity-unknown-face)
+ (?q . epa-validity-unknown-face)
+ (?n . epa-validity-disabled-face)
+ (?m . epa-validity-marginal-face)
+ (?f . epa-validity-full-face)
+ (?u . epa-validity-full-face)
+ (? . epa-validity-full-face))
"An alist mapping marks on epa-buffer to faces."
:type 'list
:group 'epa)
keymap))
(defun epa-mode ()
- "Major mode for displaying addon list.
+ "Major mode for EasyPG Assistant.
All normal editing commands are turned off."
(kill-all-local-variables)
(buffer-disable-undo)
(run-hooks 'epa-mode-hook))
(defun epa ()
+ "EasyPG Assistant."
(interactive)
(unless epa-buffer
(setq epa-buffer (generate-new-buffer "*EPA*")))
(setq entry (cdr (assq 'pub (car pointer))))
(setq key-id (cdr (assq 'key-id entry)))
(insert (format " %s %s %s\n"
- (or (cdr (assq 'trust entry)) ? )
+ (or (cdr (assq 'validity entry)) ? )
key-id
(cdr (assq 'user-id (assq 'uid (car pointer))))))
(put-text-property point (point) 'epa-key-id key-id)
(pop-to-buffer (current-buffer))
(delete-other-windows)))
-(defun epa-key-id ()
- (let ((key-id (get-text-property (point) 'epa-key-id))
- point)
+(defun epa-key-id (point)
+ (let ((key-id (get-text-property point 'epa-key-id)))
(unless key-id
- (setq point (next-single-property-change (point) 'epa-key-id))
+ (setq point (next-single-property-change point 'epa-key-id))
(when point
(goto-char point)
- (setq key-id (get-text-property (point) 'epa-key-id))))
+ (setq key-id (get-text-property point 'epa-key-id))))
key-id))
(defun epa-command-mark-key (key-id)
+ "Mark a key on the current line."
(interactive
(progn
(unless (eq major-mode 'epa-mode)
(error "Not in `epa-mode'"))
- (list (epa-key-id))))
+ (list (epa-key-id (point)))))
(let ((point (point))
(inhibit-read-only t)
buffer-read-only)
(forward-line)))
(defun epa-command-unmark-key (key-id)
+ "Unmark a key on the current line."
(interactive
(progn
(unless (eq major-mode 'epa-mode)
(error "Not in `epa-mode'"))
- (list (epa-key-id))))
+ (list (epa-key-id (point)))))
(let ((point (point))
(inhibit-read-only t)
buffer-read-only)
(forward-line)))
(defun epa-command-next-line (count)
+ "Same as next-line except that if you are at the beginning of buffer,
+you will be jumped to the first secret key."
(interactive "p")
(if (get-text-property (point) 'epa-key-id)
(next-line count)
(goto-char point)))))
(defun epa-command-encrypt-file (plain cipher recipients sign)
+ "Encrypt a file PLAIN for RECIPIENTS."
(interactive
(save-excursion
(set-buffer epa-buffer)
(message "Encrypting %s...done" (file-name-nondirectory plain)))
(defun epa-command-sign-file (plain signature detached signers)
+ "Sign a file PLAIN."
(interactive
(save-excursion
(set-buffer epa-buffer)
(defvar epg-debug nil)
(defvar epg-colons-pub-spec
- '((trust "[^:]")
+ '((validity "[^:]")
(length "[0-9]+" 0 string-to-number)
(algorithm "[0-9]+" 0 string-to-number)
(key-id "[^:]+")
(creation-date "[0-9]+")
(expiration-date "[0-9]+")
nil
- (ownertrust "[^:]")
+ (owner-trust "[^:]")
nil
nil
- (capability "[escaESCA]*"))
+ (capability "[escaESCA]+"))
"The schema of keylisting output whose type is \"pub\".
This is used by `epg-list-keys'.")
(defvar epg-colons-sec-spec
- '((trust "[^:]")
+ '((validity "[^:]")
(length "[0-9]+" 0 string-to-number)
(algorithm "[0-9]+" 0 string-to-number)
(key-id "[^:]+")
(creation-date "[0-9]+")
(expiration-date "[0-9]+")
nil
- (ownertrust "[^:]"))
+ (owner-trust "[^:]")
+ nil
+ nil
+ (capability "[escaESCA]+"))
"The schema of keylisting output whose type is \"sec\".
This is used by `epg-list-keys'.")
(defvar epg-colons-uid-spec
- '((trust "[^:]")
+ '((validity "[^:]")
nil
nil
nil
"The schema of keylisting output whose type is \"uid\".
This is used by `epg-list-keys'.")
+(defvar epg-colons-fpr-spec
+ '(nil
+ nil
+ nil
+ nil
+ nil
+ nil
+ nil
+ nil
+ (fingerprint "[^:]+"))
+ "The schema of keylisting output whose type is \"fpr\".
+This is used by `epg-list-keys'.")
+
(defconst epg-cipher-algorithm-alist
'((0 . "NONE")
(1 . "IDEA")
(defun epg-list-keys (name &optional secret)
"List keys associated with STRING."
(let ((args (append (list "--with-colons" "--no-greeting" "--batch"
- "--fixed-list-mode"
+ "--fixed-list-mode" "--with-fingerprint"
(if secret "--list-secret-keys" "--list-keys"))
(if name (list name))))
keys type symbol pointer)