- added card name to struct sc_card to allow upper level apps to identify
card type more precisely git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1173 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
3791a686af
commit
48a61e95c0
@ -104,6 +104,7 @@ static int default_init(struct sc_card *card)
|
||||
{
|
||||
int r;
|
||||
|
||||
card->name = "Unidentified card";
|
||||
card->drv_data = NULL;
|
||||
r = autodetect_class(card);
|
||||
if (r) {
|
||||
|
@ -89,6 +89,7 @@ int etoken_init(struct sc_card *card)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
card->name = "CardOS M4";
|
||||
card->cla = 0x00;
|
||||
|
||||
/* Set up algorithm info. */
|
||||
|
@ -37,47 +37,65 @@
|
||||
* of the ATR instead */
|
||||
static struct {
|
||||
const char * atr;
|
||||
int id;
|
||||
int type;
|
||||
const char * name;
|
||||
} flex_atrs[] = {
|
||||
/* Cryptoflex */
|
||||
{ "3B:85:40:20:68:01:01:05:01", /* 8k */
|
||||
TYPE_CRYPTOFLEX },
|
||||
TYPE_CRYPTOFLEX,
|
||||
"Cryptoflex 8K" },
|
||||
{ "3B:95:94:40:FF:63:01:01:02:01", /* 16k */
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN },
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN,
|
||||
"Cryptoflex 16K" },
|
||||
{ "3B:95:18:40:FF:64:02:01:01:02", /* 32K v4 */
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN },
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN,
|
||||
"Cryptoflex 32K v4" },
|
||||
{ "3B:95:18:40:FF:62:01:02:01:04", /* 32K e-gate */
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN },
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN,
|
||||
"Cryptoflex 32K e-gate" },
|
||||
{ "3B:95:18:40:FF:62:04:01:01:05", /* 32K e-gate v4 */
|
||||
TYPE_CRYPTOFLEX },
|
||||
TYPE_CRYPTOFLEX,
|
||||
"Cryptoflex 32K e-gate v4" },
|
||||
{ "3B:E2:00:00:40:20:49:06",
|
||||
TYPE_CRYPTOFLEX },
|
||||
TYPE_CRYPTOFLEX,
|
||||
"Cryptoflex" },
|
||||
{ "3B:E2:00:00:40:20:49:05", /* + full DES option */
|
||||
TYPE_CRYPTOFLEX|FLAG_FULL_DES },
|
||||
TYPE_CRYPTOFLEX|FLAG_FULL_DES,
|
||||
"Cryptoflex" },
|
||||
{ "3B:E2:00:00:40:20:49:07", /* + Key Generation */
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN },
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN,
|
||||
"Cryptoflex" },
|
||||
{ "3B:85:40:20:68:01:01:03:05", /* + Key Generation */
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN },
|
||||
TYPE_CRYPTOFLEX|FLAG_KEYGEN,
|
||||
"Cryptoflex" },
|
||||
|
||||
/* Multiflex */
|
||||
{ "3B:02:14:50", /* 3K */
|
||||
TYPE_MULTIFLEX },
|
||||
TYPE_MULTIFLEX,
|
||||
"Multiflex 3K" },
|
||||
{ "3B:19:14:55:90:01:02:01:00:05:04:B0", /* 4K */
|
||||
TYPE_MULTIFLEX },
|
||||
TYPE_MULTIFLEX,
|
||||
"Multiflex 4K" },
|
||||
{ "3B:32:15:00:06:80", /* 8K */
|
||||
TYPE_MULTIFLEX },
|
||||
TYPE_MULTIFLEX,
|
||||
"Multiflex 8K" },
|
||||
{ "3B:32:15:00:06:95", /* 8K + full DES option */
|
||||
TYPE_MULTIFLEX },
|
||||
TYPE_MULTIFLEX,
|
||||
"Multiflex 8K" },
|
||||
{ "3B:19:14:59:01:01:0F:01:00:05:08:B0", /* 8K */
|
||||
TYPE_MULTIFLEX },
|
||||
TYPE_MULTIFLEX,
|
||||
"Multiflex 8K" },
|
||||
{ "3B:19:14:55:90:01:01:01:00:05:08:B0", /* 8K */
|
||||
TYPE_MULTIFLEX },
|
||||
TYPE_MULTIFLEX,
|
||||
"Multiflex 8K" },
|
||||
|
||||
/* Cyberflex Access */
|
||||
{ "3B:16:94:81:10:06:01:81:3F", /* Crypto */
|
||||
TYPE_CYBERFLEX },
|
||||
TYPE_CYBERFLEX,
|
||||
"Cyberflex Access" },
|
||||
{ "3B:16:94:81:10:06:01:81:2F", /* Aug. Crypto */
|
||||
TYPE_CYBERFLEX },
|
||||
TYPE_CYBERFLEX,
|
||||
"Cyberflex Access" },
|
||||
|
||||
{ NULL, TYPE_UNKNOWN }
|
||||
};
|
||||
@ -118,22 +136,28 @@ static int flex_identify_card(struct sc_card *card)
|
||||
break;
|
||||
}
|
||||
|
||||
return flex_atrs[i].id;
|
||||
return i;
|
||||
}
|
||||
|
||||
static int flex_match_card(struct sc_card *card)
|
||||
{
|
||||
return flex_identify_card(card) != TYPE_UNKNOWN;
|
||||
int idx;
|
||||
|
||||
idx = flex_identify_card(card);
|
||||
return flex_atrs[idx].type != TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
static int flex_init(struct sc_card *card)
|
||||
{
|
||||
struct flex_private_data *data;
|
||||
int idx;
|
||||
|
||||
if (!(data = (struct flex_private_data *) malloc(sizeof(struct flex_private_data))))
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
data->card_type = flex_identify_card(card);
|
||||
idx = flex_identify_card(card);
|
||||
data->card_type = flex_atrs[idx].type;
|
||||
|
||||
card->name = flex_atrs[idx].name;
|
||||
card->drv_data = data;
|
||||
card->cla = 0xC0;
|
||||
/* FIXME: Card type detection */
|
||||
|
@ -109,14 +109,15 @@ static struct atrinfo {
|
||||
unsigned char atr[SC_MAX_ATR_SIZE];
|
||||
unsigned int atr_len;
|
||||
int variant;
|
||||
const char * name;
|
||||
} atrlist[] = {
|
||||
{ "\x3B\x27\x00\x80\x65\xA2\x04\x01\x01\x37", 10, GPK4000_s },
|
||||
{ "\x3B\x27\x00\x80\x65\xA2\x05\x01\x01\x37", 10, GPK4000_sp },
|
||||
{ "\x3B\x27\x00\x80\x65\xA2\x0C\x01\x01\x37", 10, GPK4000_su256 },
|
||||
{ "\x3B\xA7\x00\x40\x14\x80\x65\xA2\x14\x01\x01\x37", 12, GPK4000_sdo },
|
||||
{ "\x3B\xA7\x00\x40\x18\x80\x65\xA2\x08\x01\x01\x52", 12, GPK8000_8K },
|
||||
{ "\x3B\xA7\x00\x40\x18\x80\x65\xA2\x09\x01\x01\x52", 12, GPK8000_16K },
|
||||
{ "\x3B\xA7\x00\x40\x18\x80\x65\xA2\x09\x01\x02\x52", 12, GPK16000 },
|
||||
{ "\x3B\x27\x00\x80\x65\xA2\x04\x01\x01\x37", 10, GPK4000_s, "GPK 4K" },
|
||||
{ "\x3B\x27\x00\x80\x65\xA2\x05\x01\x01\x37", 10, GPK4000_sp, "GPK 4K" },
|
||||
{ "\x3B\x27\x00\x80\x65\xA2\x0C\x01\x01\x37", 10, GPK4000_su256, "GPK 4K" },
|
||||
{ "\x3B\xA7\x00\x40\x14\x80\x65\xA2\x14\x01\x01\x37", 12, GPK4000_sdo, "GPK 4K" },
|
||||
{ "\x3B\xA7\x00\x40\x18\x80\x65\xA2\x08\x01\x01\x52", 12, GPK8000_8K, "GPK 8K" },
|
||||
{ "\x3B\xA7\x00\x40\x18\x80\x65\xA2\x09\x01\x01\x52", 12, GPK8000_16K, "GPK 8K" },
|
||||
{ "\x3B\xA7\x00\x40\x18\x80\x65\xA2\x09\x01\x02\x52", 12, GPK16000, "GPK 16K" },
|
||||
|
||||
{ "", 0, -1 }
|
||||
};
|
||||
|
@ -182,6 +182,7 @@ static int mcrd_init(struct sc_card *card)
|
||||
priv = (struct mcrd_priv_data *) calloc (1, sizeof *priv);
|
||||
if (!priv)
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
card->name = "MICARDO";
|
||||
card->drv_data = priv;
|
||||
card->cla = 0x00;
|
||||
|
||||
|
@ -72,6 +72,7 @@ static int miocos_init(struct sc_card *card)
|
||||
priv = (struct miocos_priv_data *) malloc(sizeof(struct miocos_priv_data));
|
||||
if (priv == NULL)
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
card->name = "MioCOS";
|
||||
card->drv_data = priv;
|
||||
card->cla = 0x00;
|
||||
if (1) {
|
||||
|
@ -82,6 +82,7 @@ static int setcos_init(struct sc_card *card)
|
||||
priv = (struct setcos_priv_data *) malloc(sizeof(struct setcos_priv_data));
|
||||
if (priv == NULL)
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
card->name = "SetCOS";
|
||||
card->drv_data = priv;
|
||||
card->cla = 0x80;
|
||||
priv->type = id;
|
||||
|
@ -209,6 +209,7 @@ static int starcos_init(struct sc_card *card)
|
||||
return SC_ERROR_OUT_OF_MEMORY;
|
||||
state->sec_ops = 0;
|
||||
|
||||
card->name = "StarCOS";
|
||||
card->drv_data = state;
|
||||
card->cla = 0x00;
|
||||
|
||||
|
@ -77,6 +77,7 @@ static int tcos_init(struct sc_card *card)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
card->name = "TCOS";
|
||||
card->drv_data = NULL;
|
||||
card->cla = 0x00;
|
||||
|
||||
|
@ -400,6 +400,8 @@ int sc_connect_card(struct sc_reader *reader, int slot_id,
|
||||
r = SC_ERROR_INVALID_CARD;
|
||||
goto err;
|
||||
}
|
||||
if (card->name == NULL)
|
||||
card->name = card->driver->name;
|
||||
*card_out = card;
|
||||
|
||||
SC_FUNC_RETURN(ctx, 1, 0);
|
||||
|
@ -439,6 +439,7 @@ struct sc_card {
|
||||
|
||||
struct sc_card_driver *driver;
|
||||
struct sc_card_operations *ops;
|
||||
const char *name;
|
||||
void *drv_data;
|
||||
int max_pin_len;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user