Disable some of NVMLs useless throttle reasons
[hashcat.git] / src / shared.c
index a10a4e7..8cfa46e 100644 (file)
@@ -74,6 +74,7 @@ u64 byte_swap_64 (const u64 n)
  */
 
 #include "cpu-md5.c"
+#include "cpu-sha1.c"
 #include "cpu-sha256.c"
 
 /**
@@ -82,7 +83,7 @@ u64 byte_swap_64 (const u64 n)
 
 int last_len = 0;
 
-void log_final (FILE *fp, const char *fmt, va_list ap)
+int log_final (FILE *fp, const char *fmt, va_list ap)
 {
   if (last_len)
   {
@@ -109,84 +110,96 @@ void log_final (FILE *fp, const char *fmt, va_list ap)
   fflush (fp);
 
   last_len = len;
+
+  return len;
 }
 
-void log_out_nn (FILE *fp, const char *fmt, ...)
+int log_out_nn (FILE *fp, const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (fp, fmt, ap);
+  const int len = log_final (fp, fmt, ap);
 
   va_end (ap);
+
+  return len;
 }
 
-void log_info_nn (const char *fmt, ...)
+int log_info_nn (const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (stdout, fmt, ap);
+  const int len = log_final (stdout, fmt, ap);
 
   va_end (ap);
+
+  return len;
 }
 
-void log_error_nn (const char *fmt, ...)
+int log_error_nn (const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (stderr, fmt, ap);
+  const int len = log_final (stderr, fmt, ap);
 
   va_end (ap);
+
+  return len;
 }
 
-void log_out (FILE *fp, const char *fmt, ...)
+int log_out (FILE *fp, const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (fp, fmt, ap);
+  const int len = log_final (fp, fmt, ap);
 
   va_end (ap);
 
   fputc ('\n', fp);
 
   last_len = 0;
+
+  return len;
 }
 
-void log_info (const char *fmt, ...)
+int log_info (const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   va_list ap;
 
   va_start (ap, fmt);
 
-  log_final (stdout, fmt, ap);
+  const int len = log_final (stdout, fmt, ap);
 
   va_end (ap);
 
   fputc ('\n', stdout);
 
   last_len = 0;
+
+  return len;
 }
 
-void log_error (const char *fmt, ...)
+int log_error (const char *fmt, ...)
 {
-  if (SUPPRESS_OUTPUT) return;
+  if (SUPPRESS_OUTPUT) return 0;
 
   fputc ('\n', stderr);
   fputc ('\n', stderr);
@@ -195,7 +208,7 @@ void log_error (const char *fmt, ...)
 
   va_start (ap, fmt);
 
-  log_final (stderr, fmt, ap);
+  const int len = log_final (stderr, fmt, ap);
 
   va_end (ap);
 
@@ -203,6 +216,8 @@ void log_error (const char *fmt, ...)
   fputc ('\n', stderr);
 
   last_len = 0;
+
+  return len;
 }
 
 /**
@@ -2638,7 +2653,7 @@ void lock_file (FILE *fp)
   {
     if (errno != EINTR)
     {
-      log_error ("ERROR: failed acquiring write lock: %s", strerror (errno));
+      log_error ("ERROR: Failed acquiring write lock: %s", strerror (errno));
 
       exit (-1);
     }
@@ -2656,7 +2671,7 @@ void unlock_file (FILE *fp)
 }
 #endif // F_SETLKW
 
-#ifdef _WIN
+#ifdef WIN
 void fsync (int fd)
 {
   HANDLE h = (HANDLE) _get_osfhandle (fd);
@@ -2670,53 +2685,8 @@ void fsync (int fd)
  */
 
 #ifdef HAVE_HWMON
-#if defined(_WIN) && defined(HAVE_NVAPI)
-int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
-{
-  NvU32 pGpuCount;
-
-  if (hm_NvAPI_EnumPhysicalGPUs (data.hm_nv, nvGPUHandle, &pGpuCount) != NVAPI_OK) return (0);
-
-  if (pGpuCount == 0)
-  {
-    log_info ("WARN: No NvAPI adapters found");
-
-    return (0);
-  }
-
-  return (pGpuCount);
-}
-#endif // _WIN && HAVE_NVAPI
-
-#if defined(LINUX) && defined(HAVE_NVML)
-int hm_get_adapter_index_nv (HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX])
-{
-  int pGpuCount = 0;
-
-  for (uint i = 0; i < DEVICES_MAX; i++)
-  {
-    if (hm_NVML_nvmlDeviceGetHandleByIndex (data.hm_nv, 1, i, &nvGPUHandle[i]) != NVML_SUCCESS) break;
-
-    // can be used to determine if the device by index matches the cuda device by index
-    // char name[100]; memset (name, 0, sizeof (name));
-    // hm_NVML_nvmlDeviceGetName (data.hm_nv, nvGPUHandle[i], name, sizeof (name) - 1);
-
-    pGpuCount++;
-  }
-
-  if (pGpuCount == 0)
-  {
-    log_info ("WARN: No NVML adapters found");
-
-    return (0);
-  }
-
-  return (pGpuCount);
-}
-#endif // LINUX && HAVE_NVML
 
-#ifdef HAVE_ADL
-int get_adapters_num_amd (void *adl, int *iNumberAdapters)
+int get_adapters_num_adl (void *adl, int *iNumberAdapters)
 {
   if (hm_ADL_Adapter_NumberOfAdapters_Get ((ADL_PTR *) adl, iNumberAdapters) != ADL_OK) return -1;
 
@@ -2766,7 +2736,7 @@ int hm_show_performance_level (HM_LIB hm_dll, int iAdapterIndex)
 }
 */
 
-LPAdapterInfo hm_get_adapter_info_amd (void *adl, int iNumberAdapters)
+LPAdapterInfo hm_get_adapter_info_adl (void *adl, int iNumberAdapters)
 {
   size_t AdapterInfoSize = iNumberAdapters * sizeof (AdapterInfo);
 
@@ -2777,9 +2747,50 @@ LPAdapterInfo hm_get_adapter_info_amd (void *adl, int iNumberAdapters)
   return lpAdapterInfo;
 }
 
+int hm_get_adapter_index_nvapi (HM_ADAPTER_NVAPI nvapiGPUHandle[DEVICES_MAX])
+{
+  NvU32 pGpuCount;
+
+  if (hm_NvAPI_EnumPhysicalGPUs (data.hm_nvapi, nvapiGPUHandle, &pGpuCount) != NVAPI_OK) return (0);
+
+  if (pGpuCount == 0)
+  {
+    log_info ("WARN: No NvAPI adapters found");
+
+    return (0);
+  }
+
+  return (pGpuCount);
+}
+
+int hm_get_adapter_index_nvml (HM_ADAPTER_NVML nvmlGPUHandle[DEVICES_MAX])
+{
+  int pGpuCount = 0;
+
+  for (uint i = 0; i < DEVICES_MAX; i++)
+  {
+    if (hm_NVML_nvmlDeviceGetHandleByIndex (data.hm_nvml, 1, i, &nvmlGPUHandle[i]) != NVML_SUCCESS) break;
+
+    // can be used to determine if the device by index matches the cuda device by index
+    // char name[100]; memset (name, 0, sizeof (name));
+    // hm_NVML_nvmlDeviceGetName (data.hm_nvml, nvGPUHandle[i], name, sizeof (name) - 1);
+
+    pGpuCount++;
+  }
+
+  if (pGpuCount == 0)
+  {
+    log_info ("WARN: No NVML adapters found");
+
+    return (0);
+  }
+
+  return (pGpuCount);
+}
+
 /*
 //
-// does not help at all, since AMD does not assign different bus id, device id when we have multi GPU setups
+// does not help at all, since ADL does not assign different bus id, device id when we have multi GPU setups
 //
 
 int hm_get_opencl_device_index (hm_attrs_t *hm_device, uint num_adl_adapters, int bus_num, int dev_num)
@@ -2968,11 +2979,11 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
       if ((FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ) &&
           (FanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE))
       {
-        hm_device[opencl_device_index].fan_supported = 1;
+        hm_device[opencl_device_index].fan_get_supported = 1;
       }
       else
       {
-        hm_device[opencl_device_index].fan_supported = 0;
+        hm_device[opencl_device_index].fan_get_supported = 0;
       }
     }
     else // od_version == 6
@@ -2987,11 +2998,11 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
 
       if (faninfo.iSpeedType & ADL_OD6_FANSPEED_TYPE_PERCENT)
       {
-        hm_device[opencl_device_index].fan_supported = 1;
+        hm_device[opencl_device_index].fan_get_supported = 1;
       }
       else
       {
-        hm_device[opencl_device_index].fan_supported = 0;
+        hm_device[opencl_device_index].fan_get_supported = 0;
       }
     }
   }
@@ -3031,7 +3042,7 @@ int hm_get_overdrive_version (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_d
   return 0;
 }
 
-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_adl (hm_attrs_t *hm_device, u32 *valid_adl_device_list, int num_adl_adapters, LPAdapterInfo lpAdapterInfo)
 {
   for (int i = 0; i < num_adl_adapters; i++)
   {
@@ -3049,21 +3060,88 @@ int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list,
 
     int opencl_device_index = i;
 
-    hm_device[opencl_device_index].adapter_index.amd = info.iAdapterIndex;
+    hm_device[opencl_device_index].adl = info.iAdapterIndex;
   }
 
   return num_adl_adapters;
 }
-#endif // HAVE_ADL
+
+int hm_get_threshold_slowdown_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      if (data.hm_device[device_id].od_version == 5)
+      {
+
+      }
+      else if (data.hm_device[device_id].od_version == 6)
+      {
+        int CurrentValue = 0;
+        int DefaultValue = 0;
+
+        if (hm_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_adl, data.hm_device[device_id].adl, &CurrentValue, &DefaultValue) != ADL_OK) return -1;
+
+        // the return value has never been tested since hm_ADL_Overdrive6_TargetTemperatureData_Get() never worked on any system. expect problems.
+
+        return DefaultValue;
+      }
+    }
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    int target = 0;
+
+    if (hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target) != NVML_SUCCESS) return -1;
+
+    return target;
+  }
+
+  return -1;
+}
+
+int hm_get_threshold_shutdown_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      if (data.hm_device[device_id].od_version == 5)
+      {
+
+      }
+      else if (data.hm_device[device_id].od_version == 6)
+      {
+
+      }
+    }
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    int target = 0;
+
+    if (hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, (unsigned int *) &target) != NVML_SUCCESS) return -1;
+
+    return target;
+  }
+
+  return -1;
+}
 
 int hm_get_temperature_with_device_id (const uint device_id)
 {
   if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-  #ifdef HAVE_ADL
-  if (data.devices_param[device_id].vendor_id == VENDOR_ID_AMD)
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
   {
-    if (data.hm_amd)
+    if (data.hm_adl)
     {
       if (data.hm_device[device_id].od_version == 5)
       {
@@ -3071,7 +3149,7 @@ int hm_get_temperature_with_device_id (const uint device_id)
 
         Temperature.iSize = sizeof (ADLTemperature);
 
-        if (hm_ADL_Overdrive5_Temperature_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &Temperature) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive5_Temperature_Get (data.hm_adl, data.hm_device[device_id].adl, 0, &Temperature) != ADL_OK) return -1;
 
         return Temperature.iTemperature / 1000;
       }
@@ -3079,54 +3157,73 @@ int hm_get_temperature_with_device_id (const uint device_id)
       {
         int Temperature = 0;
 
-        if (hm_ADL_Overdrive6_Temperature_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &Temperature) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive6_Temperature_Get (data.hm_adl, data.hm_device[device_id].adl, &Temperature) != ADL_OK) return -1;
 
         return Temperature / 1000;
       }
     }
   }
-  #endif
 
-  #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
-  if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
   {
-    #if defined(LINUX) && defined(HAVE_NVML)
     int temperature = 0;
 
-    hm_NVML_nvmlDeviceGetTemperature (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_GPU, (uint *) &temperature);
+    if (hm_NVML_nvmlDeviceGetTemperature (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_TEMPERATURE_GPU, (uint *) &temperature) != NVML_SUCCESS) return -1;
 
     return temperature;
-    #endif
+  }
+
+  return -1;
+}
+
+int hm_get_fanpolicy_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.hm_device[device_id].fan_get_supported == 1)
+  {
+    if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+    {
+      if (data.hm_adl)
+      {
+        if (data.hm_device[device_id].od_version == 5)
+        {
+          ADLFanSpeedValue lpFanSpeedValue;
 
-    #if defined(WIN) && defined(HAVE_NVAPI)
-    NV_GPU_THERMAL_SETTINGS pThermalSettings;
+          memset (&lpFanSpeedValue, 0, sizeof (lpFanSpeedValue));
+
+          lpFanSpeedValue.iSize      = sizeof (lpFanSpeedValue);
+          lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
 
-    pThermalSettings.version = NV_GPU_THERMAL_SETTINGS_VER;
-    pThermalSettings.count = NVAPI_MAX_THERMAL_SENSORS_PER_GPU;
-    pThermalSettings.sensor[0].controller = NVAPI_THERMAL_CONTROLLER_UNKNOWN;
-    pThermalSettings.sensor[0].target = NVAPI_THERMAL_TARGET_GPU;
+          if (hm_ADL_Overdrive5_FanSpeed_Get (data.hm_adl, data.hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1;
 
-    if (hm_NvAPI_GPU_GetThermalSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pThermalSettings) != NVAPI_OK) return -1;
+          return (lpFanSpeedValue.iFanSpeed & ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED) ? 0 : 1;
+        }
+        else // od_version == 6
+        {
+          return 1;
+        }
+      }
+    }
 
-    return pThermalSettings.sensor[0].currentTemp;
-    #endif // WIN && HAVE_NVAPI
+    if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+    {
+      return 1;
+    }
   }
-  #endif // HAVE_NVML || HAVE_NVAPI
 
   return -1;
 }
 
 int hm_get_fanspeed_with_device_id (const uint device_id)
 {
-  // we shouldn't really need this extra CL_DEVICE_TYPE_GPU check, because fan_supported should not be set w/ CPUs
   if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-  if (data.hm_device[device_id].fan_supported == 1)
+  if (data.hm_device[device_id].fan_get_supported == 1)
   {
-    #ifdef HAVE_ADL
-    if (data.devices_param[device_id].vendor_id == VENDOR_ID_AMD)
+    if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
     {
-      if (data.hm_amd)
+      if (data.hm_adl)
       {
         if (data.hm_device[device_id].od_version == 5)
         {
@@ -3138,7 +3235,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
           lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
           lpFanSpeedValue.iFlags     = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
 
-          if (hm_ADL_Overdrive5_FanSpeed_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
+          if (hm_ADL_Overdrive5_FanSpeed_Get (data.hm_adl, data.hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1;
 
           return lpFanSpeedValue.iFanSpeed;
         }
@@ -3148,37 +3245,51 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
 
           memset (&faninfo, 0, sizeof (faninfo));
 
-          if (hm_ADL_Overdrive6_FanSpeed_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &faninfo) != ADL_OK) return -1;
+          if (hm_ADL_Overdrive6_FanSpeed_Get (data.hm_adl, data.hm_device[device_id].adl, &faninfo) != ADL_OK) return -1;
 
           return faninfo.iFanSpeedPercent;
         }
       }
     }
-    #endif // HAVE_ADL
 
-    #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
-    if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
+    if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
     {
-      #if defined(LINUX) && defined(HAVE_NVML)
       int speed = 0;
 
-      hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nv, 1, data.hm_device[device_id].adapter_index.nv, (uint *) &speed);
+      if (hm_NVML_nvmlDeviceGetFanSpeed (data.hm_nvml, 0, data.hm_device[device_id].nvml, (uint *) &speed) != NVML_SUCCESS) return -1;
 
       return speed;
-      #endif
+    }
+  }
 
-      #if defined(WIN) && defined(HAVE_NVAPI)
+  return -1;
+}
 
-      NV_GPU_COOLER_SETTINGS pCoolerSettings;
+int hm_get_buslanes_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-      pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS);
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      ADLPMActivity PMActivity;
 
-      hm_NvAPI_GPU_GetCoolerSettings (data.hm_nv, data.hm_device[device_id].adapter_index.nv, 0, &pCoolerSettings);
+      PMActivity.iSize = sizeof (ADLPMActivity);
 
-      return pCoolerSettings.Cooler[0].CurrentLevel;
-      #endif
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1;
+
+      return PMActivity.iCurrentBusLanes;
     }
-    #endif // HAVE_NVML || HAVE_NVAPI
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    unsigned int currLinkWidth;
+
+    if (hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (data.hm_nvml, 1, data.hm_device[device_id].nvml, &currLinkWidth) != NVML_SUCCESS) return -1;
+
+    return currLinkWidth;
   }
 
   return -1;
@@ -3188,54 +3299,130 @@ int hm_get_utilization_with_device_id (const uint device_id)
 {
   if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-  #ifdef HAVE_ADL
-  if (data.devices_param[device_id].vendor_id == VENDOR_ID_AMD)
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
   {
-    if (data.hm_amd)
+    if (data.hm_adl)
     {
       ADLPMActivity PMActivity;
 
       PMActivity.iSize = sizeof (ADLPMActivity);
 
-      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &PMActivity) != ADL_OK) return -1;
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1;
 
       return PMActivity.iActivityPercent;
     }
   }
-  #endif // HAVE_ADL
 
-  #if defined(HAVE_NVML) || defined(HAVE_NVAPI)
-  if (data.devices_param[device_id].vendor_id == VENDOR_ID_NV)
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
   {
-    #if defined(LINUX) && defined(HAVE_NVML)
     nvmlUtilization_t utilization;
 
-    hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &utilization);
+    if (hm_NVML_nvmlDeviceGetUtilizationRates (data.hm_nvml, 1, data.hm_device[device_id].nvml, &utilization) != NVML_SUCCESS) return -1;
 
     return utilization.gpu;
-    #endif
+  }
 
-    #if defined(WIN) && defined(HAVE_NVAPI)
-    NV_GPU_DYNAMIC_PSTATES_INFO_EX pDynamicPstatesInfoEx;
+  return -1;
+}
 
-    pDynamicPstatesInfoEx.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER;
+int hm_get_memoryspeed_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
 
-    if (hm_NvAPI_GPU_GetDynamicPstatesInfoEx (data.hm_nv, data.hm_device[device_id].adapter_index.nv, &pDynamicPstatesInfoEx) != NVAPI_OK) return -1;
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      ADLPMActivity PMActivity;
 
-    return pDynamicPstatesInfoEx.utilization[0].percentage;
-    #endif
+      PMActivity.iSize = sizeof (ADLPMActivity);
+
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1;
+
+      return PMActivity.iMemoryClock / 100;
+    }
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    unsigned int clock;
+
+    if (hm_NVML_nvmlDeviceGetClockInfo (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_CLOCK_MEM, &clock) != NVML_SUCCESS) return -1;
+
+    return clock;
+  }
+
+  return -1;
+}
+
+int hm_get_corespeed_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_adl)
+    {
+      ADLPMActivity PMActivity;
+
+      PMActivity.iSize = sizeof (ADLPMActivity);
+
+      if (hm_ADL_Overdrive_CurrentActivity_Get (data.hm_adl, data.hm_device[device_id].adl, &PMActivity) != ADL_OK) return -1;
+
+      return PMActivity.iEngineClock / 100;
+    }
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    unsigned int clock;
+
+    if (hm_NVML_nvmlDeviceGetClockInfo (data.hm_nvml, 1, data.hm_device[device_id].nvml, NVML_CLOCK_SM, &clock) != NVML_SUCCESS) return -1;
+
+    return clock;
+  }
+
+  return -1;
+}
+
+int hm_get_throttle_with_device_id (const uint device_id)
+{
+  if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+
+  }
+
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
+  {
+    unsigned long long clocksThrottleReasons = 0;
+    unsigned long long supportedThrottleReasons = 0;
+
+    if (hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons   (data.hm_nvml, 1, data.hm_device[device_id].nvml, &clocksThrottleReasons)    != NVML_SUCCESS) return -1;
+    if (hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (data.hm_nvml, 1, data.hm_device[device_id].nvml, &supportedThrottleReasons) != NVML_SUCCESS) return -1;
+
+    clocksThrottleReasons &=  supportedThrottleReasons;
+    clocksThrottleReasons &= ~nvmlClocksThrottleReasonGpuIdle;
+    clocksThrottleReasons &= ~nvmlClocksThrottleReasonApplicationsClocksSetting;
+    clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown;
+
+    if (data.kernel_power_final)
+    {
+      clocksThrottleReasons &= ~nvmlClocksThrottleReasonHwSlowdown;
+    }
+
+    return (clocksThrottleReasons != nvmlClocksThrottleReasonNone);
   }
-  #endif // HAVE_NVML || HAVE_NVAPI
 
   return -1;
 }
 
-#ifdef HAVE_ADL
-int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed)
+int hm_set_fanspeed_with_device_id_adl (const uint device_id, const int fanspeed, const int fanpolicy)
 {
-  if (data.hm_device[device_id].fan_supported == 1)
+  if (data.hm_device[device_id].fan_set_supported == 1)
   {
-    if (data.hm_amd)
+    if (data.hm_adl)
     {
       if (data.hm_device[device_id].od_version == 5)
       {
@@ -3245,10 +3432,10 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
 
         lpFanSpeedValue.iSize      = sizeof (lpFanSpeedValue);
         lpFanSpeedValue.iSpeedType = ADL_DL_FANCTRL_SPEED_TYPE_PERCENT;
-        lpFanSpeedValue.iFlags     = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
+        lpFanSpeedValue.iFlags     = (fanpolicy == 1) ? ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED : 0;
         lpFanSpeedValue.iFanSpeed  = fanspeed;
 
-        if (hm_ADL_Overdrive5_FanSpeed_Set (data.hm_amd, data.hm_device[device_id].adapter_index.amd, 0, &lpFanSpeedValue) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive5_FanSpeed_Set (data.hm_adl, data.hm_device[device_id].adl, 0, &lpFanSpeedValue) != ADL_OK) return -1;
 
         return 0;
       }
@@ -3261,7 +3448,7 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
         fan_speed_value.iSpeedType = ADL_OD6_FANSPEED_TYPE_PERCENT;
         fan_speed_value.iFanSpeed  = fanspeed;
 
-        if (hm_ADL_Overdrive6_FanSpeed_Set (data.hm_amd, data.hm_device[device_id].adapter_index.amd, &fan_speed_value) != ADL_OK) return -1;
+        if (hm_ADL_Overdrive6_FanSpeed_Set (data.hm_adl, data.hm_device[device_id].adl, &fan_speed_value) != ADL_OK) return -1;
 
         return 0;
       }
@@ -3270,24 +3457,45 @@ int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed
 
   return -1;
 }
-#endif
 
-// helper function for status display
-
-void hm_device_val_to_str (char *target_buf, int max_buf_size, char *suffix, int value)
+int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fanspeed, const int fanpolicy)
 {
-  #define VALUE_NOT_AVAILABLE "N/A"
-
-  if (value == -1)
+  if (data.hm_device[device_id].fan_set_supported == 1)
   {
-    snprintf (target_buf, max_buf_size, VALUE_NOT_AVAILABLE);
-  }
-  else
-  {
-    snprintf (target_buf, max_buf_size, "%2d%s", value, suffix);
+    if (data.hm_nvapi)
+    {
+      NV_GPU_COOLER_LEVELS CoolerLevels = { 0 };
+
+      CoolerLevels.Version = GPU_COOLER_LEVELS_VER | sizeof (NV_GPU_COOLER_LEVELS);
+
+      CoolerLevels.Levels[0].Level  = fanspeed;
+      CoolerLevels.Levels[0].Policy = fanpolicy;
+
+      if (hm_NvAPI_GPU_SetCoolerLevels (data.hm_nvapi, data.hm_device[device_id].nvapi, 0, &CoolerLevels) != NVAPI_OK) return -1;
+
+      return 0;
+    }
   }
+
+  return -1;
 }
-#endif // HAVE_HWMON
+
+int hm_set_fanspeed_with_device_id_xnvctrl (const uint device_id, const int fanspeed)
+{
+  if (data.hm_device[device_id].fan_set_supported == 1)
+  {
+    if (data.hm_xnvctrl)
+    {
+      if (set_fan_speed_target (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, fanspeed) != 0) return -1;
+
+      return 0;
+    }
+  }
+
+  return -1;
+}
+
+#endif // HAVE_HWMON
 
 /**
  * maskprocessor
@@ -3299,7 +3507,7 @@ void mp_css_to_uniq_tbl (uint css_cnt, cs_t *css, uint uniq_tbls[SP_PW_MAX][CHAR
 
   if (css_cnt > SP_PW_MAX)
   {
-    log_error ("ERROR: mask length is too long");
+    log_error ("ERROR: Mask length is too long");
 
     exit (-1);
   }
@@ -3411,7 +3619,7 @@ void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, int mp_
 
         if (in_pos == in_len)
         {
-          log_error ("ERROR: the hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", in_buf);
+          log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", in_buf);
 
           exit (-1);
         }
@@ -3420,7 +3628,7 @@ void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, int mp_
 
         if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
         {
-          log_error ("ERROR: invalid hex character detected in mask %s", in_buf);
+          log_error ("ERROR: Invalid hex character detected in mask %s", in_buf);
 
           exit (-1);
         }
@@ -3503,7 +3711,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
                   break;
         case '?': mp_add_cs_buf (&chr, 1, css, css_pos);
                   break;
-        default:  log_error ("ERROR: syntax error: %s", mask_buf);
+        default:  log_error ("ERROR: Syntax error: %s", mask_buf);
                   exit (-1);
       }
     }
@@ -3517,7 +3725,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
 
         if (mask_pos == mask_len)
         {
-          log_error ("ERROR: the hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
+          log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
 
           exit (-1);
         }
@@ -3528,7 +3736,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
 
         if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
         {
-          log_error ("ERROR: invalid hex character detected in mask %s", mask_buf);
+          log_error ("ERROR: Invalid hex character detected in mask %s", mask_buf);
 
           exit (-1);
         }
@@ -3551,7 +3759,7 @@ cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u
 
   if (css_pos == 0)
   {
-    log_error ("ERROR: invalid mask length (0)");
+    log_error ("ERROR: Invalid mask length (0)");
 
     exit (-1);
   }
@@ -3636,7 +3844,7 @@ void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index)
 
     if (len == 0)
     {
-      log_info ("WARNING: charset file corrupted");
+      log_info ("WARNING: Charset file corrupted");
 
       mp_expand (buf, strlen (buf), mp_sys, mp_usr, index, 1);
     }
@@ -3686,7 +3894,7 @@ char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len)
 
         if (mask_pos == mask_len)
         {
-          log_error ("ERROR: the hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
+          log_error ("ERROR: The hex-charset option always expects couples of exactly 2 hexadecimal chars, failed mask: %s", mask_buf);
 
           exit (-1);
         }
@@ -3697,7 +3905,7 @@ char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len)
 
         if ((is_valid_hex_char (p0) == 0) || (is_valid_hex_char (p1) == 0))
         {
-          log_error ("ERROR: invalid hex character detected in mask: %s", mask_buf);
+          log_error ("ERROR: Invalid hex character detected in mask: %s", mask_buf);
 
           exit (-1);
         }
@@ -4286,7 +4494,7 @@ int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t *cpu_se
 
 void set_cpu_affinity (char *cpu_affinity)
 {
-  #ifdef WIN
+  #ifdef _WIN
   DWORD_PTR aff_mask = 0;
   #elif _POSIX
   cpu_set_t cpuset;
@@ -4305,7 +4513,7 @@ void set_cpu_affinity (char *cpu_affinity)
 
       if (cpu_id == 0)
       {
-        #ifdef WIN
+        #ifdef _WIN
         aff_mask = 0;
         #elif _POSIX
         CPU_ZERO (&cpuset);
@@ -4316,12 +4524,12 @@ void set_cpu_affinity (char *cpu_affinity)
 
       if (cpu_id > 32)
       {
-        log_error ("ERROR: invalid cpu_id %u specified", cpu_id);
+        log_error ("ERROR: Invalid cpu_id %u specified", cpu_id);
 
         exit (-1);
       }
 
-      #ifdef WIN
+      #ifdef _WIN
       aff_mask |= 1 << (cpu_id - 1);
       #elif _POSIX
       CPU_SET ((cpu_id - 1), &cpuset);
@@ -4332,7 +4540,7 @@ void set_cpu_affinity (char *cpu_affinity)
     free (devices);
   }
 
-  #ifdef WIN
+  #ifdef _WIN
   SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
   SetThreadAffinityMask (GetCurrentThread (), aff_mask);
   #elif _POSIX
@@ -4555,7 +4763,7 @@ int sort_by_dictstat (const void *s1, const void *s2)
   dictstat_t *d1 = (dictstat_t *) s1;
   dictstat_t *d2 = (dictstat_t *) s2;
 
-  #ifdef LINUX
+  #ifdef _LINUX
   d2->stat.st_atim = d1->stat.st_atim;
   #else
   d2->stat.st_atime = d1->stat.st_atime;
@@ -5237,7 +5445,7 @@ uint setup_opencl_platforms_filter (char *opencl_platforms)
 
       if (platform < 1 || platform > 32)
       {
-        log_error ("ERROR: invalid OpenCL platform %u specified", platform);
+        log_error ("ERROR: Invalid OpenCL platform %u specified", platform);
 
         exit (-1);
       }
@@ -5272,7 +5480,7 @@ u32 setup_devices_filter (char *opencl_devices)
 
       if (device_id < 1 || device_id > 32)
       {
-        log_error ("ERROR: invalid device_id %u specified", device_id);
+        log_error ("ERROR: Invalid device_id %u specified", device_id);
 
         exit (-1);
       }
@@ -5307,7 +5515,7 @@ cl_device_type setup_device_types_filter (char *opencl_device_types)
 
       if (device_type < 1 || device_type > 3)
       {
-        log_error ("ERROR: invalid device_type %u specified", device_type);
+        log_error ("ERROR: Invalid device_type %u specified", device_type);
 
         exit (-1);
       }
@@ -5631,6 +5839,7 @@ char *stroptitype (const uint opti_type)
     case OPTI_TYPE_SINGLE_SALT:       return ((char *) OPTI_STR_SINGLE_SALT);       break;
     case OPTI_TYPE_BRUTE_FORCE:       return ((char *) OPTI_STR_BRUTE_FORCE);       break;
     case OPTI_TYPE_RAW_HASH:          return ((char *) OPTI_STR_RAW_HASH);          break;
+    case OPTI_TYPE_SLOW_HASH_SIMD:    return ((char *) OPTI_STR_SLOW_HASH_SIMD);    break;
     case OPTI_TYPE_USES_BITS_8:       return ((char *) OPTI_STR_USES_BITS_8);       break;
     case OPTI_TYPE_USES_BITS_16:      return ((char *) OPTI_STR_USES_BITS_16);      break;
     case OPTI_TYPE_USES_BITS_32:      return ((char *) OPTI_STR_USES_BITS_32);      break;
@@ -5691,6 +5900,7 @@ char *strhashtype (const uint hash_mode)
     case   121: return ((char *) HT_00121); break;
     case   122: return ((char *) HT_00122); break;
     case   124: return ((char *) HT_00124); break;
+    case   125: return ((char *) HT_00125); break;
     case   130: return ((char *) HT_00130); break;
     case   131: return ((char *) HT_00131); break;
     case   132: return ((char *) HT_00132); break;
@@ -5699,7 +5909,6 @@ char *strhashtype (const uint hash_mode)
     case   141: return ((char *) HT_00141); break;
     case   150: return ((char *) HT_00150); break;
     case   160: return ((char *) HT_00160); break;
-    case   190: return ((char *) HT_00190); break;
     case   200: return ((char *) HT_00200); break;
     case   300: return ((char *) HT_00300); break;
     case   400: return ((char *) HT_00400); break;
@@ -5851,6 +6060,28 @@ char *strhashtype (const uint hash_mode)
     case 13100: return ((char *) HT_13100); break;
     case 13200: return ((char *) HT_13200); break;
     case 13300: return ((char *) HT_13300); break;
+    case 13400: return ((char *) HT_13400); break;
+    case 13500: return ((char *) HT_13500); break;
+    case 13600: return ((char *) HT_13600); break;
+    case 13711: return ((char *) HT_13711); break;
+    case 13712: return ((char *) HT_13712); break;
+    case 13713: return ((char *) HT_13713); break;
+    case 13721: return ((char *) HT_13721); break;
+    case 13722: return ((char *) HT_13722); break;
+    case 13723: return ((char *) HT_13723); break;
+    case 13731: return ((char *) HT_13731); break;
+    case 13732: return ((char *) HT_13732); break;
+    case 13733: return ((char *) HT_13733); break;
+    case 13741: return ((char *) HT_13741); break;
+    case 13742: return ((char *) HT_13742); break;
+    case 13743: return ((char *) HT_13743); break;
+    case 13751: return ((char *) HT_13751); break;
+    case 13752: return ((char *) HT_13752); break;
+    case 13753: return ((char *) HT_13753); break;
+    case 13761: return ((char *) HT_13761); break;
+    case 13762: return ((char *) HT_13762); break;
+    case 13763: return ((char *) HT_13763); break;
+    case 13800: return ((char *) HT_13800); break;
   }
 
   return ((char *) "Unknown");
@@ -5876,7 +6107,7 @@ char *strstatus (const uint devices_status)
   return ((char *) "Unknown");
 }
 
-void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
+void ascii_digest (char *out_buf, uint salt_pos, uint digest_pos)
 {
   uint hash_type = data.hash_type;
   uint hash_mode = data.hash_mode;
@@ -6184,7 +6415,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   }
   else if (hash_mode == 23)
   {
-    // do not show the \nskyper\n part in output
+    // do not show the skyper part in output
 
     char *salt_buf_ptr = (char *) salt.salt_buf;
 
@@ -6230,7 +6461,7 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     snprintf (out_buf, len-1, "{SSHA}%s", ptr_plain);
   }
-  else if (hash_mode == 122)
+  else if ((hash_mode == 122) || (hash_mode == 125))
   {
     snprintf (out_buf, len-1, "%s%08x%08x%08x%08x%08x",
       (char *) salt.salt_buf,
@@ -6579,35 +6810,20 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
 
     wpa_t *wpa = &wpas[salt_pos];
 
-    uint pke[25] = { 0 };
-
-    char *pke_ptr = (char *) pke;
-
-    for (uint i = 0; i < 25; i++)
-    {
-      pke[i] = byte_swap_32 (wpa->pke[i]);
-    }
-
-    unsigned char mac1[6] = { 0 };
-    unsigned char mac2[6] = { 0 };
-
-    memcpy (mac1, pke_ptr + 23, 6);
-    memcpy (mac2, pke_ptr + 29, 6);
-
     snprintf (out_buf, len-1, "%s:%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
       (char *) salt.salt_buf,
-      mac1[0],
-      mac1[1],
-      mac1[2],
-      mac1[3],
-      mac1[4],
-      mac1[5],
-      mac2[0],
-      mac2[1],
-      mac2[2],
-      mac2[3],
-      mac2[4],
-      mac2[5]);
+      wpa->orig_mac1[0],
+      wpa->orig_mac1[1],
+      wpa->orig_mac1[2],
+      wpa->orig_mac1[3],
+      wpa->orig_mac1[4],
+      wpa->orig_mac1[5],
+      wpa->orig_mac2[0],
+      wpa->orig_mac2[1],
+      wpa->orig_mac2[2],
+      wpa->orig_mac2[3],
+      wpa->orig_mac2[4],
+      wpa->orig_mac2[5]);
   }
   else if (hash_mode == 4400)
   {
@@ -7236,6 +7452,12 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
   {
     char digest_buf_c[34] = { 0 };
 
+    digest_buf[0] = byte_swap_32 (digest_buf[0]);
+    digest_buf[1] = byte_swap_32 (digest_buf[1]);
+    digest_buf[2] = byte_swap_32 (digest_buf[2]);
+    digest_buf[3] = byte_swap_32 (digest_buf[3]);
+    digest_buf[4] = byte_swap_32 (digest_buf[4]);
+
     base32_encode (int_to_itoa32, (const u8 *) digest_buf, 20, (u8 *) digest_buf_c);
 
     digest_buf_c[32] = 0;
@@ -8348,6 +8570,248 @@ void ascii_digest (char out_buf[4096], uint salt_pos, uint digest_pos)
               digest_buf[2],
               digest_buf[3]);
   }
+  else if (hash_mode == 13400)
+  {
+    keepass_t *keepasss = (keepass_t *) data.esalts_buf;
+
+    keepass_t *keepass = &keepasss[salt_pos];
+
+    u32 version     = (u32) keepass->version;
+    u32 rounds      = salt.salt_iter;
+    u32 algorithm   = (u32) keepass->algorithm;
+    u32 keyfile_len = (u32) keepass->keyfile_len;
+
+    u32 *ptr_final_random_seed  = (u32 *) keepass->final_random_seed ;
+    u32 *ptr_transf_random_seed = (u32 *) keepass->transf_random_seed ;
+    u32 *ptr_enc_iv             = (u32 *) keepass->enc_iv ;
+    u32 *ptr_contents_hash      = (u32 *) keepass->contents_hash ;
+    u32 *ptr_keyfile            = (u32 *) keepass->keyfile ;
+
+    /* specific to version 1 */
+    u32 contents_len;
+    u32 *ptr_contents;
+
+    /* specific to version 2 */
+    u32 expected_bytes_len;
+    u32 *ptr_expected_bytes;
+
+    u32 final_random_seed_len;
+    u32 transf_random_seed_len;
+    u32 enc_iv_len;
+    u32 contents_hash_len;
+
+    transf_random_seed_len = 8;
+    enc_iv_len             = 4;
+    contents_hash_len      = 8;
+    final_random_seed_len  = 8;
+
+    if (version == 1)
+      final_random_seed_len = 4;
+
+    snprintf (out_buf, len-1, "%s*%d*%d*%d",
+      SIGNATURE_KEEPASS,
+      version,
+      rounds,
+      algorithm);
+
+    char *ptr_data = out_buf;
+
+    ptr_data += strlen(out_buf);
+
+    *ptr_data = '*';
+    ptr_data++;
+
+    for (uint i = 0; i < final_random_seed_len; i++, ptr_data += 8)
+      sprintf (ptr_data, "%08x", ptr_final_random_seed[i]);
+
+    *ptr_data = '*';
+    ptr_data++;
+
+    for (uint i = 0; i < transf_random_seed_len; i++, ptr_data += 8)
+      sprintf (ptr_data, "%08x", ptr_transf_random_seed[i]);
+
+    *ptr_data = '*';
+    ptr_data++;
+
+    for (uint i = 0; i < enc_iv_len; i++, ptr_data += 8)
+      sprintf (ptr_data, "%08x", ptr_enc_iv[i]);
+
+    *ptr_data = '*';
+    ptr_data++;
+
+    if (version == 1)
+    {
+      contents_len = (u32)   keepass->contents_len;
+      ptr_contents = (u32 *) keepass->contents;
+
+      for (uint i = 0; i < contents_hash_len; i++, ptr_data += 8)
+        sprintf (ptr_data, "%08x", ptr_contents_hash[i]);
+
+      *ptr_data = '*';
+      ptr_data++;
+
+      /* inline flag */
+      *ptr_data = '1';
+      ptr_data++;
+
+      *ptr_data = '*';
+      ptr_data++;
+
+      char ptr_contents_len[10] = { 0 };
+
+      sprintf ((char*) ptr_contents_len, "%d", contents_len);
+
+      sprintf (ptr_data, "%d", contents_len);
+
+      ptr_data += strlen(ptr_contents_len);
+
+      *ptr_data = '*';
+      ptr_data++;
+
+      for (uint i = 0; i < contents_len / 4; i++, ptr_data += 8)
+        sprintf (ptr_data, "%08x", ptr_contents[i]);
+    }
+    else if (version == 2)
+    {
+      expected_bytes_len = 8;
+      ptr_expected_bytes = (u32 *) keepass->expected_bytes ;
+
+      for (uint i = 0; i < expected_bytes_len; i++, ptr_data += 8)
+        sprintf (ptr_data, "%08x", ptr_expected_bytes[i]);
+
+      *ptr_data = '*';
+      ptr_data++;
+
+      for (uint i = 0; i < contents_hash_len; i++, ptr_data += 8)
+        sprintf (ptr_data, "%08x", ptr_contents_hash[i]);
+    }
+    if (keyfile_len)
+    {
+      *ptr_data = '*';
+      ptr_data++;
+
+      /* inline flag */
+      *ptr_data = '1';
+      ptr_data++;
+
+      *ptr_data = '*';
+      ptr_data++;
+
+      sprintf (ptr_data, "%d", keyfile_len);
+
+      ptr_data += 2;
+
+      *ptr_data = '*';
+      ptr_data++;
+
+      for (uint i = 0; i < 8; i++, ptr_data += 8)
+        sprintf (ptr_data, "%08x", ptr_keyfile[i]);
+    }
+  }
+  else if (hash_mode == 13500)
+  {
+    pstoken_t *pstokens = (pstoken_t *) data.esalts_buf;
+
+    pstoken_t *pstoken = &pstokens[salt_pos];
+
+    const u32 salt_len = (pstoken->salt_len > 512) ? 512 : pstoken->salt_len;
+
+    char pstoken_tmp[1024 + 1] = { 0 };
+
+    for (uint i = 0, j = 0; i < salt_len; i += 1, j += 2)
+    {
+      const u8 *ptr = (const u8 *) pstoken->salt_buf;
+
+      sprintf (pstoken_tmp + j, "%02x", ptr[i]);
+    }
+
+    snprintf (out_buf, len-1, "%08x%08x%08x%08x%08x:%s",
+      digest_buf[0],
+      digest_buf[1],
+      digest_buf[2],
+      digest_buf[3],
+      digest_buf[4],
+      pstoken_tmp);
+  }
+  else if (hash_mode == 13600)
+  {
+    zip2_t *zip2s = (zip2_t *) data.esalts_buf;
+
+    zip2_t *zip2 = &zip2s[salt_pos];
+
+    const u32 salt_len = zip2->salt_len;
+
+    char salt_tmp[32 + 1] = { 0 };
+
+    for (uint i = 0, j = 0; i < salt_len; i += 1, j += 2)
+    {
+      const u8 *ptr = (const u8 *) zip2->salt_buf;
+
+      sprintf (salt_tmp + j, "%02x", ptr[i]);
+    }
+
+    const u32 data_len = zip2->data_len;
+
+    char data_tmp[8192 + 1] = { 0 };
+
+    for (uint i = 0, j = 0; i < data_len; i += 1, j += 2)
+    {
+      const u8 *ptr = (const u8 *) zip2->data_buf;
+
+      sprintf (data_tmp + j, "%02x", ptr[i]);
+    }
+
+    const u32 auth_len = zip2->auth_len;
+
+    char auth_tmp[20 + 1] = { 0 };
+
+    for (uint i = 0, j = 0; i < auth_len; i += 1, j += 2)
+    {
+      const u8 *ptr = (const u8 *) zip2->auth_buf;
+
+      sprintf (auth_tmp + j, "%02x", ptr[i]);
+    }
+
+    snprintf (out_buf, 255, "%s*%u*%u*%u*%s*%x*%u*%s*%s*%s",
+      SIGNATURE_ZIP2_START,
+      zip2->type,
+      zip2->mode,
+      zip2->magic,
+      salt_tmp,
+      zip2->verify_bytes,
+      zip2->compress_length,
+      data_tmp,
+      auth_tmp,
+      SIGNATURE_ZIP2_STOP);
+  }
+  else if ((hash_mode >= 13700) && (hash_mode <= 13799))
+  {
+    snprintf (out_buf, len-1, "%s", hashfile);
+  }
+  else if (hash_mode == 13800)
+  {
+    win8phone_t *esalts = (win8phone_t *) data.esalts_buf;
+
+    win8phone_t *esalt = &esalts[salt_pos];
+
+    char buf[256 + 1] = { 0 };
+
+    for (int i = 0, j = 0; i < 32; i += 1, j += 8)
+    {
+      sprintf (buf + j, "%08x", esalt->salt_buf[i]);
+    }
+
+    snprintf (out_buf, len-1, "%08x%08x%08x%08x%08x%08x%08x%08x:%s",
+      digest_buf[0],
+      digest_buf[1],
+      digest_buf[2],
+      digest_buf[3],
+      digest_buf[4],
+      digest_buf[5],
+      digest_buf[6],
+      digest_buf[7],
+      buf);
+  }
   else
   {
     if (hash_type == HASH_TYPE_MD4)
@@ -8641,19 +9105,10 @@ void to_hccap_t (hccap_t *hccap, uint salt_pos, uint digest_pos)
     memcpy (hccap->eapol, wpa->eapol, wpa->eapol_size);
   }
 
