- uint16_t len;\r
- uint8_t receivedAnswer[MAX_MIFARE_FRAME_SIZE];\r
- uint8_t receivedAnswerPar[MAX_MIFARE_PARITY_SIZE];\r
- \r
- len = mifare_sendcmd_short_mfucauth(NULL, 1, 0xAF, key, receivedAnswer, receivedAnswerPar, NULL);\r
- if (len == 1) {\r
- if (MF_DBGLEVEL >= MF_DBG_ERROR)\r
- Dbprintf("Cmd Error: %02x", receivedAnswer[0]);\r
- return 1;\r
+ // tag nonce.\r
+ memcpy(enc_random_b,resp+1,8);\r
+\r
+ // decrypt nonce.\r
+ tdes_2key_dec(random_b, enc_random_b, sizeof(random_b), key, IV );\r
+ rol(random_b,8);\r
+ memcpy(rnd_ab ,random_a,8);\r
+ memcpy(rnd_ab+8,random_b,8);\r
+\r
+ if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {\r
+ Dbprintf("enc_B: %02x %02x %02x %02x %02x %02x %02x %02x",\r
+ enc_random_b[0],enc_random_b[1],enc_random_b[2],enc_random_b[3],enc_random_b[4],enc_random_b[5],enc_random_b[6],enc_random_b[7]);\r
+\r
+ Dbprintf(" B: %02x %02x %02x %02x %02x %02x %02x %02x",\r
+ random_b[0],random_b[1],random_b[2],random_b[3],random_b[4],random_b[5],random_b[6],random_b[7]);\r
+\r
+ Dbprintf("rnd_ab: %02x %02x %02x %02x %02x %02x %02x %02x",\r
+ rnd_ab[0],rnd_ab[1],rnd_ab[2],rnd_ab[3],rnd_ab[4],rnd_ab[5],rnd_ab[6],rnd_ab[7]);\r
+\r
+ Dbprintf("rnd_ab: %02x %02x %02x %02x %02x %02x %02x %02x",\r
+ rnd_ab[8],rnd_ab[9],rnd_ab[10],rnd_ab[11],rnd_ab[12],rnd_ab[13],rnd_ab[14],rnd_ab[15] );\r