Search code examples
rfidmifareapdusmartcard-readerpcsc

APDU FF 88 00 gives incorrect length


I have some PC/SC code that has encoded thousands of MIFARE cards. I now have a HID OMNIKEY 5127 CK reader and I cannot get it to authenticate. For a standard 1K MIFARE card I load the transport key with:

FF 82 20 00 06 FF FF FF FF FF FF

which succeeds and then to authenticate against the first block:

FF 88 00 00 60 00

and it gives 67 00. Has anyone else seen this?


Solution

  • The AUTHENTICATE command (CLA=FF, INS=88) has been declared obsolete in the PC/SC specification, so it might not be supported by that reader. You could instead try the GENERAL AUTHENTICATE command:

    +-----+-----+----+----+----+---------+---------+----------+------+
    | CLA | INS | P1 | P2 | Lc | Version | Address | Key type | Key# |
    +-----+-----+----+----+----+---------+---------+----------+------+
    | FF  | 86  | 00 | 00 | 05 |   01    |  00 00  |    60    |  00  |
    +-----+-----+----+----+----+---------+---------+----------+------+
    

    The relevant part of the PC/SC specification is "Part3. Requirements for PC-Connected Interface Devices" (get it here).