+;;;###autoload
+(defun epg-start-delete-keys (context keys &optional allow-secret)
+ "Initiate an delete 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-delete-keys' instead."
+ (epg-context-set-result context nil)
+ (epg-start context (cons (if allow-secret
+ "--delete-secret-key"
+ "--delete-key")
+ (mapcar
+ (lambda (key)
+ (epg-sub-key-id
+ (car (epg-key-sub-key-list key))))
+ keys))))
+
+;;;###autoload
+(defun epg-delete-keys (context keys &optional allow-secret)
+ "Delete KEYS from the key ring."
+ (unwind-protect
+ (progn
+ (epg-start-delete-keys context keys)
+ (epg-wait-for-completion context t)
+ (if (epg-context-result-for context 'error)
+ (error "Delete key failed")))
+ (epg-reset context)))
+