aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2022-08-16 11:02:25 +0000
committerWerner Koch <[email protected]>2022-08-16 11:02:25 +0000
commit2d23a72690b44528783264a93e170585a99cc774 (patch)
tree6a6738af45fdaa2b18faa327ba0848b408f39c02
parentagent: Let READKEY update the display-s/n of the Token entry. (diff)
downloadgnupg-2d23a72690b44528783264a93e170585a99cc774.tar.gz
gnupg-2d23a72690b44528783264a93e170585a99cc774.zip
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.
-rw-r--r--agent/command.c5
-rw-r--r--g10/call-agent.c23
-rw-r--r--g10/call-agent.h3
-rw-r--r--g10/card-util.c3
4 files changed, 32 insertions, 2 deletions
diff --git a/agent/command.c b/agent/command.c
index b57fa9c44..b682c55e0 100644
--- a/agent/command.c
+++ b/agent/command.c
@@ -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;
diff --git a/g10/call-agent.c b/g10/call-agent.c
index fd9f8e079..d416a72f8 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -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;
diff --git a/g10/call-agent.h b/g10/call-agent.h
index 76edb699a..dbc6e2fe9 100644
--- a/g10/call-agent.h
+++ b/g10/call-agent.h
@@ -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);
diff --git a/g10/card-util.c b/g10/card-util.c
index 03a873244..f54e5e1c4 100644
--- a/g10/card-util.c
+++ b/g10/card-util.c
@@ -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;