* mime-edit.el (mime-edit-user-agent-value): Add `xemacs-extra-name'.
[elisp/semi.git] / pgg.el
diff --git a/pgg.el b/pgg.el
index fd6eaea..2b17b3e 100644 (file)
--- a/pgg.el
+++ b/pgg.el
@@ -1,8 +1,8 @@
 ;;; pgg.el --- glue for the various PGP implementations.
 
-;; Copyright (C) 1999 Daiki Ueno
+;; Copyright (C) 1999,2000 Free Software Foundation, Inc.
 
-;; Author: Daiki Ueno <ueno@ueda.info.waseda.ac.jp>
+;; Author: Daiki Ueno <ueno@unixuser.org>
 ;; Created: 1999/10/28
 ;; Keywords: PGP
 
@@ -47,8 +47,7 @@
   (calist field-type field-value)
   (let ((s-field (assq field-type calist)))
     (cond ((null s-field)
-          (cons (cons field-type field-value) calist)
-          )
+          (cons (cons field-type field-value) calist))
          ((memq (cdr s-field) field-value)
           calist))))
 
 (ctree-set-calist-strictly
  'pgg-decrypt-condition
  '((public-key-algorithm ELG-E DSA ELG)
-   (symmetric-key-algorithm 3DES CAST5 BLOWFISH TWOFISH)
+   (symmetric-key-algorithm
+    3DES CAST5 BLOWFISH RIJNDAEL RIJNDAEL192 RIJNDAEL256 TWOFISH)
    (scheme . gpg)))
 
 ;;; @ definition of the implementation scheme
 (eval-and-compile
   (luna-define-class pgg-scheme ())
 
-  (luna-define-internal-accessors 'pgg-scheme)
-  )
+  (luna-define-internal-accessors 'pgg-scheme))
 
-(luna-define-generic lookup-key-string (scheme string &optional type)
-  "Search keys associated with STRING")
+(luna-define-generic pgg-scheme-lookup-key (scheme string &optional type)
+  "Search keys associated with STRING.")
 
-(luna-define-generic encrypt-region (scheme start end recipients)
+(luna-define-generic pgg-scheme-encrypt-region (scheme start end recipients)
   "Encrypt the current region between START and END.")
 
-(luna-define-generic decrypt-region (scheme start end)
+(luna-define-generic pgg-scheme-decrypt-region (scheme start end)
   "Decrypt the current region between START and END.")
 
-(luna-define-generic sign-region (scheme start end &optional cleartext)
+(luna-define-generic pgg-scheme-sign-region
+  (scheme start end &optional cleartext)
   "Make detached signature from text between START and END.")
 
-(luna-define-generic verify-region (scheme start end &optional signature)
-  "Verify region between START and END
-as the detached signature SIGNATURE.")
+(luna-define-generic pgg-scheme-verify-region
+  (scheme start end &optional signature)
+  "Verify region between START and END as the detached signature SIGNATURE.")
 
-(luna-define-generic insert-key (scheme)
+(luna-define-generic pgg-scheme-insert-key (scheme)
   "Insert public key at point.")
 
-(luna-define-generic snarf-keys-region (scheme start end)
-  "Add all public keys in region between START
-and END to the keyring.")
+(luna-define-generic pgg-scheme-snarf-keys-region (scheme start end)
+  "Add all public keys in region between START and END to the keyring.")
 
 ;;; @ utility functions
 ;;;
@@ -161,33 +160,27 @@ and END to the keyring.")
                                   buffer-file-coding-system)
             (prog1 (save-excursion ,@body)
               (push nil buffer-undo-list)
-              (ignore-errors (undo)))
-            )))
+              (ignore-errors (undo))))))
      (save-restriction
        (narrow-to-region ,start ,end)
        ,@body)))
 
 (defun pgg-temp-buffer-show-function (buffer)
-  (if (one-window-p (selected-window))
-      (let ((window (split-window-vertically
-                    (- (window-height) 
-                       (/ (window-height) 5)))))
-       (set-window-buffer window buffer))
-    (display-buffer buffer)))
+  (let ((window (split-window-vertically)))
+    (set-window-buffer window buffer)
+    (shrink-window-if-larger-than-buffer window)))
 
 (defun pgg-display-output-buffer (start end status)
   (if status
       (progn
        (delete-region start end)
        (insert-buffer-substring pgg-output-buffer)
-       (decode-coding-region start (point) buffer-file-coding-system)
-       )
-    (let ((temp-buffer-show-function 
+       (decode-coding-region start (point) buffer-file-coding-system))
+    (let ((temp-buffer-show-function
           (function pgg-temp-buffer-show-function)))
       (with-output-to-temp-buffer pgg-echo-buffer
        (set-buffer standard-output)
-       (insert-buffer-substring pgg-errors-buffer)))
-    ))
+       (insert-buffer-substring pgg-errors-buffer)))))
 
 (defvar pgg-passphrase-cache-expiry 16)
 (defvar pgg-passphrase-cache (make-vector 7 0))
@@ -232,8 +225,7 @@ and END to the keyring.")
          (forward-line 1)))
        (LF
        (while (re-search-forward "\r$" pgg-conversion-end t)
-         (replace-match ""))))
-     ))
+         (replace-match ""))))))
 
 (put 'pgg-as-lbt 'lisp-indent-function 3)
 
@@ -264,9 +256,9 @@ and END to the keyring.")
    (list (region-beginning)(region-end)
         (split-string (read-string "Recipients: ") "[ \t,]+")))
   (let* ((entity (pgg-make-scheme pgg-default-scheme))
-        (status (pgg-save-coding-system start end
-                  (luna-send entity 'encrypt-region entity
-                             (point-min)(point-max) rcpts))))
+        (status
+         (pgg-save-coding-system start end
+           (pgg-scheme-encrypt-region entity (point-min)(point-max) rcpts))))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))
@@ -285,9 +277,9 @@ and END to the keyring.")
                                               packet))))
              pgg-default-scheme))
         (entity (pgg-make-scheme scheme))
-        (status (pgg-save-coding-system start end
-                  (luna-send entity 'decrypt-region entity 
-                             (point-min)(point-max)))))
+        (status
+         (pgg-save-coding-system start end
+           (pgg-scheme-decrypt-region entity (point-min)(point-max)))))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))
@@ -300,9 +292,8 @@ a detached signature."
   (interactive "r")
   (let* ((entity (pgg-make-scheme pgg-default-scheme))
         (status (pgg-save-coding-system start end
-                  (luna-send entity 'sign-region entity
-                             (point-min)(point-max)
-                             (or (interactive-p) cleartext)))))
+                  (pgg-scheme-sign-region entity (point-min)(point-max)
+                                          (or (interactive-p) cleartext)))))
     (when (interactive-p)
       (pgg-display-output-buffer start end status))
     status))
@@ -322,8 +313,8 @@ signer's public key from `pgg-default-keyserver-address'."
              (buffer-disable-undo)
              (set-buffer-multibyte nil)
              (insert-file-contents signature)