-  uint pke_tmp[25] = { 0 };
-
-  for (int i = 5; i < 25; i++)
-  {
-    pke_tmp[i] = byte_swap_32 (wpa->pke[i]);
-  }
-
-  char *pke_ptr = (char *) pke_tmp;
-
-  memcpy (hccap->mac1,   pke_ptr + 23,  6);
-  memcpy (hccap->mac2,   pke_ptr + 29,  6);
-  memcpy (hccap->nonce1, pke_ptr + 67, 32);
-  memcpy (hccap->nonce2, pke_ptr + 35, 32);
+  memcpy (hccap->mac1,   wpa->orig_mac1,    6);
+  memcpy (hccap->mac2,   wpa->orig_mac2,    6);
+  memcpy (hccap->nonce1, wpa->orig_nonce1, 32);
+  memcpy (hccap->nonce2, wpa->orig_nonce2, 32);
 
   char *digests_buf_ptr = (char *) data.digests_buf;
 
@@ -8694,7 +9149,7 @@ void ResumeThreads ()
 {
   if (data.devices_status == STATUS_PAUSED)
   {
-    float ms_paused;
+    double ms_paused;
 
     hc_timer_get (data.timer_paused, ms_paused);
 
@@ -8726,7 +9181,7 @@ void stop_at_checkpoint ()
 
   if (data.restore_disable == 1)
   {
-    log_info ("WARNING: this feature is disabled when --restore-disable was specified");
+    log_info ("WARNING: This feature is disabled when --restore-disable is specified");
 
     return;
   }
@@ -8741,7 +9196,7 @@ void stop_at_checkpoint ()
 
     data.checkpoint_cur_words = get_lowest_words_done ();
 
-    log_info ("Checkpoint enabled: will quit at next Restore Point update");
+    log_info ("Checkpoint enabled: Will quit at next Restore Point update");
   }
   else
   {
@@ -8757,20 +9212,62 @@ void stop_at_checkpoint ()
 
 void myabort ()
 {
-  if (data.devices_status == STATUS_INIT)     return;
-  if (data.devices_status == STATUS_STARTING) return;
+  //if (data.devices_status == STATUS_INIT)     return;
+  //if (data.devices_status == STATUS_STARTING) return;
 
   data.devices_status = STATUS_ABORTED;
 }
 
 void myquit ()
 {
-  if (data.devices_status == STATUS_INIT)     return;
-  if (data.devices_status == STATUS_STARTING) return;
+  //if (data.devices_status == STATUS_INIT)     return;
+  //if (data.devices_status == STATUS_STARTING) return;
 
   data.devices_status = STATUS_QUIT;
 }
 
+void naive_replace (char *s, const u8 key_char, const u8 replace_char)
+{
+  const size_t len = strlen (s);
+
+  for (size_t in = 0; in < len; in++)
+  {
+    const u8 c = s[in];
+
+    if (c == key_char)
+    {
+      s[in] = replace_char;
+    }
+  }
+}
+
+void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char)
+{
+  char s_escaped[1024] = { 0 };
+
+  size_t s_escaped_max = sizeof (s_escaped);
+
+  const size_t len = strlen (s);
+
+  for (size_t in = 0, out = 0; in < len; in++, out++)
+  {
+    const u8 c = s[in];
+
+    if (c == key_char)
+    {
+      s_escaped[out] = escape_char;
+
+      out++;
+    }
+
+    if (out == s_escaped_max - 2) break;
+
+    s_escaped[out] = c;
+  }
+
+  strncpy (s, s_escaped, s_max - 1);
+}
+
 void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources)
 {
   FILE *fp = fopen (kernel_file, "rb");
@@ -8847,7 +9344,7 @@ restore_data_t *init_restore (int argc, char **argv)
 
       if (nread != 1)
       {
-        log_error ("ERROR: cannot read %s", data.eff_restore_file);
+        log_error ("ERROR: Cannot read %s", data.eff_restore_file);
 
         exit (-1);
       }
@@ -8883,7 +9380,7 @@ restore_data_t *init_restore (int argc, char **argv)
 
           if (strcmp (argv0_r, pidbin_r) == 0)
           {
-            log_error ("ERROR: already an instance %s running on pid %d", pidbin, rd->pid);
+            log_error ("ERROR: Already an instance %s running on pid %d", pidbin, rd->pid);
 
             exit (-1);
           }
@@ -8906,7 +9403,7 @@ restore_data_t *init_restore (int argc, char **argv)
         {
           if (strcmp (pidbin, pidbin2) == 0)
           {
-            log_error ("ERROR: already an instance %s running on pid %d", pidbin2, rd->pid);
+            log_error ("ERROR: Already an instance %s running on pid %d", pidbin2, rd->pid);
 
             exit (-1);
           }
@@ -8921,7 +9418,7 @@ restore_data_t *init_restore (int argc, char **argv)
 
       if (rd->version_bin < RESTORE_MIN)
       {
-        log_error ("ERROR: cannot use outdated %s. Please remove it.", data.eff_restore_file);
+        log_error ("ERROR: Cannot use outdated %s. Please remove it.", data.eff_restore_file);
 
         exit (-1);
       }
@@ -8957,14 +9454,14 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
 
   if (fp == NULL)
   {
-    log_error ("ERROR: restore file '%s': %s", eff_restore_file, strerror (errno));
+    log_error ("ERROR: Restore file '%s': %s", eff_restore_file, strerror (errno));
 
     exit (-1);
   }
 
   if (fread (rd, sizeof (restore_data_t), 1, fp) != 1)
   {
-    log_error ("ERROR: cannot read %s", eff_restore_file);
+    log_error ("ERROR: Can't read %s", eff_restore_file);
 
     exit (-1);
   }
@@ -8977,7 +9474,7 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
   {
     if (fgets (buf, HCBUFSIZ - 1, fp) == NULL)
     {
-      log_error ("ERROR: cannot read %s", eff_restore_file);
+      log_error ("ERROR: Can't read %s", eff_restore_file);
 
       exit (-1);
     }
@@ -8993,30 +9490,14 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
 
   fclose (fp);
 
-  char new_cwd[1024] = { 0 };
-
-  char *nwd = getcwd (new_cwd, sizeof (new_cwd));
-
-  if (nwd == NULL)
-  {
-    log_error ("Restore file is corrupted");
-  }
-
-  if (strncmp (new_cwd, rd->cwd, sizeof (new_cwd)) != 0)
-  {
-    if (getcwd (rd->cwd, sizeof (rd->cwd)) == NULL)
-    {
-      log_error ("ERROR: could not determine current user path: %s", strerror (errno));
-
-      exit (-1);
-    }
-
-    log_info ("WARNING: Found old restore file, updating path to %s...", new_cwd);
-  }
+  log_info ("INFO: Changing current working directory to the path found within the .restore file: '%s'", rd->cwd);
 
   if (chdir (rd->cwd))
   {
-    log_error ("ERROR: cannot chdir to %s: %s", rd->cwd, strerror (errno));
+    log_error ("ERROR: The directory '%s' does not exist. It is needed to restore (--restore) the session.\n"
+               "       You could either create this directory (or link it) or update the .restore file using e.g. the analyze_hc_restore.pl tool:\n"
+               "       https://github.com/philsmd/analyze_hc_restore\n"
+               "       The directory must be relative to (or contain) all files/folders mentioned within the command line.", rd->cwd);
 
     exit (-1);
   }
@@ -9102,13 +9583,13 @@ void cycle_restore ()
   {
     if (unlink (eff_restore_file))
     {
-      log_info ("WARN: unlink file '%s': %s", eff_restore_file, strerror (errno));
+      log_info ("WARN: Unlink file '%s': %s", eff_restore_file, strerror (errno));
     }
   }
 
   if (rename (new_restore_file, eff_restore_file))
   {
-    log_info ("WARN: rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno));
+    log_info ("WARN: Rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno));
   }
 }
 
@@ -9664,6 +10145,43 @@ int lm_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   return (PARSER_OK);
 }
 
+int arubaos_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  if ((input_len < DISPLAY_LEN_MIN_125) || (input_len > DISPLAY_LEN_MAX_125)) return (PARSER_GLOBAL_LENGTH);
+
+  if ((input_buf[8] != '0') || (input_buf[9] != '1')) return (PARSER_SIGNATURE_UNMATCHED);
+
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  char *hash_pos = input_buf + 10;
+
+  digest[0] = hex_to_u32 ((const u8 *) &hash_pos[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &hash_pos[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &hash_pos[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &hash_pos[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &hash_pos[32]);
+
+  digest[0] -= SHA1M_A;
+  digest[1] -= SHA1M_B;
+  digest[2] -= SHA1M_C;
+  digest[3] -= SHA1M_D;
+  digest[4] -= SHA1M_E;
+
+  uint salt_len = 10;
+
+  char *salt_buf_ptr = (char *) salt->salt_buf;
+
+  salt_len = parse_and_store_salt (salt_buf_ptr, input_buf, salt_len);
+
+  if (salt_len == UINT_MAX) return (PARSER_SALT_LENGTH);
+
+  salt->salt_len = salt_len;
+
+  return (PARSER_OK);
+}
+
 int osx1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_122) || (input_len > DISPLAY_LEN_MAX_122)) return (PARSER_GLOBAL_LENGTH);
@@ -10034,7 +10552,7 @@ int wpa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (salt_len > 36)
   {
-    log_info ("WARNING: the length of the ESSID is too long. The hccap file may be invalid or corrupted");
+    log_info ("WARNING: The ESSID length is too long, the hccap file may be invalid or corrupted");
 
     return (PARSER_SALT_LENGTH);
   }
@@ -10076,6 +10594,11 @@ int wpa_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
     wpa->pke[i] = byte_swap_32 (wpa->pke[i]);
   }
 
+  memcpy (wpa->orig_mac1,   in.mac1,   6);
+  memcpy (wpa->orig_mac2,   in.mac2,   6);
+  memcpy (wpa->orig_nonce1, in.nonce1, 32);
+  memcpy (wpa->orig_nonce2, in.nonce2, 32);
+
   wpa->keyver = in.keyver;
 
   if (wpa->keyver > 255)
@@ -11529,21 +12052,6 @@ int sha1_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   return (PARSER_OK);
 }
 
-int sha1linkedin_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
-{
-  if ((input_len < DISPLAY_LEN_MIN_100) || (input_len > DISPLAY_LEN_MAX_100)) return (PARSER_GLOBAL_LENGTH);
-
-  u32 *digest = (u32 *) hash_buf->digest;
-
-  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
-  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
-  digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
-  digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
-  digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
-
-  return (PARSER_OK);
-}
-
 int sha1axcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
   if ((input_len < DISPLAY_LEN_MIN_13300) || (input_len > DISPLAY_LEN_MAX_13300)) return (PARSER_GLOBAL_LENGTH);
@@ -11552,13 +12060,13 @@ int sha1axcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   u32 *digest = (u32 *) hash_buf->digest;
 
-  input_buf +=14;
+  input_buf += 14;
 
   digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
   digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
   digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
   digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
-  digest[4] = 0x00000000;
+  digest[4] = 0;
 
   return (PARSER_OK);
 }
@@ -11607,40 +12115,126 @@ int sha1s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   return (PARSER_OK);
 }
 
