-void legic_prng_init(uint8_t init) {
- lfsr.c = 0;
- lfsr.a = init;
- if(init == 0) /* hack to get a always 0 keystream */
- lfsr.b = 0;
- else
- lfsr.b = (init << 1) | 1;
+// Normal init is set following variables with a random value IV
+// a == iv
+// b == iv << 1 | 1
+// * someone mentioned iv must be ODD.
+// Hack:
+// Now we have a special case with iv == 0
+// it sets b to 0 aswell to make sure we get a all zero keystream out
+// which is used in the initialisation phase sending the IV
+//
+void legic_prng_init(uint8_t iv) {
+ lfsr.a = iv;
+ lfsr.b = 0; // hack to get a always 0 keystream
+ lfsr.c = 0;
+ if(iv)
+ lfsr.b = (iv << 1) | 1;