]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/cmdhfmf.c
Provide msclock() as Milliseconds timer for performance measures (#231)
[proxmark3-svn] / client / cmdhfmf.c
index d5ce118b52d70452ae36b719feefe4a4e40585dd..b3f7acb2a1e1d0f12a16e2dd7341fdfc172e4d7e 100644 (file)
@@ -9,8 +9,20 @@
 //-----------------------------------------------------------------------------\r
 \r
 #include <inttypes.h>\r
-#include "cmdhfmf.h"\r
-#include "./nonce2key/nonce2key.h"\r
+#include <string.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <ctype.h>\r
+#include "proxmark3.h"\r
+#include "cmdmain.h"\r
+#include "util.h"\r
+#include "ui.h"\r
+#include "mifarehost.h"\r
+#include "mifare.h"\r
+#include "nonce2key/nonce2key.h"\r
+\r
+#define NESTED_SECTOR_RETRY     10                     // how often we try mfested() until we give up\r
+\r
 \r
 static int CmdHelp(const char *Cmd);\r
 \r
@@ -551,10 +563,17 @@ int CmdHF14AMfRestore(const char *Cmd)
        return 0;\r
 }\r
 \r
+\r
+typedef struct {\r
+       uint64_t Key[2];\r
+       int foundKey[2];\r
+} sector_t;\r
+\r
+\r
 int CmdHF14AMfNested(const char *Cmd)\r
 {\r
        int i, j, res, iterations;\r
-       sector *e_sector = NULL;\r
+       sector_t *e_sector = NULL;\r
        uint8_t blockNo = 0;\r
        uint8_t keyType = 0;\r
        uint8_t trgBlockNo = 0;\r
@@ -671,10 +690,10 @@ int CmdHF14AMfNested(const char *Cmd)
                }\r
        }\r
        else { // ------------------------------------  multiple sectors working\r
-               clock_t time1;\r
-               time1 = clock();\r
+               uint64_t msclock1;\r
+               msclock1 = msclock();\r
 \r
-               e_sector = calloc(SectorsCnt, sizeof(sector));\r
+               e_sector = calloc(SectorsCnt, sizeof(sector_t));\r
                if (e_sector == NULL) return 1;\r
                \r
                //test current key and additional standard keys first\r
@@ -742,7 +761,7 @@ int CmdHF14AMfNested(const char *Cmd)
                        }\r
                }\r
 \r
-               printf("Time in nested: %1.3f (%1.3f sec per key)\n\n", ((float)clock() - time1)/CLOCKS_PER_SEC, ((float)clock() - time1)/iterations/CLOCKS_PER_SEC);\r
+               printf("Time in nested: %1.3f (%1.3f sec per key)\n\n", ((float)(msclock() - msclock1))/1000.0, ((float)(msclock() - msclock1))/iterations/1000.0);\r
                \r
                PrintAndLog("-----------------------------------------------\nIterations count: %d\n\n", iterations);\r
                //print them\r
@@ -1768,7 +1787,7 @@ int CmdHF14AMfCSetBlk(const char *Cmd)
 {\r
        uint8_t memBlock[16] = {0x00};\r
        uint8_t blockNo = 0;\r
-       bool wipeCard = FALSE;\r
+       bool wipeCard = false;\r
        int res;\r
 \r
        if (strlen(Cmd) < 1 || param_getchar(Cmd, 0) == 'h') {\r
Impressum, Datenschutz