Skip to content

Commit 1512c7b

Browse files
committed
Add option for scdaemon to prompt user to ack card.
This is useful, e.g., for Yubikeys configured with fixed touch policy.
1 parent 25ae80b commit 1512c7b

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

scd/app-openpgp.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5327,6 +5327,9 @@ do_sign (app_t app, ctrl_t ctrl, const char *keyidstr, int hashalgo,
53275327
wipe_and_free (pinvalue, pinlen);
53285328
}
53295329

5330+
// Prompt to touch/ack the card.
5331+
if (opt.ack_prompt)
5332+
pincb (pincb_arg, _("--ack"), NULL);
53305333

53315334
if (app->app_local->cardcap.ext_lc_le
53325335
&& app->app_local->keyattr[0].key_type == KEY_TYPE_RSA
@@ -5350,6 +5353,10 @@ do_sign (app_t app, ctrl_t ctrl, const char *keyidstr, int hashalgo,
53505353
cache_pin (app, ctrl, 1, NULL);
53515354
}
53525355

5356+
// Dismiss prompt after signing (or timing out)
5357+
if (opt.ack_prompt)
5358+
pincb (pincb_arg, NULL, NULL);
5359+
53535360
return rc;
53545361
}
53555362

@@ -5422,9 +5429,19 @@ do_auth (app_t app, ctrl_t ctrl, const char *keyidstr,
54225429
exmode = 0;
54235430
le_value = 0;
54245431
}
5432+
5433+
// Prompt to touch/ack the card.
5434+
if (opt.ack_prompt)
5435+
pincb (pincb_arg, _("--ack"), NULL);
5436+
54255437
rc = iso7816_internal_authenticate (app_get_slot (app), exmode,
54265438
indata, indatalen, le_value,
54275439
outdata, outdatalen);
5440+
5441+
// Dismiss prompt after authenticating (or timing out)
5442+
if (opt.ack_prompt)
5443+
pincb (pincb_arg, NULL, NULL);
5444+
54285445
if (gpg_err_code (rc) == GPG_ERR_TIMEOUT)
54295446
clear_chv_status (app, ctrl, 1);
54305447
}
@@ -5617,10 +5634,19 @@ do_decipher (app_t app, ctrl_t ctrl, const char *keyidstr,
56175634
else
56185635
exmode = le_value = 0;
56195636

5637+
// Prompt to touch/ack the card.
5638+
if (opt.ack_prompt)
5639+
pincb (pincb_arg, _("--ack"), NULL);
5640+
56205641
rc = iso7816_decipher (app_get_slot (app), exmode,
56215642
indata, indatalen, le_value, padind,
56225643
outdata, outdatalen);
56235644
xfree (fixbuf);
5645+
5646+
// Dismiss prompt after deciphering (or timing out)
5647+
if (opt.ack_prompt)
5648+
pincb (pincb_arg, NULL, NULL);
5649+
56245650
if (!rc && app->app_local->keyattr[1].key_type == KEY_TYPE_ECC)
56255651
{
56265652
unsigned char prefix = 0;

scd/scdaemon.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ enum cmd_and_opt_values
102102
oDenyAdmin,
103103
oDisableApplication,
104104
oApplicationPriority,
105+
oAckPrompt,
105106
oEnablePinpadVarlen,
106107
oListenBacklog
107108
};
@@ -170,6 +171,7 @@ static gpgrt_opt_t opts[] = {
170171
ARGPARSE_s_s (oDisableApplication, "disable-application", "@"),
171172
ARGPARSE_s_s (oApplicationPriority, "application-priority",
172173
N_("|LIST|change the application priority to LIST")),
174+
ARGPARSE_s_n (oAckPrompt, "ack-prompt", N_("display ACK prompt while waiting for card")),
173175
ARGPARSE_s_i (oListenBacklog, "listen-backlog", "@"),
174176

175177

@@ -610,6 +612,8 @@ main (int argc, char **argv )
610612

611613
case oDisablePinpad: opt.disable_pinpad = 1; break;
612614

615+
case oAckPrompt: opt.ack_prompt = 1; break;
616+
613617
case oAllowAdmin: /* Dummy because allow is now the default. */
614618
break;
615619
case oDenyAdmin: opt.allow_admin = 0; break;

scd/scdaemon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct
6060
int disable_ccid; /* Disable the use of the internal CCID driver. */
6161
int disable_pinpad; /* Do not use a pinpad. */
6262
int enable_pinpad_varlen; /* Use variable length input for pinpad. */
63+
int ack_prompt; /* Display ACK prompt to user when waiting for card. */
6364
int allow_admin; /* Allow the use of admin commands for certain
6465
cards. */
6566
int pcsc_shared; /* Use shared PC/SC access. */

0 commit comments

Comments
 (0)