esalt hex convertion.
authorMartin Lemay <mlemay@gosecure.ca>
Fri, 22 Apr 2016 19:32:06 +0000 (15:32 -0400)
committerMartin Lemay <mlemay@gosecure.ca>
Fri, 22 Apr 2016 19:32:06 +0000 (15:32 -0400)
src/shared.c

index 84196f8..047414a 100644 (file)
@@ -11770,6 +11770,9 @@ int pstoken_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
   u32 *digest = (u32 *) hash_buf->digest;
   salt_t *salt = hash_buf->salt;
   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);
 
   digest[0] = hex_to_u32 ((const u8 *) &input_buf[ 0]);
   digest[1] = hex_to_u32 ((const u8 *) &input_buf[ 8]);
@@ -11791,11 +11794,17 @@ int pstoken_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf)
 
   if (salt_len == UINT_MAX) return (PARSER_SALT_LENGTH);
 
+  for (uint i = 0; i < salt_len / 2; i++) 
+  { 
+    pstoken_tmp[i] = hex_to_u8 ((const u8 *) &salt_buf[i * 2]); 
+  }
+
+  salt_len /= 2;
   salt->salt_len = salt_len;
   pstoken->salt_len = salt_len;
 
-  memcpy(salt->salt_buf, salt_buf, 16);
-  memcpy(pstoken->salt_buf, salt_buf, salt_len);
+  memcpy(salt->salt_buf, pstoken_tmp, 16);
+  memcpy(pstoken->salt_buf, pstoken_tmp, salt_len);
 
   return (PARSER_OK);
 }