Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / include / shared.h
index c8d6207..a9696da 100644 (file)
@@ -46,7 +46,7 @@
 #define hc_thread_mutex_delete(m)   pthread_mutex_destroy  (&m)
 #endif
 
-#ifdef OSX
+#ifdef __APPLE__
 typedef struct cpu_set
 {
   uint32_t count;
@@ -72,6 +72,20 @@ static inline int  CPU_ISSET (int num, cpu_set_t *cs) { return (cs->count & (1 <
 #define hc_dlsym dlsym
 #endif
 
+#define HC_LOAD_FUNC2(ptr,name,type,var,libname,noerr) \
+  ptr->name = (type) hc_dlsym (ptr->var, #name); \
+  if (noerr != -1) { \
+    if (!ptr->name) { \
+      if (noerr == 1) { \
+        log_error ("ERROR: %s is missing from %s shared library.", #name, #libname); \
+        exit (-1); \
+      } else { \
+        log_info ("WARNING: %s is missing from %s shared library.", #name, #libname); \
+        return -1; \
+      } \
+    } \
+  }
+
 #define HC_LOAD_FUNC(ptr,name,type,libname,noerr) \
   ptr->name = (type) hc_dlsym (ptr->lib, #name); \
   if (noerr != -1) { \
@@ -81,7 +95,7 @@ static inline int  CPU_ISSET (int num, cpu_set_t *cs) { return (cs->count & (1 <
         exit (-1); \
       } else { \
         log_info ("WARNING: %s is missing from %s shared library.", #name, #libname); \
-        return (-1); \
+        return -1; \
       } \
     } \
   }
@@ -94,7 +108,7 @@ static inline int  CPU_ISSET (int num, cpu_set_t *cs) { return (cs->count & (1 <
       exit (-1); \
     } else { \
       log_error ("WARNING: %s at address %08x is missing from %s shared library.", #name, addr, #libname); \
-      return (-1); \
+      return -1; \
     } \
   }
 
@@ -114,13 +128,10 @@ static inline int  CPU_ISSET (int num, cpu_set_t *cs) { return (cs->count & (1 <
  * temperature management
  */
 
-#if _WIN
 #include "ext_ADL.h"
 #include "ext_nvapi.h"
-#else
-#include "ext_ADL.h"
 #include "ext_nvml.h"
-#endif
+#include "ext_xnvctrl.h"
 
 /**
  * shared stuff
@@ -141,15 +152,15 @@ static inline int  CPU_ISSET (int num, cpu_set_t *cs) { return (cs->count & (1 <
 #define CL_VENDOR_NV            "NVIDIA Corporation"
 #define CL_VENDOR_POCL          "The pocl project"
 
-#define VENDOR_ID_AMD           (1 << 0)
-#define VENDOR_ID_APPLE         (1 << 1)
-#define VENDOR_ID_INTEL_BEIGNET (1 << 2)
-#define VENDOR_ID_INTEL_SDK     (1 << 3)
-#define VENDOR_ID_MESA          (1 << 4)
-#define VENDOR_ID_NV            (1 << 5)
-#define VENDOR_ID_POCL          (1 << 6)
-#define VENDOR_ID_AMD_USE_INTEL (1 << 7)
-#define VENDOR_ID_GENERIC       (1 << 31)
+#define VENDOR_ID_AMD           (1u << 0)
+#define VENDOR_ID_APPLE         (1u << 1)
+#define VENDOR_ID_INTEL_BEIGNET (1u << 2)
+#define VENDOR_ID_INTEL_SDK     (1u << 3)
+#define VENDOR_ID_MESA          (1u << 4)
+#define VENDOR_ID_NV            (1u << 5)
+#define VENDOR_ID_POCL          (1u << 6)
+#define VENDOR_ID_AMD_USE_INTEL (1u << 7)
+#define VENDOR_ID_GENERIC       (1u << 31)
 
 #define BLOCK_SIZE              64
 
@@ -224,7 +235,6 @@ extern hc_thread_mutex_t mux_display;
 #define HT_00140  "sha1($salt.unicode($pass))"
 #define HT_00150  "HMAC-SHA1 (key = $pass)"
 #define HT_00160  "HMAC-SHA1 (key = $salt)"
-#define HT_00190  "sha1(LinkedIn)"
 #define HT_00200  "MySQL323"
 #define HT_00300  "MySQL4.1/MySQL5"
 #define HT_00400  "phpass, MD5(Wordpress), MD5(phpBB3), MD5(Joomla)"
@@ -358,6 +368,7 @@ extern hc_thread_mutex_t mux_display;
 #define HT_13400  "Keepass 1 (AES/Twofish) and Keepass 2 (AES)"
 #define HT_13500  "PeopleSoft PS_TOKEN"
 #define HT_13600  "WinZip"
+#define HT_13800  "Windows 8+ phone PIN/Password"
 
 #define HT_00011  "Joomla < 2.5.18"
 #define HT_00012  "PostgreSQL"
@@ -456,8 +467,6 @@ extern hc_thread_mutex_t mux_display;
 #define DISPLAY_LEN_MAX_150   40 + 1 + 51
 #define DISPLAY_LEN_MIN_150H  40 + 1 + 0
 #define DISPLAY_LEN_MAX_150H  40 + 1 + 102
-#define DISPLAY_LEN_MIN_190   40
-#define DISPLAY_LEN_MAX_190   40
 #define DISPLAY_LEN_MIN_200   16
 #define DISPLAY_LEN_MAX_200   16
 #define DISPLAY_LEN_MIN_300   40
@@ -722,6 +731,8 @@ extern hc_thread_mutex_t mux_display;
 #define DISPLAY_LEN_MAX_13500 40 + 1 + 1024
 #define DISPLAY_LEN_MIN_13600 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 16 + 1 + 1 + 1 + 1 + 1 +    0 + 1 + 20 + 1 + 7
 #define DISPLAY_LEN_MAX_13600 6 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 32 + 1 + 4 + 1 + 4 + 1 + 8192 + 1 + 20 + 1 + 7
+#define DISPLAY_LEN_MIN_13800  64 + 1 + 256
+#define DISPLAY_LEN_MAX_13800  64 + 1 + 256
 
 #define DISPLAY_LEN_MIN_11    32 + 1 + 16
 #define DISPLAY_LEN_MAX_11    32 + 1 + 32
@@ -838,6 +849,7 @@ extern hc_thread_mutex_t mux_display;
 #define HASH_TYPE_BSDICRYPT      48
 #define HASH_TYPE_RAR3HP         49
 #define HASH_TYPE_KRB5TGS        50
+#define HASH_TYPE_STDOUT         51
 
 #define KERN_TYPE_MD5                 0
 #define KERN_TYPE_MD5_PWSLT           10
@@ -853,7 +865,6 @@ extern hc_thread_mutex_t mux_display;
 #define KERN_TYPE_SHA1_SLTPWU         140
 #define KERN_TYPE_HMACSHA1_PW         150
 #define KERN_TYPE_HMACSHA1_SLT        160
-#define KERN_TYPE_SHA1_LINKEDIN       190
 #define KERN_TYPE_MYSQL               200
 #define KERN_TYPE_MYSQL41             300
 #define KERN_TYPE_PHPASS              400
@@ -878,6 +889,7 @@ extern hc_thread_mutex_t mux_display;
 #define KERN_TYPE_HMACSHA512_PW       1750
 #define KERN_TYPE_HMACSHA512_SLT      1760
 #define KERN_TYPE_SHA512CRYPT         1800
+#define KERN_TYPE_STDOUT              2000
 #define KERN_TYPE_DCC2                2100
 #define KERN_TYPE_MD5PIX              2400
 #define KERN_TYPE_MD5ASA              2410
@@ -992,6 +1004,7 @@ extern hc_thread_mutex_t mux_display;
 #define KERN_TYPE_KEEPASS             13400
 #define KERN_TYPE_PSTOKEN             13500
 #define KERN_TYPE_ZIP2                13600
+#define KERN_TYPE_WIN8PHONE           13800
 
 /**
  * signatures
@@ -1125,6 +1138,7 @@ extern hc_thread_mutex_t mux_display;
 #define ROUNDS_AXCRYPT            10000
 #define ROUNDS_KEEPASS            6000
 #define ROUNDS_ZIP2               1000
+#define ROUNDS_STDOUT             0
 
 /**
  * salt types
@@ -1216,7 +1230,6 @@ extern hc_thread_mutex_t mux_display;
  * digests
  */
 
-#define DGST_SIZE_0                 0
 #define DGST_SIZE_4_2               (2  * sizeof (uint))   // 8
 #define DGST_SIZE_4_4               (4  * sizeof (uint))   // 16
 #define DGST_SIZE_4_5               (5  * sizeof (uint))   // 20
@@ -1434,31 +1447,37 @@ void fsync (int fd);
 
 #ifdef HAVE_HWMON
 
-#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
-int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX]);
-#endif
+int get_adapters_num_adl (void *adl, int *iNumberAdapters);
 
-#ifdef HAVE_ADL
-int get_adapters_num_amd (void *adl, int *iNumberAdapters);
+int hm_get_adapter_index_adl (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
 
-int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
+int hm_get_adapter_index_nvapi (HM_ADAPTER_NVAPI nvapiGPUHandle[DEVICES_MAX]);
 
-LPAdapterInfo hm_get_adapter_info_amd (void *adl, int iNumberAdapters);
+int hm_get_adapter_index_nvml (HM_ADAPTER_NVML nvmlGPUHandle[DEVICES_MAX]);
+
+LPAdapterInfo hm_get_adapter_info_adl (void *adl, int iNumberAdapters);
 
 u32 *hm_get_list_valid_adl_adapters (int iNumberAdapters, int *num_adl_adapters, LPAdapterInfo lpAdapterInfo);
 
 int hm_get_overdrive_version  (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
 int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo);
 
-// int hm_get_device_num (void *adl, HM_ADAPTER_AMD hm_adapter_index, int *hm_device_num);
+// int hm_get_device_num (void *adl, HM_ADAPTER_ADL hm_adapter_index, int *hm_device_num);
 // void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices);
-#endif // HAVE_ADL
-
-int hm_get_temperature_with_device_id (const uint device_id);
-int hm_get_fanspeed_with_device_id    (const uint device_id);
-int hm_get_utilization_with_device_id (const uint device_id);
 
-int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed);
+int hm_get_threshold_slowdown_with_device_id (const uint device_id);
+int hm_get_threshold_shutdown_with_device_id (const uint device_id);
+int hm_get_temperature_with_device_id        (const uint device_id);
+int hm_get_fanspeed_with_device_id           (const uint device_id);
+int hm_get_fanpolicy_with_device_id          (const uint device_id);
+int hm_get_buslanes_with_device_id           (const uint device_id);
+int hm_get_utilization_with_device_id        (const uint device_id);
+int hm_get_memoryspeed_with_device_id        (const uint device_id);
+int hm_get_corespeed_with_device_id          (const uint device_id);
+int hm_get_throttle_with_device_id           (const uint device_id);
+int hm_set_fanspeed_with_device_id_adl       (const uint device_id, const int fanspeed, const int fanpolicy);
+int hm_set_fanspeed_with_device_id_nvapi     (const uint device_id, const int fanspeed, const int fanpolicy);
+int hm_set_fanspeed_with_device_id_xnvctrl   (const uint device_id, const int fanspeed);
 
 void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value);
 #endif // HAVE_HWMON
@@ -1529,7 +1548,6 @@ int osx1_parse_hash               (char *input_buf, uint input_len, hash_t *hash
 int osx512_parse_hash             (char *input_buf, uint input_len, hash_t *hash_buf);
 int phpass_parse_hash             (char *input_buf, uint input_len, hash_t *hash_buf);
 int sha1_parse_hash               (char *input_buf, uint input_len, hash_t *hash_buf);
-int sha1linkedin_parse_hash       (char *input_buf, uint input_len, hash_t *hash_buf);
 int sha1b64_parse_hash            (char *input_buf, uint input_len, hash_t *hash_buf);
 int sha1b64s_parse_hash           (char *input_buf, uint input_len, hash_t *hash_buf);
 int sha1s_parse_hash              (char *input_buf, uint input_len, hash_t *hash_buf);
@@ -1648,7 +1666,10 @@ int veracrypt_parse_hash_200000   (char *input_buf, uint input_len, hash_t *hash
 int veracrypt_parse_hash_500000   (char *input_buf, uint input_len, hash_t *hash_buf);
 int veracrypt_parse_hash_327661   (char *input_buf, uint input_len, hash_t *hash_buf);
 int veracrypt_parse_hash_655331   (char *input_buf, uint input_len, hash_t *hash_buf);
+int win8phone_parse_hash          (char *input_buf, uint input_len, hash_t *hash_buf);
 
+void naive_replace (char *s, const u8 key_char, const u8 replace_char);
+void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char);
 void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources);
 void writeProgramBin (char *dst, u8 *binary, size_t binary_size);