X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=epg.el;h=e3ff7cda11ca2dd6a7304e99a9cafc8704d33204;hb=372371d54ef4c1060f3cfc70e557b28f4a4f8ee1;hp=6356fae90ef7ba09fcb2b3e2b4391067df8dd04f;hpb=7f1f6fca222a32fc153ffddfc180d3d0855c2650;p=elisp%2Fepg.git diff --git a/epg.el b/epg.el index 6356fae..e3ff7cd 100644 --- a/epg.el +++ b/epg.el @@ -1,4 +1,4 @@ -;;; epg.el --- EasyPG, yet another GnuPG interface. +;;; epg.el --- the EasyPG Library ;; Copyright (C) 1999, 2000, 2002, 2003, 2004, ;; 2005, 2006 Free Software Foundation, Inc. ;; Copyright (C) 2006 Daiki Ueno @@ -26,7 +26,7 @@ ;;; Code: (defgroup epg () - "EasyPG, yet another GnuPG interface.") + "The EasyPG Library") (defcustom epg-gpg-program "gpg" "The `gpg' executable." @@ -83,6 +83,19 @@ (2 . "ZLIB") (3 . "BZIP2"))) +(defconst epg-invalid-recipients-alist + '((0 . "No specific reason given") + (1 . "Not Found") + (2 . "Ambigious specification") + (3 . "Wrong key usage") + (4 . "Key revoked") + (5 . "Key expired") + (6 . "No CRL known") + (7 . "CRL too old") + (8 . "Policy mismatch") + (9 . "Not a secret key") + (10 . "Key not trusted"))) + (defvar epg-key-validity-alist '((?o . unknown) (?i . invalid) @@ -362,7 +375,8 @@ This function is for internal use only." "Start `epg-gpg-program' in a subprocess with given ARGS." (let* ((args (append (list "--no-tty" "--status-fd" "1" - "--command-fd" "0") + "--command-fd" "0" + "--yes") (if (epg-context-armor context) '("--armor")) (if (epg-context-textmode context) '("--textmode")) (if (epg-context-output-file context) @@ -641,6 +655,21 @@ This function is for internal use only." (cons 'bad-armor (epg-context-result-for epg-context 'error)))) +(defun epg-status-INV_RECP (process string) + (if (string-match "\\`\\([0-9]+\\) \\(.*\\)" string) + (epg-context-set-result-for + epg-context 'error + (cons (list 'invalid-recipient + (string-to-number (match-string 1 string)) + (match-string 2 string)) + (epg-context-result-for epg-context 'error))))) + +(defun epg-status-NO_RECP (process string) + (epg-context-set-result-for + epg-context 'error + (cons 'no-recipients + (epg-context-result-for epg-context 'error)))) + (defun epg-passphrase-callback-function (key-id handback) (read-passwd (if (eq key-id 'SYM) @@ -828,7 +857,8 @@ If PLAIN is nil, it returns the result as a string." (epg-start-decrypt context (epg-make-data-from-file cipher)) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) - (error "Decryption failed")) + (error "Decrypt failed: %S" + (epg-context-result-for context 'error))) (unless plain (epg-read-output context))) (unless plain @@ -848,7 +878,8 @@ If PLAIN is nil, it returns the result as a string." (epg-start-decrypt context (epg-make-data-from-file input-file)) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) - (error "Decryption failed")) + (error "Decrypt failed: %S" + (epg-context-result-for context 'error))) (epg-read-output context)) (epg-delete-output-file context) (if (file-exists-p input-file) @@ -990,7 +1021,8 @@ Otherwise, it makes a normal signature." (epg-start-sign context (epg-make-data-from-file plain) mode) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) - (error "Sign failed")) + (error "Sign failed: %S" + (epg-context-result-for context 'error))) (unless signature (epg-read-output context))) (unless signature @@ -1010,7 +1042,8 @@ Otherwise, it makes a normal signature." (epg-start-sign context (epg-make-data-from-string plain) mode) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) - (error "Sign failed")) + (error "Sign failed: %S" + (epg-context-result-for context 'error))) (epg-read-output context)) (epg-delete-output-file context) (epg-reset context))) @@ -1068,7 +1101,8 @@ If RECIPIENTS is nil, it performs symmetric encryption." recipients sign always-trust) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) - (error "Encrypt failed")) + (error "Encrypt failed: %S" + (epg-context-result-for context 'error))) (unless cipher (epg-read-output context))) (unless cipher @@ -1088,7 +1122,8 @@ If RECIPIENTS is nil, it performs symmetric encryption." recipients sign always-trust) (epg-wait-for-completion context) (if (epg-context-result-for context 'error) - (error "Encrypt failed")) + (error "Encrypt failed: %S" + (epg-context-result-for context 'error))) (epg-read-output context)) (epg-delete-output-file context) (epg-reset context)))