]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: the "make clean" for mfkey/Makefile now deletes the executables.
authoriceman1001 <iceman@iuse.se>
Sun, 17 Jan 2016 22:06:48 +0000 (23:06 +0100)
committericeman1001 <iceman@iuse.se>
Sun, 17 Jan 2016 22:06:48 +0000 (23:06 +0100)
tools/mfkey/Makefile
tools/mfkey/crapto1.c
tools/nonce2key/crapto1.c

index 5553d9643a5ce1650ac6bdd9afb3d42128fecf29..a1bc44ad0d3f0fb403d9339a28965db50d5a68f9 100755 (executable)
@@ -4,8 +4,8 @@ CFLAGS = -Wall -Winline -O4
 LDFLAGS =
 
 OBJS = crapto1.o crypto1.o
-HEADERS = 
-EXES = mfkey64 mfkey32 mfkey32v2
+HEADERS = crapto1.h
+EXES = mfkey64 mfkey64.exe mfkey32 mfkey32.exe mfkey32v2 mfkey32v2.exe
 LIBS =
        
 all: $(OBJS) $(EXES) $(LIBS)
index 5715ad27a95c2221f9729b432e1894c45eaeb669..d0ca9e83b1cf6807d1bd84d7d7d354eb0fe55c17 100755 (executable)
@@ -110,9 +110,9 @@ extend_table(uint32_t *tbl, uint32_t **end, int bit, int m1, int m2, uint32_t in
 static inline void extend_table_simple(uint32_t *tbl, uint32_t **end, int bit)\r
 {\r
        for(*tbl <<= 1; tbl <= *end; *++tbl <<= 1)\r
-               if(filter(*tbl) ^ filter(*tbl | 1))\r
+               if(filter(*tbl) ^ filter(*tbl | 1)) {\r
                        *tbl |= filter(*tbl) ^ bit;\r
-               else if(filter(*tbl) == bit) {\r
+               else if(filter(*tbl) == bit) {\r
                        *++*end = *++tbl;\r
                        *tbl = tbl[-1] | 1;\r
                } else\r
@@ -378,6 +378,8 @@ int nonce_distance(uint32_t from, uint32_t to)
 static uint32_t fastfwd[2][8] = {\r
        { 0, 0x4BC53, 0xECB1, 0x450E2, 0x25E29, 0x6E27A, 0x2B298, 0x60ECB},\r
        { 0, 0x1D962, 0x4BC53, 0x56531, 0xECB1, 0x135D3, 0x450E2, 0x58980}};\r
+\r
+\r
 /** lfsr_prefix_ks\r
  *\r
  * Is an exported helper function from the common prefix attack\r
@@ -413,9 +415,7 @@ uint32_t *lfsr_prefix_ks(uint8_t ks[8], int isodd)
 /** check_pfx_parity\r
  * helper function which eliminates possible secret states using parity bits\r
  */\r
-static struct Crypto1State*\r
-check_pfx_parity(uint32_t prefix, uint32_t rresp, uint8_t parities[8][8],\r
-               uint32_t odd, uint32_t even, struct Crypto1State* sl)\r
+static struct Crypto1State* check_pfx_parity(uint32_t prefix, uint32_t rresp, uint8_t parities[8][8], uint32_t odd, uint32_t even, struct Crypto1State* sl)\r
 {\r
        uint32_t ks1, nr, ks2, rr, ks3, c, good = 1;\r
 \r
@@ -446,9 +446,14 @@ check_pfx_parity(uint32_t prefix, uint32_t rresp, uint8_t parities[8][8],
 \r
 /** lfsr_common_prefix\r
  * Implentation of the common prefix attack.\r
+ * Requires the 28 bit constant prefix used as reader nonce (pfx)\r
+ * The reader response used (rr)\r
+ * The keystream used to encrypt the observed NACK's (ks)\r
+ * The parity bits (par)\r
+ * It returns a zero terminated list of possible cipher states after the\r
+ * tag nonce was fed in\r
  */\r
-struct Crypto1State*\r
-lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8], uint8_t par[8][8])\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
        uint32_t *odd, *even, *o, *e, top;\r
@@ -459,8 +464,9 @@ lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8], uint8_t par[8][8])
        s = statelist = malloc((sizeof *statelist) << 20);\r
        if(!s || !odd || !even) {\r
                free(statelist);\r
-               statelist = 0;\r
-                goto out;\r
+               free(odd);\r
+               free(even);\r
+               return 0;\r
        }\r
 \r
        for(o = odd; *o + 1; ++o)\r
@@ -472,8 +478,6 @@ lfsr_common_prefix(uint32_t pfx, uint32_t rr, uint8_t ks[8], uint8_t par[8][8])
                        }\r
 \r
        s->odd = s->even = 0;\r
-out:\r
-       free(odd);\r
-       free(even);\r
+\r
        return statelist;\r
 }\r
index 5b3bab3e4df259ca9790b081bb3933acbeaa99b8..8d514a0cdd8ea6d79b92d69d63546c5f9870be28 100644 (file)
@@ -15,7 +15,7 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor,\r
     Boston, MA  02110-1301, US$\r
 \r
-    Copyright (C) 2008-2008 bla <blapost@gmail.com>\r
+    Copyright (C) 2008-2014 bla <blapost@gmail.com>\r
 */\r
 #include "crapto1.h"\r
 #include <stdlib.h>\r
@@ -107,8 +107,7 @@ extend_table(uint32_t *tbl, uint32_t **end, int bit, int m1, int m2, uint32_t in
 /** extend_table_simple\r
  * using a bit of the keystream extend the table of possible lfsr states\r
  */\r
-static inline void\r
-extend_table_simple(uint32_t *tbl, uint32_t **end, int bit)\r
+static inline void extend_table_simple(uint32_t *tbl, uint32_t **end, int bit)\r
 {\r
        for(*tbl <<= 1; tbl <= *end; *++tbl <<= 1)\r
                if(filter(*tbl) ^ filter(*tbl | 1)) {\r
Impressum, Datenschutz