* epg.el (epg-start-export-keys): New function.
authorueno <ueno>
Wed, 12 Apr 2006 08:21:19 +0000 (08:21 +0000)
committerueno <ueno>
Wed, 12 Apr 2006 08:21:19 +0000 (08:21 +0000)
(epg-export-keys): New function.
(epg-start-import-keys): New function.
(epg-import-keys): New function.

* epg.el (epg-passphrase-callback-function): Always display key-id.

ChangeLog
epg.el

index 16b5c5d..94114be 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2006-04-12  Daiki Ueno  <ueno@unixuser.org>
 
+       * epg.el (epg-start-export-keys): New function.
+       (epg-export-keys): New function.
+       (epg-start-import-keys): New function.
+       (epg-import-keys): New function.
+
        * epg-file.el (epg-file-write-region): Support public key encryption.
 
        * epg.el (epg-passphrase-callback-function): Always display key-id.
diff --git a/epg.el b/epg.el
index 26d94b7..110bbeb 100644 (file)
--- a/epg.el
+++ b/epg.el
@@ -700,7 +700,7 @@ Otherwise, it makes a normal signature."
 ;;;###autoload
 (defun epg-start-encrypt (context string recipients
                                  &optional sign always-trust)
-  "Initiate a encrypt operation on STRING.
+  "Initiate an encrypt operation on STRING.
 If RECIPIENTS is nil, it performs symmetric encryption.
 
 If you use this function, you will need to wait for the completion of
@@ -743,6 +743,56 @@ If RECIPIENTS is nil, it performs symmetric encryption."
        (epg-read-output context))
     (epg-reset context)))
 
+;;;###autoload
+(defun epg-start-export-keys (context pattern)
+  "Initiate an export keys operation.
+
+If you use this function, you will need to wait for the completion of
+`epg-gpg-program' by using `epg-wait-for-completion' and call
+`epg-reset' to clear a temporaly output file.
+If you are unsure, use synchronous version of this function
+`epg-export-keys' instead."
+  (epg-context-set-output-file context (epg-make-temp-file "epg-output"))
+  (epg-start context (list "--export" pattern)))
+
+;;;###autoload
+(defun epg-export-keys (context pattern)
+  "Extract public keys matched with PATTERN and return them."
+  (unwind-protect
+      (progn
+       (epg-start-export-keys context pattern)
+       (epg-wait-for-completion context)
+       (if (epg-context-result-for context 'error)
+           (error "Export keys failed"))
+       (epg-read-output context))
+    (epg-reset context)))
+
+;;;###autoload
+(defun epg-start-import-keys (context keys)
+  "Initiate an import key operation.
+
+If you use this function, you will need to wait for the completion of
+`epg-gpg-program' by using `epg-wait-for-completion' and call
+`epg-reset' to clear a temporaly output file.
+If you are unsure, use synchronous version of this function
+`epg-import-keys' instead."
+  (epg-context-set-output-file context (epg-make-temp-file "epg-output"))
+  (epg-start context (list "--import"))
+  (if (eq (process-status (epg-context-process context)) 'run)
+      (process-send-string (epg-context-process context) keys)))
+
+;;;###autoload
+(defun epg-import-keys (context keys)
+  "Add KEYS."
+  (unwind-protect
+      (progn
+       (epg-start-import-keys context keys)
+       (epg-wait-for-completion context)
+       (if (epg-context-result-for context 'error)
+           (error "Import keys failed"))
+       (epg-read-output context))
+    (epg-reset context)))
+
 (provide 'epg)
 
 ;;; epg.el ends here