mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-10 07:22:39 -07:00
upgrading 'hf mfu' (#830)
* chg: write new dump file format by @mceloff * chg: rename 'hf mfu dump' option 'n' to 'f' to align with other commands and RRG repo * chg: replace ISO14443A_CMD_READBLOCK by MIFARE_CMD_READBLOCK, same for WRITEBLOCK * fix: mifare_ultra_readblock() returned 14 bytes instead of 16 * chg: param_gethex_ex() now checks maximum output buffer length * chg: ul_comp_write() was incomplete and for magic testing only * fix: 16bit ULC counter had been displayed as 32bit * chg: add check for 7 Byte UID, drop check for ATQA in type identification GetHF14AMfU_Type() * fix: send HALT instead of dropping field in order to maintain a defined state * chg: DropField() when command ends * chg: check for invalid page ranges in 'hf mfu dump' * fix: print correct lock bits when page range is used * fix: do not write (incomplete) dumpfile when page range is used * add: use UID for filename when no filename is given (RRG repo) * chg: don't clear trace on each ULC authentication, clear trace at beginning of each command * fix: don't send (DESFire?) deselect command after authentication
This commit is contained in:
parent
d38bb3acc3
commit
b8dd1ef649
11 changed files with 729 additions and 772 deletions
|
@ -142,8 +142,6 @@ void MifareDES_Auth1(uint8_t arg0,uint8_t arg1,uint8_t arg2, uint8_t *datain);
|
||||||
void ReaderMifareDES(uint32_t param, uint32_t param2, uint8_t * datain);
|
void ReaderMifareDES(uint32_t param, uint32_t param2, uint8_t * datain);
|
||||||
int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout);
|
int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout);
|
||||||
size_t CreateAPDU( uint8_t *datain, size_t len, uint8_t *dataout);
|
size_t CreateAPDU( uint8_t *datain, size_t len, uint8_t *dataout);
|
||||||
void OnSuccess();
|
|
||||||
void OnError(uint8_t reason);
|
|
||||||
|
|
||||||
|
|
||||||
/// iclass.h
|
/// iclass.h
|
||||||
|
|
|
@ -1963,7 +1963,10 @@ void iClass_Dump(uint8_t blockno, uint8_t numblks) {
|
||||||
uint8_t *dataout = BigBuf_malloc(255*8);
|
uint8_t *dataout = BigBuf_malloc(255*8);
|
||||||
if (dataout == NULL){
|
if (dataout == NULL){
|
||||||
Dbprintf("out of memory");
|
Dbprintf("out of memory");
|
||||||
OnError(1);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
LED_D_OFF();
|
||||||
|
cmd_send(CMD_ACK,0,1,0,0,0);
|
||||||
|
LED_A_OFF();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(dataout,0xFF,255*8);
|
memset(dataout,0xFF,255*8);
|
||||||
|
|
|
@ -23,24 +23,42 @@
|
||||||
#define HARDNESTED_AUTHENTICATION_TIMEOUT 848 // card times out 1ms after wrong authentication (according to NXP documentation)
|
#define HARDNESTED_AUTHENTICATION_TIMEOUT 848 // card times out 1ms after wrong authentication (according to NXP documentation)
|
||||||
#define HARDNESTED_PRE_AUTHENTICATION_LEADTIME 400 // some (non standard) cards need a pause after select before they are ready for first authentication
|
#define HARDNESTED_PRE_AUTHENTICATION_LEADTIME 400 // some (non standard) cards need a pause after select before they are ready for first authentication
|
||||||
|
|
||||||
|
/*
|
||||||
// the block number for the ISO14443-4 PCB
|
// the block number for the ISO14443-4 PCB
|
||||||
static uint8_t pcb_blocknum = 0;
|
static uint8_t pcb_blocknum = 0;
|
||||||
// Deselect card by sending a s-block. the crc is precalced for speed
|
// Deselect card by sending a s-block. the crc is precalced for speed
|
||||||
static uint8_t deselect_cmd[] = {0xc2,0xe0,0xb4};
|
static uint8_t deselect_cmd[] = {0xc2,0xe0,0xb4};
|
||||||
|
|
||||||
|
static void OnSuccess(){
|
||||||
|
pcb_blocknum = 0;
|
||||||
|
ReaderTransmit(deselect_cmd, 3 , NULL);
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
LEDsoff();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void OnError(uint8_t reason){
|
||||||
|
// pcb_blocknum = 0;
|
||||||
|
// ReaderTransmit(deselect_cmd, 3 , NULL);
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
LED_D_OFF();
|
||||||
|
cmd_send(CMD_ACK,0,reason,0,0,0);
|
||||||
|
LED_A_OFF();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Select, Authenticate, Read a MIFARE tag.
|
// Select, Authenticate, Read a MIFARE tag.
|
||||||
// read block
|
// read block
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||||
{
|
{
|
||||||
// params
|
LED_A_ON();
|
||||||
|
|
||||||
uint8_t blockNo = arg0;
|
uint8_t blockNo = arg0;
|
||||||
uint8_t keyType = arg1;
|
uint8_t keyType = arg1;
|
||||||
uint64_t ui64Key = 0;
|
uint64_t ui64Key = 0;
|
||||||
ui64Key = bytes_to_num(datain, 6);
|
ui64Key = bytes_to_num(datain, 6);
|
||||||
|
|
||||||
// variables
|
|
||||||
byte_t isOK = 0;
|
byte_t isOK = 0;
|
||||||
byte_t dataoutbuf[16];
|
byte_t dataoutbuf[16];
|
||||||
uint8_t uid[10];
|
uint8_t uid[10];
|
||||||
|
@ -53,10 +71,6 @@ void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||||
|
|
||||||
clear_trace();
|
clear_trace();
|
||||||
|
|
||||||
LED_A_ON();
|
|
||||||
LED_B_OFF();
|
|
||||||
LED_C_OFF();
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if(!iso14443a_select_card(uid, NULL, &cuid, true, 0, true)) {
|
if(!iso14443a_select_card(uid, NULL, &cuid, true, 0, true)) {
|
||||||
if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
|
if (MF_DBGLEVEL >= 1) Dbprintf("Can't select card");
|
||||||
|
@ -97,14 +111,11 @@ void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||||
|
|
||||||
void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes){
|
void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes){
|
||||||
|
|
||||||
|
LED_A_ON();
|
||||||
bool turnOffField = (arg0 == 1);
|
bool turnOffField = (arg0 == 1);
|
||||||
|
|
||||||
LED_A_ON(); LED_B_OFF(); LED_C_OFF();
|
|
||||||
|
|
||||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||||
|
|
||||||
clear_trace();
|
|
||||||
|
|
||||||
if (!iso14443a_select_card(NULL, NULL, NULL, true, 0, true)) {
|
if (!iso14443a_select_card(NULL, NULL, NULL, true, 0, true)) {
|
||||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card");
|
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card");
|
||||||
OnError(0);
|
OnError(0);
|
||||||
|
@ -119,9 +130,11 @@ void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes){
|
||||||
|
|
||||||
if (turnOffField) {
|
if (turnOffField) {
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LEDsoff();
|
LED_D_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_send(CMD_ACK,1,0,0,0,0);
|
cmd_send(CMD_ACK,1,0,0,0,0);
|
||||||
|
LED_A_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arg0 = BlockNo,
|
// Arg0 = BlockNo,
|
||||||
|
@ -129,17 +142,15 @@ void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes){
|
||||||
// datain = PWD bytes,
|
// datain = PWD bytes,
|
||||||
void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain)
|
void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain)
|
||||||
{
|
{
|
||||||
|
LED_A_ON();
|
||||||
|
|
||||||
uint8_t blockNo = arg0;
|
uint8_t blockNo = arg0;
|
||||||
byte_t dataout[16] = {0x00};
|
byte_t dataout[16] = {0x00};
|
||||||
bool useKey = (arg1 == 1); //UL_C
|
bool useKey = (arg1 == 1); //UL_C
|
||||||
bool usePwd = (arg1 == 2); //UL_EV1/NTAG
|
bool usePwd = (arg1 == 2); //UL_EV1/NTAG
|
||||||
|
|
||||||
LEDsoff();
|
|
||||||
LED_A_ON();
|
|
||||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||||
|
|
||||||
clear_trace();
|
|
||||||
|
|
||||||
int len = iso14443a_select_card(NULL, NULL, NULL, true, 0, true);
|
int len = iso14443a_select_card(NULL, NULL, NULL, true, 0, true);
|
||||||
if(!len) {
|
if(!len) {
|
||||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card (RC:%02X)",len);
|
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Can't select card (RC:%02X)",len);
|
||||||
|
@ -183,7 +194,8 @@ void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain)
|
||||||
|
|
||||||
cmd_send(CMD_ACK,1,0,0,dataout,16);
|
cmd_send(CMD_ACK,1,0,0,dataout,16);
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LEDsoff();
|
LED_D_OFF();
|
||||||
|
LED_A_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -259,13 +271,11 @@ void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain)
|
||||||
// datain = KEY bytes
|
// datain = KEY bytes
|
||||||
void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
|
void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
|
||||||
{
|
{
|
||||||
LEDsoff();
|
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||||
|
|
||||||
// free eventually allocated BigBuf memory
|
// free eventually allocated BigBuf memory
|
||||||
BigBuf_free();
|
BigBuf_free();
|
||||||
clear_trace();
|
|
||||||
|
|
||||||
// params
|
// params
|
||||||
uint8_t blockNo = arg0;
|
uint8_t blockNo = arg0;
|
||||||
|
@ -340,14 +350,14 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("Blocks read %d", countblocks);
|
if (MF_DBGLEVEL >= MF_DBG_DEBUG) Dbprintf("Blocks read %d", countblocks);
|
||||||
|
|
||||||
countblocks *= 4;
|
cmd_send(CMD_ACK, 1, countblocks*4, BigBuf_max_traceLen(), 0, 0);
|
||||||
|
|
||||||
cmd_send(CMD_ACK, 1, countblocks, BigBuf_max_traceLen(), 0, 0);
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LEDsoff();
|
LED_D_OFF();
|
||||||
BigBuf_free();
|
BigBuf_free();
|
||||||
|
LED_A_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1598,17 +1608,3 @@ void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain){
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnSuccess(){
|
|
||||||
pcb_blocknum = 0;
|
|
||||||
ReaderTransmit(deselect_cmd, 3 , NULL);
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
|
||||||
LEDsoff();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnError(uint8_t reason){
|
|
||||||
pcb_blocknum = 0;
|
|
||||||
ReaderTransmit(deselect_cmd, 3 , NULL);
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
|
||||||
cmd_send(CMD_ACK,0,reason,0,0,0);
|
|
||||||
LEDsoff();
|
|
||||||
}
|
|
||||||
|
|
|
@ -542,8 +542,8 @@ void MifareSim(uint8_t flags, uint8_t exitAfterNReads, uint8_t cardsize, uint8_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(receivedCmd_dec[0] == ISO14443A_CMD_READBLOCK
|
if(receivedCmd_dec[0] == MIFARE_CMD_READBLOCK
|
||||||
|| receivedCmd_dec[0] == ISO14443A_CMD_WRITEBLOCK
|
|| receivedCmd_dec[0] == MIFARE_CMD_WRITEBLOCK
|
||||||
|| receivedCmd_dec[0] == MIFARE_CMD_INC
|
|| receivedCmd_dec[0] == MIFARE_CMD_INC
|
||||||
|| receivedCmd_dec[0] == MIFARE_CMD_DEC
|
|| receivedCmd_dec[0] == MIFARE_CMD_DEC
|
||||||
|| receivedCmd_dec[0] == MIFARE_CMD_RESTORE
|
|| receivedCmd_dec[0] == MIFARE_CMD_RESTORE
|
||||||
|
@ -562,7 +562,7 @@ void MifareSim(uint8_t flags, uint8_t exitAfterNReads, uint8_t cardsize, uint8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receivedCmd_dec[0] == ISO14443A_CMD_READBLOCK) {
|
if (receivedCmd_dec[0] == MIFARE_CMD_READBLOCK) {
|
||||||
uint8_t blockNo = receivedCmd_dec[1];
|
uint8_t blockNo = receivedCmd_dec[1];
|
||||||
emlGetMem(response, blockNo, 1);
|
emlGetMem(response, blockNo, 1);
|
||||||
if (IsSectorTrailer(blockNo)) {
|
if (IsSectorTrailer(blockNo)) {
|
||||||
|
@ -593,7 +593,7 @@ void MifareSim(uint8_t flags, uint8_t exitAfterNReads, uint8_t cardsize, uint8_t
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receivedCmd_dec[0] == ISO14443A_CMD_WRITEBLOCK) {
|
if (receivedCmd_dec[0] == MIFARE_CMD_WRITEBLOCK) {
|
||||||
uint8_t blockNo = receivedCmd_dec[1];
|
uint8_t blockNo = receivedCmd_dec[1];
|
||||||
EmSend4bit(mf_crypto1_encrypt4bit(pcs, CARD_ACK));
|
EmSend4bit(mf_crypto1_encrypt4bit(pcs, CARD_ACK));
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
|
@ -451,7 +451,7 @@ int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(blockData, receivedAnswer, 14);
|
memcpy(blockData, receivedAnswer, 16);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,6 @@
|
||||||
#define AUTH_FIRST 0
|
#define AUTH_FIRST 0
|
||||||
#define AUTH_NESTED 2
|
#define AUTH_NESTED 2
|
||||||
|
|
||||||
// mifare 4bit card answers
|
|
||||||
#define CARD_ACK 0x0A // 1010 - ACK
|
|
||||||
#define CARD_NACK_NA 0x04 // 0100 - NACK, not allowed (command not allowed)
|
|
||||||
#define CARD_NACK_TR 0x05 // 0101 - NACK, transmission error
|
|
||||||
|
|
||||||
// reader voltage field detector
|
// reader voltage field detector
|
||||||
#define MF_MINFIELDV 4000
|
#define MF_MINFIELDV 4000
|
||||||
|
|
||||||
|
|
|
@ -415,8 +415,8 @@ void annotateIso14443a(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
|
||||||
case ISO14443A_CMD_REQA:
|
case ISO14443A_CMD_REQA:
|
||||||
snprintf(exp,size,"REQA");
|
snprintf(exp,size,"REQA");
|
||||||
break;
|
break;
|
||||||
case ISO14443A_CMD_READBLOCK: snprintf(exp,size,"READBLOCK(%d)",cmd[1]); break;
|
case MIFARE_CMD_READBLOCK: snprintf(exp,size,"READBLOCK(%d)",cmd[1]); break;
|
||||||
case ISO14443A_CMD_WRITEBLOCK: snprintf(exp,size,"WRITEBLOCK(%d)",cmd[1]); break;
|
case MIFARE_CMD_WRITEBLOCK: snprintf(exp,size,"WRITEBLOCK(%d)",cmd[1]); break;
|
||||||
case ISO14443A_CMD_HALT:
|
case ISO14443A_CMD_HALT:
|
||||||
snprintf(exp,size,"HALT");
|
snprintf(exp,size,"HALT");
|
||||||
MifareAuthState = masNone;
|
MifareAuthState = masNone;
|
||||||
|
|
|
@ -1516,7 +1516,10 @@ int CmdHF14AMfSim(const char *Cmd) {
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
case 'U':
|
case 'U':
|
||||||
param_gethex_ex(Cmd, cmdp+1, uid, &uidlen);
|
uidlen = 14;
|
||||||
|
if (param_gethex_ex(Cmd, cmdp+1, uid, &uidlen)) {
|
||||||
|
return usage_hf14_mfsim();
|
||||||
|
}
|
||||||
switch (uidlen) {
|
switch (uidlen) {
|
||||||
case 14: flags = FLAG_7B_UID_IN_DATA; break;
|
case 14: flags = FLAG_7B_UID_IN_DATA; break;
|
||||||
case 8: flags = FLAG_4B_UID_IN_DATA; break;
|
case 8: flags = FLAG_4B_UID_IN_DATA; break;
|
||||||
|
@ -2726,7 +2729,7 @@ int CmdHF14AMfSniff(const char *Cmd){
|
||||||
//needs nt, ar, at, Data to decrypt
|
//needs nt, ar, at, Data to decrypt
|
||||||
int CmdDecryptTraceCmds(const char *Cmd){
|
int CmdDecryptTraceCmds(const char *Cmd){
|
||||||
uint8_t data[50];
|
uint8_t data[50];
|
||||||
int len = 0;
|
int len = 100;
|
||||||
param_gethex_ex(Cmd, 3, data, &len);
|
param_gethex_ex(Cmd, 3, data, &len);
|
||||||
return tryDecryptWord(param_get32ex(Cmd, 0, 0, 16), param_get32ex(Cmd, 1, 0, 16), param_get32ex(Cmd, 2, 0, 16), data, len/2);
|
return tryDecryptWord(param_get32ex(Cmd, 0, 0, 16), param_get32ex(Cmd, 1, 0, 16), param_get32ex(Cmd, 2, 0, 16), data, len/2);
|
||||||
}
|
}
|
||||||
|
|
1110
client/cmdhfmfu.c
1110
client/cmdhfmfu.c
File diff suppressed because it is too large
Load diff
|
@ -119,7 +119,6 @@ void AddLogCurrentDT(char *fileName) {
|
||||||
|
|
||||||
void FillFileNameByUID(char *fileName, uint8_t *uid, char *ext, int byteCount) {
|
void FillFileNameByUID(char *fileName, uint8_t *uid, char *ext, int byteCount) {
|
||||||
char * fnameptr = fileName;
|
char * fnameptr = fileName;
|
||||||
memset(fileName, 0x00, 200);
|
|
||||||
|
|
||||||
for (int j = 0; j < byteCount; j++, fnameptr += 2)
|
for (int j = 0; j < byteCount; j++, fnameptr += 2)
|
||||||
sprintf(fnameptr, "%02x", (unsigned int) uid[j]);
|
sprintf(fnameptr, "%02x", (unsigned int) uid[j]);
|
||||||
|
@ -323,13 +322,12 @@ uint32_t SwapBits(uint32_t value, int nrbits) {
|
||||||
uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize){
|
uint8_t *SwapEndian64(const uint8_t *src, const size_t len, const uint8_t blockSize){
|
||||||
static uint8_t buf[64];
|
static uint8_t buf[64];
|
||||||
memset(buf, 0x00, 64);
|
memset(buf, 0x00, 64);
|
||||||
uint8_t *tmp = buf;
|
|
||||||
for (uint8_t block=0; block < (uint8_t)(len/blockSize); block++){
|
for (uint8_t block=0; block < (uint8_t)(len/blockSize); block++){
|
||||||
for (size_t i = 0; i < blockSize; i++){
|
for (size_t i = 0; i < blockSize; i++){
|
||||||
tmp[i+(blockSize*block)] = src[(blockSize-1-i)+(blockSize*block)];
|
buf[i+(blockSize*block)] = src[(blockSize-1-i)+(blockSize*block)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tmp;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
//assumes little endian
|
//assumes little endian
|
||||||
|
@ -519,6 +517,7 @@ int param_gethex(const char *line, int paramnum, uint8_t * data, int hexcnt)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int param_gethex_ex(const char *line, int paramnum, uint8_t *data, int *hexcnt)
|
int param_gethex_ex(const char *line, int paramnum, uint8_t *data, int *hexcnt)
|
||||||
{
|
{
|
||||||
int bg, en, temp, i;
|
int bg, en, temp, i;
|
||||||
|
@ -528,6 +527,8 @@ int param_gethex_ex(const char *line, int paramnum, uint8_t * data, int *hexcnt)
|
||||||
|
|
||||||
if (param_getptr(line, &bg, &en, paramnum)) return 1;
|
if (param_getptr(line, &bg, &en, paramnum)) return 1;
|
||||||
|
|
||||||
|
if (en - bg + 1 > *hexcnt) return 1;
|
||||||
|
|
||||||
*hexcnt = en - bg + 1;
|
*hexcnt = en - bg + 1;
|
||||||
if (*hexcnt % 2) //error if not complete hex bytes
|
if (*hexcnt % 2) //error if not complete hex bytes
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -105,15 +105,15 @@ NXP/Philips CUSTOM COMMANDS
|
||||||
|
|
||||||
|
|
||||||
#define ISO14443A_CMD_REQA 0x26
|
#define ISO14443A_CMD_REQA 0x26
|
||||||
#define ISO14443A_CMD_READBLOCK 0x30
|
|
||||||
#define ISO14443A_CMD_WUPA 0x52
|
#define ISO14443A_CMD_WUPA 0x52
|
||||||
#define ISO14443A_CMD_ANTICOLL_OR_SELECT 0x93
|
#define ISO14443A_CMD_ANTICOLL_OR_SELECT 0x93
|
||||||
#define ISO14443A_CMD_ANTICOLL_OR_SELECT_2 0x95
|
#define ISO14443A_CMD_ANTICOLL_OR_SELECT_2 0x95
|
||||||
#define ISO14443A_CMD_ANTICOLL_OR_SELECT_3 0x97
|
#define ISO14443A_CMD_ANTICOLL_OR_SELECT_3 0x97
|
||||||
#define ISO14443A_CMD_WRITEBLOCK 0xA0 // or 0xA2 ?
|
|
||||||
#define ISO14443A_CMD_HALT 0x50
|
#define ISO14443A_CMD_HALT 0x50
|
||||||
#define ISO14443A_CMD_RATS 0xE0
|
#define ISO14443A_CMD_RATS 0xE0
|
||||||
|
|
||||||
|
#define MIFARE_CMD_READBLOCK 0x30
|
||||||
|
#define MIFARE_CMD_WRITEBLOCK 0xA0
|
||||||
#define MIFARE_AUTH_KEYA 0x60
|
#define MIFARE_AUTH_KEYA 0x60
|
||||||
#define MIFARE_AUTH_KEYB 0x61
|
#define MIFARE_AUTH_KEYB 0x61
|
||||||
#define MIFARE_MAGICWUPC1 0x40
|
#define MIFARE_MAGICWUPC1 0x40
|
||||||
|
@ -127,23 +127,28 @@ NXP/Philips CUSTOM COMMANDS
|
||||||
#define MIFARE_EV1_PERSONAL_UID 0x40
|
#define MIFARE_EV1_PERSONAL_UID 0x40
|
||||||
#define MIFARE_EV1_SETMODE 0x43
|
#define MIFARE_EV1_SETMODE 0x43
|
||||||
|
|
||||||
|
|
||||||
#define MIFARE_ULC_WRITE 0xA2
|
#define MIFARE_ULC_WRITE 0xA2
|
||||||
//#define MIFARE_ULC__COMP_WRITE 0xA0
|
#define MIFARE_ULC_COMP_WRITE MIFARE_CMD_WRITEBLOCK
|
||||||
#define MIFARE_ULC_AUTH_1 0x1A
|
#define MIFARE_ULC_AUTH_1 0x1A
|
||||||
#define MIFARE_ULC_AUTH_2 0xAF
|
#define MIFARE_ULC_AUTH_2 0xAF
|
||||||
|
|
||||||
#define MIFARE_ULEV1_AUTH 0x1B
|
#define MIFARE_ULEV1_AUTH 0x1B
|
||||||
#define MIFARE_ULEV1_VERSION 0x60
|
#define MIFARE_ULEV1_VERSION 0x60
|
||||||
#define MIFARE_ULEV1_FASTREAD 0x3A
|
#define MIFARE_ULEV1_FASTREAD 0x3A
|
||||||
//#define MIFARE_ULEV1_WRITE 0xA2
|
#define MIFARE_ULEV1_WRITE 0xA2
|
||||||
//#define MIFARE_ULEV1_COMP_WRITE 0xA0
|
#define MIFARE_ULEV1_COMP_WRITE MIFARE_CMD_WRITEBLOCK
|
||||||
#define MIFARE_ULEV1_READ_CNT 0x39
|
#define MIFARE_ULEV1_READ_CNT 0x39
|
||||||
#define MIFARE_ULEV1_INCR_CNT 0xA5
|
#define MIFARE_ULEV1_INCR_CNT 0xA5
|
||||||
#define MIFARE_ULEV1_READSIG 0x3C
|
#define MIFARE_ULEV1_READSIG 0x3C
|
||||||
#define MIFARE_ULEV1_CHECKTEAR 0x3E
|
#define MIFARE_ULEV1_CHECKTEAR 0x3E
|
||||||
#define MIFARE_ULEV1_VCSL 0x4B
|
#define MIFARE_ULEV1_VCSL 0x4B
|
||||||
|
|
||||||
|
// mifare 4bit card answers
|
||||||
|
#define CARD_ACK 0x0A // 1010 - ACK
|
||||||
|
#define CARD_NACK_NA 0x04 // 0100 - NACK, not allowed (command not allowed)
|
||||||
|
#define CARD_NACK_TR 0x05 // 0101 - NACK, transmission error
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
06 00 = INITIATE
|
06 00 = INITIATE
|
||||||
0E xx = SELECT ID (xx = Chip-ID)
|
0E xx = SELECT ID (xx = Chip-ID)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue