Removed SHA1 optimization.
[hashcat.git] / src / shared.c
index 2988e80..13ed50e 100644 (file)
@@ -8480,20 +8480,21 @@ void ascii_digest (char *out_buf, uint salt_pos, uint digest_pos)
         sprintf (ptr_data, "%08x", ptr_keyfile[i]);
     }
   }
-  elseif (hash_mode == 13500)
+  else if (hash_mode == 13500)
   {
     pstoken_t *pstokens = (pstoken_t *) data.esalts_buf;
     pstoken_t *pstoken  = &pstokens[salt_pos];
 
-    uint mysalt_len = pstoken->salt_len > 512 ? 512 : pstoken->salt_len;
+    uint mysalt = pstoken->salt_len > 512 ? 512 : pstoken->salt_len;
 
-    u8 pstoken_tmp[mysalt_len + 1];
+    char pstoken_tmp[1024 + 1];
+    u8 *salt_buf_ptr = (u8 *) pstoken->salt_buf;
 
-    memset(pstoken_tmp, 0, mysalt_len + 1);
+    memset(pstoken_tmp, 0, sizeof (pstoken_tmp));
 
-    for (int i = 0; i < mysalt_len; i++)
+    for (uint i = 0; i < mysalt; i++)
     {
-      snprintf(pstoken_tmp[i], 1, "%02x", pstoken->salt_buf[i]);
+      snprintf(&pstoken_tmp[i*2], 2, "%02x", salt_buf_ptr[i]);
     }
 
     snprintf (out_buf, len-1, "%08x%08x%08x%08x%08x:%s",
@@ -11796,7 +11797,7 @@ int pstoken_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   pstoken_t *pstoken = (pstoken_t *) hash_buf->esalt;
   u8 pstoken_tmp[DISPLAY_LEN_MAX_13500 - 40 - 1];
 
-  memcpy(pstoken_tmp, "\0", DISPLAY_LEN_MAX_13500 - 40 - 1);
+  memset(pstoken_tmp, 0, DISPLAY_LEN_MAX_13500 - 40 - 1);
 
   digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
   digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
@@ -11804,19 +11805,13 @@ int pstoken_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   digest[3] = hex_to_u32 ((const u8 *) &input_buf[24]);
   digest[4] = hex_to_u32 ((const u8 *) &input_buf[32]);
 
-  digest[0] -= SHA1M_A;
-  digest[1] -= SHA1M_B;
-  digest[2] -= SHA1M_C;
-  digest[3] -= SHA1M_D;
-  digest[4] -= SHA1M_E;
-
   if (input_buf[40] != data.separator) return (PARSER_SEPARATOR_UNMATCHED);
 
   uint salt_len = input_len - 40 - 1;
 
   char *salt_buf = input_buf + 40 + 1;
 
-  if (salt_len == UINT_MAX) return (PARSER_SALT_LENGTH);
+  if (salt_len == UINT_MAX || salt_len % 2 != 0) return (PARSER_SALT_LENGTH);
 
   for (uint i = 0; i < salt_len / 2; i++) 
   {