1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-21 14:47:03 +01:00

gpg: Update shadow-keys with --card-status also for non-openpgp cards.

* agent/command.c (cmd_readkey): Also allow for $AUTHKEYID in card
mode.
* g10/call-agent.c (agent_update_shadow_keys): new.
* g10/card-util.c (current_card_status): Call it.
This commit is contained in:
Werner Koch 2022-08-16 13:02:25 +02:00
parent 755920d433
commit 2d23a72690
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 32 additions and 2 deletions

View File

@ -1016,8 +1016,9 @@ cmd_readkey (assuan_context_t ctx, char *line)
goto leave;
}
/* Hack to create the shadow key for the OpenPGP standard keys. */
if ((!strcmp (keyid, "$SIGNKEYID") || !strcmp (keyid, "$ENCRKEYID"))
/* Hack to create the shadow key for the standard keys. */
if ((!strcmp (keyid, "$SIGNKEYID") || !strcmp (keyid, "$ENCRKEYID")
|| !strcmp (keyid, "$AUTHKEYID"))
&& !agent_card_getattr (ctrl, keyid, &keyidbuf))
keyid = keyidbuf;

View File

@ -1414,6 +1414,29 @@ agent_scd_readkey (const char *keyrefstr, gcry_sexp_t *r_result)
}
/* This can be called for a quick and dirty update/creation of the
* shadow key stubs. */
gpg_error_t
agent_update_shadow_keys (void)
{
gpg_error_t err;
err = start_agent (NULL, 1);
if (err)
return err;
assuan_transact (agent_ctx, "READKEY --card --no-data -- $SIGNKEYID",
NULL, NULL, NULL, NULL, NULL, NULL);
assuan_transact (agent_ctx, "READKEY --card --no-data -- $ENCRKEYID",
NULL, NULL, NULL, NULL, NULL, NULL);
assuan_transact (agent_ctx, "READKEY --card --no-data -- $AUTHKEYID",
NULL, NULL, NULL, NULL, NULL, NULL);
return err;
}
struct card_cardlist_parm_s {
int error;

View File

@ -124,6 +124,9 @@ int agent_scd_readcert (const char *certidstr,
/* Send a READKEY command to the SCdaemon. */
gpg_error_t agent_scd_readkey (const char *keyrefstr, gcry_sexp_t *r_result);
/* Update common shadow key stubs. */
gpg_error_t agent_update_shadow_keys (void);
/* Change the PIN of an OpenPGP card or reset the retry counter. */
int agent_scd_change_pin (int chvno, const char *serialno);

View File

@ -420,6 +420,9 @@ current_card_status (ctrl_t ctrl, estream_t fp,
else
tty_fprintf (fp, "Application type .: %s\n", name2);
/* Try to update/create the shadow key here for non-OpenPGP cards. */
agent_update_shadow_keys ();
agent_release_card_info (&info);
xfree (pk);
return;