-int sha1b64_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+int pstoken_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
-  if ((input_len < DISPLAY_LEN_MIN_101) || (input_len > DISPLAY_LEN_MAX_101)) return (PARSER_GLOBAL_LENGTH);
-
-  if (memcmp (SIGNATURE_SHA1B64, input_buf, 5)) return (PARSER_SIGNATURE_UNMATCHED);
+  if ((input_len < DISPLAY_LEN_MIN_13500) || (input_len > DISPLAY_LEN_MAX_13500)) return (PARSER_GLOBAL_LENGTH);
 
   u32 *digest = (u32 *) hash_buf->digest;
 
-  u8 tmp_buf[100] = { 0 };
+  salt_t *salt = hash_buf->salt;
 
-  base64_decode (base64_to_int, (const u8 *) input_buf + 5, input_len - 5, tmp_buf);
+  pstoken_t *pstoken = (pstoken_t *) hash_buf->esalt;
 
-  memcpy (digest, tmp_buf, 20);
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
 
-  digest[0] = byte_swap_32 (digest[0]);
-  digest[1] = byte_swap_32 (digest[1]);
-  digest[2] = byte_swap_32 (digest[2]);
-  digest[3] = byte_swap_32 (digest[3]);
-  digest[4] = byte_swap_32 (digest[4]);
+  if (input_buf[40] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
 
-  digest[0] -= SHA1M_A;
-  digest[1] -= SHA1M_B;
-  digest[2] -= SHA1M_C;
-  digest[3] -= SHA1M_D;
-  digest[4] -= SHA1M_E;
+  uint salt_len = input_len - 40 - 1;
 
-  return (PARSER_OK);
-}
+  char *salt_buf = input_buf + 40 + 1;
 
