aboutsummaryrefslogtreecommitdiffstats
path: root/agent/learncard.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2016-10-20 03:05:15 +0000
committerNIIBE Yutaka <[email protected]>2016-10-20 03:05:15 +0000
commit82cbab906a3e72a98fdc16096f2f0451465969a2 (patch)
tree03b9e3b4a87abb2082ec628445b438520248337b /agent/learncard.c
parentdirmngr: improve VERSIONCHECK (diff)
downloadgnupg-82cbab906a3e72a98fdc16096f2f0451465969a2.tar.gz
gnupg-82cbab906a3e72a98fdc16096f2f0451465969a2.zip
agent: Add --card option for READKEY.
* agent/findkey.c (agent_write_shadow_key): New. * agent/command-ssh.c (card_key_available): Use agent_write_shadow_key. * agent/learncard.c (agent_handle_learn): Likewise. * agent/command.c (cmd_readkey): Add --card option. -- Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'agent/learncard.c')
-rw-r--r--agent/learncard.c30
1 files changed, 3 insertions, 27 deletions
diff --git a/agent/learncard.c b/agent/learncard.c
index e9304fb8b..103a82163 100644
--- a/agent/learncard.c
+++ b/agent/learncard.c
@@ -381,8 +381,7 @@ agent_handle_learn (ctrl_t ctrl, int send, void *assuan_context, int force)
for (item = parm.info; item; item = item->next)
{
- unsigned char *pubkey, *shdkey;
- size_t n;
+ unsigned char *pubkey;
if (opt.verbose)
log_info (" id: %s (grip=%s)\n", item->id, item->hexgrip);
@@ -410,33 +409,10 @@ agent_handle_learn (ctrl_t ctrl, int send, void *assuan_context, int force)
goto leave;
}
- {
- unsigned char *shadow_info = make_shadow_info (serialno, item->id);
- if (!shadow_info)
- {
- rc = gpg_error (GPG_ERR_ENOMEM);
- xfree (pubkey);
- goto leave;
- }
- rc = agent_shadow_key (pubkey, shadow_info, &shdkey);
- xfree (shadow_info);
- }
+ rc = agent_write_shadow_key (grip, serialno, item->id, pubkey, force);
xfree (pubkey);
if (rc)
- {
- log_error ("shadowing the key failed: %s\n", gpg_strerror (rc));
- goto leave;
- }
- n = gcry_sexp_canon_len (shdkey, 0, NULL, NULL);
- assert (n);
-
- rc = agent_write_private_key (grip, shdkey, n, force);
- xfree (shdkey);
- if (rc)
- {
- log_error ("error writing key: %s\n", gpg_strerror (rc));
- goto leave;
- }
+ goto leave;
if (opt.verbose)
log_info (" id: %s - shadow key created\n", item->id);