X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=epg.el;h=18ef4b9367af5153dfae6c40ffae7d3b9829db83;hb=ba1a4d03b21a2575b3e3e4b3e686acd6b20aac2c;hp=c04b4e106cc3982b30f8a4e790d1b11a9cc44af5;hpb=e4efd2bbfbcecbe5991d9e2374ba73173320acfc;p=elisp%2Fepg.git diff --git a/epg.el b/epg.el index c04b4e1..18ef4b9 100644 --- a/epg.el +++ b/epg.el @@ -200,7 +200,7 @@ cipher-algorithm digest-algorithm compress-algorithm #'epg-passphrase-callback-function #'epg-progress-callback-function - nil nil nil nil))) + nil nil nil nil nil))) (defun epg-context-protocol (context) "Return the protocol used within CONTEXT." @@ -283,6 +283,12 @@ This function is for internal use only." (signal 'wrong-type-argument (list 'epg-context-p context))) (aref (cdr context) 12)) +(defun epg-context-operation (context) + "Return the name of the current cryptographic operation." + (unless (eq (car context) 'epg-context) + (signal 'wrong-type-argument (list 'epg-context-p context))) + (aref (cdr context) 13)) + (defun epg-context-set-protocol (context protocol) "Set the protocol used within CONTEXT." (unless (eq (car context) 'epg-context) @@ -364,6 +370,12 @@ This function is for internal use only." (signal 'wrong-type-argument (list 'epg-context-p context))) (aset (cdr context) 12 result)) +(defun epg-context-set-operation (context operation) + "Set the name of the current cryptographic operation." + (unless (eq (car context) 'epg-context) + (signal 'wrong-type-argument (list 'epg-context-p context))) + (aset (cdr context) 13 operation)) + (defun epg-make-signature (status &optional key-id) "Return a signature object." (cons 'epg-signature (vector status key-id nil nil nil nil nil nil nil nil))) @@ -880,12 +892,12 @@ This function is for internal use only." (setq epg-pending-status-list status-list) (while (and (eq (process-status (epg-context-process context)) 'run) epg-pending-status-list) - (accept-process-output (epg-context-process context) 0 1)))) + (accept-process-output (epg-context-process context) 1)))) (defun epg-wait-for-completion (context) "Wait until the `epg-gpg-program' process completes." (while (eq (process-status (epg-context-process context)) 'run) - (accept-process-output (epg-context-process context) 0 1))) + (accept-process-output (epg-context-process context) 1))) (defun epg-reset (context) "Reset the CONTEXT." @@ -1034,7 +1046,7 @@ This function is for internal use only." (epg-context-result-for epg-context 'verify)))) (defun epg-status-ERRSIG (process string) - (let ((signatures (car (epg-context-result-for epg-context 'verify)))) + (let ((signatures (epg-context-result-for epg-context 'verify))) (unless signatures (setq signatures (list (epg-make-signature 'error))) (epg-context-set-result-for epg-context 'verify signatures)) @@ -1264,11 +1276,12 @@ This function is for internal use only." (epg-context-result-for epg-context 'error))))) (defun epg-passphrase-callback-function (context key-id handback) - (read-passwd - (if (eq key-id 'SYM) - "Passphrase for symmetric encryption: " + (if (eq key-id 'SYM) + (read-passwd "Passphrase for symmetric encryption: " + (eq (epg-context-operation context) 'encrypt)) + (read-passwd (if (eq key-id 'PIN) - "Passphrase for PIN: " + "Passphrase for PIN: " (let ((entry (assoc key-id epg-user-id-alist))) (if entry (format "Passphrase for %s %s: " key-id (cdr entry)) @@ -1500,6 +1513,7 @@ If you are unsure, use synchronous version of this function `epg-decrypt-file' or `epg-decrypt-string' instead." (unless (epg-data-file cipher) (error "Not a file")) + (epg-context-set-operation context 'decrypt) (epg-context-set-result context nil) (epg-start context (list "--decrypt" (epg-data-file cipher))) ;; `gpgsm' does not read passphrase from stdin, so waiting is not needed. @@ -1561,6 +1575,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-verify-file' or `epg-verify-string' instead." + (epg-context-set-operation context 'verify) (epg-context-set-result context nil) (if signed-text ;; Detached signature. @@ -1658,6 +1673,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-sign-file' or `epg-sign-string' instead." + (epg-context-set-operation context 'sign) (epg-context-set-result context nil) (epg-start context (append (list (if (memq mode '(t detached)) @@ -1743,6 +1759,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-encrypt-file' or `epg-encrypt-string' instead." + (epg-context-set-operation context 'encrypt) (epg-context-set-result context nil) (epg-start context (append (if always-trust '("--always-trust")) @@ -1838,6 +1855,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-export-keys-to-file' or `epg-export-keys-to-string' instead." + (epg-context-set-operation context 'export-keys) (epg-context-set-result context nil) (epg-start context (cons "--export" (mapcar @@ -1881,6 +1899,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-import-keys-from-file' or `epg-import-keys-from-string' instead." + (epg-context-set-operation context 'import-keys) (epg-context-set-result context nil) (epg-start context (list "--import" (epg-data-file keys))) (when (epg-data-string keys) @@ -1920,6 +1939,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-generate-key-from-file' or `epg-generate-key-from-string' instead." + (epg-context-set-operation context 'receive-keys) (epg-context-set-result context nil) (epg-start context (cons "--recv-keys" key-id-list))) @@ -1948,6 +1968,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-delete-keys' instead." + (epg-context-set-operation context 'delete-keys) (epg-context-set-result context nil) (epg-start context (cons (if allow-secret "--delete-secret-key" @@ -1979,6 +2000,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-sign-keys' instead." + (epg-context-set-operation context 'sign-keys) (epg-context-set-result context nil) (epg-start context (cons (if local "--lsign-key" @@ -2011,6 +2033,7 @@ If you use this function, you will need to wait for the completion of `epg-reset' to clear a temporaly output file. If you are unsure, use synchronous version of this function `epg-generate-key-from-file' or `epg-generate-key-from-string' instead." + (epg-context-set-operation context 'generate-key) (epg-context-set-result context nil) (if (epg-data-file parameters) (epg-start context (list "--batch" "--genkey"