Merge pull request #167 from gm4tr1x/issue84
[hashcat.git] / src / oclHashcat.c
index da3732c..5ba2c99 100644 (file)
@@ -162,10 +162,10 @@ static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
   5000,
   10100,
   6000,
-  6100,
-  6900,
-  11700,
-  11800,
+  6100, // broken in osx
+  6900, // broken in osx
+  11700, // broken in osx
+  11800, // broken in osx
   400,
   8900,
   11900,
@@ -174,55 +174,55 @@ static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
   12100,
   23,
   2500,
-  5300,
-  5400,
-  5500,
-  5600,
+  5300, // broken in osx
+  5400, // broken in osx
+  5500, // broken in osx
+  5600, // broken in osx
   7300,
-  7500,
+  7500, // broken in osx
   8300,
-  11100,
+  11100, // broken in osx
   11200,
-  11400,
+  11400, // broken in osx
   121,
-  2611,
-  2711,
-  2811,
-  8400,
+  2611, // broken in osx
+  2711, // broken in osx
+  2811, // broken in osx
+  8400, // broken in osx
   11,
-  2612,
+  2612, // broken in osx
   7900,
   21,
   11000,
   124,
   10000,
-  3711,
-  7600,
+  3711, // broken in osx
+  7600, // broken in osx
   12,
   131,
   132,
   1731,
   200,
   300,
-  3100,
+  3100, // broken in osx
   112,
   12300,
-  8000,
+  8000, // broken in osx
   141,
   1441,
   1600,
-  12600,
+  12600, // broken in osx
   1421,
   101,
   111,
   1711,
-  3000,
+  3000, // broken in osx
   1000,
   1100,
   2100,
   12800,
-  1500,
-  12400,
+  1500, // broken in osx
+  12400, // broken in osx
   500,
   3200,
   7400,
@@ -243,45 +243,45 @@ static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
   501,
   5800,
   8100,
-  8500,
+  8500, // broken in osx
   7200,
   9900,
   7700,
   7800,
   10300,
-  8600,
-  8700,
-  9100,
+  8600, // broken in osx
+  8700, // broken in osx
+  9100, // broken in osx
   133,
-  11600,
-  12500,
+  11600, // broken in osx
+  12500, // broken in osx
   13000,
   6211,
   6221,
-  6231,
+  6231, // broken in osx
   6241,
-  8800,
+  8800, // broken in osx
   12900,
   12200,
-  9700,
-  9710,
-  9800,
-  9810,
-  9400,
-  9500,
-  9600,
-  10400,
-  10410,
+  9700, // broken in osx
+  9710, // broken in osx
+  9800, // broken in osx
+  9810, // broken in osx
+  9400, // broken in osx
+  9500, // broken in osx
+  9600, // broken in osx
+  10400, // broken in osx
+  10410, // broken in osx
   10500,
   10600,
-  10700,
+  10700, // broken in osx
   9000,
   5200,
-  6800,
-  6600,
+  6800, // broken in osx
+  6600, // broken in osx
   8200,