-             (cdr (assq 2 (pgg-decode-armor-region (point-min)(point-max))))
-             )))
+             (cdr (assq 2 (pgg-decode-armor-region
+                           (point-min)(point-max)))))))
         (scheme
          (or pgg-scheme
              (cdr (assq 'scheme
@@ -338,7 +329,7 @@ signer's public key from `pgg-default-keyserver-address'."
     (and (stringp key)
         (setq key (concat "0x" (pgg-truncate-key-identifier key)))
         (null (let ((pgg-scheme scheme))
-                (pgg-lookup-key-string key)))
+                (pgg-lookup-key key)))
         (or fetch (interactive-p))
         (y-or-n-p (format "Key %s not found; attempt to fetch? " key))
         (setq keyserver
@@ -346,16 +337,15 @@ signer's public key from `pgg-default-keyserver-address'."
                   pgg-default-keyserver-address))
         (pgg-fetch-key keyserver key))
     (setq status (pgg-save-coding-system start end
-                  (luna-send entity 'verify-region entity 
-                             (point-min)(point-max) signature)))
+                  (pgg-scheme-verify-region entity (point-min)(point-max)
+                                            signature)))
     (when (interactive-p)
       (let ((temp-buffer-show-function
             (function pgg-temp-buffer-show-function)))
        (with-output-to-temp-buffer pgg-echo-buffer
          (set-buffer standard-output)
          (insert-buffer-substring (if status pgg-output-buffer
-                                    pgg-errors-buffer))
-         )))
+                                    pgg-errors-buffer)))))
     status))
 
 ;;;###autoload
@@ -363,7 +353,7 @@ signer's public key from `pgg-default-keyserver-address'."
   "Insert the ASCII armored public key."
   (interactive)
   (let ((entity (pgg-make-scheme (or pgg-scheme pgg-default-scheme))))
-    (luna-send entity 'insert-key entity)))
+    (pgg-scheme-insert-key entity)))
 
 ;;;###autoload
 (defun pgg-snarf-keys-region (start end)
@@ -371,11 +361,11 @@ signer's public key from `pgg-default-keyserver-address'."
   (interactive "r")
   (let ((entity (pgg-make-scheme (or pgg-scheme pgg-default-scheme))))
     (pgg-save-coding-system start end
-      (luna-send entity 'snarf-keys-region entity start end))))
+      (pgg-scheme-snarf-keys-region entity start end))))
 
-(defun pgg-lookup-key-string (string &optional type)
+(defun pgg-lookup-key (string &optional type)
   (let ((entity (pgg-make-scheme (or pgg-scheme pgg-default-scheme))))
-    (luna-send entity 'lookup-key-string entity string type)))
+    (pgg-scheme-lookup-key entity string type)))
 
 (defvar pgg-insert-url-function  (function pgg-insert-url-with-w3))
 
@@ -402,8 +392,7 @@ signer's public key from `pgg-default-keyserver-address'."
        (delete-process process)
        (if (and process (eq 'run (process-status process)))
           (interrupt-process process))
-       (buffer-string)))
-    ))
+       (buffer-string)))))
 
 (defun pgg-fetch-key (keyserver key)
   "Attempt to fetch a KEY from KEYSERVER for addition to PGP or GnuPG keyring."
@@ -425,8 +414,7 @@ signer's public key from `pgg-default-keyserver-address'."
        (insert "\n")
        (with-temp-buffer
          (insert-buffer-substring pgg-output-buffer)
-         (pgg-snarf-keys-region (point-min)(point-max))))
-      )))
+         (pgg-snarf-keys-region (point-min)(point-max)))))))
 
 
 (provide 'pgg)