proxmark3 icon indicating copy to clipboard operation
proxmark3 copied to clipboard

Beware of clock wrapping

Open doegox opened this issue 5 years ago • 4 comments

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);

doegox avatar May 22 '19 11:05 doegox

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.

iceman1001 avatar May 22 '19 13:05 iceman1001

GetTickCountDelta was added and used everywhere. Where else to look at ? Or first we need to identify & document these clocks?

doegox avatar May 22 '19 22:05 doegox

I would suggest we identfy and document these clocks. Especially which that can't be mixed / used together.

iceman1001 avatar May 22 '19 22:05 iceman1001

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 ...

iceman1001 avatar Aug 21 '19 13:08 iceman1001