+;;;###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-result context nil)
+ (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 keys operation.
+KEYS is a data object.
+
+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-from-file' or `epg-import-keys-from-string' instead."
+ (epg-context-set-result context nil)
+ (epg-context-set-output-file context (epg-make-temp-file "epg-output"))
+ (epg-start context (append (list "--import") (epg-data-file keys)))
+ (if (and (epg-data-string keys)
+ (eq (process-status (epg-context-process context)) 'run))
+ (process-send-string (epg-context-process context)
+ (epg-data-string keys))))
+
+(defun epg-import-keys-1 (context 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)))
+
+;;;###autoload
+(defun epg-import-keys-from-file (context keys)
+ "Add keys from a file KEYS."
+ (epg-import-keys-1 context (epg-make-data-from-file keys)))
+
+;;;###autoload
+(defun epg-import-keys-from-string (context keys)
+ "Add keys from a string KEYS."
+ (epg-import-keys-1 context (epg-make-data-from-string keys)))
+