summaryrefslogtreecommitdiffstats
path: root/g10/call-agent.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-11-09 13:04:38 +0100
committerWerner Koch <wk@gnupg.org>2020-11-09 13:41:26 +0100
commit8fb0d5e3c775f40e321689b35431d81425406237 (patch)
treeca111c2b43df73c16f48e8bc8ab0ae2aa3371de6 /g10/call-agent.c
parentgpg: Do not print rejected digest algo notes with --quiet. (diff)
downloadgnupg2-8fb0d5e3c775f40e321689b35431d81425406237.tar.xz
gnupg2-8fb0d5e3c775f40e321689b35431d81425406237.zip
card: Run factory-reset in locked stated.
* scd/command.c (reset_notify): Add option --keep-lock. (do_reset): Add arg keep_lock. (cmd_lock): Send progress status. * g10/call-agent.c (agent_scd_apdu): Add more pseudo APDUs. * g10/card-util.c (send_apdu): Ditto. (factory_reset): Use lock commands. -- This is required so that for example Kleopatra does not detect the RESET and issues a SERIALNO of its own, thus conflicting with our SERIALNO undefined. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/call-agent.c')
-rw-r--r--g10/call-agent.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/g10/call-agent.c b/g10/call-agent.c
index c4d146392..01f59aca8 100644
--- a/g10/call-agent.c
+++ b/g10/call-agent.c
@@ -975,8 +975,14 @@ agent_scd_keypairinfo (ctrl_t ctrl, const char *keyref, keypair_info_t *r_list)
/* Send an APDU to the current card. On success the status word is
* stored at R_SW. With HEXAPDU being NULL only a RESET command is
- * send to scd. With HEXAPDU being the string "undefined" the command
- * "SERIALNO undefined" is send to scd.
+ * send to scd. HEXAPDU may also be one of these special strings:
+ *
+ * "undefined" :: Send the command "SCD SERIALNO undefined"
+ * "lock" :: Send the command "SCD LOCK --wait"
+ * "trylock" :: Send the command "SCD LOCK"
+ * "unlock" :: Send the command "SCD UNLOCK"
+ * "reset-keep-lock" :: Send the command "SCD RESET --keep-lock"
+ *
* Used by:
* card-util.c
*/
@@ -997,6 +1003,26 @@ agent_scd_apdu (const char *hexapdu, unsigned int *r_sw)
NULL, NULL, NULL, NULL, NULL, NULL);
}
+ else if (!strcmp (hexapdu, "reset-keep-lock"))
+ {
+ err = assuan_transact (agent_ctx, "SCD RESET --keep-lock",
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ }
+ else if (!strcmp (hexapdu, "lock"))
+ {
+ err = assuan_transact (agent_ctx, "SCD LOCK --wait",
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ }
+ else if (!strcmp (hexapdu, "trylock"))
+ {
+ err = assuan_transact (agent_ctx, "SCD LOCK",
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ }
+ else if (!strcmp (hexapdu, "unlock"))
+ {
+ err = assuan_transact (agent_ctx, "SCD UNLOCK",
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ }
else if (!strcmp (hexapdu, "undefined"))
{
err = assuan_transact (agent_ctx, "SCD SERIALNO undefined",