cardos5: fix reading of serial number
The corresponding GET DATA command only returns the serial, nothing else. Tested with CardOS 5.0 and 5.3 cards. The serial number is the same as shown with other tools
This commit is contained in:
parent
25bc8fc167
commit
b9810e62d6
|
@ -1190,14 +1190,19 @@ static int cardos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
|
||||||
LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
|
LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
|
||||||
if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
|
if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
|
||||||
return SC_ERROR_INTERNAL;
|
return SC_ERROR_INTERNAL;
|
||||||
if (apdu.resplen != 32) {
|
if ((apdu.resplen == 8) && (card->type == SC_CARD_TYPE_CARDOS_V5_0)) {
|
||||||
|
/* cache serial number */
|
||||||
|
memcpy(card->serialnr.value, rbuf, 8);
|
||||||
|
card->serialnr.len = 8;
|
||||||
|
} else if (apdu.resplen == 32) {
|
||||||
|
/* cache serial number */
|
||||||
|
memcpy(card->serialnr.value, &rbuf[10], 6);
|
||||||
|
card->serialnr.len = 6;
|
||||||
|
} else {
|
||||||
sc_log(card->ctx, "unexpected response to GET DATA serial"
|
sc_log(card->ctx, "unexpected response to GET DATA serial"
|
||||||
" number\n");
|
" number\n");
|
||||||
return SC_ERROR_INTERNAL;
|
return SC_ERROR_INTERNAL;
|
||||||
}
|
}
|
||||||
/* cache serial number */
|
|
||||||
memcpy(card->serialnr.value, &rbuf[10], 6);
|
|
||||||
card->serialnr.len = 6;
|
|
||||||
/* copy and return serial number */
|
/* copy and return serial number */
|
||||||
memcpy(serial, &card->serialnr, sizeof(*serial));
|
memcpy(serial, &card->serialnr, sizeof(*serial));
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue