mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
card: Support factory reset for Yubikey PIV application.
* scd/app-common.h (struct app_ctx_s): Add field cardtype. * scd/app.c (app_new_register): Set cardtype for yubikey. (app_getattr): Add CARDTYPE. (app_write_learn_status): Emit new attribute. * scd/app-piv.c (do_getattr): Add CHV-USAGE. (do_learn_status): Emit it. * tools/card-tool.h (struct card_info_s): Add field cardtype. * tools/card-call-scd.c (learn_status_cb): Parse "CARDTYPE". * tools/gpg-card-tool.c (list_piv): Print PIN usage policy. (list_card): Print card type. (cmd_factoryreset): Implement for Yubikey with PIV. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
9325c92284
commit
79bed504e5
6 changed files with 190 additions and 85 deletions
13
scd/app.c
13
scd/app.c
|
@ -228,6 +228,7 @@ app_new_register (int slot, ctrl_t ctrl, const char *name,
|
|||
&& !iso7816_apdu_direct (slot, "\x00\x1d\x00\x00\x00", 5, 0,
|
||||
NULL, &buf, &buflen))
|
||||
{
|
||||
app->cardtype = "yubikey";
|
||||
if (opt.verbose)
|
||||
{
|
||||
log_info ("Yubico: config=");
|
||||
|
@ -640,9 +641,12 @@ app_write_learn_status (app_t app, ctrl_t ctrl, unsigned int flags)
|
|||
if (!app->fnc.learn_status)
|
||||
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
|
||||
|
||||
/* We do not send APPTYPE if only keypairinfo is requested. */
|
||||
/* We do not send CARD and APPTYPE if only keypairinfo is requested. */
|
||||
if (app->cardtype && !(flags & 1))
|
||||
send_status_direct (ctrl, "CARDTYPE", app->cardtype);
|
||||
if (app->apptype && !(flags & 1))
|
||||
send_status_direct (ctrl, "APPTYPE", app->apptype);
|
||||
|
||||
err = lock_app (app, ctrl);
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -721,6 +725,11 @@ app_getattr (app_t app, ctrl_t ctrl, const char *name)
|
|||
if (!app->ref_count)
|
||||
return gpg_error (GPG_ERR_CARD_NOT_INITIALIZED);
|
||||
|
||||
if (app->cardtype && name && !strcmp (name, "CARDTYPE"))
|
||||
{
|
||||
send_status_direct (ctrl, "CARDTYPE", app->cardtype);
|
||||
return 0;
|
||||
}
|
||||
if (app->apptype && name && !strcmp (name, "APPTYPE"))
|
||||
{
|
||||
send_status_direct (ctrl, "APPTYPE", app->apptype);
|
||||
|
@ -744,7 +753,7 @@ app_getattr (app_t app, ctrl_t ctrl, const char *name)
|
|||
err = lock_app (app, ctrl);
|
||||
if (err)
|
||||
return err;
|
||||
err = app->fnc.getattr (app, ctrl, name);
|
||||
err = app->fnc.getattr (app, ctrl, name);
|
||||
unlock_app (app);
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue