mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
desfire readdata fct, now deals with both INS cases
This commit is contained in:
parent
436fedcbe4
commit
b9bf84dbf1
1 changed files with 10 additions and 6 deletions
|
@ -1903,16 +1903,18 @@ static int handler_desfire_debit(mfdes_value_t *value, uint8_t cs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handler_desfire_readdata(mfdes_data_t *data, MFDES_FILE_TYPE_T type, uint8_t cs) {
|
static int handler_desfire_readdata(mfdes_data_t *data, MFDES_FILE_TYPE_T type, uint8_t cs) {
|
||||||
if (data->fileno > 0x1F) return PM3_EINVARG;
|
if (data->fileno > 0x1F) {
|
||||||
sAPDU apdu = {0x90, MFDES_READ_DATA, 0x00, 0x00, 1 + 3 + 3, (uint8_t *)data}; // 0xBD
|
return PM3_EINVARG;
|
||||||
if (type == MFDES_RECORD_FILE) apdu.INS = MFDES_READ_RECORDS; //0xBB
|
}
|
||||||
|
|
||||||
uint16_t sw = 0;
|
sAPDU apdu = {0x90, MFDES_READ_DATA, 0x00, 0x00, 1 + 3 + 3, (uint8_t *)data}; // 0xBD
|
||||||
uint32_t resplen = 0;
|
if (type == MFDES_RECORD_FILE) {
|
||||||
|
apdu.INS = MFDES_READ_RECORDS; //0xBB
|
||||||
|
}
|
||||||
|
|
||||||
// we need the CMD 0xBD <data> to calc the CMAC
|
// we need the CMD 0xBD <data> to calc the CMAC
|
||||||
uint8_t tmp_data[8]; // Since the APDU is hardcoded to 7 bytes of payload 7+1 = 8 is enough.
|
uint8_t tmp_data[8]; // Since the APDU is hardcoded to 7 bytes of payload 7+1 = 8 is enough.
|
||||||
tmp_data[0] = 0xBD;
|
tmp_data[0] = apdu.INS;
|
||||||
memcpy(&tmp_data[1], data, 7);
|
memcpy(&tmp_data[1], data, 7);
|
||||||
|
|
||||||
// size_t plen = apdu.Lc;
|
// size_t plen = apdu.Lc;
|
||||||
|
@ -1926,6 +1928,8 @@ static int handler_desfire_readdata(mfdes_data_t *data, MFDES_FILE_TYPE_T type,
|
||||||
apdu.Lc = 7;
|
apdu.Lc = 7;
|
||||||
apdu.data = (uint8_t *)data;
|
apdu.data = (uint8_t *)data;
|
||||||
|
|
||||||
|
uint16_t sw = 0;
|
||||||
|
uint32_t resplen = 0;
|
||||||
int res = send_desfire_cmd(&apdu, false, data->data, &resplen, &sw, 0, true);
|
int res = send_desfire_cmd(&apdu, false, data->data, &resplen, &sw, 0, true);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(WARNING, _RED_(" Can't read data -> %s"), GetErrorString(res, &sw));
|
PrintAndLogEx(WARNING, _RED_(" Can't read data -> %s"), GetErrorString(res, &sw));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue