Adjustments after the big merge from PM3 master.
This commit is contained in:
@@ -847,7 +847,6 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
MifareUWriteBlock(c->arg[0], c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFAREU_WRITEBL:
|
||||
MifareUWriteBlock_Special(c->arg[0], c->d.asBytes);
|
||||
MifareUWriteBlock_Special(c->arg[0], c->arg[1], c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFARE_NESTED:
|
||||
|
||||
@@ -19,12 +19,6 @@
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
// the block number for the ISO14443-4 PCB
|
||||
uint8_t pcb_blocknum = 0;
|
||||
// Deselect card by sending a s-block. the crc is precalced for speed
|
||||
static uint8_t deselect_cmd[] = {0xc2,0xe0,0xb4};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Select, Authenticate, Read a MIFARE tag.
|
||||
// read block
|
||||
@@ -117,8 +111,6 @@ void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes){
|
||||
LEDsoff();
|
||||
}
|
||||
cmd_send(CMD_ACK,1,0,0,0,0);
|
||||
}
|
||||
cmd_send(CMD_ACK,1,0,0,0,0);
|
||||
}
|
||||
|
||||
// Arg0 = BlockNo,
|
||||
@@ -258,7 +250,6 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
|
||||
{
|
||||
// free eventually allocated BigBuf memory
|
||||
BigBuf_free();
|
||||
// clear trace
|
||||
clear_trace();
|
||||
|
||||
// params
|
||||
@@ -313,36 +304,7 @@ void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain)
|
||||
Dbprintf("Data exceeds buffer!!");
|
||||
break;
|
||||
}
|
||||
|
||||
// UL-C authentication
|
||||
if ( useKey ) {
|
||||
uint8_t key[16] = {0x00};
|
||||
memcpy(key, datain, sizeof(key) );
|
||||
|
||||
if ( !mifare_ultra_auth(key) ) {
|
||||
OnError(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// UL-EV1 / NTAG authentication
|
||||
if (usePwd) {
|
||||
uint8_t pwd[4] = {0x00};
|
||||
memcpy(pwd, datain, sizeof(pwd));
|
||||
uint8_t pack[4] = {0,0,0,0};
|
||||
|
||||
if (!mifare_ul_ev1_auth(pwd, pack)){
|
||||
OnError(1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < blocks; i++){
|
||||
if ((i*4) + 4 > CARD_MEMORY_SIZE) {
|
||||
Dbprintf("Data exceeds buffer!!");
|
||||
break;
|
||||
}
|
||||
|
||||
len = mifare_ultra_readblock(blockNo + i, dataout + 4 * i);
|
||||
|
||||
if (len) {
|
||||
@@ -1373,19 +1335,4 @@ void Mifare_DES_Auth2(uint32_t arg0, uint8_t *datain){
|
||||
cmd_send(CMD_ACK, isOK, 0, 0, dataout, sizeof(dataout));
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -398,26 +398,6 @@ int mifare_ultra_auth(uint8_t *keybytes){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// encrypt out, in, length, key, iv
|
||||
tdes_2key_enc(rnd_ab, rnd_ab, sizeof(rnd_ab), key, enc_random_b);
|
||||
|
||||
len = mifare_sendcmd_short_mfucauth(NULL, 1, 0xAF, rnd_ab, resp, respPar, NULL);
|
||||
if (len != 11) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Cmd Error: %02x", resp[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t enc_resp[8] = { 0,0,0,0,0,0,0,0 };
|
||||
uint8_t resp_random_a[8] = { 0,0,0,0,0,0,0,0 };
|
||||
memcpy(enc_resp, resp+1, 8);
|
||||
|
||||
// decrypt out, in, length, key, iv
|
||||
tdes_2key_dec(resp_random_a, enc_resp, 8, key, enc_random_b);
|
||||
if ( memcmp(resp_random_a, random_a, 8) != 0 ) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("failed authentication");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) {
|
||||
Dbprintf("e_AB: %02x %02x %02x %02x %02x %02x %02x %02x",
|
||||
rnd_ab[0],rnd_ab[1],rnd_ab[2],rnd_ab[3],
|
||||
|
||||
Reference in New Issue
Block a user