]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - armsrc/crapto1.c
syntax sugar
[proxmark3-svn] / armsrc / crapto1.c
index 627cce4f4f0a7fbb13b4e59ad1cc66db96d22bc7..e2058651392f8ee96c593048de6c5af024515aeb 100644 (file)
@@ -24,9 +24,9 @@
 static 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 i;\r
+       for(i = 0; i < 1 << 20; ++i)\r
+                       filterlut[i] = filter(i);\r
 }\r
 #define filter(x) (filterlut[(x) & 0xfffff])\r
 #endif\r
@@ -419,10 +419,11 @@ static uint16_t *dist = 0;
 int nonce_distance(uint32_t from, uint32_t to)\r
 {\r
        uint16_t x, i;\r
-       if(!dist) {\r
+       // generate distance lookup table\r
+       if (!dist) {\r
                dist = malloc(2 << 16);\r
-               if(!dist)\r
-                       return -1;\r
+               if (!dist) return -1;\r
+               \r
                for (x = i = 1; i; ++i) {\r
                        dist[(x & 0xff) << 8 | x >> 8] = i;\r
                        x = x >> 1 | (x ^ x >> 2 ^ x >> 3 ^ x >> 5) << 15;\r
@@ -446,7 +447,7 @@ static uint32_t fastfwd[2][8] = {
  * encrypt the NACK which is observed when varying only the 3 last bits of Nr\r
  * only correct iff [NR_3] ^ NR_3 does not depend on Nr_3\r
  */\r
-uint32_t *lfsr_prefix_ks(uint8_t ks[8], int isodd)\r
+uint32_tlfsr_prefix_ks(uint8_t ks[8], int isodd)\r
 {\r
        uint32_t *candidates = malloc(4 << 10);\r
        if(!candidates) return 0;\r
@@ -509,7 +510,6 @@ static struct Crypto1State* check_pfx_parity(uint32_t prefix, uint32_t rresp, ui
  * 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
@@ -521,9 +521,8 @@ struct Crypto1State* lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8]
        s = statelist = malloc((sizeof *statelist) << 21);\r
        if(!s || !odd || !even) {\r
                free(statelist);\r
-               free(odd);\r
-               free(even);\r
-               return 0;\r
+               statelist = 0;\r
+               goto out;\r
        }\r
 \r
        for(o = odd; *o + 1; ++o)\r
@@ -535,7 +534,7 @@ struct Crypto1State* lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8]
                        }\r
 \r
        s->odd = s->even = 0;\r
-\r
+out:\r
        free(odd);\r
        free(even);\r
        return statelist;\r
Impressum, Datenschutz