Topic: MIFARE UltraLight C 3DES authentication APDUs
Hi guys,
I try to perform authentication to a MIFARE UltraLight C card, but I am stuck. I have already made some Google queries, the only thing that I found were an IEEE conference document (that contains test vectors) and the libfreefare sources that I could use.
The libfreefare, as a low-level tool seemed to be very good for first sight, but I found a thing that I do not understand: the sources contain DES_ecb_encrypt() function calls of OpenSSL to encrypt/decrypt data, but the MIFARE UltraLight C public document (MF0ICU2) says, that "ek() is 2 key 3DES encryption [...] in Cipher-Block Chaining (CBC) mode", and not in ECB mode!
The publicly available IEEE study ("Studying the Pseudo Random Number Generator of a low-cost RFID tag" for IEEE conference) that I also found contains some cute test vectors:
1. Auth1_apdu:
FF:00:00:00:04:D4:42:1A:00
2. Auth1_resp:
D5:43:00:AF:63:FC:19:90:6A:77:D1:3F:90:00
3. RndA:
74bd85757bd28b77
4. RndB:
c00c24ed61ea0f3e
5. RndA||RndB':
74bd85757bd28b770c24ed61ea0f3ec0
6. Auth2_apdu:
FF:00:00:00:13:D4:42:AF:89:81:7f:e2:a8:d7:18:08:f7:03:d9:1b:dc:40:01:6f
7. Auth2_apdu:
D5:43:00:00:C6:FE:6C:74:2B:68:CE:E8:90:00
8. E(RndA'):
C6FE6C742B68CEE8
9. RndA':
bd85757bd28b7774
With the demo keys and OpenSSL I could decrypt ek(RndB) - retrieved from Auth1_resp -, converted RndB to RndB', concatenated RndA with RndB', and encrypted the whole data with the same parameters (keys, IV etc.), but I could not get the same value for Auth2_apdu (and also for my value I got an authentication error from the card).
Is there any other step before encrypting that is still have to be performed (e.g. I found an XOR-operation for some cases in libfreefare sources, but this did not even help).
Thanks in advance!
Aron