;;;###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
(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