for (i = 7; i >= 0; --i)\r
ret |= lfsr_rollback_bit(s, BIT(in, i), fb) << i;\r
*/\r
-\r
+// unfold loop 20160112\r
uint8_t ret = 0;\r
ret |= lfsr_rollback_bit(s, BIT(in, 7), fb) << 7;\r
ret |= lfsr_rollback_bit(s, BIT(in, 6), fb) << 6;\r
for (i = 31; i >= 0; --i)\r
ret |= lfsr_rollback_bit(s, BEBIT(in, i), fb) << (i ^ 24);\r
*/\r
- \r
+// unfold loop 20160112\r
uint32_t ret = 0;\r
ret |= lfsr_rollback_bit(s, BEBIT(in, 31), fb) << (31 ^ 24);\r
ret |= lfsr_rollback_bit(s, BEBIT(in, 30), fb) << (30 ^ 24);\r
ret |= lfsr_rollback_bit(s, BEBIT(in, 2), fb) << (2 ^ 24);\r
ret |= lfsr_rollback_bit(s, BEBIT(in, 1), fb) << (1 ^ 24);\r
ret |= lfsr_rollback_bit(s, BEBIT(in, 0), fb) << (0 ^ 24);\r
- \r
return ret;\r
}\r
\r
uint32_t *lfsr_prefix_ks(uint8_t ks[8], int isodd)\r
{\r
uint32_t *candidates = malloc(4 << 10);\r
+ if(!candidates) return 0;\r
+ \r
uint32_t c, entry;\r
int size = 0, i, good;\r
\r
- if(!candidates)\r
- return 0;\r
-\r
for(i = 0; i < 1 << 21; ++i) {\r
for(c = 0, good = 1; good && c < 8; ++c) {\r
entry = i ^ fastfwd[isodd][c];\r
return sl + good;\r
} \r
\r
-\r
/** lfsr_common_prefix\r
* Implentation of the common prefix attack.\r
* Requires the 28 bit constant prefix used as reader nonce (pfx)\r
* It returns a zero terminated list of possible cipher states after the\r
* tag nonce was fed in\r
*/\r
+\r
struct Crypto1State* lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8], uint8_t par[8][8])\r
{\r
struct Crypto1State *statelist, *s;\r
odd = lfsr_prefix_ks(ks, 1);\r
even = lfsr_prefix_ks(ks, 0);\r
\r
- s = statelist = malloc((sizeof *statelist) << 20);\r
+ s = statelist = malloc((sizeof *statelist) << 21);\r
if(!s || !odd || !even) {\r
free(statelist);\r
free(odd);\r
\r
free(odd);\r
free(even);\r
-\r
return statelist;\r
-}\r
+}
\ No newline at end of file