#include <stdlib.h>\r
\r
#if !defined LOWMEM && defined __GNUC__\r
-static uint8_t filterlut[1 << 20];\r
+uint8_t filterlut[1 << 20];\r
static void __attribute__((constructor)) fill_lut()\r
{\r
- uint32_t i;\r
- for(i = 0; i < 1 << 20; ++i)\r
- filterlut[i] = filter(i);\r
+ uint32_t x;\r
+ uint32_t f;\r
+ for(x = 0; x < 1 << 20; ++x) {\r
+ f = 0xf22c0 >> (x & 0xf) & 16;\r
+ f |= 0x6c9c0 >> (x >> 4 & 0xf) & 8;\r
+ f |= 0x3c8b0 >> (x >> 8 & 0xf) & 4;\r
+ f |= 0x1e458 >> (x >> 12 & 0xf) & 2;\r
+ f |= 0x0d938 >> (x >> 16 & 0xf) & 1;\r
+ filterlut[x] = BIT(0xEC57E80A, f);\r
+ }\r
}\r
-#define filter(x) (filterlut[(x) & 0xfffff])\r
#endif\r
\r
\r
*/\r
void lfsr_rollback_byte(struct Crypto1State *s, uint32_t in, int fb)\r
{\r
- int i;\r
+/* int i;\r
for (i = 7; i >= 0; --i)\r
lfsr_rollback_bit(s, BEBIT(in, i), fb);\r
+*/\r
+// unfold loop 20160112\r
+ lfsr_rollback_bit(s, BEBIT(in, 7), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 6), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 5), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 4), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 3), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 2), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 1), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 0), fb);\r
}\r
/** lfsr_rollback_word\r
* Rollback the shift register in order to get previous states\r
*/\r
void lfsr_rollback_word(struct Crypto1State *s, uint32_t in, int fb)\r
{\r
+/*\r
int i;\r
for (i = 31; i >= 0; --i)\r
lfsr_rollback_bit(s, BEBIT(in, i), fb);\r
+*/\r
+// unfold loop 20160112\r
+ lfsr_rollback_bit(s, BEBIT(in, 31), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 30), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 29), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 28), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 27), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 26), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 25), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 24), fb);\r
+\r
+ lfsr_rollback_bit(s, BEBIT(in, 23), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 22), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 21), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 20), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 19), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 18), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 17), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 16), fb);\r
+\r
+ lfsr_rollback_bit(s, BEBIT(in, 15), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 14), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 13), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 12), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 11), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 10), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 9), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 8), fb);\r
+\r
+ lfsr_rollback_bit(s, BEBIT(in, 7), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 6), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 5), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 4), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 3), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 2), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 1), fb);\r
+ lfsr_rollback_bit(s, BEBIT(in, 0), fb);\r
}\r
\r
/** nonce_distance\r