make style

This commit is contained in:
iceman1001
2022-10-16 17:56:12 +02:00
parent 2d25716704
commit 71f96ba1e7
12 changed files with 1184 additions and 841 deletions
+2 -2
View File
@@ -2182,7 +2182,7 @@ static void PacketReceived(PacketCommandNG *packet) {
uint8_t *buff = BigBuf_malloc(size);
if (buff == NULL) {
if (g_dbglevel >= DBG_DEBUG) Dbprintf ("Could not allocate buffer");
if (g_dbglevel >= DBG_DEBUG) Dbprintf("Could not allocate buffer");
// Trigger a finish downloading signal with an PM3_EMALLOC
reply_ng(CMD_SPIFFS_DOWNLOAD, PM3_EMALLOC, NULL, 0);
} else {
@@ -2199,7 +2199,7 @@ static void PacketReceived(PacketCommandNG *packet) {
}
// Trigger a finish downloading signal with an ACK frame
reply_ng(CMD_SPIFFS_DOWNLOAD, PM3_SUCCESS, NULL, 0);
BigBuf_free ();
BigBuf_free();
}
LED_B_OFF();
break;
+1 -1
View File
@@ -452,7 +452,7 @@ bool Flash_WipeMemoryPage(uint8_t page) {
FlashStop();
// let spiffs check and update its info post flash erase
rdv40_spiffs_check ();
rdv40_spiffs_check();
return true;
}
// Wipes flash memory completely, fills with 0xFF
+35 -35
View File
@@ -102,7 +102,7 @@ static s32_t rdv40_spiffs_llerase(u32_t addr, u32_t size) {
FlashStop();
// iceman: SPIFFS_OK expands to 0, erased is bool from Flash_Erase4k, which returns TRUE if ok.
// so this return logic looks wrong.
// so this return logic looks wrong.
return (SPIFFS_OK == erased);
}
@@ -152,15 +152,15 @@ int rdv40_spiffs_mount(void) {
// int ret = SPIFFS_mount(&fs, &cfg, spiffs_work_buf, spiffs_fds,
// sizeof(spiffs_fds), 0, 0, 0); cached version, experimental
int ret = SPIFFS_mount(
&fs,
&cfg,
spiffs_work_buf,
spiffs_fds,
sizeof(spiffs_fds),
spiffs_cache_buf,
sizeof(spiffs_cache_buf),
0
);
&fs,
&cfg,
spiffs_work_buf,
spiffs_fds,
sizeof(spiffs_fds),
spiffs_cache_buf,
sizeof(spiffs_cache_buf),
0
);
if (ret == SPIFFS_OK) {
RDV40_SPIFFS_MOUNT_STATUS = RDV40_SPIFFS_MOUNTED;
@@ -437,23 +437,23 @@ int rdv40_spiffs_lazy_mount_rollback(int changed) {
int rdv40_spiffs_write(const char *filename, uint8_t *src, uint32_t size, RDV40SpiFFSSafetyLevel level) {
RDV40_SPIFFS_SAFE_FUNCTION(
uint32_t idx;
if (size <= SPIFFS_WRITE_CHUNK_SIZE) {
// write small file
write_to_spiffs(filename, src, size);
size = 0;
} else { //
// write first SPIFFS_WRITE_CHUNK_SIZE bytes
// need to write the first chuck of data, then append
write_to_spiffs(filename, src, SPIFFS_WRITE_CHUNK_SIZE);
}
// append remaing SPIFFS_WRITE_CHUNK_SIZE byte chuncks
for (idx = 1; idx < (size / SPIFFS_WRITE_CHUNK_SIZE); idx++) {
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], SPIFFS_WRITE_CHUNK_SIZE);
}
// append remaing bytes
if (((int64_t)size - (SPIFFS_WRITE_CHUNK_SIZE * idx)) > 0) {
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], size - (SPIFFS_WRITE_CHUNK_SIZE * idx));
}
if (size <= SPIFFS_WRITE_CHUNK_SIZE) {
// write small file
write_to_spiffs(filename, src, size);
size = 0;
} else { //
// write first SPIFFS_WRITE_CHUNK_SIZE bytes
// need to write the first chuck of data, then append
write_to_spiffs(filename, src, SPIFFS_WRITE_CHUNK_SIZE);
}
// append remaing SPIFFS_WRITE_CHUNK_SIZE byte chuncks
for (idx = 1; idx < (size / SPIFFS_WRITE_CHUNK_SIZE); idx++) {
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], SPIFFS_WRITE_CHUNK_SIZE);
}
// append remaing bytes
if (((int64_t)size - (SPIFFS_WRITE_CHUNK_SIZE * idx)) > 0) {
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], size - (SPIFFS_WRITE_CHUNK_SIZE * idx));
}
)
}
@@ -461,13 +461,13 @@ int rdv40_spiffs_append(const char *filename, uint8_t *src, uint32_t size, RDV40
RDV40_SPIFFS_SAFE_FUNCTION(
uint32_t idx;
// Append any SPIFFS_WRITE_CHUNK_SIZE byte chunks
for (idx = 0; idx < (size/SPIFFS_WRITE_CHUNK_SIZE); idx++) {
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], SPIFFS_WRITE_CHUNK_SIZE);
}
// Append remain bytes
if (((int64_t)size - (SPIFFS_WRITE_CHUNK_SIZE * idx)) > 0) {
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], size - (SPIFFS_WRITE_CHUNK_SIZE * idx));
}
for (idx = 0; idx < (size / SPIFFS_WRITE_CHUNK_SIZE); idx++) {
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], SPIFFS_WRITE_CHUNK_SIZE);
}
// Append remain bytes
if (((int64_t)size - (SPIFFS_WRITE_CHUNK_SIZE * idx)) > 0) {
append_to_spiffs(filename, &src[SPIFFS_WRITE_CHUNK_SIZE * idx], size - (SPIFFS_WRITE_CHUNK_SIZE * idx));
}
)
}
@@ -547,7 +547,7 @@ int rdv40_spiffs_read_as_symlink(char *filename, uint8_t *dst, uint32_t size, RD
read_from_spiffs((char *)linkdest, (uint8_t *)dst, size);
)
}
}
// BEWARE ! This function is DESTRUCTIVE as it will UPDATE an existing symlink
// Since it creates a .lnk extension file it may be minor to mistake the order of arguments
+2 -2
View File
@@ -25,8 +25,8 @@ extern "C" {
#include "spiffs_config.h"
typedef enum spiffs_safety_level {
RDV40_SPIFFS_SAFETY_NORMAL,
RDV40_SPIFFS_SAFETY_LAZY,
RDV40_SPIFFS_SAFETY_NORMAL,
RDV40_SPIFFS_SAFETY_LAZY,
RDV40_SPIFFS_SAFETY_SAFE
} RDV40SpiFFSSafetyLevel;
+1 -1
View File
@@ -2770,7 +2770,7 @@ static int try_detect_modulation(void) {
#define LF_NUM_OF_TESTS 6
lf_modulation_t tests[LF_NUM_OF_TESTS];
for (int i=0; i< ARRAYLEN(tests); i++) {
for (int i = 0; i < ARRAYLEN(tests); i++) {
memset(&tests[i], 0, sizeof(lf_modulation_t));
}
+12 -11
View File
@@ -789,8 +789,8 @@ static void print_ct_blocks(uint8_t *data, size_t len) {
static void print_sr_blocks(uint8_t *data, size_t len, const uint8_t *uid) {
size_t blocks = (len / ST25TB_SR_BLOCK_SIZE) -1 ;
uint8_t * systemblock = data + blocks * ST25TB_SR_BLOCK_SIZE ;
size_t blocks = (len / ST25TB_SR_BLOCK_SIZE) - 1 ;
uint8_t *systemblock = data + blocks * ST25TB_SR_BLOCK_SIZE ;
uint8_t chipid = get_st_chipid(uid);
PrintAndLogEx(SUCCESS, _GREEN_("%s") " tag", get_st_chip_model(chipid));
@@ -1486,7 +1486,7 @@ static int CmdHF14BDump(const char *Cmd) {
// last read
if (blocknum == 0xFF) {
// we reserved space for this block after 0x0F and 0x7F, ie 0x10, 0x80
memcpy(data + ((lastblock+1) * ST25TB_SR_BLOCK_SIZE), recv, ST25TB_SR_BLOCK_SIZE);
memcpy(data + ((lastblock + 1) * ST25TB_SR_BLOCK_SIZE), recv, ST25TB_SR_BLOCK_SIZE);
break;
}
memcpy(data + (blocknum * ST25TB_SR_BLOCK_SIZE), recv, ST25TB_SR_BLOCK_SIZE);
@@ -2105,25 +2105,26 @@ out:
/* extract uid from filename
* filename must match '^hf-14b-[0-9A-F]{16}'
*/
uint8_t * get_uid_from_filename(const char *filename) {
*/
uint8_t *get_uid_from_filename(const char *filename) {
static uint8_t uid[8] ;
memset(uid, 0, 8) ;
char uidinhex[17] ;
if (strlen(filename)<23 || strncmp(filename, "hf-14b-", 7)) {
if (strlen(filename) < 23 || strncmp(filename, "hf-14b-", 7)) {
PrintAndLogEx(ERR, "can't get uid from filename '%s'. Expected format is hf-14b-<uid>...", filename);
return uid ;
}
// extract uid part from filename
strncpy(uidinhex, filename+7, 16) ; uidinhex[16]='\0' ;
int len=hex_to_bytes(uidinhex, uid, 8);
// extract uid part from filename
strncpy(uidinhex, filename + 7, 16) ;
uidinhex[16] = '\0' ;
int len = hex_to_bytes(uidinhex, uid, 8);
if (len == 8)
return SwapEndian64(uid , 8, 8);
return SwapEndian64(uid, 8, 8);
else {
PrintAndLogEx(ERR, "get_uid_from_filename failed: hex_to_bytes returned %d", len);
memset(uid, 0, 8);
}
return uid ;
return uid ;
}
static int CmdHF14BView(const char *Cmd) {
+1 -1
View File
@@ -25,7 +25,7 @@
int CmdHF14B(const char *Cmd);
int CmdHF14BNdefRead(const char *Cmd);
uint8_t * get_uid_from_filename(const char *filename);
uint8_t *get_uid_from_filename(const char *filename);
int exchange_14b_apdu(uint8_t *datain, int datainlen, bool activate_field, bool leave_signal_on, uint8_t *dataout, int maxdataoutlen, int *dataoutlen, int user_timeout);
int select_card_14443b_4(bool disconnect, iso14b_card_select_t *card);
+2 -2
View File
@@ -1147,7 +1147,7 @@ static int CmdHF15ESave(const char *Cmd) {
static void print_hrule(int blocksize) {
char dashes[] = "------------------------------------------------------------";
PrintAndLogEx(INFO, "-----+%.*s-+-%.*s-", 3*blocksize, dashes, blocksize, dashes);
PrintAndLogEx(INFO, "-----+%.*s-+-%.*s-", 3 * blocksize, dashes, blocksize, dashes);
}
static void print_blocks_15693(uint8_t *data, uint16_t bytes, int blocksize) {
@@ -1155,7 +1155,7 @@ static void print_blocks_15693(uint8_t *data, uint16_t bytes, int blocksize) {
PrintAndLogEx(NORMAL, "");
print_hrule(blocksize);
char spaces[] = " ";
PrintAndLogEx(INFO, " blk | data %.*s| ascii", MAX(0, 3*blocksize - 5), spaces);
PrintAndLogEx(INFO, " blk | data %.*s| ascii", MAX(0, 3 * blocksize - 5), spaces);
print_hrule(blocksize);
for (int i = 0; i < blocks; i++) {
PrintAndLogEx(INFO, "%4d | %s ", i, sprint_hex_ascii(data + (i * blocksize), blocksize));
+11 -11
View File
@@ -5706,7 +5706,7 @@ int CmdHFMFNDEFFormat(const char *Cmd) {
"hf mf ndefformat --2k --> MIFARE 2k\n"
"hf mf ndefformat --4k --> MIFARE 4k\n"
"hf mf ndefformat --keys hf-mf-066C8B78-key.bin --> MIFARE 1k with keys from specified file\n"
);
);
void *argtable[] = {
arg_param_begin,
@@ -5774,9 +5774,9 @@ int CmdHFMFNDEFFormat(const char *Cmd) {
// init keys to default key
uint8_t keyA[MIFARE_4K_MAXSECTOR][MFKEY_SIZE];
uint8_t keyB[MIFARE_4K_MAXSECTOR][MFKEY_SIZE];
for (uint8_t i = 0; i < MIFARE_4K_MAXSECTOR; i++ ) {
uint8_t keyB[MIFARE_4K_MAXSECTOR][MFKEY_SIZE];
for (uint8_t i = 0; i < MIFARE_4K_MAXSECTOR; i++) {
memcpy(keyA[i], g_mifare_default_key, sizeof(g_mifare_default_key));
memcpy(keyB[i], g_mifare_default_key, sizeof(g_mifare_default_key));
}
@@ -5785,15 +5785,15 @@ int CmdHFMFNDEFFormat(const char *Cmd) {
uint64_t key64 = 0;
// check if we can authenticate to sector
if (mfCheckKeys(0, MF_KEY_A, true, 1, (uint8_t*)g_mifare_mad_key, &key64) == PM3_SUCCESS) {
if (mfCheckKeys(0, MF_KEY_A, true, 1, (uint8_t *)g_mifare_mad_key, &key64) == PM3_SUCCESS) {
// if used, assume KEY A is MAD/NDEF set.
memcpy(keyA[0], g_mifare_mad_key, sizeof(g_mifare_mad_key));
memcpy(keyB[0], g_mifare_mad_key_b, sizeof(g_mifare_mad_key_b));
for (uint8_t i = 1; i < MIFARE_4K_MAXSECTOR; i++ ) {
memcpy(keyA[i], g_mifare_ndef_key, sizeof(g_mifare_ndef_key));
for (uint8_t i = 1; i < MIFARE_4K_MAXSECTOR; i++) {
memcpy(keyA[i], g_mifare_ndef_key, sizeof(g_mifare_ndef_key));
}
}
}
// Do we have a keyfile based from UID?
if (strlen(keyFilename) == 0) {
@@ -5850,7 +5850,7 @@ skipfile:
{ 0x03, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7, 0x7F, 0x07, 0x88, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
{ 0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7, 0x7F, 0x07, 0x88, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
};
// main loop
@@ -5860,7 +5860,7 @@ skipfile:
uint8_t b = (mfFirstBlockOfSector(i) + j);
uint8_t block[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
switch(b) {
switch (b) {
case 0:
continue;
case 1:
@@ -5873,7 +5873,7 @@ skipfile:
memcpy(block, firstblocks[b], MFBLOCK_SIZE);
break;
default: {
if (mfIsSectorTrailer(j) ) {
if (mfIsSectorTrailer(j)) {
// ST NDEF
memcpy(block, firstblocks[7], MFBLOCK_SIZE);
}
File diff suppressed because it is too large Load Diff
+363 -62
View File
File diff suppressed because it is too large Load Diff
+31 -7
View File
@@ -230,6 +230,9 @@ Check column "offline" for their availability.
|`hf 15 reader `|N |`Act like an ISO-15693 reader`
|`hf 15 restore `|N |`Restore from file to all memory pages of an ISO-15693 tag`
|`hf 15 samples `|N |`Acquire samples as reader (enables carrier, sends inquiry)`
|`hf 15 eload `|N |`Load image file into emulator to be used by 'sim' command`
|`hf 15 esave `|N |`Save emulator memory into image file`
|`hf 15 eview `|N |`View emulator memory`
|`hf 15 sim `|N |`Fake an ISO-15693 tag`
|`hf 15 slixdisable `|N |`Disable privacy mode on SLIX ISO-15693 tag`
|`hf 15 wrbl `|N |`Write a block`
@@ -326,6 +329,20 @@ Check column "offline" for their availability.
|`hf fido assert `|N |`FIDO2 GetAssertion command.`
### hf fudan
{ Fudan RFIDs... }
|command |offline |description
|------- |------- |-----------
|`hf fudan help `|Y |`This help`
|`hf fudan reader `|N |`Act like a fudan reader`
|`hf fudan dump `|N |`Dump FUDAN tag to binary file`
|`hf fudan rdbl `|N |`Read a fudan tag`
|`hf fudan view `|Y |`Display content from tag dump file`
|`hf fudan wrbl `|N |`Write a fudan tag`
### hf gallagher
{ Gallagher DESFire RFIDs... }
@@ -430,11 +447,12 @@ Check column "offline" for their availability.
|------- |------- |-----------
|`hf lto help `|Y |`This help`
|`hf lto dump `|N |`Dump LTO-CM tag to file`
|`hf lto restore `|N |`Restore dump file to LTO-CM tag`
|`hf lto info `|N |`Tag information`
|`hf lto rdbl `|N |`Read block`
|`hf lto wrbl `|N |`Write block`
|`hf lto list `|Y |`List LTO-CM history`
|`hf lto rdbl `|N |`Read block`
|`hf lto reader `|N |`Act like a LTO-CM reader`
|`hf lto restore `|N |`Restore dump file to LTO-CM tag`
|`hf lto wrbl `|N |`Write block`
### hf mf
@@ -458,12 +476,11 @@ Check column "offline" for their availability.
|`hf mf auth4 `|N |`ISO14443-4 AES authentication`
|`hf mf acl `|Y |`Decode and print MIFARE Classic access rights bytes`
|`hf mf dump `|N |`Dump MIFARE Classic tag to binary file`
|`hf mf mad `|N |`Checks and prints MAD`
|`hf mf ndefread `|N |`Prints NDEF records from card`
|`hf mf mad `|Y |`Checks and prints MAD`
|`hf mf personalize `|N |`Personalize UID (MIFARE Classic EV1 only)`
|`hf mf rdbl `|N |`Read MIFARE Classic block`
|`hf mf rdsc `|N |`Read MIFARE Classic sector`
|`hf mf restore `|N |`Restore MIFARE Classic binary file to BLANK tag`
|`hf mf restore `|N |`Restore MIFARE Classic binary file to tag`
|`hf mf setmod `|N |`Set MIFARE Classic EV1 load modulation strength`
|`hf mf value `|Y |`Value blocks`
|`hf mf view `|Y |`Display content from tag dump file`
@@ -491,6 +508,8 @@ Check column "offline" for their availability.
|`hf mf gen3blk `|N |`Overwrite manufacturer block`
|`hf mf gen3freeze `|N |`Perma lock UID changes. irreversible`
|`hf mf gview `|N |`View card`
|`hf mf ndefformat `|N |`Format MIFARE Classic Tag as NFC Tag`
|`hf mf ndefread `|N |`Prints NDEF records from card`
### hf mfp
@@ -642,12 +661,16 @@ Check column "offline" for their availability.
|command |offline |description
|------- |------- |-----------
|`hf topaz help `|Y |`This help`
|`hf topaz dump `|N |`Dump TOPAZ family tag to file`
|`hf topaz list `|Y |`List Topaz history`
|`hf topaz info `|N |`Tag information`
|`hf topaz reader `|N |`Act like a Topaz reader`
|`hf topaz sim `|N |`<UID> -- Simulate Topaz tag`
|`hf topaz sim `|N |`Simulate Topaz tag`
|`hf topaz sniff `|N |`Sniff Topaz reader-tag communication`
|`hf topaz raw `|N |`Send raw hex data to tag`
|`hf topaz rdbl `|N |`Read block`
|`hf topaz view `|Y |`Display content from tag dump file`
|`hf topaz wrbl `|N |`Write block`
### hf texkom
@@ -1282,6 +1305,7 @@ Check column "offline" for their availability.
|command |offline |description
|------- |------- |-----------
|`nfc mf cread `|N |`read NFC Type MIFARE Classic Tag`
|`nfc mf cformat `|N |`format MIFARE Classic Tag as NFC Tag`
|`nfc mf pread `|N |`read NFC Type MIFARE Plus Tag`
|`nfc mf help `|Y |`This help`