Support for CardOS 4.4

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4264 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
jps 2010-04-21 14:38:23 +00:00
parent ba04831e34
commit aa4d951101
4 changed files with 15 additions and 5 deletions

View File

@ -52,6 +52,8 @@ static struct sc_atr_table cardos_atrs[] = {
{ "3b:f4:98:00:ff:c1:10:31:fe:55:4d:34:63:76:b4", NULL, NULL, SC_CARD_TYPE_CARDOS_GENERIC, 0, NULL},
/* cardos m4.2 and above */
{ "3b:f2:18:00:ff:c1:0a:31:fe:55:c8:06:8a", "ff:ff:0f:ff:00:ff:00:ff:ff:00:00:00:00", NULL, SC_CARD_TYPE_CARDOS_M4_2, 0, NULL },
/* CardOS 4.4 */
{ "3b:d2:18:02:c1:0a:31:fe:58:c8:0d:51", NULL, NULL, SC_CARD_TYPE_CARDOS_M4_4, 0, NULL},
{ NULL, NULL, NULL, 0, 0, NULL }
};
@ -65,6 +67,8 @@ static int cardos_match_card(sc_card_t *card)
/* Do not change card type for CIE! */
if (card->type == SC_CARD_TYPE_CARDOS_CIE_V1)
return 1;
if (card->type == SC_CARD_TYPE_CARDOS_M4_4)
return 1;
if (card->type == SC_CARD_TYPE_CARDOS_M4_2) {
int rv;
sc_apdu_t apdu;
@ -171,7 +175,8 @@ static int cardos_init(sc_card_t *card)
card->caps |= SC_CARD_CAP_APDU_EXT;
} else if (card->type == SC_CARD_TYPE_CARDOS_M4_3
|| card->type == SC_CARD_TYPE_CARDOS_M4_2B
|| card->type == SC_CARD_TYPE_CARDOS_M4_2C) {
|| card->type == SC_CARD_TYPE_CARDOS_M4_2C
|| card->type == SC_CARD_TYPE_CARDOS_M4_4) {
card->caps |= SC_CARD_CAP_RSA_2048;
card->caps |= SC_CARD_CAP_APDU_EXT;
}
@ -650,7 +655,8 @@ static int cardos_create_file(sc_card_t *card, sc_file_t *file)
} else if (card->type == SC_CARD_TYPE_CARDOS_M4_2 ||
card->type == SC_CARD_TYPE_CARDOS_M4_3 ||
card->type == SC_CARD_TYPE_CARDOS_M4_2B ||
card->type == SC_CARD_TYPE_CARDOS_M4_2C) {
card->type == SC_CARD_TYPE_CARDOS_M4_2C ||
card->type == SC_CARD_TYPE_CARDOS_M4_4) {
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
size_t len = sizeof(sbuf);
sc_apdu_t apdu;

View File

@ -45,6 +45,7 @@ enum {
SC_CARD_TYPE_CARDOS_M4_2B, /* 4.2b is after 4.3b */
SC_CARD_TYPE_CARDOS_M4_2C,
SC_CARD_TYPE_CARDOS_CIE_V1, /* Italian CIE (eID) v1 */
SC_CARD_TYPE_CARDOS_M4_4,
/* flex/cyberflex drivers */
SC_CARD_TYPE_FLEX_BASE = 2000,

View File

@ -648,7 +648,7 @@ cardos_put_key(sc_profile_t *profile, struct sc_pkcs15_card *p15card,
key_id = key_info->key_reference;
if (key_info->modulus_length > 1024 && (card->type == SC_CARD_TYPE_CARDOS_M4_2 ||
card->type == SC_CARD_TYPE_CARDOS_M4_3 ||card->type == SC_CARD_TYPE_CARDOS_M4_2B ||
card->type == SC_CARD_TYPE_CARDOS_M4_2C )) {
card->type == SC_CARD_TYPE_CARDOS_M4_2C ||card->type == SC_CARD_TYPE_CARDOS_M4_4)) {
r = cardos_store_key_component(card, algorithm, key_id, pin_id, 0,
key->p.data, key->p.len, 0, 0);
if (r != SC_SUCCESS)

View File

@ -170,6 +170,8 @@ static int cardos_info(void)
printf(" (that's CardOS M4.2B)\n");
} else if (apdu.resp[0] == 0xc8 && apdu.resp[1] == 0x0B) {
printf(" (that's CardOS M4.2C)\n");
} else if (apdu.resp[0] == 0xc8 && apdu.resp[1] == 0x0D) {
printf(" (that's CardOS M4.4)\n");
} else {
printf(" (unknown Version)\n");
}
@ -555,8 +557,9 @@ static int cardos_format(const char *opt_startkey)
}
if ((rbuf[0] != 0xc8 || rbuf[1] != 0x09) && /* M4.2B */
(rbuf[0] != 0xc8 || rbuf[1] != 0x08) && /* M4.3B */
(rbuf[0] != 0xc8 || rbuf[1] != 0x0B)) { /* M4.2C */
printf("currently only CardOS M4.2B, M4.2C and M4.3B are supported, aborting\n");
(rbuf[0] != 0xc8 || rbuf[1] != 0x0B) && /* M4.2C */
(rbuf[0] != 0xc8 || rbuf[1] != 0x0D)) { /* M4.4 */
printf("currently only CardOS M4.2B, M4.2C, M4.3B and M4.4 are supported, aborting\n");
return 1;
}