- // encrypt out, in, length, key, iv\r
- tdes_2key_enc(rnd_ab, rnd_ab, sizeof(rnd_ab), key, enc_random_b);\r
-\r
- len = mifare_sendcmd_short_mfucauth(NULL, 1, 0xAF, rnd_ab, resp, respPar, NULL);\r
- if (len != 11) {\r
- if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Cmd Error: %02x", resp[0]);\r
- return 0;\r
- }\r
-\r
- uint8_t enc_resp[8] = { 0,0,0,0,0,0,0,0 };\r
- uint8_t resp_random_a[8] = { 0,0,0,0,0,0,0,0 };\r
- memcpy(enc_resp, resp+1, 8);\r
- \r
- // decrypt out, in, length, key, iv \r
- tdes_2key_dec(resp_random_a, enc_resp, 8, key, enc_random_b);\r
- if ( memcmp(resp_random_a, random_a, 8) != 0 ) {\r
- if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("failed authentication");\r
- return 0;\r
- } \r
-\r