Added support for XNVCTRL on Linux to add support for --gpu-temp-retain for NVidia GPU
[hashcat.git] / src / shared.c
index df90e75..43aded4 100644 (file)
@@ -3195,7 +3195,12 @@ int hm_get_fanpolicy_with_device_id (const uint device_id)
     if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
     {
       #if defined(LINUX)
-      return 0;
+      if (data.hm_xnvctrl)
+      {
+        if (set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE) != 0) return -1;
+
+        return 1;
+      }
       #endif
 
       #if defined(WIN)
@@ -3404,6 +3409,21 @@ int hm_get_throttle_with_device_id (const uint device_id)
   return -1;
 }
 
+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;
+}
+
 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_set_supported == 1)
@@ -11983,13 +12003,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);
 }
@@ -12095,7 +12115,7 @@ int pstoken_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   pstoken->pc_offset = 0;
 
-  for (int i = 0; i < (int) pstoken->salt_len - 64; i += 64)
+  for (int i = 0; i < (int) pstoken->salt_len - 63; i += 64)
   {
     uint w[16];