mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 13:53:55 -07:00
less global vars
This commit is contained in:
parent
d234e2a8f5
commit
447105511a
12 changed files with 47 additions and 50 deletions
|
@ -32,7 +32,7 @@
|
||||||
#define MAX_KEY_LEN 24
|
#define MAX_KEY_LEN 24
|
||||||
#define MAX_KEYS_LIST_LEN 1024
|
#define MAX_KEYS_LIST_LEN 1024
|
||||||
|
|
||||||
struct desfire_key defaultkey = {0};
|
static struct desfire_key defaultkey = {0};
|
||||||
static desfirekey_t sessionkey = &defaultkey;
|
static desfirekey_t sessionkey = &defaultkey;
|
||||||
|
|
||||||
//uint8_t key_zero_data[16] = { 0x00 };
|
//uint8_t key_zero_data[16] = { 0x00 };
|
||||||
|
|
|
@ -499,7 +499,7 @@ static void free_sum_bitarrays(void) {
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_KEY_ELIMINATION
|
#ifdef DEBUG_KEY_ELIMINATION
|
||||||
char failstr[250] = "";
|
static char failstr[250] = "";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const float p_K0[NUM_SUMS] = { // the probability that a random nonce has a Sum Property K
|
static const float p_K0[NUM_SUMS] = { // the probability that a random nonce has a Sum Property K
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
#include "cmdlfmotorola.h" // for Motorola menu
|
#include "cmdlfmotorola.h" // for Motorola menu
|
||||||
#include "cmdlfgallagher.h" // for GALLAGHER menu
|
#include "cmdlfgallagher.h" // for GALLAGHER menu
|
||||||
|
|
||||||
bool g_lf_threshold_set = false;
|
static bool g_lf_threshold_set = false;
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include "cmdlf.h"
|
#include "cmdlf.h"
|
||||||
#include "lfdemod.h"
|
#include "lfdemod.h"
|
||||||
|
|
||||||
uint64_t g_em410xid = 0;
|
static uint64_t g_em410xid = 0;
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ static int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
// trace pointer
|
// trace pointer
|
||||||
static uint8_t *g_trace;
|
static uint8_t *g_trace;
|
||||||
long g_traceLen = 0;
|
static long g_traceLen = 0;
|
||||||
|
|
||||||
static int usage_trace_list(void) {
|
static int usage_trace_list(void) {
|
||||||
PrintAndLogEx(NORMAL, "List protocol data in trace buffer.");
|
PrintAndLogEx(NORMAL, "List protocol data in trace buffer.");
|
||||||
|
|
|
@ -26,39 +26,33 @@
|
||||||
#include "ui.h" // Print...
|
#include "ui.h" // Print...
|
||||||
#include "bignum.h"
|
#include "bignum.h"
|
||||||
|
|
||||||
static uint8_t g_primes[ROCA_PRINTS_LENGTH] = {
|
static void rocacheck_init(mbedtls_mpi *prints) {
|
||||||
11, 13, 17, 19, 37, 53, 61, 71, 73, 79, 97, 103, 107, 109, 127, 151, 157
|
|
||||||
};
|
|
||||||
|
|
||||||
mbedtls_mpi g_prints[ROCA_PRINTS_LENGTH];
|
|
||||||
|
|
||||||
static void rocacheck_init(void) {
|
|
||||||
|
|
||||||
for (int i = 0; i < ROCA_PRINTS_LENGTH; i++)
|
for (int i = 0; i < ROCA_PRINTS_LENGTH; i++)
|
||||||
mbedtls_mpi_init(&g_prints[i]);
|
mbedtls_mpi_init(&prints[i]);
|
||||||
|
|
||||||
mbedtls_mpi_read_string(&g_prints[0], 10, "1026");
|
mbedtls_mpi_read_string(&prints[0], 10, "1026");
|
||||||
mbedtls_mpi_read_string(&g_prints[1], 10, "5658");
|
mbedtls_mpi_read_string(&prints[1], 10, "5658");
|
||||||
mbedtls_mpi_read_string(&g_prints[2], 10, "107286");
|
mbedtls_mpi_read_string(&prints[2], 10, "107286");
|
||||||
mbedtls_mpi_read_string(&g_prints[3], 10, "199410");
|
mbedtls_mpi_read_string(&prints[3], 10, "199410");
|
||||||
mbedtls_mpi_read_string(&g_prints[4], 10, "67109890");
|
mbedtls_mpi_read_string(&prints[4], 10, "67109890");
|
||||||
mbedtls_mpi_read_string(&g_prints[5], 10, "5310023542746834");
|
mbedtls_mpi_read_string(&prints[5], 10, "5310023542746834");
|
||||||
mbedtls_mpi_read_string(&g_prints[6], 10, "1455791217086302986");
|
mbedtls_mpi_read_string(&prints[6], 10, "1455791217086302986");
|
||||||
mbedtls_mpi_read_string(&g_prints[7], 10, "20052041432995567486");
|
mbedtls_mpi_read_string(&prints[7], 10, "20052041432995567486");
|
||||||
mbedtls_mpi_read_string(&g_prints[8], 10, "6041388139249378920330");
|
mbedtls_mpi_read_string(&prints[8], 10, "6041388139249378920330");
|
||||||
mbedtls_mpi_read_string(&g_prints[9], 10, "207530445072488465666");
|
mbedtls_mpi_read_string(&prints[9], 10, "207530445072488465666");
|
||||||
mbedtls_mpi_read_string(&g_prints[10], 10, "79228162521181866724264247298");
|
mbedtls_mpi_read_string(&prints[10], 10, "79228162521181866724264247298");
|
||||||
mbedtls_mpi_read_string(&g_prints[11], 10, "1760368345969468176824550810518");
|
mbedtls_mpi_read_string(&prints[11], 10, "1760368345969468176824550810518");
|
||||||
mbedtls_mpi_read_string(&g_prints[12], 10, "50079290986288516948354744811034");
|
mbedtls_mpi_read_string(&prints[12], 10, "50079290986288516948354744811034");
|
||||||
mbedtls_mpi_read_string(&g_prints[13], 10, "473022961816146413042658758988474");
|
mbedtls_mpi_read_string(&prints[13], 10, "473022961816146413042658758988474");
|
||||||
mbedtls_mpi_read_string(&g_prints[14], 10, "144390480366845522447407333004847678774");
|
mbedtls_mpi_read_string(&prints[14], 10, "144390480366845522447407333004847678774");
|
||||||
mbedtls_mpi_read_string(&g_prints[15], 10, "1800793591454480341970779146165214289059119882");
|
mbedtls_mpi_read_string(&prints[15], 10, "1800793591454480341970779146165214289059119882");
|
||||||
mbedtls_mpi_read_string(&g_prints[16], 10, "126304807362733370595828809000324029340048915994");
|
mbedtls_mpi_read_string(&prints[16], 10, "126304807362733370595828809000324029340048915994");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rocacheck_cleanup(void) {
|
static void rocacheck_cleanup(mbedtls_mpi *prints) {
|
||||||
for (int i = 0; i < ROCA_PRINTS_LENGTH; i++)
|
for (int i = 0; i < ROCA_PRINTS_LENGTH; i++)
|
||||||
mbedtls_mpi_free(&g_prints[i]);
|
mbedtls_mpi_free(&prints[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bitand_is_zero(mbedtls_mpi *a, mbedtls_mpi *b) {
|
static int bitand_is_zero(mbedtls_mpi *a, mbedtls_mpi *b) {
|
||||||
|
@ -97,8 +91,12 @@ bool emv_rocacheck(const unsigned char *buf, size_t buflen, bool verbose) {
|
||||||
mbedtls_mpi_init(&t_modulus);
|
mbedtls_mpi_init(&t_modulus);
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
mbedtls_mpi prints[ROCA_PRINTS_LENGTH];
|
||||||
|
uint8_t primes[ROCA_PRINTS_LENGTH] = {
|
||||||
|
11, 13, 17, 19, 37, 53, 61, 71, 73, 79, 97, 103, 107, 109, 127, 151, 157
|
||||||
|
};
|
||||||
|
|
||||||
rocacheck_init();
|
rocacheck_init(prints);
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&t_modulus, buf, buflen));
|
MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&t_modulus, buf, buflen));
|
||||||
|
|
||||||
|
@ -114,13 +112,13 @@ bool emv_rocacheck(const unsigned char *buf, size_t buflen, bool verbose) {
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&g_one, 10, "1"));
|
MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&g_one, 10, "1"));
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK(mbedtls_mpi_add_int(&t_prime, &t_prime, g_primes[i]));
|
MBEDTLS_MPI_CHK(mbedtls_mpi_add_int(&t_prime, &t_prime, primes[i]));
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK(mbedtls_mpi_mod_mpi(&t_temp, &t_modulus, &t_prime));
|
MBEDTLS_MPI_CHK(mbedtls_mpi_mod_mpi(&t_temp, &t_modulus, &t_prime));
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(&g_one, mpi_get_uint(&t_temp)));
|
MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(&g_one, mpi_get_uint(&t_temp)));
|
||||||
|
|
||||||
if (bitand_is_zero(&g_one, &g_prints[i])) {
|
if (bitand_is_zero(&g_one, &prints[i])) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
PrintAndLogEx(FAILED, "No fingerprint found.\n");
|
PrintAndLogEx(FAILED, "No fingerprint found.\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -138,7 +136,7 @@ bool emv_rocacheck(const unsigned char *buf, size_t buflen, bool verbose) {
|
||||||
cleanup:
|
cleanup:
|
||||||
mbedtls_mpi_free(&t_modulus);
|
mbedtls_mpi_free(&t_modulus);
|
||||||
|
|
||||||
rocacheck_cleanup();
|
rocacheck_cleanup(prints);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
int GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
int GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||||
size_t GraphTraceLen;
|
size_t GraphTraceLen;
|
||||||
int s_Buff[MAX_GRAPH_TRACE_LEN];
|
|
||||||
|
|
||||||
/* write a manchester bit to the graph
|
/* write a manchester bit to the graph
|
||||||
TODO, verfy that this doesn't overflow buffer (iceman)
|
TODO, verfy that this doesn't overflow buffer (iceman)
|
||||||
|
|
|
@ -40,7 +40,6 @@ bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge);
|
||||||
|
|
||||||
extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
extern int GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||||
extern size_t GraphTraceLen;
|
extern size_t GraphTraceLen;
|
||||||
extern int s_Buff[MAX_GRAPH_TRACE_LEN];
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,11 +34,12 @@
|
||||||
|
|
||||||
extern "C" int preferences_save(void);
|
extern "C" int preferences_save(void);
|
||||||
|
|
||||||
bool g_useOverlays = false;
|
static int s_Buff[MAX_GRAPH_TRACE_LEN];
|
||||||
int g_absVMax = 0;
|
static bool g_useOverlays = false;
|
||||||
uint32_t startMax; // Maximum offset in the graph (right side of graph)
|
static int g_absVMax = 0;
|
||||||
uint32_t PageWidth; // How many samples are currently visible on this 'page' / graph
|
static uint32_t startMax; // Maximum offset in the graph (right side of graph)
|
||||||
int unlockStart = 0;
|
static uint32_t PageWidth; // How many samples are currently visible on this 'page' / graph
|
||||||
|
static int unlockStart = 0;
|
||||||
|
|
||||||
void ProxGuiQT::ShowGraphWindow(void) {
|
void ProxGuiQT::ShowGraphWindow(void) {
|
||||||
emit ShowGraphWindowSignal();
|
emit ShowGraphWindowSignal();
|
||||||
|
|
|
@ -134,9 +134,9 @@ static int check_comm(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// first slot is always NULL, indicating absence of script when idx=0
|
// first slot is always NULL, indicating absence of script when idx=0
|
||||||
FILE *cmdscriptfile[MAX_NESTED_CMDSCRIPT + 1] = {0};
|
static FILE *cmdscriptfile[MAX_NESTED_CMDSCRIPT + 1] = {0};
|
||||||
uint8_t cmdscriptfile_idx = 0;
|
static uint8_t cmdscriptfile_idx = 0;
|
||||||
bool cmdscriptfile_stayafter = false;
|
static bool cmdscriptfile_stayafter = false;
|
||||||
|
|
||||||
int push_cmdscriptfile(char *path, bool stayafter) {
|
int push_cmdscriptfile(char *path, bool stayafter) {
|
||||||
if (cmdscriptfile_idx == MAX_NESTED_CMDSCRIPT) {
|
if (cmdscriptfile_idx == MAX_NESTED_CMDSCRIPT) {
|
||||||
|
|
|
@ -77,8 +77,8 @@ struct timeval timeout = {
|
||||||
.tv_usec = UART_FPC_CLIENT_RX_TIMEOUT_MS * 1000
|
.tv_usec = UART_FPC_CLIENT_RX_TIMEOUT_MS * 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32_t newtimeout_value = 0;
|
static uint32_t newtimeout_value = 0;
|
||||||
bool newtimeout_pending = false;
|
static bool newtimeout_pending = false;
|
||||||
|
|
||||||
int uart_reconfigure_timeouts(uint32_t value) {
|
int uart_reconfigure_timeouts(uint32_t value) {
|
||||||
newtimeout_value = value;
|
newtimeout_value = value;
|
||||||
|
|
|
@ -44,7 +44,7 @@ session_arg_t session;
|
||||||
double CursorScaleFactor = 1;
|
double CursorScaleFactor = 1;
|
||||||
int PlotGridX = 0, PlotGridY = 0, PlotGridXdefault = 64, PlotGridYdefault = 64;
|
int PlotGridX = 0, PlotGridY = 0, PlotGridXdefault = 64, PlotGridYdefault = 64;
|
||||||
uint32_t CursorCPos = 0, CursorDPos = 0;
|
uint32_t CursorCPos = 0, CursorDPos = 0;
|
||||||
bool flushAfterWrite = 0;
|
static bool flushAfterWrite = 0;
|
||||||
int GridOffset = 0;
|
int GridOffset = 0;
|
||||||
bool GridLocked = false;
|
bool GridLocked = false;
|
||||||
bool showDemod = true;
|
bool showDemod = true;
|
||||||
|
@ -176,7 +176,7 @@ void PrintAndLogOptions(const char *str[][2], size_t size, size_t space) {
|
||||||
PrintAndLogEx(NORMAL, "%s", buff);
|
PrintAndLogEx(NORMAL, "%s", buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PrintAndLogEx_spinidx = 0;
|
static uint8_t PrintAndLogEx_spinidx = 0;
|
||||||
|
|
||||||
void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue