as far as I know you can do very little with generic ISO 7816-4 commands.
every card has their own manual (most under NDA) and you need to look
at the card manual for the specific command and how to interpret the
return code.

for example this is the code we use in opensc with cardos driver to
get the serial number from cardos M4 cards:

static int cardos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
{
        int r;
        sc_apdu_t apdu;
        u8  rbuf[SC_MAX_APDU_BUFFER_SIZE];

        sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x81);
        apdu.resp = rbuf;
        apdu.resplen = sizeof(rbuf);
        apdu.le   = 256;
        r = sc_transmit_apdu(card, &apdu);
        SC_TEST_RET(card->ctx, r,  "APDU transmit failed");
        if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
                return SC_ERROR_INTERNAL;
        if (apdu.resplen != 32) {
                sc_debug(card->ctx, "unexpected response to GET DATA serial"
                                " number\n");
                return SC_ERROR_INTERNAL;
        }
        /* cache serial number */
        memcpy(card->serialnr.value, &rbuf[10], 6);
        card->serialnr.len = 6;
        /* copy and return serial number */
        memcpy(serial, &card->serialnr, sizeof(*serial));
        return SC_SUCCESS;
}

opensc supports a number of cards and similar code in each card driver I 
guess.

Regards, Andreas
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle

Reply via email to