diff options
author | Werner Koch <wk@gnupg.org> | 2014-04-15 16:40:48 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2014-04-15 19:44:50 +0200 |
commit | db3b528239c9d56bc71fd2283e07a3f1d91e4fd0 (patch) | |
tree | 905f77e255d5f32f01590c37a6802dc773de96e6 /g10/call-agent.c | |
parent | gpg: Re-indent a file. (diff) | |
download | gnupg2-db3b528239c9d56bc71fd2283e07a3f1d91e4fd0.tar.xz gnupg2-db3b528239c9d56bc71fd2283e07a3f1d91e4fd0.zip |
gpg: Re-enable secret key deletion.
* g10/call-agent.c (agent_delete_key): New.
* g10/keydb.h (FORMAT_KEYDESC_DELKEY): New.
* g10/passphrase.c (gpg_format_keydesc): Support new format.
* g10/delkey.c (do_delete_key): Add secret key deletion.
Diffstat (limited to 'g10/call-agent.c')
-rw-r--r-- | g10/call-agent.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c index 4ce6a06ab..5ad0983b9 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -2127,6 +2127,44 @@ agent_export_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc, +/* Ask the agent to delete the key identified by HEXKEYGRIP. If DESC + is not NULL, display DESC instead of the default description + message. */ +gpg_error_t +agent_delete_key (ctrl_t ctrl, const char *hexkeygrip, const char *desc) +{ + gpg_error_t err; + char line[ASSUAN_LINELENGTH]; + struct default_inq_parm_s dfltparm; + + memset (&dfltparm, 0, sizeof dfltparm); + dfltparm.ctrl = ctrl; + + err = start_agent (ctrl, 0); + if (err) + return err; + + if (!hexkeygrip || strlen (hexkeygrip) != 40) + return gpg_error (GPG_ERR_INV_VALUE); + + if (desc) + { + snprintf (line, DIM(line)-1, "SETKEYDESC %s", desc); + err = assuan_transact (agent_ctx, line, + NULL, NULL, NULL, NULL, NULL, NULL); + if (err) + return err; + } + + snprintf (line, DIM(line)-1, "DELETE_KEY %s", hexkeygrip); + err = assuan_transact (agent_ctx, line, NULL, NULL, + default_inq_cb, &dfltparm, + NULL, NULL); + return err; +} + + + /* Ask the agent to change the passphrase of the key identified by HEXKEYGRIP. If DESC is not NULL, display DESC instead of the default description message. If CACHE_NONCE_ADDR is not NULL the |