mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-03 22:53:58 +08:00
less global vars
This commit is contained in:
parent
b9b230bb99
commit
b6077df68e
5 changed files with 13 additions and 15 deletions
|
@ -3394,6 +3394,7 @@ static int CmdHF14AMfSniff(const char *Cmd) {
|
|||
SendCommandNG(CMD_HF_MIFARE_SNIFF, NULL, 0);
|
||||
|
||||
PacketResponseNG resp;
|
||||
struct Crypto1State *traceCrypto1 = NULL;
|
||||
|
||||
// wait cycle
|
||||
while (true) {
|
||||
|
@ -3490,13 +3491,13 @@ static int CmdHF14AMfSniff(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "Trace saved to %s", logHexFileName);
|
||||
}
|
||||
if (wantDecrypt)
|
||||
mfTraceInit(uid, uid_len, atqa, sak, wantSaveToEmlFile);
|
||||
mfTraceInit(&traceCrypto1, uid, uid_len, atqa, sak, wantSaveToEmlFile);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "%03d| %s |%s", num, isTag ? "TAG" : "RDR", sprint_hex(bufPtr, len));
|
||||
if (wantLogToFile)
|
||||
AddLogHex(logHexFileName, isTag ? "TAG| " : "RDR| ", bufPtr, len);
|
||||
if (wantDecrypt)
|
||||
mfTraceDecode(bufPtr, len, wantSaveToEmlFile);
|
||||
mfTraceDecode(traceCrypto1, bufPtr, len, wantSaveToEmlFile);
|
||||
num++;
|
||||
}
|
||||
bufPtr += len;
|
||||
|
|
|
@ -54,7 +54,7 @@ t55xx_conf_block_t config = {
|
|||
.downlink_mode = refFixedBit
|
||||
};
|
||||
|
||||
t55xx_memory_item_t cardmem[T55x7_BLOCK_COUNT] = {{0}};
|
||||
static t55xx_memory_item_t cardmem[T55x7_BLOCK_COUNT] = {{0}};
|
||||
|
||||
t55xx_conf_block_t Get_t55xx_Config(void) {
|
||||
return config;
|
||||
|
|
|
@ -36,7 +36,7 @@ static bool comm_thread_dead = false;
|
|||
// Transmit buffer.
|
||||
static PacketCommandOLD txBuffer;
|
||||
static PacketCommandNGRaw txBufferNG;
|
||||
size_t txBufferNGLen;
|
||||
static size_t txBufferNGLen;
|
||||
static bool txBuffer_pending = false;
|
||||
static pthread_mutex_t txBufferMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t txBufferSig = PTHREAD_COND_INITIALIZER;
|
||||
|
|
|
@ -955,9 +955,6 @@ static int traceState = TRACE_IDLE;
|
|||
static uint8_t traceCurBlock = 0;
|
||||
static uint8_t traceCurKey = 0;
|
||||
|
||||
struct Crypto1State *traceCrypto1 = NULL;
|
||||
struct Crypto1State *revstate = NULL;
|
||||
|
||||
uint32_t cuid = 0; // uid part used for crypto1.
|
||||
|
||||
int isTraceCardEmpty(void) {
|
||||
|
@ -1046,12 +1043,12 @@ int saveTraceCard(void) {
|
|||
return PM3_SUCCESS;
|
||||
}
|
||||
//
|
||||
int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile) {
|
||||
int mfTraceInit(struct Crypto1State **traceCrypto1, uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile) {
|
||||
|
||||
if (traceCrypto1)
|
||||
crypto1_destroy(traceCrypto1);
|
||||
if (*traceCrypto1)
|
||||
crypto1_destroy(*traceCrypto1);
|
||||
|
||||
traceCrypto1 = NULL;
|
||||
*traceCrypto1 = NULL;
|
||||
|
||||
if (wantSaveToEmlFile)
|
||||
loadTraceCard(tuid, uidlen);
|
||||
|
@ -1079,7 +1076,7 @@ void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len, bool i
|
|||
}
|
||||
}
|
||||
|
||||
int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
|
||||
int mfTraceDecode(struct Crypto1State *traceCrypto1, uint8_t *data_src, int len, bool wantSaveToEmlFile) {
|
||||
if (traceState == TRACE_ERROR)
|
||||
return PM3_ESOFT;
|
||||
|
||||
|
@ -1209,7 +1206,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
|
|||
uint64_t key = 0;
|
||||
uint32_t ks2 = ar_enc ^ prng_successor(nt, 64);
|
||||
uint32_t ks3 = at_enc ^ prng_successor(nt, 96);
|
||||
revstate = lfsr_recovery64(ks2, ks3);
|
||||
struct Crypto1State *revstate = lfsr_recovery64(ks2, ks3);
|
||||
lfsr_rollback_word(revstate, 0, 0);
|
||||
lfsr_rollback_word(revstate, 0, 0);
|
||||
lfsr_rollback_word(revstate, nr_enc, 1);
|
||||
|
|
|
@ -81,8 +81,8 @@ int mfCWipe(uint8_t *uid, uint8_t *atqa, uint8_t *sak);
|
|||
int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params);
|
||||
int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);
|
||||
|
||||
int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);
|
||||
int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile);
|
||||
int mfTraceInit(struct Crypto1State **traceCrypto1, uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);
|
||||
int mfTraceDecode(struct Crypto1State *traceCrypto1, uint8_t *data_src, int len, bool wantSaveToEmlFile);
|
||||
|
||||
int isTraceCardEmpty(void);
|
||||
int isBlockEmpty(int blockN);
|
||||
|
|
Loading…
Reference in a new issue