-  11300,
-  12700
+  11300, // broken in osx
+  12700 // broken in osx
 };
 
 /**
@@ -1883,7 +1883,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
 
     for (int i = 0, j = gidm; i < 16; i++, j++)
     {
-      plain_buf[i] = pw.hi1[0][j];
+      plain_buf[i] = pw.h.hi1[0][j];
     }
 
     plain_len = pw.pw_len;
@@ -1932,7 +1932,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
 
     for (int i = 0, j = gidm; i < 16; i++, j++)
     {
-      plain_buf[i] = pw.hi1[0][j];
+      plain_buf[i] = pw.h.hi1[0][j];
     }
 
     plain_len = pw.pw_len;
@@ -1993,7 +1993,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
 
     for (int i = 0, j = gidm; i < 16; i++, j++)
     {
-      plain_buf[i] = pw.hi1[0][j];
+      plain_buf[i] = pw.h.hi1[0][j];
     }
 
     plain_len = pw.pw_len;
@@ -2027,7 +2027,7 @@ static void check_hash (hc_device_param_t *device_param, const uint salt_pos, co
 
     for (int i = 0, j = gidm; i < 16; i++, j++)
     {
-      plain_buf[i] = pw.hi1[0][j];
+      plain_buf[i] = pw.h.hi1[0][j];
     }
 
     plain_len = pw.pw_len;
@@ -3341,7 +3341,7 @@ static u64 count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t
 
 static void pw_transpose_to_hi1 (const pw_t *p1, pw_t *p2)
 {
-  memcpy (p2->hi1, p1->hi1, 64 * sizeof (uint));
+  memcpy (p2->h.hi1, p1->h.hi1, 64 * sizeof (uint));
 }
 
 static uint pw_add_to_hc1 (hc_device_param_t *device_param, const u8 *pw_buf, const uint pw_len)
@@ -3352,7 +3352,7 @@ static uint pw_add_to_hc1 (hc_device_param_t *device_param, const u8 *pw_buf, co
 
   uint cache_cnt = pw_cache->cnt;
 
-  u8 *pw_hc1 = pw_cache->pw_buf.hc1[cache_cnt];
+  u8 *pw_hc1 = pw_cache->pw_buf.h.hc1[cache_cnt];
 
   memcpy (pw_hc1, pw_buf, pw_len);
 
@@ -11399,7 +11399,9 @@ int main (int argc, char **argv)
                        kernel_accel = 16;
                        break;
           case  6211:  kernel_loops = ROUNDS_TRUECRYPT_2K;
+                       #ifndef OSX
                        kernel_accel = 64;
+                       #endif
                        break;
           case  6212:  kernel_loops = ROUNDS_TRUECRYPT_2K;
                        kernel_accel = 32;
@@ -11426,7 +11428,9 @@ int main (int argc, char **argv)
                        kernel_accel = 8;
                        break;
           case  6241:  kernel_loops = ROUNDS_TRUECRYPT_1K;
+                       #ifndef OSX
                        kernel_accel = 128;
+                       #endif
                        break;
           case  6242:  kernel_loops = ROUNDS_TRUECRYPT_1K;
                        kernel_accel = 64;
@@ -11456,7 +11460,9 @@ int main (int argc, char **argv)
                        kernel_accel = 8;
                        break;
           case  7200:  kernel_loops = ROUNDS_GRUB;
+                       #ifndef OSX
                        kernel_accel = 16;
+                       #endif
                        break;
           case  7400:  kernel_loops = ROUNDS_SHA256CRYPT;
                        kernel_accel = 8;
@@ -13209,6 +13215,37 @@ int main (int argc, char **argv)
     #endif // HAVE_ADK
     #endif // HAVE_HWMON
 
+    #ifdef OSX
+    /*
+     * List of OSX kernel to fix
+     */
+    if ((hash_mode == 6100)  || (hash_mode == 6900)  || (hash_mode == 11700) || (hash_mode == 11800) || (hash_mode == 5300)  || \
+        (hash_mode == 5400)  || (hash_mode == 5500)  || (hash_mode == 5600)  || (hash_mode == 7500)  || (hash_mode == 11100) || \
+        (hash_mode == 11400) || (hash_mode == 2611)  || (hash_mode == 2711)  || (hash_mode == 2811)  || (hash_mode == 8400)  || \
+        (hash_mode == 2612)  || (hash_mode == 3711)  || (hash_mode == 7600)  || (hash_mode == 3100)  || (hash_mode == 8000)  || \
+        (hash_mode == 12600) || (hash_mode == 3000)  || (hash_mode == 1500)  || (hash_mode == 12400) || (hash_mode == 8500)  || \
+        (hash_mode == 8600)  || (hash_mode == 8700)  || (hash_mode == 9100)  || (hash_mode == 11600) || (hash_mode == 12500) || \
+        (hash_mode == 6231)  || (hash_mode == 8800)  || (hash_mode == 9700)  || (hash_mode == 9710)  || (hash_mode == 9800)  || \
+        (hash_mode == 9810)  || (hash_mode == 9400)  || (hash_mode == 9500)  || (hash_mode == 9600)  || (hash_mode == 10400) || \
+        (hash_mode == 10410) || (hash_mode == 10700) || (hash_mode == 6800)  || (hash_mode == 6600)  || (hash_mode == 11300) || \
+        (hash_mode == 12700))
+    {
+      if (force == 0)
+      {
+        log_info ("");
+        log_info ("Warning: Hash mode %d is not stable in OSX.", hash_mode);
+        log_info ("You can use --force to override this but do not post error reports if you do so");
+        log_info ("");
+
+        continue;
+      }
+    }
+    #endif
+
+    #ifdef DEBUG
+    if (benchmark == 1) log_info ("Hashmode: %d", data.hash_mode);
+    #endif
+
     uint kernel_blocks_all = 0;
 
     for (uint device_id = 0; device_id < devices_cnt; device_id++)
@@ -15640,9 +15677,9 @@ int main (int argc, char **argv)
 
           // some more resets:
 
-          memset (device_param->pw_caches, 0, 64 * sizeof (pw_cache_t));
+          if (device_param->pw_caches) memset (device_param->pw_caches, 0, 64 * sizeof (pw_cache_t));
 
-          memset (device_param->pws_buf, 0, device_param->size_pws);
+          if (device_param->pws_buf) memset (device_param->pws_buf, 0, device_param->size_pws);
 
           device_param->pw_cnt  = 0;
           device_param->pws_cnt = 0;