aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2020-08-27 05:32:04 +0000
committerNIIBE Yutaka <[email protected]>2020-08-27 05:32:04 +0000
commit9f148360a2bf04672b43ef7cec48e21d44b06ae1 (patch)
treea2d772e11b1ac3f815a563fca80b999e9d7b424c /scd/app.c
parentscd: Add condition for VERIFY with 0x82. (diff)
downloadgnupg-9f148360a2bf04672b43ef7cec48e21d44b06ae1.tar.gz
gnupg-9f148360a2bf04672b43ef7cec48e21d44b06ae1.zip
scd: Add heuristics to identify cardtype.
* scd/app-common.h (cardtype_t): Add CARDTYPE_GNUK and CARDTYPE_ZEITCONTROL. * scd/app.c (strcardtype): Handle CARDTYPE_GNUK and CARDTYPE_ZEITCONTROL. (app_new_register): Detect Gnuk and Zeit Control implementation by examining its ATR string. Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'scd/app.c')
-rw-r--r--scd/app.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/scd/app.c b/scd/app.c
index f1edfe05c..6a583d4c2 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -83,8 +83,10 @@ strcardtype (cardtype_t t)
{
switch (t)
{
- case CARDTYPE_GENERIC: return "generic";
- case CARDTYPE_YUBIKEY: return "yubikey";
+ case CARDTYPE_GENERIC: return "generic";
+ case CARDTYPE_GNUK: return "gnuk";
+ case CARDTYPE_YUBIKEY: return "yubikey";
+ case CARDTYPE_ZEITCONTROL: return "zeitcontrol";
}
return "?";
}
@@ -540,6 +542,22 @@ app_new_register (int slot, ctrl_t ctrl, const char *name,
xfree (buf);
}
}
+ else
+ {
+ unsigned char *atr;
+ size_t atrlen;
+
+ /* This is heuristics to identify different implementations. */
+ atr = apdu_get_atr (app_get_slot (app), &atrlen);
+ if (atr)
+ {
+ if (atrlen == 21 && atr[2] == 0x11)
+ card->cardtype = CARDTYPE_GNUK;
+ else if (atrlen == 21 && atr[7] == 0x75)
+ card->cardtype = CARDTYPE_ZEITCONTROL;
+ xfree (atr);
+ }
+ }
if (!err)
err = iso7816_select_file (slot, 0x2F02, 0);