proxmark3
proxmark3 copied to clipboard
Beware of clock wrapping
Eg
ti = GetTickCount();
[...]
ti = GetTickCount() - ti;
doesn't take into account when RTTC_RTVR wraps around. Better to have some GetTickDelta(uint32_t start_tick) that does the job properly.
ti = GetTickCount();
[...]
ti = GetTickDelta(ti);
Not just GetTickCount has these kinds of issues. One popular click-death was just the darkside attack in iso14443a.c was based on this kind of bug.
GetTickCountDelta was added and used everywhere. Where else to look at ? Or first we need to identify & document these clocks?
I would suggest we identfy and document these clocks. Especially which that can't be mixed / used together.
Was playing with iclass timing, since they are kind of crap, it uses SspClk and SpinDelayUS.. I thought it would be a good thing to test WaitUS... haha, not, because it uses the same clocks TC0,TC1, TC2 as Ssp ...