mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
CHG: fixed the collapsing comments when opening this file in notepad++ Need spaces between // text or /* ...
This commit is contained in:
parent
4c44d88500
commit
f38cfd6693
1 changed files with 36 additions and 50 deletions
|
@ -2142,28 +2142,12 @@ int32_t dist_nt(uint32_t nt1, uint32_t nt2) {
|
||||||
|
|
||||||
if (nt1 == nt2) return 0;
|
if (nt1 == nt2) return 0;
|
||||||
|
|
||||||
uint16_t i;
|
|
||||||
uint32_t nttmp1 = nt1;
|
uint32_t nttmp1 = nt1;
|
||||||
uint32_t nttmp2 = nt2;
|
uint32_t nttmp2 = nt2;
|
||||||
|
|
||||||
for (i = 1; i < (32768/8); ++i) {
|
for (uint16_t i = 1; i < 0xFFFF; ++i) {
|
||||||
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i;
|
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i;
|
||||||
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -i;
|
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -i;
|
||||||
|
|
||||||
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i+1;
|
|
||||||
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -(i+1);
|
|
||||||
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i+2;
|
|
||||||
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -(i+2);
|
|
||||||
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i+3;
|
|
||||||
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -(i+3);
|
|
||||||
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i+4;
|
|
||||||
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -(i+4);
|
|
||||||
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i+5;
|
|
||||||
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -(i+5);
|
|
||||||
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i+6;
|
|
||||||
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -(i+6);
|
|
||||||
nttmp1 = prng_successor(nttmp1, 1); if (nttmp1 == nt2) return i+7;
|
|
||||||
nttmp2 = prng_successor(nttmp2, 1); if (nttmp2 == nt1) return -(i+7);
|
|
||||||
}
|
}
|
||||||
// either nt1 or nt2 are invalid nonces
|
// either nt1 or nt2 are invalid nonces
|
||||||
return(-99999);
|
return(-99999);
|
||||||
|
@ -2175,6 +2159,7 @@ int32_t dist_nt(uint32_t nt1, uint32_t nt2) {
|
||||||
// Cloning MiFare Classic Rail and Building Passes, Anywhere, Anytime"
|
// Cloning MiFare Classic Rail and Building Passes, Anywhere, Anytime"
|
||||||
// (article by Nicolas T. Courtois, 2009)
|
// (article by Nicolas T. Courtois, 2009)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype ) {
|
void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype ) {
|
||||||
|
|
||||||
uint8_t mf_auth[] = { keytype, block, 0x00, 0x00 };
|
uint8_t mf_auth[] = { keytype, block, 0x00, 0x00 };
|
||||||
|
@ -2221,10 +2206,12 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype ) {
|
||||||
sync_time = GetCountSspClk() & 0xfffffff8;
|
sync_time = GetCountSspClk() & 0xfffffff8;
|
||||||
// iceman, i add 1130 because during my observations this makse the syncronization much fast to sync.
|
// iceman, i add 1130 because during my observations this makse the syncronization much fast to sync.
|
||||||
sync_cycles = PRNG_SEQUENCE_LENGTH + 1130; //65536; // Mifare Classic's random generator repeats every 2^16 cycles (and so do the nonces).
|
sync_cycles = PRNG_SEQUENCE_LENGTH + 1130; //65536; // Mifare Classic's random generator repeats every 2^16 cycles (and so do the nonces).
|
||||||
|
nt_attacked = 0;
|
||||||
|
|
||||||
|
if (MF_DBGLEVEL >= 4) Dbprintf("Mifare::Sync %08x", sync_time);
|
||||||
|
|
||||||
if (first_try) {
|
if (first_try) {
|
||||||
mf_nr_ar3 = 0;
|
mf_nr_ar3 = 0;
|
||||||
nt_attacked = 0;
|
|
||||||
par_low = 0;
|
par_low = 0;
|
||||||
} else {
|
} else {
|
||||||
// we were unsuccessful on a previous call.
|
// we were unsuccessful on a previous call.
|
||||||
|
@ -2293,11 +2280,9 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype ) {
|
||||||
// Transmit reader nonce with fake par
|
// Transmit reader nonce with fake par
|
||||||
ReaderTransmitPar(mf_nr_ar, sizeof(mf_nr_ar), par, NULL);
|
ReaderTransmitPar(mf_nr_ar, sizeof(mf_nr_ar), par, NULL);
|
||||||
|
|
||||||
WDT_HIT();
|
|
||||||
LED_B_ON();
|
|
||||||
// we didn't calibrate our clock yet,
|
// we didn't calibrate our clock yet,
|
||||||
// iceman: has to be calibrated every time.
|
// iceman: has to be calibrated every time.
|
||||||
if (previous_nt && !nt_attacked) {
|
if (first_try && previous_nt && !nt_attacked) {
|
||||||
|
|
||||||
nt_distance = dist_nt(previous_nt, nt);
|
nt_distance = dist_nt(previous_nt, nt);
|
||||||
|
|
||||||
|
@ -2426,6 +2411,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype ) {
|
||||||
set_tracing(FALSE);
|
set_tracing(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*MIFARE 1K simulate.
|
*MIFARE 1K simulate.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue