mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
agent: Let READKEY update the display-s/n of the Token entry.
* agent/findkey.c (agent_write_private_key): Factor file name generation out to ... (fname_from_keygrip): new. (write_extended_private_key): Add and implement new arg MAYBE_UPDATE. (agent_write_shadow_key): Ditto. * agent/command.c (cmd_readkey): Update the shadow-key in card mode. -- GnuPG-bug-id 6135
This commit is contained in:
parent
8e393e2592
commit
755920d433
5 changed files with 176 additions and 66 deletions
|
@ -995,6 +995,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||
char *keyidbuf = NULL;
|
||||
size_t pkbuflen;
|
||||
int opt_card, opt_no_data;
|
||||
char *dispserialno = NULL;
|
||||
|
||||
if (ctrl->restricted)
|
||||
return leave_cmd (ctx, gpg_error (GPG_ERR_FORBIDDEN));
|
||||
|
@ -1037,18 +1038,23 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||
goto leave;
|
||||
}
|
||||
|
||||
agent_card_getattr (ctrl, "$DISPSERIALNO", &dispserialno);
|
||||
if (agent_key_available (grip))
|
||||
{
|
||||
/* (Shadow)-key is not available in our key storage. */
|
||||
char *dispserialno;
|
||||
|
||||
agent_card_getattr (ctrl, "$DISPSERIALNO", &dispserialno);
|
||||
rc = agent_write_shadow_key (grip, serialno, keyid, pkbuf, 0,
|
||||
/* Shadow-key is not available in our key storage. */
|
||||
rc = agent_write_shadow_key (0, grip, serialno, keyid, pkbuf, 0,
|
||||
dispserialno);
|
||||
xfree (dispserialno);
|
||||
if (rc)
|
||||
goto leave;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Shadow-key is available in our key storage but ne check
|
||||
* whether we need to update it with a new display-s/n or
|
||||
* whatever. */
|
||||
rc = agent_write_shadow_key (1, grip, serialno, keyid, pkbuf, 0,
|
||||
dispserialno);
|
||||
}
|
||||
if (rc)
|
||||
goto leave;
|
||||
|
||||
rc = opt_no_data? 0 : assuan_send_data (ctx, pkbuf, pkbuflen);
|
||||
}
|
||||
|
@ -1079,6 +1085,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
|
|||
xfree (keyidbuf);
|
||||
xfree (serialno);
|
||||
xfree (pkbuf);
|
||||
xfree (dispserialno);
|
||||
gcry_sexp_release (s_pkey);
|
||||
return leave_cmd (ctx, rc);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue