- }
-
- start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
-
- //Read block 1, config
- if (flags & FLAG_ICLASS_READER_CONF) {
- if (sendCmdGetResponseWithRetries(readConf, sizeof(readConf), resp, sizeof(resp), 10, 10, start_time, ICLASS_READER_TIMEOUT_OTHERS, &eof_time)) {
- result_status |= FLAG_ICLASS_READER_CONF;
- memcpy(card_data+8, resp, 8);
- } else {
- Dbprintf("Failed to read config block");
- }
- start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
- }
-
- //Read block 2, e-purse
- if (flags & FLAG_ICLASS_READER_CC) {
- if (sendCmdGetResponseWithRetries(readEpurse, sizeof(readEpurse), resp, sizeof(resp), 10, 10, start_time, ICLASS_READER_TIMEOUT_OTHERS, &eof_time)) {
- result_status |= FLAG_ICLASS_READER_CC;
- memcpy(card_data + (8*2), resp, 8);
- } else {
- Dbprintf("Failed to read e-purse");
- }
- start_time = eof_time + DELAY_ICLASS_VICC_TO_VCD_READER;
- }
-
- //Read block 5, AA
- if (flags & FLAG_ICLASS_READER_AA) {
- if (sendCmdGetResponseWithRetries(readAA, sizeof(readAA), resp, sizeof(resp), 10, 10, start_time, ICLASS_READER_TIMEOUT_OTHERS, &eof_time)) {
- result_status |= FLAG_ICLASS_READER_AA;
- memcpy(card_data + (8*5), resp, 8);
- } else {
- Dbprintf("Failed to read AA block");
- }
- }
-
- cmd_send(CMD_ACK, result_status, 0, 0, card_data, sizeof(card_data));
-
- LED_A_OFF();
-}
-
-
-void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
-
- LED_A_ON();
-
- bool use_credit_key = false;
- uint8_t card_data[USB_CMD_DATA_SIZE]={0};
- uint16_t block_crc_LUT[255] = {0};
-
- //Generate a lookup table for block crc
- for (int block = 0; block < 255; block++){
- char bl = block;
- block_crc_LUT[block] = iclass_crc16(&bl ,1);
- }
- //Dbprintf("Lookup table: %02x %02x %02x" ,block_crc_LUT[0],block_crc_LUT[1],block_crc_LUT[2]);
-
- uint8_t readcheck_cc[] = { ICLASS_CMD_READCHECK_KD, 0x02 };
- if (use_credit_key)
- readcheck_cc[0] = ICLASS_CMD_READCHECK_KC;
- uint8_t check[] = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- uint8_t read[] = { 0x0c, 0x00, 0x00, 0x00 };
-
- uint16_t crc = 0;
- uint8_t cardsize = 0;
- uint8_t mem = 0;
-
- static struct memory_t {
- int k16;
- int book;
- int k2;
- int lockauth;
- int keyaccess;
- } memory;
-
- uint8_t resp[ICLASS_BUFFER_SIZE];
-
- set_tracing(true);
- clear_trace();
- Iso15693InitReader();
-
- StartCountSspClk();
- uint32_t start_time = 0;
- uint32_t eof_time = 0;
-
- while (!BUTTON_PRESS()) {
-
- WDT_HIT();
-
- if (!get_tracing()) {
- DbpString("Trace full");
- break;
- }
-
- if (!selectIclassTag(card_data, &eof_time)) continue;