]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge pull request #538 from merlokk/hardnestedsetsimd
authorIceman <iceman@iuse.se>
Sat, 6 Jan 2018 17:54:27 +0000 (18:54 +0100)
committerGitHub <noreply@github.com>
Sat, 6 Jan 2018 17:54:27 +0000 (18:54 +0100)
hardnested SIMD select

1  2 
client/cmdhfmf.c

diff --combined client/cmdhfmf.c
index c471fdf73186f5b50d54193a45ff4f9e4b0175a3,ed08917a57cccd06519a54a9e4f131ff31935227..4956df8c66e898f03fee4647db9722553a669f90
@@@ -25,6 -25,7 +25,7 @@@
  #include "mifarehost.h"\r
  #include "mifare.h"\r
  #include "mfkey.h"\r
+ #include "hardnested/hardnested_bf_core.h"\r
  \r
  #define NESTED_SECTOR_RETRY     10                    // how often we try mfested() until we give up\r
  \r
@@@ -862,6 -863,13 +863,13 @@@ int CmdHF14AMfNestedHard(const char *Cm
                PrintAndLog("      w: Acquire nonces and write them to binary file nonces.bin");\r
                PrintAndLog("      s: Slower acquisition (required by some non standard cards)");\r
                PrintAndLog("      r: Read nonces.bin and start attack");\r
+               PrintAndLog("      iX: set type of SIMD instructions. Without this flag programs autodetect it.");\r
+               PrintAndLog("        i5: AVX512");\r
+               PrintAndLog("        i2: AVX2");\r
+               PrintAndLog("        ia: AVX");\r
+               PrintAndLog("        is: SSE2");\r
+               PrintAndLog("        im: MMX");\r
+               PrintAndLog("        in: none (use CPU regular instruction set)");\r
                PrintAndLog(" ");\r
                PrintAndLog("      sample1: hf mf hardnested 0 A FFFFFFFFFFFF 4 A");\r
                PrintAndLog("      sample2: hf mf hardnested 0 A FFFFFFFFFFFF 4 A w");\r
        int tests = 0;\r
  \r
  \r
+       uint16_t iindx = 0;\r
        if (ctmp == 'R' || ctmp == 'r') {\r
                nonce_file_read = true;\r
+               iindx = 1;\r
                if (!param_gethex(Cmd, 1, trgkey, 12)) {\r
                        know_target_key = true;\r
+                       iindx = 2;\r
                }\r
        } else if (ctmp == 'T' || ctmp == 't') {\r
                tests = param_get32ex(Cmd, 1, 100, 10);\r
+               iindx = 2;\r
                if (!param_gethex(Cmd, 2, trgkey, 12)) {\r
                        know_target_key = true;\r
+                       iindx = 3;\r
                }\r
        } else {\r
                blockNo = param_get8(Cmd, 0);\r
                        know_target_key = true;\r
                        i++;\r
                }\r
+               iindx = i;\r
  \r
                while ((ctmp = param_getchar(Cmd, i))) {\r
                        if (ctmp == 's' || ctmp == 'S') {\r
                                slow = true;\r
                        } else if (ctmp == 'w' || ctmp == 'W') {\r
                                nonce_file_write = true;\r
+                       } else if (param_getlength(Cmd, i) == 2 && ctmp == 'i') {\r
+                               iindx = i;\r
                        } else {\r
-                               PrintAndLog("Possible options are w and/or s");\r
+                               PrintAndLog("Possible options are w , s and/or iX");\r
                                return 1;\r
                        }\r
                        i++;\r
                }\r
        }\r
