mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
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 <gniibe@fsij.org>
This commit is contained in:
parent
af189be481
commit
9f148360a2
@ -53,7 +53,9 @@
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CARDTYPE_GENERIC = 0,
|
CARDTYPE_GENERIC = 0,
|
||||||
CARDTYPE_YUBIKEY
|
CARDTYPE_GNUK,
|
||||||
|
CARDTYPE_YUBIKEY,
|
||||||
|
CARDTYPE_ZEITCONTROL
|
||||||
|
|
||||||
} cardtype_t;
|
} cardtype_t;
|
||||||
|
|
||||||
|
18
scd/app.c
18
scd/app.c
@ -84,7 +84,9 @@ strcardtype (cardtype_t t)
|
|||||||
switch (t)
|
switch (t)
|
||||||
{
|
{
|
||||||
case CARDTYPE_GENERIC: return "generic";
|
case CARDTYPE_GENERIC: return "generic";
|
||||||
|
case CARDTYPE_GNUK: return "gnuk";
|
||||||
case CARDTYPE_YUBIKEY: return "yubikey";
|
case CARDTYPE_YUBIKEY: return "yubikey";
|
||||||
|
case CARDTYPE_ZEITCONTROL: return "zeitcontrol";
|
||||||
}
|
}
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
@ -540,6 +542,22 @@ app_new_register (int slot, ctrl_t ctrl, const char *name,
|
|||||||
xfree (buf);
|
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)
|
if (!err)
|
||||||
err = iso7816_select_file (slot, 0x2F02, 0);
|
err = iso7816_select_file (slot, 0x2F02, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user