Skip to content

Commit a4bad44

Browse files

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/libopensc/card-atrust-acos.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,23 @@
2828

2929
/*****************************************************************************/
3030

31+
#define ACOS_EMV_A03 "A-TRUST ACOS"
32+
#define ACOS_EMV_A05 "A-TRUST ACOS A05"
33+
3134
static const char *atrust_acos_atrs[] = {
3235
"3B:BF:11:00:81:31:fe:45:45:50:41",
3336
"3B:BF:11:00:81:31:fe:45:4d:43:41",
37+
"3B:BF:13:00:81:31:fe:45:45:50:41",
38+
"3B:BF:13:00:81:31:fe:45:4d:43:41",
39+
NULL
40+
};
41+
42+
// sequence and number has to match atr table !
43+
static const char *atrust_acos_names[] = {
44+
ACOS_EMV_A03,
45+
ACOS_EMV_A03,
46+
ACOS_EMV_A05,
47+
ACOS_EMV_A05,
3448
NULL
3549
};
3650

@@ -72,7 +86,10 @@ static int atrust_acos_match_card(struct sc_card *card)
7286
continue;
7387
if (memcmp(card->atr, defatr, len) != 0)
7488
continue;
89+
7590
match = 1;
91+
card->name = atrust_acos_names[i];
92+
7693
break;
7794
}
7895
return match;
@@ -89,7 +106,6 @@ static int atrust_acos_init(struct sc_card *card)
89106
if (ex_data == NULL)
90107
return SC_ERROR_OUT_OF_MEMORY;
91108

92-
card->name = "A-TRUST ACOS";
93109
card->cla = 0x00;
94110
card->drv_data = (void *)ex_data;
95111

@@ -102,7 +118,10 @@ static int atrust_acos_init(struct sc_card *card)
102118
| SC_ALGORITHM_RSA_HASH_RIPEMD160
103119
| SC_ALGORITHM_RSA_HASH_MD5_SHA1;
104120

105-
_sc_card_add_rsa_alg(card,1536, flags, 0x10001);
121+
if (!strcmp(card->name, ACOS_EMV_A05))
122+
flags |= SC_ALGORITHM_RSA_HASH_SHA256;
123+
124+
_sc_card_add_rsa_alg(card, 1536, flags, 0x10001);
106125

107126
/* we need read_binary&friends with max 128 bytes per read */
108127
if (card->max_send_size > 128)
@@ -507,7 +526,6 @@ static int atrust_acos_select_file(struct sc_card *card,
507526
SC_FUNC_RETURN(card->ctx, 2, SC_ERROR_INVALID_ARGUMENTS);
508527
}
509528

510-
511529
/** atrust_acos_set_security_env
512530
* sets the security enviroment
513531
* \param card pointer to the sc_card object
@@ -725,6 +743,8 @@ static int atrust_acos_compute_signature(struct sc_card *card,
725743
apdu.le = 256;
726744
r = sc_transmit_apdu(card, &apdu);
727745
SC_TEST_RET(card->ctx, r, "APDU transmit failed");
746+
if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
747+
SC_FUNC_RETURN(card->ctx, 4, sc_check_sw(card, apdu.sw1, apdu.sw2));
728748
{
729749
size_t len = apdu.resplen > outlen ? outlen : apdu.resplen;
730750

src/libopensc/pkcs15-atrust-acos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static int acos_detect_card(sc_pkcs15_card_t *p15card)
9191
sc_card_t *card = p15card->card;
9292

9393
/* check if we have the correct card OS */
94-
if (strcmp(card->name, "A-TRUST ACOS"))
94+
if (strncmp(card->name, "A-TRUST ACOS", strlen("A-TRUST ACOS")))
9595
return SC_ERROR_WRONG_CARD;
9696
/* read EF_CIN_CSN file */
9797
sc_format_path("DF71D001", &path);

0 commit comments

Comments
 (0)