mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-02-22 07:04:13 +08:00
make style
This commit is contained in:
parent
5787f07617
commit
f69739da79
16 changed files with 62 additions and 63 deletions
|
@ -19,7 +19,7 @@ extern uint8_t _stack_start, __bss_end__;
|
|||
// BigBuf is the large multi-purpose buffer, typically used to hold A/D samples or traces.
|
||||
// Also used to hold various smaller buffers and the Mifare Emulator Memory.
|
||||
// We know that bss is aligned to 4 bytes.
|
||||
static uint8_t* BigBuf = &__bss_end__;
|
||||
static uint8_t *BigBuf = &__bss_end__;
|
||||
|
||||
/* BigBuf memory layout:
|
||||
Pointer to highest available memory: BigBuf_hi
|
||||
|
|
|
@ -2080,10 +2080,10 @@ void __attribute__((noreturn)) AppMain(void) {
|
|||
SpinDelay(100);
|
||||
BigBuf_initialize();
|
||||
|
||||
for (uint32_t * p = &_stack_start; p < (uint32_t *)((uintptr_t)&_stack_end - 0x200); ++p) {
|
||||
for (uint32_t *p = &_stack_start; p < (uint32_t *)((uintptr_t)&_stack_end - 0x200); ++p) {
|
||||
*p = 0xdeadbeef;
|
||||
}
|
||||
|
||||
|
||||
if (common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
|
||||
/* Initialize common area */
|
||||
memset(&common_area, 0, sizeof(common_area));
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "cmd.h"
|
||||
|
||||
static void RAMFUNC optimizedSniff(uint16_t *dest, uint16_t dsize) {
|
||||
for (;dsize > 0; dsize -= sizeof(dsize)) {
|
||||
for (; dsize > 0; dsize -= sizeof(dsize)) {
|
||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
||||
*dest = (uint16_t)(AT91C_BASE_SSC->SSC_RHR);
|
||||
dest++;
|
||||
|
@ -30,7 +30,7 @@ static void RAMFUNC optimizedSniff(uint16_t *dest, uint16_t dsize) {
|
|||
|
||||
int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
|
||||
BigBuf_free();
|
||||
BigBuf_Clear_ext(false);
|
||||
BigBuf_Clear_ext(false);
|
||||
|
||||
Dbprintf("Skipping first %d sample pairs, Skipping %d triggers", samplesToSkip, triggersToSkip);
|
||||
|
||||
|
@ -52,10 +52,10 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
|
|||
*len = (BigBuf_max_traceLen() & 0xFFFE);
|
||||
uint8_t *mem = BigBuf_malloc(*len);
|
||||
|
||||
int trigger_cnt = 0;
|
||||
int trigger_cnt = 0;
|
||||
uint16_t r = 0, interval = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
bool pressed = false;
|
||||
while (pressed == false) {
|
||||
WDT_HIT();
|
||||
|
@ -95,7 +95,7 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
|
|||
waitcount--;
|
||||
}
|
||||
|
||||
optimizedSniff((uint16_t*)mem, (*len) >> 2);
|
||||
optimizedSniff((uint16_t *)mem, (*len) >> 2);
|
||||
|
||||
Dbprintf("Trigger kicked in (%d >= 180)", r);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ static void __attribute__((optimize("O0"))) I2CSpinDelayClk(uint16_t delay) {
|
|||
#define I2C_DELAY_2CLK I2CSpinDelayClk(2)
|
||||
#define I2C_DELAY_XCLK(x) I2CSpinDelayClk((x))
|
||||
|
||||
#define I2C_DELAY_100us I2CSpinDelayClk( 100 / 3)
|
||||
#define I2C_DELAY_100us I2CSpinDelayClk( 100 / 3)
|
||||
#define I2C_DELAY_600us I2CSpinDelayClk( 600 / 3)
|
||||
#define I2C_DELAY_10ms I2CSpinDelayClk( 10 * 1000 / 3 )
|
||||
#define I2C_DELAY_30ms I2CSpinDelayClk( 30 * 1000 / 3 )
|
||||
|
@ -440,7 +440,7 @@ int16_t I2C_BufferRead(uint8_t *data, uint8_t len, uint8_t device_cmd, uint8_t d
|
|||
|
||||
// extra wait 500us (514us measured)
|
||||
// 200us (xx measured)
|
||||
// WaitUS(600);
|
||||
// WaitUS(600);
|
||||
I2C_DELAY_600us;
|
||||
|
||||
bool bBreak = true;
|
||||
|
|
|
@ -988,7 +988,7 @@ bool SimulateIso14443aInit(int tagType, int flags, uint8_t *data, tag_response_i
|
|||
counters[i] = le24toh(mfu_header->counter_tearing[i]);
|
||||
|
||||
if (mfu_header->counter_tearing[i][3] != 0x00) {
|
||||
tearings[i] = mfu_header->counter_tearing[i][3];
|
||||
tearings[i] = mfu_header->counter_tearing[i][3];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ int CmdHFTune(const char *Cmd) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
// Collects pars of u8,
|
||||
// Collects pars of u8,
|
||||
// uses 16bit transfers from FPGA for speed
|
||||
// Takes all available bigbuff memory
|
||||
// data sample to download? Not sure what we can do with the data.
|
||||
|
@ -258,7 +258,7 @@ int CmdHFSniff(const char *Cmd) {
|
|||
params.triggersToSkip = param_get32ex(Cmd, 1, 0, 10);
|
||||
|
||||
clearCommandBuffer();
|
||||
SendCommandNG(CMD_HF_SNIFF, (uint8_t*)¶ms, sizeof(params));
|
||||
SendCommandNG(CMD_HF_SNIFF, (uint8_t *)¶ms, sizeof(params));
|
||||
|
||||
for (;;) {
|
||||
|
||||
|
@ -279,10 +279,10 @@ int CmdHFSniff(const char *Cmd) {
|
|||
PrintAndLogEx(INFO, "HF sniff len %u bytes", len);
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data plot") "` to view");
|
||||
PrintAndLogEx(HINT, "Use `" _YELLOW_("data save") "` to save");
|
||||
|
||||
// download bigbuf_malloced..
|
||||
// it reservs mem from the higher range. ie we can't start from beginning idx 0.
|
||||
// but from
|
||||
|
||||
// download bigbuf_malloced..
|
||||
// it reservs mem from the higher range. ie we can't start from beginning idx 0.
|
||||
// but from
|
||||
uint32_t start = pm3_capabilities.bigbuf_size - len;
|
||||
int res = getSamplesEx(start, start + len, false);
|
||||
if (res != PM3_SUCCESS) {
|
||||
|
|
|
@ -4545,7 +4545,7 @@ static int CmdHF14AMfMAD(const char *Cmd) {
|
|||
// copy default NDEF key
|
||||
uint8_t akey[6] = {0};
|
||||
memcpy(akey, g_mifare_ndef_key, 6);
|
||||
|
||||
|
||||
// user specified key
|
||||
if (keylen == 6) {
|
||||
memcpy(akey, key, 6);
|
||||
|
@ -4584,7 +4584,7 @@ static int CmdHF14AMfMAD(const char *Cmd) {
|
|||
|
||||
for (int i = 0; i < madlen; i++) {
|
||||
if (aaid == mad[i]) {
|
||||
|
||||
|
||||
uint8_t vsector[16 * 4] = {0};
|
||||
if (mfReadSector(i + 1, keyB ? MF_KEY_B : MF_KEY_A, akey, vsector)) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
@ -4611,7 +4611,7 @@ static int CmdHF14AMfMAD(const char *Cmd) {
|
|||
for (int i = 0; i < 4; i ++)
|
||||
PrintAndLogEx(INFO, "[%d] %s", i, sprint_hex(§or0[i * 16], 16));
|
||||
}
|
||||
|
||||
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -4669,7 +4669,7 @@ static int CmdHFMFNDEF(const char *Cmd) {
|
|||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mf ndef -k `") " with your custom key");
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
||||
bool haveMAD2 = false;
|
||||
int res = MADCheck(sector0, NULL, verbose, &haveMAD2);
|
||||
if (res != PM3_SUCCESS) {
|
||||
|
|
|
@ -1400,7 +1400,7 @@ static int CmdHFMFPMAD(const char *Cmd) {
|
|||
|
||||
for (int i = 0; i < madlen; i++) {
|
||||
if (aaid == mad[i]) {
|
||||
|
||||
|
||||
uint8_t vsector[16 * 4] = {0};
|
||||
if (mfReadSector(i + 1, keyB ? MF_KEY_B : MF_KEY_A, akey, vsector)) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
|
@ -1472,7 +1472,7 @@ static int CmdHFMFPNDEF(const char *Cmd) {
|
|||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "reading MAD v1 sector");
|
||||
|
||||
|
||||
if (mfpReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifarep_mad_key, sector0, verbose)) {
|
||||
PrintAndLogEx(ERR, "error, read sector 0. card don't have MAD or don't have MAD on default keys");
|
||||
PrintAndLogEx(HINT, "Try " _YELLOW_("`hf mfp ndef -k `") " with your custom key");
|
||||
|
@ -1487,7 +1487,7 @@ static int CmdHFMFPNDEF(const char *Cmd) {
|
|||
}
|
||||
|
||||
if (haveMAD2) {
|
||||
|
||||
|
||||
if (verbose)
|
||||
PrintAndLogEx(INFO, "reading MAD v2 sector");
|
||||
|
||||
|
|
|
@ -1014,7 +1014,7 @@ int EM4x50Read(const char *Cmd, bool verbose) {
|
|||
PrintAndLogEx(INFO, "%03d | %08x", block, Code[block]);
|
||||
}
|
||||
PrintAndLogEx(INFO, "----+--------------");
|
||||
PrintAndLogEx( (AllPTest) ? SUCCESS : WARNING, "Parities checks | %s", (AllPTest) ? _GREEN_("Passed") : _RED_("Fail"));
|
||||
PrintAndLogEx((AllPTest) ? SUCCESS : WARNING, "Parities checks | %s", (AllPTest) ? _GREEN_("Passed") : _RED_("Fail"));
|
||||
|
||||
if (AllPTest == false) {
|
||||
PrintAndLogEx(HINT, "Try cleaning the read samples with " _YELLOW_("'data askedge'"));
|
||||
|
|
|
@ -36,8 +36,7 @@
|
|||
// Partly ripped from PyRun_SimpleFileExFlags
|
||||
// but does not terminate client on sys.exit
|
||||
// and print exit code only if != 0
|
||||
static int Pm3PyRun_SimpleFileNoExit(FILE *fp, const char *filename)
|
||||
{
|
||||
static int Pm3PyRun_SimpleFileNoExit(FILE *fp, const char *filename) {
|
||||
PyObject *m, *d, *v;
|
||||
int set_file_name = 0, ret = -1;
|
||||
m = PyImport_AddModule("__main__");
|
||||
|
@ -86,7 +85,7 @@ static int Pm3PyRun_SimpleFileNoExit(FILE *fp, const char *filename)
|
|||
}
|
||||
Py_DECREF(v);
|
||||
ret = 0;
|
||||
done:
|
||||
done:
|
||||
if (set_file_name && PyDict_DelItemString(d, "__file__"))
|
||||
PyErr_Clear();
|
||||
Py_XDECREF(m);
|
||||
|
|
|
@ -1455,7 +1455,7 @@ static int CmdEMVScan(const char *Cmd) {
|
|||
// current path + file name
|
||||
if (MergeJSON) {
|
||||
|
||||
root = json_load_file( (char*)filename, 0, &error);
|
||||
root = json_load_file((char *)filename, 0, &error);
|
||||
if (!root) {
|
||||
PrintAndLogEx(ERR, "Json error on line %d: %s", error.line, error.text);
|
||||
return PM3_EFILE;
|
||||
|
@ -1750,15 +1750,15 @@ static int CmdEMVScan(const char *Cmd) {
|
|||
|
||||
if (MergeJSON == false) {
|
||||
// create unique new name
|
||||
char *fname = newfilenamemcopy((char*)filename, ".json");
|
||||
char *fname = newfilenamemcopy((char *)filename, ".json");
|
||||
if (fname == NULL) {
|
||||
return PM3_EMALLOC;
|
||||
}
|
||||
strcpy((char*)filename, fname);
|
||||
strcpy((char *)filename, fname);
|
||||
free(fname);
|
||||
}
|
||||
|
||||
res = json_dump_file(root, (char*)filename, JSON_INDENT(2));
|
||||
res = json_dump_file(root, (char *)filename, JSON_INDENT(2));
|
||||
if (res) {
|
||||
PrintAndLogEx(ERR, "Can't save the file: %s", filename);
|
||||
return PM3_EFILE;
|
||||
|
|
|
@ -504,19 +504,19 @@ struct emv_pk *emv_pk_get_ca_pk(const unsigned char *rid, unsigned char idx) {
|
|||
bool isok = emv_pk_verify(pk);
|
||||
|
||||
PrintAndLogEx(INFO, "Verifying CA PK for %02hhx:%02hhx:%02hhx:%02hhx:%02hhx IDX %02hhx %zu bits. ( %s )",
|
||||
pk->rid[0],
|
||||
pk->rid[1],
|
||||
pk->rid[2],
|
||||
pk->rid[3],
|
||||
pk->rid[4],
|
||||
pk->index,
|
||||
pk->mlen * 8,
|
||||
(isok) ? _GREEN_("ok") : _RED_("failed")
|
||||
);
|
||||
pk->rid[0],
|
||||
pk->rid[1],
|
||||
pk->rid[2],
|
||||
pk->rid[3],
|
||||
pk->rid[4],
|
||||
pk->index,
|
||||
pk->mlen * 8,
|
||||
(isok) ? _GREEN_("ok") : _RED_("failed")
|
||||
);
|
||||
|
||||
if (isok) {
|
||||
return pk;
|
||||
}
|
||||
}
|
||||
|
||||
emv_pk_free(pk);
|
||||
return NULL;
|
||||
|
|
|
@ -1369,17 +1369,17 @@ static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose)
|
|||
}
|
||||
|
||||
static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
|
||||
/* For reference
|
||||
typedef struct {
|
||||
uint8_t version[8];
|
||||
uint8_t tbo[2];
|
||||
uint8_t tearing[3];
|
||||
uint8_t pack[2];
|
||||
uint8_t tbo1[1];
|
||||
uint8_t signature[32];
|
||||
uint8_t data[1024];
|
||||
} PACKED old_mfu_dump_t;
|
||||
*/
|
||||
/* For reference
|
||||
typedef struct {
|
||||
uint8_t version[8];
|
||||
uint8_t tbo[2];
|
||||
uint8_t tearing[3];
|
||||
uint8_t pack[2];
|
||||
uint8_t tbo1[1];
|
||||
uint8_t signature[32];
|
||||
uint8_t data[1024];
|
||||
} PACKED old_mfu_dump_t;
|
||||
*/
|
||||
|
||||
// convert old format
|
||||
old_mfu_dump_t *old_mfu_dump = (old_mfu_dump_t *)*dump;
|
||||
|
@ -1404,8 +1404,8 @@ typedef struct {
|
|||
|
||||
memcpy(mfu_dump->data, old_mfu_dump->data, sizeof(mfu_dump->data));
|
||||
mfu_dump->pages = old_data_len / 4 - 1;
|
||||
|
||||
// Add PACK to last block of memory.
|
||||
|
||||
// Add PACK to last block of memory.
|
||||
memcpy(mfu_dump->data + (mfu_dump->pages * 4 + MFU_DUMP_PREFIX_LENGTH), old_mfu_dump->pack, 2);
|
||||
|
||||
if (verbose) {
|
||||
|
|
|
@ -882,7 +882,7 @@ void mifare_cypher_blocks_chained(desfiretag_t tag, desfirekey_t key, uint8_t *i
|
|||
}
|
||||
|
||||
void desfire_crc32(const uint8_t *data, const size_t len, uint8_t *crc) {
|
||||
crc32_ex(data,len,crc);
|
||||
crc32_ex(data, len, crc);
|
||||
}
|
||||
|
||||
void desfire_crc32_append(uint8_t *data, const size_t len) {
|
||||
|
|
|
@ -173,7 +173,7 @@ int MADCheck(uint8_t *sector0, uint8_t *sector10, bool verbose, bool *haveMAD2)
|
|||
if (sector0 == NULL)
|
||||
return PM3_EINVARG;
|
||||
|
||||
uint8_t GPB = sector0[3 * 16 + 9];
|
||||
uint8_t GPB = sector0[3 * 16 + 9];
|
||||
if (verbose)
|
||||
PrintAndLogEx(SUCCESS, "%14s " _GREEN_("0x%02x"), "GPB", GPB);
|
||||
|
||||
|
@ -304,7 +304,7 @@ int MAD1DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose, bool *haveMA
|
|||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "---------------- " _CYAN_("Listing") " ----------------");
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, " 00 MAD v1");
|
||||
uint32_t prev_aid = 0xFFFFFFFF;
|
||||
for (int i = 1; i < 16; i++) {
|
||||
|
@ -326,10 +326,10 @@ int MAD1DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose, bool *haveMA
|
|||
|
||||
int MAD2DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose) {
|
||||
open_mad_file(&mad_known_aids, verbose);
|
||||
|
||||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "------------ " _CYAN_("MAD v2 details") " -------------");
|
||||
|
||||
|
||||
int res = madCRCCheck(sector, true, 2);
|
||||
if (verbose) {
|
||||
if (res == PM3_SUCCESS)
|
||||
|
@ -347,7 +347,7 @@ int MAD2DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose) {
|
|||
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "---------------- " _CYAN_("Listing") " ----------------");
|
||||
|
||||
|
||||
PrintAndLogEx(INFO, " 16 MAD v2");
|
||||
|
||||
uint32_t prev_aid = 0xFFFFFFFF;
|
||||
|
|
|
@ -1541,7 +1541,7 @@ static uint16_t cleanAskRawDemod(uint8_t *bits, size_t *size, int clk, int inver
|
|||
if ((pos > cl_2 - cl_4 - 1) && (pos <= clk + cl_4 + 1)) {
|
||||
bits[bitCnt++] = invert ^ 1;
|
||||
}
|
||||
|
||||
|
||||
// sample counts, like clock = 32.. it tries to find 32/4 = 8, 32/2 = 16
|
||||
for (size_t i = pos; i < *size; i++) {
|
||||
if (bits[i] >= high && waveHigh) {
|
||||
|
|
Loading…
Reference in a new issue