Next: , Previous: Importing Keys, Up: Key Management


7.4.8 Deleting Keys

— Function: gpgme_error_t gpgme_op_delete (gpgme_ctx_t ctx, const gpgme_key_t key, int allow_secret)

The function gpgme_op_delete deletes the key key from the key ring of the crypto engine used by ctx. If allow_secret is 0, only public keys are deleted, otherwise secret keys are deleted as well, if that is supported.

The function returns the error code GPG_ERR_NO_ERROR if the key was deleted successfully, GPG_ERR_INV_VALUE if ctx or key is not a valid pointer, GPG_ERR_NO_PUBKEY if key could not be found in the keyring, GPG_ERR_AMBIGUOUS_NAME if the key was not specified unambiguously, and GPG_ERR_CONFLICT if the secret key for key is available, but allow_secret is zero.

— Function: gpgme_error_t gpgme_op_delete_start (gpgme_ctx_t ctx, const gpgme_key_t key, int allow_secret)

The function gpgme_op_delete_start initiates a gpgme_op_delete operation. It can be completed by calling gpgme_wait on the context. See Waiting For Completion.

The function returns the error code GPG_ERR_NO_ERROR if the operation was started successfully, and GPG_ERR_INV_VALUE if ctx or key is not a valid pointer.