-int sha1b64s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
-{
-  if ((input_len < DISPLAY_LEN_MIN_111) || (input_len > DISPLAY_LEN_MAX_111)) return (PARSER_GLOBAL_LENGTH);
+  if (salt_len == UINT_MAX || salt_len % 2 != 0) return (PARSER_SALT_LENGTH);
 
-  if (memcmp (SIGNATURE_SSHA1B64_lower, input_buf, 6) && memcmp (SIGNATURE_SSHA1B64_upper, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
+  u8 *pstoken_ptr = (u8 *) pstoken->salt_buf;
+
+  for (uint i = 0, j = 0; i < salt_len; i += 2, j += 1)
+  {
+    pstoken_ptr[j] = hex_to_u8 ((const u8 *) &salt_buf[i]);
+  }
+
+  pstoken->salt_len = salt_len / 2;
+
+  /* some fake salt for the sorting mechanisms */
+
+  salt->salt_buf[0] = pstoken->salt_buf[0];
+  salt->salt_buf[1] = pstoken->salt_buf[1];
+  salt->salt_buf[2] = pstoken->salt_buf[2];
+  salt->salt_buf[3] = pstoken->salt_buf[3];
+  salt->salt_buf[4] = pstoken->salt_buf[4];
+  salt->salt_buf[5] = pstoken->salt_buf[5];
+  salt->salt_buf[6] = pstoken->salt_buf[6];
+  salt->salt_buf[7] = pstoken->salt_buf[7];
+
+  salt->salt_len = 32;
+
+  /* we need to check if we can precompute some of the data --
+     this is possible since the scheme is badly designed */
+
+  pstoken->pc_digest[0] = SHA1M_A;
+  pstoken->pc_digest[1] = SHA1M_B;
+  pstoken->pc_digest[2] = SHA1M_C;
+  pstoken->pc_digest[3] = SHA1M_D;
+  pstoken->pc_digest[4] = SHA1M_E;
+
+  pstoken->pc_offset = 0;
+
+  for (int i = 0; i < (int) pstoken->salt_len - 63; i += 64)
+  {
+    uint w[16];
+
+    w[ 0] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  0]);
+    w[ 1] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  1]);
+    w[ 2] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  2]);
+    w[ 3] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  3]);
+    w[ 4] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  4]);
+    w[ 5] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  5]);
+    w[ 6] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  6]);
+    w[ 7] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  7]);
+    w[ 8] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  8]);
+    w[ 9] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset +  9]);
+    w[10] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset + 10]);
+    w[11] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset + 11]);
+    w[12] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset + 12]);
+    w[13] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset + 13]);
+    w[14] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset + 14]);
+    w[15] = byte_swap_32 (pstoken->salt_buf[pstoken->pc_offset + 15]);
+
+    sha1_64 (w, pstoken->pc_digest);
+
+    pstoken->pc_offset += 16;
+  }
+
+  return (PARSER_OK);
+}
+
+int sha1b64_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  if ((input_len < DISPLAY_LEN_MIN_101) || (input_len > DISPLAY_LEN_MAX_101)) return (PARSER_GLOBAL_LENGTH);
+
+  if (memcmp (SIGNATURE_SHA1B64, input_buf, 5)) return (PARSER_SIGNATURE_UNMATCHED);
+
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  u8 tmp_buf[100] = { 0 };
+
+  base64_decode (base64_to_int, (const u8 *) input_buf + 5, input_len - 5, tmp_buf);
+
+  memcpy (digest, tmp_buf, 20);
+
+  digest[0] = byte_swap_32 (digest[0]);
+  digest[1] = byte_swap_32 (digest[1]);
+  digest[2] = byte_swap_32 (digest[2]);
+  digest[3] = byte_swap_32 (digest[3]);
+  digest[4] = byte_swap_32 (digest[4]);
+
+  digest[0] -= SHA1M_A;
+  digest[1] -= SHA1M_B;
+  digest[2] -= SHA1M_C;
+  digest[3] -= SHA1M_D;
+  digest[4] -= SHA1M_E;
+
+  return (PARSER_OK);
+}
+
+int sha1b64s_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  if ((input_len < DISPLAY_LEN_MIN_111) || (input_len > DISPLAY_LEN_MAX_111)) return (PARSER_GLOBAL_LENGTH);
+
+  if (memcmp (SIGNATURE_SSHA1B64_lower, input_buf, 6) && memcmp (SIGNATURE_SSHA1B64_upper, input_buf, 6)) return (PARSER_SIGNATURE_UNMATCHED);
 
   u32 *digest = (u32 *) hash_buf->digest;
 
