Added current engine clock and current memory clock to the status display (ADL only...
[hashcat.git] / src / shared.c
index 27c4861..4fb97de 100644 (file)
@@ -3062,7 +3062,7 @@ 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)
     {
@@ -3089,7 +3089,7 @@ int hm_get_temperature_with_device_id (const uint device_id)
   #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;
@@ -3125,7 +3125,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
   if (data.hm_device[device_id].fan_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)
       {
@@ -3158,7 +3158,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
     #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;
@@ -3190,7 +3190,7 @@ 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)
     {
@@ -3206,7 +3206,7 @@ int hm_get_utilization_with_device_id (const uint device_id)
   #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;
@@ -3231,6 +3231,52 @@ int hm_get_utilization_with_device_id (const uint device_id)
   return -1;
 }
 
+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;
+
+  #ifdef HAVE_ADL
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_amd)
+    {
+      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;
+
+      return PMActivity.iMemoryClock / 100;
+    }
+  }
+  #endif // HAVE_ADL
+
+  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;
+
+  #ifdef HAVE_ADL
+  if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
+  {
+    if (data.hm_amd)
+    {
+      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;
+
+      return PMActivity.iEngineClock / 100;
+    }
+  }
+  #endif // HAVE_ADL
+
+  return -1;
+}
+
 #ifdef HAVE_ADL
 int hm_set_fanspeed_with_device_id_amd (const uint device_id, const int fanspeed)
 {
@@ -5857,6 +5903,24 @@ char *strhashtype (const uint hash_mode)
     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;
   }
 
   return ((char *) "Unknown");
@@ -8547,7 +8611,7 @@ void ascii_digest (char *out_buf, uint salt_pos, uint digest_pos)
       sprintf (auth_tmp + j, "%02x", ptr[i]);
     }
 
-    snprintf (out_buf, 255, "%s*%u*%u*%u*%s*%4x*%u*%s*%s*%s",
+    snprintf (out_buf, 255, "%s*%u*%u*%u*%s*%x*%u*%s*%s*%s",
       SIGNATURE_ZIP2_START,
       zip2->type,
       zip2->mode,
@@ -8559,6 +8623,10 @@ void ascii_digest (char *out_buf, uint salt_pos, uint digest_pos)
       auth_tmp,
       SIGNATURE_ZIP2_STOP);
   }
+  else if ((hash_mode >= 13700) && (hash_mode <= 13799))
+  {
+    snprintf (out_buf, len-1, "%s", hashfile);
+  }
   else
   {
     if (hash_type == HASH_TYPE_MD4)
@@ -12788,7 +12856,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];
 
@@ -12835,7 +12905,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];