+;;;###autoload
+(defun epg-start-generate-key (context parameters)
+ "Initiate a key generation.
+PARAMETERS specifies parameters for the key.
+
+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-generate-key-from-file' or `epg-generate-key-from-string' instead."
+ (epg-context-set-result context nil)
+ (if (epg-data-file parameters)
+ (epg-start context (list "--batch" "--genkey"
+ (epg-data-file parameters)))
+ (epg-start context '("--batch" "--genkey"))
+ (if (eq (process-status (epg-context-process context)) 'run)
+ (process-send-string (epg-context-process context)
+ (epg-data-string parameters)))
+ (if (eq (process-status (epg-context-process context)) 'run)
+ (process-send-eof (epg-context-process context)))))
+
+;;;###autoload
+(defun epg-generate-key-from-file (context parameters)
+ "Generate a new key pair.
+PARAMETERS is a file which tells how to create the key."
+ (unwind-protect
+ (progn
+ (epg-start-generate-key context (epg-make-data-from-file parameters))
+ (epg-wait-for-completion context)
+ (if (epg-context-result-for context 'error)
+ (error "Generate key failed: %S"
+ (epg-context-result-for context 'error))))
+ (epg-reset context)))
+
+;;;###autoload
+(defun epg-generate-key-from-string (context parameters)
+ "Generate a new key pair.
+PARAMETERS is a file which tells how to create the key."
+ (unwind-protect
+ (progn
+ (epg-start-generate-key context (epg-make-data-from-string parameters))
+ (epg-wait-for-completion context)
+ (if (epg-context-result-for context 'error)
+ (error "Generate key failed: %S"
+ (epg-context-result-for context 'error))))
+ (epg-reset context)))
+