@@ -12474,7 +13068,9 @@ int truecrypt_parse_hash_1k (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = 4;
 
-  salt->salt_iter = 1000 - 1;
+  salt->salt_iter = ROUNDS_TRUECRYPT_1K - 1;
+
+  tc->signature = 0x45555254; // "TRUE"
 
   digest[0] = tc->data_buf[0];
 
@@ -12521,7 +13117,205 @@ int truecrypt_parse_hash_2k (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = 4;
 
-  salt->salt_iter = 2000 - 1;
+  salt->salt_iter = ROUNDS_TRUECRYPT_2K - 1;
+
+  tc->signature = 0x45555254; // "TRUE"
+
+  digest[0] = tc->data_buf[0];
+
+  return (PARSER_OK);
+}
+
+int veracrypt_parse_hash_200000 (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  tc_t *tc = (tc_t *) hash_buf->esalt;
+
+  if (input_len == 0)
+  {
+    log_error ("VeraCrypt container not specified");
+
+    exit (-1);
+  }
+
+  FILE *fp = fopen (input_buf, "rb");
+
+  if (fp == NULL)
+  {
+    log_error ("%s: %s", input_buf, strerror (errno));
+
+    exit (-1);
+  }
+
+  char buf[512] = { 0 };
+
+  int n = fread (buf, 1, sizeof (buf), fp);
+
+  fclose (fp);
+
+  if (n != 512) return (PARSER_VC_FILE_SIZE);
+
+  memcpy (tc->salt_buf, buf, 64);
+
+  memcpy (tc->data_buf, buf + 64, 512 - 64);
+
+  salt->salt_buf[0] = tc->salt_buf[0];
+
+  salt->salt_len = 4;
+
+  salt->salt_iter = ROUNDS_VERACRYPT_200000 - 1;
+
+  tc->signature = 0x41524556; // "VERA"
+
+  digest[0] = tc->data_buf[0];
+
+  return (PARSER_OK);
+}
+
+int veracrypt_parse_hash_500000 (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  tc_t *tc = (tc_t *) hash_buf->esalt;
+
+  if (input_len == 0)
+  {
+    log_error ("VeraCrypt container not specified");
+
+    exit (-1);
+  }
+
+  FILE *fp = fopen (input_buf, "rb");
+
+  if (fp == NULL)
+  {
+    log_error ("%s: %s", input_buf, strerror (errno));
+
+    exit (-1);
+  }
+
+  char buf[512] = { 0 };
+
+  int n = fread (buf, 1, sizeof (buf), fp);
+
+  fclose (fp);
+
+  if (n != 512) return (PARSER_VC_FILE_SIZE);
+
+  memcpy (tc->salt_buf, buf, 64);
+
+  memcpy (tc->data_buf, buf + 64, 512 - 64);
+
+  salt->salt_buf[0] = tc->salt_buf[0];
+
+  salt->salt_len = 4;
+
+  salt->salt_iter = ROUNDS_VERACRYPT_500000 - 1;
+
+  tc->signature = 0x41524556; // "VERA"
+
+  digest[0] = tc->data_buf[0];
+
+  return (PARSER_OK);
+}
+
+int veracrypt_parse_hash_327661 (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  tc_t *tc = (tc_t *) hash_buf->esalt;
+
+  if (input_len == 0)
+  {
+    log_error ("VeraCrypt container not specified");
+
+    exit (-1);
+  }
+
+  FILE *fp = fopen (input_buf, "rb");
+
+  if (fp == NULL)
+  {
+    log_error ("%s: %s", input_buf, strerror (errno));
+
+    exit (-1);
+  }
+
+  char buf[512] = { 0 };
+
+  int n = fread (buf, 1, sizeof (buf), fp);
+
+  fclose (fp);
+
+  if (n != 512) return (PARSER_VC_FILE_SIZE);
+
+  memcpy (tc->salt_buf, buf, 64);
+
+  memcpy (tc->data_buf, buf + 64, 512 - 64);
+
+  salt->salt_buf[0] = tc->salt_buf[0];
+
+  salt->salt_len = 4;
+
+  salt->salt_iter = ROUNDS_VERACRYPT_327661 - 1;
+
+  tc->signature = 0x41524556; // "VERA"
+
+  digest[0] = tc->data_buf[0];
+
+  return (PARSER_OK);
+}
+
+int veracrypt_parse_hash_655331 (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  tc_t *tc = (tc_t *) hash_buf->esalt;
+
+  if (input_len == 0)
+  {
+    log_error ("VeraCrypt container not specified");
+
+    exit (-1);
+  }
+
+  FILE *fp = fopen (input_buf, "rb");
+
+  if (fp == NULL)
+  {
+    log_error ("%s: %s", input_buf, strerror (errno));
+
+    exit (-1);
+  }
+
+  char buf[512] = { 0 };
+
+  int n = fread (buf, 1, sizeof (buf), fp);
+
+  fclose (fp);
+
+  if (n != 512) return (PARSER_VC_FILE_SIZE);
+
+  memcpy (tc->salt_buf, buf, 64);
+
+  memcpy (tc->data_buf, buf + 64, 512 - 64);
+
+  salt->salt_buf[0] = tc->salt_buf[0];
+
+  salt->salt_len = 4;
+
+  salt->salt_iter = ROUNDS_VERACRYPT_655331 - 1;
+
+  tc->signature = 0x41524556; // "VERA"
 
   digest[0] = tc->data_buf[0];
 
@@ -16067,16 +16861,18 @@ int crammd5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   char *hash_pos = strchr (salt_pos, '$');
 
-  uint salt_len = hash_pos - salt_pos;
-
   if (hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
 
+  uint salt_len = hash_pos - salt_pos;
+
   hash_pos++;
 
   uint hash_len = input_len - 10 - salt_len - 1;
 
   // base64 decode salt
 
+  if (salt_len > 133) return (PARSER_SALT_LENGTH);
+
   u8 tmp_buf[100] = { 0 };
 
   salt_len = base64_decode (base64_to_int, (const u8 *) salt_pos, salt_len, tmp_buf);
@@ -16089,12 +16885,16 @@ int crammd5_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   salt->salt_len = salt_len;
 
-  // base64 decode salt
+  // base64 decode hash
+
+  if (hash_len > 133) return (PARSER_HASH_LENGTH);
 
   memset (tmp_buf, 0, sizeof (tmp_buf));
 
   hash_len = base64_decode (base64_to_int, (const u8 *) hash_pos, hash_len, tmp_buf);
 
+  if (hash_len < 32 + 1) return (PARSER_SALT_LENGTH);
+
   uint user_len = hash_len - 32;
 
   const u8 *tmp_hash = tmp_buf + user_len;
@@ -17838,7 +18638,7 @@ int sip_auth_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (memcmp (directive_pos, "MD5", 3))
   {
-    log_info ("ERROR: only the MD5 directive is currently supported\n");
+    log_info ("ERROR: Only the MD5 directive is currently supported\n");
 
     myfree (temp_input_buf);
 
@@ -19011,26 +19811,328 @@ int axcrypt_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   return (PARSER_OK);
 }
 
-int cf10_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+int keepass_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 {
-  if ((input_len < DISPLAY_LEN_MIN_12600) || (input_len > DISPLAY_LEN_MAX_12600)) return (PARSER_GLOBAL_LENGTH);
+  if ((input_len < DISPLAY_LEN_MIN_13400) || (input_len > DISPLAY_LEN_MAX_13400)) return (PARSER_GLOBAL_LENGTH);
+
+  if (memcmp (SIGNATURE_KEEPASS, input_buf, 9)) return (PARSER_SIGNATURE_UNMATCHED);
 
   u32 *digest = (u32 *) hash_buf->digest;
 
   salt_t *salt = hash_buf->salt;
 
-  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
-  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
-  digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
-  digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
-  digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
-  digest[5] = hex_to_u32 ((const u8 *) &input_buf[40]);
-  digest[6] = hex_to_u32 ((const u8 *) &input_buf[48]);
-  digest[7] = hex_to_u32 ((const u8 *) &input_buf[56]);
-
-  if (input_buf[64] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
+  keepass_t *keepass = (keepass_t *) hash_buf->esalt;
 
-  uint salt_len = input_len - 64 - 1;
+  /**
+   * parse line
+   */
+
+  char *version_pos;
+
+  char *rounds_pos;
+
+  char *algorithm_pos;
+
+  char *final_random_seed_pos;
+  u32   final_random_seed_len;
+
+  char *transf_random_seed_pos;
+  u32   transf_random_seed_len;
+
+  char *enc_iv_pos;
+  u32   enc_iv_len;
+
+   /* default is no keyfile provided */
+   char *keyfile_len_pos;
+   u32   keyfile_len = 0;
+   u32   is_keyfile_present = 0;
+   char *keyfile_inline_pos;
+   char *keyfile_pos;
+
+  /* specific to version 1 */
+  char *contents_len_pos;
+  u32   contents_len;
+  char *contents_pos;
+
+  /* specific to version 2 */
+  char *expected_bytes_pos;
+  u32   expected_bytes_len;
+
+  char *contents_hash_pos;
+  u32   contents_hash_len;
+
+  version_pos = input_buf + 8 + 1 + 1;
+
+  keepass->version = atoi (version_pos);
+
+  rounds_pos = strchr (version_pos, '*');
+
+  if (rounds_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  rounds_pos++;
+
+  salt->salt_iter = (atoi (rounds_pos));
+
+  algorithm_pos = strchr (rounds_pos, '*');
+
+  if (algorithm_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  algorithm_pos++;
+
+  keepass->algorithm = atoi (algorithm_pos);
+
+  final_random_seed_pos = strchr (algorithm_pos, '*');
+
+  if (final_random_seed_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  final_random_seed_pos++;
+
+  keepass->final_random_seed[0] = hex_to_u32 ((const u8 *) &final_random_seed_pos[ 0]);
+  keepass->final_random_seed[1] = hex_to_u32 ((const u8 *) &final_random_seed_pos[ 8]);
+  keepass->final_random_seed[2] = hex_to_u32 ((const u8 *) &final_random_seed_pos[16]);
+  keepass->final_random_seed[3] = hex_to_u32 ((const u8 *) &final_random_seed_pos[24]);
+
+  if (keepass->version == 2)
+  {
+    keepass->final_random_seed[4] = hex_to_u32 ((const u8 *) &final_random_seed_pos[32]);
+    keepass->final_random_seed[5] = hex_to_u32 ((const u8 *) &final_random_seed_pos[40]);
+    keepass->final_random_seed[6] = hex_to_u32 ((const u8 *) &final_random_seed_pos[48]);
+    keepass->final_random_seed[7] = hex_to_u32 ((const u8 *) &final_random_seed_pos[56]);
+  }
+
+  transf_random_seed_pos = strchr (final_random_seed_pos, '*');
+
+  if (transf_random_seed_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  final_random_seed_len = transf_random_seed_pos - final_random_seed_pos;
+
+  if (keepass->version == 1 && final_random_seed_len != 32) return (PARSER_SALT_LENGTH);
+  if (keepass->version == 2 && final_random_seed_len != 64) return (PARSER_SALT_LENGTH);
+
+  transf_random_seed_pos++;
+
+  keepass->transf_random_seed[0] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[ 0]);
+  keepass->transf_random_seed[1] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[ 8]);
+  keepass->transf_random_seed[2] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[16]);
+  keepass->transf_random_seed[3] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[24]);
+  keepass->transf_random_seed[4] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[32]);
+  keepass->transf_random_seed[5] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[40]);
+  keepass->transf_random_seed[6] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[48]);
+  keepass->transf_random_seed[7] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[56]);
+
+  enc_iv_pos = strchr (transf_random_seed_pos, '*');
+
+  if (enc_iv_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  transf_random_seed_len = enc_iv_pos - transf_random_seed_pos;
+
+  if (transf_random_seed_len != 64) return (PARSER_SALT_LENGTH);
+
+  enc_iv_pos++;
+
+  keepass->enc_iv[0] = hex_to_u32 ((const u8 *) &enc_iv_pos[ 0]);
+  keepass->enc_iv[1] = hex_to_u32 ((const u8 *) &enc_iv_pos[ 8]);
+  keepass->enc_iv[2] = hex_to_u32 ((const u8 *) &enc_iv_pos[16]);
+  keepass->enc_iv[3] = hex_to_u32 ((const u8 *) &enc_iv_pos[24]);
+
+  if (keepass->version == 1)
+  {
+    contents_hash_pos = strchr (enc_iv_pos, '*');
+
+    if (contents_hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+    enc_iv_len = contents_hash_pos - enc_iv_pos;
+
+    if (enc_iv_len != 32) return (PARSER_SALT_LENGTH);
+
+    contents_hash_pos++;
+
+    keepass->contents_hash[0] = hex_to_u32 ((const u8 *) &contents_hash_pos[ 0]);
+    keepass->contents_hash[1] = hex_to_u32 ((const u8 *) &contents_hash_pos[ 8]);
+    keepass->contents_hash[2] = hex_to_u32 ((const u8 *) &contents_hash_pos[16]);
+    keepass->contents_hash[3] = hex_to_u32 ((const u8 *) &contents_hash_pos[24]);
+    keepass->contents_hash[4] = hex_to_u32 ((const u8 *) &contents_hash_pos[32]);
+    keepass->contents_hash[5] = hex_to_u32 ((const u8 *) &contents_hash_pos[40]);
+    keepass->contents_hash[6] = hex_to_u32 ((const u8 *) &contents_hash_pos[48]);
+    keepass->contents_hash[7] = hex_to_u32 ((const u8 *) &contents_hash_pos[56]);
+
+    /* get length of contents following */
+    char *inline_flag_pos = strchr (contents_hash_pos, '*');
+
+    if (inline_flag_pos == NULL) return (PARSER_SALT_LENGTH);
+
+    contents_hash_len = inline_flag_pos - contents_hash_pos;
+
+    if (contents_hash_len != 64) return (PARSER_SALT_LENGTH);
+
+    inline_flag_pos++;
+
+    u32 inline_flag = atoi (inline_flag_pos);
+
+    if (inline_flag != 1) return (PARSER_SALT_LENGTH);
+
+    contents_len_pos = strchr (inline_flag_pos, '*');
+
+    if (contents_len_pos == NULL) return (PARSER_SALT_LENGTH);
+
+    contents_len_pos++;
+
+    contents_len = atoi (contents_len_pos);
+
+    if (contents_len > 50000) return (PARSER_SALT_LENGTH);
+
+    contents_pos = strchr (contents_len_pos, '*');
+
+    if (contents_pos == NULL) return (PARSER_SALT_LENGTH);
+
+    contents_pos++;
+
+    u32 i;
+
+    keepass->contents_len = contents_len;
+
+    contents_len = contents_len / 4;
+
+    keyfile_inline_pos = strchr (contents_pos, '*');
+
+    u32 real_contents_len;
+
+    if (keyfile_inline_pos == NULL)
+      real_contents_len = input_len - (contents_pos - input_buf);
+    else
+    {
+      real_contents_len = keyfile_inline_pos - contents_pos;
+      keyfile_inline_pos++;
+      is_keyfile_present = 1;
+    }
+
+    if (real_contents_len != keepass->contents_len * 2) return (PARSER_SALT_LENGTH);
+
+    for (i = 0; i < contents_len; i++)
+      keepass->contents[i] = hex_to_u32 ((const u8 *) &contents_pos[i * 8]);
+  }
+  else if (keepass->version == 2)
+  {
+    expected_bytes_pos = strchr (enc_iv_pos, '*');
+
+    if (expected_bytes_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+    enc_iv_len = expected_bytes_pos - enc_iv_pos;
+
+    if (enc_iv_len != 32) return (PARSER_SALT_LENGTH);
+
+    expected_bytes_pos++;
+
+    keepass->expected_bytes[0] = hex_to_u32 ((const u8 *) &expected_bytes_pos[ 0]);
+    keepass->expected_bytes[1] = hex_to_u32 ((const u8 *) &expected_bytes_pos[ 8]);
+    keepass->expected_bytes[2] = hex_to_u32 ((const u8 *) &expected_bytes_pos[16]);
+    keepass->expected_bytes[3] = hex_to_u32 ((const u8 *) &expected_bytes_pos[24]);
+    keepass->expected_bytes[4] = hex_to_u32 ((const u8 *) &expected_bytes_pos[32]);
+    keepass->expected_bytes[5] = hex_to_u32 ((const u8 *) &expected_bytes_pos[40]);
+    keepass->expected_bytes[6] = hex_to_u32 ((const u8 *) &expected_bytes_pos[48]);
+    keepass->expected_bytes[7] = hex_to_u32 ((const u8 *) &expected_bytes_pos[56]);
+
+    contents_hash_pos = strchr (expected_bytes_pos, '*');
+
+    if (contents_hash_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+    expected_bytes_len = contents_hash_pos - expected_bytes_pos;
+
+    if (expected_bytes_len != 64) return (PARSER_SALT_LENGTH);
+
+    contents_hash_pos++;
+
+    keepass->contents_hash[0] = hex_to_u32 ((const u8 *) &contents_hash_pos[ 0]);
+    keepass->contents_hash[1] = hex_to_u32 ((const u8 *) &contents_hash_pos[ 8]);
+    keepass->contents_hash[2] = hex_to_u32 ((const u8 *) &contents_hash_pos[16]);
+    keepass->contents_hash[3] = hex_to_u32 ((const u8 *) &contents_hash_pos[24]);
+    keepass->contents_hash[4] = hex_to_u32 ((const u8 *) &contents_hash_pos[32]);
+    keepass->contents_hash[5] = hex_to_u32 ((const u8 *) &contents_hash_pos[40]);
+    keepass->contents_hash[6] = hex_to_u32 ((const u8 *) &contents_hash_pos[48]);
+    keepass->contents_hash[7] = hex_to_u32 ((const u8 *) &contents_hash_pos[56]);
+
+    keyfile_inline_pos = strchr (contents_hash_pos, '*');
+
+    if (keyfile_inline_pos == NULL)
+      contents_hash_len = input_len - (int) (contents_hash_pos - input_buf);
+    else
+    {
+      contents_hash_len = keyfile_inline_pos - contents_hash_pos;
+      keyfile_inline_pos++;
+      is_keyfile_present = 1;
+    }
+    if (contents_hash_len != 64) return (PARSER_SALT_LENGTH);
+  }
+
+  if (is_keyfile_present != 0)
+  {
+    keyfile_len_pos = strchr (keyfile_inline_pos, '*');
+
+    keyfile_len_pos++;
+
+    keyfile_len = atoi (keyfile_len_pos);
+
+    keepass->keyfile_len = keyfile_len;
+
+    if (keyfile_len != 64) return (PARSER_SALT_LENGTH);
+
+    keyfile_pos = strchr (keyfile_len_pos, '*');
+
+    if (keyfile_pos == NULL) return (PARSER_SALT_LENGTH);
+
+    keyfile_pos++;
+
+    u32 real_keyfile_len = input_len - (keyfile_pos - input_buf);
+
+    if (real_keyfile_len != 64) return (PARSER_SALT_LENGTH);
+
+    keepass->keyfile[0] = hex_to_u32 ((const u8 *) &keyfile_pos[ 0]);
+    keepass->keyfile[1] = hex_to_u32 ((const u8 *) &keyfile_pos[ 8]);
+    keepass->keyfile[2] = hex_to_u32 ((const u8 *) &keyfile_pos[16]);
+    keepass->keyfile[3] = hex_to_u32 ((const u8 *) &keyfile_pos[24]);
+    keepass->keyfile[4] = hex_to_u32 ((const u8 *) &keyfile_pos[32]);
+    keepass->keyfile[5] = hex_to_u32 ((const u8 *) &keyfile_pos[40]);
+    keepass->keyfile[6] = hex_to_u32 ((const u8 *) &keyfile_pos[48]);
+    keepass->keyfile[7] = hex_to_u32 ((const u8 *) &keyfile_pos[56]);
+  }
+
+  digest[0] = keepass->enc_iv[0];
+  digest[1] = keepass->enc_iv[1];
+  digest[2] = keepass->enc_iv[2];
+  digest[3] = keepass->enc_iv[3];
+
+  salt->salt_buf[0] = keepass->transf_random_seed[0];
+  salt->salt_buf[1] = keepass->transf_random_seed[1];
+  salt->salt_buf[2] = keepass->transf_random_seed[2];
+  salt->salt_buf[3] = keepass->transf_random_seed[3];
+  salt->salt_buf[4] = keepass->transf_random_seed[4];
+  salt->salt_buf[5] = keepass->transf_random_seed[5];
+  salt->salt_buf[6] = keepass->transf_random_seed[6];
+  salt->salt_buf[7] = keepass->transf_random_seed[7];
+
+  return (PARSER_OK);
+}
+
+int cf10_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  if ((input_len < DISPLAY_LEN_MIN_12600) || (input_len > DISPLAY_LEN_MAX_12600)) return (PARSER_GLOBAL_LENGTH);
+
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
+  digest[5] = hex_to_u32 ((const u8 *) &input_buf[40]);
+  digest[6] = hex_to_u32 ((const u8 *) &input_buf[48]);
+  digest[7] = hex_to_u32 ((const u8 *) &input_buf[56]);
+
+  if (input_buf[64] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
+
+  uint salt_len = input_len - 64 - 1;
 
   char *salt_buf = input_buf + 64 + 1;
 
@@ -19290,6 +20392,278 @@ int androidfde_samsung_parse_hash (char *input_buf, uint input_len, hash_t *hash
   return (PARSER_OK);
 }
 
+int zip2_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  if ((input_len < DISPLAY_LEN_MIN_13600) || (input_len > DISPLAY_LEN_MAX_13600)) return (PARSER_GLOBAL_LENGTH);
+
+  if (memcmp (SIGNATURE_ZIP2_START, input_buf                , 6)) return (PARSER_SIGNATURE_UNMATCHED);
+  if (memcmp (SIGNATURE_ZIP2_STOP , input_buf + input_len - 7, 7)) return (PARSER_SIGNATURE_UNMATCHED);
+
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  zip2_t *zip2 = (zip2_t *) hash_buf->esalt;
+
+  /**
+   * parse line
+   */
+
+  char *param0_pos = input_buf + 6 + 1;
+
+  char *param1_pos = strchr (param0_pos, '*');
+
+  if (param1_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  u32 param0_len = param1_pos - param0_pos;
+
+  param1_pos++;
+
+  char *param2_pos = strchr (param1_pos, '*');
+
+  if (param2_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  u32 param1_len = param2_pos - param1_pos;
+
+  param2_pos++;
+
+  char *param3_pos = strchr (param2_pos, '*');
+
+  if (param3_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  u32 param2_len = param3_pos - param2_pos;
+
+  param3_pos++;
+
+  char *param4_pos = strchr (param3_pos, '*');
+
+  if (param4_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  u32 param3_len = param4_pos - param3_pos;
+
+  param4_pos++;
+
+  char *param5_pos = strchr (param4_pos, '*');
+
+  if (param5_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  u32 param4_len = param5_pos - param4_pos;
+
+  param5_pos++;
+
+  char *param6_pos = strchr (param5_pos, '*');
+
+  if (param6_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  u32 param5_len = param6_pos - param5_pos;
+
+  param6_pos++;
+
+  char *param7_pos = strchr (param6_pos, '*');
+
+  if (param7_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  u32 param6_len = param7_pos - param6_pos;
+
+  param7_pos++;
+
+  char *param8_pos = strchr (param7_pos, '*');
+
+  if (param8_pos == NULL) return (PARSER_SEPARATOR_UNMATCHED);
+
+  u32 param7_len = param8_pos - param7_pos;
+
+  param8_pos++;
+
+  const uint type  = atoi (param0_pos);
+  const uint mode  = atoi (param1_pos);
+  const uint magic = atoi (param2_pos);
+
+  char *salt_buf = param3_pos;
+
+  uint verify_bytes; sscanf (param4_pos, "%4x*", &verify_bytes);
+
+  const uint compress_length = atoi (param5_pos);
+
+  char *data_buf = param6_pos;
+  char *auth     = param7_pos;
+
+  /**
+   * verify some data
+   */
+
+  if (param0_len != 1) return (PARSER_SALT_VALUE);
+
+  if (param1_len != 1) return (PARSER_SALT_VALUE);
+
+  if (param2_len != 1) return (PARSER_SALT_VALUE);
+
+  if ((param3_len != 16) && (param3_len != 24) && (param3_len != 32)) return (PARSER_SALT_VALUE);
+
+  if (param4_len >= 5) return (PARSER_SALT_VALUE);
+
+  if (param5_len >= 5) return (PARSER_SALT_VALUE);
+
+  if (param6_len >= 8192) return (PARSER_SALT_VALUE);
+
+  if (param6_len & 1) return (PARSER_SALT_VALUE);
+
+  if (param7_len != 20) return (PARSER_SALT_VALUE);
+
+  if (type != 0) return (PARSER_SALT_VALUE);
+
+  if ((mode != 1) && (mode != 2) && (mode != 3)) return (PARSER_SALT_VALUE);
+
+  if (magic != 0) return (PARSER_SALT_VALUE);
+
+  if (verify_bytes >= 0x10000) return (PARSER_SALT_VALUE);
+
+  /**
+   * store data
+   */
+
+  zip2->type  = type;
+  zip2->mode  = mode;
+  zip2->magic = magic;
+
+  if (mode == 1)
+  {
+    zip2->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_buf[ 0]);
+    zip2->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_buf[ 8]);
+    zip2->salt_buf[2] = 0;
+    zip2->salt_buf[3] = 0;
+
+    zip2->salt_len = 8;
+  }
+  else if (mode == 2)
+  {
+    zip2->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_buf[ 0]);
+    zip2->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_buf[ 8]);
+    zip2->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_buf[16]);
+    zip2->salt_buf[3] = 0;
+
+    zip2->salt_len = 12;
+  }
+  else if (mode == 3)
+  {
+    zip2->salt_buf[0] = hex_to_u32 ((const u8 *) &salt_buf[ 0]);
+    zip2->salt_buf[1] = hex_to_u32 ((const u8 *) &salt_buf[ 8]);
+    zip2->salt_buf[2] = hex_to_u32 ((const u8 *) &salt_buf[16]);
+    zip2->salt_buf[3] = hex_to_u32 ((const u8 *) &salt_buf[24]);
+
+    zip2->salt_len = 16;
+  }
+
+  zip2->salt_buf[0] = byte_swap_32 (zip2->salt_buf[0]);
+  zip2->salt_buf[1] = byte_swap_32 (zip2->salt_buf[1]);
+  zip2->salt_buf[2] = byte_swap_32 (zip2->salt_buf[2]);
+  zip2->salt_buf[3] = byte_swap_32 (zip2->salt_buf[3]);
+
+  zip2->verify_bytes = verify_bytes;
+
+  zip2->compress_length = compress_length;
+
+  char *data_buf_ptr = (char *) zip2->data_buf;
+
+  for (uint i = 0; i < param6_len; i += 2)
+  {
+    const char p0 = data_buf[i + 0];
+    const char p1 = data_buf[i + 1];
+
+    *data_buf_ptr++ = hex_convert (p1) << 0
+                    | hex_convert (p0) << 4;
+
+    zip2->data_len++;
+  }
+
+  *data_buf_ptr = 0x80;
+
+  char *auth_ptr = (char *) zip2->auth_buf;
+
+  for (uint i = 0; i < param7_len; i += 2)
+  {
+    const char p0 = auth[i + 0];
+    const char p1 = auth[i + 1];
+
+    *auth_ptr++ = hex_convert (p1) << 0
+                | hex_convert (p0) << 4;
+
+    zip2->auth_len++;
+  }
+
+  /**
+   * salt buf (fake)
+   */
+
+  salt->salt_buf[0] = zip2->salt_buf[0];
+  salt->salt_buf[1] = zip2->salt_buf[1];
+  salt->salt_buf[2] = zip2->salt_buf[2];
+  salt->salt_buf[3] = zip2->salt_buf[3];
+  salt->salt_buf[4] = zip2->data_buf[0];
+  salt->salt_buf[5] = zip2->data_buf[1];
+  salt->salt_buf[6] = zip2->data_buf[2];
+  salt->salt_buf[7] = zip2->data_buf[3];
+
+  salt->salt_len = 32;
+
+  salt->salt_iter = ROUNDS_ZIP2 - 1;
+
+  /**
+   * digest buf (fake)
+   */
+
+  digest[0] = zip2->auth_buf[0];
+  digest[1] = zip2->auth_buf[1];
+  digest[2] = zip2->auth_buf[2];
+  digest[3] = zip2->auth_buf[3];
+
+  return (PARSER_OK);
+}
+
+int win8phone_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
+{
+  if ((input_len < DISPLAY_LEN_MIN_13800) || (input_len > DISPLAY_LEN_MAX_13800)) return (PARSER_GLOBAL_LENGTH);
+
+  u32 *digest = (u32 *) hash_buf->digest;
+
+  salt_t *salt = hash_buf->salt;
+
+  win8phone_t *esalt = hash_buf->esalt;
+
+  digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
+  digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
+  digest[2] = hex_to_u32 ((const u8 *) &input_buf[16]);
+  digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
+  digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
+  digest[5] = hex_to_u32 ((const u8 *) &input_buf[40]);
+  digest[6] = hex_to_u32 ((const u8 *) &input_buf[48]);
+  digest[7] = hex_to_u32 ((const u8 *) &input_buf[56]);
+
+  if (input_buf[64] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
+
+  char *salt_buf_ptr = input_buf + 64 + 1;
+
+  u32 *salt_buf = esalt->salt_buf;
+
+  for (int i = 0, j = 0; i < 32; i += 1, j += 8)
+  {
+    salt_buf[i] = hex_to_u32 ((const u8 *) &salt_buf_ptr[j]);
+  }
+
+  salt->salt_buf[0] = salt_buf[0];
+  salt->salt_buf[1] = salt_buf[1];
+  salt->salt_buf[2] = salt_buf[2];
+  salt->salt_buf[3] = salt_buf[3];
+  salt->salt_buf[4] = salt_buf[4];
+  salt->salt_buf[5] = salt_buf[5];
+  salt->salt_buf[6] = salt_buf[6];
+  salt->salt_buf[7] = salt_buf[7];
+
+  salt->salt_len = 64;
+
+  return (PARSER_OK);
+}
+
 /**
  * parallel running threads
  */
@@ -19401,8 +20775,6 @@ void status_display ();
 
 void *thread_keypress (void *p)
 {
-  int benchmark = *((int *) p);
-
   uint quiet = data.quiet;
 
   tty_break();
@@ -19415,9 +20787,10 @@ void *thread_keypress (void *p)
 
     if (ch ==  0) continue;
 
-    #ifdef _POSIX
-    if (ch != '\n')
-    #endif
+    //https://github.com/hashcat/hashcat/issues/302
+    //#ifdef _POSIX
+    //if (ch != '\n')
+    //#endif
 
     hc_thread_mutex_lock (mux_display);
 
@@ -19426,6 +20799,7 @@ void *thread_keypress (void *p)
     switch (ch)
     {
       case 's':
+      case '\r':
       case '\n':
 
         log_info ("");
@@ -19482,8 +20856,6 @@ void *thread_keypress (void *p)
 
         log_info ("");
 
-        if (benchmark == 1) break;
-
         stop_at_checkpoint ();
 
         log_info ("");
@@ -19497,18 +20869,16 @@ void *thread_keypress (void *p)
 
         log_info ("");
 
-        if (benchmark == 1)
-        {
-          myquit ();
-        }
-        else
-        {
-          myabort ();
-        }
+        myabort ();
 
         break;
     }
 
+    //https://github.com/hashcat/hashcat/issues/302
+    //#ifdef _POSIX
+    //if (ch != '\n')
+    //#endif
+
     hc_thread_mutex_unlock (mux_display);
   }