use more static and fix [-Wmissing-prototypes]

This commit is contained in:
Philippe Teuwen 2019-04-13 21:54:04 +02:00
commit 5c55664fc5
23 changed files with 223 additions and 218 deletions

View file

@ -137,7 +137,6 @@ CMDSRCS = crapto1/crapto1.c \
loclass/cipher.c \
loclass/cipherutils.c \
loclass/ikeys.c \
loclass/hash1_brute.c \
loclass/elite_crack.c \
loclass/fileutils.c \
whereami.c \

View file

@ -570,7 +570,7 @@ static int Cmdaskmandemod(const char *Cmd) {
//by marshmellow
//manchester decode
//stricktly take 10 and 01 and convert to 0 and 1
int Cmdmandecoderaw(const char *Cmd) {
static int Cmdmandecoderaw(const char *Cmd) {
size_t size = 0;
int high = 0, low = 0;
int i = 0, errCnt = 0, invert = 0, maxErr = 20;
@ -628,7 +628,7 @@ int Cmdmandecoderaw(const char *Cmd) {
* param invert invert output
* param masxErr maximum tolerated errors
*/
int CmdBiphaseDecodeRaw(const char *Cmd) {
static int CmdBiphaseDecodeRaw(const char *Cmd) {
size_t size = 0;
int offset = 0, invert = 0, maxErr = 20, errCnt = 0;
char cmdp = tolower(param_getchar(Cmd, 0));
@ -811,7 +811,7 @@ int AutoCorrelate(const int *in, int *out, size_t len, int window, bool SaveGrph
return retval;
}
int CmdAutoCorr(const char *Cmd) {
static int CmdAutoCorr(const char *Cmd) {
uint32_t window = 4000;
uint8_t cmdp = 0;
@ -846,7 +846,7 @@ int CmdAutoCorr(const char *Cmd) {
return AutoCorrelate(GraphBuffer, GraphBuffer, GraphTraceLen, window, updateGrph, true);
}
int CmdBitsamples(const char *Cmd) {
static int CmdBitsamples(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
int cnt = 0;
uint8_t got[12288];
@ -869,7 +869,7 @@ int CmdBitsamples(const char *Cmd) {
return 0;
}
int CmdBuffClear(const char *Cmd) {
static int CmdBuffClear(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_data_buffclear();
@ -880,7 +880,7 @@ int CmdBuffClear(const char *Cmd) {
return 0;
}
int CmdDec(const char *Cmd) {
static int CmdDec(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
for (int i = 0; i < (GraphTraceLen / 2); ++i)
GraphBuffer[i] = GraphBuffer[i * 2];
@ -896,7 +896,7 @@ int CmdDec(const char *Cmd) {
* @param Cmd
* @return
*/
int CmdUndec(const char *Cmd) {
static int CmdUndec(const char *Cmd) {
char cmdp = tolower(param_getchar(Cmd, 0));
if (cmdp == 'h') return usage_data_undecimate();
@ -921,7 +921,7 @@ int CmdUndec(const char *Cmd) {
//by marshmellow
//shift graph zero up or down based on input + or -
int CmdGraphShiftZero(const char *Cmd) {
static int CmdGraphShiftZero(const char *Cmd) {
int shift = 0, shiftedVal;
//set options from parameters entered with the command
sscanf(Cmd, "%i", &shift);
@ -1411,7 +1411,7 @@ static int CmdHexsamples(const char *Cmd) {
return 0;
}
int CmdHide(const char *Cmd) {
static int CmdHide(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
HideGraphWindow();
return 0;
@ -1432,13 +1432,13 @@ int CmdHpf(const char *Cmd) {
return 0;
}
bool _headBit(BitstreamOut *stream) {
static bool _headBit(BitstreamOut *stream) {
int bytepos = stream->position >> 3; // divide by 8
int bitpos = (stream->position++) & 7; // mask out 00000111
return (*(stream->buffer + bytepos) >> (7 - bitpos)) & 1;
}
uint8_t getByte(uint8_t bits_per_sample, BitstreamOut *b) {
static uint8_t getByte(uint8_t bits_per_sample, BitstreamOut *b) {
uint8_t val = 0;
for (int i = 0 ; i < bits_per_sample; i++)
val |= (_headBit(b) << (7 - i));

View file

@ -616,7 +616,7 @@ int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leav
return 0;
}
int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
static int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
UsbCommand resp;
frameLength = 0;

View file

@ -395,7 +395,7 @@ static void print_atqb_resp(uint8_t *data, uint8_t cid) {
}
// get SRx chip model (from UID) // from ST Microelectronics
char *get_ST_Chip_Model(uint8_t data) {
static char *get_ST_Chip_Model(uint8_t data) {
static char model[20];
char *retStr = model;
memset(model, 0, sizeof(model));
@ -430,51 +430,52 @@ char *get_ST_Chip_Model(uint8_t data) {
}
// REMAKE:
int print_ST_Lock_info(uint8_t model) {
/*
static int print_ST_Lock_info(uint8_t model) {
// PrintAndLogEx(NORMAL, "Chip Write Protection Bits:");
// // now interpret the data
// switch (model){
// case 0x0: //fall through (SRIX4K special)
// case 0x3: //fall through (SRIx4K)
// case 0x7: // (SRI4K)
// //only need data[3]
// blk1 = 9;
// PrintAndLogEx(NORMAL, " raw: %s", sprint_bin(data+3, 1));
// PrintAndLogEx(NORMAL, " 07/08:%slocked", (data[3] & 1) ? " not " : " " );
// for (uint8_t i = 1; i<8; i++){
// PrintAndLogEx(NORMAL, " %02u:%slocked", blk1, (data[3] & (1 << i)) ? " not " : " " );
// blk1++;
// }
// break;
// case 0x4: //fall through (SRIX512)
// case 0x6: //fall through (SRI512)
// case 0xC: // (SRT512)
// //need data[2] and data[3]
// blk1 = 0;
// PrintAndLogEx(NORMAL, " raw: %s", sprint_bin(data+2, 2));
// for (uint8_t b=2; b<4; b++){
// for (uint8_t i=0; i<8; i++){
// PrintAndLogEx(NORMAL, " %02u:%slocked", blk1, (data[b] & (1 << i)) ? " not " : " " );
// blk1++;
// }
// }
// break;
// case 0x2: // (SR176)
// //need data[2]
// blk1 = 0;
// PrintAndLogEx(NORMAL, " raw: %s", sprint_bin(data+2, 1));
// for (uint8_t i = 0; i<8; i++){
// PrintAndLogEx(NORMAL, " %02u/%02u:%slocked", blk1, blk1+1, (data[2] & (1 << i)) ? " " : " not " );
// blk1+=2;
// }
// break;
// default:
// return rawClose();
// }
PrintAndLogEx(NORMAL, "Chip Write Protection Bits:");
// now interpret the data
switch (model){
case 0x0: //fall through (SRIX4K special)
case 0x3: //fall through (SRIx4K)
case 0x7: // (SRI4K)
//only need data[3]
blk1 = 9;
PrintAndLogEx(NORMAL, " raw: %s", sprint_bin(data+3, 1));
PrintAndLogEx(NORMAL, " 07/08:%slocked", (data[3] & 1) ? " not " : " " );
for (uint8_t i = 1; i<8; i++){
PrintAndLogEx(NORMAL, " %02u:%slocked", blk1, (data[3] & (1 << i)) ? " not " : " " );
blk1++;
}
break;
case 0x4: //fall through (SRIX512)
case 0x6: //fall through (SRI512)
case 0xC: // (SRT512)
//need data[2] and data[3]
blk1 = 0;
PrintAndLogEx(NORMAL, " raw: %s", sprint_bin(data+2, 2));
for (uint8_t b=2; b<4; b++){
for (uint8_t i=0; i<8; i++){
PrintAndLogEx(NORMAL, " %02u:%slocked", blk1, (data[b] & (1 << i)) ? " not " : " " );
blk1++;
}
}
break;
case 0x2: // (SR176)
//need data[2]
blk1 = 0;
PrintAndLogEx(NORMAL, " raw: %s", sprint_bin(data+2, 1));
for (uint8_t i = 0; i<8; i++){
PrintAndLogEx(NORMAL, " %02u/%02u:%slocked", blk1, blk1+1, (data[2] & (1 << i)) ? " " : " not " );
blk1+=2;
}
break;
default:
return rawClose();
}
return 1;
}
*/
// print UID info from SRx chips (ST Microelectronics)
static void print_st_general_info(uint8_t *data, uint8_t len) {
//uid = first 8 bytes in data
@ -503,7 +504,7 @@ static void print_st_general_info(uint8_t *data, uint8_t len) {
//a2 = ? (resp 02 [6a d3])
// 14b get and print Full Info (as much as we know)
bool HF14B_Std_Info(bool verbose) {
static bool HF14B_Std_Info(bool verbose) {
bool isSuccess = false;
@ -547,7 +548,7 @@ bool HF14B_Std_Info(bool verbose) {
}
// SRx get and print full info (needs more info...)
bool HF14B_ST_Info(bool verbose) {
static bool HF14B_ST_Info(bool verbose) {
UsbCommand c = {CMD_ISO_14443B_COMMAND, {ISO14B_CONNECT | ISO14B_SELECT_SR | ISO14B_DISCONNECT, 0, 0}, {{0}}};
clearCommandBuffer();
@ -601,7 +602,7 @@ static int CmdHF14Binfo(const char *Cmd) {
return infoHF14B(verbose);
}
bool HF14B_ST_Reader(bool verbose) {
static bool HF14B_ST_Reader(bool verbose) {
bool isSuccess = false;
@ -641,7 +642,7 @@ bool HF14B_ST_Reader(bool verbose) {
return isSuccess;
}
bool HF14B_Std_Reader(bool verbose) {
static bool HF14B_Std_Reader(bool verbose) {
bool isSuccess = false;
@ -683,7 +684,7 @@ bool HF14B_Std_Reader(bool verbose) {
}
// test for other 14b type tags (mimic another reader - don't have tags to identify)
bool HF14B_Other_Reader() {
static bool HF14B_Other_Reader() {
// uint8_t data[] = {0x00, 0x0b, 0x3f, 0x80};
// uint8_t datalen = 4;
@ -989,14 +990,13 @@ static int CmdHF14BDump(const char *Cmd) {
out:
return switch_off_field_14b();
}
/*
uint32_t srix4kEncode(uint32_t value) {
/*
static uint32_t srix4kEncode(uint32_t value) {
// vv = value
// pp = position
// vv vv vv pp
4 bytes : 00 1A 20 01
*/
// 4 bytes : 00 1A 20 01
// only the lower crumbs.
uint8_t block = (value & 0xFF);
uint8_t i = 0;
@ -1046,7 +1046,8 @@ uint32_t srix4kEncode(uint32_t value) {
PrintAndLogEx(NORMAL, "ICE encoded | %08X -> %08X", value, encvalue);
return encvalue;
}
uint32_t srix4kDecode(uint32_t value) {
static uint32_t srix4kDecode(uint32_t value) {
switch (value) {
case 0xC04F42C5:
return 0x003139;
@ -1057,13 +1058,14 @@ uint32_t srix4kDecode(uint32_t value) {
}
return 0;
}
uint32_t srix4kDecodeCounter(uint32_t num) {
static uint32_t srix4kDecodeCounter(uint32_t num) {
uint32_t value = ~num;
++value;
return value;
}
uint32_t srix4kGetMagicbytes(uint64_t uid, uint32_t block6, uint32_t block18, uint32_t block19) {
static uint32_t srix4kGetMagicbytes(uint64_t uid, uint32_t block6, uint32_t block18, uint32_t block19) {
#define MASK 0xFFFFFFFF;
uint32_t uid32 = uid & MASK;
uint32_t counter = srix4kDecodeCounter(block6);
@ -1075,7 +1077,8 @@ uint32_t srix4kGetMagicbytes(uint64_t uid, uint32_t block6, uint32_t block18, ui
PrintAndLogEx(SUCCESS, "Magic bytes | %08X", result);
return result;
}
int srix4kValid(const char *Cmd) {
static int srix4kValid(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
uint64_t uid = 0xD00202501A4532F9;
@ -1093,7 +1096,7 @@ int srix4kValid(const char *Cmd) {
PrintAndLogEx(SUCCESS, "BLOCK 21 | %08X -> %08X (no XOR)", block21, magic ^ block21);
return 0;
}
*/
static command_t CommandTable[] = {
{"help", CmdHelp, 1, "This help"},
{"dump", CmdHF14BDump, 0, "Read all memory pages of an ISO14443-B tag, save to file"},

View file

@ -196,7 +196,7 @@ const productName uidmapping[] = {
// fast method to just read the UID of a tag (collission detection not supported)
// *buf should be large enough to fit the 64bit uid
// returns 1 if suceeded
int getUID(uint8_t *buf) {
static int getUID(uint8_t *buf) {
UsbCommand resp;
UsbCommand c = {CMD_ISO_15693_COMMAND, {0, 1, 1}, {{0}}}; // len,speed,recv?

View file

@ -198,7 +198,7 @@ static void printSep() {
PrintAndLogEx(NORMAL, "------------------------------------------------------------------------------------");
}
uint16_t PrintFliteBlock(uint16_t tracepos, uint8_t *trace, uint16_t tracelen) {
static uint16_t PrintFliteBlock(uint16_t tracepos, uint8_t *trace, uint16_t tracelen) {
if (tracepos + 19 >= tracelen)
return tracelen;

View file

@ -124,7 +124,7 @@ static int CmdHFFidoInfo(const char *cmd) {
return 0;
}
json_t *OpenJson(int paramnum, char *fname, void *argtable[], bool *err) {
static json_t *OpenJson(int paramnum, char *fname, void *argtable[], bool *err) {
json_t *root = NULL;
json_error_t error;
*err = false;
@ -615,13 +615,13 @@ static int CmdHFFidoAuthenticate(const char *cmd) {
return 0;
};
void CheckSlash(char *fileName) {
static void CheckSlash(char *fileName) {
if ((fileName[strlen(fileName) - 1] != '/') &&
(fileName[strlen(fileName) - 1] != '\\'))
strcat(fileName, "/");
}
int GetExistsFileNameJson(const char *prefixDir, const char *reqestedFileName, char *fileName) {
static int GetExistsFileNameJson(const char *prefixDir, const char *reqestedFileName, char *fileName) {
fileName[0] = 0x00;
strcpy(fileName, get_my_executable_directory());
CheckSlash(fileName);

View file

@ -262,14 +262,15 @@ static int usage_hf_iclass_permutekey(void) {
return 0;
}
int xorbits_8(uint8_t val) {
/*
static int xorbits_8(uint8_t val) {
uint8_t res = val ^ (val >> 1); //1st pass
res = res ^ (res >> 1); // 2nd pass
res = res ^ (res >> 2); // 3rd pass
res = res ^ (res >> 4); // 4th pass
return res & 1;
}
*/
static int CmdHFiClassList(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
//PrintAndLogEx(NORMAL, "Deprecated command, use 'hf list iclass' instead");
@ -537,14 +538,15 @@ static int CmdHFiClassReader_Replay(const char *Cmd) {
return 0;
}
int iclassEmlSetMem(uint8_t *data, int blockNum, int blocksCount) {
/*
static int iclassEmlSetMem(uint8_t *data, int blockNum, int blocksCount) {
UsbCommand c = {CMD_MIFARE_EML_MEMSET, {blockNum, blocksCount, 0}, {{0}}};
memcpy(c.d.asBytes, data, blocksCount * 16);
clearCommandBuffer();
SendCommand(&c);
return 0;
}
*/
static int CmdHFiClassELoad(const char *Cmd) {
char ctmp = tolower(param_getchar(Cmd, 0));
@ -757,7 +759,7 @@ static int CmdHFiClassEncryptBlk(const char *Cmd) {
return 1;
}
void Calc_wb_mac(uint8_t blockno, uint8_t *data, uint8_t *div_key, uint8_t MAC[4]) {
static void Calc_wb_mac(uint8_t blockno, uint8_t *data, uint8_t *div_key, uint8_t MAC[4]) {
uint8_t wb[9];
wb[0] = blockno;
memcpy(wb + 1, data, 8);

View file

@ -410,7 +410,7 @@ static int usage_hf14_nack(void) {
return 0;
}
int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
static int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -428,7 +428,7 @@ int GetHFMF14AUID(uint8_t *uid, int *uidlen) {
return 1;
}
char *GenerateFilename(const char *prefix, const char *suffix) {
static char *GenerateFilename(const char *prefix, const char *suffix) {
uint8_t uid[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int uidlen = 0;
char *fptr = calloc(sizeof(char) * (strlen(prefix) + strlen(suffix)) + sizeof(uid) * 2 + 1, sizeof(uint8_t));
@ -674,7 +674,7 @@ static int CmdHF14AMfRdSc(const char *Cmd) {
return 0;
}
uint16_t NumOfBlocks(char card) {
static uint16_t NumOfBlocks(char card) {
switch (card) {
case '0' :
return MIFARE_MINI_MAXBLOCK;
@ -688,7 +688,8 @@ uint16_t NumOfBlocks(char card) {
return MIFARE_1K_MAXBLOCK;
}
}
uint8_t NumOfSectors(char card) {
static uint8_t NumOfSectors(char card) {
switch (card) {
case '0' :
return MIFARE_MINI_MAXSECTOR;
@ -703,7 +704,7 @@ uint8_t NumOfSectors(char card) {
}
}
uint8_t FirstBlockOfSector(uint8_t sectorNo) {
static uint8_t FirstBlockOfSector(uint8_t sectorNo) {
if (sectorNo < 32) {
return sectorNo * 4;
} else {
@ -711,7 +712,7 @@ uint8_t FirstBlockOfSector(uint8_t sectorNo) {
}
}
uint8_t NumBlocksPerSector(uint8_t sectorNo) {
static uint8_t NumBlocksPerSector(uint8_t sectorNo) {
if (sectorNo < 32) {
return 4;
} else {
@ -1512,12 +1513,15 @@ static int CmdHF14AMfNestedHard(const char *Cmd) {
return 0;
}
int randInRange(int min, int max) {
/*
static int randInRange(int min, int max) {
return min + (int)(rand() / (double)(RAND_MAX) * (max - min + 1));
}
*/
//FisherYates shuffle
void shuffle(uint8_t *array, uint16_t len) {
/*
static void shuffle(uint8_t *array, uint16_t len) {
uint8_t tmp[6];
uint16_t x;
time_t t;
@ -1530,6 +1534,7 @@ void shuffle(uint8_t *array, uint16_t len) {
memcpy(array + len, tmp, 6);
}
}
*/
static int CmdHF14AMfChk_fast(const char *Cmd) {

View file

@ -1091,7 +1091,7 @@ static int read_nonce_file(char *filename) {
}
noncelistentry_t *SearchFor2ndByte(uint8_t b1, uint8_t b2) {
static noncelistentry_t *SearchFor2ndByte(uint8_t b1, uint8_t b2) {
noncelistentry_t *p = nonces[b1].first;
while (p != NULL) {
if ((p->nonce_enc >> 16 & 0xff) == b2) {

View file

@ -260,7 +260,7 @@ const uint32_t c_D[] = {
0x5728B869, 0x30726D5A
};
void transform_D(uint8_t *ru) {
static void transform_D(uint8_t *ru) {
//Transform
uint8_t i;
uint8_t p = 0;
@ -315,7 +315,7 @@ uint32_t ul_ev1_pwdgenA(uint8_t *uid) {
}
// Certain pwd generation algo nickname B. (very simple)
uint32_t ul_ev1_pwdgenB(uint8_t *uid) {
static uint32_t ul_ev1_pwdgenB(uint8_t *uid) {
uint8_t pwd[] = {0x00, 0x00, 0x00, 0x00};
@ -394,7 +394,7 @@ uint16_t ul_ev1_packgenD(uint8_t *uid) {
return BSWAP_16(p & 0xFFFF);
}
int ul_ev1_pwdgen_selftest() {
static int ul_ev1_pwdgen_selftest() {
uint8_t uid1[] = {0x04, 0x11, 0x12, 0x11, 0x12, 0x11, 0x10};
uint32_t pwd1 = ul_ev1_pwdgenA(uid1);
@ -416,7 +416,7 @@ int ul_ev1_pwdgen_selftest() {
//------------------------------------
// get version nxp product type
char *getProductTypeStr(uint8_t id) {
static char *getProductTypeStr(uint8_t id) {
static char buf[20];
char *retStr = buf;
@ -440,7 +440,7 @@ char *getProductTypeStr(uint8_t id) {
the LSBit is set to '0' if the size is exactly 2^n
and set to '1' if the storage size is between 2^n and 2^(n+1).
*/
char *getUlev1CardSizeStr(uint8_t fsize) {
static char *getUlev1CardSizeStr(uint8_t fsize) {
static char buf[40];
char *retStr = buf;

View file

@ -307,7 +307,7 @@ static void lookupChipID(uint32_t iChipID, uint32_t mem_used) {
PrintAndLogEx(NORMAL, " --= Nonvolatile Program Memory Type: %s", asBuff);
}
int CmdDetectReader(const char *Cmd) {
static int CmdDetectReader(const char *Cmd) {
UsbCommand c = {CMD_LISTEN_READER_FIELD, {0, 0, 0}, {{0}}};
// 'l' means LF - 125/134 kHz
if (*Cmd == 'l') {
@ -324,7 +324,7 @@ int CmdDetectReader(const char *Cmd) {
}
// ## FPGA Control
int CmdFPGAOff(const char *Cmd) {
static int CmdFPGAOff(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
UsbCommand c = {CMD_FPGA_MAJOR_MODE_OFF, {0, 0, 0}, {{0}}};
clearCommandBuffer();
@ -333,7 +333,7 @@ int CmdFPGAOff(const char *Cmd) {
}
#ifdef WITH_LCD
int CmdLCD(const char *Cmd) {
static int CmdLCD(const char *Cmd) {
int i, j;
UsbCommand c = {CMD_LCD, {0, 0, 0}, {{0}}};
@ -346,7 +346,7 @@ int CmdLCD(const char *Cmd) {
return 0;
}
int CmdLCDReset(const char *Cmd) {
static int CmdLCDReset(const char *Cmd) {
UsbCommand c = {CMD_LCD_RESET, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -354,14 +354,14 @@ int CmdLCDReset(const char *Cmd) {
}
#endif
int CmdReadmem(const char *Cmd) {
static int CmdReadmem(const char *Cmd) {
UsbCommand c = {CMD_READ_MEM, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
return 0;
}
int CmdReset(const char *Cmd) {
static int CmdReset(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
UsbCommand c = {CMD_HARDWARE_RESET, {0, 0, 0}, {{0}}};
clearCommandBuffer();
@ -373,7 +373,7 @@ int CmdReset(const char *Cmd) {
* Sets the divisor for LF frequency clock: lets the user choose any LF frequency below
* 600kHz.
*/
int CmdSetDivisor(const char *Cmd) {
static int CmdSetDivisor(const char *Cmd) {
UsbCommand c = {CMD_SET_LF_DIVISOR, {strtol(Cmd, NULL, 0), 0, 0}, {{0}}};
if (c.arg[0] < 19 || c.arg[0] > 255) {
@ -387,7 +387,7 @@ int CmdSetDivisor(const char *Cmd) {
return 0;
}
int CmdSetMux(const char *Cmd) {
static int CmdSetMux(const char *Cmd) {
if (strlen(Cmd) < 5) {
PrintAndLogEx(NORMAL, "expected: lopkd | loraw | hipkd | hiraw");
@ -405,16 +405,73 @@ int CmdSetMux(const char *Cmd) {
return 0;
}
int CmdTune(const char *Cmd) {
static int CmdTune(const char *Cmd) {
return CmdTuneSamples(Cmd);
}
int CmdVersion(const char *Cmd) {
static int CmdVersion(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
pm3_version(true);
return 0;
}
bool silent = (Cmd[0] == 's' || Cmd[0] == 'S');
if (silent)
return 0;
static int CmdStatus(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
UsbCommand c = {CMD_STATUS, {0, 0, 0}, {{0}}};
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &c, 1900))
PrintAndLogEx(NORMAL, "Status command failed. USB Speed Test timed out");
return 0;
}
static int CmdPing(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
UsbCommand resp;
UsbCommand c = {CMD_PING, {0, 0, 0}, {{0}}};
SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000))
PrintAndLogEx(NORMAL, "Ping successful");
else
PrintAndLogEx(NORMAL, "Ping failed");
return 0;
}
static command_t CommandTable[] = {
{"help", CmdHelp, 1, "This help"},
{"detectreader", CmdDetectReader, 0, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)"},
{"fpgaoff", CmdFPGAOff, 0, "Set FPGA off"},
#ifdef WITH_LCD
{"lcd", CmdLCD, 0, "<HEX command> <count> -- Send command/data to LCD"},
{"lcdreset", CmdLCDReset, 0, "Hardware reset LCD"},
#endif
{"readmem", CmdReadmem, 0, "[address] -- Read memory at decimal address from flash"},
{"reset", CmdReset, 0, "Reset the Proxmark3"},
{"setlfdivisor", CmdSetDivisor, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},
{"setmux", CmdSetMux, 0, "<loraw|hiraw|lopkd|hipkd> -- Set the ADC mux to a specific value"},
{"tune", CmdTune, 0, "Measure antenna tuning"},
{"version", CmdVersion, 0, "Show version information about the connected Proxmark"},
{"status", CmdStatus, 0, "Show runtime status information about the connected Proxmark"},
{"ping", CmdPing, 0, "Test if the pm3 is responsive"},
{NULL, NULL, 0, NULL}
};
static int CmdHelp(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
CmdsHelp(CommandTable);
return 0;
}
int CmdHW(const char *Cmd) {
clearCommandBuffer();
CmdsParse(CommandTable, Cmd);
return 0;
}
void pm3_version(bool verbose) {
if (!verbose)
return;
UsbCommand c = {CMD_VERSION, {0, 0, 0}, {{0}}};
UsbCommand resp;
clearCommandBuffer();
@ -449,59 +506,4 @@ int CmdVersion(const char *Cmd) {
lookupChipID(resp.arg[0], resp.arg[1]);
}
PrintAndLogEx(NORMAL, "\n");
return 0;
}
int CmdStatus(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
UsbCommand c = {CMD_STATUS, {0, 0, 0}, {{0}}};
SendCommand(&c);
if (!WaitForResponseTimeout(CMD_ACK, &c, 1900))
PrintAndLogEx(NORMAL, "Status command failed. USB Speed Test timed out");
return 0;
}
int CmdPing(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
clearCommandBuffer();
UsbCommand resp;
UsbCommand c = {CMD_PING, {0, 0, 0}, {{0}}};
SendCommand(&c);
if (WaitForResponseTimeout(CMD_ACK, &resp, 1000))
PrintAndLogEx(NORMAL, "Ping successful");
else
PrintAndLogEx(NORMAL, "Ping failed");
return 0;
}
static command_t CommandTable[] = {
{"help", CmdHelp, 1, "This help"},
{"detectreader", CmdDetectReader, 0, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)"},
{"fpgaoff", CmdFPGAOff, 0, "Set FPGA off"},
#ifdef WITH_LCD
{"lcd", CmdLCD, 0, "<HEX command> <count> -- Send command/data to LCD"},
{"lcdreset", CmdLCDReset, 0, "Hardware reset LCD"},
#endif
{"readmem", CmdReadmem, 0, "[address] -- Read memory at decimal address from flash"},
{"reset", CmdReset, 0, "Reset the Proxmark3"},
{"setlfdivisor", CmdSetDivisor, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},
{"setmux", CmdSetMux, 0, "<loraw|hiraw|lopkd|hipkd> -- Set the ADC mux to a specific value"},
{"tune", CmdTune, 0, "Measure antenna tuning"},
{"version", CmdVersion, 0, "Show version information about the connected Proxmark"},
{"status", CmdStatus, 0, "Show runtime status information about the connected Proxmark"},
{"ping", CmdPing, 0, "Test if the pm3 is responsive"},
{NULL, NULL, 0, NULL}
};
int CmdHW(const char *Cmd) {
clearCommandBuffer();
CmdsParse(CommandTable, Cmd);
return 0;
}
int CmdHelp(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
CmdsHelp(CommandTable);
return 0;
}

View file

@ -13,15 +13,6 @@
int CmdHW(const char *Cmd);
int CmdDetectReader(const char *Cmd);
int CmdFPGAOff(const char *Cmd);
int CmdLCD(const char *Cmd);
int CmdLCDReset(const char *Cmd);
int CmdReadmem(const char *Cmd);
int CmdReset(const char *Cmd);
int CmdSetDivisor(const char *Cmd);
int CmdSetMux(const char *Cmd);
int CmdTune(const char *Cmd);
int CmdVersion(const char *Cmd);
int CmdPing(const char *Cmd);
void pm3_version(bool verbose);
#endif

View file

@ -821,7 +821,7 @@ int CmdVchDemod(const char *Cmd) {
}
//by marshmellow
bool CheckChipType(bool getDeviceData) {
static bool CheckChipType(bool getDeviceData) {
bool retval = false;

View file

@ -654,7 +654,7 @@ static int CmdEM410xWrite(const char *Cmd) {
}
//**************** Start of EM4x50 Code ************************
bool EM_EndParityTest(uint8_t *bs, size_t size, uint8_t rows, uint8_t cols, uint8_t pType) {
static bool EM_EndParityTest(uint8_t *bs, size_t size, uint8_t rows, uint8_t cols, uint8_t pType) {
if (rows * cols > size) return false;
uint8_t colP = 0;
//assume last col is a parity and do not test
@ -667,7 +667,7 @@ bool EM_EndParityTest(uint8_t *bs, size_t size, uint8_t rows, uint8_t cols, uint
return true;
}
bool EM_ByteParityTest(uint8_t *bs, size_t size, uint8_t rows, uint8_t cols, uint8_t pType) {
static bool EM_ByteParityTest(uint8_t *bs, size_t size, uint8_t rows, uint8_t cols, uint8_t pType) {
if (rows * cols > size) return false;
uint8_t rowP = 0;
@ -691,7 +691,7 @@ bool EM_ByteParityTest(uint8_t *bs, size_t size, uint8_t rows, uint8_t cols, uin
//c012345678| 0
// |- must be zero
bool EMwordparitytest(uint8_t *bits) {
static bool EMwordparitytest(uint8_t *bits) {
// last row/col parity must be 0
if (bits[44] != 0) return false;
@ -720,7 +720,7 @@ bool EMwordparitytest(uint8_t *bits) {
//////////////// 4050 / 4450 commands
uint32_t OutputEM4x50_Block(uint8_t *BitStream, size_t size, bool verbose, bool pTest) {
static uint32_t OutputEM4x50_Block(uint8_t *BitStream, size_t size, bool verbose, bool pTest) {
if (size < 45) return 0;
uint32_t code = bytebits_to_byte(BitStream, 8);
@ -976,7 +976,7 @@ static int CmdEM4x50Dump(const char *Cmd) {
#define EM_PREAMBLE_LEN 6
// download samples from device and copy to Graphbuffer
bool downloadSamplesEM() {
static bool downloadSamplesEM() {
// 8 bit preamble + 32 bit word response (max clock (128) * 40bits = 5120 samples)
uint8_t got[6000];
@ -997,7 +997,7 @@ bool downloadSamplesEM() {
}
// em_demod
bool doPreambleSearch(size_t *startIdx) {
static bool doPreambleSearch(size_t *startIdx) {
// sanity check
if (DemodBufferLen < EM_PREAMBLE_LEN) {
@ -1018,7 +1018,7 @@ bool doPreambleSearch(size_t *startIdx) {
return true;
}
bool detectFSK() {
static bool detectFSK() {
// detect fsk clock
if (!GetFskClock("", false)) {
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: FSK clock failed");
@ -1033,7 +1033,7 @@ bool detectFSK() {
return true;
}
// PSK clocks should be easy to detect ( but difficult to demod a non-repeating pattern... )
bool detectPSK() {
static bool detectPSK() {
int ans = GetPskClock("", false);
if (ans <= 0) {
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: PSK clock failed");
@ -1057,7 +1057,7 @@ bool detectPSK() {
return true;
}
// try manchester - NOTE: ST only applies to T55x7 tags.
bool detectASK_MAN() {
static bool detectASK_MAN() {
bool stcheck = false;
if (!ASKDemod_ext("0 0 0", false, false, 1, &stcheck)) {
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/Manchester Demod failed");
@ -1065,7 +1065,8 @@ bool detectASK_MAN() {
}
return true;
}
bool detectASK_BI() {
static bool detectASK_BI() {
int ans = ASKbiphaseDemod("0 0 1", false);
if (!ans) {
PrintAndLogEx(DEBUG, "DEBUG: Error - EM: ASK/biphase normal demod failed");
@ -1080,7 +1081,7 @@ bool detectASK_BI() {
}
// param: idx - start index in demoded data.
bool setDemodBufferEM(uint32_t *word, size_t idx) {
static bool setDemodBufferEM(uint32_t *word, size_t idx) {
//test for even parity bits.
uint8_t parity[45] = {0};
@ -1103,7 +1104,7 @@ bool setDemodBufferEM(uint32_t *word, size_t idx) {
// FSK, PSK, ASK/MANCHESTER, ASK/BIPHASE, ASK/DIPHASE
// should cover 90% of known used configs
// the rest will need to be manually demoded for now...
bool demodEM4x05resp(uint32_t *word) {
static bool demodEM4x05resp(uint32_t *word) {
size_t idx = 0;
*word = 0;
if (detectASK_MAN() && doPreambleSearch(&idx))
@ -1127,7 +1128,7 @@ bool demodEM4x05resp(uint32_t *word) {
}
//////////////// 4205 / 4305 commands
int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) {
static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) {
UsbCommand c = {CMD_EM4X_READ_WORD, {addr, pwd, usePwd}, {{0}}};
clearCommandBuffer();
SendCommand(&c);
@ -1253,7 +1254,7 @@ static int CmdEM4x05Write(const char *Cmd) {
return isOk;
}
void printEM4x05config(uint32_t wordData) {
static void printEM4x05config(uint32_t wordData) {
uint16_t datarate = (((wordData & 0x3F) + 1) * 2);
uint8_t encoder = ((wordData >> 6) & 0xF);
char enc[14];
@ -1357,7 +1358,7 @@ void printEM4x05config(uint32_t wordData) {
PrintAndLogEx(NORMAL, " Pigeon: %u | Pigeon Mode is %s\n", pigeon, pigeon ? "Enabled" : "Disabled");
}
void printEM4x05info(uint32_t block0, uint32_t serial) {
static void printEM4x05info(uint32_t block0, uint32_t serial) {
uint8_t chipType = (block0 >> 1) & 0xF;
uint8_t cap = (block0 >> 5) & 3;
@ -1405,7 +1406,7 @@ void printEM4x05info(uint32_t block0, uint32_t serial) {
PrintAndLogEx(NORMAL, "\n Serial #: %08X\n", serial);
}
void printEM4x05ProtectionBits(uint32_t word) {
static void printEM4x05ProtectionBits(uint32_t word) {
for (uint8_t i = 0; i < 15; i++) {
PrintAndLogEx(NORMAL, " Word: %02u | %s", i, (((1 << i) & word) || i < 2) ? "Is Write Locked" : "Is Not Write Locked");
if (i == 14)

View file

@ -496,7 +496,7 @@ bool DecodeT55xxBlock(void) {
return (bool) ans;
}
bool DecodeT5555TraceBlock(void) {
static bool DecodeT5555TraceBlock(void) {
DemodBufferLen = 0x00;
// According to datasheet. Always: RF/64, not inverted, Manchester
@ -792,7 +792,7 @@ void printT55xxBlock(uint8_t blockNum) {
PrintAndLogEx(NORMAL, " %02d | %08X | %s | %s", blockNum, blockData, sprint_bin(DemodBuffer + config.offset, 32), sprint_ascii(bytes, 4));
}
bool testModulation(uint8_t mode, uint8_t modread) {
static bool testModulation(uint8_t mode, uint8_t modread) {
switch (mode) {
case DEMOD_FSK:
if (modread >= DEMOD_FSK1 && modread <= DEMOD_FSK2a) return true;
@ -824,7 +824,7 @@ bool testModulation(uint8_t mode, uint8_t modread) {
return false;
}
bool testQ5Modulation(uint8_t mode, uint8_t modread) {
static bool testQ5Modulation(uint8_t mode, uint8_t modread) {
switch (mode) {
case DEMOD_FSK:
if (modread >= 4 && modread <= 5) return true;
@ -853,7 +853,7 @@ bool testQ5Modulation(uint8_t mode, uint8_t modread) {
return false;
}
int convertQ5bitRate(uint8_t bitRateRead) {
static int convertQ5bitRate(uint8_t bitRateRead) {
uint8_t expected[] = {8, 16, 32, 40, 50, 64, 100, 128};
for (int i = 0; i < 8; i++)
if (expected[i] == bitRateRead)
@ -862,7 +862,7 @@ int convertQ5bitRate(uint8_t bitRateRead) {
return -1;
}
bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk) {
static bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk) {
if (DemodBufferLen < 64) return false;
@ -907,7 +907,7 @@ bool testQ5(uint8_t mode, uint8_t *offset, int *fndBitRate, uint8_t clk) {
return false;
}
bool testBitRate(uint8_t readRate, uint8_t clk) {
static bool testBitRate(uint8_t readRate, uint8_t clk) {
uint8_t expected[] = {8, 16, 32, 40, 50, 64, 100, 128};
if (expected[readRate] == clk)
return true;
@ -1746,14 +1746,13 @@ char *GetSelectedModulationStr(uint8_t id) {
return buf;
}
void t55x7_create_config_block(int tagtype) {
/*
static void t55x7_create_config_block(int tagtype) {
/*
T55X7_DEFAULT_CONFIG_BLOCK, T55X7_RAW_CONFIG_BLOCK
T55X7_EM_UNIQUE_CONFIG_BLOCK, T55X7_FDXB_CONFIG_BLOCK,
T55X7_FDXB_CONFIG_BLOCK, T55X7_HID_26_CONFIG_BLOCK, T55X7_INDALA_64_CONFIG_BLOCK, T55X7_INDALA_224_CONFIG_BLOCK
T55X7_GUARDPROXII_CONFIG_BLOCK, T55X7_VIKING_CONFIG_BLOCK, T55X7_NORALYS_CONFIG_BLOCK, T55X7_IOPROX_CONFIG_BLOCK
*/
// T55X7_DEFAULT_CONFIG_BLOCK, T55X7_RAW_CONFIG_BLOCK
// T55X7_EM_UNIQUE_CONFIG_BLOCK, T55X7_FDXB_CONFIG_BLOCK,
// T55X7_FDXB_CONFIG_BLOCK, T55X7_HID_26_CONFIG_BLOCK, T55X7_INDALA_64_CONFIG_BLOCK, T55X7_INDALA_224_CONFIG_BLOCK
// T55X7_GUARDPROXII_CONFIG_BLOCK, T55X7_VIKING_CONFIG_BLOCK, T55X7_NORALYS_CONFIG_BLOCK, T55X7_IOPROX_CONFIG_BLOCK
static char buf[60];
char *retStr = buf;
@ -1772,6 +1771,7 @@ void t55x7_create_config_block(int tagtype) {
}
PrintAndLogEx(NORMAL, buf);
}
*/
static int CmdResetRead(const char *Cmd) {
(void)Cmd; // Cmd is not used so far
@ -1822,7 +1822,7 @@ static int CmdT55xxWipe(const char *Cmd) {
return 0;
}
bool IsCancelled(void) {
static bool IsCancelled(void) {
if (ukbhit()) {
int gc = getchar();
(void)gc;

View file

@ -26,6 +26,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "cda_test.h"
struct emv_pk c_mchip_05 = {
.rid = { 0xa0, 0x00, 0x00, 0x00, 0x04, },

View file

@ -63,7 +63,7 @@ COSEValueTypeNameDesc_t COSECurvesDesc[] = {
{7, "OKP", "Ed448", "Ed448 for use w/ EdDSA only"},
};
COSEValueTypeNameDesc_t *GetCOSECurveElm(int id) {
static COSEValueTypeNameDesc_t *GetCOSECurveElm(int id) {
for (int i = 0; i < ARRAYLEN(COSECurvesDesc); i++)
if (COSECurvesDesc[i].Value == id)
return &COSECurvesDesc[i];
@ -135,7 +135,7 @@ COSEValueNameDesc_t COSEAlg[] = {
{33, "AES-CCM-64-128-256", "AES-CCM mode 256-bit key, 128-bit tag, 7-byte nonce"}
};
COSEValueNameDesc_t *GetCOSEAlgElm(int id) {
static COSEValueNameDesc_t *GetCOSEAlgElm(int id) {
for (int i = 0; i < ARRAYLEN(COSEAlg); i++)
if (COSEAlg[i].Value == id)
return &COSEAlg[i];

View file

@ -7,7 +7,7 @@
#include <ctype.h>
#include "elite_crack.h"
/*
static void calc_score(uint8_t *csn, uint8_t *k) {
uint8_t score = 0 ;
uint8_t i;
@ -82,4 +82,4 @@ static void brute_hash1(void) {
}
}
}
*/

View file

@ -600,7 +600,7 @@ static uint64_t testCryptedCSN(uint64_t crypted_csn, uint64_t expected) {
return retval;
}
int testDES2(uint64_t csn, uint64_t expected) {
static int testDES2(uint64_t csn, uint64_t expected) {
uint8_t result[8] = {0};
uint8_t input[8] = {0};

View file

@ -80,7 +80,7 @@ static const char *URI_s[] = {
"urn:nfc:" // 0x23
};
uint16_t ndefTLVGetLength(uint8_t *data, size_t *indx) {
static uint16_t ndefTLVGetLength(uint8_t *data, size_t *indx) {
uint16_t len = 0;
if (data[0] == 0xff) {
len = (data[1] << 8) + data[2];
@ -93,7 +93,7 @@ uint16_t ndefTLVGetLength(uint8_t *data, size_t *indx) {
return len;
}
int ndefDecodeHeader(uint8_t *data, size_t datalen, NDEFHeader_t *header) {
static int ndefDecodeHeader(uint8_t *data, size_t datalen, NDEFHeader_t *header) {
header->Type = NULL;
header->Payload = NULL;
header->ID = NULL;
@ -129,7 +129,7 @@ int ndefDecodeHeader(uint8_t *data, size_t datalen, NDEFHeader_t *header) {
return 0;
}
int ndefPrintHeader(NDEFHeader_t *header) {
static int ndefPrintHeader(NDEFHeader_t *header) {
PrintAndLogEx(INFO, "Header:");
PrintAndLogEx(NORMAL, "\tMessage Begin: %s", STRBOOL(header->MessageBegin));
@ -148,7 +148,7 @@ int ndefPrintHeader(NDEFHeader_t *header) {
return 0;
}
int ndefDecodeSig(uint8_t *sig, size_t siglen) {
static int ndefDecodeSig(uint8_t *sig, size_t siglen) {
size_t indx = 0;
PrintAndLogEx(NORMAL, "\tsignature version: 0x%02x", sig[0]);
if (sig[0] != 0x01) {
@ -213,7 +213,7 @@ int ndefDecodeSig(uint8_t *sig, size_t siglen) {
return 0;
};
int ndefDecodePayload(NDEFHeader_t *ndef) {
static int ndefDecodePayload(NDEFHeader_t *ndef) {
switch (ndef->TypeNameFormat) {
case tnfWellKnownRecord:
@ -244,7 +244,7 @@ int ndefDecodePayload(NDEFHeader_t *ndef) {
return 0;
}
int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
static int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
NDEFHeader_t NDEFHeader = {0};
int res = ndefDecodeHeader(ndefRecord, ndefRecordLen, &NDEFHeader);
if (res)
@ -270,7 +270,7 @@ int ndefRecordDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
return 0;
}
int ndefRecordsDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
static int ndefRecordsDecodeAndPrint(uint8_t *ndefRecord, size_t ndefRecordLen) {
bool firstRec = true;
size_t len = 0;

View file

@ -71,9 +71,9 @@ main_loop(char *script_cmds_file, char *script_cmd, bool usb_present) {
SetOffline(false);
// cache Version information now:
if (execCommand || script_cmds_file || stdinOnPipe)
CmdVersion("s");
pm3_version(false);
else
CmdVersion("");
pm3_version(true);
} else {
SetOffline(true);
}