mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
CHG: removed some #DEFINE TRUE/FALSE
This commit is contained in:
parent
5f18400cbe
commit
4406f4ee2a
19 changed files with 149 additions and 133 deletions
|
@ -63,6 +63,10 @@ void BigBuf_Clear_ext(bool verbose)
|
|||
Dbprintf("Buffer cleared (%i bytes)", BIGBUF_SIZE);
|
||||
}
|
||||
|
||||
void BigBuf_Clear_EM(void){
|
||||
memset(BigBuf_get_EM_addr(), 0, CARD_MEMORY_SIZE);
|
||||
}
|
||||
|
||||
void BigBuf_Clear_keep_EM(void)
|
||||
{
|
||||
memset(BigBuf, 0, BigBuf_hi);
|
||||
|
@ -142,7 +146,7 @@ uint16_t BigBuf_get_traceLen(void)
|
|||
**/
|
||||
bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_start, uint32_t timestamp_end, uint8_t *parity, bool readerToTag)
|
||||
{
|
||||
if (!tracing) return FALSE;
|
||||
if (!tracing) return false;
|
||||
|
||||
uint8_t *trace = BigBuf_get_addr();
|
||||
|
||||
|
@ -151,8 +155,8 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_
|
|||
|
||||
// Return when trace is full
|
||||
if (traceLen + sizeof(iLen) + sizeof(timestamp_start) + sizeof(duration) + num_paritybytes + iLen >= BigBuf_max_traceLen()) {
|
||||
tracing = FALSE; // don't trace any more
|
||||
return FALSE;
|
||||
tracing = false; // don't trace any more
|
||||
return false;
|
||||
}
|
||||
// Traceformat:
|
||||
// 32 bits timestamp (little endian)
|
||||
|
@ -207,12 +211,12 @@ int LogTraceHitag(const uint8_t * btBytes, int iBits, int iSamples, uint32_t dwP
|
|||
that this logger takes number of bits as argument, not number of bytes.
|
||||
**/
|
||||
|
||||
if (!tracing) return FALSE;
|
||||
if (!tracing) return false;
|
||||
|
||||
uint8_t *trace = BigBuf_get_addr();
|
||||
uint16_t iLen = nbytes(iBits);
|
||||
// Return when trace is full
|
||||
if (traceLen + sizeof(rsamples) + sizeof(dwParity) + sizeof(iBits) + iLen > BigBuf_max_traceLen()) return FALSE;
|
||||
if (traceLen + sizeof(rsamples) + sizeof(dwParity) + sizeof(iBits) + iLen > BigBuf_max_traceLen()) return false;
|
||||
|
||||
//Hitag traces appear to use this traceformat:
|
||||
// 32 bits timestamp (little endian,Highest Bit used as readerToTag flag)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#ifndef __BIGBUF_H
|
||||
#define __BIGBUF_H
|
||||
|
||||
#include <stdbool.h> // for bool
|
||||
#include "proxmark3.h"
|
||||
#include "string.h"
|
||||
#include "ticks.h"
|
||||
|
@ -30,6 +31,7 @@ extern uint16_t BigBuf_max_traceLen(void);
|
|||
extern void BigBuf_Clear(void);
|
||||
extern void BigBuf_Clear_ext(bool verbose);
|
||||
extern void BigBuf_Clear_keep_EM(void);
|
||||
extern void BigBuf_Clear_EM(void);
|
||||
extern uint8_t *BigBuf_malloc(uint16_t);
|
||||
extern void BigBuf_free(void);
|
||||
extern void BigBuf_free_keep_EM(void);
|
||||
|
|
|
@ -1325,22 +1325,28 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
|||
|
||||
case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: {
|
||||
LED_B_ON();
|
||||
uint8_t *BigBuf = BigBuf_get_addr();
|
||||
uint8_t *mem = BigBuf_get_addr();
|
||||
bool isok = false;
|
||||
size_t len = 0;
|
||||
size_t startidx = c->arg[0];
|
||||
uint8_t isok = FALSE;
|
||||
uint32_t startidx = c->arg[0];
|
||||
uint32_t numofbytes = c->arg[1];
|
||||
// arg0 = startindex
|
||||
// arg1 = length bytes to transfer
|
||||
// arg2 = RFU
|
||||
//Dbprintf("transfer to client parameters: %" PRIu64 " | %" PRIu64 " | %" PRIu64, c->arg[0], c->arg[1], c->arg[2]);
|
||||
// arg2 = BigBuf tracelen
|
||||
//Dbprintf("transfer to client parameters: %" PRIu32 " | %" PRIu32 " | %" PRIu32, startidx, numofbytes, c->arg[2]);
|
||||
|
||||
for(size_t i = 0; i < c->arg[1]; i += USB_CMD_DATA_SIZE) {
|
||||
len = MIN( (c->arg[1] - i), USB_CMD_DATA_SIZE);
|
||||
isok = cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, i, len, BigBuf_get_traceLen(), BigBuf + startidx + i, len);
|
||||
for(size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
len = MIN( (numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
isok = cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, i, len, BigBuf_get_traceLen(), mem + startidx + i, len);
|
||||
if (!isok)
|
||||
Dbprintf("transfer to client failed :: | bytes %d", len);
|
||||
Dbprintf("transfer to client failed :: | bytes between %d - %d", i, len);
|
||||
}
|
||||
// Trigger a finish downloading signal with an ACK frame
|
||||
// iceman, when did sending samplingconfig array got attached here?!?
|
||||
// arg0 = status of download transfer
|
||||
// arg1 = RFU
|
||||
// arg2 = tracelen?
|
||||
// asbytes = samplingconfig array
|
||||
cmd_send(CMD_ACK, 1, 0, BigBuf_get_traceLen(), getSamplingConfig(), sizeof(sample_config));
|
||||
LED_B_OFF();
|
||||
break;
|
||||
|
@ -1354,21 +1360,33 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
|||
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
|
||||
else
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
uint8_t *b = BigBuf_get_addr();
|
||||
memcpy( b + c->arg[0], c->d.asBytes, USB_CMD_DATA_SIZE);
|
||||
|
||||
uint8_t *mem = BigBuf_get_addr();
|
||||
memcpy( mem + c->arg[0], c->d.asBytes, USB_CMD_DATA_SIZE);
|
||||
cmd_send(CMD_ACK,1,0,0,0,0);
|
||||
break;
|
||||
}
|
||||
case CMD_DOWNLOAD_EML_BIGBUF: {
|
||||
LED_B_ON();
|
||||
uint8_t *cardmem = BigBuf_get_EM_addr();
|
||||
uint8_t *mem = BigBuf_get_EM_addr();
|
||||
bool isok = false;
|
||||
size_t len = 0;
|
||||
for(size_t i=0; i < c->arg[1]; i += USB_CMD_DATA_SIZE) {
|
||||
len = MIN((c->arg[1] - i), USB_CMD_DATA_SIZE);
|
||||
cmd_send(CMD_DOWNLOADED_EML_BIGBUF, i, len, CARD_MEMORY_SIZE, cardmem + c->arg[0] + i, len);
|
||||
uint32_t startidx = c->arg[0];
|
||||
uint32_t numofbytes = c->arg[1];
|
||||
|
||||
// arg0 = startindex
|
||||
// arg1 = length bytes to transfer
|
||||
// arg2 = RFU
|
||||
//Dbprintf("transfer to client parameters: %" PRIu32 " | %" PRIu32 " | %" PRIu32, startidx, numofbytes, c->arg[2]);
|
||||
|
||||
for(size_t i = 0; i < numofbytes; i += USB_CMD_DATA_SIZE) {
|
||||
len = MIN((numofbytes - i), USB_CMD_DATA_SIZE);
|
||||
isok = cmd_send(CMD_DOWNLOADED_EML_BIGBUF, i, len, 0, mem + startidx + i, len);
|
||||
if (!isok)
|
||||
Dbprintf("transfer to client failed :: | bytes between %d - %d", i, len);
|
||||
}
|
||||
// Trigger a finish downloading signal with an ACK frame
|
||||
cmd_send(CMD_ACK, 1, 0, CARD_MEMORY_SIZE, 0, 0);
|
||||
cmd_send(CMD_ACK, 1, 0, 0, 0, 0);
|
||||
LED_B_OFF();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ void ClearFpgaShiftingRegisters(void);
|
|||
|
||||
// iso14443a.h
|
||||
void RAMFUNC SniffIso14443a(uint8_t param);
|
||||
void SimulateIso14443aTag(int tagType, int flags, byte_t* data);
|
||||
void SimulateIso14443aTag(int tagType, int flags, uint8_t *data);
|
||||
void ReaderIso14443a(UsbCommand * c);
|
||||
// Also used in iclass.c
|
||||
//bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t len, uint32_t timestamp_start, uint32_t timestamp_end, uint8_t *parity, bool readerToTag);
|
||||
|
|
|
@ -1519,7 +1519,7 @@ void emvsnoop() {
|
|||
uint8_t rSAK[] = {0x28, 0xB4, 0xFC};
|
||||
|
||||
iso14443a_setup(FPGA_HF_ISO14443A_TAGSIM_LISTEN);
|
||||
bool finished = FALSE;
|
||||
bool finished = false;
|
||||
|
||||
while (!BUTTON_PRESS() && !finished){
|
||||
WDT_HIT();
|
||||
|
|
|
@ -98,7 +98,7 @@ static struct {
|
|||
static uint8_t apdu_lengths_replay[5];
|
||||
|
||||
// type of card (ISO 14443 A or B)
|
||||
static char iso_type;
|
||||
static char iso_type = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Wrapper for sending APDUs to type A and B cards
|
||||
|
|
|
@ -19,7 +19,7 @@ static void RAMFUNC optimizedSnoop(void)
|
|||
if(AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY)
|
||||
{
|
||||
*dest = (uint16_t)(AT91C_BASE_SSC->SSC_RHR);
|
||||
++dest;
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
//Resetting Frame mode (First set in fpgaloader.c)
|
||||
|
@ -67,7 +67,7 @@ void HfSnoop(int samplesToSkip, int triggersToSkip)
|
|||
while(waitcount != 0) {
|
||||
|
||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY))
|
||||
--waitcount;
|
||||
waitcount--;
|
||||
}
|
||||
optimizedSnoop();
|
||||
Dbprintf("Trigger kicked! Value: %d, Dumping Samples Hispeed now.", r);
|
||||
|
|
|
@ -343,7 +343,7 @@ static void hitag2_handle_reader_command(byte_t* rx, const size_t rxlen, byte_t*
|
|||
|
||||
// Unknown command
|
||||
default:
|
||||
Dbprintf("Uknown command: %02x %02x",rx[0],rx[1]);
|
||||
Dbprintf("Unknown command: %02x %02x",rx[0],rx[1]);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ void SnoopHitag(uint32_t type) {
|
|||
|
||||
// Clean up trace and prepare it for storing frames
|
||||
clear_trace();
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
|
||||
auth_table_len = 0;
|
||||
auth_table_pos = 0;
|
||||
|
@ -946,7 +946,7 @@ void SnoopHitag(uint32_t type) {
|
|||
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LED_A_OFF();
|
||||
set_tracing(TRUE);
|
||||
set_tracing(false);
|
||||
// Dbprintf("frame received: %d",frame_count);
|
||||
// Dbprintf("Authentication Attempts: %d",(auth_table_len/8));
|
||||
// DbpString("All done");
|
||||
|
@ -970,7 +970,7 @@ void SimulateHitagTag(bool tag_mem_supplied, byte_t* data) {
|
|||
|
||||
// Clean up trace and prepare it for storing frames
|
||||
clear_trace();
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
|
||||
auth_table_len = 0;
|
||||
auth_table_pos = 0;
|
||||
|
@ -1138,7 +1138,7 @@ void SimulateHitagTag(bool tag_mem_supplied, byte_t* data) {
|
|||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
|
||||
DbpString("Sim Stopped");
|
||||
set_tracing(TRUE);
|
||||
set_tracing(false);
|
||||
}
|
||||
|
||||
void ReaderHitag(hitag_function htf, hitag_data* htd) {
|
||||
|
@ -1163,7 +1163,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
|
|||
|
||||
// Clean up trace and prepare it for storing frames
|
||||
clear_trace();
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
|
||||
//DbpString("Starting Hitag reader family");
|
||||
|
||||
|
@ -1216,7 +1216,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
|
|||
} break;
|
||||
default: {
|
||||
Dbprintf("Error, unknown function: %d",htf);
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
return;
|
||||
} break;
|
||||
}
|
||||
|
@ -1284,7 +1284,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
|
|||
//DbpString("Configured for hitag2 reader");
|
||||
} else {
|
||||
Dbprintf("Error, unknown hitag reader type: %d",htf);
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
return;
|
||||
}
|
||||
uint8_t attempt_count=0;
|
||||
|
@ -1328,7 +1328,7 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
|
|||
} break;
|
||||
default: {
|
||||
Dbprintf("Error, unknown function: %d",htf);
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
return;
|
||||
} break;
|
||||
}
|
||||
|
@ -1443,5 +1443,5 @@ void ReaderHitag(hitag_function htf, hitag_data* htd) {
|
|||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
// Dbprintf("DONE: frame received: %d",frame_count);
|
||||
cmd_send(CMD_ACK,bSuccessful,0,0,(byte_t*)tag.sectors,48);
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
}
|
|
@ -955,7 +955,7 @@ void SimulateHitagSTag(bool tag_mem_supplied, byte_t* data) {
|
|||
BigBuf_free(); BigBuf_Clear_ext(false);
|
||||
|
||||
// Clean up trace and prepare it for storing frames
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
clear_trace();
|
||||
|
||||
DbpString("Starting HitagS simulation");
|
||||
|
@ -1219,7 +1219,7 @@ void ReadHitagS(hitag_function htf, hitag_data* htd) {
|
|||
bSuccessful = false;
|
||||
|
||||
// Clean up trace and prepare it for storing frames
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
clear_trace();
|
||||
|
||||
bQuiet = false;
|
||||
|
@ -1563,7 +1563,7 @@ void WritePageHitagS(hitag_function htf, hitag_data* htd,int page_) {
|
|||
tag.tstate = HT_NO_OP;
|
||||
|
||||
// Clean up trace and prepare it for storing frames
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
clear_trace();
|
||||
|
||||
bQuiet = false;
|
||||
|
@ -1850,7 +1850,7 @@ void check_challenges(bool file_given, byte_t* data) {
|
|||
bSuccessful = false;
|
||||
|
||||
// Clean up trace and prepare it for storing frames
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
clear_trace();
|
||||
|
||||
bQuiet = false;
|
||||
|
|
|
@ -85,7 +85,7 @@ static RAMFUNC int OutOfNDecoding(int bit)
|
|||
|
||||
if(!Uart.bitBuffer) {
|
||||
Uart.bitBuffer = bit ^ 0xFF0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
Uart.bitBuffer <<= 4;
|
||||
|
@ -96,7 +96,7 @@ static RAMFUNC int OutOfNDecoding(int bit)
|
|||
Uart.output[Uart.byteCnt] = Uart.bitBuffer & 0xFF;
|
||||
Uart.byteCnt++;
|
||||
Uart.swapper = 0;
|
||||
if(Uart.byteCnt > 15) { return true; }
|
||||
if(Uart.byteCnt > 15) return true;
|
||||
}
|
||||
else {
|
||||
Uart.swapper = 1;
|
||||
|
@ -312,7 +312,7 @@ static RAMFUNC int OutOfNDecoding(int bit)
|
|||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -365,7 +365,7 @@ static RAMFUNC int ManchesterDecoding(int v)
|
|||
|
||||
if(Demod.buff < 3) {
|
||||
Demod.buff++;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(Demod.state==DEMOD_UNSYNCD) {
|
||||
|
@ -421,7 +421,7 @@ static RAMFUNC int ManchesterDecoding(int v)
|
|||
if(!(Demod.buffer2 & Demod.syncBit) || !(Demod.buffer3 & Demod.syncBit)) {
|
||||
Demod.state = DEMOD_UNSYNCD;
|
||||
error = 0x88;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: use this error value to print? Ask Holiman.
|
||||
|
@ -615,7 +615,7 @@ static RAMFUNC int ManchesterDecoding(int v)
|
|||
|
||||
} // end (state != UNSYNCED)
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -633,7 +633,7 @@ void RAMFUNC SnoopIClass(void)
|
|||
// We won't start recording the frames that we acquire until we trigger;
|
||||
// a good trigger condition to get started is probably when we see a
|
||||
// response from the tag.
|
||||
//int triggered = FALSE; // FALSE to wait first for card
|
||||
//int triggered = false; // false to wait first for card
|
||||
|
||||
// The command (reader -> tag) that we're receiving.
|
||||
// The length of a received command will in most cases be no more than 18 bytes.
|
||||
|
@ -653,7 +653,7 @@ void RAMFUNC SnoopIClass(void)
|
|||
clear_trace();
|
||||
set_tracing(true);
|
||||
|
||||
iso14a_set_trigger(FALSE);
|
||||
iso14a_set_trigger(false);
|
||||
|
||||
int lastRxCounter;
|
||||
uint8_t *upTo;
|
||||
|
@ -739,7 +739,7 @@ void RAMFUNC SnoopIClass(void)
|
|||
decbyter <<= 2;
|
||||
decbyter ^= (smpl & 0x30);
|
||||
|
||||
++div;
|
||||
div++;
|
||||
|
||||
if (( div + 1) % 2 == 0) {
|
||||
smpl = decbyter;
|
||||
|
@ -780,7 +780,7 @@ void RAMFUNC SnoopIClass(void)
|
|||
if(tracing) {
|
||||
uint8_t parity[MAX_PARITY_SIZE];
|
||||
GetParity(Demod.output, Demod.len, parity);
|
||||
LogTrace(Demod.output, Demod.len, time_start, time_stop, parity, FALSE);
|
||||
LogTrace(Demod.output, Demod.len, time_start, time_stop, parity, false);
|
||||
}
|
||||
|
||||
// And ready to receive another response.
|
||||
|
@ -812,7 +812,7 @@ done:
|
|||
Dbprintf("%x %x %x", maxBehindBy, Uart.state, Uart.byteCnt);
|
||||
Dbprintf("%x %x %x", Uart.byteCntMax, BigBuf_get_traceLen(), (int)Uart.output[0]);
|
||||
LEDsoff();
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
}
|
||||
|
||||
void rotateCSN(uint8_t* originalCSN, uint8_t* rotatedCSN) {
|
||||
|
@ -842,7 +842,7 @@ static int GetIClassCommandFromReader(uint8_t *received, int *len, int maxLen)
|
|||
for(;;) {
|
||||
WDT_HIT();
|
||||
|
||||
if(BUTTON_PRESS()) return FALSE;
|
||||
if(BUTTON_PRESS()) return false;
|
||||
|
||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||
AT91C_BASE_SSC->SSC_THR = 0x00;
|
||||
|
@ -1037,7 +1037,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
|
|||
Dbprintf("The mode is not implemented, reserved for future use");
|
||||
}
|
||||
Dbprintf("Done...");
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
}
|
||||
void AppendCrc(uint8_t* data, int len)
|
||||
{
|
||||
|
@ -1325,7 +1325,7 @@ int doIClassSimulation( int simulationMode, uint8_t *reader_mac_buf)
|
|||
|
||||
if (trace_data != NULL) {
|
||||
GetParity(trace_data, trace_data_size, parity);
|
||||
LogTrace(trace_data, trace_data_size, (t2r_time-time_0) << 4, (t2r_time-time_0) << 4, parity, FALSE);
|
||||
LogTrace(trace_data, trace_data_size, (t2r_time-time_0) << 4, (t2r_time-time_0) << 4, parity, false);
|
||||
}
|
||||
if(!tracing)
|
||||
DbpString("Trace full");
|
||||
|
@ -1527,13 +1527,13 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
|
|||
uint8_t b;
|
||||
if (elapsed) *elapsed = 0;
|
||||
|
||||
bool skip = FALSE;
|
||||
bool skip = false;
|
||||
|
||||
c = 0;
|
||||
for(;;) {
|
||||
WDT_HIT();
|
||||
|
||||
if(BUTTON_PRESS()) return FALSE;
|
||||
if(BUTTON_PRESS()) return false;
|
||||
|
||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||
AT91C_BASE_SSC->SSC_THR = 0x00; // To make use of exact timing of next command from reader!!
|
||||
|
@ -1543,7 +1543,7 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
|
|||
if(c < timeout)
|
||||
c++;
|
||||
else
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
||||
|
@ -1562,14 +1562,14 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *samples,
|
|||
int ReaderReceiveIClass(uint8_t* receivedAnswer)
|
||||
{
|
||||
int samples = 0;
|
||||
if (!GetIClassAnswer(receivedAnswer,160,&samples,0)) return FALSE;
|
||||
if (!GetIClassAnswer(receivedAnswer,160,&samples,0)) return false;
|
||||
rsamples += samples;
|
||||
if (tracing) {
|
||||
uint8_t parity[MAX_PARITY_SIZE];
|
||||
GetParity(receivedAnswer, Demod.len, parity);
|
||||
LogTrace(receivedAnswer,Demod.len,rsamples,rsamples,parity,FALSE);
|
||||
LogTrace(receivedAnswer,Demod.len,rsamples,rsamples,parity,false);
|
||||
}
|
||||
if(samples == 0) return FALSE;
|
||||
if(samples == 0) return false;
|
||||
return Demod.len;
|
||||
}
|
||||
|
||||
|
@ -1658,7 +1658,7 @@ uint8_t handshakeIclassTag_ext(uint8_t *card_data, bool use_credit_key)
|
|||
//Flag that we got to at least stage 1, read CSN
|
||||
read_status = 1;
|
||||
|
||||
// Card selected, now read e-purse (cc)
|
||||
// Card selected, now read e-purse (cc) (only 8 bytes no CRC)
|
||||
ReaderTransmitIClass(readcheck_cc, sizeof(readcheck_cc));
|
||||
if(ReaderReceiveIClass(resp) == 8) {
|
||||
//Save CC (e-purse) in response data
|
||||
|
@ -1769,14 +1769,13 @@ void ReaderIClass(uint8_t arg0) {
|
|||
LED_B_OFF();
|
||||
userCancelled = BUTTON_PRESS() || usb_poll_validate_length();
|
||||
}
|
||||
|
||||
if (userCancelled)
|
||||
cmd_send(CMD_ACK, 0xFF, 0, 0, card_data, 0);
|
||||
else
|
||||
cmd_send(CMD_ACK, 0, 0, 0, card_data, 0);
|
||||
|
||||
LEDsoff();
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
}
|
||||
|
||||
void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
|
||||
|
@ -1895,8 +1894,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
|
|||
}
|
||||
|
||||
//Send off any remaining data
|
||||
if(stored_data_length > 0)
|
||||
{
|
||||
if (stored_data_length > 0) {
|
||||
cmd_send(CMD_ACK,
|
||||
stored_data_length,//data length
|
||||
failedRead,//Failed blocks?
|
||||
|
@ -1914,7 +1912,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
|
|||
card_data, 0);
|
||||
|
||||
LED_A_OFF();
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
}
|
||||
|
||||
void iClass_ReadCheck(uint8_t blockNo, uint8_t keyType) {
|
||||
|
@ -2016,11 +2014,11 @@ bool iClass_WriteBlock_ext(uint8_t blockNo, uint8_t *data) {
|
|||
|
||||
void iClass_WriteBlock(uint8_t blockNo, uint8_t *data) {
|
||||
bool isOK = iClass_WriteBlock_ext(blockNo, data);
|
||||
if (isOK){
|
||||
if (isOK)
|
||||
Dbprintf("Write block [%02x] successful",blockNo);
|
||||
}else {
|
||||
else
|
||||
Dbprintf("Write block [%02x] failed",blockNo);
|
||||
}
|
||||
|
||||
cmd_send(CMD_ACK,isOK,0,0,0,0);
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ static void switch_off(void){
|
|||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
SpinDelay(100);
|
||||
FpgaDisableSscDma();
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
LEDsoff();
|
||||
}
|
||||
|
||||
|
@ -435,14 +435,14 @@ static RAMFUNC int Handle14443bReaderUartBit(uint8_t bit) {
|
|||
Uart.state = STATE_UNSYNCD;
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Receive a command (from the reader to us, where we are the simulated tag),
|
||||
// and store it in the given buffer, up to the given maximum length. Keeps
|
||||
// spinning, waiting for a well-framed command, until either we get one
|
||||
// (returns TRUE) or someone presses the pushbutton on the board (FALSE).
|
||||
// (returns true) or someone presses the pushbutton on the board (false).
|
||||
//
|
||||
// Assume that we're called with the SSC (to the FPGA) and ADC path set
|
||||
// correctly.
|
||||
|
@ -484,7 +484,7 @@ static int GetIso14443bCommandFromReader(uint8_t *received, uint16_t *len) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClearFpgaShiftingRegisters(void){
|
||||
|
@ -667,19 +667,19 @@ void SimulateIso14443bTag(uint32_t pupi) {
|
|||
}
|
||||
case SIM_SELECTING: {
|
||||
TransmitFor14443b_AsTag( encodedATQB, encodedATQBLen );
|
||||
LogTrace(respATQB, sizeof(respATQB), 0, 0, NULL, FALSE);
|
||||
LogTrace(respATQB, sizeof(respATQB), 0, 0, NULL, false);
|
||||
cardSTATE = SIM_WORK;
|
||||
break;
|
||||
}
|
||||
case SIM_HALTING: {
|
||||
TransmitFor14443b_AsTag( encodedOK, encodedOKLen );
|
||||
LogTrace(respOK, sizeof(respOK), 0, 0, NULL, FALSE);
|
||||
LogTrace(respOK, sizeof(respOK), 0, 0, NULL, false);
|
||||
cardSTATE = SIM_HALTED;
|
||||
break;
|
||||
}
|
||||
case SIM_ACKNOWLEDGE: {
|
||||
TransmitFor14443b_AsTag( encodedOK, encodedOKLen );
|
||||
LogTrace(respOK, sizeof(respOK), 0, 0, NULL, FALSE);
|
||||
LogTrace(respOK, sizeof(respOK), 0, 0, NULL, false);
|
||||
cardSTATE = SIM_IDLE;
|
||||
break;
|
||||
}
|
||||
|
@ -940,7 +940,7 @@ static RAMFUNC int Handle14443bTagSamplesDemod(int ci, int cq) {
|
|||
LED_C_OFF();
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -949,7 +949,7 @@ static RAMFUNC int Handle14443bTagSamplesDemod(int ci, int cq) {
|
|||
* quiet: set to 'TRUE' to disable debug output
|
||||
*/
|
||||
static void GetTagSamplesFor14443bDemod() {
|
||||
bool gotFrame = FALSE, finished = FALSE;
|
||||
bool gotFrame = false, finished = false;
|
||||
int lastRxCounter = ISO14443B_DMA_BUFFER_SIZE;
|
||||
int ci = 0, cq = 0;
|
||||
uint32_t time_0 = 0, time_stop = 0;
|
||||
|
@ -1016,10 +1016,10 @@ static void GetTagSamplesFor14443bDemod() {
|
|||
|
||||
// print the last batch of IQ values from FPGA
|
||||
if (MF_DBGLEVEL == 4)
|
||||
Dbhexdump(ISO14443B_DMA_BUFFER_SIZE, (uint8_t *)dmaBuf, FALSE);
|
||||
Dbhexdump(ISO14443B_DMA_BUFFER_SIZE, (uint8_t *)dmaBuf, false);
|
||||
|
||||
if ( Demod.len > 0 )
|
||||
LogTrace(Demod.output, Demod.len, time_0, time_stop, NULL, FALSE);
|
||||
LogTrace(Demod.output, Demod.len, time_0, time_stop, NULL, false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1408,7 +1408,7 @@ void ReadSTMemoryIso14443b(uint8_t numofblocks)
|
|||
|
||||
if (Demod.len == 0) {
|
||||
DbpString("No response from tag");
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
return;
|
||||
} else {
|
||||
Dbprintf("Randomly generated Chip ID (+ 2 byte CRC): %02x %02x %02x",
|
||||
|
@ -1424,20 +1424,20 @@ void ReadSTMemoryIso14443b(uint8_t numofblocks)
|
|||
GetTagSamplesFor14443bDemod(); //no
|
||||
if (Demod.len != 3) {
|
||||
Dbprintf("Expected 3 bytes from tag, got %d", Demod.len);
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
return;
|
||||
}
|
||||
// Check the CRC of the answer:
|
||||
ComputeCrc14443(CRC_14443_B, Demod.output, 1 , &cmd1[2], &cmd1[3]);
|
||||
if(cmd1[2] != Demod.output[1] || cmd1[3] != Demod.output[2]) {
|
||||
DbpString("CRC Error reading select response.");
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
return;
|
||||
}
|
||||
// Check response from the tag: should be the same UID as the command we just sent:
|
||||
if (cmd1[1] != Demod.output[0]) {
|
||||
Dbprintf("Bad response to SELECT from Tag, aborting: %02x %02x", cmd1[1], Demod.output[0]);
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1449,7 +1449,7 @@ void ReadSTMemoryIso14443b(uint8_t numofblocks)
|
|||
GetTagSamplesFor14443bDemod(); //no
|
||||
if (Demod.len != 10) {
|
||||
Dbprintf("Expected 10 bytes from tag, got %d", Demod.len);
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
return;
|
||||
}
|
||||
// The check the CRC of the answer (use cmd1 as temporary variable):
|
||||
|
@ -1499,7 +1499,7 @@ void ReadSTMemoryIso14443b(uint8_t numofblocks)
|
|||
++i;
|
||||
}
|
||||
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1567,8 +1567,8 @@ void RAMFUNC SnoopIso14443b(void) {
|
|||
// a good trigger condition to get started is probably when we see a
|
||||
// response from the tag.
|
||||
bool triggered = true; // TODO: set and evaluate trigger condition
|
||||
bool TagIsActive = FALSE;
|
||||
bool ReaderIsActive = FALSE;
|
||||
bool TagIsActive = false;
|
||||
bool ReaderIsActive = false;
|
||||
|
||||
iso1444b_setup_snoop();
|
||||
|
||||
|
@ -1660,7 +1660,7 @@ void RAMFUNC SnoopIso14443b(void) {
|
|||
|
||||
time_stop = GetCountSspClk() - time_0;
|
||||
|
||||
LogTrace(Demod.output, Demod.len, time_start, time_stop, NULL, FALSE);
|
||||
LogTrace(Demod.output, Demod.len, time_start, time_stop, NULL, false);
|
||||
|
||||
triggered = true;
|
||||
|
||||
|
@ -1761,7 +1761,7 @@ void SendRawCommand14443B_Ex(UsbCommand *c)
|
|||
|
||||
// turn off trigger (LED_A)
|
||||
if ((param & ISO14B_REQUEST_TRIGGER) == ISO14B_REQUEST_TRIGGER)
|
||||
iso14b_set_trigger(FALSE);
|
||||
iso14b_set_trigger(false);
|
||||
|
||||
// turn off antenna et al
|
||||
// we don't send a HALT command.
|
||||
|
|
|
@ -27,15 +27,15 @@ extern "C" {
|
|||
#include "protocols.h"
|
||||
|
||||
extern void AppendCrc14443b(uint8_t *data, int len);
|
||||
void SendRawCommand14443B_Ex(UsbCommand *c);
|
||||
void iso14443b_setup();
|
||||
uint8_t iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *response);
|
||||
uint8_t iso14443b_select_card(iso14b_card_select_t* card);
|
||||
uint8_t iso14443b_select_card_srx(iso14b_card_select_t* card);
|
||||
extern void SendRawCommand14443B_Ex(UsbCommand *c);
|
||||
extern void iso14443b_setup();
|
||||
extern uint8_t iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *response);
|
||||
extern uint8_t iso14443b_select_card(iso14b_card_select_t* card);
|
||||
extern uint8_t iso14443b_select_card_srx(iso14b_card_select_t* card);
|
||||
|
||||
// testfunctions
|
||||
void WaitForFpgaDelayQueueIsEmpty( uint16_t delay );
|
||||
void ClearFpgaShiftingRegisters(void);
|
||||
extern void WaitForFpgaDelayQueueIsEmpty( uint16_t delay );
|
||||
extern void ClearFpgaShiftingRegisters(void);
|
||||
|
||||
// States for 14B SIM command
|
||||
#define SIM_NOFIELD 0
|
||||
|
|
|
@ -285,11 +285,11 @@ static int GetIso15693AnswerFromTag(uint8_t *receivedResponse, int maxLen, int *
|
|||
{
|
||||
uint8_t *dest = BigBuf_get_addr();
|
||||
|
||||
int c = 0, getNext = FALSE;
|
||||
int c = 0, getNext = false;
|
||||
int8_t prev = 0;
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
||||
SpinDelay(100); // greg - experiment to get rid of some of the 0 byte/failed reads
|
||||
//SpinDelay(60); // greg - experiment to get rid of some of the 0 byte/failed reads
|
||||
|
||||
for(;;) {
|
||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))
|
||||
|
@ -412,11 +412,11 @@ static int GetIso15693AnswerFromSniff(uint8_t *receivedResponse, int maxLen, int
|
|||
{
|
||||
uint8_t *dest = BigBuf_get_addr();
|
||||
|
||||
int c = 0, getNext = FALSE;
|
||||
int c = 0, getNext = false;
|
||||
int8_t prev = 0;
|
||||
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
||||
SpinDelay(100); // greg - experiment to get rid of some of the 0 byte/failed reads
|
||||
//SpinDelay(60); // greg - experiment to get rid of some of the 0 byte/failed reads
|
||||
|
||||
for(;;) {
|
||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))
|
||||
|
@ -538,7 +538,7 @@ void AcquireRawAdcSamplesIso15693(void)
|
|||
{
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
|
||||
int c = 0, getNext = FALSE;
|
||||
int c = 0, getNext = false;
|
||||
int8_t prev = 0;
|
||||
volatile uint32_t r;
|
||||
|
||||
|
@ -602,7 +602,7 @@ void RecordRawAdcSamplesIso15693(void)
|
|||
{
|
||||
uint8_t *dest = BigBuf_get_addr();
|
||||
|
||||
int c = 0, getNext = FALSE;
|
||||
int c = 0, getNext = false;
|
||||
int8_t prev = 0;
|
||||
|
||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||
|
@ -983,7 +983,7 @@ void ReaderIso15693(uint32_t parameter)
|
|||
Dbhexdump(answerLen2, answer2, true);
|
||||
if ( *((uint32_t*) answer2) == 0x07160101 ) break; // exit on NoPageErr
|
||||
}
|
||||
++i;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ bool InitDesfireCard(){
|
|||
iso14a_card_select_t card;
|
||||
|
||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
|
||||
if (!iso14443a_select_card(NULL, &card, NULL, true, 0)) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) DbpString("Can't select card");
|
||||
|
@ -101,7 +101,7 @@ void MifareDesfireGetInformation(){
|
|||
CID == 0x00 first card?
|
||||
*/
|
||||
clear_trace();
|
||||
set_tracing(TRUE);
|
||||
set_tracing(true);
|
||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||
|
||||
// card select - information
|
||||
|
@ -511,7 +511,7 @@ int DesfireAPDU(uint8_t *cmd, size_t cmd_len, uint8_t *dataout){
|
|||
len = ReaderReceive(resp, par);
|
||||
if ( !len ) {
|
||||
if (MF_DBGLEVEL >= 4) Dbprintf("fukked");
|
||||
return FALSE; //DATA LINK ERROR
|
||||
return false; //DATA LINK ERROR
|
||||
}
|
||||
// if we received an I- or R(ACK)-Block with a block number equal to the
|
||||
// current block number, toggle the current block number
|
||||
|
@ -558,7 +558,7 @@ void OnSuccess(){
|
|||
mifare_ultra_halt();
|
||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||
LEDsoff();
|
||||
set_tracing(FALSE);
|
||||
set_tracing(false);
|
||||
}
|
||||
|
||||
void OnError(uint8_t reason){
|
||||
|
|
|
@ -132,16 +132,16 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
|
|||
sniffBuf[14] = sniffSAK;
|
||||
sniffBuf[15] = 0xFF;
|
||||
sniffBuf[16] = 0xFF;
|
||||
LogTrace(sniffBuf, sizeof(sniffBuf), 0, 0, NULL, TRUE);
|
||||
LogTrace(sniffBuf, sizeof(sniffBuf), 0, 0, NULL, true);
|
||||
} // intentionally no break;
|
||||
case SNF_CARD_CMD:{
|
||||
LogTrace(data, len, 0, 0, NULL, TRUE);
|
||||
LogTrace(data, len, 0, 0, NULL, true);
|
||||
sniffState = SNF_CARD_RESP;
|
||||
timerData = GetTickCount();
|
||||
break;
|
||||
}
|
||||
case SNF_CARD_RESP:{
|
||||
LogTrace(data, len, 0, 0, NULL, FALSE);
|
||||
LogTrace(data, len, 0, 0, NULL, false);
|
||||
sniffState = SNF_CARD_CMD;
|
||||
timerData = GetTickCount();
|
||||
break;
|
||||
|
@ -150,14 +150,14 @@ bool RAMFUNC MfSniffLogic(const uint8_t *data, uint16_t len, uint8_t *parity, ui
|
|||
sniffState = SNF_INIT;
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RAMFUNC MfSniffSend(uint16_t maxTimeoutMs) {
|
||||
if (BigBuf_get_traceLen() && (GetTickCount() > timerData + maxTimeoutMs)) {
|
||||
return intMfSniffSend();
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// internal sending function. not a RAMFUNC.
|
||||
|
@ -183,5 +183,5 @@ bool intMfSniffSend() {
|
|||
LED_B_OFF();
|
||||
|
||||
clear_trace();
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,6 @@ int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockN
|
|||
fast_prand();
|
||||
byte_t nr[4];
|
||||
num_to_bytes(prand(), 4, nr);
|
||||
//byte_t nr[4] = {0x01, 0x01, 0x01, 0x01};
|
||||
|
||||
uint32_t nt, ntpp; // Supplied tag nonce
|
||||
|
||||
|
@ -238,7 +237,7 @@ int mifare_ul_ev1_auth(uint8_t *keybytes, uint8_t *pack){
|
|||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED)
|
||||
Dbprintf("EV1 Auth : %02x%02x%02x%02x", key[0], key[1], key[2], key[3]);
|
||||
|
||||
len = mifare_sendcmd(0x1B, key, sizeof(key), resp, respPar, NULL);
|
||||
len = mifare_sendcmd(MIFARE_ULEV1_AUTH, key, sizeof(key), resp, respPar, NULL);
|
||||
|
||||
if (len != 4) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Cmd Error: %02x %u", resp[0], len);
|
||||
|
@ -268,7 +267,7 @@ int mifare_ultra_auth(uint8_t *keybytes){
|
|||
uint8_t respPar[3] = {0,0,0};
|
||||
|
||||
// REQUEST AUTHENTICATION
|
||||
len = mifare_sendcmd_short(NULL, 1, 0x1A, 0x00, resp, respPar ,NULL);
|
||||
len = mifare_sendcmd_short(NULL, 1, MIFARE_ULC_AUTH_1, 0x00, resp, respPar ,NULL);
|
||||
if (len != 11) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Cmd Error: %02x", resp[0]);
|
||||
return 0;
|
||||
|
@ -300,7 +299,7 @@ int mifare_ultra_auth(uint8_t *keybytes){
|
|||
// encrypt out, in, length, key, iv
|
||||
tdes_2key_enc(rnd_ab, rnd_ab, sizeof(rnd_ab), key, enc_random_b);
|
||||
|
||||
len = mifare_sendcmd(0xAF, rnd_ab, sizeof(rnd_ab), resp, respPar, NULL);
|
||||
len = mifare_sendcmd(MIFARE_ULC_AUTH_2, rnd_ab, sizeof(rnd_ab), resp, respPar, NULL);
|
||||
if (len != 11) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Cmd Error: %02x", resp[0]);
|
||||
return 0;
|
||||
|
@ -343,7 +342,7 @@ int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData) {
|
|||
uint8_t receivedAnswer[MAX_FRAME_SIZE] = {0x00};
|
||||
uint8_t receivedAnswerPar[MAX_PARITY_SIZE] = {0x00};
|
||||
|
||||
len = mifare_sendcmd_short(NULL, 1, 0x30, blockNo, receivedAnswer, receivedAnswerPar, NULL);
|
||||
len = mifare_sendcmd_short(NULL, 1, ISO14443A_CMD_READBLOCK, blockNo, receivedAnswer, receivedAnswerPar, NULL);
|
||||
if (len == 1) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("Cmd Error: %02x", receivedAnswer[0]);
|
||||
return 1;
|
||||
|
@ -376,7 +375,7 @@ int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t bl
|
|||
uint8_t receivedAnswerPar[MAX_MIFARE_PARITY_SIZE] = {0x00};
|
||||
|
||||
// command MIFARE_CLASSIC_WRITEBLOCK
|
||||
len = mifare_sendcmd_short(pcs, 1, 0xA0, blockNo, receivedAnswer, receivedAnswerPar, NULL);
|
||||
len = mifare_sendcmd_short(pcs, 1, ISO14443A_CMD_WRITEBLOCK, blockNo, receivedAnswer, receivedAnswerPar, NULL);
|
||||
|
||||
if ((len != 1) || (receivedAnswer[0] != 0x0A)) { // 0x0a - ACK
|
||||
if (MF_DBGLEVEL >= 1) Dbprintf("Cmd Error: %02x", receivedAnswer[0]);
|
||||
|
@ -418,7 +417,7 @@ int mifare_ultra_writeblock_compat(uint8_t blockNo, uint8_t *blockData) {
|
|||
uint8_t receivedAnswer[MAX_FRAME_SIZE];
|
||||
uint8_t receivedAnswerPar[MAX_PARITY_SIZE];
|
||||
|
||||
len = mifare_sendcmd_short(NULL, true, 0xA0, blockNo, receivedAnswer, receivedAnswerPar, NULL);
|
||||
len = mifare_sendcmd_short(NULL, true, ISO14443A_CMD_WRITEBLOCK, blockNo, receivedAnswer, receivedAnswerPar, NULL);
|
||||
|
||||
if ((len != 1) || (receivedAnswer[0] != 0x0A)) { // 0x0a - ACK
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR)
|
||||
|
@ -462,7 +461,7 @@ int mifare_ultra_writeblock(uint8_t blockNo, uint8_t *blockData) {
|
|||
}
|
||||
int mifare_classic_halt_ex(struct Crypto1State *pcs) {
|
||||
uint8_t receivedAnswer[4] = {0x00, 0x00, 0x00, 0x00};
|
||||
uint16_t len = mifare_sendcmd_short(pcs, (pcs == NULL) ? CRYPT_NONE : CRYPT_ALL, 0x50, 0x00, receivedAnswer, NULL, NULL);
|
||||
uint16_t len = mifare_sendcmd_short(pcs, (pcs == NULL) ? CRYPT_NONE : CRYPT_ALL, ISO14443A_CMD_HALT, 0x00, receivedAnswer, NULL, NULL);
|
||||
if (len != 0) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("halt warning. response len: %x", len);
|
||||
return 1;
|
||||
|
@ -476,9 +475,9 @@ int mifare_classic_halt(struct Crypto1State *pcs, uint32_t uid) {
|
|||
int mifare_ultra_halt() {
|
||||
uint16_t len = 0;
|
||||
uint8_t receivedAnswer[4] = {0x00, 0x00, 0x00, 0x00};
|
||||
len = mifare_sendcmd_short(NULL, CRYPT_NONE, 0x50, 0x00, receivedAnswer, NULL, NULL);
|
||||
len = mifare_sendcmd_short(NULL, CRYPT_NONE, ISO14443A_CMD_HALT, 0x00, receivedAnswer, NULL, NULL);
|
||||
if (len != 0) {
|
||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) Dbprintf("halt error. response len: %x", len);
|
||||
if (MF_DBGLEVEL >= MF_DBG_EXTENDED) Dbprintf("halt warning. response len: %x", len);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -623,7 +622,7 @@ int mifare_desfire_des_auth1(uint32_t uid, uint8_t *blockData){
|
|||
|
||||
int len;
|
||||
// load key, keynumber
|
||||
uint8_t data[2]={0x0a, 0x00};
|
||||
uint8_t data[2]={MFDES_AUTHENTICATE, 0x00};
|
||||
uint8_t receivedAnswer[MAX_FRAME_SIZE] = {0x00};
|
||||
uint8_t receivedAnswerPar[MAX_PARITY_SIZE] = {0x00};
|
||||
|
||||
|
@ -650,8 +649,7 @@ int mifare_desfire_des_auth1(uint32_t uid, uint8_t *blockData){
|
|||
int mifare_desfire_des_auth2(uint32_t uid, uint8_t *key, uint8_t *blockData){
|
||||
|
||||
int len;
|
||||
uint8_t data[17] = {0x00};
|
||||
data[0] = 0xAF;
|
||||
uint8_t data[17] = {MFDES_AUTHENTICATION_FRAME};
|
||||
memcpy(data+1,key,16);
|
||||
|
||||
uint8_t receivedAnswer[MAX_FRAME_SIZE] = {0x00};
|
||||
|
|
|
@ -42,10 +42,6 @@ typedef long long quad_t;
|
|||
typedef unsigned long u_long;
|
||||
typedef unsigned short u_short;
|
||||
typedef int ssize_t;
|
||||
/*
|
||||
typedef uint32_t uintmax_t;
|
||||
typedef int32_t intmax_t;
|
||||
*/
|
||||
|
||||
#define NBBY 8 /* number of bits in a byte */
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
void DbpString(char *str) {
|
||||
byte_t len = 0;
|
||||
while (str[len] != 0x00)
|
||||
++len;
|
||||
len++;
|
||||
|
||||
cmd_send(CMD_DEBUG_PRINT_STRING,len,0,0,(byte_t*)str,len);
|
||||
}
|
||||
|
|
|
@ -465,7 +465,7 @@ static int l_reveng_RunModel(lua_State *L){
|
|||
|
||||
static int l_hardnested(lua_State *L){
|
||||
|
||||
bool haveTarget = TRUE;
|
||||
bool haveTarget = true;
|
||||
size_t size;
|
||||
const char *p_blockno = luaL_checklstring(L, 1, &size);
|
||||
if(size != 2) return returnToLuaWithError(L,"Wrong size of blockNo, got %d bytes, expected 2", (int) size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue