diff options
author | Werner Koch <wk@gnupg.org> | 2015-01-29 16:26:07 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2015-01-29 16:26:07 +0100 |
commit | 6ab0fac575a8b04152a199cb300a08436b096753 (patch) | |
tree | 8a7309b2ef2a8493c1762963fc58049740a60a19 /agent/cvt-openpgp.c | |
parent | po: Update Japanese Translation. (diff) | |
download | gnupg2-6ab0fac575a8b04152a199cb300a08436b096753.tar.xz gnupg2-6ab0fac575a8b04152a199cb300a08436b096753.zip |
agent: Fix use of imported but unprotected openpgp keys.
* agent/agent.h (PRIVATE_KEY_OPENPGP_NONE): New.
* agent/command.c (do_one_keyinfo): Implement it.
* agent/findkey.c (agent_key_from_file): Ditto.
(agent_key_info_from_file): Ditto.
(agent_delete_key): Ditto.
* agent/protect.c (agent_private_key_type): Add detection for openpgp
"none" method.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'agent/cvt-openpgp.c')
-rw-r--r-- | agent/cvt-openpgp.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/agent/cvt-openpgp.c b/agent/cvt-openpgp.c index 8cf00233e..5f944934a 100644 --- a/agent/cvt-openpgp.c +++ b/agent/cvt-openpgp.c @@ -1051,13 +1051,25 @@ convert_from_openpgp_native (ctrl_t ctrl, /* On success try to re-write the key. */ if (!err) { - unsigned char *protectedkey = NULL; - size_t protectedkeylen; - - if (!agent_protect (*r_key, passphrase, &protectedkey, &protectedkeylen, - ctrl->s2k_count)) - agent_write_private_key (grip, protectedkey, protectedkeylen, 1); - xfree (protectedkey); + if (*passphrase) + { + unsigned char *protectedkey = NULL; + size_t protectedkeylen; + + if (!agent_protect (*r_key, passphrase, + &protectedkey, &protectedkeylen, + ctrl->s2k_count)) + agent_write_private_key (grip, protectedkey, protectedkeylen, 1); + xfree (protectedkey); + } + else + { + /* Empty passphrase: write key without protection. */ + agent_write_private_key (grip, + *r_key, + gcry_sexp_canon_len (*r_key, 0, NULL,NULL), + 1); + } } return err; |