+       \r
+       SetSIMDInstr(SIMD_AUTO);\r
+       if (iindx > 0) {\r
+               while ((ctmp = param_getchar(Cmd, iindx))) {\r
+                       if (param_getlength(Cmd, iindx) == 2 && ctmp == 'i') {\r
+                               switch(param_getchar_indx(Cmd, 1, iindx)) {\r
+                                       case '5':\r
+                                               SetSIMDInstr(SIMD_AVX512);\r
+                                               break;\r
+                                       case '2':\r
+                                               SetSIMDInstr(SIMD_AVX2);\r
+                                               break;\r
+                                       case 'a':\r
+                                               SetSIMDInstr(SIMD_AVX);\r
+                                               break;\r
+                                       case 's':\r
+                                               SetSIMDInstr(SIMD_SSE2);\r
+                                               break;\r
+                                       case 'm':\r
+                                               SetSIMDInstr(SIMD_MMX);\r
+                                               break;\r
+                                       case 'n':\r
+                                               SetSIMDInstr(SIMD_NONE);\r
+                                               break;\r
+                                       default:\r
+                                               PrintAndLog("Unknown SIMD type. %c", param_getchar_indx(Cmd, 1, iindx));\r
+                                               return 1;\r
+                               }\r
+                       }\r
+                       iindx++;\r
+               }       \r
+       }\r
  \r
        PrintAndLog("--target block no:%3d, target key type:%c, known target key: 0x%02x%02x%02x%02x%02x%02x%s, file action: %s, Slow: %s, Tests: %d ",\r
                        trgBlockNo,\r
@@@ -987,7 -1035,6 +1035,7 @@@ int CmdHF14AMfChk(const char *Cmd
        int i, res;\r
        int     keycnt = 0;\r
        char ctmp       = 0x00;\r
 +      int clen = 0;\r
        char ctmp3[3]   = {0x00};\r
        uint8_t blockNo = 0;\r
        uint8_t SectorsCnt = 0;\r
                blockNo = param_get8(Cmd, 0);\r
  \r
        ctmp = param_getchar(Cmd, 1);\r
 -      switch (ctmp) {\r
 -      case 'a': case 'A':\r
 -              keyType = 0;\r
 -              break;\r
 -      case 'b': case 'B':\r
 -              keyType = 1;\r
 -              break;\r
 -      case '?':\r
 -              keyType = 2;\r
 -              break;\r
 -      default:\r
 -              PrintAndLog("Key type must be A , B or ?");\r
 -              free(keyBlock);\r
 -              return 1;\r
 -      };\r
 +      clen = param_getlength(Cmd, 1);\r
 +      if (clen == 1) {\r
 +              switch (ctmp) {\r
 +              case 'a': case 'A':\r
 +                      keyType = 0;\r
 +                      break;\r
 +              case 'b': case 'B':\r
 +                      keyType = 1;\r
 +                      break;\r
 +              case '?':\r
 +                      keyType = 2;\r
 +                      break;\r
 +              default:\r
 +                      PrintAndLog("Key type must be A , B or ?");\r
 +                      free(keyBlock);\r
 +                      return 1;\r
 +              };\r
 +      }\r
  \r
        // transfer to emulator & create dump file\r
        ctmp = param_getchar(Cmd, 2);\r
 -      if (ctmp == 't' || ctmp == 'T') transferToEml = 1;\r
 -      if (ctmp == 'd' || ctmp == 'D') createDumpFile = 1;\r
 +      clen = param_getlength(Cmd, 2);\r
 +      if (clen == 1 && (ctmp == 't' || ctmp == 'T')) transferToEml = 1;\r
 +      if (clen == 1 && (ctmp == 'd' || ctmp == 'D')) createDumpFile = 1;\r
        \r
        param3InUse = transferToEml | createDumpFile;\r
        \r
        timeout14a = 500; // fast by default\r
        // double parameters - ts, ds\r
 -      int clen = param_getlength(Cmd, 2);\r
 +      clen = param_getlength(Cmd, 2);\r
        if (clen == 2 || clen == 3){\r
                param_getstr(Cmd, 2, ctmp3, sizeof(ctmp3));\r
                ctmp = ctmp3[1];\r
  \r
                                        if( buf[0]=='#' ) continue;     //The line start with # is comment, skip\r
  \r
 -                                      if (!isxdigit(buf[0])){\r
 +                                      if (!isxdigit((unsigned char)buf[0])){\r
                                                PrintAndLog("File content error. '%s' must include 12 HEX symbols",buf);\r
                                                continue;\r
                                        }\r
Impressum, Datenschutz