]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - common/legic_prng.c
1 #include "legic_prng.h"
2 /* legic's obfuscation function */
9 void legic_prng_init(uint8_t init
) {
11 if(init
== 0) /* hack to get a always 0 keystream */
14 lfsr
.b
= (init
<< 1) | 1;
17 void legic_prng_forward(int count
) {
21 tmp
^= (lfsr
.a
& 0x40) >> 6;
27 tmp
^= (lfsr
.b
& 4) >> 2;
29 tmp
^= (lfsr
.b
& 8) >> 3;
31 tmp
^= (lfsr
.b
& 0x80) >> 7;
38 uint8_t legic_prng_get_bit() {
39 uint8_t idx
= 7-((lfsr
.a
& 4) | ((lfsr
.a
& 8) >> 2) | ((lfsr
.a
& 0x10) >> 4));
40 return ((lfsr
.b
>> idx
) & 1);